示例#1
0
文件: groups.php 项目: vazahat/dudex
 public function inviteList()
 {
     $userId = OW::getUser()->getId();
     if (empty($userId)) {
         throw new AuthenticateException();
     }
     $language = OW::getLanguage();
     OW::getDocument()->setHeading($language->text('groups', 'group_list_heading'));
     OW::getDocument()->setHeadingIconClass('ow_ic_files');
     OW::getDocument()->setTitle($language->text('groups', 'invite_list_page_title'));
     if (!$this->service->isCurrentUserCanViewList()) {
         $this->assign('permissionMessage', $language->text('groups', 'view_no_permission'));
         $templatePath = OW::getPluginManager()->getPlugin('groups')->getCtrlViewDir() . 'no_permission.html';
         $this->setTemplate($templatePath);
         return;
     }
     OW::getRegistry()->set('groups.hide_console_invite_item', true);
     $this->service->markAllInvitesAsViewed($userId);
     $page = !empty($_GET['page']) && intval($_GET['page']) > 0 ? $_GET['page'] : 1;
     $perPage = 20;
     $first = ($page - 1) * $perPage;
     $count = $perPage;
     $dtoList = $this->service->findInvitedGroups($userId, $first, $count);
     $listCount = $this->service->findInvitedGroupsCount($userId);
     $paging = new BASE_CMP_Paging($page, ceil($listCount / $perPage), 5);
     $menu = $this->getGroupListMenu();
     $menu->getElement('invite')->setActive(true);
     $templatePath = OW::getPluginManager()->getPlugin('groups')->getCtrlViewDir() . 'groups_list.html';
     $this->setTemplate($templatePath);
     $acceptUrls = array();
     $declineUrls = array();
     $out = array();
     foreach ($dtoList as $group) {
         $acceptUrls[$group->id] = OW::getRouter()->urlFor('GROUPS_CTRL_Groups', 'join', array('groupId' => $group->id));
         $declineUrls[$group->id] = OW::getRouter()->urlFor('GROUPS_CTRL_Groups', 'declineInvite', array('groupId' => $group->id));
     }
     $acceptLabel = OW::getLanguage()->text('groups', 'invite_accept_label');
     $declineLabel = OW::getLanguage()->text('groups', 'invite_decline_label');
     foreach ($dtoList as $item) {
         /* @var $item GROUPS_BOL_Group */
         $userCount = GROUPS_BOL_Service::getInstance()->findUserListCount($item->id);
         $title = strip_tags($item->title);
         $toolbar = array(array('label' => OW::getLanguage()->text('groups', 'listing_users_label', array('count' => $userCount))), array('href' => $acceptUrls[$item->id], 'label' => $acceptLabel), array('href' => $declineUrls[$item->id], 'label' => $declineLabel));
         $out[] = array('id' => $item->id, 'url' => OW::getRouter()->urlForRoute('groups-view', array('groupId' => $item->id)), 'title' => $title, 'imageTitle' => $title, 'content' => strip_tags($item->description), 'time' => UTIL_DateTime::formatDate($item->timeStamp), 'imageSrc' => GROUPS_BOL_Service::getInstance()->getGroupImageUrl($item), 'users' => $userCount, 'toolbar' => $toolbar);
     }
     $this->addComponent('paging', $paging);
     if (!empty($menu)) {
         $this->addComponent('menu', $menu);
     } else {
         $this->assign('menu', '');
     }
     $this->assign('canCreate', $this->service->isCurrentUserCanCreate());
     $this->assign('list', $out);
 }