/** * 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)); }