예제 #1
0
 /**
  * Override store to make mw call too
  *
  * @param   boolean  $updateNulls
  * @return  boolean
  */
 public function store($updateNulls = false)
 {
     // Use getInstance, rather than User::get('username'), as existing user object won't get the right username if it was just updated
     $username = User::getInstance($this->user_id)->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->id ? 'modify' : 'add';
     $result = parent::store($updateNulls);
     if ($result) {
         $command = "update_quota '{$this->user_id}' '{$this->soft_blocks}' '{$this->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->setError(Lang::txt('COM_MEMBERS_QUOTA_USER_FAILED_TO_SAVE_TO_FILESYSTEM'));
             return false;
         }
         $log = new QuotasLog($this->_db);
         $log->set('object_type', 'user');
         $log->set('object_id', $this->id);
         $log->set('name', $username);
         $log->set('action', $action);
         $log->set('actor_id', User::get('id'));
         $log->set('soft_blocks', $this->soft_blocks);
         $log->set('hard_blocks', $this->hard_blocks);
         $log->set('soft_files', $this->soft_files);
         $log->set('hard_files', $this->hard_files);
         $log->store();
         return true;
     }
     return false;
 }
예제 #2
0
 /**
  * Override delete to add logging
  *
  * @param   string   $pk
  * @return  boolean
  */
 public function delete($pk = null)
 {
     $result = parent::delete($pk);
     if ($result) {
         $log = new QuotasLog($this->_db);
         $log->set('object_type', 'class');
         $log->set('object_id', $this->id);
         $log->set('name', $this->alias);
         $log->set('action', 'delete');
         $log->set('actor_id', User::get('id'));
         $log->set('soft_blocks', $this->soft_blocks);
         $log->set('hard_blocks', $this->hard_blocks);
         $log->set('soft_files', $this->soft_files);
         $log->set('hard_files', $this->hard_files);
         $log->store();
         return true;
     }
     return false;
 }