Exemplo n.º 1
0
 function toHtml()
 {
     $str = "";
     if ($this->_flagFrozen) {
         $str .= $this->getFrozenHtml();
     } else {
         $value = $this->getAttribute('value');
         if (is_numeric($value)) {
             $value = date('Y-m-d', $value);
         }
         $id = $this->getAttribute('id');
         $name = $this->getAttribute('name');
         if ($value) {
             $this->setAttribute('value', Base_RegionalSettingsCommon::time2reg($value, false, true, false));
         }
         if (!isset($id)) {
             $id = 'datepicker_field_' . $name;
             $this->updateAttributes(array('id' => $id));
         }
         $ex_date = Base_RegionalSettingsCommon::time2reg(null, false, true, false);
         $date_format = Base_RegionalSettingsCommon::date_format();
         $this->setType('text');
         if (!$this->getAttribute('placeholder')) {
             $this->setAttribute('placeholder', __('Click to select date'));
         }
         $js = Utils_PopupCalendarCommon::create_href(md5($id), 'new Ajax.Request(\'modules/Utils/PopupCalendar/up.php\',' . '{method:\'post\', parameters:{date: __YEAR__+\'-\'+__MONTH__+\'-\'+__DAY__},' . 'onSuccess:function(t){e=$(\'' . Epesi::escapeJS($id, false) . '\');if(e) {e.value=t.responseText;jq(e).change();}}})', null, null, 'popup.clonePosition(\'' . $id . '\',{setWidth:false,setHeight:false,offsetTop:$(\'' . $id . '\').getHeight()})', $value, $id);
         $str .= $this->_getTabs() . '<input ' . $js . ' ' . $this->_getAttrString($this->_attributes) . ' ' . Utils_TooltipCommon::open_tag_attrs(__('Example date: %s', array($ex_date)), false) . ' />';
         eval_js('Event.observe(\'' . $id . '\',\'keypress\',Utils_PopupCalendarDatePicker.validate.bindAsEventListener(Utils_PopupCalendarDatePicker,\'' . Epesi::escapeJS($date_format, false) . '\'))');
         eval_js('Event.observe(\'' . $id . '\',\'blur\',Utils_PopupCalendarDatePicker.validate_blur.bindAsEventListener(Utils_PopupCalendarDatePicker,\'' . Epesi::escapeJS($date_format, false) . '\'))');
     }
     return $str;
 }
Exemplo n.º 2
0
	function toHtml() {
		if(count($this->_cd)>1) {
			load_js('modules/Utils/CommonData/qf.js');
			$id=$this->getAttribute('id');
			if(!isset($id)) {
				$id = $this->getName();
				$this->updateAttributes(array('id'=>$id));
			}
			$val = $this->getValue();
			$val = $val[0];
			if($this->_flagFrozen) {
				eval_js('new Utils_CommonData_freeze(\''.Epesi::escapeJS($id,false).'\', \''.Epesi::escapeJS(json_encode($this->_cd),false).'\')');
				$html = '<span id="'.$id.'_label">&nbsp;</span>';
				$name = $this->getPrivateName();
				// Only use id attribute if doing single hidden input
				$html .= '<input' . $this->_getAttrString(array(
					     'type'  => 'hidden',
					     'name'  => $name,
					     'value' => $val,
					     'id'    => $id
					 )) . ' />';
				return $html;
			}
			eval_js('new Utils_CommonData(\''.Epesi::escapeJS($id,false).'\', \''.Epesi::escapeJS($val,false).'\', \''.Epesi::escapeJS(json_encode($this->_cd),false).'\', '.($this->_add_empty_fields?1:0).')');
		}
	        return parent::toHtml();
	}
Exemplo n.º 3
0
	public static function init_tooltip_div(){
		if(!isset($_SESSION['client']['utils_tooltip']['div_exists'])) {
			$smarty = Base_ThemeCommon::init_smarty();
			$smarty->assign('tip','<span id="tooltip_text"></span>');
			ob_start();
			@Base_ThemeCommon::display_smarty($smarty,'Utils_Tooltip');
			$tip_th = ob_get_clean();
			eval_js('Utils_Tooltip__create_block(\''.Epesi::escapeJS($tip_th,false).'\')',false);
			$_SESSION['client']['utils_tooltip']['div_exists'] = true;
		}
		on_exit(array('Utils_TooltipCommon', 'hide_tooltip'),null,false);
	}
Exemplo n.º 4
0
 public static function QFfield_account_name(&$form, $field, $label, $mode, $default, $desc, $rb = null)
 {
     $form->addElement('text', $field, $label, array('id' => $field));
     $form->registerRule($field, 'function', 'check_account_name', 'CRM_RoundcubeCommon');
     $form->addRule($field, __('Account Name already in use'), $field, isset($rb->record['id']) ? $rb->record['id'] : null);
     $form->setDefaults(array($field => $default));
     load_js('modules/CRM/Roundcube/utils.js');
     eval_js('CRM_RC.filled_smtp_message=\'' . Epesi::escapeJS(__('SMTP login and password was filled with imap account details. Please change them if needed.'), false, true) . '\';CRM_RC.edit_form()');
     if ($mode == 'view') {
         $form->freeze(array($field));
     }
 }
Exemplo n.º 5
0
 public static function create_href($name, $function = '', $mode = null, $first_day_of_week = null, $pos_js = null, $default = null, $id = null)
 {
     Base_ThemeCommon::load_css('Utils_PopupCalendar');
     load_js('modules/Utils/PopupCalendar/js/main2.js');
     load_js('modules/Utils/PopupCalendar/datepicker.js');
     if (!isset($mode)) {
         $mode = 'day';
     }
     if (!isset($first_day_of_week)) {
         if (Acl::is_user()) {
             $first_day_of_week = self::get_first_day_of_week();
         } else {
             $first_day_of_week = 0;
         }
     } elseif (!is_numeric($first_day_of_week)) {
         trigger_error('Invalid first day of week', E_USER_ERROR);
     }
     $calendar = '<div id="Utils_PopupCalendar">' . '<table cellspacing="0" cellpadding="0" border="0"><tr><td id="datepicker_' . $name . '_header">error</td></tr>' . '<tr><td id="datepicker_' . $name . '_view">calendar not loaded</td></tr></table></div>';
     $entry = 'datepicker_' . $name . '_calendar';
     $butt = $id === null ? 'datepicker_' . $name . '_button' : $id;
     $smarty = Base_ThemeCommon::init_smarty();
     $smarty->assign('calendar', $calendar);
     ob_start();
     Base_ThemeCommon::display_smarty($smarty, 'Utils_PopupCalendar');
     $cal_out = ob_get_clean();
     print '<div id="' . $entry . '" class="utils_popupcalendar_popup" style="display:none;z-index:2050;width:1px;">' . $cal_out . '</div>';
     if (!isset($pos_js)) {
         $pos_js = 'popup.clonePosition(\'' . $butt . '\',{setWidth:false,setHeight:false,offsetTop:$(\'' . $butt . '\').getHeight()});';
     }
     eval_js('if(Epesi.ie)$(\'' . $entry . '\').style.position="fixed";else $(\'' . $entry . '\').absolutize();');
     $ret = 'onClick="var popup=$(\'' . $entry . '\');' . $pos_js . ';$(\'' . $entry . '\').toggle()" href="javascript:void(0)" id="' . $butt . '"';
     $function .= ';$(\'' . $entry . '\').hide()';
     if ($default) {
         if (!is_numeric($default)) {
             $default = strtotime($default);
         }
         $args = date('Y', $default) . ',' . (date('n', $default) - 1) . ',' . date('d', $default);
     } else {
         $args = '';
     }
     $js = 'var datepicker_' . $name . ' = new Utils_PopupCalendar("' . Epesi::escapeJS($function, true, false) . '", \'' . $name . '\',\'' . $mode . '\',\'' . $first_day_of_week . '\',';
     $months = array(__('January'), __('February'), __('March'), __('April'), __('May'), __('June'), __('July'), __('August'), __('September'), __('October'), __('November'), __('December'));
     $days = array(__('Sun'), __('Mon'), __('Tue'), __('Wed'), __('Thu'), __('Fri'), __('Sat'));
     $js .= 'new Array(\'' . implode('\',\'', $months) . '\'),';
     $js .= 'new Array(\'' . implode('\',\'', $days) . '\')';
     $js .= ');' . 'datepicker_' . $name . '.show(' . $args . ')';
     eval_js($js);
     //		eval_js('$(\''.$entry.'\').absolutize();');
     return $ret;
 }
Exemplo n.º 6
0
 public function body()
 {
     load_js('modules/Base/Help/js/canvasutilities.js');
     load_js('modules/Base/Help/js/main.js');
     eval_js('Helper.stop_tutorial_message = "' . Epesi::escapeJS('Tutorial was stopped') . '";');
     eval_js('setTimeout("Helper.get_all_help_hooks();", 500);');
     $theme = $this->init_module('Base_Theme');
     $theme->assign('href', 'href="javascript:void(0);" onclick="Helper.menu()"');
     $theme->assign('search_placeholder', __('Start typing to search help topics'));
     $theme->assign('label', __('Help'));
     Utils_ShortcutCommon::add(array('esc'), 'function(){Helper.escape();}');
     Utils_ShortcutCommon::add(array('f1'), 'function(){Helper.menu();}');
     $theme->display();
 }
Exemplo n.º 7
0
 private static function notify_client($buffer)
 {
     if (JS_OUTPUT && class_exists('Epesi')) {
         chdir(dirname(dirname(__FILE__)));
         Epesi::clean();
         if (DISPLAY_ERRORS) {
             Epesi::js("\$('debug_content').style.display='block';");
             Epesi::text($buffer . '<hr>', 'error_box', 'prepend');
         }
         Epesi::alert('There was an error in one of epesi modules.' . (DISPLAY_ERRORS ? ' Details are displayed at the bottom of the page, please send this information to system administrator.' : ''));
         return Epesi::get_output();
     }
     return $buffer;
 }
Exemplo n.º 8
0
 public function applet($values, &$opts)
 {
     //available applet options: toggle,href,title,go,go_function,go_arguments,go_contruct_arguments
     Base_ThemeCommon::load_css('Applets_Weather');
     $opts['title'] = __('Weather');
     $rssfeed = $values['rssfeed'] . '?p=' . $values['zipcode'] . '&u=' . $values['temperature'];
     $name = md5($this->get_path() . $rssfeed);
     //div for updating
     print '<div id="Applets_Weather"><div id="rssfeed_' . $name . '"><span>' . __('Loading Weather...') . '</span></div></div>';
     //interval execution
     eval_js_once('var rssfeedcache = Array();' . 'rssfeedfunc = function(name,fee,num,cache){' . 'if(!$(\'rssfeed_\'+name)) return;' . 'if(cache && typeof rssfeedcache[name] != \'undefined\')' . '$(\'rssfeed_\'+name).innerHTML = rssfeedcache[name];' . 'else ' . 'new Ajax.Updater(\'rssfeed_\'+name,\'modules/Applets/Weather/refresh.php\',{' . 'method:\'post\',' . 'onComplete:function(r){rssfeedcache[name]=r.responseText},' . 'parameters:{feed:fee, number:num, cid: Epesi.client_id}});' . '}');
     eval_js_once('setInterval(\'rssfeedfunc(\\\'' . $name . '\\\',\\\'' . Epesi::escapeJS($rssfeed, false) . '\\\' , 2 , 0)\',1799993)');
     //29 minutes and 53 seconds
     //get rss now!
     eval_js('rssfeedfunc(\'' . $name . '\',\'' . Epesi::escapeJS($rssfeed, false) . '\' , 2 , 1)');
 }
Exemplo n.º 9
0
 public function applet($values, &$opts)
 {
     //available applet options: toggle,href,title,go,go_function,go_arguments,go_contruct_arguments
     if (!$values['title']) {
         $values['title'] = __('RSS Feed');
     }
     $opts['title'] = $values['title'];
     $name = md5($this->get_path() . $values['rssfeed']);
     //div for updating
     print '<div id="rssfeed_' . $name . '" style="width: 270px; padding: 5px 5px 5px 20px;">' . __('Loading RSS...') . '</div>';
     //interval execution
     eval_js_once('var rssfeedcache = Array();' . 'rssfeedfunc = function(name,fee,num,cache){' . 'if(!$(\'rssfeed_\'+name)) return;' . 'if(cache && typeof rssfeedcache[name] != \'undefined\')' . '$(\'rssfeed_\'+name).innerHTML = rssfeedcache[name];' . 'else ' . 'new Ajax.Updater(\'rssfeed_\'+name,\'modules/Applets/RssFeed/refresh.php\',{' . 'method:\'post\',' . 'onComplete:function(r){rssfeedcache[name]=r.responseText},' . 'parameters:{feed:fee, number:num, cid: Epesi.client_id}});' . '}');
     eval_js_once('setInterval(\'rssfeedfunc(\\\'' . $name . '\\\',\\\'' . Epesi::escapeJS($values['rssfeed'], false) . '\\\' ,' . $values['rssnumber'] . ' , 0)\',1799993)');
     //29 minutes and 53 seconds
     //get rss now!
     eval_js('rssfeedfunc(\'' . $name . '\',\'' . Epesi::escapeJS($values['rssfeed'], false) . '\' ,' . $values['rssnumber'] . ' , 1)');
 }
Exemplo n.º 10
0
	function toHtml() {
		$str = "";
		if ($this->_flagFrozen) {
			$str .= $this->getFrozenHtml();
		} else {
			$id = $this->getAttribute('id');
			$name = $this->getAttribute('name');
			if(!isset($id)) {
				$id = 'currency_field_'.$name;
				$this->updateAttributes(array('id'=>$id));
			}
			
			$this->dec_digits = DB::GetOne('SELECT MAX(decimals) FROM utils_currency');

			$str .= $this->_getTabs() . '<div style="position: relative;">';

			$str .= $this->_getTabs() .
					'<div style="margin-right:45px;" class="currency_amount"><input ' . $this->_getAttrString($this->_attributes) . ' '.
					Utils_TooltipCommon::open_tag_attrs(__('Example value: %s',array('123'.Utils_CurrencyFieldCommon::get_decimal_point().implode('',range(4,3+$this->dec_digits)))), false ).
					' /></div>';

			$str .= $this->_getTabs() .
					'<div style="margin-right:5px; width:40px; position:absolute;top:0px;right:0px;"><select style="width:40px;" name="__'.str_replace(array('[',']'),'',$name).'__currency" id="__'.$id.'__currency">';

			$curs = DB::GetAll('SELECT id, symbol, active FROM utils_currency ORDER BY code');
			foreach ($curs as $v) {
				if ($v['id']!=$this->currency && !$v['active']) continue;
				$str .= '<option value="'.$v['id'].'"';
				if ($v['id']==$this->currency) $str .= ' selected="1"';
				$str .= '>'.$v['symbol'].'</option>';
			}
			$str .= '</select></div>';

			$str .= $this->_getTabs() . '</div>';

			load_js('modules/Utils/CurrencyField/currency.js');
			$curr_format = '-?([0-9]*)\\'.Utils_CurrencyFieldCommon::get_decimal_point().'?[0-9]{0,'.$this->dec_digits.'}';
			eval_js('Event.observe(\''.$id.'\',\'keypress\',Utils_CurrencyField.validate.bindAsEventListener(Utils_CurrencyField,\''.Epesi::escapeJS($curr_format,false).'\'))');
			eval_js('Event.observe(\''.$id.'\',\'blur\',Utils_CurrencyField.validate_blur.bindAsEventListener(Utils_CurrencyField,\''.Epesi::escapeJS($curr_format,false).'\'))');
		}
		return $str;
	} //end func toHtml
Exemplo n.º 11
0
 public static function QFfield_login(&$form, $field, $label, $mode, $default, $desc, $rb = null)
 {
     $label = __('EPESI User');
     if (!Base_AclCommon::i_am_admin()) {
         return;
     }
     if ($mode == 'view') {
         if (!$default) {
             return;
         }
         if (Base_AclCommon::i_am_sa()) {
             Base_ActionBarCommon::add('settings', __('Log as user'), Module::create_href(array('log_as_user' => $default)));
             if (isset($_REQUEST['log_as_user']) && $_REQUEST['log_as_user'] == $default) {
                 Acl::set_user($default, true);
                 //tag who is logged
                 Epesi::redirect();
                 return;
             }
         }
         $form->addElement('static', $field, $label);
         $form->setDefaults(array($field => self::display_login(array('login' => $default), true, array('id' => 'login'))));
         return;
     }
     $ret = DB::Execute('SELECT id, login FROM user_login ORDER BY login');
     $users = array('' => '---', 'new' => '[' . __('Create new user') . ']');
     while ($row = $ret->FetchRow()) {
         $contact_id = Utils_RecordBrowserCommon::get_id('contact', 'login', $row['id']);
         if ($contact_id === false || $contact_id === null || $row['id'] === $default && $mode != 'add') {
             if (Base_AclCommon::i_am_admin() || $row['id'] == Acl::get_user()) {
                 $users[$row['id']] = $row['login'];
             }
         }
     }
     $form->addElement('select', $field, $label, $users, array('id' => 'crm_contacts_select_user'));
     $form->setDefaults(array($field => $default));
     if ($default !== '') {
         $form->freeze($field);
     } else {
         eval_js('new_user_textfield = function(){' . '($("crm_contacts_select_user").value=="new"?"":"none");' . '$("username").up("tr").style.display = $("set_password").up("tr").style.display = $("confirm_password").up("tr").style.display = $("_access__data").up("tr").style.display = ($("crm_contacts_select_user").value==""?"none":"");' . 'if ($("contact_admin")) $("contact_admin").up("tr").style.display = ($("crm_contacts_select_user").value==""?"none":"");' . '}');
         eval_js('new_user_textfield();');
         eval_js('Event.observe("crm_contacts_select_user","change",function(){new_user_textfield();});');
     }
     if ($default) {
         eval_js('$("_login__data").up("tr").style.display = "none";');
     }
 }
Exemplo n.º 12
0
function escapeJS($str, $double = true, $single = true)
{
    return Epesi::escapeJS($str, $double, $single);
}
Exemplo n.º 13
0
 public static function search($search, $categories)
 {
     if (!$categories) {
         return;
     }
     $token_length = self::get_token_length();
     $limit = Base_SearchCommon::get_recordset_limit_records();
     $tabs_priority = DB::GetAssoc('SELECT id,search_priority FROM recordbrowser_table_properties WHERE search_include>0');
     $categories = array_intersect($categories, array_keys($tabs_priority));
     $categories = array_map(create_function('$a', 'return DB::qstr($a);'), $categories);
     $texts = array_filter(preg_split('/[^\\p{L}0-9]/u', mb_strtolower($search)));
     $total_results = array();
     $total_max_score = 0;
     foreach ($texts as $text) {
         //for each word
         $len = mb_strlen($text);
         if ($len < $token_length) {
             continue;
         }
         //if word is less then token lenght - ignore it
         $results = array();
         $max_score = $len - $token_length + 1;
         $total_max_score += $len;
         for ($i = 0; $i <= $len - $token_length; $i++) {
             $word = mb_substr($text, $i, $token_length);
             $ret = DB::Execute('SELECT m.tab_id,m.record_id,m.field_id,m.position FROM recordbrowser_words_index w INNER JOIN recordbrowser_words_map m ON w.id=m.word_id WHERE w.word=%s AND m.tab_id IN (' . implode(',', $categories) . ')', array($word));
             while ($row = $ret->FetchRow()) {
                 $score = 1;
                 for ($k = 1; $k <= $token_length + 1; $k++) {
                     if (isset($results[$row['tab_id']][$row['record_id']][$row['field_id']][$row['position'] - $k])) {
                         $score += $results[$row['tab_id']][$row['record_id']][$row['field_id']][$row['position'] - $k];
                         break;
                     }
                 }
                 $results[$row['tab_id']][$row['record_id']][$row['field_id']][$row['position']] = min($max_score, $score);
             }
         }
         foreach ($results as $tab_id => $records) {
             foreach ($records as $record => $fields) {
                 //get max score for each field... if max score is 50% or more equal save it
                 foreach ($fields as $field => $scores) {
                     $max_score_local = max($scores);
                     if ($max_score_local > $max_score / 2) {
                         $results[$tab_id][$record][$field] = $max_score_local;
                     } else {
                         unset($results[$tab_id][$record][$field]);
                     }
                 }
                 //if some fields was saved
                 if ($results[$tab_id][$record]) {
                     $max = 0;
                     //get max score of all fields where the "word" was found
                     $max_fields = array();
                     //get field names with maximal score
                     foreach ($results[$tab_id][$record] as $field => $score) {
                         if ($max < $score) {
                             $max = $score;
                             $max_fields = array($field);
                         } elseif ($max == $score) {
                             $max_fields[] = $field;
                         }
                     }
                     $max += $token_length - 1;
                     if (!isset($total_results[$tab_id . '#' . $record])) {
                         $total_results[$tab_id . '#' . $record] = array('score' => 0, 'fields' => array(), 'fields_score' => array(), 'priority' => $tabs_priority[$tab_id]);
                     }
                     $total_results[$tab_id . '#' . $record]['score'] += $max;
                     $total_results[$tab_id . '#' . $record]['fields_score'][] = $max;
                     $total_results[$tab_id . '#' . $record]['fields'][] = $max_fields;
                 } else {
                     unset($results[$tab_id][$record]);
                 }
             }
         }
         unset($results);
     }
     if ($total_max_score == 0) {
         Epesi::alert(__('Displaying only partial results - please enter at least one word of 3 or more letters'));
         return;
     }
     //sort with score... if score is the same sort with qty of fields where the "word" was found
     uasort($total_results, create_function('$a,$b', 'return $a["score"]>$b["score"]?-1:($a["score"]<$b["score"]?1:($a["priority"]>$b["priority"]?-1:($a["priority"]<$b["priority"]?1:($a["fields"]>$b["fields"]?-1:1))));'));
     $tabs = DB::GetAssoc('SELECT id,tab FROM recordbrowser_table_properties WHERE search_include>0');
     $ret = array();
     $cols_cache = array();
     $count = 0;
     foreach ($total_results as $rec => $score) {
         list($tab_id, $id) = explode('#', $rec, 2);
         $tab = $tabs[$tab_id];
         $record = self::get_record($tab, $id);
         //get fields names translations
         if (!isset($cols_cache[$tab])) {
             $table_rows = self::init($tab);
             $cols_cache[$tab] = array();
             foreach ($table_rows as $col) {
                 $cols_cache[$tab][$col['pkey']] = array('name' => $col['name'], 'id' => $col['id']);
             }
         }
         //get access
         $has_access = self::get_access($tab, 'view', $record);
         if (!$has_access) {
             continue;
         }
         //no access at all
         //if there are fields that should not be visible, remove them from results list and recalculate score
         foreach ($score['fields'] as $fields_group => $fields) {
             foreach ($fields as $field_pos => $field_id) {
                 if (isset($cols_cache[$tab][$field_id])) {
                     $field = $cols_cache[$tab][$field_id]['id'];
                 } else {
                     $field = '';
                 }
                 if (!isset($has_access[$field]) || !$has_access[$field]) {
                     unset($score['fields'][$fields_group][$field_pos]);
                 }
             }
             if (empty($score['fields'][$fields_group])) {
                 $score['score'] -= $score['fields_score'][$fields_group];
                 unset($score['fields'][$fields_group]);
                 unset($score['fields_score'][$fields_group]);
             }
         }
         if (!$score['fields']) {
             continue;
         }
         $fields = array();
         foreach ($score['fields'] as $fields_group) {
             foreach ($fields_group as $field) {
                 $fields[] = _V($cols_cache[$tab][$field]['name']);
             }
         }
         //create link with default label
         $ret[] = self::create_default_linked_label($tab, $id) . ' <span style="color: red">' . round($score['score'] * 100 / $total_max_score) . '%</span> (' . implode(', ', $fields) . ')';
         $count++;
         if ($count >= $limit) {
             break;
         }
     }
     return $ret;
 }
Exemplo n.º 14
0
    public function view_field($action = 'add', $field = null) {
        if (!$action) $action = 'add';
        if ($this->is_back()) return false;
        if ($this->check_for_jump()) return;
        $data_type = array(
            'autonumber'=>__('Autonumber'),
            'currency'=>__('Currency'),
            'checkbox'=>__('Checkbox'),
            'date'=>__('Date'),
            'time' => __('Time'),
            'timestamp' => __('Timestamp'),
            'integer'=>__('Integer'),
            'float'=>__('Float'),
            'text'=>__('Text'),
            'long text'=>__('Long text'),
			'select'=>__('Select field')
        );
        natcasesort($data_type);
		
		load_js('modules/Utils/RecordBrowser/js/field_admin.js');
        $form = $this->init_module('Libs/QuickForm');

        switch ($action) {
            case 'add': $form->addElement('header', null, __('Add new field'));
                        break;
            case 'edit': $form->addElement('header', null, __('Edit field properties'));
                        break;
        }
        $form->addElement('text', 'field', __('Field'), array('maxlength'=>32));
        $form->registerRule('check_if_column_exists', 'callback', 'check_if_column_exists', $this);
        $this->current_field = $field;
        $form->registerRule('check_if_no_id', 'callback', 'check_if_no_id', $this);
        $form->addRule('field', __('Field required'), 'required');
        $form->addRule('field', __('Field with this name already exists.'), 'check_if_column_exists');
        $form->addRule('field', __('Field length cannot be over 32 characters.'), 'maxlength', 32);
        $form->addRule('field', __('Invalid field name.'), 'regex', '/^[a-zA-Z][a-zA-Z \(\)\%0-9]*$/');
        $form->addRule('field', __('Invalid field name.'), 'check_if_no_id');

        $form->addElement('text', 'caption', __('Caption'), array('maxlength'=>255, 'placeholder' => __('Leave empty to use default label')));

        if ($action=='edit') {
            $row = DB::GetRow('SELECT field, caption, type, visible, required, param, filter, export, tooltip, extra, position FROM '.$this->tab.'_field WHERE field=%s',array($field));
			switch ($row['type']) {
				case 'select':
					$row['select_data_type'] = 'select';
					$row['select_type'] = 'select';
					$row['data_source'] = 'rset';
					$ref = explode(';', $row['param']);
					$refe = explode('::',$ref[0]);
					$row['rset'] = array_filter(explode(',',$refe[0]));
					$row['label_field'] = isset($refe[1]) ? str_replace('|', ',', $refe[1]) : '';
					break;
				case 'multiselect':
					$row['select_data_type'] = 'select';
					$row['select_type'] = 'multiselect';
					$ref = explode(';', $row['param']);
					$refe = explode('::',$ref[0]);
					$tab = $refe[0];
					if ($tab=='__COMMON__') {
						$row['data_source'] = 'commondata';
						$order = isset($refe[2])?$refe[2]:'value';
						$row['order_by'] = ($order=='key'?'key':'value');
						$row['commondata_table'] = $refe[1];
					} else {
						$row['label_field'] = '';
                        if (isset($refe[1]))
                            $row['label_field'] = str_replace('|', ',', $refe[1]);
						$row['data_source'] = 'rset';
						$row['rset'] = array_filter(explode(',',$tab));
					}
					break;
				case 'commondata':
					$row['select_data_type'] = 'select';
					$row['select_type'] = 'select';
					$row['data_source'] = 'commondata';
					$param = Utils_RecordBrowserCommon::decode_commondata_param($row['param']);
					$form->setDefaults(array('order_by'=>$param['order_by_key']?'key':'value', 'commondata_table'=>$param['array_id']));
					break;
                case 'autonumber':
                    $row['select_data_type'] = 'autonumber';
                    Utils_RecordBrowserCommon::decode_autonumber_param($row['param'], $autonumber_prefix, $autonumber_pad_length, $autonumber_pad_mask);
                    $row['autonumber_prefix'] = $autonumber_prefix;
                    $row['autonumber_pad_length'] = $autonumber_pad_length;
                    $row['autonumber_pad_mask'] = $autonumber_pad_mask;
                    break;
				case 'text':
                    $row['select_data_type'] = $row['type'];
					$row['text_length'] = $row['param'];
                    break;
                case 'time':
                case 'timestamp':
                    $row['select_data_type'] = $row['type'];
                    $row['minute_increment'] = $row['param'];
                    break;
				default:
					$row['select_data_type'] = $row['type'];
					if (!isset($data_type[$row['type']]))
						$data_type[$row['type']] = _V(ucfirst($row['type'])); // ****** - field type
			}
			if (!isset($row['rset'])) $row['rset'] = array('contact');
			if (!isset($row['data_source'])) $row['data_source'] = 'commondata';
            $form->setDefaults($row);
            $selected_data = $row['type'];
			$this->admin_field_type = $row['select_data_type'];
			$this->admin_field = $row;
        } else {
            $selected_data = $form->exportValue('select_data_type');
            $form->setDefaults(array('visible'=>1,
                'autonumber_prefix'=>'#',
                'autonumber_pad_length'=>'6',
                'autonumber_pad_mask'=>'0'));
        }
		$this->admin_field_mode = $action;
		$this->admin_field_name = $field;
		
		$form->addElement('select', 'select_data_type', __('Data Type'), $data_type, array('id'=>'select_data_type', 'onchange'=>'RB_hide_form_fields()'));

		$form->addElement('text', 'text_length', __('Maximum Length'), array('id'=>'length'));
        $minute_increment_values = array(1=>1,2=>2,5=>5,10=>10,15=>15,20=>20,30=>30,60=>__('Full hours'));
		$form->addElement('select', 'minute_increment', __('Minutes Interval'), $minute_increment_values, array('id'=>'minute_increment'));

		$form->addElement('select', 'data_source', __('Source of Data'), array('rset'=>__('Recordset'), 'commondata'=>__('CommonData')), array('id'=>'data_source', 'onchange'=>'RB_hide_form_fields()'));
		$form->addElement('select', 'select_type', __('Type'), array('select'=>__('Single value selection'), 'multiselect'=>__('Multiple values selection')), array('id'=>'select_type'));
		$form->addElement('select', 'order_by', __('Order by'), array('key'=>__('Key'), 'value'=>__('Value')), array('id'=>'order_by'));
		$form->addElement('text', 'commondata_table', __('CommonData table'), array('id'=>'commondata_table'));

		$tables = Utils_RecordBrowserCommon::list_installed_recordsets();
		asort($tables);
		$form->addElement('multiselect', 'rset', '<span id="rset_label">'.__('Recordset').'</span>', $tables, array('id'=>'rset'));
		$form->addElement('text', 'label_field', __('Related field(s)'), array('id'=>'label_field'));

		$form->addFormRule(array($this, 'check_field_definitions'));

		$form->addElement('checkbox', 'visible', __('Table view'));
		$form->addElement('checkbox', 'tooltip', __('Tooltip view'));
		$form->addElement('checkbox', 'required', __('Required'), null, array('id'=>'required'));
		$form->addElement('checkbox', 'filter', __('Filter enabled'), null, array('id' => 'filter'));
		$form->addElement('checkbox', 'export', __('Export'));
        
        $form->addElement('text', 'autonumber_prefix', __('Prefix string'), array('id' => 'autonumber_prefix'));
        $form->addRule('autonumber_prefix', __('Double underscore is not allowed'), 'callback', array('Utils_RecordBrowser', 'qf_rule_without_double_underscore'));
        $form->addElement('text', 'autonumber_pad_length', __('Pad length'), array('id' => 'autonumber_pad_length'));
        $form->addRule('autonumber_pad_length', __('Only integer numbers are allowed.'), 'regex', '/^[0-9]*$/');
        $form->addElement('text', 'autonumber_pad_mask', __('Pad character'), array('id' => 'autonumber_pad_mask'));
        $form->addRule('autonumber_pad_mask', __('Double underscore is not allowed'), 'callback', array('Utils_RecordBrowser', 'qf_rule_without_double_underscore'));

		$form->addElement('checkbox', 'advanced', __('Edit advanced properties'), null, array('onchange'=>'RB_advanced_settings()', 'id'=>'advanced'));
		$form->addElement('text', 'display_callback', __('Value display function'), array('maxlength'=>255, 'style'=>'width:300px', 'id'=>'display_callback'));
		$form->addElement('text', 'QFfield_callback', __('Field generator function'), array('maxlength'=>255, 'style'=>'width:300px', 'id'=>'QFfield_callback'));
		
        if ($action=='edit') {
			$form->freeze('field');
			$form->freeze('select_data_type');
			$form->freeze('data_source');
			$form->freeze('rset');
		}
		
		if ($action=='edit') {
			$display_callbacback = DB::GetOne('SELECT callback FROM '.$this->tab.'_callback WHERE freezed=1 AND field=%s', array($field));
			$QFfield_callbacback = DB::GetOne('SELECT callback FROM '.$this->tab.'_callback WHERE freezed=0 AND field=%s', array($field));
			$form->setDefaults(array('display_callback'=>$display_callbacback));
			$form->setDefaults(array('QFfield_callback'=>$QFfield_callbacback));
		}

        if ($form->validate()) {
            $data = $form->exportValues();
            $data['caption'] = trim($data['caption']);
            $data['field'] = trim($data['field']);
			$type = DB::GetOne('SELECT type FROM '.$this->tab.'_field WHERE field=%s', array($field));
			if (!isset($data['select_data_type'])) $data['select_data_type'] = $type;
            if ($action=='add')
                $field = $data['field'];
            $id = preg_replace('/[^a-z0-9]/','_',strtolower($field));
            $new_id = preg_replace('/[^a-z0-9]/','_',strtolower($data['field']));
            if (preg_match('/^[a-z0-9_]*$/',$id)==0) trigger_error('Invalid column name: '.$field);
            if (preg_match('/^[a-z0-9_]*$/',$new_id)==0) trigger_error('Invalid new column name: '.$data['field']);
			$param = '';
			switch ($data['select_data_type']) {
                case 'autonumber':
                    $data['required'] = false;
                    $data['filter'] = false;
                    $param = Utils_RecordBrowserCommon::encode_autonumber_param(
                            $data['autonumber_prefix'],
                            $data['autonumber_pad_length'],
                            $data['autonumber_pad_mask']);
                    // delete field and add again later to generate values
                    if ($action != 'add') {
                        Utils_RecordBrowserCommon::delete_record_field($this->tab, $field);
                        $action = 'add';
                        $field = $data['field'];
                    }
                    break;
				case 'checkbox': 
							$data['required'] = false;
							break;
				case 'text': if ($action=='add') $param = $data['text_length'];
							else {
								if ($data['text_length']<$row['param']) trigger_error('Invalid field length', E_USER_ERROR);
								$param = $data['text_length'];
								if ($data['text_length']!=$row['param']) {
									if(DB::is_postgresql())
										DB::Execute('ALTER TABLE '.$this->tab.'_data_1 ALTER COLUMN f_'.$id.' TYPE VARCHAR('.$param.')');
									else
										DB::Execute('ALTER TABLE '.$this->tab.'_data_1 MODIFY f_'.$id.' VARCHAR('.$param.')');
								}
							}
							break;
				case 'select':
							if ($data['data_source']=='commondata') {
								if ($data['select_type']=='select') {
									$param = Utils_RecordBrowserCommon::encode_commondata_param(array('order_by_key'=>$data['order_by']=='key', 'array_id'=>$data['commondata_table']));
									$data['select_data_type'] = 'commondata';
								} else {
									$param = '__COMMON__::'.$data['commondata_table'].'::'.$data['order_by'];
									$data['select_data_type'] = 'multiselect';
								}
							} else {
								$data['select_data_type'] = $data['select_type'];
								if (!isset($row) || !isset($row['param'])) $row['param'] = ';::';
								$props = explode(';', $row['param']);
                                $change_param = false;
								if($data['rset']) {
								    $fs = explode(',', $data['label_field']);
								    if($data['label_field']) foreach($data['rset'] as $rset) {
        								$ret = $this->detranslate_field_names($rset, $fs);
	        							if (!empty($ret)) trigger_error('Invalid fields: '.implode(',',$fs));
	        						    }
	        						    $data['rset'] = implode(',',$data['rset']);
	        						    $data['label_field'] = implode('|',$fs);
                                    $change_param = true;
								} else if ($action == 'add') {
								    $data['rset'] = '__RECORDSETS__';
								    $data['label_field'] = '';
                                    $change_param = true;
								}
                                if ($change_param) {
                                    $props[0] = $data['rset'].'::'.$data['label_field'];
                                    $param = implode(';', $props);
                                } else {
                                    $param = $row['param'];
                                }
							}
							if (isset($row) && isset($row['type']) && $row['type']=='multiselect' && $data['select_type']=='select') {
								$ret = DB::Execute('SELECT id, f_'.$id.' AS v FROM '.$this->tab.'_data_1 WHERE f_'.$id.' IS NOT NULL');
								while ($rr = $ret->FetchRow()) {
									$v = Utils_RecordBrowserCommon::decode_multi($rr['v']);
									$v = array_pop($v);
									DB::Execute('UPDATE '.$this->tab.'_data_1 SET f_'.$id.'=%s WHERE id=%d', array($v, $rr['id']));
								}
							}
							if (isset($row) && isset($row['type'])  && $row['type']!='multiselect' && $data['select_type']=='multiselect') {
								if(DB::is_postgresql())
									DB::Execute('ALTER TABLE '.$this->tab.'_data_1 ALTER COLUMN f_'.$id.' TYPE TEXT');
								else
									DB::Execute('ALTER TABLE '.$this->tab.'_data_1 MODIFY f_'.$id.' TEXT');
								$ret = DB::Execute('SELECT id, f_'.$id.' AS v FROM '.$this->tab.'_data_1 WHERE f_'.$id.' IS NOT NULL');
								while ($rr = $ret->FetchRow()) {
									$v = Utils_RecordBrowserCommon::encode_multi($rr['v']);
									DB::Execute('UPDATE '.$this->tab.'_data_1 SET f_'.$id.'=%s WHERE id=%d', array($v, $rr['id']));
								}
							}
							break;
                case 'time':
                case 'timestamp':
                    $param = $data['minute_increment'];
                    break;
				default:	if (isset($row) && isset($row['param']))
								$param = $row['param'];
							break;
			}
            if ($action=='add') {
                $id = $new_id;
                if (in_array($data['select_data_type'], array('time','timestamp','currency','integer')))
                    $style = $data['select_data_type'];
                else
                    $style = '';
                $new_field_data = array('name' => $data['field'], 'type' => $data['select_data_type'], 'param' => $param, 'style' => $style);
                if (isset($this->admin_field['position']) && $this->admin_field['position']) {
                    $new_field_data['position'] = (int) $this->admin_field['position'];
                }
                Utils_RecordBrowserCommon::new_record_field($this->tab, $new_field_data);
            }
            if(!isset($data['visible']) || $data['visible'] == '') $data['visible'] = 0;
            if(!isset($data['required']) || $data['required'] == '') $data['required'] = 0;
            if(!isset($data['filter']) || $data['filter'] == '') $data['filter'] = 0;
            if(!isset($data['export']) || $data['export'] == '') $data['export'] = 0;
            if(!isset($data['tooltip']) || $data['tooltip'] == '') $data['tooltip'] = 0;

            foreach($data as $key=>$val)
                if (is_string($val)) $data[$key] = htmlspecialchars($val);

/*            DB::StartTrans();
            if ($id!=$new_id) {
                Utils_RecordBrowserCommon::check_table_name($this->tab);
                if(DB::is_postgresql())
                    DB::Execute('ALTER TABLE '.$this->tab.'_data_1 RENAME COLUMN f_'.$id.' TO f_'.$new_id);
                else {
                    $old_param = DB::GetOne('SELECT param FROM '.$this->tab.'_field WHERE field=%s', array($field));
                    DB::RenameColumn($this->tab.'_data_1', 'f_'.$id, 'f_'.$new_id, Utils_RecordBrowserCommon::actual_db_type($type, $old_param));
                }
            }*/
            DB::Execute('UPDATE '.$this->tab.'_field SET caption=%s, param=%s, type=%s, field=%s, visible=%d, required=%d, filter=%d, export=%d, tooltip=%d WHERE field=%s',
                        array($data['caption'], $param, $data['select_data_type'], $data['field'], $data['visible'], $data['required'], $data['filter'], $data['export'], $data['tooltip'], $field));
/*            DB::Execute('UPDATE '.$this->tab.'_edit_history_data SET field=%s WHERE field=%s',
                        array($new_id, $id));
            DB::CompleteTrans();*/
			
			DB::Execute('DELETE FROM '.$this->tab.'_callback WHERE freezed=1 AND field=%s', array($field));
			if ($data['display_callback'])
				DB::Execute('INSERT INTO '.$this->tab.'_callback (callback,freezed,field) VALUES (%s,1,%s)', array($data['display_callback'], $data['field']));
				
			DB::Execute('DELETE FROM '.$this->tab.'_callback WHERE freezed=0 AND field=%s', array($field));
			if ($data['QFfield_callback'])
				DB::Execute('INSERT INTO '.$this->tab.'_callback (callback,freezed,field) VALUES (%s,0,%s)', array($data['QFfield_callback'], $data['field']));
			
            $this->init(true, true);
            return false;
        }
        $form->display_as_column();

		eval_js('RB_hide_form_fields();');
		eval_js('RB_advanced_confirmation = "'.Epesi::escapeJS(__('Changing these settings may often cause system unstability. Are you sure you want to see advanced settings?')).'";');
		eval_js('RB_advanced_settings();');

		Base_ActionBarCommon::add('save', __('Save'), $form->get_submit_form_href());
		Base_ActionBarCommon::add('back', __('Cancel'), $this->create_back_href());
		
        return true;
    }
Exemplo n.º 15
0
<?php

/**
 * @author Arkadiusz Bisaga <*****@*****.**>
 * @copyright Copyright &copy; 2008, Telaxus LLC
 * @license MIT
 * @version 1.0
 * @package epesi-utils
 * @subpackage recordbrowser
 */
if (!isset($_POST['id']) || !isset($_POST['state']) || !isset($_POST['element']) || !isset($_POST['tab']) || !isset($_POST['cid'])) {
    die('Invalid request: ' . print_r($_POST, true));
}
define('JS_OUTPUT', 1);
define('CID', $_POST['cid']);
define('READ_ONLY_SESSION', true);
require_once '../../../include.php';
ModuleManager::load_modules();
$id = json_decode($_POST['id']);
$tab = json_decode($_POST['tab']);
$state = json_decode($_POST['state']);
$element = json_decode($_POST['element']);
if (!Acl::is_user()) {
    die('alert("Unauthorized access");');
}
Utils_RecordBrowserCommon::set_favs($tab, $id, $state);
print '$("' . $element . '").innerHTML="' . Epesi::escapeJS(Utils_RecordBrowserCommon::get_fav_button_tags($tab, $id, $state)) . '";';
Exemplo n.º 16
0
 public function get_submit_form_js_by_name($form_name, $submited, $indicator, $queue = false)
 {
     if (!is_array($form_name)) {
         $form_name = array($form_name);
     }
     if (!isset($indicator)) {
         $indicator = __('Processing...');
     }
     $fast = "+'&" . http_build_query(array('__action_module__' => $this->get_parent_path())) . "'";
     $pre = '';
     $chj = '';
     $post = '';
     foreach ($form_name as $f) {
         if ($submited) {
             $pre .= 'Epesi.confirmLeave.freeze(\'' . addslashes($f) . '\');';
             $pre .= "\$('" . addslashes($f) . "').submited.value=1;";
         }
         $pre .= "Event.fire(document,'e:submit_form','" . $f . "');";
         $pre .= str_replace('this', "\$('" . addslashes($f) . "')", Libs_QuickFormCommon::get_on_submit_actions());
         if ($chj) {
             $chj .= "+'&'+";
         }
         $chj .= "\$('" . addslashes($f) . "').serialize()";
         if ($submited) {
             $post .= "\$('" . addslashes($f) . "').submited.value=0;";
         }
     }
     $s = $pre . "_chj(" . $chj . $fast . ",'" . Epesi::escapeJS($indicator) . "','" . ($queue ? 'queue' : '') . "');" . $post;
     return $s;
 }
Exemplo n.º 17
0
 public static function post_install_refresh_by_ajax()
 {
     $show_processing = "Epesi.procOn++;Epesi.updateIndicatorText('" . Epesi::escapeJS(__('Running post download procedures')) . "');Epesi.updateIndicator();";
     $success_text = Epesi::escapeJS(__("Success. Restart EPESI to ensure proper operation."));
     $failure_text = Epesi::escapeJS(__("Patch apply error. See patches log for more information (EPESI_DIR/data/logs/patches.log)"));
     $ajax_req = "new Ajax.Request('modules/Base/EpesiStore/runpatches.php'," . "{ method: 'post', " . "onComplete: function(t) {Epesi.procOn--;" . "if (t.responseText == '1') statusbar_message('<div class=\"message normal\">" . $success_text . "</div>');" . "else if (t.responseText == '0') alert('{$failure_text}');" . "else alert('Error: '+t.responseText);" . "Epesi.updateIndicator();" . "}});";
     eval_js($show_processing . $ajax_req);
 }
Exemplo n.º 18
0
	die('alert(\'Invalid request\');');


define('JS_OUTPUT',1);
define('EPESI_PROCESS',1);
require_once('include.php');

if (epesi_requires_update()) {
    die ('window.location = "index.php";');
}

if(!isset($_SESSION['num_of_clients'])) {
	Epesi::alert('Session expired, restarting epesi');
	Epesi::redirect();
	Epesi::send_output();
	define('SESSION_EXPIRED',1);
	//session_commit();
	//DBSession::destroy(session_id());
} else {
	Epesi::process($_POST['url'],isset($_POST['history'])?$_POST['history']:false);
}
$content = ob_get_contents();
ob_end_clean();

require_once('libs/minify/HTTP/Encoder.php');
$he = new HTTP_Encoder(array('content' => $content));
if (MINIFY_ENCODE)
	$he->encode();
$he->sendAll();
?>
Exemplo n.º 19
0
 /**
  * Call method of the module passed as first parameter,
  * which name is passed as third parameter.
  * You can pass additional arguments.
  * Attention: do not pass the result of this function by one module to another module.
  *
  * @param module $m child module
  * @param mixed $args arguments
  * @param string $function_name function to call (get output from), if user has enought privileges.
  * @return mixed if access denied returns false, else string
  */
 public final function get_html_of_module(&$m, $args = null, $function_name = null)
 {
     $this_path = $this->get_path();
     if (!$m) {
         trigger_error('Arument 0 for display_module is null.', E_USER_ERROR);
     }
     if ($this_path != $m->get_parent_path()) {
         return false;
     }
     if (!isset($function_name)) {
         $function_name = 'body';
     }
     if (!method_exists($m, $function_name)) {
         trigger_error('Invalid method name (' . get_class($m) . '::' . $function_name . ') given as argument 2 for display_module.', E_USER_ERROR);
     }
     if ($m->displayed()) {
         trigger_error('You can\'t display the same module twice, path:' . $m->get_path() . '.', E_USER_ERROR);
     }
     if (!$m->check_access($function_name)) {
         return false;
     }
     //we cannot trigger error here, couse logout doesn't work
     //trigger_error('Method given as argument 2 for display_module inaccessible.<br>$'.$this->get_type().'->display_module(\''.$m->get_type().'\','.$args.',\''.$function_name.'\');',E_USER_ERROR);
     $s =& $m->get_module_variable('__shared_unique_vars__', array());
     foreach ($s as $k => $v) {
         $_REQUEST[$m->create_unique_key($k)] =& $_REQUEST[$v];
     }
     if (MODULE_TIMES) {
         $time = microtime(true);
     }
     //define key in array so it is before its children
     $path = $m->get_path();
     if ($this->is_inline_display()) {
         $m->set_inline_display();
     }
     if (!$m->is_inline_display()) {
         Epesi::$content[$path]['span'] = $this_path . '|' . $this->children_count_display . 'content';
         $this->children_count_display++;
     }
     Epesi::$content[$path]['module'] =& $m;
     if (!REDUCING_TRANSFER || (!$m->is_fast_process() || isset($_REQUEST['__action_module__']) && strpos($_REQUEST['__action_module__'], $path) === 0 || !isset($_SESSION['client']['__module_content__'][$path]))) {
         if ($args === null) {
             $args = array();
         } elseif (!is_array($args)) {
             $args = array($args);
         }
         ob_start();
         $callbacks = array_reverse($m->get_module_variable('__callbacks__', array()), true);
         $skip_display = false;
         foreach ($callbacks as $name => $c) {
             $ret = $m->get_module_variable_or_unique_href_variable($name);
             if ($ret == '1') {
                 $func = $c['func'];
                 if (is_array($func)) {
                     if ($func[0] === null) {
                         $func[0] =& $m;
                     }
                     if (!method_exists($func[0], $func[1])) {
                         trigger_error('Invalid method passed as callback: ' . (is_string($func[0]) ? $func[0] : $func[0]->get_type()) . '::' . $func[1], E_USER_ERROR);
                     }
                 }
                 $r = call_user_func_array($func, $c['args']);
                 if ($r) {
                     $skip_display = true;
                     break;
                 } else {
                     $m->unset_module_variable($name);
                 }
             }
         }
         if (!$skip_display) {
             $m->display_func = true;
             call_user_func_array(array($m, $function_name), $args);
             $m->display_func = false;
         }
         if (STRIP_OUTPUT) {
             require_once 'libs/minify/Minify/HTML.php';
             Epesi::$content[$path]['value'] = Minify_HTML::minify(ob_get_contents());
         } else {
             Epesi::$content[$path]['value'] = ob_get_contents();
         }
         ob_end_clean();
         Epesi::$content[$path]['js'] = $m->get_jses();
     } else {
         Epesi::$content[$path]['value'] = $_SESSION['client']['__module_content__'][$path]['value'];
         Epesi::$content[$path]['js'] = $_SESSION['client']['__module_content__'][$path]['js'];
         if (DEBUG) {
             Epesi::debug('Fast process of ' . $path);
         }
     }
     if (MODULE_TIMES) {
         Epesi::$content[$path]['time'] = microtime(true) - $time;
     }
     $m->mark_displayed();
     if ($m->is_inline_display()) {
         $ret = Epesi::$content[$path]['value'];
         Epesi::$content[$path]['value'] = '';
         return $ret;
     }
     return '<span id="' . Epesi::$content[$path]['span'] . '"></span>';
 }
Exemplo n.º 20
0
 public function send($file)
 {
     if ($this->is_back()) {
         return $this->go_back($file);
     }
     $qf = $this->init_module(Libs_QuickForm::module_name(), null, 'send_fax');
     list($providers, $providers_arr) = self::get_providers($file);
     if (empty($providers)) {
         $this->go_back($file);
         Epesi::alert(__('No fax providers installed or configured for this type of file.'));
         return;
     }
     $qf->addElement('header', null, __('Faxing file: %s', array(basename($file))));
     $qf->addElement('select', 'provider', __('Provider'), $providers);
     $qf->addElement('header', null, __('Contact'));
     $fav_contact = CRM_ContactsCommon::get_contacts(array(':Fav' => true, '!fax' => ''));
     $fav_contact2 = array();
     foreach ($fav_contact as $v) {
         $fav_contact2[$v['id']] = CRM_ContactsCommon::contact_format_default($v, true);
     }
     $rb_contact = $this->init_module(Utils_RecordBrowser_RecordPicker::module_name());
     $this->display_module($rb_contact, array('contact', 'dest_contact', array('CRM_FaxCommon', 'rpicker_contact_format'), array('!fax' => ''), array('fax' => true)));
     $qf->addElement('multiselect', 'dest_contact', '', $fav_contact2);
     $qf->addElement('static', null, $rb_contact->create_open_link('Add contact'));
     $qf->addElement('header', null, __('Company'));
     $fav_company = CRM_ContactsCommon::get_companies(array(':Fav' => true, '!fax' => ''), array('id', 'company_name'));
     $fav_company2 = array();
     foreach ($fav_company as $v) {
         $fav_company2[$v['id']] = $v['company_name'];
     }
     $rb_company = $this->init_module(Utils_RecordBrowser_RecordPicker::module_name());
     $this->display_module($rb_company, array('company', 'dest_company', array('CRM_FaxCommon', 'rpicker_company_format'), array('!fax' => ''), array('fax' => true)));
     $qf->addElement('multiselect', 'dest_company', '', $fav_company2);
     $qf->addElement('static', null, $rb_company->create_open_link('Add company'));
     $qf->addElement('header', null, __('Other'));
     $qf->addElement('text', 'dest_other', __('Other fax numbers (comma separated)'));
     $qf->addFormRule(array($this, 'check_numbers'));
     if ($qf->validate()) {
         $data = $qf->exportValues();
         if (!isset($providers_arr[$data['provider']]['send_func'])) {
             Epesi::alert(__('Invalid fax provider.'));
         } else {
             $fax_func = array($data['provider'] . 'Common', $providers_arr[$data['provider']]['send_func']);
             $numbers = array();
             $contacts = Utils_RecordBrowserCommon::get_records('contact', array('id' => $data['dest_contact']), array('fax'));
             foreach ($contacts as $row) {
                 $numbers[] = $row['fax'];
             }
             $companies = Utils_RecordBrowserCommon::get_records('company', array('id' => $data['dest_company']), array('fax'));
             foreach ($companies as $row) {
                 $numbers[] = $row['fax'];
             }
             $numbers += explode(',', $data['dest_other']);
             $ret = call_user_func($fax_func, $file, $numbers);
             if ($ret) {
                 return $this->go_back($file);
             }
         }
     }
     $qf->display();
     Base_ActionBarCommon::add('send', __('Send'), $qf->get_submit_form_href());
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
 }
Exemplo n.º 21
0
        }
    }
}
$js .= '$("grid_selected_frames").value="' . implode(';', $selected_frames) . '";';
$timeframe_string = '<table class="time_frames">';
if (isset($_SESSION['client']['utils_planner']['date'])) {
    $day = $_SESSION['client']['utils_planner']['date'];
} else {
    $day = Utils_PopupCalendarCommon::get_first_day_of_week();
}
$count = 0;
do {
    if (isset($timeframe[$day])) {
        foreach ($timeframe[$day] as $v) {
            $timeframe_string .= $v;
        }
    }
    if (isset($_SESSION['client']['utils_planner']['date'])) {
        $day = strtotime('+1 day', $day);
    } else {
        $day++;
        if ($day == 7) {
            $day = 0;
        }
    }
    $count++;
} while ($count < 7);
$timeframe_string .= '</table>';
$js .= '$("Utils_Planner__time_frames").innerHTML="' . Epesi::escapeJS($timeframe_string) . '";';
$js .= Utils_PlannerCommon::timeframe_changed($selected_frames);
print $js;
Exemplo n.º 22
0
 /**
  * For internal use only.
  */
 public function browse($name = '', $root = true)
 {
     if ($this->is_back()) {
         return false;
     }
     if (isset($_REQUEST['node_position'])) {
         list($node_id, $position) = $_REQUEST['node_position'];
         Utils_CommonDataCommon::change_node_position($node_id, $position);
     }
     $gb = $this->init_module(Utils_GenericBrowser::module_name(), null, 'browse' . md5($name));
     $gb->set_table_columns(array(array('name' => __('Position'), 'width' => 5, 'order' => 'position'), array('name' => __('Key'), 'width' => 20, 'order' => 'akey', 'search' => 1, 'quickjump' => 'akey'), array('name' => __('Value'), 'width' => 20, 'order' => 'value', 'search' => 1)));
     print '<h2>' . $name . '</h2><br>';
     $ret = Utils_CommonDataCommon::get_translated_array($name, true, true);
     foreach ($ret as $k => $v) {
         $gb_row = $gb->get_new_row();
         $gb_row->add_data($v['position'], $k, $v['value']);
         // ****** CommonData value translation
         $gb_row->add_action($this->create_callback_href(array($this, 'browse'), array($name . '/' . $k, false)), 'View');
         if (!$v['readonly']) {
             $gb_row->add_action($this->create_callback_href(array($this, 'edit'), array($name, $k)), 'Edit');
             $gb_row->add_action($this->create_confirm_callback_href(__('Delete array') . ' \'' . Epesi::escapeJS($name . '/' . $k, false) . '\'?', array('Utils_CommonData', 'remove_array'), array($name . '/' . $k)), 'Delete');
         }
         $node_id = $v['id'];
         $gb_row->add_action('class="move-handle"', 'Move', __('Drag to change node order'), 'move-up-down');
         $gb_row->set_attrs("node=\"{$node_id}\" class=\"sortable\"");
     }
     $gb->set_default_order(array(__('Position') => 'ASC'));
     //$this->display_module($gb);
     $this->display_module($gb, array(true), 'automatic_display');
     // sorting
     load_js($this->get_module_dir() . 'sort_nodes.js');
     $table_md5 = md5($gb->get_path());
     eval_js("utils_commondata_sort_nodes_init(\"{$table_md5}\")");
     Base_ActionBarCommon::add('settings', __('Reset Order By Key'), $this->create_callback_href(array('Utils_CommonDataCommon', 'reset_array_positions'), $name));
     Base_ActionBarCommon::add('add', __('Add array'), $this->create_callback_href(array($this, 'edit'), $name));
     if (!$root) {
         Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     }
     return true;
 }
Exemplo n.º 23
0
	public function month() {
		$theme = $this->pack_module('Base/Theme');
		Base_ThemeCommon::load_css('Utils_Calendar', 'common');

		$theme->assign('trash_label', __('Drag and drop to delete'));
		$theme->assign('nextyear_href', $this->create_unique_href(array('date'=>(date('Y',$this->date)+1).date('-m-d',$this->date))));
		$theme->assign('nextyear_label',__('Next year'));
		$theme->assign('nextmonth_href', $this->create_unique_href(array('date'=>date('Y-m-d',$this->date+86400*date('t',$this->date)))));
		$theme->assign('nextmonth_label',__('Next month'));
		$theme->assign('today_href', $this->create_unique_href(array('date'=>date('Y-m-d'))));
		$theme->assign('today_label', __('Today'));
		$theme->assign('prevmonth_href', $this->create_unique_href(array('date'=>date('Y-m-d',$this->date-86400*date('t',$this->date-86400*(date('d', $this->date)+1))))));
		$theme->assign('prevmonth_label', __('Previous month'));
		$theme->assign('prevyear_href', $this->create_unique_href(array('date'=>(date('Y',$this->date)-1).date('-m-d',$this->date))));
		$theme->assign('prevyear_label', __('Previous year'));
		$theme->assign('info', __('Double&nbsp;click&nbsp;on&nbsp;cell&nbsp;to&nbsp;add&nbsp;event'));

		if ($this->isset_unique_href_variable('date'))
			$this->set_date($this->get_unique_href_variable('date'));

		$link_text = $this->create_unique_href_js(array('date'=>'__YEAR__-__MONTH__-__DAY__'));
		$theme->assign('popup_calendar', Utils_PopupCalendarCommon::show('week_selector', $link_text,'month'));

		$month = $this->month_array($this->date);
		$dnd = array();
		foreach($month as & $week) {
			foreach($week['days'] as & $cday) {
				$cday['id'] = 'UCcell_'.$cday['time'];
				$dnd[] = $cday['time'];
			}
		}

		$day_headers = array();
		$day = strtotime('Sun');
		$day = strtotime('+'.Utils_PopupCalendarCommon::get_first_day_of_week().' days', $day);
		for ($i=0; $i<7; $i++) {
			$day_headers[] = array('class'=>(date('N',$day)>=6?'weekend_day_header':'day_header'), 'label'=>__date('D', $day));
			$day = strtotime('+1 day', $day);
		}

		$theme->assign('month_view_label', __('Month calendar'));

		$theme->assign('day_headers', $day_headers);
		$theme->assign('month', $month);
		$theme->assign('month_label', __date('F', $this->date));
		$theme->assign('year_label', date('Y', $this->date));
		$theme->assign('year_link', $this->create_unique_href(array('time'=>$this->date, 'tab'=>'Year','action'=>'switch')));
		$theme->assign('trash_id','UCtrash');

		$navigation_bar_additions = '';
		if (is_callable(array($this->event_module, 'get_navigation_bar_additions'))) {
			$event_module_instance = $this->init_module($this->event_module);
			$navigation_bar_additions = call_user_func(array($event_module_instance,'get_navigation_bar_additions'), '', '');
		}
		$theme->assign('navigation_bar_additions', $navigation_bar_additions);

		$theme->display('month');


		//data
		$start_t = date('Y-m-d',$month[0]['days'][0]['time']);
		//$start_t = Base_RegionalSettingsCommon::reg2time($start_t);
		$end_t = date('Y-m-d',$month[count($month)-1]['days'][6]['time']+86400);
		//$end_t = Base_RegionalSettingsCommon::reg2time($end_t);
		$ret = $this->get_events($start_t,$end_t);
		$this->displayed_events = array('start'=>$start_t, 'end'=>$end_t,'events'=>$ret);
		$this->js('Utils_Calendar.page_type=\'month\'');
		$ev_out = 'function() {';
		foreach($ret as $ev) {
			$this->print_event($ev);
			if(!isset($ev['timeless']) || !$ev['timeless'])
				$ev_start = strtotime(Base_RegionalSettingsCommon::time2reg($ev['start'],true,true,true,false));
			else
				$ev_start = strtotime($ev['timeless']);
			$ev_start = Base_RegionalSettingsCommon::reg2time(date('Y-m-d',$ev_start).' 00:00:00');
			$dest_id = 'UCcell_'.$ev_start;
			$ev_out .= 'Utils_Calendar.add_event(\''.Epesi::escapeJS($dest_id,false).'\', \''.$ev['id'].'\', '.((!isset($ev['draggable']) || $ev['draggable']==true)?1:0).', 1);';
		}
		$ev_out.='}';
		$this->js('Utils_Calendar.add_events_f = '.$ev_out);
		$this->js('Utils_Calendar.add_events("Utils%2FCalendar%2Fmonth.css")');
		if ($this->custom_new_event_href_js!==null)
			$jshref = call_user_func($this->custom_new_event_href_js, '__TIME__', '__TIMELESS__');
		else
			$jshref = $this->create_unique_href_js(array('action'=>'add','time'=>'__TIME__','timeless'=>'__TIMELESS__'));
		eval_js('Utils_Calendar.activate_dnd(\''.Epesi::escapeJS(json_encode($dnd),false).'\','.
				'\''.Epesi::escapeJS($jshref,false).'\','.
				'\''.Epesi::escapeJS($this->get_path(),false).'\','.
				'\''.CID.'\')');
	}
Exemplo n.º 24
0
 public function week()
 {
     $theme = $this->pack_module(Base_Theme::module_name());
     Base_ThemeCommon::load_css('Utils_CalendarBusyReport', 'common');
     $theme->assign('next7_href', $this->create_unique_href(array('date' => date('Y-m-d', $this->date + 604800))));
     $theme->assign('next7_label', __('Next week'));
     $theme->assign('next_href', $this->create_unique_href(array('shift_week_day' => 1)));
     $theme->assign('next_label', __('Next day'));
     $theme->assign('today_href', $this->create_unique_href(array('date' => date('Y-m-d'))));
     $theme->assign('today_label', __('Today'));
     $theme->assign('prev_href', $this->create_unique_href(array('shift_week_day' => 0)));
     $theme->assign('prev_label', __('Previous day'));
     $theme->assign('prev7_href', $this->create_unique_href(array('date' => date('Y-m-d', $this->date - 604800))));
     $theme->assign('prev7_label', __('Previous week'));
     $link_text = $this->create_unique_href_js(array('week_date' => '__YEAR__-__MONTH__-__DAY__'));
     $theme->assign('popup_calendar', Utils_PopupCalendarCommon::show('week_selector', $link_text, 'day', $this->settings['first_day_of_week']));
     $week_shift = $this->get_module_variable('week_shift', 0);
     $first_day_of_displayed_week = date('w', $this->date) - $this->settings['first_day_of_week'];
     if ($first_day_of_displayed_week < 0) {
         $first_day_of_displayed_week += 7;
     }
     $diff = $week_shift - $first_day_of_displayed_week;
     $dis_week_from = strtotime(($diff < 0 ? $diff : '+' . $diff) . ' days', $this->date);
     //headers
     $day_headers = array();
     $today = Base_RegionalSettingsCommon::time2reg(null, false, true, true, false);
     if (date('m', $dis_week_from) != date('m', $dis_week_from + 518400)) {
         $second_span_width = date('d', $dis_week_from + 518400);
         $header_month = array('first_span' => array('colspan' => 7 - $second_span_width, 'month' => __date('M', $dis_week_from), 'month_link' => $this->create_unique_href(array('action' => 'switch', 'time' => $dis_week_from, 'tab' => 'Month')), 'year' => date('Y', $dis_week_from), 'year_link' => $this->create_unique_href(array('action' => 'switch', 'time' => $dis_week_from, 'tab' => 'Year'))), 'second_span' => array('colspan' => $second_span_width, 'month' => __date('M', $dis_week_from + 518400), 'month_link' => $this->create_unique_href(array('action' => 'switch', 'time' => $dis_week_from + 518400, 'tab' => 'Month')), 'year' => date('Y', $dis_week_from + 518400), 'year_link' => $this->create_unique_href(array('action' => 'switch', 'time' => $dis_week_from + 518400, 'tab' => 'Year'))));
     } else {
         $header_month = array('first_span' => array('colspan' => 7, 'month' => __date('M', $dis_week_from), 'month_link' => $this->create_unique_href(array('action' => 'switch', 'time' => $dis_week_from, 'tab' => 'Month')), 'year' => date('Y', $dis_week_from), 'year_link' => $this->create_unique_href(array('action' => 'switch', 'time' => $dis_week_from, 'tab' => 'Year'))));
     }
     for ($i = 0; $i < 7; $i++) {
         $that_day = strtotime(date('Y-m-d', strtotime(date('Y-m-d 12:00:00', $dis_week_from)) + 3600 * 24 * $i) . ' ' . date('H:i:s', $dis_week_from));
         $day_headers[] = array('date' => date('d', $that_day) . ' ' . __date('D', $that_day), 'style' => (date('Y-m-d', $that_day) == $today ? 'today' : 'other') . (date('N', $that_day) >= 6 ? '_weekend' : ''), 'link' => $this->create_unique_href(array('action' => 'switch', 'time' => $that_day, 'tab' => 'Day')));
     }
     $theme->assign('header_month', $header_month);
     $theme->assign('day_headers', $day_headers);
     $theme->assign('head_col_width', $this->settings['head_col_width']);
     $report = array();
     //timeline and ids
     $time_ids = array();
     $timeline = array();
     for ($i = 0; $i < 7; $i++) {
         $time_ids[$i] = array();
         $today_t_timeless = strtotime(date('Y-m-d', strtotime(date('Y-m-d 12:00:00', $dis_week_from)) + 3600 * 24 * $i) . ' ' . date('H:i:s', $dis_week_from));
         $today_t = Base_RegionalSettingsCommon::reg2time(date('Y-m-d', $today_t_timeless));
         $today_date = date('Y-m-d', $today_t_timeless);
         $timeline[$today_date] = $this->get_timeline($today_date);
         $prev = null;
         foreach ($timeline[$today_date] as &$v) {
             if ($v['time'] === false) {
                 $time_ids[$i][] = false;
             } elseif (is_string($v['time'])) {
                 $ii = $today_t_timeless . '_' . $v['time'];
                 $time_ids[$i][] = $ii;
                 $report[$ii] = array();
                 //					eval_js('$("UCcell_'.$ii.'").innerHTML="'.$ii.'";'); // *DEBUG*
             } else {
                 $ii = $today_t + $v['time'];
                 $time_ids[$i][] = $ii;
                 $report[$ii] = array();
                 //					eval_js('$("UCcell_'.$ii.'").innerHTML="'.Base_RegionalSettingsCommon::time2reg($ii).'";'); // *DEBUG*
             }
             $prev = $v;
         }
     }
     $navigation_bar_additions = '';
     if (is_callable(array($this->event_module, 'get_navigation_bar_additions'))) {
         $event_module_instance = $this->init_module($this->event_module);
         $navigation_bar_additions = call_user_func(array($event_module_instance, 'get_navigation_bar_additions'), '', '');
     }
     $theme->assign('navigation_bar_additions', $navigation_bar_additions);
     $theme->assign('time_ids', $time_ids);
     $theme->assign('timeline', reset($timeline));
     $theme->assign('week_view_label', __('Week calendar'));
     //data
     //$dis_week_from = Base_RegionalSettingsCommon::reg2time($dis_week_from);
     //$dis_week_to = $dis_week_from+7*86400-1;
     $dis_week_to = date('Y-m-d', $dis_week_from + 7.5 * 86400);
     $dis_week_from = date('Y-m-d', $dis_week_from);
     $ret = $this->get_events($dis_week_from, $dis_week_to);
     $this->displayed_events = array('start' => $dis_week_from, 'end' => $dis_week_to, 'events' => $ret);
     $custom_keys = $this->settings['custom_rows'];
     $busy_labels = $this->settings['busy_labels'];
     foreach ($ret as $k => $ev) {
         if (!isset($ev['busy_label'])) {
             continue;
         }
         if (!is_array($ev['busy_label'])) {
             $ev['busy_label'] = array($ev['busy_label']);
         }
         ob_start();
         Utils_CalendarBusyReportCommon::print_event($ev);
         $ev_print = ob_get_clean();
         $day_start = explode(':', $this->settings['start_day']);
         $day_start = ($day_start[0] * 60 + $day_start[1]) * 60;
         if (!isset($ev['start'])) {
             $diff = 1;
         } else {
             $diff = ($day_start - ($ev['start'] - $today_t)) / 3600;
         }
         $dur = ceil($ev['duration'] / (strtotime($this->settings['interval']) - strtotime('0:00')));
         if (isset($ev['timeless']) && $ev['timeless']) {
             if (!isset($ev['custom_row_key'])) {
                 $ev['custom_row_key'] = 'timeless';
             }
             $today_t_timeless = strtotime($ev['timeless']);
             if (isset($custom_keys[$ev['custom_row_key']])) {
                 $dest_id = $today_t_timeless . '_' . $ev['custom_row_key'];
                 if (isset($report[$dest_id])) {
                     foreach ($ev['busy_label'] as $busy_label) {
                         if (!isset($busy_labels[$busy_label])) {
                             $busy_labels[$busy_label] = $busy_label;
                         }
                         if (!isset($report[$dest_id][$busy_label])) {
                             $report[$dest_id][$busy_label] = '';
                         }
                         $report[$dest_id][$busy_label] .= $ev_print;
                     }
                 }
             } else {
                 //					trigger_error('Invalid custom_row_key:'.$ev['custom_row_key'],E_USER_ERROR);
                 continue;
             }
         } else {
             $today_t = Base_RegionalSettingsCommon::time2reg($ev['start'], true, true, true, false);
             $today_date = date('Y-m-d', strtotime($today_t));
             $today_t = strtotime(date('Y-m-d H:i:s', Base_RegionalSettingsCommon::reg2time($today_date)));
             $ev_start = $ev['start'] - $today_t;
             if (!isset($timeline[$today_date])) {
                 continue;
             }
             $ct = count($timeline[$today_date]);
             for ($i = 1, $j = 2; $j < $ct; $i++, $j++) {
                 while ($timeline[$today_date][$i]['time'] === false) {
                     $i++;
                 }
                 while (($timeline[$today_date][$j]['time'] === false || $i >= $j) && $j < $ct) {
                     $j++;
                 }
                 if ($j == $ct) {
                     break;
                 }
                 if ($timeline[$today_date][$i]['time'] <= $ev_start && $ev_start < $timeline[$today_date][$j]['time']) {
                     break;
                 }
             }
             for ($k = $i; $k < $i + $dur; $k++) {
                 $dest_id = $today_t + $timeline[$today_date][$k]['time'];
                 if (isset($report[$dest_id])) {
                     foreach ($ev['busy_label'] as $busy_label) {
                         if (!isset($busy_labels[$busy_label])) {
                             $busy_labels[$busy_label] = $busy_label;
                         }
                         if (!isset($report[$dest_id][$busy_label])) {
                             $report[$dest_id][$busy_label] = '';
                         }
                         $report[$dest_id][$busy_label] .= $ev_print;
                     }
                 }
             }
         }
     }
     $theme->assign('report', $report);
     $theme->assign('busy_labels', $busy_labels);
     //ok, display
     $theme->display('week');
     if ($this->custom_new_event_href_js !== null) {
         $jshref = call_user_func($this->custom_new_event_href_js, '__TIME__', '__TIMELESS__', '__OBJECT__');
     } else {
         $jshref = $this->create_unique_href_js(array('action' => 'add', 'time' => '__TIME__', 'timeless' => '__TIMELESS__', 'object' => '__OBJECT__'));
     }
     eval_js('Utils_CalendarBusyReport.activate_dclick(\'' . Epesi::escapeJS($jshref, false) . '\')');
 }
Exemplo n.º 25
0
define('JS_OUTPUT', 1);
define('CID', false);
//don't load user session
define('READ_ONLY_SESSION', true);
require_once '../../../include.php';
ModuleManager::load_modules();
if (!Base_AclCommon::is_user()) {
    Epesi::alert('Session expired, logged out - reloading epesi.');
    Epesi::redirect('');
    Epesi::send_output();
    exit;
}
$default = isset($_POST['default_dash']) && $_POST['default_dash'];
if ($default && !Base_AdminCommon::get_access('Base_Dashboard') || !isset($_POST['col']) || !isset($_POST['data'])) {
    Epesi::alert('Permission denied');
    Epesi::send_output();
    exit;
}
if (!$default) {
    $user = Base_AclCommon::get_user();
}
$tab = json_decode($_POST['tab']);
parse_str($_POST['data'], $x);
if (!isset($x['ab_item'])) {
    exit;
}
if (is_numeric($_POST['col']) && $_POST['col'] < 3 && $_POST['col'] >= 0) {
    if ($default) {
        $table = 'base_dashboard_default_applets';
        $val = null;
    } else {
Exemplo n.º 26
0
    $results[$i] = array();
    $i--;
    $words[$i] = strtolower($words[$i]);
}
foreach ($helps as $m => $tutorials) {
    foreach ($tutorials as $tut) {
        $match = 0;
        $l = strtolower($tut['label']);
        foreach ($words as $w) {
            if (strpos($l, $w) !== false) {
                $match++;
            }
        }
        $l = strtolower($tut['keywords']);
        foreach ($words as $w) {
            if (strpos($l, $w) !== false) {
                $match++;
            }
        }
        if ($match) {
            $results[$match][] = $tut;
        }
    }
}
foreach ($results as $count => $tutorials) {
    foreach ($tutorials as $tut) {
        $html .= '<a href="javascript:void(0);" onclick="Helper.start_tutorial(\'' . Epesi::escapeJS(trim($tut['steps'], '#')) . '\')">' . $tut['label'] . '</a>';
    }
}
print '$("Base_Help__help_links").innerHTML = "' . Epesi::escapeJS($html) . '";';
Exemplo n.º 27
0
 public function translations()
 {
     global $translations;
     global $custom_translations;
     load_js('modules/Base/Lang/Administrator/js/main.js');
     eval_js('translate_init();');
     $lp = $this->init_module('Utils/LeightboxPrompt');
     $form = $this->init_module('Libs/QuickForm', null, 'translations_sending');
     $desc = '<div id="trans_sett_info" style="line-height:17px;">';
     $desc .= __('You have now option to contribute with your translations to help us deliver EPESI in various languages. You can opt in to send your translations to EPESI central database, allowing to deliver EPESI in your language to other users.') . '<br>';
     $desc .= __('Please note that the translations you submit aren\'t subject to copyright. EPESI Team will distribute the translations free of charge to the end users.') . '<br>';
     $desc .= __('The only data being sent is the values of the fields presented below and the translated strings, we do not receive any other information contained in EPESI.') . '<br>';
     $desc .= __('You can also change your Translations Contribution settings at later time.') . '<br>';
     $desc .= '</div>';
     eval_js('$("trans_sett_info").up("td").setAttribute("colspan",2);');
     eval_js('$("trans_sett_info").up("td").style.borderRadius="0";');
     // Not really nice, but will have to do for now
     eval_js('$("decription_label").up("td").hide();');
     eval_js('function update_credits(){$("contact_email").disabled=$("credits_website").disabled=!$("include_credits").checked||!$("allow").checked;}');
     eval_js('update_credits();');
     $ip = gethostbyname($_SERVER['SERVER_NAME']);
     $me = CRM_ContactsCommon::get_my_record();
     $form->addElement('static', 'header', '<div id="decription_label" />', $desc);
     $form->addElement('checkbox', 'allow', __('Enable sending translations'), null, array('id' => 'allow', 'onchange' => '$("include_credits").disabled=$("first_name").disabled=$("last_name").disabled=!this.checked;update_credits();'));
     $form->addElement('text', 'first_name', __('First Name'), array('id' => 'first_name'));
     $form->addElement('text', 'last_name', __('Last Name'), array('id' => 'last_name'));
     $form->addElement('checkbox', 'include_credits', __('Include in credits'), null, array('id' => 'include_credits', 'onchange' => 'update_credits();'));
     $form->addElement('text', 'credits_website', __('Credits website'), array('id' => 'credits_website'));
     $form->addElement('text', 'contact_email', __('Contact e-mail'), array('id' => 'contact_email'));
     $form->addElement('static', 'IP', __('IP'), $ip);
     $lp->add_option(null, null, null, $form);
     eval_js('$("first_name").disabled=$("last_name").disabled=!$("allow").checked;');
     $vals = $lp->export_values();
     if ($vals) {
         $values = $vals['form'];
         if (!isset($values['allow'])) {
             $values['allow'] = 0;
         }
         if (!isset($values['first_name'])) {
             $values['first_name'] = '';
         }
         if (!isset($values['last_name'])) {
             $values['last_name'] = '';
         }
         if (!isset($values['include_credits'])) {
             $values['include_credits'] = 0;
         }
         if (!isset($values['credits_website'])) {
             $values['credits_website'] = '';
         }
         if (!isset($values['contact_email'])) {
             $values['contact_email'] = '';
         }
         DB::Execute('DELETE FROM base_lang_trans_contrib WHERE user_id=%d', array(Acl::get_user()));
         DB::Execute('INSERT INTO base_lang_trans_contrib (user_id, allow, first_name, last_name, credits, credits_website, contact_email) VALUES (%d, %d, %s, %s, %d, %s, %s)', array(Acl::get_user(), $values['allow'], $values['first_name'], $values['last_name'], $values['include_credits'], $values['credits_website'], $values['contact_email']));
     }
     $allow_sending = Base_Lang_AdministratorCommon::allow_sending(true);
     if ($allow_sending === null || $allow_sending === false) {
         $form->setDefaults(array('allow' => 0, 'first_name' => $me['first_name'], 'last_name' => $me['last_name'], 'contact_email' => $me['email']));
     } else {
         $r = DB::GetRow('SELECT * FROM base_lang_trans_contrib WHERE user_id=%d', array(Acl::get_user()));
         if (!$r['first_name']) {
             $r['first_name'] = $me['first_name'];
         }
         if (!$r['last_name']) {
             $r['last_name'] = $me['last_name'];
         }
         if (!$r['contact_email']) {
             $r['contact_email'] = $me['email'];
         }
         $form->setDefaults(array('allow' => $r['allow'], 'first_name' => $r['first_name'], 'last_name' => $r['last_name'], 'contact_email' => $r['contact_email'], 'credits_website' => $r['credits_website'], 'include_credits' => $r['credits']));
     }
     Base_ActionBarCommon::add('settings', __('Translations Contributions'), $lp->get_href());
     $this->display_module($lp, array(__('Translations Contributions settings')));
     if (Base_AdminCommon::get_access('Base_Lang_Administrator', 'new_langpack')) {
         Base_ActionBarCommon::add('add', __('New langpack'), $this->create_callback_href(array($this, 'new_lang_pack')));
     }
     if (Base_AdminCommon::get_access('Base_Lang_Administrator', 'select_language')) {
         Base_ActionBarCommon::add('refresh', __('Refresh languages'), $this->create_callback_href(array('Base_LangCommon', 'refresh_cache')));
     }
     $form2 = $this->init_module('Libs/QuickForm', null, 'translaction_filter');
     $form2->addElement('select', 'lang_filter', __('Filter'), array(__('Show all'), __('Show with custom translation'), __('Show with translation'), __('Show without translation')), array('onchange' => $form2->get_submit_form_js()));
     if ($form2->validate()) {
         $vals = $form2->exportValues();
         $this->set_module_variable('filter', $vals['lang_filter']);
     }
     $filter = $this->get_module_variable('filter', 0);
     $form2->setDefaults(array('lang_filter' => $filter));
     ob_start();
     $form2->display_as_row();
     $trans_filter = ob_get_clean();
     if (!isset($_SESSION['client']['base_lang_administrator']['currently_translating'])) {
         $_SESSION['client']['base_lang_administrator']['currently_translating'] = Base_LangCommon::get_lang_code();
     }
     if (!isset($_SESSION['client']['base_lang_administrator']['notice'])) {
         print '<span class="important_notice">' . __('Please make sure the correct language is selected in the box below before you start translating') . ' <a style="float:right;" ' . $this->create_callback_href(array($this, 'hide_notice')) . '>' . __('Discard') . '</a>' . '</span>';
     }
     if (Base_AdminCommon::get_access('Base_Lang_Administrator', 'translate')) {
         $langs = Base_LangCommon::get_installed_langs();
         $form = $this->init_module('Libs/QuickForm', null, 'language_selected');
         $form->addElement('select', 'lang_code', __('Currently Translating'), $langs, array('onchange' => $form->get_submit_form_js()));
         $currently_translating = $_SESSION['client']['base_lang_administrator']['currently_translating'];
         $form->setDefaults(array('lang_code' => $currently_translating));
         if ($form->validate()) {
             $form->process(array($this, 'submit_language_select'));
         }
         if ($allow_sending) {
             $warning_mgs = __('All custom translations will be sent to our server right after you will input them. Use this mode only, if you wish to contribute your translations. If you are going to change meaning of any string, then please disable sending translations.');
             print "<h1 style=\"color:red; width: 70%\">{$warning_mgs}</h1>";
         } else {
             $contribution_mgs = __('If you wish to help us with translating EPESI to your language, then click Translation Contribution in the Action Bar.');
             print "<h3>{$contribution_mgs}</h3>";
         }
         $form->display_as_column();
         if ($allow_sending) {
             $href = $this->create_confirm_callback_href(__('Are you sure?'), array($this, 'send_lang_ajax'), array($currently_translating));
             print "<h4><a {$href}>" . __('Send all your custom translations for language %s', array($langs[$currently_translating])) . "</a></h4>";
         }
         $help_msg = __('You can open next string to translate with space button');
         print "<p>{$help_msg}</p>";
     }
     Base_LangCommon::load($_SESSION['client']['base_lang_administrator']['currently_translating']);
     $data = array();
     foreach ($custom_translations as $o => $t) {
         if ($t || !isset($translations[$o])) {
             $translations[$o] = $t;
         }
     }
     foreach ($translations as $o => $t) {
         if (isset($custom_translations[$o]) && $custom_translations[$o]) {
             $t = $custom_translations[$o];
         } else {
             if ($filter == 1) {
                 continue;
             }
         }
         if ($filter == 2 && !$t) {
             continue;
         }
         if ($filter == 3 && $t) {
             continue;
         }
         $span_id = 'trans__' . md5($o);
         if (Base_AdminCommon::get_access('Base_Lang_Administrator', 'translate')) {
             $org = '<a href="javascript:void(0);" onclick="lang_translate(\'' . Epesi::escapeJS(htmlspecialchars($o)) . '\',\'' . $span_id . '\');">' . $o . '</a>';
             $t = '<span id="' . $span_id . '">' . $t . '</span>';
         }
         eval_js('translate_add_id("' . $span_id . '","' . Epesi::escapeJS($o) . '");');
         $data[] = array($org, $t);
     }
     $gb = $this->init_module('Utils/GenericBrowser', null, 'lang_translations');
     $gb->set_custom_label($trans_filter);
     $gb->set_table_columns(array(array('name' => __('Original'), 'order_preg' => '/^<[^>]+>([^<]*)<[^>]+>$/i', 'search' => 'original'), array('name' => __('Translated'), 'search' => 'translated')));
     //$limit = $gb->get_limit(count($data));
     $id = 0;
     foreach ($data as $v) {
         //if ($id>=$limit['offset'] && $id<$limit['offset']+$limit['numrows'])
         $gb->add_row_array($v);
         $id++;
     }
     Base_LangCommon::load();
     $this->display_module($gb, array(true), 'automatic_display');
     Utils_ShortcutCommon::add(array(' '), 'translate_first_on_the_list', array('disable_in_input' => 1));
 }
Exemplo n.º 28
0
 public function validate($data)
 {
     if (DEMO_MODE) {
         print 'You cannot modify installed modules in demo';
         return false;
     }
     @set_time_limit(0);
     $installed = array();
     $install = array();
     $uninstall = array();
     $anonymous_setup = false;
     foreach ($data as $k => $v) {
         ${$k} = $v;
     }
     foreach ($installed as $name => $new_version) {
         $old_version = ModuleManager::is_installed($name);
         if ($old_version == $new_version) {
             continue;
         }
         if ($old_version == -1 && $new_version >= 0) {
             $install[$name] = $new_version;
             continue;
         }
         if ($new_version == -2) {
             $uninstall[$name] = 1;
             $install[$name] = $old_version;
             continue;
         }
         if ($old_version >= 0 && $new_version == -1) {
             $uninstall[$name] = 1;
             continue;
         }
         if ($old_version < $new_version) {
             if (!ModuleManager::upgrade($name, $new_version)) {
                 return false;
             }
             continue;
         }
         if ($old_version > $new_version) {
             if (!ModuleManager::downgrade($name, $new_version)) {
                 return false;
             }
             continue;
         }
     }
     //uninstall
     $modules_prio_rev = array();
     foreach (ModuleManager::$modules as $k => $v) {
         $modules_prio_rev[] = $k;
     }
     $modules_prio_rev = array_reverse($modules_prio_rev);
     foreach ($modules_prio_rev as $k) {
         if (array_key_exists($k, $uninstall)) {
             if (!ModuleManager::uninstall($k)) {
                 return false;
             }
             if (count(ModuleManager::$modules) == 0) {
                 print 'No modules installed';
             }
         }
     }
     //install
     foreach ($install as $i => $v) {
         $post_install[$i] = $v;
         if (isset($uninstall[$i])) {
             if (!ModuleManager::install($i, $v, true, false)) {
                 return false;
             }
         } else {
             if (!ModuleManager::install($i, $v)) {
                 return false;
             }
         }
     }
     $processed = ModuleManager::get_processed_modules();
     $this->set_module_variable('post-install', $processed['install']);
     Base_ThemeCommon::create_cache();
     if (empty($post_install)) {
         Epesi::redirect();
     }
     return true;
 }
Exemplo n.º 29
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>";
 }
Exemplo n.º 30
0
/**
 * @author Arkadiusz Bisaga <*****@*****.**>
 * @copyright Copyright &copy; 2008, Telaxus LLC
 * @license MIT
 * @version 1.0
 * @package epesi-utils
 * @subpackage watchdog
 */
if (!isset($_POST['id']) || !isset($_POST['state']) || !isset($_POST['element']) || !isset($_POST['cat']) || !isset($_POST['cid'])) {
    die('Invalid request: ' . print_r($_POST, true));
}
define('JS_OUTPUT', 1);
define('CID', $_POST['cid']);
define('READ_ONLY_SESSION', true);
require_once '../../../include.php';
ModuleManager::load_modules();
$id = json_decode($_POST['id']);
$cat = json_decode($_POST['cat']);
$state = json_decode($_POST['state']);
$element = json_decode($_POST['element']);
if (!Acl::is_user()) {
    die('alert("Unauthorized access");');
}
if ($state) {
    Utils_WatchdogCommon::subscribe($cat, $id);
} else {
    Utils_WatchdogCommon::unsubscribe($cat, $id);
}
print 'jq("#' . $element . '").html("' . Epesi::escapeJS(Utils_WatchdogCommon::get_change_subscription_icon_tags($cat, $id)) . '");';