Commit 0af545b0 authored by moyooo's avatar moyooo

end of review Use delegation for create ticket from simplified interface fixed #2734

parent d38a8f61
......@@ -48,8 +48,7 @@ if (!defined('GLPI_ROOT')) {
Session::checkLoginUser();
if ($_POST["delegate"] == 0) {
if ($_POST["nodelegate"] == 1) {
$_POST['_users_id_requester'] = Session::getLoginUserID();
$_POST['right'] = "id";
} else {
......
......@@ -86,13 +86,20 @@ class ChangeTask extends CommonITILTask {
if (!parent::canReadITILItem()) {
return false;
}
return (Session::haveRight("edit_all_change", "1")
$change = new Change();
if ($change->getFromDB($this->fields['changes_id'])) {
return (Session::haveRight("edit_all_change", "1")
|| (Session::haveRight("show_my_change", "1")
&& ($ticket->isUser(CommonITILObject::ASSIGN, Session::getLoginUserID())
&& ($change->isUser(CommonITILObject::ASSIGN, Session::getLoginUserID())
|| (isset($_SESSION["glpigroups"])
&& $ticket->haveAGroup(CommonITILObject::ASSIGN,
&& $change->haveAGroup(CommonITILObject::ASSIGN,
$_SESSION['glpigroups'])))));
} else {
return false;
}
}
......
......@@ -1914,11 +1914,12 @@ abstract class CommonITILObject extends CommonDBTM {
}
echo " ";
if (!isset($options["right"])) {
if (!isset($options["_right"])) {
$right = $this->getDefaultActorRightSearch($type);
} else {
$right = $options["right"];
$right = $options["_right"];
}
if ($options["_users_id_".$typename] == 0) {
$options["_users_id_".$typename] = $this->getDefaultActor($type);
}
......@@ -1956,8 +1957,7 @@ abstract class CommonITILObject extends CommonDBTM {
// display opened tickets for user
if ($type == self::REQUESTER
&& $options["_users_id_".$typename] > 0
&& $_SESSION['glpiactiveprofile']['interface'] == 'central') {
&& $options["_users_id_".$typename] > 0) {
$options2['field'][0] = 4; // users_id
$options2['searchtype'][0] = 'equals';
......@@ -2095,9 +2095,9 @@ abstract class CommonITILObject extends CommonDBTM {
$this->showActorAddFormOnCreate(self::REQUESTER, $options);
} else {
$delegating = User::getDelegateGroupsForUser();
if (!empty($delegating)) {
if (count($delegating)) {
//$this->getDefaultActor(self::REQUESTER);
$options['right'] = "delegate";
$options['_right'] = "delegate";
$this->showActorAddFormOnCreate(self::REQUESTER, $options);
} else {
echo self::getActorIcon('user', self::REQUESTER)." ";
......
......@@ -524,7 +524,7 @@ class Dropdown {
* @param $value preselected value.
* @param $restrict_to allows to display only yes or no in the dropdown (default is yes & no)
*
* @return nothing (print out an HTML select box)
* @return rand value
**/
static function showYesNo($name, $value=0, $restrict_to=-1) {
global $LANG;
......@@ -536,7 +536,7 @@ class Dropdown {
if ($restrict_to != 1) {
$options[1] = $LANG['choice'][1];
}
self::showFromArray($name, $options, array('value' => $value));
return self::showFromArray($name, $options, array('value' => $value));
}
......
......@@ -262,7 +262,9 @@ class Ticket extends CommonITILObject {
}
if ($this->numberOfFollowups()==0 && $this->numberOfTasks()==0
&& $this->isUser(parent::REQUESTER,Session::getLoginUserID())) {
&& ($this->isUser(parent::REQUESTER,Session::getLoginUserID())
|| $this->fields["users_id_recipient"] === Session::getLoginUserID())
) {
return true;
}
......@@ -282,7 +284,8 @@ class Ticket extends CommonITILObject {
}
// user can delete his ticket if no action on it
if ($this->isUser(parent::REQUESTER,Session::getLoginUserID())
if (($this->isUser(parent::REQUESTER,Session::getLoginUserID())
|| $this->fields["users_id_recipient"] === Session::getLoginUserID())
&& $this->numberOfFollowups() == 0
&& $this->numberOfTasks() == 0
&& $this->fields["date"] == $this->fields["date_mod"]) {
......@@ -1633,7 +1636,8 @@ class Ticket extends CommonITILObject {
function canAddFollowups() {
return ((Session::haveRight("add_followups","1")
&& $this->isUser(parent::REQUESTER,Session::getLoginUserID()))
&& ($this->isUser(parent::REQUESTER,Session::getLoginUserID())
|| $this->fields["users_id_recipient"] === Session::getLoginUserID()))
|| Session::haveRight("global_add_followups","1")
|| (Session::haveRight("group_add_followups","1")
&& isset($_SESSION["glpigroups"])
......@@ -2836,7 +2840,7 @@ class Ticket extends CommonITILObject {
// Set default values...
$values = array('_users_id_requester_notif' => array('use_notification' => ($email==""?0:1)),
'delegate' => 0,
'nodelegate' => 1,
'_users_id_requester' => 0,
'name' => '',
'content' => '',
......@@ -2850,7 +2854,7 @@ class Ticket extends CommonITILObject {
'slas_id' => 0,
'_add_validation' => 0,
'type' => -1,
'right' => "id");
'_right' => "id");
// Restore saved value or override with page parameter
......@@ -2870,25 +2874,23 @@ class Ticket extends CommonITILObject {
}
$delegating = User::getDelegateGroupsForUser();
if (!empty($delegating)) {
if (count($delegating)) {
echo "<div class='center'><table class='tab_cadre_fixe'>";
echo "<tr><th colspan='2'>".$LANG['job'][69]."&nbsp;:&nbsp;";
$items[0] = $LANG['choice'][1];
$items[1] = $LANG['choice'][0];
$rand = Dropdown::showFromArray("delegate", $items, array("value" => $options['delegate']));
$rand = Dropdown::showYesNo("nodelegate", $options['nodelegate']);
$params = array ('delegate' => '__VALUE__',
'rand' => $rand,
'right' => "delegate",
'_users_id_requester' => $options['_users_id_requester'],
'_users_id_requester_notif' => $options['_users_id_requester_notif']['use_notification'],
'use_notification' => $options['_users_id_requester_notif']['use_notification'],
'entity_restrict' => $_SESSION["glpiactive_entity"]);
Ajax::UpdateItemOnSelectEvent("dropdown_delegate".$rand, "show_result".$rand, $CFG_GLPI["root_doc"].
$params = array ('nodelegate' => '__VALUE__',
'rand' => $rand,
'right' => "delegate",
'_users_id_requester' => $options['_users_id_requester'],
'_users_id_requester_notif' => $options['_users_id_requester_notif']['use_notification'],
'use_notification' => $options['_users_id_requester_notif']['use_notification'],
'entity_restrict' => $_SESSION["glpiactive_entity"]);
Ajax::UpdateItemOnSelectEvent("dropdown_nodelegate".$rand, "show_result".$rand, $CFG_GLPI["root_doc"].
"/ajax/dropdownDelegationUsers.php", $params);
echo "</th></tr>";
......@@ -2899,8 +2901,9 @@ class Ticket extends CommonITILObject {
if ($options["_users_id_requester"] == 0) {
$options['_users_id_requester'] = Session::getLoginUserID();
} else {
$options['right'] = "delegate";
$options['_right'] = "delegate";
}
$self->showActorAddFormOnCreate(self::REQUESTER, $options);
echo "</div>";
echo "</td></tr>";
......
......@@ -109,11 +109,15 @@ class TicketTask extends CommonITILTask {
if (!parent::canReadITILItem()) {
return false;
}
return (Session::haveRight("global_add_tasks","1")
|| $ticket->isUser(CommonITILObject::ASSIGN, Session::getLoginUserID())
|| (isset($_SESSION["glpigroups"])
&& $ticket->haveAGroup(CommonITILObject::ASSIGN, $_SESSION['glpigroups'])));
$ticket = new Ticket();
if ($ticket->getFromDB($this->fields['tickets_id'])) {
return (Session::haveRight("global_add_tasks","1")
|| $ticket->isUser(CommonITILObject::ASSIGN, Session::getLoginUserID())
|| (isset($_SESSION["glpigroups"])
&& $ticket->haveAGroup(CommonITILObject::ASSIGN, $_SESSION['glpigroups'])));
} else {
return false;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment