blob: e2d98a509da69722c92d2a11772acca56bae932e (
plain)
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
|
<?php
/**
* Controller to handle actions relative to categories.
* User needs to be connected.
*/
class FreshRSS_category_Controller extends Minz_ActionController {
/**
* This action is called before every other action in that class. It is
* the common boiler plate for every action. It is triggered by the
* underlying framework.
*
*/
public function firstAction() {
if (!$this->view->loginOk) {
Minz_Error::error(
403,
array('error' => array(_t('access_denied')))
);
}
$catDAO = new FreshRSS_CategoryDAO();
$catDAO->checkDefault();
}
/**
* This action creates a new category.
*
* URL parameter is:
* - new-category
*/
public function createAction() {
$catDAO = new FreshRSS_CategoryDAO();
$url_redirect = array('c' => 'configure', 'a' => 'categorize');
if (Minz_Request::isPost()) {
invalidateHttpCache();
$cat_name = Minz_Request::param('new-category');
if (!$cat_name) {
Minz_Request::bad(_t('category_no_name'), $url_redirect);
}
$cat = new FreshRSS_Category($cat_name);
if ($catDAO->searchByName($cat->name()) != null) {
Minz_Request::bad(_t('category_name_exists'), $url_redirect);
}
$values = array(
'id' => $cat->id(),
'name' => $cat->name(),
);
if ($catDAO->addCategory($values)) {
Minz_Request::good(_t('category_created', $cat->name()), $url_redirect);
} else {
Minz_Request::bad(_t('category_not_created'), $url_redirect);
}
}
Minz_Request::forward($url_redirect, true);
}
}
|