showPrivatePublicSwitch() static public method

Private / Public switch for items which may be assign to a user and/or an entity
static public showPrivatePublicSwitch ( $is_private, $entity, $is_recursive )
$is_private default is private ?
$entity working entity ID
$is_recursive is the item recursive ?
Exemplo n.º 1
0
 /**
  * Print the bookmark form
  *
  * @param $ID        integer ID of the item
  * @param $options   array
  *     - target for the Form
  *     - type bookmark type when adding a new bookmark
  *     - url when adding a new bookmark
  *     - itemtype when adding a new bookmark
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     $ID = $this->fields['id'];
     // Only an edit form : always check w right
     if ($ID > 0) {
         $this->check($ID, UPDATE);
     } else {
         $this->check(-1, CREATE);
     }
     echo '<br>';
     echo "<form method='post' name='form_save_query' action='" . $_SERVER['PHP_SELF'] . "'>";
     echo "<div class='center'>";
     if (isset($options['itemtype'])) {
         echo "<input type='hidden' name='itemtype' value='" . $options['itemtype'] . "'>";
     }
     if (isset($options['type']) && $options['type'] != 0) {
         echo "<input type='hidden' name='type' value='" . $options['type'] . "'>";
     }
     if (isset($options['url'])) {
         echo "<input type='hidden' name='url' value='" . rawurlencode($options['url']) . "'>";
     }
     echo "<table class='tab_cadre' width='" . self::WIDTH . "px'>";
     echo "<tr><th>&nbsp;</th><th>";
     if ($ID > 0) {
         //TRANS: %1$s is the Itemtype name and $2$d the ID of the item
         printf(__('%1$s - ID %2$d'), $this->getTypeName(1), $ID);
     } else {
         _e('New item');
     }
     echo "</th></tr>";
     echo "<tr><td class='tab_bg_1'>" . __('Name') . "</td>";
     echo "<td class='tab_bg_1'>";
     Html::autocompletionTextField($this, "name", array('user' => $this->fields["users_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'><td>" . __('Type') . "</td>";
     echo "<td>";
     if (static::canCreate()) {
         Dropdown::showPrivatePublicSwitch($this->fields["is_private"], $this->fields["entities_id"], $this->fields["is_recursive"]);
     } else {
         if ($this->fields["is_private"]) {
             _e('Private');
         } else {
             _e('Public');
         }
     }
     echo "</td></tr>";
     if ($ID <= 0) {
         // add
         echo "<tr>";
         echo "<td class='tab_bg_2 top' colspan='2'>";
         echo "<input type='hidden' name='users_id' value='" . $this->fields['users_id'] . "'>";
         echo "<div class='center'>";
         echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "</div></td></tr>";
     } else {
         echo "<tr>";
         echo "<td class='tab_bg_2 top' colspan='2'>";
         echo "<input type='hidden' name='id' value='{$ID}'>";
         echo "<input type='submit' name='update' value=\"" . __s('Save') . "\" class='submit'>";
         echo "</td></tr><tr><td class='tab_bg_2 right' colspan='2'>";
         echo "<input type='submit' name='purge' value=\"" . _sx('button', 'Delete permanently') . "\"\n                class='submit'>";
         echo "</td></tr>";
     }
     echo "</table></div>";
     Html::closeForm();
 }
Exemplo n.º 2
0
 /**
  * Print the bookmark form
  *
  * @param $ID integer ID of the item
  * @param $options array
  *     - target for the Form
  *     - type bookmark type when adding a new bookmark
  *     - url when adding a new bookmark
  *     - itemtype when adding a new bookmark
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI, $LANG;
     $ID = $this->fields['id'];
     // Only an edit form : always check w right
     if ($ID > 0) {
         $this->check($ID, 'w');
     } else {
         $this->check(-1, 'w');
     }
     echo '<br>';
     echo "<form method='post' name='form_save_query' action='" . $CFG_GLPI['root_doc'] . "/front/popup.php'>";
     echo "<div class='center'>";
     if (isset($options['itemtype'])) {
         echo "<input type='hidden' name='itemtype' value='" . $options['itemtype'] . "'>";
     }
     if (isset($options['type']) && $options['type'] != 0) {
         echo "<input type='hidden' name='type' value='" . $options['type'] . "'>";
     }
     if (isset($options['url'])) {
         echo "<input type='hidden' name='url' value='" . rawurlencode($options['url']) . "'>";
     }
     echo "<table class='tab_cadre_report' width='" . self::WIDTH . "px'>";
     echo "<tr><th>&nbsp;</th><th>";
     if ($ID > 0) {
         echo $LANG['bookmark'][1] . " - " . $LANG['common'][2] . " {$ID}";
     } else {
         echo $LANG['bookmark'][4];
     }
     echo "</th></tr>";
     echo "<tr><td class='tab_bg_1'>" . $LANG['common'][16] . "&nbsp;:</td>";
     echo "<td class='tab_bg_1'>";
     autocompletionTextField($this, "name", array('user' => $this->fields["users_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'><td>" . $LANG['common'][17] . "&nbsp;:</td>";
     echo "<td>";
     if (haveRight("bookmark_public", "w")) {
         Dropdown::showPrivatePublicSwitch($this->fields["is_private"], $this->fields["entities_id"], $this->fields["is_recursive"]);
     } else {
         if ($this->fields["is_private"]) {
             echo $LANG['common'][77];
         } else {
             echo $LANG['common'][76];
         }
     }
     echo "</td></tr>";
     if ($ID <= 0) {
         // add
         echo "<tr>";
         echo "<td class='tab_bg_2 top' colspan='2'>";
         echo "<input type='hidden' name='users_id' value='" . $this->fields['users_id'] . "'>";
         echo "<div class='center'>";
         echo "<input type='submit' name='add' value=\"" . $LANG['buttons'][8] . "\" class='submit'>";
         echo "</div></td></tr>";
     } else {
         echo "<tr>";
         echo "<td class='tab_bg_2 top' colspan='2'>";
         echo "<input type='hidden' name='id' value='{$ID}'>";
         echo "<div class='center'>";
         echo "<input type='submit' name='update' value=\"" . $LANG['buttons'][7] . "\" class='submit'>";
         echo "<input type='hidden' name='id' value='{$ID}'>";
         echo "<input type='submit' name='delete' value=\"" . $LANG['buttons'][6] . "\" class='submit'>";
         echo "</div></td></tr>";
     }
     echo "</table></div></form>";
 }
Exemplo n.º 3
0
 function showAdvancedForm($ID, $options = array())
 {
     if ($ID > 0) {
         $this->check($ID, READ);
     } else {
         // Create item
         $this->check(-1, UPDATE);
         $this->getEmpty();
         echo Html::hidden('step', array('value' => 1));
     }
     echo "<form name='form' method='post' action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
     echo "<div class='center' id='tabsbody'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='2'>" . self::getTypeName() . "</th>";
     echo "<th colspan='2'>" . PluginDatainjectionDropdown::getStatusLabel($this->fields['step']) . "</th></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td><input type='hidden' name='users_id' value='" . Session::getLoginUserID() . "'>" . __('Name') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "name");
     echo "</td>";
     echo "<td colspan='2'></td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan='4' class='center'>";
     Dropdown::showPrivatePublicSwitch($this->fields["is_private"], $this->fields["entities_id"], $this->fields["is_recursive"]);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Comments') . "</td>";
     echo "<td colspan='3' class='middle'>";
     echo "<textarea cols='45' rows='5' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Type of datas to import', 'datainjection') . "</td>";
     echo "<td>";
     if ($this->fields['step'] == '' || $this->fields['step'] == self::INITIAL_STEP) {
         //Get only the primary types
         PluginDatainjectionInjectionType::dropdown($this->fields['itemtype'], true);
     } else {
         $itemtype = new $this->fields['itemtype']();
         echo $itemtype->getTypeName();
     }
     echo "</td><td colspan='2'></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Allow lines creation', 'datainjection') . "</td>";
     echo "<td>";
     Dropdown::showYesNo("behavior_add", $this->fields['behavior_add']);
     echo "</td><td>" . __('Allow lines update', 'datainjection') . "</td>";
     echo "<td>";
     Dropdown::showYesNo("behavior_update", $this->fields['behavior_update']);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><th colspan='4'>" . __('Advanced options', 'datainjection') . "</th></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Allow creation of dropdowns', 'datainjection') . "</td>";
     echo "<td>";
     Dropdown::showYesNo("can_add_dropdown", $this->fields['can_add_dropdown']);
     echo "</td>";
     echo "<td>" . __('Dates format', 'datainjection') . "</td>";
     echo "<td>";
     Dropdown::showFromArray('date_format', PluginDatainjectionDropdown::dateFormats(), array('value' => $this->fields['date_format']));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Allow update of existing fields', 'datainjection') . "</td>";
     echo "<td>";
     Dropdown::showYesNo("can_overwrite_if_not_empty", $this->fields['can_overwrite_if_not_empty']);
     echo "</td>";
     echo "<td>" . __('Float format', 'datainjection') . "</td>";
     echo "<td>";
     Dropdown::showFromArray('float_format', PluginDatainjectionDropdown::floatFormats(), array('value' => $this->fields['float_format']));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Try to establish network connection is possible', 'datainjection') . "</td>";
     echo "<td>";
     Dropdown::showYesNo("perform_network_connection", $this->fields['perform_network_connection']);
     echo "</td>";
     echo "<td>" . __('Port unicity criteria', 'datainjection') . "</td>";
     echo "<td>";
     Dropdown::showFromArray('port_unicity', PluginDatainjectionDropdown::portUnicityValues(), array('value' => $this->fields['port_unicity']));
     echo "</td></tr>";
     if ($ID > 0) {
         $tmp = self::getInstance('csv');
         $tmp->showAdditionnalForm($this);
     }
     $this->showFormButtons($options);
     return true;
 }
Exemplo n.º 4
0
 /**
  * Print the reminder form
  *
  * @param $ID Integer : Id of the item to print
  * @param $options array
  *     - target filename : where to go when done.
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI, $LANG;
     // Show Reminder or blank form
     $onfocus = "";
     if ($ID > 0) {
         $this->check($ID, 'r');
     } else {
         // Create item : do getempty before check right to set default values
         $this->check(-1, 'w');
         $onfocus = "onfocus=\"if (this.value=='" . $this->fields['name'] . "') this.value='';\"";
     }
     $canedit = $this->can($ID, 'w');
     if ($canedit) {
         echo "<form method='post' name='remind' action='" . $this->getFormURL() . "'>";
     }
     echo "<div class='center'><table class='tab_cadre' width='450'>";
     echo "<tr><th>&nbsp;</th><th>";
     if (!$ID) {
         echo $LANG['reminder'][6];
     } else {
         echo $LANG['common'][2] . " {$ID}";
     }
     echo "</th></tr>\n";
     echo "<tr class='tab_bg_2'><td>" . $LANG['common'][57] . "&nbsp;:&nbsp;</td>";
     echo "<td>";
     if ($canedit) {
         autocompletionTextField($this, "name", array('size' => 80, 'entity' => -1, 'user' => $this->fields["users_id"], 'option' => $onfocus));
     } else {
         echo $this->fields['name'];
     }
     echo "</td></tr>\n";
     if (!$canedit) {
         echo "<tr class='tab_bg_2'><td>" . $LANG['common'][95] . "&nbsp;:&nbsp;</td>";
         echo "<td>";
         echo getUserName($this->fields["users_id"]);
         echo "</td></tr>\n";
     }
     echo "<tr class='tab_bg_2'><td>" . $LANG['common'][17] . "&nbsp;:&nbsp;</td>";
     echo "<td>";
     if ($canedit && haveRight("reminder_public", "w")) {
         if (!$ID) {
             if (isset($_GET["is_private"])) {
                 $this->fields["is_private"] = $_GET["is_private"];
             }
             if (isset($_GET["is_recursive"])) {
                 $this->fields["is_recursive"] = $_GET["is_recursive"];
             }
         }
         Dropdown::showPrivatePublicSwitch($this->fields["is_private"], $this->fields["entities_id"], $this->fields["is_recursive"]);
     } else {
         if ($this->fields["is_private"]) {
             echo $LANG['common'][77];
         } else {
             echo $LANG['common'][76];
         }
     }
     echo "</td></tr>\n";
     if (haveRight("reminder_public", "w") && !$this->fields["is_private"]) {
         echo "<tr class='tab_bg_2'><td>" . $LANG['tracking'][39] . "&nbsp;:&nbsp;</td>";
         echo "<td>";
         if ($canedit) {
             Dropdown::showYesNo('is_helpdesk_visible', $this->fields['is_helpdesk_visible']);
         } else {
             echo Dropdpown::getYesNo($this->fields['is_helpdesk_visible']);
         }
         echo "</td></tr>\n";
     }
     echo "<tr class='tab_bg_2'><td >" . $LANG['buttons'][15] . "&nbsp;:&nbsp;</td>";
     echo "<td class='center'>";
     if ($canedit) {
         echo "<script type='text/javascript' >\n";
         echo "function showPlan() {\n";
         echo "Ext.get('plan').setDisplayed('none');";
         $params = array('form' => 'remind');
         if ($ID && $this->fields["is_planned"]) {
             $params['state'] = $this->fields["state"];
             $params['begin'] = $this->fields["begin"];
             $params['end'] = $this->fields["end"];
         }
         ajaxUpdateItemJsCode('viewplan', $CFG_GLPI["root_doc"] . "/ajax/planning.php", $params, false);
         echo "}";
         echo "</script>\n";
     }
     if (!$ID || !$this->fields["is_planned"]) {
         if (haveRight("show_planning", "1") || haveRight("show_group_planning", "1") || haveRight("show_all_planning", "1")) {
             echo "<div id='plan' onClick='showPlan()'>\n";
             echo "<span class='showplan'>" . $LANG['reminder'][12] . "</span>";
         }
     } else {
         if ($canedit) {
             echo "<div id='plan' onClick='showPlan()'>\n";
             echo "<span class='showplan'>";
         }
         echo Planning::getState($this->fields["state"]) . ": " . convDateTime($this->fields["begin"]) . "->" . convDateTime($this->fields["end"]);
         if ($canedit) {
             echo "</span>";
         }
     }
     if ($canedit) {
         echo "</div>\n";
         echo "<div id='viewplan'>\n";
         echo "</div>\n";
     }
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_2'><td>" . $LANG['reminder'][9] . "&nbsp;:&nbsp;</td><td>";
     if ($canedit) {
         echo "<textarea cols='80' rows='15' name='text'>" . $this->fields["text"] . "</textarea>";
     } else {
         echo nl2br($this->fields["text"]);
     }
     echo "</td></tr>\n";
     if (!$ID) {
         // add
         echo "<tr><td class='tab_bg_2 top' colspan='2'>";
         echo "<input type='hidden' name='users_id' value='" . $this->fields['users_id'] . "'>\n";
         echo "<div class='center'>";
         echo "<input type='submit' name='add' value=\"" . $LANG['buttons'][8] . "\" class='submit'>";
         echo "</div>";
         echo "</td></tr>\n";
     } else {
         if ($canedit) {
             echo "<tr><td class='tab_bg_2 top' colspan='2'>";
             echo "<input type='hidden' name='id' value='{$ID}'>\n";
             echo "<div class='center'>";
             echo "<input type='submit' name='update' value=\"" . $LANG['buttons'][7] . "\" class='submit'>";
             echo "<input type='hidden' name='id' value='{$ID}'><span class='medium_space'>";
             echo "<input type='submit' name='delete' value=\"" . $LANG['buttons'][22] . "\"\n                class='submit' " . addConfirmationOnAction($LANG['common'][50]) . ">\n               </span>";
             echo "</div>";
             echo "</td></tr>\n";
         }
     }
     echo "</table></div>\n";
     if ($canedit) {
         echo "</form>";
     }
     return true;
 }