Exemplo n.º 1
0
 /**
  * Get object history
  */
 public function listAction()
 {
     $object = Request::post('object', 'string', false);
     if (!$object) {
         Response::jsonSuccess(array());
     }
     $pager = Request::post('pager', 'array', array());
     $filter = Request::post('filter', 'array', array());
     if (!isset($filter['record_id']) || empty($filter['record_id'])) {
         Response::jsonSuccess(array());
     }
     try {
         $o = new Db_Object($object);
     } catch (Exception $e) {
         Response::jsonSuccess(array());
     }
     $filter['table_name'] = $o->getTable();
     $history = Model::factory('Historylog');
     $data = $history->getListVc($pager, $filter, false, array('date', 'type', 'id'), 'user_name');
     if (!empty($data)) {
         foreach ($data as $k => &$v) {
             if (isset(Model_Historylog::$actions[$v['type']])) {
                 $v['type'] = Model_Historylog::$actions[$v['type']];
             }
         }
         unset($v);
     }
     Response::jsonSuccess($data, array('count' => $history->getCount($filter)));
 }
Exemplo n.º 2
0
 /**
  * Validate object action
  */
 public function validateAction()
 {
     $engineUpdate = false;
     $name = Request::post('name', 'string', false);
     if (!$name) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     $objectConfig = Db_Object_Config::getInstance($name);
     // Check ACL permissions
     $acl = $objectConfig->getAcl();
     if ($acl) {
         if (!$acl->can(Db_Object_Acl::ACCESS_CREATE, $name) || !$acl->can(Db_Object_Acl::ACCESS_VIEW, $name)) {
             Response::jsonError($this->_lang->get('ACL_ACCESS_DENIED'));
         }
     }
     try {
         $obj = new Db_Object($name);
     } catch (Exception $e) {
         Response::jsonError($this->_lang->get('CANT_GET_VALIDATE_INFO'));
     }
     $builder = new Db_Object_Builder($name);
     $tableExists = $builder->tableExists();
     $colUpd = array();
     $indUpd = array();
     $keyUpd = array();
     if ($tableExists) {
         $colUpd = $builder->prepareColumnUpdates();
         $indUpd = $builder->prepareIndexUpdates();
         $keyUpd = $builder->prepareKeysUpdate();
         $engineUpdate = $builder->prepareEngineUpdate();
     }
     if (empty($colUpd) && empty($indUpd) && empty($keyUpd) && $tableExists && !$engineUpdate) {
         Response::jsonSuccess(array(), array('nothingToDo' => true));
     }
     $template = new Template();
     $template->disableCache();
     $template->engineUpdate = $engineUpdate;
     $template->columns = $colUpd;
     $template->indexes = $indUpd;
     $template->keys = $keyUpd;
     $template->tableExists = $tableExists;
     $template->tableName = $obj->getTable();
     $template->lang = $this->_lang;
     $msg = $template->render(Application::getTemplatesPath() . 'orm_validate_msg.php');
     Response::jsonSuccess(array(), array('text' => $msg, 'nothingToDo' => false));
 }