本文整理汇总了PHP中Role::getAllRoles方法的典型用法代码示例。如果您正苦于以下问题:PHP Role::getAllRoles方法的具体用法?PHP Role::getAllRoles怎么用?PHP Role::getAllRoles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Role
的用法示例。
在下文中一共展示了Role::getAllRoles方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRole
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.");
}
示例2: getRoleByName
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
}
示例3: getCode
/**
*
* @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;
}
示例4: getAllProcessRuleNames
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;
}
示例5: foreach
/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>
示例6: display
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));
//.........这里部分代码省略.........