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


PHP Profile::insert方法代码示例

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


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

示例1: setUp

 /**
  * create dependent objects before running each test
  **/
 public final function setUp()
 {
     // run the default setUp() method first
     parent::setUp();
     // create and insert a Profile to own the test Tweet
     $this->profile = new Profile(null, "@phpunit", "test@phpunit.de", "+12125551212");
     $this->profile->insert($this->getPDO());
     // create the test Tweet
     $this->tweet = new Tweet(null, $this->profile->getProfileId(), "PHPUnit favorite test passing");
     $this->tweet->insert($this->getPDO());
     // calculate the date (just use the time the unit test was setup...)
     $this->VALID_FAVORITEDATE = new DateTime();
 }
开发者ID:jfindley2,项目名称:data-design,代码行数:16,代码来源:favorite-test.php

示例2: fromUrl

 public static function fromUrl($url, $depth = 0)
 {
     common_debug('MentionURL: trying to find a profile for ' . $url);
     $url = preg_replace('#https?://#', 'https://', $url);
     try {
         $profile = Profile::fromUri($url);
     } catch (UnknownUriException $ex) {
     }
     if (!$profile instanceof Profile) {
         $profile = self::findProfileByProfileURL($url);
     }
     $url = str_replace('https://', 'http://', $url);
     if (!$profile instanceof Profile) {
         try {
             $profile = Profile::fromUri($url);
         } catch (UnknownUriException $ex) {
         }
     }
     if (!$profile instanceof Profile) {
         $profile = self::findProfileByProfileURL($url);
     }
     if (!$profile instanceof Profile) {
         $hcard = mention_url_representative_hcard($url);
         if (!$hcard) {
             return null;
         }
         $mention_profile = new Mention_url_profile();
         $mention_profile->query('BEGIN');
         $profile = new Profile();
         $profile->profileurl = $hcard['url'][0];
         $profile->fullname = $hcard['name'][0];
         preg_match('/\\/([^\\/]+)\\/*$/', $profile->profileurl, $matches);
         if (!$hcard['nickname']) {
             $hcard['nickname'] = array($matches[1]);
         }
         $profile->nickname = $hcard['nickname'][0];
         $profile->created = common_sql_now();
         $mention_profile->profile_id = $profile->insert();
         if (!$mention_profile->profile_id) {
             $mention_profile->query('ROLLBACK');
             return null;
         }
         $mention_profile->profileurl = $profile->profileurl;
         if (!$mention_profile->insert()) {
             $mention_profile->query('ROLLBACK');
             if ($depth > 0) {
                 return null;
             } else {
                 return self::fromUrl($url, $depth + 1);
             }
         } else {
             $mention_profile->query('COMMIT');
         }
     }
     return $profile;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:56,代码来源:Mention_url_profile.php

示例3: createAnonProfile

 static function createAnonProfile()
 {
     // Get the anon user's IP, and turn it into a nickname
     list($proxy, $ip) = common_client_ip();
     // IP + time + random number should help to avoid collisions
     $baseNickname = $ip . '-' . time() . '-' . common_good_rand(5);
     $profile = new Profile();
     $profile->nickname = $baseNickname;
     $id = $profile->insert();
     if (!$id) {
         // TRANS: Server exception.
         throw new ServerException(_m("Could not create anonymous user session."));
     }
     // Stick the Profile ID into the nickname
     $orig = clone $profile;
     $profile->nickname = 'anon-' . $id . '-' . $baseNickname;
     $result = $profile->update($orig);
     if (!$result) {
         // TRANS: Server exception.
         throw new ServerException(_m("Could not create anonymous user session."));
     }
     common_log(LOG_INFO, "AnonymousFavePlugin - created profile for anonymous user from IP: " . $ip . ', nickname = ' . $profile->nickname);
     return $profile;
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:24,代码来源:AnonymousFavePlugin.php

示例4: register

 /**
  * Register a new user account and profile and set up default subscriptions.
  * If a new-user welcome message is configured, this will be sent.
  *
  * @param array $fields associative array of optional properties
  *              string 'bio'
  *              string 'email'
  *              bool 'email_confirmed' pass true to mark email as pre-confirmed
  *              string 'fullname'
  *              string 'homepage'
  *              string 'location' informal string description of geolocation
  *              float 'lat' decimal latitude for geolocation
  *              float 'lon' decimal longitude for geolocation
  *              int 'location_id' geoname identifier
  *              int 'location_ns' geoname namespace to interpret location_id
  *              string 'nickname' REQUIRED
  *              string 'password' (may be missing for eg OpenID registrations)
  *              string 'code' invite code
  *              ?string 'uri' permalink to notice; defaults to local notice URL
  * @return mixed User object or false on failure
  */
 static function register($fields)
 {
     // MAGICALLY put fields into current scope
     extract($fields);
     $profile = new Profile();
     if (!empty($email)) {
         $email = common_canonical_email($email);
     }
     $nickname = common_canonical_nickname($nickname);
     $profile->nickname = $nickname;
     if (!User::allowed_nickname($nickname)) {
         common_log(LOG_WARNING, sprintf("Attempted to register a nickname that is not allowed: %s", $profile->nickname), __FILE__);
         return false;
     }
     $profile->profileurl = common_profile_url($nickname);
     if (!empty($fullname)) {
         $profile->fullname = $fullname;
     }
     if (!empty($homepage)) {
         $profile->homepage = $homepage;
     }
     if (!empty($bio)) {
         $profile->bio = $bio;
     }
     if (!empty($location)) {
         $profile->location = $location;
         $loc = Location::fromName($location);
         if (!empty($loc)) {
             $profile->lat = $loc->lat;
             $profile->lon = $loc->lon;
             $profile->location_id = $loc->location_id;
             $profile->location_ns = $loc->location_ns;
         }
     }
     $profile->created = common_sql_now();
     $user = new User();
     $user->nickname = $nickname;
     // Users who respond to invite email have proven their ownership of that address
     if (!empty($code)) {
         $invite = Invitation::staticGet($code);
         if ($invite && $invite->address && $invite->address_type == 'email' && $invite->address == $email) {
             $user->email = $invite->address;
         }
     }
     if (isset($email_confirmed) && $email_confirmed) {
         $user->email = $email;
     }
     // This flag is ignored but still set to 1
     $user->inboxed = 1;
     // Set default-on options here, otherwise they'll be disabled
     // initially for sites using caching, since the initial encache
     // doesn't know about the defaults in the database.
     $user->emailnotifysub = 1;
     $user->emailnotifyfav = 1;
     $user->emailnotifynudge = 1;
     $user->emailnotifymsg = 1;
     $user->emailnotifyattn = 1;
     $user->emailmicroid = 1;
     $user->emailpost = 1;
     $user->jabbermicroid = 1;
     $user->viewdesigns = 1;
     $user->created = common_sql_now();
     if (Event::handle('StartUserRegister', array(&$user, &$profile))) {
         $profile->query('BEGIN');
         $id = $profile->insert();
         if (empty($id)) {
             common_log_db_error($profile, 'INSERT', __FILE__);
             return false;
         }
         $user->id = $id;
         if (!empty($uri)) {
             $user->uri = $uri;
         } else {
             $user->uri = common_user_uri($user);
         }
         if (!empty($password)) {
             // may not have a password for OpenID users
             $user->password = common_munge_password($password, $id);
         }
//.........这里部分代码省略.........
开发者ID:stevertiqo,项目名称:StatusNet,代码行数:101,代码来源:User.php

示例5: ensureProfile

 protected function ensureProfile($twuser)
 {
     // check to see if there's already a profile for this user
     $profileurl = 'https://twitter.com/' . $twuser->screen_name;
     try {
         $profile = $this->getProfileByUrl($twuser->screen_name, $profileurl);
         $this->updateAvatar($twuser, $profile);
         return $profile;
     } catch (NoResultException $e) {
         common_debug(__METHOD__ . ' - Adding profile and remote profile ' . "for Twitter user: {$profileurl}.");
     }
     $profile = new Profile();
     $profile->query("BEGIN");
     $profile->nickname = $twuser->screen_name;
     $profile->fullname = $twuser->name;
     $profile->homepage = $twuser->url;
     $profile->bio = $twuser->description;
     $profile->location = $twuser->location;
     $profile->profileurl = $profileurl;
     $profile->created = common_sql_now();
     try {
         $id = $profile->insert();
         // insert _should_ throw exception on failure
         if (empty($id)) {
             throw new Exception('Failed insert');
         }
     } catch (Exception $e) {
         common_log(LOG_WARNING, __METHOD__ . " Couldn't insert profile: " . $e->getMessage());
         common_log_db_error($profile, 'INSERT', __FILE__);
         $profile->query("ROLLBACK");
         return false;
     }
     $profile->query("COMMIT");
     $this->updateAvatar($twuser, $profile);
     return $profile;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:36,代码来源:twitterimport.php

示例6: register

 static function register($fields)
 {
     # MAGICALLY put fields into current scope
     extract($fields);
     $profile = new Profile();
     $profile->query('BEGIN');
     $profile->nickname = $nickname;
     $profile->profileurl = common_profile_url($nickname);
     if (!empty($fullname)) {
         $profile->fullname = $fullname;
     }
     if (!empty($homepage)) {
         $profile->homepage = $homepage;
     }
     if (!empty($bio)) {
         $profile->bio = $bio;
     }
     if (!empty($location)) {
         $profile->location = $location;
     }
     $profile->created = common_sql_now();
     $id = $profile->insert();
     if (empty($id)) {
         common_log_db_error($profile, 'INSERT', __FILE__);
         return false;
     }
     $user = new User();
     $user->id = $id;
     $user->nickname = $nickname;
     if (!empty($password)) {
         # may not have a password for OpenID users
         $user->password = common_munge_password($password, $id);
     }
     # Users who respond to invite email have proven their ownership of that address
     if (!empty($code)) {
         $invite = Invitation::staticGet($code);
         if ($invite && $invite->address && $invite->address_type == 'email' && $invite->address == $email) {
             $user->email = $invite->address;
         }
     }
     $inboxes = common_config('inboxes', 'enabled');
     if ($inboxes === true || $inboxes == 'transitional') {
         $user->inboxed = 1;
     }
     $user->created = common_sql_now();
     $user->uri = common_user_uri($user);
     $result = $user->insert();
     if (!$result) {
         common_log_db_error($user, 'INSERT', __FILE__);
         return false;
     }
     # Everyone is subscribed to themself
     $subscription = new Subscription();
     $subscription->subscriber = $user->id;
     $subscription->subscribed = $user->id;
     $subscription->created = $user->created;
     $result = $subscription->insert();
     if (!$result) {
         common_log_db_error($subscription, 'INSERT', __FILE__);
         return false;
     }
     if (!empty($email) && !$user->email) {
         $confirm = new Confirm_address();
         $confirm->code = common_confirmation_code(128);
         $confirm->user_id = $user->id;
         $confirm->address = $email;
         $confirm->address_type = 'email';
         $result = $confirm->insert();
         if (!$result) {
             common_log_db_error($confirm, 'INSERT', __FILE__);
             return false;
         }
     }
     if (!empty($code) && $user->email) {
         $user->emailChanged();
     }
     $profile->query('COMMIT');
     if ($email && !$user->email) {
         mail_confirm_address($user, $confirm->code, $profile->nickname, $email);
     }
     return $user;
 }
开发者ID:Br3nda,项目名称:laconica,代码行数:82,代码来源:User.php

示例7: saveProfile

 /**
  * Save passed profile
  *
  * Stores the OMB profile $profile. Overwrites an existing entry.
  * Throws exceptions in case of error.
  *
  * @param OMB_Profile $profile   The OMB profile which should be saved
  *
  * @access public
  **/
 public function saveProfile($omb_profile)
 {
     if (common_profile_url($omb_profile->getNickname()) == $omb_profile->getProfileURL()) {
         throw new Exception('Not implemented');
     } else {
         $remote = Remote_profile::staticGet('uri', $omb_profile->getIdentifierURI());
         if ($remote) {
             $exists = true;
             $profile = Profile::staticGet($remote->id);
             $orig_remote = clone $remote;
             $orig_profile = clone $profile;
             // XXX: compare current postNotice and updateProfile URLs to the ones
             // stored in the DB to avoid (possibly...) above attack
         } else {
             $exists = false;
             $remote = new Remote_profile();
             $remote->uri = $omb_profile->getIdentifierURI();
             $profile = new Profile();
         }
         $profile->nickname = $omb_profile->getNickname();
         $profile->profileurl = $omb_profile->getProfileURL();
         $fullname = $omb_profile->getFullname();
         $profile->fullname = is_null($fullname) ? '' : $fullname;
         $homepage = $omb_profile->getHomepage();
         $profile->homepage = is_null($homepage) ? '' : $homepage;
         $bio = $omb_profile->getBio();
         $profile->bio = is_null($bio) ? '' : $bio;
         $location = $omb_profile->getLocation();
         $profile->location = is_null($location) ? '' : $location;
         if ($exists) {
             $profile->update($orig_profile);
         } else {
             $profile->created = DB_DataObject_Cast::dateTime();
             # current time
             $id = $profile->insert();
             if (!$id) {
                 // TRANS: Exception thrown when creating a new profile fails in OAuth store.
                 throw new Exception(_('Error inserting new profile.'));
             }
             $remote->id = $id;
         }
         $avatar_url = $omb_profile->getAvatarURL();
         if ($avatar_url) {
             if (!$this->add_avatar($profile, $avatar_url)) {
                 // TRANS: Exception thrown when creating a new avatar fails in OAuth store.
                 throw new Exception(_('Error inserting avatar.'));
             }
         } else {
             $avatar = $profile->getOriginalAvatar();
             if ($avatar) {
                 $avatar->delete();
             }
             $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
             if ($avatar) {
                 $avatar->delete();
             }
             $avatar = $profile->getAvatar(AVATAR_STREAM_SIZE);
             if ($avatar) {
                 $avatar->delete();
             }
             $avatar = $profile->getAvatar(AVATAR_MINI_SIZE);
             if ($avatar) {
                 $avatar->delete();
             }
         }
         if ($exists) {
             if (!$remote->update($orig_remote)) {
                 // TRANS: Exception thrown when updating a remote profile fails in OAuth store.
                 throw new Exception(_('Error updating remote profile.'));
             }
         } else {
             $remote->created = DB_DataObject_Cast::dateTime();
             # current time
             if (!$remote->insert()) {
                 // TRANS: Exception thrown when creating a remote profile fails in OAuth store.
                 throw new Exception(_('Error inserting remote profile.'));
             }
         }
     }
 }
开发者ID:harriewang,项目名称:InnertieWebsite,代码行数:90,代码来源:oauthstore.php

示例8: testGetValidProfileByEmail

 /**
  * test grabbing a Profile by email
  **/
 public function testGetValidProfileByEmail()
 {
     // count the number of rows and save it for later
     $numRows = $this->getConnection()->getRowCount("profile");
     // create a new Profile and insert to into mySQL
     $profile = new Profile(null, $this->VALID_ATHANDLE, $this->VALID_EMAIL, $this->VALID_PHONE);
     $profile->insert($this->getPDO());
     // grab the data from mySQL and enforce the fields match our expectations
     $pdoProfile = Profile::getProfileByEmail($this->getPDO(), $profile->getEmail());
     $this->assertSame($numRows + 1, $this->getConnection()->getRowCount("profile"));
     $this->assertSame($pdoProfile->getAtHandle(), $this->VALID_ATHANDLE);
     $this->assertSame($pdoProfile->getEmail(), $this->VALID_EMAIL);
     $this->assertSame($pdoProfile->getPhone(), $this->VALID_PHONE);
 }
开发者ID:jfindley2,项目名称:data-design,代码行数:17,代码来源:profile-test.php

示例9: register

 static function register($fields)
 {
     if (!empty($fields['userid'])) {
         $profile = Profile::getKV('id', $fields['userid']);
         if ($profile && !$profile->hasRight(Right::CREATEGROUP)) {
             common_log(LOG_WARNING, "Attempted group creation from banned user: " . $profile->nickname);
             // TRANS: Client exception thrown when a user tries to create a group while banned.
             throw new ClientException(_('You are not allowed to create groups on this site.'), 403);
         }
     }
     $fields['nickname'] = Nickname::normalize($fields['nickname']);
     // MAGICALLY put fields into current scope
     // @fixme kill extract(); it makes debugging absurdly hard
     $defaults = array('nickname' => null, 'fullname' => null, 'homepage' => null, 'description' => null, 'location' => null, 'uri' => null, 'mainpage' => null, 'aliases' => array(), 'userid' => null);
     $fields = array_merge($defaults, $fields);
     extract($fields);
     $group = new User_group();
     if (empty($uri)) {
         // fill in later...
         $uri = null;
     }
     if (empty($mainpage)) {
         $mainpage = common_local_url('showgroup', array('nickname' => $nickname));
     }
     // We must create a new, incrementally assigned profile_id
     $profile = new Profile();
     $profile->nickname = $nickname;
     $profile->fullname = $fullname;
     $profile->profileurl = $mainpage;
     $profile->homepage = $homepage;
     $profile->bio = $description;
     $profile->location = $location;
     $profile->created = common_sql_now();
     $group->nickname = $profile->nickname;
     $group->fullname = $profile->fullname;
     $group->homepage = $profile->homepage;
     $group->description = $profile->bio;
     $group->location = $profile->location;
     $group->mainpage = $profile->profileurl;
     $group->created = $profile->created;
     $profile->query('BEGIN');
     $id = $profile->insert();
     if ($id === false) {
         $profile->query('ROLLBACK');
         throw new ServerException(_('Profile insertion failed'));
     }
     $group->profile_id = $id;
     $group->uri = $uri;
     if (isset($fields['join_policy'])) {
         $group->join_policy = intval($fields['join_policy']);
     } else {
         $group->join_policy = 0;
     }
     if (isset($fields['force_scope'])) {
         $group->force_scope = intval($fields['force_scope']);
     } else {
         $group->force_scope = 0;
     }
     if (Event::handle('StartGroupSave', array(&$group))) {
         $result = $group->insert();
         if ($result === false) {
             common_log_db_error($group, 'INSERT', __FILE__);
             // TRANS: Server exception thrown when creating a group failed.
             throw new ServerException(_('Could not create group.'));
         }
         if (!isset($uri) || empty($uri)) {
             $orig = clone $group;
             $group->uri = common_local_url('groupbyid', array('id' => $group->id));
             $result = $group->update($orig);
             if (!$result) {
                 common_log_db_error($group, 'UPDATE', __FILE__);
                 // TRANS: Server exception thrown when updating a group URI failed.
                 throw new ServerException(_('Could not set group URI.'));
             }
         }
         $result = $group->setAliases($aliases);
         if (!$result) {
             // TRANS: Server exception thrown when creating group aliases failed.
             throw new ServerException(_('Could not create aliases.'));
         }
         $member = new Group_member();
         $member->group_id = $group->id;
         $member->profile_id = $userid;
         $member->is_admin = 1;
         $member->created = $group->created;
         $result = $member->insert();
         if (!$result) {
             common_log_db_error($member, 'INSERT', __FILE__);
             // TRANS: Server exception thrown when setting group membership failed.
             throw new ServerException(_('Could not set group membership.'));
         }
         self::blow('profile:groups:%d', $userid);
         if ($local) {
             $local_group = new Local_group();
             $local_group->group_id = $group->id;
             $local_group->nickname = $nickname;
             $local_group->created = common_sql_now();
             $result = $local_group->insert();
             if (!$result) {
                 common_log_db_error($local_group, 'INSERT', __FILE__);
//.........这里部分代码省略.........
开发者ID:phpsource,项目名称:gnu-social,代码行数:101,代码来源:User_group.php

示例10: ensureProfile

 function ensureProfile($user)
 {
     // check to see if there's already a profile for this user
     $profileurl = 'http://twitter.com/' . $user->screen_name;
     $profile = Profile::staticGet('profileurl', $profileurl);
     if ($profile) {
         if (defined('SCRIPT_DEBUG')) {
             common_debug("Profile for {$profile->nickname} found.");
         }
         // Check to see if the user's Avatar has changed
         $this->checkAvatar($user, $profile);
         return $profile->id;
     } else {
         if (defined('SCRIPT_DEBUG')) {
             common_debug('Adding profile and remote profile ' . "for Twitter user: {$profileurl}");
         }
         $profile = new Profile();
         $profile->query("BEGIN");
         $profile->nickname = $user->screen_name;
         $profile->fullname = $user->name;
         $profile->homepage = $user->url;
         $profile->bio = $user->description;
         $profile->location = $user->location;
         $profile->profileurl = $profileurl;
         $profile->created = common_sql_now();
         $id = $profile->insert();
         if (empty($id)) {
             common_log_db_error($profile, 'INSERT', __FILE__);
             $profile->query("ROLLBACK");
             return false;
         }
         // check for remote profile
         $remote_pro = Remote_profile::staticGet('uri', $profileurl);
         if (!$remote_pro) {
             $remote_pro = new Remote_profile();
             $remote_pro->id = $id;
             $remote_pro->uri = $profileurl;
             $remote_pro->created = common_sql_now();
             $rid = $remote_pro->insert();
             if (empty($rid)) {
                 common_log_db_error($profile, 'INSERT', __FILE__);
                 $profile->query("ROLLBACK");
                 return false;
             }
         }
         $profile->query("COMMIT");
         $this->saveAvatars($user, $id);
         return $id;
     }
 }
开发者ID:Br3nda,项目名称:laconica,代码行数:50,代码来源:twitterstatusfetcher.php

示例11: Profile

if (empty($fullname)) {
    echo 'username required';
    exit;
}
if (empty($email)) {
    echo 'email required';
    exit;
}
if (empty($password)) {
    echo 'password required';
    exit;
}
$profile = new Profile();
$profile->fullname = $fullname;
$profile->email = $email;
$profile->created = common_sql_now();
$profile_id = $profile->insert();
if (!$profile_id) {
    common_log_db_error($profile, 'INSERT', __FILE__);
    exit;
}
$profile_role = new Profile_role();
$profile_role->profile_id = $profile_id;
$profile_role->role = Profile_role::SUPERADMIN;
$profile_role->created = common_sql_now();
$profile_role->insert();
$pnew = Profile::staticGet($profile_id);
$orig = clone $pnew;
$pnew->password = common_munge_password($password, $profile_id);
$pnew->update($orig);
echo "Done!";
开发者ID:Edo78,项目名称:fluidframe,代码行数:31,代码来源:useradd.php

示例12: json_encode

        $requestObject = json_decode($requestContent);
        // make sure form is filled out fully, to prevent db issues
        if (empty($requestObject->profileName) === true) {
            throw new InvalidArgumentException("Must chose a user name", 405);
        }
        if (empty($requestObject->profileEmail) === true) {
            throw new InvalidArgumentException("Must use a valid email", 405);
        }
        if (empty($requestObject->profilePassword) === true) {
            throw new InvalidArgumentException("password cannot be empty", 405);
        }
        // sanitize the email
        $profileSalt = bin2hex(openssl_random_pseudo_bytes(32));
        $profileEmailActivation = bin2hex(openssl_random_pseudo_bytes(8));
        // create the hash
        $profileHash = hash_pbkdf2("sha512", $requestObject->profilePassword, $profileSalt, 262144, 128);
        // create a new Profile, and insert into db
        $profile = new Profile(null, $requestObject->profileEmail, $profileEmailActivation, $profile->insert($pdo));
        $reply->message = "A new Profile has been created";
    } else {
        throw new InvalidArgumentException("Invalid HTTP method");
    }
} catch (\Exception $exception) {
    $reply->status = $exception->getCode();
    $reply->message = $exception->getMessage();
} catch (\TypeError $typeError) {
    $reply->status = $typeError->getCode();
    $reply->message = $typeError->getMessage();
}
header("Content-type: application/json");
echo json_encode($reply);
开发者ID:chrispaul3625,项目名称:sprots,代码行数:31,代码来源:signup.php

示例13: linkback_profile

function linkback_profile($entry, $mf2, $response, $target)
{
    if (isset($entry['properties']['author']) && isset($entry['properties']['author'][0]['properties'])) {
        $author = $entry['properties']['author'][0]['properties'];
    } else {
        $author = linkback_hcard($mf2, $response->getEffectiveUrl());
    }
    if (!$author) {
        $author = array('name' => array($entry['name']));
    }
    if (!$author['url']) {
        $author['url'] = array($response->getEffectiveUrl());
    }
    $user = User::getKV('uri', $author['url'][0]);
    if ($user instanceof User) {
        common_log(LOG_INFO, "Linkback: ignoring linkback from local user: {$url}");
        return true;
    }
    try {
        $profile = Profile::fromUri($author['url'][0]);
    } catch (UnknownUriException $ex) {
    }
    if (!$profile instanceof Profile) {
        $profile = Profile::getKV('profileurl', $author['url'][0]);
    }
    if (!$profile instanceof Profile) {
        $profile = new Profile();
        $profile->profileurl = $author['url'][0];
        $profile->fullname = $author['name'][0];
        $profile->nickname = $author['nickname'] ? $author['nickname'][0] : str_replace(' ', '', $author['name'][0]);
        $profile->created = common_sql_now();
        $profile->insert();
    }
    return array($profile, $author);
}
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:35,代码来源:util.php

示例14: saveRemoteProfile

 function saveRemoteProfile(&$req)
 {
     # FIXME: we should really do this when the consumer comes
     # back for an access token. If they never do, we've got stuff in a
     # weird state.
     $nickname = $req->get_parameter('omb_listenee_nickname');
     $fullname = $req->get_parameter('omb_listenee_fullname');
     $profile_url = $req->get_parameter('omb_listenee_profile');
     $homepage = $req->get_parameter('omb_listenee_homepage');
     $bio = $req->get_parameter('omb_listenee_bio');
     $location = $req->get_parameter('omb_listenee_location');
     $avatar_url = $req->get_parameter('omb_listenee_avatar');
     $listenee = $req->get_parameter('omb_listenee');
     $remote = Remote_profile::staticGet('uri', $listenee);
     if ($remote) {
         $exists = true;
         $profile = Profile::staticGet($remote->id);
         $orig_remote = clone $remote;
         $orig_profile = clone $profile;
     } else {
         $exists = false;
         $remote = new Remote_profile();
         $remote->uri = $listenee;
         $profile = new Profile();
     }
     $profile->nickname = $nickname;
     $profile->profileurl = $profile_url;
     if (!is_null($fullname)) {
         $profile->fullname = $fullname;
     }
     if (!is_null($homepage)) {
         $profile->homepage = $homepage;
     }
     if (!is_null($bio)) {
         $profile->bio = $bio;
     }
     if (!is_null($location)) {
         $profile->location = $location;
     }
     if ($exists) {
         $profile->update($orig_profile);
     } else {
         $profile->created = DB_DataObject_Cast::dateTime();
         # current time
         $id = $profile->insert();
         if (!$id) {
             return false;
         }
         $remote->id = $id;
     }
     if ($exists) {
         if (!$remote->update($orig_remote)) {
             return false;
         }
     } else {
         $remote->created = DB_DataObject_Cast::dateTime();
         # current time
         if (!$remote->insert()) {
             return false;
         }
     }
     if ($avatar_url) {
         if (!$this->addAvatar($profile, $avatar_url)) {
             return false;
         }
     }
     $user = common_current_user();
     $datastore = omb_oauth_datastore();
     $consumer = $this->getConsumer($datastore, $req);
     $token = $this->getToken($datastore, $req, $consumer);
     $sub = new Subscription();
     $sub->subscriber = $user->id;
     $sub->subscribed = $remote->id;
     $sub->token = $token->key;
     # NOTE: request token, not valid for use!
     $sub->created = DB_DataObject_Cast::dateTime();
     # current time
     if (!$sub->insert()) {
         return false;
     }
     return true;
 }
开发者ID:Br3nda,项目名称:laconica,代码行数:82,代码来源:userauthorization.php

示例15: connectToEncryptedMySQL

<?php

require_once "/etc/apache2/capstone-mysql/encrypted-config.php";
require_once "profile.php";
$pdo = connectToEncryptedMySQL("/etc/apache2/data-design/vhooker.ini");
$profile = new Profile(null, 1, "this is from PHP");
$profile->insert($pdo);
$profile->setProfile("now I changed the message");
$profile->update($pdo);
$profile->delete($pdo);
开发者ID:CreativeCorrie,项目名称:lynda,代码行数:10,代码来源:profile-shakedown.php


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