| 
									
										
										
										
											2008-05-14 10:54:36 -04:00
										 |  |  | <?php | 
					
						
							| 
									
										
										
										
											2009-01-16 19:35:37 +00:00
										 |  |  | /** | 
					
						
							| 
									
										
										
										
											2009-08-25 18:12:20 -04:00
										 |  |  |  * StatusNet, the distributed open-source microblogging tool | 
					
						
							| 
									
										
										
										
											2008-05-20 15:14:12 -04:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2009-01-16 19:35:37 +00:00
										 |  |  |  * Base class for settings actions | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * PHP version 5 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * LICENCE: This program is free software: you can redistribute it and/or modify | 
					
						
							| 
									
										
										
										
											2008-05-14 15:26:48 -04:00
										 |  |  |  * it under the terms of the GNU Affero General Public License as published by | 
					
						
							|  |  |  |  * the Free Software Foundation, either version 3 of the License, or | 
					
						
							|  |  |  |  * (at your option) any later version. | 
					
						
							| 
									
										
										
										
											2008-05-20 15:14:12 -04:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2008-05-14 15:26:48 -04:00
										 |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  * GNU Affero General Public License for more details. | 
					
						
							| 
									
										
										
										
											2008-05-20 15:14:12 -04:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2008-05-14 15:26:48 -04:00
										 |  |  |  * You should have received a copy of the GNU Affero General Public License | 
					
						
							|  |  |  |  * along with this program.  If not, see <http://www.gnu.org/licenses/>. | 
					
						
							| 
									
										
										
										
											2009-01-16 19:35:37 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * @category  Settings | 
					
						
							| 
									
										
										
										
											2009-08-25 18:12:20 -04:00
										 |  |  |  * @package   StatusNet | 
					
						
							| 
									
										
										
										
											2009-08-25 18:19:04 -04:00
										 |  |  |  * @author    Evan Prodromou <evan@status.net> | 
					
						
							| 
									
										
										
										
											2009-08-25 18:12:20 -04:00
										 |  |  |  * @copyright 2008-2009 StatusNet, Inc. | 
					
						
							| 
									
										
										
										
											2009-01-16 19:35:37 +00:00
										 |  |  |  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 | 
					
						
							| 
									
										
										
										
											2009-08-25 18:16:46 -04:00
										 |  |  |  * @link      http://status.net/ | 
					
						
							| 
									
										
										
										
											2008-05-14 15:26:48 -04:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2008-05-20 15:14:12 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-26 10:41:36 -04:00
										 |  |  | if (!defined('STATUSNET') && !defined('LACONICA')) { | 
					
						
							| 
									
										
										
										
											2009-01-16 19:35:37 +00:00
										 |  |  |     exit(1); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Base class for settings group of actions | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @category Settings | 
					
						
							| 
									
										
										
										
											2009-08-25 18:12:20 -04:00
										 |  |  |  * @package  StatusNet | 
					
						
							| 
									
										
										
										
											2009-08-25 18:19:04 -04:00
										 |  |  |  * @author   Evan Prodromou <evan@status.net> | 
					
						
							| 
									
										
										
										
											2009-01-16 19:35:37 +00:00
										 |  |  |  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 | 
					
						
							| 
									
										
										
										
											2009-08-25 18:16:46 -04:00
										 |  |  |  * @link     http://status.net/ | 
					
						
							| 
									
										
										
										
											2009-01-16 19:35:37 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * @see      Widget | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2008-05-14 10:54:36 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-23 23:40:11 -04:00
										 |  |  | class SettingsAction extends CurrentUserDesignAction | 
					
						
							| 
									
										
										
										
											2008-12-23 14:49:23 -05:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-01-16 19:35:37 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * A message for the user. | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     var $msg = null; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Whether the message is a good one or a bad one. | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     var $success = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Handle input and output a page | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @param array $args $_REQUEST arguments | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return void | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2008-05-15 12:28:44 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-23 14:33:23 -05:00
										 |  |  |     function handle($args) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2008-06-23 18:36:41 -04:00
										 |  |  |         parent::handle($args); | 
					
						
							|  |  |  |         if (!common_logged_in()) { | 
					
						
							| 
									
										
										
										
											2009-01-16 19:35:37 +00:00
										 |  |  |             $this->clientError(_('Not logged in.')); | 
					
						
							| 
									
										
										
										
											2008-06-23 18:36:41 -04:00
										 |  |  |             return; | 
					
						
							| 
									
										
										
										
											2008-06-23 22:52:34 -04:00
										 |  |  |         } else if (!common_is_real_login()) { | 
					
						
							| 
									
										
										
										
											2009-01-16 19:35:37 +00:00
										 |  |  |             // Cookie theft means that automatic logins can't
 | 
					
						
							|  |  |  |             // change important settings or see private info, and
 | 
					
						
							|  |  |  |             // _all_ our settings are important
 | 
					
						
							|  |  |  |             common_set_returnto($this->selfUrl()); | 
					
						
							| 
									
										
										
										
											2009-02-05 11:46:17 -05:00
										 |  |  |             $user = common_current_user(); | 
					
						
							| 
									
										
										
										
											2009-08-04 13:10:37 -04:00
										 |  |  |             if (Event::handle('RedirectToLogin', array($this, $user))) { | 
					
						
							| 
									
										
										
										
											2009-08-04 13:17:43 -04:00
										 |  |  |                 common_redirect(common_local_url('login'), 303); | 
					
						
							| 
									
										
										
										
											2009-02-05 11:46:17 -05:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2008-06-23 18:36:41 -04:00
										 |  |  |         } else if ($_SERVER['REQUEST_METHOD'] == 'POST') { | 
					
						
							| 
									
										
										
										
											2009-01-16 19:35:37 +00:00
										 |  |  |             $this->handlePost(); | 
					
						
							| 
									
										
										
										
											2008-06-23 18:36:41 -04:00
										 |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2009-01-16 19:35:37 +00:00
										 |  |  |             $this->showForm(); | 
					
						
							| 
									
										
										
										
											2008-06-23 18:36:41 -04:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2008-05-15 12:28:44 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-16 19:35:37 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * Handle a POST request | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return boolean success flag | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2008-05-20 15:14:12 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-16 19:35:37 +00:00
										 |  |  |     function handlePost() | 
					
						
							| 
									
										
										
										
											2008-12-23 14:33:23 -05:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2008-06-23 18:36:41 -04:00
										 |  |  |         return false; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2008-05-17 08:20:45 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-16 19:35:37 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * show the settings form | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @param string $msg     an extra message for the user | 
					
						
							|  |  |  |      * @param string $success good message or bad message? | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return void | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2008-05-20 15:14:12 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-16 19:35:37 +00:00
										 |  |  |     function showForm($msg=null, $success=false) | 
					
						
							| 
									
										
										
										
											2008-12-25 09:46:01 -05:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2009-01-16 19:35:37 +00:00
										 |  |  |         $this->msg     = $msg; | 
					
						
							|  |  |  |         $this->success = $success; | 
					
						
							| 
									
										
										
										
											2008-12-25 09:46:01 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-16 19:35:37 +00:00
										 |  |  |         $this->showPage(); | 
					
						
							| 
									
										
										
										
											2008-12-25 09:46:01 -05:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2008-06-30 13:03:42 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-16 19:35:37 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * show human-readable instructions for the page | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return void | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function showPageNotice() | 
					
						
							| 
									
										
										
										
											2008-12-23 14:33:23 -05:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2009-01-16 19:35:37 +00:00
										 |  |  |         if ($this->msg) { | 
					
						
							|  |  |  |             $this->element('div', ($this->success) ? 'success' : 'error', | 
					
						
							|  |  |  |                            $this->msg); | 
					
						
							| 
									
										
										
										
											2008-12-23 14:19:07 -05:00
										 |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2009-01-16 20:00:26 +00:00
										 |  |  |             $inst   = $this->getInstructions(); | 
					
						
							| 
									
										
										
										
											2008-12-23 14:19:07 -05:00
										 |  |  |             $output = common_markup_to_html($inst); | 
					
						
							| 
									
										
										
										
											2009-01-16 19:35:37 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |             $this->elementStart('div', 'instructions'); | 
					
						
							|  |  |  |             $this->raw($output); | 
					
						
							| 
									
										
										
										
											2009-01-16 20:00:26 +00:00
										 |  |  |             $this->elementEnd('div'); | 
					
						
							| 
									
										
										
										
											2008-12-23 14:19:07 -05:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2008-06-30 13:03:42 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-16 19:35:37 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * instructions recipe for sub-classes | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * Subclasses should override this to return readable instructions. They'll | 
					
						
							|  |  |  |      * be processed by common_markup_to_html(). | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return string instructions text | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function getInstructions() | 
					
						
							| 
									
										
										
										
											2008-12-23 14:33:23 -05:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2009-01-16 19:35:37 +00:00
										 |  |  |         return ''; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-05-15 12:28:44 -04:00
										 |  |  | } |