コード例 #1
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('tagger');
     $tag = $this->action->trimmed('tag');
     if ($nickname) {
         $user = User::staticGet('nickname', $nickname);
         $user_profile = $user->getProfile();
         if ($tag) {
             $tag = Profile_list::pkeyGet(array('tagger' => $user->id, 'tag' => $tag));
         } else {
             $tag = false;
         }
     } else {
         $user_profile = false;
     }
     $this->out->elementStart('ul', array('class' => 'nav'));
     if (Event::handle('StartPeopletagGroupNav', array($this))) {
         // People tag timeline
         $this->out->menuItem(common_local_url('showprofiletag', array('tagger' => $user_profile->nickname, 'tag' => $tag->tag)), _m('MENU', 'List'), sprintf(_('%1$s list by %2$s.'), $tag->tag, $user_profile && $user_profile->fullname ? $user_profile->fullname : $nickname), $action == 'showprofiletag', 'nav_timeline_peopletag');
         // Tagged
         $this->out->menuItem(common_local_url('peopletagged', array('tagger' => $user->nickname, 'tag' => $tag->tag)), _m('MENU', 'Listed'), sprintf(_('%1$s list by %2$s.'), $tag->tag, $user_profile && $user_profile->fullname ? $user_profile->fullname : $nickname), $action == 'peopletagged', 'nav_peopletag_tagged');
         // Subscribers
         $this->out->menuItem(common_local_url('peopletagsubscribers', array('tagger' => $user->nickname, 'tag' => $tag->tag)), _m('MENU', 'Subscribers'), sprintf(_('Subscribers to %1$s list by %2$s.'), $tag->tag, $user_profile && $user_profile->fullname ? $user_profile->fullname : $nickname), $action == 'peopletagsubscribers', 'nav_peopletag_subscribers');
         $cur = common_current_user();
         if (!empty($cur) && $user_profile->id == $cur->id) {
             // Edit
             $this->out->menuItem(common_local_url('editpeopletag', array('tagger' => $user->nickname, 'tag' => $tag->tag)), _m('MENU', 'Edit'), sprintf(_('Edit %s list by you.'), $tag->tag, $user_profile && $user_profile->fullname ? $user_profile->fullname : $nickname), $action == 'editpeopletag', 'nav_peopletag_edit');
         }
         Event::handle('EndPeopletagGroupNav', array($this));
     }
     $this->out->elementEnd('ul');
 }
コード例 #2
0
ファイル: showprofiletag.php プロジェクト: Grasia/bolotweet
 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);
         return false;
     }
     if (!$tagger) {
         // TRANS: Client error displayed when a tagger is expected but not provided.
         $this->clientError(_('No tagger.'), 404);
         return false;
     }
     $user = User::staticGet('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);
         return false;
     }
     $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);
         return false;
     }
     $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: Server error when page not found (404).
         $this->serverError(_('No such page.'), $code = 404);
     }
     return true;
 }
コード例 #3
0
 function prepare($args)
 {
     parent::prepare($args);
     $this->page = $this->arg('page') ? $this->arg('page') + 0 : 1;
     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('peopletagged', $args), 301);
         return false;
     }
     if (!$tagger) {
         // TRANS: Client error displayed when a tagger is expected but not provided.
         $this->clientError(_('No tagger.'), 404);
         return false;
     }
     $user = User::staticGet('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);
         return false;
     }
     $this->tagger = $user->getProfile();
     $this->peopletag = Profile_list::pkeyGet(array('tagger' => $user->id, 'tag' => $tag));
     if (!$this->peopletag) {
         // TRANS: Client error displayed trying to reference a non-existing list.
         $this->clientError(_('No such list.'), 404);
         return false;
     }
     return true;
 }
コード例 #4
0
 static function unTag($tagger, $tagged, $tag)
 {
     $ptag = Profile_tag::pkeyGet(array('tagger' => $tagger, 'tagged' => $tagged, 'tag' => $tag));
     if (!$ptag) {
         return true;
     }
     if (Event::handle('StartUntagProfile', array($ptag))) {
         $orig = clone $ptag;
         $result = $ptag->delete();
         if (!$result) {
             common_log_db_error($this, 'DELETE', __FILE__);
             return false;
         }
         Event::handle('EndUntagProfile', array($orig));
         if ($result) {
             $profile_list = Profile_list::pkeyGet(array('tag' => $tag, 'tagger' => $tagger));
             if (!empty($profile_list)) {
                 $profile_list->taggedCount(true);
             }
             self::blowCaches($tagger, $tagged);
             return true;
         }
         return false;
     }
 }
コード例 #5
0
 function tagExists($tag)
 {
     $args = array('tagger' => $this->tagger->id, 'tag' => $tag);
     $ptag = Profile_list::pkeyGet($args);
     return !empty($ptag);
 }
コード例 #6
0
 /**
  * get the Profile_list object by the
  * given tagger and with given tag
  *
  * @param integer $tagger   the id of the creator profile
  * @param integer $tag      the tag
  *
  * @return integer count
  */
 static function getByTaggerAndTag($tagger, $tag)
 {
     $ptag = Profile_list::pkeyGet(array('tagger' => $tagger, 'tag' => $tag));
     return $ptag;
 }