示例#1
0
 /**
  * @Route("/modify/{gid}", requirements={"gid" = "^[1-9]\d*$"})
  * @Method("GET")
  *
  * Modify a group.
  *
  * @param integer $gid      the id of the group to be modified
  *
  * @return Response symfony response object.
  *
  * @throws NotFoundHttpException Thrown if the requested group isn't found
  * @throws AccessDeniedException Thrown if the user doesn't have edit access to the group
  */
 public function modifyAction($gid = 0)
 {
     // get group
     $item = ModUtil::apiFunc('ZikulaGroupsModule', 'user', 'get', array('gid' => $gid));
     if (!$item) {
         throw new NotFoundHttpException($this->__('Sorry! No such group found.'));
     }
     // Security check
     if (!SecurityUtil::checkPermission('ZikulaGroupsModule::', $item['gid'] . '::', ACCESS_EDIT)) {
         throw new AccessDeniedException();
     }
     // assign the item
     $this->view->assign('item', $item);
     // Setting various defines
     $groupsCommon = new CommonHelper();
     $grouptype = $groupsCommon->gtypeLabels();
     $groupstate = $groupsCommon->stateLabels();
     $this->view->assign('grouptype', $grouptype)->assign('groupstate', $groupstate);
     return new Response($this->view->fetch('Admin/modify.tpl'));
 }
示例#2
0
 /**
  * @Route("/memberlist/{gid}/{startnum}", requirements={"gid" = "^[1-9]\d*$", "startnum" = "\d+"})
  * @Method("GET")
  *
  * display the membership of a group
  *
  * @param integer $gid
  * @param integer $startnum
  *
  * @return Response symfony response object
  *
  * @throws \InvalidArgumentException Thrown if the gid < 1
  * @throws AccessDeniedException Thrown if the user doesn't have overview access to the memberslist component of the module
  */
 public function memberslistAction($gid = 0, $startnum = 0)
 {
     if ($gid < 1) {
         throw new \InvalidArgumentException(__('Invalid arguments array received'));
     }
     $itemsperpage = $this->getVar('itemsperpage');
     if (!SecurityUtil::checkPermission('ZikulaGroupsModule::memberslist', '::', ACCESS_OVERVIEW)) {
         throw new AccessDeniedException();
     }
     $group = ModUtil::apiFunc('ZikulaGroupsModule', 'user', 'get', array('gid' => $gid, 'numitems' => $itemsperpage, 'startnum' => $startnum));
     if (!$group) {
         return DataUtil::formatForDisplay($this->__('Error! Could not load data.'));
     }
     $uid = UserUtil::getVar('uid');
     $groupsCommon = new CommonHelper();
     $typelabel = $groupsCommon->gtypeLabels();
     $statelabel = $groupsCommon->stateLabels();
     $group['typelbl'] = $typelabel[$group['gtype']];
     $group['statelbl'] = $statelabel[$group['state']];
     $this->view->assign('mainpage', false);
     $this->view->assign('group', $group);
     if ($group['members']) {
         $onlines = ModUtil::apiFunc('ZikulaGroupsModule', 'user', 'whosonline');
         $members = array();
         foreach ($group['members'] as $userid) {
             $userinfo = UserUtil::getVars($userid['uid']);
             $userinfo['isonline'] = false;
             if (is_array($onlines)) {
                 foreach ($onlines as $online) {
                     if ($online['uid'] == $userid['uid']) {
                         $userinfo['isonline'] = true;
                         break;
                     }
                 }
             }
             $members[] = $userinfo;
         }
         // test of sorting data
         if (!empty($members)) {
             $sortAarr = array();
             foreach ($members as $res) {
                 $sortAarr[] = strtolower($res['uname']);
             }
             array_multisort($sortAarr, SORT_ASC, $members);
         }
         $this->view->assign('members', $members);
     } else {
         $this->view->assign('members', false);
     }
     if (UserUtil::isLoggedIn()) {
         $this->view->assign('ismember', ModUtil::apiFunc('ZikulaGroupsModule', 'user', 'isgroupmember', array('gid' => $gid, 'uid' => $uid)));
     } else {
         $this->view->assign('ismember', false);
     }
     $this->view->assign('pager', array('numitems' => ModUtil::apiFunc('ZikulaGroupsModule', 'user', 'countgroupmembers', array('gid' => $gid)), 'itemsperpage' => $itemsperpage));
     return new Response($this->view->fetch('User/memberslist.tpl'));
 }
示例#3
0
 /**
  * @Route("/create", options={"expose"=true})
  * @Method("POST")
  *
  * Create a blank group and return it.
  *
  * @return AjaxResponse|ForbiddenResponse|FatalResponse ajax response object
  */
 public function creategroupAction()
 {
     $this->checkAjaxToken();
     if (!SecurityUtil::checkPermission('ZikulaGroupsModule::', '::', ACCESS_ADD)) {
         return new ForbiddenResponse($this->__('You do not have permission for this action.'));
     }
     $groupsCommon = new CommonHelper();
     $typelabel = $groupsCommon->gtypeLabels();
     $statelabel = $groupsCommon->stateLabels();
     // Default values
     $obj = array('name' => '', 'gtype' => CommonHelper::GTYPE_CORE, 'state' => CommonHelper::STATE_CLOSED, 'nbumax' => 0, 'description' => '');
     $group_id = ModUtil::apiFunc('ZikulaGroupsModule', 'admin', 'create', $obj);
     if ($group_id == false) {
         return new FatalResponse($this->__('Error! Could not create the new group.'));
     }
     // update group's name
     $group = $this->entityManager->find('ZikulaGroupsModule:GroupEntity', $group_id);
     $group['name'] = $this->__f('Group %s', $group_id);
     $this->entityManager->flush();
     // convert to array
     $group = $group->toArray();
     $group['statelbl'] = $statelabel[$group['state']];
     $group['gtypelbl'] = $typelabel[$group['gtype']];
     $group['membersurl'] = $this->get('router')->generate('zikulagroupsmodule_admin_groupmembership', array('gid' => $group_id));
     return new AjaxResponse($group);
 }