UsersController Class Reference

List of all members.

Public Member Functions

 init ()
 indexAction ()
 editAction ()


Member Function Documentation

UsersController::editAction (  ) 

00021         {
00022                 $users = new Default_Model_Users;
00023                 $resources = new Default_Model_AclResources;
00024                 
00025                 $userId = $this->getRequest()->getParam('id');
00026 
00027                 $userData = $users->fetchRow($users->getAdapter()->quoteInto('UserID = ? ', $userId));
00028                 #$this->view->resources = $resources->myFetchAll($userData->Username);
00029                 $resourcesData = $resources->myFetchAll($userData->Username);
00030 
00031                 $this->view->form = $this->getForm($userData, $resourcesData);
00032                 
00033                 if ($this->getRequest()->isPost()) {
00034                         if ($this->view->form->isValid($_POST)){
00035                                 $users->getAdapter()->beginTransaction();
00036                                 try {
00037                                         $access = new Default_Model_AclAccess;
00038                                         $users->update(array(
00039                                                 'Username' => $this->getRequest()->getParam('username'),
00040                                                 'Email'    => $this->getRequest()->getParam('email'), 
00041                                                 'Password' => new Zend_Db_Expr ($this->getRequest()->getParam('password') ? 
00042                                                                                                         $users->getAdapter()->quoteInto('SHA1(?)', 
00043                                                                                                         $this->getRequest()->getParam('password')) :
00044                                                                                                 'Password'),
00045                                         ), $users->getAdapter()->quoteInto('UserID = ? ', $userId));
00046                                         $access->delete($access->getAdapter()->quoteInto('role_id = ?', $this->getRequest()->getParam('username')));
00047                                         foreach ($this->getRequest()->getParam('resources') as $res){
00048                                                 $access->insert(array ('role_id'      => $this->getRequest()->getParam('username'),
00049                                                                         'resource_id' => $res,
00050                                                                         'allow'       => '1',
00051                                                                         ));
00052                                         }
00053                                         $users->getAdapter()->commit();
00054                                 } catch (Exception $e) { 
00055                                         $users->getAdapter()->rollBack();
00056                                         $this->_redirect('users?error=1'); 
00057                                 }
00058                                 $this->_redirect('users?success=1');
00059                         }
00060                 }
00061         }

UsersController::indexAction (  ) 

00013         {
00014                 $users = new Default_Model_Users;
00015 
00016                 $this->view->success = $this->getRequest()->getParam('success');
00017                 $this->view->users = $users->fetchAll();
00018         }

UsersController::init (  ) 

00008         {
00009             /* Initialize action controller here */
00010         }


The documentation for this class was generated from the following file:

Generated on Mon Oct 19 16:22:50 2009 for IndyArticles by  doxygen 1.5.8