public static function menu() { if (Base_AclCommon::check_permission('Dashboard')) { return array(_M('Dashboard') => array()); } return array(); }
public static function menu() { if (Base_AclCommon::check_permission('Advanced User Settings')) { return array(_M('My settings') => array('__weight__' => 10, '__submenu__' => 1, _M('Control panel') => array())); } return array(); }
public static function menu() { if (!Acl::is_user() || !Base_AclCommon::check_permission('Fax - Browse')) { return array(); } return array(_M('CRM') => array('__submenu__' => 1, _M('Fax') => array())); }
public static function applet_caption() { if (!Base_AclCommon::check_permission('Calendar')) { return false; } return __('Agenda'); }
public static function applet_info() { if (Base_AclCommon::check_permission('Shoutbox')) { return __('Mini shoutbox'); } //here can be associative array return ''; }
public static function menu() { if (Base_AclCommon::check_permission('Dashboard')) { $tray_settings = Utils_TrayCommon::get_trays(); if (count($tray_settings) > 0) { return array(_M('Tray') => array('__icon__' => 'pile_small.png')); } } return array(); }
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(); } }
public function body() { if (!Base_AclCommon::check_permission('Dashboard')) { return; } $this->help('Dashboard Help', 'main'); if (Utils_RecordBrowserInstall::is_installed()) { //speed up links to RB if (Utils_RecordBrowserCommon::check_for_jump()) { return; } } $this->dashboard(); Base_ActionBarCommon::show_quick_access_shortcuts(true); }
public static function has_access_to_report($contact_record = null) { $has_permission = Base_AclCommon::check_permission('View Activity Report'); if ($contact_record === null && $has_permission) { return true; } if (isset($contact_record['login']) && $contact_record['login']) { if ($has_permission) { return true; } $id = isset($contact_record['id']) ? $contact_record['id'] : false; if (!$id) { return false; } $my_record = CRM_ContactsCommon::get_my_record(); return $id == $my_record['id']; } }
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'])); } }
public function body() { if (!Base_AclCommon::check_permission('View Activity Report')) { return; } $rb_tabs = DB::GetAssoc('SELECT tab, caption FROM recordbrowser_table_properties ORDER BY caption'); foreach ($rb_tabs as $k => $v) { $rb_tabs[$k] = Utils_RecordBrowserCommon::get_caption($k); } $form = $this->init_module('Libs/QuickForm'); $users_count = DB::GetOne('SELECT COUNT(id) FROM user_login') > Base_User_SettingsCommon::get('Utils_RecordBrowser', 'enable_autocomplete'); if ($users_count) { $crits = array('!login' => ''); $fcallback = array('CRM_ContactsCommon', 'contact_format_no_company'); $form->addElement('autoselect', 'user', __('User'), array(), array(array('CRM_ContactsCommon', 'autoselect_contact_suggestbox'), array($crits, $fcallback)), $fcallback); } else { $users = DB::GetAssoc('SELECT id, id FROM user_login'); foreach ($users as $k => $u) { $users[$k] = Base_UserCommon::get_user_label($u, true); } asort($users); $users = array('' => '[' . __('All') . ']') + $users; $form->addElement('select', 'user', __('User'), $users); } $form->addElement('multiselect', 'recordsets', __('Record Type'), $rb_tabs); $form->addElement('checkbox', 'new', __('New record')); $form->addElement('checkbox', 'edit', __('Record edit')); $form->addElement('checkbox', 'delete_restore', __('Record Delete/restore')); $form->addElement('checkbox', 'file', __('Files')); $form->addElement('datepicker', 'start_date', __('Start Date')); $form->addElement('datepicker', 'end_date', __('End Date')); //$form->addElement('submit', 'submit', __('Show')); Base_ActionBarCommon::add('search', __('Show'), $form->get_submit_form_href()); $filters = $this->get_module_variable('filters', array('user' => '', 'new' => 1, 'edit' => 1, 'delete_restore' => 1, 'recordsets' => array_keys($rb_tabs), 'start_date' => date('Y-m-01'), 'end_date' => date('Y-m-d'))); if ($form->validate()) { $filters = $form->exportValues(); $this->set_module_variable('filters', $filters); } $form->setDefaults($filters); $theme = $this->init_module('Base/Theme'); $form->assign_theme('form', $theme); $theme->display(); $filters['recordsets'] = array_flip($filters['recordsets']); foreach ($rb_tabs as $k => $v) { if (!isset($filters['recordsets'][$k])) { unset($rb_tabs[$k]); } } $gb = $this->init_module('Utils/GenericBrowser', null, 'activity_report'); $gb->set_table_columns(array(array('name' => __('Date'), 'width' => 40), array('name' => __('User'), 'width' => 40), array('name' => __('Type'), 'width' => 40), array('name' => __('Label')), array('name' => __('Actions taken'), 'width' => 40))); $tables = array(); if ($users_count) { $filters['user'] = CRM_ContactsCommon::get_contact($filters['user']); $filters['user'] = $filters['user']['login']; } $af_where = array(); foreach ($rb_tabs as $k => $t) { $af_where[] = 'ual.local ' . DB::like() . ' ' . DB::Concat(DB::qstr($k . '/'), DB::qstr('%')); } $af_where = count($af_where) ? ' (' . implode(' OR ', $af_where) . ')' : 'TRUE '; $e_where = array(); $c_where = ''; if ($filters['user']) { $e_where[] = ' edited_by = ' . $filters['user']; $c_where = ' created_by = ' . $filters['user']; $af_where .= ' AND uaf.created_by = ' . $filters['user']; } if (isset($filters['edit'])) { if (!isset($filters['delete_restore'])) { $e_where[] = ' ehd.field!=' . DB::qstr('id'); } } else { if (isset($filters['delete_restore'])) { $e_where[] = ' ehd.field=' . DB::qstr('id'); } } if ($filters['start_date']) { $date = DB::qstr(date('Y-m-d', strtotime($filters['start_date']))); $af_where .= ' AND uaf.created_on >= ' . $date; $c_where .= ($c_where ? ' AND' : '') . ' created_on >= ' . $date; $e_where[] = ' edited_on >= ' . $date; } if ($filters['end_date']) { $date = DB::qstr(date('Y-m-d 23:59:59', strtotime($filters['end_date']))); $af_where .= ' AND uaf.created_on <= ' . $date; $c_where .= ($c_where ? ' AND' : '') . ' created_on <= ' . $date; $e_where[] = ' edited_on <= ' . $date; } if (!empty($e_where)) { $e_where = ' WHERE' . implode(' AND', $e_where); } else { $e_where = ''; } if ($c_where) { $c_where = ' WHERE' . $c_where; } $postgre_cast_type = DB::is_postgresql() ? '::varchar' : ''; // **** files **** if (isset($filters['file'])) { $tables[] = 'SELECT uaf.id AS id,uaf.created_on AS edited_on,uaf.created_by AS edited_by, ual.local AS r_id, ' . DB::qstr('') . ' AS tab, ' . DB::qstr('file') . ' AS action FROM utils_attachment_file uaf INNER JOIN utils_attachment_data_1 ua ON uaf.attach_id=ua.id INNER JOIN utils_attachment_local ual ON ua.id=ual.attachment WHERE original!=' . DB::qstr('') . ' AND ' . $af_where; } // **** edit **** if (isset($filters['edit']) || isset($filters['delete_restore'])) { foreach ($rb_tabs as $k => $t) { $tables[] = 'SELECT id, edited_on, edited_by, ' . $k . '_id' . $postgre_cast_type . ' as r_id, ' . DB::qstr($k) . ' as tab, ' . DB::qstr('edit') . ' as action FROM ' . $k . '_edit_history eh LEFT JOIN ' . $k . '_edit_history_data ehd ON ehd.edit_id=eh.id' . $e_where; } } // **** create **** if (isset($filters['new'])) { foreach ($rb_tabs as $k => $t) { $tables[] = 'SELECT 0 AS id, created_on AS edited_on, created_by AS edited_by, id' . $postgre_cast_type . ' as r_id, ' . DB::qstr($k) . ' as tab, ' . DB::qstr('create') . ' as action FROM ' . $k . '_data_1' . $c_where; } } if (!empty($tables)) { $tables = implode(' UNION ', $tables); $limit = DB::GetOne('SELECT COUNT(*) FROM (' . $tables . ') AS tmp'); $limit = $gb->get_limit($limit); $ret = DB::SelectLimit('SELECT * FROM (' . $tables . ') AS tmp ORDER BY edited_on DESC', $limit['numrows'], $limit['offset']); while ($row = $ret->FetchRow()) { $user = Base_UserCommon::get_user_label($row['edited_by']); $action = ''; $link = ''; switch ($row['action']) { case 'edit': $details = DB::GetAssoc('SELECT field, old_value FROM ' . $row['tab'] . '_edit_history_data WHERE edit_id=%d', array($row['id'])); if (isset($details['id'])) { $action = $details['id'] == 'DELETED' ? __('Deleted') : __('Restored'); } else { $action = __('Edited'); $action = '<a ' . Utils_TooltipCommon::tooltip_leightbox_mode() . ' ' . Utils_TooltipCommon::ajax_open_tag_attrs(array('Utils_RecordBrowserCommon', 'get_edit_details_label'), array($row['tab'], $row['r_id'], $row['id']), 500) . '>' . $action . '</a>'; } $r_id = $row['r_id']; break; case 'create': $action = __('Created'); $r_id = $row['r_id']; break; case 'file': $action = __('Attachment') . ': '; $action .= $row['id'] == 0 ? __('New') : __('Updated'); $id = explode('/', $row['r_id']); $row['tab'] = $id[0]; $r_id = $id[1]; break; case 'note': $action = __('Note') . ': '; $action .= $row['id'] == 0 ? __('New') : __('Updated'); $id = explode('/', $row['r_id']); $row['tab'] = $id[0]; $r_id = $id[1]; break; } if (!Utils_RecordBrowserCommon::get_access($row['tab'], 'view', Utils_RecordBrowserCommon::get_record($row['tab'], $r_id))) { $link = __('Access restricted'); $action = strip_tags($action); } else { $link = Utils_TooltipCommon::create('<img src="' . Base_ThemeCommon::get_template_file('Utils_RecordBrowser', 'info.png') . '">', Utils_RecordBrowserCommon::get_html_record_info($row['tab'], $r_id), false); $link .= ' '; $link .= Utils_RecordBrowserCommon::create_default_linked_label($row['tab'], $r_id, false, false); } $gb->add_row(Base_RegionalSettingsCommon::time2reg($row['edited_on']), $user, $rb_tabs[$row['tab']], $link, $action); } } Base_ThemeCommon::load_css('Utils_RecordBrowser', 'changes_list'); $this->display_module($gb); }
public static function menu() { if (!Base_AclCommon::check_permission('Advanced User Settings')) { return array(_M('My settings') => array('__weight__' => 10, '__submenu__' => 1, _M('Change password') => array())); } }
public static function add_actionbar_change_subscription_button($category_name, $id = null) { if (!Base_AclCommon::check_permission('Watchdog - subscribe to categories')) { return; } $category_id = self::get_category_id($category_name); if (!$category_id) { return; } $href = self::get_change_subscr_href($category_name, $id); $subscribed = self::check_if_user_subscribes(Acl::get_user(), $category_id, $id); if ($subscribed) { $icon = Base_ThemeCommon::get_template_file('Utils_Watchdog', 'unwatch_big.png'); $label = __('Stop Watching'); } else { $icon = Base_ThemeCommon::get_template_file('Utils_Watchdog', 'watch_big.png'); $label = __('Watch'); } Base_ActionBarCommon::add($icon, $label, $href); }
public static function body_access() { return Base_AclCommon::check_permission('Manage Perspective'); }
public static function menu() { if (Base_AclCommon::check_permission('Messenger Alerts')) return array(_M('Messenger Alerts')=>array( '__function__'=>'browse')); return array(); }
public static function has_permission_to_manage_applets() { return Base_AclCommon::check_permission('Dashboard - manage applets'); }
public function file_history($attachment) { if ($this->is_back()) { $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(); } Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href()); $id = $attachment['id']; $tb =& $this->init_module(Utils_TabbedBrowser::module_name()); $tb->start_tab('File history'); $gb = $this->init_module(Utils_GenericBrowser::module_name(), null, 'hua' . $id); $gb->set_inline_display(); $gb->set_table_columns(array(array('name' => __('Deleted'), 'order' => 'deleted', 'width' => 10), array('name' => __('Date'), 'order' => 'upload_on', 'width' => 25), array('name' => __('Who'), 'order' => 'upload_by', 'width' => 25), array('name' => __('Attachment'), 'order' => 'uaf.original'))); $gb->set_default_order(array(__('Date') => 'DESC')); $ret = $gb->query_order_limit('SELECT uaf.id,uaf.deleted,uaf.filestorage_id,uaf.created_on as upload_on,uaf.created_by as upload_by,uaf.original FROM utils_attachment_file uaf WHERE uaf.attach_id=' . $id, 'SELECT count(*) FROM utils_attachment_file uaf WHERE uaf.attach_id=' . $id); while ($row = $ret->FetchRow()) { $r = $gb->get_new_row(); if ($row['deleted']) { $r->add_action($this->create_confirm_callback_href(__('Are you sure you want to restore attached file?'), array($this, 'restore_file'), array($row['id'])), 'restore', __('Restore')); } $view_link = ''; $lb = array(); $lb['aid'] = $id; $lb['crypted'] = $attachment['crypted']; $lb['original'] = $row['original']; $lb['id'] = $row['id']; $lb['filestorage_id'] = $row['filestorage_id']; $file = '<a ' . Utils_AttachmentCommon::get_file_leightbox($lb, $view_link) . '>' . $row['original'] . '</a>'; $r->add_data($row['deleted'] ? __('Yes') : __('No'), Base_RegionalSettingsCommon::time2reg($row['upload_on']), Base_UserCommon::get_user_label($row['upload_by']), $file); } $this->display_module($gb); $tb->end_tab(); $tb->start_tab('File access history'); $gb = $this->init_module(Utils_GenericBrowser::module_name(), null, 'hda' . $id); $gb->set_inline_display(); $gb->set_table_columns(array(array('name' => __('Create date'), 'order' => 'created_on', 'width' => 15), array('name' => __('Download date'), 'order' => 'download_on', 'width' => 15), array('name' => __('Who'), 'order' => 'created_by', 'width' => 15), array('name' => __('IP Address'), 'order' => 'ip_address', 'width' => 15), array('name' => __('Host Name'), 'order' => 'host_name', 'width' => 15), array('name' => __('Method description'), 'order' => 'description', 'width' => 20), array('name' => __('Remote'), 'order' => 'remote', 'width' => 10))); $gb->set_default_order(array(__('Create date') => 'DESC')); $query = 'SELECT uad.created_on,uad.download_on,(SELECT l.login FROM user_login l WHERE uad.created_by=l.id) as created_by,uad.remote,uad.ip_address,uad.host_name,uad.description FROM utils_attachment_download uad INNER JOIN utils_attachment_file uaf ON uaf.id=uad.attach_file_id WHERE uaf.attach_id=' . $id; $query_qty = 'SELECT count(*) FROM utils_attachment_download uad INNER JOIN utils_attachment_file uaf ON uaf.id=uad.attach_file_id WHERE uaf.attach_id=' . $id; if (Base_AclCommon::check_permission('Attachments - view full download history')) { $ret = $gb->query_order_limit($query, $query_qty); } else { print 'You are allowed to see your own downloads only'; $who = ' AND uad.created_by=' . Acl::get_user(); $ret = $gb->query_order_limit($query . $who, $query_qty . $who); } while ($row = $ret->FetchRow()) { $r = $gb->get_new_row(); $r->add_data(Base_RegionalSettingsCommon::time2reg($row['created_on']), $row['remote'] != 1 ? Base_RegionalSettingsCommon::time2reg($row['download_on']) : '', $row['created_by'], $row['ip_address'], $row['host_name'], $row['description'], $row['remote'] == 0 ? 'no' : 'yes'); } $this->display_module($gb); $tb->end_tab(); $this->display_module($tb); $this->caption = 'Note history'; return true; }
public function set_filters($rb, $display_tray_select = true, $filter_defaults = array()) { if(!Base_AclCommon::check_permission('Dashboard')) return; if($this->is_back()) { $x = ModuleManager::get_instance('/Base_Box|0'); if(!$x) trigger_error('There is no base box module instance',E_USER_ERROR); return $x->push_main('Utils_Tray'); } if (isset($_REQUEST['tray_slot'])) { Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href()); $this->set_module_variable('tray_slot', $_REQUEST['tray_slot']); } $tray_func = $this->parent->get_type().'Common::tray'; if (!is_callable($tray_func)) return; $settings = call_user_func($tray_func); if (!isset($settings[$rb->tab])) return; $slot_defs = Utils_TrayCommon::get_slots($rb->tab, $settings[$rb->tab]); Utils_TrayCommon::sort_trays($slot_defs); if ($display_tray_select) { $tray_slot_select_options = array('__NULL__'=>'---'); foreach ($slot_defs as $slot_id=>$slot_def) { $tray_slot_select_options[$slot_id] = _V($slot_def['__name__']); } $form = $this->init_module('Libs/QuickForm'); $form->addElement('select', 'tray_slot_select', __('Tray'), $tray_slot_select_options, array('style'=>'width: 130px','onchange'=>$form->get_submit_form_js())); if ($form->validate()) { $tray_slot = $form->exportValue('tray_slot_select'); $this->set_module_variable('tray_slot',$tray_slot); $rb->unset_module_variable('def_filter'); } } $tray_slot = $this->get_module_variable('tray_slot'); if (isset($slot_defs[$tray_slot]['__filters__'])) { $filters_changed = Utils_TrayCommon::are_filters_changed($slot_defs[$tray_slot]['__filters__']); } else { $filters_changed = true; } if (!isset($_REQUEST['__location']) && ($tray_slot!='__NULL__') && isset($tray_slot) && !$filters_changed){ $rb->set_additional_caption(_V($slot_defs[$tray_slot]['__name__'])); } else { $this->unset_module_variable('tray_slot'); $tray_slot='__NULL__'; } if ($display_tray_select) { $form->setDefaults(array('tray_slot_select'=>$tray_slot)); ob_start(); $form->display_as_row(); $html = ob_get_clean(); print('<div style="position: absolute;right:120px;">'.$html.'</div>'); } if (is_null($tray_slot) || $tray_slot=='__NULL__') { $rb->set_filters_defaults($filter_defaults); return; } $rb->disable_browse_mode_switch(); $rb->set_filters_defaults($slot_defs[$tray_slot]['__filters__']); }
public static function menu() { if (Base_AclCommon::check_permission('View Activity Report')) { return array(_M('Reports') => array_merge(array('__submenu__' => 1, _M('User Activity Report') => array()))); } }