Пример #1
0
 /**
  * Create a pdf of all postings belonging to the passed seminar located
  * under the passed topic_id. The PDF is dispatched automatically.
  * 
  * BEWARE: This function never returns, it dies after the PDF has been 
  * (succesfully or not) dispatched.
  * 
  * @param string $seminar_id
  * @param string $parent_id
  */
 static function createPdf($seminar_id, $parent_id = null)
 {
     $seminar_name = get_object_name($seminar_id, 'sem');
     $data = ForumEntry::getList('dump', $parent_id ?: $seminar_id);
     $first_page = true;
     $document = new ExportPDF();
     $document->SetTitle(_('Forum'));
     $document->setHeaderTitle(sprintf(_("Forum \"%s\""), $seminar_name['name']));
     $document->addPage();
     foreach ($data['list'] as $entry) {
         if (Config::get()->FORUM_ANONYMOUS_POSTINGS && $entry['anonymous']) {
             $author = _('anonym');
         } else {
             $author = $entry['author'];
         }
         if ($entry['depth'] == 1) {
             if (!$first_page) {
                 $document->addPage();
             }
             $first_page = false;
             $document->addContent('++++**' . _('Bereich') . ': ' . $entry['name_raw'] . '**++++' . "\n");
             $document->addContent($entry['content_raw']);
             $document->addContent("\n\n");
         } else {
             if ($entry['depth'] == 2) {
                 $document->addContent('++**' . _('Thema') . ': ' . $entry['name_raw'] . '**++' . "\n");
                 $document->addContent('%%' . sprintf(_('erstellt von %s am %s'), $author, strftime('%A %d. %B %Y, %H:%M', (int) $entry['mkdate'])) . '%%' . "\n");
                 $document->addContent($entry['content_raw']);
                 $document->addContent("\n\n");
             } else {
                 if ($entry['depth'] == 3) {
                     $document->addContent('**' . $entry['name_raw'] . '**' . "\n");
                     $document->addContent('%%' . sprintf(_('erstellt von %s am %s'), $author, strftime('%A %d. %B %Y, %H:%M', (int) $entry['mkdate'])) . '%%' . "\n");
                     $document->addContent($entry['content_raw']);
                     $document->addContent("\n--\n");
                 }
             }
         }
     }
     $document->dispatch($seminar_name['name'] . " - Forum");
     die;
 }
Пример #2
0
 /**
  * show the current users favorized entries
  * 
  * @param int $page show entries on submitted page
  */
 function favorites_action($page = null)
 {
     $nav = Navigation::getItem('course/forum2');
     $nav->setImage(Icon::create('forum', 'info'));
     Navigation::activateItem('course/forum2/favorites');
     // set page to which we shall jump
     if ($page) {
         ForumHelpers::setPage($page);
     }
     $this->section = 'favorites';
     $this->topic_id = $this->getId();
     $list = ForumEntry::getList('favorites', $this->topic_id);
     $this->postings = $list['list'];
     $this->number_of_entries = $list['count'];
     $this->show_full_path = true;
     // set default layout
     $layout = $GLOBALS['template_factory']->open('layouts/base');
     $this->set_layout($layout);
     if (empty($this->postings)) {
         $this->no_entries = true;
     }
     // exploit the visitdate for this view
     $this->visitdate = ForumVisit::getLastVisit($this->getId());
     $this->render_action('index');
 }
Пример #3
0
 /**
  * returns the complete seminar or only the passed sub-tree as a html-string
  *
  * @param string $seminar_id
  *
  * @return string
  */
 static function getDump($seminar_id, $parent_id = null)
 {
     $seminar_name = get_object_name($seminar_id, 'sem');
     $content = '<h1>' . _('Forum') . ': ' . $seminar_name['name'] . '</h1>';
     $data = ForumEntry::getList('dump', $parent_id ?: $seminar_id);
     foreach ($data['list'] as $entry) {
         if ($entry['depth'] == 1) {
             $content .= '<h2>' . _('Bereich') . ': ' . $entry['name'] . '</h2>';
             $content .= $entry['content'] . '<br><br>';
         } else {
             if ($entry['depth'] == 2) {
                 $content .= '<h3 style="margin-bottom: 0px;">' . _('Thema') . ': ' . $entry['name'] . '</h3>';
                 $content .= '<i>' . sprintf(_('erstellt von %s am %s'), htmlReady($entry['author']), strftime('%A %d. %B %Y, %H:%M', (int) $entry['mkdate'])) . '</i><br>';
                 $content .= $entry['content'] . '<br><br>';
             } else {
                 if ($entry['depth'] == 3) {
                     $content .= '<b>' . $entry['name'] . '</b><br>';
                     $content .= '<i>' . sprintf(_('erstellt von %s am %s'), htmlReady($entry['author']), strftime('%A %d. %B %Y, %H:%M', (int) $entry['mkdate'])) . '</i><br>';
                     $content .= $entry['content'] . '<hr><br>';
                 }
             }
         }
     }
     return $content;
 }
Пример #4
0
 /**
  * move the submitted topics[] to the passed destination
  * 
  * @param string $destination id of seminar to move topics to
  */
 function move_action($destination)
 {
     // check if destination is a category_id. if yes, use seminar_id instead
     if (ForumCat::get($destination)) {
         $category_id = $destination;
         $destination = $this->getId();
     }
     ForumPerm::check('admin', $this->getId(), $destination);
     foreach (Request::getArray('topics') as $topic_id) {
         // make sure every passed topic_id is checked against the current seminar
         ForumPerm::check('admin', $this->getId(), $topic_id);
         // if the source is an area and the target a category, just move this area to the category
         $entry = ForumEntry::getEntry($topic_id);
         if ($entry['depth'] == 1 && $category_id) {
             ForumCat::removeArea($topic_id);
             ForumCat::addArea($category_id, $topic_id);
         } else {
             // first step: move the whole topic with all childs
             ForumEntry::move($topic_id, $destination);
             // if the current topic id is an area, remove it from any categories
             ForumCat::removeArea($topic_id);
             // second step: move all to deep childs a level up (depth > 3)
             $data = ForumEntry::getList('depth_to_large', $topic_id);
             foreach ($data['list'] as $entry) {
                 $path = ForumEntry::getPathToPosting($entry['topic_id']);
                 array_shift($path);
                 // Category
                 array_shift($path);
                 // Area
                 $thread = array_shift($path);
                 // Thread
                 ForumEntry::move($entry['topic_id'], $thread['id']);
             }
             // add entry to passed category when moving to the top
             if ($category_id) {
                 ForumCat::addArea($category_id, $topic_id);
             }
         }
     }
     $this->render_nothing();
 }