public static function getRole($id) { foreach (Role::getAllRoles() as $role) { if ($role->getID() === $id) { return $role; } } throw new Exception($id . " is not a known role ID."); }
public static function getRoleByName($roleName) { foreach (Role::getAllRoles() as $arr) { if ($arr['name'] == $roleName) { return new Role($arr['id']); } } return false; // when $roleName is not found in $allRoles }
/** * * @return string */ public function getCode() { $res = "<select name=\"" . $this->name . "\" style=\"" . $this->style . "\">"; $roles = Role::getAllRoles(); if ($roles) { foreach ($roles as $role) { if (!$this->hideSpecialRoles || $role->ID != 1 && $role->ID != 3) { if ($this->value == $role->ID) { $res .= "<option value=\"" . $role->ID . "\" selected=\"selected\">" . htmlentities($role->name) . "</option>"; } else { $res .= "<option value=\"" . $role->ID . "\">" . htmlentities($role->name) . "</option>"; } } } } $res .= "</select>"; return $res; }
public static function getAllProcessRuleNames() { global $allRules; // from Generics.php $allRoles = Role::getAllRoles(); // list of all process rules $processRuleNames = array(); foreach ($allRoles as $role) { $processRuleNames = array_merge($processRuleNames, $role['ruleNames']); } return $processRuleNames; }
/admin.php?area=roles&action=add">Add New</a> <?php if (Role::getAllRoles()) { ?> <table class="table"> <thead> <tr> <th>Title</th> </tr> </thead> <tbody> <?php foreach (Role::getAllRoles() as $role) { ?> <tr> <td class="app_list_data app_list_title"> <a href="<?php echo $app->url; ?> /admin.php?area=roles&action=view&id=<?php echo $role->getID(); ?> "><?php echo $role->getName(); ?> </a> </td> </tr>
public function display() { $template = new Template(); $template->load("site_edit"); $page = new Page(); if (isset($_GET['site'])) { $page->loadProperties(DataBase::Current()->EscapeString($_GET['site'])); if (isset($_POST['save'])) { $oldpage = $page; $page->title = $_POST['title']; $page->menu = $_POST['menu']; $page->getMeta()->description = $_POST['meta-description']; $page->getMeta()->keywords = $_POST['meta-keywords']; $page->getMeta()->robots = $_POST['meta-robots']; $page->alias = $page->getDir() . $_POST['localalias']; $page->ownerid = $_POST['owner']; $page->canonical = $_POST['canonical']; $page->advancedHtmlHeader = $_POST['advanced_html_header']; $page->SetChangeFrequence($_POST['change_frequence']); if (isset($_POST['in_sitemap'])) { $page->inSitemap = $_POST['in_sitemap']; } else { $page->inSitemap = false; } $page->priority = $_POST['priority']; $page->save(); $page->getEditor()->save($page, $oldpage); Role::clearAccess($page); if ($_POST['rights']) { foreach ($_POST['rights'] as $right) { $role = new Role(); $role->load($right); $role->allowAccess($page); } } } else { if (isset($_POST['menu'])) { $page->title = $_POST['title']; $page->alias = $page->getDir() . $_POST['localalias']; $page->menu = $_POST['menu']; $page->getEditor()->content = $_POST['content']; } } $url = UrlRewriting::GetUrlByAlias("admin/pageedit", "site=" . $page->alias); $template->assign_var("PATH", $url); $template->assign_var("ALIAS", $page->alias); $template->assign_var("LOCALALIAS", $page->getLocalAlias()); if (!isset($_POST['menu'])) { foreach (Role::getAllRoles() as $role) { $index = $template->add_loop_item("RIGHTS"); $template->assign_loop_var("RIGHTS", $index, "LABEL", "/"); $template->assign_loop_var("RIGHTS", $index, "VALUE", $role->ID); $template->assign_loop_var("RIGHTS", $index, "NAME", $role->name); if ($role->canAccess($page)) { $template->assign_loop_var("RIGHTS", $index, "SELECTED", "selected=\"1\" "); } else { $template->assign_loop_var("RIGHTS", $index, "SELECTED", ""); } } } else { foreach (Role::getAllRoles() as $role) { $index = $template->add_loop_item("RIGHTS"); $template->assign_loop_var("RIGHTS", $index, "LABEL", "/"); $template->assign_loop_var("RIGHTS", $index, "VALUE", $role->ID); $template->assign_loop_var("RIGHTS", $index, "NAME", $role->name); if (isset($_POST['rights']) && in_array($role->ID, $_POST['rights'])) { $template->assign_loop_var("RIGHTS", $index, "SELECTED", "selected=\"1\" "); } else { $template->assign_loop_var("RIGHTS", $index, "SELECTED", ""); } } } $index = $template->add_loop_item("MENU"); $template->assign_loop_var("MENU", $index, "VALUE", "0"); $template->assign_loop_var("MENU", $index, "NAME", "-- " . Language::DirectTranslate("NO_MENU") . " --"); $template->assign_loop_var("MENU", $index, "SELECTED", ""); foreach (sys::getMenues($_SESSION['dir']) as $menu) { $index = $template->add_loop_item("MENU"); $template->assign_loop_var("MENU", $index, "VALUE", $menu->id); $template->assign_loop_var("MENU", $index, "NAME", $menu->name); if (isset($_POST['menu']) && $_POST['menu'] == $menu->id) { $template->assign_loop_var("MENU", $index, "SELECTED", "selected=\"1\" "); } else { if (!isset($_POST['menu']) && $menu->id == $page->menu) { $template->assign_loop_var("MENU", $index, "SELECTED", "selected=\"1\" "); } else { $template->assign_loop_var("MENU", $index, "SELECTED", ""); } } } if (isset($_POST['menu'])) { $template->assign_var("MENUPREVIEW", Menu::getCode($_POST['menu'], "<ul>", "</ul>", "<li>", "</li>", "")); } else { if ($page->menu > 0) { $template->assign_var("MENUPREVIEW", Menu::getCode($page->menu, "<ul>", "</ul>", "<li>", "</li>", "")); } else { $template->assign_var("MENUPREVIEW", ""); } } $template->assign_var("METADESCRIPTION", htmlentities($page->getMeta()->description)); $template->assign_var("METAKEYWORDS", htmlentities($page->getMeta()->keywords)); $template->assign_var("METAROBOTS", htmlentities($page->getMeta()->robots)); $template->assign_var("CANONICAL", $page->canonical); $template->assign_var("ADVANCED_HTML_HEADER", htmlentities($page->advancedHtmlHeader)); $template->assign_var("TITLE", $page->title); $template->assign_var("EDITOR", $page->getEditor()->getEditableCode()); $template->assign_var("HOST", Settings::getRootInstance()->dir($page->alias . "§page")->get("host") . $page->getDir()); $template->assign_var("CHANGE_FREQUENCE", $page->GetChangeFrequence()); $template->assign_var("PRIORITY", $page->priority); if ($page->inSitemap) { $template->assign_var("IN_SITEMAP_CHECKED", " checked=\"checked\""); } else { $template->assign_var("IN_SITEMAP_CHECKED", ""); } $selector = new PageSelector(); $selector->name = 'owner'; $selector->value = $page->ownerid; $selector->noValueText = "-- " . Language::DirectTranslate("NOOWNER") . " --"; $template->assign_var("OWNERCONTROL", $selector->getCode()); $template->output(); } }