예제 #1
0
 public function configure_applet($id, $mod, &$ok = null)
 {
     $default_dash = $this->get_module_variable('default');
     if (!$default_dash && !Base_DashboardCommon::has_permission_to_manage_applets()) {
         return;
     }
     if ($this->is_back()) {
         $ok = false;
         return false;
     }
     $sett_fn = array($mod . 'Common', 'applet_settings');
     $is_conf = is_callable($sett_fn);
     $fc = $this->get_module_variable('first_conf');
     if (!$is_conf && $fc) {
         $ok = true;
         return false;
     }
     $f = $this->init_module(Libs_QuickForm::module_name(), __('Saving settings'), 'settings');
     $caption = call_user_func(array($mod . 'Common', 'applet_caption'));
     if ($is_conf) {
         $f->addElement('header', null, __('%s settings', array($caption)));
         $menu = call_user_func($sett_fn);
         if (is_array($menu)) {
             $this->add_module_settings_to_form($menu, $f, $id, $mod);
         } else {
             trigger_error('Invalid applet settings function: ' . $mod, E_USER_ERROR);
         }
     }
     $f->addElement('header', null, $caption . ' ' . __('display settings'));
     $color = Base_DashboardCommon::get_available_colors();
     $color[0] = __('Default') . ': ' . $color[0]['label'];
     for ($k = 1; $k < count($color); $k++) {
         $color[$k] = '&bull; ' . $color[$k]['label'];
     }
     $f->addElement('select', '__color', __('Color'), $color, array('style' => 'width: 100%;'));
     $table_tabs = 'base_dashboard_' . ($default_dash ? 'default_' : '') . 'tabs';
     $table_applets = 'base_dashboard_' . ($default_dash ? 'default_' : '') . 'applets';
     $tabs = DB::GetAssoc('SELECT id,name FROM ' . $table_tabs . ($default_dash ? '' : ' WHERE user_login_id=' . Base_AclCommon::get_user()));
     $f->addElement('select', '__tab', __('Tab'), $tabs);
     $dfs = DB::GetRow('SELECT tab,color FROM ' . $table_applets . ' WHERE id=%d', array($id));
     $f->setDefaults(array('__tab' => $dfs['tab'], '__color' => $dfs['color']));
     if ($f->validate()) {
         //$f->process(array(& $this, 'submit_settings'));
         $submited = $f->exportValues();
         DB::Execute('UPDATE ' . $table_applets . ' SET tab=%d WHERE id=%d', array($submited['__tab'], $id));
         DB::Execute('UPDATE ' . $table_applets . ' SET color=%d WHERE id=%d', array($submited['__color'], $id));
         $defaults = $this->get_default_values($mod);
         $old = $this->get_values($id, $mod);
         foreach ($defaults as $name => $def_value) {
             if (!isset($submited[$name])) {
                 $submited[$name] = 0;
             }
             if ($submited[$name] != $old[$name]) {
                 if ($this->get_module_variable('default')) {
                     if ($submited[$name] == $def_value) {
                         DB::Execute('DELETE FROM base_dashboard_default_settings WHERE applet_id=%d AND name=%s', array($id, $name));
                     } else {
                         DB::Replace('base_dashboard_default_settings', array('applet_id' => $id, 'name' => $name, 'value' => $submited[$name]), array('applet_id', 'name'), true);
                     }
                 } else {
                     if ($submited[$name] == $def_value) {
                         DB::Execute('DELETE FROM base_dashboard_settings WHERE applet_id=%d AND name=%s', array($id, $name));
                     } else {
                         DB::Replace('base_dashboard_settings', array('applet_id' => $id, 'name' => $name, 'value' => $submited[$name]), array('applet_id', 'name'), true);
                     }
                 }
             }
         }
         $ok = true;
         self::$settings_cache = null;
         return false;
     }
     $ok = null;
     $f->display();
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     Base_ActionBarCommon::add('save', __('Save'), $f->get_submit_form_href());
     Base_ActionBarCommon::add('settings', __('Restore Defaults'), 'onClick="' . $this->set_default_js . '" href="javascript:void(0)"');
     return true;
 }
예제 #2
0
 * @version 1.0
 * @package epesi-base
 * @subpackage dashboard
 */
header("Content-type: text/javascript");
if (!isset($_POST['id'])) {
    die;
}
define('JS_OUTPUT', 1);
define('CID', false);
//don't load user session
define('READ_ONLY_SESSION', true);
require_once '../../../include.php';
ModuleManager::load_modules();
if (!Base_AclCommon::is_user()) {
    Epesi::alert('Session expired, logged out - reloading epesi.');
    Epesi::redirect('');
    Epesi::send_output();
    exit;
}
$default = isset($_POST['default_dash']) && $_POST['default_dash'];
if ($default && !Base_AdminCommon::get_access('Base_Dashboard') || !$default && !Base_DashboardCommon::has_permission_to_manage_applets()) {
    Epesi::alert('Permission denied');
    Epesi::send_output();
    exit;
}
if (!$default) {
    $user = Base_AclCommon::get_user();
}
$id = json_decode($_POST['id']);
Base_DashboardCommon::remove_applet($id, $default);
예제 #3
0
파일: update.php 프로젝트: cretzu89/EPESI
 */
header("Content-type: text/javascript");
define('JS_OUTPUT', 1);
define('CID', false);
//don't load user session
define('READ_ONLY_SESSION', true);
require_once '../../../include.php';
ModuleManager::load_modules();
if (!Base_AclCommon::is_user()) {
    Epesi::alert('Session expired, logged out - reloading epesi.');
    Epesi::redirect('');
    Epesi::send_output();
    exit;
}
$default = isset($_POST['default_dash']) && $_POST['default_dash'];
if ($default && !Base_AdminCommon::get_access('Base_Dashboard') || !$default && !Base_DashboardCommon::has_permission_to_manage_applets() || !isset($_POST['col']) || !isset($_POST['data'])) {
    Epesi::alert('Permission denied');
    Epesi::send_output();
    exit;
}
if (!$default) {
    $user = Base_AclCommon::get_user();
}
$tab = json_decode($_POST['tab']);
parse_str($_POST['data'], $x);
if (!isset($x['ab_item'])) {
    exit;
}
if (is_numeric($_POST['col']) && $_POST['col'] < 3 && $_POST['col'] >= 0) {
    if ($default) {
        $table = 'base_dashboard_default_applets';