/** * Get object as an array structure used for export * * @param array $params The export parameters. Not used here * @param array $files The reference to the found files used by object * @return array : the object array structure * @access public */ public function asArray($params = array(), &$files) { $image = $this->getImage(); $aRow = array('id' => $this->getID(), 'uuid' => $this->_uuid, 'label' => $this->_label, 'definition' => $this->getDefinition(), 'module' => $this->_modules->getTextDefinition(), 'groups' => $this->_groups->getTextDefinition(), 'useable' => $this->_useable, 'description' => $this->_description, 'image' => substr($image, strlen(PATH_REALROOT_WR))); if ($image) { if (!in_array($image, $files)) { $files[] = substr($image, strlen(PATH_REALROOT_WR)); } } return $aRow; }
/** * Writes the resource into persistence (MySQL for now). * * @return boolean true on success, false on failure * @access public */ function writeToPersistence() { $this->_status->writeToPersistence(); $sql_fields = "\n\t\t\tstatus_res='" . $this->_status->getID() . "',\n\t\t\teditorsStack_res='" . SensitiveIO::sanitizeSQLString($this->_editors->getTextDefinition()) . "'\n\t\t"; if ($this->_id) { $sql = "\n\t\t\t\tupdate\n\t\t\t\t\tresources\n\t\t\t\tset\n\t\t\t\t\t" . $sql_fields . "\n\t\t\t\twhere\n\t\t\t\t\tid_res='" . $this->_id . "'\n\t\t\t"; } else { $sql = "\n\t\t\t\tinsert into\n\t\t\t\t\tresources\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; }
/** * 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; }
/** * Writes the template into persistence (MySQL for now). * * @return boolean true on success, false on failure * @access public */ function writeToPersistence() { $sql_fields = "\n\t\t\tlabel_pt='" . SensitiveIO::sanitizeSQLString($this->_label) . "',\n\t\t\timage_pt='" . SensitiveIO::sanitizeSQLString($this->_image) . "',\n\t\t\tdefinitionFile_pt='" . SensitiveIO::sanitizeSQLString($this->_definitionFile) . "',\n\t\t\tgroupsStack_pt='" . SensitiveIO::sanitizeSQLString($this->_groups->getTextDefinition()) . "',\n\t\t\tmodulesStack_pt='" . SensitiveIO::sanitizeSQLString($this->_modules->getTextDefinition()) . "',\n\t\t\tinUse_pt='" . $this->_useable . "',\n\t\t\tdescription_pt='" . SensitiveIO::sanitizeSQLString($this->_description) . "',\n\t\t\twebsitesdenied_pt='" . SensitiveIO::sanitizeSQLString($this->_websitesdenied->getTextDefinition()) . "',\n\t\t\tprivate_pt='" . $this->_private . "',\n\t\t\tprintingCSOrder_pt='" . SensitiveIO::sanitizeSQLString(implode(";", $this->_printingClientSpaces)) . "'\n\t\t"; if ($this->_id) { // Some changes must be applied // to all private templates similar to this one using same xml file if ($this->_definitionFile) { $sql = "\n\t\t\t\t\tupdate\n\t\t\t\t\t\tpageTemplates\n\t\t\t\t\tset\n\t\t\t\t\t\tlabel_pt='" . SensitiveIO::sanitizeSQLString($this->_label) . "',\n\t\t\t\t\t\timage_pt='" . SensitiveIO::sanitizeSQLString($this->_image) . "',\n\t\t\t\t\t\tgroupsStack_pt='" . SensitiveIO::sanitizeSQLString($this->_groups->getTextDefinition()) . "',\n\t\t\t\t\t\tmodulesStack_pt='" . SensitiveIO::sanitizeSQLString($this->_modules->getTextDefinition()) . "',\n\t\t\t\t\t\tprintingCSOrder_pt='" . SensitiveIO::sanitizeSQLString(implode(";", $this->_printingClientSpaces)) . "'\n\t\t\t\t\twhere\n\t\t\t\t\t\tdefinitionFile_pt like '" . SensitiveIO::sanitizeSQLString($this->_definitionFile) . "'\n\t\t\t\t"; $q = new CMS_query($sql); } $sql = "\n\t\t\t\tupdate\n\t\t\t\t\tpageTemplates\n\t\t\t\tset\n\t\t\t\t\t" . $sql_fields . "\n\t\t\t\twhere\n\t\t\t\t\tid_pt='" . $this->_id . "'\n\t\t\t"; } else { $sql = "\n\t\t\t\tinsert into\n\t\t\t\t\tpageTemplates\n\t\t\t\tset\n\t\t\t\t\t" . $sql_fields; } $q = new CMS_query($sql); //pr($sql); if ($q->hasError()) { return false; } elseif (!$this->_id) { $this->_id = $q->getLastInsertedID(); } return true; }
/** * Get all info in one string * * @return string * @access public */ function toString() { return $this->_profileID . ':' . $this->_categoriesClearances->getTextDefinition(); }
/** * Writes the cmsprofile into persistence (MySQL for now). * * @return boolean true on success, false on failure * @access public */ function writeToPersistence() { $sql_fields = "\n\t\t\tadministrationClearance_pr='" . SensitiveIO::sanitizeSQLString($this->_adminClearance) . "',\n\t\t\tpageClearancesStack_pr='" . SensitiveIO::sanitizeSQLString($this->_pageClearances->getTextDefinition()) . "',\n\t\t\tvalidationClearancesStack_pr='" . SensitiveIO::sanitizeSQLString($this->_validationClearances->getTextDefinition()) . "',\n\t\t\tmoduleClearancesStack_pr='" . SensitiveIO::sanitizeSQLString($this->_moduleClearances->getTextDefinition()) . "',\n\t\t\ttemplateGroupsDeniedStack_pr='" . SensitiveIO::sanitizeSQLString($this->_templateGroupsDenied->getTextDefinition()) . "',\n\t\t\trowGroupsDeniedStack_pr='" . SensitiveIO::sanitizeSQLString($this->_rowGroupsDenied->getTextDefinition()) . "'\n\t\t"; if ($this->_id) { $sql = "\n\t\t\t\tupdate\n\t\t\t\t\tprofiles\n\t\t\t\tset\n\t\t\t\t\t" . $sql_fields . "\n\t\t\t\twhere\n\t\t\t\t\tid_pr='" . $this->_id . "'\n\t\t\t"; } else { $sql = "\n\t\t\t\tinsert into\n\t\t\t\t\tprofiles\n\t\t\t\tset\n\t\t\t\t\t" . $sql_fields; } //pr($sql); $q = new CMS_query($sql); if ($q->hasError()) { return false; } elseif (!$this->_id) { $this->_id = $q->getLastInsertedID(); } if (!sensitiveIO::isPositiveInteger($this->_moduleCategoriesClearances->getProfileID())) { $this->_moduleCategoriesClearances->setProfileID($this->_id); } // Write moduleCategories clearances to persistence also return $this->_moduleCategoriesClearances->writeToPersistence(); }
/** * 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(); }