/** * Writes the page into persistence (MySQL for now), along with base data. * * @return boolean true on success, false on failure * @access public */ function writeToPersistence() { parent::writeToPersistence(); $isNew = $this->_pageID === NULL; // Inform modules of the page creation $modules = CMS_modulesCatalog::getAll('id'); foreach ($modules as $codename => $module) { if (method_exists($module, 'pagePreSave')) { $module->pagePreSave($this, $isNew); } } //save page data $sql_fields = "\n\t\t\tresource_pag='" . parent::getID() . "',\n\t\t\tremindedEditorsStack_pag='" . SensitiveIO::sanitizeSQLString($this->_remindedEditors->getTextDefinition()) . "',\n\t\t\tlastReminder_pag='" . $this->_lastReminder->getDBValue() . "',\n\t\t\ttemplate_pag='" . $this->_templateID . "',\n\t\t\tlastFileCreation_pag='" . $this->_lastFileCreation->getDBValue() . "',\n\t\t\turl_pag='" . SensitiveIO::sanitizeSQLString($this->_pageURL) . "',\n\t\t\tprotected_pag='" . ($this->_protected ? 1 : 0) . "',\n\t\t\thttps_pag='" . ($this->_https ? 1 : 0) . "'\n\t\t"; if ($this->_pageID) { $sql = "\n\t\t\t\tupdate\n\t\t\t\t\tpages\n\t\t\t\tset\n\t\t\t\t\t" . $sql_fields . "\n\t\t\t\twhere\n\t\t\t\t\tid_pag='" . $this->_pageID . "'\n\t\t\t"; } else { $sql = "\n\t\t\t\tinsert into\n\t\t\t\t\tpages\n\t\t\t\tset\n\t\t\t\t\t" . $sql_fields; } $q = new CMS_query($sql); if ($q->hasError()) { return false; } elseif (!$this->_pageID) { $this->_pageID = $q->getLastInsertedID(); } //save base data if modified if ($this->_editedBaseData) { $sql_fields = "\n\t\t\t\tpage_pbd='" . $this->_pageID . "',\n\t\t\t\ttitle_pbd='" . SensitiveIO::sanitizeSQLString($this->_editedBaseData["title"]) . "',\n\t\t\t\tlinkTitle_pbd='" . SensitiveIO::sanitizeSQLString($this->_editedBaseData["linkTitle"]) . "',\n\t\t\t\tkeywords_pbd='" . SensitiveIO::sanitizeSQLString($this->_editedBaseData["keywords"]) . "',\n\t\t\t\tdescription_pbd='" . SensitiveIO::sanitizeSQLString($this->_editedBaseData["description"]) . "',\n\t\t\t\treminderPeriodicity_pbd='" . SensitiveIO::sanitizeSQLString($this->_editedBaseData["reminderPeriodicity"]) . "',\n\t\t\t\treminderOn_pbd='" . $this->_editedBaseData["reminderOn"]->getDBValue() . "',\n\t\t\t\treminderOnMessage_pbd='" . SensitiveIO::sanitizeSQLString($this->_editedBaseData["reminderOnMessage"]) . "',\n\t\t\t\tcategory_pbd='" . SensitiveIO::sanitizeSQLString($this->_editedBaseData["category"]) . "',\n\t\t\t\tauthor_pbd='" . SensitiveIO::sanitizeSQLString($this->_editedBaseData["author"]) . "',\n\t\t\t\treplyto_pbd='" . SensitiveIO::sanitizeSQLString($this->_editedBaseData["replyto"]) . "',\n\t\t\t\tcopyright_pbd='" . SensitiveIO::sanitizeSQLString($this->_editedBaseData["copyright"]) . "',\n\t\t\t\tlanguage_pbd='" . SensitiveIO::sanitizeSQLString($this->_editedBaseData["language"]) . "',\n\t\t\t\trobots_pbd='" . SensitiveIO::sanitizeSQLString($this->_editedBaseData["robots"]) . "',\n\t\t\t\tpragma_pbd='" . SensitiveIO::sanitizeSQLString($this->_editedBaseData["pragma"]) . "',\n\t\t\t\trefresh_pbd='" . SensitiveIO::sanitizeSQLString($this->_editedBaseData["refresh"]) . "',\n\t\t\t\tredirect_pbd='" . SensitiveIO::sanitizeSQLString($this->_editedBaseData["redirect"]->getTextDefinition()) . "',\n\t\t\t\trefreshUrl_pbd='" . SensitiveIO::sanitizeSQLString($this->_editedBaseData["refreshUrl"]) . "',\n\t\t\t\tmetas_pbd='" . SensitiveIO::sanitizeSQLString($this->_editedBaseData["metas"]) . "',\n\t\t\t\tcodename_pbd='" . SensitiveIO::sanitizeSQLString($this->_editedBaseData["codename"]) . "'\n\t\t\t"; if ($this->_baseDataID) { $sql = "\n\t\t\t\t\tupdate\n\t\t\t\t\t\tpagesBaseData_edited\n\t\t\t\t\tset\n\t\t\t\t\t\t" . $sql_fields . "\n\t\t\t\t\twhere\n\t\t\t\t\t\tid_pbd='" . $this->_baseDataID . "'\n\t\t\t\t"; } else { $sql = "\n\t\t\t\t\tinsert into\n\t\t\t\t\t\tpagesBaseData_edited\n\t\t\t\t\tset\n\t\t\t\t\t\t" . $sql_fields; } $q = new CMS_query($sql); if (!$q->hasError() && !$this->_baseDataID) { $this->_baseDataID = $q->getLastInsertedID(); } } // Inform modules of the page creation $modules = CMS_modulesCatalog::getAll('id'); foreach ($modules as $codename => $module) { if (method_exists($module, 'pagePostSave')) { $module->pagePostSave($this, $isNew); } } return true; }
/** * Writes the news into persistence (MySQL for now), along with base data. * * @return boolean true on success, false on failure * @access public */ function writeToPersistence() { $sql_fields = "\n\t\t\tlanguages_snd='" . SensitiveIO::sanitizeSQLString($this->_languages) . "',\n\t\t\tuserID_snd='" . SensitiveIO::sanitizeSQLString($this->_userID) . "',\n\t\t\tclientIP_snd='" . SensitiveIO::sanitizeSQLString($this->_clientIP) . "',\n\t\t\tsessionID_snd='" . SensitiveIO::sanitizeSQLString($this->_sessionID) . "',\n\t\t\tuserAgent_snd='" . SensitiveIO::sanitizeSQLString($this->_userAgent) . "'"; // Date if (is_a($this->_dateInserted, 'CMS_date')) { $sql_fields .= ",\n\t\t\tdateInserted_snd='" . $this->_dateInserted->getDBValue() . "'"; } if ($this->_senderID) { $sql = "\n\t\t\t\tupdate\n\t\t\t\t\tmod_cms_forms_senders\n\t\t\t\tset\n\t\t\t\t\t" . $sql_fields . "\n\t\t\t\twhere\n\t\t\t\t\tid_snd='" . $this->_senderID . "'\n\t\t\t"; } else { $sql = "\n\t\t\t\tinsert into\n\t\t\t\t\tmod_cms_forms_senders\n\t\t\t\tset\n\t\t\t\t\t" . $sql_fields; } $q = new CMS_query($sql); if ($q->hasError()) { $this->raiseError("Failed to write"); return false; } elseif (!$this->_senderID) { $this->_senderID = $q->getLastInsertedID(); } return true; }
$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"; } } $searchParamContent[] = array('title' => $cms_language->getMessage(MESSAGE_PAGE_FIELD_ORDER, false, MOD_POLYMOD_CODENAME), 'xtype' => 'fieldset', 'autoHeight' => true, 'defaults' => array('anchor' => '97%'), 'items' => $searchOrderContent); } break; case 'searchType': //nothing, this is not a search parameter break; case 'publication date after': case 'publication date before': // Dates //create object CMS_date $date = new CMS_date(); if (isset($data["value"]['search'][$searchName][$paramType])) { $date->setFromDBValue($data["value"]['search'][$searchName][$paramType]); } $label = $paramType == 'publication date after' ? MESSAGE_PAGE_FIELD_PUBLISHED_FROM : MESSAGE_PAGE_FIELD_PUBLISHED_TO; //$date_mask = $cms_language->getDateFormatMask(); $value = $date->getLocalizedDate($cms_language->getDateFormat()) ? $date->getLocalizedDate($cms_language->getDateFormat()) : ''; $mandatory = $paramValue == true ? '<span class="atm-red">*</span> ' : ''; $searchParamContent[] = array('fieldLabel' => $mandatory . $cms_language->getMessage($label, false, MOD_POLYMOD_CODENAME), 'name' => 'value[search][' . $searchName . '][' . $paramType . ']', 'width' => 100, 'format' => $cms_language->getDateFormat(), 'anchor' => false, 'xtype' => 'datefield', 'allowBlank' => !$mandatory, 'value' => $value); break; default: $paramType = trim($paramType, '()'); //remove bracket around field id if (sensitiveIO::isPositiveInteger($paramType)) { //subobjects $field = $objectFields[$paramType];
/** * Module script task * @param array $parameters the task parameters * task : string task to execute * object : string module codename for the task * field : string module uid * ... : optional field relative parameters * @return Boolean true/false * @access public */ function scriptTask($parameters) { switch ($parameters['task']) { case 'emailNotification': @set_time_limit(300); $module = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID()); //create a new script for all recipients $allUsers = $this->_getRecipients($parameters['object']); foreach ($allUsers as $userId) { //add script to send email for user if needed CMS_scriptsManager::addScript($module, array('task' => 'emailSend', 'user' => $userId, 'field' => $parameters['field'], 'object' => $parameters['object'])); } //then set sending date to current date $sendingDate = new CMS_date(); $sendingDate->setNow(); $this->_subfieldValues[1]->setValue($sendingDate->getDBValue()); $this->writeToPersistence(); break; case 'emailSend': @set_time_limit(300); $params = $this->getParamsValues(); if (!sensitiveIO::isPositiveInteger($parameters['user'])) { return false; } //instanciate script related item $item = CMS_poly_object_catalog::getObjectByID($parameters['object'], false, true); if (!is_object($item) || $item->hasError()) { return false; } //instanciate user $cms_user = new CMS_profile_user($parameters['user']); //check user if (!$cms_user || $cms_user->hasError() || !$cms_user->isActive() || $cms_user->isDeleted() || !sensitiveIO::isValidEmail($cms_user->getEmail())) { return false; } $cms_language = $cms_user->getLanguage(); //globalise cms_user and cms_language $GLOBALS['cms_language'] = $cms_user->getLanguage(); $GLOBALS['cms_user'] = $cms_user; //check user clearance on object if (!$item->userHasClearance($cms_user, CLEARANCE_MODULE_VIEW)) { return false; } //create email subject $parameters['item'] = $item; $parameters['public'] = true; $polymodParsing = new CMS_polymod_definition_parsing($params['emailSubject'], false); $subject = $polymodParsing->getContent(CMS_polymod_definition_parsing::OUTPUT_RESULT, $parameters); $body = ''; //create email body if ($params['emailBody']['type'] == 1) { //send body $parameters['module'] = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID()); $polymodParsing = new CMS_polymod_definition_parsing($params['emailBody']['html'], true, CMS_polymod_definition_parsing::PARSE_MODE, $parameters['module']); $body = $polymodParsing->getContent(CMS_polymod_definition_parsing::OUTPUT_RESULT, $parameters); } elseif ($params['emailBody']['type'] == 2) { //send a page $page = CMS_tree::getPageById($params['emailBody']['pageID']); if (!$page || $page->hasError()) { $this->raiseError('Page ID is not a valid page : ' . $params['emailBody']['pageID']); return false; } $pageHTMLFile = new CMS_file($page->getHTMLURL(false, false, PATH_RELATIVETO_FILESYSTEM)); if (!$pageHTMLFile->exists()) { $this->raiseError('Page HTML file does not exists : ' . $page->getHTMLURL(false, false, PATH_RELATIVETO_FILESYSTEM)); return false; } $body = $pageHTMLFile->readContent(); //create page URL call $polymodParsing = new CMS_polymod_definition_parsing($params['emailBody']['pageURL'], false); $pageURL = $polymodParsing->getContent(CMS_polymod_definition_parsing::OUTPUT_RESULT, $parameters); parse_str($pageURL, $GLOBALS['_REQUEST']); //$GLOBALS['_REQUEST'] //parse and eval HTML page $cms_page_included = true; $GLOBALS['cms_page_included'] = $cms_page_included; //eval() the PHP code $body = sensitiveIO::evalPHPCode($body); $website = $page->getWebsite(); $webroot = $website->getURL(); //replace URLs values $replace = array('="/' => '="' . $webroot . '/', "='/" => "='" . $webroot . "/", "url(/" => "url(" . $webroot . "/"); $body = str_replace(array_keys($replace), $replace, $body); } else { $this->raiseError('No valid email type to send : ' . $params['emailBody']['type']); return false; } if (isset($sendmail)) { //$body .= print_r($sendmail,true); } //drop email sending if (isset($sendmail) && $sendmail === false) { return false; } //if no body for email or if sendmail var is set to false, quit if (!$body) { $this->raiseError('No email body to send ... Email parameters : user : '******'user'] . ' - object ' . $parameters['object']); return false; } //This code is for debug purpose only. //$testFile = new CMS_file('/test/test_'.$cms_user->getUserId().'.php', CMS_file::WEBROOT); //$testFile->setContent($body); //$testFile->writeToPersistence(); // Set email $email = new CMS_email(); $email->setSubject($subject); $email->setEmailHTML($body); $email->setEmailTo($cms_user->getEmail()); if ($params['includeFiles']) { //check for file fields attached to object $files = array(); $this->_getFieldsFiles($item, $files); if (sizeof($files)) { foreach ($files as $file) { $email->setFile($file); } } } //set email From if (!$params['emailFrom']) { $email->setFromName(APPLICATION_LABEL); $email->setEmailFrom(APPLICATION_POSTMASTER_EMAIL); } else { $email->setFromName($params['emailFrom']); $email->setEmailFrom($params['emailFrom']); } //Send if ($email->sendEmail()) { //store email sent number $this->_subfieldValues[2]->setValue($this->_subfieldValues[2]->getValue() + 1); $this->writeToPersistence(); return true; } else { return false; } break; default: $this->raiseError('No valid task given : ' . $parameters['task']); return false; break; } }
/** * Compares two dates using the given operator. * Static function. * * @param CMS_date $date1 The leftmost date of the comparison * @param CMS_date $date2 The rightmost date of the comparison * @param string $operator the comparison operator. Can be one of ==,>=,>,<=,< * @return boolean true if the comparison is true, false otherwise * @access public */ static function compare($date1, $date2, $operator) { $allowed_operators = array("==", ">=", ">", "<", "<="); if (SensitiveIO::isInSet($operator, $allowed_operators)) { $func_body = sprintf('if (%s %s %s) { return true ; } else { return false ; }', $date1->getTimestamp(), $operator, $date2->getTimestamp()); $func = create_function('', $func_body); if (!$func) { return false; } return $func(); } else { return false; } }
/** * Process the daily routine reminders part : send reminders to users * * @return void * @access private */ protected function _dailyRoutineReminders() { $today = new CMS_date(); $today->setNow(); $sql = "\n\t\t\tSELECT\n\t\t\t\tid_pag,\n\t\t\t\tremindedEditorsStack_pag,\n\t\t\t\treminderOnMessage_pbd\n\t\t\tFROM\n\t\t\t\tpages, pagesBaseData_public\n\t\t\tWHERE\n\t\t\t\tpage_pbd = id_pag\n\t\t\t\tAND (\n\t\t\t\t\t(lastReminder_pag < reminderOn_pbd\n\t\t\t\t\tAND\n\t\t\t\t\t'" . $today->getDBValue() . "' >= reminderOn_pbd)\n\t\t\t\t\tOR (\n\t\t\t\t\t\t(to_days('" . $today->getDBValue() . "') - to_days(lastReminder_pag)) >= reminderPeriodicity_pbd\n\t\t\t\t\t\tAND\n\t\t\t\t\t\treminderPeriodicity_pbd != '0'\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t"; $q = new CMS_query($sql); $reminders = array(); while ($data = $q->getArray()) { $reminders[] = $data; } //send the emails foreach ($reminders as $reminder) { //instanciate page and update its lastReminder vars $page = CMS_tree::getPageByID($reminder["id_pag"]); $page->touchLastReminder(); $page->writeToPersistence(); //build users array $users_stack = new CMS_stack(); $users_stack->setTextDefinition($reminder["remindedEditorsStack_pag"]); $users_stack_elements = $users_stack->getElements(); $users = array(); foreach ($users_stack_elements as $element) { $usr = CMS_profile_usersCatalog::getByID($element[0]); if ($usr instanceof CMS_profile_user) { $users[$element[0]] = $usr; } } if (!$users) { continue; } //prepare emails and send them $group_email = new CMS_emailsCatalog(); $languages = CMS_languagesCatalog::getAllLanguages(); $subjects = array(); $bodies = array(); foreach ($languages as $language) { $subjects[$language->getCode()] = $language->getMessage(self::MESSAGE_MOD_STANDARD_EMAIL_REMINDER_SUBJECT); $bodies[$language->getCode()] = $language->getMessage(self::MESSAGE_MOD_STANDARD_EMAIL_REMINDER_BODY, array($page->getTitle() . " (ID : " . $page->getID() . ")")) . "\n" . $language->getMessage(self::MESSAGE_MOD_STANDARD_EMAIL_REMINDER_BODY_MESSAGE, array($reminder["reminderOnMessage_pbd"])); } $group_email->setUserMessages($users, $bodies, $subjects, ALERT_LEVEL_PAGE_ALERTS, MOD_STANDARD_CODENAME); $group_email->sendMessages(); } }
if ($paramValue && !$value['search'][$searchName][$paramType]) { //mandatory ? $formok = false; } if ($paramType == 'limit' && $value['search'][$searchName][$paramType] && !sensitiveIO::IspositiveInteger($value['search'][$searchName][$paramType])) { $cms_message .= $cms_language->getMessage(MESSAGE_FORM_ERROR_MALFORMED_FIELD, array($cms_language->getMessage(MESSAGE_PAGE_FIELD_LIMIT, false, MOD_POLYMOD_CODENAME))) . "\n"; } break; case 'publication date after': case 'publication date before': if ($paramValue && !$value['search'][$searchName][$paramType]) { //mandatory ? $formok = false; } elseif ($value['search'][$searchName][$paramType]) { //replace localised date value by db format corresponding value $date = new CMS_date(); $date->setFormat($cms_language->getDateFormat()); if ($date->setLocalizedDate($value['search'][$searchName][$paramType])) { $value['search'][$searchName][$paramType] = $date->getDBValue(); } else { $label = $paramType == 'publication date after' ? MESSAGE_PAGE_FIELD_PUBLISHED_FROM : MESSAGE_PAGE_FIELD_PUBLISHED_TO; $cms_message .= $cms_language->getMessage(MESSAGE_FORM_ERROR_MALFORMED_FIELD, array($cms_language->getMessage($label, false, MOD_POLYMOD_CODENAME))) . "\n"; } } break; case 'order': if (sizeof($paramValue)) { foreach ($paramValue as $orderName => $orderValue) { // Order direction $orderName = trim($orderName, '()'); if ($paramValue && !$value['search'][$searchName][$paramType][$orderName]) {
$itemFields .= sensitiveIO::jsonEncode($fieldAdmin) . ','; } } //do some search and replace to allow use of js functions in returned code $itemFields = str_replace('"scope":"this"', '"scope":this', $itemFields); function replaceCallBack($parts) { return 'function(' . str_replace(array('\\"', '\\/'), array('"', '/'), $parts[1]) . '}'; } $itemFields = preg_replace_callback('#"function\\((.*)}"#U', 'replaceCallBack', $itemFields); //Append pub dates if object is a primary resource $saveAndValidate = ''; $saveIconCls = $saveTooltip = ''; if ($object->isPrimaryResource()) { if (!$item->getID()) { $dt = new CMS_date(); $dt->setDebug(false); $dt->setNow(); $pubStart = $dt->getLocalizedDate($cms_language->getDateFormat()); } else { $pubStart = $item->getPublicationDateStart(false)->getLocalizedDate($cms_language->getDateFormat()); } $pubEnd = $item->getPublicationDateEnd(false)->getLocalizedDate($cms_language->getDateFormat()); $dateMask = $cms_language->getDateFormatMask(); $itemFields .= "{\n\t\ttitle:\t\t\t'{$cms_language->getJSMessage(MESSAGE_PAGE_SUBTITLE_WEBSITE_PUBS, false, MOD_POLYMOD_CODENAME)}',\n\t\txtype:\t\t\t'fieldset',\n\t\tautoHeight:\t\ttrue,\n\t\tdefaultType:\t'datefield',\n\t\tlabelWidth:\t\t140,\n\t\tdefaults:\t\t{\n\t\t\twidth:\t\t\t100,\n\t\t\tanchor:\t\t\t'',\n\t\t\tformat:\t\t\t'{$cms_language->getDateFormat()}'\n\t\t},\n\t\titems:\t\t\t[{\n\t\t\tfieldLabel:\t'<span ext:qtip=\"{$cms_language->getJSMessage(MESSAGE_PAGE_FIELD_DATE_COMMENT, array($dateMask))}\" class=\"atm-help\"><span class=\"atm-red\">*</span> {$cms_language->getJSMessage(MESSAGE_PAGE_FIELD_PUBDATE_BEG)}</span>',\n\t\t\tname:\t\t'pubStart',\n\t\t\tallowBlank:\tfalse,\n\t\t\tvalue:\t\t'{$pubStart}'\n\t\t},{\n\t\t\tfieldLabel:\t'<span ext:qtip=\"{$cms_language->getJSMessage(MESSAGE_PAGE_FIELD_DATE_COMMENT, array($dateMask))}\" class=\"atm-help\">{$cms_language->getJSMessage(MESSAGE_PAGE_FIELD_PUBDATE_END)}</span>',\n\t\t\tname:\t\t'pubEnd',\n\t\t\tallowBlank:\ttrue,\n\t\t\tvalue:\t\t'{$pubEnd}'\n\t\t}]\n\t},"; if ($cms_user->hasValidationClearance($codename)) { $saveAndValidate = ",{\n\t\t\tid:\t\t\t\t'{$winId}-save-validate',\n\t\t\txtype:\t\t\t'button',\n\t\t\ttext:\t\t\t'{$cms_language->getJSMessage(MESSAGE_PAGE_PUBLISH)}',\n\t\t\ttooltip:\t\t'{$cms_language->getJSMessage(MESSAGE_PAGE_SAVE_AND_VALID_DESC, false, MOD_POLYMOD_CODENAME)}',\n\t\t\ticonCls:\t\t'atm-pic-validate',\n\t\t\tname:\t\t\t'submitAndValidAdmin',\n\t\t\thandler:\t\tsubmitItem.createDelegate(this, ['save-validate']),\n\t\t\tscope:\t\t\tthis\n\t\t}"; $saveIconCls = 'atm-pic-draft-validation'; $saveTooltip = $cms_language->getJSMessage(MESSAGE_PAGE_SAVE_PRIMARY_DESC, false, MOD_POLYMOD_CODENAME); } $saveLabel = $cms_language->getJSMessage(MESSAGE_PAGE_SUBMIT_TO_VALID);
define("MESSAGE_PAGE_FIELD_USER", 908); define("MESSAGE_PAGE_FIELD_STATUS", 909); define("MESSAGE_PAGE_FIELD_ELEMENT", 1579); //get search vars $codename = sensitiveIO::request('module', CMS_modulesCatalog::getAllCodenames()); $pageId = sensitiveIO::request('page', 'sensitiveIO::isPositiveInteger', 0); $type = sensitiveIO::request('type', array('all', 'login', 'resource', 'admin', 'email', 'modules'), 'all'); $datestart = false; if (sensitiveIO::request('datestart')) { $datestart = new CMS_date(); $datestart->setFormat($cms_language->getDateFormat()); $datestart->setLocalizedDate(sensitiveIO::request('datestart'), true); } $dateend = false; if (sensitiveIO::request('dateend')) { $dateend = new CMS_date(); $dateend->setFormat($cms_language->getDateFormat()); $dateend->setLocalizedDate(sensitiveIO::request('dateend'), true); } $sort = sensitiveIO::request('sort', array('datetime', 'user', 'action'), 'datetime'); $dir = sensitiveIO::request('dir', array('ASC', 'DESC'), 'DESC'); $userId = sensitiveIO::request('userId', 'sensitiveIO::isPositiveInteger'); $start = sensitiveIO::request('start', 'sensitiveIO::isPositiveInteger', 0); $limit = sensitiveIO::request('limit', 'sensitiveIO::isPositiveInteger', CMS_session::getRecordsPerPage()); $delete = sensitiveIO::request('del') ? true : false; if ($delete && !$cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL)) { $delete = false; } $logsDatas = array(); $logsDatas['logs'] = array(); if (!$cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_VIEWLOG)) {
} if (is_array($archives) && $archives) { $content .= ' <table border="0" cellpadding="2" cellspacing="2"> <tr> <th class="admin">' . $cms_language->getMessage(MESSAGE_PAGE_FIELD_REFERENCE) . '</th> <th class="admin">' . $cms_language->getMessage(MESSAGE_PAGE_FIELD_TITLE) . '</th> <th class="admin">' . $cms_language->getMessage(MESSAGE_PAGE_FIELD_LASTCREATION) . '</th> <th class="admin" colspan="2">' . $cms_language->getMessage(MESSAGE_PAGE_ACTIONS) . '</th> </tr> '; $count = 0; foreach ($archives as $archive) { $count++; $td_class = $count % 2 == 0 ? "admin_lightgreybg" : "admin_darkgreybg"; $last_creation = new CMS_date(); $last_creation->setFromDBValue($archive["lastFileCreation"]); $href = PATH_ADMIN_SPECIAL_TREE_WR; $content .= ' <tr> <td class="' . $td_class . '">' . $archive["id"] . '</td> <td class="' . $td_class . '">' . htmlspecialchars($archive["title"]) . '</td> <td class="' . $td_class . '">' . $last_creation->getLocalizedDate($cms_language->getDateFormat()) . '</td> <form action="' . $_SERVER["SCRIPT_NAME"] . '" method="get" onSubmit="return confirm(\'' . addslashes($cms_language->getMessage(MESSAGE_PAGE_ACTION_DELETECONFIRM, array(htmlspecialchars($archive["title"])))) . '\')"> <input type="hidden" name="cms_action" value="delete" /> <input type="hidden" name="action_page" value="' . $archive["id"] . '" /> <td class="' . $td_class . '"> <input type="submit" class="admin_input_' . $td_class . '" value="' . $cms_language->getMessage(MESSAGE_PAGE_ACTION_DELETE) . '" /> </td> </form> <form action="' . $href . '" method="get">
/** * Writes the resourceStatus into persistence (MySQL for now). * * @return boolean true on success, false on failure * @access public */ function writeToPersistence() { //first adjust publication and start publication date $this->_adjustPublication(); if ($this->_publicationDateStart->isNull()) { $this->_publicationDateStart->setNow(); } $sql_fields = "\n\t\t\tlocation_rs='" . SensitiveIO::sanitizeSQLString($this->_location) . "',\n\t\t\tproposedFor_rs='" . SensitiveIO::sanitizeSQLString($this->_proposedFor) . "',\n\t\t\teditions_rs='" . SensitiveIO::sanitizeSQLString($this->_editions) . "',\n\t\t\tvalidationsRefused_rs='" . SensitiveIO::sanitizeSQLString($this->_validationsRefused) . "',\n\t\t\tpublication_rs='" . SensitiveIO::sanitizeSQLString($this->_publication) . "',\n\t\t\tpublicationDateStart_rs='" . $this->_publicationDateStart->getDBValue() . "',\n\t\t\tpublicationDateEnd_rs='" . $this->_publicationDateEnd->getDBValue() . "',\n\t\t\tpublicationDateStartEdited_rs='" . $this->_publicationDateStartEdited->getDBValue() . "',\n\t\t\tpublicationDateEndEdited_rs='" . $this->_publicationDateEndEdited->getDBValue() . "'\n\t\t"; if ($this->_id) { $sql = "\n\t\t\t\tupdate\n\t\t\t\t\tresourceStatuses\n\t\t\t\tset\n\t\t\t\t\t" . $sql_fields . "\n\t\t\t\twhere\n\t\t\t\t\tid_rs='" . $this->_id . "'\n\t\t\t"; } else { $sql = "\n\t\t\t\tinsert into\n\t\t\t\t\tresourceStatuses\n\t\t\t\tset\n\t\t\t\t\t" . $sql_fields; } $q = new CMS_query($sql); if ($q->hasError()) { return false; } elseif (!$this->_id) { $this->_id = $q->getLastInsertedID(); } return true; }
/** * 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; }
/** * Compile the RSS definition * * @return boolean true on success, false on failure * @access public */ function compileDefinition() { $parameters = array(); $parameters['module'] = CMS_poly_object_catalog::getModuleCodenameForObjectType($this->getValue('objectID')); $parameters['objectID'] = $this->getValue('objectID'); $parameters['public'] = true; $definitionParsing = new CMS_polymod_definition_parsing($this->_objectValues['definition'], true, CMS_polymod_definition_parsing::PARSE_MODE, $parameters['module']); $compiledDefinition = $definitionParsing->getContent(CMS_polymod_definition_parsing::OUTPUT_PHP, $parameters); $this->_objectValues['compiledDefinition'] = $compiledDefinition; $date = new CMS_date(); $date->setNow(); $this->_objectValues['lastCompilation'] = $date; return true; }
/** * Write to persistence * * @return boolean true on success, false on failure * @access public */ function writeToPersistence() { $sql_fields = "\n\t\t\t\tuser_log='" . SensitiveIO::sanitizeSQLString($this->_user->getUserId()) . "',\n\t\t\t\taction_log='" . SensitiveIO::sanitizeSQLString($this->_action) . "',\n\t\t\t\tdatetime_log='" . SensitiveIO::sanitizeSQLString($this->_datetime->getDBValue()) . "',\n\t\t\t\ttextData_log='" . SensitiveIO::sanitizeSQLString($this->_textData) . "',\n\t\t\t\tlabel_log='" . SensitiveIO::sanitizeSQLString($this->_label) . "',\n\t\t\t\tmodule_log='" . SensitiveIO::sanitizeSQLString($this->_module) . "',\n\t\t\t\tresource_log='" . SensitiveIO::sanitizeSQLString($this->_resource) . "',\n\t\t\t\trsAfterLocation_log='" . SensitiveIO::sanitizeSQLString($this->_resourceStatusAfter->getLocation()) . "',\n\t\t\t\trsAfterProposedFor_log='" . SensitiveIO::sanitizeSQLString($this->_resourceStatusAfter->getProposedFor()) . "',\n\t\t\t\trsAfterEditions_log='" . SensitiveIO::sanitizeSQLString($this->_resourceStatusAfter->getEditions()) . "',\n\t\t\t\trsAfterValidationsRefused_log='" . SensitiveIO::sanitizeSQLString($this->_resourceStatusAfter->getValidationRefused()) . "',\n\t\t\t\trsAfterPublication_log='" . SensitiveIO::sanitizeSQLString($this->_resourceStatusAfter->getPublication()) . "'\t\n\t\t\t"; if ($this->_id) { $sql = "\n\t\t\t\t\tupdate\n\t\t\t\t\t\tlog\n\t\t\t\t\tset\n\t\t\t\t\t\t" . $sql_fields . "\n\t\t\t\t\twhere\n\t\t\t\t\t\tid_log='" . $this->_id . "'\n\t\t\t\t"; } else { $sql = "\n\t\t\t\t\tinsert into\n\t\t\t\t\t\tlog\n\t\t\t\t\tset\n\t\t\t\t\t\t" . $sql_fields; } $q = new CMS_query($sql); if ($q->hasError()) { return false; } else { $this->_id = $q->getLastInsertedID(); } return true; }
} else { $cms_message = $cms_language->getMessage(MESSAGE_FORM_ERROR_WRITING); $cms_page->raiseError('Error during writing of page ' . $cms_page->getID() . '. Action : update pageMetas'); } $dt_beg = new CMS_date(); $dt_beg->setDebug(false); $dt_beg->setFormat($cms_language->getDateFormat()); $dateStart = $cms_page->getPublicationDateStart(false); $dt_end = new CMS_date(); $dt_end->setDebug(false); $dt_end->setFormat($cms_language->getDateFormat()); $dateEnd = $cms_page->getPublicationDateEnd(false); if ($dt_beg->setLocalizedDate($pubdatestart, false) && $dt_end->setLocalizedDate($pubdateend, true)) { //check if dates has changed if (!CMS_date::compare($dateStart, $dt_beg, '==') || !CMS_date::compare($dateEnd, $dt_end, '==')) { if (!$dt_end->isNull() && CMS_date::compare($dt_beg, $dt_end, '>')) { $cms_message = $cms_language->getMessage(MESSAGE_FORM_ERROR_MALFORMED_DATES); $cms_page->raiseError('Error during set pubdatestart : date start is higher than date end. Values set for date start : ' . $pubdatestart . ', for date end : ' . $pubdateend); } else { $cms_page->setPublicationDates($dt_beg, $dt_end); if ($cms_page->writeToPersistence()) { $edited = RESOURCE_EDITION_BASEDATA; $logAction = CMS_log::LOG_ACTION_RESOURCE_EDIT_BASEDATA; $cms_message = $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE); } else { $cms_message = $cms_language->getMessage(MESSAGE_FORM_ERROR_WRITING); $cms_page->raiseError('Error during writing of page ' . $cms_page->getID() . '. Action : update pubdatestart, value : ' . $pubdatestart); } } } } else {
* @author Sébastien Pauchet <*****@*****.**> */ define("ENABLE_HTML_COMPRESSION", false); require_once dirname(__FILE__) . '/../../cms_rc_admin.php'; define('MESSAGE_PAGE_NO_LOGS', 1608); define("MESSAGE_PAGE_NO_SERVER_RIGHTS", 748); //CHECKS user has admin clearance if (!$cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL)) { CMS_grandFather::raiseError('User has no administration rights'); echo $cms_language->getMessage(MESSAGE_PAGE_NO_SERVER_RIGHTS); exit; } $date = sensitiveIO::request('date'); $errorFile = ''; $gzip = false; $now = new CMS_date(); $now->setNow(true); $requestedDate = new CMS_date(); $requestedDate->setFormat($cms_language->getDateFormat()); $requestedDate->setLocalizedDate($date); if (!$requestedDate->hasError()) { if (CMS_date::compare($requestedDate, $now, '==')) { $errorFile = PATH_MAIN_FS . '/' . CMS_grandFather::ERROR_LOG; } else { $gzip = true; $requestedDate->moveDate('+1 day'); $errorFile = PATH_LOGS_FS . '/' . CMS_grandFather::ERROR_LOG . '-' . $requestedDate->getLocalizedDate('Y-m-d') . '.gz'; } } if ($errorFile && file_exists($errorFile)) { if (connection_status() == 0) {
define("MESSAGE_PAGE_SCRIPTS_IN_PROGRESS", 735); define("MESSAGE_PAGE_SCRIPTS_IN_PROGRESS_PID_OK", 736); define("MESSAGE_PAGE_NO_SCRIPTS_PID_OK", 737); define("MESSAGE_PAGE_SCRIPTS_END_PID_OK", 738); define("MESSAGE_PAGE_NO_SCRIPTS_IN_PROGRESS", 739); define("MESSAGE_PAGE_NO_SCRIPTS_QUEUED", 740); //Controler vars $details = sensitiveIO::request('details') == 'true' ? true : false; $queue = sensitiveIO::request('queue') == 'true' ? true : false; $xmlcontent = $detailsContent = $queueContent = ''; if ($details) { $runningScripts = processManager::getRunningScript(); if (is_array($runningScripts) && sizeof($runningScripts)) { $detailsContent = '<ul class="atm-server">'; foreach ($runningScripts as $runningScript) { $date = new CMS_date(); $date->setFromDBValue($runningScript["Date"]); switch ($runningScript["PIDFile"]) { case '0': $detailsContent .= '<li class="atm-pic-question" ext:qtip="' . $cms_language->getMessage(MESSAGE_PAGE_SCRIPTS_IN_PROGRESS) . '">' . $runningScript["Title"] . ' (' . $date->getLocalizedDate($cms_language->getDateFormat() . " H:i:s") . ')</li>'; break; case '1': $detailsContent .= '<li class="atm-pic-ok" ext:qtip="' . $cms_language->getMessage(MESSAGE_PAGE_SCRIPTS_IN_PROGRESS_PID_OK) . '">' . $runningScript["Title"] . ' (' . $date->getLocalizedDate($cms_language->getDateFormat() . " H:i:s") . ')</li>'; break; case '2': $detailsContent .= '<li class="atm-pic-cancel" ext:qtip="' . $cms_language->getMessage(MESSAGE_PAGE_NO_SCRIPTS_PID_OK) . '">' . $runningScript["Title"] . ' (' . $date->getLocalizedDate($cms_language->getDateFormat() . " H:i:s") . ')</li>'; break; case '3': $detailsContent .= '<li class="atm-pic-cancel" ext:qtip="' . $cms_language->getMessage(MESSAGE_PAGE_SCRIPTS_END_PID_OK) . '">' . $runningScript["Title"] . ' (' . $date->getLocalizedDate($cms_language->getDateFormat() . " H:i:s") . ')</li>'; break; }
/** * add a search condition to a given CMS_object_search object * * @param CMS_object_search $search : the reference search object which need the condition * @param array &tagAttributes : represent atm-search-param attributes * @return boolean true on success, false on failure * @access private * @static */ static function addSearchCondition(&$search, $tagAttributes) { global $cms_language; if (!isset($tagAttributes['type'])) { CMS_grandFather::raiseError("Malformed atm-search-param tag : missing 'type' attribute"); return false; } if (!isset($tagAttributes['value'])) { CMS_grandFather::raiseError("Malformed atm-search-param tag : missing 'value' attribute"); return false; } if (!isset($tagAttributes['mandatory'])) { CMS_grandFather::raiseError("Malformed atm-search-param tag : missing 'mandatory' attribute"); return false; } if (isset($tagAttributes['value'])) { $searchConditionValue = $tagAttributes['value']; } else { CMS_grandFather::raiseError("Unknown value type : " . $tagAttributes['value']); return false; } //if no value for condition and condition is mandatory : return false if (!$searchConditionValue && (!isset($tagAttributes['operator']) || !$tagAttributes['operator'])) { return $tagAttributes['mandatory'] == 'true' ? false : true; } if (is_scalar($tagAttributes['type']) && in_array($tagAttributes['type'], CMS_object_search::getStaticSearchConditionTypes()) || $tagAttributes['type'] == 'category') { if ($tagAttributes['type'] == 'publication date after' || $tagAttributes['type'] == 'publication date before') { //replace search condition value by corresponding cms_date object $date = new CMS_date(); $date->setFormat($cms_language->getDateFormat()); $date->setLocalizedDate($searchConditionValue); $searchConditionValue = $date; } $search->addWhereCondition($tagAttributes['type'], $searchConditionValue, isset($tagAttributes['operator']) ? $tagAttributes['operator'] : false); } else { if (!sensitiveIO::isPositiveInteger($tagAttributes['type'])) { CMS_grandFather::raiseError("Malformed atm-search-param tag : attribute 'type' does not represent a valid object " . $tagAttributes['type']); return false; } else { $search->addWhereCondition($tagAttributes['type'], $searchConditionValue, isset($tagAttributes['operator']) ? $tagAttributes['operator'] : false); } } return true; }
/** * Get object publication date * If object is a primary resource, return resource pub date else, try to find a date field with creation date * * @return CMS_date, the publication date object if any (false otherwise) * @access public */ function getPublicationDate() { static $pubFieldIDForObjectType; if ($this->getObjectResourceStatus() == 1) { return $this->getPublicationDateStart(); } else { //find creation date field for this type of object if (!isset($pubFieldIDForObjectType[$this->_objectID])) { $pubFieldIDForObjectType[$this->_objectID] = false; foreach (array_keys($this->_subObjectsDefinitions) as $fieldID) { $type = $this->_objectFieldsDefinition[$fieldID]->getValue('type'); if ($type == 'CMS_object_date' && $this->_objectFieldsDefinition[$fieldID]->getParameter('creationDate')) { //date field $pubFieldIDForObjectType[$this->_objectID] = $fieldID; } } } if ($pubFieldIDForObjectType[$this->_objectID] === false) { return false; } //then get field value $value = $this->_objectValues[$pubFieldIDForObjectType[$this->_objectID]]->getValue('value'); $date = new CMS_date(); $date->setFromDBValue($value); return $date; } }
} } // Date format $dateFormat = $cms_language->getDateFormat(); // d/m/Y // +----------------------------------------------------------------------+ // | Build search | // +----------------------------------------------------------------------+ //create search object for current object $search = new CMS_object_search($object); //if object is a primary resource if ($object->isPrimaryResource()) { //Order $search->setAttribute('orderBy', 'publicationDateStart_rs desc,publicationDateEnd_rs desc, id_moo desc'); // Param : Around publication date $dt_today = new CMS_date(); $dt_today->setDebug(false); $dt_today->setNow(); $dt_today->setFormat($dateFormat); $dt_from = new CMS_date(); $dt_from->setDebug(false); $dt_from->setFormat($dateFormat); if ($dt_from->setLocalizedDate(CMS_session::getSessionVar("items_dtfrm"), true)) { $search->addWhereCondition("publication date after", $dt_from); } $dt_end = new CMS_date(); $dt_end->setDebug(false); $dt_end->setFormat($dateFormat); if ($dt_end->setLocalizedDate(CMS_session::getSessionVar("items_dtnd"), true)) { // Check this date isn't greater than start date given if (!CMS_date::compare($dt_from, $dt_end, ">=")) {
if ($cms_page->getPublication() != RESOURCE_PUBLICATION_NEVERVALIDATED && $editions & RESOURCE_EDITION_CONTENT) { $panelContent .= "\n\t\t\t\t\t\t\t\tmenu.addSeparator();\n\t\t\t\t\t\t\t\tmenu.addItem(new Ext.menu.Item({\n\t\t\t\t\t\t\t\t\ttext: '<span ext:qtip=\"" . $cms_language->getJSMessage(MESSAGE_PAGE_UNDO_EDITING_INFO) . "\">" . $cms_language->getJSMessage(MESSAGE_PAGE_UNDO_EDITING) . "</span>',\n\t\t\t\t\t\t\t\t\ticonCls: 'atm-pic-editions-cancelling',\n\t\t\t\t\t\t\t\t\thandler: function(){\n\t\t\t\t\t\t\t\t\t\tAutomne.message.popup({\n\t\t\t\t\t\t\t\t\t\t\tmsg: \t\t\t\t'" . $cms_language->getJSMessage(MESSAGE_PAGE_UNDO_EDITING_CONFIRM) . "',\n\t\t\t\t\t\t\t\t\t\t\tbuttons: \t\t\tExt.MessageBox.OKCANCEL,\n\t\t\t\t\t\t\t\t\t\t\tanimEl: \t\t\tthis.getEl(),\n\t\t\t\t\t\t\t\t\t\t\tclosable: \t\t\tfalse,\n\t\t\t\t\t\t\t\t\t\t\ticon: \t\t\t\tExt.MessageBox.WARNING,\n\t\t\t\t\t\t\t\t\t\t\tfn: \t\t\t\tfunction (button) {\n\t\t\t\t\t\t\t\t\t\t\t\tif (button == 'ok') {\n\t\t\t\t\t\t\t\t\t\t\t\t\ttabs.setActiveTab('public');\n\t\t\t\t\t\t\t\t\t\t\t\t\tAutomne.server.call({\n\t\t\t\t\t\t\t\t\t\t\t\t\t\turl:\t\t\t\t'page-controler.php',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tparams: \t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcurrentPage:\t\t'" . $cms_page->getID() . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\taction:\t\t\t\t'cancel_editions'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tfcnCallback: \t\tfunction() {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//then reload page infos\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttabs.getPageInfos({\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpageId:\t\t'" . $cms_page->getID() . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tnoreload:\ttrue\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tcallBackScope:\t\tthis\n\t\t\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}));"; } if ($editions & RESOURCE_EDITION_CONTENT && $cms_user->hasValidationClearance(MOD_STANDARD_CODENAME)) { //validate $panelContent .= "\n\t\t\t\t\t\t\t\tmenu.addItem(new Ext.menu.Item({\n\t\t\t\t\t\t\t\t\ttext: '<span ext:qtip=\"" . $cms_language->getJSMessage(MESSAGE_PAGE_VALIDATION_MODIFICATIONS) . "\">" . $cms_language->getJSMessage(MESSAGE_PAGE_VALIDATION) . "</span>',\n\t\t\t\t\t\t\t\t\ticonCls: 'atm-pic-validate',\n\t\t\t\t\t\t\t\t\thandler: function () {\n\t\t\t\t\t\t\t\t\t\tAutomne.server.call('validations-controler.php', function(response, options, jsonResponse){\n\t\t\t\t\t\t\t\t\t\t\tif (!jsonResponse.success) {\n\t\t\t\t\t\t\t\t\t\t\t\t//get validation message\n\t\t\t\t\t\t\t\t\t\t\t\tif (response.responseXML && response.responseXML.getElementsByTagName('message').length) {\n\t\t\t\t\t\t\t\t\t\t\t\t\tvar message = response.responseXML.getElementsByTagName('message').item(0).firstChild.nodeValue;\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\tAutomne.message.popup({\n\t\t\t\t\t\t\t\t\t\t\t\t\tmsg: \t\t\t\tmessage,\n\t\t\t\t\t\t\t\t\t\t\t\t\tbuttons: \t\t\tExt.MessageBox.OK,\n\t\t\t\t\t\t\t\t\t\t\t\t\tclosable: \t\t\tfalse,\n\t\t\t\t\t\t\t\t\t\t\t\t\ticon: \t\t\t\tExt.MessageBox.WARNING\n\t\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\t\t\t\t\taction:\t\t\t\t'validateById',\n\t\t\t\t\t\t\t\t\t\t\tresource:\t\t\t'" . $cms_page->getID() . "',\n\t\t\t\t\t\t\t\t\t\t\tmodule:\t\t\t\t'" . MOD_STANDARD_CODENAME . "',\n\t\t\t\t\t\t\t\t\t\t\tevalMessage:\t\tfalse\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}));"; } $endPublication = $cms_page->getPublicationDateEnd(false); $now = new CMS_date(); $now->setNow(); if ($cms_page->getPublication() == RESOURCE_PUBLICATION_PUBLIC && ($endPublication->isNull() || CMS_date::compare($endPublication, $now, '>'))) { if (!$cms_page->isProtected()) { //unpublish $panelContent .= "\n\t\t\t\t\t\t\t\t\tmenu.addSeparator();\n\t\t\t\t\t\t\t\t\tmenu.addItem(new Ext.menu.Item({\n\t\t\t\t\t\t\t\t\t\ttext: '<span ext:qtip=\"" . $cms_language->getJSMessage(MESSAGE_PAGE_UNPUBLISH_PAGE_INFO) . "\">" . $cms_language->getJSMessage(MESSAGE_PAGE_UNPUBLISH_PAGE) . "</span>',\n\t\t\t\t\t\t\t\t\t\ticonCls: 'atm-pic-unpublish',\n\t\t\t\t\t\t\t\t\t\thandler: function(){\n\t\t\t\t\t\t\t\t\t\t\tAutomne.message.popup({\n\t\t\t\t\t\t\t\t\t\t\t\tmsg: \t\t\t\t'" . $cms_language->getJSMessage(MESSAGE_PAGE_UNPUBLISH_PAGE_CONFIRM) . "',\n\t\t\t\t\t\t\t\t\t\t\t\tbuttons: \t\t\tExt.MessageBox.OKCANCEL,\n\t\t\t\t\t\t\t\t\t\t\t\tanimEl: \t\t\tthis.getEl(),\n\t\t\t\t\t\t\t\t\t\t\t\tclosable: \t\t\tfalse,\n\t\t\t\t\t\t\t\t\t\t\t\ticon: \t\t\t\tExt.MessageBox.QUESTION,\n\t\t\t\t\t\t\t\t\t\t\t\tfn: \t\t\t\tfunction (button) {\n\t\t\t\t\t\t\t\t\t\t\t\t\tif (button == 'ok') {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tAutomne.server.call({\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\turl:\t\t\t\t'page-controler.php',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tparams: \t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcurrentPage:\t\t'" . $cms_page->getID() . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\taction:\t\t\t\t'unpublish'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfcnCallback: \t\tfunction() {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//then reload page infos\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttabs.getPageInfos({\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpageId:\t\t'" . $cms_page->getID() . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tnoreload:\ttrue\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcallBackScope:\t\tthis\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}));"; } } elseif ($cms_page->getPublication() != RESOURCE_PUBLICATION_NEVERVALIDATED && !$endPublication->isNull() && CMS_date::compare($endPublication, $now, '<=')) { //publish $panelContent .= "\n\t\t\t\t\t\t\t\tmenu.addSeparator();\n\t\t\t\t\t\t\t\tmenu.addItem(new Ext.menu.Item({\n\t\t\t\t\t\t\t\t\ttext: '<span ext:qtip=\"" . $cms_language->getJSMessage(MESSAGE_PAGE_PUBLISH_INFO) . "\">" . $cms_language->getJSMessage(MESSAGE_PAGE_PUBLISH) . "</span>',\n\t\t\t\t\t\t\t\t\ticonCls: 'atm-pic-publish',\n\t\t\t\t\t\t\t\t\thandler: function () {\n\t\t\t\t\t\t\t\t\t\tAutomne.message.popup({\n\t\t\t\t\t\t\t\t\t\t\tmsg: \t\t\t\t'" . $cms_language->getJSMessage(MESSAGE_PAGE_PUBLISH_PAGE_CONFIRM) . "',\n\t\t\t\t\t\t\t\t\t\t\tbuttons: \t\t\tExt.MessageBox.OKCANCEL,\n\t\t\t\t\t\t\t\t\t\t\tanimEl: \t\t\tthis.getEl(),\n\t\t\t\t\t\t\t\t\t\t\tclosable: \t\t\tfalse,\n\t\t\t\t\t\t\t\t\t\t\ticon: \t\t\t\tExt.MessageBox.QUESTION,\n\t\t\t\t\t\t\t\t\t\t\tfn: \t\t\t\tfunction (button) {\n\t\t\t\t\t\t\t\t\t\t\t\tif (button == 'ok') {\n\t\t\t\t\t\t\t\t\t\t\t\t\tAutomne.server.call({\n\t\t\t\t\t\t\t\t\t\t\t\t\t\turl:\t\t\t\t'page-controler.php',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tparams: \t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcurrentPage:\t\t'" . $cms_page->getID() . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\taction:\t\t\t\t'publish'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tfcnCallback: \t\tfunction() {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//then reload page infos\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttabs.getPageInfos({\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpageId:\t\t'" . $cms_page->getID() . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tnoreload:\ttrue\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tcallBackScope:\t\tthis\n\t\t\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}));"; } if ($cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_REGENERATEPAGES) && $cms_page->getPublication() == RESOURCE_PUBLICATION_PUBLIC) { //regenerate $panelContent .= "\n\t\t\t\t\t\t\t\tmenu.addSeparator();\n\t\t\t\t\t\t\t\tmenu.addItem(new Ext.menu.Item({\n\t\t\t\t\t\t\t\t\ttext: '<span ext:qtip=\"" . $cms_language->getJSMessage(MESSAGE_PAGE_REGEN_DESC) . "\">" . $cms_language->getJSMessage(MESSAGE_PAGE_REGENERATE) . "</span>',\n\t\t\t\t\t\t\t\t\ticonCls: 'atm-pic-scripts',\n\t\t\t\t\t\t\t\t\thandler: function () {\n\t\t\t\t\t\t\t\t\t\tAutomne.server.call({\n\t\t\t\t\t\t\t\t\t\t\turl:\t\t\t\t'page-controler.php',\n\t\t\t\t\t\t\t\t\t\t\tparams: \t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tcurrentPage:\t\t'" . $cms_page->getID() . "',\n\t\t\t\t\t\t\t\t\t\t\t\taction:\t\t\t\t'regenerate'\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}));"; } //separator $panelContent .= "'-'" . $pageDraft; } } } elseif ($cms_user->hasPageClearance($cms_page->getID(), CLEARANCE_PAGE_VIEW)) { //if user has page edition rights somewhere if ($cms_user->hasEditablePages()) { //page copy
/** * 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); } } }
/** * Return options tag list (for a select tag) of all float values for this field * * @param array $values : parameters values array(parameterName => parameterValue) in : * selected : the float value which is selected (optional) * @param multidimentionnal array $tags : xml2Array content of atm-function tag (nothing for this one) * @return string : options tag list * @access public */ function selectOptions($values, $tags) { global $cms_language; $return = ""; $fieldID = $this->_field->getID(); $allValues = array(); $status = $this->_public ? 'public' : 'edited'; $supportedOperator = array('>=', '<=', '>', '<', '>= or null', '<= or null', '> or null', '< or null', '>= and not null', '<= and not null', '> and not null', '< and not null'); $sqlOperator = ''; if (isset($values['operator']) && isset($values['boundary']) && $values['operator'] && $values['boundary'] && in_array(htmlspecialchars_decode($values['operator']), $supportedOperator)) { $operator = htmlspecialchars_decode($values['operator']); $boundary = $values['boundary']; // canBeNull $operators = explode('or', $operator); $operator = trim($operators[0]); $canBeNull = isset($operators[1]) ? ' or value is NULL' : ''; // cantBeNull $operators = explode('and', $operator); $operator = trim($operators[0]); $cantBeNull = isset($operators[1]) ? ' and value is not NULL and value != \'0000-00-00\' and value != \'0000-00-00 00:00:00\'' : ''; //boundary $date = new CMS_date(); $date->setFormat($cms_language->getDateFormat()); $date->setLocalizedDate($boundary); $sqlOperator = " and (value " . $operator . " '" . SensitiveIO::sanitizeSQLString($date->getDBValue()) . "'" . $canBeNull . $cantBeNull . ")"; } // Search all values for this field $sql = "select\n distinct value\n from\n mod_subobject_date_" . $status . "\n where\n objectFieldID='" . $fieldID . "'\n " . $sqlOperator . "\n\t\t"; $q = new CMS_query($sql); $date = new CMS_date(); while (($value = $q->getValue('value')) !== false) { if ($value) { $date->setFromDBValue($value); if (isset($values['format']) && $values['format']) { $dateValue = date($values['format'], $date->getTimeStamp()); } else { $dateValue = $date->getLocalizedDate($cms_language->GetDateFormat()); } $allValues[$date->getTimeStamp()] = $dateValue; } } if (is_array($allValues) && $allValues) { ksort($allValues); foreach ($allValues as $id => $label) { $selected = $id == $values['selected'] ? ' selected="selected"' : ''; $return .= '<option title="' . io::htmlspecialchars($label) . '" value="' . $id . '"' . $selected . '>' . $label . '</option>'; } } return $return; }