/** * Edit User permission on table's records * * @param integer $id_user User ID * @param integer $id_area Area ID * @param string $table Table name * @return void */ public function permissions($id_user, $id_area, $table) { // load dictionaries $this->dict->get_wordarray(array('form', 'groups', 'users')); $mod = new Permission_model(); // get user name $u = $mod->get_by_id($id_user, 'users', 'username'); // get area name $a = $mod->get_by_id($id_area, 'areas', 'name'); // get user privileges on the table $what = $mod->get_detail($id_user, $id_area, $table); // permission levels $l = $mod->get_levels(); $fields = array(); $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $id_user, 'name' => 'id_user'); $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $id_area, 'name' => 'id_area'); $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $table, 'name' => 'what'); $c = 0; // if table is not empty if ($what) { $fields[] = array('label' => null, 'type' => 'html', 'value' => '<div class="band inner-pad clearfix">'); // each record foreach ($what as $i) { $fields[] = array('label' => null, 'type' => 'html', 'value' => '<div class="one-half xs-one-whole">'); $value = is_null($i->level) ? 0 : $i->level; $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $i->id, 'name' => 'id_' . $c); $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $value, 'name' => 'old_value_' . $c); $fields[] = array('label' => $i->name, 'type' => 'select', 'value' => $value, 'name' => 'value_' . $c, 'options' => array($l, 'id', 'name', 0), 'suggestion' => strip_tags($i->description), 'extra' => 'class="large"'); $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div>'); $c++; } $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div>'); } // if submitted if (X4Route_core::$post) { $e = X4Validation_helper::form($fields, 'detpriv'); if ($e) { $this->detailing($_POST); } else { $this->notice($fields); } die; } // content $view = new X4View_core('editor'); $view->title = _EDIT_PRIV . ': ' . $a->name . _TRAIT_ . ucfirst($table); // form builder $view->form = '<div id="scrolled">' . X4Form_helper::doform('detpriv', $_SERVER["REQUEST_URI"], $fields, array(_RESET, _SUBMIT, 'buttons'), 'post', '', 'onclick="setForm(\'detpriv\');"') . '</div>'; $view->js = ' <script> window.addEvent("domready", function() { var myScroll = new Scrollable($("scrolled")); }); </script>'; $view->render(TRUE); }