4 Copyright (C) 2014 AUF -- www.auf.org
6 if (!defined('GLPI_ROOT')) {
7 die("Sorry. You can't access directly to this file");
10 class PluginAufProfile
extends CommonDBTM
{
12 static function canCreate() {
13 if (isset($_SESSION["glpi_plugin_auf_profile"])) {
14 return ($_SESSION["glpi_plugin_auf_profile"]['auf'] == 'w');
19 static function canView() {
20 if (isset($_SESSION["glpi_plugin_auf_profile"])) {
21 return ($_SESSION["glpi_plugin_auf_profile"]['auf'] == 'w'
22 ||
$_SESSION["glpi_plugin_auf_profile"]['auf'] == 'r');
27 static function createAdminAccess($ID) {
29 // si le profile n'existent pas déjà dans la table profile de mon plugin
30 if (!$myProf->getFromDB($ID)) {
31 // ajouter un champ dans la table comprenant l'ID du profil de la
32 // personne connectée et le droit d'écriture
33 $myProf->add(array('id' => $ID, 'right' => 'w'));
37 function createAccess($ID) {
38 $this->add(array('id' => $ID));
41 static function changeProfile() {
43 if ($prof->getFromDB($_SESSION['glpiactiveprofile']['id'])) {
44 $_SESSION["glpi_plugin_auf_profile"] = $prof->fields
;
46 unset($_SESSION["glpi_plugin_auf_profile"]);
50 function showForm($id, $options=array()) {
51 $target = $this->getFormURL();
52 if (isset($options['target'])) {
53 $target = $options['target'];
56 if (!Session
::haveRight("profile", "r")) {
60 $canedit = Session
::haveRight("profile", "w");
61 $prof = new Profile();
63 $this->getFromDB($id);
64 $prof->getFromDB($id);
67 echo "<form action='".$target."' method='post'>";
68 echo "<table class='tab_cadre_fixe'>";
69 echo "<tr><th colspan='2' class='center b'>".sprintf(__('%1$s %2$s'),
70 ('Gestion des droits -'), Dropdown
::getDropdownName("glpi_profiles",
71 $this->fields
["id"]));
74 echo "<tr class='tab_bg_2'>";
75 echo "<td>Infos AUF</td><td>";
76 Profile
::dropdownNoneReadWrite("right", $this->fields
["right"], 1, 1, 1);
80 echo "<tr class='tab_bg_1'>";
81 echo "<td class='center' colspan='2'>";
82 echo "<input type='hidden' name='id' value=$id>";
83 echo "<input type='submit' name='update_user_profile' value='Mettre à jour' class='submit'>";
90 function getTabNameForItem(CommonGLPI
$item, $withtemplate=0) {
91 if ($item->getType() == 'Profile') {
97 static function displayTabContentForItem(CommonGLPI
$item, $tabnum=1, $withtemplate=0) {
98 if ($item->getType() == 'Profile') {
101 // si le profil n'existe pas dans la base, je l'ajoute
102 if (!$prof->GetfromDB($ID)) {
103 $prof->createAccess($ID);
105 $prof->showForm($ID);