/** 
  * Get the module primary resource definition
  *
  * @return boolean true
  * @access public
  */
 function getPrimaryResourceDefinition()
 {
     if (!$this->_primaryResourceObjectDefinition instanceof CMS_poly_object_definition) {
         $this->_primaryResourceObjectDefinition = CMS_poly_object_catalog::getObjectDefinition(CMS_poly_object_catalog::getPrimaryResourceObjectType($this->getCodename()));
     }
     return true;
 }
Example #2
0
//set default display mode for this page
$view->setDisplayMode(CMS_view::SHOW_JSON);
//This file is an admin file. Interface must be secure
$view->setSecure();
$content = array('success' => false);
//instanciate module
$cms_module = CMS_modulesCatalog::getByCodename($codename);
//CHECKS user has module clearance
if (!$cms_user->hasModuleClearance($codename, CLEARANCE_MODULE_EDIT)) {
    CMS_grandFather::raiseError('Error, user has no rights on module : ' . $codename);
    $view->setContent($content);
    $view->show();
}
//load object
if ($objectId) {
    $object = CMS_poly_object_catalog::getObjectDefinition($objectId);
    $objectLabel = sensitiveIO::sanitizeJSString($object->getLabel($cms_language));
}
if ($objectId && (!isset($object) || $object->hasError())) {
    CMS_grandFather::raiseError('Error, objectId does not exists or has an error : ' . $objectId);
    $view->setContent($content);
    $view->show();
}
if (isset($object)) {
    //load item if any
    if ($itemId) {
        $item = new CMS_poly_object($objectId, $itemId);
        if ($action == 'save' || $action == 'save-validate') {
            $itemLabel = sensitiveIO::sanitizeJSString($item->getLabel());
            if ($object->isPrimaryResource()) {
                //put a lock on the resource or warn user if item is already locked by another user
Example #3
0
 /**
  * Constructor
  * 
  * @access public
  * @param $objectDefinition CMS_poly_object_definition the current search object definition or the ID of the CMS_poly_object_definition
  * @param boolean $public
  */
 function __construct($objectDefinition, $public = false)
 {
     global $cms_user;
     if (io::isPositiveInteger($objectDefinition)) {
         $objectDefinition = CMS_poly_object_catalog::getObjectDefinition($objectDefinition);
     }
     if (!is_a($objectDefinition, 'CMS_poly_object_definition')) {
         $this->raiseError('ObjectDefinition must be a valid CMS_poly_object_definition.');
         return false;
     }
     $this->_object = $objectDefinition;
     // Set public status
     $this->_public = $public;
     //add search object type condition
     $this->addWhereCondition("object", $this->_object);
     //if cms_user exists, check user rights
     if (is_object($cms_user)) {
         $this->addWhereCondition("profile", $cms_user);
     }
     //add resource condition if any
     if ($this->_object->isPrimaryResource()) {
         //if this is a public search, add limitation to resource publications dates
         if ($this->_public) {
             $limitDate = new CMS_date();
             $limitDate->setNow();
             $this->addWhereCondition("publication date before", $limitDate);
             $this->addWhereCondition("publication date end", $limitDate);
         }
     }
 }
 /**
  * Get object Definition (CMS_poly_object_definition)
  *
  * @return CMS_poly_object_definition
  * @access public
  */
 function getObjectDefinition()
 {
     //create cache object
     $cache = new CMS_cache('object' . $this->_objectID, 'atm-polymod-structure', 2592000, false);
     $datas = '';
     if (!$cache->exist() || !($datas = $cache->load())) {
         //datas does not exists : load it
         $datas = CMS_poly_object_catalog::getObjectDefinition($this->_objectID);
         if ($cache) {
             $cache->save($datas, array('type' => 'object'));
         }
     }
     return $datas;
 }
 /**
  * get an object instance of the field type
  *
  * @param boolean $returnDefinition, return object CMS_poly_object_definition or CMS_poly_object otherwise
  * @return mixed, the object instance
  * @access public
  */
 function getTypeObject($returnDefinition = false, $public = false)
 {
     if (!$this->_objectFieldValues['type']) {
         return false;
     }
     if (sensitiveIO::isPositiveInteger($this->_objectFieldValues['type'])) {
         if ($returnDefinition) {
             return CMS_poly_object_catalog::getObjectDefinition($this->_objectFieldValues['type']);
         } else {
             $item = new CMS_poly_object($this->_objectFieldValues['type'], 0, array(), $public);
             //object is used as field as another object so set it
             $item->setField($this);
             return $item;
         }
     } elseif (io::strpos($this->_objectFieldValues['type'], 'multi|') !== false) {
         return new CMS_multi_poly_object(io::substr($this->_objectFieldValues['type'], 6), array(), $this, $public);
     } elseif (class_exists($this->_objectFieldValues['type'])) {
         return new $this->_objectFieldValues['type'](array(), $this, $public);
     }
 }
Example #6
0
 /**
  * Does given user have the requested clearance for this object ?
  * This method is pretty heavy, so if it must be used on a lots of objects, prefer usage of a search on those objects, it is much faster.
  *
  * @param cms_profile_user $user : the user to check clearance
  * @param constant $clearance : the requested clearance to check (default : CLEARANCE_MODULE_VIEW)
  * @param boolean $checkParent : if no categories fields found, check the parent object (if any) to see if it as some (beware this is heavy). Default : false
  * @return boolean
  * @access public
  */
 function userHasClearance($user, $clearance = CLEARANCE_MODULE_VIEW, $checkParent = false)
 {
     if (!$this->_public || APPLICATION_ENFORCES_ACCESS_CONTROL === true) {
         //user is an administrator?
         if ($user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL)) {
             return true;
         }
         //get Object definition
         $objectDef = $this->getObjectDefinition();
         //get module codename
         $polyModuleCodename = $objectDef->getValue('module');
         //check user right on module (check only minimum needed : VIEW, proper right is checked after on category)
         if (!$user->hasModuleClearance($polyModuleCodename, CLEARANCE_MODULE_VIEW)) {
             return false;
         }
         //object has categories fields ?
         $categoriesFields = CMS_poly_object_catalog::objectHasCategories($this->getObjectID());
         $allCategories = array();
         if (!$categoriesFields && !$checkParent) {
             //no categories on object so user has rights
             return true;
         } elseif (!$categoriesFields && $checkParent) {
             //check for module Categories usage
             if (!CMS_poly_object_catalog::moduleHasCategories($polyModuleCodename)) {
                 //no categories used on module : item is viewvable
                 return true;
             }
             //check for a parent for the given object
             if ($objectParentsIDs = CMS_poly_object_catalog::getParentsObject($this->getObjectID())) {
                 $found = false;
                 //check object for each parent objects found
                 foreach ($objectParentsIDs as $objectParentID => $objectParentFields) {
                     $categoriesFields = CMS_poly_object_catalog::objectHasCategories($objectParentID);
                     if (is_array($categoriesFields) && $categoriesFields) {
                         //load current object definition
                         $object = CMS_poly_object_catalog::getObjectDefinition($objectParentID);
                         foreach ($objectParentFields as $fieldID) {
                             $search = new CMS_object_search($object, $this->_public);
                             $search->addWhereCondition($fieldID, $this->getID());
                             $ids = $search->search(CMS_object_search::POLYMOD_SEARCH_RETURN_IDS);
                             $found = $ids ? true : $found;
                         }
                     }
                 }
                 //if one parent was found then object is visible
                 return $found;
             } else {
                 //no parent object for this object, item is viewvable
                 return true;
             }
         } elseif (is_array($categoriesFields) && $categoriesFields) {
             $search = new CMS_object_search($objectDef, $clearance == CLEARANCE_MODULE_VIEW);
             $search->addWhereCondition('item', $this->getID());
             $search->addWhereCondition("profile", $user);
             $ids = $search->search(CMS_object_search::POLYMOD_SEARCH_RETURN_IDS);
             return $ids ? true : false;
         }
     }
     //user has clearance
     return true;
 }
Example #7
0
            }
        }
    }
    if ($blockVarContent) {
        $items[] = array('title' => $cms_language->getMessage(MESSAGE_VAR_SUBTITLE, null, MOD_POLYMOD_CODENAME), 'xtype' => 'fieldset', 'autoHeight' => true, 'defaults' => array('anchor' => '97%'), 'items' => $blockVarContent);
    }
}
if (isset($blockParamsDefinition['search'])) {
    foreach ($blockParamsDefinition['search'] as $searchName => $searchParams) {
        $searchType = $searchParams['searchType'];
        unset($searchParams['searchType']);
        if (!$searchParams) {
            continue;
        }
        //load searched object
        $object = CMS_poly_object_catalog::getObjectDefinition($searchType);
        if (!$object->hasError()) {
            //load fields objects for object
            $objectFields = CMS_poly_object_catalog::getFieldsDefinition($object->getID());
            $searchParamContent = array();
            foreach ($searchParams as $paramType => $paramValue) {
                $rowParams[] = $paramType;
                switch ($paramType) {
                    case 'item':
                        $mandatory = $paramValue == true ? '<span class="atm-red">*</span> ' : '';
                        $value = isset($data["value"]['search'][$searchName][$paramType]) ? $data["value"]['search'][$searchName][$paramType] : '';
                        $searchParamContent[] = array('fieldLabel' => $mandatory . $object->getLabel($cms_language), 'name' => 'value[search][' . $searchName . '][' . $paramType . ']', 'hiddenName' => 'value[search][' . $searchName . '][' . $paramType . ']', 'anchor' => '99%', 'xtype' => 'atmCombo', 'forceSelection' => true, 'mode' => 'remote', 'valueField' => 'id', 'displayField' => 'label', 'triggerAction' => 'all', 'allowBlank' => !$mandatory, 'selectOnFocus' => true, 'editable' => true, 'typeAhead' => true, 'value' => $value, 'store' => array('url' => PATH_ADMIN_MODULES_WR . '/' . MOD_POLYMOD_CODENAME . '/list-objects.php', 'baseParams' => array('objectId' => $object->getID(), 'module' => $codename), 'root' => 'objects', 'fields' => array('id', 'label')));
                        break;
                    case 'keywords':
                        // Keywords
                        $mandatory = $paramValue == true ? '<span class="atm-red">*</span> ' : '';
Example #8
0
 /**
  * Get search results objects for module by Id
  *
  * @param array : the results score ids
  * @return array : results elements (cms_page)
  * @access public
  */
 function getSearchResults($resultsIds, &$user)
 {
     if (!$resultsIds || !is_array($resultsIds)) {
         return array();
     }
     $cms_language = $user->getLanguage();
     //get results object types
     $sql = "\n\t\t\tselect\n\t\t\t\tobject_type_id_moo as type, id_moo as id\n\t\t\tfrom\n\t\t\t\tmod_object_polyobjects\n\t\t\twhere\n\t\t\t\tid_moo in (" . sensitiveIO::sanitizeSQLString(implode(',', $resultsIds)) . ")\n\t\t";
     $q = new CMS_query($sql);
     $resultsType = array();
     while ($r = $q->getArray()) {
         $resultsType[$r['type']][] = $r['id'];
     }
     $results = array();
     foreach ($resultsType as $type => $ids) {
         //load current object definition
         $object = CMS_poly_object_catalog::getObjectDefinition($type);
         //create search object for current object
         $search = new CMS_object_search($object);
         $search->addWhereCondition("items", $ids);
         $search->search(CMS_object_search::POLYMOD_SEARCH_RETURN_INDIVIDUALS_OBJECTS);
         //launch search
         $objectLabel = $object->getLabel($cms_language);
         // Check if need to use a specific display for search results
         $resultsDefinition = $object->getValue('resultsDefinition');
         if ($resultsDefinition) {
             $definitionParsing = new CMS_polymod_definition_parsing($resultsDefinition, true, CMS_polymod_definition_parsing::PARSE_MODE);
             $itemsResourcesFiles = '';
             // Add specific css and js files we use the resultsDefinition
             if (file_exists(PATH_CSS_FS . '/modules/' . $this->getCodename() . '.css')) {
                 $itemsResourcesFiles .= '<link rel="stylesheet" type="text/css" href="' . PATH_CSS_WR . '/modules/' . $this->getCodename() . '.css" />';
             }
             $jsFiles = $this->getJSFiles();
             if ($jsFiles) {
                 foreach ($jsFiles as $jsfile) {
                     $itemsResourcesFiles .= '<script type="text/javascript" src="' . $jsfile . '"></script>' . "\n";
                 }
             }
         } else {
             //load fields objects for object
             $objectFields = CMS_poly_object_catalog::getFieldsDefinition($object->getID());
         }
         //loop on results items
         while ($item = $search->getNextResult()) {
             //Resource related informations
             $htmlStatus = $pubRange = '';
             $lock = $deleted = $primaryResource = false;
             if ($object->isPrimaryResource()) {
                 $status = $item->getStatus();
                 if (is_object($status)) {
                     $htmlStatus = $status->getHTML(false, $user, $this->getCodename(), $item->getID());
                     $pubRange = $status->getPublicationRange($cms_language);
                     $lock = $item->getLock();
                     $deleted = $item->getProposedLocation() == RESOURCE_LOCATION_DELETED;
                 }
                 $primaryResource = true;
             }
             //Edit
             $edit = false;
             if (!$deleted && (!$lock || $lock == $user->getUserId())) {
                 $edit = array('url' => PATH_ADMIN_MODULES_WR . '/' . MOD_POLYMOD_CODENAME . '/item.php', 'type' => 'window', 'params' => array('module' => $this->getCodename(), 'type' => $type, 'item' => $item->getID()));
             }
             //Previz
             $view = false;
             if ($object->getValue("previewURL")) {
                 $view = array('url' => $item->getPrevizPageURL(), 'type' => 'frame');
             }
             //HTML description
             $description = POLYMOD_DEBUG ? '<span class="atm-text-alert"> (ID : ' . $item->getID() . ')</span>' : '';
             if ($resultsDefinition) {
                 //set execution parameters
                 $parameters = array();
                 $parameters['module'] = $this->getCodename();
                 $parameters['objectID'] = $object->getID();
                 $parameters['public'] = false;
                 $parameters['item'] = $item;
                 $description .= $definitionParsing->getContent(CMS_polymod_definition_parsing::OUTPUT_RESULT, $parameters);
                 if ($itemsResourcesFiles) {
                     $description = $itemsResourcesFiles . $description;
                 }
             } else {
                 $itemFieldsObjects = $item->getFieldsObjects();
                 //Add all needed fields to description
                 foreach ($itemFieldsObjects as $fieldID => $itemField) {
                     //if field is a poly object
                     if ($objectFields[$fieldID]->getValue('searchlist')) {
                         $description .= $objectFields[$fieldID]->getLabel($cms_language) . ' : <strong>' . $itemField->getHTMLDescription() . '</strong><br />';
                     }
                 }
             }
             $results[$item->getID()] = array('id' => $item->getID(), 'type' => $objectLabel, 'status' => $htmlStatus, 'pubrange' => $pubRange, 'label' => $item->getLabel(), 'description' => $description, 'resource' => $primaryResource ? array('module' => $this->getCodename(), 'resource' => $item->getID(), 'action' => 'unlock') : false, 'edit' => $edit, 'view' => $view);
         }
     }
     return $results;
 }
 /**
  * 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;
 }
 /**
  * This function is called to catch and launch all FE forms actions
  *
  * @param array $formIDs : the forms ids to check for actions
  * @param integer $pageID : the current page id
  * @param boolean $public : the data status
  * @param string $languageCode : the language code used
  * @param reference array $polymodFormsError : the forms error status to return
  * @param reference array $polymodFormsItem : reference to the forms item
  * @return boolean : true on success, false on failure
  * @access public
  * @static
  */
 static function formActions($formIDs, $pageID, $languageCode, $public, &$polymodFormsError, &$polymodFormsItems)
 {
     global $cms_language, $cms_user;
     if (!is_array($formIDs)) {
         return false;
     }
     foreach ($formIDs as $formID) {
         if (io::request('formID') && io::request('formID') == $formID) {
             if (!isset($cms_language) || $cms_language->getCode() != $languageCode) {
                 $cms_language = new CMS_language($languageCode);
             }
             //instanciate item
             $item = '';
             if (io::request('object', 'io::isPositiveInteger', '')) {
                 //check user rights on module
                 $module = CMS_poly_object_catalog::getModuleCodenameForObjectType(io::request('object'));
                 //Check user rights
                 //here assume than user should only need the view right on module, because admin right allow Automne administration access
                 if (!is_object($cms_user) || !$cms_user->hasModuleClearance($module, CLEARANCE_MODULE_VIEW)) {
                     CMS_grandFather::raiseError('No user found or user has no administration rights on module ' . $module);
                     return false;
                 }
                 //instanciate object
                 $object = CMS_poly_object_catalog::getObjectDefinition(io::request('object'));
                 if ($object && io::request('item', 'io::isPositiveInteger', '')) {
                     $search = new CMS_object_search($object, false);
                     $search->addWhereCondition('item', io::request('item'));
                     $items = $search->search();
                     if (isset($items[io::request('item')])) {
                         $item = $items[io::request('item')];
                     } else {
                         $item = new CMS_poly_object($object->getID());
                     }
                 } else {
                     $item = new CMS_poly_object($object->getID());
                 }
             }
             if (is_object($item) && !$item->hasError()) {
                 //get item fieldsObjects
                 $fieldsObjects =& $item->getFieldsObjects();
                 //checks and assignments
                 $item->setDebug(false);
                 //first, check mandatory values
                 foreach ($fieldsObjects as $fieldID => $aFieldObject) {
                     //if field is part of formular
                     if (isset($_REQUEST['polymodFields'][$fieldID])) {
                         if (!$item->checkMandatory($fieldID, $_REQUEST, '')) {
                             $polymodFormsError[$formID]['required'][$fieldID] = $fieldID;
                         }
                     }
                 }
                 //second, set values for all fields
                 foreach ($fieldsObjects as $fieldID => $aFieldObject) {
                     //if field is part of formular
                     if (isset($_REQUEST['polymodFields'][$fieldID])) {
                         //if form use a callback, call it
                         //do not use call_user_function here
                         $funcName = 'form_' . $formID . '_' . $fieldID;
                         if (!$item->setValues($fieldID, $_REQUEST, '')) {
                             $polymodFormsError[$formID]['malformed'][] = $fieldID;
                         } elseif (!isset($polymodFormsError[$formID]['required'][$fieldID]) && function_exists('form_' . $formID . '_' . $fieldID) && !$funcName($formID, $fieldID, $item)) {
                             $polymodFormsError[$formID]['malformed'][] = $fieldID;
                         }
                     }
                 }
                 //set publication dates if needed
                 if (isset($_REQUEST['polymodFields']) && $_REQUEST['polymodFields']) {
                     if ($object->isPrimaryResource()) {
                         // Dates management
                         $dt_beg = new CMS_date();
                         $dt_beg->setDebug(false);
                         $dt_beg->setFormat($cms_language->getDateFormat());
                         $dt_end = new CMS_date();
                         $dt_end->setDebug(false);
                         $dt_end->setFormat($cms_language->getDateFormat());
                         if (!($dt_set_1 = $dt_beg->setLocalizedDate(@$_REQUEST["pub_start"], true))) {
                             $polymodFormsError[$formID]['malformed'][] = 'pub_start';
                         }
                         if (!($dt_set_2 = $dt_end->setLocalizedDate(@$_REQUEST["pub_end"], true))) {
                             $polymodFormsError[$formID]['malformed'][] = 'pub_end';
                         }
                         //if $dt_beg && $dt_end, $dt_beg must be lower than $dt_end
                         if (!$dt_beg->isNull() && !$dt_end->isNull()) {
                             if (CMS_date::compare($dt_beg, $dt_end, '>')) {
                                 $polymodFormsError[$formID]['malformed'][] = 'pub_start';
                                 $polymodFormsError[$formID]['malformed'][] = 'pub_end';
                                 $dt_set_1 = $dt_set_2 = false;
                             }
                         }
                         if ($dt_set_1 && $dt_set_2) {
                             $item->setPublicationDates($dt_beg, $dt_end);
                         }
                     }
                 }
                 //Check form token
                 if (!isset($_POST["atm-token"]) || !CMS_session::checkToken(MOD_POLYMOD_CODENAME . '-' . $formID, $_POST["atm-token"])) {
                     $polymodFormsError[$formID]['error'][] = 'form-token';
                     return false;
                 } else {
                     //Token is used so expire it
                     CMS_session::expireToken(MOD_POLYMOD_CODENAME . '-' . $formID);
                 }
                 if (!$polymodFormsError[$formID]) {
                     //save the data
                     if (!$item->writeToPersistence()) {
                         $polymodFormsError[$formID]['error'][] = 'write';
                         $polymodFormsError[$formID]['filled'] = 0;
                     } else {
                         $polymodFormsError[$formID]['filled'] = 1;
                         //if form use a callback, call it
                         //do not use call_user_function here
                         $funcName = 'form_' . $formID;
                         if (function_exists('form_' . $formID) && !$funcName($formID, $item)) {
                             $polymodFormsError[$formID]['filled'] = 0;
                             $polymodFormsError[$formID]['error'][] = 'callback';
                         }
                     }
                     //if item is a primary resource, unlock it
                     if ($object->isPrimaryResource()) {
                         $item->unlock();
                     }
                 } else {
                     $polymodFormsError[$formID]['filled'] = 0;
                 }
                 //save item for later use
                 $polymodFormsItems[$formID] = $item;
             } else {
                 $polymodFormsError[$formID]['filled'] = 0;
                 $polymodFormsError[$formID]['error'][] = 'right';
                 CMS_grandFather::raiseError('No item found or user has no administration rights on item... ');
                 return false;
             }
         }
     }
     return true;
 }
 /**
  * Return a recursive structure of all objects of a given module
  *
  * @param array $structure the flat structure of all objects (function recurse on this value)
  * @param array $structure the flat structure reference of all objects
  * @param mixed $infos if array : reference of objects infos else nothing
  * @return multidimensionnal array : the recursive structure of all objects of the given module
  * @access private
  * @static
  */
 protected function _createRecursiveStructure($structure, $flatStructure, &$infos)
 {
     if ($structure) {
         foreach ($structure as $key => $value) {
             if (is_array($value)) {
                 $structure[$key] = CMS_poly_module_structure::_createRecursiveStructure($value, $flatStructure, $infos);
             } elseif (io::strpos($value, "multi|") !== false) {
                 $structure[$key] = array('multiobject' . io::substr($value, 6) => CMS_poly_module_structure::_createRecursiveStructure($flatStructure['object' . io::substr($value, 6)], $flatStructure, $infos));
             } elseif (sensitiveIO::isPositiveInteger($value)) {
                 $structure[$key] = array('object' . $value => CMS_poly_module_structure::_createRecursiveStructure($flatStructure['object' . $value], $flatStructure, $infos));
             }
             if (is_array($infos) && !isset($infos[$key])) {
                 if (io::strpos($key, "field") !== false) {
                     $infos[$key] = new CMS_poly_object_field(io::substr($key, 5));
                     if (!sensitiveIO::isPositiveInteger($value) && io::strpos($value, "multi|") === false && class_exists($value)) {
                         $infos[$value] = new $value(array(), $infos[$key]);
                     }
                 } elseif (io::strpos($key, "object") !== false) {
                     $infos[$key] = CMS_poly_object_catalog::getObjectDefinition(io::substr($key, 6));
                 }
             }
         }
     }
     return $structure;
 }
define("MESSAGE_PAGE_FIELD_FREQUENCY", 305);
define("MESSAGE_PAGE_FIELD_HOURLY", 306);
define("MESSAGE_PAGE_FIELD_DAILY", 307);
define("MESSAGE_PAGE_FIELD_WEEKLY", 308);
define("MESSAGE_PAGE_FIELD_MONTHLY", 309);
define("MESSAGE_PAGE_FIELD_YEARLY", 310);
define("MESSAGE_PAGE_FIELD_NAMESPACE", 645);
define("MESSAGE_PAGE_FIELD_NAMESPACE_EXPLANATION", 646);
//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 = CMS_poly_object_catalog::getObjectDefinition($_POST["object"]);
$RSSDefinition = new CMS_poly_rss_definitions($_POST["RSSDefinition"]);
$label = new CMS_object_i18nm($RSSDefinition->getValue("labelID"));
$description = new CMS_object_i18nm($RSSDefinition->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