Пример #1
0
 /**
  * Work through processed parameters and check for potential issues.
  *
  * @access	private
  * @return	void
  */
 private function doQueryErrorChecks()
 {
     /**************************/
     /* Parameter Error Checks */
     /**************************/
     $totalCategories = 0;
     if (is_array($this->parameters->getParameter('category'))) {
         foreach ($this->parameters->getParameter('category') as $comparisonType => $operatorTypes) {
             foreach ($operatorTypes as $operatorType => $categoryGroups) {
                 foreach ($categoryGroups as $categories) {
                     $totalCategories += count($categories);
                 }
             }
         }
     }
     if (is_array($this->parameters->getParameter('notcategory'))) {
         foreach ($this->parameters->getParameter('notcategory') as $comparisonType => $operatorTypes) {
             foreach ($operatorTypes as $operatorType => $categories) {
                 $totalCategories += count($categories);
             }
         }
     }
     //Too many categories.
     if ($totalCategories > Config::getSetting('maxCategoryCount') && !Config::getSetting('allowUnlimitedCategories')) {
         $this->logger->addMessage(\DynamicPageListHooks::FATAL_TOOMANYCATS, Config::getSetting('maxCategoryCount'));
         return false;
     }
     //Not enough categories.(Really?)
     if ($totalCategories < Config::getSetting('minCategoryCount')) {
         $this->logger->addMessage(\DynamicPageListHooks::FATAL_TOOFEWCATS, Config::getSetting('minCategoryCount'));
         return false;
     }
     //Selection criteria needs to be found.
     if (!$totalCategories && !$this->parameters->isSelectionCriteriaFound()) {
         $this->logger->addMessage(\DynamicPageListHooks::FATAL_NOSELECTION);
         return false;
     }
     //ordermethod=sortkey requires ordermethod=category
     //Delayed to the construction of the SQL query, see near line 2211, gs
     //if (in_array('sortkey',$aOrderMethods) && ! in_array('category',$aOrderMethods)) $aOrderMethods[] = 'category';
     $orderMethods = (array) $this->parameters->getParameter('ordermethod');
     //Throw an error in no categories were selected when using category sorting modes or requesting category information.
     if ($totalCategories == 0 && (in_array('categoryadd', $orderMethods) || $this->parameters->getParameter('addfirstcategorydate') === true)) {
         $this->logger->addMessage(\DynamicPageListHooks::FATAL_CATDATEBUTNOINCLUDEDCATS);
         return false;
     }
     //No more than one type of date at a time!
     //@TODO: Can this be fixed to allow all three later after fixing the article class?
     if (intval($this->parameters->getParameter('addpagetoucheddate')) + intval($this->parameters->getParameter('addfirstcategorydate')) + intval($this->parameters->getParameter('addeditdate')) > 1) {
         $this->logger->addMessage(\DynamicPageListHooks::FATAL_MORETHAN1TYPEOFDATE);
         return false;
     }
     // the dominant section must be one of the sections mentioned in includepage
     if ($this->parameters->getParameter('dominantsection') > 0 && count($this->parameters->getParameter('seclabels')) < $this->parameters->getParameter('dominantsection')) {
         $this->logger->addMessage(\DynamicPageListHooks::FATAL_DOMINANTSECTIONRANGE, count($this->parameters->getParameter('seclabels')));
         return false;
     }
     // category-style output requested with not compatible order method
     if ($this->parameters->getParameter('mode') == 'category' && !array_intersect($orderMethods, ['sortkey', 'title', 'titlewithoutnamespace'])) {
         $this->logger->addMessage(\DynamicPageListHooks::FATAL_WRONGORDERMETHOD, 'mode=category', 'sortkey | title | titlewithoutnamespace');
         return false;
     }
     // addpagetoucheddate=true with unappropriate order methods
     if ($this->parameters->getParameter('addpagetoucheddate') && !array_intersect($orderMethods, ['pagetouched', 'title'])) {
         $this->logger->addMessage(\DynamicPageListHooks::FATAL_WRONGORDERMETHOD, 'addpagetoucheddate=true', 'pagetouched | title');
         return false;
     }
     // addeditdate=true but not (ordermethod=...,firstedit or ordermethod=...,lastedit)
     //firstedit (resp. lastedit) -> add date of first (resp. last) revision
     if ($this->parameters->getParameter('addeditdate') && !array_intersect($orderMethods, ['firstedit', 'lastedit']) && ($this->parameters->getParameter('allrevisionsbefore') || $this->parameters->getParameter('allrevisionssince') || $this->parameters->getParameter('firstrevisionsince') || $this->parameters->getParameter('lastrevisionbefore'))) {
         $this->logger->addMessage(\DynamicPageListHooks::FATAL_WRONGORDERMETHOD, 'addeditdate=true', 'firstedit | lastedit');
         return false;
     }
     // adduser=true but not (ordermethod=...,firstedit or ordermethod=...,lastedit)
     /**
      * @todo allow to add user for other order methods.
      * The fact is a page may be edited by multiple users. Which user(s) should we show? all? the first or the last one?
      * Ideally, we could use values such as 'all', 'first' or 'last' for the adduser parameter.
      */
     if ($this->parameters->getParameter('adduser') && !array_intersect($orderMethods, ['firstedit', 'lastedit']) && !$this->parameters->getParameter('allrevisionsbefore') && !$this->parameters->getParameter('allrevisionssince') && !$this->parameters->getParameter('firstrevisionsince') && !$this->parameters->getParameter('lastrevisionbefore')) {
         $this->logger->addMessage(\DynamicPageListHooks::FATAL_WRONGORDERMETHOD, 'adduser=true', 'firstedit | lastedit');
         return false;
     }
     if ($this->parameters->getParameter('minoredits') && !array_intersect($orderMethods, ['firstedit', 'lastedit'])) {
         $this->logger->addMessage(\DynamicPageListHooks::FATAL_WRONGORDERMETHOD, 'minoredits', 'firstedit | lastedit');
         return false;
     }
     /**
      * If including the Uncategorized, we need the 'dpl_clview': VIEW of the categorylinks table where we have cl_to='' (empty string) for all uncategorized pages. This VIEW must have been created by the administrator of the mediawiki DB at installation. See the documentation.
      */
     if ($this->parameters->getParameter('includeuncat')) {
         //If the view is not there, we can't perform logical operations on the Uncategorized.
         if (!$this->DB->tableExists('dpl_clview')) {
             $sql = 'CREATE VIEW ' . $this->tableNames['dpl_clview'] . " AS SELECT IFNULL(cl_from, page_id) AS cl_from, IFNULL(cl_to, '') AS cl_to, cl_sortkey FROM " . $this->tableNames['page'] . ' LEFT OUTER JOIN ' . $this->tableNames['categorylinks'] . ' ON ' . $this->tableNames['page'] . '.page_id=cl_from';
             $this->logger->addMessage(\DynamicPageListHooks::FATAL_NOCLVIEW, $this->tableNames['dpl_clview'], $sql);
             return false;
         }
     }
     //add*** parameters have no effect with 'mode=category' (only namespace/title can be viewed in this mode)
     if ($this->parameters->getParameter('mode') == 'category' && ($this->parameters->getParameter('addcategories') || $this->parameters->getParameter('addeditdate') || $this->parameters->getParameter('addfirstcategorydate') || $this->parameters->getParameter('addpagetoucheddate') || $this->parameters->getParameter('incpage') || $this->parameters->getParameter('adduser') || $this->parameters->getParameter('addauthor') || $this->parameters->getParameter('addcontribution') || $this->parameters->getParameter('addlasteditor'))) {
         $this->logger->addMessage(\DynamicPageListHooks::WARN_CATOUTPUTBUTWRONGPARAMS);
     }
     //headingmode has effects with ordermethod on multiple components only
     if ($this->parameters->getParameter('headingmode') != 'none' && count($orderMethods) < 2) {
         $this->logger->addMessage(\DynamicPageListHooks::WARN_HEADINGBUTSIMPLEORDERMETHOD, $this->parameters->getParameter('headingmode'), 'none');
         $this->parameters->setParameter('headingmode', 'none');
     }
     //The 'openreferences' parameter is incompatible with many other options.
     if ($this->parameters->isOpenReferencesConflict() && $this->parameters->getParameter('openreferences') === true) {
         $this->logger->addMessage(\DynamicPageListHooks::FATAL_OPENREFERENCES);
         return false;
     }
     return true;
 }
 /**
  * Sets contents of passed object to values from current object.
  *
  * If desired, this method can also make copies of all associated (fkey referrers)
  * objects.
  *
  * @param      object $copyObj An object of Production (or compatible) type.
  * @param      boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
  * @throws     PropelException
  */
 public function copyInto($copyObj, $deepCopy = false)
 {
     $copyObj->setCreationDate($this->creation_date);
     $copyObj->setUpdateDate($this->update_date);
     $copyObj->setRoomId($this->room_id);
     if ($deepCopy) {
         // important: temporarily setNew(false) because this affects the behavior of
         // the getter/setter methods for fkey referrer objects.
         $copyObj->setNew(false);
         foreach ($this->getElements() as $relObj) {
             $copyObj->addElement($relObj->copy($deepCopy));
         }
         foreach ($this->getMessages() as $relObj) {
             $copyObj->addMessage($relObj->copy($deepCopy));
         }
         foreach ($this->getHistorys() as $relObj) {
             $copyObj->addHistory($relObj->copy($deepCopy));
         }
         foreach ($this->getProductionHistorys() as $relObj) {
             $copyObj->addProductionHistory($relObj->copy($deepCopy));
         }
         foreach ($this->getOnlines() as $relObj) {
             $copyObj->addOnline($relObj->copy($deepCopy));
         }
     }
     // if ($deepCopy)
     $copyObj->setNew(true);
     $copyObj->setProductionId(NULL);
     // this is a pkey column, so set to default value
 }
Пример #3
0
 /**
  * Uploader callback function
  * 
  * @param string  $tempPath    Temp path
  * @param string  $tempWebPath Temp webpath
  * @param string  $data        post data
  * @param integer $uploadId    upload id
  * @param array   $fileInfos   file infos
  * @param object  $response    Upload api response object
  * 
  * @return array path and webpath
  */
 public static function uploadFinished($tempPath, $tempWebPath, $data, $uploadId, $fileInfos, $response)
 {
     global $objInit;
     $lang = $objInit->loadLanguageData('Calendar');
     $tup = self::getTemporaryUploadPath($data['field_name'], $uploadId);
     $path = $tup[0] . '/' . $tup[2];
     $webPath = $tup[1] . '/' . $tup[2];
     $arrFiles = array();
     //get allowed file types
     $arrAllowedFileTypes = array();
     if (imagetypes() & IMG_GIF) {
         $arrAllowedFileTypes[] = 'gif';
     }
     if (imagetypes() & IMG_JPG) {
         $arrAllowedFileTypes[] = 'jpg';
         $arrAllowedFileTypes[] = 'jpeg';
     }
     if (imagetypes() & IMG_PNG) {
         $arrAllowedFileTypes[] = 'png';
     }
     $h = opendir($tempPath);
     if ($h) {
         while (false != ($file = readdir($h))) {
             $info = pathinfo($file);
             //skip . and ..
             if ($file == '.' || $file == '..') {
                 continue;
             }
             //delete unwanted files
             if (!in_array(strtolower($info['extension']), $arrAllowedFileTypes) && $data['allowImageOnly']) {
                 $response->addMessage(\Cx\Core_Modules\Upload\Controller\UploadResponse::STATUS_ERROR, $lang["TXT_CALENDAR_IMAGE_UPLOAD_ERROR"], $file);
                 \Cx\Lib\FileSystem\FileSystem::delete_file($tempPath . '/' . $file);
                 continue;
             }
             $arrFiles[] = $file;
         }
         closedir($h);
     }
     // Delete existing files because we need only one file to upload
     if (!empty($arrFiles)) {
         $h = opendir($path);
         if ($h) {
             while (false != ($file = readdir($h))) {
                 //skip . and ..
                 if ($file == '.' || $file == '..') {
                     continue;
                 }
                 \Cx\Lib\FileSystem\FileSystem::delete_file($path . '/' . $file);
             }
         }
     }
     return array($path, $webPath);
 }
Пример #4
0
 /**
  * Sets contents of passed object to values from current object.
  *
  * If desired, this method can also make copies of all associated (fkey referrers)
  * objects.
  *
  * @param      object $copyObj An object of User (or compatible) type.
  * @param      boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
  * @throws     PropelException
  */
 public function copyInto($copyObj, $deepCopy = false)
 {
     $copyObj->setName($this->name);
     $copyObj->setEmail($this->email);
     $copyObj->setPassword($this->password);
     $copyObj->setRoomcreator($this->roomcreator);
     if ($deepCopy) {
         // important: temporarily setNew(false) because this affects the behavior of
         // the getter/setter methods for fkey referrer objects.
         $copyObj->setNew(false);
         foreach ($this->getRooms() as $relObj) {
             $copyObj->addRoom($relObj->copy($deepCopy));
         }
         foreach ($this->getMessages() as $relObj) {
             $copyObj->addMessage($relObj->copy($deepCopy));
         }
         foreach ($this->getHistorys() as $relObj) {
             $copyObj->addHistory($relObj->copy($deepCopy));
         }
         foreach ($this->getProductionHistorys() as $relObj) {
             $copyObj->addProductionHistory($relObj->copy($deepCopy));
         }
         foreach ($this->getOnlines() as $relObj) {
             $copyObj->addOnline($relObj->copy($deepCopy));
         }
         foreach ($this->getPermissions() as $relObj) {
             $copyObj->addPermission($relObj->copy($deepCopy));
         }
     }
     // if ($deepCopy)
     $copyObj->setNew(true);
     $copyObj->setUserId(NULL);
     // this is a pkey column, so set to default value
 }