Exemplo n.º 1
0
 public function edit($params)
 {
     $groupId = (int) $params['groupId'];
     if (empty($groupId)) {
         throw new Redirect404Exception();
     }
     $groupDto = $this->service->findGroupById($groupId);
     if (!$this->service->isCurrentUserCanEdit($groupDto)) {
         throw new Redirect404Exception();
     }
     if ($groupId === null) {
         throw new Redirect404Exception();
     }
     $form = new GROUPS_EditGroupForm($groupDto);
     if (OW::getRequest()->isPost() && $form->isValid($_POST)) {
         if ($form->process()) {
             OW::getFeedback()->info(OW::getLanguage()->text('groups', 'edit_success_msg'));
         }
         $this->redirect();
     }
     $this->addForm($form);
     $this->assign('imageUrl', empty($groupDto->imageHash) ? false : $this->service->getGroupImageUrl($groupDto));
     $deleteUrl = OW::getRouter()->urlFor('GROUPS_CTRL_Groups', 'delete', array('groupId' => $groupDto->id));
     $viewUrl = $this->service->getGroupUrl($groupDto);
     $lang = OW::getLanguage()->text('groups', 'delete_confirm_msg');
     $js = UTIL_JsGenerator::newInstance();
     $js->newFunction('window.location.href=url', array('url'), 'redirect');
     $js->jQueryEvent('#groups-delete_btn', 'click', UTIL_JsGenerator::composeJsString('if( confirm({$lang}) ) redirect({$url});', array('url' => $deleteUrl, 'lang' => $lang)));
     $js->jQueryEvent('#groups-back_btn', 'click', UTIL_JsGenerator::composeJsString('redirect({$url});', array('url' => $viewUrl)));
     OW::getDocument()->addOnloadScript($js);
 }
Exemplo n.º 2
0
 public function getToolbar()
 {
     $toolbar = array();
     $groupInfo = $this->getGroupInfo();
     $js = UTIL_JsGenerator::newInstance()->jQueryEvent('#groups_toolbar_flag', 'click', UTIL_JsGenerator::composeJsString('OW.flagContent({$entity}, {$id}, {$title}, {$href}, "groups+flags", {$ownerId});', array('entity' => GROUPS_BOL_Service::WIDGET_PANEL_NAME, 'id' => $this->group->id, 'title' => $groupInfo['title'], 'href' => $groupInfo['url'], 'ownerId' => $this->group->userId)));
     OW::getDocument()->addOnloadScript($js, 1001);
     if ($this->groupService->isCurrentUserCanEdit($this->group)) {
         $toolbar[] = array('label' => OW::getLanguage()->text('groups', 'edit_btn_label'), 'href' => OW::getRouter()->urlForRoute('groups-edit', array('groupId' => $this->groupId)));
     }
     if (OW::getUser()->isAuthenticated() && OW::getUser()->getId() != $this->group->userId) {
         $toolbar[] = array('label' => OW::getLanguage()->text('base', 'flag'), 'href' => 'javascript://', 'id' => 'groups_toolbar_flag');
     }
     $event = new BASE_CLASS_EventCollector('groups.on_toolbar_collect', array('groupId' => $this->groupId));
     OW::getEventManager()->trigger($event);
     foreach ($event->getData() as $item) {
         $toolbar[] = $item;
     }
     return $toolbar;
 }