@@ -186,6 +186,7 @@ class labelsGmail
|
||||
$proName = $application['APP_PRO_TITLE'];
|
||||
$threadStatus = $application['DEL_THREAD_STATUS'];
|
||||
$appStatus = $application['APP_STATUS'];
|
||||
$tasUid = $application['TAS_UID'];
|
||||
}
|
||||
|
||||
if($threadStatus == 'CLOSED' || $unassigned == true) {
|
||||
@@ -226,7 +227,6 @@ class labelsGmail
|
||||
|
||||
//Searching the email in the user's mail
|
||||
$q = "subject:('".preg_quote($subject, '-')."') label:('".$labelsToSearch."')";
|
||||
|
||||
$messageList = $this->listMessages($service, $mail, $q, $labelsToRemove);
|
||||
|
||||
foreach ($messageList as $message) {
|
||||
@@ -235,8 +235,57 @@ class labelsGmail
|
||||
$modifyResult = $this->modifyMessage($service, $mail, $messageId, array($labelsToAdd), array($labelsToRemove));
|
||||
|
||||
}
|
||||
|
||||
//in is unassigned we must remove the label to the orher users
|
||||
if ($labelsToRemove === $labelsIds['Unassigned']) {
|
||||
require_once (PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "TaskUser.php");
|
||||
$oTaskUsers = new \TaskUser();
|
||||
$taskUsers = $oTaskUsers->getAllUsersTask($tasUid);
|
||||
foreach ($taskUsers as $user){
|
||||
$usrData = $oUsers->loadDetails($user['USR_UID']);
|
||||
$nextMail = $usrData['USR_EMAIL'];
|
||||
//this operation is just for the users that didn't make the case claim
|
||||
if ($nextMail !== $mail) {
|
||||
$this->changeLabelsOfUnassigned($appData[0], $nextMail);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function changeLabelsOfUnassigned($application, $mail)
|
||||
{
|
||||
$appNumber = $application['APP_NUMBER'];
|
||||
$index = $application['DEL_INDEX'];
|
||||
$threadUsr = $application['USR_UID'];
|
||||
$proName = $application['APP_PRO_TITLE'];
|
||||
$threadStatus = $application['DEL_THREAD_STATUS'];
|
||||
$appStatus = $application['APP_STATUS'];
|
||||
$tasUid = $application['TAS_UID'];
|
||||
|
||||
//The Subject to search the email
|
||||
$subject = "[PM] " .$proName. " Case: ". $appNumber;
|
||||
$pmGoogle = new PMGoogleApi();
|
||||
$pmGoogle->setUser($mail);
|
||||
$pmGoogle->setScope('https://www.googleapis.com/auth/gmail.modify');
|
||||
$client = $pmGoogle->serviceClient();
|
||||
$service = new Google_Service_Gmail($client);
|
||||
$labelsIds = $this->getLabelsIds($service);
|
||||
$labelsToRemove = $labelsIds['Unassigned'];
|
||||
$labelsToSearch = "*-unassigned";
|
||||
$labelsToAdd = $labelsIds['Participated'];
|
||||
|
||||
//Searching the email in the user's mail
|
||||
$q = "subject:('".preg_quote($subject, '-')."') label:('".$labelsToSearch."')";
|
||||
$messageList = $this->listMessages($service, $mail, $q, $labelsToRemove);
|
||||
|
||||
foreach ($messageList as $message) {
|
||||
$messageId = $message->getId();
|
||||
$modifyResult = $this->modifyMessage($service, $mail, $messageId, array($labelsToAdd), array($labelsToRemove));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete Label with given ID.
|
||||
@@ -355,4 +404,3 @@ class labelsGmail
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user