本文整理汇总了PHP中Utils_RecordBrowserCommon::update_access方法的典型用法代码示例。如果您正苦于以下问题:PHP Utils_RecordBrowserCommon::update_access方法的具体用法?PHP Utils_RecordBrowserCommon::update_access怎么用?PHP Utils_RecordBrowserCommon::update_access使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Utils_RecordBrowserCommon
的用法示例。
在下文中一共展示了Utils_RecordBrowserCommon::update_access方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit_permissions_rule
//.........这里部分代码省略.........
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;
}
示例2: edit_permissions_rule
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;
}