コード例 #1
0
 /**
  * method onEdit()
  * Executed whenever the user clicks at the edit button da datagrid
  */
 function onEdit($param)
 {
     try {
         if (isset($param['key'])) {
             // get the parameter $key
             $key = $param['key'];
             // open a transaction with database 'permission'
             TTransaction::open('permission');
             // instantiates object System_user
             $object = new SystemUser($key);
             unset($object->password);
             $groups = array();
             if ($groups_db = $object->getSystemUserGroups()) {
                 foreach ($groups_db as $grup) {
                     $groups[] = $grup->id;
                 }
             }
             $object->programs = $object->getSystemUserPrograms();
             $object->groups = $groups;
             // fill the form with the active record data
             $this->form->setData($object);
             // close the transaction
             TTransaction::close();
         } else {
             $this->form->clear();
         }
     } catch (Exception $e) {
         // shows the exception error message
         new TMessage('error', '<b>Error</b> ' . $e->getMessage());
         // undo all pending operations
         TTransaction::rollback();
     }
 }