Exemple #1
0
 /**
  * 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;
 }
Exemple #2
0
 /**
  * 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;
 }
     }
     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]) {
                 //mandatory ?
                 $formok = false;
             }
Exemple #4
0
 /**
  * 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;
 }
Exemple #5
0
 /**
  * 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;
     }
 }
 /**
  * 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;
 }
 /**
  * Return a variable value of a given name and check it for a given dataType
  *
  * @param string $varType : the variable type to get between var, request, session
  * @param string $name : the variable name to get
  * @param string $dataType : the type of value to check
  * @param mixed $varValue : the var value (optionnal to avoid global problems if vars are declared in previous PHP codes)
  * @return mixed : the variable value
  * @access public
  * @static
  */
 static function getVarContent($varType, $name, $dataType, $varValue = '')
 {
     if (!$name || !$dataType) {
         return false;
     }
     switch ($varType) {
         case 'request':
             if ($dataType == 'string') {
                 $dataType = 'safestring';
                 //Force safestring to avoid XSS
             }
             $varContent = isset($_REQUEST[$name]) ? $_REQUEST[$name] : null;
             break;
         case 'session':
             $varContent = isset($_SESSION[$name]) ? $_SESSION[$name] : null;
             break;
         case 'var':
             global ${$name};
             $varContent = isset(${$name}) && ${$name} !== null ? ${$name} : $varValue;
             break;
         case 'constant':
             $varContent = defined($name) ? constant($name) : null;
             break;
         case 'server':
             $varContent = isset($_SERVER[$name]) ? $_SERVER[$name] : null;
             break;
         default:
             CMS_grandFather::raiseError('Unknown var type to get : ' . $varType);
             return false;
             break;
     }
     //pr('Vartype : '.$varType.' - Name : '.$name.' - Datatype : '.$dataType.' - Content : '.$varContent);
     switch ($dataType) {
         case 'int':
             return (int) $varContent;
             break;
         case 'date':
         case 'datetime':
         case 'localisedDate':
             if ($varContent) {
                 global $cms_language;
                 $date = new CMS_date();
                 $date->setDebug(false);
                 $date->setFormat($cms_language->getDateFormat());
                 $date->setLocalizedDate($varContent);
                 if ($date->hasError()) {
                     return '';
                 }
                 switch ($dataType) {
                     case 'date':
                         return $date->getDBValue(true);
                         break;
                     case 'datetime':
                         return $date->getDBValue(false);
                         break;
                     case 'localisedDate':
                         return $date->getLocalizedDate();
                         break;
                 }
             } else {
                 return '';
             }
             break;
         case 'string':
         case 'unsafestring':
             return (string) $varContent;
             break;
         case 'safestring':
             //safestring return string without any XSS vector
             return SensitiveIO::sanitizeHTMLString((string) $varContent);
             break;
         case 'array':
             if (is_array($varContent)) {
                 return $varContent;
             } else {
                 return array();
                 //false
             }
             break;
         case 'bool':
         case 'boolean':
             if ($varContent === 'true') {
                 return true;
             } elseif ($varContent === 'false') {
                 return false;
             } else {
                 return (bool) $varContent;
             }
             break;
         case 'email':
             if (sensitiveIO::IsValidEmail($varContent)) {
                 return $varContent;
             }
             break;
         default:
             CMS_grandFather::raiseError('Unknown data type to get : ' . $dataType);
             return '';
             break;
     }
     return '';
 }
Exemple #8
0
 /**
  * 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();
     }
 }
Exemple #9
0
 /**
  * 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;
 }