/** * Processes the input of the administration interface for Langstring * * @return void */ public function processAdminUI() { // Init values. $result = null; if ($this->DEPRECATEDisOwner(User::getCurrentUser()) || User::getCurrentUser()->DEPRECATEDisSuperAdmin()) { parent::processAdminUI(); $generateur_form_select = new FormSelectGenerator(); $sql = "SELECT * FROM content_langstring_entries WHERE content_langstring_entries.langstrings_id = '{$this->id}'"; $this->mBd->execSql($sql, $result, false); if ($result != null) { while (list($key, $value) = each($result)) { $language = $generateur_form_select->getResult("langstrings_" . $this->id . "_substring_{$value['langstring_entries_id']}_language", null); if (empty($language)) { $language = ''; $languageSQL = 'NULL'; } else { $languageSQL = "'" . $language . "'"; } if (!empty($_REQUEST["langstrings_" . $this->id . "_substring_{$value['langstring_entries_id']}_erase"]) && $_REQUEST["langstrings_" . $this->id . "_substring_{$value['langstring_entries_id']}_erase"] == true) { $this->mBd->execSqlUpdate("DELETE FROM content_langstring_entries WHERE langstrings_id = '{$this->id}' AND langstring_entries_id='{$value['langstring_entries_id']}'", FALSE); // Create new cache object. $_cache = new Cache('langstrings_' . $this->id . '_substring_' . $language . '_string', $this->id); // Check if caching has been enabled. if ($_cache->isCachingEnabled) { // Remove old cached data. $_cache->eraseCachedData(); } } else { // Strip HTML tags ! $string = $_REQUEST["langstrings_" . $this->id . "_substring_{$value['langstring_entries_id']}_string"]; $string = $this->mBd->escapeString(strip_tags($string, $this->allowed_html_tags)); // If PEAR::HTML_Safe is available strips down all potentially dangerous content $_HtmlSafe = new HtmlSafe(); if ($_HtmlSafe->isHtmlSafeEnabled) { // Add "embed" and "object" to the default set of dangerous tags $_HtmlSafe->setDeleteTags(array("embed", "object"), true); // Strip HTML $string = $_HtmlSafe->parseHtml($string); } if ($value['value'] != $string || $language != $value['locales_id']) { $this->mBd->execSqlUpdate("UPDATE content_langstring_entries SET locales_id = {$languageSQL} , value = '{$string}' WHERE langstrings_id = '{$this->id}' AND langstring_entries_id='{$value['langstring_entries_id']}'", FALSE); $this->touch(); // Create new cache object. $_cache = new Cache('langstrings_' . $this->id . '_substring_' . $language . '_string', $this->id); // Check if caching has been enabled. if ($_cache->isCachingEnabled) { // Remove old cached data. $_cache->eraseCachedData(); // Save data into cache. $_cache->saveCachedData($string); } } } } } //Nouvelles chaîne(s) self::processNewUI($this->id, false); } }
/** Process admin interface of this object. When an object overrides this method, they should call the parent processAdminUI at the BEGINING of processing. */ public function processAdminUI() { if ($this->DEPRECATEDisOwner(User::getCurrentUser()) || User::getCurrentUser()->DEPRECATEDisSuperAdmin()) { $db = AbstractDb::getObject(); if ($this->getObjectType() == 'Content') { $content_type = FormSelectGenerator::getResult("content_" . $this->id . "_content_type", "Content"); $this->setContentType($content_type); } else { //Content medatada if ($this->isSimpleContent() == false || $this->isPersistent()) { /* title_is_displayed */ if (!empty($this->content_row['title'])) { $name = "content_" . $this->id . "_title_is_displayed"; !empty($_REQUEST[$name]) ? $this->setTitleIsDisplayed(true) : $this->setTitleIsDisplayed(false); } /* title */ if (empty($this->content_row['title'])) { $title = self::processNewContentUI("title_{$this->id}_new"); if ($title != null) { $title_id = $title->GetId(); $db->execSqlUpdate("UPDATE content SET title = '{$title_id}' WHERE content_id = '{$this->id}'", FALSE); } } else { $title = self::getObject($this->content_row['title']); $name = "content_" . $this->id . "_title_erase"; if (!empty($_REQUEST[$name]) && $_REQUEST[$name] == true) { $db->execSqlUpdate("UPDATE content SET title = NULL WHERE content_id = '{$this->id}'", FALSE); $title->delete($errmsg); } else { $title->processAdminUI(); } } } if ($this->isSimpleContent() == false) { /* description */ if (empty($this->content_row['description'])) { $description = self::processNewContentUI("description_{$this->id}_new"); if ($description != null) { $description_id = $description->GetId(); $db->execSqlUpdate("UPDATE content SET description = '{$description_id}' WHERE content_id = '{$this->id}'", FALSE); } } else { $description = self::getObject($this->content_row['description']); $name = "content_" . $this->id . "_description_erase"; if (!empty($_REQUEST[$name]) && $_REQUEST[$name] == true) { $db->execSqlUpdate("UPDATE content SET description = NULL WHERE content_id = '{$this->id}'", FALSE); $description->delete($errmsg); } else { $description->processAdminUI(); } } /* long description */ if (empty($this->content_row['long_description'])) { $long_description = self::processNewContentUI("long_description_{$this->id}_new"); if ($long_description != null) { $long_description_id = $long_description->GetId(); $db->execSqlUpdate("UPDATE content SET long_description = '{$long_description_id}' WHERE content_id = '{$this->id}'", FALSE); } } else { $long_description = self::getObject($this->content_row['long_description']); $name = "content_" . $this->id . "_long_description_erase"; if (!empty($_REQUEST[$name]) && $_REQUEST[$name] == true) { $db->execSqlUpdate("UPDATE content SET long_description = NULL WHERE content_id = '{$this->id}'", FALSE); $long_description->delete($errmsg); } else { $long_description->processAdminUI(); } } /* project_info */ if (empty($this->content_row['project_info'])) { $project_info = self::processNewContentUI("project_info_{$this->id}_new"); if ($project_info != null) { $project_info_id = $project_info->GetId(); $db->execSqlUpdate("UPDATE content SET project_info = '{$project_info_id}' WHERE content_id = '{$this->id}'", FALSE); } } else { $project_info = self::getObject($this->content_row['project_info']); $name = "content_" . $this->id . "_project_info_erase"; if (!empty($_REQUEST[$name]) && $_REQUEST[$name] == true) { $db->execSqlUpdate("UPDATE content SET project_info = NULL WHERE content_id = '{$this->id}'", FALSE); $project_info->delete($errmsg); } else { $project_info->processAdminUI(); } } } //End content metadata if ($this->isSimpleContent() == false || $this->isPersistent()) { /* is_persistent */ $name = "content_" . $this->id . "_is_persistent"; !empty($_REQUEST[$name]) ? $this->setIsPersistent(true) : $this->setIsPersistent(false); /* content_has_owners */ $sql = "SELECT * FROM content_has_owners WHERE content_id='{$this->id}'"; $db->execSql($sql, $content_owner_rows, false); if ($content_owner_rows != null) { foreach ($content_owner_rows as $content_owner_row) { $user = User::getObject($content_owner_row['user_id']); $user_id = $user->getId(); $name = "content_" . $this->id . "_owner_" . $user->GetId() . "_remove"; if (!empty($_REQUEST[$name])) { $this->deleteOwner($user); } else { $name = "content_" . $this->id . "_owner_" . $user->GetId() . "_is_author"; $content_owner_row['is_author'] == 't' ? $is_author = true : ($is_author = false); !empty($_REQUEST[$name]) ? $should_be_author = true : ($should_be_author = false); if ($is_author != $should_be_author) { $should_be_author ? $is_author_sql = 'TRUE' : ($is_author_sql = 'FALSE'); $sql = "UPDATE content_has_owners SET is_author={$is_author_sql} WHERE content_id='{$this->id}' AND user_id='{$user_id}'"; if (!$db->execSqlUpdate($sql, false)) { throw new Exception(_('Unable to set as author in the database.')); } } } } } $errMsg = null; $user = User::processSelectUserUI("content_{$this->id}_new_owner", $errMsg); $name = "content_{$this->id}_add_owner_submit"; if (!empty($_REQUEST[$name]) && $user != null) { $this->addOwner($user); } } } $this->refresh(); } }
/** * Processes the input of the administration interface for Picture * * @return void */ public function processAdminUI() { if ($this->DEPRECATEDisOwner(User::getCurrentUser()) || User::getCurrentUser()->DEPRECATEDisSuperAdmin()) { parent::processAdminUI(); /* width and height */ $name = "banner_add_group_{this->getId()}_widthxheight"; $widthxheight = FormSelectGenerator::getResult($name, null); //pretty_print_r($widthxheight); $name = "banner_add_group_{this->getId()}_max_width"; $max_width = $_REQUEST[$name]; /*max_height*/ $name = "banner_add_group_{this->getId()}_max_height"; $max_height = $_REQUEST[$name]; if (!empty($widthxheight)) { $widthxheightArray = explode('/', $widthxheight); $max_width_select = $widthxheightArray[0]; $max_height_select = $widthxheightArray[1]; if (($max_width_select != $max_width || $max_height_select != $max_height) && ($max_width == $this->getKVP(get_class($this) . '_max_width') && $max_height == $this->getKVP(get_class($this) . '_max_height'))) { /* Width and height weren't manually changed, or were empty */ $max_width = $max_width_select; $max_height = $max_height_select; } } $this->setKVP(get_class($this) . '_max_width', $max_width); $this->setKVP(get_class($this) . '_max_height', $max_height); } }
/** * This method will create a ProfileTemplateField based on the content type filter specified * * @param string $user_prefix A identifier provided by the programmer to * recognise it's generated form * @param string $profile_template Must be present * * @return object The ProfileTemplateField object, or null if the user didn't create one * @static */ public static function processCreateFieldUI($user_prefix, ProfileTemplate $profile_template) { $db = AbstractDb::getObject(); // Init values $profile_template_field_object = null; $max_display_order_row = null; $name = "get_new_profile_template_field_{$user_prefix}_add"; if (!empty($_REQUEST[$name])) { /* Get the display order to add the ProfileTemplateField at the end */ $sql = "SELECT MAX(display_order) as max_display_order FROM profile_template_fields WHERE profile_template_id = '" . $profile_template->getId() . "'"; $db->execSqlUniqueRes($sql, $max_display_order_row, false); $display_order = $max_display_order_row['max_display_order'] + 1; $profile_template_field_id = get_guid(); $sql = "INSERT INTO profile_template_fields (profile_template_field_id, profile_template_id, display_order) VALUES ('{$profile_template_field_id}', '{$profile_template->getId()}', {$display_order});"; if (!$db->execSqlUpdate($sql, false)) { throw new Exception(_('Unable to insert new content into database!')); } $profile_template_field_object = self::getObject($profile_template_field_id); $name = "get_new_profile_template_field_{$user_prefix}_content_type_filter"; $content_type_filter_ui_result = FormSelectGenerator::getResult($name, null); if (empty($content_type_filter_ui_result)) { throw new exception("Unable to retrieve the content type filter to associate with the new field"); } $content_type_filter = ContentTypeFilter::getObject($content_type_filter_ui_result); $profile_template_field_object->replaceContentTypeFilter($content_type_filter); } return $profile_template_field_object; }
public function processAdminUI() { $db = AbstractDb::getObject(); $currentUser = self::getCurrentUser(); if (Security::hasPermission(Permission::P('NETWORK_PERM_EDIT_ANY_USER'), $this->getNetwork())) { /* Account status */ $name = "user_" . $this->getId() . "_accountstatus"; $status = FormSelectGenerator::getResult($name, null); $this->setAccountStatus($status); } if ($this == $currentUser || Security::requirePermission(Permission::P('NETWORK_PERM_EDIT_ANY_USER'), $this->getNetwork())) { /* Username */ $name = "user_" . $this->getId() . "_username"; $this->setUsername($_REQUEST[$name]); /* Change password */ $nameOldpassword = "******" . $this->getId() . "_oldpassword"; $nameNewpassword = "******" . $this->getId() . "_newpassword"; $nameNewpasswordAgain = "user_" . $this->getId() . "_newpassword_again"; if ($_REQUEST[$nameNewpassword] != null) { if ($this == $currentUser && $this->getPasswordHash() != User::passwordHash($_REQUEST[$nameOldpassword])) { throw new Exception(_("Wrong password.")); } if ($_REQUEST[$nameNewpassword] != $_REQUEST[$nameNewpasswordAgain]) { throw new Exception(_("Passwords do not match.")); } $this->setPassword($_REQUEST[$nameNewpassword]); } // Pretend there is only one $profiles = $this->getAllProfiles(); if (!empty($profiles)) { $current_profile = $profiles[0]; if ($current_profile != null) { $current_profile->processAdminUI(); $name = "user_" . $this->getId() . "_delete_profile_" . $current_profile->getId(); if (!empty($_REQUEST[$name])) { $errmsg = null; $current_profile->delete($errmsg); } } } else { $name = "user_" . $this->getId() . "_add_profile"; if (!empty($_REQUEST[$name])) { // Get the list of profile templates for the users' network $profile_templates = ProfileTemplate::getAllProfileTemplates($this->getNetwork()); if (!empty($profile_templates)) { // Create a blank profile and link it to the user $current_profile = Profile::createNewObject(null, $profile_templates[0]); $this->addProfile($current_profile); } } } } }
function processAdminUI() { // Init values $errmsg = null; if ($this->DEPRECATEDisOwner(User::getCurrentUser()) || User::getCurrentUser()->DEPRECATEDisSuperAdmin()) { parent::processAdminUI(); /* content_ordering_mode */ $name = "content_group_" . $this->id . "_content_ordering_mode"; $this->setContentOrderingMode(FormSelectGenerator::getResult($name, null)); /*content_changes_on_mode */ $name = "content_group_" . $this->id . "_content_changes_on_mode"; $this->setContentChangesOnMode(FormSelectGenerator::getResult($name, null)); /* allow_repeat*/ $name = "content_group_" . $this->id . "_allow_repeat"; $this->setAllowRepeat(FormSelectGenerator::getResult($name, null)); /*display_num_elements*/ $name = "content_group_" . $this->id . "_display_num_elements"; $this->setDisplayNumElements($_REQUEST[$name]); /* content_group_element */ $name = "content_group_" . $this->id . "_expired_elements_shown"; if (empty($_REQUEST[$name])) { $additionalWhere = "AND (valid_until_timestamp IS NULL OR valid_until_timestamp >= CURRENT_TIMESTAMP) \n"; } else { $additionalWhere = null; } foreach ($this->getElements($additionalWhere) as $element) { $name = "content_group_" . $this->id . "_element_" . $element->GetId() . "_erase"; if (!empty($_REQUEST[$name]) && $_REQUEST[$name] == true) { $element->delete($errmsg); } else { $element->processAdminUI(); } } // The two following calls will either add a new element or add an existing one ( depending on what button the user clicked /* We explicitely call the ContentGroupElement version of processNewContentUI */ ContentGroupElement::processNewContentUI("content_group_{$this->id}_new_element", $this); // Last parameters allows for existing content ( if any was selected ) ContentGroupElement::processNewContentUI("content_group_{$this->id}_existing_element", $this, true); } }
function processAdminUI() { if ($this->DEPRECATEDisOwner(User::getCurrentUser()) || User::getCurrentUser()->DEPRECATEDisSuperAdmin()) { parent::processAdminUI(); $generator = new FormSelectGenerator(); $name = "flickr_photostream_" . $this->id . "_api_key"; !empty($_REQUEST[$name]) ? $this->setApiKey($_REQUEST[$name]) : $this->setApiKey(null); $name = "flickr_photostream_" . $this->id . "_api_shared_secret"; !empty($_REQUEST[$name]) ? $this->setApiSharedSecret($_REQUEST[$name]) : $this->setApiSharedSecret(null); $name = "flickr_photostream_" . $this->id . "_photo_batch_size"; !empty($_REQUEST[$name]) ? $this->setPhotoBatchSize($_REQUEST[$name]) : $this->setPhotoBatchSize(null); if ($generator->isPresent("DisplayMode" . $this->getID(), "FlickrPhotostream")) { $this->setDisplayMode($generator->getResult("DisplayMode" . $this->getID(), "FlickrPhotostream")); } if ($generator->isPresent("SelectionMode" . $this->getID(), "FlickrPhotostream")) { $this->setSelectionMode($generator->getResult("SelectionMode" . $this->getID(), "FlickrPhotostream")); } // Check for existing API key if ($this->getAPIKey() && $this->getSelectionMode()) { try { switch ($this->getSelectionMode()) { // Process common data for groups and users case self::SELECT_BY_GROUP: if ($generator->isPresent("GroupPhotoPool" . $this->getID(), "FlickrPhotostream")) { $this->setGroupId($generator->getResult("GroupPhotoPool" . $this->getID(), "FlickrPhotostream")); } case self::SELECT_BY_USER: $name = "flickr_photostream_" . $this->id . "_reset_user_id"; if (!empty($_REQUEST[$name]) || !$this->getFlickrUserId()) { $this->setUserId(null); $name = "flickr_photostream_" . $this->id . "_email"; if (!empty($_REQUEST[$name]) && ($flickr_user = $this->getUserByEmail($_REQUEST[$name])) != null) { $this->setUserId($flickr_user->getId()); $this->setUserName($flickr_user->getName()); } else { echo _("Could not find a Flickr user with this e-mail."); } } break; case self::SELECT_BY_TAGS: $name = "flickr_photostream_" . $this->id . "_tags"; if (!empty($_REQUEST[$name])) { $this->setTags($_REQUEST[$name]); } else { $this->setTags(null); } if ($generator->isPresent("TagMode" . $this->getID(), "FlickrPhotostream")) { $this->setTagMode($generator->getResult("TagMode" . $this->getID(), "FlickrPhotostream")); } break; } } catch (Exception $e) { echo _("Could not complete successfully the saving procedure."); } $name = "flickr_photostream_" . $this->id . "_display_title"; !empty($_REQUEST[$name]) ? $this->setDisplayTitle(true) : $this->setDisplayTitle(false); $name = "flickr_photostream_" . $this->id . "_display_tags"; !empty($_REQUEST[$name]) ? $this->setDisplayTags(true) : $this->setDisplayTags(false); $name = "flickr_photostream_" . $this->id . "_display_description"; !empty($_REQUEST[$name]) ? $this->setDisplayDescription(true) : $this->setDisplayDescription(false); if ($generator->isPresent("PreferredSize" . $this->getID(), "FlickrPhotostream")) { $this->setPreferredSize($generator->getResult("PreferredSize" . $this->getID(), "FlickrPhotostream")); } } } }