/** * Get all the aliases for a given name * * @param string $name The name to get aliases of * @param boolean $returnObject function return array of id or array of CMS_resource_cms_aliases (default) * @return array * @access public * @static */ static function getByName($name, $returnObject = true) { if (!$name || $name != sensitiveIO::sanitizeAsciiString($name, '@')) { return array(); } $sql = "\n\t\t\tselect\n\t\t\t\tid_ma\n\t\t\tfrom\n\t\t\t\tmod_cms_aliases\n\t\t\twhere \n\t\t\t\talias_ma='" . io::sanitizeSQLString($name) . "'\n\t\t\torder by id_ma asc"; $q = new CMS_query($sql); $result = array(); while ($arr = $q->getArray()) { if ($returnObject) { $alias = CMS_module_cms_aliases::getByID($arr["id_ma"]); if ($alias && !$alias->hasError()) { $result[$arr["id_ma"]] = $alias; } } else { $result[$arr["id_ma"]] = $arr["id_ma"]; } } return $result; }
if ($aliasId) { $log->logMiscAction(CMS_log::LOG_ACTION_RESOURCE_EDIT_CONTENT, $cms_user, 'Edit Alias ' . $item->getPath(), 'cms_aliases'); } else { $log->logMiscAction(CMS_log::LOG_ACTION_RESOURCE_EDIT_CONTENT, $cms_user, 'Create Alias ' . $item->getPath(), 'cms_aliases'); } $cms_message = $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE); $content = array('success' => true, 'id' => $item->getID()); } } } else { $cms_message = $cms_language->getMessage(MESSAGE_ERROR_ALIAS_PROTECTED, false, 'cms_aliases'); $item->raiseError('Error during modification of alias ' . $item->getID() . '. Alias is protected.'); } break; case 'delete': $item = CMS_module_cms_aliases::getByID($aliasId); if (!$item->isProtected()) { $path = $item->getPath(); if ($item->destroy()) { //Log action $log = new CMS_log(); $log->logMiscAction(CMS_log::LOG_ACTION_RESOURCE_DELETE, $cms_user, 'Delete Alias ' . $path, 'cms_aliases'); $cms_message = $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE); $content = array('success' => true); } else { $cms_message = $cms_language->getMessage(MESSAGE_PAGE_ACTION_DELETE_ERROR); } } else { $cms_message = $cms_language->getMessage(MESSAGE_ERROR_ALIAS_PROTECTED, false, 'cms_aliases'); $category->raiseError('Error during modification of alias ' . $item->getID() . '. Alias is protected.'); }
CMS_grandFather::raiseError('Error, user has no rights on module : ' . $codename); $view->show(); } //instanciate module $cms_module = CMS_modulesCatalog::getByCodename($codename); // Current alias object to manipulate if ($aliasId) { $item = CMS_module_cms_aliases::getByID($aliasId); if (io::isPositiveInteger($item->getParent())) { $parentAlias = CMS_module_cms_aliases::getByID($item->getParent()); } } else { $item = new CMS_resource_cms_aliases(); if (io::isPositiveInteger($fatherId)) { // Parent alias $parentAlias = CMS_module_cms_aliases::getByID($fatherId); } } $items = array(); $selectContent = array(); $aliases = CMS_module_cms_aliases::getAll(false, true); foreach ($aliases as $alias) { if ($alias->getID() != $item->getID() && !$alias->hasParent($item->getID())) { $lineage = $alias->getPath(); $selectContent[$lineage] = array($alias->getID(), $lineage); } } ksort($selectContent); array_unshift($selectContent, array(0, '/')); $selectContent = sensitiveIO::jsonEncode(array_values($selectContent)); $controlerURL = PATH_ADMIN_MODULES_WR . '/' . $codename . '/controler.php';
/** * Get the lineAge of an alias * * @param boolean $returnObject function return lineAge string or array of CMS_resource_cms_aliases * @return array or string * @access public */ function getAliasLineAge($returnObject = false, $reset = false) { static $aliasesLineAge; if ($reset || !isset($aliasesLineAge[$this->getID()])) { $aliasesLineAge[$this->getID()] = array(); if ($this->getParent()) { $aliasesLineAge[$this->getID()] = array(); $parent = CMS_module_cms_aliases::getByID($this->_parentID); while ($parent && $parent->getID() != 0) { $aliasesLineAge[$this->getID()][$parent->getID()] = $parent; if ($parent->getParent()) { $parent = CMS_module_cms_aliases::getByID($parent->getParent()); } else { $parent = ''; } } } $aliasesLineAge[$this->getID()] = array_reverse($aliasesLineAge[$this->getID()], true); } if ($returnObject) { return $aliasesLineAge[$this->getID()]; } else { $lineAgeString = ''; foreach ($aliasesLineAge[$this->getID()] as $anAlias) { $lineAgeString .= $anAlias->getAlias() . "/"; } return $lineAgeString; } }