Hello,
I have attached a patch for Multiple Requesters (see
https://forge.indepnet.net/issues/show/839). The main part is
functional, but the patch is not ready to commit to SVN yet. I am
including it here to get feedback and comments. Could a few people try
it out and give feedback and suggestions?
Right now it is possible to add multiple requesters after the ticket is
created. Also, if a ticket is created via email, anyone on the cc of the
email will be added as requesters. All requesters can view the ticket
and add follow ups.
Not finished yet:
Email notifications to all requesters.
Additional requesters can follow up by email
Changes to these files still needed:
tracking.function.php
stat.function.php
relation.constant.php, line 328
tools/generate_bigdump.function.php
install/update_0723_080.php
--Ryan Foster
Property changes on: .
___________________________________________________________________
Added: svn:ignore
+ .project
Index: locales/en_GB.php
===================================================================
--- locales/en_GB.php (revision 9181)
+++ locales/en_GB.php (working copy)
@@ -830,6 +830,7 @@
$LANG['log'][95]="cartridge's installation";
$LANG['log'][96]="cartridge's uninstallation";
$LANG['log'][97]="consumable out for the user";
+$LANG['log'][98]="add a requestor";
$LANG['login'][0]="Last login";
$LANG['login'][1]="Log in again";
Index: front/tracking.form.php
===================================================================
--- front/tracking.form.php (revision 9181)
+++ front/tracking.form.php (working copy)
@@ -43,6 +43,49 @@
checkCentralAccess();
+if(isset($_GET['useraction'])) {
+ $ticket_user=new TicketUser();
+ if ($_GET['useraction']=='add')
+ {
+ $ticket_user->check(-1,'w',$_GET);
+ $user=new User();
+ $user->getFromDB($_GET['users_id']);
+ $_GET['user_email']=$user->fields['email'];
+ unset($_GET['id']);
+ if ($_GET['users_id'] > 0
+ && $new_id=$ticket_user->add($_GET)) {
+ logEvent($_GET['tickets_id'], 'tracking', 4, 'tracking',
+ $_SESSION['glpiname'].' '.$LANG['log'][98]);
+ echo '<tr id="row'.$new_id.'"><td>';
+ if(isset($_GET['showuserlink'])) {
+ $name_data=getUserName($user->fields['id'],true);
+ echo $name_data['name'];
+ }
+ else
+ echo getUserName($user->fields['id'],false);
+ echo '</td><td>';
+ echo $user->fields['email'];
+ echo '</td><td>';
+ echo '<img class="calendrier" src="/pics/reset.png" alt="Delete"
title="Delete" '.
+ 'onclick="deleteUser('.$new_id.');" />';
+ echo '</td></tr>';
+ }
+ else
+ echo 'not added';
+ }
+ elseif ($_GET['useraction']=='delete')
+ {
+ $ticket_user->check($_GET['id'],'w');
+ if ($ticket_user->delete($_GET)) {
+ logEvent($_GET['tickets_id'], 'tracking', 4, 'tracking',
+ $_SESSION['glpiname'].' '.$LANG['log'][98]);
+ echo 'deleted';
+ }
+ else
+ echo 'not deleted';
+ }
+ return '';
+}
$fup=new Followup();
$track=new Job();
Index: config/define.php
===================================================================
--- config/define.php (revision 9181)
+++ config/define.php (working copy)
@@ -59,6 +59,7 @@
// MAILGATE CONTROL -> IN DB ?
define("MAX_MAILS_RETRIEVED",10);
+ define("TICKETUSER_TYPE",51);
//OCSNG IMPORT VARIABLES
Index: install/mysql/glpi-0.80-empty.sql
===================================================================
--- install/mysql/glpi-0.80-empty.sql (revision 9181)
+++ install/mysql/glpi-0.80-empty.sql (working copy)
@@ -2947,7 +2947,6 @@
`closedate` datetime default NULL,
`date_mod` datetime default NULL,
`status` varchar(255) collate utf8_unicode_ci default 'new',
- `users_id` int(11) NOT NULL default '0',
`users_id_recipient` int(11) NOT NULL default '0',
`groups_id` int(11) NOT NULL default '0',
`request_type` int(11) NOT NULL default '0',
@@ -2958,8 +2957,6 @@
`items_id` int(11) NOT NULL default '0',
`content` longtext collate utf8_unicode_ci,
`priority` int(11) NOT NULL default '1',
- `user_email` varchar(255) collate utf8_unicode_ci default NULL,
- `use_email_notification` tinyint(1) NOT NULL default '0',
`realtime` float NOT NULL default '0',
`ticketscategories_id` int(11) NOT NULL default '0',
`cost_time` decimal(20,4) NOT NULL default '0.0000',
@@ -2975,7 +2972,6 @@
KEY `users_id_assign` (`users_id_assign`),
KEY `groups_id_assign` (`groups_id_assign`),
KEY `suppliers_id_assign` (`suppliers_id_assign`),
- KEY `users_id` (`users_id`),
KEY `ticketscategories_id` (`ticketscategories_id`),
KEY `entities_id` (`entities_id`),
KEY `groups_id` (`groups_id`),
@@ -3049,6 +3045,20 @@
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+### Dump table glpi_ticketsusers
+
+DROP TABLE IF EXISTS `glpi_ticketsusers`;
+CREATE TABLE `glpi`.`glpi_ticketsusers` (
+ `id` int(11) NOT NULL auto_increment,
+ `tickets_id` int(11) NOT NULL default '0',
+ `users_id` int(11) NOT NULL default '0',
+ `user_email` varchar(255) collate utf8_unicode_ci default NULL,
+ `use_email_notification` tinyint(1) NOT NULL default '0',
+ PRIMARY KEY (`id`),
+ KEY `users_id` (`users_id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+
### Dump table glpi_transfers
DROP TABLE IF EXISTS `glpi_transfers`;
Index: inc/tracking.function.php
===================================================================
--- inc/tracking.function.php (revision 9181)
+++ inc/tracking.function.php (working copy)
@@ -109,15 +109,18 @@
return false;
}
- $search_users_id = " (`glpi_tickets`.`users_id` = '".$_SESSION["glpiID"]."'
+ $search_users_id = " (`glpi_ticketsusers`.`users_id` =
'".$_SESSION["glpiID"]."'
AND (`status` = 'new'
OR `status` = 'plan'
OR `status` = 'assign'
OR `status` = 'waiting'))
OR ";
+ $left_join = " LEFT JOIN `glpi_ticketsusers`
+ ON (`glpi_ticketsusers`.`tickets_id` = `glpi_tickets`.`id`)";
$search_assign = " `users_id_assign` = '".$_SESSION["glpiID"]."' ";
if ($showgrouptickets) {
$search_users_id = "";
+ $left_join = '';
$search_assign = " 0 = 1 ";
if (count($_SESSION['glpigroups'])) {
$groups = implode("','",$_SESSION['glpigroups']);
@@ -134,7 +137,7 @@
}
$query = "SELECT `id`
- FROM `glpi_tickets`";
+ FROM `glpi_tickets`".$left_join;
if ($status=="waiting") { // on affiche les tickets en attente
$query .= "WHERE ($search_assign)
@@ -416,7 +419,9 @@
$query = "SELECT ".getCommonSelectForTrackingSearch()."
FROM `glpi_tickets` ".getCommonLeftJoinForTrackingSearch()."
- WHERE (`glpi_tickets`.`users_id` = '$userID') ".
+ LEFT JOIN `glpi_ticketsusers`
+ ON (`glpi_ticketsusers`.`tickets_id` =
`glpi_tickets`.`id`)
+ WHERE (`glpi_ticketsusers`.`users_id` = '$userID') ".
getEntitiesRestrictRequest("AND","glpi_tickets")."
ORDER BY `glpi_tickets`.`date_mod` DESC
LIMIT ".intval($_SESSION['glpilist_limit']);
@@ -596,8 +601,9 @@
// Fourth Column
$fourth_col = "";
- if ($data['users_id']) {
- $userdata = getUserName($data['users_id'],2);
+ if ($data['users_ids']) {
+ $users_ids = explode(',',$data['users_ids']);
+ $userdata = getUserName($users_ids[0],2);
$comment_display = "";
if ($output_type==HTML_OUTPUT) {
$comment_display = "<a href='".$userdata["link"]."'>";
@@ -1146,6 +1152,7 @@
}
return " DISTINCT `glpi_tickets`.*,
+ `ticketsusers`.`users_ids`,
`glpi_ticketscategories`.`completename` AS catname,
`glpi_groups`.`name` AS groupname
$SELECT";
@@ -1162,7 +1169,19 @@
return " LEFT JOIN `glpi_groups` ON (`glpi_tickets`.`groups_id` =
`glpi_groups`.`id`)
LEFT JOIN `glpi_ticketscategories`
ON (`glpi_tickets`.`ticketscategories_id` =
`glpi_ticketscategories`.`id`)
+ INNER JOIN (SELECT `tickets_id`,
+ GROUP_CONCAT(`users_id` ORDER BY `id` SEPARATOR
',') AS `users_ids`
+ FROM `glpi_ticketsusers`
+ GROUP BY `tickets_id`) AS `ticketsusers`
+ ON `glpi_tickets`.`id` = `ticketsusers`.`tickets_id`
$FROM";
+ /*
+ INNER JOIN (SELECT `tickets_id`, FIRST(`users_id`) as
`first_users_id`
+ FROM `glpi_ticketsusers`
+ GROUP BY `tickets_id`) AS `ticketsusers`
+ ON `glpi_tickets`.`id` = `ticketsusers`.`tickets_id`
+ *
+ */
}
@@ -1246,6 +1265,7 @@
$SELECT = "SELECT ".getCommonSelectForTrackingSearch();
$FROM = " FROM `glpi_tickets` ".
getCommonLeftJoinForTrackingSearch();
+ $join_ticketsusers = '';
if ($search!="" && strpos($tosearch,"followup")!==false) {
$FROM .= " LEFT JOIN `glpi_ticketsfollowups`
@@ -1334,7 +1354,9 @@
$where .= " AND (`glpi_tickets`.`groups_id` IN ('$groups') ";
if ($users_id!=0) {
- $where .= " OR `glpi_tickets`.`users_id` = '$users_id'";
+ $join_ticketsusers = " LEFT JOIN `glpi_ticketsusers`
+ ON (`glpi_ticketsusers`.`tickets_id` = `glpi_tickets`.`id`)";
+ $where .= " OR `glpi_ticketsuser`.`users_id` = '$users_id'";
$search_users_id = true;
}
$where .= ")";
@@ -1342,7 +1364,9 @@
}
if ($users_id!=0 && !$search_users_id) {
- $where .= " AND `glpi_tickets`.`users_id` = '$users_id' ";
+ $join_ticketsusers = " LEFT JOIN `glpi_ticketsusers`
+ ON (`glpi_ticketsusers`.`tickets_id` =
`glpi_tickets`.`id`)";
+ $where .= " AND `glpi_ticketsusers`.`users_id` = '$users_id' ";
}
if (strcmp($users_id_assign,"mine")==0) {
@@ -1361,7 +1385,9 @@
// Display mine but also the ones which i am the users_id
$users_id_part = "";
if (!$search_users_id && isset($_SESSION['glpiID'])) {
- $users_id_part .= " OR `glpi_tickets`.`users_id` =
'".$_SESSION['glpiID']."'";
+ $join_ticketsusers = " LEFT JOIN `glpi_ticketsusers`
+ ON (`glpi_ticketsusers`.`tickets_id` =
`glpi_tickets`.`id`)";
+ $users_id_part .= " OR `glpi_ticketsusers`.`users_id` =
'".$_SESSION['glpiID']."'";
// Get Author group's
if (haveRight("show_group_ticket",1) &&
count($_SESSION["glpigroups"])) {
@@ -1496,6 +1522,7 @@
$query = "$SELECT
$FROM
+ $join_ticketsusers
$where
ORDER BY $sort $order";
@@ -1922,14 +1949,76 @@
} else {
echo "<input type='hidden' name='entities_id'
value='".$job->fields["entities_id"]."'>";
}
- } else if ($canupdate){
- echo $LANG['common'][34]." : </td>";
- echo "<td>";
-
dropdownAllUsers("users_id",$job->fields["users_id"],1,$job->fields["entities_id"]);
} else {
echo $LANG['common'][34]." : </td>";
echo "<td>";
- echo getUserName($job->fields["users_id"],$showuserlink);
+ $rand=mt_rand();
+ $query = "SELECT *
+ FROM `glpi_ticketsusers`
+ WHERE `tickets_id` = '{$job->fields['id']}'
+ ORDER BY `id`";
+ $result=$DB->query($query);
+ echo '<table id="user_table"><tbody>';
+ if ($DB->numrows($result)==0){
+ echo '<tr><td>No requestors</td></tr>';
+ } else {
+ while ($data=$DB->fetch_array($result)){
+ echo '<tr id="row'.$data['id'].'"><td>';
+ echo getUserName($data['users_id'],$showuserlink);
+ echo '</td><td>';
+ echo $data['user_email'];
+ if ($canupdate){
+ echo '</td><td>';
+ echo '<img class="calendrier" src="/pics/reset.png"
alt="Delete" '.
+ 'title="Delete" onclick="deleteUser('.$data['id'].');" />';
+ }
+ echo '</td></tr>';
+ }
+ }
+ echo '</tbody></table>';
+ if ($canupdate) {
+
$dd_rand=dropdownAllUsers('users_id','',1,$job->fields['entities_id']);
+ echo ' <input id="add_user'.$rand.'" type="submit" class="submit" '.
+ 'name="add_user" value="Add" >';
+ echo '<script type="text/javascript" >';
+ echo "
+ function deleteUser(id) {
+ Ext.get('row'+id).hide();
+ Ext.Ajax.request({
+ url: '$target',
+ method: 'GET',
+ params: 'useraction=delete&id=' + id,
+ success: function(response, opts) {
+ if(response.responseText=='deleted')
+ Ext.get('row'+id).remove();
+ else
+ Ext.get('row'+id).show();
+ },
+ failure: function(response, opts) {
+ Ext.get('row'+id).show();
+ }
+ });
+ }
+ Ext.get('add_user$rand').on('click', function (e) {
+ e.stopEvent();
+ userid=Ext.get('dropdown_users_id$dd_rand').dom.value;
+ Ext.Ajax.request({
+ url: '$target',
+ method: 'GET',
+ params: 'useraction=add&users_id=' + userid + '&tickets_id='+
{$job->fields['id']}" .
+ ($showuserlink ? "+'&showuserlink'" : "").",
+ success: function(response, opts) {
+ if(response.responseText!='not added')
+
Ext.get('user_table').first('tbody').insertHtml('beforeEnd',
+ response.responseText);
+ },
+ failure: function(response, opts) {
+ }
+ });
+ });
+ ";
+ echo '</script>'."\n";
+ }
}
echo "</td></tr>";
Index: inc/tracking.class.php
===================================================================
--- inc/tracking.class.php (revision 9181)
+++ inc/tracking.class.php (working copy)
@@ -1567,4 +1567,23 @@
}
+
+class TicketUser extends CommonDBRelation {
+
+ /**
+ * Constructor
+ **/
+ function __construct () {
+ $this->table = 'glpi_ticketsusers';
+ $this->type = TICKETUSER_TYPE;
+
+ $this->itemtype_1 = TRACKING_TYPE;
+ $this->items_id_1 = 'tickets_id';
+
+ $this->itemtype_2 = USER_TYPE;
+ $this->items_id_2 = 'users_id';
+ }
+
+}
+
?>
\ No newline at end of file
Index: inc/mailgate.class.php
===================================================================
--- inc/mailgate.class.php (revision 9181)
+++ inc/mailgate.class.php (working copy)
@@ -316,6 +316,16 @@
if ($result && $DB->numrows($result)) {
$tkt['users_id']=$DB->result($result,0,"id");
}
+
+ foreach($head['cc'] as $cc_email) {
+ $query="SELECT `id`
+ FROM `glpi_users`
+ WHERE `email`='".$cc_email."'";
+ $result=$DB->query($query);
+ if ($result && $DB->numrows($result)) {
+ $tkt['_other_users_ids'][]=$DB->result($result,0,'id');
+ }
+ }
// AUto_import
$tkt['_auto_import']=1;
// For followup : do not check users_id = login user
@@ -516,6 +526,10 @@
$mail_details=array('from'=>utf8_strtolower($sender->mailbox).'@'.$sender->host,
'subject'=>$mail_header->subject);
+ $mail_details['cc']=array();
+ foreach($mail_header->cc as $cc) {
+ $mail_details['cc'][]=utf8_strtolower($cc->mailbox).'@'.$cc->host;
+ }
if (isset($mail_header->references)) {
$mail_details['references'] = $mail_header->references;
}
_______________________________________________
Glpi-dev mailing list
Glpi-dev@gna.org
https://mail.gna.org/listinfo/glpi-dev