public static function login_check_exit() { $after = Base_AclCommon::is_user(); if ($after !== self::$logged) { if ($after) { Base_HomePageCommon::load(); } else { Base_BoxCommon::location(Base_BoxCommon::get_main_module_name()); } } }
public function body() { if (isset(Base_BoxCommon::$override_box_main)) { $this->pack_module(Base_BoxCommon::$override_box_main); return; } $theme = $this->pack_module(Base_Theme::module_name()); $ini = Base_BoxCommon::get_ini_file(); if (!$ini) { print __('Unable to read Base/Box/default.ini file! Please create one, or change theme.'); $this->pack_module(Base_Theme_Administrator::module_name(), null, 'admin'); return; } $ini_file = parse_ini_file($ini, true); $logged = Base_AclCommon::is_user(); $theme->assign('logged', $logged); $containers = array(); $containers['main'] = array('module' => null, 'name' => ''); //so 'main' is first in array $name = 0; foreach ($ini_file as $tag => $opts) { $name++; if ($logged && $opts['display'] == 'anonymous' || !$logged && $opts['display'] == 'logged') { continue; } if (isset($opts['function'])) { $containers[$tag]['function'] = $opts['function']; $containers[$tag]['arguments'] = null; } if (isset($opts['arguments'])) { $containers[$tag]['arguments'] = $opts['arguments']; } if (isset($opts['module'])) { $containers[$tag]['module'] = $opts['module']; } else { trigger_error('No module specified.', E_USER_ERROR); } $containers[$tag]['name'] = $tag; } if (isset($containers['main'])) { $containers['main']['name'] = 'main_0'; } if (isset($_REQUEST['base_box_pop_main'])) { $pop_main = $_REQUEST['base_box_pop_main']; unset($_REQUEST['base_box_pop_main']); } else { $pop_main = false; } if ($this->isset_module_variable('main')) { $mains = $this->get_module_variable('main'); if ($pop_main) { while ($pop_main--) { array_pop($mains); } $pop_main = true; } $main = array_pop($mains); if (isset($main['module']) && $main['module'] != null) { $containers['main'] =& $main; } foreach ($mains as $k => $m) { if (ModuleManager::is_installed($m['module']) >= 0) { $this->freeze_module($m['module'], isset($m['name']) ? $m['name'] : null); } } } else { $mains = array(); } if (isset($_REQUEST['box_main_href'])) { if (!isset($_SESSION['client']['base_box_hrefs'])) { $_SESSION['client']['base_box_hrefs'] = array(); } $hs =& $_SESSION['client']['base_box_hrefs']; if (isset($hs[$_REQUEST['box_main_href']])) { $rh = $hs[$_REQUEST['box_main_href']]; $href = $rh['m']; $containers['main']['module'] = $href; if (isset($rh['f'])) { $containers['main']['function'] = $rh['f']; } else { unset($containers['main']['function']); } if (isset($rh['a'])) { $containers['main']['arguments'] = $rh['a']; } else { unset($containers['main']['arguments']); } if (isset($rh['c'])) { $containers['main']['constructor_arguments'] = $rh['c']; } else { unset($containers['main']['constructor_arguments']); } $mains = array(); $pop_main = true; } unset($_REQUEST['box_main_href']); $hs = array(); } array_push($mains, $containers['main']); $main_length = count($mains); $this->set_module_variable('main', $mains); // Epesi::alert(print_r($mains,true)); // $containers['main']['name'] .= '_'.$main_length; //print_r($containers); $this->modules = array(); foreach ($containers as $k => $v) { ob_start(); if (ModuleManager::is_installed($v['module']) != -1) { $module_type = str_replace('/', '_', $v['module']); if (!isset($v['name'])) { $v['name'] = null; } if (isset($href) && $k == 'main') { $this->modules[$k] = $this->init_module($module_type, isset($v['constructor_arguments']) ? $v['constructor_arguments'] : null, $v['name'], true); } else { $this->modules[$k] = $this->init_module($module_type, isset($v['constructor_arguments']) ? $v['constructor_arguments'] : null, $v['name']); } if ($k == 'main' && $pop_main) { $this->modules[$k]->set_reload(true); } if (isset($v['function'])) { $this->display_module($this->modules[$k], isset($v['arguments']) ? $v['arguments'] : null, $v['function']); } elseif (isset($v['arguments'])) { $this->display_module($this->modules[$k], $v['arguments']); } else { $this->display_module($this->modules[$k]); } } $theme->assign($k, ob_get_contents()); ob_end_clean(); } //main output $version_no = Base_BoxCommon::update_version_check_indicator(); if (SUGGEST_DONATION) { $theme->assign('donate', Utils_TooltipCommon::create('<a target="_blank" href="http://epe.si/donate/">' . __('Support EPESI!') . '</a>', '<center>' . __('If you find our software useful, please support us by making a %s.', array(__('donation'))) . '<br/>' . __('Your funding will help to ensure continued development of this project.') . '<br/>' . __('Click for details.') . '</center>', false, 500)); } // Consider moving this code properly as initated module by *.ini file $theme->assign('home', array('href' => Base_HomePageCommon::get_href(), 'label' => __('Home'))); $theme->assign('version_no', $version_no); $theme->display(); }
public function install() { $ret = true; $ret &= DB::CreateTable('base_dashboard_tabs', ' id I4 AUTO KEY, user_login_id I4, name C(64) NOTNULL, pos I2', array('constraints' => ', FOREIGN KEY (user_login_id) REFERENCES user_login(ID)')); if (!$ret) { print 'Unable to create table base_dashboard_tabs.<br>'; return false; } $ret &= DB::CreateTable('base_dashboard_default_tabs', ' id I4 AUTO KEY, name C(64) NOTNULL, pos I2'); if (!$ret) { print 'Unable to create table base_dashboard_default_tabs.<br>'; return false; } DB::Execute('INSERT INTO base_dashboard_default_tabs(name,pos) VALUES(\'Default\',0)'); $ret &= DB::CreateTable('base_dashboard_applets', ' id I4 AUTO KEY, user_login_id I4, module_name C(128), col I2 DEFAULT 0, pos I2 DEFAULT 0, color I2 DEFAULT 0, tab I4', array('constraints' => ', FOREIGN KEY (user_login_id) REFERENCES user_login(ID), FOREIGN KEY (tab) REFERENCES base_dashboard_tabs(ID)')); if (!$ret) { print 'Unable to create table base_dashboard_applets.<br>'; return false; } $ret &= DB::CreateTable('base_dashboard_settings', ' applet_id I4, name C(32) NOTNULL, value X NOTNULL', array('constraints' => ', FOREIGN KEY (applet_id) REFERENCES base_dashboard_applets(ID), PRIMARY KEY(applet_id,name)')); if (!$ret) { print 'Unable to create table base_dashboard_settings.<br>'; return false; } $ret &= DB::CreateTable('base_dashboard_default_applets', ' id I4 AUTO KEY, module_name C(128), col I2 DEFAULT 0, pos I2 DEFAULT 0, color I2 DEFAULT 0, tab I4', array('constraints' => ', FOREIGN KEY (tab) REFERENCES base_dashboard_default_tabs(ID)')); if (!$ret) { print 'Unable to create table base_dashboard_default_applets.<br>'; return false; } $ret &= DB::CreateTable('base_dashboard_default_settings', ' applet_id I4, name C(32) NOTNULL, value X NOTNULL', array('constraints' => ', FOREIGN KEY (applet_id) REFERENCES base_dashboard_default_applets(ID), PRIMARY KEY(applet_id,name)')); if (!$ret) { print 'Unable to create table base_dashboard_default_settings<br>'; return false; } Base_ThemeCommon::install_default_theme($this->get_type()); Base_AclCommon::add_permission(_M('Dashboard'), array('ACCESS:employee')); Base_HomePageCommon::set_home_page(_M('Dashboard'), array('ACCESS:employee')); Base_HomePageCommon::set_home_page(_M('My Contact'), array()); // Not exactly the place to add that, but we need to ensure proper order of home pages return $ret; }
<?php defined("_VALID_ACCESS") || die('Direct access forbidden'); @DB::DropTable('home_page'); @DB::CreateTable('base_home_page', 'id I4 AUTO KEY,' . 'priority I4,' . 'home_page C(64)', array('constraints' => '')); @DB::CreateTable('base_home_page_clearance', 'id I4 AUTO KEY,' . 'home_page_id I,' . 'clearance C(64)', array('constraints' => ', FOREIGN KEY (home_page_id) REFERENCES base_home_page(id)')); Base_HomePageCommon::set_home_page(_M('Dashboard'), array('ACCESS:employee')); Base_HomePageCommon::set_home_page(_M('My Contact'), array());
public function edit_home_page($id = null) { if ($this->is_back()) { return false; } $counts = 5; $all_clearances = array('' => '---') + array_flip(Base_AclCommon::get_clearance(true)); $home_pages = array('' => '---'); $current_clearance = 0; $form = $this->init_module('Libs_QuickForm'); $theme = $this->init_module('Base_Theme'); $theme->assign('labels', array('and' => '<span class="joint">' . __('and') . '</span>', 'or' => '<span class="joint">' . __('or') . '</span>', 'caption' => $id ? __('Edit Home Page') : __('Add Home Page'), 'clearance' => __('Clearance requried'), 'fields' => __('Fields allowed'), 'crits' => __('Criteria required'), 'add_clearance' => __('Add clearance'), 'add_or' => __('Add criteria (or)'), 'add_and' => __('Add criteria (and)'))); $tmp = Base_HomePageCommon::get_home_pages(); $home_pages = array(); foreach ($tmp as $k => $v) { $home_pages[$k] = _V($k); } // ****** - translating home_page options $form->addElement('select', 'home_page', __('Target Home Page'), array('' => '---') + $home_pages); if ($id) { $page = DB::GetOne('SELECT home_page FROM base_home_page WHERE id=%d', array($id)); $form->setDefaults(array('home_page' => $page)); } $form->addRule('home_page', __('Field required'), 'required'); for ($i = 0; $i < $counts; $i++) { $form->addElement('select', 'clearance_' . $i, __('Clearance'), $all_clearances); } $i = 0; $clearances = DB::GetAssoc('SELECT id, clearance FROM base_home_page_clearance WHERE home_page_id=%d', array($id)); foreach ($clearances as $v) { $form->setDefaults(array('clearance_' . $i => $v)); $i++; } $current_clearance = max($i - 1, 0); if ($form->validate()) { DB::StartTrans(); $vals = $form->exportValues(); $clearances = array(); for ($i = 0; $i < $counts; $i++) { if ($vals['clearance_' . $i]) { $clearances[] = $vals['clearance_' . $i]; } } if ($id !== null) { DB::Execute('DELETE FROM base_home_page_clearance WHERE home_page_id=%d', array($id)); DB::Execute('UPDATE base_home_page SET home_page=%s WHERE id=%d', array($vals['home_page'], $id)); } else { $prio = DB::GetOne('SELECT MAX(priority) FROM base_home_page') + 1; DB::Execute('INSERT INTO base_home_page (home_page,priority) VALUES (%s, %d)', array($vals['home_page'], $prio)); $id = DB::Insert_ID('base_home_page', 'id'); } foreach ($clearances as $c) { DB::Execute('INSERT INTO base_home_page_clearance (home_page_id, clearance) VALUES (%d, %s)', array($id, $c)); } DB::CompleteTrans(); return false; } $form->add_error_closing_buttons(); $form->assign_theme('form', $theme); $theme->assign('counts', $counts); $theme->display('edit_home_pages'); load_js('modules/Base/HomePage/edit_home_pages.js'); eval_js('base_home_page__init_clearance(' . $current_clearance . ', ' . $counts . ')'); eval_js('base_home_page__initialized = true;'); Base_ActionBarCommon::add('save', __('Save'), $form->get_submit_form_href()); Base_ActionBarCommon::add('delete', __('Cancel'), $this->create_back_href()); return true; }