/** * Writes these clearances into persistence (MySQL for now). * * @return boolean true on success, false on failure * @access public */ function writeToPersistence() { if ($this->_profileID && is_a($this->_categoriesClearances, "CMS_stack")) { $err = 0; // Delete old clearances $sql = "\n\t\t\t\tdelete\n\t\t\t\tfrom\n\t\t\t\t\tmodulesCategories_clearances\n\t\t\t\twhere\n\t\t\t\t\tprofile_mcc='" . $this->_profileID . "'\n\t\t\t"; $q = new CMS_query($sql); if ($q->hasError()) { $err++; $this->raiseError("Error on sql statement : " . var_dump($sql)); } // Insert new ones $elements = $this->_categoriesClearances->getElements(); if (is_array($elements) && $elements) { $values = ''; foreach ($elements as $v) { $values .= $values ? ',' : ''; $values .= "('" . $this->_profileID . "', '" . $v[0] . "', '" . $v[1] . "')"; } $sql = "\n\t\t\t\t\tinsert into modulesCategories_clearances\n\t\t\t\t\t\t(profile_mcc, category_mcc, clearance_mcc)\n\t\t\t\t\tvalues " . $values . "\n\t\t\t\t"; $q = new CMS_query($sql); if ($q->hasError()) { $err++; $this->raiseError("Error on sql statement : " . var_dump($sql)); } } return !$err ? true : false; } }
/** * Does the template include module clientspace * * @param string $codename The module codename * @return boolean * @access public */ function hasModule($codename) { $elements = $this->_modules->getElements(); foreach ($elements as $element) { if ($element[0] == $codename) { return true; } } return false; }
/** * Gets the groups the row belongs to. * * @return array(string) The groups represented by their string in an array * @access public */ function getGroups() { $groups_arrayed = $this->_groups->getElements(); $groups = array(); foreach ($groups_arrayed as $group_arrayed) { $groups[$group_arrayed[0]] = $group_arrayed[0]; } natcasesort($groups); return $groups; }
/** * 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; }
/** * Has Validation Clearance * * @param string $moduleCodename * @return boolean * @access public */ function hasValidationClearance($moduleCodename = false) { if ($moduleCodename) { $clearanceOk = false; $clearances = $this->_validationClearances->getElementsWithOneValue($moduleCodename, 1); if (isset($clearances[0][0]) || $this->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL)) { return true; } } else { if (sizeof($this->_validationClearances->getElements()) || $this->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL)) { return true; } } return false; }
/** * Get All Groups * Static function * * @return array(string) * @access public */ static function getAllGroups($returnStack = false, $reset = false) { static $rowGroups; if (!isset($rowGroups) || $reset) { $rowGroups = array(); $sql = ' select distinct groupsStack_row from mod_standard_rows '; $q = new CMS_query($sql); while ($data = $q->getArray()) { $groupStackString = $data["groupsStack_row"]; $groupStack = new CMS_stack(); $groupStack->setTextDefinition($groupStackString); foreach ($groupStack->getElements() as $group) { if (!SensitiveIO::isInSet($group[0], $rowGroups) && $group[0]) { $rowGroups[] = $group[0]; } } } } //sort groups natcasesort($rowGroups); if ($returnStack) { $stack = new CMS_stack(); $stack->setValuesByAtom(1); foreach ($rowGroups as $rowGroup) { $stack->add($rowGroup); } return $stack; } else { return $rowGroups; } }
/** * Get All Groups * Static function * * @return array(string) * @access public */ static function getAllGroups($returnStack = false) { static $templateGroups; if (!isset($templateGroups)) { $templateGroups = array(); $sql = ' select distinct groupsStack_pt from pageTemplates where private_pt=0 '; $q = new CMS_query($sql); while ($data = $q->getArray()) { $groupStackString = $data["groupsStack_pt"]; $groupStack = new CMS_stack(); $groupStack->setTextDefinition($groupStackString); foreach ($groupStack->getElements() as $group) { if (!SensitiveIO::isInSet($group[0], $templateGroups) && $group[0]) { $templateGroups[] = $group[0]; } } } } //sort groups natcasesort($templateGroups); if ($returnStack) { $stack = new CMS_stack(); $stack->setValuesByAtom(1); foreach ($templateGroups as $tplGroup) { $stack->add($tplGroup); } return $stack; } else { return $templateGroups; } }
/** * 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(); } }