Beispiel #1
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)
 {
     //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;
         }
     }
 }
Beispiel #2
0
    if ($status != $initialStatus) {
        //Replace all the status icons by the new one across the whole interface
        $tinyStatus = $cms_page->getStatus()->getHTML(true, $cms_user, MOD_STANDARD_CODENAME, $cms_page->getID());
        $statusId = $cms_page->getStatus()->getStatusId(MOD_STANDARD_CODENAME, $cms_page->getID());
        $xmlcontent = '
		<status><![CDATA[' . $status . ']]></status>
		<tinystatus><![CDATA[' . $tinyStatus . ']]></tinystatus>';
        $view->setContent($xmlcontent);
        $jscontent = '
		Automne.utils.updateStatus(\'' . $statusId . '\', response.responseXML.getElementsByTagName(\'status\').item(0).firstChild.nodeValue, response.responseXML.getElementsByTagName(\'tinystatus\').item(0).firstChild.nodeValue);
		';
        $view->addJavascript($jscontent);
        if ($edited && $edited !== true) {
            //send validators emails
            if (APPLICATION_ENFORCES_WORKFLOW) {
                $group_email = new CMS_emailsCatalog();
                $languages = CMS_languagesCatalog::getAllLanguages();
                $subjects = array();
                $bodies = array();
                switch ($edited) {
                    case RESOURCE_EDITION_MOVE:
                        foreach ($languages as $language) {
                            $subjects[$language->getCode()] = $language->getMessage(MESSAGE_PAGE_ACTION_EMAIL_MOVE_SUBJECT);
                            $bodies[$language->getCode()] = $language->getMessage(MESSAGE_EMAIL_VALIDATION_AWAITS) . "\n" . $language->getMessage(MESSAGE_PAGE_ACTION_EMAIL_MOVE_BODY, array($cms_page->getTitle() . ' (ID : ' . $cms_page->getID() . ')', $cms_user->getFullName()));
                        }
                        break;
                    case RESOURCE_EDITION_SIBLINGSORDER:
                        foreach ($languages as $language) {
                            $subjects[$language->getCode()] = $language->getMessage(MESSAGE_PAGE_ACTION_EMAIL_SIBLINGSORDER_SUBJECT);
                            $bodies[$language->getCode()] = $language->getMessage(MESSAGE_EMAIL_VALIDATION_AWAITS) . "\n" . $language->getMessage(MESSAGE_PAGE_ACTION_EMAIL_SIBLINGSORDER_BODY, array($cms_page->getTitle() . ' (ID : ' . $cms_page->getID() . ')', $cms_user->getFullName()));
                        }
Beispiel #3
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();
     }
 }
             $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;
     $deleted = false;
 }
 //log action
 $log = new CMS_log();
 $log->logResourceAction(CMS_log::LOG_ACTION_RESOURCE_VALIDATE_EDITION, $cms_user, $validation->getModuleCodename(), $res->getStatus(), "", $res);
 if (!$deleted && $res->getStatus()) {
     //Replace all the status icons by the new one across the whole interface
     $status = $res->getStatus()->getHTML(false, $cms_user, $validation->getModuleCodename(), $res->getID());
 case 'useralerts':
     //set return to false by default
     $content = array('success' => false);
     if (is_a($user, "CMS_profile_user")) {
         //set all alerts levels
         $user->resetAlertLevel();
         foreach ($alerts as $codename => $levels) {
             $level = array_sum($levels);
             $user->setAlertLevel($level, $codename);
         }
         $user->writeToPersistence();
         $log = new CMS_log();
         $log->logMiscAction(CMS_log::LOG_ACTION_PROFILE_USER_EDIT, $cms_user, "User : "******" (edit alerts levels)");
         //if this not a personal profile update, send email alert
         if (!$personalProfile) {
             $group_email = new CMS_emailsCatalog();
             $languages = CMS_languagesCatalog::getAllLanguages();
             $subjects = array();
             $bodies = array();
             foreach ($languages as $language) {
                 $subjects[$language->getCode()] = $language->getMessage(MESSAGE_EMAIL_USER_EDIT_SUBJECT);
                 $bodies[$language->getCode()] = $language->getMessage(MESSAGE_EMAIL_USER_EDIT_BODY, array($user->getLogin())) . "\n" . $language->getMessage(MESSAGE_EMAIL_USER_EDIT_ALERTLEVEL);
             }
             $group_email->setUserMessages(array($user), $bodies, $subjects, ALERT_LEVEL_PROFILE, MOD_STANDARD_CODENAME);
             $group_email->sendMessages();
         }
         $content = array('success' => true);
         $cms_message = $cms_language->getMessage(MESSAGE_PAGE_USER_DATA_REGISTERED);
     }
     $view->setContent($content);
     break;