function clear_jabber($id)
{
    $user = User::getKV('id', $id);
    if ($user && $user->jabber) {
        echo "clearing user {$id}'s user.jabber, was: {$user->jabber}";
        if (have_option('dry-run')) {
            echo " (SKIPPING)";
        } else {
            $original = clone $user;
            $user->jabber = null;
            try {
                $user->updateWithKeys($original);
            } catch (Exception $e) {
                echo "WARNING: user update failed (setting jabber to null): " . $e->getMessage() . "\n";
            }
        }
        echo "\n";
    } else {
        if (!$user) {
            echo "Missing user for {$id}\n";
        } else {
            echo "Cleared jabber already for {$id}\n";
        }
    }
}
 /**
  * For initializing members of the class.
  *
  * @param array $argarray misc. arguments
  *
  * @return boolean true
  */
 function prepare($argarray)
 {
     Action::prepare($argarray);
     $this->id = $this->trimmed('id');
     $this->question = QnA_Question::getKV('id', $this->id);
     if (empty($this->question)) {
         // TRANS: Client exception thrown trying to view a non-existing question.
         throw new ClientException(_m('No such question.'), 404);
     }
     $this->notice = $this->question->getNotice();
     if (empty($this->notice)) {
         // Did we used to have it, and it got deleted?
         // TRANS: Client exception thrown trying to view a non-existing question notice.
         throw new ClientException(_m('No such question notice.'), 404);
     }
     $this->user = User::getKV('id', $this->question->profile_id);
     if (empty($this->user)) {
         // TRANS: Client exception thrown trying to view a question of a non-existing user.
         throw new ClientException(_m('No such user.'), 404);
     }
     $this->profile = $this->user->getProfile();
     if (empty($this->profile)) {
         // TRANS: Server exception thrown trying to view a question for a user for which the profile could not be loaded.
         throw new ServerException(_m('User without a profile.'));
     }
     try {
         $this->avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE);
     } catch (Exception $e) {
         $this->avatar = null;
     }
     return true;
 }
Beispiel #3
0
 /**
  * Take arguments for running
  *
  * This method is called first, and it lets the action class get
  * all its arguments and validate them. It's also the time
  * to fetch any relevant data from the database.
  *
  * Action classes should run parent::prepare($args) as the first
  * line of this method to make sure the default argument-processing
  * happens.
  *
  * @param array $args $_REQUEST args
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     parent::prepare($args);
     if (common_config('singleuser', 'enabled')) {
         $nickname = User::singleUserNickname();
     } else {
         // PHP 5.4
         // $nickname = $this->returnToArgs()[1]['nickname'];
         // PHP < 5.4
         $nickname = $this->returnToArgs();
         $nickname = $nickname[1]['nickname'];
     }
     $this->user = User::getKV('nickname', $nickname);
     if (!$this->user) {
         // TRANS: Client error displayed when trying to display bookmarks for a non-existing user.
         $this->clientError(_('No such user.'));
     }
     $this->page = $this->arg('page') ? $this->arg('page') + 0 : 1;
     $stream = new BookmarksNoticeStream($this->user->id, true);
     $this->notices = $stream->getNotices(($this->page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
     if ($this->page > 1 && $this->notices->N == 0) {
         throw new ClientException(_('No such page.'), 404);
     }
     return true;
 }
Beispiel #4
0
 function prepare($args)
 {
     parent::prepare($args);
     $nickname_arg = $this->arg('nickname');
     if (empty($nickname_arg)) {
         // TRANS: Client error displayed when requesting Friends of a Friend feed without providing a user nickname.
         $this->clientError(_('No such user.'), 404);
     }
     $this->nickname = common_canonical_nickname($nickname_arg);
     // Permanent redirect on non-canonical nickname
     if ($nickname_arg != $this->nickname) {
         common_redirect(common_local_url('foaf', array('nickname' => $this->nickname)), 301);
     }
     $this->user = User::getKV('nickname', $this->nickname);
     if (!$this->user) {
         // TRANS: Client error displayed when requesting Friends of a Friend feed for an object that is not a user.
         $this->clientError(_('No such user.'), 404);
     }
     $this->profile = $this->user->getProfile();
     if (!$this->profile) {
         // TRANS: Error message displayed when referring to a user without a profile.
         $this->serverError(_('User has no profile.'), 500);
     }
     return true;
 }
Beispiel #5
0
 function prepare($args)
 {
     parent::prepare($args);
     $nickname_arg = $this->arg('nickname');
     $nickname = Nickname::normalize($nickname_arg);
     // Permanent redirect on non-canonical nickname
     if ($nickname_arg != $nickname) {
         $args = array('nickname' => $nickname);
         if ($this->arg('page') && $this->arg('page') != 1) {
             $args['page'] = $this->arg['page'];
         }
         common_redirect(common_local_url($this->trimmed('action'), $args), 301);
     }
     $this->user = User::getKV('nickname', $nickname);
     if (!$this->user) {
         // TRANS: Client error displayed when referring to a non-existing user.
         $this->clientError(_m('No such user.'), 404);
     }
     $this->profile = $this->user->getProfile();
     if (!$this->profile) {
         // TRANS: Error message displayed when referring to a user without a profile.
         $this->serverError(_m('User has no profile.'));
     }
     $page = $this->trimmed('page');
     if (!empty($page) && Validate::number($page)) {
         $this->page = $page + 0;
     } else {
         $this->page = 1;
     }
     $this->notices = empty($this->tag) ? $this->user->getNotices(($this->page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1) : $this->user->getTaggedNotices($this->tag, ($this->page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1, 0, 0, null);
     return true;
 }
 /**
  * If poster is in one of the forced groups, make sure their notice
  * gets saved into that group even if not explicitly mentioned.
  *
  * @param Notice $notice
  * @return boolean event hook return
  */
 function onStartNoticeDistribute($notice)
 {
     $profile = $notice->getProfile();
     $isRemote = !User::getKV('id', $profile->id);
     if ($isRemote) {
         /*
          * Notices from remote users on other sites
          * will normally not end up here unless they're
          * specifically directed here, e.g.: via explicit
          * post to a remote (to them) group. But remote
          * notices can also be `pulled in' as a result of
          * local users subscribing to the remote user;
          * from the remote user's perspective, this results
          * in group-forcing appearing effectively random.
          * So let's be consistent, and just never force
          * incoming remote notices into a ForceGroup:
          */
         return true;
     }
     foreach ($this->post as $nickname) {
         $group = User_group::getForNickname($nickname);
         if ($group && $profile->isMember($group)) {
             $notice->addToGroupInbox($group);
         }
     }
     return true;
 }
 /**
  * Class handler.
  *
  * @param array $args query arguments
  *
  * @return boolean false if nickname or user isn't found
  */
 protected function handle()
 {
     parent::handle();
     $nickname = $this->trimmed('nickname');
     if (!$nickname) {
         // TRANS: Client error displayed trying to get an avatar without providing a nickname.
         $this->clientError(_('No nickname.'));
     }
     $size = $this->trimmed('size') ?: 'original';
     $user = User::getKV('nickname', $nickname);
     if (!$user) {
         // TRANS: Client error displayed trying to get an avatar for a non-existing user.
         $this->clientError(_('No such user.'));
     }
     $profile = $user->getProfile();
     if (!$profile) {
         // TRANS: Error message displayed when referring to a user without a profile.
         $this->clientError(_('User has no profile.'));
     }
     if ($size === 'original') {
         try {
             $avatar = Avatar::getUploaded($profile);
             $url = $avatar->displayUrl();
         } catch (NoAvatarException $e) {
             $url = Avatar::defaultImage(AVATAR_PROFILE_SIZE);
         }
     } else {
         $url = $profile->avatarUrl($size);
     }
     common_redirect($url, 302);
 }
 function prepare($args)
 {
     parent::prepare($args);
     if (common_config('singleuser', 'enabled')) {
         $nickname_arg = User::singleUserNickname();
     } else {
         $nickname_arg = $this->arg('nickname');
     }
     $nickname = common_canonical_nickname($nickname_arg);
     // Permanent redirect on non-canonical nickname
     if ($nickname_arg != $nickname) {
         $args = array('nickname' => $nickname);
         if ($this->arg('page') && $this->arg('page') != 1) {
             $args['page'] = $this->arg['page'];
         }
         common_redirect(common_local_url('peopletagsforuser', $args), 301);
     }
     $this->user = User::getKV('nickname', $nickname);
     if (!$this->user) {
         // TRANS: Client error displayed trying to perform an action related to a non-existing user.
         $this->clientError(_('No such user.'), 404);
     }
     $this->tagged = $this->user->getProfile();
     if (!$this->tagged) {
         // TRANS: Error message displayed when referring to a user without a profile.
         $this->serverError(_('User has no profile.'));
     }
     $this->page = $this->arg('page') ? $this->arg('page') + 0 : 1;
     return true;
 }
 public function onStartCheckPassword($nickname, $password, &$authenticatedUser)
 {
     if (common_is_email($nickname)) {
         $this->unauthed_user = User::getKV('email', common_canonical_email($nickname));
     } else {
         $this->unauthed_user = User::getKV('nickname', Nickname::normalize($nickname));
     }
     if (!$this->unauthed_user instanceof User) {
         // Unknown username continue processing StartCheckPassword (maybe uninitialized LDAP user etc?)
         return true;
     }
     $this->failed_attempts = (int) $this->unauthed_user->getPref(self::FAILED_LOGIN_IP_SECTION, $this->client_ip);
     switch (true) {
         case $this->failed_attempts >= 5:
             common_log(LOG_WARNING, sprintf('Multiple failed login attempts for user %s from IP %s - brute force attack?', $this->unauthed_user->getNickname(), $this->client_ip));
             // 5 seconds is a good max waiting time anyway...
             sleep($this->failed_attempts % 5 + 1);
             break;
         case $this->failed_attempts > 0:
             common_debug(sprintf('Previously failed login on user %s from IP %s - sleeping %u seconds.', $this->unauthed_user->getNickname(), $this->client_ip, $this->failed_attempts));
             sleep($this->failed_attempts);
             break;
         default:
             // No sleeping if it's our first failed attempt.
     }
     return true;
 }
 function onEndShowAccountProfileBlock(HTMLOutputter $out, Profile $profile)
 {
     $user = User::getKV('id', $profile->id);
     if ($user) {
         $url = common_local_url('profiledetail', array('nickname' => $user->nickname));
         // TRANS: Link text on user profile page leading to extended profile page.
         $out->element('a', array('href' => $url, 'class' => 'profiledetail'), _m('More details...'));
     }
 }
 function handle($notice)
 {
     assert($notice instanceof Notice);
     $this->notice = $notice;
     $this->user = User::getKV('id', $notice->profile_id);
     try {
         $profile = $this->notice->getProfile();
     } catch (Exception $e) {
         common_log(LOG_ERR, "Can't get profile for notice; skipping: " . $e->getMessage());
         return true;
     }
     if ($notice->isLocal()) {
         // Notices generated on remote sites will have already
         // been pushed to user's subscribers by their origin sites.
         $this->pushUser();
     }
     foreach ($notice->getGroups() as $group) {
         $oprofile = Ostatus_profile::getKV('group_id', $group->id);
         if ($oprofile) {
             // remote group
             if ($notice->isLocal()) {
                 $this->pingReply($oprofile);
             }
         } else {
             // local group
             $this->pushGroup($group->id);
         }
     }
     if ($notice->isLocal()) {
         // Notices generated on other sites will have already
         // pinged their reply-targets.
         foreach ($notice->getReplies() as $profile_id) {
             $oprofile = Ostatus_profile::getKV('profile_id', $profile_id);
             if ($oprofile) {
                 $this->pingReply($oprofile);
             }
         }
         if (!empty($this->notice->reply_to)) {
             $replyTo = Notice::getKV('id', $this->notice->reply_to);
             if (!empty($replyTo)) {
                 foreach ($replyTo->getReplies() as $profile_id) {
                     $oprofile = Ostatus_profile::getKV('profile_id', $profile_id);
                     if ($oprofile) {
                         $this->pingReply($oprofile);
                     }
                 }
             }
         }
         foreach ($notice->getProfileTags() as $ptag) {
             $oprofile = Ostatus_profile::getKV('peopletag_id', $ptag->id);
             if (!$oprofile) {
                 $this->pushPeopletag($ptag);
             }
         }
     }
     return true;
 }
 function handle($object)
 {
     $userId = $object;
     $user = User::getKV($userId);
     common_log(LOG_INFO, "Making backup file for user " . $user->nickname);
     $fileName = $this->makeBackupFile($user);
     common_log(LOG_INFO, "Notifying user " . $user->nickname . " of their new backup file.");
     $this->notifyBackupFile($user, $fileName);
     return true;
 }
 /**
  * Take arguments for running
  *
  * @param array $args $_REQUEST args
  *
  * @return boolean success flag
  *
  */
 protected function prepare(array $args = array())
 {
     parent::prepare($args);
     $user = User::getKV('nickname', $this->arg('screen_name'));
     if (!$user instanceof User) {
         // TRANS: Client error displayed when requesting user information for a non-existing user.
         $this->clientError(_('User not found.'), 404);
     }
     $this->target = $user->getProfile();
     $this->size = $this->arg('size');
     return true;
 }
 function prepare($args)
 {
     parent::prepare($args);
     $nickname = common_canonical_nickname($this->arg('nickname'));
     $this->user = User::getKV('nickname', $nickname);
     $this->page = $this->trimmed('page');
     if (!$this->page) {
         $this->page = 1;
     }
     common_set_returnto($this->selfUrl());
     return true;
 }
Beispiel #15
0
 /**
  * Initialization.
  *
  * @param array $args Web and URL arguments
  *
  * @return boolean false if user doesn't exist
  *
  */
 function prepare($args)
 {
     parent::prepare($args);
     $nickname = $this->trimmed('nickname');
     $this->user = User::getKV('nickname', $nickname);
     if (!$this->user) {
         // TRANS: Client error when user not found for an rss related action.
         $this->clientError(_('No such user.'));
     } else {
         $this->notices = $this->getNotices($this->limit);
         return true;
     }
 }
Beispiel #16
0
 /**
  * Find the user to display by supplied nickname
  *
  * @param array $args Arguments from $_REQUEST
  *
  * @return boolean success
  */
 function prepare($args)
 {
     parent::prepare($args);
     $nickname = $this->trimmed('nickname');
     $this->user = User::getKV('nickname', $nickname);
     if (!$this->user) {
         // TRANS: Client error displayed when trying to get the RSS feed with favorites of a user that does not exist.
         $this->clientError(_('No such user.'));
     } else {
         $this->notices = $this->getNotices($this->limit);
         return true;
     }
 }
Beispiel #17
0
 function prepare($args)
 {
     parent::prepare($args);
     $nickname = $this->trimmed('nickname');
     $this->user = User::getKV('nickname', $nickname);
     if (!$this->user) {
         // TRANS: Client error displayed when providing a non-existing nickname in a RSS 1.0 action.
         $this->clientError(_('No such user.'));
     } else {
         $this->notices = $this->getNotices($this->limit);
         return true;
     }
 }
 function onStartCheckPassword($nickname, $password, &$authenticatedUser)
 {
     if (!strpos($nickname, '@')) {
         return true;
     }
     $user = User::getKV('email', $nickname);
     if ($user instanceof User && $user->email === $nickname) {
         if (common_check_user($user->nickname, $password)) {
             $authenticatedUser = $user;
             return false;
         }
     }
     return true;
 }
 function setUp()
 {
     $user = User::getKV('nickname', 'userrightstestuser');
     if ($user) {
         // Leftover from a broken test run?
         $profile = $user->getProfile();
         $user->delete();
         $profile->delete();
     }
     $this->user = User::register(array('nickname' => 'userrightstestuser'));
     if (!$this->user) {
         throw new Exception("Couldn't register userrightstestuser");
     }
 }
 function changePassword($username, $oldpassword, $newpassword)
 {
     $username = Nickname::normalize($username);
     if (!$this->password_changeable) {
         return false;
     }
     $user = User::getKV('nickname', $username);
     if (empty($user)) {
         return false;
     }
     $original = clone $user;
     $user->password = $this->hashPassword($newpassword, $user->getProfile());
     return true === $user->validate() && $user->update($original);
 }
 /**
  * For initializing members of the class.
  *
  * @param array $argarray misc. arguments
  *
  * @return boolean true
  */
 function prepare($argarray)
 {
     parent::prepare($argarray);
     $user = common_current_user();
     if (!empty($user)) {
         // TRANS: Client exception thrown when trying to register while already logged in.
         throw new ClientException(_m('You are already logged in.'));
     }
     $this->code = $this->trimmed('code');
     $this->confirm = Confirm_address::getKV('code', $this->code);
     if (empty($this->confirm)) {
         // TRANS: Client exception thrown when trying to register with a non-existing confirmation code.
         throw new ClientException(_m('Confirmation code not found.'));
         return;
     }
     $this->user = User::getKV('id', $this->confirm->user_id);
     if (empty($this->user)) {
         // TRANS: Client exception thrown when trying to register with a confirmation code that is not connected with a user.
         throw new ServerException(_m('No user for that confirmation code.'));
     }
     $type = $this->confirm->address_type;
     if ($type != 'email') {
         // TRANS: Client exception thrown when trying to register with a invalid e-mail address.
         // TRANS: %s is the invalid e-mail address.
         throw new ServerException(sprintf(_m('Unrecognized address type %s.'), $type));
     }
     if (!empty($this->user->email) && $this->user->email == $confirm->address) {
         // TRANS: Client error for an already confirmed email/jabber/sms address.
         throw new ClientException(_m('That address has already been confirmed.'));
     }
     if ($this->isPost()) {
         $this->checkSessionToken();
         $password = $this->trimmed('password');
         $confirm = $this->trimmed('confirm');
         if (strlen($password) < 6) {
             // TRANS: Client exception thrown when trying to register with too short a password.
             throw new ClientException(_m('Password too short.'));
             return;
         } else {
             if (0 != strcmp($password, $confirm)) {
                 // TRANS: Client exception thrown when trying to register without providing the same password twice.
                 throw new ClientException(_m('Passwords do not match.'));
                 return;
             }
         }
         $this->password = $password;
     }
     return true;
 }
 function impossibleStream()
 {
     $user = User::getKV('id', $this->streamProfile->id);
     // If it's a private stream, and no user or not a subscriber
     if (!empty($user) && $user->private_stream && (empty($this->userProfile) || !$this->userProfile->isSubscribed($this->streamProfile))) {
         return true;
     }
     // If it's a spammy stream, and no user or not a moderator
     if (common_config('notice', 'hidespam')) {
         if ($this->streamProfile->hasRole(Profile_role::SILENCED) && (empty($this->userProfile) || $this->userProfile->id !== $this->streamProfile->id && !$this->userProfile->hasRight(Right::REVIEWSPAM))) {
             return true;
         }
     }
     return false;
 }
 /**
  * Class handler.
  *
  * @param array $args array of arguments
  *
  * @return nothing
  */
 function handle($args)
 {
     parent::handle($args);
     $nickname = common_canonical_nickname($this->arg('nickname'));
     $user = User::getKV('nickname', $nickname);
     if (!$user) {
         // TRANS: Client error displayed trying to make a micro summary without providing a valid user.
         $this->clientError(_('No such user.'), 404);
     }
     $notice = $user->getCurrentNotice();
     if (!$notice) {
         // TRANS: Client error displayed trying to make a micro summary without providing a status.
         $this->clientError(_('No current status.'), 404);
     }
     header('Content-Type: text/plain');
     print $user->nickname . ': ' . $notice->content;
 }
Beispiel #24
0
 function prepare($args)
 {
     parent::prepare($args);
     $nickname = $this->trimmed('nickname');
     $this->user = User::getKV('nickname', $nickname);
     $this->tag = $this->trimmed('tag');
     if (!$this->user) {
         // TRANS: Client error displayed when user not found for an action.
         $this->clientError(_('No such user.'));
     }
     if (!empty($this->tag)) {
         $this->notices = $this->getTaggedNotices();
     } else {
         $this->notices = $this->getNotices();
     }
     return true;
 }
Beispiel #25
0
 function prepare($args)
 {
     parent::prepare($args);
     if (common_config('singleuser', 'enabled')) {
         $tagger_arg = User::singleUserNickname();
     } else {
         $tagger_arg = $this->arg('tagger');
     }
     $tag_arg = $this->arg('tag');
     $tagger = common_canonical_nickname($tagger_arg);
     $tag = common_canonical_tag($tag_arg);
     // Permanent redirect on non-canonical nickname
     if ($tagger_arg != $tagger || $tag_arg != $tag) {
         $args = array('tagger' => $nickname, 'tag' => $tag);
         if ($this->page != 1) {
             $args['page'] = $this->page;
         }
         common_redirect(common_local_url('showprofiletag', $args), 301);
     }
     if (!$tagger) {
         // TRANS: Client error displayed when a tagger is expected but not provided.
         $this->clientError(_('No tagger.'), 404);
     }
     $user = User::getKV('nickname', $tagger);
     if (!$user) {
         // TRANS: Client error displayed trying to perform an action related to a non-existing user.
         $this->clientError(_('No such user.'), 404);
     }
     $this->tagger = $user->getProfile();
     $this->peopletag = Profile_list::pkeyGet(array('tagger' => $user->id, 'tag' => $tag));
     $current = common_current_user();
     $can_see = !empty($this->peopletag) && (!$this->peopletag->private || $this->peopletag->private && $this->peopletag->tagger === $current->id);
     if (!$can_see) {
         // TRANS: Client error displayed trying to reference a non-existing list.
         $this->clientError(_('No such list.'), 404);
     }
     $this->page = $this->arg('page') ? $this->arg('page') + 0 : 1;
     $this->userProfile = Profile::current();
     $stream = new PeopletagNoticeStream($this->peopletag, $this->userProfile);
     $this->notice = $stream->getNotices(($this->page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
     if ($this->page > 1 && $this->notice->N == 0) {
         // TRANS: Client error when page not found (404).
         $this->clientError(_('No such page.'), 404);
     }
     return true;
 }
Beispiel #26
0
 /**
  * Take arguments for running
  *
  * @param array $args $_REQUEST args
  *
  * @return boolean success flag
  *
  */
 protected function prepare(array $args = array())
 {
     parent::prepare($args);
     $email = $this->arg('email');
     // XXX: email field deprecated in Twitter's API
     if (!empty($email)) {
         $user = User::getKV('email', $email);
     } else {
         $user = $this->getTargetUser($this->arg('id'));
     }
     if (!$user instanceof User) {
         // TRANS: Client error displayed when requesting user information for a non-existing user.
         $this->clientError(_('User not found.'), 404);
     }
     $this->target = $user->getProfile();
     return true;
 }
 public function handle($user)
 {
     if (!$user instanceof User) {
         common_log(LOG_ERR, "Got a bogus user, not deleting");
         return true;
     }
     $user = User::getKV('id', $user->id);
     if (!$user) {
         common_log(LOG_INFO, "User {$user->nickname} was deleted before we got here.");
         return true;
     }
     try {
         if (!$user->hasRole(Profile_role::DELETED)) {
             common_log(LOG_INFO, "User {$user->nickname} is not pending deletion; aborting.");
             return true;
         }
     } catch (UserNoProfileException $unp) {
         common_log(LOG_INFO, "Deleting user {$user->nickname} with no profile... probably a good idea!");
     }
     $notice = $this->getNextBatch($user);
     if ($notice->N) {
         common_log(LOG_INFO, "Deleting next {$notice->N} notices by {$user->nickname}");
         while ($notice->fetch()) {
             $del = clone $notice;
             $del->delete();
         }
         // @todo improve reliability in case we died during the above deletions
         // with a fatal error. If the job is lost, we should perform some kind
         // of garbage collection later.
         // Queue up the next batch.
         $qm = QueueManager::get();
         $qm->enqueue($user, 'deluser');
     } else {
         // Out of notices? Let's finish deleting this profile!
         try {
             $user->getProfile()->delete();
         } catch (UserNoProfileException $e) {
             // in case a profile didn't exist for some reason, just delete the User directly
             $user->delete();
         }
         common_log(LOG_INFO, "User {$user->id} {$user->nickname} deleted.");
         return true;
     }
     return true;
 }
 function onStartRegistrationFormData($action)
 {
     // TRANS: User instructions after registration.
     $instr = _m('Note you will initially be "sandboxed" so your posts will not appear in the public timeline.');
     if (isset($this->contact)) {
         $contactuser = User::getKV('nickname', $this->contact);
         if ($contactuser instanceof User) {
             $contactlink = sprintf('@<a href="%s">%s</a>', htmlspecialchars($contactuser->getProfile()->getUrl()), htmlspecialchars($contactuser->getProfile()->getNickname()));
             // TRANS: User instructions after registration.
             // TRANS: %s is a clickable OStatus profile URL.
             $instr = sprintf(_m('Note you will initially be "sandboxed" so your posts will not appear in the public timeline. ' . 'Send a message to %s to speed up the unsandboxing process.'), $contactlink);
         }
     }
     $output = common_markup_to_html($instr);
     $action->elementStart('div', 'instructions');
     $action->raw($output);
     $action->elementEnd('div');
 }
Beispiel #29
0
 function prepare($args)
 {
     parent::prepare($args);
     if (common_is_real_login()) {
         // TRANS: Client error displayed trying to use "one time password login" when already logged in.
         $this->clientError(_('Already logged in.'));
     }
     $id = $this->trimmed('user_id');
     if (empty($id)) {
         // TRANS: Client error displayed trying to use "one time password login" without specifying a user.
         $this->clientError(_('No user ID specified.'));
     }
     $this->user = User::getKV('id', $id);
     if (empty($this->user)) {
         // TRANS: Client error displayed trying to use "one time password login" without using an existing user.
         $this->clientError(_('No such user.'));
     }
     $this->token = $this->trimmed('token');
     if (empty($this->token)) {
         // TRANS: Client error displayed trying to use "one time password login" without specifying a login token.
         $this->clientError(_('No login token specified.'));
     }
     $this->lt = Login_token::getKV('user_id', $id);
     if (empty($this->lt)) {
         // TRANS: Client error displayed trying to use "one time password login" without requesting a login token.
         $this->clientError(_('No login token requested.'));
     }
     if ($this->lt->token != $this->token) {
         // TRANS: Client error displayed trying to use "one time password login" while specifying an invalid login token.
         $this->clientError(_('Invalid login token specified.'));
     }
     if ($this->lt->modified > time() + Login_token::TIMEOUT) {
         //token has expired
         //delete the token as it is useless
         $this->lt->delete();
         $this->lt = null;
         // TRANS: Client error displayed trying to use "one time password login" while specifying an expired login token.
         $this->clientError(_('Login token expired.'));
     }
     $this->rememberme = $this->boolean('rememberme');
     $this->returnto = $this->trimmed('returnto');
     return true;
 }
Beispiel #30
0
 /**
  * Take arguments for running
  *
  * @param array $args $_REQUEST args
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     if (!parent::prepare($args)) {
         return false;
     }
     $cur = common_current_user();
     assert(!empty($cur));
     // checked by parent
     if (!$cur->hasRight(Right::DELETEUSER)) {
         // TRANS: Client error displayed when trying to delete a user without having the right to delete users.
         $this->clientError(_('You cannot delete users.'));
     }
     $this->user = User::getKV('id', $this->profile->id);
     if (empty($this->user)) {
         // TRANS: Client error displayed when trying to delete a non-local user.
         $this->clientError(_('You can only delete local users.'));
     }
     return true;
 }