本文整理汇总了PHP中Roles::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Roles::get方法的具体用法?PHP Roles::get怎么用?PHP Roles::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Roles
的用法示例。
在下文中一共展示了Roles::get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dirname
<?php
$login_required = TRUE;
include "../includes/page.php";
require_once dirname(__FILE__) . '/../../config.inc';
require_once "{$path_prefix}/api/Roles/Roles.php";
if ($_POST['id']) {
$role = new Roles();
$role->id = $_POST['id'];
$roles = $role->get($_POST['id']);
$div_generate = '<fieldset class="center_box"><input type="hidden"
name="role_id" value="' . $_POST['id'] . ' "/><div class="field"><h4>Name
</h4><input type="text" name="role_name" class="text longer" value =
"' . $roles->name . '" /></div><div class="field_bigger"><h4>Description :
</h4><textarea name="desc">' . $roles->description . '</textarea></fieldset><div
class="button_position"><input type="submit" class="button-submit" name="submit"
value="Save" /></div>';
}
echo $div_generate;
示例2: restoreRoleSettings
private function restoreRoleSettings($restore_roles, $_msg = null)
{
try {
if (count($restore_roles) > 0) {
$roles = new Roles();
$roles_info = $roles->get_multiple(null);
foreach ($roles_info as $_role) {
$role = $roles->get($_role->id);
if (is_object($role)) {
if (!$role->read_only) {
$roles->delete((int) $_role->id);
}
}
}
foreach ($restore_roles as $role) {
$_role = Roles::getRoleInfoByID($role['id'], $fetch_mode = DB_FETCHMODE_ASSOC);
if (isset($_role['id'])) {
// existing role, need to update only
$new_role = new Roles();
$new_role->id = $role['id'];
$new_role->description = $role['description'];
$new_role->name = $role['name'];
$new_role->type = $role['type'];
$new_role->update();
Roles::delete_role_tasks($new_role->id);
if (!empty($role['tasks'])) {
$tasks = array();
foreach ($role['tasks'] as $task) {
$tasks[] = $task['id'];
}
Roles::assign_tasks_to_role($tasks, $new_role->id);
}
} else {
$new_role = new Roles();
$new_role->description = $role['description'];
$new_role->name = $role['name'];
$role_id = $new_role->create();
if ($role_id && !empty($role['tasks'])) {
$tasks = array();
foreach ($role['tasks'] as $task) {
$tasks[] = $task['id'];
}
Roles::assign_tasks_to_role($tasks, $role_id);
}
}
}
$error_msg = $_msg ? $_msg : __('Default Roles settings sucessfully restored.');
} else {
$error_msg = __('There is no Roles data in default XML settings file.');
}
} catch (Exception $e) {
$error = TRUE;
$error_msg = $e->getMessage();
}
return $error_msg;
}