当前位置: 首页>>代码示例>>PHP>>正文


PHP Roles::update方法代码示例

本文整理汇总了PHP中Roles::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Roles::update方法的具体用法?PHP Roles::update怎么用?PHP Roles::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Roles的用法示例。


在下文中一共展示了Roles::update方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: editsystemroleAction

 /** Edit a system role
  */
 public function editsystemroleAction()
 {
     $form = new SystemRoleForm();
     $this->view->form = $form;
     if ($this->_request->isPost()) {
         $formData = $this->_request->getPost();
         if ($form->isValid($formData)) {
             $roles = new Roles();
             $updateData = array('role' => $form->getValue('role'), 'description' => $form->getValue('description'), 'updated' => $this->getTimeForForms(), 'updatedBy' => $this->getIdentityForForms());
             $where = array();
             $where[] = $roles->getAdapter()->quoteInto('id = ?', $this->_getParam('id'));
             $update = $roles->update($updateData, $where);
             $this->_flashMessenger->addMessage($form->getValue('role') . '\'s details updated.');
             $this->_redirect('/admin/systemroles/');
         } else {
             $form->populate($formData);
         }
     } else {
         // find id is expected in $params['id']
         $id = (int) $this->_request->getParam('id', 0);
         if ($id > 0) {
             $roles = new Roles();
             $roles = $roles->fetchRow('id=' . $id);
             $form->populate($roles->toArray());
         }
     }
 }
开发者ID:rwebley,项目名称:Beowulf---PAS,代码行数:29,代码来源:SystemController.php

示例2: editAction

 function editAction()
 {
     $request = new Bolts_Request($this->getRequest());
     $roles_table = new Roles();
     $role = null;
     if ($request->has('id')) {
         if (!is_null($request->id)) {
             $role = $roles_table->fetchRow($roles_table->select()->where("id = ?", $request->id));
             if (!is_null($role)) {
                 // we do not edit the guest role
                 if ($role->shortname == "guest") {
                     $this->_redirect("/bolts/role");
                 }
                 $this->view->role = $role->toArray();
                 $this->view->role_tree = $roles_table->getRoleTree(null, $role->id);
                 $this->view->inherited_ids = $roles_table->getInheritedRoles($role->id);
             }
         }
     }
     if (is_null($role)) {
         $this->view->role_tree = $roles_table->getRoleTree();
     }
     if ($this->getRequest()->isPost()) {
         $errors = array();
         if ($request->has('inherit_role')) {
             $parents = array();
             foreach ($request->inherit_role as $inherit_role) {
                 $parents = array_merge($parents, $roles_table->getAllAncestors($inherit_role));
             }
             $inherit_ids = array();
             foreach ($request->inherit_role as $inherit_role) {
                 if (!in_array($inherit_role, $parents)) {
                     $inherit_ids[] = $inherit_role;
                 }
             }
         }
         if ($request->has('shortname')) {
             $shortname = $request->shortname;
             if (!Bolts_Validate::checkLength($request->shortname, 1, 255)) {
                 $errors[] = $this->_T("Shortname must be between 1 and 255 chars.");
             }
         } else {
             $errors[] = $this->_T("Shortname is a requried field.");
         }
         $description = $request->description;
         $isadmin = (int) $request->checkbox('isadmin');
         if (count($errors) == 0) {
             $data = array('shortname' => $shortname, 'description' => $description, 'isadmin' => $isadmin);
             //If we have an id, this is an update.
             $id = (int) $this->_request->getPost('id');
             if ($id != 0) {
                 $where = 'id = ' . $id;
                 $roles_table->update($data, $where);
             } else {
                 //We don't, this is an insert.
                 $id = $roles_table->insert($data);
             }
             $roles_table->removeInheritedRole($id);
             foreach ($inherit_ids as $in_id) {
                 $roles_table->setInheritedRole($id, $in_id);
             }
             $this->_redirect("/bolts/role");
         } else {
             $this->view->errors = $errors;
         }
     }
     if ($request->has('id')) {
         // this is an edit
         $id = $request->id;
         if ($id > 0) {
             $this->view->role = $roles_table->fetchRow('id = ' . $id)->toArray();
         }
         $this->view->inherited_ids = $roles_table->getInheritedRoles($id);
     } else {
         foreach ($roles_table->fetchAll()->toArray() as $role) {
             $role_choices[$role['id']] = $role['shortname'];
         }
         $this->view->role_choices = $role_choices;
     }
 }
开发者ID:jaybill,项目名称:Bolts,代码行数:80,代码来源:RoleController.php

示例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;
 }
开发者ID:Cyberspace-Networks,项目名称:CoreSystem,代码行数:56,代码来源:CNRoleManageModule.php

示例4: Roles

    //old method for spawned networks
    $configure_permission = current_user_can('configure_network');
}
/********/
$msg = "";
if (@$_GET['msg_id']) {
    $msg = $_GET['msg_id'];
}
if (@$_POST['role_id']) {
    $role = new Roles();
    filter_all_post($_POST);
    $role->id = $_POST['role_id'];
    $role->description = $_POST['desc'];
    $role->name = $_POST['role_name'];
    try {
        $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();
开发者ID:CivicCommons,项目名称:oldBellCaPA,代码行数:31,代码来源:roles.php


注:本文中的Roles::update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。