Exemple #1
0
    /**
     * get all pages
     *
     * @param array $args Arguments array.
     *
     * @return mixed array of items, or false on failure
     */
    public function getall($args)
    {
        // Optional arguments.
        if (!isset($args['startnum']) || empty($args['startnum'])) {
            $args['startnum'] = 0;
        }
        if (!isset($args['numitems']) || empty($args['numitems'])) {
            $args['numitems'] = -1;
        }
        if (!isset($args['ignoreml']) || !is_bool($args['ignoreml'])) {
            $args['ignoreml'] = false;
        }
        if (!isset($args['language'])) {
            $args['language'] = null;
        }
        if (!isset($args['category'])) {
            $args['category'] = null;
        }

        if (!is_numeric($args['startnum']) || !is_numeric($args['numitems'])) {
            return LogUtil::registerArgsError();
        }

        // Security check
        if (!SecurityUtil::checkPermission('Pages::', '::', ACCESS_READ)) {
            return array();
        }

        $catFilter = array();
        if (isset($args['category']) && !empty($args['category'])) {
            if (is_array($args['category'])) {
                $catFilter = $args['category'];
            } elseif (isset($args['property'])) {
                $property = $args['property'];
                $catFilter[$property] = $args['category'];
            }
            $catFilter['__META__'] = array('module' => 'Pages');
        } elseif (isset($args['catfilter'])) {
            $catFilter = $args['catfilter'];
        }

        // populate an array with each part of the where clause and then implode the array if there is a need.
        // credit to Jorg Napp for this technique - markwest
        $table = DBUtil::getTables();
        $pagescolumn = $table['pages_column'];
        $queryargs = array();
        if (System::getVar('multilingual') == 1 && !$args['ignoreml'] && $args['language']) {
            $queryargs[] = '(' . $pagescolumn['language'] . ' = "' . DataUtil::formatForStore($args['language']) . '"'
                    .' OR ' . $pagescolumn['language'] . ' = "")';
        }

        $where = null;
        if (count($queryargs) > 0) {
            $where = ' WHERE ' . implode(' AND ', $queryargs);
        }

        // define the permission filter to apply
        $permFilter   = array();
        $permFilter[] = array('component_left'  => 'Pages',
                'instance_left'   => 'title',
                'instance_right'  => 'pageid',
                'level'           => ACCESS_READ);

        $orderby = $pagescolumn['pageid'];
        if (isset($args['order']) && !empty($args['order'])) {
            $orderby = $pagescolumn[strtolower($args['order'])];
        }
        $orderdir = 'DESC';
        if (isset($args['orderdir']) && !empty($args['orderdir'])) {
            $orderdir = $args['orderdir'];
        }
        $orderby = $orderby . ' ' . $orderdir;

        // get the objects from the db
        $objArray = DBUtil::selectObjectArray(
            'pages',
            $where,
            $orderby,
            $args['startnum']-1,
            $args['numitems'],
            '',
            $permFilter,
            $catFilter
        );

        // check for an error with the database code, and if so set an appropriate
        // error message and return
        if ($objArray === false) {
            return LogUtil::registerError($this->__('Error! Could not load any page.'));
        }

        // need to do this here as the category expansion code can't know the
        // root category which we need to build the relative path component
        if ($objArray && isset($args['catregistry']) && $args['catregistry']) {
            ObjectUtil::postProcessExpandedObjectArrayCategories($objArray, $args['catregistry']);
        }

        // return the items
        return $objArray;
    }
Exemple #2
0
    /**
     * get all feeds feeds
     * @return mixed array of items, or false on failure
     */
    public function getall($args)
    {
        // Optional arguments.
        if (!isset($args['startnum']) || !is_numeric($args['startnum'])) {
            $args['startnum'] = 0;
        }
        if (!isset($args['numitems']) || !is_numeric($args['numitems'])) {
            $args['numitems'] = -1;
        }
        if (!isset($args['category'])) {
            $args['category'] = null;
        }

        if (!is_numeric($args['startnum']) ||
                !is_numeric($args['numitems'])) {
            return LogUtil::registerArgsError();
        }

        $items = array();

        // Security check
        if (!SecurityUtil::checkPermission( 'Feeds::', '::', ACCESS_READ)) {
            return $items;
        }

        $args['catFilter'] = array();
        if (isset($args['category']) && !empty($args['category'])){
            if (is_array($args['category'])) {
                $args['catFilter'] = $args['category'];
            } elseif (isset($args['property'])) {
                $property = $args['property'];
                $args['catFilter'][$property] = $args['category'];
            }
            $args['catFilter']['__META__'] = array('module' => 'Feeds');
        }

        // define the permission filter to apply
        $permFilter = array(array('realm'           => 0,
                        'component_left'  => 'Feeds',
                        'component_right' => 'item',
                        'instance_left'   => 'name',
                        'instance_right'  => 'fid',
                        'level'           => ACCESS_READ));

        $orderby = null;
        if (!empty($args['order'])) {
            $dbtable = DBUtil::getTables();
            $feedscolumn = $dbtable['feeds_column'];
            $orderby = $feedscolumn[$args['order']].' DESC';
        }

        // get the objects from the db
        $objArray = DBUtil::selectObjectArray('feeds', '', 'fid', $args['startnum']-1, $args['numitems'], '', $permFilter, $args['catFilter']);

        if ($objArray === false) {
            return LogUtil::registerError(__('Error! Could not load any Feed.'));
        }

        // need to do this here as the category expansion code can't know the
        // root category which we need to build the relative path component
        if ($objArray && isset($args['catregistry']) && $args['catregistry']) {
            ObjectUtil::postProcessExpandedObjectArrayCategories($objArray, $args['catregistry']);
        }

        // Return the items
        return $objArray;
    }
Exemple #3
0
 /**
  * Get all Quotes
  * @author The Zikula Development Team
  * @author Greg Allan
  * @return array array containing quote id, quote, author
  */
 public function getall($args)
 {
     // security check
     if (!SecurityUtil::checkPermission('Quotes::', '::', ACCESS_READ)) {
         return array();
     }
     $where = $this->_process_args($args);
     $sort = isset($args['sort']) && $args['sort'] ? $args['sort'] : '';
     $sortdir = isset($args['sortdir']) && $args['sortdir'] ? $args['sortdir'] : 'ASC';
     if ($sort) {
         if ($sort == 'qid') {
             $sort .= ' ' . $sortdir;
         } else {
             $sort .= ' ' . $sortdir . ', qid ' . $sortdir;
         }
     } else {
         $sort = 'qid DESC';
     }
     // define the permissions filter to use
     $permFilter = array();
     $permFilter[] = array('realm' => 0, 'component_left' => 'Quotes', 'component_middle' => '', 'component_right' => '', 'instance_left' => 'author', 'instance_middle' => '', 'instance_right' => 'qid', 'level' => ACCESS_READ);
     $args['catFilter'] = array();
     if (isset($args['category']) && !empty($args['category'])) {
         if (is_array($args['category'])) {
             $args['catFilter'] = $args['category'];
         } elseif (isset($args['property'])) {
             $property = $args['property'];
             $args['catFilter'][$property] = $args['category'];
         }
         $args['catFilter']['__META__'] = array('module' => 'Quotes');
     }
     // get the object array from the db
     $objArray = DBUtil::selectObjectArray('quotes', $where, $sort, $args['startnum'], $args['numitems'], '', $permFilter, $args['catFilter']);
     // check for an error with the database code, and if so set an appropriate
     // error message and return
     if ($objArray === false) {
         return LogUtil::registerError($this->__('Error! Could not load any quotes.'));
     }
     // need to do this here as the category expansion code can't know the
     // root category which we need to build the relative path component
     if ($objArray && isset($args['catregistry']) && $args['catregistry']) {
         ObjectUtil::postProcessExpandedObjectArrayCategories($objArray, $args['catregistry']);
     }
     // return the items
     return $objArray;
 }
Exemple #4
0
    /**
     * get all news items
     * @author Mark West
     * @return mixed array of items, or false on failure
     */
    public function getall($args)
    {
        // Optional arguments.
        if (!isset($args['status']) || (empty($args['status']) && $args['status'] !== 0)) {
            $args['status'] = null;
        }
        if (!isset($args['startnum']) || empty($args['startnum'])) {
            $args['startnum'] = 1;
        }
        if (!isset($args['numitems']) || empty($args['numitems'])) {
            $args['numitems'] = -1;
        }
        if (!isset($args['ignoreml']) || !is_bool($args['ignoreml'])) {
            $args['ignoreml'] = false;
        }
        if (!isset($args['language'])) {
            $args['language'] = '';
        }
        if (!isset($args['filterbydate'])) {
            $args['filterbydate'] = true;
        }

        if ((!empty($args['status']) && !is_numeric($args['status'])) ||
                !is_numeric($args['startnum']) ||
                !is_numeric($args['numitems'])) {
            return LogUtil::registerArgsError();
        }

        // create a empty result set
        $items = array();

        // Security check
        if (!SecurityUtil::checkPermission('News::', '::', ACCESS_OVERVIEW)) {
            return $items;
        }

        $where = $this->generateWhere($args);

        $tables = DBUtil::getTables();
        $news_column = $tables['news_column'];
        $orderby = '';
        // Handle the sort order, if nothing requested use admin setting
        if (!isset($args['order'])) {
            $args['order'] = $this->getVar('storyorder');
            switch ($args['order'])
            {
                case 0:
                    $order = 'sid';
                    break;
                case 2:
                    $order = 'weight';
                    break;
                case 1:
                default:
                    $order = 'from';
            }
        } elseif (isset($news_column[$args['order']])) {
            $order = $args['order'];
        }

        // if ordering is used also set the order direction, ascending/descending
        if (!empty($order)) {
            if (isset($args['orderdir']) && in_array(strtoupper($args['orderdir']), array('ASC', 'DESC'))) {
                $orderby = $news_column[$order].' '.strtoupper($args['orderdir']);
            } else {
                $orderby = $news_column[$order].' DESC';
            }
        } elseif ($args['order'] == 'random') {
            $orderby = 'RAND()';
        }

        // if sorted by weight add second ordering "from", since weight is not unique
        if ($order == 'weight') {
            $orderby .= ', ' . $news_column['from'] . ' DESC';
        }

        $permChecker = new News_ResultChecker($this->getVar('enablecategorization'), $this->getVar('enablecategorybasedpermissions'));
        $objArray = DBUtil::selectObjectArrayFilter('news', $where, $orderby, $args['startnum'] - 1, $args['numitems'], '', $permChecker, $this->getCatFilter($args));

        // Check for an error with the database code, and if so set an appropriate
        // error message and return
        if ($objArray === false) {
            return LogUtil::registerError($this->__('Error! Could not load any articles.'));
        }

        // need to do this here as the category expansion code can't know the
        // root category which we need to build the relative path component
        if ($this->getVar('enablecategorization') && $objArray && isset($args['catregistry']) && $args['catregistry']) {
            ObjectUtil::postProcessExpandedObjectArrayCategories($objArray, $args['catregistry']);
        }

        // Return the items
        return $objArray;
    }