Exemplo n.º 1
0
	public function edit_permissions_rule($id = null, $clone = false) {
		if (Base_AdminCommon::get_access('Utils_RecordBrowser', 'permissions')!=2) return false;
        if ($this->is_back()) {
            return false;
		}
		load_js('modules/Utils/RecordBrowser/edit_permissions.js');
		$all_clearances = array(''=>'---')+array_flip(Base_AclCommon::get_clearance(true));
		$all_fields = array();
		$this->init();
		foreach ($this->table_rows as $k=>$v)
			$all_fields[$v['id']] = $k;
		$js = '';
		$operators = array(
			'='=>__('equal'), 
			'!'=>__('not equal'), 
			'>'=>'>',
			'>='=>'>=',
			'<'=>'<',
			'<='=>'<='
		);

		$form = $this->init_module('Libs_QuickForm');
		$theme = $this->init_module('Base_Theme');
		
		$counts = array(
			'clearance'=>5,
			'ands'=>5,
			'ors'=>10
		);
		
		$actions = $this->get_permission_actions();
		$form->addElement('select', 'action', __('Action'), $actions);
		
		$fields_permissions = $all_fields;

		foreach ($all_fields as $k=>$v) {
			if ($this->table_rows[$v]['type']=='calculated' || $this->table_rows[$v]['type']=='hidden') unset($all_fields[$k]);
			else $this->manage_permissions_set_field_values($k);
		}

		$all_fields = array(
			':Created_by'=>__('Created by'),
			':Created_on'=>__('Created on'),
			':Edited_on'=>__('Edited on')
		) + $all_fields;
		if ($this->tab=='contact' || $this->tab=='company')
			$all_fields = array('id'=>__('ID')) + $all_fields;
		
		$this->manage_permissions_set_field_values(':Created_by', array('USER_ID'=>__('User Login')));
		$this->manage_permissions_set_field_values(':Created_on', Utils_RecordBrowserCommon::$date_values);
		$this->manage_permissions_set_field_values(':Edited_on', Utils_RecordBrowserCommon::$date_values);
		if ($this->tab=='contact')
			$this->manage_permissions_set_field_values('id', array('USER'=>__('User Contact')));
		if ($this->tab=='company')
			$this->manage_permissions_set_field_values('id', array('USER_COMPANY'=>__('User Company')));
		
		for ($i=0; $i<$counts['clearance']; $i++)
			$form->addElement('select', 'clearance_'.$i, __('Clearance'), $all_clearances);
		$current_or = array();
		$current_and = 0;
		
		foreach ($all_fields as $k=>$v) {
			if (isset($this->table_rows[$v])) {
				$v = $this->table_rows[$v]['name'];
			}
			$all_fields[$k] = _V($v);
		}
		
		for ($i=0; $i<$counts['ands']; $i++) {
			$current_or[$i] = 0;
			for ($j=0; $j<$counts['ors']; $j++) {
				$form->addElement('select', 'crits_'.$i.'_'.$j.'_field', __('Crits'), array(''=>'---')+$all_fields, array('onchange'=>'utils_recordbrowser__update_field_values('.$i.', '.$j.');', 'id'=>'crits_'.$i.'_'.$j.'_field'));
				$form->addElement('select', 'crits_'.$i.'_'.$j.'_op', __('Operator'), array(''=>'---')+$operators);
				$form->addElement('select', 'crits_'.$i.'_'.$j.'_value', __('Value'), array(), array('id'=>'crits_'.$i.'_'.$j.'_value', 'onchange'=>'utils_recordbrowser__update_field_sub_values('.$i.', '.$j.');'));
				$form->addElement('select', 'crits_'.$i.'_'.$j.'_sub_value', __('Subrecord Value'), array(), array('id'=>'crits_'.$i.'_'.$j.'_sub_value', 'style'=>'display:none;'));
				$js .= 'utils_recordbrowser__update_field_values('.$i.', '.$j.');';
			}
		}
		$defaults = array();
		foreach ($fields_permissions as $k=>$v) {
			$defaults['field_'.$k] = 1;
			$form->addElement('checkbox', 'field_'.$k, _V($this->table_rows[$v]['name']));
		}
		$theme->assign('labels', array(
			'and' => '<span class="joint">'.__('and').'</span>',
			'or' => '<span class="joint">'.__('or').'</span>',
			'caption' => $id?__('Edit permission rule'):__('Add permission rule'),
			'clearance' => __('Clearance requried'),
			'fields' => __('Fields allowed'),
			'crits' => __('Criteria required'),
			'add_clearance' => __('Add clearance'),
			'add_or' => __('Add criteria (or)'),
			'add_and' => __('Add criteria (and)')
 		));
		$current_clearance = 0;
		$sub_values = array();
		if ($id!==null && $this->tab!='__RECORDSETS__' && !preg_match('/,/',$this->tab)) {
			$row = DB::GetRow('SELECT * FROM '.$this->tab.'_access AS acs WHERE id=%d', array($id));
			
			$defaults['action'] = $row['action'];
			$crits = unserialize($row['crits']);
			$i = 0;
			$j = 0;
			$or = false;
			$first = true;
			foreach ($crits as $k=>$v) {
				$operator = '=';
				while (($k[0]<'a' || $k[0]>'z') && ($k[0]<'A' || $k[0]>'Z') && $k[0]!=':') {
					if ($k[0]=='!') $operator = '!';
					if ($k[0]=='(' && $or) $or = false;
					if ($k[0]=='|') $or = true;
					if ($k[0]=='<') $operator = '<';
					if ($k[0]=='>') $operator = '>';
					if ($k[0]=='~') $operator = DB::like();
					if ($k[1]=='=' && $operator!=DB::like()) {
						$operator .= '=';
						$k = substr($k, 2);
					} else $k = substr($k, 1);
				}
				if (!$first) {
					if ($or) $j++;
					else {
						$current_or[$i] += $j;
						$j = 0;
						$i++;
					}
				} else {
					$first = false;
				}
				$sub_value = null;
				if (!isset($r[$k]) && $k[strlen($k)-1]==']') {
					$sub_value = $v;
					list($k, $v) = explode('[', trim($k, ']'));
				}
				$defaults['crits_'.$i.'_'.$j.'_field'] = $k;
				$defaults['crits_'.$i.'_'.$j.'_op'] = $operator;
				$js .= '$("crits_'.$i.'_'.$j.'_value").value = "'.$v.'";';
				if ($sub_value!==null) $sub_values['crits_'.$i.'_'.$j.'_sub_value'] = $sub_value;
			}
			$current_or[$i] += $j;
			$current_and += $i;
			
			$i = 0;
			$tmp = DB::GetAll('SELECT * FROM '.$this->tab.'_access_clearance AS acs WHERE rule_id=%d', array($id));
			foreach ($tmp as $t) {
				$defaults['clearance_'.$i] = $t['clearance'];
				$i++;
			}
			$current_clearance += $i-1;
			
			$tmp = DB::GetAll('SELECT * FROM '.$this->tab.'_access_fields AS acs WHERE rule_id=%d', array($id));
			foreach ($tmp as $t) {
				unset($defaults['field_'.$t['block_field']]);
			}
		}
		for ($i=0; $i<$counts['ands']; $i++)
			for ($j=0; $j<$counts['ors']; $j++)
				$js .= 'utils_recordbrowser__update_field_sub_values('.$i.', '.$j.');';
		foreach ($sub_values as $k=>$v)
			$js .= '$("'.$k.'").value = "'.$v.'";';

		$form->setDefaults($defaults);
		
		if ($form->validate()) {
			$vals = $form->exportValues();
			$action = $vals['action'];

			$clearance = array();
			for ($i=0; $i<$counts['clearance']; $i++)
				if ($vals['clearance_'.$i]) $clearance[] = $vals['clearance_'.$i];
			
			$crits = array();
			for ($i=0; $i<$counts['ands']; $i++) {
				$or = '(';
				for ($j=0; $j<$counts['ors']; $j++) {
					if ($vals['crits_'.$i.'_'.$j.'_field'] && $vals['crits_'.$i.'_'.$j.'_op']) {
						if (!isset($operators[$vals['crits_'.$i.'_'.$j.'_op']])) trigger_error('Fatal error',E_USER_ERROR);
						if (!isset($all_fields[$vals['crits_'.$i.'_'.$j.'_field']])) trigger_error('Fatal error',E_USER_ERROR);
						$op = $vals['crits_'.$i.'_'.$j.'_op'];
						if ($op=='=') $op = '';
						if (isset($vals['crits_'.$i.'_'.$j.'_sub_value'])) {
							$vals['crits_'.$i.'_'.$j.'_field'] = $vals['crits_'.$i.'_'.$j.'_field'].'['.$vals['crits_'.$i.'_'.$j.'_value'].']';
							$vals['crits_'.$i.'_'.$j.'_value'] = $vals['crits_'.$i.'_'.$j.'_sub_value'];
						}
						$next = array($or.$op.$vals['crits_'.$i.'_'.$j.'_field'] => $vals['crits_'.$i.'_'.$j.'_value']);
						$crits = Utils_RecordBrowserCommon::merge_crits($crits, $next);
					}
					$or = '|';
				}
			}

			$blocked_fields = array();
			foreach ($fields_permissions as $k=>$v) {
				if (isset($vals['field_'.$k])) continue;
				$blocked_fields[] = $k;
			}
			
			if ($id===null || $clone)
				Utils_RecordBrowserCommon::add_access($this->tab, $action, $clearance, $crits, $blocked_fields);
			else
				Utils_RecordBrowserCommon::update_access($this->tab, $id, $action, $clearance, $crits, $blocked_fields);
			return false;
		}
		
		eval_js($js);

		eval_js('utils_recordbrowser__init_clearance('.$current_clearance.', '.$counts['clearance'].')');
		eval_js('utils_recordbrowser__init_crits_and('.$current_and.', '.$counts['ands'].')');
		for ($i=0; $i<$counts['ands']; $i++)
				eval_js('utils_recordbrowser__init_crits_or('.$i.', '.$current_or[$i].', '.$counts['ors'].')');
		eval_js('utils_recordbrowser__crits_initialized = true;');
		
		$form->assign_theme('form', $theme);
		$theme->assign('fields', $fields_permissions);
		$theme->assign('counts', $counts);
		
		$theme->display('edit_permissions');
		Base_ActionBarCommon::add('save', __('Save'), $form->get_submit_form_href());
		Base_ActionBarCommon::add('delete', __('Cancel'), $this->create_back_href());
		return true;
	}
Exemplo n.º 2
0
 */
header("Content-type: text/javascript");
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';
Exemplo n.º 3
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.º 4
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');
 }
Exemplo n.º 5
0
 * @version 1.0
 * @package epesi-base
 * @subpackage dashboard
 */
header("Content-type: text/javascript");
if (!isset($_POST['id'])) {
    die;
}
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') || !$default && !Base_DashboardCommon::has_permission_to_manage_applets()) {
    Epesi::alert('Permission denied');
    Epesi::send_output();
    exit;
}
if (!$default) {
    $user = Base_AclCommon::get_user();
}
$id = json_decode($_POST['id']);
Base_DashboardCommon::remove_applet($id, $default);
Exemplo n.º 6
0
 public function edit_permissions_rule($id = null, $clone = false)
 {
     if (Base_AdminCommon::get_access('Utils_RecordBrowser', 'permissions') != 2) {
         return false;
     }
     if ($this->is_back()) {
         return false;
     }
     load_js('modules/Utils/RecordBrowser/edit_permissions.js');
     $all_clearances = array('' => '---') + array_flip(Base_AclCommon::get_clearance(true));
     $all_fields = array();
     $this->init();
     foreach ($this->table_rows as $k => $v) {
         $all_fields[$v['id']] = $k;
     }
     $form = $this->init_module('Libs_QuickForm');
     $theme = $this->init_module('Base_Theme');
     $counts = array('clearance' => 5);
     $actions = $this->get_permission_actions();
     $form->addElement('select', 'action', __('Action'), $actions);
     $fields_permissions = $all_fields;
     for ($i = 0; $i < $counts['clearance']; $i++) {
         $form->addElement('select', 'clearance_' . $i, __('Clearance'), $all_clearances);
     }
     $defaults = array();
     foreach ($fields_permissions as $k => $v) {
         $defaults['field_' . $k] = 1;
         $form->addElement('checkbox', 'field_' . $k, _V($this->table_rows[$v]['name']));
     }
     $theme->assign('labels', array('and' => '<span class="joint">' . __('and') . '</span>', 'or' => '<span class="joint">' . __('or') . '</span>', 'caption' => $id ? __('Edit permission rule') : __('Add permission rule'), 'clearance' => __('Clearance requried'), 'fields' => __('Fields allowed'), 'crits' => __('Criteria required'), 'add_clearance' => __('Add clearance'), 'add_or' => __('Add criteria (or)'), 'add_and' => __('Add criteria (and)')));
     $current_clearance = 0;
     $crits = array();
     if ($id !== null && $this->tab != '__RECORDSETS__' && !preg_match('/,/', $this->tab)) {
         $row = DB::GetRow('SELECT * FROM ' . $this->tab . '_access AS acs WHERE id=%d', array($id));
         $defaults['action'] = $row['action'];
         $crits = Utils_RecordBrowserCommon::unserialize_crits($row['crits']);
         if (is_array($crits)) {
             $crits = Utils_RecordBrowser_Crits::from_array($crits);
         }
         $i = 0;
         $tmp = DB::GetAll('SELECT * FROM ' . $this->tab . '_access_clearance AS acs WHERE rule_id=%d', array($id));
         foreach ($tmp as $t) {
             $defaults['clearance_' . $i] = $t['clearance'];
             $i++;
         }
         $current_clearance += $i - 1;
         $tmp = DB::GetAll('SELECT * FROM ' . $this->tab . '_access_fields AS acs WHERE rule_id=%d', array($id));
         foreach ($tmp as $t) {
             unset($defaults['field_' . $t['block_field']]);
         }
     }
     $qbi = new Utils_RecordBrowser_QueryBuilderIntegration($this->tab);
     $qb = $qbi->get_builder_module($this, $crits);
     $qb->add_to_form($form, 'qb_crits', __('Crits'), 'qb_crits_editor');
     $form->setDefaults($defaults);
     if ($form->validate()) {
         $vals = $form->exportValues();
         $action = $vals['action'];
         $clearance = array();
         for ($i = 0; $i < $counts['clearance']; $i++) {
             if ($vals['clearance_' . $i]) {
                 $clearance[] = $vals['clearance_' . $i];
             }
         }
         $crits = $qbi->json_to_crits($vals['qb_crits']);
         $blocked_fields = array();
         foreach ($fields_permissions as $k => $v) {
             if (isset($vals['field_' . $k])) {
                 continue;
             }
             $blocked_fields[] = $k;
         }
         if ($id === null || $clone) {
             Utils_RecordBrowserCommon::add_access($this->tab, $action, $clearance, $crits, $blocked_fields);
         } else {
             Utils_RecordBrowserCommon::update_access($this->tab, $id, $action, $clearance, $crits, $blocked_fields);
         }
         return false;
     }
     eval_js('utils_recordbrowser__init_clearance(' . $current_clearance . ', ' . $counts['clearance'] . ')');
     eval_js('utils_recordbrowser__crits_initialized = true;');
     $form->assign_theme('form', $theme);
     $theme->assign('fields', $fields_permissions);
     $theme->assign('counts', $counts);
     $theme->display('edit_permissions');
     Base_ActionBarCommon::add('save', __('Save'), $form->get_submit_form_href());
     Base_ActionBarCommon::add('delete', __('Cancel'), $this->create_back_href());
     return true;
 }
Exemplo n.º 7
0
 public function user_actions($r, $gb_row)
 {
     static $admin_levels = false;
     static $my_level = false;
     if ($admin_levels === false) {
         $admin_levels = DB::GetAssoc('SELECT id,admin FROM user_login');
     }
     if ($my_level === false) {
         $my_level = isset($admin_levels[Base_AclCommon::get_user()]) ? $admin_levels[Base_AclCommon::get_user()] : 0;
     }
     $mod = 'Base_User_Administrator';
     $log_as_user = Base_AdminCommon::get_access($mod, 'log_as_user');
     $log_as_admin = Base_AdminCommon::get_access($mod, 'log_as_admin');
     $user_level = isset($admin_levels[$r['login']]) ? $admin_levels[$r['login']] : 0;
     // 2 is superadmin, 1 admin, 0 user
     if ($my_level == 2 || $my_level == 1 && ($user_level == 0 && $log_as_user || $user_level == 1 && $log_as_admin)) {
         // contact is admin and I can login as admin
         if (Base_UserCommon::is_active($r['login'])) {
             $gb_row->add_action($this->create_callback_href(array($this, 'change_user_active_state'), array($r['login'], false)), 'Deactivate user', null, Base_ThemeCommon::get_template_file('Utils_GenericBrowser', 'active-on.png'));
             $gb_row->add_action(Module::create_href(array('log_as_user' => $r['login'])), 'Log as user', null, Base_ThemeCommon::get_template_file('Utils_GenericBrowser', 'restore.png'));
             // action!
             if (isset($_REQUEST['log_as_user']) && $_REQUEST['log_as_user'] == $r['login']) {
                 Acl::set_user($r['login'], true);
                 Epesi::redirect();
                 return;
             }
         } else {
             $gb_row->add_action($this->create_callback_href(array($this, 'change_user_active_state'), array($r['login'], true)), 'Activate user', null, Base_ThemeCommon::get_template_file('Utils_GenericBrowser', 'active-off.png'));
         }
     }
 }
Exemplo n.º 8
0
<?php

/**
 * @author Arkadiusz Bisaga <*****@*****.**>
 * @copyright Copyright &copy; 2008, Telaxus LLC
 * @license MIT
 * @version 1.0
 * @package epesi-lang
 * @subpackage timesheet
 */
if (!isset($_POST['original']) || !isset($_POST['new']) || !isset($_POST['cid'])) {
    die('alert(\'Invalid request\')');
}
define('JS_OUTPUT', 1);
define('CID', $_POST['cid']);
define('READ_ONLY_SESSION', true);
require_once '../../../../include.php';
ModuleManager::load_modules();
if (!Base_AdminCommon::get_access('Base_Lang_Administrator', 'translate')) {
    die('Unauthorized access');
}
$original = $_POST['original'];
$new = $_POST['new'];
$lang = $_SESSION['client']['base_lang_administrator']['currently_translating'];
Base_LangCommon::append_custom($lang, array($original => $new));
Base_Lang_AdministratorCommon::send_translation($lang, $original, $new);
Exemplo n.º 9
0
 private function banning_form()
 {
     if (!Base_AdminCommon::get_access($this->get_type(), 'manage_ban')) {
         return;
     }
     $qf = $this->init_module(Libs_QuickForm::module_name(), null, 'ban');
     $qf->addElement('select', 'forbid_autologin', __('Forbid Remember Me'), array("0" => __('No'), "1" => __('Yes')), array('onChange' => $qf->get_submit_form_js()));
     $qf->addElement('select', 'bantype', __('Ban by'), array("0" => __('IP Address'), "1" => "User login from specific IP address"), array('onChange' => $qf->get_submit_form_js()));
     $qf->addElement('select', 'bantries', __('Number of failed logins to ban'), array(0 => __('Disable ban'), 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 10 => 10), array('onChange' => $qf->get_submit_form_js()));
     $qf->addElement('select', 'bantime', __('Ban time after  failed logins'), array(10 => __('10 seconds'), 30 => __('30 seconds'), 60 => __('1 minute'), 180 => __('3 minutes'), 300 => __('5 minutes'), 900 => __('15 minutes'), 1800 => __('30 minutes'), 3600 => __('1 hour'), 3600 * 6 => __('6 hours'), 3600 * 24 => __('1 day')), array('onChange' => $qf->get_submit_form_js()));
     $qf->setDefaults(array('forbid_autologin' => Variable::get('forbid_autologin', false), 'bantype' => Variable::get('host_ban_by_login', false), 'bantries' => Variable::get('host_ban_nr_of_tries'), 'bantime' => Variable::get('host_ban_time')));
     if ($qf->validate()) {
         $values = $qf->exportValues();
         Variable::set('forbid_autologin', $values['forbid_autologin']);
         Variable::set('host_ban_by_login', $values['bantype']);
         Variable::set('host_ban_nr_of_tries', $values['bantries']);
         Variable::set('host_ban_time', $values['bantime']);
     }
     if (Variable::get('host_ban_nr_of_tries') == 0) {
         $qf->getElement('bantime')->setAttribute('disabled', 'disabled');
     }
     $qf->display_as_row();
 }
Exemplo n.º 10
0
 * @author Paul Bukowski <*****@*****.**>
 * @copyright Copyright &copy; 2008, Telaxus LLC
 * @license MIT
 * @version 1.0
 * @package epesi-base
 * @subpackage dashboard
 */
header("Content-type: text/javascript");
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')) {
    Epesi::alert('Permission denied');
    Epesi::send_output();
    exit;
}
if (!$default) {
    $user = Base_AclCommon::get_user();
}
$id = json_decode($_POST['id']);
Base_DashboardCommon::remove_applet($id, $default);
Exemplo n.º 11
0
 */
header("Content-type: text/javascript");
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') || !$default && !Base_DashboardCommon::has_permission_to_manage_applets() || !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';