Example #1
0
 function prepare($args)
 {
     parent::prepare($args);
     $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($this->trimmed('action'), $args), 301);
         return false;
     }
     $this->user = User::staticGet('nickname', $nickname);
     if (!$this->user) {
         $this->clientError(_('No such user.'), 404);
         return false;
     }
     $this->profile = $this->user->getProfile();
     if (!$this->profile) {
         $this->serverError(_('User has no profile.'));
         return false;
     }
     $this->tag = $this->trimmed('tag');
     $this->page = $this->arg('page') ? $this->arg('page') + 0 : 1;
     common_set_returnto($this->selfUrl());
     return true;
 }
Example #2
0
 function prepare($args)
 {
     parent::prepare($args);
     $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($this->trimmed('action'), $args), 301);
         return false;
     }
     $this->user = User::staticGet('nickname', $nickname);
     if (!$this->user) {
         $this->clientError(_m('No such user.'), 404);
         return false;
     }
     $this->profile = $this->user->getProfile();
     if (!$this->profile) {
         $this->serverError(_m('User has no profile.'));
         return false;
     }
     $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;
 }
Example #3
0
 function prepare($args)
 {
     parent::prepare($args);
     $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($this->trimmed('action'), $args), 301);
         return false;
     }
     $this->user = User::staticGet('nickname', $nickname);
     if (!$this->user) {
         // TRANS: Client error displayed when calling a profile action without specifying a user.
         $this->clientError(_('No such user.'), 404);
         return false;
     }
     $this->profile = $this->user->getProfile();
     if (!$this->profile) {
         // TRANS: Server error displayed when calling a profile action while the specified user does not have a profile.
         $this->serverError(_('User has no profile.'));
         return false;
     }
     $this->tag = $this->trimmed('tag');
     $this->page = $this->arg('page') ? $this->arg('page') + 0 : 1;
     common_set_returnto($this->selfUrl());
     return true;
 }
Example #4
0
 function prepare($args)
 {
     parent::prepare($args);
     // FIXME very similar code below
     $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($this->trimmed('action'), $args), 301);
         return false;
     }
     $this->user = User::staticGet('nickname', $nickname);
     if (!$this->user) {
         $this->clientError(_('用户不存在'), 404);
         return false;
     }
     $this->profile = $this->user->getProfile();
     if (!$this->profile) {
         $this->serverError(_('无该用户资料'));
         return false;
     }
     $this->page = $this->arg('page') ? $this->arg('page') + 0 : 1;
     $this->tag = $this->trimmed('tag');
     $this->q = $this->trimmed('q');
     return true;
 }
 /**
  * Prepare to run
  */
 function prepare($args)
 {
     parent::prepare($args);
     if (!common_logged_in()) {
         $this->clientError(_('You must be logged in to register an application.'));
         return false;
     }
     return true;
 }
 /**
  * Prepare to run
  */
 function prepare($args)
 {
     parent::prepare($args);
     if (!common_logged_in()) {
         // TRANS: Client error displayed trying to add a new application while not logged in.
         $this->clientError(_('You must be logged in to register an application.'));
         return false;
     }
     return true;
 }
 /**
  * Prepare to run
  */
 function prepare($args)
 {
     parent::prepare($args);
     if (!common_logged_in()) {
         $this->clientError(_('You must be logged in to edit an application.'));
         return false;
     }
     $id = (int) $this->arg('id');
     $this->app = Oauth_application::staticGet($id);
     $this->owner = User::staticGet($this->app->owner);
     $cur = common_current_user();
     if ($cur->id != $this->owner->id) {
         $this->clientError(_('You are not the owner of this application.'), 401);
     }
     if (!$this->app) {
         $this->clientError(_('No such application.'));
         return false;
     }
     return true;
 }
Example #8
0
 function prepare($args)
 {
     OwnerDesignAction::prepare($args);
     $this->id = $this->trimmed('id');
     $this->vid = Video::getKV('id', $this->id);
     if (empty($this->vid)) {
         throw new ClientException(_('No such video.'), 404);
     }
     $this->notice = $this->vid->getNotice();
     if (empty($this->notice)) {
         throw new ClientException(_('No such video'), 404);
     }
     $this->user = User::getKV('id', $this->vid->profile_id);
     if (empty($this->user)) {
         throw new ClientException(_('No such user.'), 404);
     }
     $this->profile = $this->user->getProfile();
     if (empty($this->profile)) {
         throw new ServerException(_('User without a profile.'));
     }
     return true;
 }
Example #9
0
 /**
  * Prepare the object
  *
  * Check the input values and initialize the object.
  * Shows an error page on bad input.
  *
  * @param array $args $_REQUEST data
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     parent::prepare($args);
     $nickname = common_canonical_nickname($this->arg('nickname'));
     $this->user = User::staticGet('nickname', $nickname);
     if (!$this->user) {
         $this->clientError(_('No such user.'));
         return false;
     }
     $profile = $this->user->getProfile();
     if (!$profile) {
         $this->serverError(_('User has no profile.'));
         return false;
     }
     $this->page = $this->arg('page') ? $this->arg('page') + 0 : 1;
     common_set_returnto($this->selfUrl());
     $this->notice = $this->user->getReplies(($this->page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
     if ($this->page > 1 && $this->notice->N == 0) {
         // TRANS: Server error when page not found (404)
         $this->serverError(_('No such page.'), $code = 404);
     }
     return true;
 }
 /**
  * Prepare to run
  */
 function prepare($args)
 {
     parent::prepare($args);
     if (!common_logged_in()) {
         // TRANS: Client error displayed trying to edit an application while not logged in.
         $this->clientError(_('You must be logged in to edit an application.'));
         return false;
     }
     $id = (int) $this->arg('id');
     $this->app = Oauth_application::staticGet($id);
     $this->owner = User::staticGet($this->app->owner);
     $cur = common_current_user();
     if ($cur->id != $this->owner->id) {
         // TRANS: Client error displayed trying to edit an application while not being its owner.
         $this->clientError(_('You are not the owner of this application.'), 401);
     }
     if (!$this->app) {
         // TRANS: Client error displayed trying to edit an application that does not exist.
         $this->clientError(_('No such application.'));
         return false;
     }
     return true;
 }
 function prepare($args)
 {
     OwnerDesignAction::prepare($args);
     // skip the ProfileAction code and replace it...
     $id = $this->arg('id');
     $this->user = false;
     $this->profile = Profile::staticGet('id', $id);
     if (!$this->profile) {
         $this->serverError(_('User has no profile.'));
         return false;
     }
     $user = User::staticGet('id', $this->profile->id);
     if ($user) {
         // This is a local user -- send to their regular profile.
         $url = common_local_url('showstream', array('nickname' => $user->nickname));
         common_redirect($url);
         return false;
     }
     $this->tag = $this->trimmed('tag');
     $this->page = $this->arg('page') ? $this->arg('page') + 0 : 1;
     common_set_returnto($this->selfUrl());
     return true;
 }
Example #12
0
 /**
  * Load attributes based on database arguments
  *
  * Loads all the DB stuff
  *
  * @param array $args $_REQUEST array
  *
  * @return success flag
  */
 function prepare($args)
 {
     parent::prepare($args);
     $id = $this->arg('notice');
     $this->notice = Notice::staticGet($id);
     if (empty($this->notice)) {
         // Did we used to have it, and it got deleted?
         $deleted = Deleted_notice::staticGet($id);
         if (!empty($deleted)) {
             $this->clientError(_('Notice deleted.'), 410);
         } else {
             $this->clientError(_('No such notice.'), 404);
         }
         return false;
     }
     $this->profile = $this->notice->getProfile();
     if (empty($this->profile)) {
         $this->serverError(_('Notice has no profile.'), 500);
         return false;
     }
     $this->user = User::staticGet('id', $this->profile->id);
     $this->avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE);
     return true;
 }
Example #13
0
 /**
  * For initializing members of the class.
  *
  * @param array $argarray misc. arguments
  *
  * @return boolean true
  */
 function prepare($argarray)
 {
     OwnerDesignAction::prepare($argarray);
     $this->id = $this->trimmed('id');
     $this->bookmark = Bookmark::staticGet('id', $this->id);
     if (empty($this->bookmark)) {
         throw new ClientException(_('No such bookmark.'), 404);
     }
     $this->notice = Notice::staticGet('uri', $this->bookmark->uri);
     if (empty($this->notice)) {
         // Did we used to have it, and it got deleted?
         throw new ClientException(_('No such bookmark.'), 404);
     }
     $this->user = User::staticGet('id', $this->bookmark->profile_id);
     if (empty($this->user)) {
         throw new ClientException(_('No such user.'), 404);
     }
     $this->profile = $this->user->getProfile();
     if (empty($this->profile)) {
         throw new ServerException(_('User without a profile.'));
     }
     $this->avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE);
     return true;
 }
Example #14
0
 /**
  * Prepare the object
  *
  * Check the input values and initialize the object.
  * Shows an error page on bad input.
  *
  * @param array $args $_REQUEST data
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     parent::prepare($args);
     $nickname = common_canonical_nickname($this->arg('nickname'));
     $this->user = User::staticGet('nickname', $nickname);
     if (!$this->user) {
         $this->clientError(_('用户不存在'));
         return false;
     }
     $this->page = $this->trimmed('page');
     if (!$this->page) {
         $this->page = 1;
     }
     common_set_returnto($this->selfUrl());
     $cur = common_current_user();
     if (!empty($cur) && $cur->id == $this->user->id) {
         // Show imported/gateway notices as well as local if
         // the user is looking at his own favorites
         $this->notice = $this->user->favoriteNotices(($this->page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1, true);
     } else {
         $this->notice = $this->user->favoriteNotices(($this->page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1, false);
     }
     if (empty($this->notice)) {
         $this->serverError(_('Could not retrieve favorite notices.'));
         return;
     }
     if ($this->page > 1 && $this->notice->N == 0) {
         // TRANS: Server error when page not found (404)
         $this->serverError(_('您访问的网页不存在'), $code = 404);
     }
     return true;
 }
Example #15
0
 /**
  * Prepare the object
  *
  * Check the input values and initialize the object.
  * Shows an error page on bad input.
  *
  * @param array $args $_REQUEST data
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     parent::prepare($args);
     $nickname = common_canonical_nickname($this->arg('nickname'));
     $this->user = User::staticGet('nickname', $nickname);
     if (!$this->user) {
         // TRANS: Client error displayed when trying to display favourite notices for a non-existing user.
         $this->clientError(_('No such user.'));
         return false;
     }
     $this->page = $this->trimmed('page');
     if (!$this->page) {
         $this->page = 1;
     }
     common_set_returnto($this->selfUrl());
     $cur = common_current_user();
     if (!empty($cur) && $cur->id == $this->user->id) {
         // Show imported/gateway notices as well as local if
         // the user is looking at their own favorites
         $this->notice = $this->user->favoriteNotices(true, ($this->page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
     } else {
         $this->notice = $this->user->favoriteNotices(false, ($this->page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
     }
     if (empty($this->notice)) {
         // TRANS: Server error displayed when favourite notices could not be retrieved from the database.
         $this->serverError(_('Could not retrieve favorite notices.'));
         return;
     }
     if ($this->page > 1 && $this->notice->N == 0) {
         // TRANS: Server error when page not found (404)
         $this->serverError(_('No such page.'), $code = 404);
     }
     return true;
 }