public static function get_installed_applets_html() { $colors = Base_DashboardCommon::get_available_colors(); $app_cap = ModuleManager::call_common_methods('applet_caption'); asort($app_cap); $app_info = ModuleManager::call_common_methods('applet_info'); $html = ''; foreach ($app_cap as $name => $cap) { if (!$cap) { continue; } $th = Base_ThemeCommon::init_smarty(); $id = str_replace('_', '-', $name); if (!isset($app_info[$name])) { $app_info[$name] = ''; } $th->assign('content', '<div class="content" style="padding:4px;" id="dashboard_applet_content_' . $id . '">' . $app_info[$name] . '</div>'); $th->assign('handle_class', 'handle'); $th->assign('caption', $cap); $th->assign('color', $colors[0]['class']); $remove_button = Base_DashboardCommon::get_remove_applet_button($id, false); $th->assign('remove', $remove_button); $th->assign('__link', array('remove' => Base_ThemeCommon::parse_links('remove', $remove_button))); //print('<xmp>'.self::get_remove_applet_button(null, false).'</xmp><br>'); $th->assign('actions', array()); $th->assign('config_mode', true); $html .= '<div class="applet" searchkey="' . strtolower($cap ? $cap : $name) . ';' . strtolower($app_info[$name]) . '" id="ab_item_' . 'new_' . $id . '">'; ob_start(); Base_ThemeCommon::display_smarty($th, 'Base_Dashboard', 'default'); $html .= ob_get_clean(); $html .= '</div>'; } return $html; }
function mobile_menu() { $menus = ModuleManager::call_common_methods('mobile_menu'); global $menus_out, $menus_out_tmp; $menus_out = array(); foreach ($menus as $m => $r) { if (!is_array($r)) { continue; } foreach ($r as $cap => $met) { if (is_array($met)) { if (!isset($met['func'])) { continue; } $method = array($m . 'Common', $met['func']); $args = isset($met['args']) ? $met['args'] : array(); $weight = isset($met['weight']) ? $met['weight'] : 0; $color = isset($met['color']) ? $met['color'] : 'white'; } else { $method = array($m . 'Common', $met); $args = array(); $weight = 0; $color = 'white'; } $menus_out[$cap] = array($method, $args, $weight, $color); } } $menus_out_tmp = $menus_out; uksort($menus_out, 'sort_menus_cmp'); foreach ($menus_out as $cap => $met) { print '<a ' . mobile_stack_href($met[0], $met[1], $cap) . ' ' . (IPHONE ? ' class="button ' . $met[3] . '"' : '') . '>' . $cap . '</a>' . (IPHONE ? '' : '<br>'); } }
public static function user_settings() { if (Acl::is_user()) { $methods = array('none' => __('None'), 'callto' => __('Skype and other "callto" protocol applications')) + ModuleManager::call_common_methods('dialer_description'); return array(__('Dialing') => array(array('name' => 'method', 'label' => __('Dialing Method'), 'type' => 'select', 'values' => $methods, 'default' => 'none')), __('Misc') => array(array('name' => 'default_record_permission', 'label' => __('Default Records Permission'), 'type' => 'select', 'default' => 0, 'values' => Utils_CommonDataCommon::get_translated_array('CRM/Access', false)))); } return array(); }
public static function get_trays() { static $trays; static $user; if (!isset($trays) || $user != Acl::get_user()) { $user = Acl::get_user(); $trays = ModuleManager::call_common_methods('tray', false); } return $trays; }
public static function get_notifications() { $module = 'Base_Notify'; $notifications_date = Base_User_SettingsCommon::get($module, 'last_update'); if (!$notifications_date) { $notifications_date = time() - self::reset_time * 3600; } Base_User_SettingsCommon::save($module, 'last_update', time()); return ModuleManager::call_common_methods('tray_notification', false, array($notifications_date)); }
public static function get_home_pages() { static $cache = null; if ($cache === null) { $cache = array(); $tmp = ModuleManager::call_common_methods('home_page'); foreach ($tmp as $k => $v) { $cache = array_merge($cache, $v); } } return $cache; }
public static function get_menus() { static $menus; static $user; if (!isset($menus) || $user != Acl::get_user()) { $user = Acl::get_user(); $menus = ModuleManager::call_common_methods('menu', false); foreach ($menus as $m => $r) { if (!is_array($r)) { unset($menus[$m]); } } } return $menus; }
if (CRON_TOKEN != $_GET['token']) { die('Invalid token in URL - please go to Administrator Panel->Cron and copy valid cron URL.'); } } require_once 'include.php'; $lock = DATA_DIR . '/cron.lock'; if (file_exists($lock) && filemtime($lock) > time() - 6 * 3600) { die; } register_shutdown_function(create_function('', '@unlink("' . $lock . '");')); file_put_contents($lock, ''); set_time_limit(0); ini_set('memory_limit', '512M'); ModuleManager::load_modules(); Base_AclCommon::set_sa_user(); $ret = ModuleManager::call_common_methods('cron'); $cron_last = DB::GetAssoc('SELECT func,last,running FROM cron ORDER BY last'); $cron_funcs_prior = array(); //array of outdated cron callbacks $t = time(); foreach ($ret as $name => $obj) { if (!$obj) { continue; } if (is_array($obj)) { foreach ($obj as $func => $every) { if (!strpos($func, '::')) { $func = $name . 'Common::' . $func; } $func_md5 = md5($func); //if first cron run exists and it was executed in specified time or it keep running less then 24h - skip
public function body() { $qs_keyword = $this->get_module_variable('qs_keyword', ''); if (isset($_REQUEST['quick_search'])) { $qs_keyword = $_REQUEST['quick_search']; } $this->set_module_variable('qs_keyword', $qs_keyword); $form = $this->init_module(Libs_QuickForm::module_name(), __('Searching')); $theme = $this->pack_module(Base_Theme::module_name()); $form->addElement('header', 'quick_search_header', __('Quick Search')); $form->addElement('text', 'quick_search', __('Keyword'), array('id' => 'quick_search_text')); $form->addRule('quick_search', __('Field required'), 'required'); $form->addElement('header', 'categories_header', __('Categories')); $modules_with_search = ModuleManager::check_common_methods('search'); $search_categories = ModuleManager::call_common_methods('search_categories'); $search_categories_checkboxes = array(); $defaults = array(); $defaults['search_categories'] = array(); $categories_tmp =& $this->get_module_variable('categories', array()); foreach ($search_categories as $mod => $cats) { foreach ($cats as $cat_id => $cat_name) { $checked = 0; if (is_array($cat_name)) { if (!isset($cat_name['caption'])) { continue; } $checked = isset($cat_name['checked']) && $cat_name['checked']; $cat_name = $cat_name['caption']; } $search_categories_checkboxes[] = $form->createElement('advcheckbox', $mod . '#' . $cat_id, '', $cat_name); if (isset($categories_tmp[$mod . '#' . $cat_id])) { $checked = $categories_tmp[$mod . '#' . $cat_id]; } $defaults['search_categories'][$mod . '#' . $cat_id] = $checked; } } $form->addGroup($search_categories_checkboxes, 'search_categories', '', '</li><li>'); $form->addElement('submit', 'quick_search_submit', __('Search'), array('class' => 'submit')); $form->addElement('button', 'quick_search_select_none', __('Deselect all'), array('onClick' => 'jq("#' . $form->getAttribute('name') . ' input[type=checkbox]").removeAttr("checked")', 'class' => 'submit')); $form->addElement('button', 'quick_search_select_all', __('Select all'), array('onClick' => 'jq("#' . $form->getAttribute('name') . ' input[type=checkbox]").attr("checked","checked")', 'class' => 'submit')); $defaults['quick_search'] = $qs_keyword; $form->setDefaults($defaults); $form->assign_theme('form', $theme); $theme->assign('form_mini', 'no'); $theme->display('Search'); if ($form->validate() || $qs_keyword) { if ($form->exportValue('submited') == 1) { $keyword = $form->exportValue('quick_search'); } elseif (isset($_POST['qs_keyword'])) { $keyword = $_POST['qs_keyword']; } elseif (isset($qs_keyword)) { $keyword = $qs_keyword; } if ($keyword) { $categories_tmp = $form->exportValue('search_categories'); $categories = array(); if ($categories_tmp) { foreach ($categories_tmp as $cat => $val) { if (!$val) { continue; } list($mod, $cat_id) = explode('#', $cat, 2); if (!isset($categories[$mod])) { $categories[$mod] = array(); } $categories[$mod][] = $cat_id; } } $links = array(); $this->set_module_variable('quick_search', $keyword); $count = 0; foreach ($modules_with_search as $k) { $results = call_user_func(array($k . 'Common', 'search'), $keyword, isset($categories[$k]) ? $categories[$k] : array()); if (!empty($results)) { foreach ($results as $rk => $rv) { $count++; if ($count == 101) { $warning = __('Only 100 results are displayed.'); break; } $links[] = $rv; } } } $qs_theme = $this->pack_module(Base_Theme::module_name()); $qs_theme->assign('header', __('Search results')); $qs_theme->assign('links', $links); $qs_theme->assign('warning', isset($warning) ? $warning : null); $qs_theme->display('Results'); return; } } }
<?php if (!isset($_POST['keywords']) || !isset($_POST['cid']) || !is_numeric($_POST['cid'])) { die('Invalid request'); } define('CID', $_POST['cid']); define('READ_ONLY_SESSION', true); require_once '../../../include.php'; ModuleManager::load_modules(); $helps = ModuleManager::call_common_methods('help'); $html = ''; $words = explode(' ', trim($_POST['keywords'])); $results = array(); $i = count($words); while ($i >= 1) { $results[$i] = array(); $i--; $words[$i] = strtolower($words[$i]); } foreach ($helps as $m => $tutorials) { foreach ($tutorials as $tut) { $match = 0; $l = strtolower($tut['label']); foreach ($words as $w) { if (strpos($l, $w) !== false) { $match++; } } $l = strtolower($tut['keywords']); foreach ($words as $w) { if (strpos($l, $w) !== false) {
public function admin() { if (!Base_AclCommon::i_am_sa() || $this->is_back()) { $this->parent->reset(); return; } Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href()); $cmr = ModuleManager::call_common_methods('admin_caption'); foreach ($cmr as $name => $caption) { if (!ModuleManager::check_access($name, 'admin') || $name == 'Base_Admin') { continue; } if (!isset($caption)) { continue; } if (!is_array($caption)) { $caption = array('label' => $caption); } if (!isset($caption['section'])) { $caption['section'] = __('Misc'); } $mod_ok[$name] = $caption; } uksort($mod_ok, 'strcasecmp'); $form = $this->init_module('Libs_QuickForm'); $buttons = array(); load_js('modules/Base/Admin/js/main.js'); foreach ($mod_ok as $name => $caption) { if (method_exists($name . 'Common', 'admin_icon')) { $icon = call_user_func(array($name . 'Common', 'admin_icon')); } else { $icon = Base_ThemeCommon::get_template_file($name, 'icon.png'); if (!file_exists($icon)) { $icon = Base_ThemeCommon::get_template_file('Base_Admin', 'icon.png'); } } $button_id = $name . '__button'; $enable_field = $name . '_enable'; $sections = array(); $sections_id = $name . '__sections'; $enable_default = Base_AdminCommon::get_access($name, '', true); $form->addElement('checkbox', $enable_field, $enable_default === null ? __('Access blocked') : __('Allow access'), null, array('onchange' => 'admin_switch_button("' . $button_id . '",this.checked, "' . $sections_id . '");', 'id' => $enable_field, 'style' => $enable_default === null ? 'display:none;' : '')); $form->setDefaults(array($enable_field => $enable_default)); eval_js('admin_switch_button("' . $button_id . '",$("' . $enable_field . '").checked, "' . $sections_id . '", 1);'); if (class_exists($name . 'Common') && is_callable(array($name . 'Common', 'admin_access_levels'))) { $raws = call_user_func(array($name . 'Common', 'admin_access_levels')); if (is_array($raws)) { foreach ($raws as $s => $v) { $type = isset($v['values']) ? 'select' : 'checkbox'; $vals = isset($v['values']) ? $v['values'] : null; $s_field = $name . '__' . $s . '__switch'; $form->addElement($type, $s_field, $v['label'], $vals); $form->setDefaults(array($s_field => Base_AdminCommon::get_access($name, $s, true))); $sections[$s] = $s_field; } } } $buttons[$caption['section']][$name] = array('label' => $caption['label'], 'icon' => $icon, 'id' => $button_id, 'enable_switch' => $enable_field, 'sections_id' => $sections_id, 'sections' => $sections); } if ($form->validate()) { $vals = $form->exportValues(); DB::Execute('DELETE FROM base_admin_access'); foreach ($buttons as $section => $bs) { foreach ($bs as $name => $b) { DB::Execute('INSERT INTO base_admin_access (module, section, allow) VALUES (%s, %s, %d)', array($name, '', isset($vals[$b['enable_switch']]) && $vals[$b['enable_switch']] ? 1 : 0)); foreach ($b['sections'] as $s => $f) { DB::Execute('INSERT INTO base_admin_access (module, section, allow) VALUES (%s, %s, %d)', array($name, $s, isset($vals[$f]) ? $vals[$f] : 0)); } } } $this->parent->reset(); return; } Base_ActionBarCommon::add('save', __('Save'), $form->get_submit_form_href()); $sections = array(); foreach ($buttons as $section => $b) { $sections[$section] = array('header' => $section, 'buttons' => $b); } $sections = $this->sort_sections($sections); $theme = $this->pack_module('Base/Theme'); $form->assign_theme('form', $theme); $theme->assign('header', __('Admin Panel Access')); $theme->assign('sections', $sections); $theme->display('access_panel'); }
public function main_page() { if (!Acl::is_user()) { print 'Log in to change your settings.'; } $modules = array(); $admin_settings = $this->get_module_variable('admin_settings'); $us = ModuleManager::call_common_methods('user_settings'); foreach ($us as $name => $menu) { if (!is_array($menu)) { continue; } foreach ($menu as $k => $v) { $display = false; if (is_array($v)) { foreach ($v as $k2 => $m2) { if (isset($m2['type']) && $m2['type'] != 'hidden') { $display = true; break; } if ($display) { break; } } } else { $display = true; } if (!$display) { continue; } if (isset($modules[$k])) { if (!is_string($v) && !isset($modules[$k]['external'])) { $modules[$k]['module_names'][] = $name; } else { trigger_error('You cannot override this key: ' . $k, E_USER_ERROR); } } else { if (!is_string($v)) { $modules[$k] = array('action' => $this->create_unique_href(array('settings_branch' => $k)), 'module_names' => array($name)); } elseif (!$admin_settings) { $modules[$k] = array('action' => $this->create_main_href($name, $v), 'module_names' => array($name), 'external' => true); } } } } ksort($modules); $buttons = array(); foreach ($modules as $caption => $arg) { $icon = null; sort($arg['module_names']); foreach ($arg['module_names'] as $m) { $f = array($m . 'Common', 'user_settings_icon'); if (is_callable($f)) { $ret = call_user_func($f); if (is_array($ret)) { if (isset($ret[$caption])) { $icon = $ret[$caption]; break; } } elseif (is_string($ret)) { $icon = $ret; break; } } } if (!$icon) { foreach ($arg['module_names'] as $m) { $new = Base_ThemeCommon::get_template_file($m, 'icon.png'); if ($new) { $icon = $new; } } } $buttons[] = array('link' => '<a ' . $arg['action'] . '>' . $caption . '</a>', 'module' => $arg['module_names'], 'icon' => $icon); } $theme = $this->pack_module('Base/Theme'); $theme->assign('header', __('User Settings')); $theme->assign('buttons', $buttons); $theme->display(); }
private static function get_providers($file = null) { $providers_arr = ModuleManager::call_common_methods('fax_provider', true, array($file)); $providers = array(); foreach ($providers_arr as $module => $arr) { if (!$arr) { unset($providers_arr[$module]); continue; } $providers[$module] = $arr['name']; } return array($providers, $providers_arr); }
public static function get_file_leightbox($row, & $view_link = '') { static $th; if(!isset($th)) $th = Base_ThemeCommon::init_smarty(); if($row['original']==='') return ''; $links = array(); $lid = 'get_file_'.md5(serialize($row)); if(isset($_GET['save_google_docs']) && $_GET['save_google_docs']==$lid) { self::save_google_docs($row['id']); } if(isset($_GET['discard_google_docs']) && $_GET['discard_google_docs']==$lid) { self::discard_google_docs($row['id']); } $close_leightbox_js = 'leightbox_deactivate(\''.$lid.'\');'; if (Variable::get('utils_attachments_google_user',false) && preg_match('/\.(xlsx?|docx?|txt|odt|ods|csv)$/i',$row['original'])) { $label = __('Open with Google Docs'); $label = explode(' ', $label); $mid = floor(count($label) / 2); $label = implode(' ', array_slice($label, 0, $mid)).' '.implode(' ', array_slice($label, $mid)); $script = 'get_google_docs'; $onclick = '$(\'attachment_save_options_'.$row['id'].'\').style.display=\'\';$(\'attachment_download_options_'.$row['id'].'\').hide();'; $th->assign('save_options_id','attachment_save_options_'.$row['id']); $links['save'] = '<a href="javascript:void(0);" onclick="'.$close_leightbox_js.Module::create_href_js(array('save_google_docs'=>$lid)).'">'.__('Save Changes').'</a><br>'; $links['discard'] ='<a href="javascript:void(0);" onclick="'.$close_leightbox_js.Module::create_href_js(array('discard_google_docs'=>$lid)).'">'.__('Discard Changes').'</a><br>'; } else { $label = __('View'); $th->assign('save_options_id',''); $script = 'get'; $onclick = $close_leightbox_js; } $th->assign('download_options_id','attachment_download_options_'.$row['id']); $view_link = 'modules/Utils/Attachment/'.$script.'.php?'.http_build_query(array('id'=>$row['id'],'cid'=>CID,'view'=>1)); $links['view'] = '<a href="'.$view_link.'" target="_blank" onClick="'.$onclick.'">'.$label.'</a><br>'; $links['download'] = '<a href="modules/Utils/Attachment/get.php?'.http_build_query(array('id'=>$row['id'],'cid'=>CID)).'" onClick="leightbox_deactivate(\''.$lid.'\')">'.__('Download').'</a><br>'; load_js('modules/Utils/Attachment/remote.js'); if(!$row['crypted']) { $links['link'] = '<a href="javascript:void(0)" onClick="utils_attachment_get_link('.$row['id'].', '.CID.',\'get link\');leightbox_deactivate(\''.$lid.'\')">'.__('Get link').'</a><br>'; } $th->assign('filename',$row['original']); $f_filename = DATA_DIR.'/Utils_Attachment/'.$row['aid'].'/'.$row['id']; if(!file_exists($f_filename)) return 'missing file: '.$f_filename; $th->assign('file_size',__('File size: %s',array(filesize_hr($f_filename)))); $th->assign('labels',array( 'filename'=>__('Filename'), 'file_size'=>__('File size') )); foreach($links as $key=>&$l) { $th->assign($key,$l); $l = Base_ThemeCommon::parse_links($key, $l); } $th->assign('__link',$links); $custom_getters = array(); if(!$row['crypted']) { $getters = ModuleManager::call_common_methods('attachment_getters'); foreach($getters as $mod=>$arr) { if (is_array($arr)) foreach($arr as $caption=>$func) { $cus_id = md5($mod.$caption.serialize($func)); if(isset($_GET['utils_attachment_custom_getter']) && $_GET['utils_attachment_custom_getter']==$cus_id) call_user_func_array(array($mod.'Common',$func['func']),array($f_filename,$row['original'],$row['id'])); $custom_getters[] = array('open'=>'<a href="javascript:void(0)" onClick="'.Epesi::escapeJS(Module::create_href_js(array('utils_attachment_custom_getter'=>$cus_id)),true,false).';leightbox_deactivate(\''.$lid.'\')">','close'=>'</a>','text'=>$caption,'icon'=>$func['icon']); } } } $th->assign('custom_getters',$custom_getters); ob_start(); Base_ThemeCommon::display_smarty($th,'Utils_Attachment','download'); $c = ob_get_clean(); Libs_LeightboxCommon::display($lid,$c,__('Attachment')); return Libs_LeightboxCommon::get_open_href($lid); }
public static function get_file_leightbox($row, &$view_link = '') { static $th; if (!isset($th)) { $th = Base_ThemeCommon::init_smarty(); } if ($row['original'] === '') { return ''; } $links = array(); $lid = 'get_file_' . md5(serialize($row)); $close_leightbox_js = 'leightbox_deactivate(\'' . $lid . '\');'; $label = __('View'); $th->assign('save_options_id', ''); $script = 'get'; $onclick = $close_leightbox_js; $th->assign('download_options_id', 'attachment_download_options_' . $row['id']); $view_link = 'modules/Utils/Attachment/' . $script . '.php?' . http_build_query(array('id' => $row['id'], 'cid' => CID, 'view' => 1)); $links['view'] = '<a href="' . $view_link . '" target="_blank" onClick="' . $onclick . '">' . $label . '</a><br>'; $links['download'] = '<a href="modules/Utils/Attachment/get.php?' . http_build_query(array('id' => $row['id'], 'cid' => CID)) . '" onClick="leightbox_deactivate(\'' . $lid . '\')">' . __('Download') . '</a><br>'; load_js('modules/Utils/Attachment/remote.js'); if (!$row['crypted']) { $links['link'] = '<a href="javascript:void(0)" onClick="utils_attachment_get_link(' . $row['id'] . ', ' . CID . ',\'get link\');leightbox_deactivate(\'' . $lid . '\')">' . __('Get link') . '</a><br>'; } $th->assign('filename', $row['original']); $meta = Utils_FileStorageCommon::meta($row['filestorage_id']); $f_filename = $meta['file']; if (!file_exists($f_filename)) { return 'missing file: ' . $f_filename; } $th->assign('file_size', __('File size: %s', array(filesize_hr($f_filename)))); $th->assign('labels', array('filename' => __('Filename'), 'file_size' => __('File size'))); foreach ($links as $key => &$l) { $th->assign($key, $l); $l = Base_ThemeCommon::parse_links($key, $l); } $th->assign('__link', $links); $custom_getters = array(); if (!$row['crypted']) { $getters = ModuleManager::call_common_methods('attachment_getters'); foreach ($getters as $mod => $arr) { if (is_array($arr)) { foreach ($arr as $caption => $func) { $cus_id = md5($mod . $caption . serialize($func)); if (isset($_GET['utils_attachment_custom_getter']) && $_GET['utils_attachment_custom_getter'] == $cus_id) { call_user_func_array(array($mod . 'Common', $func['func']), array($f_filename, $row['original'], $row['id'])); } $custom_getters[] = array('open' => '<a href="javascript:void(0)" onClick="' . Epesi::escapeJS(Module::create_href_js(array('utils_attachment_custom_getter' => $cus_id)), true, false) . ';leightbox_deactivate(\'' . $lid . '\')">', 'close' => '</a>', 'text' => $caption, 'icon' => $func['icon']); } } } } $th->assign('custom_getters', $custom_getters); ob_start(); Base_ThemeCommon::display_smarty($th, 'Utils_Attachment', 'download'); $c = ob_get_clean(); Libs_LeightboxCommon::display($lid, $c, __('Attachment')); return Libs_LeightboxCommon::get_open_href($lid); }