Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 624 lines (500 sloc) 23.128 kB
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
1 <?php
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
2
3 /**
4 * @package content
5 */
6
7 /**
8 * Controller page for all Symphony Author related activity
9 * including making new Authors, editing Authors or deleting
10 * Authors from Symphony
11 */
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
12 require_once(TOOLKIT . '/class.administrationpage.php');
3715cc3 @brendo Fix Language Count Typo
brendo authored
13 require_once(TOOLKIT . '/class.sectionmanager.php');
b0c62ea @eKoeS Allows sorting by ID in the entries list
eKoeS authored
14 require_once(CONTENT . '/class.sortable.php');
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
15
16 Class contentSystemAuthors extends AdministrationPage{
17
4e30a45 @brendo Update of Authors Page. New delegates, correct use of SYMPHONY constant
brendo authored
18 public $_Author;
19 public $_errors = array();
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
20
b0c62ea @eKoeS Allows sorting by ID in the entries list
eKoeS authored
21 public function sort(&$sort, &$order, $params){
22 if(is_null($sort) || $sort == 'name'){
23 $sort = 'name';
24 return AuthorManager::fetch("first_name $order, last_name", $order);
25 }
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
26
b0c62ea @eKoeS Allows sorting by ID in the entries list
eKoeS authored
27 return AuthorManager::fetch($sort, $order);
28 }
29
30 public function __viewIndex(){
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
31 $this->setPageType('table');
f0645df @nils-werner Invert order of textelements in title
nils-werner authored
32 $this->setTitle(__('%1$s &ndash; %2$s', array(__('Authors'), __('Symphony'))));
868c18e @brendo Documented Author class, made changes all Author related code to alig…
brendo authored
33
4e30a45 @brendo Update of Authors Page. New delegates, correct use of SYMPHONY constant
brendo authored
34 if (Administration::instance()->Author->isDeveloper()) {
7ab86a6 @brendo The Merry Christmas Merge
brendo authored
35 $this->appendSubheading(__('Authors'), Widget::Anchor(__('Add an Author'), Administration::instance()->getCurrentPageURL().'new/', __('Add a new author'), 'create button', NULL, array('accesskey' => 'c')));
4e30a45 @brendo Update of Authors Page. New delegates, correct use of SYMPHONY constant
brendo authored
36 } else $this->appendSubheading(__('Authors'));
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
37
b0c62ea @eKoeS Allows sorting by ID in the entries list
eKoeS authored
38 Sortable::init($this, $authors, $sort, $order);
39
40 $columns = array(
41 array(
42 'label' => __('Name'),
43 'sortable' => true,
44 'handle' => 'name'
45 ),
46 array(
47 'label' => __('Email Address'),
48 'sortable' => true,
49 'handle' => 'email'
50 ),
51 array(
52 'label' => __('Last Seen'),
53 'sortable' => true,
54 'handle' => 'last_seen'
55 )
56 );
57
58 $aTableHead = Sortable::buildTableHeaders(
59 $columns, $sort, $order, (isset($_REQUEST['filter']) ? '&amp;filter=' . $_REQUEST['filter'] : '')
94c16e9 @nilshoerrmann add missing calls to the translation function and trim lines.
nilshoerrmann authored
60 );
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
61
62 $aTableBody = array();
b0c62ea @eKoeS Allows sorting by ID in the entries list
eKoeS authored
63
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
64 if(!is_array($authors) || empty($authors)){
65 $aTableBody = array(
3715cc3 @brendo Fix Language Count Typo
brendo authored
66 Widget::TableRow(array(Widget::TableData(__('None found.'), 'inactive', NULL, count($aTableHead))), 'odd')
67 );
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
68 }
69 else{
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
70 foreach($authors as $a){
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
71 ## Setup each cell
929b1f2 Tweaked the behaviour of author profiles when edited. It is possible …
Alistair Kearney authored
72 if(Administration::instance()->Author->isDeveloper() || Administration::instance()->Author->get('id') == $a->get('id')) {
868c18e @brendo Documented Author class, made changes all Author related code to alig…
brendo authored
73 $td1 = Widget::TableData(
4e30a45 @brendo Update of Authors Page. New delegates, correct use of SYMPHONY constant
brendo authored
74 Widget::Anchor($a->getFullName(), Administration::instance()->getCurrentPageURL() . 'edit/' . $a->get('id') . '/', $a->get('username'), 'author')
868c18e @brendo Documented Author class, made changes all Author related code to alig…
brendo authored
75 );
e681237 @knupska Just a few small Author/Developer (basic access control) usability im…
knupska authored
76 } else {
77 $td1 = Widget::TableData($a->getFullName(), 'inactive');
78 }
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
79
6424133 @eKoeS Found an emancipated string
eKoeS authored
80 $td2 = Widget::TableData(Widget::Anchor($a->get('email'), 'mailto:'.$a->get('email'), __('Email this author')));
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
81
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
82 if(!is_null($a->get('last_seen'))) {
4e30a45 @brendo Update of Authors Page. New delegates, correct use of SYMPHONY constant
brendo authored
83 $td3 = Widget::TableData(
4bb68eb @nilshoerrmann Make DateTimeObj::get() default to English dates and DateTimeObj::for…
nilshoerrmann authored
84 DateTimeObj::format($a->get('last_seen'), __SYM_DATETIME_FORMAT__)
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
85 );
86 } else {
b0c62ea @eKoeS Allows sorting by ID in the entries list
eKoeS authored
87 $td3 = Widget::TableData(__('Unknown'), 'inactive');
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
88 }
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
89
929b1f2 Tweaked the behaviour of author profiles when edited. It is possible …
Alistair Kearney authored
90 if (Administration::instance()->Author->isDeveloper()) {
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
91 if ($a->get('id') != Administration::instance()->Author->get('id')) {
92 $td3->appendChild(Widget::Input('items['.$a->get('id').']', NULL, 'checkbox'));
93 }
e681237 @knupska Just a few small Author/Developer (basic access control) usability im…
knupska authored
94 }
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
95
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
96 ## Add a row to the body array, assigning each cell to the row
c65f8dc @eKoeS Replaces .odd with the equivalent CSS3 property
eKoeS authored
97 $aTableBody[] = Widget::TableRow(array($td1, $td2, $td3));
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
98 }
99 }
100
101 $table = Widget::Table(
3715cc3 @brendo Fix Language Count Typo
brendo authored
102 Widget::TableHead($aTableHead),
103 NULL,
8515a74 @nilshoerrmann Make sure the Selectable is only applied to elements that explicitly …
nilshoerrmann authored
104 Widget::TableBody($aTableBody),
105 'selectable'
3715cc3 @brendo Fix Language Count Typo
brendo authored
106 );
107
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
108 $this->Form->appendChild($table);
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
109
929b1f2 Tweaked the behaviour of author profiles when edited. It is possible …
Alistair Kearney authored
110 if(Administration::instance()->Author->isDeveloper()) {
e681237 @knupska Just a few small Author/Developer (basic access control) usability im…
knupska authored
111 $tableActions = new XMLElement('div');
112 $tableActions->setAttribute('class', 'actions');
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
113
e681237 @knupska Just a few small Author/Developer (basic access control) usability im…
knupska authored
114 $options = array(
94c16e9 @nilshoerrmann add missing calls to the translation function and trim lines.
nilshoerrmann authored
115 array(NULL, false, __('With Selected...')),
7f4d72e @nilshoerrmann Move confirm messages to data attributes to improve the localisation …
nilshoerrmann authored
116 array('delete', false, __('Delete'), 'confirm', null, array(
117 'data-message' => __('Are you sure you want to delete the selected authors?')
118 ))
e681237 @knupska Just a few small Author/Developer (basic access control) usability im…
knupska authored
119 );
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
120
e681237 @knupska Just a few small Author/Developer (basic access control) usability im…
knupska authored
121 $tableActions->appendChild(Widget::Select('with-selected', $options));
94c16e9 @nilshoerrmann add missing calls to the translation function and trim lines.
nilshoerrmann authored
122 $tableActions->appendChild(Widget::Input('action[apply]', __('Apply'), 'submit'));
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
123
94c16e9 @nilshoerrmann add missing calls to the translation function and trim lines.
nilshoerrmann authored
124 $this->Form->appendChild($tableActions);
e681237 @knupska Just a few small Author/Developer (basic access control) usability im…
knupska authored
125 }
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
126
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
127 }
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
128
4e30a45 @brendo Update of Authors Page. New delegates, correct use of SYMPHONY constant
brendo authored
129 public function __actionIndex(){
bb16d06 @rainerborene array_keys must receive an array as argument
rainerborene authored
130 if($_POST['with-selected'] == 'delete' && is_array($_POST['items'])){
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
131
cb2fe36 Don't select things that have no input. Check for an array, in the ca…
Brendan Abbott authored
132 $checked = (is_array($_POST['items'])) ? array_keys($_POST['items']) : null;
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
133
134 if(!empty($checked)) {
135
136 /**
137 * Prior to deleting an author, provided with an array of Author ID's.
138 *
139 * @delegate AuthorPreDelete
140 * @since Symphony 2.2
141 * @param string $context
142 * '/system/authors/'
143 * @param array $author_ids
144 * An array of Author ID that are about to be removed
145 */
8d0cab1 @brendo Add new Page delete, AppendPageContent, implement Symphony::Extension…
brendo authored
146 Symphony::ExtensionManager()->notifyMembers('AuthorPreDelete', '/system/authors/', array('author_ids' => $checked));
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
147
148 foreach($checked as $author_id) {
149 $a = AuthorManager::fetchByID($author_id);
150 if(is_object($a) && $a->get('id') != Administration::instance()->Author->get('id')) {
151 AuthorManager::delete($author_id);
152 }
153 }
154 }
155
156 redirect(SYMPHONY_URL . '/system/authors/');
94c16e9 @nilshoerrmann add missing calls to the translation function and trim lines.
nilshoerrmann authored
157 }
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
158 }
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
159
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
160 ## Both the Edit and New pages need the same form
4e30a45 @brendo Update of Authors Page. New delegates, correct use of SYMPHONY constant
brendo authored
161 public function __viewNew(){
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
162 $this->__form();
163 }
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
164
4e30a45 @brendo Update of Authors Page. New delegates, correct use of SYMPHONY constant
brendo authored
165 public function __viewEdit(){
94c16e9 @nilshoerrmann add missing calls to the translation function and trim lines.
nilshoerrmann authored
166 $this->__form();
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
167 }
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
168
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
169 public function __form(){
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
170
94c16e9 @nilshoerrmann add missing calls to the translation function and trim lines.
nilshoerrmann authored
171 require_once(TOOLKIT . '/class.field.php');
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
172
7f8e347 @brendo Documentation of the Symphony class, added a few missing translation …
brendo authored
173 ## Handle unknown context
4e30a45 @brendo Update of Authors Page. New delegates, correct use of SYMPHONY constant
brendo authored
174 if(!in_array($this->_context[0], array('new', 'edit'))) Administration::instance()->errorPageNotFound();
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
175
7f8e347 @brendo Documentation of the Symphony class, added a few missing translation …
brendo authored
176 if($this->_context[0] == 'new' && !Administration::instance()->Author->isDeveloper()) {
177 Administration::instance()->customError(__('Access Denied'), __('You are not authorised to access this page.'));
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
178 }
179
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
180 if(isset($this->_context[2])){
181 switch($this->_context[2]){
182 case 'saved':
2969855 @pointybeard Updated all success page alert messages
pointybeard authored
183 $this->pageAlert(
8acf6f9 @eKoeS First attemp to make the translator's life easier
eKoeS authored
184 __('Author updated at %s.', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__)))
185 . ' <a href="' . SYMPHONY_URL . '/system/authors/new/" accesskey="c">'
186 . __('Create another?')
187 . '</a> <a href="' . SYMPHONY_URL . '/system/authors/" accesskey="a">'
188 . __('View all Authors')
189 . '</a>'
190 , Alert::SUCCESS);
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
191 break;
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
192
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
193 case 'created':
2969855 @pointybeard Updated all success page alert messages
pointybeard authored
194 $this->pageAlert(
8acf6f9 @eKoeS First attemp to make the translator's life easier
eKoeS authored
195 __('Author created at %s.', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__)))
196 . ' <a href="' . SYMPHONY_URL . '/system/authors/new/" accesskey="c">'
197 . __('Create another?')
198 . '</a> <a href="' . SYMPHONY_URL . '/system/authors/" accesskey="a">'
199 . __('View all Authors')
200 . '</a>'
201 , Alert::SUCCESS);
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
202 break;
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
203 }
204 }
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
205
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
206 $this->setPageType('form');
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
207
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
208 $isOwner = false;
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
209
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
210 if(isset($_POST['fields'])) {
94c16e9 @nilshoerrmann add missing calls to the translation function and trim lines.
nilshoerrmann authored
211 $author = $this->_Author;
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
212 }
213 else if($this->_context[0] == 'edit') {
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
214
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
215 if(!$author_id = $this->_context[1]) redirect(SYMPHONY_URL . '/system/authors/');
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
216
0514b90 Made the AuthorManager class static. No longer a need for Author to m…
Alistair Kearney authored
217 if(!$author = AuthorManager::fetchByID($author_id)){
7f8e347 @brendo Documentation of the Symphony class, added a few missing translation …
brendo authored
218 Administration::instance()->customError(__('Author not found'), __('The author profile you requested does not exist.'));
2969855 @pointybeard Updated all success page alert messages
pointybeard authored
219 }
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
220 }
0514b90 Made the AuthorManager class static. No longer a need for Author to m…
Alistair Kearney authored
221 else $author = new Author;
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
222
929b1f2 Tweaked the behaviour of author profiles when edited. It is possible …
Alistair Kearney authored
223 if($this->_context[0] == 'edit' && $author->get('id') == Administration::instance()->Author->get('id')) $isOwner = true;
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
224
7f8e347 @brendo Documentation of the Symphony class, added a few missing translation …
brendo authored
225 if ($this->_context[0] == 'edit' && !$isOwner && !Administration::instance()->Author->isDeveloper()) {
226 Administration::instance()->customError(__('Access Denied'), __('You are not authorised to edit other authors.'));
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
227 }
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
228
f0645df @nils-werner Invert order of textelements in title
nils-werner authored
229 $this->setTitle(__(($this->_context[0] == 'new' ? '%2$s &ndash; %3$s' : '%1$s &ndash; %2$s &ndash; %3$s'), array($author->getFullName(), __('Authors'), __('Symphony'))));
94c16e9 @nilshoerrmann add missing calls to the translation function and trim lines.
nilshoerrmann authored
230 $this->appendSubheading(($this->_context[0] == 'new' ? __('Untitled') : $author->getFullName()));
79b7684 @eKoeS Breadcrumbs for all the standard content pages + extra buttons on the…
eKoeS authored
231 $this->insertBreadcrumbs(array(
232 Widget::Anchor(__('Authors'), SYMPHONY_URL . '/system/authors/'),
233 ));
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
234
94c16e9 @nilshoerrmann add missing calls to the translation function and trim lines.
nilshoerrmann authored
235 ### Essentials ###
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
236 $group = new XMLElement('fieldset');
237 $group->setAttribute('class', 'settings');
94cc362 @ahwayakchih First step of handling translation in content files. Some strings cou…
ahwayakchih authored
238 $group->appendChild(new XMLElement('legend', __('Essentials')));
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
239
240 $div = new XMLElement('div');
241 $div->setAttribute('class', 'group');
242
94cc362 @ahwayakchih First step of handling translation in content files. Some strings cou…
ahwayakchih authored
243 $label = Widget::Label(__('First Name'));
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
244 $label->appendChild(Widget::Input('fields[first_name]', $author->get('first_name')));
4e30a45 @brendo Update of Authors Page. New delegates, correct use of SYMPHONY constant
brendo authored
245 $div->appendChild((isset($this->_errors['first_name']) ? Widget::wrapFormElementWithError($label, $this->_errors['first_name']) : $label));
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
246
247
94cc362 @ahwayakchih First step of handling translation in content files. Some strings cou…
ahwayakchih authored
248 $label = Widget::Label(__('Last Name'));
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
249 $label->appendChild(Widget::Input('fields[last_name]', $author->get('last_name')));
4e30a45 @brendo Update of Authors Page. New delegates, correct use of SYMPHONY constant
brendo authored
250 $div->appendChild((isset($this->_errors['last_name']) ? Widget::wrapFormElementWithError($label, $this->_errors['last_name']) : $label));
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
251
252 $group->appendChild($div);
253
94c16e9 @nilshoerrmann add missing calls to the translation function and trim lines.
nilshoerrmann authored
254 $label = Widget::Label(__('Email Address'));
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
255 $label->appendChild(Widget::Input('fields[email]', $author->get('email')));
4e30a45 @brendo Update of Authors Page. New delegates, correct use of SYMPHONY constant
brendo authored
256 $group->appendChild((isset($this->_errors['email']) ? Widget::wrapFormElementWithError($label, $this->_errors['email']) : $label));
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
257
94c16e9 @nilshoerrmann add missing calls to the translation function and trim lines.
nilshoerrmann authored
258 $this->Form->appendChild($group);
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
259 ###
260
261 ### Login Details ###
262 $group = new XMLElement('fieldset');
263 $group->setAttribute('class', 'settings');
94cc362 @ahwayakchih First step of handling translation in content files. Some strings cou…
ahwayakchih authored
264 $group->appendChild(new XMLElement('legend', __('Login Details')));
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
265
266 $div = new XMLElement('div');
267 $div->setAttribute('class', 'group');
268
94cc362 @ahwayakchih First step of handling translation in content files. Some strings cou…
ahwayakchih authored
269 $label = Widget::Label(__('Username'));
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
270 $label->appendChild(Widget::Input('fields[username]', $author->get('username'), NULL));
4e30a45 @brendo Update of Authors Page. New delegates, correct use of SYMPHONY constant
brendo authored
271 $div->appendChild((isset($this->_errors['username']) ? Widget::wrapFormElementWithError($label, $this->_errors['username']) : $label));
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
272
9872e8d @sirlancelot Fixed user access permissions. Closes Issue 4
sirlancelot authored
273 // Only developers can change the user type. Primary account should NOT be able to change this
929b1f2 Tweaked the behaviour of author profiles when edited. It is possible …
Alistair Kearney authored
274 if (Administration::instance()->Author->isDeveloper() && !$author->isPrimaryAccount()) {
9872e8d @sirlancelot Fixed user access permissions. Closes Issue 4
sirlancelot authored
275 $label = Widget::Label(__('User Type'));
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
276
9872e8d @sirlancelot Fixed user access permissions. Closes Issue 4
sirlancelot authored
277 $options = array(
94cc362 @ahwayakchih First step of handling translation in content files. Some strings cou…
ahwayakchih authored
278 array('author', false, __('Author')),
279 array('developer', $author->isDeveloper(), __('Developer'))
9872e8d @sirlancelot Fixed user access permissions. Closes Issue 4
sirlancelot authored
280 );
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
281
9872e8d @sirlancelot Fixed user access permissions. Closes Issue 4
sirlancelot authored
282 $label->appendChild(Widget::Select('fields[user_type]', $options));
283 $div->appendChild($label);
284 }
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
285
286 $group->appendChild($div);
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
287
929b1f2 Tweaked the behaviour of author profiles when edited. It is possible …
Alistair Kearney authored
288 $div = new XMLElement('div', NULL, array('class' => 'group'));
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
289
0290e0e @ahwayakchih When user wants to change email or password, require entering old pas…
ahwayakchih authored
290 if($this->_context[0] == 'edit') {
291 $div->setAttribute('id', 'change-password');
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
292
929b1f2 Tweaked the behaviour of author profiles when edited. It is possible …
Alistair Kearney authored
293 if(!Administration::instance()->Author->isDeveloper() || $isOwner === true){
294 $div->setAttribute('class', 'triple group');
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
295
929b1f2 Tweaked the behaviour of author profiles when edited. It is possible …
Alistair Kearney authored
296 $label = Widget::Label(__('Old Password'));
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
297 if(isset($this->_errors['old-password'])) {
298 $label->setAttributeArray(array('class' => 'contains-error', 'title' => $this->_errors['old-password']));
299 }
300
929b1f2 Tweaked the behaviour of author profiles when edited. It is possible …
Alistair Kearney authored
301 $label->appendChild(Widget::Input('fields[old-password]', NULL, 'password'));
4e30a45 @brendo Update of Authors Page. New delegates, correct use of SYMPHONY constant
brendo authored
302 $div->appendChild((isset($this->_errors['old-password']) ? Widget::wrapFormElementWithError($label, $this->_errors['old-password']) : $label));
929b1f2 Tweaked the behaviour of author profiles when edited. It is possible …
Alistair Kearney authored
303 }
0290e0e @ahwayakchih When user wants to change email or password, require entering old pas…
ahwayakchih authored
304 }
305
94c16e9 @nilshoerrmann add missing calls to the translation function and trim lines.
nilshoerrmann authored
306 $label = Widget::Label(($this->_context[0] == 'edit' ? __('New Password') : __('Password')));
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
307 $label->appendChild(Widget::Input('fields[password]', NULL, 'password'));
4e30a45 @brendo Update of Authors Page. New delegates, correct use of SYMPHONY constant
brendo authored
308 $div->appendChild((isset($this->_errors['password']) ? Widget::wrapFormElementWithError($label, $this->_errors['password']) : $label));
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
309
94cc362 @ahwayakchih First step of handling translation in content files. Some strings cou…
ahwayakchih authored
310 $label = Widget::Label(($this->_context[0] == 'edit' ? __('Confirm New Password') : __('Confirm Password')));
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
311 if(isset($this->_errors['password-confirmation'])) {
312 $label->setAttributeArray(array('class' => 'contains-error', 'title' => $this->_errors['password-confirmation']));
313 }
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
314 $label->appendChild(Widget::Input('fields[password-confirmation]', NULL, 'password'));
315 $div->appendChild($label);
316 $group->appendChild($div);
317
929b1f2 Tweaked the behaviour of author profiles when edited. It is possible …
Alistair Kearney authored
318 if($this->_context[0] == 'edit'){
319 $group->appendChild(new XMLElement('p', __('Leave password fields blank to keep the current password'), array('class' => 'help')));
320 }
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
321
929b1f2 Tweaked the behaviour of author profiles when edited. It is possible …
Alistair Kearney authored
322 if(Administration::instance()->Author->isDeveloper()) {
e681237 @knupska Just a few small Author/Developer (basic access control) usability im…
knupska authored
323 $label = Widget::Label();
324 $input = Widget::Input('fields[auth_token_active]', 'yes', 'checkbox');
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
325
326 if($author->isTokenActive()) {
327 $input->setAttribute('checked', 'checked');
328 }
329
330 $temp = SYMPHONY_URL . '/login/' . $author->createAuthToken() . '/';
8acf6f9 @eKoeS First attemp to make the translator's life easier
eKoeS authored
331 $label->setValue(__('%s Allow remote login via', array($input->generate())) . ' <a href="' . $temp . '">' . $temp . '</a>');
e681237 @knupska Just a few small Author/Developer (basic access control) usability im…
knupska authored
332 $group->appendChild($label);
ef78eed @nils-werner Fix for broken author form when not a developer
nils-werner authored
333 }
32d3107 Allow the Sections index to be set as a Default Area for Developer's.…
Brendan Abbott authored
334
ef78eed @nils-werner Fix for broken author form when not a developer
nils-werner authored
335 $label = Widget::Label(__('Default Area'));
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
336
26109d9 @brendo SectionManager is now static.
brendo authored
337 $sections = SectionManager::fetch(NULL, 'ASC', 'sortorder');
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
338
ef78eed @nils-werner Fix for broken author form when not a developer
nils-werner authored
339 $options = array();
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
340
32d3107 Allow the Sections index to be set as a Default Area for Developer's.…
Brendan Abbott authored
341 // If the Author is the Developer, allow them to set the Default Area to
342 // be the Sections Index.
343 if($author->isDeveloper()) {
344 $options[] = array('/blueprints/sections/', $author->get('default_area') == '/blueprints/sections/', __('Sections Index'));
345 }
346
ef78eed @nils-werner Fix for broken author form when not a developer
nils-werner authored
347 if(is_array($sections) && !empty($sections)) {
348 foreach($sections as $s) {
349 $options[] = array($s->get('id'), $author->get('default_area') == $s->get('id'), $s->get('name'));
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
350 }
ef78eed @nils-werner Fix for broken author form when not a developer
nils-werner authored
351 }
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
352
ef78eed @nils-werner Fix for broken author form when not a developer
nils-werner authored
353 /**
354 * Allows injection or manipulation of the Default Area dropdown for an Author.
355 * Take care with adding in options that are only valid for Developers, as if a
356 * normal Author is set to that option, they will be redirected to their own
357 * Author record.
358 *
359 *
360 * @delegate AddDefaultAuthorAreas
361 * @since Symphony 2.2
362 * @param string $context
072aa86 @brendo Fix badly formatted delegate docs. Closes #754
brendo authored
363 * '/system/authors/'
ef78eed @nils-werner Fix for broken author form when not a developer
nils-werner authored
364 * @param array $options
365 * An associative array of options, suitable for use for the Widget::Select
366 * function. By default this will be an array of the Sections in the current
367 * installation. New options should be the path to the page after the `SYMPHONY_URL`
368 * constant.
369 * @param string $default_area
370 * The current `default_area` for this Author.
371 */
372 Symphony::ExtensionManager()->notifyMembers('AddDefaultAuthorAreas', '/system/authors/', array(
373 'options' => &$options,
374 'default_area' => $author->get('default_area')
375 ));
376
377 $label->appendChild(Widget::Select('fields[default_area]', $options));
378 $group->appendChild($label);
fde4902 @pointybeard Added per-author language preferences. Defaults to the system languag…
pointybeard authored
379
ef78eed @nils-werner Fix for broken author form when not a developer
nils-werner authored
380 $this->Form->appendChild($group);
381 ###
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
382
ef78eed @nils-werner Fix for broken author form when not a developer
nils-werner authored
383 ### Custom Language Selection ###
384 $languages = Lang::getAvailableLanguages();
385 if(count($languages) > 1) {
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
386
ef78eed @nils-werner Fix for broken author form when not a developer
nils-werner authored
387 // Get language names
388 asort($languages);
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
389
ef78eed @nils-werner Fix for broken author form when not a developer
nils-werner authored
390 $group = new XMLElement('fieldset');
391 $group->setAttribute('class', 'settings');
392 $group->appendChild(new XMLElement('legend', __('Custom Preferences')));
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
393
ef78eed @nils-werner Fix for broken author form when not a developer
nils-werner authored
394 $div = new XMLElement('div');
395 $div->setAttribute('class', 'group');
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
396
ef78eed @nils-werner Fix for broken author form when not a developer
nils-werner authored
397 $label = Widget::Label(__('Language'));
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
398
ef78eed @nils-werner Fix for broken author form when not a developer
nils-werner authored
399 $options = array(
400 array(NULL, is_null($author->get('language')), __('System Default'))
401 );
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
402
ef78eed @nils-werner Fix for broken author form when not a developer
nils-werner authored
403 foreach($languages as $code => $name) {
404 $options[] = array($code, $code == $author->get('language'), $name);
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
405 }
ef78eed @nils-werner Fix for broken author form when not a developer
nils-werner authored
406 $select = Widget::Select('fields[language]', $options);
407 $label->appendChild($select);
408 $group->appendChild($label);
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
409
ef78eed @nils-werner Fix for broken author form when not a developer
nils-werner authored
410 $this->Form->appendChild($group);
411 }
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
412
ef78eed @nils-werner Fix for broken author form when not a developer
nils-werner authored
413 $div = new XMLElement('div');
414 $div->setAttribute('class', 'actions');
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
415
ef78eed @nils-werner Fix for broken author form when not a developer
nils-werner authored
416 $div->appendChild(Widget::Input('action[save]', ($this->_context[0] == 'edit' ? __('Save Changes') : __('Create Author')), 'submit', array('accesskey' => 's')));
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
417
ef78eed @nils-werner Fix for broken author form when not a developer
nils-werner authored
418 if($this->_context[0] == 'edit' && !$isOwner && !$author->isPrimaryAccount()){
419 $button = new XMLElement('button', __('Delete'));
7f4d72e @nilshoerrmann Move confirm messages to data attributes to improve the localisation …
nilshoerrmann authored
420 $button->setAttributeArray(array('name' => 'action[delete]', 'class' => 'button confirm delete', 'title' => __('Delete this author'), 'type' => 'submit', 'accesskey' => 'd', 'data-message' => __('Are you sure you want to delete this author?')));
ef78eed @nils-werner Fix for broken author form when not a developer
nils-werner authored
421 $div->appendChild($button);
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
422 }
817f982 Added the AddElementstoAuthorForm delegate. Closes #565
Brendan Abbott authored
423
ef78eed @nils-werner Fix for broken author form when not a developer
nils-werner authored
424 $this->Form->appendChild($div);
425
817f982 Added the AddElementstoAuthorForm delegate. Closes #565
Brendan Abbott authored
426 /**
427 * Allows the injection of custom form fields given the current `$this->Form`
428 * object. Please note that this custom data should be saved in own extension
429 * tables and that modifying `tbl_authors` to house your data is highly discouraged.
430 *
431 * @delegate AddElementstoAuthorForm
432 * @since Symphony 2.2
433 * @param string $context
072aa86 @brendo Fix badly formatted delegate docs. Closes #754
brendo authored
434 * '/system/authors/'
817f982 Added the AddElementstoAuthorForm delegate. Closes #565
Brendan Abbott authored
435 * @param XMLElement $form
436 * The contents of `$this->Form` after all the default form elements have been appended.
437 * @param Author $author
438 * The current Author object that is being edited
439 */
440 Symphony::ExtensionManager()->notifyMembers('AddElementstoAuthorForm', '/system/authors/', array(
441 'form' => &$this->Form,
442 'author' => $author
443 ));
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
444 }
445
4e30a45 @brendo Update of Authors Page. New delegates, correct use of SYMPHONY constant
brendo authored
446 public function __actionNew(){
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
447
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
448 if(@array_key_exists('save', $_POST['action']) || @array_key_exists('done', $_POST['action'])) {
449
450 $fields = $_POST['fields'];
451
868c18e @brendo Documented Author class, made changes all Author related code to alig…
brendo authored
452 $this->_Author = new Author;
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
453 $this->_Author->set('user_type', $fields['user_type']);
454 $this->_Author->set('primary', 'no');
455 $this->_Author->set('email', $fields['email']);
456 $this->_Author->set('username', $fields['username']);
457 $this->_Author->set('first_name', General::sanitize($fields['first_name']));
458 $this->_Author->set('last_name', General::sanitize($fields['last_name']));
459 $this->_Author->set('last_seen', NULL);
03ac949 @pointybeard Switched to use SHA1() instead of MD5() for user passwords. [Closes I…
pointybeard authored
460 $this->_Author->set('password', (trim($fields['password']) == '' ? '' : General::hash($fields['password'])));
4e30a45 @brendo Update of Authors Page. New delegates, correct use of SYMPHONY constant
brendo authored
461 $this->_Author->set('default_area', $fields['default_area']);
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
462 $this->_Author->set('auth_token_active', ($fields['auth_token_active'] ? $fields['auth_token_active'] : 'no'));
fde4902 @pointybeard Added per-author language preferences. Defaults to the system languag…
pointybeard authored
463 $this->_Author->set('language', $fields['language']);
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
464
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
465 if($this->_Author->validate($this->_errors)) {
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
466 if($fields['password'] != $fields['password-confirmation']){
94c16e9 @nilshoerrmann add missing calls to the translation function and trim lines.
nilshoerrmann authored
467 $this->_errors['password'] = $this->_errors['password-confirmation'] = __('Passwords did not match');
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
468 }
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
469 else if($author_id = $this->_Author->commit()) {
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
470
4e30a45 @brendo Update of Authors Page. New delegates, correct use of SYMPHONY constant
brendo authored
471 /**
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
472 * Creation of a new Author. The Author object is provided as read
473 * only through this delegate.
474 *
475 * @delegate AuthorPostCreate
476 * @since Symphony 2.2
477 * @param string $context
478 * '/system/authors/'
479 * @param Author $author
480 * The Author object that has just been created
481 */
8d0cab1 @brendo Add new Page delete, AppendPageContent, implement Symphony::Extension…
brendo authored
482 Symphony::ExtensionManager()->notifyMembers('AuthorPostCreate', '/system/authors/', array('author' => $this->_Author));
4e30a45 @brendo Update of Authors Page. New delegates, correct use of SYMPHONY constant
brendo authored
483
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
484 redirect(SYMPHONY_URL . "/system/authors/edit/$author_id/created/");
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
485 }
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
486 }
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
487
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
488 if(is_array($this->_errors) && !empty($this->_errors)) {
2969855 @pointybeard Updated all success page alert messages
pointybeard authored
489 $this->pageAlert(__('There were some problems while attempting to save. Please check below for problem fields.'), Alert::ERROR);
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
490 }
491 else {
8acf6f9 @eKoeS First attemp to make the translator's life easier
eKoeS authored
492 $this->pageAlert(
493 __('Unknown errors occurred while attempting to save.')
494 . '<a href="' . SYMPHONY_URL . '/system/log/">'
495 . __('Check your activity log')
496 . '</a>.'
497 , Alert::ERROR);
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
498 }
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
499 }
500 }
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
501
4e30a45 @brendo Update of Authors Page. New delegates, correct use of SYMPHONY constant
brendo authored
502 public function __actionEdit(){
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
503
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
504 if(!$author_id = $this->_context[1]) redirect(SYMPHONY_URL . '/system/authors/');
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
505
929b1f2 Tweaked the behaviour of author profiles when edited. It is possible …
Alistair Kearney authored
506 $isOwner = ($author_id == Administration::instance()->Author->get('id'));
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
507
508 if(@array_key_exists('save', $_POST['action']) || @array_key_exists('done', $_POST['action'])) {
509
510 $fields = $_POST['fields'];
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
511 $this->_Author = AuthorManager::fetchByID($author_id);
0290e0e @ahwayakchih When user wants to change email or password, require entering old pas…
ahwayakchih authored
512 $authenticated = false;
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
513
0290e0e @ahwayakchih When user wants to change email or password, require entering old pas…
ahwayakchih authored
514 if($fields['email'] != $this->_Author->get('email')) $changing_email = true;
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
515
929b1f2 Tweaked the behaviour of author profiles when edited. It is possible …
Alistair Kearney authored
516 // Check the old password was correct
03ac949 @pointybeard Switched to use SHA1() instead of MD5() for user passwords. [Closes I…
pointybeard authored
517 if(isset($fields['old-password']) && strlen(trim($fields['old-password'])) > 0 && General::hash(trim($fields['old-password'])) == $this->_Author->get('password')) {
0290e0e @ahwayakchih When user wants to change email or password, require entering old pas…
ahwayakchih authored
518 $authenticated = true;
519 }
929b1f2 Tweaked the behaviour of author profiles when edited. It is possible …
Alistair Kearney authored
520 // Developers don't need to specify the old password, unless it's their own account
93960e2 Developers are no longer required to give their password when changin…
Brendan Abbott authored
521 else if(Administration::instance()->Author->isDeveloper()){
94c16e9 @nilshoerrmann add missing calls to the translation function and trim lines.
nilshoerrmann authored
522 $authenticated = true;
929b1f2 Tweaked the behaviour of author profiles when edited. It is possible …
Alistair Kearney authored
523 }
0290e0e @ahwayakchih When user wants to change email or password, require entering old pas…
ahwayakchih authored
524
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
525 $this->_Author->set('id', $author_id);
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
526
929b1f2 Tweaked the behaviour of author profiles when edited. It is possible …
Alistair Kearney authored
527 if ($this->_Author->isPrimaryAccount() || ($isOwner && Administration::instance()->Author->isDeveloper())){
9872e8d @sirlancelot Fixed user access permissions. Closes Issue 4
sirlancelot authored
528 $this->_Author->set('user_type', 'developer'); // Primary accounts are always developer, Developers can't lower their level
929b1f2 Tweaked the behaviour of author profiles when edited. It is possible …
Alistair Kearney authored
529 }
530 elseif (Administration::instance()->Author->isDeveloper() && isset($fields['user_type'])){
9872e8d @sirlancelot Fixed user access permissions. Closes Issue 4
sirlancelot authored
531 $this->_Author->set('user_type', $fields['user_type']); // Only developer can change user type
929b1f2 Tweaked the behaviour of author profiles when edited. It is possible …
Alistair Kearney authored
532 }
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
533
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
534 $this->_Author->set('email', $fields['email']);
535 $this->_Author->set('username', $fields['username']);
536 $this->_Author->set('first_name', General::sanitize($fields['first_name']));
537 $this->_Author->set('last_name', General::sanitize($fields['last_name']));
fde4902 @pointybeard Added per-author language preferences. Defaults to the system languag…
pointybeard authored
538 $this->_Author->set('language', $fields['language']);
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
539
0290e0e @ahwayakchih When user wants to change email or password, require entering old pas…
ahwayakchih authored
540 if(trim($fields['password']) != ''){
03ac949 @pointybeard Switched to use SHA1() instead of MD5() for user passwords. [Closes I…
pointybeard authored
541 $this->_Author->set('password', General::hash($fields['password']));
0290e0e @ahwayakchih When user wants to change email or password, require entering old pas…
ahwayakchih authored
542 $changing_password = true;
543 }
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
544
32d3107 Allow the Sections index to be set as a Default Area for Developer's.…
Brendan Abbott authored
545 // Don't allow authors to set the Section Index as a default area
546 // If they had it previously set, just save `null` which will redirect
547 // the Author (when logging in) to their own Author record
548 if(
549 $this->_Author->get('user_type') == 'author'
550 && $fields['default_area'] == '/blueprints/sections/'
551 ) {
552 $this->_Author->set('default_area', null);
553 }
554 else {
555 $this->_Author->set('default_area', $fields['default_area']);
556 }
557
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
558 $this->_Author->set('auth_token_active', ($fields['auth_token_active'] ? $fields['auth_token_active'] : 'no'));
0290e0e @ahwayakchih When user wants to change email or password, require entering old pas…
ahwayakchih authored
559
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
560 if($this->_Author->validate($this->_errors)) {
0290e0e @ahwayakchih When user wants to change email or password, require entering old pas…
ahwayakchih authored
561 if(!$authenticated && ($changing_password || $changing_email)){
94cc362 @ahwayakchih First step of handling translation in content files. Some strings cou…
ahwayakchih authored
562 if($changing_password) $this->_errors['old-password'] = __('Wrong password. Enter old password to change it.');
563 elseif($changing_email) $this->_errors['old-password'] = __('Wrong password. Enter old one to change email address.');
0290e0e @ahwayakchih When user wants to change email or password, require entering old pas…
ahwayakchih authored
564 }
565
566 elseif(($fields['password'] != '' || $fields['password-confirmation'] != '') && $fields['password'] != $fields['password-confirmation']){
94cc362 @ahwayakchih First step of handling translation in content files. Some strings cou…
ahwayakchih authored
567 $this->_errors['password'] = $this->_errors['password-confirmation'] = __('Passwords did not match');
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
568 }
94c16e9 @nilshoerrmann add missing calls to the translation function and trim lines.
nilshoerrmann authored
569 elseif($this->_Author->commit()){
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
570
7456bf0 Code clean up. Converted to using static Symphony::Database() and Sym…
Alistair Kearney authored
571 Symphony::Database()->delete('tbl_forgotpass', " `expiry` < '".DateTimeObj::getGMT('c')."' OR `author_id` = '".$author_id."' ");
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
572
4e30a45 @brendo Update of Authors Page. New delegates, correct use of SYMPHONY constant
brendo authored
573 if($isOwner) Administration::instance()->login($this->_Author->get('username'), $this->_Author->get('password'), true);
574
575 /**
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
576 * After editing an author, provided with the Author object
577 *
578 * @delegate AuthorPostEdit
579 * @since Symphony 2.2
580 * @param string $context
581 * '/system/authors/'
582 * @param Author $author
583 * An Author object
584 */
8d0cab1 @brendo Add new Page delete, AppendPageContent, implement Symphony::Extension…
brendo authored
585 Symphony::ExtensionManager()->notifyMembers('AuthorPostEdit', '/system/authors/', array('author' => $this->_Author));
4e30a45 @brendo Update of Authors Page. New delegates, correct use of SYMPHONY constant
brendo authored
586
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
587 redirect(SYMPHONY_URL . '/system/authors/edit/' . $author_id . '/saved/');
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
588 }
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
589
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
590 else {
8acf6f9 @eKoeS First attemp to make the translator's life easier
eKoeS authored
591 $this->pageAlert(
592 __('Unknown errors occurred while attempting to save.')
593 . '<a href="' . SYMPHONY_URL . '/system/log/">'
594 . __('Check your activity log')
595 . '</a>.'
596 , Alert::ERROR);
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
597 }
598 }
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
599 }
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
600 else if(@array_key_exists('delete', $_POST['action'])) {
601
602 /**
603 * Prior to deleting an author, provided with the Author ID.
604 *
605 * @delegate AuthorPreDelete
606 * @since Symphony 2.2
607 * @param string $context
608 * '/system/authors/'
609 * @param integer $author_id
610 * The ID of Author ID that is about to be deleted
611 */
8d0cab1 @brendo Add new Page delete, AppendPageContent, implement Symphony::Extension…
brendo authored
612 Symphony::ExtensionManager()->notifyMembers('AuthorPreDelete', '/system/authors/', array('author_id' => $author_id));
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
613
6c8b8b9 @brendo Fix bug caused by previous commit, 42f01fe3006706bdf707. Replace inst…
brendo authored
614 if(!$isOwner) {
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
615 AuthorManager::delete($author_id);
197bf54 @brendo Formatting fixes, new constant, SYMPHONY_URL added. Few regressions f…
brendo authored
616 redirect(SYMPHONY_URL . '/system/authors/');
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
617 }
618 else {
6c8b8b9 @brendo Fix bug caused by previous commit, 42f01fe3006706bdf707. Replace inst…
brendo authored
619 $this->pageAlert(__('You cannot remove yourself as you are the active Author.'), Alert::ERROR);
42f01fe @brendo Fixes #412 and adds a check to the actionEdit to ensure that you can'…
brendo authored
620 }
94c16e9 @nilshoerrmann add missing calls to the translation function and trim lines.
nilshoerrmann authored
621 }
7f90fa0 Initial commit of Revision 5 code
Alistair Kearney authored
622 }
623 }
Something went wrong with that request. Please try again.