本文整理汇总了PHP中Profile_User类的典型用法代码示例。如果您正苦于以下问题:PHP Profile_User类的具体用法?PHP Profile_User怎么用?PHP Profile_User使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Profile_User类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: Profile
GLPI is free software; you can redistribute it and/or modify
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, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
include '../inc/includes.php';
Session::checkCentralAccess();
$profile = new Profile();
$right = new Profile_User();
$user = new User();
if (isset($_POST["add"])) {
$right->check(-1, CREATE, $_POST);
if ($right->add($_POST)) {
Event::log($_POST["users_id"], "users", 4, "setup", sprintf(__('%s adds a user to an entity'), $_SESSION["glpiname"]));
}
Html::back();
}
Html::displayErrorAndDie("lost");
示例3: 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>
示例4: cleanDBonPurge
function cleanDBonPurge()
{
global $DB;
$gpr = new ProfileRight();
$gpr->cleanDBonItemDelete($this->getType(), $this->fields['id']);
$gpu = new Profile_User();
$gpu->cleanDBonItemDelete($this->getType(), $this->fields['id']);
Rule::cleanForItemAction($this);
// PROFILES and UNIQUE_PROFILE in RuleMailcollector
Rule::cleanForItemCriteria($this, 'PROFILES');
Rule::cleanForItemCriteria($this, 'UNIQUE_PROFILE');
$gki = new KnowbaseItem_Profile();
$gki->cleanDBonItemDelete($this->getType(), $this->fields['id']);
$gr = new Profile_Reminder();
$gr->cleanDBonItemDelete($this->getType(), $this->fields['id']);
}
示例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: 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
//.........这里部分代码省略.........
示例7: prepareInputDataForProcess
/**
* @see RuleCollection::prepareInputDataForProcess()
**/
function prepareInputDataForProcess($input, $params)
{
$input['mailcollector'] = $params['mailcollector'];
$input['_users_id_requester'] = $params['_users_id_requester'];
$fields = $this->getFieldsToLookFor();
//Add needed ticket datas for rules processing
if (isset($params['ticket']) && is_array($params['ticket'])) {
foreach ($params['ticket'] as $key => $value) {
if (in_array($key, $fields) && !isset($input[$key])) {
$input[$key] = $value;
}
}
}
//Add needed headers for rules processing
if (isset($params['headers']) && is_array($params['headers'])) {
foreach ($params['headers'] as $key => $value) {
if (in_array($key, $fields) && !isset($input[$key])) {
$input[$key] = $value;
}
}
}
//Add all user's groups
if (in_array('groups', $fields)) {
foreach (Group_User::getUserGroups($input['_users_id_requester']) as $group) {
$input['GROUPS'][] = $group['id'];
}
}
//Add all user's profiles
if (in_array('profiles', $fields)) {
foreach (Profile_User::getForUser($input['_users_id_requester']) as $profile) {
$input['PROFILES'][$profile['profiles_id']] = $profile['profiles_id'];
}
}
//If the criteria is "user has only one time the profile xxx"
if (in_array('unique_profile', $fields)) {
//Get all profiles
$profiles = Profile_User::getForUser($input['_users_id_requester']);
foreach ($profiles as $profile) {
if (Profile_User::haveUniqueRight($input['_users_id_requester'], $profile['profiles_id'])) {
$input['UNIQUE_PROFILE'][$profile['profiles_id']] = $profile['profiles_id'];
}
}
}
//Store the number of profiles of which the user belongs to
if (in_array('one_profile', $fields)) {
$profiles = Profile_User::getForUser($input['_users_id_requester']);
if (count($profiles) == 1) {
$tmp = array_pop($profiles);
$input['ONE_PROFILE'] = $tmp['profiles_id'];
}
}
//Store the number of profiles of which the user belongs to
if (in_array('known_domain', $fields)) {
if (preg_match("/@(.*)/", $input['from'], $results)) {
if (Entity::getEntityIDByDomain($results[1]) != -1) {
$input['KNOWN_DOMAIN'] = 1;
} else {
$input['KNOWN_DOMAIN'] = 0;
}
}
}
return $input;
}
示例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: 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);
//.........这里部分代码省略.........
示例10: Config
break;
case 3:
Ticket::showListForUser($_POST["id"]);
break;
case 4:
Group_User::showForUser($user);
break;
case 5:
Document::showAssociated($user);
break;
case 6:
$config = new Config();
$user->computePreferences();
$config->showFormUserPrefs($user->fields);
break;
case 11:
Reservation::showForUser($_POST["id"]);
break;
case 12:
Auth::showSynchronizationForm($_POST["id"]);
break;
case 13:
Log::showForItem($user);
break;
default:
if (!Plugin::displayAction($user, $_REQUEST['glpi_tab'])) {
Profile_User::showForUser($user);
}
}
}
ajaxFooter();
示例11: addToAddressesList
/**
* Add new mail with lang to current email array
*
* @param $data : array of data (mail, lang)
**/
function addToAddressesList($data)
{
global $CFG_GLPI;
$new_mail = trim(utf8_strtolower($data['email']));
$new_lang = '';
if (isset($data['language'])) {
$new_lang = trim($data['language']);
}
$username = '';
if (isset($data['name']) && !empty($data['name'])) {
$username = $data['name'];
}
if (isset($data['id']) && $data['id'] > 0) {
$user = new User();
if (!$user->getFromDB($data['id']) || $user->getField('is_deleted') == 1 || $user->getField('is_active') == 0) {
// unknown, deleted or disabled user
return false;
}
$filt = getEntitiesRestrictRequest('AND', 'glpi_profiles_users', '', $this->getEntity(), true);
$prof = Profile_User::getUserProfiles($data['id'], $filt);
if (!count($prof)) {
// No right on the entity of the object
return false;
}
if (empty($username)) {
$username = formatUserName(0, $user->getField('name'), $user->getField('realname'), $user->getField('firstname'), 0, 0, true);
}
}
$notificationoption = $this->addAdditionnalUserInfo($data);
if (!empty($new_mail)) {
if (NotificationMail::isUserAddressValid($new_mail) && !isset($this->target[$new_mail])) {
$this->target[$new_mail] = array('language' => empty($new_lang) ? $CFG_GLPI["language"] : $new_lang, 'email' => $new_mail, 'additionnaloption' => $notificationoption, 'username' => $username);
}
}
}
示例12: define
(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.
--------------------------------------------------------------------------
*/
define('GLPI_ROOT', '..');
include GLPI_ROOT . "/inc/includes.php";
$profile = new Profile();
$right = new Profile_User();
$user = new User();
if (isset($_POST["add"])) {
$right->check(-1, 'w', $_POST);
if ($right->add($_POST)) {
Event::log($_POST["users_id"], "users", 4, "setup", $_SESSION["glpiname"] . " " . $LANG['log'][61]);
}
glpi_header($_SERVER['HTTP_REFERER']);
} else {
if (isset($_POST["delete"])) {
if (isset($_POST["item"]) && count($_POST["item"])) {
foreach ($_POST["item"] as $key => $val) {
if ($val == 1) {
if ($right->can($key, 'w')) {
$right->delete(array('id' => $key));
}
示例13: 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);
//.........这里部分代码省略.........
示例14: 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));
示例15: Profile
GLPI is free software; you can redistribute it and/or modify
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, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
include '../inc/includes.php';
Session::checkCentralAccess();
$profile = new Profile();
$right = new Profile_User();
$user = new User();
if (isset($_POST["add"])) {
$right->check(-1, 'w', $_POST);
if ($right->add($_POST)) {
Event::log($_POST["users_id"], "users", 4, "setup", sprintf(__('%s adds a user to an entity'), $_SESSION["glpiname"]));
}
Html::back();
}
Html::displayErrorAndDie("lost");