Exemple #1
0
 /**
  * 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;
 }
Exemple #2
0
 /**
  * This function counts the call of a posting
  * @param id   id of the ticket to close
  */
 public static function addView($id)
 {
     // build posting repository
     $repository = MUBoard_Util_Model::getPostingRepository();
     $entity = $repository->selectById($id);
     $serviceManager = ServiceUtil::getManager();
     $entityManager = $serviceManager->getService('doctrine.entitymanager');
     $invocation = $entity->getInvocations();
     $entity->setInvocations($invocation + 1);
     $entityManager->flush();
     return true;
 }
Exemple #3
0
 /**
  *
  */
 public static function actualPostings($userid)
 {
     if (UserUtil::isLoggedIn() == true) {
         // we get a repository for users
         $userrepository = MUBoard_Util_Model::getUserRepository();
         $where = 'tbl.userid = \'' . DataUtil::formatForStore($userid) . '\'';
         $user = $userrepository->selectWhere($where);
         // we get the datetime of the last visit of muboard
         $lastVisit = $user[0]['lastVisit'];
         // we get the timestamp
         $lastVisit = $lastVisit->getTimestamp();
         // we format for
         $lastVisit = date('Y-m-d H:i:s', $lastVisit);
         $date = DateUtil::getDatetime();
         // we get a repository for postings
         $postingrepository = MUBoard_Util_Model::getPostingRepository();
         $where = 'tbl.createdDate > \'' . $lastVisit . '\'';
         $postings = $postingrepository->selectWhere($where);
         $forumids = array();
         $postingids = array();
         foreach ($postings as $posting) {
             // get forum id
             $forum = $posting->getForum();
             $forumid = $forum->getId();
             if (!in_array($forumid, $forumids)) {
                 $forumids[] = $forumid;
             }
             // get posting id
             $parent = $posting->getParent();
             if (!is_null($parent)) {
                 $parentid = $parent->getId();
                 if ($parentid != NULL) {
                     if (!in_array($parentid, $postingids)) {
                         $postingids[] = $parentid;
                     }
                 }
             } else {
                 $id = $posting->getId();
                 if (!in_array($id, $postingids)) {
                     $postingids[] = $id;
                 }
             }
         }
         //SessionUtil::setVar('muboardforumids', $forumids);
         SessionUtil::setVar('muboardpostingids', $postingids);
     }
 }
Exemple #4
0
 /**
  * Executes the actual search process.
  *
  * @param array $args List of arguments.
  *
  * @return boolean
  */
 public function search($args)
 {
     if (!SecurityUtil::checkPermission($this->name . '::', '::', ACCESS_READ)) {
         return '';
     }
     // ensure that database information of Search module is loaded
     ModUtil::dbInfoLoad('Search');
     // save session id as it is used when inserting search results below
     $sessionId = session_id();
     // retrieve list of activated object types
     //$searchTypes = isset($args['objectTypes']) ? (array)$args['objectTypes'] : (array)FormUtil::getPassedValue('search_mediarepository_types', array(), 'GETPOST');
     $searchTypes[] = 'posting';
     $controllerHelper = new MUBoard_Util_Controller($this->serviceManager);
     $utilArgs = array('api' => 'search', 'action' => 'search');
     //$allowedTypes = $controllerHelper->getObjectTypes('api', $utilArgs);
     $allowedTypes[] = 'posting';
     $entityManager = ServiceUtil::getService('doctrine.entitymanager');
     $currentPage = 1;
     $resultsPerPage = 50;
     //  foreach ($searchTypes as $objectType) {
     /* if (!in_array($objectType, $allowedTypes)) {
     		continue;
     		}*/
     $whereArray = array();
     $languageField = null;
     $whereArray[] = 'title';
     $whereArray[] = 'text';
     /*switch ($objectType) {
     		 case 'repository':
     		$whereArray[] = 'name';
     		$whereArray[] = 'workDirectory';
     		$whereArray[] = 'storageDirectory';
     		$whereArray[] = 'cacheDirectory';
     		$whereArray[] = 'uploadNamingPrefix';
     		$whereArray[] = 'mailRecipient';
     		break;
     		case 'mediaHandler':
     		$whereArray[] = 'mimeType';
     		$whereArray[] = 'fileType';
     		$whereArray[] = 'foundMimeType';
     		$whereArray[] = 'foundFileType';
     		$whereArray[] = 'handlerName';
     		$whereArray[] = 'title';
     		$whereArray[] = 'image';
     		break;
     		case 'medium':
     		$whereArray[] = 'title';
     		$whereArray[] = 'keywords';
     		$whereArray[] = 'description';
     		$whereArray[] = 'description2';
     		$whereArray[] = 'dateTaken';
     		$whereArray[] = 'placeTaken';
     		$whereArray[] = 'notes';
     		$whereArray[] = 'license';
     		$whereArray[] = 'areamap';
     		$whereArray[] = 'url';
     		$whereArray[] = 'mediaHandler';
     		$whereArray[] = 'fileUpload';
     		break;
     		case 'thumbSize':
     		$whereArray[] = 'name';
     		break;
     		}*/
     $where = Search_Api_User::construct_where($args, $whereArray, $languageField);
     $repository = $entityManager->getRepository($this->name . '_Entity_' . ucfirst($objectType));
     $repository = MUBoard_Util_Model::getPostingRepository();
     // get objects from database
     list($entities, $objectCount) = $repository->selectWherePaginated($where, '', $currentPage, $resultsPerPage, false);
     if ($objectCount == 0) {
         continue;
     }
     $idFields = ModUtil::apiFunc($this->name, 'selection', 'getIdFields', array('ot' => $objectType));
     $titleField = $repository->getTitleFieldName();
     $descriptionField = $repository->getDescriptionFieldName();
     foreach ($entities as $entity) {
         $urlArgs = array('ot' => $objectType);
         // create identifier for permission check
         $instanceId = '';
         foreach ($idFields as $idField) {
             $urlArgs[$idField] = $entity[$idField];
             if (!empty($instanceId)) {
                 $instanceId .= '_';
             }
             $instanceId .= $entity[$idField];
         }
         $urlArgs['id'] = $instanceId;
         if (isset($entity['slug'])) {
             $urlArgs['slug'] = $entity['slug'];
         }
         if (!SecurityUtil::checkPermission($this->name . ':' . ucfirst($objectType) . ':', $instanceId . '::', ACCESS_OVERVIEW)) {
             continue;
         }
         $title = $titleField != '' ? $entity[$titleField] : $this->__('Item');
         $description = $descriptionField != '' ? $entity[$descriptionField] : '';
         $created = isset($entity['createdDate']) ? $entity['createdDate'] : '';
         $searchItem = array('title' => $title, 'text' => $description, 'extra' => serialize($urlArgs), 'created' => $created, 'module' => $this->name, 'session' => $sessionId);
         if (!DBUtil::insertObject($searchItem, 'search_result')) {
             return LogUtil::registerError($this->__('Error! Could not save the search results.'));
         }
     }
     //  }
     return true;
 }
Exemple #5
0
 /**
  * this function change the forum for the children of a posting
  * $args
  */
 public function movetoforum($args)
 {
     $work = $this->request->query->filter('work', 'none', FILTER_SANITIZE_STRING);
     $args['postingid'] = $this->getId();
     $forum = $args['forum'];
     $children = $args['children'];
     if ($work == 'movetoforum') {
         $serviceManager = ServiceUtil::getManager();
         $entityManager = $serviceManager->getService('doctrine.entitymanager');
         $postingrepository = MUBoard_Util_Model::getPostingRepository();
         foreach ($children as $child) {
             $posting = $postingrepository->selectById($child['id']);
             $posting->setForum($forum);
             $entityManager->flush();
         }
     }
 }
Exemple #6
0
 /**
  * This method get the abos of the relevant posting and return the mailadresses
  * @param int $postingid      id of the relevant issue
  */
 protected static function getPostingAbos()
 {
     // we get a posting repository
     $repository = MUBoard_Util_Model::getPostingRepository();
 }