/** * Returns all the resource validations the user can do * Static function. * * @param CMS_user $user The user we want the validations of * @param string $module_codebame The module codename we want the validations of, if ommitted, validations for all the modules will be returned * @return array(string=>CMS_resourceValidation) The validations to do, indexed by module codename * @access public */ static function getValidations(&$user, $module_codename = false) { if (!is_a($user, "CMS_user")) { parent::raiseError("User is not a valid CMS_user object"); return; } if ($module_codename) { if (!($module = CMS_resourceModulesCatalog::getByCodename($codename))) { return; } } if ($module) { $modules = array($module); } else { $modules = CMS_modulesCatalog::getAll(); } $validations = array(); foreach ($modules as $aModule) { if (!$user->hasValidationClearance($aModule->getID())) { continue; } $validations_to_add = $aModule->getValidations($user); if ($validations_to_add) { $validations[$aModule->getCodename()] = $validations_to_add; } } return $validations; }
/** * Constructor. * initializes object. * @param integer $treatmentMode The current treatment mode (see constants in cms_rc.php for accepted values). * @param integer $visualizationMode The current visualization mode (see constants in cms_rc.php for accepted values). * @param object $treatedObject The reference object to treat. * * @return void * @access public */ function __construct($treatmentMode, $visualizationMode, &$treatedObject) { $this->_treatmentMode = $treatmentMode; $this->_visualizationMode = $visualizationMode; $this->_treatedObject =& $treatedObject; $this->_modules = CMS_modulesCatalog::getAll("id"); foreach ($this->_modules as $codename => $aModule) { $moduleTreatment = $aModule->getWantedTags($this->_treatmentMode, $this->_visualizationMode, $this->_treatedObject); if ($treatmentMode == MODULE_TREATMENT_PAGECONTENT_TAGS && isset($moduleTreatment['atm-meta-tags'])) { $this->raiseError("Tag atm-meta-tags must be treated in MODULE_TREATMENT_PAGEHEADER_TAGS mode. Module " . $codename . " try to use atm-meta-tags in MODULE_TREATMENT_PAGECONTENT_TAGS mode which is deprecated since Automne V4.0.0RC3. Edit file " . $codename . ".php and change MODULE_TREATMENT_PAGECONTENT_TAGS by MODULE_TREATMENT_PAGEHEADER_TAGS in methods getWantedTags and treatWantedTag for tag atm-meta-tags"); unset($moduleTreatment['atm-meta-tags']); } if (is_array($moduleTreatment) && $moduleTreatment) { //if module return tags, save it. $this->_modulesTreatment[$codename] = $moduleTreatment; } else { //else remove useless modules from list unset($this->_modules[$codename]); } } return true; }
/** * Replace vars like {object:field:type} or {var|session|request|page:name:type}. Called during definition compilation * * @param string $text : the text which need to be replaced * @param boolean reverse : reverse single and double quotes useage (default is false : double quotes) * @param array $optionalReplacement : optionnal replacement to do * @param boolean $cleanNotMatches : remove vars without matches * @param mixed $matchCallback : function name or array(object classname, object method) which represent a valid callback function to execute on matches * @return text : the text replaced * @access public */ function preReplaceVars($text, $reverse = false, $cleanNotMatches = false, $matchCallback = array('CMS_polymod_definition_parsing', 'encloseString'), $returnMatchedVarsArray = false) { static $replacements; //if no text => return if (!$text || !trim($text)) { return $text; } //substitute simple replacement values $preReplaceCount = 0; $text = preg_replace("#{([a-zA-Z]+)}#", '@@@\\1@@@', $text, -1, $preReplaceCount); $count = 1; //loop on text for vars to replace if any while (preg_match_all("#{[^{}\n]+}#", $text, $matches) && $count) { $matches = array_unique($matches[0]); //get all tags handled by modules if (!$replacements) { //create replacement array $replacements = array(); $modules = CMS_modulesCatalog::getAll("id"); foreach ($modules as $codename => $aModule) { $moduleReplacements = $aModule->getModuleReplacements(); if (is_array($moduleReplacements) && $moduleReplacements) { foreach ($moduleReplacements as $pattern => $replacement) { $replacements[$pattern] = $replacement; } } } } $replace = $replacements; //pr($matches); if ($reverse) { $reversedReplace = array(); foreach ($replace as $key => $value) { $reversedReplace[str_replace("'", "\\\\'", $key)] = $value; } $replace = $reversedReplace; } $count = 0; $matchesValues = preg_replace(array_keys($replace), $replace, $matches, -1, $count); //create vars conversion table $replace = array(); if ($matchesValues) { if (isset($this->_parameters['module'])) { $externalReferences = CMS_poly_object_catalog::getFieldsReferencesUsage($this->_parameters['module']); } else { $externalReferences = CMS_poly_object_catalog::getFieldsReferencesUsage(); } foreach ($matches as $key => $match) { //record external references for cache reference if ($externalReferences) { foreach ($externalReferences as $id => $type) { if (strpos($match, '[\'fields\'][' . $id . ']') !== false || strpos($match, '[\\\'fields\\\'][' . $id . ']') !== false) { //CMS_grandFather::log(print_r($this->_elements, true)); $this->_elements = array_merge_recursive($type, (array) $this->_elements); //CMS_grandFather::log(print_r($this->_elements, true)); } } } //record used pages for cache reference if (strpos($match, '{page:') !== false) { $this->_elements['module'][] = MOD_STANDARD_CODENAME; } //record used users for cache reference if (strpos($match, '{user:'******'resource'][] = 'users'; } if ($match != $matchesValues[$key]) { $matchValue = $matchesValues[$key]; } else { $matchValue = null; } //apply callback if any to value if (isset($matchValue)) { if ($matchCallback !== false) { if (is_callable($matchCallback)) { $replace[$match] = call_user_func($matchCallback, $matchValue, $reverse); } else { CMS_grandFather::raiseError("Unknown callback function : " . $matchCallback); return false; } } else { $replace[$match] = $matchValue; } } elseif ($cleanNotMatches) { $replace[$match] = ''; } } } //return matched vars if needed if ($returnMatchedVarsArray) { //substitute simple replacement values if ($preReplaceCount) { $replace = preg_replace("#\\@\\@\\@([a-zA-Z]+)\\@\\@\\@#", '{\\1}', $replace); } return $replace; } else { //then replace variables in text and return it $text = str_replace(array_keys($replace), $replace, $text); } } //substitute simple replacement values if ($preReplaceCount) { $text = preg_replace("#\\@\\@\\@([a-zA-Z]+)\\@\\@\\@#", '{\\1}', $text); } return $text; }
define("MESSAGE_PAGE_VERSION", 542); define("MESSAGE_PAGE_ABOUT_MESSAGE", 672); define("MESSAGE_TOOLBAR_HELP_MESSAGE", 673); define("MESSAGE_PAGE_TITLE", 644); //load interface instance $view = CMS_view::getInstance(); //set default display mode for this page $view->setDisplayMode(CMS_view::SHOW_RAW); //This file is an admin file. Interface must be secure $view->setSecure(); if (!defined('MOD_POLYMOD_CODENAME')) { define('MOD_POLYMOD_CODENAME', 'polymod'); } //show version number $lastUpdate = AUTOMNE_LASTUPDATE ? date($cms_language->getDateFormat() . ' - H:i:s', AUTOMNE_LASTUPDATE) : $cms_language->getMessage(MESSAGE_PAGE_NEVER); $modules = CMS_modulesCatalog::getAll(); $modulesInfo = '<ul>'; foreach ($modules as $module) { if (!$module->isPolymod() && $module->getCodename() != MOD_STANDARD_CODENAME) { $modulesInfo .= '<li>' . $module->getLabel($cms_language); if (file_exists(PATH_MODULES_FS . '/' . $module->getCodename() . '/VERSION')) { $modulesInfo .= ' - ' . $cms_language->getMessage(MESSAGE_PAGE_VERSION) . ' : ' . file_get_contents(PATH_MODULES_FS . '/' . $module->getCodename() . '/VERSION'); } if ($module->getCodename() == 'mail' && file_exists(PATH_MODULES_FS . '/mailing/VERSION')) { $modulesInfo .= ' - ' . $cms_language->getMessage(MESSAGE_PAGE_VERSION) . ' : ' . file_get_contents(PATH_MODULES_FS . '/mailing/VERSION'); } $modulesInfo .= '</li>'; } } $modulesInfo .= '</ul>'; //Scripts content
/** * Constructor. * initializes object. * * @return void * @access public */ function __construct() { //get all modules $this->_modules = CMS_modulesCatalog::getAll("id"); }
/** * Automne autoload handler * * @return true * @access public */ static function autoload($classname) { static $classes, $modules; if (!isset($classes)) { $classes = array('cms_stack' => PATH_PACKAGES_FS . '/common/stack.php', 'cms_contactdata' => PATH_PACKAGES_FS . '/common/contactdata.php', 'cms_contactdatas_catalog' => PATH_PACKAGES_FS . '/common/contactdatascatalog.php', 'cms_href' => PATH_PACKAGES_FS . '/common/href.php', 'cms_log_catalog' => PATH_PACKAGES_FS . '/common/logcatalog.php', 'cms_log' => PATH_PACKAGES_FS . '/common/log.php', 'cms_languagescatalog' => PATH_PACKAGES_FS . '/common/languagescatalog.php', 'cms_actions' => PATH_PACKAGES_FS . '/common/actions.php', 'cms_action' => PATH_PACKAGES_FS . '/common/action.php', 'cms_search' => PATH_PACKAGES_FS . '/common/search.php', 'cms_contactdatas_catalog' => PATH_PACKAGES_FS . '/common/contactdatascatalog.php', 'cms_email' => PATH_PACKAGES_FS . '/common/email.php', 'cms_emailscatalog' => PATH_PACKAGES_FS . '/common/emailscatalog.php', 'cms_query' => PATH_PACKAGES_FS . '/common/query.php', 'cms_date' => PATH_PACKAGES_FS . '/common/date.php', 'cms_language' => PATH_PACKAGES_FS . '/common/language.php', 'cms_oembed' => PATH_PACKAGES_FS . '/common/oembed.php', 'sensitiveio' => PATH_PACKAGES_FS . '/common/sensitiveio.php', 'io' => PATH_PACKAGES_FS . '/common/sensitiveio.php', 'cms_context' => PATH_PACKAGES_FS . '/dialogs/context.php', 'cms_wysiwyg_toolbar' => PATH_PACKAGES_FS . '/dialogs/toolbar.php', 'cms_dialog' => PATH_PACKAGES_FS . '/dialogs/dialog.php', 'cms_jsdialog' => PATH_PACKAGES_FS . '/dialogs/jsdialog.php', 'cms_view' => PATH_PACKAGES_FS . '/dialogs/view.php', 'cms_submenus' => PATH_PACKAGES_FS . '/dialogs/submenus.php', 'cms_submenu' => PATH_PACKAGES_FS . '/dialogs/submenu.php', 'cms_dialog_listboxes' => PATH_PACKAGES_FS . '/dialogs/dialoglistboxes.php', 'cms_dialog_href' => PATH_PACKAGES_FS . '/dialogs/dialoghref.php', 'cms_fileupload_dialog' => PATH_PACKAGES_FS . '/dialogs/fileupload.php', 'cms_loadingdialog' => PATH_PACKAGES_FS . '/dialogs/loadingDialog.php', 'cms_texteditor' => PATH_PACKAGES_FS . '/dialogs/texteditor.php', 'cms_stats' => PATH_PACKAGES_FS . '/dialogs/stats.php', 'cms_patch' => PATH_PACKAGES_FS . '/files/patch.php', 'cms_file' => PATH_PACKAGES_FS . '/files/filesManagement.php', 'cms_archive' => PATH_PACKAGES_FS . '/files/archive.php', 'cms_gzip_file' => PATH_PACKAGES_FS . '/files/archive-gzip.php', 'cms_tar_file' => PATH_PACKAGES_FS . '/files/archive-tar.php', 'cms_zip_file' => PATH_PACKAGES_FS . '/files/archive-zip.php', 'cms_fileupload' => PATH_PACKAGES_FS . '/files/fileupload.php', 'cms_cache' => PATH_PACKAGES_FS . '/files/cache.php', 'cms_image' => PATH_PACKAGES_FS . '/files/image.php', 'cms_module' => PATH_MODULES_FS . '/module.php', 'cms_modulescodes' => PATH_MODULES_FS . '/modulesCodes.php', 'cms_modulevalidation' => PATH_MODULES_FS . '/moduleValidation.php', 'cms_superresource' => PATH_MODULES_FS . '/super_resource.php', 'cms_modulecategory' => PATH_MODULES_FS . '/modulecategory.php', 'cms_modulescatalog' => PATH_MODULES_FS . '/modulescatalog.php', 'cms_modulecategories_catalog' => PATH_MODULES_FS . '/modulecategoriescatalog.php', 'cms_modulestags' => PATH_MODULES_FS . '/modulesTags.php', 'cms_moduleclientspace' => PATH_MODULES_FS . '/moduleclientspace.php', 'cms_superresource' => PATH_MODULES_FS . '/super_resource.php', 'cms_polymod' => PATH_MODULES_FS . '/polymod.php', 'cms_modulepolymodvalidation' => PATH_MODULES_FS . '/modulePolymodValidation.php', 'cms_module_export' => PATH_MODULES_FS . '/export.php', 'cms_module_import' => PATH_MODULES_FS . '/import.php', 'cms_rowscatalog' => PATH_MODULES_FS . '/standard/rowscatalog.php', 'cms_row' => PATH_MODULES_FS . '/standard/row.php', 'cms_block' => PATH_MODULES_FS . '/standard/block.php', 'cms_block_file' => PATH_MODULES_FS . '/standard/blockfile.php', 'cms_block_flash' => PATH_MODULES_FS . '/standard/blockflash.php', 'cms_block_image' => PATH_MODULES_FS . '/standard/blockimage.php', 'cms_blockscatalog' => PATH_MODULES_FS . '/standard/blockscatalog.php', 'cms_block_text' => PATH_MODULES_FS . '/standard/blocktext.php', 'cms_block_varchar' => PATH_MODULES_FS . '/standard/blockvarchar.php', 'cms_block_link' => PATH_MODULES_FS . '/standard/blocklink.php', 'cms_moduleclientspace_standard' => PATH_MODULES_FS . '/standard/clientspace.php', 'cms_moduleclientspace_standard_catalog' => PATH_MODULES_FS . '/standard/clientspacescatalog.php', 'cms_xmltag_admin' => PATH_MODULES_FS . '/standard/tags/admin.php', 'cms_xmltag_noadmin' => PATH_MODULES_FS . '/standard/tags/noadmin.php', 'cms_xmltag_edit' => PATH_MODULES_FS . '/standard/tags/edit.php', 'cms_xmltag_noedit' => PATH_MODULES_FS . '/standard/tags/noedit.php', 'cms_xmltag_title' => PATH_MODULES_FS . '/standard/tags/title.php', 'cms_xmltag_page' => PATH_MODULES_FS . '/standard/tags/page.php', 'cms_xmltag_website' => PATH_MODULES_FS . '/standard/tags/website.php', 'cms_xmltag_anchor' => PATH_MODULES_FS . '/standard/tags/anchor.php', 'cms_xmltag_header' => PATH_MODULES_FS . '/standard/tags/header.php', 'cms_xmltag_redirect' => PATH_MODULES_FS . '/standard/tags/redirect.php', 'cms_xmltag_xml' => PATH_MODULES_FS . '/standard/tags/xml.php', 'cms_xmltag_js_add' => PATH_MODULES_FS . '/standard/tags/js-add.php', 'cms_xmltag_css_add' => PATH_MODULES_FS . '/standard/tags/css-add.php', 'cms_linxescatalog' => PATH_PACKAGES_FS . '/pageContent/linxescatalog.php', 'cms_xml2array' => PATH_PACKAGES_FS . '/pageContent/xml2Array.php', 'cms_linx' => PATH_PACKAGES_FS . '/pageContent/linx.php', 'cms_linxcondition' => PATH_PACKAGES_FS . '/pageContent/linxcondition.php', 'cms_linxdisplay' => PATH_PACKAGES_FS . '/pageContent/linxdisplay.php', 'cms_linxnodespec' => PATH_PACKAGES_FS . '/pageContent/linxnodespec.php', 'cms_xmltag' => PATH_PACKAGES_FS . '/pageContent/xmltag.php', 'cms_xmlparser' => PATH_PACKAGES_FS . '/pageContent/xmlparser.php', 'cms_domdocument' => PATH_PACKAGES_FS . '/pageContent/xmldomdocument.php', 'cms_array2xml' => PATH_PACKAGES_FS . '/pageContent/array2Xml.php', 'cms_array2csv' => PATH_PACKAGES_FS . '/pageContent/array2csv.php', 'processmanager' => PATH_PACKAGES_FS . '/scripts/backgroundScript/processmanager.php', 'backgroundscript' => PATH_PACKAGES_FS . '/scripts/backgroundScript/backgroundscript.php', 'cms_scriptsmanager' => PATH_PACKAGES_FS . '/scripts/scriptsmanager.php', 'cms_tree' => PATH_PACKAGES_FS . '/tree/tree.php', 'cms_page' => PATH_PACKAGES_FS . '/tree/page.php', 'cms_pagetemplatescatalog' => PATH_PACKAGES_FS . '/tree/pagetemplatescatalog.php', 'cms_pagetemplate' => PATH_PACKAGES_FS . '/tree/pagetemplate.php', 'cms_websitescatalog' => PATH_PACKAGES_FS . '/tree/websitescatalog.php', 'cms_website' => PATH_PACKAGES_FS . '/tree/website.php', 'cms_profile_user' => PATH_PACKAGES_FS . '/user/profileuser.php', 'cms_profile' => PATH_PACKAGES_FS . '/user/profile.php', 'cms_modulecategoriesclearances' => PATH_PACKAGES_FS . '/user/profilemodulecategoriesclearances.php', 'cms_profile_userscatalog' => PATH_PACKAGES_FS . '/user/profileuserscatalog.php', 'cms_profile_usersgroupscatalog' => PATH_PACKAGES_FS . '/user/profileusersgroupscatalog.php', 'cms_profile_usersgroup' => PATH_PACKAGES_FS . '/user/profileusersgroup.php', 'cms_session' => PATH_PACKAGES_FS . '/user/session.php', 'cms_auth' => PATH_PACKAGES_FS . '/user/auth.php', 'cms_resource' => PATH_PACKAGES_FS . '/workflow/resource.php', 'cms_resourcestatus' => PATH_PACKAGES_FS . '/workflow/resourcestatus.php', 'cms_resourcevalidationinfo' => PATH_PACKAGES_FS . '/workflow/resourcevalidationinfo.php', 'cms_resourcevalidation' => PATH_PACKAGES_FS . '/workflow/resourcevalidation.php', 'cms_resourcevalidationscatalog' => PATH_PACKAGES_FS . '/workflow/resourcevalidationscatalog.php', 'fckeditor' => PATH_MAIN_FS . '/fckeditor/fckeditor.php', 'ckeditor' => PATH_MAIN_FS . '/ckeditor/ckeditor.php', 'jsmin' => PATH_MAIN_FS . '/jsmin/jsmin.php', 'cssmin' => PATH_MAIN_FS . '/cssmin/cssmin.php', 'phpexcel' => PATH_MAIN_FS . '/phpexcel/PHPExcel.php', 'phpexcel_iofactory' => PATH_MAIN_FS . '/phpexcel/PHPExcel/IOFactory.php', 'lessc' => PATH_MAIN_FS . '/lessphp/lessc.inc.php'); } $file = ''; if (isset($classes[strtolower($classname)])) { $file = $classes[strtolower($classname)]; } elseif (strpos($classname, 'CMS_module_') === 0) { //modules lazy loading if (file_exists(PATH_MODULES_FS . '/' . substr($classname, 11) . '.php')) { $file = PATH_MODULES_FS . '/' . substr($classname, 11) . '.php'; } else { //here, we need to stop return false; } } if (!$file) { //Zend Framework if (substr(strtolower($classname), 0, 5) == 'zend_') { chdir(PATH_MAIN_FS); require_once PATH_MAIN_FS . '/Zend/Loader/Autoloader.php'; if (!Zend_Loader_Autoloader::autoload($classname)) { return false; } /*only for stats*/ if (STATS_DEBUG) { CMS_stats::$filesLoaded++; } if (STATS_DEBUG && VIEW_SQL) { CMS_stats::$filesTable[] = array('class' => $classname, 'from' => io::getCallInfos(3)); CMS_stats::$memoryTable[] = array('class' => $classname, 'memory' => memory_get_usage(), 'peak' => memory_get_peak_usage()); } return true; } //try modules Autoload if (!isset($modules)) { $modules = CMS_modulesCatalog::getAll("id"); } $polymodDone = false; foreach ($modules as $codename => $module) { if ((!$polymodDone && $module->isPolymod() || !$module->isPolymod()) && method_exists($module, 'load')) { if (!$polymodDone && $module->isPolymod()) { $polymodDone = true; } $file = $module->load($classname); } elseif ($polymodDone && $module->isPolymod()) { unset($modules[$codename]); } if ($file) { break; } } //in case this website do not use any polymod module if (!$polymodDone && !$file) { require_once PATH_MODULES_FS . '/polymod.php'; $file = CMS_polymod::load($classname); } } if ($file) { require_once $file; /*only for stats*/ if (defined('STATS_DEBUG') && defined('VIEW_SQL')) { if (STATS_DEBUG) { CMS_stats::$filesLoaded++; } if (STATS_DEBUG && VIEW_SQL) { CMS_stats::$filesTable[] = array('file' => $file, 'class' => $classname, 'from' => io::getCallInfos(3)); CMS_stats::$memoryTable[] = array('file' => $file, 'class' => $classname, 'memory' => memory_get_usage(), 'peak' => memory_get_peak_usage()); } } } }
if (sizeof($new_parameters)) { $module->setAndWriteParameters($new_parameters); } $cms_message = $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE); $parameters = $module->getParameters(false, true); break; case 'delete_module': if ($module->destroy()) { $cms_message = $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE); } else { $cms_message = 'Error during module deletion ...'; } unset($module); unset($modules); unset($moduleCodename); $modules = CMS_modulesCatalog::getAll("label", false, true); break; } $content = ''; $dialog->setTitle($cms_language->getMessage(MESSAGE_PAGE_TITLE_APPLICATIONS) . " :: " . $cms_language->getMessage(MESSAGE_PAGE_TITLE), 'picto_modules.gif'); //Show a list of all modules if (!sizeof($modules)) { $content .= $cms_language->getMessage(MESSAGE_PAGE_EMPTY_SET) . "<br /><br />"; $content .= ' <form action="polymod_mod.php" method="post"> <input type="submit" class="admin_input_submit" value="' . $cms_language->getMessage(MESSAGE_PAGE_ACTION_NEW) . '" /> </form><br />'; } else { $content .= ' <form action="' . $_SERVER["SCRIPT_NAME"] . '" method="post"> ' . $cms_language->getMessage(MESSAGE_PAGE_CHOOSE_MODULE) . ' :
/** * Get count of validations available for the given user * * @param CMS_profile_user The user we want the validations for * @return integer * @access public */ static function getValidationsCount(&$user) { $modules = CMS_modulesCatalog::getAll(); $validationsCount = 0; if (is_array($modules)) { foreach ($modules as $module) { if (method_exists($module, "getValidationsCount")) { $validationsCount += $module->getValidationsCount($user); } elseif (method_exists($module, "getValidationsInfo")) { $validations = $module->getValidationsInfo($user); $validationsCount += $validations ? count($validations) : 0; } elseif (is_object($module)) { $validations = $module->getValidations($user); $validationsCount += $validations ? count($validations) : 0; } } } return $validationsCount; }
/** * Writes into persistence (MySQL for now), along with base data. * * @return boolean true on success, false on failure * @access public */ function writeToPersistence() { if (!$this->_uuid) { $this->_uuid = io::uuid(); } $isNew = $this->_categoryID === NULL; // Inform modules of the object creation $modules = CMS_modulesCatalog::getAll('id'); foreach ($modules as $codename => $module) { if (method_exists($module, 'moduleCategoryPreSave')) { $module->moduleCategoryPreSave($this, $isNew); } } // Prepare SQL $sql_fields = "\n\t\t\tmodule_mca='" . SensitiveIO::sanitizeSQLString($this->_moduleCodename) . "',\n\t\t\troot_mca='" . SensitiveIO::sanitizeSQLString($this->_rootID) . "',\n\t\t\tparent_mca='" . SensitiveIO::sanitizeSQLString($this->_parentID) . "',\n\t\t\torder_mca='" . SensitiveIO::sanitizeSQLString($this->_order) . "',\n\t\t\ticon_mca='" . SensitiveIO::sanitizeSQLString($this->_icon) . "',\n\t\t\tuuid_mca='" . SensitiveIO::sanitizeSQLString($this->_uuid) . "',\n\t\t\tprotected_mca='" . ($this->_protected ? 1 : 0) . "'\n\t\t"; // Finish SQL if ($this->_categoryID) { $sql = "\n\t\t\t\tupdate\n\t\t\t\t\tmodulesCategories\n\t\t\t\tset\n\t\t\t\t\t" . $sql_fields . "\n\t\t\t\twhere\n\t\t\t\t\tid_mca='" . $this->_categoryID . "'\n\t\t\t"; } else { $sql = "\n\t\t\t\tinsert into\n\t\t\t\t\tmodulesCategories\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->_categoryID) { $this->_categoryID = $q->getLastInsertedID(); } //reset catalog info CMS_moduleCategories_catalog::getParentIdOf($this->_categoryID, true); // Update lineage again with current ID $lineage = (string) @implode(';', CMS_moduleCategories_catalog::getLineageOfCategory($this->_categoryID, true)); if ($this->_lineageFromDB != $lineage) { $sql = "\n\t\t\t\tupdate\n\t\t\t\t\tmodulesCategories\n\t\t\t\tset\n\t\t\t\t\tlineage_mca='" . SensitiveIO::sanitizeSQLString($lineage) . "'\n\t\t\t\twhere\n\t\t\t\t\tid_mca='" . $this->_categoryID . "'\n\t\t\t"; $q = new CMS_query($sql); //update siblings lineage if any if ($this->hasSiblings()) { $siblings = $this->getSiblings(); foreach ($siblings as $aSibling) { $aSibling->writeToPersistence(); } } } // Save translations // Number of languages availables depends on module // instead of languages initially stored into object // A way to support easily any new language if (is_array($this->_labels) && $this->_labels && $this->_categoryID) { $err = 0; // Insert each label foreach (CMS_languagesCatalog::getAllLanguages($this->_moduleCodename) as $aLanguage) { $lang = $aLanguage->getCode(); // Delete $sql = "\n\t\t\t\t\tdelete\n\t\t\t\t\tfrom\n\t\t\t\t\t\tmodulesCategories_i18nm\n\t\t\t\t\twhere\n\t\t\t\t\t\tcategory_mcl='" . $this->_categoryID . "'\n\t\t\t\t\t\tand language_mcl='" . SensitiveIO::sanitizeSQLString($lang) . "'\n\t\t\t\t"; $qD = new CMS_query($sql); if ($qD->hasError()) { $err++; $this->raiseError("Error deleting label in language : `{$lang}`"); } // Insert $sql = "\n\t\t\t\t\tinsert into\n\t\t\t\t\t\tmodulesCategories_i18nm\n\t\t\t\t\tset\n\t\t\t\t\t\tlanguage_mcl='" . SensitiveIO::sanitizeSQLString($lang) . "',\n\t\t\t\t\t\tcategory_mcl = " . $this->_categoryID . ",\n\t\t\t\t\t\tlabel_mcl='" . SensitiveIO::SanitizeSQLString(@$this->_labels[$lang]) . "',\n\t\t\t\t\t\tdescription_mcl='" . SensitiveIO::SanitizeSQLString(@$this->_descriptions[$lang]) . "',\n\t\t\t\t\t\tfile_mcl='" . SensitiveIO::SanitizeSQLString(@$this->_files[$lang]) . "'\n\t\t\t\t"; $q = new CMS_query($sql); if ($q->hasError()) { $err++; $this->raiseError("Error inserting label in language : `{$lang}`"); } } // have to repeat the call here $modules = CMS_modulesCatalog::getAll('id'); foreach ($modules as $codename => $module) { if (method_exists($module, 'moduleCategoryPostSave')) { $module->moduleCategoryPostSave($this, $isNew); } } //Clear polymod cache //CMS_cache::clearTypeCacheByMetas('polymod', array('module' => $this->_moduleCodename)); CMS_cache::clearTypeCache('polymod'); return $err <= 0; } $modules = CMS_modulesCatalog::getAll('id'); foreach ($modules as $codename => $module) { if (method_exists($module, 'moduleCategoryPostSave')) { $module->moduleCategoryPostSave($this, $isNew); } } //Clear polymod cache //CMS_cache::clearTypeCacheByMetas('polymod', array('module' => $this->_moduleCodename)); CMS_cache::clearTypeCache('polymod'); return true; }
/** * Clear a type cache * * @param string $type : the cache type to clear * @return boolean * @access public * @static */ function clearTypeCache($type) { $type = io::sanitizeAsciiString($type); if (!$type) { CMS_grandFather::raiseError('$type must be a valid cache type'); return false; } if (is_dir(PATH_CACHE_FS . '/' . $type)) { // First we'll check all modules to see if one of them implements a clearTypeCache method $modules = CMS_modulesCatalog::getAll('id'); $cleared = false; foreach ($modules as $codename => $module) { if (method_exists($module, 'clearTypeCache')) { $cleared = $module->clearTypeCache($type); } } // No module deleted the cache, use automne standard cache clear if (!$cleared) { //delete all type cache if (!CMS_file::deltree(PATH_CACHE_FS . '/' . $type, false, true)) { CMS_grandFather::raiseError('Cannot clear cache for type ' . $type); return false; } } } return true; }
/** * Writes all objects values into persistence (MySQL for now), along with base data. * * @param boolean $withResource treat also the resource status (if object is a primary resource) default true * @param boolean $emailValidators send emails to validators (if object is a primary resource) default true * @param boolean $onlyCreateID create only the object ID (used to save fiels fields). Default false * @return boolean true on success, false on failure * @access public */ function writeToPersistence($treatResource = true, $emailValidators = true, $onlyCreateID = false) { global $cms_user; if ($this->_public) { $this->raiseError("Can't write public object"); return false; } if ($this->hasError()) { $this->raiseError("Can't write object with error"); return false; } $isNew = $this->_ID === NULL; // Inform modules of the object creation $modules = CMS_modulesCatalog::getAll('id'); foreach ($modules as $codename => $module) { if (method_exists($module, 'polyObjectPreSave')) { $module->polyObjectPreSave($this, $isNew); } } if (!$this->_ID) { //first, if object does not have ID, create one $sql = "\n\t\t\t\tinsert into\n\t\t\t\t\tmod_object_polyobjects\n\t\t\t\tset\n\t\t\t\t\tobject_type_id_moo='" . SensitiveIO::sanitizeSQLString($this->_objectID) . "'\n\t\t\t\t"; $q = new CMS_query($sql); if ($q->hasError()) { $this->raiseError("Can't save object"); return false; } elseif (!$this->_ID) { //set ID $this->_ID = $q->getLastInsertedID(); //reload all sub objects definition to add ID $this->_populateSubObjectsDefinitions(); } if ($onlyCreateID) { return true; } } $forceSecondaryRessourcePublication = false; //if this object is a primary resource if ($this->_objectResourceStatus == 1) { if ($treatResource) { //add content edition status $this->addEdition(RESOURCE_EDITION_CONTENT, $cms_user); } //write parent to persistence parent::writeToPersistence(); //set $this->_resource $this->_resource->setValue(parent::getID()); //then save resource ID //set definition for resource $definition = array('objectID' => $this->_ID, 'fieldID' => 0, 'subFieldID' => 0); $this->_resource->setDefinition($definition); if (!$this->_resource->writeToPersistence()) { return false; } } elseif ($this->_objectResourceStatus == 2) { //if this object is a secondary resource //get all primary resource associated $primaryItems = CMS_poly_object_catalog::getPrimaryItemsWhichUsesSecondaryItem($this->_ID, true, false); if ($primaryItems) { foreach ($primaryItems as $primaryItem) { $primaryItem->writeToPersistence(); } } else { $forceSecondaryRessourcePublication = true; } } //save all subobjects foreach (array_keys($this->_objectValues) as $fieldID) { if (is_a($this->_objectValues[$fieldID], 'CMS_poly_object')) { //set definition for poly object field in $this->_polyObjectValues $definition = array('objectID' => $this->_ID, 'fieldID' => $fieldID, 'subFieldID' => 0); $this->_polyObjectValues[$fieldID]->setDefinition($definition); if (!$this->_polyObjectValues[$fieldID]->writeToPersistence()) { return false; } } else { //set sub fields definitions for other object fields $this->_objectValues[$fieldID]->setSubFieldsDefinition($this->_subObjectsDefinitions[$fieldID]); if (!$this->_objectValues[$fieldID]->writeToPersistence()) { return false; } } } //resource management if ($treatResource) { //get Object definition $objectDef = $this->getObjectDefinition(); //get module codename $polyModuleCodename = $objectDef->getValue('module'); //if object is not a resource, copy datas to public location if ($this->_objectResourceStatus != 1 && $this->_objectResourceStatus != 2 || $this->_objectResourceStatus == 2 && $forceSecondaryRessourcePublication) { $modulesCodes = new CMS_modulesCodes(); //add a call to all modules for before validation specific treatment $modulesCodes->getModulesCodes(MODULE_TREATMENT_BEFORE_VALIDATION_TREATMENT, '', $this, array('result' => VALIDATION_OPTION_ACCEPT, 'lastvalidation' => true, 'module' => $polyModuleCodename, 'action' => 'update')); //move resource datas to public location CMS_modulePolymodValidation::moveResourceData($polyModuleCodename, $this->getID(), RESOURCE_DATA_LOCATION_EDITED, RESOURCE_DATA_LOCATION_PUBLIC, true); //add a call to all modules for after validation specific treatment $modulesCodes->getModulesCodes(MODULE_TREATMENT_AFTER_VALIDATION_TREATMENT, '', $this, array('result' => VALIDATION_OPTION_ACCEPT, 'lastvalidation' => true, 'module' => $polyModuleCodename, 'action' => 'update')); } //if item is a primary resource, send emails to validators if ($this->_objectResourceStatus == 1) { if (APPLICATION_ENFORCES_WORKFLOW) { if (!NO_APPLICATION_MAIL && $emailValidators) { $validators = CMS_profile_usersCatalog::getValidators($polyModuleCodename); //get editors $editors = $this->getEditors(); $editorsIds = array(); foreach ($editors as $editor) { $editorsIds[] = $editor->getUserId(); } foreach ($validators as $validator) { //add script to send email for validator if needed CMS_scriptsManager::addScript($polyModuleCodename, array('task' => 'emailNotification', 'object' => $this->getID(), 'validator' => $validator->getUserId(), 'type' => 'validate', 'editors' => $editorsIds)); } //then launch scripts execution CMS_scriptsManager::startScript(); } } else { $validation = new CMS_resourceValidation($polyModuleCodename, RESOURCE_EDITION_CONTENT, $this); $mod = CMS_modulesCatalog::getByCodename($polyModuleCodename); $mod->processValidation($validation, VALIDATION_OPTION_ACCEPT); } //Log action $log = new CMS_log(); $language = $cms_user->getLanguage(); $log->logResourceAction(CMS_log::LOG_ACTION_RESOURCE_EDIT_CONTENT, $cms_user, $polyModuleCodename, $this->getStatus(), 'Item \'' . $this->getLabel() . '\' (' . $objectDef->getLabel($language) . ')', $this); } else { //Log action $log = new CMS_log(); $language = $cms_user->getLanguage(); $log->logMiscAction(CMS_log::LOG_ACTION_RESOURCE_EDIT_CONTENT, $cms_user, 'Item \'' . $this->getLabel() . '\' (' . $objectDef->getLabel($language) . ')', $polyModuleCodename); } //Clear polymod cache //CMS_cache::clearTypeCacheByMetas('polymod', array('module' => $polyModuleCodename)); CMS_cache::clearTypeCache('polymod'); } // Inform modules of the object creation $modules = CMS_modulesCatalog::getAll('id'); foreach ($modules as $codename => $module) { if (method_exists($module, 'polyObjectPostSave')) { $module->polyObjectPostSave($this, $isNew); } } return true; }
/** * Authenticate user * This method can * - authenticate user throught authentification process * - load already authenticated user in current session (or SSO) * - disconnect user * * @param array $params : indexed array of authentification parameters (default : nothing) * Accepted array keys are : * - authenticate : boolean : default true if disconnect is not set * - disconnect : boolean : default false * - login : string : user login to authenticate * - password : string : user password to authenticate * - remember : boolean : default false * - tokenName : string * - token : string * - type : string : type of authentification (admin|frontend) : default APPLICATION_USER_TYPE contant * - ... and any parameter needed by authentifications processes handled by modules * @return void * @access public * @static */ public static function authenticate($params = array()) { //first clean old sessions datas from database CMS_session::_cleanSessions(); // Get Zend Auth instance $auth = Zend_Auth::getInstance(); // Use CMS_auth as session storage space $auth->setStorage(new Zend_Auth_Storage_Session('atm-auth')); //set authentification type if (!isset($params['type'])) { $params['type'] = APPLICATION_USER_TYPE; } //set permanent auth status if (isset($params['remember']) && $params['remember']) { self::$_permanent = true; } else { $params['remember'] = false; } //clear auth storage if disconnection is queried and set default authenticate value if (isset($params['disconnect']) && $params['disconnect']) { //log disconection if user exists $storageValue = $auth->getStorage()->read(); if (io::isPositiveInteger($storageValue)) { //load user $user = CMS_profile_usersCatalog::getByID($storageValue); if ($user) { //log new session $log = new CMS_log(); $log->logMiscAction(CMS_log::LOG_ACTION_DISCONNECT, $user, 'IP: ' . @$_SERVER['REMOTE_ADDR'] . ', UA: ' . @$_SERVER['HTTP_USER_AGENT']); } } //clear session content CMS_session::deleteSession(true); if (!isset($params['authenticate'])) { $params['authenticate'] = false; } } else { $params['disconnect'] = false; if (!isset($params['authenticate'])) { $params['authenticate'] = true; } } //init authenticated boolean $authenticated = false; //keep old storage value, because storage will be reseted by each module authentification $storageValue = $auth->getStorage()->read(); //loop on each authentification types suupported foreach (array('credentials', 'session', 'cookie', 'sso') as $authType) { //load modules $modules = CMS_modulesCatalog::getAll('id'); //get last module $module = array_pop($modules); //set authentification type as param $params['authType'] = $authType; //then try it for each modules do { //if module has auth method, try it if (method_exists($module, 'getAuthAdapter')) { //overwrite auth storage value with old value $auth->getStorage()->write($storageValue); //get module auth adapter $authAdapter = $module->getAuthAdapter($params); //authenticate user self::$_result = $auth->authenticate($authAdapter); //To debug Auth process easily, discomment this line //CMS_grandFather::log($_SERVER['SCRIPT_NAME'].' - '.$module->getCodename().' - Auth type : '.$authType.'/'.$params['type'].' - Auth result : '.self::$_result->getCode().($auth->hasIdentity() ? ' - Identity : '.$auth->getIdentity() : '').' - Message : '.(sizeof(self::$_result->getMessages()) == 1 ? array_pop(self::$_result->getMessages()) : print_r(self::$_result->getMessages(), true))); switch (self::$_result->getCode()) { case Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND: //user crendentials does not exists (ex: no login/pass provided) //nothing for now break; case Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID: //invalid login/pass //nothing for now break; case Zend_Auth_Result::SUCCESS: if ($auth->hasIdentity()) { // get user from identity found $user = $authAdapter->getUser($auth->getIdentity()); //check if user is valid if (isset($user) && $user && !$user->hasError() && !$user->isDeleted() && $user->isActive()) { $authenticated = true; //overwrite auth identity with valid user Id $auth->getStorage()->write($user->getUserId()); } else { unset($user); } } break; case Zend_Auth_Result::FAILURE: //user found but has error during loading (user inactive or deleted) //nothing for now break; default: //other unidentified cases : thrown an error CMS_grandFather::raiseError('Authentification return code ' . self::$_result->getCode() . ' for module ' . $module->getCodename() . ' with parameters ' . print_r($params, true)); break; } } //get next last module $module = array_pop($modules); } while (!$authenticated && $module); //if user is authenticated, break authentification foreach if ($authenticated) { break; } } //if authenticated : set or refresh session datas in table, regenerate session Id if ($authenticated && $user) { $q = new CMS_query("\n\t\t\tselect \n\t\t\t\tid_ses, cookie_expire_ses\n\t\t\tfrom \n\t\t\t\tsessions \n\t\t\twhere \n\t\t\t\tphpid_ses='" . sensitiveIO::sanitizeSQLString(Zend_Session::getId()) . "' \n\t\t\t\tand user_ses='" . sensitiveIO::sanitizeSQLString($user->getUserId()) . "'"); //get old session Id $oldSessionId = Zend_Session::getId(); if ($q->getNumRows() > 0) { //if session already exists : update it //regenerate session Id randomly (arround 1/100 times) //removed : cause session instability /*if (!rand(0, 100)) { //session id should not be regenerated each times because in case of a lot of concurrent calls, session can be destroyed Zend_Session::regenerateId(); }*/ $r = $q->getArray(); $id = $r['id_ses']; //Cookie if (self::$_permanent || $r['cookie_expire_ses'] != '0000-00-00 00:00:00') { self::$_permanent = true; // Cookie expire in APPLICATION_COOKIE_EXPIRATION days $expires = time() + 60 * 60 * 24 * APPLICATION_COOKIE_EXPIRATION; CMS_session::setCookie(CMS_session::getAutoLoginCookieName(), base64_encode($id . '|' . Zend_Session::getId()), $expires); } //DB session $sql = "\n\t\t\t\t\tupdate \n\t\t\t\t\t\tsessions \n\t\t\t\t\tset\n\t\t\t\t\t\tlastTouch_ses=NOW(),\n\t\t\t\t\t\tuser_ses='" . sensitiveIO::sanitizeSQLString($user->getUserId()) . "',\n\t\t\t\t\t\tphpid_ses='" . sensitiveIO::sanitizeSQLString(Zend_Session::getId()) . "',\n\t\t\t\t\t\tremote_addr_ses='" . sensitiveIO::sanitizeSQLString(@$_SERVER['REMOTE_ADDR']) . "'"; if (self::$_permanent) { $sql .= ",\n\t\t\t\t\t\tcookie_expire_ses = DATE_ADD(NOW(), INTERVAL " . APPLICATION_COOKIE_EXPIRATION . " DAY)"; } $sql .= "\n\t\t\t\t\twhere\n\t\t\t\t\t \tid_ses='" . sensitiveIO::sanitizeSQLString($id) . "'"; $q = new CMS_query($sql); //if autologin : log it if (in_array(CMS_auth::AUTH_AUTOLOGIN_VALID, self::$_result->getMessages())) { //log autologin session $log = new CMS_log(); $log->logMiscAction(CMS_log::LOG_ACTION_AUTO_LOGIN, $user, 'IP: ' . @$_SERVER['REMOTE_ADDR'] . ', UA: ' . @$_SERVER['HTTP_USER_AGENT']); } } else { //otherwhise, create user session //regenerate session Id Zend_Session::regenerateId(); //delete old session record if any $q = new CMS_query("\n\t\t\t\t\tdelete\n\t\t\t\t\tfrom \n\t\t\t\t\t\tsessions \n\t\t\t\t\twhere \n\t\t\t\t\t\tphpid_ses='" . sensitiveIO::sanitizeSQLString($oldSessionId) . "'"); //insert new session record $sql = "\n\t\t\t\t\tinsert into\n\t\t\t\t\t\tsessions\n\t\t\t\t\tset\n\t\t\t\t\t\tlastTouch_ses=NOW(),\n\t\t\t\t\t\tphpid_ses='" . sensitiveIO::sanitizeSQLString(Zend_Session::getId()) . "',\n\t\t\t\t\t\tuser_ses='" . sensitiveIO::sanitizeSQLString($user->getUserId()) . "',\n\t\t\t\t\t\tremote_addr_ses='" . sensitiveIO::sanitizeSQLString(@$_SERVER['REMOTE_ADDR']) . "'\n\t\t\t\t"; if (self::$_permanent) { $sql .= ",\n\t\t\t\t\tcookie_expire_ses = DATE_ADD(NOW(), INTERVAL " . APPLICATION_COOKIE_EXPIRATION . " DAY)"; } $q = new CMS_query($sql); if (!$q->hasError() && self::$_permanent) { // Cookie expire in APPLICATION_COOKIE_EXPIRATION days $expires = time() + 60 * 60 * 24 * APPLICATION_COOKIE_EXPIRATION; CMS_session::setCookie(CMS_session::getAutoLoginCookieName(), base64_encode($q->getLastInsertedID() . '|' . Zend_Session::getId()), $expires); } //log new session $log = new CMS_log(); $log->logMiscAction(CMS_log::LOG_ACTION_LOGIN, $user, 'Permanent cookie: ' . (self::$_permanent ? 'Yes' : 'No') . ', IP: ' . @$_SERVER['REMOTE_ADDR'] . ', UA: ' . @$_SERVER['HTTP_USER_AGENT']); } //set user as currently logged user self::$_userID = $user->getUserId(); } else { if (APPLICATION_USER_TYPE == "frontend" && APPLICATION_ENFORCES_ACCESS_CONTROL) { //set public user as currently logged user self::$_userID = ANONYMOUS_PROFILEUSER_ID; } } //for backward compatibility $_SESSION["cms_context"] = new CMS_context(); }
/** * Force compilation for all stored definitions * * @return void * @access public */ function compileDefinitions() { //foreach definition, plugin and rss, recompile stored values if exists $modules = CMS_modulesCatalog::getAll("id", true); $hasPolyModule = false; foreach ($modules as $module) { if ($module->isPolymod()) { $hasPolyModule = true; //get objects definition for module $objects = CMS_poly_object_catalog::getObjectsForModule($module->getCodename()); foreach ($objects as $object) { if ($object->getValue('indexURL')) { $object->compileDefinition(); $object->writeToPersistence(); } } //get plugins for module $plugins = CMS_poly_object_catalog::getAllPluginDefIDForModule($module->getCodename()); foreach ($plugins as $pluginID) { $plugin = new CMS_poly_plugin_definitions($pluginID); if ($plugin->getValue('definition') && method_exists($plugin, 'compileDefinition')) { $plugin->compileDefinition(); $plugin->writeToPersistence(); } } } } if ($hasPolyModule) { //get all RSS definition $rssDefinitions = CMS_poly_object_catalog::getAllRSSDefinitionsForObject(); foreach ($rssDefinitions as $rssDefinition) { if ($rssDefinition->getValue('definition')) { $rssDefinition->compileDefinition(); $rssDefinition->writeToPersistence(); } } } }
/** * Get All the modules actions possible * * @return array(integer=>integer) The actions indexed by their messages * @access public */ static function getModulesActions($cms_language) { $modules = CMS_modulesCatalog::getAll(); $actions = array(); foreach ($modules as $module) { if (method_exists($module, 'getLogActions')) { foreach ($module->getLogActions() as $msg => $action) { $actions[$cms_language->getMessage($msg, false, $module->getCodename())] = $action; } } } return $actions; }
/** * 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; }
} $dialog = new CMS_dialog(); $content = ''; $dialog->setTitle($cms_language->getMessage(MESSAGE_PAGE_TITLE_APPLICATIONS) . " :: " . $cms_language->getMessage(MESSAGE_PAGE_TITLE, array($object->getLabel($cms_languege))), 'picto_modules.gif'); $dialog->setBacklink("modules_admin.php?moduleCodename=" . $moduleCodename . "&object=" . $object->getID() . "&field=" . $field->getID()); if ($cms_message) { $dialog->setActionMessage($cms_message); } if ($moduleCodename) { $polymod = CMS_modulesCatalog::getByCodename($moduleCodename); } $required = $field->getValue("required") ? ' checked="checked"' : ''; $indexable = $field->getValue("indexable") ? ' checked="checked"' : ''; $searchlist = $field->getValue("searchlist") ? ' checked="checked"' : ''; $searchable = $field->getValue("searchable") ? ' checked="checked"' : ''; $polyModules = CMS_modulesCatalog::getAll("label", true); $poly_types = array(); foreach ($polyModules as $aModule) { $poly_types = array_merge($poly_types, CMS_poly_object_catalog::getObjectsForModule($aModule->getCodename())); } $object_types = CMS_object_catalog::getObjects($field, true); $typeObject = $field->getTypeObject(true); $objectUseage = CMS_poly_object_catalog::getObjectUsage($object->getID()); if (is_object($typeObject) && $typeObject->hasParameters()) { if (is_a($typeObject, 'CMS_poly_object_definition')) { //need to load parameters first $typeObject->loadParameters($field); } $parametersHTML = $typeObject->getHTMLSubFieldsParameters($cms_language, 'type'); } $content = '
/** * Return a valid page for a given URL * * @param string $pageUrl the page URL * @param boolean $useDomain : use queried domain to found root page associated (default : true) * @return CMS_page if page found, false otherwise * @access public */ static function analyseURL($pageUrl, $useDomain = true) { if (strpos($pageUrl, PATH_FORBIDDEN_WR) === 0 || strpos($pageUrl, PATH_SPECIAL_PAGE_NOT_FOUND_WR) === 0) { return false; } $requestedPageId = null; $urlinfo = @parse_url($pageUrl); if (isset($urlinfo['path'])) { $pathinfo = pathinfo($urlinfo['path']); $basename = isset($pathinfo['filename']) ? $pathinfo['filename'] : $pathinfo['basename']; } //if extension exists and is not PHP, return if (isset($pathinfo['extension']) && $pathinfo['extension'] && $pathinfo['extension'] != 'php') { return false; } if (isset($urlinfo['query'])) { $querystring = $urlinfo['query']; } //if basename found try to get page id if (isset($urlinfo['path']) && $urlinfo['path'] != PATH_REALROOT_WR . '/' && $basename && (isset($pathinfo['extension']) && strtolower($pathinfo['extension']) == 'php' || !isset($pathinfo['extension']))) { //search page id in basename (declare matching patterns by order of research) $patterns[] = "#^([0-9]+)-#U"; // for request like id-page_title.php $patterns[] = "#^print-([0-9]+)-#U"; // for request like print-id-page_title.php $patterns[] = "#_([0-9]+)_\$#U"; // for request like _id_id_.php : old V3 style url $patterns[] = "#^([0-9]+)\$#U"; // for request like id $count = 0; while (!preg_match($patterns[$count], $basename, $requestedPageId) && $count + 1 < sizeof($patterns)) { $count++; } if (isset($requestedPageId[1]) && sensitiveIO::IsPositiveInteger($requestedPageId[1]) && CMS_tree::getPageValue($requestedPageId[1], 'exists')) { //try to instanciate the requested page $cms_page = CMS_tree::getPageByID($requestedPageId[1]); if ($cms_page && !$cms_page->hasError()) { return $cms_page; } } } if ($useDomain) { $httpHost = @parse_url($_SERVER['HTTP_HOST'], PHP_URL_HOST) ? @parse_url($_SERVER['HTTP_HOST'], PHP_URL_HOST) : $_SERVER['HTTP_HOST']; //search page id by domain address $domain = isset($urlinfo['host']) ? $urlinfo['host'] : $httpHost; $domainfound = CMS_websitesCatalog::getWebsiteFromDomain($domain, isset($urlinfo['path']) && $urlinfo['path'] != PATH_REALROOT_WR . '/' ? $urlinfo['path'] : ''); if (is_object($domainfound)) { $cms_page = $domainfound->getRoot(); if ($cms_page && !$cms_page->hasError()) { return $cms_page; } } } //query modules to get page from them $modules = CMS_modulesCatalog::getAll(); foreach ($modules as $module) { if (method_exists($module, 'getPageFromURL')) { $cms_page = $module->getPageFromURL($pageUrl, $useDomain); if ($cms_page) { return $cms_page; } } } return false; }