Пример #1
0
 function prepare($args)
 {
     parent::prepare($args);
     $this->user = common_current_user();
     if (empty($this->user)) {
         // TRANS: Client error displayed when trying to repeat a notice while not logged in.
         $this->clientError(_('Only logged-in users can repeat notices.'));
         return false;
     }
     $id = $this->trimmed('notice');
     if (empty($id)) {
         // TRANS: Client error displayed when trying to repeat a notice while not providing a notice ID.
         $this->clientError(_('No notice specified.'));
         return false;
     }
     $this->notice = Notice::staticGet('id', $id);
     if (empty($this->notice)) {
         // TRANS: Client error displayed when trying to repeat a non-existing notice.
         $this->clientError(_('No notice specified.'));
         return false;
     }
     $token = $this->trimmed('token-' . $id);
     if (empty($token) || $token != common_session_token()) {
         // TRANS: Client error displayed when the session token does not match or is not given.
         $this->clientError(_('There was a problem with your session token. Try again, please.'));
         return false;
     }
     return true;
 }
Пример #2
0
 /**
  * Show body - override to add a special CSS class for the pin pages's
  * "desktop mode" (minimal display)
  *
  * Calls template methods
  *
  * @return nothing
  */
 function showBody()
 {
     $bodyClasses = array();
     if ($this->desktopMode) {
         $bodyClasses[] = 'oauth-desktop-mode';
     }
     if (common_current_user()) {
         $bodyClasses[] = 'user_in';
     }
     $attrs = array('id' => strtolower($this->trimmed('action')));
     if (!empty($bodyClasses)) {
         $attrs['class'] = implode(' ', $bodyClasses);
     }
     $this->elementStart('body', $attrs);
     $this->elementStart('div', array('id' => 'wrap'));
     if (Event::handle('StartShowHeader', array($this))) {
         $this->showHeader();
         Event::handle('EndShowHeader', array($this));
     }
     $this->showCore();
     if (Event::handle('StartShowFooter', array($this))) {
         $this->showFooter();
         Event::handle('EndShowFooter', array($this));
     }
     $this->elementEnd('div');
     $this->showScripts();
     $this->elementEnd('body');
 }
Пример #3
0
 /**
  * Take arguments for running
  *
  * @param array $args $_REQUEST args
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     if (!parent::prepare($args)) {
         return false;
     }
     if (!common_logged_in()) {
         // TRANS: Client error displayed trying to delete an application while not logged in.
         $this->clientError(_('You must be logged in to delete an application.'));
         return false;
     }
     $id = (int) $this->arg('id');
     $this->app = Oauth_application::staticGet('id', $id);
     if (empty($this->app)) {
         // TRANS: Client error displayed trying to delete an application that does not exist.
         $this->clientError(_('Application not found.'));
         return false;
     }
     $cur = common_current_user();
     if ($cur->id != $this->app->owner) {
         // TRANS: Client error displayed trying to delete an application the current user does not own.
         $this->clientError(_('You are not the owner of this application.'), 401);
         return false;
     }
     return true;
 }
Пример #4
0
 /**
  * Check parameters
  *
  * @param array $args action arguments (URL, GET, POST)
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     if (!parent::prepare($args)) {
         return false;
     }
     $this->role = $this->arg('role');
     if (!Profile_role::isValid($this->role)) {
         $this->clientError(_('Invalid role.'));
         return false;
     }
     if (!Profile_role::isSettable($this->role)) {
         $this->clientError(_('This role is reserved and cannot be set.'));
         return false;
     }
     $cur = common_current_user();
     assert(!empty($cur));
     // checked by parent
     if (!$cur->hasRight(Right::REVOKEROLE)) {
         $this->clientError(_('You cannot revoke user roles on this site.'));
         return false;
     }
     assert(!empty($this->profile));
     // checked by parent
     if (!$this->profile->hasRole($this->role)) {
         $this->clientError(_("User doesn't have this role."));
         return false;
     }
     return true;
 }
Пример #5
0
 /**
  * Handle input and output a page
  *
  * @param array $args $_REQUEST arguments
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     if (!common_logged_in()) {
         $this->clientError(_('Not logged in.'));
         return;
     } else {
         if (!common_is_real_login()) {
             // 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());
             $user = common_current_user();
             if (Event::handle('RedirectToLogin', array($this, $user))) {
                 common_redirect(common_local_url('login'), 303);
             }
         } else {
             if ($_SERVER['REQUEST_METHOD'] == 'POST') {
                 $this->handlePost();
             } else {
                 $this->showForm();
             }
         }
     }
 }
Пример #6
0
 /**
  * Check parameters
  *
  * @param array $args action arguments (URL, GET, POST)
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     if (!parent::prepare($args)) {
         return false;
     }
     $this->role = $this->arg('role');
     if (!Profile_role::isValid($this->role)) {
         // TRANS: Client error displayed when trying to revoke an invalid role.
         $this->clientError(_('Invalid role.'));
     }
     if (!Profile_role::isSettable($this->role)) {
         // TRANS: Client error displayed when trying to revoke a reserved role.
         $this->clientError(_('This role is reserved and cannot be set.'));
     }
     $cur = common_current_user();
     assert(!empty($cur));
     // checked by parent
     if (!$cur->hasRight(Right::REVOKEROLE)) {
         // TRANS: Client error displayed when trying to revoke a role without having the right to do that.
         $this->clientError(_('You cannot revoke user roles on this site.'));
     }
     assert(!empty($this->profile));
     // checked by parent
     if (!$this->profile->hasRole($this->role)) {
         // TRANS: Client error displayed when trying to revoke a role that is not set.
         $this->clientError(_('User does not have this role.'));
     }
     return true;
 }
Пример #7
0
 /**
  * For initializing members of the class.
  *
  * @param array $argarray misc. arguments
  *
  * @return boolean true
  */
 function prepare($argarray)
 {
     parent::prepare($argarray);
     $this->user = common_current_user();
     if (empty($this->user)) {
         // TRANS: Client exception thrown when trying to view group private messages without being logged in.
         throw new ClientException(_m('Only logged-in users can view private messages.'), 403);
     }
     $id = $this->trimmed('id');
     $this->gm = Group_message::getKV('id', $id);
     if (empty($this->gm)) {
         // TRANS: Client exception thrown when trying to view a non-existing group private message.
         throw new ClientException(_m('No such message.'), 404);
     }
     $this->group = User_group::getKV('id', $this->gm->to_group);
     if (empty($this->group)) {
         // TRANS: Server exception thrown when trying to view group private messages for a non-exsting group.
         throw new ServerException(_m('Group not found.'));
     }
     if (!$this->user->isMember($this->group)) {
         // TRANS: Client exception thrown when trying to view a group private message without being a group member.
         throw new ClientException(_m('Cannot read message.'), 403);
     }
     $this->sender = Profile::getKV('id', $this->gm->from_profile);
     if (empty($this->sender)) {
         // TRANS: Server exception thrown when trying to view a group private message without a sender.
         throw new ServerException(_m('No sender found.'));
     }
     return true;
 }
Пример #8
0
 /**
  * Check pre-requisites and instantiate attributes
  *
  * @param Array $args array of arguments (URL, GET, POST)
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     parent::prepare($args);
     // CSRF protection
     $token = $this->trimmed('token');
     if (!$token || $token != common_session_token()) {
         // TRANS: Client error displayed when the session token does not match or is not given.
         $this->clientError(_('There was a problem with your session token.' . ' Try again, please.'));
         return false;
     }
     // Only for logged-in users
     $this->user = common_current_user();
     if (empty($this->user)) {
         // TRANS: Error message displayed when trying to perform an action that requires a logged in user.
         $this->clientError(_('Not logged in.'));
         return false;
     }
     $id = $this->arg('peopletag_id');
     $this->peopletag = Profile_list::staticGet('id', $id);
     if (empty($this->peopletag)) {
         // TRANS: Client error displayed trying to reference a non-existing list.
         $this->clientError(_('No such list.'));
         return false;
     }
     $field = $this->arg('field');
     if (!in_array($field, array('fulltext', 'nickname', 'fullname', 'description', 'location', 'uri'))) {
         // TRANS: Client error displayed when trying to add an unindentified field to profile.
         // TRANS: %s is a field name.
         $this->clientError(sprintf(_('Unidentified field %s.'), htmlspecialchars($field)), 404);
         return false;
     }
     $this->field = $field;
     return true;
 }
Пример #9
0
 /**
  * For initializing members of the class.
  *
  * @param array $argarray misc. arguments
  *
  * @return boolean true
  */
 function prepare($argarray)
 {
     parent::prepare($argarray);
     if ($this->boolean('ajax')) {
         GNUsocial::setApi(true);
     }
     $this->user = common_current_user();
     if (empty($this->user)) {
         // TRANS: Client exception thrown trying to respond to a poll while not logged in.
         throw new ClientException(_m('You must be logged in to respond to a poll.'), 403);
     }
     if ($this->isPost()) {
         $this->checkSessionToken();
     }
     $id = $this->trimmed('id');
     $this->poll = Poll::getKV('id', $id);
     if (empty($this->poll)) {
         // TRANS: Client exception thrown trying to respond to a non-existing poll.
         throw new ClientException(_m('Invalid or missing poll.'), 404);
     }
     $selection = intval($this->trimmed('pollselection'));
     if ($selection < 1 || $selection > count($this->poll->getOptions())) {
         // TRANS: Client exception thrown responding to a poll with an invalid answer.
         throw new ClientException(_m('Invalid poll selection.'));
     }
     $this->selection = $selection;
     return true;
 }
Пример #10
0
 /**
  * For initializing members of the class.
  *
  * @param array $argarray misc. arguments
  *
  * @return boolean true
  */
 function prepare($argarray)
 {
     parent::prepare($argarray);
     $cur = common_current_user();
     if (empty($cur)) {
         throw new ClientException(_('Only for logged-in users'), 403);
     }
     $nicknameArg = $this->trimmed('nickname');
     $nickname = common_canonical_nickname($nicknameArg);
     if ($nickname != $nicknameArg) {
         $url = common_local_url('groupinbox', array('nickname' => $nickname));
         common_redirect($url);
         return false;
     }
     $localGroup = Local_group::staticGet('nickname', $nickname);
     if (empty($localGroup)) {
         throw new ClientException(_('No such group'), 404);
     }
     $this->group = User_group::staticGet('id', $localGroup->group_id);
     if (empty($this->group)) {
         throw new ClientException(_('No such group'), 404);
     }
     if (!$cur->isMember($this->group)) {
         throw new ClientException(_('Only for members'), 403);
     }
     $this->page = $this->trimmed('page');
     if (!$this->page) {
         $this->page = 1;
     }
     $this->gm = Group_message::forGroup($this->group, ($this->page - 1) * MESSAGES_PER_PAGE, MESSAGES_PER_PAGE + 1);
     return true;
 }
Пример #11
0
 /**
  * Check pre-requisites and instantiate attributes
  *
  * @param Array $args array of arguments (URL, GET, POST)
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     parent::prepare($args);
     // CSRF protection
     $token = $this->trimmed('token');
     if (!$token || $token != common_session_token()) {
         // TRANS: Client error displayed when the session token does not match or is not given.
         $this->clientError(_('There was a problem with your session token.' . ' Try again, please.'));
     }
     // Only for logged-in users
     $this->user = common_current_user();
     if (empty($this->user)) {
         // TRANS: Error message displayed when trying to perform an action that requires a logged in user.
         $this->clientError(_('Not logged in.'));
     }
     // Profile to subscribe to
     $tagged_id = $this->arg('tagged');
     $this->tagged = Profile::getKV('id', $tagged_id);
     if (empty($this->tagged)) {
         // TRANS: Client error displayed trying to perform an action related to a non-existing profile.
         $this->clientError(_('No such profile.'));
     }
     $id = $this->arg('peopletag_id');
     $this->peopletag = Profile_list::getKV('id', $id);
     if (empty($this->peopletag)) {
         // TRANS: Client error displayed trying to reference a non-existing list.
         $this->clientError(_('No such list.'));
     }
     return true;
 }
Пример #12
0
 /**
  * Take arguments for running
  *
  * @param array $args $_REQUEST args
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     parent::prepare($args);
     $this->checkSessionToken();
     if (!common_logged_in()) {
         if ($_SERVER['REQUEST_METHOD'] == 'POST') {
             $this->clientError(_('Not logged in.'));
         } else {
             // Redirect to login.
             common_set_returnto($this->selfUrl());
             $user = common_current_user();
             if (Event::handle('RedirectToLogin', array($this, $user))) {
                 common_redirect(common_local_url('login'), 303);
             }
         }
         return false;
     }
     $id = $this->trimmed('profileid');
     if (!$id) {
         $this->clientError(_('No profile specified.'));
         return false;
     }
     $this->profile = Profile::staticGet('id', $id);
     if (!$this->profile) {
         $this->clientError(_('No profile with that ID.'));
         return false;
     }
     return true;
 }
Пример #13
0
 /**
  * Prepare for the action
  *
  * We check to see that the user is logged in, has
  * authenticated in this session, and has the right
  * to configure the site.
  *
  * @param array $args Array of arguments from Web driver
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     parent::prepare($args);
     // User must be logged in.
     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.'));
     }
     $user = common_current_user();
     // ...because they're logged in
     assert(!empty($user));
     // It must be a "real" login, not saved cookie login
     if (!common_is_real_login()) {
         // Cookie theft is too easy; we require automatic
         // logins to re-authenticate before admining the site
         common_set_returnto($this->selfUrl());
         if (Event::handle('RedirectToLogin', array($this, $user))) {
             common_redirect(common_local_url('login'), 303);
         }
     }
     // User must have the right to change admin settings
     if (!$user->hasRight(Right::CONFIGURESITE)) {
         // TRANS: Client error message thrown when a user tries to change admin settings but has no access rights.
         $this->clientError(_('You cannot make changes to this site.'));
     }
     // This panel must be enabled
     $name = $this->trimmed('action');
     $name = mb_substr($name, 0, -10);
     if (!self::canAdmin($name)) {
         // TRANS: Client error message throw when a certain panel's settings cannot be changed.
         $this->clientError(_('Changes to that panel are not allowed.'), 403);
     }
     return true;
 }
Пример #14
0
 /**
  * For initializing members of the class.
  *
  * @param array $argarray misc. arguments
  *
  * @return boolean true
  */
 function prepare($argarray)
 {
     parent::prepare($argarray);
     $this->user = common_current_user();
     if (empty($this->user)) {
         throw new ClientException(_('Only logged-in users can view private messages.'), 403);
     }
     $id = $this->trimmed('id');
     $this->gm = Group_message::staticGet('id', $id);
     if (empty($this->gm)) {
         throw new ClientException(_('No such message'), 404);
     }
     $this->group = User_group::staticGet('id', $this->gm->to_group);
     if (empty($this->group)) {
         throw new ServerException(_('Group not found.'));
     }
     if (!$this->user->isMember($this->group)) {
         throw new ClientException(_('Cannot read message.'), 403);
     }
     $this->sender = Profile::staticGet('id', $this->gm->from_profile);
     if (empty($this->sender)) {
         throw new ServerException(_('No sender found.'));
     }
     return true;
 }
 function showContent()
 {
     $cur = common_current_user();
     $profile = $cur->getProfile();
     $widget = new ExtendedProfileWidget($this, $profile, ExtendedProfileWidget::EDITABLE);
     $widget->show();
 }
Пример #16
0
 function showContent()
 {
     if (empty($this->user)) {
         return;
     }
     $this->elementStart('a', array('href' => $this->photo->uri));
     $this->element('img', array('src' => $this->photo->uri));
     $this->elementEnd('a');
     //Image "toolbar"
     $cur = common_current_user();
     if ($this->photo->profile_id == $cur->profile_id) {
         $this->elementStart('div', array('id' => 'image_toolbar'));
         $this->element('a', array('href' => '/editphoto/' . $this->photo->id), 'Edit');
         $this->elementEnd('div');
     }
     $this->element('p', array('class' => 'photodescription'), $this->photo->photo_description);
     //This is a hack to hide the top-level comment
     $this->element('style', array(), "#notice-{$this->photo->notice_id} div { display: none } #notice-{$this->photo->notice_id} ol li div { display: inline }");
     if (Event::handle('StartShowConversation', array($this, $this->conv, $this->scoped))) {
         $notices = $this->conv->getNotices($this->scoped);
         $nl = new FullThreadedNoticeList($notices, $this, $this->scoped);
         $cnt = $nl->show();
     }
     Event::handle('EndShowConversation', array($this, $this->conv, $this->scoped));
 }
Пример #17
0
 /**
  * Check parameters
  *
  * @param array $args action arguments (URL, GET, POST)
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     if (!parent::prepare($args)) {
         return false;
     }
     $this->role = $this->arg('role');
     if (!Profile_role::isValid($this->role)) {
         // TRANS: Client error displayed when trying to assign an invalid role to a user.
         $this->clientError(_('Invalid role.'));
         return false;
     }
     if (!Profile_role::isSettable($this->role)) {
         // TRANS: Client error displayed when trying to assign an reserved role to a user.
         $this->clientError(_('This role is reserved and cannot be set.'));
         return false;
     }
     $cur = common_current_user();
     assert(!empty($cur));
     // checked by parent
     if (!$cur->hasRight(Right::GRANTROLE)) {
         // TRANS: Client error displayed when trying to assign a role to a user while not being allowed to set roles.
         $this->clientError(_('You cannot grant user roles on this site.'));
         return false;
     }
     assert(!empty($this->profile));
     // checked by parent
     if ($this->profile->hasRole($this->role)) {
         // TRANS: Client error displayed when trying to assign a role to a user that already has that role.
         $this->clientError(_('User already has this role.'));
         return false;
     }
     return true;
 }
 function show()
 {
     $links = array();
     $you = false;
     $cur = common_current_user();
     foreach ($this->getProfiles() as $id) {
         if ($cur && $cur->id == $id) {
             $you = true;
             // TRANS: Reference to the logged in user in favourite list.
             array_unshift($links, _m('FAVELIST', 'You'));
         } else {
             $profile = Profile::getKV('id', $id);
             if ($profile instanceof Profile) {
                 $links[] = sprintf('<a class="h-card" href="%s">%s</a>', htmlspecialchars($profile->getUrl()), htmlspecialchars($profile->getBestName()));
             }
         }
     }
     if ($links) {
         $count = count($links);
         $msg = $this->getListMessage($count, $you);
         $out = sprintf($msg, $this->magicList($links));
         $this->showStart();
         $this->out->raw($out);
         $this->showEnd();
         return $count;
     } else {
         return 0;
     }
 }
Пример #19
0
 /**
  * Take arguments for running
  *
  * @param array $args $_REQUEST args
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     parent::prepare($args);
     $this->checkSessionToken();
     if (!common_logged_in()) {
         if ($_SERVER['REQUEST_METHOD'] == 'POST') {
             // TRANS: Error message displayed when trying to perform an action that requires a logged in user.
             $this->clientError(_('Not logged in.'));
         } else {
             // Redirect to login.
             common_set_returnto($this->selfUrl());
             $user = common_current_user();
             if (Event::handle('RedirectToLogin', array($this, $user))) {
                 common_redirect(common_local_url('login'), 303);
             }
         }
         return false;
     }
     $id = $this->trimmed('profileid');
     if (!$id) {
         // TRANS: Client error displayed when trying to change user options without specifying a user to work on.
         $this->clientError(_('No profile specified.'));
         return false;
     }
     $this->profile = Profile::staticGet('id', $id);
     if (!$this->profile) {
         // TRANS: Client error displayed when trying to change user options without specifying an existing user to work on.
         $this->clientError(_('No profile with that ID.'));
         return false;
     }
     return true;
 }
Пример #20
0
 /**
  * Check pre-requisites and instantiate attributes
  *
  * @param Array $args array of arguments (URL, GET, POST)
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     parent::prepare($args);
     // Only allow POST requests
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         // TRANS: Client error displayed trying to perform any request method other than POST.
         // TRANS: Do not translate POST.
         $this->clientError(_('This action only accepts POST requests.'));
         return false;
     }
     // CSRF protection
     $token = $this->trimmed('token');
     if (!$token || $token != common_session_token()) {
         // TRANS: Client error displayed when the session token is not okay.
         $this->clientError(_('There was a problem with your session token.' . ' Try again, please.'));
         return false;
     }
     // Only for logged-in users
     $this->user = common_current_user();
     if (empty($this->user)) {
         // TRANS: Error message displayed when trying to perform an action that requires a logged in user.
         $this->clientError(_('Not logged in.'));
         return false;
     }
     // Profile to subscribe to
     $other_id = $this->arg('subscribeto');
     $this->other = Profile::staticGet('id', $other_id);
     if (empty($this->other)) {
         // TRANS: Client error displayed trying to subscribe to a non-existing profile.
         $this->clientError(_('No such profile.'));
         return false;
     }
     return true;
 }
Пример #21
0
 function __construct($action, $profile)
 {
     parent::__construct($action);
     $this->profile = clone $profile;
     $this->user = common_current_user();
     $this->mirror = SubMirror::pkeyGet(array('subscriber' => $this->user->id, 'subscribed' => $this->profile->id));
 }
 /**
  * Check pre-requisites and instantiate attributes
  *
  * @param Array $args array of arguments (URL, GET, POST)
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     parent::prepare($args);
     // Only for logged-in users
     $this->user = common_current_user();
     if (empty($this->user)) {
         // TRANS: Error message displayed when trying to perform an action that requires a logged in user.
         $this->clientError(_('Not logged in.'));
     }
     // CSRF protection
     $token = $this->trimmed('token');
     if (!$token || $token != common_session_token()) {
         // TRANS: Client error displayed when the session token does not match or is not given.
         $this->clientError(_('There was a problem with your session token.' . ' Try again, please.'));
     }
     $profile = $this->user->getProfile();
     $tags = $profile->getLists($this->scoped);
     $this->tags = array();
     while ($tags->fetch()) {
         if (empty($this->last_mod)) {
             $this->last_mod = $tags->modified;
         }
         $arr = array();
         $arr['tag'] = $tags->tag;
         $arr['mode'] = $tags->private ? 'private' : 'public';
         // $arr['url'] = $tags->homeUrl();
         $arr['freq'] = $tags->taggedCount();
         $this->tags[] = $arr;
     }
     $tags = NULL;
     return true;
 }
Пример #23
0
 /**
  * Check pre-requisites and instantiate attributes
  *
  * @param Array $args array of arguments (URL, GET, POST)
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     parent::prepare($args);
     // @fixme these are pretty common, should a parent class factor these out?
     // Only allow POST requests
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         // TRANS: Client error displayed when trying to use another method than POST.
         // TRANS: Do not translate POST.
         $this->clientError(_('This action only accepts POST requests.'));
     }
     // CSRF protection
     $token = $this->trimmed('token');
     if (!$token || $token != common_session_token()) {
         // TRANS: Client error displayed when the session token does not match or is not given.
         $this->clientError(_('There was a problem with your session token.' . ' Try again, please.'));
     }
     // Only for logged-in users
     $this->user = common_current_user();
     if (empty($this->user)) {
         // TRANS: Error message displayed when trying to perform an action that requires a logged in user.
         $this->clientError(_('Not logged in.'));
     }
     if (!AdminPanelAction::canAdmin('plugins')) {
         // TRANS: Client error displayed when trying to enable or disable a plugin without access rights.
         $this->clientError(_('You cannot administer plugins.'));
     }
     $this->plugin = $this->arg('plugin');
     $defaultPlugins = common_config('plugins', 'default');
     if (!array_key_exists($this->plugin, $defaultPlugins)) {
         // TRANS: Client error displayed when trying to enable or disable a non-existing plugin.
         $this->clientError(_('No such plugin.'));
     }
     return true;
 }
Пример #24
0
 function saveDetails()
 {
     common_debug(var_export($_POST, true));
     $user = common_current_user();
     try {
         $this->saveStandardProfileDetails($user);
         $profile = $user->getProfile();
         $simpleFieldNames = array('title', 'spouse', 'kids', 'manager');
         $dateFieldNames = array('birthday');
         foreach ($simpleFieldNames as $name) {
             $value = $this->trimmed('extprofile-' . $name);
             if (!empty($value)) {
                 $this->saveField($user, $name, $value);
             }
         }
         foreach ($dateFieldNames as $name) {
             $value = $this->trimmed('extprofile-' . $name);
             $dateVal = $this->parseDate($name, $value);
             $this->saveField($user, $name, null, null, null, $dateVal);
         }
         $this->savePhoneNumbers($user);
         $this->saveIms($user);
         $this->saveWebsites($user);
         $this->saveExperiences($user);
         $this->saveEducations($user);
     } catch (Exception $e) {
         $this->showForm($e->getMessage(), false);
         return;
     }
     // TRANS: Success message after saving extended profile details.
     $this->showForm(_m('Details saved.'), true);
 }
Пример #25
0
 function prepare($args)
 {
     parent::prepare($args);
     $this->user = common_current_user();
     if (empty($this->user)) {
         $this->clientError(_('Only logged-in users can repeat notices.'));
         return false;
     }
     $id = $this->trimmed('notice');
     if (empty($id)) {
         $this->clientError(_('No notice specified.'));
         return false;
     }
     $this->notice = Notice::staticGet('id', $id);
     if (empty($this->notice)) {
         $this->clientError(_('No notice specified.'));
         return false;
     }
     if ($this->user->id == $this->notice->profile_id) {
         $this->clientError(_("You can't repeat your own notice."));
         return false;
     }
     $token = $this->trimmed('token-' . $id);
     if (empty($token) || $token != common_session_token()) {
         $this->clientError(_('There was a problem with your session token. Try again, please.'));
         return false;
     }
     $profile = $this->user->getProfile();
     if ($profile->hasRepeated($id)) {
         $this->clientError(_('You already repeated that notice.'));
         return false;
     }
     return true;
 }
Пример #26
0
 function __construct($out, Profile $profile)
 {
     parent::__construct($out);
     $this->profile = $profile;
     $user = common_current_user();
     $this->lists = $profile->getLists($user);
 }
Пример #27
0
 /**
  * Show the menu
  *
  * @return void
  */
 function show()
 {
     $user = null;
     // FIXME: we should probably pass this in
     $action = $this->action->trimmed('action');
     $nickname = $this->action->trimmed('nickname');
     if ($nickname) {
         $user = User::staticGet('nickname', $nickname);
         $user_profile = $user->getProfile();
     } else {
         $user_profile = false;
     }
     if (Event::handle('StartPersonalGroupNav', array($this))) {
         $cur = common_current_user();
         if ($user && $cur && $cur->id == $user->id) {
             $this->out->elementStart('ul', array('class' => 'nav'));
             //                $this->out->menuItem(common_local_url('outbox', array('nickname' =>
             //                                                                         $nickname)),
             //                                 _('Outbox'),
             //                                 _('Your sent messages'),
             //                                 $action == 'outbox');
             $this->out->elementEnd('ul');
         }
         Event::handle('EndPersonalGroupNav', array($this));
     }
 }
Пример #28
0
 /**
  * For initializing members of the class.
  *
  * @param array $argarray misc. arguments
  *
  * @return boolean true
  */
 function prepare($argarray)
 {
     parent::prepare($argarray);
     $cur = common_current_user();
     if (empty($cur)) {
         // TRANS: Client exception thrown when trying to view group inbox while not logged in.
         throw new ClientException(_m('Only for logged-in users.'), 403);
     }
     $nicknameArg = $this->trimmed('nickname');
     $nickname = common_canonical_nickname($nicknameArg);
     if ($nickname != $nicknameArg) {
         $url = common_local_url('groupinbox', array('nickname' => $nickname));
         common_redirect($url);
     }
     $localGroup = Local_group::getKV('nickname', $nickname);
     if (empty($localGroup)) {
         // TRANS: Client exception thrown when trying to view group inbox for non-existing group.
         throw new ClientException(_m('No such group.'), 404);
     }
     $this->group = User_group::getKV('id', $localGroup->group_id);
     if (empty($this->group)) {
         // TRANS: Client exception thrown when trying to view group inbox for non-existing group.
         throw new ClientException(_m('No such group.'), 404);
     }
     if (!$cur->isMember($this->group)) {
         // TRANS: Client exception thrown when trying to view group inbox while not a member.
         throw new ClientException(_m('Only for members.'), 403);
     }
     $this->page = $this->trimmed('page');
     if (!$this->page) {
         $this->page = 1;
     }
     $this->gm = Group_message::forGroup($this->group, ($this->page - 1) * MESSAGES_PER_PAGE, MESSAGES_PER_PAGE + 1);
     return true;
 }
Пример #29
0
 /**
  * Show the menu
  *
  * @return void
  */
 function show()
 {
     $cur = common_current_user();
     $action = $this->action->trimmed('action');
     $this->out->elementStart('ul', array('class' => 'nav'));
     if (Event::handle('StartSubGroupNav', array($this))) {
         $this->out->menuItem(common_local_url('showstream', array('nickname' => $this->user->nickname)), _m('MENU', 'Profile'), empty($profile) ? $this->user->nickname : $profile->getBestName(), $action == 'showstream', 'nav_profile');
         $this->out->menuItem(common_local_url('subscriptions', array('nickname' => $this->user->nickname)), _m('MENU', 'Subscriptions'), sprintf(_('People %s subscribes to.'), $this->user->nickname), $action == 'subscriptions', 'nav_subscriptions');
         $this->out->menuItem(common_local_url('subscribers', array('nickname' => $this->user->nickname)), _m('MENU', 'Subscribers'), sprintf(_('People subscribed to %s.'), $this->user->nickname), $action == 'subscribers', 'nav_subscribers');
         if ($cur && $cur->id == $this->user->id) {
             // Possibly site admins should be able to get in here too
             $pending = $this->countPendingSubs();
             if ($pending || $cur->subscribe_policy == User::SUBSCRIBE_POLICY_MODERATE) {
                 $this->out->menuItem(common_local_url('subqueue', array('nickname' => $this->user->nickname)), sprintf(_m('MENU', 'Pending (%d)'), $pending), sprintf(_('Approve pending subscription requests.'), $this->user->nickname), $action == 'subqueueaction', 'nav_subscribers');
             }
         }
         $this->out->menuItem(common_local_url('usergroups', array('nickname' => $this->user->nickname)), _m('MENU', 'Groups'), sprintf(_('Groups %s is a member of.'), $this->user->nickname), $action == 'usergroups', 'nav_usergroups');
         $this->out->menuItem(common_local_url('peopletagsubscriptions', array('nickname' => $this->user->nickname)), _m('MENU', 'Lists'), sprintf(_('List subscriptions by %s.'), $this->user->nickname), in_array($action, array('peopletagsbyuser', 'peopletagsubscriptions', 'peopletagsforuser')), 'nav_timeline_peopletags');
         if (common_config('invite', 'enabled') && !is_null($cur) && $this->user->id === $cur->id) {
             $this->out->menuItem(common_local_url('invite'), _m('MENU', 'Invite'), sprintf(_('Invite friends and colleagues to join you on %s.'), common_config('site', 'name')), $action == 'invite', 'nav_invite');
         }
         Event::handle('EndSubGroupNav', array($this));
     }
     $this->out->elementEnd('ul');
 }
Пример #30
0
 function onEndToolsLocalNav($action)
 {
     $actionName = $action->trimmed('action');
     $user = common_current_user();
     if (!empty($user)) {
         if ($actionName === 'taskcreate') {
             $action->elementStart('li', array('id' => 'nav_task', 'class' => 'current'));
         } else {
             $action->elementStart('li', array('id' => 'nav_task'));
         }
         $action->elementStart('a', array('href' => common_local_url('taskcreate'), 'title' => _m('Tareas de Clase')));
         $action->text('Tareas');
         // Si es alumno, mostramos las tareas pendientes.
         if (!$user->hasRole('grader')) {
             // Llamamos a la función que obtenga el numero de tareas
             $number = Task::getNumberPendingTasks($user->id);
             if ($number != 0) {
                 $action->element('span', 'pending-tasks-number', $number);
             }
         }
         $action->elementEnd('a');
         $action->elementEnd('li');
     }
     return true;
 }