Example #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);
 }
Example #2
0
 public function body()
 {
     $m = $this->init_module(Utils_GenericBrowser::module_name(), null, 't1');
     $m->set_table_columns(array(array('name' => 'xxx', 'width' => 50), array('name' => 'xyz', 'width' => 50)));
     $m->add_row('xxx', '123');
     $m->add_row('sdasf', '567');
     $m->add_row('wwww', 'abc');
     $m->add_row('asgfs', 'bla bla');
     $m->add_row('test', 'adsad');
     $m->add_row('search', 'sjfksdfjdk');
     $m->add_row('search keyword', 'test');
     $m->add_row('ttttesst', 'djsdkdkdkd kskdk');
     $m->add_row('xxx', 'yyyy');
     $this->display_module($m);
     $m = $this->init_module(Utils_GenericBrowser::module_name(), null, 't2');
     $m->set_table_columns(array(array('name' => 'xxx', 'search' => 1)));
     $m->add_row('xxx');
     $m->add_row('sdasf');
     $m->add_row('wwww');
     $m->add_row('asgfs');
     $m->add_row('test');
     $m->add_row('search');
     $m->add_row('search keyword');
     $m->add_row('ttttesst');
     $m->add_row('xxxy');
     $this->display_module($m, array(true), 'automatic_display');
     //------------------------------ print out src
     print '<hr><b>Install</b><br>';
     $this->pack_module(Utils_CatFile::module_name(), 'modules/Tests/GenericBrowser/GenericBrowserInstall.php');
     print '<hr><b>Main</b><br>';
     $this->pack_module(Utils_CatFile::module_name(), 'modules/Tests/GenericBrowser/GenericBrowser_0.php');
     print '<hr><b>Common</b><br>';
     $this->pack_module(Utils_CatFile::module_name(), 'modules/Tests/GenericBrowser/GenericBrowserCommon_0.php');
 }
Example #3
0
 public function admin()
 {
     if ($this->is_back()) {
         $this->parent->reset();
     }
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     Base_ActionBarCommon::add('add', __('Add Home Page'), $this->create_callback_href(array($this, 'edit_home_page')));
     $gb = $this->init_module(Utils_GenericBrowser::module_name(), null, 'home_page_admin');
     $gb->set_table_columns(array(array('name' => 'Home Page'), array('name' => 'Clearance')));
     $pages = DB::Execute('SELECT * FROM base_home_page ORDER BY priority');
     $next = null;
     while ($row = $pages->FetchRow()) {
         $gbr = $gb->get_new_row();
         $clearances = DB::GetAssoc('SELECT id, clearance FROM base_home_page_clearance WHERE home_page_id=%d', array($row['id']));
         $gbr->add_data($row['home_page'], Base_AclCommon::display_clearances($clearances));
         if ($next) {
             $next->add_action($this->create_callback_href(array($this, 'change_priority'), array($last_row['id'], $last_row['priority'], +1)), 'Move down', null, 'move-down');
         }
         if ($row['priority'] > 1) {
             $gbr->add_action($this->create_callback_href(array($this, 'change_priority'), array($row['id'], $row['priority'], -1)), 'Move up', null, 'move-up');
         }
         $gbr->add_action($this->create_callback_href(array($this, 'delete_home_page'), array($row['id'])), 'Delete');
         $gbr->add_action($this->create_callback_href(array($this, 'edit_home_page'), array($row['id'])), 'Edit');
         $next = $gbr;
         $last_row = $row;
     }
     $this->display_module($gb);
     eval_js('base_home_page__initialized = false;');
 }
Example #4
0
 public function download_template()
 {
     $ld = $this->get_data_dir() . 'list/';
     if (!file_exists($ld)) {
         return $this->download_templates_list();
     }
     if ($this->is_back()) {
         return false;
     }
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     Base_ActionBarCommon::add('search', __('Update templates list'), $this->create_callback_href(array($this, 'download_templates_list')));
     $m = $this->init_module(Utils_GenericBrowser::module_name(), null, 'new_templates');
     $m->set_table_columns(array(array('name' => 'Name', 'search' => 1), array('name' => 'Version'), array('name' => 'Screenshot'), array('name' => 'Author', 'search' => 1), array('name' => 'Info', 'search' => 1), array('name' => 'Compatible')));
     $content = scandir($ld);
     foreach ($content as $template_name) {
         if ($template_name == '.' || $template_name == '..') {
             continue;
         }
         $ini = parse_ini_file($ld . $template_name . '/info.ini');
         $compatible = version_compare($ini['epesi_version'], EPESI_VERSION) <= 0;
         $installed = is_dir(DATA_DIR . '/Base_Theme/templates/' . $template_name);
         if ($installed) {
             $installed_ini = @parse_ini_file(DATA_DIR . '/Base_Theme/templates/' . $template_name . '/info.ini');
             if (!$installed_ini) {
                 $installed_ini = array('version' => 0);
             }
         }
         if (isset($ini['screenshot'])) {
             $th_big = Utils_ImageCommon::create_thumb($ld . $template_name . '/' . $ini['screenshot'], 640, 480);
             $thumb = '<a href="' . $th_big['thumb'] . '" rel="lyteshow">' . Utils_ImageCommon::get_thumb_html($ld . $template_name . '/' . $ini['screenshot'], 120, 120) . '</a>';
         } else {
             $thumb = '';
         }
         $r = $m->get_new_row();
         $r->add_data($template_name, $ini['version'], $thumb, $ini['author'], $ini['info'], $compatible ? '<font color="green">yes</font>' : '<font color="red">NO</font> epesi ' . $ini['epesi_version'] . ' required');
         if ($compatible && !$installed) {
             $r->add_action($this->create_callback_href(array($this, 'install_template'), $template_name), 'Install');
         }
         if ($installed) {
             $r->add_action($this->create_callback_href(array($this, 'delete_template'), $template_name), 'Delete');
             if ($ini['version'] > $installed_ini['version']) {
                 $r->add_action($this->create_callback_href(array($this, 'update_template'), $template_name), 'Update');
             }
         }
     }
     $this->display_module($m, array(true), 'automatic_display');
     return true;
 }
Example #5
0
 /**
  * Displays menu editor.
  */
 public function body()
 {
     $edit = $this->get_module_variable_or_unique_href_variable('edit');
     if (isset($edit)) {
         return $this->edit($edit);
     }
     $gb = $this->init_module(Utils_GenericBrowser::module_name(), null, 'custommenu');
     $data = $this->get_module_variable('data');
     $gb->set_table_columns(array(array('name' => __('Menu entry path'), 'width' => 70)));
     foreach ($data as $row) {
         $r =& $gb->get_new_row();
         $r->add_data($row);
         $r->add_action($this->create_unique_href(array('edit' => $row)), 'Edit');
         $r->add_action($this->create_confirm_callback_href(__('Are you sure?'), array($this, 'delete_entry'), $row), 'Delete');
     }
     $this->display_module($gb);
     Base_ActionBarCommon::add('add', __('New menu entry'), $this->create_unique_href(array('edit' => false)));
 }
Example #6
0
 public function admin()
 {
     if ($this->is_back()) {
         $this->parent->reset();
     }
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     $theme = $this->init_module(Base_Theme::module_name());
     $new_token_href = $this->create_confirm_callback_href(__('Are you sure?'), array($this, 'new_token'));
     $theme->assign('new_token_href', $new_token_href);
     $theme->assign('wiki_url', 'http://www.epesi.org/Cron');
     $theme->assign('cron_url', Base_CronCommon::get_cron_url());
     $m = $this->init_module(Utils_GenericBrowser::module_name(), null, 'cron');
     $m->set_table_columns(array(array('name' => 'Description', 'width' => 65), array('name' => 'Last Run', 'width' => 20), array('name' => 'Running', 'width' => 15)));
     $ret = DB::Execute('SELECT description,last,running FROM cron ORDER BY last DESC');
     while ($row = $ret->FetchRow()) {
         $m->add_row($row['description'] ? $row['description'] : '???', $row['last'] ? Base_RegionalSettingsCommon::time2reg($row['last']) : '---', $row['running'] ? '<span style="color:red">' . __('Yes') . '</span>' : '<span style="color:green">' . __('No') . '</span>');
     }
     $html = $this->get_html_of_module($m);
     $theme->assign('history', $html);
     $theme->display();
 }
Example #7
0
 public function translations()
 {
     global $translations;
     global $custom_translations;
     load_js('modules/Base/Lang/Administrator/js/main.js');
     eval_js('translate_init();');
     $lp = $this->init_module(Utils_LeightboxPrompt::module_name());
     $form = $this->init_module(Libs_QuickForm::module_name(), null, 'translations_sending');
     $desc = '<div id="trans_sett_info" style="line-height:17px;">';
     $desc .= __('You have now option to contribute with your translations to help us deliver EPESI in various languages. You can opt in to send your translations to EPESI central database, allowing to deliver EPESI in your language to other users.') . '<br>';
     $desc .= __('Please note that the translations you submit aren\'t subject to copyright. EPESI Team will distribute the translations free of charge to the end users.') . '<br>';
     $desc .= __('The only data being sent is the values of the fields presented below and the translated strings, we do not receive any other information contained in EPESI.') . '<br>';
     $desc .= __('You can also change your Translations Contribution settings at later time.') . '<br>';
     $desc .= '</div>';
     eval_js('$("trans_sett_info").up("td").setAttribute("colspan",2);');
     eval_js('$("trans_sett_info").up("td").style.borderRadius="0";');
     // Not really nice, but will have to do for now
     eval_js('$("decription_label").up("td").hide();');
     eval_js('function update_credits(){$("contact_email").disabled=$("credits_website").disabled=!$("include_credits").checked||!$("allow").checked;}');
     eval_js('update_credits();');
     $ip = gethostbyname($_SERVER['SERVER_NAME']);
     $me = CRM_ContactsCommon::get_my_record();
     $form->addElement('static', 'header', '<div id="decription_label" />', $desc);
     $form->addElement('checkbox', 'allow', __('Enable sending translations'), null, array('id' => 'allow', 'onchange' => '$("include_credits").disabled=$("first_name").disabled=$("last_name").disabled=!this.checked;update_credits();'));
     $form->addElement('text', 'first_name', __('First Name'), array('id' => 'first_name'));
     $form->addElement('text', 'last_name', __('Last Name'), array('id' => 'last_name'));
     $form->addElement('checkbox', 'include_credits', __('Include in credits'), null, array('id' => 'include_credits', 'onchange' => 'update_credits();'));
     $form->addElement('text', 'credits_website', __('Credits website'), array('id' => 'credits_website'));
     $form->addElement('text', 'contact_email', __('Contact e-mail'), array('id' => 'contact_email'));
     $form->addElement('static', 'IP', __('IP'), $ip);
     $lp->add_option(null, null, null, $form);
     eval_js('$("first_name").disabled=$("last_name").disabled=!$("allow").checked;');
     $vals = $lp->export_values();
     if ($vals) {
         $values = $vals['form'];
         if (!isset($values['allow'])) {
             $values['allow'] = 0;
         }
         if (!isset($values['first_name'])) {
             $values['first_name'] = '';
         }
         if (!isset($values['last_name'])) {
             $values['last_name'] = '';
         }
         if (!isset($values['include_credits'])) {
             $values['include_credits'] = 0;
         }
         if (!isset($values['credits_website'])) {
             $values['credits_website'] = '';
         }
         if (!isset($values['contact_email'])) {
             $values['contact_email'] = '';
         }
         DB::Execute('DELETE FROM base_lang_trans_contrib WHERE user_id=%d', array(Acl::get_user()));
         DB::Execute('INSERT INTO base_lang_trans_contrib (user_id, allow, first_name, last_name, credits, credits_website, contact_email) VALUES (%d, %d, %s, %s, %d, %s, %s)', array(Acl::get_user(), $values['allow'], $values['first_name'], $values['last_name'], $values['include_credits'], $values['credits_website'], $values['contact_email']));
     }
     $allow_sending = Base_Lang_AdministratorCommon::allow_sending(true);
     if ($allow_sending === null || $allow_sending === false) {
         $form->setDefaults(array('allow' => 0, 'first_name' => $me['first_name'], 'last_name' => $me['last_name'], 'contact_email' => $me['email']));
     } else {
         $r = DB::GetRow('SELECT * FROM base_lang_trans_contrib WHERE user_id=%d', array(Acl::get_user()));
         if (!$r['first_name']) {
             $r['first_name'] = $me['first_name'];
         }
         if (!$r['last_name']) {
             $r['last_name'] = $me['last_name'];
         }
         if (!$r['contact_email']) {
             $r['contact_email'] = $me['email'];
         }
         $form->setDefaults(array('allow' => $r['allow'], 'first_name' => $r['first_name'], 'last_name' => $r['last_name'], 'contact_email' => $r['contact_email'], 'credits_website' => $r['credits_website'], 'include_credits' => $r['credits']));
     }
     Base_ActionBarCommon::add('settings', __('Translations Contributions'), $lp->get_href());
     $this->display_module($lp, array(__('Translations Contributions settings')));
     if (Base_AdminCommon::get_access('Base_Lang_Administrator', 'new_langpack')) {
         Base_ActionBarCommon::add('add', __('New langpack'), $this->create_callback_href(array($this, 'new_lang_pack')));
     }
     if (Base_AdminCommon::get_access('Base_Lang_Administrator', 'select_language')) {
         Base_ActionBarCommon::add('refresh', __('Refresh languages'), $this->create_callback_href(array('Base_LangCommon', 'refresh_cache')));
     }
     $form2 = $this->init_module(Libs_QuickForm::module_name(), null, 'translaction_filter');
     $form2->addElement('select', 'lang_filter', __('Filter'), array(__('Show all'), __('Show with custom translation'), __('Show with translation'), __('Show without translation')), array('onchange' => $form2->get_submit_form_js()));
     if ($form2->validate()) {
         $vals = $form2->exportValues();
         $this->set_module_variable('filter', $vals['lang_filter']);
     }
     $filter = $this->get_module_variable('filter', 0);
     $form2->setDefaults(array('lang_filter' => $filter));
     ob_start();
     $form2->display_as_row();
     $trans_filter = ob_get_clean();
     if (!isset($_SESSION['client']['base_lang_administrator']['currently_translating'])) {
         $_SESSION['client']['base_lang_administrator']['currently_translating'] = Base_LangCommon::get_lang_code();
     }
     if (!isset($_SESSION['client']['base_lang_administrator']['notice'])) {
         print '<span class="important_notice">' . __('Please make sure the correct language is selected in the box below before you start translating') . ' <a style="float:right;" ' . $this->create_callback_href(array($this, 'hide_notice')) . '>' . __('Discard') . '</a>' . '</span>';
     }
     if (Base_AdminCommon::get_access('Base_Lang_Administrator', 'translate')) {
         $langs = Base_LangCommon::get_installed_langs();
         $form = $this->init_module(Libs_QuickForm::module_name(), null, 'language_selected');
         $form->addElement('select', 'lang_code', __('Currently Translating'), $langs, array('onchange' => $form->get_submit_form_js()));
         $currently_translating = $_SESSION['client']['base_lang_administrator']['currently_translating'];
         $form->setDefaults(array('lang_code' => $currently_translating));
         if ($form->validate()) {
             $form->process(array($this, 'submit_language_select'));
         }
         if ($allow_sending) {
             $warning_mgs = __('All custom translations will be sent to our server right after you will input them. Use this mode only, if you wish to contribute your translations. If you are going to change meaning of any string, then please disable sending translations.');
             print "<h1 style=\"color:red; width: 70%\">{$warning_mgs}</h1>";
         } else {
             $contribution_mgs = __('If you wish to help us with translating EPESI to your language, then click Translation Contribution in the Action Bar.');
             print "<h3>{$contribution_mgs}</h3>";
         }
         $form->display_as_column();
         if ($allow_sending) {
             $href = $this->create_confirm_callback_href(__('Are you sure?'), array($this, 'send_lang_ajax'), array($currently_translating));
             print "<h4><a {$href}>" . __('Send all your custom translations for language %s', array($langs[$currently_translating])) . "</a></h4>";
         }
         $help_msg = __('You can open next string to translate with space button');
         print "<p>{$help_msg}</p>";
     }
     Base_LangCommon::load($_SESSION['client']['base_lang_administrator']['currently_translating']);
     $data = array();
     foreach ($custom_translations as $o => $t) {
         if ($t || !isset($translations[$o])) {
             $translations[$o] = $t;
         }
     }
     foreach ($translations as $o => $t) {
         if (isset($custom_translations[$o]) && $custom_translations[$o]) {
             $t = $custom_translations[$o];
         } else {
             if ($filter == 1) {
                 continue;
             }
         }
         if ($filter == 2 && !$t) {
             continue;
         }
         if ($filter == 3 && $t) {
             continue;
         }
         $span_id = 'trans__' . md5($o);
         if (Base_AdminCommon::get_access('Base_Lang_Administrator', 'translate')) {
             $org = '<a href="javascript:void(0);" onclick="lang_translate(\'' . Epesi::escapeJS(htmlspecialchars($o)) . '\',\'' . $span_id . '\');">' . $o . '</a>';
             $t = '<span id="' . $span_id . '">' . $t . '</span>';
         }
         eval_js('translate_add_id("' . $span_id . '","' . Epesi::escapeJS($o) . '");');
         $data[] = array($org, $t);
     }
     $gb = $this->init_module(Utils_GenericBrowser::module_name(), null, 'lang_translations');
     $gb->set_custom_label($trans_filter);
     $gb->set_table_columns(array(array('name' => __('Original'), 'order_preg' => '/^<[^>]+>([^<]*)<[^>]+>$/i', 'search' => 'original'), array('name' => __('Translated'), 'search' => 'translated')));
     //$limit = $gb->get_limit(count($data));
     $id = 0;
     foreach ($data as $v) {
         //if ($id>=$limit['offset'] && $id<$limit['offset']+$limit['numrows'])
         $gb->add_row_array($v);
         $id++;
     }
     Base_LangCommon::load();
     $this->display_module($gb, array(true), 'automatic_display');
     Utils_ShortcutCommon::add(array(' '), 'translate_first_on_the_list', array('disable_in_input' => 1));
 }
Example #8
0
 public function manage_permissions()
 {
     $this->help('Permissions Editor', 'permissions');
     $this->init();
     $gb = $this->init_module(Utils_GenericBrowser::module_name(), 'permissions_' . $this->tab, 'permissions_' . $this->tab);
     $gb->set_table_columns(array(array('name' => __('Access type'), 'width' => '100px'), array('name' => __('Clearance required'), 'width' => '30'), array('name' => __('Applies to records'), 'width' => '60'), array('name' => __('Fields'), 'width' => '100px')));
     $ret = DB::Execute('SELECT * FROM ' . $this->tab . '_access AS acs ORDER BY action DESC');
     $tmp = DB::GetAll('SELECT * FROM ' . $this->tab . '_access_clearance AS acs');
     $clearance = array();
     foreach ($tmp as $t) {
         $clearance[$t['rule_id']][] = $t['clearance'];
     }
     $tmp = DB::GetAll('SELECT * FROM ' . $this->tab . '_access_fields AS acs');
     $fields = array();
     foreach ($tmp as $t) {
         $fields[$t['rule_id']][] = $t['block_field'];
     }
     $all_clearances = array_flip(Base_AclCommon::get_clearance(true));
     $all_fields = array();
     foreach ($this->table_rows as $v) {
         $all_fields[$v['id']] = $v['name'];
     }
     $actions = $this->get_permission_actions();
     $rules = array();
     while ($row = $ret->FetchRow()) {
         if (!isset($clearance[$row['id']])) {
             $clearance[$row['id']] = array();
         }
         if (!isset($fields[$row['id']])) {
             $fields[$row['id']] = array();
         }
         $action = $actions[$row['action']];
         $crits = Utils_RecordBrowserCommon::parse_access_crits($row['crits'], true);
         $crits_text = Utils_RecordBrowserCommon::crits_to_words($this->tab, $crits);
         foreach ($fields[$row['id']] as $k => $v) {
             if (isset($all_fields[$v])) {
                 $fields[$row['id']][$k] = $all_fields[$v];
             } else {
                 unset($fields[$row['id']][$k]);
             }
         }
         foreach ($clearance[$row['id']] as $k => $v) {
             if (isset($all_clearances[$v])) {
                 $clearance[$row['id']][$k] = $all_clearances[$v];
             } else {
                 unset($clearance[$row['id']][$k]);
             }
         }
         $c_all_fields = count($all_fields);
         $c_fields = count($fields[$row['id']]);
         $props = $c_all_fields ? ($c_all_fields - $c_fields) / $c_all_fields : 0;
         $color = dechex(255 - 68 * $props) . dechex(187 + 68 * $props) . 'BB';
         $fields_value = $c_all_fields - $c_fields . ' / ' . $c_all_fields;
         if ($props != 1) {
             $fields_value = Utils_TooltipCommon::create($fields_value, '<b>' . __('Excluded fields') . ':</b><hr>' . implode('<br>', $fields[$row['id']]), false);
         }
         $rules[$row['action']][$row['id']] = array($action, '<span class="Utils_RecordBrowser__permissions_crits">' . implode(' <span class="joint">' . __('and') . '</span><br>', $clearance[$row['id']]) . '</span>', array('value' => '<span class="Utils_RecordBrowser__permissions_crits">' . $crits_text . '</span>', 'overflow_box' => false), array('style' => 'background-color:#' . $color, 'value' => $fields_value));
     }
     foreach ($actions as $a => $l) {
         if (isset($rules[$a])) {
             foreach ($rules[$a] as $id => $vals) {
                 $gb_row = $gb->get_new_row();
                 $gb_row->add_data_array($vals);
                 if (Base_AdminCommon::get_access('Utils_RecordBrowser', 'permissions') == 2) {
                     $gb_row->add_action($this->create_callback_href(array($this, 'edit_permissions_rule'), array($id)), 'edit', 'Edit');
                     $gb_row->add_action($this->create_callback_href(array($this, 'edit_permissions_rule'), array($id, true)), 'copy', __('Clone rule'), Base_ThemeCommon::get_template_file(Utils_Attachment::module_name(), 'copy_small.png'));
                     $gb_row->add_action($this->create_confirm_callback_href(__('Are you sure you want to delete this rule?'), array($this, 'delete_permissions_rule'), array($id)), 'delete', 'Delete');
                 }
             }
         }
     }
     if (Base_AdminCommon::get_access('Utils_RecordBrowser', 'permissions') == 2) {
         Base_ActionBarCommon::add('add', __('Add new rule'), $this->create_callback_href(array($this, 'edit_permissions_rule'), array(null)));
     }
     Base_ThemeCommon::load_css('Utils_RecordBrowser', 'edit_permissions');
     $this->display_module($gb);
     eval_js('utils_recordbrowser__crits_initialized = false;');
 }
Example #9
0
 public function queue_tab($count_f, $get_f, $statuses)
 {
     $t = time();
     $status =& $this->get_module_variable('queue_status', current(array_keys($statuses)));
     $offset =& $this->get_module_variable('queue_offset', 0);
     $form = $this->init_module(Libs_QuickForm::module_name());
     $theme = $this->pack_module(Base_Theme::module_name());
     $form->addElement('select', 'status', __('Status'), $statuses);
     $form->addElement('submit', 'submit_button', __('Show'));
     $form->addRule('status', 'Field required', 'required');
     $form->setDefaults(array('status' => $status));
     if ($form->validate()) {
         $data = $form->exportValues();
         if (array_key_exists($data['status'], $statuses)) {
             $status = $data['status'];
         }
         $offset = 0;
     }
     $form->assign_theme('form', $theme);
     $m = $this->init_module(Utils_GenericBrowser::module_name(), null, 'queue');
     $m->set_table_columns(array(array('name' => 'To', 'width' => 30, 'order' => 'toNumber'), array('name' => 'Status', 'width' => 10), array('name' => 'Date', 'width' => 10, 'order' => 'creationDate'), array('name' => 'File', 'width' => 30, 'order' => 'fileName')));
     $m->set_default_order(array('Date' => 'DESC'));
     $count = call_user_func($count_f, $status);
     if ($count === false) {
         $count = 0;
     }
     $limits = $m->get_limit($count);
     $order = $m->get_order();
     if ($count != 0) {
         $data = call_user_func($get_f, $status, $order[0]['order'], $order[0]['direction'], $limits['numrows'], (string) ($limits['offset'] + 1));
     }
     if ($count == 0 || $data === false) {
         $data = array();
     }
     foreach ($data as $row) {
         $from_rec = CRM_ContactsCommon::get_contacts(array('fax' => $row['toNumber']));
         foreach ($from_rec as &$rec) {
             $rec = CRM_ContactsCommon::contact_format_default($rec);
         }
         $from_rec_comp = CRM_ContactsCommon::get_companies(array('fax' => $row['toNumber']));
         foreach ($from_rec_comp as $rec) {
             $from_rec[] = Utils_RecordBrowserCommon::create_linked_label('company', 'Company Name', $rec);
         }
         $m->add_row(empty($from_rec) ? $row['toNumber'] : ' (' . implode(', ', $from_rec) . ')', $statuses[$row['faxStatus']], Base_RegionalSettingsCommon::time2reg($row['creationDate']), '<a href="' . $row['fileUrl'] . '" target="_blank">' . $row['fileName'] . '</a>');
     }
     $theme->assign('table_data', $this->get_html_of_module($m));
     $theme->display();
 }
Example #10
0
 public function body($contact = null)
 {
     if (!Apps_ActivityReportCommon::has_access_to_report($contact)) {
         return;
     }
     $fixed_user_id = $contact['login'];
     $rb_tabs = Utils_RecordBrowserCommon::list_installed_recordsets();
     asort($rb_tabs);
     $form = $this->init_module(Libs_QuickForm::module_name());
     if ($fixed_user_id == null) {
         $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'));
     if ($contact) {
         $form->addElement('submit', 'submit', __('Show'));
     } else {
         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);
     }
     if ($fixed_user_id) {
         $filters['user'] = $fixed_user_id;
     }
     $form->setDefaults($filters);
     $theme = $this->init_module(Base_Theme::module_name());
     $form->assign_theme('form', $theme);
     $theme->display();
     if ($fixed_user_id == null && $users_count) {
         $filters['user'] = CRM_ContactsCommon::get_contact($filters['user']);
         $filters['user'] = $filters['user']['login'];
     }
     $tables = array();
     $recordsets = $filters['recordsets'];
     $gb = $this->init_module(Utils_GenericBrowser::module_name(), null, 'activity_report');
     $columns = array();
     $columns[] = array('name' => __('Date'), 'width' => 40);
     if (!$fixed_user_id) {
         $columns[] = array('name' => __('User'), 'width' => 40);
     }
     $columns[] = array('name' => __('Type'), 'width' => 40);
     $columns[] = array('name' => __('Label'));
     $columns[] = array('name' => __('Actions taken'), 'width' => 40);
     $gb->set_table_columns($columns);
     $af_where = array();
     foreach ($recordsets as $k) {
         $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 ($recordsets as $k) {
             $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 ($recordsets as $k) {
             $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'];
                         if ($action == 'DELETED') {
                             $action = __('Deleted');
                         }
                         if ($action == 'RESTORED') {
                             $action = __('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 (!isset($r_id) || !$r_id) {
                 continue;
             }
             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 .= '&nbsp;';
                 $link .= Utils_RecordBrowserCommon::create_default_linked_label($row['tab'], $r_id, false, false);
             }
             $row_data = array();
             $row_data[] = Base_RegionalSettingsCommon::time2reg($row['edited_on']);
             if (!$fixed_user_id) {
                 $row_data[] = $user;
             }
             $row_data[] = $rb_tabs[$row['tab']];
             $row_data[] = $link;
             $row_data[] = $action;
             $gb->add_row_array($row_data);
         }
     }
     Base_ThemeCommon::load_css('Utils_RecordBrowser', 'changes_list');
     $this->display_module($gb);
 }
Example #11
0
 public function actions_for_mails($r, $gb_row)
 {
     $gb_row->add_action($this->create_callback_href(array($this, 'copy'), array($r['id'])), 'copy', null, Base_ThemeCommon::get_template_file($this->get_type(), 'copy_small.png'));
     $gb_row->add_action('style="display:none;" href="javascript:void(0)" class="expand"', 'Expand', null, Base_ThemeCommon::get_template_file(Utils_GenericBrowser::module_name(), 'expand.gif'), 5);
     $gb_row->add_action('style="display:none;" href="javascript:void(0)" class="collapse"', 'Collapse', null, Base_ThemeCommon::get_template_file(Utils_GenericBrowser::module_name(), 'collapse.gif'), 5);
 }
Example #12
0
 public function applet($conf, &$opts)
 {
     $opts['go'] = true;
     $gb = $this->init_module(Utils_GenericBrowser::module_name(), null, 'agendaX');
     $columns = array(array('name' => __('Start'), 'order' => 'e.starts', 'width' => 25, 'wrapmode' => 'nowrap'), array('name' => __('Title'), 'order' => 'e.title', 'width' => 50));
     $gb->set_table_columns($columns);
     $start = date('Y-m-d', time());
     $end = date('Y-m-d', time() + $conf['days'] * 24 * 60 * 60);
     $gb->set_default_order(array(__('Start') => 'ASC'));
     CRM_Calendar_EventCommon::$filter = '(' . CRM_FiltersCommon::get_my_profile() . ')';
     $data = array();
     Base_ThemeCommon::load_css('CRM_Calendar', 'agenda');
     $custom_events = DB::GetAssoc('SELECT id, handler_callback FROM crm_calendar_custom_events_handlers ORDER BY group_name');
     $ret = array();
     if (!empty($custom_events)) {
         $c = 0;
         foreach ($custom_events as $id => $cb) {
             if ($conf['events_handlers__' . $id]) {
                 $cb = explode('::', $cb);
                 if (!is_callable($cb)) {
                     continue;
                 }
                 $add = call_user_func($cb, 'get_all', $start, $end, CRM_Calendar_EventCommon::$filter);
                 foreach ($add as $v) {
                     $ret[str_pad($v['start'], 16, '0', STR_PAD_LEFT) . '__' . $c] = $v;
                     $c++;
                 }
             }
         }
     }
     ksort($ret);
     foreach ($ret as $row) {
         if (isset($row['status']) && $row['status'] == 'closed') {
             continue;
         }
         if (!isset($row['view_action'])) {
             $ex = Utils_CalendarCommon::process_event($row);
             $view_action = '<a ' . $this->create_callback_href(array($this, 'view_event'), $row['id']) . '>';
             $ev_id = explode('_', $row['id'], 2);
             $ev_id = $ev_id[0];
         } else {
             $tmp = Utils_CalendarCommon::process_event($row);
             $ex = $row;
             $ex['start'] = $tmp['start'];
             $view_action = '<a ' . $row['view_action'] . '>';
         }
         //////////////////////////
         // left column
         $date = $ex['start'];
         ///////////////////
         // right column
         $title = Utils_TooltipCommon::create($row['title'], $row['custom_tooltip']);
         $day = isset($row['timeless']) && $row['timeless'] ? $row['timeless'] : Base_RegionalSettingsCommon::time2reg($row['start'], false, true, true, false);
         if ($day < date('Y-m-d')) {
             $class = 'past';
         } elseif ($day == date('Y-m-d')) {
             $class = 'today';
         } elseif ($day == date('Y-m-d', strtotime('+1 day'))) {
             $class = 'tomorrow';
         } else {
             $class = 'other';
         }
         $gb_row = $gb->get_new_row();
         $gb_row->set_attrs('class="CRM_Calendar_applet__' . $class . '"');
         $gb_row->add_data(array('value' => $date, 'order_value' => isset($row['timeless']) && $row['timeless'] ? strtotime($row['timeless']) : $row['start']), array('value' => $view_action . $title . '</a>'));
     }
     $this->display_module($gb, array(false), 'automatic_display');
 }
Example #13
0
 public function applet($conf, &$opts)
 {
     $categories = array();
     $methods = DB::GetAssoc('SELECT id,callback FROM utils_watchdog_category');
     foreach ($methods as $k => $v) {
         $methods[$k] = explode('::', $v);
         if (isset($conf['category_' . $k]) && $conf['category_' . $k] && is_numeric($k)) {
             $categories[] = $k;
         }
     }
     if (empty($categories)) {
         print __('No category selected');
         return;
     }
     $records_limit = isset($conf['records_limit']) ? $conf['records_limit'] : 15;
     if ($records_limit == '__all__') {
         $records_limit = null;
     }
     $header = array(array('name' => __('Cat.'), 'width' => 5), array('name' => __('Title'), 'width' => 15));
     if (count($categories) == 1) {
         $title = call_user_func($methods[$categories[0]]);
         $opts['title'] = __('Watchdog - %s', array($title['category']));
         $header = array(array('name' => __('Title')));
     } elseif (count($categories) == count($methods)) {
         $opts['title'] = __('Watchdog - All');
     } else {
         $opts['title'] = __('Watchdog - Selection');
     }
     $only_new = ' AND last_seen_event<(SELECT MAX(id) FROM utils_watchdog_event AS uwe WHERE uwe.internal_id=uws.internal_id AND uwe.category_id=uws.category_id)';
     $records = DB::GetAll('SELECT internal_id,category_id FROM utils_watchdog_subscription AS uws WHERE user_id=%d ' . $only_new . 'AND category_id IN (' . implode(',', $categories) . ')', array(Acl::get_user()));
     $gb = $this->init_module(Utils_GenericBrowser::module_name(), 'subscriptions', 'subscriptions');
     $gb->set_table_columns($header);
     $something_to_purge = false;
     $count = 0;
     foreach ($records as $rec_key => $w) {
         $k = $w['internal_id'];
         $v = $w['category_id'];
         $changes = Utils_WatchdogCommon::check_if_notified($v, $k);
         if (!is_array($changes)) {
             $changes = array();
         }
         $data = call_user_func($methods[$v], $k, $changes);
         if ($data == null) {
             // mark events as seen when user can't see them
             Utils_WatchdogCommon::notified($v, $k);
             unset($records[$rec_key]);
             continue;
         }
         $gb_row = $gb->get_new_row();
         if (count($categories) == 1) {
             $gb_row->add_data($data['title']);
         } else {
             $gb_row->add_data($data['category'], $data['title']);
         }
         $gb_row->add_action(Utils_WatchdogCommon::get_confirm_change_subscr_href($v, $k), 'Stop Watching', __('Click to stop watching this record for changes'), Base_ThemeCommon::get_template_file(Utils_Watchdog::module_name(), 'watching_small_new_events.png'));
         $gb_row->add_action($data['view_href'], 'View');
         if ($only_new || Utils_WatchdogCommon::check_if_notified($v, $k) !== true) {
             $gb_row->set_attrs('name="watchdog_table_row_' . $v . '__' . $k . '"');
             load_js('modules/Utils/Watchdog/applet_mark_as_read.js');
             $gb_row->add_action('href="javascript:void(0);" onclick="watchdog_applet_mark_as_read(\'' . $v . '__' . $k . '\')"', 'Mark as Read', __('Mark as read'), Base_ThemeCommon::get_template_file(Utils_Watchdog::module_name(), 'mark_as_read.png'));
             $something_to_purge = true;
         }
         if (isset($data['events']) && $data['events']) {
             $gb_row->add_info($data['events'], true);
         }
         $count++;
         if ($records_limit && $count >= $records_limit) {
             break;
         }
     }
     $records_qty = count($records);
     if ($records_limit && $count < $records_qty) {
         print __('Displaying %s of %s records', array($count, $records_qty));
     }
     $this->set_module_variable('display_at_time', time());
     if ($something_to_purge) {
         $opts['actions'][] = '<a ' . Utils_TooltipCommon::open_tag_attrs(__('Mark all entries as read')) . ' ' . $this->create_confirm_callback_href(__('This will mark all entries in selected categories as read, are you sure you want to continue?'), array($this, 'purge_subscriptions_applet'), array($categories)) . '><img src="' . Base_ThemeCommon::get_template_file('Utils_Watchdog', 'purge.png') . '" border="0"></a>';
     }
     $this->display_module($gb);
 }
Example #14
0
 public function admin()
 {
     if ($this->is_back()) {
         if ($this->parent->get_type() == 'Base_Admin') {
             $this->parent->reset();
         } else {
             location(array());
         }
         return;
     }
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     $user = $this->get_module_variable('filter_user', '');
     $form = $this->init_module(Libs_QuickForm::module_name(), null, 'filter');
     $form->setDefaults(array('users' => $user));
     $count = DB::GetOne('SELECT COUNT(*) FROM user_login');
     if ($count > Base_User_SettingsCommon::get('Utils_RecordBrowser', 'enable_autocomplete')) {
         $f_callback = array('CRM_LoginAuditCommon', 'user_label');
         $form->addElement('autoselect', 'users', __('Select user'), array(), array(array('CRM_LoginAuditCommon', 'user_suggestbox'), array($f_callback)), $f_callback, array('onChange' => $form->get_submit_form_js(), 'style' => 'width:200px'));
     } else {
         $ret = DB::Execute('SELECT id, active FROM user_login ORDER BY active DESC, login ASC');
         $el = $form->addElement('select', 'users', __('Select user'), array(), array('onChange' => $form->get_submit_form_js(), 'style' => 'width:200px'));
         $el->addOption(__('All'), '');
         $contacts_raw = CRM_ContactsCommon::get_contacts(array('!login' => ''));
         $contacts = array();
         foreach ($contacts_raw as $c) {
             $contacts[$c['login']] = $c;
         }
         $active = array();
         $inactive = array();
         while ($row = $ret->FetchRow()) {
             $label = '[' . Base_UserCommon::get_user_login($row['id']) . ']';
             if (isset($contacts[$row['id']])) {
                 $label = CRM_ContactsCommon::contact_format_no_company($contacts[$row['id']], true) . ' ' . $label;
             }
             if ($row['active']) {
                 $active[$row['id']] = $label;
             } else {
                 $inactive[$row['id']] = $label;
             }
         }
         asort($active);
         asort($inactive);
         foreach ($active as $id => $label) {
             $el->addOption($label, $id);
         }
         foreach ($inactive as $id => $label) {
             $el->addOption($label, $id, array('style' => 'background-color: lightgray;'));
         }
     }
     $user = $form->exportValue('users');
     $form->display_as_row();
     $this->set_module_variable('filter_user', $user);
     $gb = $this->init_module(Utils_GenericBrowser::module_name(), null, 'login_audit');
     $gb->set_table_columns(array(array('name' => '<b>' . __('Login') . '</b> ' . __('[uid] -> User Name'), 'order' => 'b.user_login_id', 'width' => 20), array('name' => __('Start'), 'order' => 'b.start_time', 'width' => 15), array('name' => __('End'), 'order' => 'b.end_time', 'width' => 15), array('name' => __('Duration'), 'width' => 10), array('name' => __('IP Address'), 'order' => 'b.ip_address', 'width' => 10), array('name' => __('Host Name'), 'order' => 'b.host_name', 'width' => 30)));
     $gb->set_default_order(array(__('End') => 'DESC'));
     if ($user > 0) {
         $query = 'SELECT b.user_login_id, b.start_time, b.end_time, b.ip_address, b.host_name FROM base_login_audit b WHERE b.user_login_id=' . $user;
         $query_qty = 'SELECT count(b.id) FROM base_login_audit b WHERE b.user_login_id=' . $user;
     } else {
         $query = 'SELECT b.user_login_id, b.start_time, b.end_time, b.ip_address, b.host_name FROM base_login_audit b';
         $query_qty = 'SELECT count(b.id) FROM base_login_audit b';
     }
     $ret = $gb->query_order_limit($query, $query_qty);
     if ($ret) {
         while ($row = $ret->FetchRow()) {
             $c = CRM_ContactsCommon::get_contact_by_user_id($row['user_login_id']);
             $ulogin = Base_UserCommon::get_user_login($row['user_login_id']);
             $uid = __('Contact not set');
             if ($c) {
                 $uid = $c['first_name'] . ' ' . $c['last_name'];
             }
             $offset = strtotime("1970-01-01 00:00:00");
             $sess_time = date("G:i:s", strtotime($row['end_time']) - strtotime($row['start_time']) + $offset);
             $gb->add_row('<b>' . $ulogin . ' [' . $row['user_login_id'] . ']</b> -> ' . $uid, $row['start_time'], $row['end_time'], $sess_time, $row['ip_address'], $row['host_name']);
         }
     }
     $this->display_module($gb);
     if (!DEMO_MODE) {
         Base_ActionBarCommon::add('settings', __('Maintenance'), $this->create_callback_href(array($this, 'purge_log')));
     }
     return true;
 }
Example #15
0
 public function agenda()
 {
     $theme = $this->pack_module(Base_Theme::module_name());
     Base_ThemeCommon::load_css('Utils_Calendar', 'common');
     /////////////// controls ////////////////////////
     $start =& $this->get_module_variable('agenda_start', date('Y-m-d', $this->date));
     $end =& $this->get_module_variable('agenda_end', date('Y-m-d', $this->date + 7 * 24 * 60 * 60));
     $form = $this->init_module(Libs_QuickForm::module_name(), null, 'agenda_frm');
     $form->addElement('datepicker', 'start', __('From'));
     $form->addElement('datepicker', 'end', __('To'));
     $form->addElement('submit', 'submit_button', __('Show'));
     $form->addRule('start', 'Field required', 'required');
     $form->addRule('end', 'Field required', 'required');
     $form->setDefaults(array('start' => $start, 'end' => $end));
     if ($form->validate()) {
         $data = $form->exportValues();
         $start = $data['start'];
         $end = $data['end'];
         $end = date('Y-m-d', strtotime($end) + 86400);
     }
     $form->assign_theme('form', $theme, new HTML_QuickForm_Renderer_TCMSArraySmarty());
     if (is_callable(array($this->event_module, 'get_navigation_bar_additions'))) {
         $event_module_instance = $this->init_module($this->event_module);
         $navigation_bar_additions = call_user_func(array($event_module_instance, 'get_navigation_bar_additions'), '', '');
     }
     $theme->assign('navigation_bar_additions', $navigation_bar_additions);
     //////////////// data ////////////////////////
     $gb = $this->init_module(Utils_GenericBrowser::module_name(), null, 'agenda');
     $columns = array(array('name' => __('Start'), 'order' => 'start', 'width' => 10), array('name' => __('Duration'), 'order' => 'end', 'width' => 5), array('name' => __('Title'), 'order' => 'title', 'width' => 10));
     $add_cols = array();
     if (is_array($this->settings['custom_agenda_cols'])) {
         $w = 50 / count($this->settings['custom_agenda_cols']);
         foreach ($this->settings['custom_agenda_cols'] as $k => $col) {
             if (!is_array($col)) {
                 $col = array('name' => $col, 'order' => 'cus_col_' . $k, 'width' => $w);
             }
             $columns[] = $col;
             $add_cols[] = $k;
         }
     }
     $gb->set_table_columns($columns);
     $gb->set_default_order(array(__('Start') => 'ASC'));
     //add data
     $ret = $this->get_events($start, $end);
     $this->displayed_events = array('start' => $start, 'end' => $end, 'events' => $ret);
     foreach ($ret as $row) {
         $r = $gb->get_new_row();
         if (isset($row['status']) && $row['status'] == 'closed') {
             continue;
         }
         $view_h = $this->create_callback_href(array($this, 'push_event_action'), array('view', $row['id']));
         $edit_h = $this->create_callback_href(array($this, 'push_event_action'), array('edit', $row['id']));
         $del_h = $this->create_confirm_callback_href(__('Delete this event?'), array($this, 'delete_event'), $row['id']);
         if (isset($row['view_action'])) {
             $view_h = $row['view_action'];
         }
         if (isset($row['edit_action'])) {
             $edit_h = $row['edit_action'];
         }
         if (isset($row['delete_action'])) {
             $del_h = $row['delete_action'];
         }
         $ex = Utils_CalendarCommon::process_event($row);
         $rrr = array(array('value' => $ex['start'], 'order_value' => $row['start']), Utils_TooltipCommon::create($ex['duration'], $ex['end'], false), '<a ' . $view_h . '>' . $row['title'] . '</a>');
         foreach ($add_cols as $a) {
             if (isset($row['custom_agenda_col_' . $a])) {
                 $rrr[] = $row['custom_agenda_col_' . $a];
             } else {
                 $rrr[] = '';
             }
         }
         $r->add_data_array($rrr);
         if ($row['additional_info'] !== '' || $row['additional_info2']) {
             $r->add_info($row['additional_info'] . ($row['additional_info'] !== '' && $row['additional_info2'] !== '' ? '<hr>' : '') . $row['additional_info2']);
         }
         $r->add_action($del_h, 'Delete');
         $r->add_action($edit_h, 'Edit');
         $r->add_action($view_h, 'View');
     }
     $theme->assign('agenda', $this->get_html_of_module($gb, array(false), 'automatic_display'));
     //////////////// display ///////////////
     $theme->display('agenda');
 }
Example #16
0
 public function applet()
 {
     $gb = $this->init_module(Utils_GenericBrowser::module_name(), null, 'agenda');
     $columns = array(array('name' => __('Done'), 'order' => 'done', 'width' => 5), array('name' => __('Start'), 'order' => 'alert_on', 'width' => 15), array('name' => __('Info'), 'width' => 80));
     $gb->set_table_columns($columns);
     $gb->set_default_order(array(__('Start') => 'ASC'));
     $this->lp = $this->init_module('Utils_LeightboxPrompt');
     $this->lp->add_option('holdon_' . 5 * 60, __('5 minutes'), null);
     $this->lp->add_option('holdon_' . 15 * 60, __('15 minutes'), null);
     $this->lp->add_option('holdon_' . 30 * 60, __('30 minutes'), null);
     $this->lp->add_option('holdon_' . 60 * 60, __('1 hour'), null);
     $this->lp->add_option('holdon_' . 240 * 60, __('4 hours'), null);
     $this->lp->add_option('holdon_' . 12 * 3600, __('12 hours'), null);
     $this->lp->add_option('holdon_' . 24 * 3600, __('24 hours'), null);
     $this->display_module($this->lp, array('Hold on', array('alert_id'), '', false));
     $vals = $this->lp->export_values();
     if ($vals) {
         if (preg_match('/^holdon_([0-9]+)$/', $vals['option'], $reqs)) {
             $_SESSION['utils_messenger_holdon'][$vals['params']['alert_id']] = time() + $reqs[1];
         }
     }
     $t = time();
     // postgres compatible interval with type cast
     $interval = DB::is_postgresql() ? '::timestamp - interval \'1 hour\'' : '-INTERVAL 1 hour';
     $ret = DB::Execute('(SELECT u.done,m.* FROM utils_messenger_message m INNER JOIN utils_messenger_users u ON u.message_id=m.id WHERE u.user_login_id=%d AND u.done=0 AND m.alert_on<%T)' . ' UNION ' . '(SELECT u.done,m.* FROM utils_messenger_message m INNER JOIN utils_messenger_users u ON u.message_id=m.id WHERE u.user_login_id=%d AND m.alert_on<%T AND u.done_on>=%T' . $interval . ' AND u.done=1 ORDER BY m.alert_on DESC LIMIT 3)' . ' UNION ' . '(SELECT 0 as done,m.* FROM utils_messenger_message m INNER JOIN utils_messenger_users u ON u.message_id=m.id WHERE u.user_login_id=%d AND m.alert_on>=%T ORDER BY m.alert_on ASC LIMIT 5)' . $gb->get_query_order(), array(Acl::get_user(), $t, Acl::get_user(), $t, $t, Acl::get_user(), $t));
     while ($row = $ret->FetchRow()) {
         $info = call_user_func_array(unserialize($row['callback_method']), unserialize($row['callback_args']));
         $info = str_replace("\n", '<br>', $info);
         $alert_on = Base_RegionalSettingsCommon::time2reg($row['alert_on']);
         $gb->add_row($row['done'] ? '<span class="checkbox_on" />' : '<a ' . Utils_TooltipCommon::open_tag_attrs(__('Turn off alarm')) . ' ' . $this->create_confirm_callback_href(__('Are you sure you want to turn off the alarm?'), array('Utils_MessengerCommon', 'turn_off'), array($row['id'])) . '><span class="checkbox_off" /></a>', $row['done'] || $row['alert_on'] > $t ? $alert_on : '<a ' . Utils_TooltipCommon::open_tag_attrs(__('Hold on')) . ' ' . $this->lp->get_href(array($row['id'])) . '>' . $alert_on . '</a>', $info . '<br>' . ($row['message'] ? __('Alarm comment: %s', array($row['message'])) : ''));
     }
     $this->display_module($gb);
 }
Example #17
0
 public function admin()
 {
     if (ModuleManager::is_installed('CRM_Contacts') >= 0) {
         $this->pack_module('CRM_Contacts', array(), 'user_admin');
         $this->banning_form();
         return;
     }
     if ($this->is_back()) {
         if ($this->parent->get_type() == 'Base_Admin') {
             $this->parent->reset();
         } else {
             location(array());
         }
         return;
     }
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     Base_ActionBarCommon::add('edit', __('E-mail header'), $this->create_callback_href(array($this, 'change_email_header')));
     $gb = $this->init_module(Utils_GenericBrowser::module_name(), null, 'user_list');
     //$gb->set_module_variable('adv_search',false);
     $cols = array();
     $cols[] = array('name' => __('ID'), 'order' => 'u.id', 'width' => 6, 'search' => 'id');
     $cols[] = array('name' => __('Login'), 'order' => 'u.login', 'width' => 20, 'search' => 'login');
     $is_contacts = CRM_ContactsInstall::is_installed();
     if ($is_contacts) {
         $cols[] = array('name' => __('Contact'), 'width' => 27);
     }
     $cols[] = array('name' => __('Active'), 'order' => 'u.active', 'width' => 5);
     $cols[] = array('name' => __('Mail'), 'order' => 'p.mail', 'width' => 20, 'search' => 'mail');
     $cols[] = array('name' => __('Access'), 'width' => '27');
     if (Base_AclCommon::i_am_sa()) {
         $cols[] = array('name' => __('Actions'), 'width' => '80px');
     }
     $gb->set_table_columns($cols);
     $gb->set_default_order(array(__('Login') => 'ASC'));
     $search = $gb->get_search_query();
     $query = 'SELECT u.login, p.mail, u.id, u.active, u.admin FROM user_login u INNER JOIN user_password p on p.user_login_id=u.id' . ($search ? ' WHERE ' . $search : '');
     $query_qty = 'SELECT count(u.id) FROM user_login u INNER JOIN user_password p on p.user_login_id=u.id' . ($search ? ' WHERE ' . $search : '');
     $ret = $gb->query_order_limit($query, $query_qty);
     $yes = '<span style="color:green;">' . __('Yes') . '</span>';
     $no = '<span style="color:red;">' . __('No') . '</span>';
     if ($ret) {
         while ($row = $ret->FetchRow()) {
             $gb_row = array();
             $gb_row[] = $row['id'];
             $gb_row[] = '<a ' . $this->create_callback_href(array($this, 'edit_user_form'), array($row['id'])) . '>' . $row['login'] . '</a>';
             if ($is_contacts) {
                 $c = CRM_ContactsCommon::get_contact_by_user_id($row['id']);
                 $gb_row[] = $c ? CRM_ContactsCommon::contact_format_default($c) : '---';
             }
             $gb_row[] = $row['active'] ? $yes : $no;
             $gb_row[] = $row['mail'];
             switch ($row['admin']) {
                 case 2:
                     $admin = __('Super Administrator');
                     break;
                 case 1:
                     $admin = __('Administrator');
                     break;
                 default:
                     $admin = __('User');
                     break;
             }
             $gb_row[] = $admin;
             if (Base_AclCommon::i_am_sa()) {
                 $gb_row[] = '<a ' . $this->create_callback_href(array($this, 'log_as_user'), $row['id']) . '>' . __('Log as user') . '</a>';
             }
             $gb->add_row_array($gb_row);
         }
     }
     $this->display_module($gb);
     $this->banning_form();
     Base_ActionBarCommon::add('add', __('New user'), $this->create_callback_href(array($this, 'edit_user_form'), array(-1)));
 }
Example #18
0
 public function edit($user_settings_nav = true)
 {
     if ($user_settings_nav) {
         Base_ActionBarCommon::add('back', __('Back'), $this->create_main_href('Base_User_Settings'));
     }
     Base_ActionBarCommon::add('add', __('Add preset'), $this->create_callback_href(array($this, 'edit_group')));
     $gb = $this->init_module(Utils_GenericBrowser::module_name(), null, 'edit');
     $gb->set_table_columns(array(array('name' => __('Name'), 'width' => 20, 'order' => 'g.name'), array('name' => __('Description'), 'width' => 30, 'order' => 'g.description'), array('name' => __('Users in category'), 'width' => 50, 'order' => '')));
     $ret = DB::Execute('SELECT g.name,g.id,g.description FROM crm_filters_group g WHERE g.user_login_id=' . Acl::get_user());
     while ($row = $ret->FetchRow()) {
         $gb_row =& $gb->get_new_row();
         $gb_row->add_action($this->create_confirm_callback_href(__('Delete this group?'), array('CRM_Filters', 'delete_group'), $row['id']), 'Delete');
         $gb_row->add_action($this->create_callback_href(array($this, 'edit_group'), $row['id']), 'Edit');
         $cids = DB::GetAssoc('SELECT c.contact_id, c.contact_id FROM crm_filters_contacts c WHERE c.group_id=%d', array($row['id']));
         $users = array();
         foreach ($cids as $v) {
             $users[] = CRM_ContactsCommon::contact_format_no_company(CRM_ContactsCommon::get_contact($v), true);
         }
         $gb_row->add_data($row['name'], $row['description'], implode(', ', $users));
     }
     $this->display_module($gb);
     $qf = $this->init_module(Libs_QuickForm::module_name(), null, 'default_filter');
     $qf->addElement('checkbox', 'show_all_contacts_in_filters', __('Show all contacts in Perspective selection'), null, array('onChange' => $qf->get_submit_form_js()));
     $qf->addElement('checkbox', 'show_only_users_in_filters', __('Show only users in Perspective selection'), null, array('onChange' => $qf->get_submit_form_js()));
     $qf->setDefaults(array('show_all_contacts_in_filters' => Base_User_SettingsCommon::get('CRM_Contacts', 'show_all_contacts_in_filters'), 'show_only_users_in_filters' => Base_User_SettingsCommon::get('CRM_Contacts', 'show_only_users_in_filters')));
     if ($qf->validate()) {
         $vals = $qf->exportValues();
         if (!isset($vals['show_all_contacts_in_filters'])) {
             $vals['show_all_contacts_in_filters'] = 0;
         }
         if (!isset($vals['show_only_users_in_filters'])) {
             $vals['show_only_users_in_filters'] = 0;
         }
         Base_User_SettingsCommon::save('CRM_Contacts', 'show_all_contacts_in_filters', $vals['show_all_contacts_in_filters']);
         Base_User_SettingsCommon::save('CRM_Contacts', 'show_only_users_in_filters', $vals['show_only_users_in_filters']);
     }
     $qf->display();
 }
Example #19
0
 public static function mobile_table($cols, $data, $enable_sort = true)
 {
     if ($enable_sort && is_string($enable_sort) && !isset($_GET['order'])) {
         $x = explode(' ', $enable_sort);
         foreach ($cols as $i => $v) {
             if ($x[0] == $v['order']) {
                 $_GET['order'] = $i;
             }
         }
         if (isset($_GET['order'])) {
             if (count($x) < 2) {
                 $_GET['order_dir'] = 'asc';
             } else {
                 $_GET['order_dir'] = $x[1];
             }
         }
     }
     $th = Base_ThemeCommon::init_smarty();
     $all_width = 0;
     foreach ($cols as $v) {
         if (array_key_exists('display', $v) && $v['display'] == false) {
             continue;
         }
         if (isset($v['width'])) {
             $all_width += $v['width'];
         }
     }
     $headers = array();
     foreach ($cols as $i => $v) {
         if (array_key_exists('display', $v) && $v['display'] == false) {
             continue;
         }
         if (isset($v['order'])) {
             $is_order = true;
         }
         $headers[$i] = array();
         if (isset($_GET['order']) && isset($_GET['order_dir']) && $i == $_GET['order']) {
             $sort_direction = $_GET['order_dir'] == 'desc' ? 'asc' : 'desc';
             $sort = 'style="padding-right: 12px; background-image: url(' . Base_ThemeCommon::get_template_file('Utils_GenericBrowser', 'sort-' . $sort_direction . 'ending.png') . '); background-repeat: no-repeat; background-position: right;"';
         } else {
             $sort = '';
             $sort_direction = 'asc';
         }
         $headers[$i]['label'] = (isset($v['preppend']) ? $v['preppend'] : '') . (isset($v['order']) ? '<a href="mobile.php?' . http_build_query(array_merge($_GET, array('order' => $i, 'order_dir' => $sort_direction))) . '">' . '<span ' . $sort . '>' . $v['name'] . '</span></a>' : '<span>' . $v['name'] . '</span>') . (isset($v['append']) ? $v['append'] : '');
         $headers[$i]['attrs'] = '';
         if ($all_width && isset($v['width'])) {
             $headers[$i]['attrs'] .= 'style="width: ' . intval(100 * $v['width'] / $all_width) . '%" ';
         }
         $headers[$i]['attrs'] .= 'nowrap="1" ';
     }
     $th->assign('cols', array_values($headers));
     //sort data
     if ($enable_sort && isset($_GET['order']) && isset($_GET['order_dir'])) {
         $col = array();
         foreach ($data as $j => $d) {
             foreach ($d as $i => $c) {
                 if (isset($cols[$i]['order']) && $i == $_GET['order']) {
                     if (is_array($c)) {
                         if (isset($c['order_value'])) {
                             $xxx = $c['order_value'];
                         } else {
                             $xxx = $c['value'];
                         }
                     } else {
                         $xxx = $c;
                     }
                     if (isset($cols[$i]['order_preg'])) {
                         $ret = array();
                         preg_match($cols[$i]['order_preg'], $xxx, $ret);
                         $xxx = isset($ret[1]) ? $ret[1] : '';
                     }
                     $xxx = strip_tags(strtolower($xxx));
                     $col[$j] = $xxx;
                 }
             }
         }
         asort($col);
         $data2 = array();
         foreach ($col as $j => $v) {
             $data2[] = $data[$j];
         }
         if ($_GET['order_dir'] != 'asc') {
             $data2 = array_reverse($data2);
         }
         $data = $data2;
     }
     $out_data = array();
     foreach ($data as $row) {
         foreach ($row as $k => $cell) {
             if (!isset($cols[$k]) || array_key_exists('display', $cols[$k]) && $cols[$k]['display'] == false) {
                 continue;
             }
             if (!is_array($cell)) {
                 $cell .= '&nbsp;';
                 $out_data[] = array('label' => $cell, 'attrs' => '');
             } else {
                 if (!isset($cell['attrs'])) {
                     $cell['attrs'] = '';
                 }
                 if (!isset($cell['label'])) {
                     $cell['label'] = '';
                 }
                 $cell['label'] .= '&nbsp;';
                 $out_data[] = $cell;
             }
         }
     }
     unset($data);
     $th->assign('data', $out_data);
     Base_ThemeCommon::display_smarty($th, Utils_GenericBrowser::module_name(), 'mobile');
 }
Example #20
0
 /**
  * For internal use only.
  */
 public function browse($name = '', $root = true)
 {
     if ($this->is_back()) {
         return false;
     }
     if (isset($_REQUEST['node_position'])) {
         list($node_id, $position) = $_REQUEST['node_position'];
         Utils_CommonDataCommon::change_node_position($node_id, $position);
     }
     $gb = $this->init_module(Utils_GenericBrowser::module_name(), null, 'browse' . md5($name));
     $gb->set_table_columns(array(array('name' => __('Position'), 'width' => 5, 'order' => 'position'), array('name' => __('Key'), 'width' => 20, 'order' => 'akey', 'search' => 1, 'quickjump' => 'akey'), array('name' => __('Value'), 'width' => 20, 'order' => 'value', 'search' => 1)));
     print '<h2>' . $name . '</h2><br>';
     $ret = Utils_CommonDataCommon::get_translated_array($name, true, true);
     foreach ($ret as $k => $v) {
         $gb_row = $gb->get_new_row();
         $gb_row->add_data($v['position'], $k, $v['value']);
         // ****** CommonData value translation
         $gb_row->add_action($this->create_callback_href(array($this, 'browse'), array($name . '/' . $k, false)), 'View');
         if (!$v['readonly']) {
             $gb_row->add_action($this->create_callback_href(array($this, 'edit'), array($name, $k)), 'Edit');
             $gb_row->add_action($this->create_confirm_callback_href(__('Delete array') . ' \'' . Epesi::escapeJS($name . '/' . $k, false) . '\'?', array('Utils_CommonData', 'remove_array'), array($name . '/' . $k)), 'Delete');
         }
         $node_id = $v['id'];
         $gb_row->add_action('class="move-handle"', 'Move', __('Drag to change node order'), 'move-up-down');
         $gb_row->set_attrs("node=\"{$node_id}\" class=\"sortable\"");
     }
     $gb->set_default_order(array(__('Position') => 'ASC'));
     //$this->display_module($gb);
     $this->display_module($gb, array(true), 'automatic_display');
     // sorting
     load_js($this->get_module_dir() . 'sort_nodes.js');
     $table_md5 = md5($gb->get_path());
     eval_js("utils_commondata_sort_nodes_init(\"{$table_md5}\")");
     Base_ActionBarCommon::add('settings', __('Reset Order By Key'), $this->create_callback_href(array('Utils_CommonDataCommon', 'reset_array_positions'), $name));
     Base_ActionBarCommon::add('add', __('Add array'), $this->create_callback_href(array($this, 'edit'), $name));
     if (!$root) {
         Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     }
     return true;
 }
Example #21
0
 public function construct()
 {
     $this->gb = $this->init_module(Utils_GenericBrowser::module_name(), null, 'report_page');
 }
Example #22
0
 private function summary()
 {
     if ($this->rows_qty != 0) {
         return __('Records %s to %s of %s', array('<b>' . ($this->get_module_variable('offset') + 1) . '</b>', '<b>' . ($this->get_module_variable('offset') + $this->get_module_variable('per_page') > $this->rows_qty ? $this->rows_qty : $this->get_module_variable('offset') + $this->get_module_variable('per_page')) . '</b>', '<b>' . $this->rows_qty . '</b>'));
     } else {
         if ((isset($this->rows_qty) || !isset($this->rows_qty) && empty($this->rows)) && !Base_User_SettingsCommon::get(Utils_GenericBrowser::module_name(), 'display_no_records_message')) {
             return __('No records found');
         } else {
             return '';
         }
     }
 }
Example #23
0
 public function display_activities($events, $tasks, $phonecalls)
 {
     $gb = $this->init_module(Utils_GenericBrowser::module_name(), 'activities', 'activities');
     $gb->set_table_columns(array(array('name' => __('Type'), 'wrapmode' => 'nowrap', 'width' => 8), array('name' => __('Subject'), 'width' => 20), array('name' => __('Date/Deadline'), 'wrapmode' => 'nowrap', 'width' => 8), array('name' => __('Employees'), 'width' => 11), array('name' => __('Customers'), 'width' => 11), array('name' => __('Attachments'), 'width' => 4)));
     $amount = 0;
     if ($this->display['events']) {
         $amount += count($events);
     }
     if ($this->display['tasks']) {
         $amount += count($tasks);
     }
     if ($this->display['phonecalls']) {
         $amount += count($phonecalls);
     }
     $limit = $gb->get_limit($amount);
     for ($i = 0; $i < $limit['offset'] + $limit['numrows'] && $i < $amount; $i++) {
         if ($this->display['events'] && count($events)) {
             $ev = current($events);
         } else {
             $ev = array('start' => -1);
         }
         if ($this->display['tasks'] && count($tasks)) {
             $t = current($tasks);
             if (!$t['deadline']) {
                 $t['deadline'] = 0;
             } else {
                 $t['deadline'] = strtotime($t['deadline']);
             }
         } else {
             $t = array('deadline' => -1);
         }
         if ($this->display['phonecalls'] && count($phonecalls)) {
             $ph = current($phonecalls);
             $ph['date_and_time'] = strtotime($ph['date_and_time']);
         } else {
             $ph = array('date_and_time' => -1);
         }
         $maxt = max($ev['start'], $t['deadline'], $ph['date_and_time']);
         $gb_row = $gb->get_new_row();
         if ($ev['start'] == $maxt) {
             $v = array_shift($events);
             if ($i >= $limit['offset'] && $v) {
                 if (isset($v['view_action'])) {
                     $view_href = $v['view_action'];
                 } else {
                     $view_href = $this->create_callback_href(array($this, 'view_event'), array($v['id']));
                 }
                 $title = '<a ' . $view_href . '>' . $v['title'] . '</a>';
                 if (isset($v['description']) && $v['description'] != '') {
                     $title = '<span ' . Utils_TooltipCommon::open_tag_attrs($v['description'], false) . '>' . $title . '</span>';
                 }
                 $gb_row->add_info(Utils_RecordBrowserCommon::get_html_record_info('crm_meeting', $v['id']));
                 $gb_row->add_data(__('Meeting'), $title, Base_RegionalSettingsCommon::time2reg($v['start'], $v['duration'] == -1 ? false : 2), CRM_ContactsCommon::display_contact(array('employees' => $v['employees']), false, array('id' => 'employees', 'param' => ';CRM_ContactsCommon::contact_format_no_company')), CRM_ContactsCommon::display_company_contact(array('customers' => $v['customers']), false, array('id' => 'customers', 'param' => ';::')), Utils_AttachmentCommon::count('crm_meeting/' . $v['id']));
             }
         } elseif ($t['deadline'] == $maxt) {
             $v = array_shift($tasks);
             $v = Utils_RecordBrowserCommon::filter_record_by_access('task', $v);
             if ($i >= $limit['offset'] && $v) {
                 $gb_row->add_info(Utils_RecordBrowserCommon::get_html_record_info('task', $v['id']));
                 $gb_row->add_data(__('Task'), CRM_TasksCommon::display_title($v, false), !isset($v['deadline']) || !$v['deadline'] ? __('No deadline') : Base_RegionalSettingsCommon::time2reg($v['deadline'], false, true, false), CRM_ContactsCommon::display_contact($v, false, array('id' => 'employees', 'param' => ';CRM_ContactsCommon::contact_format_no_company')), CRM_ContactsCommon::display_company_contact($v, false, array('id' => 'customers')), Utils_AttachmentCommon::count('task/' . $v['id']));
             }
         } else {
             $v = array_shift($phonecalls);
             $v = Utils_RecordBrowserCommon::filter_record_by_access('phonecall', $v);
             if ($i >= $limit['offset'] && $v) {
                 $gb_row->add_info(Utils_RecordBrowserCommon::get_html_record_info('phonecall', $v['id']));
                 $gb_row->add_data(__('Phonecall'), CRM_PhoneCallCommon::display_subject($v), Base_RegionalSettingsCommon::time2reg($v['date_and_time'], 2), CRM_ContactsCommon::display_contact($v, false, array('id' => 'employees', 'param' => ';CRM_ContactsCommon::contact_format_no_company')), CRM_PhoneCallCommon::display_contact_name($v, false), Utils_AttachmentCommon::count('phonecall/' . $v['id']));
             }
         }
     }
     $this->display_module($gb);
 }
Example #24
0
 public function history($uid = null)
 {
     $th = $this->init_module(Base_Theme::module_name());
     $th->assign('header', __('Shoutbox History'));
     $qf = $this->init_module(Libs_QuickForm::module_name());
     if (ModuleManager::is_installed('CRM_Contacts') >= 0) {
         $emps = DB::GetAssoc('SELECT l.id,' . DB::ifelse('cd.f_last_name!=\'\'', DB::concat('cd.f_last_name', DB::qstr(' '), 'cd.f_first_name'), 'l.login') . ' as name FROM user_login l LEFT JOIN contact_data_1 cd ON (cd.f_login=l.id AND cd.active=1) WHERE l.active=1 ORDER BY name');
     } else {
         $emps = DB::GetAssoc('SELECT id,login FROM user_login WHERE active=1 ORDER BY login');
     }
     $qf->addElement('select', 'user', __('User'), array('all' => '[' . __('All') . ']') + $emps);
     $qf->addElement('datepicker', 'from_date', __('From'));
     $qf->addElement('datepicker', 'to_date', __('To'));
     $qf->addElement('text', 'search', __('Search for'));
     $qf->addElement('submit', 'submit_button', __('Filter'));
     $to_date =& $this->get_module_variable('to_date');
     $from_date =& $this->get_module_variable('from_date');
     $user =& $this->get_module_variable('to', "all");
     $qf->setDefaults(array('from_date' => $from_date, 'to_date' => $to_date, 'user' => $uid));
     //if submited
     if ($qf->validate()) {
         $from_date = $qf->exportValue('from_date');
         $to_date = $qf->exportValue('to_date');
         $user = $qf->exportValue('user');
         $search_word = $qf->exportValue('search');
     }
     $qf->assign_theme('form', $th);
     $uid = is_numeric($user) ? $user : null;
     $date_where = '';
     if ($from_date) {
         $date_where .= 'AND posted_on>=' . DB::DBDate($from_date);
     }
     if ($to_date) {
         $date_where .= 'AND posted_on<=' . DB::DBDate($to_date);
     }
     if (isset($search_word) && $search_word) {
         $search_word = explode(' ', $search_word);
         foreach ($search_word as $word) {
             if ($word) {
                 $date_where .= ' AND message ' . DB::like() . ' ' . DB::Concat(DB::qstr('%'), DB::qstr(htmlspecialchars($word, ENT_QUOTES, 'UTF-8')), DB::qstr('%'));
             }
         }
     }
     $gb = $this->init_module(Utils_GenericBrowser::module_name(), null, 'shoutbox_history');
     $gb->set_table_columns(array(array('name' => __('From'), 'width' => 10), array('name' => __('To'), 'width' => 10), array('name' => __('Message'), 'width' => 64), array('name' => __('Date'), 'width' => 16)));
     // $gb->set_default_order(array(__('Date')=>'DESC'));
     $myid = Base_AclCommon::get_user();
     $where = '(' . ($uid ? '(base_user_login_id=' . $myid . ' AND to_user_login_id=' . $uid . ') OR (base_user_login_id=' . $uid . ' AND to_user_login_id=' . $myid . ') OR (to_user_login_id is null AND base_user_login_id=' . $uid . ')' : 'to_user_login_id is null OR to_user_login_id=' . $myid . ' OR base_user_login_id=' . $myid) . ')' . $date_where;
     $query = 'SELECT base_user_login_id, to_user_login_id, message, posted_on FROM apps_shoutbox_messages WHERE ' . $where . ' ORDER BY posted_on DESC';
     $query_qty = 'SELECT count(id) FROM apps_shoutbox_messages WHERE ' . $where;
     $ret = $gb->query_order_limit($query, $query_qty);
     if ($ret) {
         while ($row = $ret->FetchRow()) {
             $ulogin = Base_UserCommon::get_user_label($row['base_user_login_id']);
             if ($row['to_user_login_id'] !== null) {
                 $tologin = Base_UserCommon::get_user_label($row['to_user_login_id']);
             } else {
                 $tologin = '******' . __('All') . ']';
             }
             $gb->add_row('<span class="author">' . $ulogin . '</span>', '<span class="author">' . $tologin . '</span>', array('value' => Utils_BBCodeCommon::parse($row['message']), 'overflow_box' => false), Base_RegionalSettingsCommon::time2reg($row['posted_on']));
         }
     }
     $gb->set_inline_display(true);
     $th->assign('messages', $this->get_html_of_module($gb));
     $th->display();
     return true;
 }
Example #25
0
 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;
 }
Example #26
0
 protected function GB_generic(Utils_GenericBrowser $gb, array $items, $banned_columns = array(), $row_data_transform_callback = null, $row_additional_actions_callback = null)
 {
     if (count($items)) {
         // add column headers
         $first_el = reset($items);
         if ($row_data_transform_callback != null && is_callable($row_data_transform_callback)) {
             $first_el = call_user_func($row_data_transform_callback, $first_el);
         }
         $columns = array();
         foreach ($first_el as $k => $v) {
             if (in_array($k, $banned_columns)) {
                 continue;
             }
             $columns[] = array('name' => ucwords(str_replace('_', ' ', $k)));
         }
         $gb->set_table_columns($columns);
         // add elements
         foreach ($items as $r) {
             $v = array();
             $r_modified = $r;
             if ($row_data_transform_callback != null && is_callable($row_data_transform_callback)) {
                 $r_modified = call_user_func($row_data_transform_callback, $r);
             }
             foreach ($r_modified as $k => $x) {
                 if (in_array($k, $banned_columns)) {
                     continue;
                 }
                 $v[] = $x;
             }
             /* @var $row Utils_GenericBrowser_Row_Object */
             $row = $gb->get_new_row();
             $row->add_data_array($v);
             if ($row_additional_actions_callback != null && is_callable($row_additional_actions_callback)) {
                 call_user_func($row_additional_actions_callback, $row, $r);
             }
         }
     }
     return $gb;
 }