Skip to content
Permalink
Browse files

Add Dashboard Logging

Add Create, Edit, or Delete logging for the following:

- Departments
- Organizations
- Staff
- Task
- Ticket
- User
- Canned Response
- FAQ Categories
- Emails
- FAQs
- Ticket Filters
- Help Topics
- Lists
- Pages
- Roles
- SLA
- Teams
- Email Templates
  • Loading branch information...
aydreeihn committed Feb 26, 2019
1 parent 72974c8 commit 27cfd653f7264c3ea3cd98b36beeac60c6576f7e
@@ -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;
}
@@ -443,6 +443,9 @@ function updateProfile($vars, &$errors) {
));
}
$type = array('type' => 'edited');
Signal::send('object.edited', $this, $type);
return $this->save();
}
@@ -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;
}
@@ -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;
}
@@ -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;
@@ -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();
}
@@ -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)
@@ -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')),
@@ -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++;
}
}
@@ -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)
@@ -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) {
@@ -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)
@@ -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',
@@ -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.'),
@@ -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'])
@@ -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.'),
@@ -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)
@@ -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')),
@@ -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)

0 comments on commit 27cfd65

Please sign in to comment.
You can’t perform that action at this time.