function save_order_action() { ForumPerm::check('sort_area', $this->getId()); foreach (Request::getArray('areas') as $category_id => $areas) { $pos = 0; foreach ($areas as $area_id) { ForumPerm::checkCategoryId($this->getId(), $category_id); ForumPerm::check('sort_area', $this->getId(), $area_id); ForumCat::addArea($category_id, $area_id); ForumCat::setAreaPosition($area_id, $pos); $pos++; } } $this->render_nothing(); }
/** * 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(); }
/** * Delete an entry * * @delete /forum_entry/:entry_id */ public function deleteForumEntry($entry_id) { $entry = $this->findEntry($entry_id); $cid = $parent['course_id']; if (!\ForumPerm::hasEditPerms($entry_id) || !\ForumPerm::has('remove_entry', $cid)) { $this->error(401); } \ForumEntry::delete($entry_id); $this->status(204); }
?> " alt="<?php echo $infotext; ?> " title="<?php echo $infotext; ?> "> <?php echo Icon::create('link-intern', 'clickable', ['title' => $infotext = _("Direkt zum Beitrag..."), 'id' => 'tutorLatestAnswer'])->asImg(); ?> </a> <? else: ?> <br> <?php echo _('keine Antworten'); ?> <? endif; ?> <? endif; ?> </td> <td class="icon" style="text-align: right; padding-right: 2px;"> <? if (ForumPerm::has('sort_area', $seminar_id)) : ?> <img src="<?php echo $picturepath; ?> /anfasser_48.png" class="handle js" id="tutorMoveArea"> <? endif ?> </td> </tr>
<? if (!ForumPerm::has('fav_entry', $seminar_id)) return; ?> <!-- set/unset favorite --> <? if (!$favorite) : ?> <a href="<?php echo PluginEngine::getLink('coreforum/index/set_favorite/' . $topic_id); ?> " onClick="STUDIP.Forum.setFavorite('<?php echo $topic_id; ?> ');return false;"> <?php echo Icon::create('exclaim', 'clickable', ['title' => _('Beitrag merken')])->asImg(); ?> </a> <? else : ?> <a href="<?php echo PluginEngine::getLink('coreforum/index/unset_favorite/' . $topic_id); ?> " onClick="STUDIP.Forum.unsetFavorite('<?php echo $topic_id; ?> ');return false;"> <?php echo Icon::create('exclaim', 'attention', ['title' => _('Beitrag nicht mehr merken')])->asImg(); ?> </a> <? endif ?>
<?php echo $this->render_partial('index/_abo_link', compact('constraint')); ?> </span> <? endif ?> <? if (ForumPerm::has('pdfexport', $seminar_id)) : ?> <?php echo Studip\LinkButton::create(_('Beiträge als PDF exportieren'), PluginEngine::getLink('coreforum/index/pdfexport/' . $topic_id), array('target' => '_blank')); ?> <? endif ?> </div> </div> </div> <? endif ?> <? endif ?> <? if (ForumPerm::has('add_entry', $seminar_id)): ?> <?php echo $this->render_partial('index/_new_entry'); ?> <? endif ?> </div> <!-- Mail-Notifikationen verschicken (soweit am Ende der Seite wie möglich!) --> <? if ($flash['notify']) : ForumAbo::notify($flash['notify']); endif ?>
/** * Generate a pdf-export for the whole forum or the passed subtree * * @param string $parent_id */ function pdfexport_action($parent_id = null) { ForumPerm::check('pdfexport', $this->getId(), $parent_id); ForumHelpers::createPDF($this->getId(), $parent_id); }
/** * Check if the current user is allowed to edit the topic * denoted by the passed id * * @staticvar array $perms * * @param string $topic_id the id for the topic to check for * * @return bool true if the user has the necessary perms, false otherwise */ static function hasEditPerms($topic_id) { static $perms = array(); if (!$perms[$topic_id]) { // find out if the posting is the last in the thread $constraints = ForumEntry::getConstraints($topic_id); $stmt = DBManager::get()->prepare("SELECT user_id, seminar_id\n FROM forum_entries WHERE topic_id = ?"); $stmt->execute(array($topic_id)); $data = $stmt->fetch(); $closed = ForumEntry::isClosed($topic_id); $perms[$topic_id] = ($GLOBALS['user']->id == $data['user_id'] && $GLOBALS['user']->id != 'nobody' || ForumPerm::has('edit_entry', $constraints['seminar_id'])) && (!$closed || $closed && ForumPerm::has('edit_closed', $constraints['seminar_id'])); } return $perms[$topic_id]; }
<? if ($category_id && ForumPerm::has('add_area', $seminar_id) && Request::get('add_area') == $category_id) : ?> <?php echo $this->render_partial('area/_add_area_form'); ?> <? endif ?> <? if (!$entries): ?> <!-- this row allows dropping on otherwise empty categories --> <tr class="sort-disabled"> <td class="areaborder" style="height: 5px; padding: 0px; margin: 0px"colspan="7"> </td> </tr> <? endif; ?> </tbody> <tfoot> <? if ($category_id && ForumPerm::has('add_area', $seminar_id)) : ?> <? if (Request::get('add_area') != $category_id) : ?> <tr class="add_area"> <td colspan="5" onClick="STUDIP.Forum.addArea('<?php echo $category_id; ?> '); return false;" class="add_area"> <a href="<?php echo PluginEngine::getLink('coreforum/index/index/?add_area=' . $category_id); ?> #cat_<?php echo $category_id; ?> " title="<?php echo _('Neuen Bereich zu dieser Kategorie hinzufügen.'); ?>
function getNotificationObjects($course_id, $since, $user_id) { $this->setupAutoload(); if (ForumPerm::has('view', $course_id, $user_id)) { $postings = ForumEntry::getLatestSince($course_id, $since); $contents = array(); foreach ($postings as $post) { $obj = get_object_name($course_id, 'sem'); $summary = sprintf(_('%s hat im Forum der Veranstaltung "%s" einen Forenbeitrag verfasst.'), get_fullname($post['user_id']), $obj['name']); $contents[] = new ContentElement(_('Forum: ') . $obj['name'], $summary, formatReady($post['content']), $post['user_id'], $post['author'], PluginEngine::getURL($this, array(), 'index/index/' . $post['topic_id'] . '?cid=' . $course_id . '#' . $post['topic_id']), $post['mkdate']); } } return $contents; }
<? $confirmLinkApproved = PluginEngine::getURL('coreforum/index/delete_entry/' . $post['topic_id'] . '?approve_delete=1') ?> <? if ($constraint['depth'] == $post['depth']) : /* this is not only a posting, but a thread */ ?> <? $confirmText = _('Wenn Sie diesen Beitrag löschen wird ebenfalls das gesamte Thema gelöscht. Sind Sie sicher, dass Sie das tun möchten?') ?> <?php echo Studip\LinkButton::create(_('Thema löschen'), $confirmLink, array('onClick' => "STUDIP.Forum.showDialog('{$confirmText}', '{$confirmLinkApproved}'); return false;")); ?> <? else : ?> <? $confirmText = _('Möchten Sie diesen Beitrag wirklich löschen?') ?> <?php echo Studip\LinkButton::create(_('Beitrag löschen'), $confirmLink, array('onClick' => "STUDIP.Forum.showDialog('{$confirmText}', '{$confirmLinkApproved}'); return false;")); ?> <? endif ?> </span> <? endif ?> <? if (ForumPerm::has('forward_entry', $seminar_id)) : ?> <?php echo Studip\LinkButton::create(_('Beitrag weiterleiten'), "javascript:STUDIP.Forum.forwardEntry('" . $post['topic_id'] . "')", array('class' => 'js')); ?> <? endif ?> </span> </div> </div> </div> <? if ($perms['edit']) : ?> <span data-edit-topic="<?php echo $post['topic_id']; ?> " <?php