public static function list_of_groups() { if (isset($_GET['err'])) { switch ($_GET['err']) { case "reserved": Notification::statusNotify(t("ce nom est reservé au système"), Notification::STATUS_ERROR); break; case "exists": Notification::statusNotify(t("ce groupe existe déjà"), Notification::STATUS_ERROR); break; default: Notification::statusNotify(t("une erreur est survenue"), Notification::STATUS_ERROR); break; } } $groups = GroupObject::loadAll(); $theme = new Theme(); $theme->set_title(t("Groupes")); $rows = array(); foreach ($groups as $g) { $rows[] = array($g->gid, $g->label, Theme::linking(Page::url("/admin/groups/" . $g->label), t("details")), Theme::linking(Page::url("/admin/groups/confirm/" . $g->label), t("supprimer"))); } $head = array(t("identifiant du groupe"), t("nom du group"), t("actions")); $form = new Form("POST", Page::url("/admin/groups/create")); $form->addElement(new InputElement("group_name", t("nom du groupe"), "")); $form->addElement(new InputElement("add-group", "", t("créer le groupe"), "submit")); $theme->add_to_body(Theme::forming($form), t("Créer un nouveau groupe")); $theme->add_to_body(Theme::tabling($rows, $head), t("Liste des groupes existants")); $theme->process_theme(Theme::STRUCT_ADMIN); }
public function page_permissions() { if (isset($_POST['save-permissions'])) { PermissionObject::removeAllPermissions(); if (isset($_POST['permission'])) { foreach ($_POST['permission'] as $perm => $groups) { foreach ($groups as $grp => $d) { PermissionObject::addPermission($grp, $perm); } } } Notification::statusNotify(t("configuration enregistrée"), Notification::STATUS_SUCCESS); } $defined_permissions = PermissionObject::loadAllPermissions(); $df = array(); foreach ($defined_permissions as $p) { if (!isset($df[$p->pid])) { $df[$p->pid] = array(); } $df[$p->pid][$p->gid] = 1; } $p = new PermissionsManager(); $permissions = $p->scanForPermission(); $groups = GroupObject::loadAll(); $table = array(); $hcol = array(""); $hrow = array(); foreach ($permissions as $u => $t) { $hrow[] = $t; $row = array(); foreach ($groups as $gd => $g) { if ($u == 0) { $hcol[] = $g->label; } $pm = new PermissionObject(); $pm->loadByName($t); $tlabel = "permission[" . $g->gid . "][" . $pm->pid . "]"; if (isset($df[$pm->pid][$g->gid])) { $row[] = "<input type='checkbox' name='{$tlabel}' id='{$tlabel}' checked='checked'/>"; } else { $row[] = "<input type='checkbox' name='{$tlabel}' id='{$tlabel}' />"; } } $table[] = $row; } $theme = new Theme(); $theme->set_title(t("Permissions déclarées")); $table = Themed::tabling($table, $hcol, $hrow); $theme->add_to_body("<form method='POST' action=''>{$table} <input type='submit' name='save-permissions' value='" . t("Enregistrer") . "'/></form>"); $theme->process_theme(Theme::STRUCT_ADMIN); }