Example #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)));
 }
Example #2
0
 /**
  * Get list of available controllers
  */
 public function controllersAction()
 {
     $appPath = $this->_configMain['application_path'];
     $folders = File::scanFiles($this->_configMain->get('frontend_controllers'), false, true, File::Dirs_Only);
     $data = array();
     if (!empty($folders)) {
         foreach ($folders as $item) {
             $name = basename($item);
             if (file_exists($item . '/Controller.php')) {
                 $name = str_replace($appPath, '', $item . '/Controller.php');
                 $name = Utils::classFromPath($name);
                 $data[] = array('id' => $name, 'title' => $name);
             }
         }
     }
     if ($this->_configMain->get('allow_externals')) {
         $config = Config::factory(Config::File_Array, $this->_configMain->get('configs') . 'externals.php');
         $eExpert = new Externals_Expert($this->_configMain, $config);
         $classes = $eExpert->getClasses();
         $extControllers = $eExpert->getFrontendControllers();
         if (!empty($extControllers)) {
             $data = array_merge($data, array_values($extControllers));
         }
     }
     Response::jsonSuccess($data);
 }
Example #3
0
 /**
  * Import DB fields into the form object
  */
 public function importdbfieldsAction()
 {
     $connection = Request::post('connection', 'string', false);
     $table = Request::post('table', 'string', false);
     $conType = Request::post('type', 'integer', false);
     $importFields = Request::post('importfields', 'array', array());
     if ($connection === false || !$table || empty($importFields) || $conType === false) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     $conManager = new Backend_Orm_Connections_Manager($this->_configMain->get('db_configs'));
     $cfg = $conManager->getConnection($conType, $connection);
     if (!$cfg) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     $cfg = $cfg->__toArray();
     $tableFields = Backend_Designer_Import::getTableFields($cfg, $table);
     if ($tableFields === false) {
         Response::jsonError($this->_lang->CANT_CONNECT);
     }
     foreach ($importFields as $name) {
         if (isset($tableFields[$name]) && !empty($tableFields[$name])) {
             $this->_importDbField($name, $tableFields[$name]);
         }
     }
     $this->_storeProject();
     Response::jsonSuccess();
 }
Example #4
0
 /**
  * Get list of accepted menu
  */
 public function menulistAction()
 {
     $menuModel = Model::factory('menu');
     $list = $menuModel->getList(false, false, array('id', 'title'));
     if (!empty($list)) {
         $list = array_values($list);
     }
     Response::jsonSuccess($list);
 }
Example #5
0
 public function resetAction()
 {
     $this->_checkCanDelete();
     if (Backend_Cache_Manager::resetAll()) {
         Response::jsonSuccess();
     } else {
         Response::jsonError($this->_lang->CANT_RESET_CACHE);
     }
 }
Example #6
0
 /**
  * Get JS code for project
  */
 public function projectcodeAction()
 {
     $project = $this->_getProject();
     $projectCfg = $project->getConfig();
     $templates = $this->_config->get('templates');
     $replaces = array(array('tpl' => $templates['wwwroot'], 'value' => $this->_configMain->get('wwwroot')), array('tpl' => $templates['adminpath'], 'value' => $this->_configMain->get('adminPath')), array('tpl' => $templates['urldelimiter'], 'value' => $this->_configMain->get('urlDelimiter')));
     Ext_Code::setRunNamespace($projectCfg['runnamespace']);
     Ext_Code::setNamespace($projectCfg['namespace']);
     Response::jsonSuccess($project->getCode($replaces));
 }
Example #7
0
 public function syncFsAction($toFile = false)
 {
     if ($toFile !== false) {
         if ($this->_appConfig['deploy_use_console']) {
             return $this->_fsmap($toFile);
         } else {
             return $this->_fsmapByPhp($toFile);
         }
     } else {
         Response::jsonSuccess($this->_fsmap());
     }
 }
Example #8
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 #9
0
 public function getlogfilesAction()
 {
     //$version = $this->_configMain['development_version'];
     $logPath = $this->_configMain['orm_log_path'];
     //$fileName = $logPath . 'default_'.$version . '_build_log.sql';
     $files = File::scanFiles($logPath, array('.sql'), false);
     $data = array();
     foreach ($files as $file) {
         $file = basename($file, '.sql');
         $data[] = array('id' => $file);
     }
     Response::jsonSuccess($data);
 }
Example #10
0
 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());
     $filter['object_name'] = $object;
     $model = Model::factory('Vc');
     $data = $model->getListVc($pager, $filter, false, array('version', 'date', 'id', 'record_id'), 'user_name');
     $result = array('success' => true, 'count' => $model->getCount($filter), 'data' => $data);
     Response::jsonArray($result);
 }
Example #11
0
 /**
  * Save permissions action
  */
 public function savepermissionsAction()
 {
     $this->_checkCanEdit();
     $data = Request::post('data', 'raw', false);
     $groupId = Request::post('group_id', 'int', false);
     $data = json_decode($data, true);
     if (empty($data) || !$groupId) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     if (Model::factory('acl_simple')->updateGroupPermissions($groupId, $data)) {
         Response::jsonSuccess();
     } else {
         Response::jsonError($this->_lang->CANT_EXEC);
     }
 }
Example #12
0
 /**
  * Set object property
  */
 public function setpropertyAction()
 {
     $id = Request::post('id', 'string', false);
     $property = Request::post('name', 'string', false);
     $value = Request::post('value', 'raw', false);
     if (!$id || !$this->_object->getFiltersFeature()->filterExists($id)) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     $object = $this->_object->getFiltersFeature()->getFilter($id);
     if (!$object->isValidProperty($property)) {
         Response::jsonError();
     }
     $object->{$property} = $value;
     $this->_storeProject();
     Response::jsonSuccess();
 }
Example #13
0
 /**
  * Save ActionJs code
  */
 public function saveAction()
 {
     $code = Request::post('code', 'raw', false);
     if ($code === false) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     $project = $this->_getProject();
     $actionjs = str_replace('../', '', $project->actionjs);
     if ($actionjs[0] !== '.') {
         $actionjs = '.' . $actionjs;
     }
     if (!@file_put_contents($actionjs, $code)) {
         Response::jsonError($this->_lang->CANT_WRITE_FS . ' ' . $actionjs);
     }
     Response::jsonSuccess();
 }
Example #14
0
 /**
  * Get object properties
  */
 public function listAction()
 {
     $id = Request::post('id', 'string', false);
     if (!method_exists($this->_object, 'fieldExists')) {
         Response::jsonError(get_class($this->_object) . '[' . $this->_object->getName() . '] deprecated type');
     }
     if (!$id || !$this->_object->fieldExists($id)) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     $field = $this->_object->getField($id);
     $config = $field->getConfig();
     $properties = $config->__toArray();
     if (isset($properties['isExtended'])) {
         unset($properties['isExtended']);
     }
     Response::jsonSuccess($properties);
 }
Example #15
0
 /**
  * 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();
 }
Example #16
0
 /**
  * Change window size
  */
 public function changesizeAction()
 {
     $object = Request::post('object', 'string', false);
     $width = Request::post('width', 'integer', false);
     $height = Request::post('height', 'integer', false);
     if ($object === false || $width === false || $height === false) {
         Response::jsonError($this->_lang->WRONG_REQUEST . 'code 1');
     }
     $project = $this->_getProject();
     if (!$project->objectExists($object)) {
         Response::jsonError($this->_lang->WRONG_REQUEST . 'code 2');
     }
     $object = $project->getObject($object);
     $object->width = $width;
     $object->height = $height;
     $this->_storeProject();
     Response::jsonSuccess();
 }
Example #17
0
 public function listAction()
 {
     $logsModel = Model::factory('Historylog');
     $pager = Request::post('pager', 'array', array());
     $filter = Request::post('filter', 'array', array());
     if (isset($filter['type']) && $filter['type'] == 0) {
         unset($filter['type']);
     }
     $count = $logsModel->getCount($filter);
     $joins = array(array('joinType' => 'joinLeft', 'table' => array('u' => Model::factory('User')->table()), 'fields' => array('user' => 'name'), 'condition' => 'u.id = user_id'));
     $list = $logsModel->getListVc($pager, $filter, false, '*', false, false, $joins);
     if (!empty($list)) {
         foreach ($list as &$value) {
             if (isset(Model_Historylog::$actions[$value['type']])) {
                 $value['type'] = Model_Historylog::$actions[$value['type']];
             }
         }
     }
     Response::jsonSuccess($list, array('count' => $count));
 }
Example #18
0
 public function updateAction()
 {
     $this->_checkCanEdit();
     $data = Request::post('data', 'raw', false);
     if ($data === false) {
         Response::jsonError($this->_lang->INVALID_VALUE);
     }
     $data = json_decode($data, true);
     if (!isset($data[0])) {
         $data = array($data);
     }
     $modulesCfg = Config::factory(Config::File_Array, $this->_configMain->get('configs') . 'externals.php');
     $modulesCfg->removeAll();
     foreach ($data as $v) {
         $modulesCfg->set($v['id'], array('active' => $v['active']));
     }
     if ($modulesCfg->save()) {
         Response::jsonSuccess();
     } else {
         Response::jsonError($this->_lang->CANT_WRITE_FS);
     }
 }
Example #19
0
 /**
  * Change field type
  */
 public function changetypeAction()
 {
     $this->_checkLoaded();
     $object = $this->_getObject();
     $type = Request::post('type', 'string', false);
     $adapter = Request::post('adapter', 'string', false);
     $dictionary = Request::post('dictionary', 'string', false);
     if ($type === 'Form_Field_Adapter') {
         $newObject = Ext_Factory::object($adapter);
         /*
          * Invalid adapter
          */
         if (!$adapter || !strlen($adapter) || !class_exists($adapter)) {
             Response::jsonError($this->_lang->INVALID_VALUE, array('adapter' => $this->_lang->INVALID_VALUE));
         }
         if ($adapter === 'Ext_Component_Field_System_Dictionary') {
             /*
              * Inavalid dictionary
              */
             if (!$dictionary || !strlen($dictionary)) {
                 Response::jsonError($this->_lang->INVALID_VALUE, array('dictionary' => $this->_lang->INVALID_VALUE));
             }
             $newObject->dictionary = $dictionary;
         }
     } else {
         $newObject = Ext_Factory::object($type);
         /*
          * No changes
          */
         if ($type === $object->getClass()) {
             Response::jsonSuccess();
         }
     }
     Ext_Factory::copyProperties($object, $newObject);
     $newObject->setName($object->getName());
     parent::_getObject()->setViewObject($newObject);
     $this->_storeProject();
     Response::jsonSuccess();
 }
Example #20
0
 /**
  * Get list of ORM object fields
  */
 public function fieldsAction()
 {
     $objectName = Request::post('object', 'string', false);
     if (!$objectName) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     try {
         $config = Db_Object_Config::getInstance($objectName);
     } catch (Exception $e) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     $fields = $config->getFieldsConfig();
     if (empty($fields)) {
         Response::jsonSuccess(array());
     }
     $data = array();
     foreach ($fields as $name => $cfg) {
         $type = $cfg['db_type'];
         if ($config->isLink($name)) {
             if ($config->isDictionaryLink($name)) {
                 $type = $this->_lang->DICTIONARY_LINK . '"' . $config->getLinkedDictionary($name) . '"';
             } else {
                 $obj = $config->getLinkedObject($name);
                 $oName = $obj . '';
                 try {
                     $oCfg = Db_Object_Config::getInstance($obj);
                     $oName .= ' (' . $oCfg->get('title') . ')';
                 } catch (Exception $e) {
                     //empty on error
                 }
                 $type = $this->_lang->OBJECT_LINK . ' - ' . $oName;
             }
         }
         $data[] = array('name' => $name, 'title' => $cfg['title'], 'type' => $type);
     }
     Response::jsonSuccess($data);
 }
Example #21
0
 /**
  * Create sub dictionary
  */
 public function createsubAction()
 {
     $name = Request::post('name', Filter::FILTER_ALPHANUM, false);
     if (empty($name)) {
         Response::jsonError($this->_lang->get('INVALID_VALUE_FOR_FIELD') . ' ' . $this->_lang->get('DICTIONARY_NAME'));
     }
     if ($this->_manager->dictionaryExists($name)) {
         Response::jsonError($this->_lang->get('DICTIONARY_EXISTS'));
     }
     try {
         $this->_manager->createDictionary($name);
     } catch (Exception $e) {
         Response::jsonError($e->getMessage());
     }
     Response::jsonSuccess();
 }
Example #22
0
 /**
  * Add store field
  */
 public function addfieldAction()
 {
     $this->_checkLoaded();
     $this->_checkObject();
     $id = Request::post('id', 'string', false);
     if (!$id || $this->_object->fieldExists($id)) {
         Response::jsonError($this->_lang->FIELD_EXISTS);
     }
     if ($this->_object->addField(array('name' => $id, 'type' => 'string'))) {
         $o = $this->_object->getField($id);
         $this->_storeProject();
         Response::jsonSuccess(array('name' => $o->name, 'type' => $o->type));
     } else {
         Response::jsonError($this->_lang->CANT_EXEC);
     }
 }
Example #23
0
 public function connectobjectAction()
 {
     $connectionId = Request::post('connId', 'string', false);
     $connectionType = Request::post('type', 'integer', false);
     $table = Request::post('table', 'string', false);
     if ($connectionId === false || $connectionType === false || $table === 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());
     }
     $import = new Db_Object_Import();
     if (!$import->isValidPrimaryKey($db, $table)) {
         $errors = $import->getErrors();
         if (!empty($errors)) {
             $errors = '<br>' . implode('<br>', $errors);
         } else {
             $errors = '';
         }
         Response::jsonError($this->_lang->DB_CANT_CONNECT_TABLE . ' ' . $this->_lang->DB_MSG_UNIQUE_PRIMARY . ' ' . $errors);
     }
     $manager = new Db_Object_Manager();
     $newObjectName = strtolower(str_replace('_', '', $table));
     if ($manager->objectExists($newObjectName)) {
         $newObjectName = strtolower(str_replace('_', '', $cfg['dbname'])) . $newObjectName;
         if ($manager->objectExists($newObjectName)) {
             $k = 0;
             $alphabet = Utils_String::alphabetEn();
             while ($manager->objectExists($newObjectName)) {
                 if (!isset($alphabet[$k])) {
                     Response::jsonError('Can not create unique object name' . $errors);
                 }
                 $newObjectName .= $alphabet[$k];
                 $k++;
             }
         }
     }
     $config = $import->createConfigByTable($db, $table, $cfg['prefix']);
     $config['connection'] = $connectionId;
     if (!$config) {
         $errors = $import->getErrors();
         if (!empty($errors)) {
             $errors = '<br>' . implode('<br>', $errors);
         } else {
             $errors = '';
         }
         Response::jsonError($this->_lang->DB_CANT_CONNECT_TABLE . ' ' . $errors);
     } else {
         $path = $this->_configMain->get('object_configs') . $newObjectName . '.php';
         if (!Config_File_Array::create($path)) {
             Response::jsonError($this->_lang->CANT_WRITE_FS . ' ' . $path);
         }
         $cfg = Config::factory(Config::File_Array, $path);
         $cfg->setData($config);
         if (!$cfg->save()) {
             Response::jsonError($this->_lang->CANT_WRITE_FS . ' ' . $path);
         }
     }
     Response::jsonSuccess();
 }
Example #24
0
 /**
  * Delete module
  */
 public function deletemoduleAction()
 {
     $this->_checkCanEdit();
     $module = Request::post('id', 'string', false);
     $removeRelated = Request::post('delete_related', 'boolean', false);
     $manager = new Backend_Modules_Manager();
     $moduleName = $manager->getModuleName($module);
     if (!$module || !strlen($module) || !$manager->isValidModule($moduleName)) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     $filesToDelete = array();
     if ($removeRelated) {
         $item = $manager->getModuleConfig($moduleName);
         $classFile = './system/app/' . str_replace('_', '/', $item['class']) . '.php';
         if (file_exists($classFile)) {
             $filesToDelete[] = $classFile;
         }
         if (!empty($item['designer'])) {
             if (file_exists($item['designer'])) {
                 $filesToDelete[] = $item['designer'];
             }
             $crudJs = './js/app/system/crud/' . strtolower($manager->getModuleName($item['class'])) . '.js';
             if (file_exists($crudJs)) {
                 $filesToDelete[] = $crudJs;
             }
             $actionJs = './js/app/actions/' . strtolower($manager->getModuleName($item['class'])) . '.js';
             if (file_exists($actionJs)) {
                 $filesToDelete[] = $actionJs;
             }
         }
     }
     // check before deleting
     if (!empty($filesToDelete)) {
         $err = array();
         foreach ($filesToDelete as $file) {
             if (!is_writable($file)) {
                 $err[] = $file;
             }
         }
         if (!empty($err)) {
             Response::jsonError($this->_lang->CANT_WRITE_FS . "\n<br>" . implode(",\n<br>", $err));
         }
     }
     $manager->removeModule($moduleName);
     if (!$manager->save()) {
         Response::jsonError($this->_lang->CANT_WRITE_FS . ' ' . $manager->getConfig()->getName());
     }
     // try to delete
     if (!empty($filesToDelete)) {
         $err = array();
         foreach ($filesToDelete as $file) {
             if (!unlink($file)) {
                 $err[] = $file;
             }
         }
         if (!empty($err)) {
             Response::jsonError($this->_lang->CANT_WRITE_FS . "\n<br>" . implode(",\n<br>", $err));
         }
     }
     Response::jsonSuccess();
 }
Example #25
0
 /**
  * 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'));
     }
 }
Example #26
0
 public function imglistAction()
 {
     $templates = $this->_config->get('templates');
     $dirPath = $this->_configMain->get('docroot');
     $dir = Request::post('dir', 'string', '');
     if (!is_dir($dirPath . $dir)) {
         Response::jsonArray(array());
     }
     $files = File::scanFiles($dirPath . $dir, array('.jpg', '.png', '.gif', '.jpeg'), false, File::Files_Only);
     if (empty($files)) {
         Response::jsonArray(array());
     }
     sort($files);
     $list = array();
     foreach ($files as $k => $fpath) {
         // ms fix
         $fpath = str_replace('\\', '/', $fpath);
         $text = basename($fpath);
         if ($text === '.svn') {
             continue;
         }
         $list[] = array('name' => $text, 'url' => str_replace($dirPath . '/', $this->_configMain->get('wwwroot'), $fpath), 'path' => str_replace($dirPath . '/', $templates['wwwroot'], $fpath));
     }
     Response::jsonSuccess($list);
 }
Example #27
0
 /**
  * Remove configuration record
  */
 public function deleteAction()
 {
     $this->_checkCanDelete();
     $data = Request::post('data', 'raw', false);
     if ($data === false) {
         Response::jsonSuccess();
     }
     $dataType = json_decode($data);
     if (!is_array($dataType)) {
         $data = array(json_decode($data, true));
     } else {
         $data = json_decode($data, true);
     }
     $media = Model::factory('Medialib');
     $configImage = $media->getConfig()->get('image');
     foreach ($data as $item) {
         $code = Filter::filterValue('pagecode', $item['code']);
         unset($configImage['sizes'][$code]);
         unset($configImage['thumb_types'][$code]);
     }
     $config = $media->getConfig();
     $config->set('image', $configImage);
     if (!$config->save()) {
         Response::jsonError($this->_lang->CANT_WRITE_FS);
     }
     Response::jsonSuccess();
 }
Example #28
0
 /**
  * Rebuild all packages
  */
 public function rebuildallAction()
 {
     $this->_checkCanEdit();
     $dest = $this->_packagesConfig->get('path');
     /*
      * Returning a reference from a function
      */
     $data =& $this->_packagesConfig->dataLink();
     if ($this->_packagesConfig->get('all_in_one')) {
         $s = '';
         foreach ($data['packages'] as $item) {
             if (!$item['active']) {
                 continue;
             }
             $s .= $this->_compilePackage($item);
         }
         Utils::exportCode($dest . $this->_packagesConfig->get('main_package') . '.php', $s);
     } else {
         foreach ($data['packages'] as $name => $item) {
             $s = $this->_compilePackage($item);
             $data['packages'][$name]['checksum'] = md5($s);
             if (Utils::exportCode($dest . $name . '.php', $s) === false) {
                 Response::jsonError($this->_lang->CANT_WRITE_FS);
             }
             $data['packages'][$name]['fchecksum'] = md5_file($dest . $name . '.php');
         }
     }
     if ($this->buildmapAction() === false) {
         Response::jsonError($this->_lang->CANT_WRITE_FS);
     }
     if (!$this->_packagesConfig->save()) {
         Response::jsonError($this->_lang->CANT_WRITE_FS);
     } else {
         Response::jsonSuccess();
     }
 }
Example #29
0
File: Vc.php Project: vgrish/dvelum
 /**
  * Unpublish object
  * Sends JSON reply in the result
  * and closes the application.
  * @param Db_Object $object
  */
 public function unpublishObject(Db_Object $object)
 {
     if (!$object->get('published')) {
         Response::jsonError($this->_lang->NOT_PUBLISHED);
     }
     if (!$object->unpublish()) {
         Response::jsonError($this->_lang->CANT_EXEC);
     }
     Response::jsonSuccess();
 }
Example #30
0
 /**
  * Save default blockmap
  */
 public function defaultblockssaveAction()
 {
     $this->_checkCanEdit();
     $data = Request::post('blocks', 'raw', '');
     if (strlen($data)) {
         $data = json_decode($data, true);
     } else {
         $data = array();
     }
     $blockMapping = Model::factory('Blockmapping');
     $blockMapping->clearMap(0);
     if (!empty($data)) {
         foreach ($data as $place => $items) {
             $blockMapping->addBlocks(0, $place, Utils::fetchCol('id', $items));
         }
     }
     $blockManager = new Blockmanager();
     $blockManager->invalidateDefaultMap();
     Response::jsonSuccess();
 }