1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
<?php
/*
* Copyright (C) 2011 - Till Glöggler <tgloeggl@uos.de>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*/
require_once 'forum_controller.php';
class Course_Forum_AreaController extends ForumController
{
function add_action($category_id)
{
ForumPerm::check('add_area', $this->getId());
$new_id = md5(uniqid(rand()));
$name = Request::get('name', _('Kein Titel'));
$content = Request::get('content');
ForumEntry::insert([
'topic_id' => $new_id,
'seminar_id' => $this->getId(),
'user_id' => $GLOBALS['user']->id,
'name' => $name,
'content' => $content,
'author' => get_fullname($GLOBALS['user']->id),
'author_host' => ($GLOBALS['user']->id == 'nobody') ? getenv('REMOTE_ADDR') : ''
], $this->getId());
ForumCat::addArea($category_id, $new_id);
if (Request::isXhr()) {
$this->set_layout(null);
$entries = ForumEntry::parseEntries([ForumEntry::getEntry($new_id)]);
$this->entry = array_pop($entries);
$this->visitdate = ForumVisit::getLastVisit($this->getId());
} else {
$this->redirect('course/forum/index/index/');
}
}
function edit_action($area_id)
{
ForumPerm::check('edit_area', $this->getId(), $area_id);
ForumEntry::update($area_id, Request::get('name'), Request::get('content'));
if (Request::isAjax()) {
$this->render_json(['content' => ForumEntry::killFormat(ForumEntry::killEdit(Request::get('content')))]);
} else {
$this->flash['messages'] = ['success' => _('Die Änderungen am Bereich wurden gespeichert.')];
$this->redirect('course/forum/index/index');
}
}
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();
}
}
|