app/control/communication/SystemDocumentForm.class.php
/**
     * Load object to form data
     * @param $param Request
     */
Load object to form data
@param $param Request
Load object to form data @param $param Request
public function onEdit( $param )
    {
        try
        {
            if (isset($param['key']))
            {
                $key = $param['key'];  
                TTransaction::open('communication'); 
                $object = new SystemDocument($key); 
                if ($object->system_user_id == TSession::getValue('userid') OR TSession::getValue('login') === 'admin')
                {
                    $object->user_ids = $object->getSystemUsersIds();
                    $object->group_ids = $object->getSystemGroupsIds();
                    $this->form->setData($object); 
                }
                else
                {
                    throw new Exception(_t('Permission denied'));
                }
                TTransaction::close(); 
                if (empty($param['hasfile']))
                {
                    TSession::setValue('system_document_upload_file', $object->filename);
                }
            }
            else
            {
                $this->form->clear();
            }
        }
        catch (Exception $e) 
        {
            new TMessage('error', $e->getMessage()); 
            TTransaction::rollback(); 
        }
    }
public function onEdit ( $ param ) { try { if ( isset ( $ param [ 'key' ] ) ) { $ key = $ param [ 'key' ] ; TTransaction :: open ( 'communication' ) ; $ object = new SystemDocument ( $ key ) ; if ( $ object -> system_user_id == TSession :: getValue ( 'userid' ) OR TSession :: getValue ( 'login' ) === 'admin' ) { $ object -> user_ids = $ object -> getSystemUsersIds ( ) ; $ object -> group_ids = $ object -> getSystemGroupsIds ( ) ; $ this -> form -> setData ( $ object ) ; } else { throw new Exception ( _t ( 'Permission denied' ) ) ; } TTransaction :: close ( ) ; if ( empty ( $ param [ 'hasfile' ] ) ) { TSession :: setValue ( 'system_document_upload_file' , $ object -> filename ) ; } } else { $ this -> form -> clear ( ) ; } } catch ( Exception $ e ) { new TMessage ( 'error' , $ e -> getMessage ( ) ) ; TTransaction :: rollback ( ) ; } }
Load object to form data
 @param $param Request
Load object to form data @param $param Request
// get the parameter $key // open a transaction // instantiates the Active Record // fill the form // close the transaction // in case of exception // shows the exception error message // undo all pending operations