Skip to content
Permalink
Browse files

Code Cleanup

- remove unused $thisstaff variables
- pass an array called $extra to the register function so that we can set the interval and file name
- Error Fix: missing curly brace
- Lint Fixes: misspelled method calls
- Add AuditEntry stubs
- Reduce lines of code
  • Loading branch information...
aydreeihn committed Sep 17, 2019
1 parent 5c91dc1 commit ac1e99c434fd550075621d531d8e1e940edcdbf4
@@ -615,8 +615,8 @@ function hasFlag($flag) {
}
function flagChanged($flag, $var) {
if (($this->hasflag($flag) && !$var) ||
(!$this->hasflag($flag) && $var))
if (($this->hasFlag($flag) && !$var) ||
(!$this->hasFlag($flag) && $var))
return true;
}
@@ -771,7 +771,7 @@ function save($refetch=false) {
}
function update($vars, &$errors) {
global $cfg, $thisstaff;
global $cfg;
$id = $this->id;
if ($id && $id != $vars['id'])
@@ -241,7 +241,7 @@ function save($refetch=false) {
}
function update($vars, &$errors=false) {
global $cfg, $thisstaff;
global $cfg;
// very basic checks
$vars['cpasswd']=$this->getPasswd(); //Current decrypted password.
@@ -552,13 +552,13 @@ static function generateId($len=6) {
return $id;
}
static function register($exporter) {
static function register($exporter, $extra=array()) {
if (!$exporter instanceof Exporter)
return false;
$_SESSION['Exports'][$exporter->getId()] = $exporter->getOptions() + array(
'file' => $exporter->getFile(),
'class' => get_class($exporter));
'class' => get_class($exporter)) + $extra ?: $extra;
}
static function load($id) {
@@ -111,8 +111,8 @@ function hasFlag($flag) {
}
function flagChanged($flag, $var) {
if (($this->hasflag($flag) && $var != $flag) ||
(!$this->hasflag($flag) && $var == $flag))
if (($this->hasFlag($flag) && $var != $flag) ||
(!$this->hasFlag($flag) && $var == $flag))
return true;
}
@@ -135,8 +135,8 @@ function hasFlag($flag) {
}
function flagChanged($flag, $var) {
if (($this->hasflag($flag) && $var != $flag) ||
(!$this->hasflag($flag) && $var == $flag))
if (($this->hasFlag($flag) && $var != $flag) ||
(!$this->hasFlag($flag) && $var == $flag))
return true;
}
@@ -119,29 +119,25 @@
if (count($categories)==$count)
$msg = sprintf(__('Successfully deleted %s.'),
_N('selected category', 'selected categories', $count));
if (class_exists('AuditEntry')) {
$data = array();
foreach ($_POST['ids'] as $id) {
$data = AuditEntry::getDataById($id, 'C');
if ($data)
$name = json_decode($data[1], true);
else {
$name = __('NA');
$data = array('C', $id);
}
if (PluginManager::auditPlugin()) {
$type = array('type' => 'deleted');
Signal::send('object.deleted', $data, $type);
}
}
}
}
elseif ($categories > 0)
$warn = sprintf(__('%1$d of %2$d %3$s deleted'), $categories, $count,
_N('selected category', 'selected categories', $count));
elseif (!$errors['err'])
$errors['err'] = sprintf(__('Unable to delete %s.'),
_N('selected category', 'selected categories', $count));
if (PluginManager::auditPlugin() && (count($categories)==$count || $categories>0)) {
$data = array();
foreach ($_POST['ids'] as $id) {
if ($data = AuditEntry::getDataById($id, 'C'))
$name = json_decode($data[2], true);
else {
$name = __('NA');
$data = array('C', $id);
}
$type = array('type' => 'deleted');
Signal::send('object.deleted', $data, $type);
}
}
break;
default:
$errors['err']=sprintf('%s - %s', __('Unknown action'), __('Get technical help!'));
@@ -170,31 +170,25 @@
if($topics && $topics==$count)
$msg = sprintf(__('Successfully deleted %s.'),
_N('selected help topic', 'selected help topics', $count));
if (class_exists('AuditEntry')) {
$data = array();
foreach ($_POST['ids'] as $id) {
$data = AuditEntry::getDataById($id, 'H');
if ($data)
$name = json_decode($data[1], true);
else {
$name = __('NA');
$data = array('H', $id);
}
if (PluginManager::auditPlugin()) {
$type = array('type' => 'deleted');
Signal::send('object.deleted', $data, $type);
}
}
}
}
elseif($topics>0)
$warn = sprintf(__('%1$d of %2$d %3$s deleted'), $topics, $count,
_N('selected help topic', 'selected help topics', $count));
elseif(!$errors['err'])
$errors['err'] = sprintf(__('Unable to delete %s.'),
_N('selected help topic', 'selected help topics', $count));
if (PluginManager::auditPlugin() && ($topics==$count || $topics>0)) {
$data = array();
foreach ($_POST['ids'] as $id) {
if ($data = AuditEntry::getDataById($id, 'H'))
$name = json_decode($data[2], true);
else {
$name = __('NA');
$data = array('H', $id);
}
$type = array('type' => 'deleted');
Signal::send('object.deleted', $data, $type);
}
}
break;
case 'sort':
try {
@@ -100,29 +100,28 @@
->filter(array('id__in'=>$_POST['ids']))
->delete();
if($i && $i==$count) {
if($i && $i==$count)
$msg = sprintf(__('Successfully deleted %s.'),
_N('selected site page', 'selected site pages', $count));
if (PluginManager::auditPlugin()) {
$data = array();
foreach ($_POST['ids'] as $id) {
if ($exists = AuditEntry::getDataById($id, 'G'))
$data = json_decode($exists[1], true);
else
$data['name'] = 'NA';
$data[0] = 'G';
$type = array('type' => 'deleted');
Signal::send('object.deleted', $data, $type);
}
}
}
elseif($i>0)
$warn = sprintf(__('%1$d of %2$d %3$s deleted'), $i, $count,
_N('selected site page', 'selected site pages', $count));
elseif(!$errors['err'])
$errors['err'] = sprintf(__('Unable to delete %s.'),
_N('selected site page', 'selected site pages', $count));
if (PluginManager::auditPlugin() && ($i==$count || $i>0)) {
$data = array();
foreach ($_POST['ids'] as $id) {
if ($data = AuditEntry::getDataById($id, 'G'))
$name = json_decode($data[2], true);
else {
$name = __('NA');
$data = array('G', $id);
}
$type = array('type' => 'deleted');
Signal::send('object.deleted', $data, $type);
}
}
break;
default:
$errors['err']=sprintf('%s - %s', __('Unknown action'), __('Get technical help!'));
@@ -243,6 +243,10 @@ function HashPassword() {}
class SplFileObject {
function fseek() {}
class AuditEntry {
function getDataById() {}
function getTableInfo() {}
}
?>

0 comments on commit ac1e99c

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