/** * Override save to add logging * * @return boolean */ public function save() { // Use getInstance, rather than User::get('username'), as existing // user object won't get the right username if it was just updated $username = $this->member()->get('username'); // Don't try to save quotas for auth link temp accounts (negative number usernames) if (is_numeric($username) && $username < 0) { return false; } $action = $this->get('id') ? 'modify' : 'add'; $result = parent::save(); if ($result) { $command = "update_quota '" . $this->get('user_id') . "' '" . $this->get('soft_blocks') . "' '" . $this->get('hard_blocks') . "'"; $cmd = "/bin/sh " . PATH_CORE . "/components/com_tools/scripts/mw {$command} 2>&1 </dev/null"; exec($cmd, $results, $status); // Check exec status if (!isset($status) || $status != 0) { // Something went wrong $this->addError(Lang::txt('COM_MEMBERS_QUOTA_USER_FAILED_TO_SAVE_TO_FILESYSTEM')); return false; } $log = Log::blank(); $log->set('object_type', 'class'); $log->set('object_id', (int) $this->get('id')); $log->set('name', (string) $this->get('alias')); $log->set('action', (string) $action); $log->set('actor_id', (int) User::get('id')); $log->set('soft_blocks', (int) $this->get('soft_blocks')); $log->set('hard_blocks', (int) $this->get('hard_blocks')); $log->set('soft_files', (int) $this->get('soft_files')); $log->set('hard_files', (int) $this->get('hard_files')); $log->save(); } return $result; }
/** * Override destroy to add logging * * @return boolean */ public function destroy() { foreach ($this->groups()->rows() as $group) { if (!$group->destroy()) { $this->addError($group->getError()); return false; } } $result = parent::destroy(); if ($result) { $log = Log::blank(); $log->set('object_type', 'class'); $log->set('object_id', $this->get('id')); $log->set('name', $this->get('alias')); $log->set('action', 'delete'); $log->set('actor_id', User::get('id')); $log->set('soft_blocks', $this->get('soft_blocks')); $log->set('hard_blocks', $this->get('hard_blocks')); $log->set('soft_files', $this->get('soft_files')); $log->set('hard_files', $this->get('hard_files')); $log->save(); } return $result; }