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


PHP UserRole::find方法代码示例

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


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

示例1: getRemoveRole

 public function getRemoveRole($user_id, $role_id)
 {
     $userroles = UserRole::find(array('user_id', '=', $user_id), array('role_id', '=', $role_id));
     foreach ($userroles as $ur) {
         if ($ur->delete()) {
             $this->flash()->success('@string/user_role_remove_success');
         }
     }
     return $this->response()->redirect();
 }
开发者ID:mermetbt,项目名称:biome,代码行数:10,代码来源:UserController.php

示例2: findByUserId

 public static function findByUserId($id)
 {
     $userroles = UserRole::find(array('where' => 'user_id = :user_id', 'values' => array(':user_id' => (int) $id)));
     if (count($userroles) <= 0) {
         return false;
     }
     $roles = array();
     foreach ($userroles as $role) {
         $roles[] = Role::findById($role->role_id);
     }
     return $roles;
 }
开发者ID:ariksavage,项目名称:superior-optical-eyewear,代码行数:12,代码来源:Role.php

示例3: mail

 public function mail()
 {
     if (!(($id = OAInput::post('id')) && ($contact = Contact::find_by_id($id, array('select' => 'name, email, message'))))) {
         return false;
     }
     if (!(($admin_ids = array_unique(column_array(UserRole::find('all', array('select' => 'user_id', 'conditions' => array('name IN (?)', array('root', 'contact_manager')))), 'user_id'))) && ($admins = User::find('all', array('select' => 'name, email', 'conditions' => array('id IN (?)', $admin_ids)))))) {
         return false;
     }
     $this->load->library('OAMail');
     $email = $contact->email;
     $name = $contact->name;
     $message = $contact->message;
     $mail = OAMail::create()->setSubject('[系統通知] 官網有新的留言!')->setBody("<article style='font-size:15px;line-height:22px;color:rgb(85,85,85)'><p style='margin-bottom:0'>Hi 管理員,</p><section style='padding:5px 20px'><p>剛剛有一個訪客在您的「聯絡我們」留言囉,以下他所留下的聯絡資料:</p><table style='width:100%;border-collapse:collapse'><tbody><tr><th style='width:100px;text-align:right;padding:11px 5px 10px 0;border-bottom:1px dashed rgba(200,200,200,1)'>E-Mail:</th><td style='text-align:left;text-align:left;padding:11px 0 10px 5px;border-bottom:1px dashed rgba(200,200,200,1)'>" . $email . "</td></tr><tr><th style='width:100px;text-align:right;padding:11px 5px 10px 0;border-bottom:1px dashed rgba(200,200,200,1)'>稱 呼:</th><td style='text-align:left;text-align:left;padding:11px 0 10px 5px;border-bottom:1px dashed rgba(200,200,200,1)'>" . $name . "</td></tr><tr><th style='width:100px;text-align:right;padding:11px 5px 10px 0;border-bottom:1px dashed rgba(200,200,200,1)'>內容:</th><td style='text-align:left;text-align:left;padding:11px 0 10px 5px;border-bottom:1px dashed rgba(200,200,200,1)'>" . $message . "</td></tr></tbody></table><br/><p style='text-align:right'>如果需要詳細列表,可以置<a href='" . base_url('admin', 'contacts') . "' style='color:rgba(96,156,255,1);margin:0 2px'>管理後台</a>檢閱。</p></section></article>");
     foreach ($admins as $admin) {
         $mail->addTo($admin->email, $admin->name);
     }
     $mail->send();
     $mail = OAMail::create()->setSubject('[宙思設計] 留言成功通知!')->setBody("<article style='font-size:15px;line-height:22px;color:rgb(85, 85, 85)'><p style='margin-bottom:0'>Hi " . $name . ",</p><section style='padding:5px 20px'><p>您好,我們是<a href='http://www.zeusdesign.com.tw/' style='color:rgba(96, 156, 255, 1);margin:0 2px'>宙思設計</a>團隊,我們已經收到您的留言囉。</p><p>我們稍後會有專人主動與您聯絡或回信給您!</p><p>若是尚未得到回覆,您可以至<a href='https://www.facebook.com/ZeusDesignStudio/' style='color:rgba(96, 156, 255, 1);margin:0 2px'>宙思設計臉書粉絲專頁</a>留言,或來電(02-2941-6737)聯絡我們。</p><p style='text-align:right'>- <a href='http://www.zeusdesign.com.tw/' style='color:rgba(96, 156, 255, 1);margin:0 2px'>宙思設計</a>團隊感謝您。</p></section></article>")->addTo($email, $name);
     $mail->send();
 }
开发者ID:comdan66,项目名称:zeusdesign,代码行数:20,代码来源:contacts.php

示例4: update

 public function update()
 {
     if (!$this->has_post()) {
         return redirect_message(array('admin', $this->get_class(), $this->user->id, 'edit'), array('_flash_message' => '非 POST 方法,錯誤的頁面請求。'));
     }
     $posts = OAInput::post();
     if ($msg = $this->_validation_posts($posts)) {
         return redirect_message(array('admin', $this->get_class(), $this->user->id, 'edit'), array('_flash_message' => $msg, 'posts' => $posts));
     }
     if ($columns = array_intersect_key($posts, $this->user->table()->columns)) {
         foreach ($columns as $column => $value) {
             $this->user->{$column} = $value;
         }
     }
     $user = $this->user;
     $update = user::transaction(function () use($user) {
         return $user->save();
     });
     if (!$update) {
         return redirect_message(array('admin', $this->get_class(), $this->user->id, 'edit'), array('_flash_message' => '更新失敗!', 'posts' => $posts));
     }
     $ori_keys = column_array($user->roles, 'name');
     if (($del_keys = array_diff($ori_keys, $posts['roles'])) && ($roles = UserRole::find('all', array('select' => 'id', 'conditions' => array('user_id = ? AND name IN (?)', $user->id, $del_keys))))) {
         foreach ($roles as $role) {
             UserRole::transaction(function () use($role) {
                 return $role->destroy();
             });
         }
     }
     if ($add_keys = array_diff($posts['roles'], $ori_keys)) {
         foreach ($add_keys as $add_key) {
             UserRole::transaction(function () use($add_key, $user) {
                 return verifyCreateOrm(UserRole::create(Array_intersect_key(array('name' => $add_key, 'user_id' => $user->id), UserRole::table()->columns)));
             });
         }
     }
     return redirect_message(array('admin', $this->get_class()), array('_flash_message' => '更新成功!'));
 }
开发者ID:comdan66,项目名称:zeusdesign,代码行数:38,代码来源:users.php

示例5: _templateUserRoles

 /**
  * Template User Roles
  * If null user roles get all user roles and set it to all.
  * 
  * @param mixed $roles 
  * @todo Why is this checking a variable that isn't passed?
  */
 protected function _templateUserRoles($roles)
 {
     if ($template['Webpage']['user_roles'] === null) {
         App::uses('UserRole', 'Users.Model');
         $UserRole = new UserRole();
         $roles = serialize(Set::extract('/UserRole/id', $UserRole->find('all', array('fields' => array('UserRole.id')))));
     }
     return $roles;
 }
开发者ID:ajayphp,项目名称:Zuha,代码行数:16,代码来源:Webpage.php

示例6: GetByRoleId

 public static function GetByRoleId($roleId)
 {
     return UserRole::find('all', array('role_id' => $roleId));
 }
开发者ID:krasaler,项目名称:FamilyStore,代码行数:4,代码来源:UserRoleService.php

示例7: role_destroy

 public function role_destroy($id)
 {
     UserRole::find($id)->delete();
 }
开发者ID:sammy8806,项目名称:gsi_laravel,代码行数:4,代码来源:PermissionAdminController.php

示例8: deleteAction

 /**
  * @Route("/delete/{id}", methods={"POST"}, name="userroledelete")
  */
 public function deleteAction($id)
 {
     $userdata = explode('-', $id);
     $userid = $userdata[0];
     $roleid = $userdata[1];
     $entity = UserRole::find(array("conditions" => "userid = :userid: and roleid = :roleid:", "bind" => array('userid' => $userid, 'roleid' => $roleid)));
     if (!$entity->delete()) {
         foreach ($addres->getMessages() as $message) {
             $this->flash->error($message);
         }
         return $this->dispatcher->forward(array("controller" => "UserRole", "action" => "show", "parameters" => array($id)));
     } else {
         $this->response->redirect(array('for' => 'userrolelist', 'userid' => $userid));
     }
 }
开发者ID:andresfranco,项目名称:Phalcontest,代码行数:18,代码来源:UserRoleController.php

示例9: menu

 /**
  * Menu method
  * Create a new menu for a user specific case for menu creation during build
  * 
  */
 public function menu()
 {
     App::uses('UserRole', 'Users.Model');
     $UserRole = new UserRole();
     $userRoles = $UserRole->find('list');
     $text = __('%s Dashboard', Inflector::humanize($userRoles[$this->request->data['WebpageMenu']['user_role_id']]));
     $this->request->data['WebpageMenu']['name'] = $text;
     $this->request->data['WebpageMenu']['parent_id'] = null;
     $this->request->data['WebpageMenu']['item_text'] = $text;
     App::uses('WebpageMenu', 'Webpages.Model');
     $WebpageMenu = new WebpageMenu();
     $WebpageMenu->create();
     if ($WebpageMenu->save($this->request->data)) {
         $this->Session->setFlash(__('New flow started'));
         $this->redirect($this->referer());
     } else {
         $this->Session->setFlash(__('Save failure. Please, try again.'));
         $this->redirect($this->referer());
     }
 }
开发者ID:ayaou,项目名称:Zuha,代码行数:25,代码来源:InstallController.php


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