예제 #1
0
 /**
  * Constructor.
  * initializes the template if the id is given.
  *
  * @param integer $id DB id
  * @return void
  * @access public
  */
 function __construct($id = 0)
 {
     $this->_groups = new CMS_stack();
     $this->_modules = new CMS_stack();
     $this->_websitesdenied = new CMS_stack();
     if ($id) {
         if (!SensitiveIO::isPositiveInteger($id)) {
             $this->raiseError("Id is not a positive integer");
             return;
         }
         $sql = "\n\t\t\t\tselect\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\tpageTemplates\n\t\t\t\twhere\n\t\t\t\t\tid_pt='{$id}'\n\t\t\t";
         $q = new CMS_query($sql);
         if ($q->getNumRows()) {
             $data = $q->getArray();
             $this->_id = $id;
             $this->_label = $data["label_pt"];
             $this->_image = $data["image_pt"];
             $this->_definitionFile = $data["definitionFile_pt"];
             $this->_groups->setTextDefinition($data["groupsStack_pt"]);
             $this->_modules->setTextDefinition($data["modulesStack_pt"]);
             $this->_useable = $data["inUse_pt"];
             $this->_private = $data["private_pt"];
             $this->_printingClientSpaces = trim($data["printingCSOrder_pt"]) ? explode(";", $data["printingCSOrder_pt"]) : array();
             $this->_description = $data["description_pt"];
             $this->_websitesdenied->setTextDefinition($data["websitesdenied_pt"]);
         } else {
             $this->raiseError("Unknown ID :" . $id);
         }
     }
 }
예제 #2
0
파일: row.php 프로젝트: davidmottet/automne
 /**
  * Constructor.
  *
  * @param integer $id the DB ID of the row
  * @param string $tagID the XML Tag ID of the row (if instansiated from the tag)
  * @return void
  * @access public
  */
 function __construct($id = 0, $tagID = false)
 {
     $this->_tagID = $tagID;
     $this->_modules = new CMS_stack();
     $this->_groups = new CMS_stack();
     if ($id) {
         if (!SensitiveIO::isPositiveInteger($id)) {
             $this->raiseError("Id is not a positive integer");
             return;
         }
         $sql = "\n\t\t\t\tselect\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\tmod_standard_rows\n\t\t\t\twhere\n\t\t\t\t\tid_row='{$id}'\n\t\t\t";
         $q = new CMS_query($sql);
         if ($q->getNumRows()) {
             $data = $q->getArray();
             $this->_id = $id;
             $this->_label = $data["label_row"];
             $this->_groups->setTextDefinition($data["groupsStack_row"]);
             $this->_definitionFile = $data["definitionFile_row"];
             $this->_modules->setTextDefinition($data["modulesStack_row"]);
             $this->_image = $data["image_row"] ? $data["image_row"] : $this->_image;
             $this->_useable = $data["useable_row"] ? true : false;
             $this->_description = $data["description_row"];
             $this->_tplfilter = trim($data["tplfilter_row"]) ? explode(';', $data["tplfilter_row"]) : array();
             $this->_uuid = $data["uuid_row"];
         } else {
             $this->raiseError("Unknown id :" . $id);
         }
     }
 }
예제 #3
0
 /**
  * Constructor.
  * initializes the resource if the id is given
  *
  * @param integer $id DB id
  * @return void
  * @access public
  */
 function CMS_resource($id = 0)
 {
     if ($id) {
         if (SensitiveIO::isPositiveInteger($id)) {
             $sql = "\n\t\t\t\t\tselect\n\t\t\t\t\t\t*\n\t\t\t\t\tfrom\n\t\t\t\t\t\tresources,\n\t\t\t\t\t\tresourceStatuses\n\t\t\t\t\twhere\n\t\t\t\t\t\tid_res='{$id}'\n\t\t\t\t\t\tand status_res=id_rs\n\t\t\t\t";
             $q = new CMS_query($sql);
             if ($q->getNumRows()) {
                 $data = $q->getArray();
                 $this->_id = $id;
                 $this->_status = new CMS_resourceStatus($data);
                 if ($this->_status->hasError()) {
                     $this->raiseError("Unfound status :" . $data["status_res"]);
                     return;
                 }
                 //build editors stack. If stack is malformed, it's a minor error, so proceed.
                 $this->_editors = new CMS_stack();
                 if (!$this->_editors->setTextDefinition($data["editorsStack_res"])) {
                     $this->raiseError("Editors stack malformed");
                     $this->_editors->emptyStack();
                 }
             } else {
                 $this->raiseError("Unknown ID :" . $id);
             }
         } elseif (is_array($id)) {
             $data = $id;
             $this->_id = $data["id_res"];
             $this->_status = new CMS_resourceStatus($data);
             if ($this->_status->hasError()) {
                 $this->raiseError("Unfound status :" . $data["status_res"]);
                 return;
             }
             //build editors stack. If stack is malformed, it's a minor error, so proceed.
             $this->_editors = new CMS_stack();
             if (!$this->_editors->setTextDefinition($data["editorsStack_res"])) {
                 $this->raiseError("Editors stack malformed");
                 $this->_editors->emptyStack();
             }
         } else {
             $this->raiseError("Id is not a positive integer nor array");
             return;
         }
     } else {
         $this->_status = new CMS_resourceStatus();
         $this->_editors = new CMS_stack();
     }
 }
예제 #4
0
 /**
  * Constructor.
  * initializes the page if the id is given.
  *
  * @param integer $id DB id
  * @return void
  * @access public
  */
 function __construct($id = 0)
 {
     $this->_remindedEditors = new CMS_stack();
     $this->_lastReminder = new CMS_date();
     $this->_lastFileCreation = new CMS_date();
     if ($id) {
         if (!SensitiveIO::isPositiveInteger($id)) {
             $this->raiseError("Id is not a positive integer");
             return;
         }
         $sql = "\n\t\t\t\tselect\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\tpages,\n\t\t\t\t\tresources,\n\t\t\t\t\tresourceStatuses\n\t\t\t\twhere\n\t\t\t\t\tid_pag='{$id}' and\n\t\t\t\t\tresource_pag = id_res and\n\t\t\t\t\tstatus_res = id_rs\n\t\t\t";
         $q = new CMS_query($sql);
         if ($q->getNumRows()) {
             $data = $q->getArray();
             $this->_pageID = $id;
             $this->_remindedEditors->setTextDefinition($data["remindedEditorsStack_pag"]);
             $this->_lastReminder->setFromDBValue($data["lastReminder_pag"]);
             $this->_templateID = $data["template_pag"];
             $this->_lastFileCreation->setFromDBValue($data["lastFileCreation_pag"]);
             $this->_pageURL = $data["url_pag"];
             $this->_protected = $data["protected_pag"] ? true : false;
             $this->_https = $data["https_pag"] ? true : false;
             //initialize super-class
             parent::__construct($data);
         } else {
             //display this error only if we are in HTTP mode (not cli) because it is only relevant in this mode
             if (!defined('APPLICATION_EXEC_TYPE') || APPLICATION_EXEC_TYPE == 'http') {
                 $this->raiseError("Unknown ID :" . $id . ' from ' . io::getCallInfos(3));
             } else {
                 $this->raiseError();
             }
         }
     } else {
         //initialize super-class
         parent::__construct();
     }
 }
예제 #5
0
 /**
  * Constructor.
  * initializes the profile from the database if the id
  * is given
  *
  * @param integer $id if of profile 
  * @return void
  * @access public
  */
 function __construct($id = 0)
 {
     // Initiate Stack objects
     $this->_pageClearances = new CMS_stack();
     $this->_validationClearances = new CMS_stack();
     $this->_validationClearances->setValuesByAtom(1);
     $this->_moduleClearances = new CMS_stack();
     $this->_templateGroupsDenied = new CMS_stack();
     $this->_templateGroupsDenied->setValuesByAtom(1);
     // Assume 1 atom
     $this->_rowGroupsDenied = new CMS_stack();
     $this->_rowGroupsDenied->setValuesByAtom(1);
     // Assume 1 atom
     // Categories clearance only
     $this->_moduleCategoriesClearances = new CMS_moduleCategoriesClearances();
     if ($id) {
         if (SensitiveIO::isPositiveInteger($id)) {
             $this->_id = $id;
             $sql = "\n\t\t\t\t\tselect\n\t\t\t\t\t\t*\n\t\t\t\t\tfrom\n\t\t\t\t\t\tprofiles\n\t\t\t\t\twhere\n\t\t\t\t\t\tid_pr='{$id}'\n\t\t\t\t";
             $q = new CMS_query($sql);
             if ($q->getNumRows()) {
                 $data = $q->getArray();
                 // Get integer values
                 $this->_adminClearance = $data["administrationClearance_pr"];
                 // Categories clearance only
                 $this->_moduleCategoriesClearances = new CMS_moduleCategoriesClearances($this->_id);
                 //Get values Catch errors?
                 if (!$this->_pageClearances->setTextDefinition($data["pageClearancesStack_pr"]) || !$this->_validationClearances->setTextDefinition($data["validationClearancesStack_pr"]) || !$this->_moduleClearances->setTextDefinition($data["moduleClearancesStack_pr"]) || !$this->_templateGroupsDenied->setTextDefinition($data["templateGroupsDeniedStack_pr"]) || !$this->_rowGroupsDenied->setTextDefinition($data["rowGroupsDeniedStack_pr"])) {
                     $this->raiseError("Incorrect Stack formation in profile id " . $id);
                 }
             } else {
                 $this->raiseError("Unknown DB ID : " . $id);
             }
         } elseif (is_array($id)) {
             $data = $id;
             // Get integer values
             $this->_id = $data["id_pr"];
             $this->_adminClearance = $data["administrationClearance_pr"];
             // Categories clearance only
             $this->_moduleCategoriesClearances = new CMS_moduleCategoriesClearances($this->_id);
             //Get values Catch errors?
             if (!$this->_pageClearances->setTextDefinition($data["pageClearancesStack_pr"]) || !$this->_validationClearances->setTextDefinition($data["validationClearancesStack_pr"]) || !$this->_moduleClearances->setTextDefinition($data["moduleClearancesStack_pr"]) || !$this->_templateGroupsDenied->setTextDefinition($data["templateGroupsDeniedStack_pr"]) || !$this->_rowGroupsDenied->setTextDefinition($data["rowGroupsDeniedStack_pr"])) {
                 $this->raiseError("Incorrect Stack formation in profile id " . $id);
             }
         } else {
             $this->raiseError("Id is not a positive integer nor array");
             return;
         }
     } else {
         //set default templates groups
         $this->_templateGroupsDenied = CMS_pageTemplatesCatalog::getAllGroups(true);
         //set default rows groups
         $this->_rowGroupsDenied = CMS_rowsCatalog::getAllGroups(true);
     }
     if ($this->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL)) {
         $this->_moduleCategoriesClearances->setAdminLevel(true);
     }
 }
예제 #6
0
 /**
  * Destroy the module
  *
  * @return void
  * @access public
  */
 function destroy()
 {
     global $cms_user;
     // Check module exists and is polymod
     if (!$this->isDestroyable()) {
         return false;
     }
     // CHECK USED ROWS
     $rowsIds = CMS_rowsCatalog::getByModules(array($this->_codename), false, false);
     //delete all module rows
     foreach ($rowsIds as $rowId) {
         $row = CMS_rowsCatalog::getByID($rowId);
         if (is_object($row)) {
             $row->destroy();
         }
     }
     // TREAT CATEGORIES
     $attrs = array("module" => $this->_codename, "language" => CMS_languagesCatalog::getDefaultLanguage(), "level" => -1, "root" => -1, "cms_user" => $cms_user, "clearanceLevel" => CLEARANCE_MODULE_EDIT, "strict" => false);
     $cats = CMS_moduleCategories_catalog::getAll($attrs);
     if ($cats) {
         foreach ($cats as $cat) {
             // Destroy category
             $cat->destroy();
         }
     }
     // TREAT MODULE & VALIDATIONS RIGHTS
     $sql = "\n\t\t\tselect \n\t\t\t\t*\n\t\t\tfrom\n\t\t\t\tprofiles\n\t\t\twhere\n\t\t\t\tmoduleClearancesStack_pr like '" . io::sanitizeSQLString($this->_codename) . ",%'\n\t\t\t\t or moduleClearancesStack_pr like '%;" . io::sanitizeSQLString($this->_codename) . ",%'\n\t\t ";
     $q = new CMS_query($sql);
     if ($q->getNumRows()) {
         while ($r = $q->getArray()) {
             $stack = new CMS_stack();
             $stack->setTextDefinition($r['moduleClearancesStack_pr']);
             $stack->delAllWithOneKey($this->_codename);
             $qInsert = new CMS_query("update profiles set moduleClearancesStack_pr='" . io::sanitizeSQLString($stack->getTextDefinition()) . "' where id_pr='" . $r['id_pr'] . "'");
         }
     }
     $sql = "\n\t\t\tselect \n\t\t\t\t*\n\t\t\tfrom\n\t\t\t\tprofiles\n\t\t\twhere\n\t\t\t\tvalidationClearancesStack_pr like '" . io::sanitizeSQLString($this->_codename) . ";%'\n\t\t\t\t or validationClearancesStack_pr like '%;" . io::sanitizeSQLString($this->_codename) . ";%'\n\t\t\t\t or validationClearancesStack_pr = '" . io::sanitizeSQLString($this->_codename) . "'\n\t\t\t";
     $q = new CMS_query($sql);
     if ($q->getNumRows()) {
         while ($r = $q->getArray()) {
             $stack = new CMS_stack();
             $stack->setTextDefinition($r['validationClearancesStack_pr']);
             $stack->delAllWithOneKey($this->_codename);
             $qInsert = new CMS_query("update profiles set validationClearancesStack_pr='" . io::sanitizeSQLString($stack->getTextDefinition()) . "' where id_pr='" . $r['id_pr'] . "'");
         }
     }
     //remove module files
     if (CMS_file::deltreeSimulation(PATH_MODULES_FILES_FS . '/' . $this->_codename, true)) {
         CMS_file::deltree(PATH_MODULES_FILES_FS . '/' . $this->_codename, true);
     }
     //remove JS and CSS
     if (is_dir(PATH_JS_FS . '/modules/' . $this->_codename) && CMS_file::deltreeSimulation(PATH_JS_FS . '/modules/' . $this->_codename, true)) {
         CMS_file::deltree(PATH_JS_FS . '/modules/' . $this->_codename, true);
     }
     if (is_dir(PATH_CSS_FS . '/modules/' . $this->_codename) && CMS_file::deltreeSimulation(PATH_CSS_FS . '/modules/' . $this->_codename, true)) {
         CMS_file::deltree(PATH_CSS_FS . '/modules/' . $this->_codename, true);
     }
     $cssFiles = $this->getCSSFiles('', true);
     foreach ($cssFiles as $mediaCssFiles) {
         foreach ($mediaCssFiles as $cssFile) {
             CMS_file::deleteFile(PATH_REALROOT_FS . '/' . $cssFile);
         }
     }
     //Clear polymod cache
     //CMS_cache::clearTypeCacheByMetas('polymod', array('module' => $this->_codename));
     CMS_cache::clearTypeCache('polymod');
     // Destroy module
     return parent::destroy();
 }
예제 #7
0
    /**
     * 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;
        }
    }
예제 #8
0
    /**
     * 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;
        }
    }
예제 #9
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();
     }
 }