/**
  * Show profile form
  *
  * @param $items_id integer id of the profile
  * @param $target value url of target
  *
  * @return nothing
  **/
 function showForm($profiles_id = 0, $openform = TRUE, $closeform = TRUE)
 {
     echo "<div class='firstbloc'>";
     if (($canedit = Session::haveRightsOr(self::$rightname, array(CREATE, UPDATE, PURGE))) && $openform) {
         $profile = new Profile();
         echo "<form method='post' action='" . $profile->getFormURL() . "'>";
     }
     $profile = new Profile();
     $profile->getFromDB($profiles_id);
     if ($profile->getField('interface') == 'central') {
         $rights = $this->getAllRights();
         $profile->displayRightsChoiceMatrix($rights, array('canedit' => $canedit, 'default_class' => 'tab_bg_2', 'title' => __('General')));
     }
     echo "<table class='tab_cadre_fixehov'>";
     echo "<tr class='tab_bg_1'><th colspan='4'>" . __('Helpdesk') . "</th></tr>\n";
     $effective_rights = ProfileRight::getProfileRights($profiles_id, array('plugin_racks_open_ticket'));
     echo "<tr class='tab_bg_2'>";
     echo "<td width='20%'>" . __('Associable items to a ticket') . "</td>";
     echo "<td colspan='5'>";
     Html::showCheckbox(array('name' => '_plugin_racks_open_ticket', 'checked' => $effective_rights['plugin_racks_open_ticket']));
     echo "</td></tr>\n";
     echo "</table>";
     if ($canedit && $closeform) {
         echo "<div class='center'>";
         echo Html::hidden('id', array('value' => $profiles_id));
         echo Html::submit(_sx('button', 'Save'), array('name' => 'update'));
         echo "</div>\n";
         Html::closeForm();
     }
     echo "</div>";
 }
Exemplo n.º 2
0
function plugin_pdf_MassiveActionsProcess($data)
{
    switch ($data["action"]) {
        case "plugin_pdf_DoIt":
            foreach ($data['item'] as $key => $val) {
                if ($val) {
                    $tab_id[] = $key;
                }
            }
            $_SESSION["plugin_pdf"]["type"] = $data["itemtype"];
            $_SESSION["plugin_pdf"]["tab_id"] = serialize($tab_id);
            echo "<script type='text/javascript'>\n               location.href='../plugins/pdf/front/export.massive.php'</script>";
            break;
        case "plugin_pdf_allow":
            $profglpi = new Profile();
            $prof = new PluginPdfProfile();
            foreach ($data['item'] as $key => $val) {
                if ($profglpi->getFromDB($key) && $profglpi->fields['interface'] != 'helpdesk') {
                    if ($prof->getFromDB($key)) {
                        $prof->update(array('id' => $key, 'use' => $data['use']));
                    } else {
                        if ($data['use']) {
                            $prof->add(array('id' => $key, 'use' => $data['use']));
                        }
                    }
                }
            }
            break;
    }
}
Exemplo n.º 3
0
 /**
  * Configuration form
  **/
 function showForm($id, $options = array())
 {
     $target = $this->getFormURL();
     if (isset($options['target'])) {
         $target = $options['target'];
     }
     if (!Session::haveRight("profile", "r")) {
         return false;
     }
     $canedit = Session::haveRight("profile", "w");
     $prof = new Profile();
     if ($id) {
         $this->getFromDB($id);
         $prof->getFromDB($id);
     }
     echo "<form action='" . $target . "' method='post'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='2' class='center b'>" . sprintf(_('%1$s %2$s'), 'gestion Vip :', Dropdown::getDropdownName("glpi_groups", $this->fields["id"]));
     echo "</th></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>Groupe Vip</td><td>";
     Dropdown::showYesNo("isvip", $this->fields["isvip"]);
     echo "</td></tr>";
     if ($canedit) {
         echo "<tr class='tab_bg_2'>";
         echo "<td class='center' colspan='2'>";
         echo "<input type='hidden' name='id' value={$id}>";
         echo "<input type='submit' name='update_vip_group' value='Mettre à jour' class='submit'>";
         echo "</td></tr>";
     }
     echo "</table>";
     Html::closeForm();
 }
Exemplo n.º 4
0
 /**
  * profiles modification
  **/
 function showForm($id, $options = array())
 {
     $target = $this->getFormURL();
     if (isset($options['target'])) {
         $target = $options['target'];
     }
     if (!Session::haveRight("profile", "r")) {
         return false;
     }
     $canedit = Session::haveRight("profile", "w");
     $prof = new Profile();
     if ($id) {
         $this->getFromDB($id);
         $prof->getFromDB($id);
     }
     echo "<form action='" . $target . "' method='post'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='2' class='center b'>" . sprintf(__('%1$s %2$s'), __('Rights management'), $this->fields["name"]);
     echo "</th></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Use the tree', 'treeview') . "</td><td>";
     Profile::dropdownNoneReadWrite("treeview", $this->fields["treeview"], 1, 1, 0);
     echo "</td></tr>";
     if ($canedit) {
         echo "<tr class='tab_bg_1'>";
         echo "<td class='center' colspan='2'>";
         echo "<input type='hidden' name='id' value={$id}>";
         echo "<input type='submit' name='update_user_profile' value='" . _sx('button', 'Update') . "'\n                class='submit'>";
         echo "</td></tr>";
     }
     echo "</table>";
     Html::closeForm();
 }
Exemplo n.º 5
0
 function showForm($ID, $options = array())
 {
     global $LANG;
     if (!Profile::canView()) {
         return false;
     }
     $canedit = self::canUpdate();
     $profile = new Profile();
     if ($ID) {
         //$this->getFromDBByProfile($ID);
         $profile->getFromDB($ID);
     }
     if ($canedit) {
         echo "<form action='" . $profile->getFormURL() . "' method='post'>";
     }
     $rights = $this->getAllRights();
     $profile->displayRightsChoiceMatrix($rights, array('canedit' => $canedit, 'default_class' => 'tab_bg_2'));
     if ($canedit) {
         echo "<div class='center'>";
         echo "<input type='hidden' name='id' value=" . $ID . ">";
         echo "<input type='submit' name='update' value=\"" . _sx('button', 'Save') . "\" class='submit'>";
         echo "</div>";
     }
     Html::closeForm();
     $this->showLegend();
 }
 /**
  * Show profile form
  *
  * @param $items_id integer id of the profile
  * @param $target value url of target
  *
  * @return nothing
  **/
 function showForm($profiles_id = 0, $openform = TRUE, $closeform = TRUE)
 {
     echo "<div class='firstbloc'>";
     if (($canedit = Session::haveRightsOr(self::$rightname, array(CREATE, UPDATE, PURGE))) && $openform) {
         $profile = new Profile();
         echo "<form method='post' action='" . $profile->getFormURL() . "'>";
     }
     $profile = new Profile();
     $profile->getFromDB($profiles_id);
     $rights = array(array('itemtype' => 'PluginAddressingAddressing', 'label' => __('Generate reports', 'addressing'), 'field' => 'plugin_addressing'));
     $profile->displayRightsChoiceMatrix($rights, array('canedit' => $canedit, 'default_class' => 'tab_bg_2', 'title' => __('General')));
     echo "<table class='tab_cadre_fixehov'>";
     $effective_rights = ProfileRight::getProfileRights($profiles_id, array('plugin_addressing_use_ping_in_equipment'));
     echo "<tr class='tab_bg_2'>";
     echo "<td width='20%'>" . __('Use ping on equipment form', 'addressing') . "</td>";
     echo "<td colspan='5'>";
     Html::showCheckbox(array('name' => '_plugin_addressing_use_ping_in_equipment[1_0]', 'checked' => $effective_rights['plugin_addressing_use_ping_in_equipment']));
     echo "</td></tr>\n";
     echo "</table>";
     if ($canedit && $closeform) {
         echo "<div class='center'>";
         echo Html::hidden('id', array('value' => $profiles_id));
         echo Html::submit(_sx('button', 'Save'), array('name' => 'update'));
         echo "</div>\n";
         Html::closeForm();
     }
     echo "</div>";
 }
Exemplo n.º 7
0
    function showForm($ID, $options = array())
    {
        global $LANG;
        $target = $this->getFormURL();
        if (isset($options['target'])) {
            $target = $options['target'];
        }
        if (!Session::haveRight("profile", "r")) {
            return false;
        }
        $profil = new Profile();
        if ($ID) {
            $this->getFromDB($ID);
            $profil->getFromDB($ID);
        }
        ?>
		<form action='<?php 
        echo $target;
        ?>
' method='post'>
			<table class='tab_cadre_fixe'>
				<tr>
					<th colspan='2' class='center b'><?php 
        echo $LANG['plugin_ticketmail']['profile'][0] . " " . $profil->fields["name"];
        ?>
</th>
				</tr>
				<tr class='tab_bg_2'>
					<td><?php 
        echo $LANG['plugin_ticketmail']['profile'][1];
        ?>
:</td>
					<td>
						<?php 
        Dropdown::showYesNo("show_ticketmail_onglet", $this->fields["show_ticketmail_onglet"]);
        ?>
					</td>
				</tr>
				<tr class='tab_bg_1'>
					<td class='center' colspan='2'>
						<input type='hidden' name='id' value= '<?php 
        echo $ID;
        ?>
'>
						<input type='submit' name='update_user_profile' value='<?php 
        echo __s('Update');
        ?>
' class='submit'>
					</td>
				</tr>
			</table>

		<?php 
        Html::closeForm();
    }
Exemplo n.º 8
0
 function showForm($ID, $options = array())
 {
     $target = $this->getFormURL();
     if (isset($options['target'])) {
         $target = $options['target'];
     }
     if (!Session::haveRight("profile", "r")) {
         return false;
     }
     $canedit = Session::haveRight("profile", "w");
     $prof = new Profile();
     if ($ID) {
         $this->getFromDB($ID);
         $prof->getFromDB($ID);
     }
     echo "<form action='" . $target . "' method='post'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='2'>" . sprintf(__('%1$s %2$s'), __('Rights management', 'appliances'), $this->fields["name"]);
     echo "</th></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Appliances', 'appliances') . "</td><td>";
     if ($prof->fields['interface'] != 'helpdesk') {
         Profile::dropdownNoneReadWrite("appliance", $this->fields["appliance"], 1, 1, 1);
     } else {
         _e('No access');
     }
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Linkable items to a ticket - Appliances') . "</td><td>";
     if ($prof->fields['create_ticket']) {
         Dropdown::showYesNo("open_ticket", $this->fields["open_ticket"]);
     } else {
         echo Dropdown::getYesNo(0);
     }
     echo "</td></tr>";
     if ($canedit) {
         echo "<tr class='tab_bg_1'>";
         echo "<td class='center' colspan='2'>";
         echo "<input type='hidden' name='id' value='" . $ID . "'>";
         echo "<input type='submit' name='update_user_profile' value=\"" . _sx('button', 'Update') . "\"\n               class='submit'>";
         echo "</td></tr>";
     }
     echo "</table>";
     Html::closeForm();
 }
Exemplo n.º 9
0
 function showForm($profiles_id = 0, $openform = TRUE, $closeform = TRUE)
 {
     echo "<div class='firstbloc'>";
     if (($canedit = Session::haveRightsOr(self::$rightname, array(CREATE, PURGE))) && $openform) {
         $profile = new Profile();
         echo "<form method='post' action='" . $profile->getFormURL() . "'>";
     }
     $profile = new Profile();
     $profile->getFromDB($profiles_id);
     $rights = $this->getAllRights();
     $profile->displayRightsChoiceMatrix($rights, array('canedit' => $canedit, 'default_class' => 'tab_bg_2', 'title' => __('General')));
     if ($canedit && $closeform) {
         echo "<div class='center'>";
         echo Html::hidden('id', array('value' => $profiles_id));
         echo Html::submit(_sx('button', 'Save'), array('name' => 'update'));
         echo "</div>\n";
         Html::closeForm();
     }
     echo "</div>";
 }
Exemplo n.º 10
0
 function showForm($ID, $options = array())
 {
     global $DB;
     $profile = new Profile();
     if ($ID) {
         $this->getFromDB($ID);
         $profile->getFromDB($ID);
     } else {
         $this->getEmpty();
     }
     if ($canedit = self::canUpdate()) {
         $options['colspan'] = 1;
         $options['target'] = $profile->getFormURL();
         $this->fields["id"] = $ID;
         $this->showFormHeader($options);
     }
     $rights = $this->getGeneralRights();
     $profile->displayRightsChoiceMatrix($rights, array('canedit' => $canedit, 'default_class' => 'tab_bg_2'));
     if ($canedit) {
         $options['candel'] = false;
         $this->showFormButtons($options);
     }
 }
Exemplo n.º 11
0
 function showForm($ID)
 {
     global $LANG;
     if (!Session::haveRight("profile", "r")) {
         return false;
     }
     $canedit = Session::haveRight("profile", "w");
     $prof = new Profile();
     if ($ID) {
         $this->getFromDBByProfile($ID);
         $prof->getFromDB($ID);
     }
     echo "<form action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "' method='post'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<th colspan='4' align='center'><strong>" . $LANG['plugin_simcard']['profile'][0] . " " . $prof->fields["name"] . "</strong></th>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . $LANG['plugin_simcard']['profile'][1] . ":</td><td>";
     Profile::dropdownNoneReadWrite("simcard", $this->fields["simcard"], 1, 1, 1);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . $LANG['setup'][352] . " - " . $LANG['plugin_simcard']['profile'][1] . ":</td><td>";
     if ($prof->fields['create_ticket']) {
         Dropdown::showYesNo("open_ticket", $this->fields["open_ticket"]);
     } else {
         echo Dropdown::getYesNo(0);
     }
     echo "</td>";
     echo "</tr>";
     if ($canedit) {
         echo "<tr class='tab_bg_1'>";
         echo "<td align='center' colspan='2'>";
         echo "<input type='hidden' name='id' value=" . $this->getID() . ">";
         echo "<input type='submit' name='update' value=\"" . $LANG['buttons'][7] . "\" class='submit'>";
         echo "</td></tr>";
     }
     echo "</table>";
     Html::closeForm();
 }
Exemplo n.º 12
0
function plugin_barcode_MassiveActionsProcess($data)
{
    global $CFG_GLPI;
    switch ($data['action']) {
        case 'plugin_barcode_barcode':
        case 'plugin_barcode_qrcode':
            $pbConfig = new PluginBarcodeConfig();
            $pbQRcode = new PluginBarcodeQRcode();
            $itemtype = $data['itemtype'];
            $item = new $itemtype();
            $rand = mt_rand();
            $number = 0;
            $codes = array();
            if ($data['eliminate'] > 0) {
                for ($nb = 0; $nb < $data['eliminate']; $nb++) {
                    $codes[] = '';
                }
            }
            if ($data['type'] == 'QRcode') {
                foreach ($data['item'] as $key => $val) {
                    if ($val == 1) {
                        $filename = $pbQRcode->generateQRcode($itemtype, $key, $rand, $number, $data);
                        if ($filename) {
                            $codes[] = $filename;
                            $number++;
                        }
                    }
                }
            } else {
                foreach ($data['item'] as $key => $val) {
                    if ($val == 1) {
                        $item->getFromDB($key);
                        if ($item->isField('otherserial')) {
                            $codes[] = $item->getField('otherserial');
                        }
                    }
                }
            }
            if (count($codes) > 0) {
                $params['codes'] = $codes;
                $params['type'] = $data['type'];
                $params['size'] = $data['size'];
                $params['border'] = $data['border'];
                $params['orientation'] = $data['orientation'];
                $barcode = new PluginBarcodeBarcode();
                $file = $barcode->printPDF($params);
                $filePath = explode('/', $file);
                $filename = $filePath[count($filePath) - 1];
                $msg = "<a href='" . $CFG_GLPI['root_doc'] . '/plugins/barcode/front/send.php?file=' . urlencode($filename) . "'>" . __('Generated file', 'barcode') . "</a>";
                Session::addMessageAfterRedirect($msg);
                $pbQRcode->cleanQRcodefiles($rand, $number);
            }
            return true;
            break;
        case "plugin_barcode_allow":
            $profglpi = new Profile();
            $prof = new PluginBarcodeProfile();
            foreach ($data['item'] as $key => $val) {
                if ($profglpi->getFromDB($key) && $profglpi->fields['interface'] != 'helpdesk') {
                    if ($prof->getFromDB($key)) {
                        $prof->update(array('id' => $key, 'generate' => $data['generate'], 'config' => $data['config']));
                    } else {
                        if ($data['generate']) {
                            $prof->add(array('id' => $key, 'generate' => $data['generate']));
                        } else {
                            if ($data['config']) {
                                $prof->add(array('id' => $key, 'config' => $data['config']));
                            }
                        }
                    }
                }
            }
            break;
    }
}
Exemplo n.º 13
0
 /**
  * @param $prof   Profile object
  **/
 static function showForProfile(Profile $prof)
 {
     global $DB, $LANG;
     $target = Toolbox::getItemTypeFormURL(__CLASS__);
     $profiles_id = $prof->getField('id');
     $prof->check($profiles_id, 'r');
     $canedit = $prof->can($profiles_id, 'w');
     $prof = new Profile();
     if ($profiles_id) {
         $prof->getFromDB($profiles_id);
     }
     $rights = self::getAllRights(array('profiles_id' => $profiles_id));
     if ($canedit) {
         echo "<form action='" . $target . "' method='post'>";
     }
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='4' class='center b'>";
     printf(__('%1$s: %2$s'), __('Rights management by profil', 'reports'), $prof->fields["name"]);
     echo "</th></tr>";
     $plugname = array();
     foreach (searchReport() as $key => $plug) {
         $mod = $plug == 'reports' ? $key : "{$plug}_{$key}";
         echo "<tr class='tab_bg_1'>";
         if (!isset($plugname[$plug])) {
             // Retrieve the plugin name
             $function = "plugin_version_{$plug}";
             $tmp = $function();
             $plugname[$plug] = $tmp['name'];
         }
         echo "<td>" . $plugname[$plug] . "</td>";
         if (strpos($key, 'stat') === false) {
             echo "<td>" . _n('Report', 'Reports', 2) . "</td>";
         } else {
             echo "<td>" . __('Statistics') . "</td>";
         }
         echo "<td>" . $LANG["plugin_{$plug}"][$key] . "</td><td>";
         if (isStat($key) && $prof->getField('statistic') == 1 || !isStat($key) && $prof->getField('reports') == 'r') {
             Profile::dropdownNoneReadWrite($mod, isset($rights[$mod]) ? $rights[$mod] : '', 1, 1, 0);
         } else {
             // Can't access because missing right from GLPI core
             // Profile::dropdownNoneReadWrite($mod,'',1,0,0);
             echo "<input type='hidden' name='{$mod}' value='NULL'>" . __('No Access');
             echo isStat($key) ? " **" : " *";
         }
         echo "</td></tr>";
     }
     if ($prof->getField('statistic') != 1 || $prof->getField('reports') != 'r') {
         echo "<tr class='b tab_bg_4'><td colspan='4'>";
         if ($prof->getField('reports') != 'r') {
             echo '*  ' . __('No right on Tools / Reports', 'reports') . '.<br>';
         }
         if ($prof->getField('statistic') != 1) {
             echo '** ' . __('No right on Assistance / Statistics', 'reports') . '.';
         }
         echo "</td></tr>\n";
     }
     if ($canedit) {
         echo "<tr class='tab_bg_1'>";
         echo "<td class='center' colspan='4'>";
         echo "<input type='hidden' name='profiles_id' value={$profiles_id}>";
         echo "<input type='submit' name='update_user_profile' value='" . _sx('button', 'Update') . "'\n                class='submit'>";
         echo "</td></tr>\n";
         echo "</table>";
         Html::closeForm();
     } else {
         echo "</table>";
     }
 }
Exemplo n.º 14
0
 function showForm($ID, $options = array())
 {
     if (!Session::haveRight("profile", "r")) {
         return false;
     }
     //      $target = $this->getFormURL();
     //      if (isset($options['target'])) {
     //        $target = $options['target'];
     //      }
     $prof = new Profile();
     if ($ID) {
         $this->getFromDBByProfile($ID);
         $prof->getFromDB($ID);
     }
     $this->showFormHeader($options);
     //      echo "<form action='".$target."' method='post'>";
     //      echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_2'>";
     echo "<th colspan='4'>" . sprintf(__('%1$s - %2$s'), __('Rights management', 'addressing'), $prof->fields["name"]) . "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Generate reports', 'addressing') . "</td><td>";
     Profile::dropdownNoneReadWrite("addressing", $this->fields["addressing"], 1, 1, 1);
     echo "</td>";
     echo "<td>" . __('Use ping on equipment form', 'addressing') . "</td><td>";
     Dropdown::showYesNo("use_ping_in_equipment", $this->fields["use_ping_in_equipment"]);
     echo "</td>";
     echo "</tr>";
     echo "<input type='hidden' name='id' value=" . $this->fields["id"] . ">";
     $options['candel'] = false;
     $this->showFormButtons($options);
 }
Exemplo n.º 15
0
 function showForm($ID, $options = array())
 {
     global $LANG;
     if (!Session::haveRight("profile", "r")) {
         return false;
     }
     $prof = new Profile();
     if ($ID) {
         $this->getFromDBByProfile($ID);
         $prof->getFromDB($ID);
     }
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_2'>";
     echo "<th colspan='4'>" . $LANG['plugin_mreporting']["name"] . " " . $prof->fields["name"] . "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __("Display report") . ":</td><td>";
     Profile::dropdownNoneReadWrite("reports", $this->fields["reports"], 1, 1, 0);
     echo "</td>";
     echo "<td>" . __("Setup") . ":</td><td>";
     Profile::dropdownNoneReadWrite("config", $this->fields["config"], 1, 0, 1);
     echo "</td>";
     echo "</tr>";
     echo "<input type='hidden' name='id' value=" . $this->fields["id"] . ">";
     $options['candel'] = false;
     $this->showFormButtons($options);
 }
 /**
  * Init profiles during installation :
  * - add rights in profile table for the current user's profile
  * - current profile has all rights on the plugin
  */
 static function initProfile()
 {
     $pfProfile = new self();
     $profile = new Profile();
     $a_rights = $pfProfile->getAllRights();
     foreach ($a_rights as $data) {
         if (countElementsInTable("glpi_profilerights", "`name` = '" . $data['field'] . "'") == 0) {
             ProfileRight::addProfileRights(array($data['field']));
             $_SESSION['glpiactiveprofile'][$data['field']] = 0;
         }
     }
     // Add all rights to current profile of the user
     if (isset($_SESSION['glpiactiveprofile'])) {
         $dataprofile = array();
         $dataprofile['id'] = $_SESSION['glpiactiveprofile']['id'];
         $profile->getFromDB($_SESSION['glpiactiveprofile']['id']);
         foreach ($a_rights as $info) {
             if (is_array($info) && (!empty($info['itemtype']) || !empty($info['rights'])) && !empty($info['label']) && !empty($info['field'])) {
                 if (isset($info['rights'])) {
                     $rights = $info['rights'];
                 } else {
                     $rights = $profile->getRightsFor($info['itemtype']);
                 }
                 foreach ($rights as $right => $label) {
                     $dataprofile['_' . $info['field']][$right] = 1;
                     $_SESSION['glpiactiveprofile'][$data['field']] = $right;
                 }
             }
         }
         $profile->update($dataprofile);
     }
 }
Exemplo n.º 17
0
 function showForm($ID, $options = array())
 {
     if (!Session::haveRight("profile", "r")) {
         return false;
     }
     $prof = new Profile();
     if ($ID) {
         $this->getFromDBByProfile($ID);
         $prof->getFromDB($ID);
     }
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_2'>";
     echo "<th colspan='4'>" . sprintf(__('%1$s - %2$s'), __('Rights management', 'positions'), $prof->fields["name"]) . "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . PluginPositionsPosition::getTypeName() . ":</td><td>";
     if ($prof->fields['interface'] != 'helpdesk') {
         Profile::dropdownNoneReadWrite("positions", $this->fields["positions"], 1, 1, 1);
     } else {
         Profile::dropdownNoneReadWrite("positions", $this->fields["positions"], 1, 1, 0);
     }
     echo "</td>";
     echo "<td></td>";
     echo "</tr>";
     echo "<input type='hidden' name='id' value=" . $this->fields["id"] . ">";
     $options['candel'] = false;
     $this->showFormButtons($options);
 }
Exemplo n.º 18
0
 function showForm($ID, $options = array())
 {
     if (!Session::haveRight("profile", "r")) {
         return false;
     }
     $prof = new Profile();
     if ($ID) {
         $this->getFromDBByProfile($ID);
         $prof->getFromDB($ID);
     }
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_2'>";
     echo "<th colspan='4' class='center b'>" . sprintf(__('%1$s - %2$s'), __('Rights management', 'racks'), $prof->fields["name"]) . "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . _n('Rack enclosure', 'Rack enclosures', 2, 'racks') . "</td><td>";
     Profile::dropdownNoneReadWrite("racks", $this->fields["racks"], 1, 1, 1);
     echo "</td>";
     echo "<td>" . __('Equipments models specifications', 'racks') . "</td><td>";
     Profile::dropdownNoneReadWrite("model", $this->fields["model"], 1, 1, 1);
     echo "</td>";
     echo "</tr>";
     echo "<input type='hidden' name='id' value=" . $this->fields["id"] . ">";
     $options['candel'] = false;
     $this->showFormButtons($options);
 }
Exemplo n.º 19
0
         if ($config_object->getFromDB(1)) {
             $current_config = $config_object->fields;
         }
     }
 }
 if (count($current_config) > 0) {
     $CFG_GLPI = array_merge($CFG_GLPI, $current_config);
     if (isset($CFG_GLPI['priority_matrix'])) {
         $CFG_GLPI['priority_matrix'] = importArrayFromDB($CFG_GLPI['priority_matrix'], true);
     }
     if (isset($CFG_GLPI['lock_item_list'])) {
         $CFG_GLPI['lock_item_list'] = importArrayFromDB($CFG_GLPI['lock_item_list']);
     }
     if (isset($CFG_GLPI['lock_lockprofile_id']) && $CFG_GLPI["lock_use_lock_item"] && $CFG_GLPI["lock_lockprofile_id"] > 0 && !isset($CFG_GLPI['lock_lockprofile'])) {
         $prof = new Profile();
         $prof->getFromDB($CFG_GLPI["lock_lockprofile_id"]);
         $prof->cleanProfile();
         $CFG_GLPI['lock_lockprofile'] = $prof->fields;
     }
     // Path for icon of document type (web mode only)
     if (isset($CFG_GLPI["root_doc"])) {
         $CFG_GLPI["typedoc_icon_dir"] = $CFG_GLPI["root_doc"] . "/pics/icones";
     }
 } else {
     echo "Error accessing config table";
     exit;
 }
 if (isCommandLine() && isset($_SERVER['argv'])) {
     $key = array_search('--debug', $_SERVER['argv']);
     if ($key) {
         $_SESSION['glpi_use_mode'] = Session::DEBUG_MODE;
 function showForm($ID, $options = array())
 {
     global $LANG, $DB;
     if (!Session::haveRight("profile", READ)) {
         return false;
     }
     $target = $this->getFormURL();
     if (isset($options['target'])) {
         $target = $options['target'];
     }
     // TODO : Should be useless if we can use this->showFormHeader() and $this->ShowFormButtons()
     if (!Session::haveRight("profile", UPDATE)) {
         return false;
     }
     $canedit = Session::haveRight("profile", UPDATE);
     $prof = new Profile();
     if ($ID) {
         $this->getFromDB($ID);
         $prof->getFromDB($ID);
     }
     $itemtype = '';
     $query = "SELECT *\n                FROM `glpi_plugin_customfields_fields`\n                WHERE `restricted` = 1\n                ORDER BY `itemtype`, `sort_order`;";
     if (($result = $DB->query($query)) && $DB->numrows($result)) {
         echo "<form action='" . $target . "' method='post'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_2'>";
         echo "<th colspan='4'>" . __('Title', 'customfields') . " " . $prof->fields["name"] . "</th>";
         echo "</tr>";
         while ($data = $DB->fetch_array($result)) {
             if ($data['itemtype'] != $itemtype) {
                 $itemtype = $data['itemtype'];
                 echo "<tr><th colspan='3'>" . __($itemtype) . "</th></tr>";
             }
             $profile_field = $data['itemtype'] . '_' . $data['system_name'];
             echo "<tr class='tab_bg_2'><td>" . $data['label'] . " (" . __($data['data_type'], 'customfields') . "):</td><td>";
             if ($data['data_type'] == 'sectionhead') {
                 Dropdown::showYesNo($profile_field, $this->fields[$profile_field], 1, 1, 1);
             } else {
                 Profile::dropdownNoneReadWrite($profile_field, $this->fields[$profile_field], 1, 1, 1);
             }
             echo "</td></tr>";
         }
         if ($canedit) {
             echo "<tr class='tab_bg_1'>";
             echo "<td class='center' colspan='2'>";
             echo "<input type='hidden' name='id' value={$ID}>";
             echo "<input type='submit' name='update_user_profile' value=\"" . _sx('button', 'Update') . "\" class='submit'>";
             echo "</td></tr>";
         }
         echo "</table>";
         $options['candel'] = false;
         Html::closeForm();
     } else {
         echo __('There is no restricted field', 'customfields');
     }
 }
Exemplo n.º 21
0
 public function showForm($ID, $options = array())
 {
     if (!Session::haveRight("profile", "r")) {
         return false;
     }
     $prof = new Profile();
     if ($ID) {
         $this->getFromDBByProfile($ID);
         $prof->getFromDB($ID);
     }
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_2'>";
     echo "<th colspan='4'>" . sprintf(__('%1$s - %2$s'), __('Rights management', 'accounts'), $prof->fields["name"]) . "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . PluginAccountsAccount::getTypeName(2) . ":</td><td>";
     Profile::dropdownNoneReadWrite("accounts", $this->fields["accounts"], 1, 1, 1);
     echo "</td>";
     echo "<td>" . __('See accounts of my groups', 'accounts') . ":</td><td>";
     Profile::dropdownNoneReadWrite("my_groups", $this->fields["my_groups"], 1, 1, 0);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('See all accounts', 'accounts') . ":</td><td>";
     Profile::dropdownNoneReadWrite("all_users", $this->fields["all_users"], 1, 1, 0);
     echo "</td>";
     echo "<td>" . __('Associable items to a ticket') . " - " . PluginAccountsAccount::getTypeName(2) . "</td><td>";
     if ($prof->fields['create_ticket']) {
         Dropdown::showYesNo("open_ticket", $this->fields["open_ticket"]);
     } else {
         echo Dropdown::getYesNo(0);
     }
     echo "</td>";
     echo "</tr>";
     echo "<input type='hidden' name='id' value=" . $this->fields["id"] . ">";
     $options['candel'] = false;
     $this->showFormButtons($options);
 }
Exemplo n.º 22
0
/**
 * Update helpdesk_item_type in a profile if a ProfileRight changes or is created
 * 
 * Add or remove simcard item type to match the status of "associable to tickets" in simcard's right
 * 
 * @since 1.4.1
 */
function plugin_simcard_profileRightUpdate($item)
{
    if ($item->fields['name'] == PluginSimcardProfile::RIGHT_SIMCARD_SIMCARD) {
        $profile = new Profile();
        $profile->getFromDB($item->fields['profiles_id']);
        $helpdeskItemTypes = json_decode($profile->fields['helpdesk_item_type'], true);
        $index = array_search('PluginSimcardSimcard', $helpdeskItemTypes);
        if ($item->fields['rights'] & PluginSimcardProfile::SIMCARD_ASSOCIATE_TICKET) {
            if ($index === false) {
                $helpdeskItemTypes[] = 'PluginSimcardSimcard';
                if ($_SESSION['glpiactiveprofile']['id'] == $profile->fields['id']) {
                    $_SESSION['glpiactiveprofile']['helpdesk_item_type'][] = 'PluginSimcardSimcard';
                }
            }
        } else {
            if ($index !== false) {
                unset($helpdeskItemTypes[$index]);
                if ($_SESSION['glpiactiveprofile']['id'] == $profile->fields['id']) {
                    // Just in case this is not the same index in the session vars
                    $index = array_search('PluginSimcardSimcard', $_SESSION['glpiactiveprofile']['helpdesk_item_type']);
                    if ($index !== false) {
                        unset($_SESSION['glpiactiveprofile']['helpdesk_item_type'][$index]);
                    }
                }
            }
        }
        $tmp = array('id' => $profile->fields['id'], 'helpdesk_item_type' => json_encode($helpdeskItemTypes));
        $profile->update($tmp, false);
    }
}
Exemplo n.º 23
0
/**
 * Change active profile to the $ID one. Update glpiactiveprofile session variable.
 *
 * @param $ID : ID of the new profile
 *
 * @return Nothing
**/
function changeProfile($ID)
{
    if (isset($_SESSION['glpiprofiles'][$ID]) && count($_SESSION['glpiprofiles'][$ID]['entities'])) {
        $profile = new Profile();
        if ($profile->getFromDB($ID)) {
            $profile->cleanProfile();
            $data = $profile->fields;
            $data['entities'] = $_SESSION['glpiprofiles'][$ID]['entities'];
            $_SESSION['glpiactiveprofile'] = $data;
            $_SESSION['glpiactiveentities'] = array();
            Search::resetSaveSearch();
            $active_entity_done = false;
            // Try to load default entity if it is a root entity
            foreach ($data['entities'] as $key => $val) {
                if ($val['id'] == $_SESSION["glpidefault_entity"]) {
                    if (changeActiveEntities($val['id'], $val['is_recursive'])) {
                        $active_entity_done = true;
                    }
                }
            }
            if (!$active_entity_done) {
                // Try to load default entity
                if (!changeActiveEntities($_SESSION["glpidefault_entity"], true)) {
                    // Load all entities
                    changeActiveEntities("all");
                }
            }
            doHook("change_profile");
        }
    }
    // Clean specific datas
    if (isset($_SESSION['glpi_faqcategories'])) {
        unset($_SESSION['glpi_faqcategories']);
    }
}
Exemplo n.º 24
0
 /**
  * profiles modification
  **/
 function showForm($ID, $options = array())
 {
     $target = $this->getFormURL();
     if (isset($options['target'])) {
         $target = $options['target'];
     }
     if (!Session::haveRight("profile", "r")) {
         return false;
     }
     $prof = new Profile();
     if ($ID) {
         $this->getFromDBByProfile($ID);
         $prof->getFromDB($ID);
     }
     echo "<form action='" . $target . "' method='post'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_2'>";
     echo "<th colspan='4'>" . sprintf(__('%1$s - %2$s'), __('Rights management', 'webapplications'), $prof->fields["name"]) . "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . PluginWebapplicationsWebapplication::getTypeName(2) . " : </td><td>";
     if ($prof->fields['interface'] != 'helpdesk') {
         Profile::dropdownNoneReadWrite("webapplications", $this->fields["webapplications"], 1, 1, 1);
     } else {
         _e('No access');
         // No access;
     }
     echo "</td>";
     echo "<td>" . __('Associable items to a ticket') . " - " . PluginWebapplicationsWebapplication::getTypeName(2) . "</td><td>";
     if ($prof->fields['create_ticket']) {
         Dropdown::showYesNo("open_ticket", $this->fields["open_ticket"]);
     } else {
         echo Dropdown::getYesNo(0);
     }
     echo "</td>";
     echo "</tr>";
     echo "<input type='hidden' name='profiles_id' value=" . $this->fields["profiles_id"] . ">";
     echo "<input type='hidden' name='id' value=" . $this->fields["id"] . ">";
     $options['candel'] = false;
     $this->showFormButtons($options);
 }
Exemplo n.º 25
0
 function showForm($ID, $options = array())
 {
     if (!Session::haveRight("profile", "r")) {
         return false;
     }
     $prof = new Profile();
     if ($ID) {
         $this->getFromDBByProfile($ID);
         $prof->getFromDB($ID);
     }
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_2'>";
     echo "<th colspan='2'>" . sprintf(__('%1$s - %2$s'), __('Rights management', 'immobilizationsheets'), $prof->fields["name"]) . "</th>";
     echo "<td>" . __('Generate the immobilization sheet', 'immobilizationsheets') . ":</td><td>";
     Profile::dropdownNoneReadWrite("immobilizationsheets", $this->fields["immobilizationsheets"], 1, 1, 0);
     echo "</td>";
     echo "</tr>";
     echo "<input type='hidden' name='id' value=" . $this->fields["id"] . ">";
     $options['candel'] = false;
     $this->showFormButtons($options);
 }
Exemplo n.º 26
0
 function showForm($ID, $options = array())
 {
     if (!Session::haveRight("profile", "r")) {
         return false;
     }
     $prof = new Profile();
     if ($ID) {
         $this->getFromDBByProfile($ID);
         $prof->getFromDB($ID);
     }
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_2'>";
     echo "<th colspan='2' class='center b'>" . self::getTypeName() . " " . $prof->fields["name"] . "</th>";
     echo "<td>" . PluginShellcommandsShellcommand::getTypeName(2) . ":</td><td>";
     Profile::dropdownNoneReadWrite("shellcommands", $this->fields["shellcommands"], 1, 1, 1);
     echo "</td>";
     echo "</tr>";
     echo "<input type='hidden' name='id' value=" . $this->fields["id"] . ">";
     $options['candel'] = false;
     $this->showFormButtons($options);
 }
Exemplo n.º 27
0
 /**
  * Add a message on update action
  **/
 function addMessageOnUpdateAction()
 {
     $link = $this->getFormURL();
     if (!isset($link)) {
         return;
     }
     $addMessAfterRedirect = false;
     if (isset($this->input['_update'])) {
         $addMessAfterRedirect = true;
     }
     if (isset($this->input['_no_message']) || !$this->auto_message_on_action) {
         $addMessAfterRedirect = false;
     }
     if ($addMessAfterRedirect) {
         $profile = new Profile();
         $profile->getFromDB($this->fields['profiles_id']);
         // Do not display quotes
         if (isset($profile->fields['name'])) {
             $profile->fields['name'] = stripslashes($profile->fields['name']);
         } else {
             $profile->fields['name'] = $profile->getTypeName() . " : " . __('ID') . " " . $profile->fields['id'];
         }
         Session::addMessageAfterRedirect(__('Item successfully updated') . "&nbsp;: " . (isset($this->input['_no_message_link']) ? $profile->getNameID() : $profile->getLink()));
     }
 }
Exemplo n.º 28
0
 function showForm($ID, $options = array())
 {
     global $LANG;
     $target = $this->getFormURL();
     if (isset($options['target'])) {
         $target = $options['target'];
     }
     if (!Session::haveRight("profile", "r")) {
         return false;
     }
     $prof = new Profile();
     if ($ID) {
         $this->getFromDBByProfile($ID);
         $prof->getFromDB($ID);
     }
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<th colspan='2'>" . $LANG['plugin_mobile']['profile'][0] . " " . $prof->fields["name"] . "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['plugin_mobile']['profile'][1] . " : </td><td>";
     if ($prof->fields['interface'] != 'helpdesk') {
         Profile::dropdownNoneReadWrite("mobile_user", $this->fields["mobile_user"], 1, 1, 1);
     } else {
         echo $LANG['profiles'][12];
         // No access;
     }
     echo "</td>";
     echo "</tr>";
     echo "<input type='hidden' name='id' value=" . $this->fields["id"] . ">";
     $options['candel'] = false;
     $this->showFormButtons($options);
 }
Exemplo n.º 29
0
 static function install(Migration $migration)
 {
     global $DB;
     $profileRight = new ProfileRight();
     $profile = new Profile();
     //Update needed
     if (TableExists('glpi_plugin_genericobject_profiles')) {
         foreach (getAllDatasFromTable('glpi_plugin_genericobject_profiles') as $right) {
             if (preg_match("/PluginGenericobject(.*)/", $right['itemtype'], $results)) {
                 $newrightname = 'plugin_genericobject_' . strtolower($results[1]) . 's';
                 if (!countElementsInTable('glpi_profilerights', "`profiles_id`='" . $right['profiles_id'] . "' \n                                           AND `name`='{$newrightname}'")) {
                     switch ($right['right']) {
                         case NULL:
                         case '':
                             $rightvalue = 0;
                             break;
                         case 'r':
                             $rightvalue = READ;
                             break;
                         case 'w':
                             $rightvalue = ALLSTANDARDRIGHT;
                             break;
                     }
                     $profileRight->add(array('profiles_id' => $right['profiles_id'], 'name' => $newrightname, 'rights' => $rightvalue));
                     if (!countElementsInTable('glpi_profilerights', "`profiles_id`='" . $right['profiles_id'] . "' \n                                              AND `name`='plugin_genericobject_types'")) {
                         $profileRight->add(array('profiles_id' => $right['profiles_id'], 'name' => 'plugin_genericobject_types', 'rights' => 23));
                     }
                 }
                 if ($right['open_ticket']) {
                     $profile->getFromDB($right['profiles_id']);
                     $helpdesk_item_types = json_decode($profile->fields['helpdesk_item_type'], true);
                     if (is_array($helpdesk_item_types)) {
                         if (!in_array($right['itemtype'], $helpdesk_item_types)) {
                             $helpdesk_item_types[] = $right['itemtype'];
                         }
                     } else {
                         $helpdesk_item_types = array($right['itemtype']);
                     }
                     $tmp['id'] = $profile->getID();
                     $tmp['helpdesk_item_type'] = json_encode($helpdesk_item_types);
                     $profile->update($tmp);
                 }
             }
         }
         //$migration->dropTable('glpi_plugin_genericobject_profiles');
     }
     if (!countElementsInTable('glpi_profilerights', "`name` LIKE '%genericobject%'")) {
         self::createFirstAccess();
     }
 }
Exemplo n.º 30
0
 function showForm($ID, $options = array())
 {
     if (!Session::haveRight("profile", "r")) {
         return false;
     }
     $prof = new Profile();
     if ($ID) {
         $this->getFromDBByProfile($ID);
         $prof->getFromDB($ID);
     }
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_2'>";
     echo "<th colspan='4' class='center b'>" . sprintf(__('%1$s - %2$s'), __('Rights management', 'domains'), $prof->fields["name"]) . "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . PluginDomainsDomain::getTypeName(2) . "</td><td>";
     if ($prof->fields['interface'] != 'helpdesk') {
         Profile::dropdownNoneReadWrite("domains", $this->fields["domains"], 1, 1, 1);
     } else {
         echo Dropdown::getYesNo(0);
     }
     echo "</td>";
     echo "<td>" . __('Associable items to a ticket') . " - " . PluginDomainsDomain::getTypeName(2) . "</td><td>";
     if ($prof->fields['create_ticket']) {
         Dropdown::showYesNo("open_ticket", $this->fields["open_ticket"]);
     } else {
         echo Dropdown::getYesNo(0);
     }
     echo "</td>";
     echo "</tr>";
     echo "<input type='hidden' name='id' value=" . $this->fields["id"] . ">";
     $options['candel'] = false;
     $this->showFormButtons($options);
 }