Пример #1
0
 function createAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         // Add the "add new group"-form to the view.
         $form = new Default_Form_AddGroupForm();
         $this->view->form = $form;
         // If the form is posted and valid, add the new group to db.
         $request = $this->getRequest();
         if ($request->isPost()) {
             $post = $request->getPost();
             if ($form->isValid($post)) {
                 // Add new group to db.
                 $groupModel = new Default_Model_Groups();
                 $newGroupId = $groupModel->createGroup($this->replaceWhitespace($post['groupname']), $post['grouptype'], $post['groupdesc'], $post['groupbody']);
                 // Set weblinks
                 $groupWeblinksModel = new Default_Model_GroupWeblinks();
                 if (isset($post['weblinks_name_site1']) && isset($post['weblinks_url_site1'])) {
                     $groupWeblinksModel->setWeblink($newGroupId, $post['weblinks_name_site1'], $post['weblinks_url_site1'], 1);
                 }
                 if (isset($post['weblinks_name_site2']) && isset($post['weblinks_url_site2'])) {
                     $groupWeblinksModel->setWeblink($newGroupId, $post['weblinks_name_site2'], $post['weblinks_url_site2'], 2);
                 }
                 if (isset($post['weblinks_name_site3']) && isset($post['weblinks_url_site3'])) {
                     $groupWeblinksModel->setWeblink($newGroupId, $post['weblinks_name_site3'], $post['weblinks_url_site3'], 3);
                 }
                 if (isset($post['weblinks_name_site4']) && isset($post['weblinks_url_site4'])) {
                     $groupWeblinksModel->setWeblink($newGroupId, $post['weblinks_name_site4'], $post['weblinks_url_site4'], 4);
                 }
                 if (isset($post['weblinks_name_site5']) && isset($post['weblinks_url_site5'])) {
                     $groupWeblinksModel->setWeblink($newGroupId, $post['weblinks_name_site5'], $post['weblinks_url_site5'], 5);
                 }
                 // Add the files to the group
                 $files = $_FILES['content_file_upload'];
                 $filesModel = new Default_Model_Files();
                 $filesModel->newFiles($newGroupId, "group", $files);
                 // Add the current user to the new group.
                 $userHasGroupModel = new Default_Model_UserHasGroup();
                 $userHasGroupModel->addUserToGroup($newGroupId, $this->view->userid);
                 // Make the current user an admin for the new group.
                 $groupAdminModel = new Default_Model_GroupAdmins();
                 $groupAdminModel->addAdminToGroup($newGroupId, $this->view->userid);
                 $target = $this->_urlHelper->url(array('groupid' => $newGroupId, 'language' => $this->view->language), 'group_shortview', true);
                 $this->_redirector->gotoUrl($target);
             }
         }
     } else {
         // Not logged in.
         $target = $this->_urlHelper->url(array('controller' => 'groupsandcampaigns', 'action' => 'index', 'language' => $this->view->language), 'lang_default', true);
         $this->_redirector->gotoUrl($target);
     }
 }
Пример #2
0
 function createAction()
 {
     // Add the "add new group"-form to the view.
     $form = new Default_Form_AddGroupForm();
     $this->view->form = $form;
     // If the form is posted and valid, add the new group to db.
     $request = $this->getRequest();
     if ($request->isPost()) {
         $post = $request->getPost();
         if ($form->isValid($post)) {
             // Add new group to db.
             $groupModel = new Default_Model_Groups();
             $newGroupId = $groupModel->createGroup($post['groupname'], $post['groupdesc'], $post['groupbody']);
             // Add the current user to the new group.
             $userHasGroupModel = new Default_Model_UserHasGroup();
             $userHasGroupModel->addUserToGroup($newGroupId, $this->view->userid);
             // Make the current user an admin for the new group.
             $groupAdminModel = new Default_Model_GroupAdmins();
             $groupAdminModel->addAdminToGroup($newGroupId, $this->view->userid);
             $target = $this->_urlHelper->url(array('groupid' => $newGroupId, 'language' => $this->view->language), 'group_shortview', true);
             $this->_redirector->gotoUrl($target);
         }
     }
 }