本文整理汇总了PHP中Profile_User::getUserEntities方法的典型用法代码示例。如果您正苦于以下问题:PHP Profile_User::getUserEntities方法的具体用法?PHP Profile_User::getUserEntities怎么用?PHP Profile_User::getUserEntities使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Profile_User
的用法示例。
在下文中一共展示了Profile_User::getUserEntities方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: date
$data_fin = $_REQUEST['date2'];
} else {
$data_ini = date("Y-01-01");
$data_fin = date("Y-m-d");
}
# entity
$sql_e = "SELECT value FROM glpi_plugin_dashboard_config WHERE name = 'entity' AND users_id = " . $_SESSION['glpiID'] . "";
$result_e = $DB->query($sql_e);
$sel_ent = $DB->result($result_e, 0, 'value');
//select entity
if ($sel_ent == '' || $sel_ent == -1) {
$query_ent1 = "\n\tSELECT entities_id\n\tFROM glpi_users\n\tWHERE id = " . $_SESSION['glpiID'] . " ";
$res_ent1 = $DB->query($query_ent1);
$user_ent = $DB->result($res_ent1, 0, 'entities_id');
//get all user entities
$entities = Profile_User::getUserEntities($_SESSION['glpiID'], true);
$entities[] = $user_ent;
$ent = implode(",", $entities);
$entidade = "AND glpi_tickets.entities_id IN (" . $ent . ") ";
$entidade1 = "";
} else {
$entidade = "AND glpi_tickets.entities_id IN (" . $sel_ent . ") ";
}
?>
<html>
<head>
<title> GLPI - <?php
echo __('Tickets', 'dashboard') . ' ' . __('by SLAs', 'dashboard');
?>
</title>
示例2: showMyForm
//.........这里部分代码省略.........
echo "<td colspan='2'></tr>";
}
echo "<tr class='tab_bg_1'><td>" . __('First name') . "</td><td>";
if ($extauth && isset($authtype['firstname_field']) && !empty($authtype['firstname_field'])) {
echo $this->fields["firstname"];
} else {
Html::autocompletionTextField($this, "firstname");
}
echo "</td>";
if (!$extauth && Session::haveRight("password_update", "1")) {
echo "<td>" . __('Password confirmation') . "</td>";
echo "<td><input type='password' name='password2' value='' size='30' autocomplete='off'>";
echo "</td></tr>";
} else {
echo "<td colspan='2'></tr>";
}
echo "<tr class='tab_bg_1'><td class='top'>" . _n('Email', 'Emails', 2);
UserEmail::showAddEmailButton($this);
echo "</td><td>";
UserEmail::showForUser($this);
echo "</td>";
if (!$extauth && Session::haveRight("password_update", "1")) {
echo "<td>" . __('Password security policy') . "</td>";
echo "<td>";
Config::displayPasswordSecurityChecks();
echo "</td>";
} else {
echo "<td colspan='2'>";
}
echo "</tr>";
echo "<tr class='tab_bg_1'><td>" . __('Mobile phone') . " :</td><td>";
if ($extauth && isset($authtype['mobile_field']) && !empty($authtype['mobile_field'])) {
echo $this->fields["mobile"];
} else {
Html::autocompletionTextField($this, "mobile");
}
echo "</td>";
if (!GLPI_DEMO_MODE) {
echo "<td>" . __('Language') . "</td><td>";
// Use session variable because field in table may be null if same of the global config
Dropdown::showLanguages("language", array('value' => $_SESSION["glpilanguage"]));
} else {
echo "<td colspan='2'> ";
}
echo "</td></tr>";
echo "<tr class='tab_bg_1'><td>" . __('Phone') . "</td><td>";
if ($extauth && isset($authtype['phone_field']) && !empty($authtype['phone_field'])) {
echo $this->fields["phone"];
} else {
Html::autocompletionTextField($this, "phone");
}
echo "</td>";
if (count($_SESSION['glpiprofiles']) > 1) {
echo "<td>" . __('Default profile') . "</td><td>";
$options = array(0 => Dropdown::EMPTY_VALUE);
$options += Dropdown::getDropdownArrayNames('glpi_profiles', Profile_User::getUserProfiles($this->fields['id']));
Dropdown::showFromArray("profiles_id", $options, array('value' => $this->fields["profiles_id"]));
} else {
echo "<td colspan='2'> ";
}
echo "</td></tr>";
echo "<tr class='tab_bg_1'><td>" . __('Phone 2') . "</td><td>";
if ($extauth && isset($authtype['phone2_field']) && !empty($authtype['phone2_field'])) {
echo $this->fields["phone2"];
} else {
Html::autocompletionTextField($this, "phone2");
}
echo "</td>";
$entities = Profile_User::getUserEntities($this->fields['id'], 1);
if (!GLPI_DEMO_MODE && count($_SESSION['glpiactiveentities']) > 1) {
echo "<td>" . __('Default entity') . "</td><td>";
Entity::dropdown(array('value' => $this->fields['entities_id'], 'entity' => $entities));
} else {
echo "<td colspan='2'> ";
}
echo "</td></tr>";
echo "<tr class='tab_bg_1'><td>" . __('Location') . "</td><td>";
$entities = Profile_User::getUserEntities($ID, true);
Location::dropdown(array('value' => $this->fields['locations_id'], 'entity' => $entities));
if (Session::haveRight("config", "w")) {
echo "<td>" . __('Use GLPI in mode') . "</td><td>";
$modes[Session::NORMAL_MODE] = __('Normal');
//$modes[Session::TRANSLATION_MODE] = __('Translation');
$modes[Session::DEBUG_MODE] = __('Debug');
Dropdown::showFromArray('use_mode', $modes, array('value' => $this->fields["use_mode"]));
} else {
echo "<td colspan='2'> ";
}
echo "</td></tr>";
echo "<tr><td class='tab_bg_2 center' colspan='4'>";
echo "<input type='submit' name='update' value=\"" . _sx('button', 'Save') . "\" class='submit'>";
echo "</td></tr>";
echo "</table>";
Html::closeForm();
echo "</div>";
$CFG_GLPI["use_ajax_autocompletion"] = $save_autocompletion;
return true;
}
return false;
}
示例3: getCentral
/**
* Clone of Ticket::showForm()
* Change '$this' by '$ticket', 'self' by 'Ticket' and 'parent' by 'Ticket'
*/
static function getCentral($ID = 0, $options = array())
{
global $CFG_GLPI;
// * Added by plugin survey ticket
$ticket = new Ticket();
// * End of adding
$default_values = Ticket::getDefaultValues();
// Get default values from posted values on reload form
if (!isset($options['template_preview'])) {
if (isset($_POST)) {
$values = $_POST;
}
}
// Restore saved value or override with page parameter
$saved = $ticket->restoreInput();
foreach ($default_values as $name => $value) {
if (!isset($values[$name])) {
if (isset($saved[$name])) {
$values[$name] = $saved[$name];
} else {
$values[$name] = $value;
}
}
}
// Default check
if ($ID > 0) {
$ticket->check($ID, 'r');
} else {
// Create item
$ticket->check(-1, 'w', $values);
}
if (!$ID) {
$ticket->userentities = array();
if ($values["_users_id_requester"]) {
//Get all the user's entities
$all_entities = Profile_User::getUserEntities($values["_users_id_requester"], true, true);
//For each user's entity, check if the technician which creates the ticket have access to it
foreach ($all_entities as $tmp => $ID_entity) {
if (Session::haveAccessToEntity($ID_entity)) {
$ticket->userentities[] = $ID_entity;
}
}
}
$ticket->countentitiesforuser = count($ticket->userentities);
if ($ticket->countentitiesforuser > 0 && !in_array($ticket->fields["entities_id"], $ticket->userentities)) {
// If entity is not in the list of user's entities,
// then use as default value the first value of the user's entites list
$ticket->fields["entities_id"] = $ticket->userentities[0];
// Pass to values
$values['entities_id'] = $ticket->userentities[0];
}
}
if ($values['type'] <= 0) {
$values['type'] = Entity::getUsedConfig('tickettype', $values['entities_id'], '', Ticket::INCIDENT_TYPE);
}
if (!isset($options['template_preview'])) {
$options['template_preview'] = 0;
}
// Load ticket template if available :
$tt = $ticket->getTicketTemplateToUse($options['template_preview'], $values['type'], $values['itilcategories_id'], $values['entities_id']);
// Predefined fields from template : reset them
if (isset($values['_predefined_fields'])) {
$values['_predefined_fields'] = Toolbox::decodeArrayFromInput($values['_predefined_fields']);
} else {
$values['_predefined_fields'] = array();
}
// Store predefined fields to be able not to take into account on change template
// Only manage predefined values on ticket creation
$predefined_fields = array();
if (!$ID) {
if (isset($tt->predefined) && count($tt->predefined)) {
foreach ($tt->predefined as $predeffield => $predefvalue) {
if (isset($default_values[$predeffield])) {
// Is always default value : not set
// Set if already predefined field
// Set if ticket template change
if ($values[$predeffield] == $default_values[$predeffield] || isset($values['_predefined_fields'][$predeffield]) && $values[$predeffield] == $values['_predefined_fields'][$predeffield] || isset($values['_tickettemplates_id']) && $values['_tickettemplates_id'] != $tt->getID()) {
// Load template data
$values[$predeffield] = $predefvalue;
$ticket->fields[$predeffield] = $predefvalue;
$predefined_fields[$predeffield] = $predefvalue;
}
}
}
} else {
// No template load : reset predefined values
if (count($values['_predefined_fields'])) {
foreach ($values['_predefined_fields'] as $predeffield => $predefvalue) {
if ($values[$predeffield] == $predefvalue) {
$values[$predeffield] = $default_values[$predeffield];
}
}
}
}
}
// Put ticket template on $values for actors
//.........这里部分代码省略.........
示例4: showForm
function showForm($ID, $options = array())
{
global $DB, $CFG_GLPI;
$default_values = self::getDefaultValues();
// Get default values from posted values on reload form
// On get because of tabs
// we use REQUEST because method differ with layout (lefttab : GET, vsplit: POST)
if (!isset($options['template_preview'])) {
if (isset($_REQUEST)) {
$values = Html::cleanPostForTextArea($_REQUEST);
}
}
// Restore saved value or override with page parameter
$saved = $this->restoreInput();
foreach ($default_values as $name => $value) {
if (!isset($values[$name])) {
if (isset($saved[$name])) {
$values[$name] = $saved[$name];
} else {
$values[$name] = $value;
}
}
}
if (isset($values['content'])) {
// Clean new lines to be fix encoding
$order = array('\\r', '\\n', "\\");
$replace = array("", "", "");
$values['content'] = str_replace($order, $replace, $values['content']);
}
if (isset($values['name'])) {
$values['name'] = str_replace("\\", "", $values['name']);
}
if (!$ID) {
// Override defaut values from projecttask if needed
if (isset($options['_projecttasks_id'])) {
$pt = new ProjectTask();
if ($pt->getFromDB($options['_projecttasks_id'])) {
$values['name'] = $pt->getField('name');
$values['content'] = $pt->getField('name');
}
}
}
// Check category / type validity
if ($values['itilcategories_id']) {
$cat = new ITILCategory();
if ($cat->getFromDB($values['itilcategories_id'])) {
switch ($values['type']) {
case self::INCIDENT_TYPE:
if (!$cat->getField('is_incident')) {
$values['itilcategories_id'] = 0;
}
break;
case self::DEMAND_TYPE:
if (!$cat->getField('is_request')) {
$values['itilcategories_id'] = 0;
}
break;
default:
break;
}
}
}
// Default check
if ($ID > 0) {
$this->check($ID, READ);
} else {
// Create item
$this->check(-1, CREATE, $values);
}
if (!$ID) {
$this->userentities = array();
if ($values["_users_id_requester"]) {
//Get all the user's entities
$all_entities = Profile_User::getUserEntities($values["_users_id_requester"], true, true);
//For each user's entity, check if the technician which creates the ticket have access to it
foreach ($all_entities as $tmp => $ID_entity) {
if (Session::haveAccessToEntity($ID_entity)) {
$this->userentities[] = $ID_entity;
}
}
}
$this->countentitiesforuser = count($this->userentities);
if ($this->countentitiesforuser > 0 && !in_array($this->fields["entities_id"], $this->userentities)) {
// If entity is not in the list of user's entities,
// then use as default value the first value of the user's entites list
$this->fields["entities_id"] = $this->userentities[0];
// Pass to values
$values['entities_id'] = $this->userentities[0];
}
}
if ($values['type'] <= 0) {
$values['type'] = Entity::getUsedConfig('tickettype', $values['entities_id'], '', Ticket::INCIDENT_TYPE);
}
if (!isset($options['template_preview'])) {
$options['template_preview'] = 0;
}
// Load ticket template if available :
if ($ID) {
$tt = $this->getTicketTemplateToUse($options['template_preview'], $this->fields['type'], $this->fields['itilcategories_id'], $this->fields['entities_id']);
} else {
//.........这里部分代码省略.........
示例5: showForm
function showForm($ID, $options = array())
{
global $DB, $CFG_GLPI, $LANG;
$canupdate = haveRight('update_ticket', '1');
$canpriority = haveRight('update_priority', '1');
$showuserlink = 0;
if (haveRight('user', 'r')) {
$showuserlink = 1;
}
if ($ID > 0) {
$this->check($ID, 'r');
} else {
// Create item
$this->check(-1, 'w', $options);
}
$this->showTabs($options);
$canupdate_descr = $canupdate || $this->fields['status'] == 'new' && $this->isUser(self::REQUESTER, getLoginUserID()) && $this->numberOfFollowups() == 0 && $this->numberOfTasks() == 0;
if (!$ID) {
//Get all the user's entities
$all_entities = Profile_User::getUserEntities($options["_users_id_requester"], true);
$this->userentities = array();
//For each user's entity, check if the technician which creates the ticket have access to it
foreach ($all_entities as $tmp => $ID_entity) {
if (haveAccessToEntity($ID_entity)) {
$this->userentities[] = $ID_entity;
}
}
$this->countentitiesforuser = count($this->userentities);
if ($this->countentitiesforuser > 0 && !in_array($this->fields["entities_id"], $this->userentities)) {
// If entity is not in the list of user's entities,
// then use as default value the first value of the user's entites list
$this->fields["entities_id"] = $this->userentities[0];
}
}
echo "<form method='post' name='form_ticket' enctype='multipart/form-data' action='" . $CFG_GLPI["root_doc"] . "/front/ticket.form.php'>";
echo "<div class='spaced' id='tabsbody'>";
echo "<table class='tab_cadre_fixe'>";
// Optional line
$ismultientities = isMultiEntitiesMode();
echo '<tr><th colspan="4">';
if ($ID) {
echo $this->getTypeName() . " - " . $LANG['common'][2] . " {$ID} ";
if ($ismultientities) {
echo "(" . Dropdown::getDropdownName('glpi_entities', $this->fields['entities_id']) . ")";
}
} else {
if ($ismultientities) {
echo $LANG['job'][46] . " : " . Dropdown::getDropdownName("glpi_entities", $this->fields['entities_id']);
} else {
echo $LANG['job'][13];
}
}
echo '</th></tr>';
echo "<tr>";
echo "<th class='left' colspan='2'>";
echo "<table>";
echo "<tr>";
echo "<td><span class='tracking_small'>" . $LANG['joblist'][11] . " : </span></td>";
echo "<td>";
$date = $this->fields["date"];
if (!$ID) {
$date = date("Y-m-d H:i:s");
}
if ($canupdate) {
showDateTimeFormItem("date", $date, 1, false);
} else {
echo convDateTime($date);
}
echo "</td></tr>";
if ($ID) {
echo "<tr><td><span class='tracking_small'>" . $LANG['common'][95] . " :</span></td><td>";
if ($canupdate) {
User::dropdown(array('name' => 'users_id_recipient', 'value' => $this->fields["users_id_recipient"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
} else {
echo getUserName($this->fields["users_id_recipient"], $showuserlink);
}
echo "</td></tr>";
}
echo "</table>";
echo "</th>";
echo "<th class='left' colspan='2'>";
echo "<table>";
if ($ID) {
echo "<tr><td><span class='tracking_small'>" . $LANG['common'][26] . " :</span></td>";
echo "<td><span class='tracking_small'>" . convDateTime($this->fields["date_mod"]) . "\n";
if ($this->fields['users_id_lastupdater'] > 0) {
echo $LANG['common'][95] . " ";
echo getUserName($this->fields["users_id_lastupdater"], $showuserlink);
}
echo "</span>";
echo "</td></tr>";
}
// SLA
echo "<tr>";
echo "<td><span class='tracking_small'>" . $LANG['sla'][5] . " : </span></td>";
echo "<td>";
if ($ID) {
if ($this->fields["slas_id"] > 0) {
echo "<span class='tracking_small'> ";
echo convDateTime($this->fields["due_date"]) . "</span>";
//.........这里部分代码省略.........
示例6: displayDatas
//.........这里部分代码省略.........
$headers_line_bottom .= $headers_line;
}
$headers_line_top .= self::showEndHeader($data['display_type']);
// $headers_line_bottom .= self::showEndHeader($data['display_type']);
echo $headers_line_top;
// Init list of items displayed
if ($data['display_type'] == self::HTML_OUTPUT) {
Session::initNavigateListItems($data['itemtype']);
}
// Num of the row (1=header_line)
$row_num = 1;
$massiveaction_field = 'id';
if ($data['itemtype'] != 'AllAssets' && isset($CFG_GLPI["union_search_type"][$data['itemtype']])) {
$massiveaction_field = 'refID';
}
$typenames = array();
// Display Loop
foreach ($data['data']['rows'] as $rowkey => $row) {
// Column num
$item_num = 1;
$row_num++;
// New line
echo self::showNewLine($data['display_type'], $row_num % 2, $data['search']['is_deleted']);
$current_type = isset($row['TYPE']) ? $row['TYPE'] : $data['itemtype'];
$massiveaction_type = $current_type;
if ($data['itemtype'] != 'AllAssets' && isset($CFG_GLPI["union_search_type"][$data['itemtype']])) {
$massiveaction_type = $data['itemtype'];
}
// Add item in item list
Session::addToNavigateListItems($current_type, $row["id"]);
if ($data['display_type'] == self::HTML_OUTPUT && $showmassiveactions) {
// HTML display - massive modif
$tmpcheck = "";
if ($data['itemtype'] == 'Entity' && !in_array($row["id"], $_SESSION["glpiactiveentities"])) {
$tmpcheck = " ";
} else {
if ($data['itemtype'] == 'User' && !Session::isViewAllEntities() && !Session::haveAccessToOneOfEntities(Profile_User::getUserEntities($row["id"], false))) {
$tmpcheck = " ";
} else {
if ($data['item'] instanceof CommonDBTM && $data['item']->maybeRecursive() && !in_array($row["entities_id"], $_SESSION["glpiactiveentities"])) {
$tmpcheck = " ";
} else {
$tmpcheck = Html::getMassiveActionCheckBox($massiveaction_type, $row[$massiveaction_field]);
}
}
}
echo self::showItem($data['display_type'], $tmpcheck, $item_num, $row_num, "width='10'");
}
// Print other toview items
foreach ($data['data']['cols'] as $colkey => $col) {
if (!$col['meta']) {
echo self::showItem($data['display_type'], $row[$colkey]['displayname'], $item_num, $row_num, self::displayConfigItem($data['itemtype'], $col['id'], $row, $colkey));
} else {
// META case
echo self::showItem($data['display_type'], $row[$colkey]['displayname'], $item_num, $row_num);
}
}
if (isset($CFG_GLPI["union_search_type"][$data['itemtype']])) {
if (!isset($typenames[$row["TYPE"]])) {
if ($itemtmp = getItemForItemtype($row["TYPE"])) {
$typenames[$row["TYPE"]] = $itemtmp->getTypeName();
}
}
echo self::showItem($data['display_type'], $typenames[$row["TYPE"]], $item_num, $row_num);
}
// End Line
echo self::showEndLine($data['display_type']);
}
// Create title
$title = '';
if ($data['display_type'] == self::PDF_OUTPUT_LANDSCAPE || $data['display_type'] == self::PDF_OUTPUT_PORTRAIT) {
$title = self::computeTitle($data);
}
if ($data['display_type'] == self::HTML_OUTPUT) {
echo $headers_line_bottom;
}
// Display footer
echo self::showFooter($data['display_type'], $title);
// Delete selected item
if ($data['display_type'] == self::HTML_OUTPUT) {
if ($showmassiveactions) {
$massiveactionparams['ontop'] = false;
Html::showMassiveActions($massiveactionparams);
// End form for delete item
Html::closeForm();
} else {
echo "<br>";
}
}
if ($data['display_type'] == self::HTML_OUTPUT) {
// In case of HTML display
Html::printPager($data['search']['start'], $data['data']['totalcount'], $data['search']['target'], $parameters, '', 0, $search_config_bottom);
}
} else {
if ($item !== null && $item->maybeDeleted()) {
echo "<div class='center'>" . self::isDeletedSwitch($data['search']['is_deleted']) . "</div><br/>";
}
echo self::showError($data['display_type']);
}
}
示例7: header
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GLPI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GLPI; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
--------------------------------------------------------------------------
*/
// ----------------------------------------------------------------------
// Original Author of file: Julien Dombre
// Purpose of file:
// ----------------------------------------------------------------------
// Direct access to file
if (strpos($_SERVER['PHP_SELF'], "dropdownUserEntities.php")) {
include "../../../inc/includes.php";
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
}
if (!defined('GLPI_ROOT')) {
die("Can not acces directly to this file");
}
Session::checkLoginUser();
$all_entities = Profile_User::getUserEntities($_POST["value"], true);
$value = current($all_entities);
Dropdown::show("Entity", array('name' => 'entities_id', 'value' => $value, 'entity' => $all_entities));
示例8: showForUser
/** Show groups of a user
*
* @param $user User object
**/
static function showForUser(User $user)
{
global $CFG_GLPI;
$ID = $user->fields['id'];
if (!Group::canView() || !$user->can($ID, READ)) {
return false;
}
$canedit = $user->can($ID, UPDATE);
$rand = mt_rand();
$groups = self::getUserGroups($ID);
$used = array();
if (!empty($groups)) {
foreach ($groups as $data) {
$used[$data["id"]] = $data["id"];
}
}
if ($canedit) {
echo "<div class='firstbloc'>";
echo "<form name='groupuser_form{$rand}' id='groupuser_form{$rand}' method='post'";
echo " action='" . Toolbox::getItemTypeFormURL('User') . "'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_1'><th colspan='6'>" . __('Associate to a group') . "</th></tr>";
echo "<tr class='tab_bg_2'><td class='center'>";
echo "<input type='hidden' name='users_id' value='{$ID}'>";
// All entities "edited user" have access
$strict_entities = Profile_User::getUserEntities($ID, true);
// Keep only entities "connected user" have access
foreach ($strict_entities as $key => $val) {
if (!Session::haveAccessToEntity($val)) {
unset($strict_entities[$key]);
}
}
$nb = countElementsInTableForEntity("glpi_groups", $strict_entities, '`is_usergroup`');
if ($nb > count($used)) {
Group::dropdown(array('entity' => $strict_entities, 'used' => $used, 'condition' => '`is_usergroup`'));
echo "</td><td>" . __('Manager') . "</td><td>";
Dropdown::showYesNo('is_manager');
echo "</td><td>" . __('Delegatee') . "</td><td>";
Dropdown::showYesNo('is_userdelegate');
echo "</td><td class='tab_bg_2 center'>";
echo "<input type='submit' name='addgroup' value=\"" . _sx('button', 'Add') . "\"\n class='submit'>";
} else {
_e('None');
}
echo "</td></tr>";
echo "</table>";
Html::closeForm();
echo "</div>";
}
echo "<div class='spaced'>";
if ($canedit && count($used)) {
$rand = mt_rand();
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
echo "<input type='hidden' name='users_id' value='" . $user->fields['id'] . "'>";
$massiveactionparams = array('num_displayed' => count($used), 'container' => 'mass' . __CLASS__ . $rand);
Html::showMassiveActions($massiveactionparams);
}
echo "<table class='tab_cadre_fixehov table-striped table-hover'>";
$header_begin = "<tr>";
$header_top = '';
$header_bottom = '';
$header_end = '';
if ($canedit && count($used)) {
$header_begin .= "<th width='10'>";
$header_top .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
$header_bottom .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
$header_end .= "</th>";
}
$header_end .= "<th>" . Group::getTypeName(1) . "</th>";
$header_end .= "<th>" . __('Dynamic') . "</th>";
$header_end .= "<th>" . __('Manager') . "</th>";
$header_end .= "<th>" . __('Delegatee') . "</th></tr>";
echo $header_begin . $header_top . $header_end;
$group = new Group();
if (!empty($groups)) {
Session::initNavigateListItems('Group', sprintf(__('%1$s = %2$s'), User::getTypeName(1), $user->getName()));
foreach ($groups as $data) {
if (!$group->getFromDB($data["id"])) {
continue;
}
Session::addToNavigateListItems('Group', $data["id"]);
echo "<tr class='tab_bg_1'>";
if ($canedit && count($used)) {
echo "<td width='10'>";
Html::showMassiveActionCheckBox(__CLASS__, $data["linkID"]);
echo "</td>";
}
$link = $data["completename"];
if ($_SESSION["glpiis_ids_visible"]) {
$link = sprintf(__('%1$s (%2$s)'), $link, $data["id"]);
}
$href = "<a href='" . $CFG_GLPI["root_doc"] . "/front/group.form.php?id=" . $data["id"] . "'>" . $link . "</a>";
if ($data["is_dynamic"]) {
$href = sprintf(__('%1$s (%2$s)'), $href, "<span class='b'>" . __('D') . "</span>");
}
echo "<td>" . $group->getLink() . "</td>";
//.........这里部分代码省略.........
示例9: foreach
$entities = Profile_User::getUserEntitiesForRight($user->getID(), Planning::READGROUP);
$groups = Group_User::getUserGroups($user->getID());
foreach ($groups as $group) {
if ($_GET["gID"] == $group['id'] && in_array($group['entities_id'], $entities)) {
$ismine = true;
}
}
}
}
$canview = false;
// If not mine check global right
if (!$ismine) {
// First check user
$entities = Profile_User::getUserEntitiesForRight($user->getID(), Planning::READALL);
if ($_GET["uID"]) {
$userentities = Profile_User::getUserEntities($user->getID());
$intersect = array_intersect($entities, $userentities);
if (count($intersect)) {
$canview = true;
}
}
// Else check group
if (!$canview && $_GET['gID']) {
$group = new Group();
if ($group->getFromDB($_GET['gID'])) {
if (in_array($group->getEntityID(), $entities)) {
$canview = true;
}
}
}
}
示例10: showForUser
/** Show groups of a user
*
* @param $user the user
**/
static function showForUser(User $user)
{
global $CFG_GLPI, $LANG;
$ID = $user->fields['id'];
if (!haveRight("group", "r") || !$user->can($ID, 'r')) {
return false;
}
$canedit = $user->can($ID, 'w');
$rand = mt_rand();
$nb_per_line = 3;
if ($canedit) {
$headerspan = $nb_per_line * 2;
echo "<form name='groupuser_form{$rand}' id='groupuser_form{$rand}' method='post'";
echo " action='" . getItemTypeFormURL('User') . "'>";
} else {
$headerspan = $nb_per_line;
}
$groups = self::getUserGroups($ID);
$used = array();
if (!empty($groups)) {
foreach ($groups as $data) {
$used[$data["id"]] = $data["id"];
}
}
if ($canedit) {
echo "<div class='firstbloc'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_1'><th colspan='2'>" . $LANG['setup'][604] . "</th></tr>";
echo "<tr><td class='tab_bg_2 center'>";
echo "<input type='hidden' name='users_id' value='{$ID}'>";
// All entities "edited user" have access
$strict_entities = Profile_User::getUserEntities($ID, true);
// Keep only entities "connected user" have access
foreach ($strict_entities as $key => $val) {
if (!haveAccessToEntity($val)) {
unset($strict_entities[$key]);
}
}
if (countElementsInTableForEntity("glpi_groups", $strict_entities) > count($used)) {
Dropdown::show('Group', array('entity' => $strict_entities, 'used' => $used));
echo "</td><td class='tab_bg_2 center'>";
echo "<input type='submit' name='addgroup' value=\"" . $LANG['buttons'][8] . "\"\n class='submit'>";
} else {
echo $LANG['common'][49];
}
echo "</td></tr>";
echo "</table></div>";
}
echo "<div class='spaced'>";
echo "<table class='tab_cadre_fixehov'><tr>";
echo "<th colspan='{$headerspan}'>" . $LANG['Menu'][36] . " (D=" . $LANG['profiles'][29] . ")</th>";
echo "</tr>";
if (!empty($groups)) {
initNavigateListItems('Group', $user->getTypeName() . " = " . $user->getName());
$i = 0;
foreach ($groups as $data) {
addToNavigateListItems('Group', $data["id"]);
if ($i % $nb_per_line == 0) {
if ($i != 0) {
echo "</tr>";
}
echo "<tr class='tab_bg_1'>";
}
if ($canedit) {
echo "<td width='10'>";
$sel = "";
if (isset($_GET["select"]) && $_GET["select"] == "all") {
$sel = "checked";
}
echo "<input type='checkbox' name='item[" . $data["linkID"] . "]' value='1' {$sel}>";
echo "</td>";
}
echo "<td><a href='" . $CFG_GLPI["root_doc"] . "/front/group.form.php?id=" . $data["id"] . "'>" . $data["name"] . ($_SESSION["glpiis_ids_visible"] ? " (" . $data["id"] . ")" : "") . "</a>";
echo " ";
if ($data["is_dynamic"]) {
echo "<strong> (D)</strong>";
}
echo "</td>";
$i++;
}
while ($i % $nb_per_line != 0) {
if ($canedit) {
echo "<td> </td>";
}
echo "<td> </td>";
$i++;
}
echo "</tr>";
} else {
echo "<tr class='tab_bg_1'>";
echo "<td colspan='{$headerspan}' class='center'>" . $LANG['common'][49] . "</td></tr>";
}
echo "</table>";
if ($canedit) {
if (count($used)) {
openArrowMassive("groupuser_form{$rand}", true);
//.........这里部分代码省略.........
示例11: showForItem
/**
* Show projet associated to an item
*
* @since version 0.84
*
* @param $item CommonDBTM object for which associated projet must be displayed
* @param $withtemplate (default '')
**/
static function showForItem(CommonDBTM $item, $withtemplate = '')
{
global $DB, $CFG_GLPI;
$ID = $item->getField('id');
if ($item->isNewID($ID)) {
return false;
}
if (!plugin_projet_haveRight('projet', 'r')) {
return false;
}
if (!$item->can($item->fields['id'], 'r')) {
return false;
}
if (empty($withtemplate)) {
$withtemplate = 0;
}
$canedit = $item->canadditem('PluginProjetProjet');
$rand = mt_rand();
$is_recursive = $item->isRecursive();
$query = "SELECT `glpi_plugin_projet_projets_items`.`id` AS assocID,\n `glpi_entities`.`id` AS entity,\n `glpi_plugin_projet_projets`.`name` AS assocName,\n `glpi_plugin_projet_projets`.*\n FROM `glpi_plugin_projet_projets_items`\n LEFT JOIN `glpi_plugin_projet_projets`\n ON (`glpi_plugin_projet_projets_items`.`plugin_projet_projets_id`=`glpi_plugin_projet_projets`.`id`)\n LEFT JOIN `glpi_entities` ON (`glpi_plugin_projet_projets`.`entities_id`=`glpi_entities`.`id`)\n WHERE `glpi_plugin_projet_projets_items`.`items_id` = '{$ID}'\n AND `glpi_plugin_projet_projets_items`.`itemtype` = '" . $item->getType() . "' ";
$query .= getEntitiesRestrictRequest(" AND", "glpi_plugin_projet_projets", '', '', true);
$query .= " ORDER BY `assocName`";
$result = $DB->query($query);
$number = $DB->numrows($result);
$i = 0;
$projets = array();
$used = array();
if ($numrows = $DB->numrows($result)) {
while ($data = $DB->fetch_assoc($result)) {
$projets[$data['assocID']] = $data;
$used[$data['id']] = $data['id'];
}
}
$projet = new PluginProjetProjet();
if ($canedit && $withtemplate < 2) {
// Restrict entity for knowbase
$entities = "";
$entity = $_SESSION["glpiactive_entity"];
if ($item->isEntityAssign()) {
/// Case of personal items : entity = -1 : create on active entity (Reminder case))
if ($item->getEntityID() >= 0) {
$entity = $item->getEntityID();
}
if ($item->isRecursive()) {
$entities = getSonsOf('glpi_entities', $entity);
} else {
$entities = $entity;
}
}
$limit = getEntitiesRestrictRequest(" AND ", "glpi_plugin_projet_projets", '', $entities, true);
$q = "SELECT COUNT(*)\n FROM `glpi_plugin_projet_projets`\n WHERE `is_deleted` = '0'\n AND `is_template` = '0' ";
if ($item->getType() != 'User') {
$q .= " {$limit}";
}
$result = $DB->query($q);
$nb = $DB->result($result, 0, 0);
echo "<div class='firstbloc'>";
if (plugin_projet_haveRight('projet', 'r') && $nb > count($used)) {
echo "<form name='projet_form{$rand}' id='projet_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL('PluginProjetProjet') . "'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_1'>";
echo "<td colspan='4' class='center'>";
echo "<input type='hidden' name='entities_id' value='{$entity}'>";
echo "<input type='hidden' name='is_recursive' value='{$is_recursive}'>";
echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>";
echo "<input type='hidden' name='items_id' value='{$ID}'>";
if ($item->getType() == 'Ticket') {
echo "<input type='hidden' name='tickets_id' value='{$ID}'>";
}
if ($item->getType() != 'User') {
$projet->dropdownProjet("plugin_projet_projets_id", $entities, $used);
} else {
$strict_entities = Profile_User::getUserEntities($ID, true);
if (!Session::haveAccessToOneOfEntities($strict_entities) && !isViewAllEntities()) {
$canedit = false;
}
if (countElementsInTableForEntity("glpi_plugin_projet_projets", $strict_entities) > count($used)) {
Dropdown::show('PluginProjetProjet', array('name' => "plugin_projet_projets_id", 'used' => $used, 'entity' => $strict_entities));
}
}
echo "</td><td class='center' width='20%'>";
echo "<input type='submit' name='additem' value=\"" . _sx('button', 'Associate a project', 'projet') . "\" class='submit'>";
echo "</td>";
echo "</tr>";
echo "</table>";
Html::closeForm();
}
echo "</div>";
}
echo "<div class='spaced'>";
if ($canedit && $number && $withtemplate < 2) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
//.........这里部分代码省略.........
示例12: findUser
/**
* Find a user. Look for login OR firstname + lastname OR lastname + firstname
*
* @param value the user to look for
* @param entity the entity where the user should have right
*
* @return the user ID if found or ''
**/
private static function findUser($value, $entity)
{
global $DB;
$sql = "SELECT `id`\n FROM `glpi_users`\n WHERE LOWER(`name`) = '" . strtolower($value) . "'\n OR (CONCAT(LOWER(`realname`),' ',LOWER(`firstname`)) = '" . strtolower($value) . "'\n OR CONCAT(LOWER(`firstname`),' ',LOWER(`realname`)) = '" . strtolower($value) . "')";
$result = $DB->query($sql);
if ($DB->numrows($result) > 0) {
//check if user has right on the current entity
$ID = $DB->result($result, 0, "id");
$entities = Profile_User::getUserEntities($ID, true);
if (in_array($entity, $entities)) {
return $ID;
}
return self::DROPDOWN_EMPTY_VALUE;
}
return self::DROPDOWN_EMPTY_VALUE;
}
示例13: showMyForm
//.........这里部分代码省略.........
}
echo "</td>";
//do some rights verification
if (!$extauth && haveRight("password_update", "1")) {
echo "<td>" . $LANG['setup'][19] . " :</td>";
echo "<td><input type='password' name='password' value='' size='30' autocomplete='off'>";
echo "</td></tr>";
} else {
echo "<td colspan='2'></tr>";
}
echo "<tr class='tab_bg_1'><td>" . $LANG['common'][43] . " :</td><td>";
if ($extauth && isset($authtype['firstname_field']) && !empty($authtype['firstname_field'])) {
echo $this->fields["firstname"];
} else {
autocompletionTextField($this, "firstname");
}
echo "</td>";
if (!$extauth && haveRight("password_update", "1")) {
echo "<td>" . $LANG['setup'][20] . " :</td>";
echo "<td><input type='password' name='password2' value='' size='30' autocomplete='off'>";
echo "</td></tr>";
} else {
echo "<td colspan='2'></tr>";
}
echo "</td></tr>";
echo "<tr class='tab_bg_1'><td>" . $LANG['setup'][14] . " :</td><td>";
if ($extauth && isset($authtype['email_field']) && !empty($authtype['email_field'])) {
echo $this->fields["email"];
} else {
autocompletionTextField($this, "email", array('name' => "email_form"));
if (!NotificationMail::isUserAddressValid($this->fields["email"])) {
echo "<br><span class='red'>" . $LANG['mailing'][110] . "</span>";
}
}
echo "</td>";
if (!GLPI_DEMO_MODE) {
echo "<td>" . $LANG['setup'][41] . " :</td><td>";
/// Use sesion variable because field in table may be null if same of the global config
Dropdown::showLanguages("language", array('value' => $_SESSION["glpilanguage"]));
} else {
echo "<td colspan='2'> ";
}
echo "</td></tr>";
echo "<tr class='tab_bg_1'><td>" . $LANG['common'][42] . " :</td><td>";
if ($extauth && isset($authtype['mobile_field']) && !empty($authtype['mobile_field'])) {
echo $this->fields["mobile"];
} else {
autocompletionTextField($this, "mobile");
}
echo "</td>";
if (count($_SESSION['glpiprofiles']) > 1) {
echo "<td>" . $LANG['profiles'][13] . " :</td><td>";
$options = array(0 => DROPDOWN_EMPTY_VALUE);
$options += Dropdown::getDropdownArrayNames('glpi_profiles', Profile_User::getUserProfiles($this->fields['id']));
Dropdown::showFromArray("profiles_id", $options, array('value' => $this->fields["profiles_id"]));
} else {
echo "<td colspan='2'> ";
}
echo "</td></tr>";
echo "<tr class='tab_bg_1'><td>" . $LANG['help'][35] . " :</td><td>";
if ($extauth && isset($authtype['phone_field']) && !empty($authtype['phone_field'])) {
echo $this->fields["phone"];
} else {
autocompletionTextField($this, "phone");
}
echo "</td>";
if (!GLPI_DEMO_MODE && count($_SESSION['glpiactiveentities']) > 1) {
$entities = Profile_User::getUserEntities($this->fields['id'], 1);
echo "<td>" . $LANG['profiles'][37] . " :</td><td>";
Dropdown::show('Entity', array('value' => $this->fields['entities_id'], 'entity' => $entities));
} else {
echo "<td colspan='2'> ";
}
echo "</td></tr>";
echo "<tr class='tab_bg_1'><td>" . $LANG['help'][35] . " 2 : </td><td>";
if ($extauth && isset($authtype['phone2_field']) && !empty($authtype['phone2_field'])) {
echo $this->fields["phone2"];
} else {
autocompletionTextField($this, "phone2");
}
echo "</td>";
if (haveRight("config", "w")) {
echo "<td>" . $LANG['setup'][138] . " :</td><td>";
$modes[NORMAL_MODE] = $LANG['setup'][135];
$modes[TRANSLATION_MODE] = $LANG['setup'][136];
$modes[DEBUG_MODE] = $LANG['setup'][137];
Dropdown::showFromArray('use_mode', $modes, array('value' => $this->fields["use_mode"]));
} else {
echo "<td colspan='2'> ";
}
echo "</td></tr>";
echo "<tr><td class='tab_bg_2 center' colspan='4'>";
echo "<input type='submit' name='update' value=\"" . $LANG['buttons'][7] . "\" class='submit'>";
echo "</td></tr>";
echo "</table></form></div>";
$CFG_GLPI["use_ajax_autocompletion"] = $save_autocompletion;
return true;
}
return false;
}