/** * Gets a validation for a given item * * @param integer $itemID The item we want the validations for * @param CMS_user $user The user we want the validations for * @param integer $getEditionType The validation type we want. * by default function return RESOURCE_EDITION_LOCATION then RESOURCE_EDITION_CONTENT then RESOURCE_EDITION_SIBLINGSORDER * @return array(CMS_resourceValidation) The resourceValidations objects, false if none found for the given user. * @access public */ function getValidationByID($itemID, &$user, $getEditionType = false) { if (!$user instanceof CMS_profile_user) { $this->raiseError("User is not a valid CMS_profile_user object"); return false; } if (!$user->hasValidationClearance($this->_codename)) { return false; } if (CMS_poly_object_catalog::hasPrimaryResource($this->getCodename())) { //get object type ID $objectID = CMS_poly_object_catalog::getPrimaryResourceObjectType($this->getCodename()); //get viewvable objects list for current user if (CMS_poly_object_catalog::objectHasCategories($objectID)) { $objects = CMS_poly_object_catalog::getAllObjects($objectID, false, array(), false); //$where = (is_array($objects) && $objects) ? ' and objectID in ('.implode(',',$objects).')' : ''; if (is_array($objects) && $objects) { $where = ' and objectID in (' . implode(',', $objects) . ')'; } else { return false; } } else { $where = ''; } $this->getPrimaryResourceDefinition(); if (!$getEditionType) { $getEditionType = RESOURCE_EDITION_LOCATION + RESOURCE_EDITION_CONTENT; } $sql = "\n\t\t\t\t\tselect\n\t\t\t\t\t\tobjectID as id,\n\t\t\t\t\t\tlocation_rs as location,\n\t\t\t\t\t\tproposedFor_rs as proposedFor,\n\t\t\t\t\t\tvalidationsRefused_rs as validationsRefused,\n\t\t\t\t\t\teditions_rs as editions,\n\t\t\t\t\t\tmod_subobject_integer_edited.id as fieldID\n\t\t\t\t\tfrom\n\t\t\t\t\t\tmod_subobject_integer_edited,\n\t\t\t\t\t\tmod_object_polyobjects,\n\t\t\t\t\t\tresources,\n\t\t\t\t\t\tresourceStatuses\n\t\t\t\t\twhere\n\t\t\t\t\t\tobjectID = '" . $itemID . "'\n\t\t\t\t\t\tand value = id_res\n\t\t\t\t\t\tand object_type_id_moo = '" . $objectID . "'\n\t\t\t\t\t\tand id_moo = objectID\n\t\t\t\t\t\tand objectFieldID = 0\n\t\t\t\t\t\tand objectSubFieldID = 0\n\t\t\t\t\t\tand status_res = id_rs\n\t\t\t\t\t\t{$where}\n\t\t\t\t"; $q = new CMS_query($sql); if ($q->getNumRows() >= 1) { $r = $q->getArray(); $id = $r["id"]; //here, this is an ugly hack to resolve a strange bug (multiple resources for an unique object). //not time to found the real cause for now ... if ($q->getNumRows() > 1) { while ($exceptionFiledID = $q->getValue('fieldID')) { $sql_delete = "delete from mod_subobject_integer_edited where id = '" . $exceptionFiledID . "'"; $q_delete = new CMS_query($sql_delete); } } //search the type of edition //RESOURCE_EDITION_LOCATION if ($r["location"] == RESOURCE_LOCATION_USERSPACE && $r["proposedFor"] != 0 && !($r["validationsRefused"] & RESOURCE_EDITION_LOCATION) && $getEditionType & RESOURCE_EDITION_LOCATION) { $language = $user->getLanguage(); $item = $this->getResourceByID($id); $validation = new CMS_resourceValidation($this->_codename, RESOURCE_EDITION_LOCATION, $item); if (!$validation->hasError()) { $validation->setValidationTypeLabel($language->getMessage(self::MESSAGE_MOD_POLYMOD_VALIDATION_LOCATIONCHANGE, array($this->_primaryResourceObjectDefinition->getLabel($language)), MOD_POLYMOD_CODENAME)); $validation->setValidationLabel($language->getMessage(self::MESSAGE_MOD_POLYMOD_VALIDATION_LOCATIONCHANGE_OFRESOURCE, array($this->_primaryResourceObjectDefinition->getLabel($language)), MOD_POLYMOD_CODENAME) . " " . io::decodeEntities($item->{$this->_resourceNameMethod}())); $validation->setValidationShortLabel(io::decodeEntities($item->{$this->_resourceNameMethod}())); $previzURL = $item->getPrevizPageURL(); if ($previzURL) { $validation->addHelpUrl($language->getMessage(self::MESSAGE_PAGE_ACTION_PREVIZ), $previzURL); } $validation->setEditorsStack($item->getEditorsStack()); return $validation; } else { return false; } //RESOURCE_EDITION_CONTENT } elseif ($r["location"] == RESOURCE_LOCATION_USERSPACE && $r["proposedFor"] == 0 && ($r["editions"] & RESOURCE_EDITION_CONTENT && !($r["validationsRefused"] & RESOURCE_EDITION_CONTENT)) && $getEditionType & RESOURCE_EDITION_CONTENT) { $language = $user->getLanguage(); $editions = $r["editions"]; //RESOURCE_EDITION_CONTENT $item = $this->getResourceByID($id); $validation = new CMS_resourceValidation($this->_codename, $editions, $item); if (!$validation->hasError()) { $validation->setValidationTypeLabel($language->getMessage(self::MESSAGE_MOD_POLYMOD_VALIDATION_EDITION, array($this->_primaryResourceObjectDefinition->getLabel($language)), MOD_POLYMOD_CODENAME)); $validation->setValidationLabel($language->getMessage(self::MESSAGE_MOD_POLYMOD_VALIDATION_EDITION_OFRESOURCE, array($this->_primaryResourceObjectDefinition->getLabel($language)), MOD_POLYMOD_CODENAME) . " " . io::decodeEntities($item->{$this->_resourceNameMethod}())); $validation->setValidationShortLabel(io::decodeEntities($item->{$this->_resourceNameMethod}())); $previzURL = $item->getPrevizPageURL(); if ($previzURL) { $validation->addHelpUrl($language->getMessage(self::MESSAGE_PAGE_ACTION_PREVIZ), $previzURL); } $validation->setEditorsStack($item->getEditorsStack()); return $validation; } else { return false; } } } elseif ($q->getNumRows() == 0) { return false; } else { $this->raiseError("Can't have more than one item for a given ID"); return false; } } else { return false; } }
define("MESSAGE_PAGE_FIELD_STANDARD_OBJECTS", 1247); define("MESSAGE_PAGE_FIELD_POLY_OBJECTS", 1248); define("MESSAGE_PAGE_FIELD_DESCRIPTION", 139); define("MESSAGE_PAGE_TREEH1", 1049); define("MESSAGE_FIELD_NO", 1083); define("MESSAGE_FIELD_YES", 1082); //Polymod messages define("MESSAGE_PAGE_FIELD_INDEXABLE", 322); //checks rights if (!$cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL)) { header("Location: " . PATH_ADMIN_SPECIAL_ENTRY_WR . "?cms_message_id=" . MESSAGE_PAGE_CLEARANCE_ERROR . "&" . session_name() . "=" . session_id()); exit; } //load page objects and vars $moduleCodename = $_POST["moduleCodename"] ? $_POST["moduleCodename"] : $_GET["moduleCodename"]; $object = new CMS_poly_object_definition($_POST["object"]); $field = new CMS_poly_object_field($_POST["field"]); $label = new CMS_object_i18nm($field->getValue("labelID")); $description = new CMS_object_i18nm($field->getValue("descriptionID")); $availableLanguagesCodes = CMS_object_i18nm::getAvailableLanguages(); $cms_message = ""; // **************************************************************** // ** ACTIONS MANAGEMENT ** // **************************************************************** switch ($_POST["cms_action"]) { case "validate": //checks and assignments $field->setDebug(false); if (!$_POST["label" . $availableLanguagesCodes[0]] || !$_POST["type"]) { $cms_message .= $cms_language->getMessage(MESSAGE_FORM_ERROR_MANDATORY_FIELDS); }
/** * Get object field as an array structure used for export * * @param array $params The export parameters. Not used here * @param array $files The reference to the found files used by object * @return array : the object array structure * @access public */ public function asArray($params = array(), &$files) { $aField = array('id' => $this->_fieldID, 'uuid' => $this->_objectFieldValues['uuid'], 'labels' => CMS_object_i18nm::getValues($this->_objectFieldValues['labelID']), 'descriptions' => CMS_object_i18nm::getValues($this->_objectFieldValues['descriptionID']), 'objectID' => $this->_objectFieldValues['objectID'], 'type' => null, 'multi' => null, 'params' => array('order' => $this->_objectFieldValues['order'], 'required' => $this->_objectFieldValues['required'], 'indexable' => $this->_objectFieldValues['indexable'], 'searchlist' => $this->_objectFieldValues['searchlist'], 'searchable' => $this->_objectFieldValues['searchable'])); $linkedObjectId = null; if (io::strpos($this->_objectFieldValues['type'], 'multi|') !== false) { $aField['multi'] = 1; $type = explode('|', $this->_objectFieldValues['type']); $aField['type'] = $type[1]; $linkedObjectId = $type[1]; } else { $aField['multi'] = 0; $aField['type'] = $this->_objectFieldValues['type']; if (io::isPositiveInteger($aField['type'])) { $linkedObjectId = $this->_objectFieldValues['type']; } } if ($linkedObjectId) { $objectDefition = new CMS_poly_object_definition($linkedObjectId); if ($objectDefition) { $aField['params']['linkedObjectUuid'] = $objectDefition->getValue('uuid'); } } if (!io::isPositiveInteger($aField['type'])) { if (class_exists($aField['type'])) { $oType = new $aField['type'](array(), $this, false); $aField['params']['params'] = $oType->asArray(); } } elseif ($aField['multi']) { $oType = new CMS_multi_poly_object($aField['type'], array(), $this, false); $aField['params']['params'] = $oType->asArray(); } return $aField; }
/** * Returns the next result in the current search results stack, false if no results left * Search must be already done using search method and mode self::POLYMOD_SEARCH_RETURN_INDIVIDUALS_OBJECTS. * * @access public * @param $return, the returned values in : * self::POLYMOD_SEARCH_RETURN_OBJECTS for objetcs (default) * self::POLYMOD_SEARCH_RETURN_OBJECTSLIGHT for light objects (without subobjects datas) * self::POLYMOD_SEARCH_RETURN_OBJECTSLIGHT_EDITED for edited light objects. /!\ This method must not be used for objects which should be saved (used by getListOfNamesForObject only) /!\ * @param boolean $loadSubObjects : all the found objects can load theirs own sub objects (default false) * /!\ CAUTION : Pass this option to true can generate a lot of subqueries /!\ * @return array(CMS_poly_object) */ function getNextResult($return = self::POLYMOD_SEARCH_RETURN_OBJECTS, $loadSubObjects = false) { if ($return == self::POLYMOD_SEARCH_RETURN_OBJECTSLIGHT && !$this->_public) { $this->raiseError('Return type can\'t be self::POLYMOD_SEARCH_RETURN_OBJECTSLIGHT in a non-public search.'); $return = self::POLYMOD_SEARCH_RETURN_OBJECTS; } //this is a hack to allow light search in edited userspace. /!\ Objects must not be saved after /!\ if ($return == self::POLYMOD_SEARCH_RETURN_OBJECTSLIGHT_EDITED) { $return = self::POLYMOD_SEARCH_RETURN_OBJECTSLIGHT; } if ($this->_searchMode !== self::POLYMOD_SEARCH_RETURN_INDIVIDUALS_OBJECTS) { $this->raiseError('You cannot use this method if search was not launched with mode self::POLYMOD_SEARCH_RETURN_INDIVIDUALS_OBJECTS'); return false; } if ($return == self::POLYMOD_SEARCH_RETURN_IDS) { $currentResult = each($this->_sortedResultsIds); if ($currentResult !== false) { $this->_objectsCount++; return $currentResult['value']; } return false; } //return objects if ($this->_values && $this->_sortedResultsIds) { //1- create objects values : all subObjects found for searched objects if ($this->_objectsValues === false) { $this->_objectsValues = array(); foreach ($this->_resultsSubObjectsIds as $subObjectId) { $this->_objectsValues[$subObjectId] =& $this->_values[$subObjectId]; } } //load sub objects values $loadSubObjectsValues = $return != self::POLYMOD_SEARCH_RETURN_OBJECTSLIGHT; //create object $currentResult = each($this->_sortedResultsIds); if ($currentResult !== false) { //2- add object values to objects values if (!isset($this->_objectsValues[$currentResult['value']])) { $this->_objectsValues[$currentResult['value']] =& $this->_values[$currentResult['value']]; } //instanciate and return object $this->_objectsCount++; return new CMS_poly_object($this->_object->getID(), $currentResult['value'], $this->_objectsValues, $this->_public, $loadSubObjects, $loadSubObjectsValues); } } return false; }
* @package Automne * @subpackage admin-v3 * @author Sébastien Pauchet <*****@*****.**> */ /* * Polymod messages */ define("MESSAGE_PAGE_PLUGIN_DEFINITIONS", 275); define("MESSAGE_PAGE_ACTION_DELETEPLUGINCONFIRM", 279); define("MESSAGE_PAGE_RSS_DEFINITIONS", 290); define("MESSAGE_PAGE_ACTION_DELETERSSCONFIRM", 291); define("MESSAGE_PAGE_FIELD_OBJECT_INDEXABLE", 322); //Polymod message define("MESSAGE_PAGE_FIELD_INDEXABLE", 322); if (sensitiveIO::IsPositiveInteger($objectID)) { $object = new CMS_poly_object_definition($objectID); } // **************************************************************** // ** ACTIONS MANAGEMENT ** // **************************************************************** switch ($_POST["cms_action"]) { case 'index': $field = new CMS_poly_object_field($_POST["field"]); if (!$field->hasError()) { if (!$field->setValue("indexable", $_POST["indexable"])) { $cms_message .= "\n" . $cms_language->getMessage(MESSAGE_FORM_ERROR_MALFORMED_FIELD, array($cms_language->getMessage(MESSAGE_PAGE_FIELD_FRONTEND))); } else { //save the data $field->writeToPersistence(); $cms_message .= $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE); }
/** * Import module objects from given array datas * * @param array $data The module datas to import * @param array $params The import parameters. * array( * module => false|true : the module to create categories (required) * create => false|true : create missing objects (default : true) * update => false|true : update existing objects (default : true) * files => false|true : use files from PATH_TMP_FS (default : true) * ) * @param CMS_language $cms_language The CMS_langage to use * @param array $idsRelation : Reference : The relations between import datas ids and real imported ids * @param string $infos : Reference : The import infos returned * @return boolean : true on success, false on failure * @access public */ static function fromArray($data, $params, $cms_language, &$idsRelation, &$infos) { if (!isset($params['module'])) { $infos .= 'Error : missing module codename for objects importation ...' . "\n"; return false; } $module = CMS_modulesCatalog::getByCodename($params['module']); if ($module->hasError()) { $infos .= 'Error : invalid module for objects importation : ' . $params['module'] . "\n"; return false; } $return = true; //first create missing objects to get relation ids foreach ($data as $objectDatas) { if (!isset($objectDatas['uuid']) || !CMS_poly_object_catalog::objectExists($params['module'], $objectDatas['uuid'])) { //create new object if we can if (!isset($params['create']) || $params['create'] == true) { //create object $object = new CMS_poly_object_definition(); //set module $object->setValue('module', $params['module']); //set uuid $object->setUuid($objectDatas['uuid']); //write object to persistence to get relations ids $object->writeToPersistence(); //set id translation if (isset($objectDatas['id']) && $objectDatas['id']) { // && $object->getID() != $objectDatas['id']) { // Fix for bug #3157 : in some cases the imported object will have the same id has the newly created, // we still need the relation table otherwise it will fail to link to the new object $idsRelation['objects'][$objectDatas['id']] = $object->getID(); } //set uuid translation if (isset($objectDatas['uuid']) && $objectDatas['uuid'] && $object->getValue('uuid') != $objectDatas['uuid']) { $idsRelation['objects-uuid'][$objectDatas['uuid']] = $object->getValue('uuid'); } } } elseif (isset($objectDatas['uuid']) && isset($objectDatas['id'])) { //get relation between imported object id and local id $id = CMS_poly_object_catalog::objectExists($params['module'], $objectDatas['uuid']); if (io::isPositiveInteger($id)) { $idsRelation['objects'][$objectDatas['id']] = $id; } } } //then import objects datas foreach ($data as $objectDatas) { $importType = ''; if (isset($objectDatas['uuid']) && ($id = CMS_poly_object_catalog::objectExists($params['module'], $objectDatas['uuid']))) { //object already exist : load it if we can update it if (!isset($params['update']) || $params['update'] == true) { $object = CMS_poly_object_catalog::getObjectDefinition($id); $importType = ' (Update)'; //set id translation $idsRelation['objects'][$objectDatas['id']] = $id; } } else { //check for translated id if (isset($objectDatas['id']) && isset($idsRelation['objects'][$objectDatas['id']])) { //object exists with a translated id $objectDatas['id'] = $idsRelation['objects'][$objectDatas['id']]; //load translated object $object = CMS_poly_object_catalog::getObjectDefinition($objectDatas['id']); $importType = ' (Creation)'; } //check for translated uuid if (isset($objectDatas['uuid']) && isset($idsRelation['objects-uuid'][$objectDatas['uuid']])) { //object exists with a translated uuid $objectDatas['uuid'] = $idsRelation['objects-uuid'][$objectDatas['uuid']]; //load translated object if ($id = CMS_poly_object_catalog::objectExists($params['module'], $objectDatas['uuid'])) { $object = CMS_poly_object_catalog::getObjectDefinition($id); $importType = ' (Creation)'; } } } if (isset($object)) { if ($object->fromArray($objectDatas, $params, $cms_language, $idsRelation, $infos)) { $return &= true; $infos .= 'Object "' . $object->getLabel($cms_language) . '" successfully imported' . $importType . "\n"; } else { $return = false; $infos .= 'Error during import of object ' . $objectDatas['id'] . $importType . "\n"; } } } return $return; }
define("MESSAGE_PAGE_OBJECT_INDEXABLE", 325); define("MESSAGE_PAGE_OBJECT_MULTILANGUAGE", 634); define("MESSAGE_PAGE_OBJECT_INDEXATION", 326); define("MESSAGE_PAGE_OBJECT_INDEXABLE_EXPLANATION", 327); define("MESSAGE_PAGE_OBJECT_INDEXATION_LINK_TO", 328); define("MESSAGE_PAGE_OBJECT_INDEXATION_LINK_TO_EXPLANATION", 329); define("MESSAGE_PAGE_FIELD_SEARCH_RESULTS_DISPLAY", 420); define("MESSAGE_PAGE_FIELD_SEARCH_RESULTS_DISPLAY_LEGEND", 421); define("MESSAGE_PAGE_FIELD_OBJECT_SYNTAX", 421); //checks if (!$cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL)) { header("Location: " . PATH_ADMIN_SPECIAL_ENTRY_WR . "?cms_message_id=" . MESSAGE_PAGE_CLEARANCE_ERROR . "&" . session_name() . "=" . session_id()); exit; } $moduleCodename = $_REQUEST["moduleCodename"]; $object = new CMS_poly_object_definition($_REQUEST["object"]); $label = new CMS_object_i18nm($object->getValue("labelID")); $description = new CMS_object_i18nm($object->getValue("descriptionID")); $availableLanguagesCodes = CMS_object_i18nm::getAvailableLanguages(); if ($moduleCodename) { $polymod = CMS_modulesCatalog::getByCodename($moduleCodename); } // **************************************************************** // ** ACTIONS MANAGEMENT ** // **************************************************************** switch ($_POST["cms_action"]) { case "validate": case "switchexplanation": //checks and assignments $cms_message = ""; $object->setDebug(false);
define("MESSAGE_ACTION_OBJECT_STRUCTURE", 1279); define("MESSAGE_PAGE_FIELD_OBJECT", 1234); define("MESSAGE_PAGE_FIELD_OBJECT_USEAGE", 1281); define("MESSAGE_PAGE_FIELD_OBJECT_USED", 1282); define("MESSAGE_PAGE_FIELD_OBJECT_GRAYED_INFOS", 1292); define("MESSAGE_PAGE_FIELD_COMPOSED_LABEL", 1294); define("MESSAGE_PAGE_FIELD_ONLY_FOR_ADMIN", 1276); //Polymod messages define("MESSAGE_PAGE_FIELD_MULTI", 190); //checks if (!$cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL)) { header("Location: " . PATH_ADMIN_SPECIAL_ENTRY_WR . "?cms_message_id=" . MESSAGE_PAGE_CLEARANCE_ERROR . "&" . session_name() . "=" . session_id()); exit; } $moduleCodename = $_POST["moduleCodename"] ? $_POST["moduleCodename"] : $_GET["moduleCodename"]; $object = new CMS_poly_object_definition($_POST["object"]); $availableLanguagesCodes = CMS_object_i18nm::getAvailableLanguages(); $objectsStructure = CMS_poly_module_structure::getModuleStructure($moduleCodename, true); if ($moduleCodename) { $polymod = CMS_modulesCatalog::getByCodename($moduleCodename); } $dialog = new CMS_dialog(); $content = ''; $dialog->setTitle($cms_language->getMessage(MESSAGE_PAGE_TITLE_APPLICATIONS) . " :: " . $polymod->getLabel($cms_language) . " :: " . $cms_language->getMessage(MESSAGE_PAGE_TITLE, array($object->getLabel($cms_language))), 'picto_modules.gif'); $dialog->setBacklink("modules_admin.php?moduleCodename=" . $moduleCodename . "&object=" . $object->getID()); if ($cms_message) { $dialog->setActionMessage($cms_message); } $resourceStatus = array(0 => MESSAGE_PAGE_FIELD_RESOURCE_NONE, 1 => MESSAGE_PAGE_FIELD_RESOURCE_PRIMARY, 2 => MESSAGE_PAGE_FIELD_RESOURCE_SECONDARY); $adminEditableStatus = array(0 => MESSAGE_PAGE_FIELD_YES, 1 => MESSAGE_PAGE_FIELD_NO, 2 => MESSAGE_PAGE_FIELD_ONLY_FOR_ADMIN); $objectUseage = CMS_poly_object_catalog::getObjectUsage($object->getID(), true);
define("MESSAGE_PAGE_FIELD_OBJECT_PARAMETERS", 199); define("MESSAGE_PAGE_WORKING_TAGS", 113); define("MESSAGE_PAGE_WORKING_TAGS_EXPLANATION", 114); define("MESSAGE_PAGE_BLOCK_GENRAL_VARS", 140); define("MESSAGE_PAGE_BLOCK_GENRAL_VARS_EXPLANATION", 139); define("MESSAGE_PAGE_FIELD_PLUGIN_DEF_EXPLANATION", 278); define("MESSAGE_PAGE_PLUGIN_TAG", 287); define("MESSAGE_PAGE_PLUGIN_TAG_EXPLANATION", 288); //checks rights if (!$cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL)) { header("Location: " . PATH_ADMIN_SPECIAL_ENTRY_WR . "?cms_message_id=" . MESSAGE_PAGE_CLEARANCE_ERROR . "&" . session_name() . "=" . session_id()); exit; } //load page objects and vars $moduleCodename = $_POST["moduleCodename"] ? $_POST["moduleCodename"] : $_GET["moduleCodename"]; $object = new CMS_poly_object_definition($_POST["object"]); $pluginDefinition = new CMS_poly_plugin_definitions($_POST["pluginDefinition"]); $label = new CMS_object_i18nm($pluginDefinition->getValue("labelID")); $description = new CMS_object_i18nm($pluginDefinition->getValue("descriptionID")); $availableLanguagesCodes = CMS_object_i18nm::getAvailableLanguages(); if ($moduleCodename) { $polymod = CMS_modulesCatalog::getByCodename($moduleCodename); } $cms_message = ""; // **************************************************************** // ** ACTIONS MANAGEMENT ** // **************************************************************** switch ($_POST["cms_action"]) { case "validate": case "switchexplanation": //checks and assignments