/** * Get moduiles list */ public function listAction() { $manager = new Backend_Modules_Manager(); $data = $manager->getList(); foreach ($data as $k => &$item) { $item['related_files'] = ''; $classFile = './system/app/' . str_replace('_', '/', $item['class']) . '.php'; if (file_exists($classFile)) { $item['related_files'] .= $classFile . '</br>'; } if (!empty($item['designer'])) { $item['related_files'] .= $item['designer'] . '</br>'; $crudJs = './js/app/system/crud/' . strtolower($manager->getModuleName($item['class'])) . '.js'; if (file_exists($crudJs)) { $item['related_files'] .= $crudJs . '</br>'; } $actionJs = './js/app/actions/' . strtolower($manager->getModuleName($item['class'])) . '.js'; if (file_exists($actionJs)) { $item['related_files'] .= $actionJs . '</br>'; } } } Response::jsonSuccess(array_values($data)); }
protected function _prepareRecords($adminPass, $adminEmail, $adminName) { try { $toCleanModels = array(Model::factory('User'), Model::factory('Group'), Model::factory('Permissions'), Model::factory('Page')); foreach ($toCleanModels as $model) { $model->getDbConnection()->delete($model->table()); } // Add group $group = new Db_Object('Group'); $group->setValues(array('title' => $this->_dictionary['ADMINISTRATORS'], 'system' => true)); $group->save(true, false); $groupId = $group->getId(); // Add user $user = new Db_Object('user'); $user->setValues(array('name' => 'Admin', 'email' => $adminEmail, 'login' => $adminName, 'pass' => Utils::hash($adminPass), 'enabled' => true, 'admin' => true, 'registration_date' => date('Y-m-d H:i:s'), 'confirmation_code' => md5(date('Y-m-d H:i:s')), 'group_id' => $groupId, 'confirmed' => true, 'avatar' => '', 'registration_ip' => $_SERVER['REMOTE_ADDR'], 'last_ip' => $_SERVER['REMOTE_ADDR'], 'confirmation_date' => date('Y-m-d H:i:s'))); $userId = $user->save(false, false); if (!$userId) { return false; } // Add permissions $permissionsModel = Model::factory('Permissions'); $modulesManager = new Backend_Modules_Manager(); $modules = $modulesManager->getList(); foreach ($modules as $name => $config) { if (!$permissionsModel->setGroupPermissions($groupId, $name, true, true, true, true)) { return false; } } $u = User::getInstance(); $u->setId($userId); $u->setAuthorized(); // Add index Page $page = new Db_Object('Page'); $page->setValues(array('code' => 'index', 'is_fixed' => 1, 'html_title' => 'Index', 'menu_title' => 'Index', 'page_title' => 'Index', 'meta_keywords' => '', 'meta_description' => '', 'parent_id' => null, 'text' => '[Index page content]', 'func_code' => '', 'order_no' => 1, 'show_blocks' => true, 'published' => true, 'published_version' => 0, 'editor_id' => $userId, 'date_created' => date('Y-m-d H:i:s'), 'date_updated' => date('Y-m-d H:i:s'), 'author_id' => $userId, 'blocks' => '', 'theme' => 'default', 'date_published' => date('Y-m-d H:i:s'), 'in_site_map' => true, 'default_blocks' => true)); if (!$page->save(true, false)) { return false; } //404 Page $page = new Db_Object('Page'); $page->setValues(array('code' => '404', 'is_fixed' => 1, 'html_title' => 'Error 404. Page not found', 'menu_title' => '404', 'page_title' => 'We cannot find the page you are looking for.', 'meta_keywords' => '', 'meta_description' => '', 'parent_id' => null, 'text' => 'We cannot find the page you are looking for.', 'func_code' => '', 'order_no' => 2, 'show_blocks' => true, 'published' => true, 'published_version' => 0, 'editor_id' => $userId, 'date_created' => date('Y-m-d H:i:s'), 'date_updated' => date('Y-m-d H:i:s'), 'author_id' => $userId, 'blocks' => '', 'theme' => 'default', 'date_published' => date('Y-m-d H:i:s'), 'in_site_map' => false, 'default_blocks' => true)); if (!$page->save(true, false)) { return false; } //API Page $page = new Db_Object('Page'); $page->setValues(array('code' => 'api', 'is_fixed' => 1, 'html_title' => 'API [System]', 'menu_title' => 'API', 'page_title' => 'API [System]', 'meta_keywords' => '', 'meta_description' => '', 'parent_id' => null, 'text' => '', 'func_code' => 'api', 'order_no' => 3, 'show_blocks' => false, 'published' => true, 'published_version' => 0, 'editor_id' => $userId, 'date_created' => date('Y-m-d H:i:s'), 'date_updated' => date('Y-m-d H:i:s'), 'author_id' => $userId, 'blocks' => '', 'theme' => 'default', 'date_published' => date('Y-m-d H:i:s'), 'in_site_map' => false, 'default_blocks' => false)); if (!$page->save(true, false)) { return false; } return true; } catch (Exception $e) { return false; } }