Example #1
0
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);
        }
    case 'switchexplanation':
Example #2
0
     $mandatory = $paramValue == true ? '<span class="atm-red">*</span> ' : '';
     $value = isset($data["value"]['search'][$searchName][$paramType]) ? $data["value"]['search'][$searchName][$paramType] : '';
     $searchParamContent[] = array('fieldLabel' => $mandatory . $cms_language->getMessage(MESSAGE_PAGE_FIELD_LIMIT, false, MOD_POLYMOD_CODENAME), 'name' => 'value[search][' . $searchName . '][' . $paramType . ']', 'anchor' => '99%', 'allowNegative' => false, 'allowDecimals' => false, 'xtype' => 'numberfield', 'allowBlank' => !$mandatory, 'value' => $value);
     break;
 case 'order':
     if (sizeof($paramValue)) {
         $orderNameList = array('objectID' => MESSAGE_PAGE_FIELD_ORDER_OBJECTID, 'random' => MESSAGE_PAGE_FIELD_ORDER_RANDOM, 'publication date after' => MESSAGE_PAGE_FIELD_ORDER_PUBLICATION_START, 'publication date before' => MESSAGE_PAGE_FIELD_ORDER_PUBLICATION_END);
         $searchOrderContent = array();
         foreach ($paramValue as $orderName => $orderValue) {
             $fieldLabel = '';
             if (in_array($orderName, CMS_object_search::getStaticOrderConditionTypes())) {
                 $fieldLabel = $cms_language->getMessage($orderNameList[$orderName], false, MOD_POLYMOD_CODENAME);
             } else {
                 $orderName = trim($orderName, '()');
                 if (io::isPositiveInteger($orderName)) {
                     $field = new CMS_poly_object_field($orderName);
                     if ($field && !$field->hasError()) {
                         $label = new CMS_object_i18nm($field->getValue('labelID'));
                         $fieldLabel = $label->getValue($cms_language->getCode());
                     }
                 }
             }
             if ($fieldLabel) {
                 // Order direction
                 $mandatory = $paramValue == true ? '<span class="atm-red">*</span> ' : '';
                 $value = isset($data["value"]['search'][$searchName][$paramType][$orderName]) ? $data["value"]['search'][$searchName][$paramType][$orderName] : '';
                 $searchOrderContent[] = array('xtype' => 'atmCombo', 'fieldLabel' => $mandatory . $fieldLabel, 'name' => 'value[search][' . $searchName . '][' . $paramType . '][' . $orderName . ']', 'hiddenName' => 'value[search][' . $searchName . '][' . $paramType . '][' . $orderName . ']', 'forceSelection' => true, 'mode' => 'local', 'valueField' => 'id', 'displayField' => 'name', 'triggerAction' => 'all', 'allowBlank' => !$mandatory, 'selectOnFocus' => true, 'editable' => false, 'value' => $value, 'store' => array('xtype' => 'arraystore', 'fields' => array('id', 'name'), 'data' => array(array('', '-'), array('asc', $cms_language->getMessage(MESSAGE_PAGE_FIELD_ORDER_ASC, false, MOD_POLYMOD_CODENAME)), array('desc', $cms_language->getMessage(MESSAGE_PAGE_FIELD_ORDER_DESC, false, MOD_POLYMOD_CODENAME)))));
             } else {
                 $cms_message .= $cms_language->getMessage(MESSAGE_PAGE_SEARCH_ORDERTYPE_ERROR, array($searchName, $row->getLabel(), $orderName), MOD_POLYMOD_CODENAME) . "\n";
             }
         }
Example #3
0
 /**
  * Get all selected recipients for the field
  * @return array of usersIds which are recipients of the notification
  * @access public
  */
 private function _getRecipients($objectID)
 {
     $params = $this->getParamsValues();
     $recipients = array();
     if (isset($params['usersGroupsField']) && $params['usersGroupsField']) {
         //instanciate related item
         $item = CMS_poly_object_catalog::getObjectByID($objectID, false, true);
         if (!is_object($item) || $item->hasError()) {
             return $recipients;
         }
         //does selected field represent users or groups ?
         $field = new CMS_poly_object_field($params['usersGroupsField']);
         $isGroup = $field->getParameter('isGroup');
         //get item field value
         $ids = $item->objectValues($params['usersGroupsField'])->getValue('ids');
         if (!$ids) {
             return array();
         }
         //get users ids
         if ($isGroup) {
             foreach ($ids as $groupId) {
                 $usersIds = CMS_profile_usersGroupsCatalog::getGroupUsers($groupId, false);
                 foreach ($usersIds as $userId) {
                     $recipients[$userId] = $userId;
                 }
             }
         } else {
             $recipients = $ids;
         }
     } else {
         //get all active users ids
         $allUsers = CMS_profile_usersCatalog::getAll(true, false, false);
         //check if user is in included or excluded parameters lists
         $selectedGroups = $params['disableGroups'] ? explode(';', $params['disableGroups']) : array();
         $selectedUsers = $params['disableUsers'] ? explode(';', $params['disableUsers']) : array();
         //check all users to see if it match selection parameters
         foreach ($allUsers as $userId) {
             if ($params['includeExclude']) {
                 //user must be in selected groups or users to get email
                 $userSelected = false;
                 if (is_array($selectedGroups) && $selectedGroups) {
                     foreach ($selectedGroups as $groupId) {
                         if (CMS_profile_usersGroupsCatalog::userBelongsToGroup($userId, $groupId)) {
                             $userSelected = true;
                         }
                     }
                 }
                 if (is_array($selectedUsers) && $selectedUsers && in_array($userId, $selectedUsers)) {
                     $userSelected = true;
                 }
             } else {
                 //user must NOT be in selected groups or users to get email
                 $userSelected = true;
                 if (is_array($selectedGroups) && $selectedGroups) {
                     foreach ($selectedGroups as $groupId) {
                         if (CMS_profile_usersGroupsCatalog::userBelongsToGroup($userId, $groupId)) {
                             $userSelected = false;
                         }
                     }
                 }
                 if (is_array($selectedUsers) && $selectedUsers && in_array($userId, $selectedUsers)) {
                     $userSelected = false;
                 }
             }
             if ($userSelected) {
                 $recipients[] = $userId;
             }
         }
     }
     return $recipients;
 }
Example #4
0
         }
     }
     break;
 case 'deleteObject':
     if ($object->destroy()) {
         unset($object);
         unset($objectID);
         //unset fields catalog in cache
         CMS_cache::clearTypeCacheByMetas('atm-polymod-structure', array('type' => 'fields'));
         $cms_message .= $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE);
     } else {
         $cms_message .= $cms_language->getMessage(MESSAGE_ACTION_DELETE_OBJECT_ERROR);
     }
     break;
 case "delete":
     $field = new CMS_poly_object_field($_POST["field"]);
     if (!$field->hasError() && $field->destroy()) {
         //then reload object
         if (sensitiveIO::IsPositiveInteger($objectID)) {
             $object = new CMS_poly_object_definition($objectID);
         }
         $cms_message .= $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE);
     } else {
         $cms_message .= $cms_language->getMessage(MESSAGE_ACTION_DELETE_FIELD_ERROR);
     }
     break;
 case 'deleteRSS':
     $RSSDefinition = new CMS_poly_rss_definitions($_POST['RSSDefinition']);
     $RSSDefinition->destroy();
     $cms_message .= $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE);
     break;
 /**
  * Import object from given array datas
  *
  * @param array $data The object datas to import
  * @param array $params The import parameters.
  *		array(
  *				module	=> false|true : the module to create object (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
  */
 function fromArray($data, $params, $cms_language, &$idsRelation, &$infos)
 {
     if (!isset($params['module'])) {
         $infos .= 'Error : missing module codename for object importation ...' . "\n";
         return false;
     }
     $module = CMS_modulesCatalog::getByCodename($params['module']);
     if ($module->hasError()) {
         $infos .= 'Error : invalid module for object importation : ' . $params['module'] . "\n";
         return false;
     }
     if (!$this->getID() && CMS_poly_object_catalog::objectUuidExists($data['uuid'])) {
         //check imported uuid. If objects does not have an Id, the uuid must be unique or must be regenerated
         $uuid = io::uuid();
         //store old uuid relation
         $idsRelation['objects-uuid'][$data['uuid']] = $uuid;
         $data['uuid'] = $uuid;
     }
     //set object uuid if not exists
     if (!$this->_objectValues["uuid"]) {
         $this->_objectValues["uuid"] = $data['uuid'];
     }
     if (isset($data['labels'])) {
         $label = new CMS_object_i18nm($this->getValue("labelID"));
         $label->setValues($data['labels']);
         $label->writeToPersistence();
         $this->setValue("labelID", $label->getID());
     }
     if (isset($data['descriptions'])) {
         $description = new CMS_object_i18nm($this->getValue("descriptionID"));
         $description->setValues($data['descriptions']);
         $description->writeToPersistence();
         $this->setValue("descriptionID", $description->getID());
     }
     if (isset($data['params']['resourceUsage'])) {
         $this->setValue("resourceUsage", $data['params']['resourceUsage']);
     }
     if (isset($data['params']['admineditable'])) {
         $this->setValue("admineditable", $data['params']['admineditable']);
     }
     if (isset($data['params']['indexable'])) {
         $this->setValue("indexable", $data['params']['indexable']);
     }
     if (isset($data['params']['multilanguage'])) {
         $this->setValue("multilanguage", $data['params']['multilanguage']);
     }
     if (isset($data['params']['composedLabel'])) {
         $this->setValue("composedLabel", $module->convertDefinitionString($data['params']['composedLabel'], false));
     }
     if (isset($data['params']['previewURL'])) {
         $this->setValue("previewURL", $module->convertDefinitionString($data['params']['previewURL'], false));
     }
     if (isset($data['params']['indexURL'])) {
         $this->setValue("indexURL", $module->convertDefinitionString($data['params']['indexURL'], false));
     }
     if (isset($data['params']['resultsDefinition'])) {
         $this->setValue("resultsDefinition", $module->convertDefinitionString($data['params']['resultsDefinition'], false));
     }
     //write object
     if (!$this->writeToPersistence()) {
         $infos .= 'Error : can not write object ...' . "\n";
         return false;
     }
     //if current object id has changed from imported id, set relation
     if (isset($data['id']) && $data['id'] && $this->getID() != $data['id']) {
         $idsRelation['objects'][$data['id']] = $this->getID();
     }
     //set this object into definition to convert array so it can be converted again at end of import process
     $idsRelation['definitionToConvert'][] = $this;
     $return = true;
     //object fields
     if (isset($data['fields'])) {
         foreach ($data['fields'] as $fieldDatas) {
             $importType = '';
             if (isset($fieldDatas['type'])) {
                 if (isset($fieldDatas['uuid']) && ($id = CMS_poly_object_catalog::fieldExists($params['module'], $fieldDatas['uuid']))) {
                     //field already exist : load it if we can update it
                     if (!isset($params['update']) || $params['update'] == true) {
                         $field = new CMS_poly_object_field($id);
                         $importType = ' (Update)';
                     }
                 } else {
                     //create new field if we can
                     if (!isset($params['create']) || $params['create'] == true) {
                         $field = new CMS_poly_object_field();
                         $importType = ' (Creation)';
                     }
                 }
                 if (isset($field)) {
                     if ($field->fromArray($fieldDatas, $params, $cms_language, $idsRelation, $infos)) {
                         $return &= true;
                         $infos .= 'Field "' . $field->getLabel($cms_language) . '" successfully imported' . $importType . "\n";
                     } else {
                         $return = false;
                         $infos .= 'Error during import of field ...' . $importType . "\n";
                     }
                 }
             } else {
                 $return = false;
                 $infos .= 'Error during import of field : missing type' . "\n";
             }
         }
     }
     //object rss feeds
     if (isset($data['rss'])) {
         foreach ($data['rss'] as $rssDatas) {
             $importType = '';
             if (isset($rssDatas['uuid']) && ($id = CMS_poly_object_catalog::rssExists($params['module'], $rssDatas['uuid']))) {
                 //rss already exist : load it if we can update it
                 if (!isset($params['update']) || $params['update'] == true) {
                     $rss = new CMS_poly_rss_definitions($id);
                     $importType = ' (Update)';
                 }
             } else {
                 //create new rss if we can
                 if (!isset($params['create']) || $params['create'] == true) {
                     $rss = new CMS_poly_rss_definitions();
                     $importType = ' (Creation)';
                 }
             }
             if (isset($rss)) {
                 if ($rss->fromArray($rssDatas, $params, $cms_language, $idsRelation, $infos)) {
                     $return &= true;
                     $infos .= 'RSS feed "' . $rss->getLabel($cms_language) . '" successfully imported' . $importType . "\n";
                 } else {
                     $return = false;
                     $infos .= 'Error during import of rss feed ...' . $importType . "\n";
                 }
             }
         }
     }
     //plugins wysiwyg
     if (isset($data['plugins'])) {
         foreach ($data['plugins'] as $pluginDatas) {
             $importType = '';
             if (isset($pluginDatas['uuid']) && ($id = CMS_poly_object_catalog::pluginExists($params['module'], $pluginDatas['uuid']))) {
                 //plugin already exist : load it if we can update it
                 if (!isset($params['update']) || $params['update'] == true) {
                     $plugin = new CMS_poly_plugin_definitions($id);
                     $importType = ' (Update)';
                 }
             } else {
                 //create new plugin if we can
                 if (!isset($params['create']) || $params['create'] == true) {
                     $plugin = new CMS_poly_plugin_definitions();
                     $importType = ' (Creation)';
                 }
             }
             if (isset($plugin)) {
                 if ($plugin->fromArray($pluginDatas, $params, $cms_language, $idsRelation, $infos)) {
                     $return &= true;
                     $infos .= 'Plugin Wysiwyg "' . $plugin->getLabel($cms_language) . '" successfully imported' . $importType . "\n";
                 } else {
                     $return = false;
                     $infos .= 'Error during import of plugin wysiwyg ...' . $importType . "\n";
                 }
             }
         }
     }
     return $return;
 }
 /**
  * Get an object for a given moduleDetailledStructurePath
  *
  * @param string $value : the value to convert
  * @return string : the converted value
  * @access public
  * @static
  */
 function getObjectForDetailledStructurePath($detailledPath)
 {
     if (io::strpos($detailledPath, 'fields') !== false) {
         $replace = array("#\\[([0-9]+)\\]\$#U" => '\\1');
         if (preg_match("#\\[([0-9]+)\\]\$#U", $detailledPath, $match)) {
             $field = new CMS_poly_object_field($match[1]);
             return $field->getTypeObject();
         } else {
             CMS_grandFather::raiseError("Malformed detailledStructurePath : " . $detailledPath);
             return false;
         }
     } elseif (io::strpos($detailledPath, '[\'object') === 0) {
         return new CMS_poly_object(io::substr($detailledPath, 8, -2));
     } else {
         CMS_grandFather::raiseError("Malformed detailledStructurePath : " . $detailledPath);
         return false;
     }
 }