Beispiel #1
0
 public function Index($Offset = FALSE, $Keywords = '')
 {
     $this->Permission(array('Garden.Users.Add', 'Garden.Users.Edit', 'Garden.Users.Delete'), '', FALSE);
     if ($this->Head) {
         $this->Head->AddScript('js/library/jquery.gardenmorepager.js');
         $this->Head->AddScript('/applications/garden/js/user.js');
         $this->Head->Title(Translate('Users'));
     }
     $this->AddSideMenu('garden/user');
     $this->Form->Method = 'get';
     // Input Validation
     $Offset = is_numeric($Offset) ? $Offset : 0;
     if (!$Keywords) {
         $Keywords = $this->Form->GetFormValue('Keywords');
         if ($Keywords) {
             $Offset = 0;
         }
     }
     // Put the Keyword back in the form
     if ($Keywords) {
         $this->Form->SetFormValue('Keywords', $Keywords);
     }
     $UserModel = new Gdn_UserModel();
     $Like = trim($Keywords) == '' ? FALSE : array('u.Name' => $Keywords);
     $Limit = 30;
     $TotalRecords = $UserModel->GetCountLike($Like);
     $this->UserData = $UserModel->GetLike($Like, 'u.Name', 'asc', $Limit, $Offset);
     // Build a pager
     $PagerFactory = new PagerFactory();
     $this->Pager = $PagerFactory->GetPager('MorePager', $this);
     $this->Pager->MoreCode = 'More';
     $this->Pager->LessCode = 'Previous';
     $this->Pager->ClientID = 'Pager';
     $this->Pager->Wrapper = '<tr %1$s><td colspan="5">%2$s</td></tr>';
     $this->Pager->Configure($Offset, $Limit, $TotalRecords, 'user/browse/%1$s/' . urlencode($Keywords));
     // Deliver json data if necessary
     if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
         $this->SetJson('LessRow', $this->Pager->ToString('less'));
         $this->SetJson('MoreRow', $this->Pager->ToString('more'));
         $this->View = 'users';
     }
     $this->Render();
 }