Skip to content
Snippets Groups Projects
Commit a08de3be authored by Jared Hancock's avatar Jared Hancock
Browse files

orgs: Auto add collaborators to new tickets

parent ce485e04
Branches
Tags
No related merge requests found
......@@ -44,6 +44,18 @@ class OrganizationModel extends VerySimpleModel {
return $this->staff_id;
}
function autoAddCollabs() {
return $this->check(self::COLLAB_ALL_MEMBERS | self::COLLAB_PRIMARY_CONTACT);
}
function autoAddPrimaryContactsAsCollabs() {
return $this->check(self::COLLAB_PRIMARY_CONTACT);
}
function autoAddMembersAsCollabs() {
return $this->check(self::COLLAB_ALL_MEMBERS);
}
function getUpdateDate() {
return $this->updated;
}
......
......@@ -2415,6 +2415,28 @@ class Ticket {
$dept = $ticket->getDept();
// Add organizational collaborators
if ($org && $org->autoAddCollabs()) {
$pris = $org->autoAddPrimaryContactsAsCollabs();
$members = $org->autoAddMembersAsCollabs();
$settings = array('isactive' => true);
$collabs = array();
foreach ($org->allMembers() as $u) {
if ($members || ($pris && $u->isPrimaryContact())) {
if ($c = $this->addCollaborator($u, $settings, $errors)) {
$collabs[] = (string) $c;
}
}
}
//TODO: Can collaborators add others?
if ($collabs) {
//TODO: Change EndUser to name of user.
$this->logNote(sprintf('Collaborators for %s organization added',
$org->getName()),
implode("<br>", $collabs), $org->getName(), false);
}
}
//post the message.
unset($vars['cannedattachments']); //Ticket::open() might have it set as part of open & respond.
$vars['title'] = $vars['subject']; //Use the initial subject as title of the post.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment