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


PHP Permission::save方法代码示例

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


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

示例1: store

 /**
  * Store a newly created resource in storage.
  * POST /admin.permissions
  *
  * @return Response
  */
 public function store()
 {
     //Asignamos los valores del post a la instancia.
     $this->permission = new Permission();
     //Si no es posible guardar la instancia mandamos errores
     if (!$this->permission->save()) {
         //dd($this->permission->errors()->all());
         return Redirect::back()->withErrors($this->permission->errors());
     }
     //Se han guardado los valores, expresamos al usuario nuestra felicidad al respecto.
     return Redirect::to('admin/permission/create')->with('success', '¡Se ha creado correctamente el permiso: ' . $this->permission->name . " !");
 }
开发者ID:ferns24,项目名称:catastro,代码行数:18,代码来源:AdminPermissionsController.php

示例2: grantAccess

 /**
  * Grants access to an user over a resource.
  * 
  * @param string $subj_type
  * @param number $subj_id
  * @param string $rule_name
  * @param string $obj_type
  * @param number $obj_id
  * @return boolean
  */
 public static function grantAccess($subj_type, $subj_id, $rule_name, $obj_type = null, $obj_id = null)
 {
     $ret_val = false;
     if (isset($subj_type) && isset($subj_id) && isset($rule_name)) {
         $rule = Rule::model()->findByAttributes(array('name' => $rule_name));
         if (isset($rule)) {
             $attr['subject_type'] = $subj_type;
             $attr['subject_id'] = $subj_id;
             $attr['rule_id'] = $rule->id;
             $attr['object_type'] = isset($obj_type) ? $obj_type : null;
             $attr['object_id'] = isset($obj_id) ? $obj_id : null;
             $found = Permission::model()->findByAttributes($attr);
             if (!isset($found)) {
                 $obj_perm = new Permission();
                 $obj_perm->subject_type = $subj_type;
                 $obj_perm->subject_id = $subj_id;
                 $obj_perm->rule_id = $rule->id;
                 $obj_perm->object_type = isset($obj_type) ? $obj_type : null;
                 $obj_perm->object_id = isset($obj_id) ? $obj_id : null;
                 if ($obj_perm->save()) {
                     $ret_val = true;
                 }
             }
         }
     }
     return $ret_val;
 }
开发者ID:bafio89,项目名称:qea-u,代码行数:37,代码来源:QAuthManager.php

示例3: run

 public function run()
 {
     $ver_usuarios = new Permission();
     $ver_usuarios->name = 'ver_usuarios';
     $ver_usuarios->display_name = 'ver usuarios';
     $ver_usuarios->save();
     $ver_roles = new Permission();
     $ver_roles->name = 'ver_roles';
     $ver_roles->display_name = 'ver roles';
     $ver_roles->save();
     $crear_roles = new Permission();
     $crear_roles->name = 'crear_roles';
     $crear_roles->display_name = 'crear roles';
     $crear_roles->save();
     $crear_usuarios = new Permission();
     $crear_usuarios->name = 'crear_usuarios';
     $crear_usuarios->display_name = 'crear usuarios';
     $crear_usuarios->save();
     $editar_roles = new Permission();
     $editar_roles->name = 'editar_roles';
     $editar_roles->display_name = 'editar roles';
     $editar_roles->save();
     $editar_usuarios = new Permission();
     $editar_usuarios->name = 'editar_usuarios';
     $editar_usuarios->display_name = 'editar usuarios';
     $editar_usuarios->save();
     $eliminar_usuarios = new Permission();
     $eliminar_usuarios->name = 'eliminar_usuarios';
     $eliminar_usuarios->display_name = 'eliminar usuarios';
     $eliminar_usuarios->save();
     $eliminar_roles = new Permission();
     $eliminar_roles->name = 'eliminar_roles';
     $eliminar_roles->display_name = 'eliminar roles';
     $eliminar_roles->save();
 }
开发者ID:ofcadavidm,项目名称:laravel-entrust,代码行数:35,代码来源:PermissionsSeeder.php

示例4: createPermission

 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function createPermission()
 {
     $input = array('modulename' => Input::get('modulename'));
     $validator = Validator::make($input, array('modulename' => 'required'));
     // process the login
     if ($validator->fails()) {
         return Redirect::action('PermissionController@create')->withErrors($validator);
     } else {
         $module = Input::get('modulename');
         $permission = new Permission();
         $permission->modulename = strtolower(Input::get('modulename'));
         $permission->permissions = Input::get('permissions');
         $c = array();
         $perms_array = $permission->permissions;
         $c = explode(',', $perms_array);
         $perm = '';
         foreach ($c as $key => $value) {
             $val = '"' . $permission->modulename . '.' . $c[$key] . '"';
             $perm .= $val . ', ';
         }
         $perm2 = rtrim($perm, ", ");
         $perm3 = '[' . $perm2 . ']';
         //echo $perm3;
         $permission->permissions = $perm3;
         $permission->save();
         return Redirect::action('PermissionController@index')->with('success', Lang::get('permissions.create_success'));
     }
 }
开发者ID:jarciga,项目名称:Euler2015Alpha,代码行数:33,代码来源:PermissionController.php

示例5: run

 public function run()
 {
     if (file_exists(app_path() . '/config/creds.yml')) {
         $creds = yaml_parse_file(app_path() . '/config/creds.yml');
     } else {
         $creds = array('admin_email' => 'admin@example.com');
     }
     $admin = new Role();
     $admin->name = 'Admin';
     $admin->save();
     $independent_sponsor = new Role();
     $independent_sponsor->name = 'Independent Sponsor';
     $independent_sponsor->save();
     $permIds = array();
     foreach ($this->adminPermissions as $permClass => $data) {
         $perm = new Permission();
         foreach ($data as $key => $val) {
             $perm->{$key} = $val;
         }
         $perm->save();
         $permIds[] = $perm->id;
     }
     $admin->perms()->sync($permIds);
     $user = User::where('email', '=', $creds['admin_email'])->first();
     $user->attachRole($admin);
     $createDocPerm = new Permission();
     $createDocPerm->name = "independent_sponsor_create_doc";
     $createDocPerm->display_name = "Independent Sponsoring";
     $createDocPerm->save();
     $independent_sponsor->perms()->sync(array($createDocPerm->id));
 }
开发者ID:iaincollins,项目名称:madison,代码行数:31,代码来源:RbacSeeder.php

示例6: actionSetpermission

 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionSetpermission()
 {
     // echo "set permission";
     $user = $_REQUEST['user'];
     $permission_id = $_REQUEST['per_id'];
     $bool = $_REQUEST['bool'];
     echo $bool;
     if ($bool == "true") {
         $bool = 1;
     } else {
         $bool = 0;
     }
     // $ =  $_REQUEST['per_id'];
     $model = Permission::model()->count("username = '{$user}' and permission_id = '{$permission_id}' ");
     if ($model == 0) {
         $p = new Permission();
         $p->username = $user;
         $p->permission_id = $permission_id;
         $p->status = 1;
         if ($p->save()) {
             echo "added";
         } else {
             print_r($p->getErrors());
         }
     } else {
         $p = Permission::model()->find("username = '{$user}' and permission_id = '{$permission_id}' ");
         $p->status = $bool;
         if ($p->save()) {
             echo "updated";
         } else {
             print_r($p->getErrors());
         }
     }
 }
开发者ID:Dvionst,项目名称:vvfy,代码行数:38,代码来源:RulesController.php

示例7: run

 public function run()
 {
     $adminEmail = Config::get('madison.seeder.admin_email');
     $admin = new Role();
     $admin->name = 'Admin';
     $admin->save();
     $independent_sponsor = new Role();
     $independent_sponsor->name = 'Independent Sponsor';
     $independent_sponsor->save();
     $permIds = array();
     foreach ($this->adminPermissions as $permClass => $data) {
         $perm = new Permission();
         foreach ($data as $key => $val) {
             $perm->{$key} = $val;
         }
         $perm->save();
         $permIds[] = $perm->id;
     }
     $admin->perms()->sync($permIds);
     $user = User::where('email', '=', $adminEmail)->first();
     $user->attachRole($admin);
     $createDocPerm = new Permission();
     $createDocPerm->name = "independent_sponsor_create_doc";
     $createDocPerm->display_name = "Independent Sponsoring";
     $createDocPerm->save();
     $independent_sponsor->perms()->sync(array($createDocPerm->id));
 }
开发者ID:krues8dr,项目名称:madison,代码行数:27,代码来源:RbacSeeder.php

示例8: save

 public function save($id = FALSE)
 {
     if ($_POST) {
         $user_type = new User_type($id);
         $user_type->from_array($_POST);
         $user_type->save();
         foreach ($user_type->permission as $item) {
             $item->delete();
         }
         if (isset($_POST['checkbox'])) {
             foreach ($_POST['checkbox'] as $module => $item) {
                 $data['user_type_id'] = $user_type->id;
                 $data['module'] = $module;
                 foreach ($item as $perm => $val) {
                     $data[$perm] = $val;
                 }
                 $permission = new Permission();
                 $permission->from_array($data);
                 $permission->save();
                 $data = array();
             }
         }
         set_notify('success', lang('save_data_complete'));
     }
     //redirect('permissions/admin/permissions');
     redirect($_SERVER['HTTP_REFERER']);
 }
开发者ID:unisexx,项目名称:imac,代码行数:27,代码来源:permissions.php

示例9: Permission

 function _savePermissions($setting_values)
 {
     $newGroup = new Permission($this->dbcon);
     foreach ($setting_values as $perid) {
         $newGroup->dropID();
         $newGroup->setData(array('perid' => $perid, 'groupid' => $this->id));
         $newGroup->save();
     }
 }
开发者ID:radicaldesigns,项目名称:amp,代码行数:9,代码来源:Group.php

示例10: createRbacRules

 public function createRbacRules()
 {
     $this->destroyRbacRules();
     $ownerRole = new Role();
     $ownerRole->name = "group_{$this->id}_owner";
     $ownerRole->save();
     $permissions = $this->getPermissionsArray();
     $permIds = array();
     $permLookup = array();
     foreach ($permissions as $perm) {
         $permModel = new Permission();
         foreach ($perm as $key => $val) {
             $permModel->{$key} = $val;
         }
         $permModel->save();
         $permIds[] = $permModel->id;
         switch ($perm['name']) {
             case "group_{$this->id}_create_document":
                 $permLookup['create'] = $permModel->id;
                 break;
             case "group_{$this->id}_edit_document":
                 $permLookup['edit'] = $permModel->id;
                 break;
             case "group_{$this->id}_delete_document":
                 $permLookup['delete'] = $permModel->id;
                 break;
             case "group_{$this->id}_manage_document":
                 $permLookup['manage'] = $permModel->id;
                 break;
         }
     }
     $ownerRole->perms()->sync($permIds);
     $editorRole = new Role();
     $editorRole->name = "group_{$this->id}_editor";
     $editorRole->save();
     $editorRole->perms()->sync(array($permLookup['create'], $permLookup['edit'], $permLookup['manage']));
     $staffRole = new Role();
     $staffRole->name = "group_{$this->id}_staff";
     $staffRole->save();
     $users = array(static::ROLE_OWNER => $this->findUsersByRole(static::ROLE_OWNER), static::ROLE_EDITOR => $this->findUsersByRole(static::ROLE_EDITOR), static::ROLE_STAFF => $this->findUsersByRole(static::ROLE_STAFF));
     foreach ($users as $role => $userList) {
         foreach ($userList as $userObj) {
             switch ($role) {
                 case static::ROLE_OWNER:
                     $userObj->attachRole($ownerRole);
                     break;
                 case static::ROLE_EDITOR:
                     $userObj->attachRole($editorRole);
                     break;
                 case static::ROLE_STAFF:
                     $userObj->attachRole($staffRole);
                     break;
             }
         }
     }
 }
开发者ID:iaincollins,项目名称:madison,代码行数:56,代码来源:Group.php

示例11: grantInternal

 /**
  * @param string $sourceName
  * @param int $sourceId
  * @param string $targetName
  * @param int $targetId
  * @param string $permission
  * @return bool Whether the permission record was saved successfully.
  */
 protected function grantInternal($sourceName, $sourceId, $targetName, $targetId, $permission)
 {
     $perm = new Permission();
     $perm->source = $sourceName;
     $perm->source_id = $sourceId;
     $perm->target = $targetName;
     $perm->target_id = $targetId;
     $perm->permission = $permission;
     return $perm->save();
 }
开发者ID:sam-it,项目名称:abac,代码行数:18,代码来源:Manager.php

示例12: store

 /**
  * Store a newly created resource in storage.
  * POST /permissions
  *
  * @return Response
  */
 public function store()
 {
     $permission = new Permission();
     $permission->name = Input::get('name');
     $permission->display_name = Input::get('display_name');
     if ($permission->save()) {
         return Redirect::back()->with('permissions-notice', '"' . Input::get('display_name') . '" has been created.');
     } else {
         return Redirect::back()->with('permissions-errors', $permission->errors());
     }
 }
开发者ID:vanderlin,项目名称:halp,代码行数:17,代码来源:PermissionsController.php

示例13: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $permission = new Permission();
     $permission->perm_name = Input::get('perm_name');
     $permission->perm_key = Input::get('perm_key');
     $permission->visible = Input::get('visible');
     $permission->date_created = new DateTime();
     $permission->save();
     $message = 'Permission has been created';
     return Redirect::action('settings.permission')->with('success', $message);
 }
开发者ID:pacificcasinohotel,项目名称:pointsystem,代码行数:16,代码来源:PermissionController.php

示例14: run

 public function run()
 {
     /**
      * ------------------------ Role Definitions ------------------------
      */
     $admin = new Role();
     $admin->name = 'administrator';
     $admin->display_name = 'Administrator';
     $admin->description = 'master admin';
     $admin->save();
     $user = new Role();
     $user->name = 'user';
     $user->display_name = 'User';
     $user->description = 'Generic user';
     $user->save();
     /**
      * --------------------- Permission Definitions ---------------------
      */
     $editAllPosts = new Permission();
     $editAllPosts->name = 'edit_all_posts';
     $editAllPosts->display_name = 'Can Edit All Posts';
     $editAllPosts->description = 'permission for the master admin to be able to edit all posts';
     $editAllPosts->save();
     $editAllUsers = new Permission();
     $editAllUsers->name = 'edit_all_users';
     $editAllUsers->display_name = 'Can Edit All Users';
     $editAllUsers->description = 'Able to edit all user profiles and information';
     $editAllUsers->save();
     $editAllRoles = new Permission();
     $editAllRoles->name = 'edit_all_roles';
     $editAllRoles->display_name = 'Can Edit All Roles';
     $editAllRoles->description = 'Able to add or remove any role for any user';
     $editAllRoles->save();
     $editOwnPosts = new Permission();
     $editOwnPosts->name = 'edit_own_posts';
     $editOwnPosts->display_name = 'Can Edit Own Posts';
     $editOwnPosts->description = 'Users can edit their own posts';
     $editOwnPosts->save();
     $editOwnProfile = new Permission();
     $editOwnProfile->name = 'edit_own_profile';
     $editOwnProfile->display_name = 'Can Edit Own Profile';
     $editOwnProfile->description = 'Users can edit their own profiles';
     $editOwnProfile->save();
     $createPost = new Permission();
     $createPost->name = 'create_post';
     $createPost->display_name = 'Can Create Post';
     $createPost->description = 'Able to create a post';
     $createPost->save();
     /**
      * ----------------------- Attatch Permissions -----------------------
      */
     $admin->attatchPermissions([$editAllPosts, $editAllUsers, $editAllRoles, $editOwnPosts, $editOwnProfile, $createPost]);
     $user->attatchPermissions([$editOwnPosts, $editOwnProfile, $createPost]);
 }
开发者ID:ZJScapstone,项目名称:capstone.dev,代码行数:54,代码来源:EntrustTableSeeder.php

示例15: doSave

 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aPermission !== null) {
             if ($this->aPermission->isModified() || $this->aPermission->isNew()) {
                 $affectedRows += $this->aPermission->save($con);
             }
             $this->setPermission($this->aPermission);
         }
         if ($this->aPermissionItem !== null) {
             if ($this->aPermissionItem->isModified() || $this->aPermissionItem->isNew()) {
                 $affectedRows += $this->aPermissionItem->save($con);
             }
             $this->setPermissionItem($this->aPermissionItem);
         }
         if ($this->isNew()) {
             $this->modifiedColumns[] = PermissionToPermissionItemPeer::ID;
         }
         // If this object has been modified, then save it to the database.
         $this->objectSaved = false;
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = PermissionToPermissionItemPeer::doInsert($this, $con);
                 $affectedRows += 1;
                 // we are assuming that there is only 1 row per doInsert() which
                 // should always be true here (even though technically
                 // BasePeer::doInsert() can insert multiple rows).
                 $this->setId($pk);
                 //[IMV] update autoincrement primary key
                 $this->setNew(false);
                 $this->objectSaved = true;
             } else {
                 $affectedObjects = PermissionToPermissionItemPeer::doUpdate($this, $con);
                 if ($affectedObjects) {
                     $this->objectSaved = true;
                 }
                 $affectedRows += $affectedObjects;
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
开发者ID:DBezemer,项目名称:server,代码行数:63,代码来源:BasePermissionToPermissionItem.php


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