Skip to content
Permalink
Browse files

Code Optimization

We can log some edits in class.orm.php during the save function when this->dirty is generated rather than having to log them all within their classes.
  • Loading branch information...
aydreeihn committed Oct 10, 2019
1 parent 5ba9e89 commit 419a4785837152cadc92ea18de223725be125b9f
@@ -389,16 +389,6 @@ function update($vars, &$errors=false) {
if($errors) return false;
//checkboxes
$vars['noautoresp'] = isset($vars['noautoresp']) ? 1 : 0;
$vars['smtp_spoofing'] = isset($vars['smtp_spoofing']) ? 1 : 0;
foreach ($vars as $key => $value) {
if (isset($this->$key) && ($this->$key != $value)) {
$type = array('type' => 'edited', 'key' => $key);
Signal::send('object.edited', $this, $type);
}
}
$this->mail_errors = 0;
$this->mail_lastfetch = null;
$this->email = $vars['email'];
@@ -360,13 +360,6 @@ function update($vars,&$errors) {
$vars['target'] = 'Email';
}
foreach ($vars as $key => $value) {
if (isset($this->$key) && ($this->$key != $value) && $key != 'rules' && $key != 'actions') {
$type = array('type' => 'edited', 'key' => $key);
Signal::send('object.edited', $this, $type);
}
}
//Note: this will be set when validating filters
if ($vars['email_id'])
$emailId = $vars['email_id'];
@@ -682,6 +682,10 @@ function save($refetch=false) {
else {
$data = array('dirty' => $this->dirty);
Signal::send('model.updated', $this, $data);
foreach ($this->dirty as $key => $value) {
$type = array('type' => 'edited', 'key' => $key, 'orm_audit' => true);
Signal::send('object.edited', $this, $type);
}
}
# Refetch row from database
if ($refetch) {
@@ -268,13 +268,6 @@ function update($vars, &$errors, $allowempty=false) {
if($errors) return false;
foreach ($vars as $key => $value) {
if (isset($this->$key) && ($this->$key != $value)) {
$type = array('type' => 'edited', 'key' => $key);
Signal::send('object.edited', $this, $type);
}
}
$this->type = $vars['type'];
$this->name = $vars['name'];
$this->body = Format::sanitize($vars['body']);
@@ -167,12 +167,6 @@ function update($vars, &$errors) {
if ($errors)
return false;
foreach ($vars as $key => $value) {
if (isset($this->$key) && ($this->$key != $value) && ($key != 'perms')) {
$type = array('type' => 'edited', 'key' => $key);
Signal::send('object.edited', $this, $type);
}
}
$this->name = $vars['name'];
$this->notes = $vars['notes'];
@@ -742,14 +742,6 @@ function updateProfile($vars, &$errors) {
}
$vars['onvacation'] = isset($vars['onvacation']) ? 1 : 0;
foreach ($vars as $key => $value) {
if (isset($this->$key) && ($this->$key != $value)) {
$type = array('type' => 'edited', 'key' => $key);
Signal::send('object.edited', $this, $type);
}
}
$this->firstname = $vars['firstname'];
$this->lastname = $vars['lastname'];
$this->email = $vars['email'];
@@ -1160,14 +1152,6 @@ function update($vars, &$errors) {
$vars['onvacation'] = isset($vars['onvacation']) ? 1 : 0;
$vars['assigned_only'] = isset($vars['assigned_only']) ? 1 : 0;
foreach ($vars as $key => $value) {
if ($key == 'islocked') $key = 'isactive';
if (isset($this->$key) && ($this->$key != $value) && ($key != 'perms') && ($key != 'teams') && ($key != 'dept_access')) {
$type = array('type' => 'edited', 'key' => ($key == 'isactive') ? 'islocked' : $key);
Signal::send('object.edited', $this, $type);
}
}
$this->isadmin = $vars['isadmin'];
$this->isactive = $vars['islocked'];
$this->isvisible = $vars['isvisible'];
@@ -449,9 +449,6 @@ function update($vars, &$errors) {
if ($key == 'status' && $this->getStatus() && strtolower($this->getStatus()) != $value && $this->topic) {
$type = array('type' => 'edited', 'status' => ucfirst($value));
Signal::send('object.edited', $this, $type);
} elseif (isset($this->$key) && ($this->$key != $value) && ($key != 'forms')) {
$type = array('type' => 'edited', 'key' => $key);
Signal::send('object.edited', $this, $type);
}
}
@@ -105,7 +105,7 @@
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())
$i++;
}

0 comments on commit 419a478

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