| 57 | | { |
| 58 | | $db = AbstractDb::getObject(); |
| 59 | | |
| 60 | | // Init values |
| 61 | | $row = null; |
| 62 | | |
| 63 | | $profile_template_id = $db->escapeString($profile_template_id); |
| 64 | | $sql = "SELECT * FROM profile_templates WHERE profile_template_id = '{$profile_template_id}';"; |
| 65 | | $db->execSqlUniqueRes($sql, $row, false); |
| 66 | | |
| 67 | | if ($row == null) { |
| 68 | | throw new Exception("The profile template with id {$profile_template_id} could not be found in the database!"); |
| 69 | | } |
| 70 | | |
| 71 | | $this->_row = $row; |
| 72 | | $this->id = $db->escapeString($row['profile_template_id']); |
| 73 | | } |
| | 57 | { |
| | 58 | $db = AbstractDb::getObject(); |
| | 59 | |
| | 60 | // Init values |
| | 61 | $row = null; |
| | 62 | |
| | 63 | $profile_template_id = $db->escapeString($profile_template_id); |
| | 64 | $sql = "SELECT * FROM profile_templates WHERE profile_template_id = '{$profile_template_id}';"; |
| | 65 | $db->execSqlUniqueRes($sql, $row, false); |
| | 66 | |
| | 67 | if ($row == null) { |
| | 68 | throw new Exception("The profile template with id {$profile_template_id} could not be found in the database!"); |
| | 69 | } |
| | 70 | |
| | 71 | $this->_row = $row; |
| | 72 | $this->id = $db->escapeString($row['profile_template_id']); |
| | 73 | } |
| 102 | | $db = AbstractDb :: getObject(); |
| 103 | | |
| 104 | | // Init values |
| 105 | | $whereClause = ""; |
| 106 | | $rows = null; |
| 107 | | $objects = array (); |
| 108 | | |
| 109 | | if (!empty ($network) && get_class($network) == "Network") { |
| 110 | | $db->execSql("SELECT profile_template_id FROM network_has_profile_templates WHERE network_id = '{$network->getId()}'", $rows, false); |
| 111 | | } else { |
| 112 | | $db->execSql("SELECT profile_template_id FROM profile_templates", $rows, false); |
| 113 | | } |
| 114 | | |
| 115 | | if ($rows) { |
| 116 | | foreach ($rows as $row) { |
| 117 | | $objects[] = self :: getObject($row['profile_template_id']); |
| 118 | | } |
| 119 | | } |
| 120 | | |
| 121 | | return $objects; |
| 122 | | } |
| 123 | | |
| | 102 | $db = AbstractDb :: getObject(); |
| | 103 | |
| | 104 | // Init values |
| | 105 | $whereClause = ""; |
| | 106 | $rows = null; |
| | 107 | $objects = array (); |
| | 108 | |
| | 109 | if (!empty ($network) && get_class($network) == "Network") { |
| | 110 | $db->execSql("SELECT profile_template_id FROM network_has_profile_templates WHERE network_id = '{$network->getId()}'", $rows, false); |
| | 111 | } else { |
| | 112 | $db->execSql("SELECT profile_template_id FROM profile_templates", $rows, false); |
| | 113 | } |
| | 114 | |
| | 115 | if ($rows) { |
| | 116 | foreach ($rows as $row) { |
| | 117 | $objects[] = self :: getObject($row['profile_template_id']); |
| | 118 | } |
| | 119 | } |
| | 120 | |
| | 121 | return $objects; |
| | 122 | } |
| | 123 | |
| 250 | | public static function processCreateNewObjectUI() {} |
| 251 | | |
| 252 | | /** |
| 253 | | * Get an interface to pick an object of this class |
| 254 | | * |
| 255 | | * If there is only one server available, no interface is actually shown |
| 256 | | * |
| | 256 | public static function processCreateNewObjectUI() |
| | 257 | { |
| | 258 | // Init values |
| | 259 | $retval = null; |
| | 260 | $name = "new_profile_template_id"; |
| | 261 | |
| | 262 | if (!empty ($_REQUEST[$name])) { |
| | 263 | $newId = $_REQUEST[$name]; |
| | 264 | } |
| | 265 | else |
| | 266 | { |
| | 267 | $newId = null; |
| | 268 | } |
| | 269 | Security::requirePermission(Permission::P('SERVER_PERM_EDIT_PROFILE_TEMPLATES'), Server::getServer()); |
| | 270 | $retval = self::createNewObject($newId); |
| | 271 | |
| | 272 | return $retval; |
| | 273 | } |
| | 274 | |
| | 275 | |
| | 276 | /** |
| | 277 | * Get an interface to pick an object of this class |
| | 278 | * |
| | 279 | * If there is only one server available, no interface is actually shown |
| | 280 | * |
| 272 | | { |
| 273 | | $db = AbstractDb::getObject(); |
| 274 | | |
| 275 | | // Init values |
| 276 | | $_html = ""; |
| 277 | | $_profile_template_rows = null; |
| 278 | | |
| 279 | | !empty($userData['preSelectedId'])?$selectedId=$userData['preSelectedId']:$selectedId=null; |
| 280 | | !empty($userData['additionalWhere'])?$additional_where=$userData['additionalWhere']:$additional_where=null; |
| 281 | | !empty($userData['typeInterface'])?$type_interface=$userData['typeInterface']:$type_interface=null; |
| 282 | | |
| 283 | | $sql = "SELECT * FROM profile_templates WHERE 1=1 $additional_where ORDER BY profile_template_label ASC"; |
| 284 | | $db->execSql($sql, $_profile_template_rows, false); |
| 285 | | |
| 286 | | if ($_profile_template_rows != null) { |
| 287 | | $_name = $user_prefix; |
| 288 | | |
| 289 | | $_html .= _("Profile template").": \n"; |
| 290 | | |
| 291 | | $_i = 0; |
| 292 | | foreach ($_profile_template_rows as $_profile_template_row) { |
| 293 | | $_tab[$_i][0] = $_profile_template_row['profile_template_id']; |
| 294 | | $_tab[$_i][1] = empty($_profile_template_row['profile_template_label']) ? "["._("No label")."] - ".$_profile_template_row['profile_template_id'] : $_profile_template_row['profile_template_label']; |
| 295 | | $_i ++; |
| 296 | | } |
| 297 | | |
| 298 | | $_html .= FormSelectGenerator::generateFromArray($_tab, $selectedId, $_name, null, false); |
| 299 | | |
| 300 | | if ($type_interface == "add") { |
| 301 | | if (isset ($_tab)) { |
| 302 | | $name = "{$user_prefix}_add"; |
| 303 | | $value = _("Add"); |
| 304 | | $_html .= "<div class='admin_element_tools'>"; |
| 305 | | $_html .= '<input type="submit" class="submit" name="' . $name . '" value="' . $value . '">'; |
| 306 | | $_html .= "</div>"; |
| 307 | | } |
| 308 | | } |
| 309 | | } |
| 310 | | |
| 311 | | return $_html; |
| 312 | | } |
| 313 | | |
| 314 | | |
| | 296 | { |
| | 297 | $db = AbstractDb::getObject(); |
| | 298 | |
| | 299 | // Init values |
| | 300 | $_html = ""; |
| | 301 | $_profile_template_rows = null; |
| | 302 | |
| | 303 | !empty($userData['preSelectedId'])?$selectedId=$userData['preSelectedId']:$selectedId=null; |
| | 304 | !empty($userData['additionalWhere'])?$additional_where=$userData['additionalWhere']:$additional_where=null; |
| | 305 | !empty($userData['typeInterface'])?$type_interface=$userData['typeInterface']:$type_interface=null; |
| | 306 | |
| | 307 | $sql = "SELECT * FROM profile_templates WHERE 1=1 $additional_where ORDER BY profile_template_label ASC"; |
| | 308 | $db->execSql($sql, $_profile_template_rows, false); |
| | 309 | |
| | 310 | if ($_profile_template_rows != null) { |
| | 311 | $_name = $user_prefix; |
| | 312 | |
| | 313 | $_html .= _("Profile template").": \n"; |
| | 314 | |
| | 315 | $_i = 0; |
| | 316 | foreach ($_profile_template_rows as $_profile_template_row) { |
| | 317 | $_tab[$_i][0] = $_profile_template_row['profile_template_id']; |
| | 318 | $_tab[$_i][1] = empty($_profile_template_row['profile_template_label']) ? "["._("No label")."] - ".$_profile_template_row['profile_template_id'] : $_profile_template_row['profile_template_label']; |
| | 319 | $_i ++; |
| | 320 | } |
| | 321 | |
| | 322 | $_html .= FormSelectGenerator::generateFromArray($_tab, $selectedId, $_name, null, false); |
| | 323 | |
| | 324 | if ($type_interface == "add") { |
| | 325 | if (isset ($_tab)) { |
| | 326 | $name = "{$user_prefix}_add"; |
| | 327 | $value = _("Add"); |
| | 328 | $_html .= "<div class='admin_element_tools'>"; |
| | 329 | $_html .= '<input type="submit" class="submit" name="' . $name . '" value="' . $value . '">'; |
| | 330 | $_html .= "</div>"; |
| | 331 | } |
| | 332 | } |
| | 333 | } |
| | 334 | |
| | 335 | return $_html; |
| | 336 | } |
| | 337 | |
| | 338 | |
| 344 | | $db = AbstractDb :: getObject(); |
| 345 | | |
| 346 | | // Init values |
| 347 | | $html = ""; |
| 348 | | |
| 349 | | $link_table = $db->escapeString($link_table); |
| 350 | | $link_table_obj_key_col = $db->escapeString($link_table_obj_key_col); |
| 351 | | $link_table_obj_key = $db->escapeString($link_table_obj_key); |
| 352 | | |
| 353 | | /* Profile templates already linked */ |
| 354 | | $current_profile_templates_sql = "SELECT * FROM $link_table WHERE $link_table_obj_key_col = '$link_table_obj_key'"; |
| 355 | | $rows = null; |
| 356 | | $db->execSql($current_profile_templates_sql, $rows, false); |
| 357 | | |
| 358 | | $html .= "<table class='content_management_tools'>\n"; |
| 359 | | $html .= "<th>" . _('Profile template label') . '</th><th>' . _('Actions') . '</th>' . "\n"; |
| 360 | | if ($rows) |
| 361 | | foreach ($rows as $row) { |
| 362 | | $profile_template = self :: getObject($row['profile_template_id']); |
| 363 | | $html .= "<tr class='already_linked_content'>\n"; |
| 364 | | $html .= "<td>\n"; |
| 365 | | $html .= $profile_template->getLabel(); |
| 366 | | $html .= "</td>\n"; |
| 367 | | $html .= "<td>\n"; |
| 368 | | $name = "{$user_prefix}_" . $profile_template->GetId() . "_edit"; |
| 369 | | $html .= "<input type='button' class='submit' name='$name' value='" . _("Edit") . "' onClick='window.open(\"" . GENERIC_OBJECT_ADMIN_ABS_HREF . "?object_class=ProfileTemplate&action=edit&object_id=" . $profile_template->GetId() . "\");'>\n"; |
| 370 | | $name = "{$user_prefix}_" . $profile_template->GetId() . "_erase"; |
| 371 | | $html .= "<input type='submit' class='submit' name='$name' value='" . _("Remove") . "'>"; |
| 372 | | $html .= "</td>\n"; |
| 373 | | $html .= "</tr>\n"; |
| 374 | | } |
| 375 | | |
| 376 | | /* Add a profile template */ |
| 377 | | $html .= "<tr class='add_existing_content'>\n"; |
| 378 | | $html .= "<td colspan ='2'>\n"; |
| 379 | | $name = "{$user_prefix}_new_existing"; |
| 380 | | $profileTemplateSelector = self :: getSelectUI($name, Array('additionalWhere' => "AND profile_template_id NOT IN (SELECT profile_template_id FROM $link_table WHERE $link_table_obj_key_col='$link_table_obj_key')", 'typeInterface' => "add")); |
| 381 | | $html .= $profileTemplateSelector; |
| 382 | | $html .= "</td>\n"; |
| 383 | | $html .= "</tr>\n"; |
| 384 | | |
| 385 | | $html .= "</table>\n"; |
| 386 | | return $html; |
| 387 | | } |
| 388 | | |
| | 368 | $db = AbstractDb :: getObject(); |
| | 369 | |
| | 370 | // Init values |
| | 371 | $html = ""; |
| | 372 | |
| | 373 | $link_table = $db->escapeString($link_table); |
| | 374 | $link_table_obj_key_col = $db->escapeString($link_table_obj_key_col); |
| | 375 | $link_table_obj_key = $db->escapeString($link_table_obj_key); |
| | 376 | |
| | 377 | /* Profile templates already linked */ |
| | 378 | $current_profile_templates_sql = "SELECT * FROM $link_table WHERE $link_table_obj_key_col = '$link_table_obj_key'"; |
| | 379 | $rows = null; |
| | 380 | $db->execSql($current_profile_templates_sql, $rows, false); |
| | 381 | |
| | 382 | $html .= "<table class='content_management_tools'>\n"; |
| | 383 | $html .= "<th>" . _('Profile template label') . '</th><th>' . _('Actions') . '</th>' . "\n"; |
| | 384 | if ($rows) |
| | 385 | foreach ($rows as $row) { |
| | 386 | $profile_template = self :: getObject($row['profile_template_id']); |
| | 387 | $html .= "<tr class='already_linked_content'>\n"; |
| | 388 | $html .= "<td>\n"; |
| | 389 | $html .= $profile_template->getLabel(); |
| | 390 | $html .= "</td>\n"; |
| | 391 | $html .= "<td>\n"; |
| | 392 | $name = "{$user_prefix}_" . $profile_template->GetId() . "_edit"; |
| | 393 | $html .= "<input type='button' class='submit' name='$name' value='" . _("Edit") . "' onClick='window.open(\"" . GENERIC_OBJECT_ADMIN_ABS_HREF . "?object_class=ProfileTemplate&action=edit&object_id=" . $profile_template->GetId() . "\");'>\n"; |
| | 394 | $name = "{$user_prefix}_" . $profile_template->GetId() . "_erase"; |
| | 395 | $html .= "<input type='submit' class='submit' name='$name' value='" . _("Remove") . "'>"; |
| | 396 | $html .= "</td>\n"; |
| | 397 | $html .= "</tr>\n"; |
| | 398 | } |
| | 399 | |
| | 400 | /* Add a profile template */ |
| | 401 | $html .= "<tr class='add_existing_content'>\n"; |
| | 402 | $html .= "<td colspan ='2'>\n"; |
| | 403 | $name = "{$user_prefix}_new_existing"; |
| | 404 | $profileTemplateSelector = self :: getSelectUI($name, Array('additionalWhere' => "AND profile_template_id NOT IN (SELECT profile_template_id FROM $link_table WHERE $link_table_obj_key_col='$link_table_obj_key')", 'typeInterface' => "add")); |
| | 405 | $html .= $profileTemplateSelector; |
| | 406 | $html .= "</td>\n"; |
| | 407 | $html .= "</tr>\n"; |
| | 408 | |
| | 409 | $html .= "</table>\n"; |
| | 410 | return $html; |
| | 411 | } |
| | 412 | |
| 394 | | $db = AbstractDb :: getObject(); |
| 395 | | $link_table = $db->escapeString($link_table); |
| 396 | | $link_table_obj_key_col = $db->escapeString($link_table_obj_key_col); |
| 397 | | $link_table_obj_key = $db->escapeString($link_table_obj_key); |
| 398 | | |
| 399 | | // Profile templates already linked |
| 400 | | $current_content_sql = "SELECT * FROM $link_table WHERE $link_table_obj_key_col='$link_table_obj_key'"; |
| 401 | | $rows = null; |
| 402 | | $db->execSql($current_content_sql, $rows, false); |
| 403 | | if ($rows) |
| 404 | | foreach ($rows as $row) { |
| 405 | | $profile_template = ProfileTemplate :: getObject($row['profile_template_id']); |
| 406 | | $profile_template_id = $db->escapeString($profile_template->getId()); |
| 407 | | $name = "{$user_prefix}_" . $profile_template->GetId() . "_erase"; |
| 408 | | if (!empty ($_REQUEST[$name])) { |
| 409 | | $sql = "DELETE FROM $link_table WHERE $link_table_obj_key_col='$link_table_obj_key' AND profile_template_id = '$profile_template_id';\n"; |
| 410 | | $db->execSqlUpdate($sql, false); |
| 411 | | } |
| 412 | | } |
| 413 | | // Link an existing profile template |
| 414 | | $name = "{$user_prefix}_new_existing_add"; |
| 415 | | if (!empty ($_REQUEST[$name])) { |
| 416 | | $name = "{$user_prefix}_new_existing"; |
| 417 | | $profile_template = ProfileTemplate :: processSelectProfileTemplateUI($name); |
| 418 | | if ($profile_template) { |
| 419 | | $profile_template_id = $db->escapeString($profile_template->getId()); |
| 420 | | $sql = "INSERT INTO $link_table (profile_template_id, $link_table_obj_key_col) VALUES ('$profile_template_id', '$link_table_obj_key');\n"; |
| 421 | | $db->execSqlUpdate($sql, false); |
| 422 | | } |
| 423 | | } |
| 424 | | } |
| 425 | | |
| 426 | | /**Get all fields |
| | 418 | $db = AbstractDb :: getObject(); |
| | 419 | $link_table = $db->escapeString($link_table); |
| | 420 | $link_table_obj_key_col = $db->escapeString($link_table_obj_key_col); |
| | 421 | $link_table_obj_key = $db->escapeString($link_table_obj_key); |
| | 422 | |
| | 423 | // Profile templates already linked |
| | 424 | $current_content_sql = "SELECT * FROM $link_table WHERE $link_table_obj_key_col='$link_table_obj_key'"; |
| | 425 | $rows = null; |
| | 426 | $db->execSql($current_content_sql, $rows, false); |
| | 427 | if ($rows) |
| | 428 | foreach ($rows as $row) { |
| | 429 | $profile_template = ProfileTemplate :: getObject($row['profile_template_id']); |
| | 430 | $profile_template_id = $db->escapeString($profile_template->getId()); |
| | 431 | $name = "{$user_prefix}_" . $profile_template->GetId() . "_erase"; |
| | 432 | if (!empty ($_REQUEST[$name])) { |
| | 433 | $sql = "DELETE FROM $link_table WHERE $link_table_obj_key_col='$link_table_obj_key' AND profile_template_id = '$profile_template_id';\n"; |
| | 434 | $db->execSqlUpdate($sql, false); |
| | 435 | } |
| | 436 | } |
| | 437 | // Link an existing profile template |
| | 438 | $name = "{$user_prefix}_new_existing_add"; |
| | 439 | if (!empty ($_REQUEST[$name])) { |
| | 440 | $name = "{$user_prefix}_new_existing"; |
| | 441 | $profile_template = ProfileTemplate :: processSelectProfileTemplateUI($name); |
| | 442 | if ($profile_template) { |
| | 443 | $profile_template_id = $db->escapeString($profile_template->getId()); |
| | 444 | $sql = "INSERT INTO $link_table (profile_template_id, $link_table_obj_key_col) VALUES ('$profile_template_id', '$link_table_obj_key');\n"; |
| | 445 | $db->execSqlUpdate($sql, false); |
| | 446 | } |
| | 447 | } |
| | 448 | } |
| | 449 | |
| | 450 | /**Get all fields |
| 449 | | public function getAdminUI() |
| 450 | | { |
| 451 | | Security::requirePermission(Permission::P('SERVER_PERM_EDIT_PROFILE_TEMPLATES'), Server::getServer()); |
| 452 | | $db = AbstractDb::getObject(); |
| 453 | | $sql = "SELECT COUNT(*) as num_used_profiles FROM profile_templates JOIN profiles USING (profile_template_id) WHERE profile_template_id = '" . $this->getId() . "'"; |
| 454 | | $db->execSqlUniqueRes($sql, $num_used_profiles, false); |
| 455 | | |
| 456 | | // Init values |
| 457 | | $html = ''; |
| 458 | | |
| 459 | | $html .= "<fieldset class='admin_container ".get_class($this)."'>\n"; |
| 460 | | $html .= "<legend>"._("Profile template management")."</legend>\n"; |
| | 473 | public function getAdminUI() |
| | 474 | { |
| | 475 | Security::requirePermission(Permission::P('SERVER_PERM_EDIT_PROFILE_TEMPLATES'), Server::getServer()); |
| | 476 | $db = AbstractDb::getObject(); |
| | 477 | $sql = "SELECT COUNT(*) as num_used_profiles FROM profile_templates JOIN profiles USING (profile_template_id) WHERE profile_template_id = '" . $this->getId() . "'"; |
| | 478 | $db->execSqlUniqueRes($sql, $num_used_profiles, false); |
| | 479 | |
| | 480 | // Init values |
| | 481 | $html = ''; |
| | 482 | |
| | 483 | $html .= "<fieldset class='admin_container ".get_class($this)."'>\n"; |
| | 484 | $html .= "<legend>"._("Profile template management")."</legend>\n"; |
| 462 | | |
| 463 | | // profile_template_id |
| 464 | | $_value = htmlspecialchars($this->getId(), ENT_QUOTES); |
| 465 | | |
| 466 | | $html .= "<li class='admin_element_item_container'>\n"; |
| 467 | | $html .= "<div class='admin_element_label'>" . _("ProfileTemplate ID") . ":</div>\n"; |
| 468 | | $html .= "<div class='admin_element_data'>\n"; |
| 469 | | $html .= $_value; |
| 470 | | $html .= "</div>\n"; |
| 471 | | $html .= "</li>\n"; |
| 472 | | |
| 473 | | // label |
| 474 | | $_name = "profile_template_" . $this->getId() . "_label"; |
| 475 | | $_value = htmlspecialchars($this->getLabel(), ENT_QUOTES); |
| 476 | | |
| 477 | | $html .= "<li class='admin_element_item_container'>\n"; |
| 478 | | $html .= "<div class='admin_element_label'>" . _("Label") . ":</div>\n"; |
| 479 | | $html .= "<div class='admin_element_data'>\n"; |
| 480 | | $html .= "<input type='text' size='50' value='$_value' name='$_name'>\n"; |
| 481 | | $html .= "</div>\n"; |
| 482 | | $html .= "</li>\n"; |
| 483 | | |
| 484 | | // creation date |
| 485 | | $_value = htmlspecialchars($this->getCreationDate(), ENT_QUOTES); |
| 486 | | |
| 487 | | $html .= "<li class='admin_element_item_container'>\n"; |
| 488 | | $html .= "<div class='admin_element_label'>" . _("Creation date") . ":</div>\n"; |
| 489 | | $html .= "<div class='admin_element_data'>\n"; |
| 490 | | $html .= $_value; |
| 491 | | $html .= "</div>\n"; |
| 492 | | $html .= "</li>\n"; |
| 493 | | |
| 494 | | // profile template fields |
| 495 | | $html .= "<li class='admin_element_item_container'>\n"; |
| | 486 | |
| | 487 | // profile_template_id |
| | 488 | $_value = htmlspecialchars($this->getId(), ENT_QUOTES); |
| | 489 | |
| | 490 | $html .= "<li class='admin_element_item_container'>\n"; |
| | 491 | $html .= "<div class='admin_element_label'>" . _("ProfileTemplate ID") . ":</div>\n"; |
| | 492 | $html .= "<div class='admin_element_data'>\n"; |
| | 493 | $html .= $_value; |
| | 494 | $html .= "</div>\n"; |
| | 495 | $html .= "</li>\n"; |
| | 496 | |
| | 497 | // label |
| | 498 | $_name = "profile_template_" . $this->getId() . "_label"; |
| | 499 | $_value = htmlspecialchars($this->getLabel(), ENT_QUOTES); |
| | 500 | |
| | 501 | $html .= "<li class='admin_element_item_container'>\n"; |
| | 502 | $html .= "<div class='admin_element_label'>" . _("Label") . ":</div>\n"; |
| | 503 | $html .= "<div class='admin_element_data'>\n"; |
| | 504 | $html .= "<input type='text' size='50' value='$_value' name='$_name'>\n"; |
| | 505 | $html .= "</div>\n"; |
| | 506 | $html .= "</li>\n"; |
| | 507 | |
| | 508 | // creation date |
| | 509 | $_value = htmlspecialchars($this->getCreationDate(), ENT_QUOTES); |
| | 510 | |
| | 511 | $html .= "<li class='admin_element_item_container'>\n"; |
| | 512 | $html .= "<div class='admin_element_label'>" . _("Creation date") . ":</div>\n"; |
| | 513 | $html .= "<div class='admin_element_data'>\n"; |
| | 514 | $html .= $_value; |
| | 515 | $html .= "</div>\n"; |
| | 516 | $html .= "</li>\n"; |
| | 517 | |
| | 518 | // profile template fields |
| | 519 | $html .= "<li class='admin_element_item_container'>\n"; |
| 558 | | public function delete(&$errmsg) |
| 559 | | { |
| 560 | | require_once('classes/User.php'); |
| 561 | | |
| 562 | | $db = AbstractDb::getObject(); |
| 563 | | |
| 564 | | // Init values |
| 565 | | $_retVal = false; |
| 566 | | |
| 567 | | if (Security::hasPermission(Permission::P('SERVER_PERM_EDIT_PROFILE_TEMPLATES'), Server::getServer())) { |
| 568 | | $errmsg = _('Access denied'); |
| 569 | | } else { |
| 570 | | $_id = $db->escapeString($this->getId()); |
| 571 | | |
| 572 | | if (!$db->execSqlUpdate("DELETE FROM profile_templates WHERE profile_template_id = '{$_id}'", false)) { |
| 573 | | $errmsg = _('Could not delete ProfileTemplate!'); |
| 574 | | } else { |
| 575 | | $_retVal = true; |
| 576 | | } |
| 577 | | } |
| 578 | | |
| 579 | | return $_retVal; |
| 580 | | } |
| 581 | | |
| 582 | | |
| | 582 | public function delete(&$errmsg) |
| | 583 | { |
| | 584 | require_once('classes/User.php'); |
| | 585 | |
| | 586 | $db = AbstractDb::getObject(); |
| | 587 | |
| | 588 | // Init values |
| | 589 | $_retVal = false; |
| | 590 | |
| | 591 | if (Security::hasPermission(Permission::P('SERVER_PERM_EDIT_PROFILE_TEMPLATES'), Server::getServer())) { |
| | 592 | $_id = $db->escapeString($this->getId()); |
| | 593 | |
| | 594 | if (!$db->execSqlUpdate("DELETE FROM profile_templates WHERE profile_template_id = '{$_id}'", false)) { |
| | 595 | $errmsg = _('Could not delete ProfileTemplate!'); |
| | 596 | } |
| | 597 | else { |
| | 598 | $_retVal = true; |
| | 599 | } |
| | 600 | } |
| | 601 | else { |
| | 602 | $errmsg = _('Access denied'); |
| | 603 | } |
| | 604 | |
| | 605 | return $_retVal; |
| | 606 | } |
| | 607 | |
| | 608 | |