Exemplo n.º 1
0
 public function admin()
 {
     if ($this->is_back()) {
         if ($this->parent->get_type() == 'Base_Admin') {
             $this->parent->reset();
         } elseif (Base_BoxCommon::main_module_instance()->get_type() == $this->get_type()) {
             Base_BoxCommon::pop_main();
         }
         return;
     }
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     $gb = $this->init_module(Utils_GenericBrowser::module_name(), null, 'rb_custom');
     $gb->set_table_columns(array(array('name' => __('Table')), array('name' => __('Caption')), array('name' => __('Menu Entry'))));
     $tabs = DB::GetAll('SELECT * FROM recordbrowser_custom_recordsets ORDER BY tab ASC');
     foreach ($tabs as $t) {
         $gbr = $gb->get_new_row();
         if (!$t['active']) {
             $gbr->add_action($this->create_callback_href(array($this, 'set_active'), array($t['id'], true)), 'Activate', null, 'active-off');
         } else {
             $gbr->add_action($this->create_callback_href(array($this, 'set_active'), array($t['id'], false)), 'Deactivate', null, 'active-on');
         }
         $gbr->add_action($this->create_callback_href(array($this, 'edit_rset'), array($t['id'])), 'edit');
         $table_name = $t['tab'];
         $table_href = $this->create_callback_href(array($this, 'manage_recordset'), array($table_name));
         $gbr->add_data("<a {$table_href}>{$table_name}</a>", Utils_RecordBrowserCommon::get_caption($t['tab']), str_replace(Utils_RecordBrowser_CustomRecordsetsCommon::$sep, ' -> ', $t['menu']));
     }
     Base_ActionBarCommon::add('new', __('Create new'), $this->create_callback_href(array($this, 'edit_rset')));
     $this->display_module($gb);
 }
Exemplo n.º 2
0
 public function applet($conf, &$opts)
 {
     $opts['go'] = false;
     $this->date = $this->get_module_variable_or_unique_href_variable('date');
     if ($this->date == null) {
         $this->date = date('Y-m-15');
     }
     $this->set_module_variable('date', $this->date);
     $this->date = strtotime($this->date);
     $theme = $this->pack_module('Base/Theme');
     $theme->assign('nextyear_href', $this->create_unique_href(array('date' => date('Y-m-15', $this->date + 30 * 24 * 60 * 60))));
     $theme->assign('today_href', $this->create_unique_href(array('date' => date('Y-m-d'))));
     $theme->assign('prevyear_href', $this->create_unique_href(array('date' => date('Y-m-15', $this->date - 30 * 24 * 60 * 60))));
     $link_text = $this->create_unique_href_js(array('date' => '__YEAR__-__MONTH__-__DAY__'));
     $theme->assign('popup_calendar', Utils_PopupCalendarCommon::show('week_selector', $link_text, 'month', null, null, ''));
     $day_headers = array();
     $day = strtotime('Sun');
     $day = strtotime('+' . Utils_PopupCalendarCommon::get_first_day_of_week() . ' days', $day);
     for ($i = 0; $i < 7; $i++) {
         $day_headers[] = __date('D', $day);
         $day = strtotime('+1 day', $day);
     }
     $year = array();
     $me = CRM_ContactsCommon::get_my_record();
     CRM_Calendar_EventCommon::$filter = '(' . $me['id'] . ')';
     $ret = call_user_func(array('CRM_Calendar_EventCommon', 'get_event_days'), date('Y-m-01', $this->date), date('Y-m-d', strtotime(date('Y-m-t', $this->date)) + 86400));
     $month = $this->month_array($this->date, $ret);
     $year[] = array('month' => $month, 'month_link' => Base_BoxCommon::create_href($this, 'CRM_Calendar', null, null, null, array('jump_to_date' => $this->date, 'switch_to_tab' => 'Month')), 'month_label' => __date('F', $this->date), 'year_label' => date('Y', $this->date));
     $theme->assign('year', $year);
     $theme->assign('day_headers', $day_headers);
     $theme->display('year');
 }
Exemplo n.º 3
0
 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());
         }
     }
 }
Exemplo n.º 4
0
 public function body()
 {
     if (!Base_AclCommon::i_am_user()) {
         print __('First log in to the system.');
         return;
     }
     $form = $this->init_module(Libs_QuickForm::module_name(), __('Saving settings'));
     //pass
     $form->addElement('header', null, __('Change password'));
     $form->addElement('html', '<tr><td colspan=2>' . __('Leave password boxes empty if you prefer your current password') . '</td></tr>');
     $form->addElement('password', 'new_pass', __('New password'));
     $form->addElement('password', 'new_pass_c', __('Confirm new password'));
     $form->addRule(array('new_pass', 'new_pass_c'), __('Your passwords don\'t match'), 'compare');
     $form->addRule('new_pass', __('Your password must be longer then 5 chars'), 'minlength', 6);
     //mail
     $form->addElement('header', null, __('Change e-mail'));
     $form->addElement('text', 'mail', __('New e-mail address'));
     $form->addRule('mail', __('Field required'), 'required');
     $form->addRule('mail', __('Invalid e-mail address'), 'email');
     //autologin
     $ret = DB::GetAll('SELECT autologin_id,description,last_log FROM user_autologin WHERE user_login_id=%d', array(Acl::get_user()));
     if ($ret) {
         $form->addElement('header', null, __('Delete autologin'));
     }
     foreach ($ret as $row) {
         $form->addElement('checkbox', 'delete_autologin[' . $row['autologin_id'] . ']', $row['description'], Base_RegionalSettingsCommon::time2reg($row['last_log']));
     }
     //confirmation
     $form->addElement('header', null, __('Confirmation'));
     $form->addElement('password', 'old_pass', __('Old password'));
     $form->registerRule('check_old_pass', 'callback', 'check_old_pass', $this);
     $form->addRule('old_pass', __('Old password incorrect'), 'check_old_pass');
     $form->addRule('old_pass', __('Field required'), 'required');
     if (Base_AclCommon::check_permission('Advanced User Settings')) {
         Base_ActionBarCommon::add('back', __('Back'), $this->create_main_href('Base_User_Settings'));
     }
     Base_ActionBarCommon::add('save', __('Save'), $form->get_submit_form_href());
     #$form->addElement('submit', 'submit_button', __('OK'));
     if ($form->validate_with_message('Setting saved', __('Problem encountered'))) {
         if ($form->process(array(&$this, 'submit_user_preferences'))) {
             if (Base_AclCommon::check_permission('Advanced User Settings')) {
                 Base_BoxCommon::location('Base_User_Settings');
             }
         }
     } else {
         //defaults
         $ret = DB::Execute('SELECT p.mail FROM user_password p  WHERE p.user_login_id=%d', Acl::get_user());
         if ($row = $ret->FetchRow()) {
             $form->setDefaults(array('mail' => $row[0]));
         }
         $form->display();
     }
 }
Exemplo n.º 5
0
 public function edit_permissions($permission_name = null)
 {
     if ($this->is_back()) {
         Base_BoxCommon::pop_main();
     }
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     Base_ThemeCommon::load_css('Base_Acl', 'edit_permissions');
     $gb = $this->init_module('Utils_GenericBrowser', 'acl_editor', 'acl_editor');
     $gb->set_table_columns(array(array('name' => '&nbsp;', 'width' => 20)));
     $sql = 'SELECT id, name FROM base_acl_permission';
     $args = array();
     $perm_id = null;
     if ($permission_name) {
         $sql .= ' WHERE name=%s';
         $args[] = $permission_name;
         $perm_id = DB::GetOne('SELECT id FROM base_acl_permission WHERE name=%s', array($permission_name));
     }
     $sql .= ' ORDER BY name ASC';
     $perms = DB::GetAssoc($sql, $args);
     Base_ActionBarCommon::add('add', __('Add rule'), $this->create_callback_href(array($this, 'edit_rule'), array(null, $perm_id)));
     foreach ($perms as $p_id => $p_name) {
         $gb_row = $gb->get_new_row();
         $gb_row->add_data(array('value' => _V($p_name), 'class' => 'Base_Acl__permission', 'attrs' => 'colspan="2"'));
         $gb_row->no_actions();
         $perms = DB::GetAssoc('SELECT id, id FROM base_acl_rules WHERE permission_id=%d', array($p_id));
         foreach ($perms as $r_id) {
             $clearances = DB::GetAssoc('SELECT id, clearance FROM base_acl_rules_clearance WHERE rule_id=%d', array($r_id));
             $gb_row = $gb->get_new_row();
             $gb_row->add_action($this->create_confirm_callback_href(__('Are you sure you want to delete this rule?'), array($this, 'delete_rule'), array($r_id)), 'delete', __('Delete Rule'));
             $gb_row->add_action($this->create_callback_href(array($this, 'edit_rule'), array($r_id, $p_id)), 'edit', __('Edit Rule'));
             $gb_row->add_data(Base_AclCommon::display_clearances($clearances));
         }
     }
     $this->display_module($gb);
     eval_js('base_acl__initialized = false;');
 }
Exemplo n.º 6
0
 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();
 }
Exemplo n.º 7
0
 public static function submit_meeting($values, $mode)
 {
     $me = CRM_ContactsCommon::get_my_record();
     switch ($mode) {
         case 'delete':
             Utils_MessengerCommon::delete_by_id('CRM_Calendar_Event:' . $values['id']);
             break;
         case 'display':
             $pdf = Utils_RecordBrowser::$rb_obj->pack_module('Libs/TCPDF', 'L');
             if ($pdf->prepare()) {
                 $pdf->set_title($values['title']);
                 $pdf->set_subject('');
                 $pdf->prepare_header();
                 $pdf->AddPage();
                 $v = CRM_Calendar_EventCommon::get(DB::GetOne('SELECT id FROM crm_calendar_custom_events_handlers WHERE group_name=%s', array('Meetings')) . '#' . $values['id']);
                 $ev_mod = Utils_RecordBrowser::$rb_obj->init_module('CRM/Calendar/Event');
                 $ev_mod->make_event_PDF($pdf, $v, true, 'view');
             }
             $pdf->add_actionbar_icon('Print');
             if (isset($_REQUEST['day'])) {
                 $values['date'] = $_REQUEST['day'];
             }
             $ret = array();
             if ($values['time']) {
                 // normal event
                 $start = $values['time'];
                 // time in unix timestamp UTC
                 $start_disp = strtotime(Base_RegionalSettingsCommon::time2reg($start, true, true, true, false));
             } else {
                 // when event is timeless - all day event
                 $time = $values['date'] . ' 00:00:01';
                 $start = Base_RegionalSettingsCommon::reg2time($time);
                 $start_disp = strtotime($time);
             }
             $end = strtotime('+' . $values['duration'] . ' seconds', $start);
             $ret['day_details'] = array('start' => array('day' => '<a ' . Base_BoxCommon::create_href(null, 'CRM/Calendar', 'body', array(array('default_view' => 'day', 'default_date' => strtotime($values['date']))), array()) . '>' . date('j', $start_disp) . '</a>', 'month' => '<a ' . Base_BoxCommon::create_href(null, 'CRM/Calendar', 'body', array(array('default_view' => 'month', 'default_date' => strtotime($values['date']))), array()) . '>' . __date('F', $start_disp) . '</a>', 'year' => '<a ' . Base_BoxCommon::create_href(null, 'CRM/Calendar', 'body', array(array('default_view' => 'year', 'default_date' => strtotime($values['date']))), array()) . '>' . date('Y', $start_disp) . '</a>', 'weekday' => '<a ' . Base_BoxCommon::create_href(null, 'CRM/Calendar', 'body', array(array('default_view' => 'week', 'default_date' => strtotime($values['date']))), array()) . '>' . __date('l', $start_disp) . '</a>'));
             if (!isset($values['timeless']) || !$values['timeless']) {
                 $ret['event_info'] = array('start_time' => Base_RegionalSettingsCommon::time2reg($start, 2, false), 'end_time' => Base_RegionalSettingsCommon::time2reg($end, 2, false), 'duration' => Base_RegionalSettingsCommon::seconds_to_words($values['duration']), 'start_date' => '-', 'end_date' => '-');
             }
             $ret['form_data']['timeless'] = array('label' => __('Timeless'), 'html' => 'value');
             $ret['toggle_duration'] = 'tog';
             $ret['duration_block_id'] = '1';
             $ret['event_end_block_id'] = '2';
             $values['title'] = __('Follow-up') . ': ' . $values['title'];
             $values['status'] = 0;
             $cus = reset($values['customers']);
             if (ModuleManager::is_installed('CRM/Meeting') >= 0) {
                 $ret['new']['event'] = '<a ' . Utils_TooltipCommon::open_tag_attrs(__('New Meeting')) . ' ' . Utils_RecordBrowserCommon::create_new_record_href('crm_meeting', array('title' => $values['title'], 'permission' => $values['permission'], 'priority' => $values['priority'], 'description' => $values['description'], 'date' => date('Y-m-d'), 'time' => date('H:i:s'), 'duration' => 3600, 'employees' => $values['employees'], 'customers' => $values['customers'], 'status' => 0), 'none', false) . '><img border="0" src="' . Base_ThemeCommon::get_template_file('CRM_Calendar', 'icon-small.png') . '" /></a>';
             }
             if (ModuleManager::is_installed('CRM/Tasks') >= 0) {
                 $ret['new']['task'] = '<a ' . Utils_TooltipCommon::open_tag_attrs(__('New Task')) . ' ' . Utils_RecordBrowserCommon::create_new_record_href('task', array('title' => $values['title'], 'permission' => $values['permission'], 'priority' => $values['priority'], 'description' => $values['description'], 'employees' => $values['employees'], 'customers' => $values['customers'], 'status' => 0, 'deadline' => date('Y-m-d', strtotime('+1 day')))) . '><img border="0" src="' . Base_ThemeCommon::get_template_file('CRM_Tasks', 'icon-small.png') . '"></a>';
             }
             if (ModuleManager::is_installed('CRM/PhoneCall') >= 0) {
                 $ret['new']['phonecall'] = '<a ' . Utils_TooltipCommon::open_tag_attrs(__('New Phonecall')) . ' ' . Utils_RecordBrowserCommon::create_new_record_href('phonecall', array('subject' => $values['title'], 'permission' => $values['permission'], 'priority' => $values['priority'], 'description' => $values['description'], 'date_and_time' => date('Y-m-d H:i:s'), 'employees' => $values['employees'], 'customer' => $cus, 'status' => 0), 'none', false) . '><img border="0" src="' . Base_ThemeCommon::get_template_file('CRM_PhoneCall', 'icon-small.png') . '" /></a>';
             }
             $ret['new']['note'] = Utils_RecordBrowser::$rb_obj->add_note_button('crm_meeting/' . $values['id']);
             return $ret;
         case 'edit':
             self::subscribed_employees($values);
             $alarms = Utils_MessengerCommon::get_alarms('CRM_Calendar_Event:' . $values['id']);
             $old = Utils_RecordBrowserCommon::get_record('crm_meeting', $values['id']);
             $old_time = strtotime($old['date'] . ' ' . date('H:i:s', strtotime($old['time'])));
             $new_time = strtotime($values['date'] . ' ' . date('H:i:s', strtotime($values['time'])));
             foreach ($alarms as $id => $time) {
                 $time = strtotime($time);
                 $diff = $old_time - $time;
                 Utils_MessengerCommon::update_time($id, $new_time - $diff);
             }
         case 'add':
             if (isset($values['duration_switch']) && !$values['duration_switch']) {
                 $values['duration'] = strtotime($values['end_time']) - strtotime($values['time']);
                 if ($values['duration'] < 0) {
                     $values['duration'] += 60 * 60 * 24;
                 }
                 // failsafe
             }
             if (isset($values['timeless']) && $values['timeless']) {
                 $values['duration'] = -1;
             }
             $new = '';
             foreach (array(0 => 'Mon', 1 => 'Tue', 2 => 'Wed', 3 => 'Thu', 4 => 'Fri', 5 => 'Sat', 6 => 'Sun') as $k => $v) {
                 if (isset($values['recurrence_hash_' . $k]) && $values['recurrence_hash_' . $k]) {
                     $new .= '1';
                 } else {
                     $new .= '0';
                 }
             }
             if ($new != '0000000') {
                 $values['recurrence_hash'] = $new;
             }
             if ($values['duration'] != -1) {
                 if (isset($values['modded'])) {
                     $time = Base_RegionalSettingsCommon::time2reg($values['time'], true, true, true, false);
                     $reg_timestamp = $values['date'] . ' ' . date('H:i:s', strtotime($time));
                     $timestamp = Base_RegionalSettingsCommon::reg2time($reg_timestamp);
                     $values['date'] = date('Y-m-d', $timestamp);
                     $values['time'] = date('Y-m-d H:i:s', $timestamp);
                     if (isset($values['recurrence_end']) && $values['recurrence_end']) {
                         $values['recurrence_end'] = date('Y-m-d', Base_RegionalSettingsCommon::reg2time($values['recurrence_end'] . ' ' . date('H:i:s', strtotime($time))));
                         if ($values['recurrence_end'] < $values['date']) {
                             $values['recurrence_end'] = $values['date'];
                         }
                         if ($values['recurrence_type'] == 8) {
                             $date = date('Y-m-d', strtotime('+6 days', strtotime($values['date'])));
                             if ($values['recurrence_end'] < $date) {
                                 $values['recurrence_end'] = $date;
                             }
                         }
                     }
                 }
             } else {
                 $values['time'] = '';
             }
             break;
         case 'adding':
             $values['permission'] = Base_User_SettingsCommon::get('CRM_Common', 'default_record_permission');
         case 'editing':
         case 'view':
             $values['modded'] = 1;
             if (!isset($values['date'])) {
                 $values['date'] = date('Y-m-d');
             }
             if (!isset($values['time'])) {
                 $values['time'] = time();
             }
             if (!isset($values['duration'])) {
                 $values['duration'] = 3600;
             }
             if (!is_numeric($values['time'])) {
                 $values['time'] = strtotime($values['time']);
             }
             if ($values['duration'] != -1) {
                 if (isset($values['date']) && $values['date']) {
                     $values['date'] = Base_RegionalSettingsCommon::time2reg($values['date'] . ' ' . date('H:i:s', $values['time']), false, true, true, false);
                     $values['time'] = Base_RegionalSettingsCommon::time2reg($values['date'] . ' ' . date('H:i:s', $values['time']), true, false, true, false);
                     $values['time'] = Base_RegionalSettingsCommon::reg2time($values['date'] . ' ' . $values['time']);
                 }
                 if (isset($values['recurrence_end']) && $values['recurrence_end']) {
                     $values['recurrence_end'] = Base_RegionalSettingsCommon::time2reg($values['recurrence_end'] . ' ' . date('H:i:s', $values['time']), false, true, true, false);
                 }
             }
             break;
         case 'added':
             if (isset($values['follow_up'])) {
                 CRM_FollowupCommon::add_tracing_notes($values['follow_up'][0], $values['follow_up'][1], $values['follow_up'][2], 'meeting', $values['id'], $values['title']);
             }
             self::subscribed_employees($values);
             $related = array_merge($values['employees'], $values['customers']);
             foreach ($related as $v) {
                 if ($mode === 'edit' && in_array($v, $old_related)) {
                     continue;
                 }
                 if (!is_numeric($v)) {
                     list($t, $id) = explode(':', $v);
                 } else {
                     $t = 'P';
                     $id = $v;
                 }
                 if ($t == 'P') {
                     $t = 'contact';
                 } else {
                     $t = 'company';
                 }
                 $subs = Utils_WatchdogCommon::get_subscribers($t, $id);
                 foreach ($subs as $s) {
                     Utils_WatchdogCommon::user_subscribe($s, 'crm_meeting', $values['id']);
                 }
             }
             if (isset($values['messenger_on']) && $values['messenger_on'] != 'none') {
                 $start = strtotime($values['date'] . ' ' . date('H:i:s', strtotime($values['time'])));
                 if ($values['messenger_on'] == 'me') {
                     Utils_MessengerCommon::add('CRM_Calendar_Event:' . $values['id'], 'CRM_Meeting', $values['messenger_message'], $start - $values['messenger_before'], array('CRM_MeetingCommon', 'get_alarm'), array($values['id']));
                 } else {
                     $eee = array();
                     foreach ($values['employees'] as $v) {
                         $c = CRM_ContactsCommon::get_contact($v);
                         if (isset($c['login'])) {
                             $eee[] = $c['login'];
                         }
                     }
                     Utils_MessengerCommon::add('CRM_Calendar_Event:' . $values['id'], 'CRM_Meeting', $values['messenger_message'], $start - $values['messenger_before'], array('CRM_MeetingCommon', 'get_alarm'), array($values['id']), $eee);
                 }
             }
             break;
     }
     return $values;
 }
Exemplo n.º 8
0
 public function mini()
 {
     if (!Base_AclCommon::check_permission('Search')) {
         return '';
     }
     $form = $this->init_module(Libs_QuickForm::module_name(), __('Searching'));
     $form->addElement('text', 'quick_search', __('Quick Search'), array('x-webkit-speech' => 'x-webkit-speech', 'lang' => Base_LangCommon::get_lang_code(), 'onwebkitspeechchange' => $form->get_submit_form_js()));
     $form->addElement('submit', 'quick_search_submit', __('Search'), array('class' => 'mini_submit'));
     $theme = $this->pack_module(Base_Theme::module_name());
     $theme->assign('submit_href', $form->get_submit_form_href());
     $theme->assign('submit_label', __('Search'));
     $form->assign_theme('form', $theme);
     $theme->assign('form_mini', 'yes');
     $theme->display('Search');
     if ($form->validate()) {
         $search = $form->exportValues();
         Base_BoxCommon::location('Base_Search', null, null, null, array('quick_search' => $search['quick_search']));
     }
 }
Exemplo n.º 9
0
 private static function _display_payments_for_order($order_id)
 {
     $orders = Base_EssClientCommon::server()->orders_list();
     if (isset($orders[$order_id])) {
         $o = $orders[$order_id];
         $keys = array_keys($o['price']);
         $currency = reset($keys);
         $value = $o['price'][$currency]['to_pay'];
         $main_module = Base_BoxCommon::main_module_instance();
         $store = $main_module->init_module(Base_EpesiStore::module_name());
         $main_module->display_module($store, array($o['id'], $value, $currency), 'form_payment_frame');
         return true;
     }
     return "No such order to perform payment.";
 }
Exemplo n.º 10
0
 public static function create_href_js($mod, $arr, $ret = 'js')
 {
     $main_mod = $arr['box_main_module'];
     unset($arr['box_main_module']);
     if (isset($arr['box_main_function'])) {
         $main_func = $arr['box_main_function'];
         unset($arr['box_main_function']);
     } else {
         $main_func = null;
     }
     if (isset($arr['box_main_arguments'])) {
         $main_args = $arr['box_main_arguments'];
         unset($arr['box_main_arguments']);
     } else {
         $main_args = null;
     }
     if (isset($arr['box_main_constructor_arguments'])) {
         $constr_args = $arr['box_main_constructor_arguments'];
         unset($arr['box_main_constructor_arguments']);
     } else {
         $constr_args = null;
     }
     switch ($ret) {
         case 'js':
             return $mod->create_main_href_js($main_mod, $main_func, $main_args, $constr_args, $arr);
         case 'href':
             return $mod->create_main_href($main_mod, $main_func, $main_args, $constr_args, $arr);
         case 'array':
             return array_merge($arr, Base_BoxCommon::create_href_array($mod, $main_mod, $main_func, $main_args, $constr_args));
     }
     return '';
 }
Exemplo n.º 11
0
 public function no_ssl_settings()
 {
     $f = $this->init_module("Libs/QuickForm");
     $f->addElement('checkbox', 'allow', 'Allow unsecure connection');
     Base_ActionBarCommon::add('back', __('Back'), Base_BoxCommon::pop_main_href());
     Base_ActionBarCommon::add('save', __('Save'), $f->get_submit_form_href());
     if ($f->validate()) {
         $x = $f->exportValues();
         $allow = false;
         if (isset($x['allow']) && $x['allow']) {
             $allow = true;
         }
         Base_EssClientCommon::set_no_ssl_allow($allow);
         Base_BoxCommon::pop_main();
         return;
     }
     $f->setDefaults(array('allow' => Base_EssClientCommon::is_no_ssl_allowed()));
     print '<div class="important_notice">';
     print __('Allowing unsecure connection will cause all the data to be transferred without encryption. This creates opportunity for third parties to capture the data being transmitted, including your License Key. Please note that License Key should be kept confidential and that using the same License Key on several EPESI installations is a direct violation of Terms of Service and will result in termination of the License Key.');
     print '<center>';
     $f->display();
     print '</center>';
     print '</div>';
 }
Exemplo n.º 12
0
    public static function submit_attachment($values, $mode) {
        static $new_values, $old_password;
        switch ($mode) {
            case 'browse':
                if (isset($values['id']) && isset($values['crypted']) && $values['crypted'] == false) {
                    // store to mark as read. Do not mark it here, because
                    // we won't get red eye in the table view
                    self::$mark_as_read[] = $values['id'];
                }
                return $values;
            case 'index':
                if($values['crypted']) unset($values['note']);
                return $values;
            case 'adding':
                $values['edited_on'] = time();
                return $values;
            case 'add':
            case 'edit':
                if(isset($values['__date'])) $values['edited_on'] = $values['__date'];
                else $values['edited_on'] = time();

                $crypted = 0;
                $old_pass = ($mode=='edit' && isset($_SESSION['client']['cp'.$values['id']]))?$_SESSION['client']['cp'.$values['id']]:($mode=='add' && isset($values['clone_id']) && isset($_SESSION['client']['cp'.$values['clone_id']])?$_SESSION['client']['cp'.$values['clone_id']]:'');
                if((is_array($values['crypted']) && isset($values['crypted']['crypted']) && $values['crypted']['crypted']) || (!is_array($values['crypted']) && $values['crypted'])) {
                    if(is_array($values['crypted']) && isset($values['crypted']['note_password'])) {
                        if($values['crypted']['note_password']=='*@#old@#*')
                            $values['crypted']['note_password'] = $old_pass;
                    }
                    $crypted = 1;
                }

                if(is_array($values['crypted']) && isset($values['crypted']['note_password']) && $mode=='edit' && $old_pass!=$values['crypted']['note_password']) {
                    //reencrypt old revisions
                    $old_notes = DB::GetAssoc('SELECT hd.edit_id,hd.old_value FROM utils_attachment_edit_history h INNER JOIN utils_attachment_edit_history_data hd ON h.id=hd.edit_id WHERE h.utils_attachment_id=%d AND hd.field="note"', array($values['id']));
                    foreach($old_notes as $old_id=>$old_note) {
                        if($old_pass!=='') $old_note = Utils_AttachmentCommon::decrypt($old_note,$old_pass);
                        if($old_note===false) continue;
                        if($crypted && $values['crypted']['note_password']) $old_note = Utils_AttachmentCommon::encrypt($old_note,$values['crypted']['note_password']);
                        if($old_note===false) continue;
                        DB::Execute('UPDATE utils_attachment_edit_history_data SET old_value=%s WHERE edit_id=%d AND field="note"',array($old_note,$old_id));
                    }
                    //file reencryption
                    $old_files = DB::GetCol('SELECT uaf.id as id FROM utils_attachment_file uaf WHERE uaf.attach_id=%d',array($values['id']));
                    foreach($old_files as $old_id) {
                        $filename = DATA_DIR.'/Utils_Attachment/'.$values['id'].'/'.$old_id;
                        $content = @file_get_contents($filename);
                        if($content===false) continue;
                        if($old_pass!=='') $content = Utils_AttachmentCommon::decrypt($content,$old_pass);
                        if($content===false) continue;
                        if($crypted && $values['crypted']['note_password']) $content = Utils_AttachmentCommon::encrypt($content,$values['crypted']['note_password']);
                        if($content===false) continue;
                        file_put_contents($filename,$content);
                    }
                }

                if($crypted) {
                    if(is_array($values['crypted']) && isset($values['crypted']['note_password'])) {
                        $values['note'] = Utils_AttachmentCommon::encrypt($values['note'],$values['crypted']['note_password']);
                        $values['note_password']=$values['crypted']['note_password'];
                    }
                    $values['crypted'] = 1;
                } else {
                    $values['crypted'] = 0;
                }
                $new_values = $values;

                break;
            case 'cloning':
                $values['clone_id']=$values['id'];
                break;
            case 'added':
                if(isset($values['local']))
                    DB::Execute('INSERT INTO utils_attachment_local(attachment,local,func,args) VALUES(%d,%s,%s,%s)',array($values['id'],$values['local'],$values['func'],$values['args']));
                $new_values = $values;
                break;
            case 'edit_changes':
                if(isset($values['note']) && isset($values['crypted']) && $new_values['crypted']!=$values['crypted']) {
                    if($new_values['crypted'] && isset($new_values['note_password'])) {
                        $values['note'] = Utils_AttachmentCommon::encrypt($values['note'],$new_values['note_password']);
                    } elseif(!$new_values['crypted'] && isset($_SESSION['client']['cp'.$new_values['id']])) {
                        $values['note'] = Utils_AttachmentCommon::decrypt($values['note'],$_SESSION['client']['cp'.$new_values['id']]);
                        unset($_SESSION['client']['cp'.$new_values['id']]);
                    }
                } elseif(isset($new_values['note_password']) && isset($old_password) && $new_values['note_password']!=$old_password) {
                    $values['note'] = Utils_AttachmentCommon::decrypt($values['note'],$old_password);
                    $values['note'] = Utils_AttachmentCommon::encrypt($values['note'],$new_values['note_password']);
                }
                break;
            case 'view':
                $ret = self::get_access($values['id']);
                if(!$ret) print(__('Access denied'));
                return $ret;
            case 'display':
                if(DB::GetOne('SELECT 1 FROM utils_attachment_file WHERE attach_id=%d',array($values['id']))) {
                    $ret = array();
                    $ret['new'] = array();
                    $ret['new']['crm_filter'] = '<a '.Utils_TooltipCommon::open_tag_attrs(__('File history')).' '.Module::create_href(array('file_history'=>1)).'>F</a>';
                    if (isset($_REQUEST['file_history']) && (!$values['crypted'] || isset($_SESSION['client']['cp'.$values['id']])))
                        Base_BoxCommon::push_module('Utils_Attachment','file_history',array($values));
                    //    CRM_FiltersCommon::set_profile('c'.$values['id']);
                    return $ret;
                }
                break;
            case 'delete':
                if($values['crypted'] && !isset($_SESSION['client']['cp'.$values['id']])) {
                    Epesi::alert(__('Cannot delete encrypted note'));
                    return false;
                }
                $count_locals = DB::GetOne('SELECT count(DISTINCT local) FROM utils_attachment_local WHERE attachment=%d',array($values['id']));
                if($count_locals>1) {
                    $is_local = false;
                    if(isset($_SESSION['client']['utils_attachment_group']))
                        $is_local = DB::GetOne('SELECT 1 FROM utils_attachment_local WHERE attachment=%d AND local=%s',array($values['id'],$_SESSION['client']['utils_attachment_group']));
                    if($is_local) {
                        DB::Execute('DELETE FROM utils_attachment_local WHERE attachment=%d AND local=%s',array($values['id'],$_SESSION['client']['utils_attachment_group']));
                        self::new_watchdog_event($_SESSION['client']['utils_attachment_group'], '-', $values['id']);
                    } else
                        Epesi::alert(__('This note is attached to multiple records - please go to record and delete note there.'));
                    location(array());
                    return false;
                } 
                location(array());
                return true;
        }
        switch($mode) {
            case 'edit':
            case 'added':
                if(isset($values['note_password'])) {
                    $old_password = isset($_SESSION['client']['cp' . $values['id']])
                        ? $_SESSION['client']['cp' . $values['id']] : '';
                    $_SESSION['client']['cp'.$values['id']] = $values['note_password'];
                }

                $note_id = $values['id'];
                $files_dir = self::Instance()->get_data_dir().$note_id;
                
                if(isset($values['delete_files']))
                    $deleted_files = array_filter(explode(';',$values['delete_files']));
                else
                    $deleted_files = array();
                foreach ($deleted_files as $k=>$v)
                    $deleted_files[$k] = intVal($v);
                if($deleted_files) $deleted_files = array_combine($deleted_files,$deleted_files);
                
                if($mode=='added' && isset($values['clone_id'])) { //on cloning
                    $locals = DB::Execute('SELECT local,func,args FROM utils_attachment_local WHERE attachment=%d',array($values['clone_id']));
                    while($local = $locals->FetchRow())
                        DB::Execute('INSERT INTO utils_attachment_local(attachment,local,func,args) VALUES(%d,%s,%s,%s)',array($note_id,$local['local'],$local['func'],$local['args']));
                    
                    $clone_files = DB::GetAll('SELECT id,original,created_by,created_on FROM utils_attachment_file uaf WHERE uaf.attach_id=%d AND uaf.deleted=0', array($values['clone_id']));
                    foreach($clone_files as $file) {
                        $cf = self::Instance()->get_data_dir().$values['clone_id'].'/'.$file['id'];
                        if(!file_exists($cf)) continue;
                        if(!file_exists($files_dir))
                            mkdir($files_dir,0777,true);

                        DB::Execute('INSERT INTO utils_attachment_file (attach_id,deleted,original,created_by,created_on) VALUES(%d,0,%s,%d,%T)',array($note_id,$file['original'],$file['created_by'],$file['created_on']));
                        $new_file_id = DB::Insert_ID('utils_attachment_file','id');
                        if(isset($deleted_files[$file['id']])) $deleted_files[$file['id']] = $new_file_id;

                        $cf2 = $files_dir.'/'.$new_file_id;
                        copy($cf,$cf2);
                        if(isset($_SESSION['client']['cp'.$values['clone_id']]) && $_SESSION['client']['cp'.$values['clone_id']])
                            file_put_contents($cf2,Utils_AttachmentCommon::decrypt(file_get_contents($cf2),$_SESSION['client']['cp'.$values['clone_id']]));
                        if($values['crypted'])
                            file_put_contents($cf2,Utils_AttachmentCommon::encrypt(file_get_contents($cf2),$values['note_password']));
                    }
                }

                $current_files = DB::GetAssoc('SELECT id, id FROM utils_attachment_file uaf WHERE uaf.attach_id=%d AND uaf.deleted=0', array($note_id));
                $remaining_files = $current_files;
                foreach ($deleted_files as $k=>$v) {
                    if (!isset($remaining_files[$v])) unset($deleted_files[$k]);
                    else unset($remaining_files[$v]);
                }
                foreach ($deleted_files as $v)
                    DB::Execute('UPDATE utils_attachment_file SET deleted=1 WHERE id=%d', array($v));

                if(isset($values['clipboard_files'])) {
                    $clipboard_files = array_filter(explode(';',$values['clipboard_files']));
                    foreach ($clipboard_files as $cf_id) {
                        $cf = DB::GetOne('SELECT filename FROM utils_attachment_clipboard WHERE id=%d', array($cf_id));
                        if($values['crypted'])
                            file_put_contents($cf,Utils_AttachmentCommon::encrypt(file_get_contents($cf),$values['note_password']));
                        Utils_AttachmentCommon::add_file($note_id, Acl::get_user(), __('clipboard').'.png', $cf);
                    }
                }

                $files = isset($_SESSION['client']['utils_attachment'][CID]['files'])?$_SESSION['client']['utils_attachment'][CID]['files']:array();
                $_SESSION['client']['utils_attachment'][CID]['files'] = array();
                foreach ($files as $f) {
                    $file_path = $f['path'];
                    $file_name = $f['name'];
                    if($values['crypted'])
                        file_put_contents($file_path,Utils_AttachmentCommon::encrypt(file_get_contents($file_path),$values['note_password']));
                    Utils_AttachmentCommon::add_file($note_id, Acl::get_user(), $file_name, $file_path);
                }

                $locals = DB::GetCol('SELECT local FROM utils_attachment_local WHERE attachment=%d',array($note_id));
                foreach ($locals as $local) {
                    $param = explode('/', $local);
                    if (count($param) == 2 && preg_match('/^[1-9][0-9]*$/', $param[1])) {
                        $subscribers = Utils_WatchdogCommon::get_subscribers($param[0], $param[1]);
                        foreach ($subscribers as $user_id) {
                            Utils_WatchdogCommon::user_subscribe($user_id, 'utils_attachment', $note_id);
                        }
                    }
                }

                break;
        }
        return $values;
    }
Exemplo n.º 13
0
 public static function update_version_check_indicator($force = false)
 {
     $version_no = __('version %s', array(EPESI_VERSION));
     if (CHECK_VERSION && Base_EpesiStoreInstall::is_installed()) {
         load_js('modules/Base/Box/check_for_new_version.js');
         if ($force) {
             eval_js('jq("#epesi_new_version").attr("done","0");');
         }
         eval_js('check_for_new_version();');
         $version_no = '<span id="epesi_new_version">' . Utils_TooltipCommon::create($version_no, __('Checking if there are updates available...'), false) . '</span>';
         if (isset($_REQUEST['go_to_epesi_store_for_updates'])) {
             Base_BoxCommon::push_module('Base_EpesiStore', 'admin');
             return;
         }
     }
     return $version_no;
 }
Exemplo n.º 14
0
 public static function QFfield_attachments(&$form, $field, $label, $mode, $default, $desc, $rb_obj)
 {
     if (isset($_GET['rc_reply']) || isset($_GET['rc_replyall']) || isset($_GET['rc_forward'])) {
         $attachments = DB::GetAssoc('SELECT mime_id,name FROM rc_mails_attachments WHERE mail_id=%d AND attachment=1', array($rb_obj->record['id']));
         $data = array();
         if ($attachments) {
             $hash = md5(time() . ' ' . serialize($rb_obj->record));
             DB::Execute('INSERT INTO rc_mails_attachments_download(mail_id,hash) VALUES(%d,%s)', array($rb_obj->record['id'], $hash));
             foreach ($attachments as $k => &$n) {
                 $filename = DATA_DIR . '/CRM_Roundcube/attachments/' . $rb_obj->record['id'] . '/' . $k;
                 if (file_exists($filename)) {
                     $data[] = '<a href="' . rtrim(get_epesi_url() . '/') . '/modules/CRM/Roundcube/get_remote.php?' . http_build_query(array('mime_id' => $k, 'mail_id' => $rb_obj->record['id'], 'hash' => $hash)) . '" target="_blank">' . $n . '</a>';
                 }
             }
         }
         $attachments = implode('<br />', $data);
     } else {
         $attachments = '';
     }
     if (isset($_GET['rc_reply']) && $_GET['rc_reply'] == $rb_obj->record['id']) {
         Base_BoxCommon::push_module('CRM_Roundcube', 'new_mail', array(html_entity_decode($rb_obj->record['from']), (preg_match('/^Re:/i', $rb_obj->record['subject']) ? '' : 'Re: ') . $rb_obj->record['subject'], '<br /><br /><strong>' . __('On %s wrote', array(Base_RegionalSettingsCommon::time2reg($rb_obj->record['date']) . ', ' . $rb_obj->record['from'])) . ':</strong><br/>' . $rb_obj->record['body'] . ($attachments ? '<hr /><strong>' . __('Attachments') . ':</strong><br/>' . $attachments : ''), $rb_obj->record['message_id'], html_entity_decode($rb_obj->record['references'])));
     } elseif (isset($_GET['rc_replyall']) && $_GET['rc_replyall'] == $rb_obj->record['id']) {
         $to = explode(',', $rb_obj->record['to']);
         $to[] = $rb_obj->record['from'];
         $mails = Utils_RecordBrowserCommon::get_records('rc_accounts', array('epesi_user' => Acl::get_user()), array('email'));
         foreach ($to as $k => $t) {
             $to[$k] = trim($t);
             foreach ($mails as $m) {
                 if (strpos($t, $m['email']) !== false) {
                     unset($to[$k]);
                     break;
                 }
             }
         }
         Base_BoxCommon::push_module('CRM_Roundcube', 'new_mail', array(html_entity_decode(implode(', ', $to)), (preg_match('/^Re:/i', $rb_obj->record['subject']) ? '' : 'Re: ') . $rb_obj->record['subject'], '<br /><br /><strong>' . __('On %s wrote', array(Base_RegionalSettingsCommon::time2reg($rb_obj->record['date']) . ', ' . $rb_obj->record['from'])) . ':</strong><br/>' . $rb_obj->record['body'] . ($attachments ? '<hr /><strong>' . __('Attachments') . ':</strong><br/>' . $attachments : ''), $rb_obj->record['message_id'], html_entity_decode($rb_obj->record['references'])));
     } elseif (isset($_GET['rc_forward']) && $_GET['rc_forward'] == $rb_obj->record['id']) {
         Base_BoxCommon::push_module('CRM_Roundcube', 'new_mail', array('', (preg_match('/^Re:/i', $rb_obj->record['subject']) ? '' : 'Re: ') . $rb_obj->record['subject'], '<br /><br /><strong>' . __('On %s wrote', array(Base_RegionalSettingsCommon::time2reg($rb_obj->record['date']) . ', ' . $rb_obj->record['from'])) . ':</strong><br/>' . $rb_obj->record['body'] . ($attachments ? '<hr /><strong>' . __('Attachments') . ':</strong><br/>' . $attachments : '')));
     }
     Base_ActionBarCommon::add('reply', __('Reply'), Module::create_href(array('rc_reply' => $rb_obj->record['id'])));
     Base_ActionBarCommon::add('reply', __('Reply All'), Module::create_href(array('rc_replyall' => $rb_obj->record['id'])));
     Base_ActionBarCommon::add('forward', __('Forward'), Module::create_href(array('rc_forward' => $rb_obj->record['id'])));
 }
Exemplo n.º 15
0
 public function change_email_header()
 {
     $adm = $this->init_module('Base_User_Administrator');
     $back = $adm->is_back();
     if ($back) {
         Base_BoxCommon::pop_main();
         return false;
     }
     $result = $this->display_module($adm, array(), 'change_email_header');
     print '<span style="display:none;">' . microtime(true) . '</span>';
     return true;
 }
Exemplo n.º 16
0
 protected function call($function, $params, $serialize_response = true)
 {
     self::log($function, $params, $serialize_response);
     $post_data = $this->build_query_post_data($function, $params, $serialize_response);
     $try_times = 3;
     while ($try_times--) {
         try {
             if ($this->secure_connection() == false) {
                 Base_EssClientCommon::add_client_message_warning("Used unsecure connection!");
             }
             $response = $this->request_server($post_data, !$serialize_response);
             return $this->return_response_value_handling_user_messages($serialize_response, $response);
         } catch (SecureConnectionException $e) {
             if (!Base_EssClientCommon::is_no_ssl_allowed()) {
                 try {
                     $main = Base_BoxCommon::main_module_instance();
                     $disable_link_href = $main->create_callback_href(array('Base_BoxCommon', 'push_module'), array('Base_EssClient', 'no_ssl_settings'));
                     $disable_msg = "<br/>Or disable secure connection here: <a {$disable_link_href}>SSL settings</a>";
                 } catch (Exception $e) {
                     $disable_msg = "<br/>Or disable secure connection";
                 }
                 Base_EssClientCommon::add_client_message_error($e->getMessage() . $disable_msg);
             } else {
                 $this->disable_secure_connection();
                 continue;
             }
         } catch (ErrorException $e) {
             Base_EssClientCommon::add_client_message_error($e->getMessage());
             return null;
         }
     }
     if (!$try_times) {
         Base_EssClientCommon::add_client_message_error("Connection try limit exceeded");
     }
 }
Exemplo n.º 17
0
 public function jump_to_epesi_registration()
 {
     Base_BoxCommon::push_module('Base_EssClient');
     return false;
 }
Exemplo n.º 18
0
 public function account_manager($pushed_on_top = false)
 {
     if ($pushed_on_top) {
         if ($this->is_back()) {
             Base_BoxCommon::pop_main();
             return;
         }
         Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     } else {
         Base_ActionBarCommon::add('back', __('Back'), $this->create_main_href('Base_User_Settings'));
     }
     $this->rb = $this->init_module('Utils/RecordBrowser', 'rc_accounts', 'rc_accounts');
     $this->rb->set_defaults(array('epesi_user' => Acl::get_user()));
     $order = array(array('login' => 'DESC'), array('epesi_user' => Acl::get_user()), array('epesi_user' => false));
     $this->display_module($this->rb, $order);
     // other settings
     $qf = $this->init_module('Libs/QuickForm');
     $qf->addElement('advcheckbox', 'standard_mailto', __("Use standard mailto links"), null, array('onchange' => $qf->get_submit_form_js()));
     $use_standard_mailto = CRM_RoundcubeCommon::use_standard_mailto();
     $qf->setDefaults(array('standard_mailto' => $use_standard_mailto));
     if ($qf->validate()) {
         CRM_RoundcubeCommon::set_standard_mailto($qf->exportValue('standard_mailto'));
     }
     $qf->display_as_row();
 }
Exemplo n.º 19
0
 public function body($branch = null, $admin_settings = false)
 {
     $branch = $this->get_module_variable_or_unique_href_variable('settings_branch', $branch);
     if ($branch !== null && $this->is_back()) {
         $branch = null;
     }
     if ($branch === null) {
         if ($this->is_back()) {
             if ($this->parent->get_type() == 'Base_Admin') {
                 $this->parent->reset();
             } else {
                 location(array());
             }
             return;
         }
         if ($this->parent->get_type() == 'Base_Admin') {
             Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
         }
     }
     $this->set_module_variable('settings_branch', $branch);
     $this->get_module_variable('admin_settings', $admin_settings);
     if (!$branch) {
         $x = ModuleManager::get_instance('/Base_Box|0');
         if (!$x) {
             trigger_error('There is no base box module instance', E_USER_ERROR);
         }
         $mains = $x->get_module_variable('main');
         if (count($mains) > 1) {
             $x->pop_main();
         } else {
             $this->main_page();
         }
         return;
     }
     $f = $this->init_module('Libs/QuickForm', __('Saving settings'), 'settings');
     $f->addElement('header', null, $branch);
     $this->indicator = ': ' . $branch;
     $this->settings_fields = array();
     $this->set_default_js = '';
     $us = ModuleManager::call_common_methods('user_settings');
     foreach ($us as $name => $menu) {
         if (!is_array($menu)) {
             continue;
         }
         foreach ($menu as $k => $v) {
             if ($k == $branch) {
                 if (is_string($v)) {
                     Base_BoxCommon::location($name, $v);
                 } else {
                     $this->add_module_settings_to_form($v, $f, $name);
                 }
             }
         }
     }
     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'), 'href="javascript:void(0)" onClick="' . $this->set_default_js . '"');
     if ($f->validate()) {
         $this->submit_settings($f->exportValues());
         $this->set_back_location();
     } else {
         $f->display();
     }
     return;
 }