Esempio n. 1
0
 public function manage()
 {
     if (!Base_EpesiStoreCommon::admin_access()) {
         return;
     }
     $button_label = Base_EssClientCommon::has_license_key() ? __('License Key') : __('Register EPESI!');
     Base_ActionBarCommon::add(Base_ThemeCommon::get_template_file('Base_EpesiStore', 'icon.png'), $button_label, $this->create_callback_href(array($this, 'display_registration_form')));
     Base_ActionBarCommon::add('view', __('Invoices'), $this->create_callback_href(array($this, 'display_invoices')));
     $setup = $this->init_module('Base_Setup');
     $setup->set_inline_display();
     if (Base_SetupCommon::is_simple_setup()) {
         if (!$this->isset_module_variable('filter_set')) {
             eval_js('base_setup__last_filter="' . (!Base_EssClientCommon::has_license_key() ? '' : (Base_EpesiStoreCommon::is_update_available() ? 'updates' : 'store')) . '";');
             $this->set_module_variable('filter_set', true);
         }
         $this->display_module($setup, array(true), 'admin');
         return;
     }
     Base_ActionBarCommon::add('settings', __('Simple view'), $this->create_callback_href(array($this, 'switch_simple'), true));
     $tb = $this->init_module('Utils_TabbedBrowser');
     $tb->set_tab('Modules Setup', array($this, 'setup_admin'), array($setup));
     $tb->set_tab('Epesi Store', array($this, 'form_main_store'), array());
     $tb->tag();
     $this->display_module($tb);
 }
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
	private function print_structure($t = array(), $level = 0, $path = null) {
		if(count($t) > 0) {
			if($path===null) {
				$this->_sub = 0;
				$ret = '<div class=utils_tree_root>';
			} else {
				$ret = '<div class=utils_tree_submenu id=utils_tree_'.$this->_id.'_'.$this->_sub.'>';
				$this->_sub++;
			}
			foreach( $t as $k => $v ) {
				$ret .= '<div id=utils_tree_node_'.$this->_id.' class=utils_tree_node onmouseover=\'if(typeof(utils_tree_hl)!="undefined")utils_tree_hl(this)\' onmouseout=\'if(typeof(utils_tree_rg)!="undefined")utils_tree_rg(this)\'><table><tr>';
				if(isset($v['sub']) && count($v['sub']) > 0)
					$ret .= '<td id=utils_tree_opener_'.$this->_id.'_'.($this->_sub).' class=utils_tree_opener_active_closed onclick="tree_node_visibility_toggle('.$this->_id.', '.($this->_sub).')"><img id=utils_tree_opener_img_'.$this->_id.'_'.($this->_sub).' src="'.Base_ThemeCommon::get_template_file($this->get_type(),'opener_active_closed.gif').'"></td>';
				else
				$ret .= '<td class=utils_tree_opener_inactive><img src="'.Base_ThemeCommon::get_template_file($this->get_type(),'opener_inactive.gif').'"></td>';
				if(isset($v['selected']) && $v['selected'] == 1)
					$ret .= "<td class=utils_tree_node_content_selected>".$v['name']."</td>";
				else
					$ret .= "<td class=utils_tree_node_content>".$v['name']."</td>";
				if(isset($v['visible']) && $v['visible'] == 1 && $path!==null)
					array_push($this->_opened_paths, $path);
				if(isset($v['opened']) && $v['opened'] == 1 && is_array($v['sub']) && !empty($v['sub']))
					array_push($this->_opened_paths, $path.'_'.$this->_sub);
					
				$ret .= "</tr></table></div>";
				if(isset($v['sub']) && is_array($v['sub'])) {
					$ret .= $this->print_structure($v['sub'], $level + 1, $path.'_'.$this->_sub);
				}
			}
			$ret .= "</div>";
			return $ret;
		}
		return '';
	}
Esempio n. 4
0
 public static function get_ini_file()
 {
     if (Base_BoxCommon::$ini_file) {
         $ini = Base_BoxCommon::$ini_file;
     } else {
         $ini = Base_ThemeCommon::get_template_file('Base_Box', 'default.ini');
     }
     return $ini;
 }
Esempio n. 5
0
 public static function get_ini_file()
 {
     if (Base_BoxCommon::$ini_file) {
         $ini = Base_BoxCommon::$ini_file;
     } elseif (file_exists($ini = Base_ThemeCommon::get_template_file('Base_Box', 'default.ini'))) {
         return $ini;
     } else {
         $ini = __DIR__ . '/default.ini';
     }
     return file_exists($ini) ? $ini : null;
 }
Esempio n. 6
0
	/**
	 * Returns string that when placed as tag attribute
	 * will enable ajax request to set a tooltip when placing mouse over that element.
	 *
	 * @param callback method that will be called to get tooltip content
	 * @param array parameters that will be passed to the callback
	 * @return string HTML tag attributes
	 */
	public static function ajax_open_tag_attrs( $callback, $args, $max_width=300 ) {
		if(MOBILE_DEVICE) return '';
		static $tooltip_id = 0;
		static $tooltip_cleared = false;
		if (isset($_REQUEST['__location']) && $tooltip_cleared!=$_REQUEST['__location']) {
			$tooltip_cleared = $_REQUEST['__location'];
			$tooltip_id = 0;
		}
		$tooltip_id++;
		$_SESSION['client']['utils_tooltip']['callbacks'][$tooltip_id] = array('callback'=>$callback, 'args'=>$args);
		$loading_message = '<center><img src='.Base_ThemeCommon::get_template_file('Utils_Tooltip','loader.gif').' /><br/>'.__('Loading...').'</center>';
		return ' onMouseMove="if(typeof(Utils_Tooltip__showTip)!=\'undefined\')Utils_Tooltip__load_ajax_Tip(this,event,'.$max_width.')" tip="'.$loading_message.'" tooltip_id="'.$tooltip_id.'" onMouseOut="if(typeof(Utils_Tooltip__hideTip)!=\'undefined\')Utils_Tooltip__hideTip()" onMouseUp="if(typeof(Utils_Tooltip__hideTip)!=\'undefined\')Utils_Tooltip__hideTip()" ';
	}
Esempio n. 7
0
 public static function show($name, $function = '', $mode = null, $first_day_of_week = null, $pos_js = null, $label = null, $default = null)
 {
     // label seems to be unused and always null.
     if ($label === null) {
         if ($mode == 'month') {
             $label = __('Select month');
         } elseif ($mode == 'year') {
             $label = __('Select year');
         } else {
             $label = __('Select date');
         }
     }
     return '<a class="button" ' . self::create_href($name, $function, $mode, $first_day_of_week, $pos_js, $default) . '>' . $label . '&nbsp;&nbsp;<img style="vertical-align: middle;" src=' . Base_ThemeCommon::get_template_file('Utils_PopupCalendar', 'select.png') . '>' . '</a>';
 }
Esempio n. 8
0
 public static function display($header, $content, $info = false)
 {
     $l = Variable::get('logo_file', false);
     if (!$l) {
         $l = Base_ThemeCommon::get_template_file('images/logo-small.png');
     }
     $smarty = Base_ThemeCommon::init_smarty();
     $smarty->assign('header', $header);
     $smarty->assign('contents', $content);
     $smarty->assign('info', $info);
     $smarty->assign('footer', '');
     $smarty->assign('logo', $l);
     $smarty->assign('url', get_epesi_url());
     Base_ThemeCommon::display_smarty($smarty, 'Utils_FrontPage', 'default');
 }
Esempio n. 9
0
 public static function prepare_header(&$tcpdf, $title = '', $subject = '', $printed_by = true, $logo_filename = null, $l = array())
 {
     if ($title !== null) {
         if ($logo_filename === null) {
             $logo_filename = Libs_TCPDFCommon::get_logo_filename();
         }
         if ($logo_filename !== false && !file_exists($logo_filename)) {
             $logo_filename = Base_ThemeCommon::get_template_file(Libs_TCPDF::module_name(), 'logo-small.png');
         }
         $margins = $tcpdf->getMargins();
         if ($logo_filename) {
             $logo_size = getimagesize($logo_filename);
             $logo_height = $logo_size[1] * PDF_HEADER_LOGO_WIDTH / $logo_size[0];
         } else {
             $logo_height = 0;
         }
         $tcpdf->SetHeaderMargin(10);
         $tcpdf->SetTopMargin($logo_height + $margins['top']);
         $tcpdf->SetHeaderData($logo_filename, $logo_filename ? PDF_HEADER_LOGO_WIDTH : 0, $title, $subject);
     } else {
         $tcpdf->setPrintHeader(false);
     }
     //set some language-dependent strings
     $l['a_meta_charset'] = "UTF-8";
     $l['a_meta_dir'] = "ltr";
     $l['a_meta_language'] = "pl";
     $who = null;
     if (CRM_ContactsInstall::is_installed()) {
         $who = CRM_ContactsCommon::get_contact_by_user_id(Acl::get_user());
     }
     if ($who !== null) {
         $who = $who['last_name'] . ' ' . $who['first_name'];
     } else {
         $who = Base_UserCommon::get_user_login(Acl::get_user());
     }
     $when = date('Y-m-d H:i:s');
     if (!isset($l['w_page'])) {
         $l['w_page'] = '';
         if ($printed_by) {
             $product_name = EPESI;
             $url = EPESI == 'EPESI' ? ' (http://epe.si)' : '';
             $l['w_page'] .= __('Printed with %s by %s, on %s, ', array($product_name . $url, $who, $when));
         }
         $l['w_page'] .= __('Page');
     }
     $tcpdf->setLanguageArray($l);
     self::SetFont($tcpdf, self::$default_font, '', 9);
 }
Esempio n. 10
0
 public function applet()
 {
     Base_ThemeCommon::load_css($this->get_type());
     print '<div id="google">';
     print '
         <form method="get" action="http://www.google.com/search" target="_blank">
             <fieldset style="border: 0px;">
                 <a href="http://www.google.com/search"><img src="' . Base_ThemeCommon::get_template_file('Applets/Google', 'Logo_40wht.gif') . '" alt="Google" style="border: 0px; width: 128px; height: 53px;" /></a>
                 <center>
                 <table>
                     <tr>
                         <td><input name="q" size="30" maxlength="255" value="" type="text" /></td>
                         <td><input class="button" name="sa" value="' . __('Search') . '" type="submit" /></td>
                     </tr>
                 </table>
                 </center>
             </fieldset>
         </form>
     ';
     print '</div>';
 }
Esempio n. 11
0
 public static function get_error_closing_button()
 {
     return ' <a href="javascript:void(0);" onclick="this.parentNode.innerHTML=\'\'"><img src="' . Base_ThemeCommon::get_template_file('Libs_QuickForm', 'close.png') . '"></a>';
 }
Esempio n. 12
0
 public static function crm_event_get($id, $day = null)
 {
     if (!is_array($id)) {
         $id = explode('_', $id);
         if (isset($id[1]) && $day === null) {
             $day = $id[1];
         }
         $id = reset($id);
         $r = Utils_RecordBrowserCommon::get_record('crm_meeting', $id);
     } else {
         $r = $id;
         $id = $r['id'];
     }
     $r = Utils_RecordBrowserCommon::filter_record_by_access('crm_meeting', $r);
     if ($r === false) {
         return null;
     }
     $next = array('type' => __('Meeting'));
     //		if ($r['duration']!=-1) {
     //			$r['date'] = Base_RegionalSettingsCommon::time2reg($r['date'].' '.date('H:i:s', strtotime($r['time'])),false,true,true,false);
     //			$r['recurrence_end'] = Base_RegionalSettingsCommon::time2reg($r['recurrence_end'].' '.date('H:i:s', strtotime($r['time'])),false,true,true,false);
     //		}
     if ($day === null) {
         $day = $r['date'];
         $iday = strtotime($day);
         $next['id'] = $r['id'];
     } else {
         $iday = strtotime($day);
         if ($day < $r['date']) {
             return null;
         }
         if ($r['recurrence_end'] && $day > $r['recurrence_end']) {
             return null;
         }
         if ($r['recurrence_type'] <= 7 && $r['recurrence_type'] > 0) {
             $diff = round(($iday - strtotime($r['date'])) / (3600 * 24));
             if ($diff < 0 || $diff % $r['recurrence_type'] != 0) {
                 return null;
             }
         }
         if ($r['recurrence_type'] == 8) {
             if (isset($r['recurrence_hash'][date('N', $iday) - 1]) && !$r['recurrence_hash'][date('N', $iday) - 1]) {
                 return null;
             }
         }
         if ($r['recurrence_type'] == 9) {
             $diff = round(($iday - strtotime($r['date'])) / (3600 * 24));
             if ($diff < 0 || $diff % 14 != 0) {
                 return null;
             }
         }
         if ($r['recurrence_type'] == 10) {
             $numdays = date('t', $iday);
             $cday = date('d', $iday);
             $tday = date('d', strtotime($r['date']));
             if ($cday != $tday && ($tday <= $numdays || $numdays != $cday)) {
                 return null;
             }
         }
         if ($r['recurrence_type'] == 11) {
             $cmonth = date('m', $iday);
             $tmonth = date('m', strtotime($r['date']));
             if ($cmonth != $tmonth) {
                 return null;
             }
             $numdays = date('t', $iday);
             $cday = date('d', $iday);
             $tday = date('d', strtotime($r['date']));
             if ($cday != $tday && ($tday <= $numdays || $numdays != $cday)) {
                 return null;
             }
         }
         $next['id'] = $r['id'];
     }
     if ($r['recurrence_type'] > 0) {
         $next['id'] = $r['id'] . '_' . $day;
     }
     $base_unix_time = strtotime(date('1970-01-01 00:00:00'));
     //		$next['start'] = Base_RegionalSettingsCommon::reg2time(Base_RegionalSettingsCommon::time2reg(date('Y-m-d',$iday).' '.date('H:i:s',strtotime($r['time'])), true, false, true, false));
     //		$next['end'] = Base_RegionalSettingsCommon::reg2time(date('Y-m-d',$iday).' '.Base_RegionalSettingsCommon::time2reg(date('Y-m-d',$iday).' '.date('H:i:s',strtotime($r['time'])+$r['duration']), true, false, true, false));
     $next['start'] = date('Y-m-d', $iday) . ' ' . date('H:i:s', strtotime($r['time']));
     $next['end'] = date('Y-m-d', $iday) . ' ' . date('H:i:s', strtotime($r['time']) + $r['duration']);
     $next['start'] = strtotime($next['start']);
     $next['end'] = strtotime($next['end']);
     if ($r['duration'] == -1) {
         $next['timeless'] = $day;
     }
     $next['duration'] = intval($r['duration']);
     $next['title'] = (string) $r['title'];
     $next['description'] = (string) $r['description'];
     $next['color'] = 'gray';
     if ($r['status'] == 0 || $r['status'] == 1) {
         switch ($r['priority']) {
             case 0:
                 $next['color'] = 'green';
                 break;
             case 1:
                 $next['color'] = 'yellow';
                 break;
             case 2:
                 $next['color'] = 'red';
                 break;
         }
     }
     if ($r['status'] == 2) {
         $next['color'] = 'blue';
     }
     if ($r['status'] == 3) {
         $next['color'] = 'gray';
     }
     if ($r['recurrence_type']) {
         $next['title'] = '<img src="' . Base_ThemeCommon::get_template_file('CRM_Calendar_Event', 'recurrence.png') . '" border=0 hspace=0 vspace=0 align=left>' . $next['title'];
     }
     $next['view_action'] = Utils_RecordBrowserCommon::create_record_href('crm_meeting', $r['id'], 'view', array('day' => $day));
     if (Utils_RecordBrowserCommon::get_access('crm_meeting', 'edit', $r) !== false) {
         $next['edit_action'] = Utils_RecordBrowserCommon::create_record_href('crm_meeting', $r['id'], 'edit');
         if ($r['status'] <= 1) {
             $r_new = $r;
             if ($r['status'] == 0) {
                 $r_new['status'] = 1;
             }
             $next['actions'] = array(array('icon' => Base_ThemeCommon::get_template_file('CRM/Meeting', 'close_event.png'), 'href' => self::get_status_change_leightbox_href($r_new, false, array('id' => 'status'))));
         }
     } else {
         $next['edit_action'] = false;
         $next['move_action'] = false;
     }
     if (Utils_RecordBrowserCommon::get_access('crm_meeting', 'delete', $r) == false) {
         $next['delete_action'] = false;
     }
     $start_time = Base_RegionalSettingsCommon::time2reg($next['start'], 2, false, $r['duration'] != -1);
     $event_date = Base_RegionalSettingsCommon::time2reg($next['start'], false, 3, $r['duration'] != -1);
     $end_time = Base_RegionalSettingsCommon::time2reg($next['end'], 2, false, $r['duration'] != -1);
     $inf2 = array(__('Date') => '<b>' . $event_date . '</b>');
     if ($r['duration'] == -1) {
         $inf2 += array(__('Time') => __('Timeless event'));
     } else {
         $inf2 += array(__('Time') => $start_time . ' - ' . $end_time, __('Duration') => Base_RegionalSettingsCommon::seconds_to_words($r['duration']));
     }
     $emps = array();
     foreach ($r['employees'] as $e) {
         $e = CRM_ContactsCommon::contact_format_no_company($e, true);
         $e = str_replace('&nbsp;', ' ', $e);
         if (mb_strlen($e, 'UTF-8') > 33) {
             $e = mb_substr($e, 0, 30, 'UTF-8') . '...';
         }
         $emps[] = $e;
     }
     $next['busy_label'] = $r['employees'];
     $cuss = array();
     foreach ($r['customers'] as $c) {
         $c = CRM_ContactsCommon::display_company_contact(array('customers' => $c), true, array('id' => 'customers'));
         $cuss[] = str_replace('&nbsp;', ' ', $c);
     }
     $inf2 += array(__('Event') => '<b>' . $next['title'] . '</b>', __('Description') => $next['description'], __('Assigned to') => implode('<br>', $emps), __('Contacts') => implode('<br>', $cuss), __('Status') => Utils_CommonDataCommon::get_value('CRM/Status/' . $r['status'], true), __('Access') => Utils_CommonDataCommon::get_value('CRM/Access/' . $r['permission'], true), __('Priority') => Utils_CommonDataCommon::get_value('CRM/Priority/' . $r['priority'], true), __('Notes') => Utils_AttachmentCommon::count('crm_meeting/' . $r['id']));
     //		$next['employees'] = implode('<br>',$emps);
     //		$next['customers'] = implode('<br>',$cuss);
     $next['employees'] = $r['employees'];
     $next['customers'] = $r['customers'];
     $next['status'] = $r['status'] <= 2 ? 'active' : 'closed';
     $next['custom_tooltip'] = '<center><b>' . __('Meeting') . '</b></center><br>' . Utils_TooltipCommon::format_info_tooltip($inf2) . '<hr>' . CRM_ContactsCommon::get_html_record_info($r['created_by'], $r['created_on'], null, null);
     return $next;
 }
Esempio n. 13
0
	public function manage_permissions() {
		$this->help('Permissions Editor','permissions');
		$this->init();
        $gb = $this->init_module('Utils/GenericBrowser','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 = Utils_RecordBrowserCommon::crits_to_words($this->tab, $crits, false);
			$crits_text = '';
			foreach ($crits as $c) {
				switch ($c) {
					case 'and': $crits_text .= '<span class="joint">'.__('and').'</span><br>'; break;
					case 'or': $crits_text .= '<span class="joint">'.__('or').'</span> '; break;
					default: $crits_text .= $c.' ';
				}
			}
			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','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;');
	}
Esempio n. 14
0
 private function dashboard()
 {
     load_js($this->get_module_dir() . 'ab.js');
     $default_dash = $this->get_module_variable('default');
     $config_mode = $this->get_module_variable('config_mode', false);
     if ($default_dash || Base_DashboardCommon::has_permission_to_manage_applets()) {
         if ($config_mode) {
             Base_ActionBarCommon::add('back', __('Done'), $this->create_callback_href(array($this, 'switch_config_mode')));
         } else {
             Base_ActionBarCommon::add('settings', __('Config'), $this->create_callback_href(array($this, 'switch_config_mode')));
         }
     }
     if ($default_dash || !Base_DashboardCommon::has_permission_to_manage_applets()) {
         $tabs = DB::GetAll('SELECT * FROM base_dashboard_default_tabs ORDER BY pos');
     } else {
         $tabs = DB::GetAll('SELECT * FROM base_dashboard_tabs WHERE user_login_id=%d ORDER BY pos', array(Base_AclCommon::get_user()));
         if (!$tabs) {
             Base_DashboardCommon::set_default_applets();
             $tabs = DB::GetAll('SELECT * FROM base_dashboard_tabs WHERE user_login_id=%d ORDER BY pos', array(Base_AclCommon::get_user()));
         }
     }
     if ($config_mode) {
         // *** New tab code ****
         $f = $this->init_module('Libs_QuickForm');
         $f->addElement('hidden', 'tab_name', 'Tab Name', array('id' => 'dashboard_tab_name'));
         $f->addElement('hidden', 'id', 'Tab ID', array('id' => 'dashboard_tab_id'));
         $f->display();
         if ($f->validate()) {
             $vals = $f->exportValues();
             $name = $vals['tab_name'];
             if ($name) {
                 $id = $vals['id'];
                 $table = 'base_dashboard_' . ($default_dash ? 'default_' : '') . 'tabs';
                 if ($id) {
                     DB::Execute('UPDATE ' . $table . ' SET name=%s WHERE id=%d', array($name, $id));
                 } else {
                     if ($default_dash) {
                         $max = DB::GetOne('SELECT max(pos)+1 FROM ' . $table);
                         if ($max === false || $max === null) {
                             $max = 0;
                         }
                         DB::Execute('INSERT INTO ' . $table . '(name,pos) VALUES(%s,%d)', array($name, $max));
                     } else {
                         $max = DB::GetOne('SELECT max(pos)+1 FROM ' . $table . ' WHERE user_login_id=%d', array(Base_AclCommon::get_user()));
                         if ($max === false || $max === null) {
                             $max = 0;
                         }
                         DB::Execute('INSERT INTO ' . $table . '(name,pos,user_login_id) VALUES(%s,%d,%d)', array($name, $max, Base_AclCommon::get_user()));
                     }
                 }
                 location(array());
                 return;
             }
         }
         eval_js('edit_dashboard_tab=function(id){if(get_new_dashboard_tab_name("' . __('Enter label for the Dashboard tab') . '","' . __('Label cannot be empty') . '",id)){' . $f->get_submit_form_js() . '}}');
     }
     if ($config_mode) {
         print '<table style="width:100%;"><tr><td style="width:75%;vertical-align:top;">';
     }
     $init_tabs_js = array();
     if (count($tabs) > 1 || $config_mode) {
         foreach ($tabs as $tab) {
             $label = $tab['name'];
             $buttons = array();
             if ($config_mode) {
                 $label .= '&nbsp;';
                 if ($tab['pos'] > $tabs[0]['pos']) {
                     $label .= '<a ' . $this->create_callback_href(array($this, 'move_tab'), array($tab['id'], $tab['pos'], -1)) . '><img src="' . Base_ThemeCommon::get_template_file('/Base/Dashboard', 'roll-left.png') . '" onMouseOver="this.src=\'' . Base_ThemeCommon::get_template_file('/Base/Dashboard', 'roll-left-hover.png') . '\';" onMouseOut="this.src=\'' . Base_ThemeCommon::get_template_file('/Base/Dashboard', 'roll-left.png') . '\';" width="14" height="14" alt="<" border="0"></a>';
                 }
                 if ($tab['pos'] < $tabs[count($tabs) - 1]['pos']) {
                     $label .= '<a ' . $this->create_callback_href(array($this, 'move_tab'), array($tab['id'], $tab['pos'], +1)) . '><img src="' . Base_ThemeCommon::get_template_file('/Base/Dashboard', 'roll-right.png') . '" onMouseOver="this.src=\'' . Base_ThemeCommon::get_template_file('/Base/Dashboard', 'roll-right-hover.png') . '\';" onMouseOut="this.src=\'' . Base_ThemeCommon::get_template_file('/Base/Dashboard', 'roll-right.png') . '\';" width="14" height="14" alt="<" border="0"></a>';
                 }
                 $label .= '<a href="javascript:void(0);" onclick="edit_dashboard_tab(' . $tab['id'] . ');"><img src="' . Base_ThemeCommon::get_template_file('/Base/Dashboard', 'configure.png') . '" onMouseOver="this.src=\'' . Base_ThemeCommon::get_template_file('/Base/Dashboard', 'configure-hover.png') . '\';" onMouseOut="this.src=\'' . Base_ThemeCommon::get_template_file('/Base/Dashboard', 'configure.png') . '\';" width="14" height="14" alt="<" border="0"></a>';
                 $label .= '<a ' . $this->create_confirm_callback_href(__('Delete this tab and all applets assigned to it?'), array($this, 'delete_tab'), $tab['id']) . '><img src="' . Base_ThemeCommon::get_template_file('/Base/Dashboard', 'close.png') . '" onMouseOver="this.src=\'' . Base_ThemeCommon::get_template_file('/Base/Dashboard', 'close-hover.png') . '\';" onMouseOut="this.src=\'' . Base_ThemeCommon::get_template_file('/Base/Dashboard', 'close.png') . '\';" width="14" height="14" alt="<" border="0"></a>';
             }
             $this->tb->set_tab($label, array($this, 'display_dashboard'), $tab['id'], $config_mode, $buttons);
             $init_tabs_js[] = $tab['id'];
         }
         if ($config_mode) {
             // *** New tab button ****
             $this->tb->start_tab(__('Add new Tab'));
             $this->tb->set_href('href="javascript:void(0);" onclick="edit_dashboard_tab(null);"');
             $this->tb->end_tab();
         }
         $remember_tab = Base_User_SettingsCommon::get('Base_Dashboard', 'remember_tab');
         if ($remember_tab) {
             if (isset($_REQUEST['__homepage_req_session__']) && isset($_SESSION['client']['dashboard_tab'])) {
                 $this->tb->switch_tab($_SESSION['client']['dashboard_tab']);
                 //force switch tab
             } elseif (isset($_SESSION['client']['dashboard_tab'])) {
                 $this->tb->set_default_tab($_SESSION['client']['dashboard_tab']);
             } else {
                 $this->tb->set_default_tab($this->tb->get_tab());
             }
             $_SESSION['client']['dashboard_tab'] = $this->tb->get_tab();
         }
         $this->display_module($this->tb);
         $this->tb->tag();
     } else {
         $this->display_dashboard($tabs[0]['id']);
         $init_tabs_js[] = $tabs[0]['id'];
     }
     if ($config_mode) {
         print '</td>';
         print '<td id="dashboard" style="vertical-align:top;">';
         $search_caption = __('Search applets...');
         print '<input type="text" id="dashboard_applets_filter" style="color:#555;width:90%;" value="' . $search_caption . '" onblur="dashboard_prepare_filter_box(0,\'' . $search_caption . '\')" onfocus="dashboard_prepare_filter_box(1,\'' . $search_caption . '\')" onkeyup="dashboard_filter_applets()">';
         print '<div id="dashboard_applets_new_scroll" style="overflow-y:auto;overflow-x: hidden;height:200px;vertical-align:top">';
         print '<div id="dashboard_applets_new" style="vertical-align:top">';
         print Base_DashboardCommon::get_installed_applets_html();
         print '</div>';
         print '</div>';
         print '</td></tr></table>';
         eval_js('var dim=document.viewport.getDimensions();var dct=$("dashboard_applets_new_scroll");dct.style.height=(Math.max(dim.height,document.documentElement.clientHeight)-150)+"px";');
     }
     eval_js('dashboard_activate(' . json_encode($init_tabs_js) . ',' . ($default_dash ? 1 : 0) . ',' . ($default_dash || Base_DashboardCommon::has_permission_to_manage_applets() ? 1 : 0) . ')');
 }
Esempio n. 15
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');
 }
Esempio n. 16
0
	/**
	 * This returns HTML of created thumb.
	 */
	public static function get_thumb_html($img, $attr_x = null, $attr_y = null) {
		$x = self::create_thumb($img, $attr_x, $attr_y);
		$md = md5($x['thumb']);
		load_js("modules/Utils/Image/js/image.js");
		eval_js('utils_image_load_thumb(\''.$x['thumb'].'\', \''.$md.'\')');

		return '<img class="loader_'.$md.'" src="'.Base_ThemeCommon::get_template_file('Utils/Image','loader.gif').'">';
	}
Esempio n. 17
0
 public static function crm_calendar_handler($action)
 {
     $args = func_get_args();
     array_shift($args);
     $ret = null;
     switch ($action) {
         case 'get_all':
             $ret = call_user_func_array(array('CRM_TasksCommon', 'crm_event_get_all'), $args);
             break;
         case 'update':
             $ret = call_user_func_array(array('CRM_TasksCommon', 'crm_event_update'), $args);
             break;
         case 'get':
             $ret = call_user_func_array(array('CRM_TasksCommon', 'crm_event_get'), $args);
             break;
         case 'delete':
             $ret = call_user_func_array(array('CRM_TasksCommon', 'crm_event_delete'), $args);
             break;
         case 'new_event_types':
             $ret = array(array('label' => __('Task'), 'icon' => Base_ThemeCommon::get_template_file('CRM_Tasks', 'icon.png')));
             break;
         case 'new_event':
             $ret = call_user_func_array(array('CRM_TasksCommon', 'crm_new_event'), $args);
             break;
         case 'view_event':
             $ret = call_user_func_array(array('CRM_TasksCommon', 'crm_view_event'), $args);
             break;
         case 'edit_event':
             $ret = call_user_func_array(array('CRM_TasksCommon', 'crm_edit_event'), $args);
             break;
         case 'recordset':
             $ret = 'task';
     }
     return $ret;
 }
Esempio n. 18
0
 /**
  * Displays tabs.
  * You can alternatively choose to use different template file for tabs display.
  * 
  * @param string template file that will be used
  */
 public function body($template = null)
 {
     if (empty($this->tabs)) {
         return;
     }
     $theme = $this->init_module(Base_Theme::module_name());
     load_js($this->get_module_dir() . 'tb_.js');
     $i = 0;
     if (is_numeric($this->page) && $this->page >= count($this->tabs)) {
         $this->page = 0;
     }
     $this->max = count($this->tabs);
     $body = '';
     $submenus = array();
     foreach ($this->tabs as $caption => $val) {
         if (substr_count($caption, '#') == 1) {
             list($group, $s_caption) = explode('#', $caption);
             if (!isset($submenus[$group])) {
                 $submenus[$group] = array();
             }
             $submenus[$group][$s_caption] = $val;
             $this->tabs[$s_caption] = $val;
             unset($this->tabs[$caption]);
         }
     }
     foreach ($submenus as $group => $captions) {
         if (count($captions) == 1) {
             unset($submenus[$group]);
         } else {
             if (isset($this->tabs[$group])) {
                 $submenus[$group][$group] = $this->tabs[$group];
                 unset($this->tabs[$group]);
             }
             foreach ($captions as $caption => $val) {
                 unset($this->tabs[$caption]);
             }
         }
     }
     $final_captions = array();
     foreach ($this->tabs as $caption => $val) {
         $selected = $this->page === $i || is_string($this->page) && $this->page == $caption;
         $final_captions[$caption] = $this->get_link($i, $val, $caption);
         if ($selected || $val['js']) {
             $body .= $this->display_contents($val, $i, $selected);
         }
         $i++;
     }
     $captions_subs = array();
     foreach ($submenus as $group => $captions) {
         $selected_c = ' class="tabbed_browser_unselected"';
         $subs = array();
         foreach ($captions as $caption => $val) {
             $selected = $this->page === $i || is_string($this->page) && $this->page == $caption;
             if ($selected) {
                 $selected_c = ' class="tabbed_browser_selected"';
                 $group = $group . ': ' . $caption;
             }
             if ($selected || $val['js']) {
                 $body .= $this->display_contents($val, $i, $selected);
             }
             $subs[] = $this->get_link($i, $val, $caption, $group);
             $i++;
         }
         $final_captions[$group] = '<span id="tabbed_browser_submenu_' . $group . '"' . $selected_c . '>' . $group . '&nbsp;' . '<img src="' . Base_ThemeCommon::get_template_file('Utils_TabbedBrowser', 'submenu.png') . '">' . '</span>';
         $captions_subs[$group] = $subs;
     }
     $this->tag = md5($body . $this->page);
     $theme->assign('selected', $this->page);
     $theme->assign('captions', $final_captions);
     $theme->assign('captions_submenus', $captions_subs);
     $theme->assign('body', $body);
     $theme->display($template);
 }
Esempio n. 19
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. 20
0
 public function add_actions($row, $r, $rb)
 {
     if ($row['crypted'] && !isset($_SESSION['client']['cp' . $row['id']]) || count($this->group) != 1) {
         return;
     }
     $text = $row['note'];
     if ($row['crypted']) {
         $text = Utils_AttachmentCommon::decrypt($text, $_SESSION['client']['cp' . $row['id']]);
     }
     $r->add_action($this->create_callback_href(array($this, 'copy'), array($row['id'], $text, $this->group)), __('Copy link'), null, Base_ThemeCommon::get_template_file($this->get_type(), 'copy_small.png'), 3);
     $r->add_action($this->create_confirm_callback_href(__('Are you sure you want to cut this note?'), array($this, 'cut'), array($row['id'], $text, $this->group)), __('Cut'), null, Base_ThemeCommon::get_template_file($this->get_type(), 'cut_small.png'), 4);
 }
Esempio n. 21
0
 public static function get_change_subscription_icon_tags($category_name, $id)
 {
     $category_id = self::get_category_id($category_name);
     if (!$category_id) {
         return;
     }
     $last_seen = self::check_if_notified($category_name, $id);
     load_js('modules/Utils/Watchdog/subscribe.js');
     $tag_id = 'watchdog_sub_button_' . $category_name . '_' . $id;
     $href = ' onclick="utils_watchdog_set_subscribe(' . ($last_seen === null ? 1 : 0) . ',\'' . $category_name . '\',' . $id . ',\'' . $tag_id . '\')" href="javascript:void(0);"';
     if ($last_seen === null) {
         $icon = Base_ThemeCommon::get_template_file('Utils_Watchdog', 'not_watching_small.png');
         $tooltip = __('Click to watch this record for changes.');
     } else {
         if ($last_seen === true) {
             $icon = Base_ThemeCommon::get_template_file('Utils_Watchdog', 'watching_small.png');
             $tooltip = __('You are watching this record, click to stop watching this record for changes.');
         } else {
             $icon = Base_ThemeCommon::get_template_file('Utils_Watchdog', 'watching_small_new_events.png');
             $ev = self::display_events($category_id, $last_seen, $id);
             $tooltip = __('You are watching this record, click to stop watching this record for changes.') . ($ev ? '<br>' . __('The following changes were made since the last time you were viewing this record:') . '<br><br>' . $ev['events'] : '');
         }
     }
     $subscribers = self::get_subscribers($category_name, $id);
     $my_user = Base_AclCommon::get_user();
     if ($subscribers) {
         $icon_on = ' src="' . Base_ThemeCommon::get_template_file('Utils_Watchdog', 'watching_small.png') . '"';
         $icon_off = ' src="' . Base_ThemeCommon::get_template_file('Utils_Watchdog', 'watching_small_new_events.png') . '"';
         $other_subscribers = array();
         foreach ($subscribers as $subscriber) {
             if ($subscriber == $my_user) {
                 continue;
             }
             if (class_exists('CRM_ContactsCommon')) {
                 $contact = CRM_ContactsCommon::get_user_label($subscriber, true);
             } else {
                 $contact = Base_UserCommon::get_user_login($subscriber);
             }
             $notified = self::user_check_if_notified($subscriber, $category_name, $id);
             $icon2 = $notified === true ? $icon_on : $icon_off;
             $other_subscribers[] = '<img style="margin-right:4px;" ' . $icon2 . ' /><a>' . Utils_RecordBrowserCommon::no_wrap($contact) . '</a>';
         }
         if ($other_subscribers) {
             $tooltip .= '<hr />' . implode('<br>', $other_subscribers);
         }
     }
     $tooltip = Utils_TooltipCommon::open_tag_attrs($tooltip);
     return '<a ' . $href . ' ' . $tooltip . '><img border="0" src="' . $icon . '"></a>';
 }
Esempio n. 22
0
 public function simple_setup()
 {
     Base_ActionBarCommon::add('settings', __('Advanced view'), $this->create_confirm_callback_href(__('Switch to advanced view?'), array($this, 'switch_simple'), false));
     $module_dirs = $this->get_module_dirs();
     $is_required = ModuleManager::required_modules(true);
     $structure = array();
     foreach ($module_dirs as $entry => $versions) {
         $installed = ModuleManager::is_installed($entry);
         $module_install_class = $entry . 'Install';
         $func_simple = array($module_install_class, 'simple_setup');
         if (is_callable($func_simple)) {
             $simple_module = call_user_func($func_simple);
         } else {
             $simple_module = false;
         }
         if ($simple_module === false) {
             continue;
         }
         if ($simple_module === true) {
             $simple_module = array('package' => __('Uncategorized'), 'option' => $entry);
         }
         if (is_string($simple_module)) {
             $simple_module = array('package' => $simple_module);
         }
         if (!isset($simple_module['option'])) {
             $simple_module['option'] = null;
         }
         $simple_module['module'] = $entry;
         $simple_module['installed'] = $installed >= 0;
         $simple_module['key'] = $simple_module['package'] . ($simple_module['option'] ? '|' . $simple_module['option'] : '');
         $structure[$entry] = $simple_module;
     }
     $packages = array();
     foreach ($structure as $s) {
         if (!isset($packages[$s['key']])) {
             $packages[$s['key']] = array('also_uninstall' => array(), 'modules' => array(), 'is_required' => array(), 'installed' => null, 'icon' => false, 'version' => null, 'url' => null, 'core' => 0);
         }
         $package =& $packages[$s['key']];
         $package['modules'][] = $s['module'];
         $package['name'] = $s['package'];
         $package['option'] = $s['option'];
         if (isset($s['core'])) {
             $package['core'] = $s['core'];
         }
         if ($package['installed'] === null) {
             $package['installed'] = $s['installed'];
         } else {
             if ($s['installed'] && !$package['installed'] || !$s['installed'] && $package['installed']) {
                 $package['installed'] = 'partial';
             }
         }
         if (!isset($is_required[$s['module']])) {
             $is_required[$s['module']] = array();
         }
         foreach ($is_required[$s['module']] as $r) {
             if (!isset($structure[$r])) {
                 $package['also_uninstall'][] = $r;
                 continue;
             }
             if ($structure[$r]['package'] == $s['package']) {
                 continue;
             }
             $package['is_required'][$structure[$r]['key']] = $structure[$r]['key'];
         }
         if (isset($s['icon'])) {
             $package['icon'] = Base_ThemeCommon::get_template_file($s['module'], 'package-icon.png');
         }
         if (isset($s['version'])) {
             $package['version'] = $s['version'];
         }
         if (isset($s['url'])) {
             $package['url'] = $s['url'];
         }
     }
     $sorted = array();
     foreach ($packages as $key => $p) {
         if ($key === 0) {
             continue;
         }
         $name = $p['name'];
         $option = $p['option'];
         if (!isset($sorted[$name])) {
             $sorted[$name] = array();
             $sorted[$name]['name'] = $name;
             $sorted[$name]['modules'] = array();
             $sorted[$name]['buttons'] = array();
             $sorted[$name]['options'] = array();
             $sorted[$name]['status'] = __('Options only');
             $sorted[$name]['filter'] = array('available');
             $sorted[$name]['style'] = 'disabled';
             $sorted[$name]['installed'] = null;
             $sorted[$name]['instalable'] = 0;
             $sorted[$name]['uninstalable'] = 0;
             $sorted[$name]['core'] = 0;
         }
         $sorted[$name]['core'] |= $p['core'];
         $buttons = array();
         $status = '';
         if ($p['installed'] === true || $p['installed'] === 'partial') {
             if (!$p['core'] && empty($p['is_required'])) {
                 $mods = $p['modules'];
                 foreach ($p['also_uninstall'] as $pp) {
                     $mods[] = $pp;
                 }
                 if ($p['option'] === null) {
                     // also add all options as available for uninstall
                     foreach ($packages as $pp) {
                         if ($pp['name'] === $p['name']) {
                             $mods = array_merge($mods, $pp['modules']);
                         }
                     }
                 }
                 $buttons[] = array('label' => __('Uninstall'), 'style' => 'uninstall', 'href' => $this->create_confirm_callback_href(__('Are you sure you want to uninstall this package and remove all associated data?'), array($this, 'simple_uninstall'), array($mods)));
             } else {
                 if ($p['core']) {
                     $message = __('EPESI Core can not be uninstalled');
                 } elseif (empty($p['is_required'])) {
                     $message = __('This package can not be uninstalled');
                 } else {
                     $required = array();
                     foreach ($p['is_required'] as $v) {
                         $required[] = str_replace('|', ' / ', $v);
                     }
                     $message = __('This package is required by the following packages: %s', array('<br>' . implode('<br>', $required)));
                 }
                 $buttons[] = array('label' => __('Uninstall'), 'style' => 'disabled', 'href' => Utils_TooltipCommon::open_tag_attrs($message, false));
             }
         }
         if ($p['installed'] === false || $p['installed'] === 'partial') {
             $buttons[] = array('label' => __('Install'), 'style' => 'install', 'href' => $this->create_callback_href(array($this, 'simple_install'), array($p['modules'])));
         }
         switch (true) {
             case $p['installed'] === false:
                 $style = 'available';
                 $filter = array('available');
                 $status = __('Available');
                 break;
             case $p['installed'] === true:
                 $style = 'install';
                 $filter = array('installed');
                 $status = __('Installed');
                 break;
             case $p['installed'] === 'partial':
                 $style = 'partial-install';
                 $filter = array('installed');
                 $status = __('Partially');
                 break;
         }
         if ($option === null) {
             $sorted[$name]['modules'] = $p['modules'];
             $sorted[$name]['buttons'] = $buttons;
             $sorted[$name]['status'] = $status;
             $sorted[$name]['style'] = $style;
             $sorted[$name]['installed'] = $p['installed'];
             $sorted[$name]['instalable'] = 1;
             $sorted[$name]['uninstalable'] = empty($p['is_required']);
             $sorted[$name]['filter'] = $filter;
             $sorted[$name]['icon'] = $p['icon'];
             $sorted[$name]['version'] = $p['version'];
             $sorted[$name]['url'] = $p['url'];
         } else {
             $sorted[$name]['options'][$option] = array('name' => $option, 'buttons' => $buttons, 'status' => $status, 'style' => $style);
         }
     }
     $filters = array(__('All') => array('arg' => ''), __('Installed') => array('arg' => 'installed'), __('Available') => array('arg' => 'available'));
     if (ModuleManager::is_installed('Base_EpesiStore') >= 0) {
         $store_visible = Base_SetupCommon::is_store_visible();
         if ($store_visible) {
             $this->add_store_products($sorted, $filters);
         }
         $icon = $store_visible ? 'delete' : 'add';
         $text = $store_visible ? __('Disable EPESI Store') : __('Enable EPESI Store');
         $href = $this->create_callback_href(array('Base_SetupCommon', 'set_store_visibility'), array(!$store_visible));
         $desc = $store_visible ? __('Disabling communication with EPESI Store will improve processing speed, but will not update the list of additional modules in the store.') : '';
         Base_ActionBarCommon::add($icon, $text, $href, $desc);
     }
     foreach ($sorted as $name => $v) {
         ksort($sorted[$name]['options']);
         $buttons_tooltip =& $sorted[$name]['buttons_tooltip'];
         $buttons_tooltip = $buttons_tooltip ? Utils_TooltipCommon::open_tag_attrs($buttons_tooltip, false) : '';
     }
     uasort($sorted, array($this, 'simple_setup_sort'));
     $t = $this->init_module('Base/Theme');
     $t->assign('packages', $sorted);
     $t->assign('filters', $filters);
     $t->assign('version_label', __('Ver. '));
     $t->assign('labels', array('options' => __('Optional')));
     $t->display();
 }
Esempio n. 23
0
 private function build_menu(&$menu, &$m, $prefix = '')
 {
     foreach ($m as $k => $arr) {
         if ($k == '__split__') {
             $menu->add_split();
         } else {
             $icon = null;
             if (array_key_exists('__icon_small__', $arr)) {
                 $icon = Base_ThemeCommon::get_template_file($arr['parent_module'], $arr['__icon_small__']);
                 unset($arr['__icon_small__']);
                 unset($arr['__icon__']);
             } else {
                 if (array_key_exists('__icon__', $arr)) {
                     $icon = Base_ThemeCommon::get_template_file($arr['parent_module'], $arr['__icon__']);
                     unset($arr['__icon__']);
                 } else {
                     if (isset($arr['parent_module']) && is_string($arr['parent_module'])) {
                         $icon = Base_ThemeCommon::get_template_file($arr['parent_module'], 'icon-small.png');
                     }
                 }
             }
             if (!$icon) {
                 if (array_key_exists('__submenu__', $arr)) {
                     $icon = Base_ThemeCommon::get_template_file('Base_Menu', 'folder.png');
                 } else {
                     $icon = Base_ThemeCommon::get_template_file('Base_Menu', 'element.png');
                 }
             }
             unset($arr['parent_module']);
             if (array_key_exists('__description__', $arr)) {
                 $description = "'" . $arr['__description__'] . "'";
                 unset($arr['__description__']);
             } else {
                 $description = 'null';
             }
             if (array_key_exists('__url__', $arr)) {
                 $url = $arr['__url__'];
                 unset($arr['__url__']);
                 if (array_key_exists('__target__', $arr)) {
                     $target = $arr['__target__'];
                     unset($arr['__target__']);
                 } else {
                     $target = '_blank';
                 }
             } else {
                 $url = null;
             }
             $label = _V($k);
             // ****** Menu - translate labels
             if (array_key_exists('__submenu__', $arr)) {
                 unset($arr['__submenu__']);
                 $menu->begin_submenu($label, $icon, $prefix . $k);
                 $this->build_menu($menu, $arr, $prefix . $k . '_');
                 $menu->end_submenu();
             } else {
                 if ($url) {
                     $menu->add_link($label, $url, $icon, $target, $prefix . $k);
                 } else {
                     $menu->add_link($label, 'javascript:' . Base_MenuCommon::create_href_js($this, $arr), $icon, '', $prefix . $k);
                 }
             }
         }
     }
 }
Esempio n. 24
0
 public static function QFfield_select(&$form, $field, $label, $mode, $default, $desc, $rb_obj)
 {
     if (self::QFfield_static_display($form, $field, $label, $mode, $default, $desc, $rb_obj)) {
         return;
     }
     $record = $rb_obj->record;
     $comp = array();
     $param = explode(';', $desc['param']);
     $crits_callback = isset($param[1]) ? $param[1] : null;
     $multi_adv_params_callback = isset($param[2]) ? explode('::', $param[2]) : null;
     $multi_adv_params = array();
     if (is_callable($multi_adv_params_callback)) {
         $multi_adv_params = call_user_func($multi_adv_params_callback, $record);
     }
     // check multi_adv_params structure and fill empty values
     if (!is_array($multi_adv_params)) {
         $multi_adv_params = array();
     }
     if (!isset($multi_adv_params['order'])) {
         $multi_adv_params['order'] = array();
     }
     if (!isset($multi_adv_params['cols'])) {
         $multi_adv_params['cols'] = array();
     }
     if (!isset($multi_adv_params['format_callback'])) {
         $multi_adv_params['format_callback'] = array();
     }
     $reference = explode('::', $param[0]);
     $tab = $reference[0];
     $columns = isset($reference[1]) ? $reference[1] : null;
     if (!isset($columns)) {
         trigger_error("Columns not set for field: {$field}");
     }
     if ($tab == '__COMMON__') {
         $order = isset($reference[2]) ? $reference[2] : 'value';
         $data = Utils_CommonDataCommon::get_translated_tree($columns, $order == 'key');
         if (!is_array($data)) {
             $data = array();
         }
         $comp = $comp + $data;
         $rec_count = 0;
         $label = Utils_RecordBrowserCommon::get_field_tooltip($label, 'commondata', $columns);
     } else {
         if (isset($crits_callback)) {
             $crit_callback = explode('::', $crits_callback);
             if (is_callable($crit_callback)) {
                 $crits = call_user_func($crit_callback, false, $record);
                 $adv_crits = call_user_func($crit_callback, true, $record);
             } else {
                 $crits = $adv_crits = array();
             }
             if ($adv_crits === $crits) {
                 $adv_crits = null;
             }
             if ($adv_crits !== null) {
                 $crits = $adv_crits;
             }
         } else {
             $crits = array();
         }
         if ($tab == '__RECORDSETS__') {
             $tabs = DB::GetCol('SELECT tab FROM recordbrowser_table_properties');
         } else {
             $tabs = explode(',', $tab);
         }
         $single_tab = count($tabs) == 1;
         if (!$single_tab && empty($crits)) {
             foreach ($tabs as $tab) {
                 $crits[$tab] = array();
             }
         }
         // get related records with proper columns
         $col_id = array();
         if ($single_tab) {
             $columns = array_filter(explode('|', $columns));
             foreach ($columns as $c) {
                 $col_id[] = self::get_field_id($c);
             }
         }
         $rec_count = 0;
         foreach ($tabs as $t) {
             if (!empty($crits) && !$single_tab && !isset($crits[$t])) {
                 continue;
             }
             $rec_count += Utils_RecordBrowserCommon::get_records_count($t, $single_tab ? $crits : $crits[$t], null);
         }
         if ($rec_count <= Utils_RecordBrowserCommon::$options_limit) {
             $records = array();
             foreach ($tabs as $t) {
                 if (!empty($crits) && !$single_tab && !isset($crits[$t])) {
                     continue;
                 }
                 $access = self::get_access($t, 'selection', null, true);
                 if ($access === false) {
                     continue;
                 }
                 if ($access !== true && is_array($access)) {
                     if ($single_tab) {
                         $crits = self::merge_crits($crits, $access);
                     } elseif (isset($crits[$t]) && is_array($crits[$t]) && $crits[$t]) {
                         $crits[$t] = self::merge_crits($crits[$t], $access);
                     } else {
                         $crits[$t] = $access;
                     }
                 }
                 $records_tmp = Utils_RecordBrowserCommon::get_records($t, $single_tab ? $crits : $crits[$t], array(), !empty($multi_adv_params['order']) ? $multi_adv_params['order'] : array());
                 foreach ($records_tmp as $key => $rec) {
                     if (!self::get_access($t, 'view', $rec)) {
                         continue;
                     }
                     $records[($single_tab ? '' : $t . '/') . $key] = $rec;
                 }
             }
         } else {
             $records = array();
         }
         // set current record field value to array
         if (isset($record[$field])) {
             if (!is_array($record[$field])) {
                 if ($record[$field] != '') {
                     $record[$field] = array($record[$field] => $record[$field]);
                 } else {
                     $record[$field] = array();
                 }
             }
         }
         if ($default) {
             if (!is_array($default)) {
                 $record[$field][$default] = $default;
             } else {
                 foreach ($default as $v) {
                     $record[$field][$v] = $v;
                 }
             }
         }
         $ext_rec = array();
         $columns_qty = count($col_id);
         if (isset($record[$field])) {
             $ext_rec = array_flip($record[$field]);
             foreach ($ext_rec as $k => $v) {
                 $kk = explode('/', $k, 2);
                 if (count($kk) == 1) {
                     if ($single_tab && is_numeric($kk[0])) {
                         $t = $tab;
                         $record_id = $kk[0];
                     } else {
                         continue;
                     }
                 } else {
                     $t = $kk[0];
                     $record_id = $kk[1];
                     if (!self::check_table_name($t, false, false) || !is_numeric($record_id)) {
                         continue;
                     }
                 }
                 $c = Utils_RecordBrowserCommon::get_record($t, $record_id);
                 if (!empty($multi_adv_params['format_callback'])) {
                     $n = call_user_func($multi_adv_params['format_callback'], $c);
                 } else {
                     if ($columns_qty == 0) {
                         $n = self::create_default_linked_label($t, $record_id, true);
                     } elseif ($columns_qty == 1) {
                         $n = self::get_val($t, $col_id[0], $c, true);
                     } else {
                         $n = array();
                         foreach ($col_id as $cid) {
                             $n[] = self::get_val($t, $cid, $c, true);
                         }
                         $n = implode(' ', $n);
                     }
                 }
                 $comp[($single_tab ? '' : $t . '/') . $record_id] = $n;
             }
         }
         //            if (!empty($multi_adv_params['order']))
         //                natcasesort($comp);
         foreach ($records as $k => $v) {
             if (!empty($multi_adv_params['format_callback'])) {
                 $n = call_user_func($multi_adv_params['format_callback'], $v);
             } else {
                 if ($single_tab && is_numeric($k)) {
                     $t = $tab;
                     $record_id = $k;
                 } else {
                     $kk = explode('/', $k, 2);
                     $t = $kk[0];
                     $record_id = $kk[1];
                 }
                 if ($columns_qty == 0) {
                     $n = self::create_default_linked_label($t, $record_id, true);
                 } elseif ($columns_qty == 1) {
                     $n = self::get_val($t, $col_id[0], $v, true);
                 } else {
                     $n = array();
                     foreach ($col_id as $cid) {
                         $n[] = self::get_val($t, $cid, $v, true);
                     }
                     $n = implode(' ', $n);
                 }
             }
             $comp[$k] = $n;
             unset($ext_rec[$v['id']]);
             unset($ext_rec[$k]);
         }
         if (empty($multi_adv_params['order'])) {
             natcasesort($comp);
         }
         if ($single_tab) {
             $label = Utils_RecordBrowserCommon::get_field_tooltip($label, $desc['type'], reset($tabs), $crits);
         }
     }
     if ($rec_count > Utils_RecordBrowserCommon::$options_limit) {
         $f_callback = $multi_adv_params['format_callback'];
         if (empty($f_callback)) {
             $f_callback = array('Utils_RecordBrowserCommon', 'autoselect_label');
         }
         if ($desc['type'] == 'multiselect') {
             $el = $form->addElement('automulti', $field, $label, array('Utils_RecordBrowserCommon', 'automulti_suggestbox'), array($rb_obj->tab, $crits, $f_callback, $desc['param']), $f_callback);
             if ($single_tab) {
                 ${'rp_' . $field} = $rb_obj->init_module(Utils_RecordBrowser_RecordPicker::module_name(), array());
                 $filters_defaults = isset($multi_adv_params['filters_defaults']) ? $multi_adv_params['filters_defaults'] : array();
                 $rb_obj->display_module(${'rp_' . $field}, array($tab, $field, $multi_adv_params['format_callback'], $crits, array(), array(), array(), $filters_defaults));
                 $el->set_search_button('<a ' . ${'rp_' . $field}->create_open_href() . ' ' . Utils_TooltipCommon::open_tag_attrs(__('Advanced Selection')) . ' href="javascript:void(0);"><img border="0" src="' . Base_ThemeCommon::get_template_file('Utils_RecordBrowser', 'icon_zoom.png') . '"></a>');
             }
         } else {
             $form->addElement('autoselect', $field, $label, $comp, array(array('Utils_RecordBrowserCommon', 'automulti_suggestbox'), array($rb_obj->tab, $crits, $f_callback, $desc['param'])), $f_callback);
         }
     } else {
         if ($desc['type'] === 'select') {
             $comp = array('' => '---') + $comp;
         }
         $form->addElement($desc['type'], $field, $label, $comp, array('id' => $field));
     }
     if ($mode !== 'add') {
         $form->setDefaults(array($field => $default));
     }
 }
Esempio n. 25
0
 public function launchpad()
 {
     if (self::$launchpad == null) {
         return;
     }
     $launcher = array();
     usort(self::$launchpad, array($this, 'compare_launcher'));
     if (!empty(self::$launchpad)) {
         $icon = Base_ThemeCommon::get_template_file($this->get_type(), 'launcher.png');
         $th = $this->pack_module(Base_Theme::module_name());
         usort(self::$launchpad, array($this, 'compare_launcher'));
         $th->assign('icons', self::$launchpad);
         eval_js_once('actionbar_launchpad_deactivate = function(){leightbox_deactivate(\'actionbar_launchpad\');}');
         ob_start();
         $th->display('launchpad');
         $lp_out = ob_get_clean();
         $big = count(self::$launchpad) > 10;
         Libs_LeightboxCommon::display('actionbar_launchpad', $lp_out, __('Launchpad'), $big);
         $launcher[] = array('label' => __('Launchpad'), 'description' => 'Quick modules launcher', 'open' => '<a ' . Libs_LeightboxCommon::get_open_href('actionbar_launchpad') . '>', 'close' => '</a>', 'icon' => $icon);
         $th = $this->pack_module(Base_Theme::module_name());
         $th->assign('icons', array());
         $th->assign('launcher', array_reverse($launcher));
         $th->display();
         eval_js('$("launchpad_button_section").style.display="";');
         eval_js('$("launchpad_button_section_spacing").style.display="";');
     }
 }
Esempio n. 26
0
 public function admin()
 {
     if (!Base_AclCommon::i_am_sa() || $this->is_back()) {
         $this->parent->reset();
         return;
     }
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     $cmr = ModuleManager::call_common_methods('admin_caption');
     foreach ($cmr as $name => $caption) {
         if (!ModuleManager::check_access($name, 'admin') || $name == 'Base_Admin') {
             continue;
         }
         if (!isset($caption)) {
             continue;
         }
         if (!is_array($caption)) {
             $caption = array('label' => $caption);
         }
         if (!isset($caption['section'])) {
             $caption['section'] = __('Misc');
         }
         $mod_ok[$name] = $caption;
     }
     uksort($mod_ok, 'strcasecmp');
     $form = $this->init_module('Libs_QuickForm');
     $buttons = array();
     load_js('modules/Base/Admin/js/main.js');
     foreach ($mod_ok as $name => $caption) {
         if (method_exists($name . 'Common', 'admin_icon')) {
             $icon = call_user_func(array($name . 'Common', 'admin_icon'));
         } else {
             $icon = Base_ThemeCommon::get_template_file($name, 'icon.png');
             if (!file_exists($icon)) {
                 $icon = Base_ThemeCommon::get_template_file('Base_Admin', 'icon.png');
             }
         }
         $button_id = $name . '__button';
         $enable_field = $name . '_enable';
         $sections = array();
         $sections_id = $name . '__sections';
         $enable_default = Base_AdminCommon::get_access($name, '', true);
         $form->addElement('checkbox', $enable_field, $enable_default === null ? __('Access blocked') : __('Allow access'), null, array('onchange' => 'admin_switch_button("' . $button_id . '",this.checked, "' . $sections_id . '");', 'id' => $enable_field, 'style' => $enable_default === null ? 'display:none;' : ''));
         $form->setDefaults(array($enable_field => $enable_default));
         eval_js('admin_switch_button("' . $button_id . '",$("' . $enable_field . '").checked, "' . $sections_id . '", 1);');
         if (class_exists($name . 'Common') && is_callable(array($name . 'Common', 'admin_access_levels'))) {
             $raws = call_user_func(array($name . 'Common', 'admin_access_levels'));
             if (is_array($raws)) {
                 foreach ($raws as $s => $v) {
                     $type = isset($v['values']) ? 'select' : 'checkbox';
                     $vals = isset($v['values']) ? $v['values'] : null;
                     $s_field = $name . '__' . $s . '__switch';
                     $form->addElement($type, $s_field, $v['label'], $vals);
                     $form->setDefaults(array($s_field => Base_AdminCommon::get_access($name, $s, true)));
                     $sections[$s] = $s_field;
                 }
             }
         }
         $buttons[$caption['section']][$name] = array('label' => $caption['label'], 'icon' => $icon, 'id' => $button_id, 'enable_switch' => $enable_field, 'sections_id' => $sections_id, 'sections' => $sections);
     }
     if ($form->validate()) {
         $vals = $form->exportValues();
         DB::Execute('DELETE FROM base_admin_access');
         foreach ($buttons as $section => $bs) {
             foreach ($bs as $name => $b) {
                 DB::Execute('INSERT INTO base_admin_access (module, section, allow) VALUES (%s, %s, %d)', array($name, '', isset($vals[$b['enable_switch']]) && $vals[$b['enable_switch']] ? 1 : 0));
                 foreach ($b['sections'] as $s => $f) {
                     DB::Execute('INSERT INTO base_admin_access (module, section, allow) VALUES (%s, %s, %d)', array($name, $s, isset($vals[$f]) ? $vals[$f] : 0));
                 }
             }
         }
         $this->parent->reset();
         return;
     }
     Base_ActionBarCommon::add('save', __('Save'), $form->get_submit_form_href());
     $sections = array();
     foreach ($buttons as $section => $b) {
         $sections[$section] = array('header' => $section, 'buttons' => $b);
     }
     $sections = $this->sort_sections($sections);
     $theme = $this->pack_module('Base/Theme');
     $form->assign_theme('form', $theme);
     $theme->assign('header', __('Admin Panel Access'));
     $theme->assign('sections', $sections);
     $theme->display('access_panel');
 }
Esempio n. 27
0
 public function applet($conf, &$opts)
 {
     Epesi::load_js('modules/CRM/Roundcube/utils.js');
     $opts['go'] = true;
     $accounts = array();
     $ret = array();
     $update_applet = '';
     foreach ($conf as $key => $on) {
         $x = explode('_', $key);
         if ($x[0] == 'account' && $on) {
             $id = $x[1];
             $accounts[] = $id;
         }
     }
     $accs = Utils_RecordBrowserCommon::get_records('rc_accounts', array('epesi_user' => Acl::get_user(), 'id' => $accounts));
     print '<ul>';
     foreach ($accs as $row) {
         $mail = $row['account_name'];
         $cell_id = 'mailaccount_' . $opts['id'] . '_' . $row['id'];
         //interval execution
         eval_js_once('setInterval(\'CRM_RC.update_msg_num(' . $opts['id'] . ' ,' . $row['id'] . ' , 0)\',300000)');
         //and now
         $update_applet .= 'CRM_RC.update_msg_num(' . $opts['id'] . ' ,' . $row['id'] . ' ,1);';
         print '<li><i><a' . $this->create_callback_href(array($this, 'open_rc_account'), $row['id']) . '>' . $mail . '</a></i> - <span id="' . $cell_id . '"></span></li>';
     }
     print '</ul>';
     $this->js($update_applet);
     $href = $this->create_callback_href(array('Base_BoxCommon', 'push_module'), array($this->get_type(), 'account_manager', array(true)));
     $img = '<img src="' . Base_ThemeCommon::get_template_file('Base_Dashboard', 'configure.png') . '" border="0">';
     $tooltip = Utils_TooltipCommon::open_tag_attrs(__('Go to account settings'));
     $opts['actions'][] = "<a {$tooltip} {$href}>{$img}</a>";
 }
Esempio n. 28
0
 public static function display_contacts_with_notification($recordset, $record, $nolink, $desc)
 {
     $icon_on = Utils_TooltipCommon::open_tag_attrs(__('This person is up to date with all changes made to this record.')) . ' src="' . Base_ThemeCommon::get_template_file('Utils_Watchdog', 'watching_small.png') . '"';
     $icon_off = Utils_TooltipCommon::open_tag_attrs(__('This person has notifications pending about changes made to this record.')) . ' src="' . Base_ThemeCommon::get_template_file('Utils_Watchdog', 'watching_small_new_events.png') . '"';
     $icon_none = Utils_TooltipCommon::open_tag_attrs(__('This person is not watching this record.')) . ' src="' . Base_ThemeCommon::get_template_file('Utils_Watchdog', 'not_watching_small.png') . '"';
     $v = $record[$desc['id']];
     $def = '';
     $first = true;
     $param = explode(';', $desc['param']);
     if (!is_array($v) && !is_numeric($v)) {
         return $v;
     }
     if ($param[1] == '::') {
         $callback = array('CRM_ContactsCommon', 'contact_format_default');
     } else {
         $callback = explode('::', $param[1]);
     }
     if (!is_array($v)) {
         $v = array($v);
     }
     foreach ($v as $k => $w) {
         if ($w == '') {
             break;
         }
         if ($first) {
             $first = false;
         } else {
             $def .= '<br>';
         }
         $contact = CRM_ContactsCommon::get_contact($w);
         if (!$nolink) {
             if ($contact['login'] == '') {
                 $icon = $icon_none;
             } else {
                 $icon = Utils_WatchdogCommon::user_check_if_notified($contact['login'], $recordset, $record['id']);
                 if ($icon === null) {
                     $icon = $icon_none;
                 } elseif ($icon === true) {
                     $icon = $icon_on;
                 } else {
                     $icon = $icon_off;
                 }
             }
             $def .= '<img style="margin-right:4px;" ' . $icon . ' />';
         }
         $def .= Utils_RecordBrowserCommon::no_wrap(call_user_func($callback, $contact, $nolink));
     }
     if (!$def) {
         $def = '---';
     }
     return $def;
 }
Esempio n. 29
0
	private function get_icon($records_count) {
		$limits = array(10=>'pile3', 5=>'pile2', 1=>'pile1', 0=>'pile0');

		foreach ($limits as $limit=>$file) {
			if ($records_count >= $limit) break;
		}

		return Base_ThemeCommon::get_template_file($this->get_type(),$file.'.png');
	}
Esempio n. 30
0
 public function main_page()
 {
     if (!Acl::is_user()) {
         print 'Log in to change your settings.';
     }
     $modules = array();
     $admin_settings = $this->get_module_variable('admin_settings');
     $us = ModuleManager::call_common_methods('user_settings');
     foreach ($us as $name => $menu) {
         if (!is_array($menu)) {
             continue;
         }
         foreach ($menu as $k => $v) {
             $display = false;
             if (is_array($v)) {
                 foreach ($v as $k2 => $m2) {
                     if (isset($m2['type']) && $m2['type'] != 'hidden') {
                         $display = true;
                         break;
                     }
                     if ($display) {
                         break;
                     }
                 }
             } else {
                 $display = true;
             }
             if (!$display) {
                 continue;
             }
             if (isset($modules[$k])) {
                 if (!is_string($v) && !isset($modules[$k]['external'])) {
                     $modules[$k]['module_names'][] = $name;
                 } else {
                     trigger_error('You cannot override this key: ' . $k, E_USER_ERROR);
                 }
             } else {
                 if (!is_string($v)) {
                     $modules[$k] = array('action' => $this->create_unique_href(array('settings_branch' => $k)), 'module_names' => array($name));
                 } elseif (!$admin_settings) {
                     $modules[$k] = array('action' => $this->create_main_href($name, $v), 'module_names' => array($name), 'external' => true);
                 }
             }
         }
     }
     ksort($modules);
     $buttons = array();
     foreach ($modules as $caption => $arg) {
         $icon = null;
         sort($arg['module_names']);
         foreach ($arg['module_names'] as $m) {
             $f = array($m . 'Common', 'user_settings_icon');
             if (is_callable($f)) {
                 $ret = call_user_func($f);
                 if (is_array($ret)) {
                     if (isset($ret[$caption])) {
                         $icon = $ret[$caption];
                         break;
                     }
                 } elseif (is_string($ret)) {
                     $icon = $ret;
                     break;
                 }
             }
         }
         if (!$icon) {
             foreach ($arg['module_names'] as $m) {
                 $new = Base_ThemeCommon::get_template_file($m, 'icon.png');
                 if ($new) {
                     $icon = $new;
                 }
             }
         }
         $buttons[] = array('link' => '<a ' . $arg['action'] . '>' . $caption . '</a>', 'module' => $arg['module_names'], 'icon' => $icon);
     }
     $theme = $this->pack_module('Base/Theme');
     $theme->assign('header', __('User Settings'));
     $theme->assign('buttons', $buttons);
     $theme->display();
 }