/** * Initialize form handler. * * This method takes care of all necessary initialisation of our data and form states. * * @return boolean False in case of initialization errors, otherwise true. */ public function initialize(Zikula_Form_View $view) { // we get forumid for edit form to answer to an issue // we get func $func = $this->request->query->filter('func', 'main', FILTER_SANITIZE_STRING); // we get forum for edit form to create a new issue $forum = $this->request->query->filter('forum', 0, FILTER_SANITIZE_NUMBER_INT); // we get parentid for edit form to answer to an issue $parentid = $this->request->query->filter('id', 0, FILTER_SANITIZE_NUMBER_INT); if (!SecurityUtil::checkPermission('MUBoard:Forum:', 'ForumID::1', ACCESS_ADD)) { return $view->registerError(LogUtil::registerPermissionError()); } parent::initialize($view); // build posting repository $repository = MUBoard_Util_Model::getPostingRepository(); if ($func == 'display') { // we get forumid for edit form to answer to an issue if ($parentid > 0) { $entity = $repository->selectById($parentid); $forumOfEntity = $entity->getForum(); $forumid = $forumOfEntity['id']; } else { $forumid = 0; } } else { $id = $this->request->query->filter('id', 0, FILTER_SANITIZE_NUMBER_INT); if ($id > 0) { $entity = $repository->selectById($id); $parent = $entity->getParent(); if ($parent) { $parentid = $parent->getId(); } else { $parentid = 0; } } } // set mode to create if we want to answer if ($func == 'display') { // set mode to create $this->mode = 'create'; } else { // if we func is not display // if id > 0 set mode to edit if ($id > 0) { // set mode to edit $this->mode = 'edit'; } } // rule of token TODO with this we get problems with the edit // because e get always an error messahe nor permissions /* if ($this->mode == 'edit') { $token = $this->request->query->filter('token'); if (SecurityUtil::validateCsrfToken($token)){ // nothing to do } else { if($parentid > 0) { $url = ModUtil::url($this->name, 'user', 'display', array('ot' => 'posting', 'id' => $parentid)); } else { $url = ModUtil::url($this->name, 'user', 'display', array('ot' => 'forum', 'id' => $forum)); } return LogUtil::registerPermissionError($url); } }*/ // get text for the picture upload fields $maxSize = MUBoard_Util_Controller::maxSize(); // get modvars $uploadImages = ModUtil::getVar('MUBoard', 'uploadImages'); $uploadFiles = ModUtil::getVar('MUBoard', 'uploadFiles'); $numberImages = ModUtil::getVar('MUBoard', 'numberImages'); $numberFiles = ModUtil::getVar('MUBoard', 'numberFiles'); // we assign to template $this->view->assign('uploadImages', $uploadImages)->assign('maxSize', $maxSize)->assign('uploadFiles', $uploadFiles)->assign('numberImages', $numberImages)->assign('numberFiles', $numberFiles)->assign('mode', $this->mode)->assign('forum', $forum)->assign('forumid', $forumid)->assign('parentid', $parentid); // everything okay, no initialization errors occured return true; }