public function getModule() { $dataObject = Request::post('d_object', 'string', false); if (!$dataObject || !Db_Object_Config::configExists($dataObject)) { Response::jsonError($this->_lang->WRONG_REQUEST); } return ucfirst($dataObject); }
/** * Check Db_Object structure * @throws Exception */ public function checkOrmStructure() { if (!Db_Object_Config::configExists($this->_object)) { throw new Exception('Filestorage_Orm undefined Orm object'); } $cfg = Db_Object_Config::getInstance($this->_object); $fields = $cfg->getFieldsConfig(true); foreach ($this->_objectFields as $name) { if (!isset($fields[$name])) { throw new Exception('Filestorage_Orm invalid orm structure, field ' . $name . ' not found'); } } }
/** * Import fields into the form object */ public function importfieldsAction() { $importObject = Request::post('importobject', 'string', false); $importFields = Request::post('importfields', 'array', array()); if (!$importObject || empty($importFields) || !Db_Object_Config::configExists($importObject)) { Response::jsonError($this->_lang->WRONG_REQUEST); } $importObjectConfig = Db_Object_Config::getInstance($importObject); foreach ($importFields as $name) { if ($importObjectConfig->fieldExists($name)) { $this->_importOrmField($name, $importObjectConfig); } } $this->_object->objectName = $importObject; $this->_storeProject(); Response::jsonSuccess(); }
/** * List permissions action */ public function permissionsAction() { $user = Request::post('user_id', 'int', 0); $group = Request::post('group_id', 'int', 0); if ($user && $group) { Response::jsonError($this->_lang->WRONG_REQUEST); } if ($group) { $data = Model::factory('acl_simple')->getGroupPermissions($group); } if (!empty($data)) { $data = Utils::rekey('object', $data); } $manager = new Db_Object_Manager(); $objects = $manager->getRegisteredObjects(); foreach ($objects as $name) { if (!isset($data[$name])) { $data[$name] = array('object' => $name, 'create' => false, 'view' => false, 'edit' => false, 'delete' => false, 'user_id' => null, 'publish' => false, 'group_id' => $group); } } foreach ($data as $k => &$v) { if (!Db_Object_Config::configExists($k)) { unset($data[$k]); continue; } $cfg = Db_Object_Config::getInstance($k); if ($cfg->isRevControl()) { $v['rc'] = true; } else { $v['rc'] = false; } $v['title'] = $cfg->getTitle(); } unset($v); Response::jsonSuccess(array_values($data)); }
public function uploadAction() { $object = Request::post('object', 'string', false); if (!$object || !Db_Object_Config::configExists($object)) { Response::jsonError($this->_lang->get('FILL_FORM')); } $cfg = Db_Object_Config::getInstance($object); $fields = $cfg->getFieldsConfig(false); $expectedCols = array(); $expectedCols[] = array('id' => $cfg->getPrimaryKey(), 'text' => $this->_lang->get('PRIMARY_KEY'), 'columnIndex' => -1, 'required' => 1); foreach ($fields as $name => $fConfig) { $expectedCols[] = array('id' => $name, 'text' => $fConfig['title'], 'columnIndex' => -1, 'required' => $cfg->isRequired($name)); } $result = array('success' => true, 'expectedColumns' => $expectedCols, 'data' => array(), 'uploadId' => 1); if (!$cfg->isSystem()) { $result['importTypes'][] = array('name' => 'type', 'inputValue' => 'rewrite', 'boxLabel' => $this->_iLang->get('REWRITE')); } //echo json_encode(array('success'=>false,'msg'=>'Cannot upload file')); exit; for ($i = 0; $i < 30; $i++) { $result['data'][] = array('col0' => 'Data' . rand(0, 6), 'col1' => rand(1000, 9999), 'col2' => rand(1, 700), 'col3' => rand(1, 700), 'col4' => rand(1, 700), 'col5' => rand(1, 700), 'col6' => rand(1, 700)); } $result['col_count'] = sizeof($result['data'][0]); Response::jsonArray($result); }
/** * Check if the listed objects exist * @param string $name * @param mixed integer/array $ids * @return boolean */ public static function objectExists($name, $ids) { if (!Db_Object_Config::configExists($name)) { return false; } try { $cfg = Db_Object_Config::getInstance($name); } catch (Exception $e) { return false; } if (!is_array($ids)) { $ids = array($ids); } $model = Model::factory($name); $data = $model->getItems($ids); if (empty($data)) { return false; } $data = Utils::fetchCol($cfg->getPrimaryKey(), $data); foreach ($ids as $v) { if (!in_array(intval($v), $data, true)) { return false; } } return true; }
/** * Check for broken object links * return array | boolean false */ public function hasBrokenLinks() { $links = $this->_objectConfig->getLinks(); $brokenFields = array(); if (!empty($links)) { $brokenFields = array(); foreach ($links as $o => $fieldList) { if (!Db_Object_Config::configExists($o)) { foreach ($fieldList as $field => $cfg) { $brokenFields[$field] = $o; } } } } if (empty($brokenFields)) { return false; } else { return $brokenFields; } }
/** * Get object title */ public function otitleAction() { $object = Request::post('object', 'string', false); $id = Request::post('id', 'string', false); if (!$object || !Db_Object_Config::configExists($object)) { Response::jsonError($this->_lang->WRONG_REQUEST); } if (!in_array(strtolower($object), $this->_canViewObjects, true)) { Response::jsonError($this->_lang->CANT_VIEW); } $objectConfig = Db_Object_Config::getInstance($object); // Check ACL permissions $acl = $objectConfig->getAcl(); if ($acl) { if (!$acl->can(Db_Object_Acl::ACCESS_VIEW, $object)) { Response::jsonError($this->_lang->get('ACL_ACCESS_DENIED')); } } try { $o = Db_Object::factory($object, $id); Response::jsonSuccess(array('title' => $o->getTitle())); } catch (Exception $e) { Model::factory($object)->logError('Cannot get title for ' . $object . ':' . $id); Response::jsonError($this->_lang->get('CANT_EXEC')); } }
public function decryptDataAction() { $this->_checkCanEdit(); $object = Request::post('object', 'string', false); if (!$object || !Db_Object_Config::configExists($object)) { Response::jsonError($this->_lang->get('WRONG_REQUEST')); } $container = $this->decryptContainerPrefix . $object; $objectModel = Model::factory($object); $taskModel = Model::factory('bgtask'); $signalModel = Model::factory('Bgtask_Signal'); //disable profiling in dev mode if ($this->_configMain->get('development')) { $taskModel->getDbConnection()->getProfiler()->setEnabled(false); $signalModel->getDbConnection()->getProfiler()->setEnabled(false); $objectModel->getDbConnection()->getProfiler()->setEnabled(false); } $logger = new Bgtask_Log_File($this->_configMain['task_log_path'] . $container . '_' . date('d_m_Y__H_i_s')); $bgStorage = new Bgtask_Storage_Orm($taskModel, $signalModel); $tm = Bgtask_Manager::getInstance(); $tm->setStorage($bgStorage); $tm->setLogger($logger); // Start encryption task $tm->launch(Bgtask_Manager::LAUNCHER_SIMPLE, 'Task_Orm_Decrypt', array('object' => $object, 'session_container' => $container)); }
public function otitleAction() { $object = Request::post('object', 'string', false); $id = Request::post('id', 'string', false); if (!$object || !Db_Object_Config::configExists($object)) { Response::jsonError($this->_lang->WRONG_REQUEST); } try { $o = Db_Object::factory($object, $id); Response::jsonSuccess(array('title' => $o->getTitle())); } catch (Exception $e) { Model::factory($object)->logError('Cannot get title for ' . $object . ':' . $id); Response::jsonError($this->_lang->get('CANT_EXEC')); } }