/** * Get array of contacts data by Email * * @param string $data * @return array of CMS_profile_user * @access public */ static function getByEmail($data) { if (!SensitiveIO::isValidEmail($data)) { CMS_grandFather::raiseError('$data must be a valid email : ' . $data); return array(); } $aUsers = array(); //create the request to look for the data $sql = 'select `id_cd` from `contactDatas` where `email_cd` = "' . sensitiveIO::sanitizeSQLString($data) . '"'; //launching the request $q = new CMS_query($sql); //checking if ok and looping on results if (!$q->hasError()) { while (($oTmpUserId = $q->getValue("id_cd")) !== false) { //creating the user and filling the data $oTmpUser = CMS_profile_usersCatalog::getByID($oTmpUserId); if (!$oTmpUser->hasError()) { $oTmpUser->getContactData(); if (!$oTmpUser->hasError()) { $aUsers[] = $oTmpUser; } } } unset($oTmpUser, $oTmpUserId); } return $aUsers; }
/** * @param array(CMS_users) $users users to send message to * @param array(CMS_profile_user) $users * @param array($language=>$subject) $messages indexed by languages code * @param array($language=>$subject) $subjects indexed by languages code * @param integer $alertLevel * @return void * @access public */ function setUserMessages($users, $messages, $subjects, $alertLevel = ALERT_LEVEL_VALIDATION, $module = MOD_STANDARD_CODENAME) { $mainURL = CMS_websitesCatalog::getMainURL(); $template = is_file(PATH_MAIL_TEMPLATES_FS) ? PATH_MAIL_TEMPLATES_FS : ''; foreach ($users as $user) { //if is integer create user object if (!is_a($user, "CMS_user_profile") && SensitiveIO::isPositiveInteger($user)) { $user = CMS_profile_usersCatalog::getByID($user); } //if user hasn't alert level for this module or user is not active anymore, skip it if (!$user->hasAlertLevel($alertLevel, $module) || $user->isDeleted() || !$user->isActive()) { //CMS_grandFather::raiseError('user '.$user->getFullName().' has no alerts for level '.$alertLevel.' for module '.$module); continue; } $userLang = $user->getLanguage(); $email = new CMS_email(); if ($user->getEmail()) { if ($email->setEmailTo($user->getEmail())) { $email->setSubject($subjects[$userLang->getCode()], true); $email->setBody($messages[$userLang->getCode()]); $email->setFooter($userLang->getMessage(self::MESSAGE_EMAIL_BODY_URLS, array(APPLICATION_LABEL, $mainURL . "/", $mainURL . PATH_ADMIN_WR . "/"))); $email->setTemplate($template); $this->_messages[] = $email; } else { $this->raiseError("Email Catalog: email invalid (" . $user->getEmail() . ") for user : " . $user->getFullName()); } } } }
/** * Get the resource's owner * * @access public * @return CMS_profile_user, or null if none found */ function getOwner() { if ($this->_ownerID > 0) { return CMS_profile_usersCatalog::getByID($this->_ownerID); } else { return null; } }
/** * get an object value * * @param string $name : the name of the value to get * @param string $parameters (optional) : parameters for the value to get * @return multidimentionnal array : the object values structure * @access public */ function getValue($name, $parameters = '') { global $cms_language; $params = $this->getParamsValues(); $name = $name !== 0 ? $name : "0"; switch ($name) { case 'ids': $ids = array(); foreach (array_keys($this->_subfieldValues) as $subFieldID) { if (is_object($this->_subfieldValues[$subFieldID])) { $ids[] = $this->_subfieldValues[$subFieldID]->getValue(); } } return $ids; break; case 'values': return $this->_subfieldValues; break; case 'count': return sizeof($this->_subfieldValues); break; default: if (sensitiveIO::isPositiveInteger($name) || $name === "0") { if (!is_object($this->_subfieldValues[$name])) { return ''; } switch ($parameters) { case 'id': return $this->_subfieldValues[$name]->getValue(); break; case 'label': //load user/group $userGroup = $params['isGroup'] ? CMS_profile_usersGroupsCatalog::getByID($this->_subfieldValues[$name]->getValue()) : CMS_profile_usersCatalog::getByID($this->_subfieldValues[$name]->getValue()); if (is_object($userGroup) && !$userGroup->hasError()) { return $params['isGroup'] ? io::htmlspecialchars($userGroup->getLabel()) : io::htmlspecialchars($userGroup->getFirstName() . ' ' . $userGroup->getLastName()); } return ''; break; case 'email': //load user/group $userGroup = $params['isGroup'] ? CMS_profile_usersGroupsCatalog::getByID($this->_subfieldValues[$name]->getValue()) : CMS_profile_usersCatalog::getByID($this->_subfieldValues[$name]->getValue()); if (is_object($userGroup) && !$userGroup->hasError()) { return $params['isGroup'] ? '' : io::htmlspecialchars($userGroup->getEmail()); } return ''; break; } } else { if (!isset($this->_subfieldValues[0]) || !is_object($this->_subfieldValues[0])) { return ''; } switch ($name) { case 'label': //load user/group $userGroup = $params['isGroup'] ? CMS_profile_usersGroupsCatalog::getByID($this->_subfieldValues[0]->getValue()) : CMS_profile_usersCatalog::getByID($this->_subfieldValues[0]->getValue()); if (is_object($userGroup) && !$userGroup->hasError()) { return $params['isGroup'] ? io::htmlspecialchars($userGroup->getLabel()) : io::htmlspecialchars($userGroup->getFirstName() . ' ' . $userGroup->getLastName()); } return ''; break; case 'email': //load user/group $userGroup = $params['isGroup'] ? CMS_profile_usersGroupsCatalog::getByID($this->_subfieldValues[0]->getValue()) : CMS_profile_usersCatalog::getByID($this->_subfieldValues[0]->getValue()); if (is_object($userGroup) && !$userGroup->hasError()) { return $params['isGroup'] ? '' : io::htmlspecialchars($userGroup->getEmail()); } return ''; break; case 'id': return $this->_subfieldValues[0]->getValue(); break; default: return parent::getValue($name, $parameters); break; } } break; } }
/** * Gets the users for a group * Static function. * * @param integer $groupID * @param boolean returnObjects : return CMS_profile_user objects (default) or array of userId * @access public */ static function getGroupUsers($groupID, $returnObjects = true) { $sql = "\n\t\t\tselect\n\t\t\t\tid_pru\n\t\t\tfrom\n\t\t\t\tprofilesUsers,\n\t\t\t\tprofileUsersByGroup\n\t\t\twhere\n\t\t\t\tuserId_gu=id_pru\n\t\t\t\tand deleted_pru=0\n\t\t\t\tand groupId_gu='" . SensitiveIO::sanitizeSQLString($groupID) . "'\n\t\t\torder by\n\t\t\t\tlastName_pru,\n\t\t\t\tfirstName_pru\n\t\t"; $q = new CMS_query($sql); $users = array(); while ($id = $q->getValue("id_pru")) { if ($returnObjects) { $usr = CMS_profile_usersCatalog::getByID($id); if (is_a($usr, "CMS_profile_user") && !$usr->hasError()) { $users[$id] = $usr; } } else { $users[$id] = $id; } } return $users; }
/** * 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) { //if script concern a field, pass to it if (isset($parameters['field']) && sensitiveIO::isPositiveInteger($parameters['field'])) { if (!is_object($this->_objectValues[$parameters['field']]) || !method_exists($this->_objectValues[$parameters['field']], 'scriptTask')) { return false; } //then pass task to field return $this->_objectValues[$parameters['field']]->scriptTask($parameters); } else { //this is an object related script switch ($parameters['task']) { case 'emailNotification': //instanciate user $user = CMS_profile_usersCatalog::getByID($parameters['validator']); if ($this->userHasClearance($user, CLEARANCE_MODULE_EDIT)) { //get Object definition $objectDef = $this->getObjectDefinition(); //get module $codename = CMS_poly_object_catalog::getModuleCodenameForObjectType($objectDef->getID()); switch ($parameters['type']) { case 'validate': $group_email = new CMS_emailsCatalog(); $languages = CMS_languagesCatalog::getAllLanguages(); $subjects = array(); $bodies = array(); //editors $editorsIds = $parameters['editors']; $editors = array(); foreach ($editorsIds as $editorId) { $editor = CMS_profile_usersCatalog::getByID($editorId); if (is_a($editor, 'CMS_profile_user') && !$editor->hasError()) { $editors[] = $editor; } } //$editors = $this->getEditors(); $editorsInfos = ''; foreach ($editors as $editor) { $editorsInfos .= $editorsInfos ? ",\n" : ''; $editorsInfos .= $editor->getFullName() . ($editor->getEmail() ? ' (' . $editor->getEmail() . ')' : ''); } foreach ($languages as $language) { $subjects[$language->getCode()] = $language->getMessage(self::MESSAGE_POLYMOD_ACTION_EMAIL_SUBJECT, array($objectDef->getLabel($language)), MOD_POLYMOD_CODENAME); $bodies[$language->getCode()] = $language->getMessage(MESSAGE_EMAIL_VALIDATION_AWAITS) . "\n" . $language->getMessage(self::MESSAGE_POLYMOD_ACTION_EMAIL_BODY, array($objectDef->getLabel($language), $this->getLabel(), $editorsInfos), MOD_POLYMOD_CODENAME); } $group_email->setUserMessages(array($user), $bodies, $subjects, ALERT_LEVEL_VALIDATION, $codename); $group_email->sendMessages(); break; case 'delete': $group_email = new CMS_emailsCatalog(); $languages = CMS_languagesCatalog::getAllLanguages(); $subjects = array(); $bodies = array(); //editors $editorsIds = $parameters['editors']; $editors = array(); foreach ($editorsIds as $editorId) { $editor = CMS_profile_usersCatalog::getByID($editorId); if (is_a($editor, 'CMS_profile_user') && !$editor->hasError()) { $editors[] = $editor; } } //$editors = $this->getEditors(); $editorsInfos = ''; foreach ($editors as $editor) { $editorsInfos .= $editorsInfos ? ",\n" : ''; $editorsInfos .= $editor->getFullName() . ($editor->getEmail() ? ' (' . $editor->getEmail() . ')' : ''); } foreach ($languages as $language) { $subjects[$language->getCode()] = $language->getMessage(self::MESSAGE_POLYMOD_ACTION_EMAIL_DELETE_SUBJECT, array($objectDef->getLabel($language)), MOD_POLYMOD_CODENAME); $bodies[$language->getCode()] = $language->getMessage(MESSAGE_EMAIL_VALIDATION_AWAITS) . "\n" . $language->getMessage(self::MESSAGE_POLYMOD_ACTION_EMAIL_DELETE_BODY, array($objectDef->getLabel($language), $this->getLabel(), $editorsInfos), MOD_POLYMOD_CODENAME); } $group_email->setUserMessages(array($user), $bodies, $subjects, ALERT_LEVEL_VALIDATION, $codename); $group_email->sendMessages(); break; default: $this->raiseError('Unknown script task to do : ' . print_r($parameters, true)); return false; break; } } return true; break; default: $this->raiseError('Unknown script task to do : ' . print_r($parameters, true)); return false; break; } } }
} } if (is_a($group, "CMS_profile_usersGroup") && is_a($user, "CMS_profile_user")) { //add group $user->addGroup($groupId); //then write user profile into persistence $user->writeToPersistence(); $log = new CMS_log(); $log->logMiscAction(CMS_log::LOG_ACTION_PROFILE_USER_EDIT, $cms_user, "User : "******" (add group to user)"); } else { $cms_message = $cms_language->getMessage(MESSAGE_PAGE_USER_OR_GROUP_UNKNOWN); } break; case 'deluser': if ($userId) { $user = CMS_profile_usersCatalog::getByID($userId); if (!$user || $user->hasError()) { $user = false; } } if (is_a($group, "CMS_profile_usersGroup") && is_a($user, "CMS_profile_user")) { //Get current user groups ids $userGroupIds = CMS_profile_usersGroupsCatalog::getGroupsOfUser($user, true, true); //first reset profile clearances $user->resetClearances(); //then loop through user groups foreach ($userGroupIds as $userGroupId) { if ($userGroupId == $groupId) { //remove user to group $oldGroup = CMS_profile_usersGroupsCatalog::getByID($groupId); if ($oldGroup->removeUser($user)) {
* * == END LICENSE == * * Editor configuration settings. * * Follow this link for more information: * http://docs.fckeditor.net/FCKeditor_2.x/Developers_Guide/Configuration/Configuration_Options */ // $Id: fckconfig.php,v 1.7 2010/03/08 16:44:28 sebastien Exp $ //for this page, HTML output compression is not welcome. define("ENABLE_HTML_COMPRESSION", false); //load requirements (FE only because it can be used in FE and BO) require_once dirname(__FILE__) . '/../../cms_rc_frontend.php'; if (!is_object($cms_user)) { //initialize public user $cms_user = CMS_profile_usersCatalog::getByID(ANONYMOUS_PROFILEUSER_ID); } // Prevent the browser from caching the result. // Date in the past header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // always modified header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // HTTP/1.1 header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: post-check=0, pre-check=0', false); // HTTP/1.0 header('Pragma: no-cache'); //send document UTF-8 BOM (do not remove) header('Content-type: text/javascript; charset=UTF-8'); echo '' . "\n"; //include modules codes in output file
/** * Get user object * * @return user object * @access public */ public static function getUser() { if (!io::isPositiveInteger(self::$_userID)) { return false; } return CMS_profile_usersCatalog::getByID(self::$_userID); }
/** * Remove User * * @var integer or CMS_profile_user * @access public */ function removeUser(&$user) { if (is_a($user, "CMS_profile_user")) { if (SensitiveIO::isInSet($user->getUserId(), $this->_users)) { $users = array(); foreach ($this->_users as $userId) { if ($userId != $user->getUserId()) { $users[] = $userId; } } $this->_users = $users; //then remove categories clearance to user because they are only associated to group $user->deleteCategoriesClearances(); } } elseif (SensitiveIO::isPositiveInteger($user)) { if (SensitiveIO::isInSet($user, $this->_users)) { $users = array(); foreach ($this->_users as $userId) { if ($userId != $user) { $users[] = $userId; } } $this->_users = $users; //then remove categories clearance to user because they are only associated to group $user = CMS_profile_usersCatalog::getByID($user); if (is_a($user, "CMS_profile_user")) { $user->deleteCategoriesClearances(); } } } else { $this->raiseError('Incorrect user type'); return false; } //Clear polymod cache //CMS_cache::clearTypeCacheByMetas('polymod', array('resource' => 'users')); CMS_cache::clearTypeCache('polymod'); return true; }
/** * Get by resource * * @param CMS_ * @return array(CMS_log) * @access public */ static function getByResourceAction($moduleCodename, $resourceId, $action, $limit = false) { $sql = "\n\t\t\tselect\n\t\t\t\t*\n\t\t\tfrom\n\t\t\t\tlog\n\t\t\twhere\n\t\t\t\tmodule_log='" . sensitiveIO::sanitizeSQLString($moduleCodename) . "'\n\t\t\t\tand resource_log='" . sensitiveIO::sanitizeSQLString($resourceId) . "'"; if (is_array($action)) { $sql .= " and action_log in (" . sensitiveIO::sanitizeSQLString(implode(',', $action)) . ")"; } else { $sql .= " and action_log='" . sensitiveIO::sanitizeSQLString($action) . "'"; } $sql .= "\n\t\t\torder by\n\t\t\t\tdatetime_log desc\n\t\t"; if ($limit && sensitiveIO::isPositiveInteger($limit)) { $sql .= " limit 0, " . $limit; } $logs = array(); $q = new CMS_query($sql); if ($q->getNumRows()) { $users = array(); while ($r = $q->getArray()) { if (!isset($users[$r["user_log"]])) { $users[$r["user_log"]] = CMS_profile_usersCatalog::getByID($r["user_log"]); } $lg = new CMS_log($r, $users[$r["user_log"]]); if (!$lg->hasError()) { $logs[] = $lg; } } } return $logs; }
/** * Returns all the validators. * Static function. * * @param string $moduleCodename The codename of the module to validate * @return array(CMS_profile_user) * @access public */ static function getValidators($moduleCodename) { $sql = "\n\t\t\tselect\n\t\t\t\tuserId_puv\n\t\t\tfrom\n\t\t\t\tprofilesUsers_validators,\n\t\t\t\tprofilesUsers\n\t\t\twhere\n\t\t\t\tmodule_puv='" . SensitiveIO::sanitizeSQLString($moduleCodename) . "'\n\t\t\t\tand userId_puv = id_pru\n\t\t\t\tand active_pru = 1\n\t\t\t\tand deleted_pru = 0\n\t\t"; $q = new CMS_query($sql); $users = array(); $users_ids = array(); while ($id = $q->getValue("userId_puv")) { $usr = CMS_profile_usersCatalog::getByID($id); if (!$usr->hasError()) { $users[$usr->getLastName() . '-' . $id] = $usr; $users_ids[] = $id; } } //add the users with 'edit & validate all' right $sql = "\n\t\t\tselect\n\t\t\t\tid_pru\n\t\t\tfrom\n\t\t\t\tprofilesUsers,\n\t\t\t\tprofiles\n\t\t\twhere\n\t\t\t\tprofile_pru = id_pr\n\t\t\t\tand administrationClearance_pr & " . CLEARANCE_ADMINISTRATION_EDITVALIDATEALL . "\n\t\t\t\tand active_pru = 1\n\t\t\t\tand deleted_pru = 0\n\t\t"; $q = new CMS_query($sql); while ($id = $q->getValue("id_pru")) { if (!in_array($id, $users_ids)) { $usr = CMS_profile_usersCatalog::getByID($id); if (!$usr->hasError()) { $users[$usr->getLastName() . '-' . $id] = $usr; } } } //sort users by last name uksort($users, array('io', 'natcasecmp')); return $users; }
$view->show(); } //do action on resource //check for lock if ($action != 'unlock' && $resource->getLock() && $resource->getLock() != $cms_user->getUserId()) { CMS_grandFather::raiseError('Object ' . $resourceId . ' of module ' . $codename . ' is currently locked by another user and can\'t be updated.'); $lockuser = CMS_profile_usersCatalog::getByID($resource->getLock()); $view->setActionMessage($cms_language->getmessage(MESSAGE_ERROR_ELEMENT_LOCKED, array($lockuser->getFullName()))); $view->show(); } $initialStatus = $resource->getStatus()->getHTML(false, $cms_user, $codename, $resource->getID()); switch ($action) { case 'unlock': if ($resource->getLock() && $resource->getLock() != $cms_user->getUserId() && !$cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL)) { CMS_grandFather::raiseError('Object ' . $resourceId . ' of module ' . $codename . ' is currently locked by another user and can\'t be unlocked.'); $lockuser = CMS_profile_usersCatalog::getByID($resource->getLock()); $view->setActionMessage($cms_language->getmessage(MESSAGE_ERROR_ELEMENT_REALY_LOCKED, array($lockuser->getFullName()))); $view->show(); } if ($resource->getLock()) { $resource->unlock(); } break; default: CMS_grandFather::raiseError('Unknown action ' . $action . ' to do for resource ' . $resourceId . ' with value : ' . $value); $view->show(); break; } //set user message if any if ($cms_message) { $view->setActionMessage($cms_message);
foreach ($elements as $element) { $usr = CMS_profile_usersCatalog::getByID($element[0]); if (is_a($usr, 'CMS_profile_user') && !$usr->hasError()) { $users[] = $usr; } } foreach ($languages as $language) { $subjects[$language->getCode()] = $language->getMessage(MESSAGE_PAGE_ACTION_EMAIL_REFUSE_SUBJECT); $bodies[$language->getCode()] = $language->getMessage(MESSAGE_PAGE_ACTION_EMAIL_REFUSE_BODY, $args); } break; case VALIDATION_OPTION_TRANSFER: if ($transferUser) { //send an email to the transferred validator $args = array($cms_user->getFullName(), $validation->getValidationLabel() . " (ID : " . $validation->getResourceID() . ")", $mod->getLabel($cms_language), SensitiveIO::sanitizeHTMLString($comment)); $users = array(CMS_profile_usersCatalog::getByID($transferUser)); foreach ($languages as $language) { $subjects[$language->getCode()] = $language->getMessage(MESSAGE_PAGE_ACTION_EMAIL_TRANSFER_SUBJECT); $bodies[$language->getCode()] = $language->getMessage(MESSAGE_PAGE_ACTION_EMAIL_TRANSFER_BODY, $args); } } break; } $group_email = new CMS_emailsCatalog(); $group_email->setUserMessages($users, $bodies, $subjects, ALERT_LEVEL_VALIDATION, $validation->getModuleCodename()); $group_email->sendMessages(); //check if resource still exists $resUpdated = $validation->getResource(); $deleted = true; if ($resUpdated && is_object($resUpdated)) { $res = $resUpdated;
/** * Gets the page reminded editors for an edition * * @param integer $edition The edition the user should have made to be returned * @return array(CMS_profile_user) The editors * @access public */ function getRemindedEditors($edition) { $elements = $this->_remindedEditors->getElementsWithOneValue($edition, 2); $editors = array(); foreach ($elements as $element) { $user = CMS_profile_usersCatalog::getByID($element[0]); if ($user) { $editors[] = $user; } } return $editors; }
/** * Get the editors for an edition, or all the editors if no edition given. * * @param integer $edition We want the editors that edited this edition, or all if it's set to false * @return array(CMS_profile_user) The users, or an empty array if none found * @access public */ function getEditors($edition = false) { if ($edition) { $usersIDs = $this->_editors->getElementsWithOneValue($edition, 2); } else { $usersIDs = $this->_editors->getElements(); } $users = array(); foreach ($usersIDs as $userID) { $user = CMS_profile_usersCatalog::getByID($userID[0]); if (is_a($user, 'CMS_profile_user') && !$user->hasError()) { $users[] = $user; } } return $users; }
/** * Test user auto login from cookie values * * @return boolean true if autologin accepted, false otherwise * @access private */ function _autoLogin() { $attrs = @explode("|", base64_decode($_COOKIE[CMS_session::getAutoLoginCookieName()])); $id_ses = (int) $attrs[0]; $session_id = $attrs[1]; if ($id_ses > 0 && $session_id) { $sql = "\n\t\t\t\tselect\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\tsessions\n\t\t\t\twhere\n\t\t\t\t\tid_ses = '" . SensitiveIO::sanitizeSQLString($id_ses) . "'\n\t\t\t\t\tand phpid_ses = '" . SensitiveIO::sanitizeSQLString($session_id) . "'\n\t\t\t\t\tand cookie_expire_ses != '0000-00-00 00:00:00'\n\t\t\t"; if (CHECK_REMOTE_IP_MASK && isset($_SERVER['REMOTE_ADDR'])) { //Check for a range in IPv4 or for the exact address in IPv6 if (filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { $a_ip_seq = explode(".", $_SERVER['REMOTE_ADDR']); $sql .= "and remote_addr_ses like '" . SensitiveIO::sanitizeSQLString($a_ip_seq[0] . "." . $a_ip_seq[1] . ".") . "%'\n\t\t\t\t\t"; } else { $sql .= "and remote_addr_ses = '" . SensitiveIO::sanitizeSQLString($_SERVER['REMOTE_ADDR']) . "'\n\t\t\t\t\t"; } } $q = new CMS_query($sql); if ($q->getNumRows() == 1) { $this->_user = CMS_profile_usersCatalog::getByID($q->getValue('user_ses')); if ($this->_user && !$this->_user->hasError() && !$this->_user->isDeleted() && $this->_user->isActive()) { $this->_messages[] = self::AUTH_AUTOLOGIN_VALID; $this->_result = new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $this->_user->getUserId(), $this->_messages); return true; } else { $this->_messages[] = self::AUTH_AUTOLOGIN_INVALID_USER; $this->_result = new Zend_Auth_Result(Zend_Auth_Result::FAILURE, null, $this->_messages); } } } return false; }
//try to instanciate the requested page $cms_page = CMS_tree::getPageByID($currentPage); //instanciate page and check if user has view rights on it if (isset($cms_page) && $cms_page->hasError()) { CMS_grandFather::raiseError('Error on page : ' . $cms_page->getID()); $view->show(); } //check for edit rights for user if (!$cms_user->hasPageClearance($cms_page->getID(), CLEARANCE_PAGE_EDIT)) { CMS_grandFather::raiseError('Error, user has no rights on page : ' . $cms_page->getID()); $view->show(); } //check for lock if ($cms_page->getLock() && $cms_page->getLock() != $cms_user->getUserId()) { CMS_grandFather::raiseError('Page ' . $currentPage . ' is currently locked by another user and can\'t be updated.'); $lockuser = CMS_profile_usersCatalog::getByID($cms_page->getLock()); $view->setActionMessage($cms_language->getMessage(MESSAGE_PAGE_ERROR_LOCKED, array($lockuser->getFullName()))); $view->show(); } $initialStatus = $cms_page->getStatus()->getHTML(false, $cms_user, MOD_STANDARD_CODENAME, $cms_page->getID()); //page edited status $edited = false; switch ($action) { case 'add-row': //instanciate the clientspace $clientSpace = CMS_moduleClientSpace_standard_catalog::getByTemplateAndTagID($tpl, $cs, $visualMode == PAGE_VISUALMODE_FORM); //generate row unique ID $uniqueId = md5(uniqid()); //add row to CS $row = $clientSpace->addRow($rowId, $uniqueId, $index); if ($row) {
/** * 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(); } }