コード例 #1
0
ファイル: quota.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * Set default class for given set of users
  *
  * @param   array  $users
  * @return  bool
  */
 public static function setDefaultClass($users)
 {
     $deflt = Category::defaultEntry();
     if (!$deflt->get('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.
         $result = self::blank()->getQuery()->update($this->getTableName())->set(array('class_id' => (int) $deflt->get('id')))->whereIn('id', $users)->execute();
         if (!$result) {
             return false;
         }
     }
     return true;
 }
コード例 #2
0
ファイル: quotas.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * Check for registered users without quota entries and add them
  *
  * @return  void
  */
 public function importMissingTask()
 {
     // Query for all members in the CMS
     $results = Member::all()->select('id')->rows();
     if ($results->count() > 0) {
         $updates = 0;
         $class = Category::defaultEntry();
         if (!$class->get('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');
         }
         foreach ($results as $r) {
             $quota = Quota::all()->whereEquals('user_id', $r->get('id'))->row();
             if ($quota->get('id')) {
                 continue;
             }
             $quota->set('user_id', $r->get('id'));
             $quota->set('class_id', $class->get('id'));
             $quota->set('soft_blocks', $class->get('soft_blocks'));
             $quota->set('hard_blocks', $class->get('hard_blocks'));
             $quota->set('soft_files', $class->get('soft_files'));
             $quota->set('hard_files', $class->get('hard_files'));
             $quota->save();
             $updates++;
         }
     }
     // Output message and redirect
     Notify::success(Lang::txt('COM_MEMBERS_QUOTA_MISSING_USERS_IMPORT_SUCCESSFUL', $updates));
     $this->cancelTask();
 }