public function create() { if (!OW::getUser()->isAuthenticated()) { throw new AuthenticateException(); } $language = OW::getLanguage(); OW::getDocument()->setHeading($language->text('groups', 'create_heading')); OW::getDocument()->setHeadingIconClass('ow_ic_new'); OW::getDocument()->setTitle($language->text('groups', 'create_page_title')); OW::getDocument()->setDescription($language->text('groups', 'create_page_description')); if (!$this->service->isCurrentUserCanCreate()) { $this->assign('permissionMessage', OW::getLanguage()->text('groups', 'create_no_permission')); return; } $eventParams = array('pluginKey' => 'groups', 'action' => 'add_group'); $credits = OW::getEventManager()->call('usercredits.check_balance', $eventParams); if ($credits === false) { $this->assign('permissionMessage', OW::getEventManager()->call('usercredits.error_message', $eventParams)); return; } $this->assign('permissionMessage', false); $form = new GROUPS_CreateGroupForm(); if (OW::getRequest()->isPost() && $form->isValid($_POST)) { $groupDto = $form->process(); if (empty($groupDto)) { $this->redirect(); } $this->service->addUser($groupDto->id, OW::getUser()->getId()); OW::getFeedback()->info($language->text('groups', 'create_success_msg')); $this->redirect($this->service->getGroupUrl($groupDto)); } $this->addForm($form); }
public function create() { if (!OW::getUser()->isAuthenticated()) { throw new AuthenticateException(); } if (!$this->service->isCurrentUserCanCreate()) { $permissionStatus = BOL_AuthorizationService::getInstance()->getActionStatus('groups', 'create'); throw new AuthorizationException($permissionStatus['msg']); } $language = OW::getLanguage(); OW::getDocument()->setHeading($language->text('groups', 'create_heading')); OW::getDocument()->setHeadingIconClass('ow_ic_new'); OW::getDocument()->setTitle($language->text('groups', 'create_page_title')); OW::getDocument()->setDescription($language->text('groups', 'create_page_description')); $form = new GROUPS_CreateGroupForm(); if (OW::getRequest()->isPost() && $form->isValid($_POST)) { $groupDto = $form->process(); if (empty($groupDto)) { $this->redirect(); } $this->service->addUser($groupDto->id, OW::getUser()->getId()); OW::getFeedback()->info($language->text('groups', 'create_success_msg')); $this->redirect($this->service->getGroupUrl($groupDto)); } $this->addForm($form); }