diff --git a/include/class.dept.php b/include/class.dept.php index a45e34ca67..e7bd44b59e 100644 --- a/include/class.dept.php +++ b/include/class.dept.php @@ -879,6 +879,9 @@ function update($vars, &$errors) { // The ID wasn't available until after the commit $this->path = $this->getFullPath(); $this->save(); + } else { + $type = array('type' => 'edited'); + Signal::send('object.edited', $this, $type); } return true; } diff --git a/include/class.organization.php b/include/class.organization.php index 224b6aeac5..ddec6d1466 100644 --- a/include/class.organization.php +++ b/include/class.organization.php @@ -443,6 +443,9 @@ function updateProfile($vars, &$errors) { )); } + $type = array('type' => 'edited'); + Signal::send('object.edited', $this, $type); + return $this->save(); } diff --git a/include/class.staff.php b/include/class.staff.php index 785369ed96..4d092316ef 100644 --- a/include/class.staff.php +++ b/include/class.staff.php @@ -779,6 +779,9 @@ function updateProfile($vars, &$errors) { ); $this->_config = $_config->getInfo(); + $type = array('type' => 'edited'); + Signal::send('object.edited', $this, $type); + return $this->save(); } @@ -1170,6 +1173,9 @@ function update($vars, &$errors) { if ($this->save()) { if ($vars['welcome_email']) $this->sendResetEmail('registration-staff', false); + + $type = array('type' => 'edited'); + Signal::send('object.edited', $this, $type); return true; } diff --git a/include/class.task.php b/include/class.task.php index 9663610f12..da18142f09 100644 --- a/include/class.task.php +++ b/include/class.task.php @@ -678,6 +678,9 @@ function claim(ClaimForm $form, &$errors) { if ($errors) return false; + $type = array('type' => 'assigned', 'data' => array('claim' => true)); + Signal::send('object.edited', $this, $type); + return $this->assignToStaff($assignee, $form->getComments(), false); } @@ -705,9 +708,6 @@ function assignToStaff($staff, $note, $alert=true) { $this->logEvent('assigned', $data); - $type = array('type' => 'assigned', 'data' => array('name' => $this->getNumber(), 'staff' => $staff->getName()->name)); - Signal::send('object.edited', $this, $type); - return true; } diff --git a/include/class.ticket.php b/include/class.ticket.php index b2aae68a01..9ee811a82c 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -2742,7 +2742,7 @@ function assignToStaff($staff, $note, $alert=true, $user=null) { $this->logEvent('assigned', $data, $user); - $type = array('type' => 'assigned', 'data' => array('name' => $this->getNumber(), 'staff' => $staff->getName()->name)); + $type = array('type' => 'assigned', 'data' => array('claim' => true)); Signal::send('object.edited', $this, $type); return true; diff --git a/include/class.user.php b/include/class.user.php index 49d5af5b18..66c64b04ab 100644 --- a/include/class.user.php +++ b/include/class.user.php @@ -251,6 +251,8 @@ static function fromVars($vars, $create=true, $update=false) { catch (OrmException $e) { return null; } + $type = array('type' => 'created', 'data' => array('id' => $user->getId(), 'name' => $user->getName()->name)); + Signal::send('object.created', $user, $type); Signal::send('user.created', $user); } elseif ($update) { @@ -641,6 +643,9 @@ function delete() { $entry->delete(); } + $type = array('type' => 'deleted', 'data' => array('id' => $this->getId(), 'name' => $this->getName()->name)); + Signal::send('object.deleted', $this, $type); + // Delete user return parent::delete(); } diff --git a/scp/canned.php b/scp/canned.php index 88fdf4b813..af2164d0be 100644 --- a/scp/canned.php +++ b/scp/canned.php @@ -53,6 +53,9 @@ $msg=sprintf(__('Successfully updated %s.'), __('this canned response')); + $type = array('type' => 'edited'); + Signal::send('object.edited', $canned, $type); + //Delete removed attachments. //XXX: files[] shouldn't be changed under any circumstances. // Upload NEW attachments IF ANY - TODO: validate attachment types?? @@ -84,6 +87,8 @@ $premade = Canned::create(); if ($premade->update($_POST,$errors)) { $msg=sprintf(__('Successfully added %s.'), Format::htmlchars($_POST['title'])); + $type = array('type' => 'created'); + Signal::send('object.created', $premade, $type); $_REQUEST['a']=null; //Upload attachments $keepers = $canned_form->getField('attachments')->getClean(); @@ -144,8 +149,11 @@ $i=0; foreach($_POST['ids'] as $k=>$v) { - if(($c=Canned::lookup($v)) && $c->delete()) + if(($c=Canned::lookup($v)) && $c->delete()) { + // $type = array('type' => 'deleted'); + // Signal::send('object.deleted', $c, $type); $i++; + } } if($i==$count) diff --git a/scp/categories.php b/scp/categories.php index fe481645a4..7e482b698e 100644 --- a/scp/categories.php +++ b/scp/categories.php @@ -41,14 +41,16 @@ sprintf(__('Unable to update %s.'), __('this category')), __('Correct any errors below and try again.')); } + $type = array('type' => 'edited'); + Signal::send('object.edited', $category, $type); break; case 'create': $category = Category::create(); if ($category->update($_POST, $errors)) { $msg=sprintf(__('Successfully added %s.'), Format::htmlchars($_POST['name'])); + $_REQUEST['a']=null; $type = array('type' => 'created'); Signal::send('object.created', $category, $type); - $_REQUEST['a']=null; } elseif(!$errors['err']) { $errors['err'] = sprintf('%s %s', sprintf(__('Unable to add %s.'), __('this category')), diff --git a/scp/departments.php b/scp/departments.php index e2b1835c22..07d050dff6 100644 --- a/scp/departments.php +++ b/scp/departments.php @@ -105,6 +105,8 @@ FilterAction::setFilterFlag($filter_actions, 'dept', false); if($d->save()) $num++; + $type = array('type' => 'edited', 'data' => array('type' => 'Enabled')); + Signal::send('object.edited', $d, $type); } if ($num > 0) { @@ -131,6 +133,8 @@ $filter_actions = FilterAction::objects()->filter(array('type' => 'dept', 'configuration' => '{"dept_id":'. $d->getId().'}')); FilterAction::setFilterFlag($filter_actions, 'dept', true); if($d->save()) { + $type = array('type' => 'edited', 'data' => array('type' => 'Disabled')); + Signal::send('object.edited', $d, $type); $num++; } } diff --git a/scp/emails.php b/scp/emails.php index b119d11b45..31c9f2a17e 100644 --- a/scp/emails.php +++ b/scp/emails.php @@ -28,6 +28,8 @@ }elseif($email->update($_POST,$errors)){ $msg=sprintf(__('Successfully updated %s.'), __('this email')); + $type = array('type' => 'edited'); + Signal::send('object.edited', $email, $type); }elseif(!$errors['err']){ $errors['err'] = sprintf('%s %s', sprintf(__('Unable to update %s.'), __('this email')), @@ -40,6 +42,8 @@ $id = $box->getId(); $msg=sprintf(__('Successfully added %s.'), Format::htmlchars($_POST['name'])); $_REQUEST['a']=null; + $type = array('type' => 'created'); + Signal::send('object.created', $box, $type); }elseif(!$errors['err']){ $errors['err']=sprintf('%s %s', sprintf(__('Unable to add %s.'), __('this email')), @@ -57,8 +61,12 @@ case 'delete': $i=0; foreach($_POST['ids'] as $k=>$v) { - if($v!=$cfg->getDefaultEmailId() && ($e=Email::lookup($v)) && $e->delete()) + if($v!=$cfg->getDefaultEmailId() && ($e=Email::lookup($v)) && $e->delete()) { + $type = array('type' => 'deleted'); + Signal::send('object.deleted', $e, $type); $i++; + } + } if($i && $i==$count) diff --git a/scp/faq.php b/scp/faq.php index 8fe053f041..8406b0568c 100644 --- a/scp/faq.php +++ b/scp/faq.php @@ -102,6 +102,8 @@ $errors['err'] = sprintf('%s %s', sprintf(__('Unable to update %s.'), __('this FAQ article')), __('Correct any errors below and try again.')); + $type = array('type' => 'edited'); + Signal::send('object.edited', $faq, $type); break; case 'manage-faq': if(!$faq) { diff --git a/scp/filters.php b/scp/filters.php index 00e6d8da70..5ed1f5fef2 100644 --- a/scp/filters.php +++ b/scp/filters.php @@ -32,6 +32,8 @@ $errors['err']=sprintf(__('%s: Unknown or invalid'), __('ticket filter')); }elseif($filter->update($_POST,$errors)){ $msg=sprintf(__('Successfully updated %s.'), __('this ticket filter')); + $type = array('type' => 'edited'); + Signal::send('object.edited', $filter, $type); }elseif(!$errors['err']){ $errors['err']=sprintf('%s %s', sprintf(__('Unable to update %s.'), __('this ticket filter')), @@ -42,6 +44,8 @@ $filter = new Filter(); if ($filter->update($_POST, $errors)) { $msg=sprintf(__('Successfully updated %s.'), __('this ticket filter')); + $type = array('type' => 'created'); + Signal::send('object.created', $filter, $type); $_REQUEST['a']=null; }elseif(!$errors['err']){ $errors['err'] = sprintf('%s %s', @@ -103,8 +107,12 @@ case 'delete': $i=0; foreach($_POST['ids'] as $k=>$v) { - if(($f=Filter::lookup($v)) && !$f->isSystemBanlist() && $f->delete()) + if(($f=Filter::lookup($v)) && !$f->isSystemBanlist() && $f->delete()) { + $type = array('type' => 'deleted'); + Signal::send('object.deleted', $f, $type); $i++; + } + } if($i && $i==$count) diff --git a/scp/helptopics.php b/scp/helptopics.php index 3d52735210..62251f650a 100644 --- a/scp/helptopics.php +++ b/scp/helptopics.php @@ -30,6 +30,8 @@ }elseif($topic->update($_POST,$errors)){ $msg=sprintf(__('Successfully updated %s.'), __('this help topic')); + $type = array('type' => 'edited'); + Signal::send('object.edited', $topic, $type); }elseif(!$errors['err']){ $errors['err'] = sprintf('%s %s', sprintf(__('Unable to update %s.'), __('this help topic')), @@ -41,6 +43,8 @@ if ($_topic->update($_POST, $errors)) { $topic = $_topic; $msg=sprintf(__('Successfully added %s.'), Format::htmlchars($_POST['topic'])); + $type = array('type' => 'created'); + Signal::send('object.created', $topic, $type); $_REQUEST['a']=null; }elseif(!$errors['err']){ $errors['err']=sprintf('%s %s', diff --git a/scp/lists.php b/scp/lists.php index 3692991377..8e029f17e7 100644 --- a/scp/lists.php +++ b/scp/lists.php @@ -87,6 +87,8 @@ $list->_items = null; $msg = sprintf(__('Successfully updated %s.'), __('this custom list')); + $type = array('type' => 'edited'); + Signal::send('object.edited', $list, $type); } } elseif ($errors) @@ -102,6 +104,8 @@ if ($list=DynamicList::add($_POST, $errors)) { $form = $list->getForm(true); Messages::success(sprintf(__('Successfully added %s.'), __('this custom list'))); + $type = array('type' => 'created'); + Signal::send('object.created', $list, $type); // Redirect to list page $redirect = "lists.php?id={$list->id}#items"; } elseif ($errors) { @@ -124,8 +128,11 @@ case 'delete': $i=0; foreach($_POST['ids'] as $k=>$v) { - if(($t=DynamicList::lookup($v)) && $t->delete()) + if(($t=DynamicList::lookup($v)) && $t->delete()) { + $type = array('type' => 'deleted'); + Signal::send('object.deleted', $t, $type); $i++; + } } if ($i && $i==$count) $msg = sprintf(__('Successfully deleted %s.'), diff --git a/scp/pages.php b/scp/pages.php index c7dc6a068d..32acbffe2f 100644 --- a/scp/pages.php +++ b/scp/pages.php @@ -28,6 +28,8 @@ $pageId = $page->getId(); $_REQUEST['a'] = null; $msg=sprintf(__('Successfully added %s.'), Format::htmlchars($_POST['name'])); + $type = array('type' => 'created'); + Signal::send('object.created', $page, $type); Draft::deleteForNamespace('page'); } elseif(!$errors['err']) $errors['err']=sprintf('%s %s', @@ -41,6 +43,8 @@ elseif($page->update($_POST, $errors)) { $msg=sprintf(__('Successfully updated %s.'), __('this site page')); + $type = array('type' => 'edited'); + Signal::send('object.edited', $page, $type); $_REQUEST['a']=null; //Go back to view Draft::deleteForNamespace('page.'.$page->getId().'%'); } elseif(!$errors['err']) diff --git a/scp/roles.php b/scp/roles.php index fbfd74949a..bd3869646b 100644 --- a/scp/roles.php +++ b/scp/roles.php @@ -37,6 +37,8 @@ __('Role')); } elseif ($role->update($_POST, $errors)) { $msg = __('Role updated successfully'); + $type = array('type' => 'edited'); + Signal::send('object.edited', $role, $type); } elseif ($errors) { $errors['err'] = $errors['err'] ?: sprintf('%s %s', sprintf(__('Unable to update %s.'), __('this role')), @@ -53,6 +55,8 @@ unset($_REQUEST['a']); $msg = sprintf(__('Successfully added %s.'), __('role')); + $type = array('type' => 'created'); + Signal::send('object.created', $_role, $type); } elseif ($errors) { $errors['err'] = sprintf('%s %s', sprintf(__('Unable to add %s.'), __('this role')), @@ -113,8 +117,11 @@ case 'delete': $i=0; foreach ($_POST['ids'] as $k=>$v) { - if (($r=Role::lookup($v)) && $r->isDeleteable() && $r->delete()) + if (($r=Role::lookup($v)) && $r->isDeleteable() && $r->delete()) { + $type = array('type' => 'deleted'); + Signal::send('object.deleted', $r, $type); $i++; + } } if ($i && $i==$count) $msg = sprintf(__('Successfully deleted %s.'), diff --git a/scp/slas.php b/scp/slas.php index 22e3e44e67..32b8bb3e5a 100644 --- a/scp/slas.php +++ b/scp/slas.php @@ -30,6 +30,8 @@ }elseif($sla->update($_POST,$errors)){ $msg=sprintf(__('Successfully updated %s.'), __('this SLA plan')); + $type = array('type' => 'edited'); + Signal::send('object.edited', $sla, $type); }elseif(!$errors['err']){ $errors['err']=sprintf('%s %s', sprintf(__('Unable to update %s.'), __('this SLA plan')), @@ -41,6 +43,8 @@ if (($_sla->update($_POST, $errors))) { $msg=sprintf(__('Successfully added %s.'), __('a SLA plan')); + $type = array('type' => 'created'); + Signal::send('object.created', $_sla, $type); $_REQUEST['a']=null; } elseif (!$errors['err']) { $errors['err']=sprintf('%s %s', @@ -99,8 +103,11 @@ foreach ($_POST['ids'] as $k => $v) { if (($p=SLA::lookup($v)) && $p->getId() != $cfg->getDefaultSLAId() - && $p->delete()) - $i++; + && $p->delete()) { + $type = array('type' => 'deleted'); + Signal::send('object.deleted', $p, $type); + $i++; + } } if($i && $i==$count) diff --git a/scp/teams.php b/scp/teams.php index 5bf93593a8..e4763c6629 100644 --- a/scp/teams.php +++ b/scp/teams.php @@ -27,6 +27,8 @@ }elseif($team->update($_POST,$errors)){ $msg=sprintf(__('Successfully updated %s.'), __('this team')); + $type = array('type' => 'edited'); + Signal::send('object.edited', $team, $type); }elseif(!$errors['err']){ $errors['err']=sprintf('%s %s', sprintf(__('Unable to update %s.'), __('this team')), diff --git a/scp/templates.php b/scp/templates.php index 929e220d5a..02cdea978a 100644 --- a/scp/templates.php +++ b/scp/templates.php @@ -70,6 +70,8 @@ }elseif($template->update($_POST,$errors)){ $msg=sprintf(__('Successfully updated %s.'), mb_convert_case(__('this message template'), MB_CASE_TITLE)); + $type = array('type' => 'edited'); + Signal::send('object.edited', $template, $type); }elseif(!$errors['err']){ $errors['err']=sprintf('%s %s', sprintf(__('Unable to update %s.'), __('this message template')), @@ -82,6 +84,8 @@ $msg=sprintf(__('Successfully added %s.'), mb_convert_case(__('a template set'), MB_CASE_TITLE)); $_REQUEST['a']=null; + $type = array('type' => 'created'); + Signal::send('object.created', $new, $type); }elseif(!$errors['err']){ $errors['err']=sprintf('%s %s', sprintf(__('Unable to add %s.'), __('this message template')), @@ -131,8 +135,12 @@ case 'delete': $i=0; foreach($_POST['ids'] as $k=>$v) { - if(($t=EmailTemplateGroup::lookup($v)) && !$t->isInUse() && $t->delete()) + if(($t=EmailTemplateGroup::lookup($v)) && !$t->isInUse() && $t->delete()) { + $type = array('type' => 'deleted'); + Signal::send('object.deleted', $t, $type); $i++; + } + } if($i && $i==$count)