本文整理汇总了PHP中common_nicknamize函数的典型用法代码示例。如果您正苦于以下问题:PHP common_nicknamize函数的具体用法?PHP common_nicknamize怎么用?PHP common_nicknamize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了common_nicknamize函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onAutoRegister
/**
* Internal AutoRegister event handler
* @param nickname
* @param provider_name
* @param user - the newly registered user
*/
function onAutoRegister($nickname, $provider_name, &$user)
{
if ($provider_name == $this->provider_name && $this->autoregistration) {
$suggested_nickname = $this->suggestNicknameForUsername($nickname);
$test_user = User::staticGet('nickname', $suggested_nickname);
if ($test_user) {
//someone already exists with the suggested nickname, so used the passed nickname
$suggested_nickname = common_nicknamize($nickname);
}
$test_user = User::staticGet('nickname', $suggested_nickname);
if ($test_user) {
//someone already exists with the suggested nickname
//not much else we can do
} else {
$user = $this->autoRegister($nickname, $suggested_nickname);
if ($user) {
User_username::register($user, $nickname, $this->provider_name);
return false;
}
}
}
}
示例2: common_url_to_nickname
function common_url_to_nickname($url)
{
static $bad = array('query', 'user', 'password', 'port', 'fragment');
$parts = parse_url($url);
# If any of these parts exist, this won't work
foreach ($bad as $badpart) {
if (array_key_exists($badpart, $parts)) {
return null;
}
}
# We just have host and/or path
# If it's just a host...
if (array_key_exists('host', $parts) && (!array_key_exists('path', $parts) || strcmp($parts['path'], '/') == 0)) {
$hostparts = explode('.', $parts['host']);
# Try to catch common idiom of nickname.service.tld
if (count($hostparts) > 2 && strlen($hostparts[count($hostparts) - 2]) > 3 && strcmp($hostparts[0], 'www') != 0) {
return common_nicknamize($hostparts[0]);
} else {
# Do the whole hostname
return common_nicknamize($parts['host']);
}
} else {
if (array_key_exists('path', $parts)) {
# Strip starting, ending slashes
$path = preg_replace('@/$@', '', $parts['path']);
$path = preg_replace('@^/@', '', $path);
$path = basename($path);
if ($path) {
return common_nicknamize($path);
}
}
}
return null;
}
示例3: getActivityObjectNickname
public static function getActivityObjectNickname(ActivityObject $object, array $hints = array())
{
if ($object->poco) {
if (!empty($object->poco->preferredUsername)) {
return common_nicknamize($object->poco->preferredUsername);
}
}
if (!empty($object->nickname)) {
return common_nicknamize($object->nickname);
}
if (array_key_exists('nickname', $hints)) {
return $hints['nickname'];
}
// Try the profile url (like foo.example.com or example.com/user/foo)
if (!empty($object->link)) {
$profileUrl = $object->link;
} else {
if (!empty($hints['profileurl'])) {
$profileUrl = $hints['profileurl'];
}
}
if (!empty($profileUrl)) {
$nickname = self::nicknameFromURI($profileUrl);
}
// Try the URI (may be a tag:, http:, acct:, ...
if (empty($nickname)) {
$nickname = self::nicknameFromURI($object->id);
}
// Try a Webfinger if one was passed (way) down
if (empty($nickname)) {
if (array_key_exists('webfinger', $hints)) {
$nickname = self::nicknameFromURI($hints['webfinger']);
}
}
// Try the name
if (empty($nickname)) {
$nickname = common_nicknamize($object->title);
}
return $nickname;
}
示例4: nicknamize
function nicknamize($str)
{
return common_nicknamize($str);
}
示例5: common_url_to_nickname
function common_url_to_nickname($url)
{
static $bad = array('query', 'user', 'password', 'port', 'fragment');
$parts = parse_url($url);
// If any of these parts exist, this won't work
foreach ($bad as $badpart) {
if (array_key_exists($badpart, $parts)) {
return null;
}
}
// We just have host and/or path
// If it's just a host...
if (array_key_exists('host', $parts) && (!array_key_exists('path', $parts) || strcmp($parts['path'], '/') == 0)) {
$hostparts = explode('.', $parts['host']);
// Try to catch common idiom of nickname.service.tld
if (count($hostparts) > 2 && strlen($hostparts[count($hostparts) - 2]) > 3 && strcmp($hostparts[0], 'www') != 0) {
return common_nicknamize($hostparts[0]);
} else {
// Do the whole hostname
return common_nicknamize($parts['host']);
}
} else {
if (array_key_exists('path', $parts)) {
// Strip starting, ending slashes
$path = preg_replace('@/$@', '', $parts['path']);
$path = preg_replace('@^/@', '', $path);
$path = basename($path);
// Hack for MediaWiki user pages, in the form:
// http://example.com/wiki/User:Myname
// ('User' may be localized.)
if (strpos($path, ':')) {
$parts = array_filter(explode(':', $path));
$path = $parts[count($parts) - 1];
}
if ($path) {
return common_nicknamize($path);
}
}
}
return null;
}
示例6: define
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define('INSTALLDIR', realpath(dirname(__FILE__) . '/../..'));
$shortoptions = "e:";
$helptext = <<<END_OF_REGISTERBYEMAIL_HELP
USAGE: registerbyemail.php
Registers a new user by email address and sends a confirmation email
-e email Email to register
END_OF_REGISTERBYEMAIL_HELP;
require_once INSTALLDIR . '/scripts/commandline.inc';
$email = get_option_value('e', 'email');
$parts = explode('@', $email);
$nickname = common_nicknamize($parts[0]);
$user = User::getKV('nickname', $nickname);
if (!empty($user)) {
$confirm = new Confirm_address();
$confirm->user_id = $user->id;
$confirm->address_type = 'email';
if ($confirm->find(true)) {
$url = common_local_url('confirmfirstemail', array('code' => $confirm->code));
print "{$url}\n";
} else {
print "User not waiting for confirmation.\n";
}
exit;
}
$user = User::register(array('nickname' => $nickname, 'password' => null));
$confirm = new Confirm_address();
示例7: xriToNickname
function xriToNickname($xri)
{
$base = $this->xriBase($xri);
if (!$base) {
return null;
} else {
// =evan.prodromou
// or @gratis*evan.prodromou
$parts = explode('*', substr($base, 1));
return common_nicknamize(array_pop($parts));
}
}
示例8: suggestNicknameForUsername
function suggestNicknameForUsername($username)
{
$entry = $this->ldapCommon->get_user($username, $this->attributes);
if (!$entry) {
//this really shouldn't happen
$nickname = $username;
} else {
$nickname = $entry->getValue($this->attributes['nickname'], 'single');
if (!$nickname) {
$nickname = $username;
}
}
return common_nicknamize($nickname);
}