/**
  * DOCUMENT ME
  */
 public static function retrieveCategoriesWithCounts()
 {
     $categorizables = aCategoryTable::getCategorizables();
     $q = aCategoryTable::getInstance()->createQuery();
     foreach ($categorizables as $key => $info) {
         $q->leftJoin($info['relation'] . ' ' . $key);
         $q->addSelect(sprintf('COUNT(%s.id)'));
     }
 }
 /**
  * DOCUMENT ME
  * @return mixed
  */
 protected function getTaggedItems()
 {
     $value = $this->slot->getArrayValue();
     $this->items = array();
     $this->itemIds = array();
     // Not set yet
     if (!count($value)) {
         return;
     }
     if (isset($value['form'])) {
         // Tolerate what my early alphas did to save our devs some grief, but don't
         // respect it
         return;
     }
     // We have getBrowseQuery, so reuse it!
     $params = array();
     if (isset($value['categories_list'])) {
         $params['allowed_categories'] = aCategoryTable::getInstance()->createQuery('c')->whereIn('c.id', $value['categories_list'])->execute();
     }
     if (isset($value['tags_list'])) {
         $params['allowed_tags'] = $value['tags_list'];
     }
     if (isset($this->options['constraints'])) {
         foreach ($this->options['constraints'] as $k => $v) {
             $params[$k] = $v;
         }
     }
     $params['type'] = 'image';
     $q = aMediaItemTable::getBrowseQuery($params);
     $q->andWhere('(aMediaItem.view_is_secure IS NULL OR aMediaItem.view_is_secure IS FALSE)');
     $q->limit($value['count']);
     $q->orderBy('aMediaItem.created_at DESC');
     $this->items = $q->execute();
     // shuffle likes real arrays better
     $a = array();
     foreach ($this->items as $item) {
         $a[] = $item;
     }
     $this->items = $a;
     $this->itemIds = aArray::getIds($this->items);
 }
    public function executeIcalFeed(sfWebRequest $request)
    {
        $this->buildParams();
        $this->dateRange = '';
        $this->aEvent = $this->getRoute()->getObject();
        $this->categories = aCategoryTable::getCategoriesForPage($this->page);
        $this->forward404Unless($this->aEvent);
        $this->forward404Unless($this->aEvent['status'] == 'published' || $this->getUser()->isAuthenticated());
        aBlogItemTable::populatePages(array($this->aEvent));
        header("Content-type: text/calendar");
        header('Content-disposition: attachment; filename=' . str_replace('.', '-', $this->getRequest()->getHost() . '-' . $this->aEvent->id) . '.ics');
        $start = $this->aEvent->getVcalStartDateTime();
        $end = $this->aEvent->getVcalEndDateTime();
        $title = aString::toVcal(aHtml::toPlaintext($this->aEvent->getTitle()));
        $body = aString::toVcal(aHtml::toPlaintext($this->aEvent->Page->getAreaText('blog-body')));
        echo <<<EOM
BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VEVENT
CATEGORIES:MEETING
DTSTART:{$start}
DTEND:{$end}
SUMMARY:{$title}
DESCRIPTION:{$body}
CLASS:PRIVATE
END:VEVENT
END:VCALENDAR
EOM;
        exit(0);
    }
Example #4
0
 /**
  * Returns categories that were added to this object by someone else which this user
  * is not eligible to remove
  * @return mixed
  */
 public function getAdminCategories()
 {
     $reserved = array();
     $existing = Doctrine::getTable('aCategory')->createQuery('c')->select('c.*')->innerJoin('c.MediaItems mi WITH mi.id = ?', $this->id)->execute();
     $categoriesForUser = aCategoryTable::getInstance()->addCategoriesForUser(sfContext::getInstance()->getUser()->getGuardUser(), $this->isAdmin())->execute();
     $ours = array_flip(aArray::getIds($categoriesForUser));
     foreach ($existing as $category) {
         if (!isset($ours[$category->id])) {
             $reserved[] = $category;
         }
     }
     return $reserved;
 }