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


PHP Roles::findFirst方法代码示例

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


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

示例1: indexAction

 public function indexAction($action = null, $role_id = null, $user_id = null)
 {
     // Add a user to a mailing list
     if ($this->request->isPost()) {
         $user_id = $this->request->getPost("user_id");
         $role_id = $this->request->getPost("role_id");
         if (!empty($user_id)) {
             // If user and corresponding role already exist
             if ($mail = PMailList::findFirst("role_id={$role_id} AND user_id={$user_id}")) {
                 $this->flash->error("Получатель уже существует");
             } else {
                 $mail_list = new PMailList();
                 $mail_list->role_id = $role_id;
                 $mail_list->user_id = $user_id;
                 if ($mail_list->save()) {
                     $this->flash->success("Получатель добавлен");
                 }
             }
             return $this->response->redirect("mailer/index");
         }
     }
     // Delete a user from a mailing list
     if ($action == 'delete') {
         if ($mail = PMailList::findFirst("role_id={$role_id} AND user_id={$user_id}")) {
             if (!$mail->delete()) {
                 $this->flash->error("Произошла ошибка");
             } else {
                 $this->flash->success("Получатель удален");
             }
             return $this->response->redirect("mailer/index");
         }
     }
     // List of roles
     foreach ($this->roles as $alias) {
         $role = Roles::findFirst("alias='{$alias}'");
         $roles[$role->id] = $role->name;
     }
     $this->view->roles = $roles;
     // List of users subscribed
     $list = [];
     $all = PMailList::find();
     foreach ($all as $one) {
         $list[] = [$one->role_id => [$one->user_id => $one->Accounts->name]];
     }
     $this->view->list = $list;
 }
开发者ID:serge2300,项目名称:madeheart,代码行数:46,代码来源:MailerController.php

示例2: get_all_permissions

 public function get_all_permissions()
 {
     // $request = $this->get_request();
     // $id_user = $request->id;
     $id_user = 1;
     $role_acos = array();
     $user = Users::findFirst($id_user);
     foreach ($user->RolesUsers as $rol_usuario) {
         $roles = Roles::findFirst($rol_usuario->getIdRole());
         foreach ($roles->RolesPermissions as $rol_permission) {
             $role_acos[] = $rol_permission->Permissions->getIdAco();
         }
     }
     $user_acos = array();
     $user = Users::findFirst($id_user);
     foreach ($user->UsersPermissions as $user_permission) {
         $user_acos[] = $user_permission->Permissions->getIdAco();
     }
     $merge_permissions = array_merge($role_acos, $user_acos);
     $result = array_unique($merge_permissions);
     return $result;
 }
开发者ID:julianmc90,项目名称:phalcon-db-acl-plugin,代码行数:22,代码来源:Acl.php


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