/** * @see Zend_Validate_Interface::isValid() * * @param mixed $value * @return boolean */ public function isValid($value) { // permitted roles $roles = UserRow::getRoles(); if (in_array($value, $roles)) { return true; } $this->_error('invalid', $value); return false; }
/** * Update the user information * @param $data array * @param $user - the user to update */ public function updateUser(array $data) { $roles = UserRow::getRoles(); $data['role'] = $roles[$data['role']]; try { $row = $this->fetchRow(array('email = ?' => $data['email'])); if (!$row) { throw new Zend_Exception('Fails to update - no such registered user ' . $data['email']); } $row->role = $data['role']; $row->save(); } catch (Exception $e) { throw new Zend_Exception('Fails to update' . $e->getMessage()); } }
/** * The default action - show the registration form */ public function adminAction() { $this->authenticate(); // check if admin $identity = Zend_Auth::getInstance()->getIdentity(); if ($identity['role'] != 'admin') { $this->_helper->getHelper('Redirector')->goto('view', 'portal'); } if ($this->getRequest()->isPost()) { // submitting form $data = $this->_request->getParams(); // update the user try { $this->users->updateUser($data); } catch (Exception $e) { $this->view->message = $e->getMessage(); } } // show form $this->view->roles = UserRow::getRoles(); }
function registerCore($ncUid = 0, $name = '', $email = '') { // registers a user on the core cloud system //$info=$this->serialize(0,$ncUid,$name,$email); //$userid=$this->update($info); $user = new UserRow($this->db); $user->ncUid = $ncUid; $user->name = $name; $user->email = $email; $userid = $user->insert(); return $userid; }
public function testGetsUsersWithPermission() { $resourceId = 123; $userRows = new UserRow(); $userRows->With(1)->With(2); $this->db->SetRows($userRows->Rows()); $list = $this->repository->GetUsersWithPermission($resourceId); $this->assertTrue($this->db->ContainsCommand(new GetResourceUserPermissionCommand($resourceId, AccountStatus::ACTIVE))); $this->assertEquals(2, $list->PageInfo()->Total); }