/** * List discussions, filtered by various criteria * @params array $filters The array of filters allowed keys * 'state' => array('Y', 'D', 'R') * * Allowed states * Y => OK, * D => Declined * R => awaiting approval * defaults to 'R' - passing an empty array means 'all' * 'category' => The category id to filter for * 'user' => A user's numeric id to filter for */ public function listDiscussions(array $filters = array()) { $filters = array_merge(array('state' => array('Y'), 'limit' => array()), $filters); $dm = $this->_mappers->create('Dolcore_Rdo_DiscussionMapper'); $query = new Horde_Rdo_Query($dm); if ($filters['category']) { $query->addTest('kategorie_id', '=', $filters['category']); } if ($filters['user']) { $query->addTest('benutzer_id', '=', $filters['user']); } if (count($filters['state'])) { $query->addTest('checked', 'IN', $filters['state']); } $query->sortBy('erstelldatum DESC'); return $dm->find($query); }
/** * get any number of pastes from a bin, ordered by date, narrowed by limit and offset * @param string $bin A paste bin to query * @param integer $limit a maximum of pastes to retrieve (optional, default to null = all) * @param integer start a number of pastes to skip before retrieving (optional, default to null = begin with first) * @return array a list of pastes */ public function getPastes($bin, $limit = null, $start = null) { $pm = $this->_mappers->create('Pastie_Entity_PasteMapper'); $query = new Horde_Rdo_Query($pm); $query->sortBy('paste_timestamp DESC'); if ($limit !== null) { if ($start === null) { $start = 0; } $query->limit($limit, $start); } $pastes = array(); foreach ($pm->find($query) as $paste) { $pastes[$paste['paste_uuid']] = $this->_fromBackend($paste); } return $pastes; }