public function action_index() { // get acl $acl = Acl::instance(); // get modules $modules = Settings::factory('modules')->as_array(); // get navigation $settings = Settings::factory('navigation', array('settings' . DIRECTORY_SEPARATOR . Website::instance()->id() . DIRECTORY_SEPARATOR, 'settings')); $navigation = $settings->get('menu'); // filter out allowed modules $allowedModules = array(); foreach ($modules as $module => $data) { if ($acl->allowed($module, 'access')) { $allowedModules[$module] = $data; } } // fill up sections $sections = array(); foreach ($navigation as $section => $modules) { foreach ($modules as $module) { if (isset($allowedModules[$module])) { // section has a allowed module, so include it if (!isset($sections[$section])) { $sections[$section] = array(); } // add module to section $sections[$section][$module] = $allowedModules[$module]; } } } $view = View::factory('start', array('sections' => $sections)); $this->response->body($view->render()); }
/** * Default action in default controller */ public function action_index() { // get acl $acl = Acl::instance(); // get first allowed module // get modules $modules = Settings::factory('modules')->as_array(); $modules = array_keys($modules); $module = State::instance()->get('active.module'); if ($module !== FALSE && $module !== 'Default') { if ($acl->allowed($module, 'access', FALSE, $this->_website) === TRUE) { $url = URL::to($module, array('website' => $this->_website)); $this->redirect($url); exit; } } // find the first allowed module & redirect foreach ($modules as $module) { if ($acl->allowed($module, 'access', FALSE, $this->_website) === TRUE) { $url = URL::to($module, array('website' => $this->_website)); $this->redirect($url); exit; } } }
function __construct($table, $property = null, $value = null) { $this->settings = Settings::factory(); $this->table = $this->settings->tbl_prefix . $table; $this->dbh = @mysql_connect($this->settings->db_host, $this->settings->db_user, $this->settings->db_pass); if ($this->dbh === FALSE) { throw new exception("construct:データベースに接続できない"); } $sqlstr = "use " . $this->settings->db_name; $res = $this->__query($sqlstr); if ($res === false) { throw new exception("construct: " . $sqlstr); } $sqlstr = "set NAMES utf8"; $res = $this->__query($sqlstr); if ($property == null || $value == null) { // レコードを特定する要素が指定されない場合はid=0として空のオブジェクトを作成する $this->id = 0; } else { $sqlstr = "SELECT * FROM " . $this->table . " WHERE " . mysql_real_escape_string($property) . "='" . mysql_real_escape_string($value) . "'"; $res = $this->__query($sqlstr); $arr = mysql_fetch_array($res, MYSQL_ASSOC); if ($arr === FALSE) { throw new exception("construct:無効な行"); } // 最初にヒットした行のidを使用する $this->id = $arr['id']; } return; }
public function saveSettings() { require_once INSTALL_PATH . "/Settings.class.php"; $settings = Settings::factory(); $settings->post(); $settings->save(); $smarty = new Smarty(); $smarty->template_dir = dirname(dirname(__FILE__)) . '/templates/'; $smarty->compile_dir = dirname(dirname(__FILE__)) . '/templates_c/'; $smarty->assign('message', '設定が保存されました'); $smarty->assign('url', 'index.php'); $smarty->display("dialog.html"); }
/** * Get module navigation */ public function action_module() { // get request $request = Request::initial(); // get settings $settings = Settings::factory($request->controller()); // navigation viewer $navigation = Viewer::instance('Navigation')->settings($settings->get('navigation'))->request(Request::initial())->acl(Acl::instance()); // create view $view = View::factory($settings->get('view.navigation'), array('navigation' => $navigation)); // raise event Event::raise($this, Event::BEFORE_NAVIGATION_RENDER, array('navigation' => $navigation)); // render view $this->response->body($view->render()); }
/** * INIT */ public function init() { // call parent before parent::init(); //create settings //read from website specific settings before general settings $this->_settings = Settings::factory($this->_controller, array('settings' . DIRECTORY_SEPARATOR . $this->_website . DIRECTORY_SEPARATOR, 'settings')); // set up listeners $this->listeners(); // set up navigation if (Request::current()->is_initial() === TRUE) { $navigation = Viewer::instance('Navigation'); $navigation->breadcrumb(Text::instance()->get('section.start'), URL::to('Start')); $navigation->breadcrumb(Text::instance()->get('module.name'), URL::to($this->_controller)); $navigation->title(Text::instance()->get('title.' . $this->_action)); } }
/** * init */ public function init() { // raise event Event::raise($this, Event::BEFORE_INIT); // get website and feed it the current uri so we can figure out the ->id() $website = Website::instance()->uri(Request::initial()->uri()); // set controller vars $this->_website = $website->id(); $this->_directory = Request::current()->directory(); $this->_controller = Request::current()->controller(); $this->_action = Request::current()->action(); $this->_language = isset(Identity::instance()->user) ? Identity::instance()->user->language : 'nl'; // manually set website in Website // this will be used by alias Website::instance()->id($this->_website); // set state session // get state instance for this website / controller State::session(Session::instance('database')); $this->_state = State::instance($this->_website . '.' . $this->_controller); // set route in URL helper URL::route('backend'); // Let Filereader cache results Reader::cache(Cache::instance('reader_backend'), 'backend'); // set default language Text::language($this->_language); // get that language's text instance and configure it Text::instance($this->_language)->load(array_keys(Settings::factory('modules')->as_array()))->group($this->_controller)->substitutes('module'); // set URL presets $base = URL::base(); URL::set('base', $base); URL::set('library', $base . 'library/'); URL::set('vendor', $base . 'vendor/'); URL::set('files', $base . 'files/'); // set website in view View::set_global('_website', $this->_website); // set language in view View::set_global('_language', $this->_language); }
#!/usr/bin/php <?php // 録画が完了したことを知らせるフラグ // @TODO gen-thumbnailを実行する require_once "config.php"; require_once INSTALL_PATH . "/DBRecord.class.php"; $settings = Settings::factory(); $reserve_id = $argv[1]; try { $rrec = new DBRecord(RESERVE_TBL, "id", $reserve_id); if (file_exists(INSTALL_PATH . $settings->spool . "/" . $rrec->path)) { // 予約完了 $rrec->complete = '1'; } else { // 予約失敗 $rrec->delete(); } } catch (Exception $e) { exit($e->getMessage()); }
public static function cancel($reserve_id = 0, $program_id = 0) { $settings = Settings::factory(); $rec = null; try { if ($reserve_id) { $rec = new DBRecord(RESERVE_TBL, "id", $reserve_id); } else { if ($program_id) { $rec = new DBRecord(RESERVE_TBL, "program_id", $program_id); } } if ($rec == null) { throw new Exception("IDの指定が無効です"); } if (!$rec->complete) { // 未実行の予約である if (strtotime($rec->starttime) < time() + PADDING_TIME + $settings->former_time) { throw new Exception("過去の録画予約です"); } exec($settings->atrm . " " . $rec->job); } $rec->delete(); } catch (Exception $e) { throw $e; } }