本文整理汇总了PHP中Roles::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Roles::create方法的具体用法?PHP Roles::create怎么用?PHP Roles::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Roles
的用法示例。
在下文中一共展示了Roles::create方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
public function create()
{
if (isset($_POST['rolename']) && !empty($_POST['rolename'])) {
$role = new Roles();
$role->role_name = $_POST['rolename'];
$role->role_description = $_POST['description'];
$role->date_created = date('Y-m-d H:i:s');
if ($role->create()) {
return 1;
} else {
return 2;
}
}
}
示例2: run
public function run()
{
// se crean todos los roles del sistema
$arr_roles = array(array('code' => '1', 'name' => 'Ver Clientes'), array('code' => '1.1', 'name' => 'Crear Clientes'), array('code' => '1.2', 'name' => 'Editar Clientes'), array('code' => '1.3', 'name' => 'Eliminar Clientes'), array('code' => '2', 'name' => 'Ver Categoria'), array('code' => '2.1', 'name' => 'Crear Categoria'), array('code' => '2.2', 'name' => 'Editar Categoria'), array('code' => '2.3', 'name' => 'Eliminar Categoria'), array('code' => '3', 'name' => 'Ver Sub Categoria'), array('code' => '3.1', 'name' => 'Crear Sub Categoria'), array('code' => '3.2', 'name' => 'Editar Sub Categoria'), array('code' => '3.3', 'name' => 'Eliminar Sub Categoria'), array('code' => '4', 'name' => 'Ver Productos'), array('code' => '4.1', 'name' => 'Crear Productos'), array('code' => '4.2', 'name' => 'Editar Productos'), array('code' => '4.3', 'name' => 'Eliminar Productos'));
$db_roles = Roles::all()->toArray();
for ($i = 0; $i < count($arr_roles); $i++) {
$inser = true;
for ($j = 0; $j < count($db_roles); $j++) {
if ($arr_roles[$i]['code'] == $db_roles[$j]['code']) {
$inser = false;
}
}
if ($inser) {
Roles::create($arr_roles[$i]);
}
}
}
示例3: 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;
}
示例4: header
$role->update();
$msg = 9009;
header("Location:roles.php?msg_id={$msg}");
exit;
} catch (PAException $e) {
$msg = "{$e->message}";
$error = TRUE;
}
}
if (@$_POST['submit']) {
$role = new Roles();
filter_all_post($_POST);
try {
$role->description = $_POST['desc'];
$role->name = $_POST['role_name'];
$role->create();
$msg = 9007;
header("Location:roles.php?msg_id={$msg}");
exit;
} catch (PAException $e) {
$msg = "{$e->message}";
$error = TRUE;
}
}
//$configure_permission = current_user_can('configure_network');
$permission_denied_msg = '';
if (!$configure_permission) {
$error = TRUE;
$permission_denied_msg = "Sorry! you are not authorized to view the content of this page";
}
$page = new PageRenderer("setup_module", PAGE_ROLE_MANAGE, "", 'container_two_column.tpl', 'header.tpl', PRI, HOMEPAGE, $network_info);