* @author Evan Prodromou <evan@status.net>
* @author Sarven Capadisli <csarven@status.net>
* @copyright 2008-2009 StatusNet, Inc.
+ * @copyright 2013 Free Software Foundation, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*/
{
parent::prepare($args);
- if (!common_logged_in()) {
- // TRANS: Client error displayed trying to create a group while not logged in.
- $this->clientError(_('You must be logged in to create a group.'), 403);
- }
-
// $this->scoped is the current user profile
if (!$this->scoped->hasRight(Right::CREATEGROUP)) {
// TRANS: Client exception thrown when a user tries to create a group while banned.
* @author Zach Copley <zach@status.net>
* @author Sarven Capadisli <csarven@status.net>
* @copyright 2008-2009 StatusNet, Inc.
+ * @copyright 2013 Free Software Foundation, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*/
-if (!defined('STATUSNET') && !defined('LACONICA')) {
+if (!defined('STATUSNET')) {
exit(1);
}
{
parent::prepare($args);
- if (!common_logged_in()) {
- $this->needLogin();
- }
-
$user = $this->scoped->getUser();
$this->content = $this->trimmed('content');
return _m('TITLE','New notice');
}
- /**
- * Handle input, produce output
- *
- * Switches based on GET or POST method. On GET, shows a form
- * for posting a notice. On POST, saves the results of that form.
- *
- * Results may be a full page, or just a single notice list item,
- * depending on whether AJAX was requested.
- *
- * @param array $args $_REQUEST contents
- *
- * @return void
- */
- protected function prepare(array $args=array())
- {
- parent::prepare($args);
-
- if (!common_logged_in()) {
- // TRANS: Error message displayed when trying to perform an action that requires a logged in user.
- $this->clientError(_('Not logged in.'), 403);
- }
-
- return true;
- }
-
/**
* This handlePost saves a new notice, based on arguments
*
protected $action = false;
protected $ajax = false;
protected $menus = true;
+ protected $needLogin = false;
// The currently scoped profile
protected $scoped = null;
StatusNet::setAjax(true);
}
+ if ($this->needLogin) {
+ $this->checkLogin(); // if not logged in, this redirs/excepts
+ }
+
$this->scoped = Profile::current();
return true;
}
/**
- * Redirect to login page (with returnto)
+ * If not logged in, take appropriate action (redir or exception)
*
- * @return nothing
+ * @param boolean $redir Redirect to login if not logged in
+ *
+ * @return boolean true if logged in (never returns if not)
*/
- function needLogin()
+ public function checkLogin($redir=true)
{
- // this might be updated with a login check before redirecting
- common_set_returnto($_SERVER['REQUEST_URI']);
- common_redirect(common_local_url('login'));
+ if (common_logged_in()) {
+ return true;
+ }
+
+ if ($redir==true) {
+ common_set_returnto($_SERVER['REQUEST_URI']);
+ common_redirect(common_local_url('login'));
+ }
+
+ // TRANS: Error message displayed when trying to perform an action that requires a logged in user.
+ $this->clientError(_('Not logged in.'), 403);
}
/**
{
protected $form = null;
protected $type = null;
+ protected $needLogin = true;
protected function prepare(array $args=array()) {
parent::prepare($args);