当前位置: 首页>>代码示例>>PHP>>正文


PHP Profile::getByID方法代码示例

本文整理汇总了PHP中Profile::getByID方法的典型用法代码示例。如果您正苦于以下问题:PHP Profile::getByID方法的具体用法?PHP Profile::getByID怎么用?PHP Profile::getByID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Profile的用法示例。


在下文中一共展示了Profile::getByID方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: join

 /**
  * Method to add a user to a group.
  * In most cases, you should call Profile->joinGroup() instead.
  *
  * @param integer $group_id   Group to add to
  * @param integer $profile_id Profile being added
  * 
  * @return Group_member new membership object
  */
 static function join($group_id, $profile_id)
 {
     $member = new Group_member();
     $member->group_id = $group_id;
     $member->profile_id = $profile_id;
     $member->created = common_sql_now();
     $member->uri = self::newUri(Profile::getByID($profile_id), User_group::getByID($group_id), $member->created);
     $result = $member->insert();
     if (!$result) {
         common_log_db_error($member, 'INSERT', __FILE__);
         // TRANS: Exception thrown when joining a group fails.
         throw new Exception(_("Group join failed."));
     }
     return $member;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:24,代码来源:Group_member.php

示例2: doPreparation

 protected function doPreparation()
 {
     // accessing by ID just requires an ID, not a nickname
     $this->target = Profile::getByID($this->trimmed('id'));
     // For local users when accessed by id number, redirect with
     // the nickname as argument instead of id.
     if ($this->target->isLocal()) {
         // Support redirecting to FOAF rdf/xml if the agent prefers it...
         // Internet Explorer doesn't specify "text/html" and does list "*/*"
         // at least through version 8. We need to list text/html up front to
         // ensure that only user-agents who specifically ask for RDF get it.
         $page_prefs = 'text/html,application/xhtml+xml,application/rdf+xml,application/xml;q=0.3,text/xml;q=0.2';
         $httpaccept = isset($_SERVER['HTTP_ACCEPT']) ? $_SERVER['HTTP_ACCEPT'] : null;
         $type = common_negotiate_type(common_accept_to_prefs($httpaccept), common_accept_to_prefs($page_prefs));
         $page = $type === 'application/rdf+xml' ? 'foaf' : 'showstream';
         $url = common_local_url($page, array('nickname' => $this->target->getNickname()));
         common_redirect($url, 303);
     }
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:19,代码来源:userbyid.php

示例3: common_find_mentions

/**
 * Find @-mentions in the given text, using the given notice object as context.
 * References will be resolved with common_relative_profile() against the user
 * who posted the notice.
 *
 * Note the return data format is internal, to be used for building links and
 * such. Should not be used directly; rather, call common_linkify_mentions().
 *
 * @param string    $text
 * @param Profile   $sender the Profile that is sending the current text
 * @param Notice    $parent the Notice this text is in reply to, if any
 *
 * @return array
 *
 * @access private
 */
function common_find_mentions($text, Profile $sender, Notice $parent = null)
{
    $mentions = array();
    if (Event::handle('StartFindMentions', array($sender, $text, &$mentions))) {
        // Get the context of the original notice, if any
        $origMentions = array();
        // Does it have a parent notice for context?
        if ($parent instanceof Notice) {
            $ids = $parent->getReplies();
            // replied-to _profile ids_
            foreach ($ids as $id) {
                try {
                    $repliedTo = Profile::getByID($id);
                    $origMentions[$repliedTo->getNickname()] = $repliedTo;
                } catch (NoResultException $e) {
                    // continue foreach
                }
            }
        }
        $matches = common_find_mentions_raw($text);
        foreach ($matches as $match) {
            try {
                $nickname = Nickname::normalize($match[0]);
            } catch (NicknameException $e) {
                // Bogus match? Drop it.
                continue;
            }
            // Try to get a profile for this nickname.
            // Start with conversation context, then go to
            // sender context.
            if ($parent instanceof Notice && $parent->getProfile()->getNickname() === $nickname) {
                $mentioned = $parent->getProfile();
            } else {
                if (!empty($origMentions) && array_key_exists($nickname, $origMentions)) {
                    $mentioned = $origMentions[$nickname];
                } else {
                    // sets to null if no match
                    $mentioned = common_relative_profile($sender, $nickname);
                }
            }
            if ($mentioned instanceof Profile) {
                $user = User::getKV('id', $mentioned->id);
                try {
                    $url = $mentioned->getUrl();
                } catch (InvalidUrlException $e) {
                    $url = common_local_url('userbyid', array('id' => $mentioned->getID()));
                }
                $mention = array('mentioned' => array($mentioned), 'type' => 'mention', 'text' => $match[0], 'position' => $match[1], 'length' => mb_strlen($match[0]), 'title' => $mentioned->getFullname(), 'url' => $url);
                $mentions[] = $mention;
            }
        }
        // @#tag => mention of all subscriptions tagged 'tag'
        preg_match_all('/(?:^|[\\s\\.\\,\\:\\;]+)@#([\\pL\\pN_\\-\\.]{1,64})/', $text, $hmatches, PREG_OFFSET_CAPTURE);
        foreach ($hmatches[1] as $hmatch) {
            $tag = common_canonical_tag($hmatch[0]);
            $plist = Profile_list::getByTaggerAndTag($sender->getID(), $tag);
            if (!$plist instanceof Profile_list || $plist->private) {
                continue;
            }
            $tagged = $sender->getTaggedSubscribers($tag);
            $url = common_local_url('showprofiletag', array('nickname' => $sender->getNickname(), 'tag' => $tag));
            $mentions[] = array('mentioned' => $tagged, 'type' => 'list', 'text' => $hmatch[0], 'position' => $hmatch[1], 'length' => mb_strlen($hmatch[0]), 'url' => $url);
        }
        preg_match_all('/(?:^|[\\s\\.\\,\\:\\;]+)!(' . Nickname::DISPLAY_FMT . ')/', $text, $hmatches, PREG_OFFSET_CAPTURE);
        foreach ($hmatches[1] as $hmatch) {
            $nickname = Nickname::normalize($hmatch[0]);
            $group = User_group::getForNickname($nickname, $sender);
            if (!$group instanceof User_group || !$sender->isMember($group)) {
                continue;
            }
            $profile = $group->getProfile();
            $mentions[] = array('mentioned' => array($profile), 'type' => 'group', 'text' => $hmatch[0], 'position' => $hmatch[1], 'length' => mb_strlen($hmatch[0]), 'url' => $group->permalink(), 'title' => $group->getFancyName());
        }
        Event::handle('EndFindMentions', array($sender, $text, &$mentions));
    }
    return $mentions;
}
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:93,代码来源:util.php

示例4: getTagger

 /**
  * get the tagger of this profile_list object
  *
  * @return Profile the tagger
  */
 function getTagger()
 {
     return Profile::getByID($this->tagger);
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:9,代码来源:Profile_list.php

示例5: getProfile

 function getProfile()
 {
     return Profile::getByID($this->user_id);
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:4,代码来源:Foreign_link.php

示例6: showFeedForm

 function showFeedForm(SubMirror $mirror)
 {
     $profile = Profile::getByID($mirror->subscribed);
     $form = new EditMirrorForm($this, $profile);
     $form->show();
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:6,代码来源:mirrorsettings.php

示例7: onEndShowSections

 function onEndShowSections(Action $action)
 {
     if (!$action instanceof ShowstreamAction) {
         // early return for actions we're not interested in
         return true;
     }
     $scoped = $action->getScoped();
     if (!$scoped instanceof Profile || !$scoped->hasRight(self::VIEWMODLOG)) {
         // only continue if we are allowed to VIEWMODLOG
         return true;
     }
     $profile = $action->getTarget();
     $ml = new ModLog();
     $ml->profile_id = $profile->getID();
     $ml->orderBy("created");
     $cnt = $ml->find();
     if ($cnt > 0) {
         $action->elementStart('div', array('id' => 'entity_mod_log', 'class' => 'section'));
         $action->element('h2', null, _('Moderation'));
         $action->elementStart('table');
         while ($ml->fetch()) {
             $action->elementStart('tr');
             $action->element('td', null, strftime('%y-%m-%d', strtotime($ml->created)));
             $action->element('td', null, sprintf($ml->is_grant ? _('+%s') : _('-%s'), $ml->role));
             $action->elementStart('td');
             if ($ml->moderator_id) {
                 $mod = Profile::getByID($ml->moderator_id);
                 if (empty($mod)) {
                     $action->text(_('[unknown]'));
                 } else {
                     $action->element('a', array('href' => $mod->getUrl(), 'title' => $mod->getFullname()), $mod->getNickname());
                 }
             } else {
                 $action->text(_('[unknown]'));
             }
             $action->elementEnd('td');
             $action->elementEnd('tr');
         }
         $action->elementEnd('table');
         $action->elementEnd('div');
     }
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:42,代码来源:ModLogPlugin.php

示例8: initGroupMemberURI

function initGroupMemberURI()
{
    printfnq("Ensuring all group memberships have a URI...");
    $mem = new Group_member();
    $mem->whereAdd('uri IS NULL');
    if ($mem->find()) {
        while ($mem->fetch()) {
            try {
                $mem->decache();
                $mem->query(sprintf('update group_member set uri = "%s" ' . 'where profile_id = %d ' . 'and group_id = %d ', Group_member::newUri(Profile::getByID($mem->profile_id), User_group::getByID($mem->group_id), $mem->created), $mem->profile_id, $mem->group_id));
            } catch (Exception $e) {
                common_log(LOG_ERR, "Error updated membership URI: " . $e->getMessage());
            }
        }
    }
    printfnq("DONE.\n");
}
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:17,代码来源:upgrade.php

示例9: setTag

 static function setTag($tagger, $tagged, $tag, $desc = null, $private = false)
 {
     $ptag = Profile_tag::pkeyGet(array('tagger' => $tagger, 'tagged' => $tagged, 'tag' => $tag));
     # if tag already exists, return it
     if ($ptag instanceof Profile_tag) {
         return $ptag;
     }
     $tagger_profile = Profile::getByID($tagger);
     $tagged_profile = Profile::getByID($tagged);
     if (Event::handle('StartTagProfile', array($tagger_profile, $tagged_profile, $tag))) {
         if (!$tagger_profile->canTag($tagged_profile)) {
             // TRANS: Client exception thrown trying to set a tag for a user that cannot be tagged.
             throw new ClientException(_('You cannot tag this user.'));
         }
         $tags = new Profile_list();
         $tags->tagger = $tagger;
         $count = (int) $tags->count('distinct tag');
         if ($count >= common_config('peopletag', 'maxtags')) {
             // TRANS: Client exception thrown trying to set more tags than allowed.
             throw new ClientException(sprintf(_('You already have created %d or more tags ' . 'which is the maximum allowed number of tags. ' . 'Try using or deleting some existing tags.'), common_config('peopletag', 'maxtags')));
         }
         $plist = new Profile_list();
         $plist->query('BEGIN');
         $profile_list = Profile_list::ensureTag($tagger, $tag, $desc, $private);
         if ($profile_list->taggedCount() >= common_config('peopletag', 'maxpeople')) {
             // TRANS: Client exception thrown when trying to add more people than allowed to a list.
             throw new ClientException(sprintf(_('You already have %1$d or more people in list %2$s, ' . 'which is the maximum allowed number. ' . 'Try unlisting others first.'), common_config('peopletag', 'maxpeople'), $tag));
         }
         $newtag = new Profile_tag();
         $newtag->tagger = $tagger;
         $newtag->tagged = $tagged;
         $newtag->tag = $tag;
         $result = $newtag->insert();
         if (!$result) {
             common_log_db_error($newtag, 'INSERT', __FILE__);
             $plist->query('ROLLBACK');
             return false;
         }
         try {
             $plist->query('COMMIT');
             Event::handle('EndTagProfile', array($newtag));
         } catch (Exception $e) {
             $newtag->delete();
             $profile_list->delete();
             throw $e;
         }
         $profile_list->taggedCount(true);
         self::blowCaches($tagger, $tagged);
     }
     return $newtag;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:51,代码来源:Profile_tag.php

示例10: getSubscribed

 public function getSubscribed()
 {
     return Profile::getByID($this->subscribed);
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:4,代码来源:Subscription.php

示例11: getActor

 public function getActor()
 {
     return Profile::getByID($this->profile_id);
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:4,代码来源:Deleted_notice.php


注:本文中的Profile::getByID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。