Example #1
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;
 }
Example #2
0
 public static function print_event($ev, $mode = '', $with_div = true)
 {
     $th = Base_ThemeCommon::init_smarty();
     $ex = self::process_event($ev);
     $th->assign('event_id', $ev['id']);
     $th->assign('draggable', !isset($ev['draggable']) || $ev['draggable'] === true);
     $title = $ev['title'];
     $title_st = strip_tags($ev['title']);
     $title_s = $title;
     $th->assign('with_div', $with_div);
     $th->assign('title', $title);
     $th->assign('title_s', $title_s);
     $th->assign('description', $ev['description']);
     $th->assign('color', $ev['color']);
     $th->assign('start', $ex['start']);
     $th->assign('start_time', $ex['start_time']);
     $th->assign('end_time', $ex['end_time']);
     $th->assign('start_date', $ex['start_date']);
     $th->assign('end_date', $ex['end_date']);
     $th->assign('start_day', $ex['start_day']);
     $th->assign('end_day', $ex['end_day']);
     $th->assign('end', $ex['end']);
     $th->assign('duration', $ex['duration']);
     $th->assign('show_hide_info', __('Click to show / hide menu'));
     $th->assign('additional_info', $ev['additional_info']);
     $th->assign('additional_info2', $ev['additional_info2']);
     if (isset($ev['custom_tooltip'])) {
         $th->assign('custom_tooltip', $ev['custom_tooltip']);
     }
     ob_start();
     Base_ThemeCommon::display_smarty($th, 'Utils_Calendar', 'event_tip');
     $tip = ob_get_clean();
     $th->assign('tip_tag_attrs', Utils_TooltipCommon::open_tag_attrs($tip, false));
     if (!isset($ev['view_action']) || $ev['view_action'] === true) {
         $th->assign('view_href', Module::create_href(array('UCev_id' => $ev['id'], 'UCaction' => 'view')));
     } elseif ($ev['view_action'] !== false) {
         $th->assign('view_href', $ev['view_action']);
     }
     if (!isset($ev['edit_action']) || $ev['edit_action'] === true) {
         $th->assign('edit_href', Module::create_href(array('UCev_id' => $ev['id'], 'UCaction' => 'edit')));
     } elseif ($ev['edit_action'] !== false) {
         $th->assign('edit_href', $ev['edit_action']);
     }
     $link_text = Module::create_href_js(array('UCev_id' => $ev['id'], 'UCaction' => 'move', 'UCdate' => '__YEAR__-__MONTH__-__DAY__'));
     if (!isset($ev['move_action']) || $ev['move_action'] === true) {
         $th->assign('move_href', Utils_PopupCalendarCommon::create_href('move_event' . str_replace(array('#', '-'), '_', $ev['id']), $link_text, null, null, 'popup.clonePosition(\'utils_calendar_event:' . $ev['id'] . '\',{setWidth:false,setHeight:false,offsetTop:$(\'utils_calendar_event:' . $ev['id'] . '\').getHeight()})'));
     }
     if (!isset($ev['delete_action']) || $ev['delete_action'] === true) {
         $th->assign('delete_href', Module::create_confirm_href(__('Delete this event?'), array('UCev_id' => $ev['id'], 'UCaction' => 'delete')));
     } elseif ($ev['delete_action'] !== false) {
         $th->assign('delete_href', $ev['delete_action']);
     }
     $th->assign('handle_class', 'handle');
     $th->assign('custom_actions', $ev['actions']);
     Base_ThemeCommon::display_smarty($th, 'Utils_Calendar', 'event' . ($mode ? '_' . $mode : ''));
 }
Example #3
0
 public static function create_record_href($tab, $id, $action = 'view', $more = array())
 {
     if (MOBILE_DEVICE) {
         $cap = DB::GetOne('SELECT caption FROM recordbrowser_table_properties WHERE tab=%s', array($tab));
         return mobile_stack_href(array('Utils_RecordBrowserCommon', 'mobile_rb_view'), array($tab, $id), $cap);
     }
     return Module::create_href(self::get_record_href_array($tab, $id, $action) + $more);
 }
Example #4
0
 public static function get_href()
 {
     return Module::create_href(array('Base_HomePage_load' => '1'));
 }
Example #5
0
 public static function user_get_change_subscr_href($user, $category_name, $id = null)
 {
     return Module::create_href(self::user_get_change_subscr_href_array($user, $category_name, $id));
 }
Example #6
0
 private static function copy_company_data_subroutine($values)
 {
     $access = Utils_RecordBrowserCommon::get_access('contact', 'edit', $values);
     if (!$access) {
         return;
     }
     /* First click should generate html code for leightbox and show it.
      * This function is rarely used and we don't want to increase page size.
      * To do this we use REQUEST variable UCD.
      *
      * We use module variable UCD to indicate that form was shown and we
      * must check if it was submitted. If yes - do action. If it wasn't
      * we should come back to initial state - do not print LB.
      */
     if (!(isset($_REQUEST['UCD']) || Module::static_get_module_variable('CRM/Contacts', 'UCD', 0))) {
         if (isset($values['company_name']) && $values['company_name']) {
             Base_ActionBarCommon::add('edit', __('Copy company data'), Module::create_href(array('UCD' => true)));
         }
     }
     if (isset($_REQUEST['UCD']) || Module::static_get_module_variable('CRM/Contacts', 'UCD', 0)) {
         $ucd = Module::static_get_module_variable('CRM/Contacts', 'UCD', 0);
         $ucd++;
         if ($ucd > 1) {
             Module::static_unset_module_variable('CRM/Contacts', 'UCD');
         } else {
             Module::static_set_module_variable('CRM/Contacts', 'UCD', $ucd);
         }
         $lid = 'UCDprompt';
         $form = ModuleManager::new_instance('Libs_QuickForm', null, 'QFUCDprompt');
         $form->construct();
         $sel_val = array();
         foreach (array_merge(array($values['company_name']), is_array($values['related_companies']) ? $values['related_companies'] : array()) as $id) {
             $sel_val[$id] = self::company_format_default(self::get_company($id), true);
         }
         $form->addElement('select', 'company', __('Select company:'), $sel_val);
         unset($sel_val);
         $form->addElement('html', __('Select which fields should be copied:'));
         $data = array(array('sid' => 'address_1', 'tid' => 'address_1', 'text' => __('Address 1'), 'checked' => true), array('sid' => 'address_2', 'tid' => 'address_2', 'text' => __('Address 2'), 'checked' => true), array('sid' => 'city', 'tid' => 'city', 'text' => __('City'), 'checked' => true), array('sid' => 'country', 'tid' => 'country', 'text' => __('Country'), 'checked' => true), array('sid' => 'zone', 'tid' => 'zone', 'text' => __('Zone'), 'checked' => true), array('sid' => 'postal_code', 'tid' => 'postal_code', 'text' => __('Postal Code'), 'checked' => true), array('sid' => 'phone', 'tid' => 'work_phone', 'text' => __('Phone as Work Phone'), 'checked' => false), array('sid' => 'fax', 'tid' => 'fax', 'text' => __('Fax'), 'checked' => false));
         foreach ($data as $row) {
             if (is_array($access) && isset($access[$row['tid']]) && $access[$row['tid']]) {
                 $form->addElement('checkbox', $row['sid'], $row['text'], '', $row['checked'] ? array('checked' => 'checked') : array());
             }
         }
         $ok = $form->createElement('submit', 'submit', __('Confirm'), array('onclick' => 'leightbox_deactivate("' . $lid . '")'));
         $cancel = $form->createElement('button', 'cancel', __('Cancel'), array('onclick' => 'leightbox_deactivate("' . $lid . '")'));
         $form->addGroup(array($ok, $cancel));
         if ($form->validate()) {
             $Uvalues = $form->exportValues();
             $fields = array();
             foreach ($data as $row) {
                 if (array_key_exists($row['sid'], $Uvalues)) {
                     $fields[$row['tid']] = $row['sid'];
                 }
             }
             if (isset($Uvalues['company'])) {
                 $company = CRM_ContactsCommon::get_company($Uvalues['company']);
                 $new_data = array();
                 foreach ($fields as $k => $v) {
                     $new_data[$k] = $company[$v];
                 }
                 Utils_RecordBrowserCommon::update_record('contact', $values['id'], $new_data);
             }
             Module::static_unset_module_variable('CRM/Contacts', 'UCD');
             location(array());
         }
         // set default to main company
         if ($mc = self::get_main_company()) {
             $form->setDefaults(array('company' => $mc));
         }
         $html = $form->toHtml();
         Libs_LeightboxCommon::display($lid, $html);
         Base_ActionBarCommon::add('edit', __('Copy company data'), Libs_LeightboxCommon::get_open_href($lid));
         if (isset($_REQUEST['UCD'])) {
             eval_js('leightbox_activate(\'' . $lid . '\')');
         }
         unset($_REQUEST['UCD']);
     }
 }
Example #7
0
    public static function submit_attachment($values, $mode) {
        static $new_values, $old_password;
        switch ($mode) {
            case 'browse':
                if (isset($values['id']) && isset($values['crypted']) && $values['crypted'] == false) {
                    // store to mark as read. Do not mark it here, because
                    // we won't get red eye in the table view
                    self::$mark_as_read[] = $values['id'];
                }
                return $values;
            case 'index':
                if($values['crypted']) unset($values['note']);
                return $values;
            case 'adding':
                $values['edited_on'] = time();
                return $values;
            case 'add':
            case 'edit':
                if(isset($values['__date'])) $values['edited_on'] = $values['__date'];
                else $values['edited_on'] = time();

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

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

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

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

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

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

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

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

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

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

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

                break;
        }
        return $values;
    }
Example #8
0
 public static function create_href($parent_module, $module, $function = null, array $arguments = null, array $constructor_args = null, array $other_href_args = array())
 {
     return Module::create_href(array_merge($other_href_args, Base_BoxCommon::create_href_array($parent_module, $module, $function, $arguments, $constructor_args)));
 }
Example #9
0
 public static function create_new_event_href($def, $id = 'none')
 {
     return Module::create_href(self::get_new_event_href($def, $id));
 }
Example #10
0
 public static function get_mailto_link($v)
 {
     if (isset($_REQUEST['rc_mailto'])) {
         $x = ModuleManager::get_instance('/Base_Box|0');
         $x->push_main('CRM_Roundcube', 'new_mail', array($_REQUEST['rc_mailto']));
         unset($_REQUEST['rc_mailto']);
     }
     if (!CRM_RoundcubeCommon::use_standard_mailto()) {
         $ret = Utils_RecordBrowserCommon::get_records_count('rc_accounts', array('epesi_user' => Acl::get_user()));
         if ($ret) {
             return '<a ' . Module::create_href(array('rc_mailto' => $v)) . '>' . $v . '</a>';
         }
     }
     return '<a href="mailto:' . $v . '">' . $v . '</a>';
 }
Example #11
0
 public function user_actions($r, $gb_row)
 {
     static $admin_levels = false;
     static $my_level = false;
     if ($admin_levels === false) {
         $admin_levels = DB::GetAssoc('SELECT id,admin FROM user_login');
     }
     if ($my_level === false) {
         $my_level = isset($admin_levels[Base_AclCommon::get_user()]) ? $admin_levels[Base_AclCommon::get_user()] : 0;
     }
     $mod = 'Base_User_Administrator';
     $log_as_user = Base_AdminCommon::get_access($mod, 'log_as_user');
     $log_as_admin = Base_AdminCommon::get_access($mod, 'log_as_admin');
     $user_level = isset($admin_levels[$r['login']]) ? $admin_levels[$r['login']] : 0;
     // 2 is superadmin, 1 admin, 0 user
     if ($my_level == 2 || $my_level == 1 && ($user_level == 0 && $log_as_user || $user_level == 1 && $log_as_admin)) {
         // contact is admin and I can login as admin
         if (Base_UserCommon::is_active($r['login'])) {
             $gb_row->add_action($this->create_callback_href(array($this, 'change_user_active_state'), array($r['login'], false)), 'Deactivate user', null, Base_ThemeCommon::get_template_file('Utils_GenericBrowser', 'active-on.png'));
             $gb_row->add_action(Module::create_href(array('log_as_user' => $r['login'])), 'Log as user', null, Base_ThemeCommon::get_template_file('Utils_GenericBrowser', 'restore.png'));
             // action!
             if (isset($_REQUEST['log_as_user']) && $_REQUEST['log_as_user'] == $r['login']) {
                 Acl::set_user($r['login'], true);
                 Epesi::redirect();
                 return;
             }
         } else {
             $gb_row->add_action($this->create_callback_href(array($this, 'change_user_active_state'), array($r['login'], true)), 'Activate user', null, Base_ThemeCommon::get_template_file('Utils_GenericBrowser', 'active-off.png'));
         }
     }
 }
Example #12
0
 public static function user_settings()
 {
     $ret = array(array('name' => null, 'label' => __('General'), 'type' => 'header'), array('name' => 'one_cache', 'label' => __('Show each notification'), 'type' => 'select', 'values' => array(0 => __('multiple times every login and on each device'), 1 => __('only once and only on one device')), 'default' => 1), array('name' => null, 'label' => __('Browser Notification') . ' - ' . __('General'), 'type' => 'header'), array('name' => 'general_timeout', 'reload' => 1, 'label' => __('Close Message Timeout'), 'type' => 'select', 'values' => Utils_CommonDataCommon::get_translated_array('Base_Notify/Timeout', true), 'default' => 0), array('name' => 'general_group', 'label' => __('Group Similar Notifications'), 'type' => 'checkbox', 'default' => 1), array('name' => 'browser_settings', 'label' => '', 'type' => 'static', 'values' => '<a class="button" onClick="Base_Notify.notify (\'Notification\', {body: \'enabled\', icon: \'' . self::get_icon('Base_Notify') . '\'}, true);">' . __('Browser Settings') . '</a>'), array('name' => null, 'label' => __('Browser Notification') . ' - ' . __('Module Specific Timeout'), 'type' => 'header'));
     $modules = ModuleManager::check_common_methods('notification');
     foreach ($modules as $module) {
         $label = self::get_module_caption($module);
         $ret = array_merge($ret, array(array('name' => $module . '_timeout', 'label' => $label, 'type' => 'select', 'values' => array(-2 => _M('Use general setting')) + Utils_CommonDataCommon::get_translated_array('Base_Notify/Timeout', true), 'default' => -2)));
     }
     $ret[] = array('name' => null, 'label' => __('Telegram Notification'), 'type' => 'header');
     $telegram = DB::GetOne('SELECT 1 FROM base_notify WHERE single_cache_uid=%d AND telegram=1', array(Base_AclCommon::get_user()));
     if ($telegram && isset($_GET['telegram'])) {
         $telegram = 0;
         DB::Execute('UPDATE base_notify SET telegram=0 WHERE single_cache_uid=%d', array(Base_AclCommon::get_user()));
     }
     $ret[] = array('name' => 'telegram_url', 'label' => '<a class="button" href="modules/Base/Notify/telegram.php" target="_blank">' . ($telegram ? __('Connect to another telegram account') : __('Connect to your telegram account')) . '</a>', 'type' => 'static', 'values' => $telegram ? '<a class="button" ' . Module::create_href(array('telegram' => 1)) . '>' . __('Disconnect telegram') . '</a>' : '');
     return array(__('Notifications') => $ret);
 }
Example #13
0
 * @subpackage tooltip
 */
if (!isset($_POST['cid'])) {
    die('Invalid request' . print_r($_POST, true));
}
define('JS_OUTPUT', 1);
define('CID', $_POST['cid']);
define('READ_ONLY_SESSION', 1);
require_once '../../../include.php';
ModuleManager::load_modules();
$registered = Base_EssClientCommon::is_registered();
$ver = __('version %s', array(EPESI_VERSION));
if (!$registered) {
    print $ver;
    return;
}
$updates = Base_EpesiStoreCommon::is_update_available();
if (!$updates) {
    print $ver;
    return;
}
if (Base_AclCommon::i_am_sa()) {
    $tooltip = __('There are updates available for download, click to go to EPESI store.');
} else {
    $tooltip = __('There are updates available for download. Please contact your administrator.');
}
$message = Utils_TooltipCommon::create(__('version %s', array(EPESI_VERSION)) . '<br/><b>(' . __('Updates Available!') . ')</b>', $tooltip, false);
if (Base_AclCommon::i_am_sa()) {
    $message = '<a ' . Module::create_href(array('go_to_epesi_store_for_updates' => true)) . 'class="version">' . $message . '</a>';
}
print $message;