Esempio n. 1
0
 public function body()
 {
     $t = $this->pack_module('Base/Theme');
     //caption
     $box_module = ModuleManager::get_instance('/Base_Box|0');
     if ($box_module) {
         $active_module = $box_module->get_main_module();
     }
     if ($active_module && is_callable(array($active_module, 'caption'))) {
         $caption = $active_module->caption();
         if (Variable::get('show_module_indicator')) {
             $t->assign('text', $caption);
         } else {
             $t->assign('text', '');
         }
         $show_caption = Variable::get('show_caption_in_title');
         $maintenance_mode = MaintenanceMode::is_on() ? ' (Maintenance mode)' : '';
         $base_title = Variable::get('base_page_title') . $maintenance_mode;
         if ($show_caption || strlen($base_title) > 0) {
             if ($show_caption && strlen($base_title) > 0) {
                 $caption = $base_title . ' - ' . $caption;
             } elseif (strlen($base_title) > 0) {
                 $caption = $base_title;
             }
             eval_js('document.title=\'' . addslashes($caption) . '\'');
         }
     } else {
         $t->assign('text', '');
         eval_js('document.title=\'' . addslashes(Variable::get('base_page_title')) . '\'');
     }
     $t->display();
 }
Esempio n. 2
0
 public static function submit_contact($values, $mode)
 {
     if ($mode == 'display') {
         $ret = array();
         $in = self::Instance();
         $filename = self::get_photo($values['id']);
         if ($filename) {
             $file = $in->get_data_dir() . $filename;
         } else {
             $file = Base_ThemeCommon::get_template_file('CRM/Contacts/Photo', 'placeholder.png');
             $ret['photo_note'] = __('Click to change');
         }
         $ret['photo_link'] = Module::create_href(array('upload_new_photo' => $values['id'])) . ' ' . Utils_TooltipCommon::open_tag_attrs(__('Click to change the photo'), false);
         $ret['photo_src'] = $file;
     } else {
         $ret = $values;
     }
     if (isset($_REQUEST['upload_new_photo']) && $_REQUEST['upload_new_photo'] == $values['id']) {
         unset($_REQUEST['upload_new_photo']);
         $x = ModuleManager::get_instance('/Base_Box|0');
         if (!$x) {
             trigger_error('There is no base box module instance', E_USER_ERROR);
         }
         $x->push_main('CRM/Contacts/Photo', 'body', array($values));
     }
     return $ret;
 }
Esempio n. 3
0
 public function back_to_calendar()
 {
     $x = ModuleManager::get_instance('/Base_Box|0');
     if (!$x) {
         trigger_error('There is no base box module instance', E_USER_ERROR);
     }
     $x->pop_main();
 }
Esempio n. 4
0
 public function manage_filters()
 {
     $x = ModuleManager::get_instance('/Base_Box|0');
     if (!$x) {
         trigger_error('There is no base box module instance', E_USER_ERROR);
     }
     $x->push_main($this->get_type(), 'edit', array(false));
 }
Esempio n. 5
0
 public function push_box0($func, $args, $const_args)
 {
     $x = ModuleManager::get_instance('/Base_Box|0');
     if (!$x) {
         trigger_error('There is no base box module instance', E_USER_ERROR);
     }
     $x->push_main('Utils/Messenger', $func, $args, $const_args);
 }
Esempio n. 6
0
 public function this_stack()
 {
     $x = ModuleManager::get_instance('/Base_Box|0');
     if (!$x) {
         trigger_error('There is no base box module instance', E_USER_ERROR);
     }
     $x->push_main('Tests/Callbacks', 'body');
     return true;
 }
Esempio n. 7
0
 public static function fax_file($f, $oryg)
 {
     $tmp = self::Instance()->get_data_dir() . $oryg;
     copy($f, $tmp);
     $x = ModuleManager::get_instance('/Base_Box|0');
     if (!$x) {
         trigger_error('There is no base box module instance', E_USER_ERROR);
     }
     $x->push_main('CRM_Fax', 'send', $tmp);
 }
Esempio n. 8
0
 public static function view_event($func, $def)
 {
     $x = ModuleManager::get_instance('/Base_Box|0');
     if (!$x) {
         trigger_error('There is no base box module instance', E_USER_ERROR);
     }
     if ($func == 'add') {
         $def = array(date('Y-m-d H:i:s'), false, $def);
     }
     $x->push_main('CRM_Calendar_Event', $func, $def);
 }
Esempio n. 9
0
 public function body($record)
 {
     $form = $this->init_module('Utils/FileUpload', array(false));
     $form->addElement('header', 'upload', __('Upload new photo') . ': ' . $record['last_name'] . ' ' . $record['first_name']);
     $form->set_upload_button_caption(__('Save'));
     $form->add_upload_element();
     Base_ActionBarCommon::add('save', __('Save'), $form->get_submit_form_href());
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     if (CRM_Contacts_PhotoCommon::get_photo($record['id'])) {
         Base_ActionBarCommon::add('delete', __('Clear'), $this->create_confirm_callback_href(__('Are you sure?'), array($this, 'clear_photo'), array($record['id'])));
     }
     $this->display_module($form, array(array($this, 'submit_attach'), $record));
     if ($this->is_back() || $this->submitted) {
         $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();
     }
 }
Esempio n. 10
0
 public function body()
 {
     /* Do not delete anything - all messages are kept in history
     		// to allow delete by admin uncomment below lines
     		// if i am admin add "clear shoutbox" actionbar button
     		if(Base_AclCommon::i_am_admin())
     			Base_ActionBarCommon::add('delete',__('Clear shoutbox'),$this->create_callback_href(array($this,'delete_all')));
     		*/
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     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);
         }
         $x->pop_main();
         return;
     }
     $tb = $this->init_module(Utils_TabbedBrowser::module_name());
     $tb->set_tab(__('Chat'), array($this, 'chat'), true, null);
     $tb->set_tab(__('History'), array($this, 'history'), null);
     $this->display_module($tb);
 }
Esempio n. 11
0
 public function body($branch = null, $admin_settings = false)
 {
     $branch = $this->get_module_variable_or_unique_href_variable('settings_branch', $branch);
     if ($branch !== null && $this->is_back()) {
         $branch = null;
     }
     if ($branch === null) {
         if ($this->is_back()) {
             if ($this->parent->get_type() == 'Base_Admin') {
                 $this->parent->reset();
             } else {
                 location(array());
             }
             return;
         }
         if ($this->parent->get_type() == 'Base_Admin') {
             Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
         }
     }
     $this->set_module_variable('settings_branch', $branch);
     $this->get_module_variable('admin_settings', $admin_settings);
     if (!$branch) {
         $x = ModuleManager::get_instance('/Base_Box|0');
         if (!$x) {
             trigger_error('There is no base box module instance', E_USER_ERROR);
         }
         $mains = $x->get_module_variable('main');
         if (count($mains) > 1) {
             $x->pop_main();
         } else {
             $this->main_page();
         }
         return;
     }
     $f = $this->init_module('Libs/QuickForm', __('Saving settings'), 'settings');
     $f->addElement('header', null, $branch);
     $this->indicator = ': ' . $branch;
     $this->settings_fields = array();
     $this->set_default_js = '';
     $us = ModuleManager::call_common_methods('user_settings');
     foreach ($us as $name => $menu) {
         if (!is_array($menu)) {
             continue;
         }
         foreach ($menu as $k => $v) {
             if ($k == $branch) {
                 if (is_string($v)) {
                     Base_BoxCommon::location($name, $v);
                 } else {
                     $this->add_module_settings_to_form($v, $f, $name);
                 }
             }
         }
     }
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     Base_ActionBarCommon::add('save', __('Save'), $f->get_submit_form_href());
     Base_ActionBarCommon::add('settings', __('Restore Defaults'), 'href="javascript:void(0)" onClick="' . $this->set_default_js . '"');
     if ($f->validate()) {
         $this->submit_settings($f->exportValues());
         $this->set_back_location();
     } else {
         $f->display();
     }
     return;
 }
Esempio n. 12
0
 private static function _base_box_instance()
 {
     $x = ModuleManager::get_instance('/Base_Box|0');
     if (!$x) {
         trigger_error('There is no base box module instance', E_USER_ERROR);
     }
     return $x;
 }
Esempio n. 13
0
 public function edit_user_form($edit_id)
 {
     if ($this->is_back()) {
         if ($this->parent->get_type() != 'Base_Admin') {
             $x = ModuleManager::get_instance('/Base_Box|0');
             if (!$x) {
                 trigger_error('There is no base box module instance', E_USER_ERROR);
             }
             $x->pop_main();
         }
         return false;
     }
     $form = $this->init_module(Libs_QuickForm::module_name(), $edit_id >= 0 ? __('Applying changes') : __('Creating new user'));
     //create new user
     $form->addElement('header', null, $edit_id >= 0 ? __('Edit user') : __('Create new user'));
     $form->addElement('hidden', $this->create_unique_key('edit_user'), $edit_id);
     $form->addElement('text', 'username', __('Username'));
     // require a username
     $form->addRule('username', __('A username must be between 3 and 32 chars'), 'rangelength', array(3, 32));
     $form->addRule('username', __('Field required'), 'required');
     $form->addElement('text', 'mail', __('E-mail'));
     $form->addRule('mail', __('Field required'), 'required');
     $form->addRule('mail', __('Invalid e-mail address'), 'email');
     $form->addElement('select', 'admin', __('Administrator'), array(0 => __('No'), 1 => __('Administrator'), 2 => __('Super Administrator')));
     if ($edit_id < 0) {
         $form->addElement('html', '<tr><td colspan=2><b>' . __('If you leave password fields empty random password is automatically generated and e-mailed to the user.') . '</b></td></tr>');
     } else {
         $form->addElement('html', '<tr><td colspan=2><b>' . __('If you leave password fields empty, password is not changed.') . '</b></td></tr>');
     }
     //$form->addElement('header',null,__('If you leave this fields empty, password is not changed.'));
     $form->addElement('password', 'pass', __('Password'));
     $form->addElement('password', 'pass_c', __('Confirm Password'));
     $form->addRule(array('pass', 'pass_c'), __('Passwords don\'t match'), 'compare');
     $form->addRule('pass', __('Your password must be longer then 5 chars'), 'minlength', 5);
     if ($edit_id >= 0) {
         $form->addElement('select', 'active', __('Active'), array(1 => __('Yes'), 0 => __('No')));
         //set defaults
         $ret = DB::Execute('SELECT u.login, p.mail, u.active, u.admin FROM user_login u INNER JOIN user_password p ON (p.user_login_id=u.id) WHERE u.id=%d', $edit_id);
         if ($ret && ($row = $ret->FetchRow())) {
             $form->setDefaults(array('username' => $row['login'], 'mail' => $row['mail'], 'active' => $row['active'], 'admin' => $row['admin']));
         }
     }
     $form->registerRule('check_username', 'callback', 'check_username_free', 'Base_User_LoginCommon');
     $form->addRule(array('username', $this->create_unique_key('edit_user')), __('Username already taken'), 'check_username');
     if ($form->validate()) {
         if ($form->process(array(&$this, 'submit_edit_user_form'))) {
             if ($this->parent->get_type() != 'Base_Admin') {
                 $x = ModuleManager::get_instance('/Base_Box|0');
                 if (!$x) {
                     trigger_error('There is no base box module instance', E_USER_ERROR);
                 }
                 $x->pop_main();
             }
             return false;
         }
     } else {
         $form->display();
     }
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     Base_ActionBarCommon::add('save', __('Save'), $form->get_submit_form_href());
     if (Base_AclCommon::i_am_sa() && $edit_id >= 0) {
         Base_ActionBarCommon::add('settings', __('Log as user'), $this->create_callback_href(array($this, 'log_as_user'), $edit_id));
     }
     return true;
 }
Esempio n. 14
0
 public function company_addon_new_contact($id)
 {
     $x = ModuleManager::get_instance('/Base_Box|0');
     if (!$x) {
         trigger_error('There is no base box module instance', E_USER_ERROR);
     }
     $x->push_main('CRM/Contacts', 'new_contact', $id, array());
     return false;
 }
Esempio n. 15
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;
 }
Esempio n. 16
0
 public static function check_for_jump()
 {
     if (isset($_REQUEST['__jump_to_RB_table']) && isset($_REQUEST['__jump_to_RB_record'])) {
         $tab = $_REQUEST['__jump_to_RB_table'];
         $id = $_REQUEST['__jump_to_RB_record'];
         $action = $_REQUEST['__jump_to_RB_action'];
         if (!is_numeric($id)) {
             return false;
         }
         Utils_RecordBrowserCommon::check_table_name($tab);
         if (!self::get_access($tab, 'browse')) {
             return false;
         }
         if (!DB::GetOne('SELECT id FROM ' . $tab . '_data_1 WHERE id=%d', $id)) {
             return false;
         }
         unset($_REQUEST['__jump_to_RB_record']);
         unset($_REQUEST['__jump_to_RB_table']);
         unset($_REQUEST['__jump_to_RB_action']);
         $x = ModuleManager::get_instance('/Base_Box|0');
         if (!$x) {
             trigger_error('There is no base box module instance', E_USER_ERROR);
         }
         $x->push_main(Utils_RecordBrowser::module_name(), 'view_entry_with_REQUEST', array($action, $id, array(), true, $_REQUEST), array($tab));
         return true;
     }
     return false;
 }
Esempio n. 17
0
 public static function get_status_change_leightbox_href($record, $nolink, $desc)
 {
     if ($nolink) {
         return false;
     }
     $prefix = 'crm_meeting_leightbox';
     CRM_FollowupCommon::drawLeightbox($prefix);
     $v = $record[$desc['id']];
     if (!$v) {
         $v = 0;
     }
     $status = Utils_CommonDataCommon::get_translated_array('CRM/Status');
     if (!Utils_RecordBrowserCommon::get_access('crm_meeting', 'edit', $record) && !Base_AclCommon::i_am_admin()) {
         return false;
     }
     if ($v >= 2) {
         return false;
     }
     if (isset($_REQUEST['form_name']) && $_REQUEST['form_name'] == $prefix . '_follow_up_form' && $_REQUEST['id'] == $record['id']) {
         unset($_REQUEST['form_name']);
         $v = $_REQUEST['closecancel'];
         $action = $_REQUEST['action'];
         $note = $_REQUEST['note'];
         if ($note) {
             if (get_magic_quotes_gpc()) {
                 $note = stripslashes($note);
             }
             $note = str_replace("\n", '<br />', $note);
             Utils_AttachmentCommon::add('crm_meeting/' . $record['id'], 0, Acl::get_user(), $note);
         }
         if ($action == 'set_in_progress') {
             $v = 1;
         }
         Utils_RecordBrowserCommon::update_record('crm_meeting', $record['id'], array('status' => $v));
         if ($action == 'set_in_progress') {
             location(array());
         }
         $values = $record;
         $values['date_and_time'] = date('Y-m-d H:i:s');
         $values['title'] = __('Follow-up') . ': ' . $values['title'];
         $values['status'] = 0;
         if ($action != 'none') {
             $x = ModuleManager::get_instance('/Base_Box|0');
             $values['follow_up'] = array('meeting', $record['id'], $record['title']);
             if ($action == 'new_meeting') {
                 $x->push_main('Utils/RecordBrowser', 'view_entry', array('add', null, $values), array('crm_meeting'));
             }
             if ($action == 'new_task') {
                 $x->push_main('Utils/RecordBrowser', 'view_entry', array('add', null, array('title' => $values['title'], 'permission' => $values['permission'], 'priority' => $values['priority'], 'description' => $values['description'], 'deadline' => date('Y-m-d H:i:s', strtotime('+1 day')), 'employees' => $values['employees'], 'customers' => $values['customers'], 'status' => 0, 'follow_up' => $values['follow_up'])), array('task'));
             }
             if ($action == 'new_phonecall') {
                 $x->push_main('Utils/RecordBrowser', 'view_entry', array('add', null, array('subject' => $values['title'], 'permission' => $values['permission'], 'priority' => $values['priority'], 'description' => $values['description'], 'date_and_time' => date('Y-m-d H:i:s'), 'employees' => $values['employees'], 'status' => 0, 'customer' => !empty($values['customers']) ? array_pop($values['customers']) : '', 'follow_up' => $values['follow_up'])), array('phonecall'));
             }
             return false;
         }
         location(array());
     }
     if ($v == 0) {
         return ' href="javascript:void(0)" onclick="' . $prefix . '_set_action(\'set_in_progress\');' . $prefix . '_set_id(\'' . $record['id'] . '\');' . $prefix . '_submit_form();"';
     }
     return ' href="javascript:void(0)" class="lbOn" rel="' . $prefix . '_followups_leightbox" onMouseDown="' . $prefix . '_set_id(' . $record['id'] . ');"';
 }
Esempio n. 18
0
    public function search_by_id_form($label) {
        $message = '';
        $form = $this->init_module('Libs/QuickForm');
        $theme = $this->init_module('Base/Theme');
        $form->addElement('text', 'record_id', $label);
        $form->addRule('record_id', __('Must be a number'), 'numeric');
        $form->addRule('record_id', __('Field required'), 'required');
        $ret = false;
		if ($form->isSubmitted())
            $ret = true;
        if ($form->validate()) {
            $id = $form->exportValue('record_id');
            if (!is_numeric($id)) trigger_error('Invalid id',E_USER_ERROR);
            $r = Utils_RecordBrowserCommon::get_record($this->tab,$id);
            if (!$r || empty($r)) $message = __('There is no such record').'<br>';
            else if (!$r[':active']) $message = __('This record was deleted from the system').'<br>';
            else {
                $x = ModuleManager::get_instance('/Base_Box|0');
                if (!$x) trigger_error('There is no base box module instance',E_USER_ERROR);
                $x->push_main('Utils/RecordBrowser','view_entry',array('view', $id),array($this->tab));
                return;
            }
        }
        $form->assign_theme('form', $theme);
        $theme->assign('message', $message);
        $theme->display('search_by_id');
        return $ret;
    }
Esempio n. 19
0
 public function cancel()
 {
     $GLOBALS['rpfs_old_sel'] = $this->get_module_variable('old_selected', array());
     $x = ModuleManager::get_instance('/Base_Box|0');
     $x->pop_main();
 }
Esempio n. 20
0
 public static function mail_file($f, $d, $file_id)
 {
     $t = time() + 3600 * 24 * 7;
     $url = Utils_AttachmentCommon::create_remote($file_id, 'mail', $t);
     $x = ModuleManager::get_instance('/Base_Box|0');
     $x->push_main('CRM_Roundcube', 'new_mail', array('', __('File attachment, expires on: %s', array(Base_RegionalSettingsCommon::time2reg($t))), "<br /><br />" . $url));
 }
Esempio n. 21
0
 public function body()
 {
     if (isset(Base_BoxCommon::$override_box_main)) {
         $this->pack_module(Base_BoxCommon::$override_box_main);
         return;
     }
     $theme = $this->pack_module('Base/Theme');
     $ini = Base_BoxCommon::get_ini_file();
     if (!$ini) {
         print __('Unable to read Base/Box/default.ini file! Please create one, or change theme.');
         $this->pack_module('Base/Theme/Administrator', null, 'admin');
         return;
     }
     $ini_file = parse_ini_file($ini, true);
     $logged = Base_AclCommon::is_user();
     $theme->assign('logged', $logged);
     $containers = array();
     $containers['main'] = array('module' => null, 'name' => '');
     //so 'main' is first in array
     $name = 0;
     foreach ($ini_file as $tag => $opts) {
         $name++;
         if ($logged && $opts['display'] == 'anonymous' || !$logged && $opts['display'] == 'logged') {
             continue;
         }
         if (isset($opts['function'])) {
             $containers[$tag]['function'] = $opts['function'];
             $containers[$tag]['arguments'] = null;
         }
         if (isset($opts['arguments'])) {
             $containers[$tag]['arguments'] = $opts['arguments'];
         }
         if (isset($opts['module'])) {
             $containers[$tag]['module'] = $opts['module'];
         } else {
             trigger_error('No module specified.', E_USER_ERROR);
         }
         $containers[$tag]['name'] = $tag;
     }
     if (isset($containers['main'])) {
         $containers['main']['name'] = 'main_0';
     }
     if (isset($_REQUEST['base_box_pop_main'])) {
         $pop_main = $_REQUEST['base_box_pop_main'];
         unset($_REQUEST['base_box_pop_main']);
     } else {
         $pop_main = false;
     }
     if ($this->isset_module_variable('main')) {
         $mains = $this->get_module_variable('main');
         if ($pop_main) {
             while ($pop_main--) {
                 array_pop($mains);
             }
             $pop_main = true;
         }
         $main = array_pop($mains);
         if (isset($main['module']) && $main['module'] != null) {
             $containers['main'] =& $main;
         }
         foreach ($mains as $k => $m) {
             if (ModuleManager::is_installed($m['module']) >= 0) {
                 $this->freeze_module($m['module'], isset($m['name']) ? $m['name'] : null);
             }
         }
     } else {
         $mains = array();
     }
     if (isset($_REQUEST['box_main_href'])) {
         if (!isset($_SESSION['client']['base_box_hrefs'])) {
             $_SESSION['client']['base_box_hrefs'] = array();
         }
         $hs =& $_SESSION['client']['base_box_hrefs'];
         $hs_gc =& $this->get_module_variable('__hrefs_gc__', 0);
         if (isset($hs[$_REQUEST['box_main_href']])) {
             $rh = $hs[$_REQUEST['box_main_href']];
             $href = $rh['m'];
             $containers['main']['module'] = $href;
             if (isset($rh['f'])) {
                 $containers['main']['function'] = $rh['f'];
             } else {
                 unset($containers['main']['function']);
             }
             if (isset($rh['a'])) {
                 $containers['main']['arguments'] = $rh['a'];
             } else {
                 unset($containers['main']['arguments']);
             }
             if (isset($rh['c'])) {
                 $containers['main']['constructor_arguments'] = $rh['c'];
             } else {
                 unset($containers['main']['constructor_arguments']);
             }
             $mains = array();
             $pop_main = true;
         }
         unset($_REQUEST['box_main_href']);
         $hs_gc++;
         if ($hs_gc > 4) {
             foreach ($hs as $k => $v) {
                 if (!$v['p'] || !ModuleManager::get_instance($v['p'])) {
                     unset($hs[$k]);
                 }
             }
             $hs_gc = 0;
         }
     }
     array_push($mains, $containers['main']);
     $main_length = count($mains);
     $this->set_module_variable('main', $mains);
     //      Epesi::alert(print_r($mains,true));
     //      $containers['main']['name'] .= '_'.$main_length;
     //print_r($containers);
     $this->modules = array();
     foreach ($containers as $k => $v) {
         ob_start();
         if (ModuleManager::is_installed($v['module']) != -1) {
             $module_type = str_replace('/', '_', $v['module']);
             if (!isset($v['name'])) {
                 $v['name'] = null;
             }
             if (isset($href) && $k == 'main') {
                 $this->modules[$k] = $this->init_module($module_type, isset($v['constructor_arguments']) ? $v['constructor_arguments'] : null, $v['name'], true);
             } else {
                 $this->modules[$k] = $this->init_module($module_type, isset($v['constructor_arguments']) ? $v['constructor_arguments'] : null, $v['name']);
             }
             if ($k == 'main' && $pop_main) {
                 $this->modules[$k]->set_reload(true);
             }
             if (isset($v['function'])) {
                 $this->display_module($this->modules[$k], isset($v['arguments']) ? $v['arguments'] : null, $v['function']);
             } elseif (isset($v['arguments'])) {
                 $this->display_module($this->modules[$k], $v['arguments']);
             } else {
                 $this->display_module($this->modules[$k]);
             }
         }
         $theme->assign($k, ob_get_contents());
         ob_end_clean();
     }
     //main output
     $version_no = Base_BoxCommon::update_version_check_indicator();
     if (SUGGEST_DONATION) {
         $theme->assign('donate', Utils_TooltipCommon::create('<a target="_blank" href="http://epe.si/cost">' . __('Support EPESI!') . '</a>', '<center>' . __('If you find our software useful, please support us by making a %s.', array(__('donation'))) . '<br/>' . __('Your funding will help to ensure continued development of this project.') . '<br/>' . __('Click for details.') . '</center>', false, 500));
     }
     // Consider moving this code properly as initated module by *.ini file
     $theme->assign('home', array('href' => Base_HomePageCommon::get_href(), 'label' => __('Home')));
     $theme->assign('version_no', $version_no);
     $theme->display();
 }
Esempio n. 22
0
 private static function _base_box_instance()
 {
     $x = ModuleManager::get_instance('/Base_Box|0');
     if (!$x) {
         throw new Exception('There is no base box module instance');
     }
     return $x;
 }
Esempio n. 23
0
 public function view_event($id)
 {
     $x = ModuleManager::get_instance('/Base_Box|0');
     if (!$x) {
         trigger_error('There is no base box module instance', E_USER_ERROR);
     }
     $x->push_main('CRM_Calendar_Event', 'view', $id);
 }
Esempio n. 24
0
    public static function QFfield_note(&$form, $field, $label, $mode, $default, $desc, $rb_obj) {
        load_js('modules/Utils/Attachment/attachments.js');

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

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

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

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

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

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

            $form->setDefaults(array($field=>$default));
        } else {
            $form->addElement('static', $field, $label);
            $form->setDefaults(array($field=>self::display_note($rb_obj->record,false,null,true)));
            if(class_exists('ZipArchive')) {
                $files = DB::GetOne('SELECT 1 FROM utils_attachment_file uaf WHERE uaf.attach_id=%d AND uaf.deleted=0', array($rb_obj->record['id']));
                if($files) Base_ActionBarCommon::add('download','Download all attachments','href="'.self::Instance()->get_module_dir().'get_all.php?id='.$rb_obj->record['id'].'&cid='.CID.'" target="_blank"');
            }
        }
    }
Esempio n. 25
0
 public static function crm_new_event($timestamp, $timeless, $id, $object, $cal_obj)
 {
     $x = ModuleManager::get_instance('/Base_Box|0');
     if (!$x) {
         trigger_error('There is no base box module instance', E_USER_ERROR);
     }
     $me = CRM_ContactsCommon::get_my_record();
     $defaults = array('employees' => $me['id'], 'priority' => CRM_CommonCommon::get_default_priority(), 'permission' => 0, 'status' => 0);
     $defaults['deadline'] = date('Y-m-d', $timestamp);
     if ($object) {
         $defaults['employees'] = $object;
     }
     $x->push_main('Utils_RecordBrowser', 'view_entry', array('add', null, $defaults), 'task');
 }
Esempio n. 26
0
 public function go_back($file)
 {
     unlink($file);
     $x = ModuleManager::get_instance('/Base_Box|0');
     if (!$x) {
         trigger_error('There is no base box module instance', E_USER_ERROR);
     }
     $x->pop_main();
 }
Esempio n. 27
0
 public function open_rc_account($id)
 {
     $x = ModuleManager::get_instance('/Base_Box|0');
     $x->push_main('CRM_Roundcube', 'body', array(array(), $id));
 }
Esempio n. 28
0
 public function push_event_action($action, $arg = null)
 {
     $x = ModuleManager::get_instance('/Base_Box|0');
     if (!$x) {
         trigger_error('There is no base box module instance', E_USER_ERROR);
     }
     $x->push_main($this->event_module, $action, $arg);
 }
Esempio n. 29
0
	public function push_settings($s) {
		$x = ModuleManager::get_instance('/Base_Box|0');
		if(!$x) trigger_error('There is no base box module instance',E_USER_ERROR);
		$x->push_main('Base_User_Settings',null,array(_V($s)));
	}
Esempio n. 30
0
 public static function process($url, $history_call = false, $refresh = false)
 {
     if (MODULE_TIMES) {
         $time = microtime(true);
     }
     $url = str_replace('&amp;', '&', $url);
     //do we need this if we set arg_separator.output to &?
     if ($url) {
         $_POST = array();
         parse_str($url, $_POST);
         if (get_magic_quotes_gpc()) {
             $_POST = undoMagicQuotes($_POST);
         }
         $_GET = $_REQUEST =& $_POST;
     }
     ModuleManager::load_modules();
     self::check_firstrun();
     if ($history_call === '0') {
         History::clear();
     } elseif ($history_call) {
         History::set_id($history_call);
     }
     //on init call methods...
     $ret = on_init(null, null, null, true);
     foreach ($ret as $k) {
         call_user_func_array($k['func'], $k['args']);
     }
     $root =& ModuleManager::create_root();
     self::go($root);
     //go somewhere else?
     $loc = location(null, true);
     //on exit call methods...
     $ret = on_exit(null, null, null, true, $loc === false);
     foreach ($ret as $k) {
         call_user_func_array($k['func'], $k['args']);
     }
     if ($loc !== false) {
         if (isset($_REQUEST['__action_module__'])) {
             $loc['__action_module__'] = $_REQUEST['__action_module__'];
         }
         //clean up
         foreach (self::$content as $k => $v) {
             unset(self::$content[$k]);
         }
         foreach (self::$jses as $k => $v) {
             if ($v[1]) {
                 unset(self::$jses[$k]);
             }
         }
         //go
         $loc['__location'] = microtime(true);
         return self::process(http_build_query($loc), false, true);
     }
     $debug = '';
     if (DEBUG && ($debug_diff = @(include_once 'tools/Diff.php'))) {
         require_once 'tools/Text/Diff/Renderer/inline.php';
         $diff_renderer = new Text_Diff_Renderer_inline();
     }
     //clean up old modules
     if (isset($_SESSION['client']['__module_content__'])) {
         $to_cleanup = array_keys($_SESSION['client']['__module_content__']);
         foreach ($to_cleanup as $k) {
             $mod = ModuleManager::get_instance($k);
             if ($mod === null) {
                 $xx = explode('/', $k);
                 $yy = explode('|', $xx[count($xx) - 1]);
                 $mod = $yy[0];
                 if (is_callable(array($mod . 'Common', 'destroy'))) {
                     call_user_func(array($mod . 'Common', 'destroy'), $k, isset($_SESSION['client']['__module_vars__'][$k]) ? $_SESSION['client']['__module_vars__'][$k] : null);
                 }
                 if (DEBUG) {
                     $debug .= 'Clearing mod vars & module content ' . $k . '<br>';
                 }
                 unset($_SESSION['client']['__module_vars__'][$k]);
                 unset($_SESSION['client']['__module_content__'][$k]);
             }
         }
     }
     $reloaded = array();
     foreach (self::$content as $k => $v) {
         $reload = $v['module']->get_reload();
         $parent = $v['module']->get_parent_path();
         if (DEBUG && REDUCING_TRANSFER) {
             $debug .= '<hr style="height: 3px; background-color:black">';
             $debug .= '<b> Checking ' . $k . ', &nbsp;&nbsp;&nbsp; parent=' . $v['module']->get_parent_path() . '</b><ul>' . '<li>Force - ' . (isset($reload) ? print_r($reload, true) : 'not set') . '</li>' . '<li>First display - ' . (isset($_SESSION['client']['__module_content__'][$k]) ? 'no</li>' . '<li>Content changed - ' . ($_SESSION['client']['__module_content__'][$k]['value'] !== $v['value'] ? 'yes' : 'no') . '</li>' . '<li>JS changed - ' . ($_SESSION['client']['__module_content__'][$k]['js'] !== $v['js'] ? 'yes' : 'no') : 'yes') . '</li>' . '<li>Parent reloaded - ' . (isset($reloaded[$parent]) ? 'yes' : 'no') . '</li>' . '<li>History call - ' . ($history_call ? 'yes' : 'no') . '</li>' . '</ul>';
         }
         if (!REDUCING_TRANSFER || (!isset($reload) && (!isset($_SESSION['client']['__module_content__'][$k]) || $_SESSION['client']['__module_content__'][$k]['value'] !== $v['value'] || $_SESSION['client']['__module_content__'][$k]['js'] !== $v['js']) || $history_call || $reload == true || isset($reloaded[$parent]))) {
             //force reload or parent reloaded
             if (DEBUG && isset($_SESSION['client']['__module_content__'])) {
                 $debug .= '<b>Reloading: ' . (isset($v['span']) ? ';&nbsp;&nbsp;&nbsp;&nbsp;span=' . $v['span'] . ',' : '') . '&nbsp;&nbsp;&nbsp;&nbsp;triggered=' . ($reload == true ? 'force' : 'auto') . ',&nbsp;&nbsp;</b><hr><b>New value:</b><br><pre>' . htmlspecialchars($v['value']) . '</pre>' . (isset($_SESSION['client']['__module_content__'][$k]['value']) ? '<hr><b>Old value:</b><br><pre>' . htmlspecialchars($_SESSION['client']['__module_content__'][$k]['value']) . '</pre>' : '');
                 if ($debug_diff && isset($_SESSION['client']['__module_content__'][$k]['value'])) {
                     $xxx = new Text_Diff(explode("\n", $_SESSION['client']['__module_content__'][$k]['value']), explode("\n", $v['value']));
                     $debug .= '<hr><b>Diff:</b><br><pre>' . $diff_renderer->render($xxx) . '</pre>';
                 }
                 $debug .= '<hr style="height: 5px; background-color:black">';
             }
             if (isset($v['span'])) {
                 self::text($v['value'], $v['span']);
             }
             if ($v['js']) {
                 self::js(join(";", $v['js']));
             }
             if (REDUCING_TRANSFER) {
                 $_SESSION['client']['__module_content__'][$k]['value'] = $v['value'];
                 $_SESSION['client']['__module_content__'][$k]['js'] = $v['js'];
             }
             $_SESSION['client']['__module_content__'][$k]['parent'] = $parent;
             $reloaded[$k] = true;
             if (method_exists($v['module'], 'reloaded')) {
                 $v['module']->reloaded();
             }
         }
     }
     foreach ($_SESSION['client']['__module_content__'] as $k => $v) {
         if (!array_key_exists($k, self::$content) && isset($reloaded[$v['parent']])) {
             if (DEBUG) {
                 $debug .= 'Reloading missing ' . $k . '<hr>';
             }
             if (isset($v['span'])) {
                 self::text($v['value'], $v['span']);
             }
             if (isset($v['js']) && $v['js']) {
                 self::js(join(";", $v['js']));
             }
             $reloaded[$k] = true;
         }
     }
     if (DEBUG) {
         $debug .= 'vars ' . CID . ': ' . print_r($_SESSION['client']['__module_vars__'], true) . '<br>';
         $debug .= 'user='******'<br>';
         if (isset($_REQUEST['__action_module__'])) {
             $debug .= 'action module=' . $_REQUEST['__action_module__'] . '<br>';
         }
     }
     $debug .= self::debug();
     if (MODULE_TIMES) {
         foreach (self::$content as $k => $v) {
             $style = 'color:red;font-weight:bold';
             if ($v['time'] < 0.5) {
                 $style = 'color:orange;font-weight:bold';
             }
             if ($v['time'] < 0.05) {
                 $style = 'color:green;font-weight:bold';
             }
             $debug .= 'Time of loading module <b>' . $k . '</b>: <i>' . '<span style="' . $style . ';">' . number_format($v['time'], 4) . '</span>' . '</i><br>';
         }
         $debug .= 'Page renderered in ' . (microtime(true) - $time) . 's<hr>';
     }
     if (SQL_TIMES) {
         $debug .= '<font size="+1">QUERIES</font><br>';
         $queries = DB::GetQueries();
         $sum = 0;
         $qty = 0;
         foreach ($queries as $kk => $q) {
             $style = 'color:red;font-weight:bold';
             if ($q['time'] < 0.5) {
                 $style = 'color:orange;font-weight:bold';
             }
             if ($q['time'] < 0.05) {
                 $style = 'color:green';
             }
             for ($kkk = 0; $kkk < $kk; $kkk++) {
                 if ($queries[$kkk]['args'] == $q['args']) {
                     $style .= ';text-decoration:underline';
                 }
             }
             $debug .= '<span style="' . $style . ';">' . '<b>' . $q['func'] . '</b> ' . htmlspecialchars(var_export($q['args'], true)) . ' <i><b>' . number_format($q['time'], 4) . '</b></i>' . (isset($q['caller']) ? ', ' . $q['caller'] : '') . '<br>' . '</span>';
             $sum += $q['time'];
             $qty++;
         }
         $debug .= '<b>Number of queries:</b> ' . $qty . '<br>';
         $debug .= '<b>Queries times:</b> ' . $sum . '<br>';
     }
     if (!isset($_SESSION['client']['custom_debug']) || $debug != $_SESSION['client']['custom_debug']) {
         self::text($debug, 'debug');
         if ($debug) {
             Epesi::js("\$('debug_content').style.display='block';");
         }
         $_SESSION['client']['custom_debug'] = $debug;
     }
     if (!$history_call && !History::soft_call()) {
         History::set();
     }
     if (!$history_call) {
         self::js('Epesi.history_add(' . History::get_id() . ')');
     }
     self::send_output();
 }