Example #1
0
 public function objectsAction()
 {
     $manager = new Db_Object_Manager();
     $objects = $manager->getRegisteredObjects();
     $data = array();
     if (!empty($objects)) {
         foreach ($objects as $name) {
             $data[] = array('name' => $name, 'title' => Db_Object_Config::getInstance($name)->getTitle());
         }
     }
     Response::jsonSuccess($data);
 }
Example #2
0
 protected static function _buildAssociations()
 {
     if (!is_null(self::$_objectAssociations)) {
         return;
     }
     $manager = new Db_Object_Manager();
     $objects = $manager->getRegisteredObjects();
     foreach ($objects as $name) {
         $config = Db_Object_Config::getInstance($name);
         $links = $config->getLinks();
         self::$_objectAssociations[$name] = $links;
     }
 }
Example #3
0
 /**
  * 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));
 }
Example #4
0
 public function externaltablesAction()
 {
     $connectionId = Request::post('connId', 'string', false);
     $connectionType = Request::post('type', 'integer', false);
     if ($connectionId === false || $connectionType === false) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     $cfg = $this->_manager->getConnection($connectionType, $connectionId);
     if (!$cfg) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     $cfg = $cfg->__toArray();
     try {
         $db = Zend_Db::factory($cfg['adapter'], $cfg);
         $db->query('SET NAMES ' . $cfg['charset']);
         $tables = $db->listTables();
     } catch (Exception $e) {
         Response::jsonError($this->_lang->CANT_CONNECT . ' ' . $e->getMessage());
     }
     $data = array();
     $manager = new Db_Object_Manager();
     $objects = $manager->getRegisteredObjects();
     $tablesObjects = array();
     foreach ($objects as $object) {
         $model = Model::factory($object);
         $tablesObjects[$model->table()][] = $object;
     }
     if (!empty($tables)) {
         foreach ($tables as $table) {
             $same = false;
             if (isset($tablesObjects[$table]) && !empty($tablesObjects[$table])) {
                 foreach ($tablesObjects[$table] as $oName) {
                     $mCfg = Model::factory($oName)->getDbConnection()->getConfig();
                     if ($mCfg['host'] === $cfg['host'] && $mCfg['dbname'] === $cfg['dbname']) {
                         $same = true;
                         break;
                     }
                 }
             }
             if (!$same) {
                 $data[] = array('name' => $table);
             }
         }
     }
     Response::jsonSuccess($data);
 }
Example #5
0
 /**
  * Get list of registered Db_Object's
  */
 public function objectsAction()
 {
     $manager = new Db_Object_Manager();
     $list = $manager->getRegisteredObjects();
     $data = array();
     $systemObjects = $this->_configBackend['system_objects'];
     foreach ($list as $key) {
         if (!in_array(ucfirst($key), $systemObjects) && !class_exists('Backend_' . Utils_String::formatClassName($key) . '_Controller')) {
             $data[] = array('id' => $key, 'title' => Db_Object_Config::getInstance($key)->getTitle());
         }
     }
     Response::jsonSuccess($data);
 }
Example #6
0
 /**
  * Check and fix config files
  */
 public function fixconfigsAction()
 {
     $manager = new Db_Object_Manager();
     $names = $manager->getRegisteredObjects();
     foreach ($names as $objectName) {
         $cfg = Db_Object_Config::getInstance($objectName);
         $cfg->save();
     }
     Response::jsonSuccess();
 }