예제 #1
0
 /**
  * Set default class for given set of users
  *
  * @param   array  $users
  * @return  boolean
  */
 public function setDefaultClass($users)
 {
     $class = new QuotasClasses($this->_db);
     $class->load(array('alias' => 'default'));
     if (!$class->id) {
         return false;
     }
     if ($users && count($users) > 0) {
         // Update their class id, and their actual quota will be
         // updated the next time they log in.
         $query = "UPDATE " . $this->_db->quoteName($this->_tbl);
         $query .= " SET `class_id` = " . (int) $class->id;
         $query .= " WHERE `id` IN (" . implode(',', $users) . ")";
         $this->_db->setQuery($query);
         $this->_db->query();
     }
     return true;
 }
예제 #2
0
 /**
  * Check for registered users without quota entries and add them
  *
  * @return     void
  */
 public function importMissingTask()
 {
     // Query for all members in the CMS
     $query = "SELECT `id` FROM `#__users`";
     $this->database->setQuery($query);
     $results = $this->database->loadObjectList();
     if (count($results) > 0) {
         $updates = 0;
         $class = new Tables\QuotasClasses($this->database);
         $class->load(array('alias' => 'default'));
         if (!$class->id) {
             // Output message and redirect
             App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&task=import', false), Lang::txt('COM_MEMBERS_QUOTA_MISSING_DEFAULT_CLASS'), 'error');
             return;
         }
         foreach ($results as $r) {
             $quota = new Tables\UsersQuotas($this->database);
             $quota->load(array('user_id' => $r->id));
             if ($quota->id) {
                 continue;
             }
             $quota->set('user_id', $r->id);
             $quota->set('class_id', $class->id);
             $quota->set('soft_blocks', $class->soft_blocks);
             $quota->set('hard_blocks', $class->hard_blocks);
             $quota->set('soft_files', $class->soft_files);
             $quota->set('hard_files', $class->hard_files);
             $quota->store();
             $updates++;
         }
     }
     // Output message and redirect
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_MEMBERS_QUOTA_MISSING_USERS_IMPORT_SUCCESSFUL', $updates), 'passed');
     return;
 }