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


PHP Role::findOne方法代码示例

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


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

示例1: describe

 public function describe()
 {
     $this->unserialize();
     $old = $this->old_serialized;
     $new = $this->new_serialized;
     switch ($this->priority) {
         case Logic_Log_Admin::USEREDIT:
             if ($old instanceof Row_User && $new instanceof Row_User) {
                 $oldData = $old->toArray();
                 $newData = $new->toArray();
                 $changes = array();
                 $headers = $old->getHeaderMappings();
                 $translate = Zend_Registry::get('Zend_Translate');
                 foreach ($oldData as $col => $val) {
                     if ($newData[$col] != $val) {
                         $description = isset($headers[$col]) ? $translate->_($headers[$col]['title']) : $col;
                         $description .= ': z "' . $oldData[$col] . '" na "' . $newData[$col] . '"';
                         $description = $description;
                         $changes[] = $description;
                     }
                 }
                 return 'Zmieniono ' . implode(', ', $changes);
             }
         case Logic_Log_Admin::ROLEADD:
         case Logic_Log_Admin::ROLEDELETE:
             $role = new Role();
             if ($old instanceof Row_ProfileRole) {
                 $row = $role->findOne($old->id_role);
                 return 'Odebrano rolę ' . $row->role_name;
             } elseif ($new instanceof Row_ProfileRole) {
                 $row = $role->findOne($new->id_role);
                 return 'Przyznano rolę ' . $row->role_name;
             }
             break;
         case Logic_Log_Admin::PROFILEADD:
         case Logic_Log_Admin::PROFILEDELETE:
             $branch = new Branch();
             if ($old instanceof Row_Profile) {
                 $row = $branch->findOne($old->id_branch);
                 return 'Usunięto profil ' . $row->branch_name;
             } elseif ($new instanceof Row_Profile) {
                 $row = $branch->findOne($new->id_branch);
                 return 'Dodano profil ' . $row->branch_name;
             }
             break;
         case Logic_Log_Admin::USERLOCK:
             $newData = $new->toArray();
             $description = 'Dodano blokadę konta';
             $from = date('Y-m-d', strtotime($newData['timelock_start']));
             $to = date('Y-m-d', strtotime($newData['timelock_end']));
             if ($from != '1970-01-01') {
                 $description .= ' od ' . $from;
             }
             if ($to != '1970-01-01') {
                 $description .= ' do ' . $to;
             }
             if (!empty($newData['lock_reason'])) {
                 $description .= ', powód blokady: ' . $newData['lock_reason'];
             } else {
                 $description .= ', nie podano powodu blokady';
             }
             return $description;
             break;
         case Logic_Log_Admin::USERUNLOCK:
             return 'Odblokowano konto użytkownika';
             break;
         case Logic_Log_Admin::USERDELETE:
             $newData = $new->toArray();
             $time = '';
             if (!empty($newData['last_lock_at'])) {
                 $time = date('Y-m-d', strtotime($newData['last_lock_at']));
             } else {
                 $time = date('Y-m-d', strtotime($newData['timelock_start']));
             }
             $description = 'Trwale dezaktywowano konto użytkownika od ' . $time;
             if (!empty($newData['lock_reason'])) {
                 $description .= ', powód blokady: ' . $newData['lock_reason'];
             } else {
                 $description .= ', nie podano powodu blokady';
             }
             return $description;
             break;
         case Logic_Log_Admin::INTERESTCHANGE:
             $negotiationId = array_shift(array_keys($new));
             $oldData = $old[$negotiationId];
             $newData = $new[$negotiationId];
             $descriptionArray = array();
             foreach ($oldData as $step => $options) {
                 foreach ($options as $optionKey => $option) {
                     if ($option != $newData[$step][$optionKey]) {
                         $descriptionArray[] = 'krok ' . $step . ' - wariant ' . $optionKey . ': zmiana z ' . number_format($option, 3) . '% na ' . number_format($newData[$step][$optionKey], 3) . '%';
                     }
                 }
             }
             return implode(', ', $descriptionArray);
             break;
     }
 }
开发者ID:knatorski,项目名称:SMS,代码行数:98,代码来源:AdminPanel.php

示例2: getGroupsForRole

 /**
  * Pobranie grup uprawnień dla roli
  *
  * @param integer $id id roli
  * @return array
  */
 public function getGroupsForRole($id)
 {
     $roleModel = new Role();
     return $roleModel->findOne($id)->findDependentRowset('RoleGroup')->toArray();
 }
开发者ID:knatorski,项目名称:SMS,代码行数:11,代码来源:Privileges.php

示例3: editAction

 public function editAction()
 {
     $request = $this->getRequest();
     $id = $request->getParam('id');
     $id = $this->_helper->IdConvert->hexToStr($id);
     $logic = new Logic_Privileges();
     $form = $logic->getFormWithGroups();
     if ($this->getRequest()->isPost()) {
         if ($form->isCancelled($this->getRequest()->getPost())) {
             $this->_helper->redirector('index', null, null);
             return;
         } elseif ($form->isValid($this->getRequest()->getPost())) {
             try {
                 $logic->updateRole($form, $id);
                 $cache = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('cachemanager')->getCache('rolecache');
                 $cache->clean(Zend_Cache::CLEANING_MODE_ALL);
                 $this->_helper->messenger("success", 'New role was successfully edited.');
                 $this->_helper->redirector('index');
                 return;
             } catch (Logic_Uzytkownik_Exception $e) {
                 $this->_helper->messenger('error', MSG_ERROR, $e);
             }
         }
     } else {
         $roleModel = new Role();
         $data = $roleModel->findOne($id);
         $groups = $data->findDependentRowset('RoleGroup');
         $form->setDefaults($data->toArray(), $groups->toArray());
         $form->removeDecorator('FormErrorsGoTo');
     }
     $this->view->form = $form;
 }
开发者ID:knatorski,项目名称:SMS,代码行数:32,代码来源:RoleController.php

示例4: testHasManyRelation

 public function testHasManyRelation()
 {
     $this->assertCount(1, Role::findOne(['name'], ['Admin'])->users());
 }
开发者ID:gigorok,项目名称:php-orm,代码行数:4,代码来源:ModelTest.php

示例5: _updateProfile

 /**
  * Aktualizacja ról oraz grup dla profilu
  *
  * @param Base_Form_Abstract $form formularz z danymi do zapisania
  * @param integer $id id profilu
  * @return integer ilość poprawionych wierszy
  */
 public function _updateProfile($form, $id, $id_user)
 {
     $model = new User();
     $userRow = $model->findOne($id_user)->toArray();
     $profileRoleModel = new ProfileRole();
     $profileGroupModel = new ProfileGroup();
     $log = Zend_Registry::get('admin_log');
     $profileGroupModel->getAdapter()->beginTransaction();
     try {
         $select = $profileRoleModel->select()->where('id_profile = ' . $id . ' and ghost = false')->setIntegrityCheck(false);
         $dataArray = $profileRoleModel->fetchAll($select)->toArray();
         foreach ($dataArray as $key => $val) {
             $profileRoleRow = $profileRoleModel->findOne($val['id']);
             $roleModel = new Role();
             $roleData = $roleModel->findOne($val['id_role'])->toArray();
             $profileRoleRowData = $profileRoleRow->toArray();
             $log->roledelete(array('old' => $profileRoleRow));
             $profileRoleRow->delete();
         }
         $select = $profileGroupModel->select()->where('id_profile = ' . $id . ' and ghost = false')->setIntegrityCheck(false);
         $dataArray = $profileGroupModel->fetchAll($select)->toArray();
         foreach ($dataArray as $key => $val) {
             $profileGroupRow = $profileGroupModel->findOne($val['id']);
             $profileGroupRow->setFromArray(array('ghost' => 't'));
             $profileGroupRow->save();
         }
         // dodanie grupy logowania
         $groupModel = new Group();
         $logGroupRow = $groupModel->fetchRow(array('group_name = ?' => 'logowanie'));
         $profileGroupModel->insert(array('id_profile' => $id, 'id_group' => $logGroupRow->id));
         $values = $form->getValues();
         $roleModel = new Role();
         $roleNames = array();
         foreach ($values['role'] as $roleId) {
             $roleRow = $roleModel->findOne($roleId);
             $roleNames[] = $roleRow->role_name;
         }
         if (!empty($values['role'][0])) {
             $landingRole = $roleModel->findOne($values['role'][0]);
             $landing = $landingRole->landing;
         } else {
             $landing = '/login';
         }
         //            $landing = in_array('dsk', $roleNames) ? '/dsk' : '/admin';
         $profileModel = new Profile();
         $profileRow = $profileModel->findOne($id);
         $profileRow->landing = $landing;
         $profileRow->save();
         if (isset($values['role']) && !empty($values['role'])) {
             foreach ($values['role'] as $role_id) {
                 $profileRoleRow = $profileRoleModel->createRow(array('id_profile' => $id, 'id_role' => $role_id));
                 $log->roleadd(array('new' => $profileRoleRow));
                 $profileRoleRow->save();
                 $roleModel = new Role();
                 $roleData = $roleModel->findOne($role_id)->toArray();
                 $profileRoleRowData = $profileRoleRow->toArray();
                 $roleGroupModel = new RoleGroup();
                 $roleGroupsSelect = $roleGroupModel->select()->where('id_role = ?', $role_id);
                 $roleGroups = $roleGroupModel->fetchAll($roleGroupsSelect);
                 foreach ($roleGroups as $roleRow) {
                     $profileGroupRow = $profileGroupModel->createRow(array('id_profile' => $id, 'id_group' => $roleRow->id_group));
                     $profileGroupRow->save();
                 }
             }
         }
         $profileGroupModel->getAdapter()->commit();
         $cache = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('cachemanager')->getCache('rolecache');
         $cache->clean(Zend_Cache::CLEANING_MODE_ALL);
     } catch (Exception $e) {
         $profileGroupModel->getAdapter()->rollBack();
     }
 }
开发者ID:knatorski,项目名称:SMS,代码行数:79,代码来源:User.php


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