Пример #1
0
 public static function init()
 {
     load_js('modules/Base/Notify/js/desktop-notify.js');
     load_js('modules/Base/Notify/js/main.js');
     eval_js_once("if (notify.isSupported) {\n\t\tclearInterval(Base_Notify__interval);\n\t\tvar Base_Notify__interval = setInterval(function () {Base_Notify__refresh('" . CID . "');}, " . self::refresh_rate * 1000 . ");\n\t\t}");
     eval_js_once('function Base_Notify__alert () {alert(\'' . __('Notifications disabled or not supported!') . '\\n' . __('Check your browser settings and allow notifications to use this feature...') . '\');}');
 }
Пример #2
0
 public static function init()
 {
     if (Base_AclCommon::is_user() == false || self::$initialized) {
         return;
     }
     DB::Execute('DELETE FROM base_notify WHERE single_cache_uid is null AND last_refresh < %d', array(strtotime('-24 hours')));
     load_js('modules/Base/Notify/js/desktop-notify.js');
     load_js('modules/Base/Notify/js/main.js');
     $disabled_message = __('Notifications disabled or not supported!') . '\\n' . __('Check your browser settings and allow notifications to use this feature...');
     $disabled_message = json_encode($disabled_message);
     eval_js_once("Base_Notify.init (" . self::refresh_rate * 1000 . ", {$disabled_message});");
     self::$initialized = true;
 }
Пример #3
0
 public function applet($values, &$opts)
 {
     //available applet options: toggle,href,title,go,go_function,go_arguments,go_contruct_arguments
     Base_ThemeCommon::load_css('Applets_Weather');
     $opts['title'] = __('Weather');
     $rssfeed = $values['rssfeed'] . '?p=' . $values['zipcode'] . '&u=' . $values['temperature'];
     $name = md5($this->get_path() . $rssfeed);
     //div for updating
     print '<div id="Applets_Weather"><div id="rssfeed_' . $name . '"><span>' . __('Loading Weather...') . '</span></div></div>';
     //interval execution
     eval_js_once('var rssfeedcache = Array();' . 'rssfeedfunc = function(name,fee,num,cache){' . 'if(!$(\'rssfeed_\'+name)) return;' . 'if(cache && typeof rssfeedcache[name] != \'undefined\')' . '$(\'rssfeed_\'+name).innerHTML = rssfeedcache[name];' . 'else ' . 'new Ajax.Updater(\'rssfeed_\'+name,\'modules/Applets/Weather/refresh.php\',{' . 'method:\'post\',' . 'onComplete:function(r){rssfeedcache[name]=r.responseText},' . 'parameters:{feed:fee, number:num, cid: Epesi.client_id}});' . '}');
     eval_js_once('setInterval(\'rssfeedfunc(\\\'' . $name . '\\\',\\\'' . Epesi::escapeJS($rssfeed, false) . '\\\' , 2 , 0)\',1799993)');
     //29 minutes and 53 seconds
     //get rss now!
     eval_js('rssfeedfunc(\'' . $name . '\',\'' . Epesi::escapeJS($rssfeed, false) . '\' , 2 , 1)');
 }
Пример #4
0
 public function applet($values, &$opts)
 {
     //available applet options: toggle,href,title,go,go_function,go_arguments,go_contruct_arguments
     if (!$values['title']) {
         $values['title'] = __('RSS Feed');
     }
     $opts['title'] = $values['title'];
     $name = md5($this->get_path() . $values['rssfeed']);
     //div for updating
     print '<div id="rssfeed_' . $name . '" style="width: 270px; padding: 5px 5px 5px 20px;">' . __('Loading RSS...') . '</div>';
     //interval execution
     eval_js_once('var rssfeedcache = Array();' . 'rssfeedfunc = function(name,fee,num,cache){' . 'if(!$(\'rssfeed_\'+name)) return;' . 'if(cache && typeof rssfeedcache[name] != \'undefined\')' . '$(\'rssfeed_\'+name).innerHTML = rssfeedcache[name];' . 'else ' . 'new Ajax.Updater(\'rssfeed_\'+name,\'modules/Applets/RssFeed/refresh.php\',{' . 'method:\'post\',' . 'onComplete:function(r){rssfeedcache[name]=r.responseText},' . 'parameters:{feed:fee, number:num, cid: Epesi.client_id}});' . '}');
     eval_js_once('setInterval(\'rssfeedfunc(\\\'' . $name . '\\\',\\\'' . Epesi::escapeJS($values['rssfeed'], false) . '\\\' ,' . $values['rssnumber'] . ' , 0)\',1799993)');
     //29 minutes and 53 seconds
     //get rss now!
     eval_js('rssfeedfunc(\'' . $name . '\',\'' . Epesi::escapeJS($values['rssfeed'], false) . '\' ,' . $values['rssnumber'] . ' , 1)');
 }
Пример #5
0
 public static function drawLeightbox($prefix)
 {
     if (MOBILE_DEVICE) {
         return;
     }
     $meetings = CRM_MeetingInstall::is_installed();
     $tasks = CRM_TasksInstall::is_installed();
     $phonecall = CRM_PhoneCallInstall::is_installed();
     self::check_location();
     if (!isset(self::$leightbox_ready[$prefix])) {
         self::$leightbox_ready[$prefix] = true;
         $theme = Base_ThemeCommon::init_smarty();
         eval_js_once($prefix . '_followups_deactivate = function(){leightbox_deactivate(\'' . $prefix . '_followups_leightbox\');}');
         if ($meetings) {
             $theme->assign('new_meeting', array('open' => '<a id="' . $prefix . '_new_meeting_button" onclick="' . $prefix . '_set_action(\'new_meeting\');' . $prefix . '_submit_form();">', 'text' => __('New Meeting'), 'close' => '</a>'));
             eval_js('Event.observe(\'' . $prefix . '_new_meeting_button\',\'click\', ' . $prefix . '_followups_deactivate)');
         }
         if ($tasks) {
             $theme->assign('new_task', array('open' => '<a id="' . $prefix . '_new_task_button" onclick="' . $prefix . '_set_action(\'new_task\');' . $prefix . '_submit_form();">', 'text' => __('New Task'), 'close' => '</a>'));
             eval_js('Event.observe(\'' . $prefix . '_new_task_button\',\'click\', ' . $prefix . '_followups_deactivate)');
         }
         if ($phonecall) {
             $theme->assign('new_phonecall', array('open' => '<a id="' . $prefix . '_new_phonecall_button" onclick="' . $prefix . '_set_action(\'new_phonecall\');' . $prefix . '_submit_form();">', 'text' => __('New Phonecall'), 'close' => '</a>'));
             eval_js('Event.observe(\'' . $prefix . '_new_phonecall_button\',\'click\', ' . $prefix . '_followups_deactivate)');
         }
         $theme->assign('just_close', array('open' => '<a id="' . $prefix . '_just_close_button" onclick="' . $prefix . '_set_action(\'none\');' . $prefix . '_submit_form();">', 'text' => __('Save'), 'close' => '</a>'));
         eval_js('Event.observe(\'' . $prefix . '_just_close_button\',\'click\', ' . $prefix . '_followups_deactivate)');
         eval_js($prefix . '_submit_form = function () {' . '$(\'' . $prefix . '_follow_up_form\').submited.value=1;Epesi.href($(\'' . $prefix . '_follow_up_form\').serialize(), \'processing...\');$(\'' . $prefix . '_follow_up_form\').submited.value=0;' . '}');
         eval_js($prefix . '_set_action = function (arg) {' . 'document.forms["' . $prefix . '_follow_up_form"].action.value = arg;' . '}');
         eval_js($prefix . '_set_id = function (id) {' . 'document.forms["' . $prefix . '_follow_up_form"].id.value = id;' . '$("' . $prefix . '_closecancel").value=3;' . '$("' . $prefix . '_note").value="";' . '}');
         $theme->assign('form_open', '<form id="' . $prefix . '_follow_up_form" name="' . $prefix . '_follow_up_form" method="POST">' . '<input type="hidden" name="submited" value="0" />' . '<input type="hidden" name="form_name" value="' . $prefix . '_follow_up_form" />' . '<input type="hidden" name="id" value="" />' . '<input type="hidden" name="action" value="" />');
         $status_select_options = '';
         $statuses = Utils_CommonDataCommon::get_translated_array('CRM/Status');
         foreach ($statuses as $key => $value) {
             $status_select_options .= '<option value="' . htmlspecialchars($key) . '"' . ($key == 3 ? ' selected="1"' : '') . '>' . htmlspecialchars($value) . '</option>';
         }
         $theme->assign('form_closecancel', array('label' => __('Status'), 'html' => '<select name="closecancel" id="' . $prefix . '_closecancel" value="0">' . $status_select_options . '</select>'));
         $theme->assign('form_note', array('label' => __('Note'), 'html' => '<textarea name="note" id="' . $prefix . '_note"></textarea>'));
         $theme->assign('form_close', '</form>');
         ob_start();
         Base_ThemeCommon::display_smarty($theme, 'CRM_Followup', 'leightbox');
         $profiles_out = ob_get_clean();
         Libs_LeightboxCommon::display($prefix . '_followups_leightbox', $profiles_out, __('Follow-up'));
     }
 }
Пример #6
0
 public function construct($indicator = null, $action = '', $target = '', $on_submit = null, $form_name = null)
 {
     if (!$form_name) {
         $form_name = 'libs_qf_' . md5($this->get_path());
     }
     if ($target == '' && $action != '') {
         $target = '_blank';
     }
     if (!isset($on_submit)) {
         $on_submit = $this->get_submit_form_js_by_name($form_name, true, $indicator, '') . "return false;";
     }
     $this->qf = new HTML_QuickForm($form_name, 'post', $action, $target, array('onSubmit' => $on_submit), true);
     $this->qf->addElement('hidden', 'submited', 0);
     $this->qf->setRequiredNote('<span class="required_note_star">*</span> <span class="required_note">' . __('denotes required field') . '</span>');
     eval_js_once("set_qf_sub0 = function(fn){var x=\$(fn);if(x)x.submited.value=0}");
     eval_js("set_qf_sub0('" . addslashes($form_name) . "')");
     Base_ThemeCommon::load_css('Libs_QuickForm');
 }
Пример #7
0
    public function body($file = null, $callback = null)
    {
        if (!isset($file)) {
            if (!isset($this->file)) {
                trigger_error('You have to specify file to download', E_USER_ERROR);
            }
            $file = $this->file;
        }
        if (!isset($callback)) {
            if (!isset($this->callback)) {
                trigger_error('You have to specify callback to call on download complete', E_USER_ERROR);
            }
            $callback = $this->callback;
        }
        if (isset($_REQUEST['download_complete_' . $this->get_path()])) {
            $did = $this->get_module_variable('download_id');
            $dd = $this->get_data_dir();
            if (!isset($did) || !file_exists($dd . $did . '.tmp')) {
                print 'Download error.';
            } else {
                DB::Execute('DELETE FROM utils_filedownload_files WHERE id=%d', array($did));
                $tf = $dd . $did . '.tmp';
                call_user_func($callback, $tf, basename($file));
                @unlink($tf);
            }
            return;
        }
        $path = $this->get_path();
        $id = $this->create_unique_key('stat');
        print '<div id="' . $id . '"></div>';
        eval_js_once('utils_filedownload_refresh = function(id,path){var stat=$(id);if(!stat || stat.innerHTML==\'Processing downloaded file\') return;' . 'new Ajax.Updater(id,\'' . $this->get_module_dir() . 'refresh.php\',{method:\'post\', parameters:{path: path}});' . 'setTimeout("utils_filedownload_refresh(\'"+id+"\',\'"+path+"\')",3000);}');
        eval_js_once('utils_filedownload_check_completed = function(id){stat=document.getElementById(id);' . 'if(stat && stat.innerHTML==\'Finished\'){
					stat.innerHTML=\'Processing downloaded file\';' . $this->create_href_js(array('download_complete_' . $this->get_path() => 1), __('Download finished'), 'queue') . '}setTimeout(\'utils_filedownload_check_completed("\'+id+\'")\',500);}');
        DB::Execute('INSERT INTO utils_filedownload_files(path,size) VALUES (%s,-1)', array($file));
        $this->set_module_variable('download_id', DB::Insert_ID('utils_downloadfile_files', 'id'));
        print '<iframe src="' . $this->get_module_dir() . 'download.php?' . http_build_query(array('client_id' => CID, 'path' => $path)) . '"  width=0 height=0 frameborder=0>';
        eval_js('utils_filedownload_refresh("' . $id . '","' . $path . '");utils_filedownload_check_completed("' . $id . '")');
    }
Пример #8
0
 public function launchpad()
 {
     if (self::$launchpad == null) {
         return;
     }
     $launcher = array();
     usort(self::$launchpad, array($this, 'compare_launcher'));
     if (!empty(self::$launchpad)) {
         $icon = Base_ThemeCommon::get_template_file($this->get_type(), 'launcher.png');
         $th = $this->pack_module(Base_Theme::module_name());
         usort(self::$launchpad, array($this, 'compare_launcher'));
         $th->assign('icons', self::$launchpad);
         eval_js_once('actionbar_launchpad_deactivate = function(){leightbox_deactivate(\'actionbar_launchpad\');}');
         ob_start();
         $th->display('launchpad');
         $lp_out = ob_get_clean();
         $big = count(self::$launchpad) > 10;
         Libs_LeightboxCommon::display('actionbar_launchpad', $lp_out, __('Launchpad'), $big);
         $launcher[] = array('label' => __('Launchpad'), 'description' => 'Quick modules launcher', 'open' => '<a ' . Libs_LeightboxCommon::get_open_href('actionbar_launchpad') . '>', 'close' => '</a>', 'icon' => $icon);
         $th = $this->pack_module(Base_Theme::module_name());
         $th->assign('icons', array());
         $th->assign('launcher', array_reverse($launcher));
         $th->display();
         eval_js('$("launchpad_button_section").style.display="";');
         eval_js('$("launchpad_button_section_spacing").style.display="";');
     }
 }
Пример #9
0
<?php

/**
 * Codepress editor
 * This module uses CodePress editor released under
 * GNU LESSER GENERAL PUBLIC LICENSE Version 2.1
 *
 * @author Paul Bukowski <*****@*****.**>
 * @copyright Copyright &copy; 2008, Telaxus LLC
 * @license MIT
 * @version 0.1
 * @package epesi-libs
 * @subpackage codepress
 */
defined("_VALID_ACCESS") || die('Direct access forbidden');
HTML_Quickform::registerElementType('codepress', 'modules/Libs/Codepress/HTML_Quickform_codepress_0.php', 'HTML_Quickform_codepress');
load_js('modules/Libs/Codepress/0.9.6/codepress.js');
eval_js_once('document.observe("e:load", function(){CodePress.run();})');
Libs_QuickFormCommon::add_on_submit_action('CodePress.update(this)');
class Libs_CodepressCommon extends ModuleCommon
{
}
Пример #10
0
 public function body()
 {
     if (!Acl::is_user()) {
         return;
     }
     $th = $this->init_module('Base/Theme');
     eval_js_once('crm_filters_deactivate = function(){leightbox_deactivate(\'crm_filters\');}');
     $th->assign('my', '<a ' . $this->create_callback_href(array('CRM_FiltersCommon', 'set_profile'), 'my') . ' id="crm_filters_my">' . __('My records') . '</a>');
     eval_js('Event.observe(\'crm_filters_my\',\'click\', crm_filters_deactivate)');
     /*$th->assign('all','<a '.$this->create_callback_href(array('CRM_FiltersCommon','set_profile'),'all').' id="crm_filters_all">'.__('All records').'</a>');
     		eval_js('Event.observe(\'crm_filters_all\',\'click\', crm_filters_deactivate)');*/
     $th->assign('manage', '<a ' . $this->create_callback_href(array($this, 'manage_filters')) . ' id="crm_filters_manage">' . __('Manage presets') . '</a>');
     eval_js('Event.observe(\'crm_filters_manage\',\'click\', crm_filters_deactivate)');
     $ret = DB::Execute('SELECT id,name,description FROM crm_filters_group WHERE user_login_id=%d', array(Acl::get_user()));
     $filters = array();
     while ($row = $ret->FetchRow()) {
         $filters[] = array('title' => $row['name'], 'description' => '', 'open' => '<a ' . Utils_TooltipCommon::open_tag_attrs($row['description'], false) . ' ' . $this->create_callback_href(array('CRM_FiltersCommon', 'set_profile'), $row['id']) . ' id="crm_filters_' . $row['id'] . '">', 'close' => '</a>');
         eval_js('Event.observe(\'crm_filters_' . $row['id'] . '\',\'click\', crm_filters_deactivate)');
     }
     $th->assign('filters', $filters);
     $qf = $this->init_module('Libs/QuickForm');
     $fcallback = array('CRM_ContactsCommon', 'contact_format_no_company');
     $recent_crits = array();
     if (!Base_User_SettingsCommon::get('CRM_Contacts', 'show_all_contacts_in_filters')) {
         $recent_crits = array('(company_name' => CRM_ContactsCommon::get_main_company(), '|related_companies' => array(CRM_ContactsCommon::get_main_company()));
     }
     if (Base_User_SettingsCommon::get('CRM_Contacts', 'show_only_users_in_filters')) {
         $recent_crits['!login'] = '';
     }
     $contacts = CRM_ContactsCommon::get_contacts($recent_crits, array(), array(), 15);
     $cont = array();
     foreach ($contacts as $v) {
         $cont[$v['id']] = call_user_func($fcallback, $v, true);
     }
     asort($cont);
     $crits = array();
     if (!Base_User_SettingsCommon::get('CRM_Contacts', 'show_all_contacts_in_filters')) {
         $crits = array('(company_name' => CRM_ContactsCommon::get_main_company(), '|related_companies' => array(CRM_ContactsCommon::get_main_company()));
     }
     $qf->addElement('autoselect', 'crm_filter_contact', __('Records of'), $cont, array(array('CRM_ContactsCommon', 'autoselect_contact_suggestbox'), array($crits, $fcallback, false)), $fcallback);
     if (isset($_SESSION['client']['filter_' . Acl::get_user()]['value'])) {
         $qf->setDefaults(array('crm_filter_contact' => explode(',', $_SESSION['client']['filter_' . Acl::get_user()]['value'])));
     }
     $qf->addElement('submit', 'submit', __('Show'), array('onclick' => 'crm_filters_deactivate()'));
     if ($qf->validate()) {
         $c = $qf->exportValue('crm_filter_contact');
         CRM_FiltersCommon::set_profile('c' . $c);
         location(array());
     }
     $th->assign('saved_filters', __('Saved Presets'));
     $qf->assign_theme('contacts', $th);
     //$th->assign('contacts',$qf->toHtml());
     ob_start();
     $th->display();
     $profiles_out = ob_get_clean();
     Libs_LeightboxCommon::display('crm_filters', $profiles_out, __('Perspective'), true);
     if (!isset($_SESSION['client']['filter_' . Acl::get_user()]['desc'])) {
         CRM_FiltersCommon::set_profile('my');
     }
     //Base_ActionBarCommon::add('folder',__('Filters'),'class="lbOn" rel="crm_filters"',$this->get_module_variable('profile_desc',__('My records')));
     if (isset($_REQUEST['__location'])) {
         $in_use = CRM_FiltersCommon::$in_use === $_REQUEST['__location'];
     } else {
         $in_use = CRM_FiltersCommon::$in_use;
     }
     print '<a class="lbOn' . ($in_use ? '' : ' disabled') . ' button" rel="crm_filters">' . __('Perspective') . ': ' . '<b>' . $_SESSION['client']['filter_' . Acl::get_user()]['desc'] . '</b><div class="filter_icon_img"></div></a>';
 }
Пример #11
0
 public static function create_new_record_href($tab, $def, $id = 'none', $check_defaults = true, $multiple_defaults = false)
 {
     if ($multiple_defaults) {
         static $done = false;
         if ($done) {
             return Libs_LeightboxCommon::get_open_href('actionbar_rb_new_record');
         }
         eval_js_once('actionbar_rb_new_record_deactivate = function(){leightbox_deactivate(\'actionbar_rb_new_record\');}');
         $th = Base_ThemeCommon::init_smarty();
         $cds = array();
         foreach ($def as $k => $v) {
             $cds[] = array('label' => _V($k), 'open' => '<a OnClick="actionbar_rb_new_record_deactivate();' . Module::create_href_js(self::get_new_record_href($tab, $v['defaults'], $id, $check_defaults)) . '">', 'icon' => $v['icon'], 'close' => '</a>');
         }
         $th->assign('custom_defaults', $cds);
         ob_start();
         Base_ThemeCommon::display_smarty($th, 'Utils_RecordBrowser', 'new_record_leightbox');
         $panel = ob_get_clean();
         Libs_LeightboxCommon::display('actionbar_rb_new_record', $panel, __('New record'));
         $done = true;
         return Libs_LeightboxCommon::get_open_href('actionbar_rb_new_record');
     } else {
         return Module::create_href(self::get_new_record_href($tab, $def, $id, $check_defaults));
     }
 }
Пример #12
0
 public static function QFfield_duration(&$form, $field, $label, $mode, $default, $desc)
 {
     if ($mode == 'add' || $mode == 'edit') {
         $dur = array(-1 => '---', 300 => __('5 minutes'), 900 => __('15 minutes'), 1800 => __('30 minutes'), 2700 => __('45 minutes'), 3600 => __('1 hour'), 7200 => __('2 hours'), 14400 => __('4 hours'), 28800 => __('8 hours'));
         if (isset($dur[$default])) {
             $duration_switch = '1';
         } else {
             $duration_switch = '0';
         }
         $form->addElement('select', $field, $label, $dur, array('id' => $field));
         $time_format = Base_RegionalSettingsCommon::time_12h() ? 'h:i a' : 'H:i';
         $lang_code = Base_LangCommon::get_lang_code();
         $form->addElement('timestamp', 'end_time', __('End Time'), array('date' => false, 'format' => $time_format, 'optionIncrement' => array('i' => 5), 'language' => $lang_code, 'id' => 'end_time'));
         $form->addElement('hidden', 'duration_switch', $duration_switch, array('id' => 'duration_switch'));
         eval_js_once('crm_calendar_duration_switcher = function(x) {' . 'var sw = $(\'duration_switch\');' . 'if((!x && sw.value==\'0\') || (x && sw.value==\'1\')) {' . 'var end_b=$(\'crm_calendar_event_end_block\');if(end_b)end_b.hide();' . 'var dur_b=$(\'crm_calendar_duration_block\');if(dur_b)dur_b.show();' . 'sw.value=\'1\';' . '} else {' . 'var end_b=$(\'crm_calendar_event_end_block\');if(end_b)end_b.show();' . 'var dur_b=$(\'crm_calendar_duration_block\');if(dur_b)dur_b.hide();' . 'sw.value=\'0\';' . '}}');
         eval_js_once('crm_calendar_event_timeless = function(val) {' . 'var cal_style;' . 'var tdb=$(\'toggle_duration_button\');' . 'if(tdb==null) return;' . 'if(val){' . 'cal_style = \'none\';' . '}else{' . 'cal_style = \'\';' . '}' . 'var db = $(\'duration_end_date__data_\');' . 'if(db) db.style.display = cal_style;' . 'var ts = $(\'time_s\');' . 'if(ts) ts.style.display = cal_style;' . '}');
         $form->addElement('button', 'toggle', __('Toggle'), array('onclick' => 'crm_calendar_duration_switcher()', 'id' => 'toggle_duration_button', 'class' => 'button'));
         $form->addElement('checkbox', 'timeless', __('Timeless'), null, array('onClick' => 'crm_calendar_event_timeless(this.checked)', 'id' => 'timeless'));
         eval_js('crm_calendar_event_timeless($("timeless").checked)');
         eval_js('crm_calendar_duration_switcher(1)');
         $form->setDefaults(array('duration_switch' => $duration_switch));
         $form->setDefaults(array($field => $default));
         $form->setDefaults(array('timeless' => $default == -1 ? 1 : 0));
         if (class_exists('Utils_RecordBrowser') && isset(Utils_RecordBrowser::$last_record['time'])) {
             $form->setDefaults(array('end_time' => strtotime('+' . $default . ' seconds', Utils_RecordBrowser::$last_record['time'])));
         }
         $form->addFormRule(array('CRM_MeetingCommon', 'check_date_and_time'));
     } else {
         $form->addElement('checkbox', 'timeless', __('Timeless'));
         $form->setDefaults(array('timeless' => $default == -1 ? 1 : 0));
     }
     //messanger
     if ($mode == 'add') {
         eval_js_once('crm_calendar_event_messenger = function(v) {var mb=$("messenger_block");if(!mb)return;if(v)mb.show();else mb.hide();}');
         $form->addElement('select', 'messenger_before', __('Popup alert'), array(0 => __('on event start'), 900 => __('15 minutes before event'), 1800 => __('30 minutes before event'), 2700 => __('45 minutes before event'), 3600 => __('1 hour before event'), 2 * 3600 => __('2 hours before event'), 3 * 3600 => __('3 hours before event'), 4 * 3600 => __('4 hours before event'), 8 * 3600 => __('8 hours before event'), 12 * 3600 => __('12 hours before event'), 24 * 3600 => __('24 hours before event')));
         $form->addElement('textarea', 'messenger_message', __('Popup message'), array('id' => 'messenger_message'));
         $form->addElement('select', 'messenger_on', __('Alert'), array('none' => __('None'), 'me' => __('me'), 'all' => __('all selected employees')), array('onChange' => 'crm_calendar_event_messenger(this.value!="none");$("messenger_message").value=$("title").value;'));
         //			$form->addElement('checkbox','messenger_on',__('Alert me'),null,array('onClick'=>'crm_calendar_event_messenger(this.checked);$("messenger_message").value=$("event_title").value;'));
         eval_js('crm_calendar_event_messenger(' . ($form->exportValue('messenger_on') != 'none' && $form->exportValue('messenger_on') != '' ? 1 : 0) . ')');
         $form->registerRule('check_my_user', 'callback', array('CRM_MeetingCommon', 'check_my_user'));
         $form->addRule(array('messenger_on', 'emp_id'), __('You have to select your contact to set alarm on it'), 'check_my_user');
     }
 }
Пример #13
0
 public static function client_messages_frame()
 {
     static $printed = null;
     if ($printed) {
         return '';
     }
     $printed = true;
     $content = self::format_client_messages();
     $hide_all = __('Hide messages');
     $show_all = __('Show messages');
     $show_discarded = __('Show discarded');
     $discard = __('Discard');
     eval_js_once('var ess_client_messages_hide_button_label = ' . json_encode($hide_all) . '; var ess_client_messages_show_button_label = ' . json_encode($show_all) . '; var ess_client_messages_discard_label = ' . json_encode($discard));
     $buttons = "<div class=\"button\" style=\"width:auto; padding:2px 10px\" id=\"client_messages_frame_hide\">{$hide_all}</div>" . "<div class=\"button\" style=\"width:auto; padding:2px 10px\" id=\"client_messages_frame_show_discarded\">{$show_discarded}</div>";
     load_js('modules/Base/EssClient/messages_hiding.js');
     eval_js('set_client_messages_frame_id("client_messages_frame");');
     return '<div id="client_messages_frame"><div id="client_messages_frame_content">' . $content . '</div>' . $buttons . '</div>';
 }
Пример #14
0
 public static function load_js()
 {
     self::load_cache();
     load_js('modules/Utils/CurrencyField/currency.js');
     $currencies = Utils_CurrencyFieldCommon::get_all_currencies();
     $js = 'Utils_CurrencyField.currencies=new Array();';
     foreach ($currencies as $k => $v) {
         $symbol = Utils_CurrencyFieldCommon::get_symbol($k);
         $position = Utils_CurrencyFieldCommon::get_symbol_position($k);
         $curr_format = '-?([0-9]*)\\' . Utils_CurrencyFieldCommon::get_decimal_point($k) . '?[0-9]{0,' . Utils_CurrencyFieldCommon::get_precission($k) . '}';
         $js .= 'Utils_CurrencyField.currencies[' . $k . ']={' . '"decp":"' . Utils_CurrencyFieldCommon::get_decimal_point($k) . '",' . '"thop":"' . Utils_CurrencyFieldCommon::get_thousand_point($k) . '",' . '"symbol_before":"' . ($position ? $symbol : '') . '",' . '"symbol_after":"' . (!$position ? $symbol : '') . '",' . '"dec_digits":' . Utils_CurrencyFieldCommon::get_precission($k) . ',' . '"regex":' . json_encode($curr_format) . '};';
     }
     eval_js_once($js);
 }
Пример #15
0
			ob_end_clean();
			DB::Execute('UPDATE utils_messenger_users SET follow=1 WHERE message_id=%d AND user_login_id=%d',array($row['id'],$row['user_login_id']));

			$mail = Base_User_SettingsCommon::get('Utils_Messenger','mail');
			if($mail) {
				$msg = __('Alert on: %s',array(Base_RegionalSettingsCommon::time2reg($row['alert_on'],2)))."\n".$fret."\n".($row['message']?__('Alarm comment: %s',array($row['message'])):'');
				Base_MailCommon::send($mail,'Alert!',$msg);
			}
			Acl::set_user();
		}
		
		return '';
	}

    public static function menu() {
		if (Base_AclCommon::check_permission('Messenger Alerts'))
			return array(_M('Messenger Alerts')=>array(
				'__function__'=>'browse'));
		return array();
	}
	
	public static function turn_off($id) {
	    DB::Execute('UPDATE utils_messenger_users SET done=1,done_on=%T WHERE user_login_id=%d AND message_id=%d',array(time(),Acl::get_user(),$id));
	}
}

eval_js_once('utils_messenger_on = true; utils_messenger_refresh = function(){'.
			'if(utils_messenger_on) new Ajax.Request(\'modules/Utils/Messenger/refresh.php\',{method:\'get\'});'.
			'};setInterval(\'utils_messenger_refresh()\',180000);utils_messenger_refresh()');

?>
Пример #16
0
	/**
	 * Displays the table.
	 *
	 * @param string template file that should be used to display the table, use Base_ThemeCommon::get_template_filename() for proper filename
	 * @param bool enabling paging, true by default
	 */
	public function body($template=null,$paging=true){
		if(!$this->columns) trigger_error('columns array empty, please call set_table_columns',E_USER_ERROR);
		$md5_id = md5($this->get_path());
		$this->set_module_variable('first_display','done');
		$theme = $this->init_module('Base/Theme');
		$per_page = $this->get_module_variable('per_page');
		$order = $this->get_module_variable('order');
        $this->expandable = $this->get_module_variable('expandable',$this->expandable);
        $expand_action_only = false;
        if ($this->expandable) {
            if(!$this->en_actions) {
                $expand_action_only = true;
                $this->en_actions = true;
            }
        }
		if ($this->en_actions) $actions_position = Base_User_SettingsCommon::get('Utils/GenericBrowser','actions_position');

		$ch_adv_search = $this->get_unique_href_variable('adv_search');
		if (isset($ch_adv_search)) {
			$this->set_module_variable('adv_search',$ch_adv_search);
			$this->set_module_variable('search',array());
			location(array());
		}

		$search = $this->get_module_variable('search');

		$renderer = new HTML_QuickForm_Renderer_TCMSArraySmarty();
		$form_p = $this->init_module('Libs/QuickForm');
		$pager_on = false;
		if(isset($this->rows_qty) && $paging) {
			if(!$this->forced_per_page) {
				$form_p->addElement('select','per_page',__('Number of rows per page'), Utils_GenericBrowserCommon::$possible_vals_for_per_page, 'onChange="'.$form_p->get_submit_form_js(false).'"');
				$form_p->setDefaults(array('per_page'=>$per_page));
			}
			$qty_pages = ceil($this->rows_qty/$this->per_page);
			if ($qty_pages<=25) {
					$pages = array();
				if($this->rows_qty==0)
					$pages[0] = 1;
				else
					foreach (range(1, $qty_pages) as $v) $pages[$v] = $v;
				$form_p->addElement('select','page',__('Page'), $pages, 'onChange="'.$form_p->get_submit_form_js(false).'"');
				$form_p->setDefaults(array('page'=>(int)(ceil($this->offset/$this->per_page)+1)));
			} else {
				$form_p->addElement('text','page',__('Page (%s to %s)', array(1,$qty_pages)), array('onclick'=>'this.focus();this.select();', 'onChange'=>$form_p->get_submit_form_js(false), 'style'=>'width:'.(7*strlen($qty_pages)).'px;'));
				$form_p->setDefaults(array('page'=>(int)(ceil($this->offset/$this->per_page)+1)));
			}
			$pager_on = true;
		}
		$search_on=false;
		if(!$this->is_adv_search_on()) {
			foreach($this->columns as $k=>$v)
				if (isset($v['search'])) {
					$this->form_s->addElement('text','search',__('Keyword'), array('id'=>'gb_search_field', 'placeholder'=>__('search keyword...'), 'x-webkit-speech'=>'x-webkit-speech', 'lang'=>Base_LangCommon::get_lang_code(), 'onwebkitspeechchange'=>$this->form_s->get_submit_form_js()));
					$this->form_s->setDefaults(array('search'=>isset($search['__keyword__'])?$search['__keyword__']:''));
					$search_on=true;
					break;
				}
		} else {
			$search_fields = array();
			if ($this->en_actions && $actions_position==0) $mov = 1;
			else $mov=0;
			foreach($this->columns as $k=>$v) {
				if(isset($v['display']) && !$v['display']) {
					$mov--;
					continue;
				}
				if (isset($v['search'])) {
					$this->form_s->addElement('hidden','search__'.$v['search'],'');
					$default = isset($search[$v['search']])?$search[$v['search']]:'';
					$this->form_s->setDefaults(array('search__'.$v['search']=>$default));
					$in = '<input value="'.$default.'" x-webkit-speech="x-webkit-speech" lang="'.Base_LangCommon::get_lang_code().'" name="search__textbox_'.$v['search'].'" placeholder="'.__('search keyword...').'" onblur="document.forms[\''.$this->form_s->getAttribute('name').'\'].search__'.$v['search'].'.value = this.value;" onkeydown="if (event.keyCode==13) {document.forms[\''.$this->form_s->getAttribute('name').'\'].search__'.$v['search'].'.value = this.value;'.$this->form_s->get_submit_form_js().';}" />';
					$search_fields[$k+$mov] = $in;
					$search_on=true;
				}
			}
			$theme->assign('search_fields', $search_fields);
		}
		if ($search_on) {
			$this->form_s->addElement('submit','submit_search',__('Search'), array('id'=>'gb_search_button'));
			if (Base_User_SettingsCommon::get($this->get_type(), 'show_all_button')) {
				$el = $this->form_s->addElement('hidden','show_all_pressed');
				$this->form_s->addElement('button','show_all',__('Show all'), array('onclick'=>'document.forms["'.$this->form_s->getAttribute('name').'"].show_all_pressed.value="1";'.$this->form_s->get_submit_form_js()));
				$el->setValue('0');
			}
		}
		if ($pager_on) {
			$form_p->accept($renderer);
			$form_array = $renderer->toArray();
			$theme->assign('form_data_paging', $form_array);
			$theme->assign('form_name_paging', $form_p->getAttribute('name'));

			// form processing
			if($form_p->validate()) {
				$values = $form_p->exportValues();
				if(isset($values['per_page'])) {
					$this->set_module_variable('per_page',$values['per_page']);
					Base_User_SettingsCommon::save('Utils/GenericBrowser','per_page',$values['per_page']);
				}
				if(isset($values['page']) && is_numeric($values['page']) && ($values['page']>=1 && $values['page']<=$qty_pages)) {
					$this->set_module_variable('offset',($values['page']-1)*$this->per_page);
				}
				location(array());
				return;
			}
		}
		if ($search_on) {
			$this->form_s->accept($renderer);
			$form_array = $renderer->toArray();
			$theme->assign('form_data_search', $form_array);
			$theme->assign('form_name_search', $this->form_s->getAttribute('name'));

			// form processing
			if($this->form_s->validate()) {
				$values = $this->form_s->exportValues();
				if (isset($values['show_all_pressed']) && $values['show_all_pressed']) {
					$this->set_module_variable('search',array());
					$this->set_module_variable('show_all_triggered',true);
					location(array());
					return;
				}
				$search = array();
				foreach ($values as $k=>$v){
					if ($k=='search') {
						if ($v!=__('search keyword...') && $v!='')
							$search['__keyword__'] = $v;
						break;
					}
					if (substr($k,0,8)=='search__') {
						$val = substr($k,8);
						if ($v!=__('search keyword...') && $v!='') $search[$val] = $v;
					}
				}
				$this->set_module_variable('search',$search);
				location(array());
				return;
			}
		}

		$headers = array();
		if ($this->en_actions) {
			$max_actions = 0; // Possibly improve it to calculate it during adding actions
			foreach($this->actions as $i=>$v) {
				$this_width = 0;
				foreach ($v as $vv) {
					$this_width += $vv['size'];
				}
				if ($this_width>$max_actions) $max_actions = $this_width;
			}
			if ($actions_position==0) $headers[-1] = array('label'=>'<span>'.'&nbsp;'.'</span>','attrs'=>'style="width: '.($max_actions*16+6).'px;" class="Utils_GenericBrowser__actions"');
			else $headers[count($this->columns)] = array('label'=>'<span>'.'&nbsp;'.'</span>','attrs'=>'style="width: '.($max_actions*16+6).'px;" class="Utils_GenericBrowser__actions"');
		}

		$all_width = 0;
		foreach($this->columns as $k=>$v) {
			if (!isset($this->columns[$k]['width'])) $this->columns[$k]['width'] = 100;
			if (!is_numeric($this->columns[$k]['width'])) continue;
			$all_width += $this->columns[$k]['width'];
			if (isset($v['quickjump'])) {
				$quickjump = $this->set_module_variable('quickjump',$v['quickjump']);
				$quickjump_col = $k;
			}
		}
		$i = 0;
		$is_order = false;
		$adv_history = Base_User_SettingsCommon::get('Utils/GenericBrowser','adv_history');
		foreach($this->columns as $v) {
			if (array_key_exists('display', $v) && $v['display']==false) {
				$i++;
				continue;
			}
			if(isset($v['order'])) $is_order = true;
			if(!isset($headers[$i])) $headers[$i] = array('label'=>'');
			if (!$adv_history && $v['name'] && $v['name']==$order[0]['column']) $label = '<span style="padding-right: 12px; margin-right: 12px; background-image: url('.Base_ThemeCommon::get_template_file('Utils_GenericBrowser','sort-'.strtolower($order[0]['direction']).'ending.png').'); background-repeat: no-repeat; background-position: right;">'.$v['name'].'</span>';
			else $label = $v['name'];
			$headers[$i]['label'] .= (isset($v['preppend'])?$v['preppend']:'').(isset($v['order'])?'<a '.$this->create_unique_href(array('change_order'=>$v['name'])).'>' . $label . '</a>':$label).(isset($v['append'])?$v['append']:'');
			//if ($v['search']) $headers[$i] .= $form_array['search__'.$v['search']]['label'].$form_array['search__'.$v['search']]['html'];
            if ($this->absolute_width) {
                 $headers[$i]['attrs'] = 'width="'.$v['width'].'" ';
            } elseif (!is_numeric($v['width'])) {
                $headers[$i]['attrs'] = 'style="width:'.$v['width'].'" ';
            } else {
                $headers[$i]['attrs'] = 'width="'.intval(100*$v['width']/$all_width).'%" ';
            }
			$headers[$i]['attrs'] .= 'nowrap="1" ';
			if (isset($v['attrs'])) $headers[$i]['attrs'] .= $v['attrs'].' ';
			$i++;
		}
		ksort($headers);
		$out_headers = array_values($headers);
		unset($headers);

		$out_data = array();

        if($this->expandable) {
            eval_js_once('gb_expandable["'.$md5_id.'"] = {};');
            eval_js_once('gb_expanded["'.$md5_id.'"] = 0;');

            eval_js_once('gb_expand_icon = "'.Base_ThemeCommon::get_template_file('Utils/GenericBrowser', 'expand.gif').'";');
            eval_js_once('gb_collapse_icon = "'.Base_ThemeCommon::get_template_file('Utils/GenericBrowser', 'collapse.gif').'";');
            eval_js_once('gb_expand_icon_off = "'.Base_ThemeCommon::get_template_file('Utils/GenericBrowser', 'expand_gray.gif').'";');
            eval_js_once('gb_collapse_icon_off = "'.Base_ThemeCommon::get_template_file('Utils/GenericBrowser', 'collapse_gray.gif').'";');
        }

		foreach($this->rows as $i=>$r) {
			$col = array();

            if($this->expandable) {
                $row_id =  $md5_id.'_'.$i;
                $this->__add_row_action($i,'style="display:none;" href="javascript:void(0)" onClick="gb_expand(\''.$md5_id.'\',\''.$i.'\')" id="gb_more_'.$row_id.'"','Expand', null, Base_ThemeCommon::get_template_file('Utils/GenericBrowser', 'plus_gray.png'), 1001);
                $this->__add_row_action($i,'style="display:none;" href="javascript:void(0)" onClick="gb_collapse(\''.$md5_id.'\',\''.$i.'\')" id="gb_less_'.$row_id.'"','Collapse', null, Base_ThemeCommon::get_template_file('Utils/GenericBrowser', 'minus_gray.png'), 1001, false, 0);
                $this->__add_row_js($i,'gb_expandable_init("'.Epesi::escapeJS($md5_id,true,false).'","'.Epesi::escapeJS($i,true,false).'")');
                if(!isset($this->row_attrs[$i])) $this->row_attrs[$i]='';
                $this->row_attrs[$i] .= 'id="gb_row_'.$row_id.'"';
            }

            if ($this->en_actions) {
				if ($actions_position==0) $column_no = -1;
				else $column_no = count($this->columns);
				$col[$column_no]['attrs'] = '';
				if (!empty($this->actions[$i])) {
					uasort($this->actions[$i], array($this,'sort_actions'));
					$actions = '';
					foreach($this->actions[$i] as $icon=>$arr) {
						$actions .= '<a '.Utils_TooltipCommon::open_tag_attrs($arr['tooltip']!==null?$arr['tooltip']:$arr['label'], $arr['tooltip']===null).' '.$arr['tag_attrs'].'>';
					    if ($icon=='view' || $icon=='delete' || $icon=='edit' || $icon=='info' || $icon=='restore' || $icon=='append data' || $icon=='active-on' || $icon=='active-off' || $icon=='history' || $icon=='move-down' || $icon=='move-up' || $icon=='history_inactive' || $icon=='print' || $icon == 'move-up-down') {
							$actions .= '<img class="action_button" src="'.Base_ThemeCommon::get_template_file('Utils/GenericBrowser',$icon.($arr['off']?'-off':'').'.png').'" border="0">';
					    } elseif(file_exists($icon)) {
							$actions .= '<img class="action_button" src="'.$icon.'" border="0">';
					    } else {
							$actions .= $arr['label'];
					    }
						$actions .= '</a>';
					}
					$col[$column_no]['label'] = $actions;
                    $col[$column_no]['attrs'] .= ' class="Utils_GenericBrowser__actions Utils_GenericBrowser__td"';

					// Add overflow_box to actions
					$settings = Base_User_SettingsCommon::get('Utils_GenericBrowser', 'zoom_actions');
					if ($settings==2 || ($settings==1 && detect_iphone()))
						$col[$column_no]['attrs'] .= ' onmouseover="if(typeof(table_overflow_show)!=\'undefined\')table_overflow_show(this,true);"';
				} else {
					$col[$column_no]['label'] = '&nbsp;';
                    $col[$column_no]['attrs'] .= 'nowrap="nowrap"'.' class="Utils_GenericBrowser__td"';
				}
				if (isset($this->no_actions[$i]))
					$col[$column_no]['attrs'] .= ' style="display:none;"';
			}
			foreach($r as $k=>$v) {
				if (is_array($v) && isset($v['dummy'])) $v['style'] = 'display:none;';
				if (array_key_exists('display',$this->columns[$k]) && $this->columns[$k]['display']==false) continue;
				if (is_array($v) && isset($v['attrs'])) $col[$k]['attrs'] = $v['attrs'];
				else $col[$k]['attrs'] = '';
				if ($this->absolute_width) $col[$k]['attrs'] .= ' width="'.$this->columns[$k]['width'].'"';
				if (!is_array($v)) $v = array('value'=>$v);
				$col[$k]['label'] = $v['value'];
				if (!isset($v['overflow_box']) || $v['overflow_box']) {
					$col[$k]['attrs'] .= ' onmouseover="if(typeof(table_overflow_show)!=\'undefined\')table_overflow_show(this);"';
				} else {
					if (!isset($v['style'])) $v['style'] = '';
					$v['style'] .= 'white-space: normal;';
				}
				$col[$k]['attrs'] .= ' class="Utils_GenericBrowser__td '.(isset($v['class'])?$v['class']:'').'"';
				$col[$k]['attrs'] .= isset($v['style'])? ' style="'.$v['style'].'"':'';
				if (isset($quickjump_col) && $k==$quickjump_col) $col[$k]['attrs'] .= ' class="Utils_GenericBrowser__quickjump"';
				if ((!isset($this->columns[$k]['wrapmode']) || $this->columns[$k]['wrapmode']!='cut') && isset($v['hint'])) $col[$k]['attrs'] .= ' title="'.$v['hint'].'"';
				$col[$k]['attrs'] .= (isset($this->columns[$k]['wrapmode']) && $this->columns[$k]['wrapmode']=='nowrap')?' nowrap':'';
				if ($all_width!=0)
        				$max_width = 130*$this->columns[$k]['width']/$all_width*(7+(isset($this->columns[$k]['fontsize'])?$this->columns[$k]['fontsize']:0));
        			else
        			        $max_width = 0;
				if (isset($this->columns[$k]['wrapmode']) && $this->columns[$k]['wrapmode']=='cut'){
					if (strlen($col[$k]['label'])>$max_width){
						if (is_array($v) && isset($v['hint'])) $col[$k]['attrs'] .= ' title="'.$col[$k]['label'].': '.$v['hint'].'"';
						else $col[$k]['attrs'] .= ' title="'.$col[$k]['label'].'"';
						$col[$k]['label'] = substr($col[$k]['label'],0,$max_width-3).'...';
					} elseif (is_array($v) && isset($v['hint'])) $col[$k]['attrs'] .= ' title="'.$v['hint'].'"';
					$col[$k]['attrs'] .= ' nowrap';
				}
			}
			ksort($col);
			$expanded = $this->expandable ? ' expanded' : '';
			foreach($col as $v)
				$out_data[] = array('label'=>'<div class="expandable'.$expanded.'">'.$v['label'].'</div>','attrs'=>$v['attrs']);
			if(isset($this->rows_jses[$i]))
				eval_js($this->rows_jses[$i]);
		}
		if (isset($quickjump)) {
			$quickjump_to = $this->get_module_variable('quickjump_to');
			$all = '<span class="all">'.__('All').'</span>';
			if (isset($quickjump_to) && $quickjump_to != '') $all = '<a class="all" '.$this->create_unique_href(array('quickjump_to'=>'')).'>'.__('All').'</a>';
			$letter_links = array(0 => $all);
			if ($quickjump_to != '0')
				$letter_links[] .= '<a class="all" '.$this->create_unique_href(array('quickjump_to'=>'0')).'>'.'123'.'</a>';
			else
				$letter_links[] .= '<span class="all">' . '123' . '</span>';
			$letter = 'A';
			while ($letter<='Z') {
				if ($quickjump_to != $letter)
					$letter_links[] .= '<a class="letter" '.$this->create_unique_href(array('quickjump_to'=>$letter)).'>'.$letter.'</a>';
				else
					$letter_links[] .= '<span class="letter">' . $letter . '</span>';
				$letter = chr(ord($letter)+1);
			}
			$theme->assign('letter_links', $letter_links);
			$theme->assign('quickjump_to', $quickjump_to);
		}

		$theme->assign('data', $out_data);
		$theme->assign('cols', $out_headers);

		$theme->assign('row_attrs', $this->row_attrs);

        $theme->assign('table_id','table_'.$md5_id);
        if($expand_action_only) {
            eval_js('gb_expandable_hide_actions("'.$md5_id.'")');
        }
		$theme->assign('table_prefix', $this->table_prefix);
		$theme->assign('table_postfix', $this->table_postfix);

		$theme->assign('summary', $this->summary());
		$theme->assign('first', $this->gb_first());
		$theme->assign('prev', $this->gb_prev());
		$theme->assign('next', $this->gb_next());
		$theme->assign('last', $this->gb_last());
		$theme->assign('custom_label', $this->custom_label);
		$theme->assign('custom_label_args', $this->custom_label_args);

        if($this->expandable) {
            $theme->assign('expand_collapse',array(
                'e_label'=>__('Expand All'),
                'e_href'=>'href="javascript:void(0);" onClick=\'gb_expand_all("'.$md5_id.'")\'',
                'e_id'=>'expand_all_button_'.$md5_id,
                'c_label'=>__('Collapse All'),
                'c_href'=>'href="javascript:void(0);" onClick=\'gb_collapse_all("'.$md5_id.'")\'',
                'c_id'=>'collapse_all_button_'.$md5_id
            ));
            $max_actions = isset($max_actions) ? $max_actions : 0;
            eval_js('gb_expandable_adjust_action_column("'.$md5_id.'", ' . $max_actions . ')');
            eval_js('gb_show_hide_buttons("'.$md5_id.'")');
        }

		if ($search_on) $theme->assign('adv_search','<a id="switch_search_'.($this->is_adv_search_on()?'simple':'advanced').'" class="button" '.$this->create_unique_href(array('adv_search'=>!$this->is_adv_search_on())).'>' . ($this->is_adv_search_on()?__('Simple Search'):__('Advanced Search')) . '&nbsp;&nbsp;&nbsp;<img src="' . Base_ThemeCommon::get_template_file($this -> get_type(), 'advanced.png') . '" width="8px" height="20px" border="0" style="vertical-align: middle;"></a>');
		else $theme->assign('adv_search','');

		if (Base_User_SettingsCommon::get('Utils/GenericBrowser','adv_history') && $is_order){
			$theme->assign('reset', '<a '.$this->create_unique_href(array('action'=>'reset_order')).'>'.__('Reset Order').'</a>');
			$theme->assign('order',$this->get_module_variable('order_history_display'));
		}
		$theme->assign('id',md5($this->get_path()));
		
		if ($this->resizable_columns) {
			load_js($this->get_module_dir().'js/col_resizable.js');
				
			$fixed_col_setting = !empty($this->fixed_columns_selector)? ', skipColumnClass:"'.$this->fixed_columns_selector.'"':'';
			eval_js('jq("#table_'.$md5_id.'").colResizable({liveDrag:true, postbackSafe:true, partialRefresh:true'.$fixed_col_setting.'});');
		}
		
		if(isset($template))
			$theme->display($template,true);
		else
			$theme->display();
		$this->set_module_variable('show_all_triggered',false);
	}
Пример #17
0
 /**
  * For internal use only.
  */
 public static function load($lang_code = null)
 {
     global $translations;
     global $custom_translations;
     self::$lang_code = $lang_code;
     if ($lang_code === null) {
         $lang_code = self::get_lang_code();
     }
     if (!$lang_code) {
         return;
     }
     $translations = array();
     $custom_translations = array();
     $file = DATA_DIR . '/Base_Lang/base/' . $lang_code . '.php';
     if (file_exists($file)) {
         include $file;
     }
     if (!is_array($translations)) {
         $translations = array();
     }
     $file = DATA_DIR . '/Base_Lang/custom/' . $lang_code . '.php';
     if (file_exists($file)) {
         include $file;
     }
     if (!is_array($custom_translations)) {
         $custom_translations = array();
     }
     self::$loaded = true;
     eval_js_once('Epesi.default_indicator="' . __('Loading...') . '";');
 }
Пример #18
0
 public function body($header = '', $params = array(), $add_disp = '', $big = true)
 {
     if (MOBILE_DEVICE) {
         return;
     }
     if (isset($_REQUEST['__location']) && $this->last_location != $_REQUEST['__location']) {
         $this->last_location = $_REQUEST['__location'];
         $this->leightbox_ready = false;
     }
     if (!$this->leightbox_ready) {
         if (!empty($params)) {
             $this->params = $params;
             $js = 'f' . $this->group . '_set_params = function(arg' . implode(',arg', array_keys($params)) . '){';
             foreach ($params as $k => $v) {
                 $js .= 'els=document.getElementsByName(\'' . $this->group . '_' . $v . '\');';
                 $js .= 'i=0;while(i<els.length){els[i].value=arg' . $k . ';i++;}';
             }
             $js .= '}';
             eval_js($js);
         }
         $this->leightbox_ready = true;
         eval_js_once('f' . $this->group . '_prompt_deactivate = function(){leightbox_deactivate(\'' . $this->group . '_prompt_leightbox\');}');
         eval_js_once('f' . $this->group . '_show_form = function(arg){$(arg+\'_' . $this->group . '_form_section\').style.display=\'block\';$(\'' . $this->group . '_buttons_section\').style.display=\'none\';}');
         eval_js('$(\'' . $this->group . '_buttons_section\').style.display=\'' . (count($this->options) == 1 ? 'none' : 'block') . '\';');
         $buttons = array();
         $sections = array();
         foreach ($this->options as $k => $v) {
             $next_button = array('icon' => $v['icon'], 'label' => $v['label']);
             if ($v['form'] !== null) {
                 $form = $v['form'];
             } else {
                 $form = $this->options[$k]['form'] = $this->init_module(Libs_QuickForm::module_name());
             }
             if (!empty($params)) {
                 foreach ($params as $w) {
                     $form->addElement('hidden', $this->group . '_' . $w, 'none', array('id' => $this->group . '_' . $w));
                 }
             }
             if ($v['form'] !== null) {
                 $v['form']->addElement('button', 'cancel', __('Cancel'), array('id' => $this->group . '_lp_cancel', 'onclick' => count($this->options) == 1 ? 'f' . $this->group . '_prompt_deactivate();' : '$(\'' . $this->group . '_buttons_section\').style.display=\'block\';$(\'' . $k . '_' . $this->group . '_form_section\').style.display=\'none\';'));
                 $v['form']->addElement('submit', 'submit', __('OK'), array('id' => $this->group . '_lp_submit', 'onclick' => 'f' . $this->group . '_prompt_deactivate();'));
                 ob_start();
                 $th = $this->init_module(Base_Theme::module_name());
                 $v['form']->assign_theme('form', $th);
                 $th->assign('id', $this->get_instance_id());
                 $th->display('form');
                 $form_contents = ob_get_clean();
                 $next_button['open'] = '<a href="javascript:void(0);" onclick="f' . $this->group . '_show_form(\'' . $k . '\');">';
                 $sections[] = '<div id="' . $k . '_' . $this->group . '_form_section" style="display:none;">' . $form_contents . '</div>';
                 eval_js('$(\'' . $k . '_' . $this->group . '_form_section\').style.display=\'' . (count($this->options) != 1 ? 'none' : 'block') . '\';');
                 if ($v['form']->exportValue('submited') && !$v['form']->validate()) {
                     // open this selection
                     eval_js('f' . $this->get_group_key() . "_show_form('{$k}')");
                 }
             } else {
                 //                  $next_button['open'] = '<a '.$this->create_callback_href(array($this,'option_chosen'), array($k)).' onmouseup="f'.$this->group.'_prompt_deactivate();">';
                 $next_button['open'] = '<a href="javascript:void(0);" onmouseup="f' . $this->group . '_prompt_deactivate();' . $form->get_submit_form_js() . ';">';
                 $form->display();
             }
             $next_button['close'] = '</a>';
             $buttons[] = $next_button;
         }
         $theme = $this->init_module(Base_Theme::module_name());
         $theme->assign('open_buttons_section', '<div id="' . $this->group . '_buttons_section">');
         $theme->assign('buttons', $buttons);
         $theme->assign('sections', $sections);
         $theme->assign('additional_info', $add_disp);
         $theme->assign('close_buttons_section', '</div>');
         ob_start();
         $theme->display('leightbox');
         $profiles_out = ob_get_clean();
         Libs_LeightboxCommon::display($this->group . '_prompt_leightbox', $profiles_out, $header, $big);
     }
 }
Пример #19
0
        $def = array('default' => __('default server time (%s minutes)', array($time / 60)));
        if ($time < 1800) {
            $def['1800'] = __('30 minutes');
        }
        if ($time < 3600) {
            $def['3600'] = __('1 hour');
        }
        if ($time < 7200) {
            $def['7200'] = __('2 hours');
        }
        if ($time < 14400) {
            $def['14400'] = __('4 hours');
        }
        if ($time < 28800) {
            $def['28800'] = __('8 hours');
        }
        return array(__('Misc') => array(array('name' => 'time', 'label' => __('Keep session at least'), 'type' => 'select', 'values' => $def, 'default' => 28800, 'reload' => true)));
    }
}
load_js('modules/Tools/SessionKeeper/sk.js');
$sys_time = ini_get("session.gc_maxlifetime");
$interval = $sys_time / 3;
if (Acl::is_user()) {
    $time = Base_User_SettingsCommon::get('Tools/SessionKeeper', 'time');
    if ($time == 'default') {
        $time = $sys_time;
    }
    eval_js_once('SessionKeeper.maxtime=' . $time . ';' . 'SessionKeeper.interval=' . $interval . ';' . 'SessionKeeper.load()');
} else {
    eval_js_once('SessionKeeper.maxtime=201600;' . 'SessionKeeper.interval=' . $interval . ';' . 'SessionKeeper.load()');
}
Пример #20
0
    public static function QFfield_note(&$form, $field, $label, $mode, $default, $desc, $rb_obj) {
        load_js('modules/Utils/Attachment/attachments.js');

        if($rb_obj->record['crypted']) {
            if(!(isset($rb_obj->record['id']) && isset($_SESSION['client']['cp'.$rb_obj->record['id']])) && !(isset($rb_obj->record['clone_id']) && isset($_SESSION['client']['cp'.$rb_obj->record['clone_id']]))) {
                /*Epesi::alert(__('Note encrypted.'));
                $x = ModuleManager::get_instance('/Base_Box|0');
                if(!$x) trigger_error('There is no base box module instance',E_USER_ERROR);
                return $x->pop_main();*/
                $form->addElement('static', $field, $label);
                $txt = '<div id="note_value_'.$rb_obj->record['id'].'"><a href="javascript:void(0);" onclick="utils_attachment_password(\''.Epesi::escapeJS(__('Password').':').'\',\''.Epesi::escapeJS(__('OK')).'\','.$rb_obj->record['id'].',1)" style="color:red">'.__('Note encrypted').'</a></div>';
                $form->setDefaults(array($field=>$txt));
                return;
            } else {
                if(isset($rb_obj->record['id']) && isset($_SESSION['client']['cp'.$rb_obj->record['id']]))
                    $note_pass = $_SESSION['client']['cp'.$rb_obj->record['id']];
                else
                    $note_pass = $_SESSION['client']['cp'.$rb_obj->record['clone_id']];
                $decoded = Utils_AttachmentCommon::decrypt($default,$note_pass);
                if($decoded!==false) $default = $decoded;
                else {
                    Epesi::alert(__('Note encrypted.'));
                    $x = ModuleManager::get_instance('/Base_Box|0');
                    if(!$x) trigger_error('There is no base box module instance',E_USER_ERROR);
                    return $x->pop_main();
                }
            }
        }
        if ($mode=='add' || $mode=='edit') {

            $fck = $form->addElement('ckeditor', $field, $label);
            $fck->setFCKProps('99%','300',Base_User_SettingsCommon::get(self::Instance()->get_type(),'editor'));

            load_js('modules/Utils/Attachment/js/lib/plupload.js');
            load_js('modules/Utils/Attachment/js/lib/plupload.flash.js');
            load_js('modules/Utils/Attachment/js/lib/plupload.browserplus.js');
            load_js('modules/Utils/Attachment/js/lib/plupload.html4.js');
            load_js('modules/Utils/Attachment/js/lib/plupload.html5.js');
            if (!isset($_SESSION['client']['utils_attachment'][CID])) $_SESSION['client']['utils_attachment'][CID] = array('files'=>array());
            eval_js('Utils_Attachment__init_uploader("'.floor(self::max_upload_size()/1024/1024).'mb")');
//            eval_js('alert("'.self::max_upload_size().'")');
            eval_js_once('var Utils_Attachment__delete_button = "'.Base_ThemeCommon::get_template_file('Utils_Attachment', 'delete.png').'";');
            eval_js_once('var Utils_Attachment__restore_button = "'.Base_ThemeCommon::get_template_file('Utils_Attachment', 'restore.png').'";');
            eval_js('Utils_Attachment__submit_note = function() {'.$form->get_submit_form_js().'}');

            $del = $form->addElement('hidden', 'delete_files', null, array('id'=>'delete_files'));
            $add = $form->addElement('hidden', 'clipboard_files', null, array('id'=>'clipboard_files'));

            Libs_QuickFormCommon::add_on_submit_action('if(uploader.files.length){uploader.start();return;}');

            if(isset($rb_obj->record['id']))
                $files = DB::GetAssoc('SELECT id, original FROM utils_attachment_file uaf WHERE uaf.attach_id=%d AND uaf.deleted=0', array($rb_obj->record['id']));
            elseif(isset($rb_obj->record['clone_id']))
                $files = DB::GetAssoc('SELECT id, original FROM utils_attachment_file uaf WHERE uaf.attach_id=%d AND uaf.deleted=0', array($rb_obj->record['clone_id']));
            else $files = array();
            foreach($files as $id=>$name) {
                eval_js('Utils_Attachment__add_file_to_list("'.Epesi::escapeJS($name,true,false).'", null, '.$id.');');
            }

            $form->setDefaults(array($field=>$default));
        } else {
            $form->addElement('static', $field, $label);
            $form->setDefaults(array($field=>self::display_note($rb_obj->record,false,null,true)));
            if(class_exists('ZipArchive')) {
                $files = DB::GetOne('SELECT 1 FROM utils_attachment_file uaf WHERE uaf.attach_id=%d AND uaf.deleted=0', array($rb_obj->record['id']));
                if($files) Base_ActionBarCommon::add('download','Download all attachments','href="'.self::Instance()->get_module_dir().'get_all.php?id='.$rb_obj->record['id'].'&cid='.CID.'" target="_blank"');
            }
        }
    }
Пример #21
0
 public function chat($big = false, $uid = null)
 {
     $to =& $this->get_module_variable('to', "all");
     eval_js('shoutbox_uid="' . $to . '"');
     if (Base_AclCommon::is_user()) {
         //initialize HTML_QuickForm
         $qf = $this->init_module(Libs_QuickForm::module_name());
         /*            $myid = Base_AclCommon::get_user();
                 	if(Base_User_SettingsCommon::get('Apps_Shoutbox','enable_im')) {
                 	    $adm = Base_User_SettingsCommon::get_admin('Apps_Shoutbox','enable_im');
                 	    if(ModuleManager::is_installed('CRM_Contacts')>=0) {
                     	    $emps = DB::GetAssoc('SELECT l.id,IF(cd.f_last_name!=\'\',CONCAT(cd.f_last_name,\' \',cd.f_first_name,\' (\',l.login,\')\'),l.login) as name FROM user_login l LEFT JOIN contact_data_1 cd ON (cd.f_login=l.id AND cd.active=1) LEFT JOIN base_user_settings us ON (us.user_login_id=l.id AND module=\'Apps_Shoutbox\' AND variable=\'enable_im\') WHERE l.active=1 AND l.id!=%d AND (us.value=%s OR us.value is '.($adm?'':'not ').'null) ORDER BY name',array($myid,serialize(1)));			    
         		        } else
             		        $emps = DB::GetAssoc('SELECT l.id,l.login FROM user_login l LEFT JOIN base_user_settings us ON (us.user_login_id=l.id AND module=\'Apps_Shoutbox\' AND variable=\'enable_im\') WHERE l.active=1 AND l.id!=%d AND (us.value=%s OR us.value is '.($adm?'':'not ').'null) ORDER BY l.login',array($myid,serialize(1)));
             		} else $emps = array();
             		if(ModuleManager::is_installed('Tools_WhoIsOnline')>=0) {
             		    $online = Tools_WhoIsOnlineCommon::get_ids();
             		    foreach($online as $id) {
             		        if(isset($emps[$id])) 
             		            $emps[$id] = '* '.$emps[$id] ;
             		    }
             		}
                		$qf->addElement('select','to',__('To'),array('all'=>'['.__('All').']')+$emps,array('id'=>'shoutbox_to'.($big?'_big':''),'onChange'=>'shoutbox_uid=this.value;shoutbox_refresh'.($big?'_big':'').'()'));*/
         $myid = Base_AclCommon::get_user();
         if (Base_User_SettingsCommon::get('Apps_Shoutbox', 'enable_im') && ModuleManager::is_installed('Tools_WhoIsOnline') >= 0) {
             $adm = Base_User_SettingsCommon::get_admin('Apps_Shoutbox', 'enable_im');
             $online = Tools_WhoIsOnlineCommon::get_ids();
             if ($online) {
                 if (ModuleManager::is_installed('CRM_Contacts') >= 0) {
                     $emps = DB::GetAssoc('SELECT l.id,' . DB::Concat(DB::qstr("* "), DB::ifelse('cd.f_last_name!=\'\'', DB::concat('cd.f_last_name', DB::qstr(' '), 'cd.f_first_name', DB::qstr(' ('), 'l.login', DB::qstr(')')), 'l.login')) . ' as name FROM user_login l LEFT JOIN contact_data_1 cd ON (cd.f_login=l.id AND cd.active=1) LEFT JOIN base_user_settings us ON (us.user_login_id=l.id AND module=\'Apps_Shoutbox\' AND variable=\'enable_im\') WHERE l.active=1 AND l.id!=%d AND (us.value=%s OR us.value is ' . ($adm ? '' : 'not ') . 'null) AND l.id IN (' . implode(',', $online) . ') ORDER BY name', array($myid, serialize(1)));
                 } else {
                     $emps = DB::GetAssoc('SELECT l.id,' . DB::Concat(DB::qstr("* "), 'l.login') . ' FROM user_login l LEFT JOIN base_user_settings us ON (us.user_login_id=l.id AND module=\'Apps_Shoutbox\' AND variable=\'enable_im\') WHERE l.active=1 AND l.id!=%d AND (us.value=%s OR us.value is ' . ($adm ? '' : 'not ') . 'null) AND l.id IN (' . implode(',', $online) . ') ORDER BY l.login', array($myid, serialize(1)));
                 }
             } else {
                 $emps = array();
             }
         } else {
             $emps = array();
         }
         $e = $qf->addElement('autoselect', 'shoutbox_to', __('To'), array('all' => '[' . __('All') . ']') + $emps, array(array($this->get_type() . 'Common', 'user_search'), array()), array($this->get_type() . 'Common', 'user_format'));
         $e->setAttribute('id', 'shoutbox_to' . ($big ? '_big' : ''));
         $e->setAttribute('onChange', 'shoutbox_uid=this.value;shoutbox_refresh' . ($big ? '_big' : '') . '()');
         if (!Base_User_SettingsCommon::get('Apps_Shoutbox', 'enable_im')) {
             $qf->freeze(array('shoutbox_to'));
         }
         //create text box
         $qf->addElement($big ? 'textarea' : 'textarea', 'post', __('Message'), 'class="border_radius_6px" id="shoutbox_text' . ($big ? '_big' : '') . '"');
         $qf->addRule('post', __('Field required'), 'required');
         //create submit button
         $qf->addElement('submit', 'submit_button', __('Send'), 'id="shoutbox_button' . ($big ? '_big' : '') . '"');
         //add it
         $qf->setRequiredNote(null);
         $qf->setDefaults(array('shoutbox_to' => $to));
         $theme = $this->init_module(Base_Theme::module_name());
         $qf->assign_theme('form', $theme);
         //confirm when sending messages to all
         eval_js("jq('#shoutbox_button, #shoutbox_button_big').click(function() {\n      \t\t\t\t\tvar submit = true;\n\t\t    \t\t\tif (jq('#shoutbox_to').val() == 'all' && !confirm('" . __('Send message to all?') . "')) {\n         \t\t\t\t\tsubmit = false;\n      \t\t\t\t\t}\n\t\t    \n\t\t    \t\t\treturn submit;\t\t    \t\t\t\n\t\t\t\t\t});");
         //if submited
         if ($qf->validate()) {
             //get post group
             $msg = $qf->exportValue('post');
             $to = $qf->exportValue('shoutbox_to');
             //get msg from post group
             $msg = Utils_BBCodeCommon::optimize($msg);
             //get logged user id
             $user_id = Base_AclCommon::get_user();
             //clear text box and focus it
             eval_js('$(\'shoutbox_text' . ($big ? '_big' : '') . '\').value=\'\';focus_by_id(\'shoutbox_text' . ($big ? '_big' : '') . '\');shoutbox_uid="' . $to . '"');
             //insert to db
             DB::Execute('INSERT INTO apps_shoutbox_messages(message,base_user_login_id,to_user_login_id) VALUES(%s,%d,%d)', array(htmlspecialchars($msg, ENT_QUOTES, 'UTF-8'), $user_id, is_numeric($to) ? $to : null));
         }
     } else {
         print __('Please log in to post message') . '<br>';
         return;
     }
     $theme->assign('board', '<div id=\'shoutbox_board' . ($big ? '_big' : '') . '\'></div>');
     $theme->assign('header', __('Shoutbox'));
     $theme->display('chat_form' . ($big ? '_big' : ''));
     //if shoutbox is diplayed, call myFunctions->refresh from refresh.php file every 5s
     eval_js_once('shoutbox_refresh' . ($big ? '_big' : '') . ' = function(){if(!$(\'shoutbox_board' . ($big ? '_big' : '') . '\')) return;' . 'new Ajax.Updater(\'shoutbox_board' . ($big ? '_big' : '') . '\',\'modules/Apps/Shoutbox/refresh.php\',{method:\'get\', parameters: { uid: shoutbox_uid }});' . '};setInterval(\'shoutbox_refresh' . ($big ? '_big' : '') . '()\',' . ($big ? '10000' : '30000') . ')');
     eval_js('shoutbox_refresh' . ($big ? '_big' : '') . '()');
 }
Пример #22
0
 public function advanced_setup($store = false)
 {
     //create default module form
     $form = $this->init_module('Libs/QuickForm', 'Processing modules', 'setup');
     //install module header
     $form->addElement('header', 'mod_header', '<b>' . __('Please select modules to be installed/uninstalled.') . '<br>' . __('For module details please click on "i" icon.'));
     $module_dirs = $this->get_module_dirs();
     $structure = array();
     $def = array();
     $is_required = ModuleManager::required_modules(true);
     // transform is_required array to javascript
     eval_js('var deps = new Array(' . sizeof($is_required) . ');');
     foreach ($is_required as $k => $mod) {
         eval_js('deps["' . $k . '"] = new Array(' . sizeof($mod) . ');');
         $i = 0;
         foreach ($mod as $dep_mod) {
             eval_js('deps["' . $k . '"][' . $i++ . '] = "' . $dep_mod . '";');
         }
     }
     // javascript to show warning only once and cascade uninstall
     load_js('modules/Base/Setup/js/main.js');
     eval_js('var showed = false;');
     eval_js_once('var original_select = new Array(' . sizeof($is_required) . ');');
     eval_js_once('base_setup__reinstall_warning = \'' . __('Warning!\\nAll data in reinstalled modules will be lost.') . '\'');
     eval_js_once('base_setup__uninstall_warning = \'' . __('Warning! The following modules will be uninstalled. Are you sure you want to continue?') . '\'');
     foreach ($module_dirs as $entry => $versions) {
         $installed = ModuleManager::is_installed($entry);
         $module_install_class = $entry . 'Install';
         $func_info = array($module_install_class, 'info');
         $info = '';
         if (is_callable($func_info)) {
             $module_info = call_user_func($func_info);
             if ($module_info) {
                 $info = ' <a ' . Libs_LeightboxCommon::get_open_href($entry) . '><img style="vertical-align: middle; cursor: pointer;" border="0" width="14" height="14" src=' . Base_ThemeCommon::get_template_file('Base_Setup', 'info.png') . '></a>';
                 $iii = '<h1>' . str_replace('_', '/', $entry) . '</h1><table>';
                 foreach ($module_info as $k => $v) {
                     $iii .= '<tr><td>' . $k . '</td><td>' . $v . '</td></tr>';
                 }
                 $iii .= '</table>';
                 Libs_LeightboxCommon::display($entry, $iii, 'Additional info');
             }
         }
         // Show Tooltip if module is required
         $tooltip = null;
         if (isset($is_required[$entry])) {
             $tooltip = __('Required by:') . '<ul>';
             foreach ($is_required[$entry] as $mod_name) {
                 $tooltip .= '<li>' . $mod_name . '</li>';
             }
             $tooltip .= '</ul>';
         }
         $versions[-1] = 'not installed';
         ksort($versions);
         if ($installed != -1 && !isset($is_required[$entry])) {
             $versions[-2] = 'reinstall';
         }
         $path = explode('_', $entry);
         $c =& $structure;
         for ($i = 0, $path_count = count($path) - 1; $i < $path_count; $i++) {
             if (!array_key_exists($path[$i], $c)) {
                 $c[$path[$i]] = array();
                 $c[$path[$i]]['name'] = $path[$i];
                 $c[$path[$i]]['sub'] = array();
             }
             $c =& $c[$path[$i]]['sub'];
         }
         $params_arr = array('onChange' => "show_alert(this,'{$entry}');", 'style' => 'width: 100px');
         $ele = $form->createElement('select', 'installed[' . $entry . ']', $path[count($path) - 1], $versions, $params_arr);
         $ele->setValue($installed);
         eval_js("original_select[\"{$entry}\"] = {$installed}");
         $c[$path[count($path) - 1]] = array();
         $c[$path[count($path) - 1]]['name'] = '<table width="400px"><tr><td align=left>' . $info . ' ' . $path[count($path) - 1] . '</td><td width="100px" align=right ' . ($tooltip ? Utils_TooltipCommon::open_tag_attrs($tooltip, false) : '') . '>' . $ele->toHtml() . '</td></tr></table>';
         $c[$path[count($path) - 1]]['sub'] = array();
         array_push($def, array('installed[' . $entry . ']' => $installed));
     }
     $tree = $this->init_module('Utils/Tree');
     $tree->set_structure($structure);
     $tree->set_inline_display();
     //$form->addElement('html', '<tr><td colspan=2>'.$tree->toHtml().'</td></tr>');
     $form->addElement('html', '<tr><td colspan=2>' . $this->get_html_of_module($tree) . '</td></tr>');
     $form->setDefaults($def);
     //validation or display
     if ($form->exportValue('submited') && $form->validate()) {
         ob_start();
         if (!$this->validate($form->getSubmitValues())) {
             print ob_get_clean();
             print '<hr class="line"><center><a class="button"' . $this->create_href(array()) . '>Back</a></center>';
         } else {
             ob_end_clean();
             location(array());
         }
         return;
     }
     $form->display();
     Base_ActionBarCommon::add('save', __('Save'), $form->get_submit_form_href());
     if (!$store) {
         Base_ActionBarCommon::add('settings', __('Simple view'), $this->create_callback_href(array($this, 'switch_simple'), true));
     }
 }
Пример #23
0
 public function applet($conf, &$opts)
 {
     Epesi::load_js('modules/CRM/Roundcube/utils.js');
     $opts['go'] = true;
     $accounts = array();
     $ret = array();
     $update_applet = '';
     foreach ($conf as $key => $on) {
         $x = explode('_', $key);
         if ($x[0] == 'account' && $on) {
             $id = $x[1];
             $accounts[] = $id;
         }
     }
     $accs = Utils_RecordBrowserCommon::get_records('rc_accounts', array('epesi_user' => Acl::get_user(), 'id' => $accounts));
     print '<ul>';
     foreach ($accs as $row) {
         $mail = $row['account_name'];
         $cell_id = 'mailaccount_' . $opts['id'] . '_' . $row['id'];
         //interval execution
         eval_js_once('setInterval(\'CRM_RC.update_msg_num(' . $opts['id'] . ' ,' . $row['id'] . ' , 0)\',300000)');
         //and now
         $update_applet .= 'CRM_RC.update_msg_num(' . $opts['id'] . ' ,' . $row['id'] . ' ,1);';
         print '<li><i><a' . $this->create_callback_href(array($this, 'open_rc_account'), $row['id']) . '>' . $mail . '</a></i> - <span id="' . $cell_id . '"></span></li>';
     }
     print '</ul>';
     $this->js($update_applet);
     $href = $this->create_callback_href(array('Base_BoxCommon', 'push_module'), array($this->get_type(), 'account_manager', array(true)));
     $img = '<img src="' . Base_ThemeCommon::get_template_file('Base_Dashboard', 'configure.png') . '" border="0">';
     $tooltip = Utils_TooltipCommon::open_tag_attrs(__('Go to account settings'));
     $opts['actions'][] = "<a {$tooltip} {$href}>{$img}</a>";
 }
Пример #24
0
 public static function QFfield_smtp_auth(&$form, $field, $label, $mode, $default, $desc, $rb = null)
 {
     eval_js_once('var smtp_auth_change = function(val){if(val){$("smtp_login").enable();$("smtp_pass").enable();$("smtp_security").enable();}else{$("smtp_login").disable();$("smtp_pass").disable();$("smtp_security").disable();}}');
     $form->addElement('checkbox', $field, $label, '', array('onChange' => 'smtp_auth_change(this.checked)', 'id' => $field));
     $form->setDefaults(array($field => $default));
     eval_js('smtp_auth_change(' . ($default ? 1 : 0) . ')');
     if ($mode == 'view') {
         $form->freeze(array($field));
     }
 }