@@ -25,7 +25,7 @@ |
||
25 | 25 | |
26 | 26 | $deactivate = $this->Esnotification->read('deactivate'); |
27 | 27 | if (!isset($this->request->params['named']['token']) |
28 | - || (int)$this->request->params['named']['token'] !== (int)$deactivate['Esnotification']['deactivate'] |
|
28 | + || (int) $this->request->params['named']['token'] !== (int) $deactivate['Esnotification']['deactivate'] |
|
29 | 29 | ) { |
30 | 30 | throw new MethodNotAllowedException(); |
31 | 31 | } |
@@ -1,13 +1,13 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | - App::uses('AppController', 'Controller'); |
|
3 | + App::uses('AppController', 'Controller'); |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * Esnotifications Controller |
7 | 7 | * |
8 | 8 | * @property Esnotification $Esnotification |
9 | 9 | */ |
10 | - class EsnotificationsController extends AppController { |
|
10 | + class EsnotificationsController extends AppController { |
|
11 | 11 | |
12 | 12 | /** |
13 | 13 | * delete method |
@@ -17,30 +17,30 @@ discard block |
||
17 | 17 | * @param string $id |
18 | 18 | * @return void |
19 | 19 | */ |
20 | - public function unsubscribe($id = null) { |
|
21 | - $this->Esnotification->id = $id; |
|
22 | - if (!$this->Esnotification->exists()) { |
|
23 | - throw new NotFoundException(__('Invalid esnotification')); |
|
24 | - } |
|
20 | + public function unsubscribe($id = null) { |
|
21 | + $this->Esnotification->id = $id; |
|
22 | + if (!$this->Esnotification->exists()) { |
|
23 | + throw new NotFoundException(__('Invalid esnotification')); |
|
24 | + } |
|
25 | 25 | |
26 | - $deactivate = $this->Esnotification->read('deactivate'); |
|
27 | - if (!isset($this->request->params['named']['token']) |
|
28 | - || (int)$this->request->params['named']['token'] !== (int)$deactivate['Esnotification']['deactivate'] |
|
29 | - ) { |
|
30 | - throw new MethodNotAllowedException(); |
|
31 | - } |
|
32 | - if ($this->Esnotification->deleteNotificationWithId($id)) { |
|
33 | - $this->Session->setFlash(__('Succesfully unsubscribed.'), 'flash/success'); |
|
34 | - $this->redirect('/'); |
|
35 | - } |
|
36 | - $this->Session->setFlash(__('Error. Could not unsubscribe.')); |
|
37 | - $this->redirect('/'); |
|
38 | - } |
|
26 | + $deactivate = $this->Esnotification->read('deactivate'); |
|
27 | + if (!isset($this->request->params['named']['token']) |
|
28 | + || (int)$this->request->params['named']['token'] !== (int)$deactivate['Esnotification']['deactivate'] |
|
29 | + ) { |
|
30 | + throw new MethodNotAllowedException(); |
|
31 | + } |
|
32 | + if ($this->Esnotification->deleteNotificationWithId($id)) { |
|
33 | + $this->Session->setFlash(__('Succesfully unsubscribed.'), 'flash/success'); |
|
34 | + $this->redirect('/'); |
|
35 | + } |
|
36 | + $this->Session->setFlash(__('Error. Could not unsubscribe.')); |
|
37 | + $this->redirect('/'); |
|
38 | + } |
|
39 | 39 | |
40 | - public function beforeFilter() { |
|
41 | - parent::beforeFilter(); |
|
42 | - $this->Auth->allow('unsubscribe'); |
|
43 | - } |
|
40 | + public function beforeFilter() { |
|
41 | + parent::beforeFilter(); |
|
42 | + $this->Auth->allow('unsubscribe'); |
|
43 | + } |
|
44 | 44 | |
45 | - } |
|
45 | + } |
|
46 | 46 |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | 'entry_id' => $this->request->data['id'], |
49 | 49 | ]; |
50 | 50 | $this->Bookmark->create(); |
51 | - return (bool)$this->Bookmark->save($data); |
|
51 | + return (bool) $this->Bookmark->save($data); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | $this->_getBookmark($id, $this->CurrentUser->getId()); |
99 | 99 | $this->autoRender = false; |
100 | 100 | $this->Bookmark->id = $id; |
101 | - return (bool)$this->Bookmark->delete(); |
|
101 | + return (bool) $this->Bookmark->delete(); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | public function beforeFilter() { |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | - App::uses('AppController', 'Controller'); |
|
3 | + App::uses('AppController', 'Controller'); |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * Bookmarks Controller |
@@ -9,127 +9,127 @@ discard block |
||
9 | 9 | */ |
10 | 10 | class BookmarksController extends AppController { |
11 | 11 | |
12 | - public $helpers = ['EntryH']; |
|
12 | + public $helpers = ['EntryH']; |
|
13 | 13 | |
14 | 14 | /** |
15 | 15 | * @throws MethodNotAllowedException |
16 | 16 | */ |
17 | - public function index() { |
|
18 | - if (!$this->CurrentUser->isLoggedIn()) { |
|
19 | - throw new MethodNotAllowedException; |
|
20 | - } |
|
21 | - $bookmarks = $this->Bookmark->find('all', [ |
|
22 | - 'contain' => ['Entry' => ['Category', 'User']], |
|
23 | - 'conditions' => ['Bookmark.user_id' => $this->CurrentUser->getId()], |
|
24 | - 'order' => 'Bookmark.id DESC', |
|
25 | - ]); |
|
26 | - $this->set('bookmarks', $bookmarks); |
|
27 | - } |
|
17 | + public function index() { |
|
18 | + if (!$this->CurrentUser->isLoggedIn()) { |
|
19 | + throw new MethodNotAllowedException; |
|
20 | + } |
|
21 | + $bookmarks = $this->Bookmark->find('all', [ |
|
22 | + 'contain' => ['Entry' => ['Category', 'User']], |
|
23 | + 'conditions' => ['Bookmark.user_id' => $this->CurrentUser->getId()], |
|
24 | + 'order' => 'Bookmark.id DESC', |
|
25 | + ]); |
|
26 | + $this->set('bookmarks', $bookmarks); |
|
27 | + } |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * @return bool |
31 | 31 | * @throws MethodNotAllowedException |
32 | 32 | * @throws BadRequestException |
33 | 33 | */ |
34 | - public function add() { |
|
35 | - if (!$this->request->is('ajax')) { |
|
36 | - throw new BadRequestException; |
|
37 | - } |
|
38 | - if (!$this->CurrentUser->isLoggedIn()) { |
|
39 | - throw new MethodNotAllowedException; |
|
40 | - } |
|
41 | - $this->autoRender = false; |
|
42 | - if (!$this->request->is('post')) { |
|
43 | - return false; |
|
44 | - } |
|
45 | - |
|
46 | - $data = [ |
|
47 | - 'user_id' => $this->CurrentUser->getId(), |
|
48 | - 'entry_id' => $this->request->data['id'], |
|
49 | - ]; |
|
50 | - $this->Bookmark->create(); |
|
51 | - return (bool)$this->Bookmark->save($data); |
|
52 | - } |
|
53 | - |
|
54 | - /** |
|
55 | - * @param null $id |
|
56 | - * @throws NotFoundException |
|
57 | - * @throws MethodNotAllowedException |
|
58 | - */ |
|
59 | - public function edit($id = null) { |
|
60 | - $bookmark = $this->_getBookmark($id); |
|
61 | - |
|
62 | - if (!$this->request->is('post') && !$this->request->is('put')) { |
|
63 | - $posting = array( |
|
64 | - 'Entry' => $bookmark['Entry'], |
|
65 | - 'Category' => $bookmark['Entry']['Category'], |
|
66 | - 'User' => $bookmark['Entry']['User'], |
|
67 | - ); |
|
68 | - $this->set('entry', $this->dic->newInstance('\Saito\Posting\Posting', |
|
69 | - ['rawData' => $posting])); |
|
70 | - $this->request->data = $bookmark; |
|
71 | - return; |
|
72 | - } |
|
73 | - |
|
74 | - $data['Bookmark'] = [ |
|
75 | - 'id' => $id, |
|
76 | - 'comment' => $this->request->data['Bookmark']['comment'] |
|
77 | - ]; |
|
78 | - $success = $this->Bookmark->save($data); |
|
79 | - if (!$success) { |
|
80 | - $this->Session->setFlash( |
|
81 | - __('The bookmark could not be saved. Please, try again.')); |
|
82 | - return; |
|
83 | - } |
|
84 | - $this->redirect(['action' => 'index', |
|
85 | - '#' => $bookmark['Bookmark']['entry_id']]); |
|
86 | - } |
|
34 | + public function add() { |
|
35 | + if (!$this->request->is('ajax')) { |
|
36 | + throw new BadRequestException; |
|
37 | + } |
|
38 | + if (!$this->CurrentUser->isLoggedIn()) { |
|
39 | + throw new MethodNotAllowedException; |
|
40 | + } |
|
41 | + $this->autoRender = false; |
|
42 | + if (!$this->request->is('post')) { |
|
43 | + return false; |
|
44 | + } |
|
45 | + |
|
46 | + $data = [ |
|
47 | + 'user_id' => $this->CurrentUser->getId(), |
|
48 | + 'entry_id' => $this->request->data['id'], |
|
49 | + ]; |
|
50 | + $this->Bookmark->create(); |
|
51 | + return (bool)$this->Bookmark->save($data); |
|
52 | + } |
|
53 | + |
|
54 | + /** |
|
55 | + * @param null $id |
|
56 | + * @throws NotFoundException |
|
57 | + * @throws MethodNotAllowedException |
|
58 | + */ |
|
59 | + public function edit($id = null) { |
|
60 | + $bookmark = $this->_getBookmark($id); |
|
61 | + |
|
62 | + if (!$this->request->is('post') && !$this->request->is('put')) { |
|
63 | + $posting = array( |
|
64 | + 'Entry' => $bookmark['Entry'], |
|
65 | + 'Category' => $bookmark['Entry']['Category'], |
|
66 | + 'User' => $bookmark['Entry']['User'], |
|
67 | + ); |
|
68 | + $this->set('entry', $this->dic->newInstance('\Saito\Posting\Posting', |
|
69 | + ['rawData' => $posting])); |
|
70 | + $this->request->data = $bookmark; |
|
71 | + return; |
|
72 | + } |
|
73 | + |
|
74 | + $data['Bookmark'] = [ |
|
75 | + 'id' => $id, |
|
76 | + 'comment' => $this->request->data['Bookmark']['comment'] |
|
77 | + ]; |
|
78 | + $success = $this->Bookmark->save($data); |
|
79 | + if (!$success) { |
|
80 | + $this->Session->setFlash( |
|
81 | + __('The bookmark could not be saved. Please, try again.')); |
|
82 | + return; |
|
83 | + } |
|
84 | + $this->redirect(['action' => 'index', |
|
85 | + '#' => $bookmark['Bookmark']['entry_id']]); |
|
86 | + } |
|
87 | 87 | |
88 | 88 | /** |
89 | 89 | * @param null $id |
90 | 90 | * @return bool |
91 | 91 | * @throws BadRequestException |
92 | 92 | */ |
93 | - public function delete($id = null) { |
|
94 | - if (!$this->request->is('ajax')) { |
|
95 | - throw new BadRequestException; |
|
96 | - } |
|
97 | - |
|
98 | - $this->_getBookmark($id, $this->CurrentUser->getId()); |
|
99 | - $this->autoRender = false; |
|
100 | - $this->Bookmark->id = $id; |
|
101 | - return (bool)$this->Bookmark->delete(); |
|
102 | - } |
|
103 | - |
|
104 | - public function beforeFilter() { |
|
105 | - parent::beforeFilter(); |
|
106 | - |
|
107 | - $this->Security->unlockedActions = ['add']; |
|
108 | - } |
|
109 | - |
|
110 | - /** |
|
111 | - * @param $id |
|
112 | - * @throws NotFoundException |
|
113 | - * @throws MethodNotAllowedException |
|
114 | - * @throws Saito\Exception\SaitoForbiddenException |
|
115 | - * @return mixed |
|
116 | - */ |
|
117 | - protected function _getBookmark($id) { |
|
118 | - if (!$this->CurrentUser->isLoggedIn()) { |
|
119 | - throw new MethodNotAllowedException; |
|
120 | - } |
|
121 | - |
|
122 | - if (!$this->Bookmark->exists($id)) { |
|
123 | - throw new NotFoundException(__('Invalid bookmark.')); |
|
124 | - } |
|
125 | - |
|
126 | - $this->Bookmark->contain(['Entry' => ['Category', 'User']]); |
|
127 | - $bookmark = $this->Bookmark->findById($id); |
|
128 | - |
|
129 | - if ($bookmark['Bookmark']['user_id'] != $this->CurrentUser->getId()) { |
|
130 | - throw new Saito\Exception\SaitoForbiddenException("Attempt to edit bookmark $id."); |
|
131 | - } |
|
132 | - return $bookmark; |
|
133 | - } |
|
93 | + public function delete($id = null) { |
|
94 | + if (!$this->request->is('ajax')) { |
|
95 | + throw new BadRequestException; |
|
96 | + } |
|
97 | + |
|
98 | + $this->_getBookmark($id, $this->CurrentUser->getId()); |
|
99 | + $this->autoRender = false; |
|
100 | + $this->Bookmark->id = $id; |
|
101 | + return (bool)$this->Bookmark->delete(); |
|
102 | + } |
|
103 | + |
|
104 | + public function beforeFilter() { |
|
105 | + parent::beforeFilter(); |
|
106 | + |
|
107 | + $this->Security->unlockedActions = ['add']; |
|
108 | + } |
|
109 | + |
|
110 | + /** |
|
111 | + * @param $id |
|
112 | + * @throws NotFoundException |
|
113 | + * @throws MethodNotAllowedException |
|
114 | + * @throws Saito\Exception\SaitoForbiddenException |
|
115 | + * @return mixed |
|
116 | + */ |
|
117 | + protected function _getBookmark($id) { |
|
118 | + if (!$this->CurrentUser->isLoggedIn()) { |
|
119 | + throw new MethodNotAllowedException; |
|
120 | + } |
|
121 | + |
|
122 | + if (!$this->Bookmark->exists($id)) { |
|
123 | + throw new NotFoundException(__('Invalid bookmark.')); |
|
124 | + } |
|
125 | + |
|
126 | + $this->Bookmark->contain(['Entry' => ['Category', 'User']]); |
|
127 | + $bookmark = $this->Bookmark->findById($id); |
|
128 | + |
|
129 | + if ($bookmark['Bookmark']['user_id'] != $this->CurrentUser->getId()) { |
|
130 | + throw new Saito\Exception\SaitoForbiddenException("Attempt to edit bookmark $id."); |
|
131 | + } |
|
132 | + return $bookmark; |
|
133 | + } |
|
134 | 134 | |
135 | 135 | } |
136 | 136 | \ No newline at end of file |
@@ -72,7 +72,7 @@ |
||
72 | 72 | if (isset($this->request->data['Category']['modeMove']) && isset($this->request->data['Category']['targetCategory'])): |
73 | 73 | /* move category items before deleting the cateogry */ |
74 | 74 | |
75 | - $targetId = (int)$this->request->data['Category']['targetCategory']; |
|
75 | + $targetId = (int) $this->request->data['Category']['targetCategory']; |
|
76 | 76 | |
77 | 77 | /* make sure that target category exists */ |
78 | 78 | $this->Category->contain(); |
@@ -1,123 +1,123 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | - App::uses('AppController', 'Controller'); |
|
4 | - |
|
5 | - class CategoriesController extends AppController { |
|
6 | - |
|
7 | - public $name = 'Categories'; |
|
8 | - |
|
9 | - public $paginate = [ |
|
10 | - /** |
|
11 | - * sets limit unrealisticly high so we should never reach the upper limit |
|
12 | - * i.e. always show all entries on one page |
|
13 | - */ |
|
14 | - 'limit' => 1000, |
|
15 | - ]; |
|
16 | - |
|
17 | - public function admin_index() { |
|
18 | - $this->Category->recursive = 0; |
|
19 | - $this->set('categories', $this->paginate()); |
|
20 | - } |
|
21 | - |
|
22 | - public function admin_add() { |
|
23 | - if (!empty($this->request->data)) { |
|
24 | - $this->Category->create(); |
|
25 | - if ($this->Category->save($this->request->data)) { |
|
26 | - $this->Session->setFlash(__('The category has been saved')); |
|
27 | - $this->redirect(array('action' => 'index')); |
|
28 | - } else { |
|
29 | - $this->Session->setFlash(__('The category could not be saved. Please, try again.')); |
|
30 | - } |
|
31 | - } |
|
32 | - } |
|
33 | - |
|
34 | - public function admin_edit($id = null) { |
|
35 | - if (!$id && empty($this->request->data)) { |
|
36 | - $this->Session->setFlash(__('Invalid category')); |
|
37 | - $this->redirect(array('action' => 'index')); |
|
38 | - } |
|
39 | - if (!empty($this->request->data)) { |
|
40 | - if ($this->Category->save($this->request->data)) { |
|
41 | - $this->Session->setFlash(__('The category has been saved')); |
|
42 | - $this->redirect(array('action' => 'index')); |
|
43 | - } else { |
|
44 | - $this->Session->setFlash(__('The category could not be saved. Please, try again.')); |
|
45 | - } |
|
46 | - } |
|
47 | - if (empty($this->request->data)) { |
|
48 | - $this->Category->contain(); |
|
49 | - $this->request->data = $this->Category->read(null, $id); |
|
50 | - } |
|
51 | - } |
|
52 | - |
|
53 | - public function admin_delete($id = null) { |
|
54 | - if (!$id) { |
|
55 | - $this->Session->setFlash(__('Invalid id for category'), 'flash/error'); |
|
56 | - $this->redirect($this->referer(array('action' => 'index'))); |
|
57 | - exit(); |
|
58 | - } |
|
59 | - |
|
60 | - /* check if category to exists */ |
|
61 | - $this->Category->contain(); |
|
62 | - $categoryToDelete = $this->Category->findById($id); |
|
63 | - if (empty($categoryToDelete)) : |
|
64 | - $this->Session->setFlash(__('Category not found.'), 'flash/error'); |
|
65 | - $this->redirect($this->referer(array('action' => 'index'))); |
|
66 | - exit(); |
|
67 | - endif; |
|
68 | - |
|
69 | - if (isset($this->request->data['Category']['modeDelete'])): |
|
70 | - $failure = false; |
|
71 | - |
|
72 | - if (isset($this->request->data['Category']['modeMove']) && isset($this->request->data['Category']['targetCategory'])): |
|
73 | - /* move category items before deleting the cateogry */ |
|
74 | - |
|
75 | - $targetId = (int)$this->request->data['Category']['targetCategory']; |
|
76 | - |
|
77 | - /* make sure that target category exists */ |
|
78 | - $this->Category->contain(); |
|
79 | - $categoryToDelete = $this->Category->findById($targetId); |
|
80 | - if (empty($categoryToDelete)) : |
|
81 | - $this->Session->setFlash(__('Target category not found.'), |
|
82 | - 'flash/error'); |
|
83 | - $this->redirect($this->referer()); |
|
84 | - exit(); |
|
85 | - endif; |
|
86 | - |
|
87 | - $this->Category->id = $id; |
|
88 | - if ($this->Category->mergeIntoCategory($targetId) == false) : |
|
89 | - $this->Session->setFlash(__('Error moving category.'), |
|
90 | - 'flash/error'); |
|
91 | - $failure = $failure || true; |
|
92 | - else: |
|
93 | - $this->Session->setFlash(__('Category moved.'), 'flash/notice'); |
|
94 | - endif; |
|
95 | - endif; |
|
96 | - |
|
97 | - $this->Category->id = $id; |
|
98 | - if ($this->Category->deleteWithAllEntries() == false) : |
|
99 | - $this->Session->setFlash(__("Error deleting category."), |
|
100 | - 'flash/error'); |
|
101 | - $failure = $failure || true; |
|
102 | - else: |
|
103 | - $this->Session->setFlash(__('Category deleted.'), 'flash/notice'); |
|
104 | - endif; |
|
105 | - |
|
106 | - if ($failure == false) : |
|
107 | - $this->redirect(array('action' => 'index', 'admin' => true)); |
|
108 | - exit(); |
|
109 | - endif; |
|
110 | - |
|
111 | - endif; // move or delete category |
|
112 | - |
|
113 | - /* get categories for target <select> */ |
|
114 | - $categories = $this->CurrentUser->Categories->getAllowed('list'); |
|
115 | - unset($categories[$id]); |
|
116 | - $this->set('targetCategory', $categories); |
|
117 | - |
|
118 | - $this->Category->contain(); |
|
119 | - $this->request->data = $this->Category->read(null, $id); |
|
120 | - } |
|
121 | - |
|
122 | - } |
|
3 | + App::uses('AppController', 'Controller'); |
|
4 | + |
|
5 | + class CategoriesController extends AppController { |
|
6 | + |
|
7 | + public $name = 'Categories'; |
|
8 | + |
|
9 | + public $paginate = [ |
|
10 | + /** |
|
11 | + * sets limit unrealisticly high so we should never reach the upper limit |
|
12 | + * i.e. always show all entries on one page |
|
13 | + */ |
|
14 | + 'limit' => 1000, |
|
15 | + ]; |
|
16 | + |
|
17 | + public function admin_index() { |
|
18 | + $this->Category->recursive = 0; |
|
19 | + $this->set('categories', $this->paginate()); |
|
20 | + } |
|
21 | + |
|
22 | + public function admin_add() { |
|
23 | + if (!empty($this->request->data)) { |
|
24 | + $this->Category->create(); |
|
25 | + if ($this->Category->save($this->request->data)) { |
|
26 | + $this->Session->setFlash(__('The category has been saved')); |
|
27 | + $this->redirect(array('action' => 'index')); |
|
28 | + } else { |
|
29 | + $this->Session->setFlash(__('The category could not be saved. Please, try again.')); |
|
30 | + } |
|
31 | + } |
|
32 | + } |
|
33 | + |
|
34 | + public function admin_edit($id = null) { |
|
35 | + if (!$id && empty($this->request->data)) { |
|
36 | + $this->Session->setFlash(__('Invalid category')); |
|
37 | + $this->redirect(array('action' => 'index')); |
|
38 | + } |
|
39 | + if (!empty($this->request->data)) { |
|
40 | + if ($this->Category->save($this->request->data)) { |
|
41 | + $this->Session->setFlash(__('The category has been saved')); |
|
42 | + $this->redirect(array('action' => 'index')); |
|
43 | + } else { |
|
44 | + $this->Session->setFlash(__('The category could not be saved. Please, try again.')); |
|
45 | + } |
|
46 | + } |
|
47 | + if (empty($this->request->data)) { |
|
48 | + $this->Category->contain(); |
|
49 | + $this->request->data = $this->Category->read(null, $id); |
|
50 | + } |
|
51 | + } |
|
52 | + |
|
53 | + public function admin_delete($id = null) { |
|
54 | + if (!$id) { |
|
55 | + $this->Session->setFlash(__('Invalid id for category'), 'flash/error'); |
|
56 | + $this->redirect($this->referer(array('action' => 'index'))); |
|
57 | + exit(); |
|
58 | + } |
|
59 | + |
|
60 | + /* check if category to exists */ |
|
61 | + $this->Category->contain(); |
|
62 | + $categoryToDelete = $this->Category->findById($id); |
|
63 | + if (empty($categoryToDelete)) : |
|
64 | + $this->Session->setFlash(__('Category not found.'), 'flash/error'); |
|
65 | + $this->redirect($this->referer(array('action' => 'index'))); |
|
66 | + exit(); |
|
67 | + endif; |
|
68 | + |
|
69 | + if (isset($this->request->data['Category']['modeDelete'])): |
|
70 | + $failure = false; |
|
71 | + |
|
72 | + if (isset($this->request->data['Category']['modeMove']) && isset($this->request->data['Category']['targetCategory'])): |
|
73 | + /* move category items before deleting the cateogry */ |
|
74 | + |
|
75 | + $targetId = (int)$this->request->data['Category']['targetCategory']; |
|
76 | + |
|
77 | + /* make sure that target category exists */ |
|
78 | + $this->Category->contain(); |
|
79 | + $categoryToDelete = $this->Category->findById($targetId); |
|
80 | + if (empty($categoryToDelete)) : |
|
81 | + $this->Session->setFlash(__('Target category not found.'), |
|
82 | + 'flash/error'); |
|
83 | + $this->redirect($this->referer()); |
|
84 | + exit(); |
|
85 | + endif; |
|
86 | + |
|
87 | + $this->Category->id = $id; |
|
88 | + if ($this->Category->mergeIntoCategory($targetId) == false) : |
|
89 | + $this->Session->setFlash(__('Error moving category.'), |
|
90 | + 'flash/error'); |
|
91 | + $failure = $failure || true; |
|
92 | + else: |
|
93 | + $this->Session->setFlash(__('Category moved.'), 'flash/notice'); |
|
94 | + endif; |
|
95 | + endif; |
|
96 | + |
|
97 | + $this->Category->id = $id; |
|
98 | + if ($this->Category->deleteWithAllEntries() == false) : |
|
99 | + $this->Session->setFlash(__("Error deleting category."), |
|
100 | + 'flash/error'); |
|
101 | + $failure = $failure || true; |
|
102 | + else: |
|
103 | + $this->Session->setFlash(__('Category deleted.'), 'flash/notice'); |
|
104 | + endif; |
|
105 | + |
|
106 | + if ($failure == false) : |
|
107 | + $this->redirect(array('action' => 'index', 'admin' => true)); |
|
108 | + exit(); |
|
109 | + endif; |
|
110 | + |
|
111 | + endif; // move or delete category |
|
112 | + |
|
113 | + /* get categories for target <select> */ |
|
114 | + $categories = $this->CurrentUser->Categories->getAllowed('list'); |
|
115 | + unset($categories[$id]); |
|
116 | + $this->set('targetCategory', $categories); |
|
117 | + |
|
118 | + $this->Category->contain(); |
|
119 | + $this->request->data = $this->Category->read(null, $id); |
|
120 | + } |
|
121 | + |
|
122 | + } |
|
123 | 123 |
@@ -89,8 +89,10 @@ discard block |
||
89 | 89 | $this->Session->setFlash(__('Error moving category.'), |
90 | 90 | 'flash/error'); |
91 | 91 | $failure = $failure || true; |
92 | - else: |
|
92 | + else { |
|
93 | + : |
|
93 | 94 | $this->Session->setFlash(__('Category moved.'), 'flash/notice'); |
95 | + } |
|
94 | 96 | endif; |
95 | 97 | endif; |
96 | 98 | |
@@ -99,8 +101,10 @@ discard block |
||
99 | 101 | $this->Session->setFlash(__("Error deleting category."), |
100 | 102 | 'flash/error'); |
101 | 103 | $failure = $failure || true; |
102 | - else: |
|
104 | + else { |
|
105 | + : |
|
103 | 106 | $this->Session->setFlash(__('Category deleted.'), 'flash/notice'); |
107 | + } |
|
104 | 108 | endif; |
105 | 109 | |
106 | 110 | if ($failure == false) : |
@@ -63,7 +63,7 @@ |
||
63 | 63 | |
64 | 64 | public function admin_edit($id = null) { |
65 | 65 | if (!$id) { |
66 | - $this->redirect(array( 'action ' => 'index' )); |
|
66 | + $this->redirect(array('action ' => 'index')); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | $this->Setting->id = $id; |
@@ -1,94 +1,94 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | - App::uses('AppController', 'Controller'); |
|
3 | + App::uses('AppController', 'Controller'); |
|
4 | 4 | |
5 | - class SettingsController extends AppController { |
|
5 | + class SettingsController extends AppController { |
|
6 | 6 | |
7 | - public $name = 'Settings'; |
|
7 | + public $name = 'Settings'; |
|
8 | 8 | |
9 | - public $helpers = [ |
|
10 | - 'Setting', |
|
11 | - 'TimeH' |
|
12 | - ]; |
|
9 | + public $helpers = [ |
|
10 | + 'Setting', |
|
11 | + 'TimeH' |
|
12 | + ]; |
|
13 | 13 | |
14 | - protected $_settingsShownInAdminIndex = [ |
|
15 | - 'api_crossdomain' => 1, |
|
16 | - 'api_enabled' => 1, |
|
17 | - 'autolink' => 1, |
|
18 | - 'bbcode_img' => 1, |
|
19 | - 'block_user_ui' => 1, |
|
20 | - // Activates and deactivates the category-chooser on entries/index |
|
21 | - 'category_chooser_global' => 1, |
|
22 | - // Allows users to show the category-chooser even if the default |
|
23 | - // setting `category_chooser_global` is off |
|
24 | - 'category_chooser_user_override' => 1, |
|
25 | - 'edit_delay' => 1, |
|
26 | - 'edit_period' => 1, |
|
27 | - 'embedly_enabled' => 1, |
|
28 | - 'embedly_key' => 1, |
|
29 | - 'email_contact' => 1, |
|
30 | - 'email_register' => 1, |
|
31 | - 'email_system' => 1, |
|
32 | - 'forum_disabled' => 1, |
|
33 | - 'forum_disabled_text' => 1, |
|
34 | - 'forum_email' => 1, |
|
35 | - 'forum_name' => 1, |
|
36 | - 'map_enabled' => 1, |
|
37 | - 'map_api_key' => 1, |
|
38 | - 'quote_symbol' => 1, |
|
39 | - 'shoutbox_enabled' => 1, |
|
40 | - 'shoutbox_max_shouts' => 1, |
|
41 | - 'smilies' => 1, |
|
42 | - 'signature_separator' => 1, |
|
43 | - 'stopwatch_get' => 1, |
|
44 | - 'store_ip' => 1, |
|
45 | - 'store_ip_anonymized' => 1, |
|
46 | - 'subject_maxlength' => 1, |
|
47 | - 'text_word_maxlength' => 1, |
|
48 | - 'thread_depth_indent' => 1, |
|
49 | - 'timezone' => 1, |
|
50 | - 'topics_per_page' => 1, |
|
51 | - 'tos_enabled' => 1, |
|
52 | - 'tos_url' => 1, |
|
53 | - 'upload_max_img_size' => 1, |
|
54 | - 'upload_max_number_of_uploads' => 1, |
|
55 | - 'video_domains_allowed' => 1, |
|
56 | - ]; |
|
14 | + protected $_settingsShownInAdminIndex = [ |
|
15 | + 'api_crossdomain' => 1, |
|
16 | + 'api_enabled' => 1, |
|
17 | + 'autolink' => 1, |
|
18 | + 'bbcode_img' => 1, |
|
19 | + 'block_user_ui' => 1, |
|
20 | + // Activates and deactivates the category-chooser on entries/index |
|
21 | + 'category_chooser_global' => 1, |
|
22 | + // Allows users to show the category-chooser even if the default |
|
23 | + // setting `category_chooser_global` is off |
|
24 | + 'category_chooser_user_override' => 1, |
|
25 | + 'edit_delay' => 1, |
|
26 | + 'edit_period' => 1, |
|
27 | + 'embedly_enabled' => 1, |
|
28 | + 'embedly_key' => 1, |
|
29 | + 'email_contact' => 1, |
|
30 | + 'email_register' => 1, |
|
31 | + 'email_system' => 1, |
|
32 | + 'forum_disabled' => 1, |
|
33 | + 'forum_disabled_text' => 1, |
|
34 | + 'forum_email' => 1, |
|
35 | + 'forum_name' => 1, |
|
36 | + 'map_enabled' => 1, |
|
37 | + 'map_api_key' => 1, |
|
38 | + 'quote_symbol' => 1, |
|
39 | + 'shoutbox_enabled' => 1, |
|
40 | + 'shoutbox_max_shouts' => 1, |
|
41 | + 'smilies' => 1, |
|
42 | + 'signature_separator' => 1, |
|
43 | + 'stopwatch_get' => 1, |
|
44 | + 'store_ip' => 1, |
|
45 | + 'store_ip_anonymized' => 1, |
|
46 | + 'subject_maxlength' => 1, |
|
47 | + 'text_word_maxlength' => 1, |
|
48 | + 'thread_depth_indent' => 1, |
|
49 | + 'timezone' => 1, |
|
50 | + 'topics_per_page' => 1, |
|
51 | + 'tos_enabled' => 1, |
|
52 | + 'tos_url' => 1, |
|
53 | + 'upload_max_img_size' => 1, |
|
54 | + 'upload_max_number_of_uploads' => 1, |
|
55 | + 'video_domains_allowed' => 1, |
|
56 | + ]; |
|
57 | 57 | |
58 | - public function admin_index() { |
|
59 | - $settings = $this->request->data = $this->Setting->getSettings(); |
|
60 | - $settings = array_intersect_key($settings, $this->_settingsShownInAdminIndex); |
|
61 | - $this->set('Settings', $settings); |
|
62 | - } |
|
58 | + public function admin_index() { |
|
59 | + $settings = $this->request->data = $this->Setting->getSettings(); |
|
60 | + $settings = array_intersect_key($settings, $this->_settingsShownInAdminIndex); |
|
61 | + $this->set('Settings', $settings); |
|
62 | + } |
|
63 | 63 | |
64 | - public function admin_edit($id = null) { |
|
65 | - if (!$id) { |
|
66 | - $this->redirect(array( 'action ' => 'index' )); |
|
67 | - } |
|
64 | + public function admin_edit($id = null) { |
|
65 | + if (!$id) { |
|
66 | + $this->redirect(array( 'action ' => 'index' )); |
|
67 | + } |
|
68 | 68 | |
69 | - $this->Setting->id = $id; |
|
69 | + $this->Setting->id = $id; |
|
70 | 70 | |
71 | - if (empty($this->request->data)) { |
|
72 | - $this->request->data = $this->Setting->read(); |
|
73 | - if (empty($this->request->data)) { |
|
74 | - $this->Session->setFlash("Couldn't find parameter: {$id}", 'flash/error'); |
|
75 | - $this->redirect(array( |
|
76 | - 'controller' => 'settings', 'action' => 'index', 'admin' => true ) |
|
77 | - ); |
|
78 | - } |
|
79 | - if ($id === 'timezone') : |
|
80 | - $this->render('admin_timezone'); |
|
81 | - endif; |
|
82 | - } else { |
|
83 | - $this->Setting->id = $id; |
|
84 | - if ($this->Setting->save($this->request->data)) { |
|
85 | - $this->Session->setFlash('Saved. @lo', 'flash/notice'); |
|
86 | - $this->redirect(['action' => 'index', '#' => $id]); |
|
87 | - return; |
|
88 | - } else { |
|
89 | - $this->Session->setFlash('Something went wrong @lo', 'flash/error'); |
|
90 | - } |
|
91 | - } |
|
92 | - } |
|
71 | + if (empty($this->request->data)) { |
|
72 | + $this->request->data = $this->Setting->read(); |
|
73 | + if (empty($this->request->data)) { |
|
74 | + $this->Session->setFlash("Couldn't find parameter: {$id}", 'flash/error'); |
|
75 | + $this->redirect(array( |
|
76 | + 'controller' => 'settings', 'action' => 'index', 'admin' => true ) |
|
77 | + ); |
|
78 | + } |
|
79 | + if ($id === 'timezone') : |
|
80 | + $this->render('admin_timezone'); |
|
81 | + endif; |
|
82 | + } else { |
|
83 | + $this->Setting->id = $id; |
|
84 | + if ($this->Setting->save($this->request->data)) { |
|
85 | + $this->Session->setFlash('Saved. @lo', 'flash/notice'); |
|
86 | + $this->redirect(['action' => 'index', '#' => $id]); |
|
87 | + return; |
|
88 | + } else { |
|
89 | + $this->Session->setFlash('Something went wrong @lo', 'flash/error'); |
|
90 | + } |
|
91 | + } |
|
92 | + } |
|
93 | 93 | |
94 | - } |
|
94 | + } |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | $order = '`Entry`.`time` DESC'; |
80 | 80 | $fields = '*'; |
81 | 81 | if ($query['order'] === 'rank') { |
82 | - $order = 'rating DESC, ' . $order; |
|
83 | - $fields = $fields . ", (MATCH (Entry.subject) AGAINST ('$q' IN BOOLEAN MODE)*2) + (MATCH (Entry.text) AGAINST ('$q' IN BOOLEAN MODE)) + (MATCH (Entry.name) AGAINST ('$q' IN BOOLEAN MODE)*4) AS rating"; |
|
82 | + $order = 'rating DESC, '.$order; |
|
83 | + $fields = $fields.", (MATCH (Entry.subject) AGAINST ('$q' IN BOOLEAN MODE)*2) + (MATCH (Entry.text) AGAINST ('$q' IN BOOLEAN MODE)) + (MATCH (Entry.name) AGAINST ('$q' IN BOOLEAN MODE)*4) AS rating"; |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | // query |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | 'Y-m-d H:i:s', |
153 | 153 | mktime(0, 0, 0, $month, 1, $year)); |
154 | 154 | |
155 | - if (isset($query['category_id']) && (int)$query['category_id'] !== 0) { |
|
156 | - if (!isset($categories[(int)$query['category_id']])) { |
|
155 | + if (isset($query['category_id']) && (int) $query['category_id'] !== 0) { |
|
156 | + if (!isset($categories[(int) $query['category_id']])) { |
|
157 | 157 | throw new NotFoundException; |
158 | 158 | } |
159 | 159 | } else { |
@@ -180,6 +180,9 @@ |
||
180 | 180 | return Sanitize::escape($string, $this->Entry->useDbConfig); |
181 | 181 | } |
182 | 182 | |
183 | + /** |
|
184 | + * @param string[] $params |
|
185 | + */ |
|
183 | 186 | protected function _filterQuery($params) { |
184 | 187 | $this->request->query = array_intersect_key($this->request->query, |
185 | 188 | array_fill_keys($params, 1)); |
@@ -1,188 +1,188 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | - use Saito\SimpleSearchString; |
|
4 | - |
|
5 | - App::uses('AppController', 'Controller'); |
|
6 | - |
|
7 | - class SearchesController extends AppController { |
|
8 | - |
|
9 | - public $components = [ |
|
10 | - 'Paginator', |
|
11 | - 'Search.Prg' => [ |
|
12 | - 'commonProcess' => [ |
|
13 | - 'allowedParams' => ['nstrict'], |
|
14 | - 'keepPassed' => true, |
|
15 | - 'filterEmpty' => true, |
|
16 | - 'paramType' => 'querystring' |
|
17 | - ] |
|
18 | - ] |
|
19 | - ]; |
|
20 | - |
|
21 | - public $helpers = ['Form', 'Html', 'EntryH']; |
|
22 | - |
|
23 | - public $uses = [ |
|
24 | - 'Entry' |
|
25 | - ]; |
|
26 | - |
|
27 | - protected $_paginateConfig = [ |
|
28 | - 'limit' => 25 |
|
29 | - ]; |
|
30 | - |
|
31 | - public function beforeFilter() { |
|
32 | - parent::beforeFilter(); |
|
33 | - $this->Auth->allow('simple'); |
|
34 | - } |
|
35 | - |
|
36 | - public function simple() { |
|
37 | - $defaults = [ |
|
38 | - 'order' => 'time' |
|
39 | - ]; |
|
40 | - $this->set('order', $defaults['order']); |
|
41 | - |
|
42 | - // @todo pgsql |
|
43 | - $db = $this->Entry->getDataSource(); |
|
44 | - // @codingStandardsIgnoreStart |
|
45 | - // on 5.5 phpcs assumes this is the deprecated PHP MySQL extension |
|
46 | - if (!($db instanceof Mysql)) { |
|
47 | - // @codingStandardsIgnoreEnd |
|
48 | - $this->redirect(['action' => 'advanced']); |
|
49 | - return; |
|
50 | - } |
|
51 | - |
|
52 | - $minWordLength = $this->Entry->query("SHOW VARIABLES LIKE 'ft_min_word_len'")[0]; |
|
53 | - $minWordLength = array_shift($minWordLength)['Value']; |
|
54 | - $this->set(compact('minWordLength')); |
|
55 | - |
|
56 | - if (!isset($this->request->query['q'])) { |
|
57 | - // request for empty search form |
|
58 | - return; |
|
59 | - } |
|
60 | - |
|
61 | - $this->_filterQuery(['q', 'page', 'order']); |
|
62 | - $qRaw = $this->request->query['q']; |
|
63 | - $query = $this->request->query += $defaults; |
|
64 | - $this->set(['q' => $qRaw, 'order' => $query['order']]); |
|
65 | - |
|
66 | - // test query is valid |
|
67 | - $SearchString = new SimpleSearchString($qRaw, $minWordLength); |
|
68 | - $this->set('minChars', $minWordLength); |
|
69 | - |
|
70 | - $query['q'] = $SearchString->replaceOperators(); |
|
71 | - $omitted = $SearchString->getOmittedWords(); |
|
72 | - $this->set('omittedWords', $omitted); |
|
73 | - |
|
74 | - // sanitize search-term for manual SQL-query |
|
75 | - $query['q'] = $this->_sanitize($query['q']); |
|
76 | - |
|
77 | - // build query |
|
78 | - $q = $query['q']; |
|
79 | - $order = '`Entry`.`time` DESC'; |
|
80 | - $fields = '*'; |
|
81 | - if ($query['order'] === 'rank') { |
|
82 | - $order = 'rating DESC, ' . $order; |
|
83 | - $fields = $fields . ", (MATCH (Entry.subject) AGAINST ('$q' IN BOOLEAN MODE)*2) + (MATCH (Entry.text) AGAINST ('$q' IN BOOLEAN MODE)) + (MATCH (Entry.name) AGAINST ('$q' IN BOOLEAN MODE)*4) AS rating"; |
|
84 | - } |
|
85 | - |
|
86 | - // query |
|
87 | - $this->Paginator->settings = [ |
|
88 | - 'fields' => $fields, |
|
89 | - 'conditions' => [ |
|
90 | - "MATCH (Entry.subject, Entry.text, Entry.name) AGAINST ('$q' IN BOOLEAN MODE)", |
|
91 | - 'Entry.category_id' => $this->CurrentUser->Categories->getAllowed() |
|
92 | - ], |
|
93 | - 'order' => $order, |
|
94 | - 'paramType' => 'querystring' |
|
95 | - ]; |
|
96 | - $this->Paginator->settings += $this->_paginateConfig; |
|
97 | - $results = $this->Paginator->paginate('Entry'); |
|
98 | - $this->set('results', $results); |
|
99 | - } |
|
100 | - |
|
101 | - /** |
|
102 | - * @throws NotFoundException |
|
103 | - * @throws BadRequestException |
|
104 | - */ |
|
105 | - public function advanced() { |
|
106 | - // year for date drop-down |
|
107 | - $first = $this->Entry->find('first', |
|
108 | - ['contain' => false, 'order' => 'Entry.id ASC']); |
|
109 | - if ($first !== false) { |
|
110 | - $startDate = strtotime($first['Entry']['time']); |
|
111 | - } else { |
|
112 | - $startDate = time(); |
|
113 | - } |
|
114 | - $this->set('start_year', date('Y', $startDate)); |
|
115 | - |
|
116 | - // category drop-down |
|
117 | - $categories = $this->CurrentUser->Categories->getAllowed('list'); |
|
118 | - $this->set('categories', $categories); |
|
119 | - |
|
120 | - // calculate current month and year |
|
121 | - if (isset($this->request->query['month'])) { |
|
122 | - $month = $this->request->query['month']; |
|
123 | - $year = $this->request->query['year']; |
|
124 | - } else { |
|
125 | - $month = date('n', $startDate); |
|
126 | - $year = date('Y', $startDate); |
|
127 | - } |
|
128 | - |
|
129 | - $this->Prg->commonProcess(); |
|
130 | - $query = $this->Prg->parsedParams(); |
|
131 | - |
|
132 | - if (!empty($query['subject']) || !empty($query['text']) || |
|
133 | - !empty($query['name']) |
|
134 | - ) { |
|
135 | - // strict username search: set before parseCriteria |
|
136 | - if (!empty($this->request->query['nstrict'])) { |
|
137 | - // presetVars controller var isn't working in Search v2.3 |
|
138 | - $this->Entry->filterArgs['name']['type'] = 'value'; |
|
139 | - } |
|
140 | - |
|
141 | - $settings = [ |
|
142 | - 'conditions' => $this->Entry->parseCriteria($query), |
|
143 | - 'order' => ['Entry.time' => 'DESC'], |
|
144 | - 'paramType' => 'querystring' |
|
145 | - ] + $this->_paginateConfig; |
|
146 | - |
|
147 | - $time = mktime(0, 0, 0, $month, 1, $year); |
|
148 | - if (!$time) { |
|
149 | - throw new BadRequestException; |
|
150 | - } |
|
151 | - $settings['conditions']['time >'] = date( |
|
152 | - 'Y-m-d H:i:s', |
|
153 | - mktime(0, 0, 0, $month, 1, $year)); |
|
154 | - |
|
155 | - if (isset($query['category_id']) && (int)$query['category_id'] !== 0) { |
|
156 | - if (!isset($categories[(int)$query['category_id']])) { |
|
157 | - throw new NotFoundException; |
|
158 | - } |
|
159 | - } else { |
|
160 | - $settings['conditions']['Entry.category_id'] = $this->CurrentUser |
|
161 | - ->Categories->getAllowed(); |
|
162 | - } |
|
163 | - $this->Paginator->settings = $settings; |
|
164 | - unset( |
|
165 | - $this->request->query['direction'], |
|
166 | - $this->request->query['sort'] |
|
167 | - ); |
|
168 | - $this->set('results', |
|
169 | - $this->Paginator->paginate(null, null, ['Entry.time'])); |
|
170 | - } |
|
171 | - |
|
172 | - if (!isset($query['category_id'])) { |
|
173 | - $this->request->data['Entry']['category_id'] = 0; |
|
174 | - } |
|
175 | - |
|
176 | - $this->set(compact('month', 'year')); |
|
177 | - } |
|
178 | - |
|
179 | - protected function _sanitize($string) { |
|
180 | - return Sanitize::escape($string, $this->Entry->useDbConfig); |
|
181 | - } |
|
182 | - |
|
183 | - protected function _filterQuery($params) { |
|
184 | - $this->request->query = array_intersect_key($this->request->query, |
|
185 | - array_fill_keys($params, 1)); |
|
186 | - } |
|
187 | - |
|
188 | - } |
|
3 | + use Saito\SimpleSearchString; |
|
4 | + |
|
5 | + App::uses('AppController', 'Controller'); |
|
6 | + |
|
7 | + class SearchesController extends AppController { |
|
8 | + |
|
9 | + public $components = [ |
|
10 | + 'Paginator', |
|
11 | + 'Search.Prg' => [ |
|
12 | + 'commonProcess' => [ |
|
13 | + 'allowedParams' => ['nstrict'], |
|
14 | + 'keepPassed' => true, |
|
15 | + 'filterEmpty' => true, |
|
16 | + 'paramType' => 'querystring' |
|
17 | + ] |
|
18 | + ] |
|
19 | + ]; |
|
20 | + |
|
21 | + public $helpers = ['Form', 'Html', 'EntryH']; |
|
22 | + |
|
23 | + public $uses = [ |
|
24 | + 'Entry' |
|
25 | + ]; |
|
26 | + |
|
27 | + protected $_paginateConfig = [ |
|
28 | + 'limit' => 25 |
|
29 | + ]; |
|
30 | + |
|
31 | + public function beforeFilter() { |
|
32 | + parent::beforeFilter(); |
|
33 | + $this->Auth->allow('simple'); |
|
34 | + } |
|
35 | + |
|
36 | + public function simple() { |
|
37 | + $defaults = [ |
|
38 | + 'order' => 'time' |
|
39 | + ]; |
|
40 | + $this->set('order', $defaults['order']); |
|
41 | + |
|
42 | + // @todo pgsql |
|
43 | + $db = $this->Entry->getDataSource(); |
|
44 | + // @codingStandardsIgnoreStart |
|
45 | + // on 5.5 phpcs assumes this is the deprecated PHP MySQL extension |
|
46 | + if (!($db instanceof Mysql)) { |
|
47 | + // @codingStandardsIgnoreEnd |
|
48 | + $this->redirect(['action' => 'advanced']); |
|
49 | + return; |
|
50 | + } |
|
51 | + |
|
52 | + $minWordLength = $this->Entry->query("SHOW VARIABLES LIKE 'ft_min_word_len'")[0]; |
|
53 | + $minWordLength = array_shift($minWordLength)['Value']; |
|
54 | + $this->set(compact('minWordLength')); |
|
55 | + |
|
56 | + if (!isset($this->request->query['q'])) { |
|
57 | + // request for empty search form |
|
58 | + return; |
|
59 | + } |
|
60 | + |
|
61 | + $this->_filterQuery(['q', 'page', 'order']); |
|
62 | + $qRaw = $this->request->query['q']; |
|
63 | + $query = $this->request->query += $defaults; |
|
64 | + $this->set(['q' => $qRaw, 'order' => $query['order']]); |
|
65 | + |
|
66 | + // test query is valid |
|
67 | + $SearchString = new SimpleSearchString($qRaw, $minWordLength); |
|
68 | + $this->set('minChars', $minWordLength); |
|
69 | + |
|
70 | + $query['q'] = $SearchString->replaceOperators(); |
|
71 | + $omitted = $SearchString->getOmittedWords(); |
|
72 | + $this->set('omittedWords', $omitted); |
|
73 | + |
|
74 | + // sanitize search-term for manual SQL-query |
|
75 | + $query['q'] = $this->_sanitize($query['q']); |
|
76 | + |
|
77 | + // build query |
|
78 | + $q = $query['q']; |
|
79 | + $order = '`Entry`.`time` DESC'; |
|
80 | + $fields = '*'; |
|
81 | + if ($query['order'] === 'rank') { |
|
82 | + $order = 'rating DESC, ' . $order; |
|
83 | + $fields = $fields . ", (MATCH (Entry.subject) AGAINST ('$q' IN BOOLEAN MODE)*2) + (MATCH (Entry.text) AGAINST ('$q' IN BOOLEAN MODE)) + (MATCH (Entry.name) AGAINST ('$q' IN BOOLEAN MODE)*4) AS rating"; |
|
84 | + } |
|
85 | + |
|
86 | + // query |
|
87 | + $this->Paginator->settings = [ |
|
88 | + 'fields' => $fields, |
|
89 | + 'conditions' => [ |
|
90 | + "MATCH (Entry.subject, Entry.text, Entry.name) AGAINST ('$q' IN BOOLEAN MODE)", |
|
91 | + 'Entry.category_id' => $this->CurrentUser->Categories->getAllowed() |
|
92 | + ], |
|
93 | + 'order' => $order, |
|
94 | + 'paramType' => 'querystring' |
|
95 | + ]; |
|
96 | + $this->Paginator->settings += $this->_paginateConfig; |
|
97 | + $results = $this->Paginator->paginate('Entry'); |
|
98 | + $this->set('results', $results); |
|
99 | + } |
|
100 | + |
|
101 | + /** |
|
102 | + * @throws NotFoundException |
|
103 | + * @throws BadRequestException |
|
104 | + */ |
|
105 | + public function advanced() { |
|
106 | + // year for date drop-down |
|
107 | + $first = $this->Entry->find('first', |
|
108 | + ['contain' => false, 'order' => 'Entry.id ASC']); |
|
109 | + if ($first !== false) { |
|
110 | + $startDate = strtotime($first['Entry']['time']); |
|
111 | + } else { |
|
112 | + $startDate = time(); |
|
113 | + } |
|
114 | + $this->set('start_year', date('Y', $startDate)); |
|
115 | + |
|
116 | + // category drop-down |
|
117 | + $categories = $this->CurrentUser->Categories->getAllowed('list'); |
|
118 | + $this->set('categories', $categories); |
|
119 | + |
|
120 | + // calculate current month and year |
|
121 | + if (isset($this->request->query['month'])) { |
|
122 | + $month = $this->request->query['month']; |
|
123 | + $year = $this->request->query['year']; |
|
124 | + } else { |
|
125 | + $month = date('n', $startDate); |
|
126 | + $year = date('Y', $startDate); |
|
127 | + } |
|
128 | + |
|
129 | + $this->Prg->commonProcess(); |
|
130 | + $query = $this->Prg->parsedParams(); |
|
131 | + |
|
132 | + if (!empty($query['subject']) || !empty($query['text']) || |
|
133 | + !empty($query['name']) |
|
134 | + ) { |
|
135 | + // strict username search: set before parseCriteria |
|
136 | + if (!empty($this->request->query['nstrict'])) { |
|
137 | + // presetVars controller var isn't working in Search v2.3 |
|
138 | + $this->Entry->filterArgs['name']['type'] = 'value'; |
|
139 | + } |
|
140 | + |
|
141 | + $settings = [ |
|
142 | + 'conditions' => $this->Entry->parseCriteria($query), |
|
143 | + 'order' => ['Entry.time' => 'DESC'], |
|
144 | + 'paramType' => 'querystring' |
|
145 | + ] + $this->_paginateConfig; |
|
146 | + |
|
147 | + $time = mktime(0, 0, 0, $month, 1, $year); |
|
148 | + if (!$time) { |
|
149 | + throw new BadRequestException; |
|
150 | + } |
|
151 | + $settings['conditions']['time >'] = date( |
|
152 | + 'Y-m-d H:i:s', |
|
153 | + mktime(0, 0, 0, $month, 1, $year)); |
|
154 | + |
|
155 | + if (isset($query['category_id']) && (int)$query['category_id'] !== 0) { |
|
156 | + if (!isset($categories[(int)$query['category_id']])) { |
|
157 | + throw new NotFoundException; |
|
158 | + } |
|
159 | + } else { |
|
160 | + $settings['conditions']['Entry.category_id'] = $this->CurrentUser |
|
161 | + ->Categories->getAllowed(); |
|
162 | + } |
|
163 | + $this->Paginator->settings = $settings; |
|
164 | + unset( |
|
165 | + $this->request->query['direction'], |
|
166 | + $this->request->query['sort'] |
|
167 | + ); |
|
168 | + $this->set('results', |
|
169 | + $this->Paginator->paginate(null, null, ['Entry.time'])); |
|
170 | + } |
|
171 | + |
|
172 | + if (!isset($query['category_id'])) { |
|
173 | + $this->request->data['Entry']['category_id'] = 0; |
|
174 | + } |
|
175 | + |
|
176 | + $this->set(compact('month', 'year')); |
|
177 | + } |
|
178 | + |
|
179 | + protected function _sanitize($string) { |
|
180 | + return Sanitize::escape($string, $this->Entry->useDbConfig); |
|
181 | + } |
|
182 | + |
|
183 | + protected function _filterQuery($params) { |
|
184 | + $this->request->query = array_intersect_key($this->request->query, |
|
185 | + array_fill_keys($params, 1)); |
|
186 | + } |
|
187 | + |
|
188 | + } |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | |
137 | 137 | // activate stopwatch in debug mode |
138 | 138 | $this->set('showStopwatchOutput', false); |
139 | - if ((int)Configure::read('debug') > 0) { |
|
139 | + if ((int) Configure::read('debug') > 0) { |
|
140 | 140 | $this->set('showStopwatchOutput', true); |
141 | 141 | }; |
142 | 142 | |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | |
184 | 184 | $this->set('lastAction', $this->localReferer('action')); |
185 | 185 | $this->set('lastController', $this->localReferer('controller')); |
186 | - $this->set('isDebug', (int)Configure::read('debug') > 0); |
|
186 | + $this->set('isDebug', (int) Configure::read('debug') > 0); |
|
187 | 187 | $this->_setLayoutTitles(); |
188 | 188 | |
189 | 189 | $this->_setXFrameOptionsHeader(); |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | } else { |
289 | 289 | $_pageTitle = __d( |
290 | 290 | 'page_titles', |
291 | - $this->params['controller'] . '/' . $this->params['action'] |
|
291 | + $this->params['controller'].'/'.$this->params['action'] |
|
292 | 292 | ); |
293 | 293 | } |
294 | 294 | $this->set('title_for_page', $_pageTitle); |
@@ -449,9 +449,9 @@ discard block |
||
449 | 449 | */ |
450 | 450 | protected function _l10nRenderFile() { |
451 | 451 | $locale = Configure::read('Config.language'); |
452 | - $l10nViewPath = $this->viewPath . DS . $locale; |
|
453 | - $l10nViewFile = $l10nViewPath . DS . $this->view . '.ctp'; |
|
454 | - if ($locale && file_exists(APP . 'View' . DS . $l10nViewFile) |
|
452 | + $l10nViewPath = $this->viewPath.DS.$locale; |
|
453 | + $l10nViewFile = $l10nViewPath.DS.$this->view.'.ctp'; |
|
454 | + if ($locale && file_exists(APP.'View'.DS.$l10nViewFile) |
|
455 | 455 | ) { |
456 | 456 | $this->viewPath = $l10nViewPath; |
457 | 457 | } |
@@ -1,196 +1,196 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | - use Saito\Exception\SaitoBlackholeException; |
|
3 | + use Saito\Exception\SaitoBlackholeException; |
|
4 | 4 | |
5 | - App::uses('Controller', 'Controller'); |
|
6 | - App::uses('CakeEmail', 'Network/Email'); |
|
7 | - App::import('Lib', 'Stopwatch.Stopwatch'); |
|
5 | + App::uses('Controller', 'Controller'); |
|
6 | + App::uses('CakeEmail', 'Network/Email'); |
|
7 | + App::import('Lib', 'Stopwatch.Stopwatch'); |
|
8 | 8 | |
9 | - if (Configure::read('debug') > 0) { |
|
10 | - App::uses('FireCake', 'DebugKit.Lib'); |
|
11 | - } |
|
9 | + if (Configure::read('debug') > 0) { |
|
10 | + App::uses('FireCake', 'DebugKit.Lib'); |
|
11 | + } |
|
12 | 12 | |
13 | - class AppController extends Controller { |
|
13 | + class AppController extends Controller { |
|
14 | 14 | |
15 | - public $components = [ |
|
16 | - // 'DebugKit.Toolbar', |
|
15 | + public $components = [ |
|
16 | + // 'DebugKit.Toolbar', |
|
17 | 17 | |
18 | - // Leave in front to catch all unauthorized access first |
|
19 | - 'Security', 'Auth', |
|
20 | - // Leave in front to have it available in all Components |
|
21 | - 'Detectors.Detectors', |
|
18 | + // Leave in front to catch all unauthorized access first |
|
19 | + 'Security', 'Auth', |
|
20 | + // Leave in front to have it available in all Components |
|
21 | + 'Detectors.Detectors', |
|
22 | 22 | /** |
23 | - * You have to have Cookie before CurrentUser to have the salt initialized. |
|
24 | - * Check by deleting Session cookie when persistent cookie is present. |
|
25 | - * @td maybe bug in Cake, because Cookies should be initialized in CurrentUser's $components |
|
26 | - */ |
|
27 | - 'Cookie', |
|
28 | - 'CurrentUser', |
|
29 | - 'CacheSupport', |
|
30 | - 'Cron.Cron', |
|
31 | - 'JsData', |
|
32 | - 'Parser', |
|
33 | - 'SaitoEmail', |
|
34 | - 'EmailNotification', |
|
35 | - // Enabling data view for rss/xml and json |
|
36 | - 'RequestHandler', |
|
37 | - 'Session', |
|
38 | - 'Themes' |
|
39 | - ]; |
|
40 | - |
|
41 | - public $helpers = [ |
|
42 | - 'JsData', |
|
43 | - // 'Markitup.Markitup', |
|
44 | - 'Layout', |
|
45 | - 'RequireJs', |
|
46 | - 'SaitoHelp.SaitoHelp', |
|
47 | - 'Stopwatch.Stopwatch', |
|
48 | - 'TimeH', |
|
49 | - 'UserH', |
|
50 | - // CakePHP helpers |
|
51 | - 'Js' => array('Jquery'), |
|
52 | - 'Html', |
|
53 | - 'Form', |
|
54 | - 'Session' |
|
55 | - ]; |
|
56 | - |
|
57 | - public $uses = [ |
|
58 | - 'Setting', |
|
59 | - 'User' |
|
60 | - ]; |
|
23 | + * You have to have Cookie before CurrentUser to have the salt initialized. |
|
24 | + * Check by deleting Session cookie when persistent cookie is present. |
|
25 | + * @td maybe bug in Cake, because Cookies should be initialized in CurrentUser's $components |
|
26 | + */ |
|
27 | + 'Cookie', |
|
28 | + 'CurrentUser', |
|
29 | + 'CacheSupport', |
|
30 | + 'Cron.Cron', |
|
31 | + 'JsData', |
|
32 | + 'Parser', |
|
33 | + 'SaitoEmail', |
|
34 | + 'EmailNotification', |
|
35 | + // Enabling data view for rss/xml and json |
|
36 | + 'RequestHandler', |
|
37 | + 'Session', |
|
38 | + 'Themes' |
|
39 | + ]; |
|
40 | + |
|
41 | + public $helpers = [ |
|
42 | + 'JsData', |
|
43 | + // 'Markitup.Markitup', |
|
44 | + 'Layout', |
|
45 | + 'RequireJs', |
|
46 | + 'SaitoHelp.SaitoHelp', |
|
47 | + 'Stopwatch.Stopwatch', |
|
48 | + 'TimeH', |
|
49 | + 'UserH', |
|
50 | + // CakePHP helpers |
|
51 | + 'Js' => array('Jquery'), |
|
52 | + 'Html', |
|
53 | + 'Form', |
|
54 | + 'Session' |
|
55 | + ]; |
|
56 | + |
|
57 | + public $uses = [ |
|
58 | + 'Setting', |
|
59 | + 'User' |
|
60 | + ]; |
|
61 | 61 | |
62 | 62 | /** |
63 | 63 | * name of the theme used |
64 | 64 | * |
65 | 65 | * @var string |
66 | 66 | */ |
67 | - public $theme = 'paz'; |
|
67 | + public $theme = 'paz'; |
|
68 | 68 | |
69 | 69 | /** |
70 | 70 | * S(l)idetabs used by the application |
71 | 71 | * |
72 | 72 | * @var array |
73 | 73 | */ |
74 | - public $installedSlidetabs = [ |
|
75 | - 'slidetab_userlist', |
|
76 | - 'slidetab_recentposts', |
|
77 | - 'slidetab_recententries', |
|
78 | - 'slidetab_shoutbox' |
|
79 | - ]; |
|
74 | + public $installedSlidetabs = [ |
|
75 | + 'slidetab_userlist', |
|
76 | + 'slidetab_recentposts', |
|
77 | + 'slidetab_recententries', |
|
78 | + 'slidetab_shoutbox' |
|
79 | + ]; |
|
80 | 80 | |
81 | 81 | /** |
82 | 82 | * Are app stats calculated |
83 | 83 | * |
84 | 84 | * @var bool |
85 | 85 | */ |
86 | - protected $_areAppStatsSet = false; |
|
86 | + protected $_areAppStatsSet = false; |
|
87 | 87 | |
88 | 88 | /** |
89 | 89 | * @var bool show disclaimer in page footer |
90 | 90 | */ |
91 | - public $showDisclaimer = false; |
|
92 | - |
|
93 | - /** |
|
94 | - * objects shared between controllers & models |
|
95 | - * |
|
96 | - * Avoids a lot of boilerplate code and shuffling around singletons. |
|
97 | - * |
|
98 | - * @var array objects shared between controllers & models |
|
99 | - */ |
|
100 | - public $SharedObjects = []; |
|
101 | - |
|
102 | - public function __construct($request = null, $response = null) { |
|
103 | - Stopwatch::start( |
|
104 | - '---------------------- Controller ----------------------' |
|
105 | - ); |
|
106 | - |
|
107 | - ClassRegistry::addObject('dic', \Saito\DicSetup::getNewDic()); |
|
108 | - parent::__construct($request, $response); |
|
109 | - } |
|
110 | - |
|
111 | - public function __get($name) { |
|
112 | - switch ($name) { |
|
113 | - case 'dic': |
|
114 | - return ClassRegistry::getObject('dic'); |
|
115 | - default: |
|
116 | - return parent::__get($name); |
|
117 | - } |
|
118 | - } |
|
119 | - |
|
120 | - public function beforeFilter() { |
|
121 | - Stopwatch::start('App->beforeFilter()'); |
|
122 | - |
|
123 | - // must be called before CakeError early return |
|
124 | - $this->Themes->theme(Configure::read('Saito.themes')); |
|
125 | - $this->Setting->load(Configure::read('Saito.Settings')); |
|
126 | - |
|
127 | - // CakeErrors run through this beforeFilter, which is usually not necessary |
|
128 | - // for error messages |
|
129 | - if ($this->name === 'CakeError') { |
|
130 | - return; |
|
131 | - } |
|
132 | - |
|
133 | - $this->Security->blackHoleCallback = 'blackhole'; |
|
134 | - $this->Security->csrfUseOnce = false; |
|
135 | - $this->Security->csrfExpires = '+3 hours'; |
|
136 | - |
|
137 | - // activate stopwatch in debug mode |
|
138 | - $this->set('showStopwatchOutput', false); |
|
139 | - if ((int)Configure::read('debug') > 0) { |
|
140 | - $this->set('showStopwatchOutput', true); |
|
141 | - }; |
|
142 | - |
|
143 | - // setup for admin area |
|
144 | - if (isset($this->params['admin'])): |
|
145 | - $this->_beforeFilterAdminArea(); |
|
146 | - endif; |
|
147 | - |
|
148 | - // disable forum with admin pref |
|
149 | - if (Configure::read('Saito.Settings.forum_disabled') && |
|
150 | - $this->request['action'] !== 'login' && |
|
151 | - !$this->CurrentUser->isAdmin() |
|
152 | - ) { |
|
153 | - $this->Themes->setDefault(); |
|
154 | - return $this->render('/Pages/forum_disabled', 'barebone'); |
|
155 | - exit; |
|
156 | - } |
|
157 | - |
|
158 | - $this->_setupSlideTabs(); |
|
159 | - |
|
160 | - $this->_setConfigurationFromGetParams(); |
|
161 | - |
|
162 | - // must be set after all language chooser |
|
163 | - \Saito\String\Properize::setLanguage(Configure::read('Config.language')); |
|
164 | - |
|
165 | - // allow sql explain for DebugKit toolbar |
|
166 | - if ($this->request->plugin === 'debug_kit') { |
|
167 | - $this->Auth->allow('sql_explain'); |
|
168 | - } |
|
169 | - |
|
170 | - $this->_l10nRenderFile(); |
|
171 | - |
|
172 | - Stopwatch::stop('App->beforeFilter()'); |
|
173 | - } |
|
174 | - |
|
175 | - public function beforeRender() { |
|
176 | - Stopwatch::start('App->beforeRender()'); |
|
177 | - |
|
178 | - parent::beforeRender(); |
|
179 | - |
|
180 | - if ($this->showDisclaimer) { |
|
181 | - $this->_showDisclaimer(); |
|
182 | - } |
|
183 | - |
|
184 | - $this->set('lastAction', $this->localReferer('action')); |
|
185 | - $this->set('lastController', $this->localReferer('controller')); |
|
186 | - $this->set('isDebug', (int)Configure::read('debug') > 0); |
|
187 | - $this->_setLayoutTitles(); |
|
188 | - |
|
189 | - $this->_setXFrameOptionsHeader(); |
|
190 | - |
|
191 | - Stopwatch::stop('App->beforeRender()'); |
|
192 | - Stopwatch::start('---------------------- Rendering ---------------------- '); |
|
193 | - } |
|
91 | + public $showDisclaimer = false; |
|
92 | + |
|
93 | + /** |
|
94 | + * objects shared between controllers & models |
|
95 | + * |
|
96 | + * Avoids a lot of boilerplate code and shuffling around singletons. |
|
97 | + * |
|
98 | + * @var array objects shared between controllers & models |
|
99 | + */ |
|
100 | + public $SharedObjects = []; |
|
101 | + |
|
102 | + public function __construct($request = null, $response = null) { |
|
103 | + Stopwatch::start( |
|
104 | + '---------------------- Controller ----------------------' |
|
105 | + ); |
|
106 | + |
|
107 | + ClassRegistry::addObject('dic', \Saito\DicSetup::getNewDic()); |
|
108 | + parent::__construct($request, $response); |
|
109 | + } |
|
110 | + |
|
111 | + public function __get($name) { |
|
112 | + switch ($name) { |
|
113 | + case 'dic': |
|
114 | + return ClassRegistry::getObject('dic'); |
|
115 | + default: |
|
116 | + return parent::__get($name); |
|
117 | + } |
|
118 | + } |
|
119 | + |
|
120 | + public function beforeFilter() { |
|
121 | + Stopwatch::start('App->beforeFilter()'); |
|
122 | + |
|
123 | + // must be called before CakeError early return |
|
124 | + $this->Themes->theme(Configure::read('Saito.themes')); |
|
125 | + $this->Setting->load(Configure::read('Saito.Settings')); |
|
126 | + |
|
127 | + // CakeErrors run through this beforeFilter, which is usually not necessary |
|
128 | + // for error messages |
|
129 | + if ($this->name === 'CakeError') { |
|
130 | + return; |
|
131 | + } |
|
132 | + |
|
133 | + $this->Security->blackHoleCallback = 'blackhole'; |
|
134 | + $this->Security->csrfUseOnce = false; |
|
135 | + $this->Security->csrfExpires = '+3 hours'; |
|
136 | + |
|
137 | + // activate stopwatch in debug mode |
|
138 | + $this->set('showStopwatchOutput', false); |
|
139 | + if ((int)Configure::read('debug') > 0) { |
|
140 | + $this->set('showStopwatchOutput', true); |
|
141 | + }; |
|
142 | + |
|
143 | + // setup for admin area |
|
144 | + if (isset($this->params['admin'])): |
|
145 | + $this->_beforeFilterAdminArea(); |
|
146 | + endif; |
|
147 | + |
|
148 | + // disable forum with admin pref |
|
149 | + if (Configure::read('Saito.Settings.forum_disabled') && |
|
150 | + $this->request['action'] !== 'login' && |
|
151 | + !$this->CurrentUser->isAdmin() |
|
152 | + ) { |
|
153 | + $this->Themes->setDefault(); |
|
154 | + return $this->render('/Pages/forum_disabled', 'barebone'); |
|
155 | + exit; |
|
156 | + } |
|
157 | + |
|
158 | + $this->_setupSlideTabs(); |
|
159 | + |
|
160 | + $this->_setConfigurationFromGetParams(); |
|
161 | + |
|
162 | + // must be set after all language chooser |
|
163 | + \Saito\String\Properize::setLanguage(Configure::read('Config.language')); |
|
164 | + |
|
165 | + // allow sql explain for DebugKit toolbar |
|
166 | + if ($this->request->plugin === 'debug_kit') { |
|
167 | + $this->Auth->allow('sql_explain'); |
|
168 | + } |
|
169 | + |
|
170 | + $this->_l10nRenderFile(); |
|
171 | + |
|
172 | + Stopwatch::stop('App->beforeFilter()'); |
|
173 | + } |
|
174 | + |
|
175 | + public function beforeRender() { |
|
176 | + Stopwatch::start('App->beforeRender()'); |
|
177 | + |
|
178 | + parent::beforeRender(); |
|
179 | + |
|
180 | + if ($this->showDisclaimer) { |
|
181 | + $this->_showDisclaimer(); |
|
182 | + } |
|
183 | + |
|
184 | + $this->set('lastAction', $this->localReferer('action')); |
|
185 | + $this->set('lastController', $this->localReferer('controller')); |
|
186 | + $this->set('isDebug', (int)Configure::read('debug') > 0); |
|
187 | + $this->_setLayoutTitles(); |
|
188 | + |
|
189 | + $this->_setXFrameOptionsHeader(); |
|
190 | + |
|
191 | + Stopwatch::stop('App->beforeRender()'); |
|
192 | + Stopwatch::start('---------------------- Rendering ---------------------- '); |
|
193 | + } |
|
194 | 194 | |
195 | 195 | /** |
196 | 196 | * Sets forum configuration from GET parameter in url |
@@ -199,120 +199,120 @@ discard block |
||
199 | 199 | * - stopwatch:true |
200 | 200 | * - lang:<lang_id> |
201 | 201 | */ |
202 | - protected function _setConfigurationFromGetParams() { |
|
203 | - if (!$this->CurrentUser->isLoggedIn()) { |
|
204 | - return; |
|
205 | - } |
|
206 | - |
|
207 | - // change theme on the fly with ?theme=<name> |
|
208 | - if (isset($this->request->query['theme'])) { |
|
209 | - $this->theme = $this->request->query['theme']; |
|
210 | - } |
|
211 | - |
|
212 | - // activate stopwatch |
|
213 | - if (isset($this->request->query['stopwatch']) && Configure::read('Saito.Settings.stopwatch_get')) { |
|
214 | - $this->set('showStopwatchOutput', true); |
|
215 | - }; |
|
216 | - |
|
217 | - // change language |
|
218 | - if (isset($this->request->query['lang'])) { |
|
219 | - $L10n = ClassRegistry::init('L10n'); |
|
220 | - $lang = $this->request->query['lang']; |
|
221 | - if ($L10n->catalog($lang)) { |
|
222 | - Configure::write('Config.language', $lang); |
|
223 | - } |
|
224 | - }; |
|
225 | - } |
|
202 | + protected function _setConfigurationFromGetParams() { |
|
203 | + if (!$this->CurrentUser->isLoggedIn()) { |
|
204 | + return; |
|
205 | + } |
|
206 | + |
|
207 | + // change theme on the fly with ?theme=<name> |
|
208 | + if (isset($this->request->query['theme'])) { |
|
209 | + $this->theme = $this->request->query['theme']; |
|
210 | + } |
|
211 | + |
|
212 | + // activate stopwatch |
|
213 | + if (isset($this->request->query['stopwatch']) && Configure::read('Saito.Settings.stopwatch_get')) { |
|
214 | + $this->set('showStopwatchOutput', true); |
|
215 | + }; |
|
216 | + |
|
217 | + // change language |
|
218 | + if (isset($this->request->query['lang'])) { |
|
219 | + $L10n = ClassRegistry::init('L10n'); |
|
220 | + $lang = $this->request->query['lang']; |
|
221 | + if ($L10n->catalog($lang)) { |
|
222 | + Configure::write('Config.language', $lang); |
|
223 | + } |
|
224 | + }; |
|
225 | + } |
|
226 | 226 | |
227 | 227 | /** |
228 | 228 | * sets layout/title/page vars |
229 | 229 | * |
230 | 230 | * @td helper? |
231 | 231 | */ |
232 | - protected function _setLayoutTitles() { |
|
233 | - $_pageTitle = $this->_setPageTitle(); |
|
234 | - $_forumName = $this->_setForumName(); |
|
235 | - $this->_setForumTitle($_pageTitle, $_forumName); |
|
236 | - } |
|
237 | - |
|
238 | - /** |
|
239 | - * Sets forum name according to forum settings if not already set |
|
240 | - * |
|
241 | - * @return string |
|
242 | - */ |
|
243 | - protected function _setForumName() { |
|
244 | - if (isset($this->viewVars['forum_name'])) { |
|
245 | - return $this->viewVars['forum_name']; |
|
246 | - } |
|
247 | - $_forumName = Configure::read('Saito.Settings.forum_name'); |
|
248 | - $this->set('forum_name', $_forumName); |
|
249 | - return $_forumName; |
|
250 | - } |
|
251 | - |
|
252 | - /** |
|
253 | - * Sets forum title `<page> - <forum>` |
|
254 | - * |
|
255 | - * @param string $pageTitle |
|
256 | - * @param string $forumName |
|
257 | - * @return string |
|
258 | - */ |
|
259 | - protected function _setForumTitle($pageTitle, $forumName) { |
|
260 | - $_forumTitle = $pageTitle; |
|
261 | - if (!empty($forumName)) { |
|
262 | - $_forumTitle = CakeText::insert(__('forum-title-template'), |
|
263 | - ['page' => $pageTitle, 'forum' => $forumName]); |
|
264 | - } |
|
265 | - $this->set('title_for_layout', $_forumTitle); |
|
266 | - return $_forumTitle; |
|
267 | - } |
|
268 | - |
|
269 | - /** |
|
270 | - * Sets page title |
|
271 | - * |
|
272 | - * Looks in this order for: |
|
273 | - * 1. title_for_page |
|
274 | - * 2. title_for_layout |
|
275 | - * 3. `page_titles.po` language file with 'controller/view' title, |
|
276 | - * use plural for for controller title: 'entries/index' (not 'entry/index')! |
|
277 | - * |
|
278 | - * @return string |
|
279 | - */ |
|
280 | - protected function _setPageTitle() { |
|
281 | - if (isset($this->viewVars['title_for_page'])) { |
|
282 | - $_pageTitle = $this->viewVars['title_for_page']; |
|
283 | - } elseif (isset($this->viewVars['title_for_layout'])) { |
|
284 | - // provides CakePHP backwards-compatibility |
|
285 | - $_pageTitle = $this->viewVars['title_for_layout']; |
|
286 | - } elseif ($this->name === 'CakeError') { |
|
287 | - $_pageTitle = ''; |
|
288 | - } else { |
|
289 | - $_pageTitle = __d( |
|
290 | - 'page_titles', |
|
291 | - $this->params['controller'] . '/' . $this->params['action'] |
|
292 | - ); |
|
293 | - } |
|
294 | - $this->set('title_for_page', $_pageTitle); |
|
295 | - return $_pageTitle; |
|
296 | - } |
|
297 | - |
|
298 | - protected function _setXFrameOptionsHeader() { |
|
299 | - $xFO = Configure::read('Saito.X-Frame-Options'); |
|
300 | - if (empty($xFO)) { |
|
301 | - $xFO = 'SAMEORIGIN'; |
|
302 | - } |
|
303 | - $this->response->header('X-Frame-Options', $xFO); |
|
304 | - } |
|
305 | - |
|
306 | - /** |
|
307 | - * |
|
308 | - * |
|
309 | - * @param $type |
|
310 | - * @throws Saito\Exception\SaitoBlackholeException |
|
311 | - */ |
|
312 | - public function blackhole($type) { |
|
313 | - throw new SaitoBlackholeException($type, |
|
314 | - ['CurrentUser' => $this->CurrentUser]); |
|
315 | - } |
|
232 | + protected function _setLayoutTitles() { |
|
233 | + $_pageTitle = $this->_setPageTitle(); |
|
234 | + $_forumName = $this->_setForumName(); |
|
235 | + $this->_setForumTitle($_pageTitle, $_forumName); |
|
236 | + } |
|
237 | + |
|
238 | + /** |
|
239 | + * Sets forum name according to forum settings if not already set |
|
240 | + * |
|
241 | + * @return string |
|
242 | + */ |
|
243 | + protected function _setForumName() { |
|
244 | + if (isset($this->viewVars['forum_name'])) { |
|
245 | + return $this->viewVars['forum_name']; |
|
246 | + } |
|
247 | + $_forumName = Configure::read('Saito.Settings.forum_name'); |
|
248 | + $this->set('forum_name', $_forumName); |
|
249 | + return $_forumName; |
|
250 | + } |
|
251 | + |
|
252 | + /** |
|
253 | + * Sets forum title `<page> - <forum>` |
|
254 | + * |
|
255 | + * @param string $pageTitle |
|
256 | + * @param string $forumName |
|
257 | + * @return string |
|
258 | + */ |
|
259 | + protected function _setForumTitle($pageTitle, $forumName) { |
|
260 | + $_forumTitle = $pageTitle; |
|
261 | + if (!empty($forumName)) { |
|
262 | + $_forumTitle = CakeText::insert(__('forum-title-template'), |
|
263 | + ['page' => $pageTitle, 'forum' => $forumName]); |
|
264 | + } |
|
265 | + $this->set('title_for_layout', $_forumTitle); |
|
266 | + return $_forumTitle; |
|
267 | + } |
|
268 | + |
|
269 | + /** |
|
270 | + * Sets page title |
|
271 | + * |
|
272 | + * Looks in this order for: |
|
273 | + * 1. title_for_page |
|
274 | + * 2. title_for_layout |
|
275 | + * 3. `page_titles.po` language file with 'controller/view' title, |
|
276 | + * use plural for for controller title: 'entries/index' (not 'entry/index')! |
|
277 | + * |
|
278 | + * @return string |
|
279 | + */ |
|
280 | + protected function _setPageTitle() { |
|
281 | + if (isset($this->viewVars['title_for_page'])) { |
|
282 | + $_pageTitle = $this->viewVars['title_for_page']; |
|
283 | + } elseif (isset($this->viewVars['title_for_layout'])) { |
|
284 | + // provides CakePHP backwards-compatibility |
|
285 | + $_pageTitle = $this->viewVars['title_for_layout']; |
|
286 | + } elseif ($this->name === 'CakeError') { |
|
287 | + $_pageTitle = ''; |
|
288 | + } else { |
|
289 | + $_pageTitle = __d( |
|
290 | + 'page_titles', |
|
291 | + $this->params['controller'] . '/' . $this->params['action'] |
|
292 | + ); |
|
293 | + } |
|
294 | + $this->set('title_for_page', $_pageTitle); |
|
295 | + return $_pageTitle; |
|
296 | + } |
|
297 | + |
|
298 | + protected function _setXFrameOptionsHeader() { |
|
299 | + $xFO = Configure::read('Saito.X-Frame-Options'); |
|
300 | + if (empty($xFO)) { |
|
301 | + $xFO = 'SAMEORIGIN'; |
|
302 | + } |
|
303 | + $this->response->header('X-Frame-Options', $xFO); |
|
304 | + } |
|
305 | + |
|
306 | + /** |
|
307 | + * |
|
308 | + * |
|
309 | + * @param $type |
|
310 | + * @throws Saito\Exception\SaitoBlackholeException |
|
311 | + */ |
|
312 | + public function blackhole($type) { |
|
313 | + throw new SaitoBlackholeException($type, |
|
314 | + ['CurrentUser' => $this->CurrentUser]); |
|
315 | + } |
|
316 | 316 | |
317 | 317 | /** |
318 | 318 | * Custom referer which can return only referer's action or controller |
@@ -320,141 +320,141 @@ discard block |
||
320 | 320 | * @param string $type 'controller' or 'action' |
321 | 321 | * @return string |
322 | 322 | */ |
323 | - public function localReferer($type = null) { |
|
324 | - $referer = parent::referer(null, true); |
|
325 | - $parsed = Router::parse($referer); |
|
326 | - if (isset($parsed[$type])) { |
|
327 | - return $parsed[$type]; |
|
328 | - } else { |
|
329 | - if ($type === 'action') { |
|
330 | - return 'index'; |
|
331 | - } elseif ($type === 'controller') { |
|
332 | - return 'entries'; |
|
333 | - } |
|
334 | - } |
|
335 | - return $referer; |
|
336 | - } |
|
323 | + public function localReferer($type = null) { |
|
324 | + $referer = parent::referer(null, true); |
|
325 | + $parsed = Router::parse($referer); |
|
326 | + if (isset($parsed[$type])) { |
|
327 | + return $parsed[$type]; |
|
328 | + } else { |
|
329 | + if ($type === 'action') { |
|
330 | + return 'index'; |
|
331 | + } elseif ($type === 'controller') { |
|
332 | + return 'entries'; |
|
333 | + } |
|
334 | + } |
|
335 | + return $referer; |
|
336 | + } |
|
337 | 337 | |
338 | 338 | /** |
339 | 339 | * Setup which slidetabs are available and user sorting |
340 | 340 | * |
341 | 341 | * @throws ForbiddenException |
342 | 342 | */ |
343 | - protected function _setupSlideTabs() { |
|
344 | - $slidetabs = $this->installedSlidetabs; |
|
345 | - |
|
346 | - if (!empty($this->CurrentUser['slidetab_order'])) { |
|
347 | - $slidetabsUser = unserialize($this->CurrentUser['slidetab_order']); |
|
348 | - // disabled tabs still set in user-prefs are unset |
|
349 | - $slidetabsUser = array_intersect($slidetabsUser, $this->installedSlidetabs); |
|
350 | - // new tabs not set in user-prefs are added |
|
351 | - $slidetabs = array_unique(array_merge($slidetabsUser, $this->installedSlidetabs)); |
|
352 | - } |
|
353 | - if (Configure::read('Saito.Settings.shoutbox_enabled') == false) { |
|
354 | - unset($slidetabs[array_search('slidetab_shoutbox', $slidetabs)]); |
|
355 | - } |
|
356 | - $this->set('slidetabs', $slidetabs); |
|
357 | - } |
|
358 | - |
|
359 | - protected function _beforeFilterAdminArea() { |
|
360 | - // protect the admin area |
|
361 | - if ($this->CurrentUser->isAdmin() !== true) : |
|
362 | - throw new ForbiddenException(); |
|
363 | - endif; |
|
364 | - |
|
365 | - $this->layout = 'admin'; |
|
366 | - } |
|
367 | - |
|
368 | - /** |
|
369 | - * manually require auth and redirect cycle |
|
370 | - */ |
|
371 | - protected function _requireAuth() { |
|
372 | - $this->Session->setFlash(__('auth_autherror'), 'flash/warning'); |
|
373 | - $here = $this->request->here(false); |
|
374 | - $this->Auth->redirectUrl($here); |
|
375 | - $this->redirect(['controller' => 'users', 'action' => 'login']); |
|
376 | - } |
|
343 | + protected function _setupSlideTabs() { |
|
344 | + $slidetabs = $this->installedSlidetabs; |
|
345 | + |
|
346 | + if (!empty($this->CurrentUser['slidetab_order'])) { |
|
347 | + $slidetabsUser = unserialize($this->CurrentUser['slidetab_order']); |
|
348 | + // disabled tabs still set in user-prefs are unset |
|
349 | + $slidetabsUser = array_intersect($slidetabsUser, $this->installedSlidetabs); |
|
350 | + // new tabs not set in user-prefs are added |
|
351 | + $slidetabs = array_unique(array_merge($slidetabsUser, $this->installedSlidetabs)); |
|
352 | + } |
|
353 | + if (Configure::read('Saito.Settings.shoutbox_enabled') == false) { |
|
354 | + unset($slidetabs[array_search('slidetab_shoutbox', $slidetabs)]); |
|
355 | + } |
|
356 | + $this->set('slidetabs', $slidetabs); |
|
357 | + } |
|
358 | + |
|
359 | + protected function _beforeFilterAdminArea() { |
|
360 | + // protect the admin area |
|
361 | + if ($this->CurrentUser->isAdmin() !== true) : |
|
362 | + throw new ForbiddenException(); |
|
363 | + endif; |
|
364 | + |
|
365 | + $this->layout = 'admin'; |
|
366 | + } |
|
367 | + |
|
368 | + /** |
|
369 | + * manually require auth and redirect cycle |
|
370 | + */ |
|
371 | + protected function _requireAuth() { |
|
372 | + $this->Session->setFlash(__('auth_autherror'), 'flash/warning'); |
|
373 | + $here = $this->request->here(false); |
|
374 | + $this->Auth->redirectUrl($here); |
|
375 | + $this->redirect(['controller' => 'users', 'action' => 'login']); |
|
376 | + } |
|
377 | 377 | |
378 | 378 | /** |
379 | 379 | * Shows the disclaimer in the layout |
380 | 380 | */ |
381 | - protected function _showDisclaimer() { |
|
382 | - $this->_setAppStats(); |
|
383 | - $this->set('showDisclaimer', true); |
|
384 | - } |
|
381 | + protected function _showDisclaimer() { |
|
382 | + $this->_setAppStats(); |
|
383 | + $this->set('showDisclaimer', true); |
|
384 | + } |
|
385 | 385 | |
386 | 386 | /** |
387 | 387 | * Set application statistics used in the disclaimer |
388 | 388 | */ |
389 | - protected function _setAppStats() { |
|
390 | - if ($this->_areAppStatsSet) { |
|
391 | - return; |
|
392 | - } |
|
393 | - Stopwatch::start('AppController->_setAppStats()'); |
|
394 | - $this->_areAppStatsSet = true; |
|
395 | - |
|
396 | - $loggedinUsers = $this->User->UserOnline->getLoggedIn(); |
|
397 | - $this->set('UsersOnline', $loggedinUsers); |
|
398 | - |
|
399 | - /* @var $headCounter array or false */ |
|
400 | - $headCounter = Cache::read('header_counter', 'short'); |
|
401 | - if (!$headCounter) { |
|
402 | - $countableItems = [ |
|
403 | - 'user_online' => ['model' => 'UserOnline', 'conditions' => ''], |
|
404 | - 'user' => ['model' => 'User', 'conditions' => ''], |
|
405 | - 'entries' => ['model' => 'Entry', 'conditions' => ''], |
|
406 | - 'threads' => [ |
|
407 | - 'model' => 'Entry', |
|
408 | - 'conditions' => ['pid' => 0] |
|
409 | - ] |
|
410 | - ]; |
|
411 | - |
|
412 | - if (!isset($this->Entry)) { |
|
413 | - $this->loadModel('Entry'); |
|
414 | - } |
|
415 | - |
|
416 | - // @td foreach not longer feasable, refactor |
|
417 | - foreach ($countableItems as $titel => $options) { |
|
418 | - if ($options['model'] === 'Entry') { |
|
419 | - $headCounter[$titel] = $this->{$options['model']}->find( |
|
420 | - 'count', |
|
421 | - ['contain' => false, 'conditions' => $options['conditions']] |
|
422 | - ); |
|
423 | - } elseif ($options['model'] === 'User') { |
|
424 | - $headCounter[$titel] = $this->Entry->{$options['model']}->find( |
|
425 | - 'count', |
|
426 | - ['contain' => false, 'conditions' => $options['conditions']] |
|
427 | - ); |
|
428 | - } elseif ($options['model'] === 'UserOnline') { |
|
429 | - $headCounter[$titel] = $this->Entry->User->{$options['model']}->find( |
|
430 | - 'count', |
|
431 | - ['contain' => false, 'conditions' => $options['conditions']] |
|
432 | - ); |
|
433 | - } |
|
434 | - } |
|
435 | - $headCounter['latestUser'] = $this->Entry->User->find('latest'); |
|
436 | - Cache::write('header_counter', $headCounter, 'short'); |
|
437 | - } |
|
438 | - $headCounter['user_registered'] = count($loggedinUsers); |
|
439 | - $anonUser = $headCounter['user_online'] - $headCounter['user_registered']; |
|
440 | - // compensate for cached 'user_online' so that user_anonymous can't get negative |
|
441 | - $headCounter['user_anonymous'] = ($anonUser < 0) ? 0 : $anonUser; |
|
442 | - |
|
443 | - $this->set('HeaderCounter', $headCounter); |
|
444 | - Stopwatch::stop('AppController->_setAppStats()'); |
|
445 | - } |
|
446 | - |
|
447 | - /** |
|
448 | - * sets l10n .ctp file if available |
|
449 | - */ |
|
450 | - protected function _l10nRenderFile() { |
|
451 | - $locale = Configure::read('Config.language'); |
|
452 | - $l10nViewPath = $this->viewPath . DS . $locale; |
|
453 | - $l10nViewFile = $l10nViewPath . DS . $this->view . '.ctp'; |
|
454 | - if ($locale && file_exists(APP . 'View' . DS . $l10nViewFile) |
|
455 | - ) { |
|
456 | - $this->viewPath = $l10nViewPath; |
|
457 | - } |
|
458 | - } |
|
459 | - |
|
460 | - } |
|
389 | + protected function _setAppStats() { |
|
390 | + if ($this->_areAppStatsSet) { |
|
391 | + return; |
|
392 | + } |
|
393 | + Stopwatch::start('AppController->_setAppStats()'); |
|
394 | + $this->_areAppStatsSet = true; |
|
395 | + |
|
396 | + $loggedinUsers = $this->User->UserOnline->getLoggedIn(); |
|
397 | + $this->set('UsersOnline', $loggedinUsers); |
|
398 | + |
|
399 | + /* @var $headCounter array or false */ |
|
400 | + $headCounter = Cache::read('header_counter', 'short'); |
|
401 | + if (!$headCounter) { |
|
402 | + $countableItems = [ |
|
403 | + 'user_online' => ['model' => 'UserOnline', 'conditions' => ''], |
|
404 | + 'user' => ['model' => 'User', 'conditions' => ''], |
|
405 | + 'entries' => ['model' => 'Entry', 'conditions' => ''], |
|
406 | + 'threads' => [ |
|
407 | + 'model' => 'Entry', |
|
408 | + 'conditions' => ['pid' => 0] |
|
409 | + ] |
|
410 | + ]; |
|
411 | + |
|
412 | + if (!isset($this->Entry)) { |
|
413 | + $this->loadModel('Entry'); |
|
414 | + } |
|
415 | + |
|
416 | + // @td foreach not longer feasable, refactor |
|
417 | + foreach ($countableItems as $titel => $options) { |
|
418 | + if ($options['model'] === 'Entry') { |
|
419 | + $headCounter[$titel] = $this->{$options['model']}->find( |
|
420 | + 'count', |
|
421 | + ['contain' => false, 'conditions' => $options['conditions']] |
|
422 | + ); |
|
423 | + } elseif ($options['model'] === 'User') { |
|
424 | + $headCounter[$titel] = $this->Entry->{$options['model']}->find( |
|
425 | + 'count', |
|
426 | + ['contain' => false, 'conditions' => $options['conditions']] |
|
427 | + ); |
|
428 | + } elseif ($options['model'] === 'UserOnline') { |
|
429 | + $headCounter[$titel] = $this->Entry->User->{$options['model']}->find( |
|
430 | + 'count', |
|
431 | + ['contain' => false, 'conditions' => $options['conditions']] |
|
432 | + ); |
|
433 | + } |
|
434 | + } |
|
435 | + $headCounter['latestUser'] = $this->Entry->User->find('latest'); |
|
436 | + Cache::write('header_counter', $headCounter, 'short'); |
|
437 | + } |
|
438 | + $headCounter['user_registered'] = count($loggedinUsers); |
|
439 | + $anonUser = $headCounter['user_online'] - $headCounter['user_registered']; |
|
440 | + // compensate for cached 'user_online' so that user_anonymous can't get negative |
|
441 | + $headCounter['user_anonymous'] = ($anonUser < 0) ? 0 : $anonUser; |
|
442 | + |
|
443 | + $this->set('HeaderCounter', $headCounter); |
|
444 | + Stopwatch::stop('AppController->_setAppStats()'); |
|
445 | + } |
|
446 | + |
|
447 | + /** |
|
448 | + * sets l10n .ctp file if available |
|
449 | + */ |
|
450 | + protected function _l10nRenderFile() { |
|
451 | + $locale = Configure::read('Config.language'); |
|
452 | + $l10nViewPath = $this->viewPath . DS . $locale; |
|
453 | + $l10nViewFile = $l10nViewPath . DS . $this->view . '.ctp'; |
|
454 | + if ($locale && file_exists(APP . 'View' . DS . $l10nViewFile) |
|
455 | + ) { |
|
456 | + $this->viewPath = $l10nViewPath; |
|
457 | + } |
|
458 | + } |
|
459 | + |
|
460 | + } |
@@ -130,7 +130,7 @@ |
||
130 | 130 | * @return array with Theme names |
131 | 131 | */ |
132 | 132 | public function themeDirs() { |
133 | - $_ThemeDir = new Folder(App::paths()['View'][0] . 'Themed'); |
|
133 | + $_ThemeDir = new Folder(App::paths()['View'][0].'Themed'); |
|
134 | 134 | return $_ThemeDir->read()[0]; |
135 | 135 | } |
136 | 136 |
@@ -1,137 +1,137 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | - App::uses('App', 'Core'); |
|
4 | - App::uses('Folder', 'Utility'); |
|
5 | - App::uses('Component', 'Controller'); |
|
6 | - |
|
7 | - class ThemesComponent extends Component { |
|
8 | - |
|
9 | - protected $_config = null; |
|
10 | - |
|
11 | - protected $_applied = null; |
|
12 | - |
|
13 | - protected $_available = []; |
|
14 | - |
|
15 | - protected $_Controller = null; |
|
16 | - |
|
17 | - public function initialize(Controller $controller) { |
|
18 | - $this->_Controller = $controller; |
|
19 | - } |
|
20 | - |
|
21 | - /** |
|
22 | - * Sets and/or gets current theme |
|
23 | - * |
|
24 | - * @param mixed $params name string or config array |
|
25 | - * @return string current theme |
|
26 | - * @throws InvalidArgumentException |
|
27 | - * @throws UnexpectedValueException |
|
28 | - */ |
|
29 | - public function theme($params = null) { |
|
30 | - if (is_array($params)) { |
|
31 | - $this->_config = $params; |
|
32 | - $this->_setTheme($this->_getApplied()); |
|
33 | - } elseif (is_string($params)) { |
|
34 | - $this->_setTheme($params); |
|
35 | - } |
|
36 | - if (empty($this->_applied)) { |
|
37 | - if ($params === null) { |
|
38 | - throw new UnexpectedValueException( |
|
39 | - sprintf( |
|
40 | - 'Theme could not be determined: %s', |
|
41 | - print_r($params, true) |
|
42 | - ) |
|
43 | - ); |
|
44 | - } else { |
|
45 | - throw new InvalidArgumentException('Theme is not set yet.'); |
|
46 | - } |
|
47 | - } |
|
48 | - return $this->_applied; |
|
49 | - } |
|
50 | - |
|
51 | - /** |
|
52 | - * Gets currently applied theme |
|
53 | - */ |
|
54 | - protected function _getApplied() { |
|
55 | - if ($this->_applied) { |
|
56 | - return $this->_applied; |
|
57 | - } |
|
58 | - if ($this->_Controller->CurrentUser->isLoggedIn()) { |
|
59 | - $_userTheme = $this->_Controller->CurrentUser['user_theme']; |
|
60 | - if (in_array($_userTheme, $this->getAvailable())) { |
|
61 | - $this->_applied = $_userTheme; |
|
62 | - } |
|
63 | - } |
|
64 | - if (!$this->_applied) { |
|
65 | - $this->_applied = $this->_config['default']; |
|
66 | - } |
|
67 | - return $this->_applied; |
|
68 | - } |
|
69 | - |
|
70 | - public function setDefault() { |
|
71 | - $this->_setTheme($this->_config['default']); |
|
72 | - } |
|
73 | - |
|
74 | - protected function _setTheme($theme) { |
|
75 | - $this->_applied = $theme; |
|
76 | - $this->_Controller->theme = $this->_applied; |
|
77 | - } |
|
78 | - |
|
79 | - /** |
|
80 | - * Gets available themes |
|
81 | - * |
|
82 | - * @return array |
|
83 | - */ |
|
84 | - public function getAvailable() { |
|
85 | - if (!$this->_available) { |
|
86 | - $this->_setAvailable(); |
|
87 | - } |
|
88 | - return $this->_available; |
|
89 | - } |
|
90 | - |
|
91 | - /** |
|
92 | - * Sets available themes |
|
93 | - */ |
|
94 | - protected function _setAvailable() { |
|
95 | - $_themesSubset = []; |
|
96 | - |
|
97 | - $this->_available = $this->themeDirs(); |
|
98 | - |
|
99 | - // allowed themes for all users |
|
100 | - if (isset($this->_config['available']['all'])) { |
|
101 | - if ($this->_config['available']['all'] !== '*') { |
|
102 | - $_themesSubset = $this->_config['available']['all']; |
|
103 | - } |
|
104 | - } else { |
|
105 | - $_themesSubset = [$this->_config['default']]; |
|
106 | - } |
|
107 | - |
|
108 | - // allowed user themes |
|
109 | - $_currentUserId = $this->_Controller->CurrentUser->getId(); |
|
110 | - if (isset($this->_config['available']['users'][$_currentUserId])) { |
|
111 | - $_themesSubset = array_merge($_themesSubset, |
|
112 | - $this->_config['available']['users'][$_currentUserId]); |
|
113 | - } |
|
114 | - |
|
115 | - // filter themes |
|
116 | - if ($_themesSubset) { |
|
117 | - $this->_available = array_intersect($this->_available, $_themesSubset); |
|
118 | - } |
|
119 | - |
|
120 | - // default theme is always available |
|
121 | - array_unshift($this->_available, $this->_config['default']); |
|
122 | - |
|
123 | - // make sure default/every theme is in list only one time |
|
124 | - $this->_available = array_unique($this->_available); |
|
125 | - } |
|
126 | - |
|
127 | - /** |
|
128 | - * Reads all available themes from disk |
|
129 | - * |
|
130 | - * @return array with Theme names |
|
131 | - */ |
|
132 | - public function themeDirs() { |
|
133 | - $_ThemeDir = new Folder(App::paths()['View'][0] . 'Themed'); |
|
134 | - return $_ThemeDir->read()[0]; |
|
135 | - } |
|
136 | - |
|
137 | - } |
|
3 | + App::uses('App', 'Core'); |
|
4 | + App::uses('Folder', 'Utility'); |
|
5 | + App::uses('Component', 'Controller'); |
|
6 | + |
|
7 | + class ThemesComponent extends Component { |
|
8 | + |
|
9 | + protected $_config = null; |
|
10 | + |
|
11 | + protected $_applied = null; |
|
12 | + |
|
13 | + protected $_available = []; |
|
14 | + |
|
15 | + protected $_Controller = null; |
|
16 | + |
|
17 | + public function initialize(Controller $controller) { |
|
18 | + $this->_Controller = $controller; |
|
19 | + } |
|
20 | + |
|
21 | + /** |
|
22 | + * Sets and/or gets current theme |
|
23 | + * |
|
24 | + * @param mixed $params name string or config array |
|
25 | + * @return string current theme |
|
26 | + * @throws InvalidArgumentException |
|
27 | + * @throws UnexpectedValueException |
|
28 | + */ |
|
29 | + public function theme($params = null) { |
|
30 | + if (is_array($params)) { |
|
31 | + $this->_config = $params; |
|
32 | + $this->_setTheme($this->_getApplied()); |
|
33 | + } elseif (is_string($params)) { |
|
34 | + $this->_setTheme($params); |
|
35 | + } |
|
36 | + if (empty($this->_applied)) { |
|
37 | + if ($params === null) { |
|
38 | + throw new UnexpectedValueException( |
|
39 | + sprintf( |
|
40 | + 'Theme could not be determined: %s', |
|
41 | + print_r($params, true) |
|
42 | + ) |
|
43 | + ); |
|
44 | + } else { |
|
45 | + throw new InvalidArgumentException('Theme is not set yet.'); |
|
46 | + } |
|
47 | + } |
|
48 | + return $this->_applied; |
|
49 | + } |
|
50 | + |
|
51 | + /** |
|
52 | + * Gets currently applied theme |
|
53 | + */ |
|
54 | + protected function _getApplied() { |
|
55 | + if ($this->_applied) { |
|
56 | + return $this->_applied; |
|
57 | + } |
|
58 | + if ($this->_Controller->CurrentUser->isLoggedIn()) { |
|
59 | + $_userTheme = $this->_Controller->CurrentUser['user_theme']; |
|
60 | + if (in_array($_userTheme, $this->getAvailable())) { |
|
61 | + $this->_applied = $_userTheme; |
|
62 | + } |
|
63 | + } |
|
64 | + if (!$this->_applied) { |
|
65 | + $this->_applied = $this->_config['default']; |
|
66 | + } |
|
67 | + return $this->_applied; |
|
68 | + } |
|
69 | + |
|
70 | + public function setDefault() { |
|
71 | + $this->_setTheme($this->_config['default']); |
|
72 | + } |
|
73 | + |
|
74 | + protected function _setTheme($theme) { |
|
75 | + $this->_applied = $theme; |
|
76 | + $this->_Controller->theme = $this->_applied; |
|
77 | + } |
|
78 | + |
|
79 | + /** |
|
80 | + * Gets available themes |
|
81 | + * |
|
82 | + * @return array |
|
83 | + */ |
|
84 | + public function getAvailable() { |
|
85 | + if (!$this->_available) { |
|
86 | + $this->_setAvailable(); |
|
87 | + } |
|
88 | + return $this->_available; |
|
89 | + } |
|
90 | + |
|
91 | + /** |
|
92 | + * Sets available themes |
|
93 | + */ |
|
94 | + protected function _setAvailable() { |
|
95 | + $_themesSubset = []; |
|
96 | + |
|
97 | + $this->_available = $this->themeDirs(); |
|
98 | + |
|
99 | + // allowed themes for all users |
|
100 | + if (isset($this->_config['available']['all'])) { |
|
101 | + if ($this->_config['available']['all'] !== '*') { |
|
102 | + $_themesSubset = $this->_config['available']['all']; |
|
103 | + } |
|
104 | + } else { |
|
105 | + $_themesSubset = [$this->_config['default']]; |
|
106 | + } |
|
107 | + |
|
108 | + // allowed user themes |
|
109 | + $_currentUserId = $this->_Controller->CurrentUser->getId(); |
|
110 | + if (isset($this->_config['available']['users'][$_currentUserId])) { |
|
111 | + $_themesSubset = array_merge($_themesSubset, |
|
112 | + $this->_config['available']['users'][$_currentUserId]); |
|
113 | + } |
|
114 | + |
|
115 | + // filter themes |
|
116 | + if ($_themesSubset) { |
|
117 | + $this->_available = array_intersect($this->_available, $_themesSubset); |
|
118 | + } |
|
119 | + |
|
120 | + // default theme is always available |
|
121 | + array_unshift($this->_available, $this->_config['default']); |
|
122 | + |
|
123 | + // make sure default/every theme is in list only one time |
|
124 | + $this->_available = array_unique($this->_available); |
|
125 | + } |
|
126 | + |
|
127 | + /** |
|
128 | + * Reads all available themes from disk |
|
129 | + * |
|
130 | + * @return array with Theme names |
|
131 | + */ |
|
132 | + public function themeDirs() { |
|
133 | + $_ThemeDir = new Folder(App::paths()['View'][0] . 'Themed'); |
|
134 | + return $_ThemeDir->read()[0]; |
|
135 | + } |
|
136 | + |
|
137 | + } |
@@ -12,7 +12,7 @@ |
||
12 | 12 | |
13 | 13 | public function startup(Controller $controller) { |
14 | 14 | $this->_Controller = $controller; |
15 | - $this->settings['maxNumberOfShouts'] = (int)Configure::read( |
|
15 | + $this->settings['maxNumberOfShouts'] = (int) Configure::read( |
|
16 | 16 | 'Saito.Settings.shoutbox_max_shouts'); |
17 | 17 | } |
18 | 18 |
@@ -1,42 +1,42 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | - App::uses('Component', 'Controller'); |
|
3 | + App::uses('Component', 'Controller'); |
|
4 | 4 | |
5 | - class ShoutsComponent extends Component { |
|
5 | + class ShoutsComponent extends Component { |
|
6 | 6 | |
7 | - public $settings = ['maxNumberOfShouts' => 10]; |
|
7 | + public $settings = ['maxNumberOfShouts' => 10]; |
|
8 | 8 | |
9 | - protected $_Controller; |
|
9 | + protected $_Controller; |
|
10 | 10 | |
11 | - protected $_ShoutModel = null; |
|
11 | + protected $_ShoutModel = null; |
|
12 | 12 | |
13 | - public function startup(Controller $controller) { |
|
14 | - $this->_Controller = $controller; |
|
15 | - $this->settings['maxNumberOfShouts'] = (int)Configure::read( |
|
16 | - 'Saito.Settings.shoutbox_max_shouts'); |
|
17 | - } |
|
13 | + public function startup(Controller $controller) { |
|
14 | + $this->_Controller = $controller; |
|
15 | + $this->settings['maxNumberOfShouts'] = (int)Configure::read( |
|
16 | + 'Saito.Settings.shoutbox_max_shouts'); |
|
17 | + } |
|
18 | 18 | |
19 | - public function setShoutsForView() { |
|
20 | - // @performance only do if cache is not valid and html need to be rendered |
|
21 | - $this->_Controller->set('shouts', $this->get()); |
|
22 | - } |
|
19 | + public function setShoutsForView() { |
|
20 | + // @performance only do if cache is not valid and html need to be rendered |
|
21 | + $this->_Controller->set('shouts', $this->get()); |
|
22 | + } |
|
23 | 23 | |
24 | - public function get() { |
|
25 | - return $this->_model()->get(); |
|
26 | - } |
|
24 | + public function get() { |
|
25 | + return $this->_model()->get(); |
|
26 | + } |
|
27 | 27 | |
28 | - public function push($data) { |
|
29 | - return $this->_model()->push($data); |
|
30 | - } |
|
28 | + public function push($data) { |
|
29 | + return $this->_model()->push($data); |
|
30 | + } |
|
31 | 31 | |
32 | - protected function _model() { |
|
33 | - if ($this->_ShoutModel !== null) { |
|
34 | - return $this->_ShoutModel; |
|
35 | - } |
|
36 | - $this->_Controller->loadModel('Shout'); |
|
37 | - $this->_ShoutModel = $this->_Controller->Shout; |
|
38 | - $this->_ShoutModel->maxNumberOfShouts = $this->settings['maxNumberOfShouts']; |
|
39 | - return $this->_ShoutModel; |
|
40 | - } |
|
32 | + protected function _model() { |
|
33 | + if ($this->_ShoutModel !== null) { |
|
34 | + return $this->_ShoutModel; |
|
35 | + } |
|
36 | + $this->_Controller->loadModel('Shout'); |
|
37 | + $this->_ShoutModel = $this->_Controller->Shout; |
|
38 | + $this->_ShoutModel->maxNumberOfShouts = $this->settings['maxNumberOfShouts']; |
|
39 | + return $this->_ShoutModel; |
|
40 | + } |
|
41 | 41 | |
42 | - } |
|
42 | + } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | $event->data['subject'], |
22 | 22 | 'EmailNotification'); |
23 | 23 | if ($recipients): |
24 | - $method = '_' . $this->_handledEvents[$event->name()]; |
|
24 | + $method = '_'.$this->_handledEvents[$event->name()]; |
|
25 | 25 | if (method_exists($this, $method)) { |
26 | 26 | $this->$method($event, $recipients); |
27 | 27 | } |
@@ -43,10 +43,10 @@ discard block |
||
43 | 43 | 'conditions' => ['Entry.id' => $event->data['data']['Entry'][$idKey]] |
44 | 44 | ]); |
45 | 45 | |
46 | - $lang = Configure::read( 'Config.language'); |
|
46 | + $lang = Configure::read('Config.language'); |
|
47 | 47 | $config = [ |
48 | 48 | 'subject' => __('New reply to "%s"', $subject['Entry']['subject']), |
49 | - 'template' => $lang . DS . 'notification-model-entry-afterReply', |
|
49 | + 'template' => $lang.DS.'notification-model-entry-afterReply', |
|
50 | 50 | 'viewVars' => [ |
51 | 51 | 'parentEntry' => $subject, |
52 | 52 | 'newEntry' => $event->data['data'], |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | 'subject' => __('Successfull registration'), |
77 | 77 | 'template' => Configure::read( |
78 | 78 | 'Config.language' |
79 | - ) . DS . 'notification-admin-user_activated', |
|
79 | + ).DS.'notification-admin-user_activated', |
|
80 | 80 | 'viewVars' => array('user' => $newUser, 'ip' => env('REMOTE_ADDR')), |
81 | 81 | |
82 | 82 | ]; |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | protected function _shouldRecipientReceiveReplyMessage($recipient, $entry) { |
90 | 90 | if (Configure::read('debug') === 0 && |
91 | 91 | // don't send answer if new entry belongs to the user itself |
92 | - (int)$recipient['id'] === (int)$entry['user_id'] |
|
92 | + (int) $recipient['id'] === (int) $entry['user_id'] |
|
93 | 93 | ) { |
94 | 94 | return false; |
95 | 95 | } else { |
@@ -1,113 +1,113 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | - App::uses('NotificationComponent', 'Lib/Controller/Component'); |
|
3 | + App::uses('NotificationComponent', 'Lib/Controller/Component'); |
|
4 | 4 | |
5 | - class EmailNotificationComponent extends NotificationComponent { |
|
5 | + class EmailNotificationComponent extends NotificationComponent { |
|
6 | 6 | |
7 | - protected $_handledEvents = array( |
|
8 | - 'Model.Entry.replyToEntry' => 'modelEntryReplyToEntry', |
|
9 | - 'Model.Entry.replyToThread' => 'modelEntryReplyToThread', |
|
10 | - ); |
|
7 | + protected $_handledEvents = array( |
|
8 | + 'Model.Entry.replyToEntry' => 'modelEntryReplyToEntry', |
|
9 | + 'Model.Entry.replyToThread' => 'modelEntryReplyToThread', |
|
10 | + ); |
|
11 | 11 | |
12 | - public function implementedEvents() { |
|
13 | - $handledEvents = parent::implementedEvents(); |
|
14 | - $handledEvents['Model.User.afterActivate'] = 'userActivatedAdminNotice'; |
|
15 | - return $handledEvents; |
|
16 | - } |
|
12 | + public function implementedEvents() { |
|
13 | + $handledEvents = parent::implementedEvents(); |
|
14 | + $handledEvents['Model.User.afterActivate'] = 'userActivatedAdminNotice'; |
|
15 | + return $handledEvents; |
|
16 | + } |
|
17 | 17 | |
18 | - protected function _process($event) { |
|
19 | - $recipients = $this->_Esevent->getUsersForEventOnSubjectWithReceiver( |
|
20 | - $event->name(), |
|
21 | - $event->data['subject'], |
|
22 | - 'EmailNotification'); |
|
23 | - if ($recipients): |
|
24 | - $method = '_' . $this->_handledEvents[$event->name()]; |
|
25 | - if (method_exists($this, $method)) { |
|
26 | - $this->$method($event, $recipients); |
|
27 | - } |
|
28 | - endif; |
|
29 | - } |
|
18 | + protected function _process($event) { |
|
19 | + $recipients = $this->_Esevent->getUsersForEventOnSubjectWithReceiver( |
|
20 | + $event->name(), |
|
21 | + $event->data['subject'], |
|
22 | + 'EmailNotification'); |
|
23 | + if ($recipients): |
|
24 | + $method = '_' . $this->_handledEvents[$event->name()]; |
|
25 | + if (method_exists($this, $method)) { |
|
26 | + $this->$method($event, $recipients); |
|
27 | + } |
|
28 | + endif; |
|
29 | + } |
|
30 | 30 | |
31 | - protected function _modelEntryReplyToThread($event, array $recipients) { |
|
32 | - $this->_entryReply($recipients, $event, 'tid'); |
|
33 | - } |
|
31 | + protected function _modelEntryReplyToThread($event, array $recipients) { |
|
32 | + $this->_entryReply($recipients, $event, 'tid'); |
|
33 | + } |
|
34 | 34 | |
35 | - protected function _modelEntryReplyToEntry($event, array $recipients) { |
|
36 | - $this->_entryReply($recipients, $event, 'pid'); |
|
37 | - } |
|
35 | + protected function _modelEntryReplyToEntry($event, array $recipients) { |
|
36 | + $this->_entryReply($recipients, $event, 'pid'); |
|
37 | + } |
|
38 | 38 | |
39 | - protected function _entryReply($recipients, $event, $idKey) { |
|
40 | - $subject = $event->subject()->find('first', |
|
41 | - [ |
|
42 | - 'contain' => ['User'], |
|
43 | - 'conditions' => ['Entry.id' => $event->data['data']['Entry'][$idKey]] |
|
44 | - ]); |
|
39 | + protected function _entryReply($recipients, $event, $idKey) { |
|
40 | + $subject = $event->subject()->find('first', |
|
41 | + [ |
|
42 | + 'contain' => ['User'], |
|
43 | + 'conditions' => ['Entry.id' => $event->data['data']['Entry'][$idKey]] |
|
44 | + ]); |
|
45 | 45 | |
46 | - $lang = Configure::read( 'Config.language'); |
|
47 | - $config = [ |
|
48 | - 'subject' => __('New reply to "%s"', $subject['Entry']['subject']), |
|
49 | - 'template' => $lang . DS . 'notification-model-entry-afterReply', |
|
50 | - 'viewVars' => [ |
|
51 | - 'parentEntry' => $subject, |
|
52 | - 'newEntry' => $event->data['data'], |
|
53 | - ] |
|
54 | - ]; |
|
55 | - foreach ($recipients as $recipient) { |
|
56 | - if (!$this->_shouldRecipientReceiveReplyMessage($recipient, |
|
57 | - $event->data['data']['Entry']) |
|
58 | - ) { |
|
59 | - continue; |
|
60 | - } |
|
61 | - $config['recipient'] = ['User' => $recipient]; |
|
62 | - $config['viewVars']['recipient'] = $recipient; |
|
63 | - $config['viewVars']['notification'] = $recipient['Esnotification']; |
|
64 | - $this->_email($config); |
|
65 | - } |
|
66 | - return $config; |
|
67 | - } |
|
46 | + $lang = Configure::read( 'Config.language'); |
|
47 | + $config = [ |
|
48 | + 'subject' => __('New reply to "%s"', $subject['Entry']['subject']), |
|
49 | + 'template' => $lang . DS . 'notification-model-entry-afterReply', |
|
50 | + 'viewVars' => [ |
|
51 | + 'parentEntry' => $subject, |
|
52 | + 'newEntry' => $event->data['data'], |
|
53 | + ] |
|
54 | + ]; |
|
55 | + foreach ($recipients as $recipient) { |
|
56 | + if (!$this->_shouldRecipientReceiveReplyMessage($recipient, |
|
57 | + $event->data['data']['Entry']) |
|
58 | + ) { |
|
59 | + continue; |
|
60 | + } |
|
61 | + $config['recipient'] = ['User' => $recipient]; |
|
62 | + $config['viewVars']['recipient'] = $recipient; |
|
63 | + $config['viewVars']['notification'] = $recipient['Esnotification']; |
|
64 | + $this->_email($config); |
|
65 | + } |
|
66 | + return $config; |
|
67 | + } |
|
68 | 68 | |
69 | - public function userActivatedAdminNotice($event) { |
|
70 | - $recipients = Configure::read('Saito.Notification.userActivatedAdminNoticeToUserWithID'); |
|
71 | - if (!is_array($recipients)) { |
|
72 | - return; |
|
73 | - } |
|
74 | - $newUser = $event->data['User']; |
|
75 | - $config = [ |
|
76 | - 'subject' => __('Successfull registration'), |
|
77 | - 'template' => Configure::read( |
|
78 | - 'Config.language' |
|
79 | - ) . DS . 'notification-admin-user_activated', |
|
80 | - 'viewVars' => array('user' => $newUser, 'ip' => env('REMOTE_ADDR')), |
|
69 | + public function userActivatedAdminNotice($event) { |
|
70 | + $recipients = Configure::read('Saito.Notification.userActivatedAdminNoticeToUserWithID'); |
|
71 | + if (!is_array($recipients)) { |
|
72 | + return; |
|
73 | + } |
|
74 | + $newUser = $event->data['User']; |
|
75 | + $config = [ |
|
76 | + 'subject' => __('Successfull registration'), |
|
77 | + 'template' => Configure::read( |
|
78 | + 'Config.language' |
|
79 | + ) . DS . 'notification-admin-user_activated', |
|
80 | + 'viewVars' => array('user' => $newUser, 'ip' => env('REMOTE_ADDR')), |
|
81 | 81 | |
82 | - ]; |
|
83 | - foreach ($recipients as $recipient) : |
|
84 | - $config['recipient'] = $recipient; |
|
85 | - $this->_email($config); |
|
86 | - endforeach; |
|
87 | - } |
|
82 | + ]; |
|
83 | + foreach ($recipients as $recipient) : |
|
84 | + $config['recipient'] = $recipient; |
|
85 | + $this->_email($config); |
|
86 | + endforeach; |
|
87 | + } |
|
88 | 88 | |
89 | - protected function _shouldRecipientReceiveReplyMessage($recipient, $entry) { |
|
90 | - if (Configure::read('debug') === 0 && |
|
91 | - // don't send answer if new entry belongs to the user itself |
|
92 | - (int)$recipient['id'] === (int)$entry['user_id'] |
|
93 | - ) { |
|
94 | - return false; |
|
95 | - } else { |
|
96 | - return true; |
|
97 | - } |
|
98 | - } |
|
89 | + protected function _shouldRecipientReceiveReplyMessage($recipient, $entry) { |
|
90 | + if (Configure::read('debug') === 0 && |
|
91 | + // don't send answer if new entry belongs to the user itself |
|
92 | + (int)$recipient['id'] === (int)$entry['user_id'] |
|
93 | + ) { |
|
94 | + return false; |
|
95 | + } else { |
|
96 | + return true; |
|
97 | + } |
|
98 | + } |
|
99 | 99 | |
100 | - protected function _email($config) { |
|
101 | - $config['sender'] = 'system'; |
|
102 | - try { |
|
103 | - $this->_Controller->SaitoEmail->email($config); |
|
104 | - } catch (Exception $e) { |
|
105 | - $Logger = new Saito\Logger\ExceptionLogger(); |
|
106 | - $Logger->write('Error in EmailNotificationComponent::_email()', [ |
|
107 | - 'e' => $e, |
|
108 | - 'msgs' => ['config' => $config] |
|
109 | - ]); |
|
110 | - } |
|
111 | - } |
|
100 | + protected function _email($config) { |
|
101 | + $config['sender'] = 'system'; |
|
102 | + try { |
|
103 | + $this->_Controller->SaitoEmail->email($config); |
|
104 | + } catch (Exception $e) { |
|
105 | + $Logger = new Saito\Logger\ExceptionLogger(); |
|
106 | + $Logger->write('Error in EmailNotificationComponent::_email()', [ |
|
107 | + 'e' => $e, |
|
108 | + 'msgs' => ['config' => $config] |
|
109 | + ]); |
|
110 | + } |
|
111 | + } |
|
112 | 112 | |
113 | - } |
|
114 | 113 | \ No newline at end of file |
114 | + } |
|
115 | 115 | \ No newline at end of file |