本文整理汇总了PHP中UserUrl函数的典型用法代码示例。如果您正苦于以下问题:PHP UserUrl函数的具体用法?PHP UserUrl怎么用?PHP UserUrl使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了UserUrl函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: UserController_TempBan_Create
public function UserController_TempBan_Create($Sender, $Args)
{
$Sender->Permission('Garden.Moderation.Manage');
$UserID = (int) GetValue('0', $Args);
$Unban = (bool) GetValue('1', $Args);
$User = Gdn::UserModel()->GetID($UserID, DATASET_TYPE_ARRAY);
if (!$User) {
throw NotFoundException($User);
}
$UserModel = Gdn::UserModel();
if ($Sender->Form->AuthenticatedPostBack()) {
if ($Unban) {
$UserModel->Unban($UserID, array('RestoreContent' => $Sender->Form->GetFormValue('RestoreContent')));
} else {
$Minutes = $Sender->Form->GetValue('TempBanPeriodMinutes');
$Hours = $Sender->Form->GetValue('TempBanPeriodHours');
$Days = $Sender->Form->GetValue('TempBanPeriodDays');
$Months = $Sender->Form->GetValue('TempBanPeriodMonths');
$Years = $Sender->Form->GetValue('TempBanPeriodYears');
if (!(empty($Minutes) && empty($Hours) && empty($Days) && empty($Months) && empty($Years))) {
$AutoExpirePeriod = Gdn_Format::ToDateTime(strtotime("+{$Years} years {$Months} months {$Days} days {$Hours} hours {$Minutes} minutes"));
} else {
$Sender->Form->AddError('ValidateRequired', 'Ban Period');
}
if (!ValidateRequired($Sender->Form->GetFormValue('Reason'))) {
$Sender->Form->AddError('ValidateRequired', 'Reason');
}
if ($Sender->Form->GetFormValue('Reason') == 'Other' && !ValidateRequired($Sender->Form->GetFormValue('ReasonText'))) {
$Sender->Form->AddError('ValidateRequired', 'Reason Text');
}
if ($Sender->Form->ErrorCount() == 0) {
if ($Sender->Form->GetFormValue('Reason') == 'Other') {
$Reason = $Sender->Form->GetFormValue('ReasonText');
} else {
$Reason = $Sender->Form->GetFormValue('Reason');
}
Gdn::Locale()->SetTranslation('HeadlineFormat.Ban', FormatString('{RegardingUserID,You} banned {ActivityUserID,you} until {BanExpire, date}.', array('BanExpire' => $AutoExpirePeriod)));
$UserModel->Ban($UserID, array('Reason' => $Reason));
$UserModel->SetField($UserID, 'BanExpire', $AutoExpirePeriod);
}
}
if ($Sender->Form->ErrorCount() == 0) {
// Redirect after a successful save.
if ($Sender->Request->Get('Target')) {
$Sender->RedirectUrl = $Sender->Request->Get('Target');
} else {
$Sender->RedirectUrl = Url(UserUrl($User));
}
}
}
$Sender->SetData('User', $User);
$Sender->AddSideMenu();
$Sender->Title($Unban ? T('Unban User') : T('Temporary Ban User'));
if ($Unban) {
$Sender->View = 'Unban';
} else {
$Sender->View = $this->ThemeView('tempban');
}
$Sender->Render();
}
示例2: ToString
public function ToString()
{
$Session = Gdn::Session();
$Controller = Gdn::Controller();
$UserID = $Controller->User->UserID;
$MemberOptions = array();
$ProfileOptions = array();
$Controller->EventArguments['UserID'] = $UserID;
$Controller->EventArguments['ProfileOptions'] =& $ProfileOptions;
$Controller->EventArguments['MemberOptions'] =& $MemberOptions;
if ($Controller->EditMode) {
return '<div class="ProfileOptions">' . Anchor(T('Back to Profile'), UserUrl($Controller->User), array('class' => 'ProfileButtons')) . '</div>';
// $ProfileOptions[] = array('Text' => T('Back to Profile'), 'Url' => UserUrl($Controller->User), 'CssClass' => 'BackToProfile');
} else {
// Profile Editing
if (hasEditProfile($Controller->User->UserID)) {
$ProfileOptions[] = array('Text' => Sprite('SpEditProfile') . ' ' . T('Edit Profile'), 'Url' => UserUrl($Controller->User, '', 'edit'));
}
// Ban/Unban
$MayBan = CheckPermission('Garden.Moderation.Manage') || CheckPermission('Garden.Users.Edit') || CheckPermission('Moderation.Users.Ban');
if ($MayBan && $UserID != $Session->UserID) {
if ($Controller->User->Banned) {
$ProfileOptions[] = array('Text' => Sprite('SpBan') . ' ' . T('Unban'), 'Url' => "/user/ban?userid={$UserID}&unban=1", 'CssClass' => 'Popup');
} elseif (!$Controller->User->Admin) {
$ProfileOptions[] = array('Text' => Sprite('SpBan') . ' ' . T('Ban'), 'Url' => "/user/ban?userid={$UserID}", 'CssClass' => 'Popup');
}
}
// Delete content.
if (CheckPermission('Garden.Moderation.Manage')) {
$ProfileOptions[] = array('Text' => Sprite('SpDelete') . ' ' . T('Delete Content'), 'Url' => "/user/deletecontent?userid={$UserID}", 'CssClass' => 'Popup');
}
}
return parent::ToString();
}
示例3: ToString
public function ToString()
{
if ($this->_UserData->NumRows() == 0) {
return '';
}
$String = '';
ob_start();
?>
<div class="Box">
<?php
echo panelHeading(T('In this Discussion'));
?>
<ul class="PanelInfo">
<?php
foreach ($this->_UserData->Result() as $User) {
?>
<li>
<?php
echo Anchor(Wrap(Wrap(Gdn_Format::Date($User->DateLastActive, 'html')), 'span', array('class' => 'Aside')) . ' ' . Wrap(Wrap(GetValue('Name', $User), 'span', array('class' => 'Username')), 'span'), UserUrl($User));
?>
</li>
<?php
}
?>
</ul>
</div>
<?php
$String = ob_get_contents();
@ob_end_clean();
return $String;
}
示例4: profileController_beforeProfileOptions_handler
/**
* Add "Signature Settings" to Profile Edit button group.
* Only do this if they cannot edit profiles because otherwise they can't navigate there.
*
* @param $Sender
*/
public function profileController_beforeProfileOptions_handler($Sender, $Args)
{
$CanEditProfiles = CheckPermission('Garden.Users.Edit') || CheckPermission('Moderation.Profiles.Edit');
if (CheckPermission('Moderation.Signatures.Edit') && !$CanEditProfiles) {
$Args['ProfileOptions'][] = array('Text' => Sprite('SpSignatures') . ' ' . T('Signature Settings'), 'Url' => UserUrl($Sender->User, '', 'signature'));
}
}
示例5: ProfileController_AfterAddSideMenu_Handler
public function ProfileController_AfterAddSideMenu_Handler($Sender)
{
if (!Gdn::Session()->CheckPermission('Garden.SignIn.Allow')) {
return;
}
$SideMenu = $Sender->EventArguments['SideMenu'];
$ViewingUserID = Gdn::Session()->UserID;
if ($Sender->User->UserID == $ViewingUserID) {
$SideMenu->AddLink('Options', Sprite('SpQuote') . ' ' . T('Quote Settings'), '/profile/quotes', FALSE, array('class' => 'Popup'));
} else {
$SideMenu->AddLink('Options', Sprite('SpQuote') . ' ' . T('Quote Settings'), UserUrl($Sender->User, '', 'quotes'), 'Garden.Users.Edit', array('class' => 'Popup'));
}
}
示例6: ConnectButton
function ConnectButton($Row)
{
$c = Gdn::Controller();
$Connected = GetValue('Connected', $Row);
$CssClass = $Connected ? 'Active' : 'InActive';
$ConnectUrl = GetValue('ConnectUrl', $Row);
$DisconnectUrl = UserUrl($c->User, '', 'Disconnect', array('provider' => $Row['ProviderKey']));
$Result = '<span class="ActivateSlider ActivateSlider-' . $CssClass . '">';
if ($Connected) {
$Result .= Anchor(T('Connected'), $DisconnectUrl, 'Button Primary Hijack');
} else {
$Result .= Anchor(T('Connect'), $ConnectUrl, 'Button');
}
$Result .= '</span>';
return $Result;
}
示例7: CalculateRow
public function CalculateRow(&$Row)
{
$ActivityType = self::GetActivityType($Row['ActivityTypeID']);
$Row['ActivityType'] = GetValue('Name', $ActivityType);
if (is_string($Row['Data'])) {
$Row['Data'] = @unserialize($Row['Data']);
}
$Row['PhotoUrl'] = Url($Row['Route'], TRUE);
if (!$Row['Photo']) {
if (isset($Row['ActivityPhoto'])) {
$Row['Photo'] = $Row['ActivityPhoto'];
$Row['PhotoUrl'] = UserUrl($Row, 'Activity');
} else {
$User = Gdn::UserModel()->GetID($Row['ActivityUserID'], DATASET_TYPE_ARRAY);
if ($User) {
$Photo = $User['Photo'];
$Row['PhotoUrl'] = UserUrl($User);
if (!$Photo || StringBeginsWith($Photo, 'http')) {
$Row['Photo'] = $Photo;
} else {
$Row['Photo'] = Gdn_Upload::Url(ChangeBasename($Photo, 'n%s'));
}
}
}
}
$Data = $Row['Data'];
if (isset($Data['ActivityUserIDs'])) {
$Row['ActivityUserID'] = array_merge(array($Row['ActivityUserID']), $Data['ActivityUserIDs']);
}
if (isset($Data['RegardingUserIDs'])) {
$Row['RegardingUserID'] = array_merge(array($Row['RegardingUserID']), $Data['RegardingUserIDs']);
}
$Row['Url'] = ExternalUrl($Row['Route']);
if ($Row['HeadlineFormat']) {
$Row['Headline'] = FormatString($Row['HeadlineFormat'], $Row);
} else {
$Row['Headline'] = Gdn_Format::ActivityHeadline($Row);
}
}
示例8: ToString
public function ToString()
{
$Session = Gdn::Session();
$Controller = Gdn::Controller();
$UserID = $Controller->User->UserID;
$MemberOptions = array();
$ProfileOptions = array();
$Controller->EventArguments['UserID'] = $UserID;
$Controller->EventArguments['ProfileOptions'] =& $ProfileOptions;
$Controller->EventArguments['MemberOptions'] =& $MemberOptions;
if ($Controller->EditMode) {
$ProfileOptions[] = array('Text' => T('Back to Profile'), 'Url' => UserUrl($Controller->User), 'CssClass' => 'BackToProfile');
} else {
if ($Controller->User->UserID != $Session->UserID) {
if ($Session->CheckPermission('Garden.Users.Edit')) {
$ProfileOptions[] = array('Text' => Sprite('SpEditProfile') . T('Edit Profile'), 'Url' => UserUrl($Controller->User, '', 'edit'));
}
} else {
if (C('Garden.UserAccount.AllowEdit')) {
$ProfileOptions[] = array('Text' => Sprite('SpEditProfile') . T('Edit Profile'), 'Url' => '/profile/edit');
}
}
if ($Session->CheckPermission('Garden.Moderation.Manage') && $UserID != $Session->UserID) {
// Ban/Unban
if ($Controller->User->Banned) {
$ProfileOptions[] = array('Text' => Sprite('SpBan') . T('Unban'), 'Url' => "/user/ban?userid={$UserID}&unban=1", 'CssClass' => 'Popup');
} else {
$ProfileOptions[] = array('Text' => Sprite('SpBan') . T('Ban'), 'Url' => "/user/ban?userid={$UserID}", 'CssClass' => 'Popup');
}
// Delete content.
if (!$Controller->User->Banned) {
$ProfileOptions[] = array('Text' => Sprite('SpDelete') . T('Delete Content'), 'Url' => "/user/deletecontent?userid={$UserID}", 'CssClass' => 'Popup');
}
}
}
return parent::ToString();
}
示例9: Anchor
<div id="Head">
<h1><?php
echo Anchor(C('Garden.Title') . ' ' . Wrap(T('Visit Site')), '/');
?>
</h1>
<div class="User">
<?php
$Session = Gdn::Session();
if ($Session->IsValid()) {
$this->FireEvent('BeforeUserOptionsMenu');
$Name = $Session->User->Name;
$CountNotifications = $Session->User->CountNotifications;
if (is_numeric($CountNotifications) && $CountNotifications > 0) {
$Name .= Wrap($CountNotifications);
}
echo Anchor($Name, UserUrl($Session->User), 'Profile');
echo Anchor(T('Sign Out'), SignOutUrl(), 'Leave');
}
?>
</div>
</div>
<div id="Body">
<div id="Panel">
<?php
$this->RenderAsset('Panel');
?>
</div>
<div id="Content"><?php
$this->RenderAsset('Content');
?>
</div>
示例10: UserController_Warning_Create
public function UserController_Warning_Create($Sender, $Args)
{
$Sender->Permission('Garden.Moderation.Manage');
$UserID = (int) GetValue('0', $Args);
$User = Gdn::UserModel()->GetID($UserID);
if (!$User) {
throw NotFoundException($User);
}
if ($Sender->Form->AuthenticatedPostBack()) {
$Type = $Sender->Form->GetValue('Warning');
$Reason = $Sender->Form->GetValue('Reason');
if (empty($Type) || !in_array($Type, $this->WarnLevel)) {
$Sender->Form->AddError('ValidateRequired', 'Warn Level');
}
if (empty($Reason)) {
$Sender->Form->AddError('ValidateRequired', 'Reason');
}
if ($Sender->Form->ErrorCount() == 0) {
Gdn::UserModel()->SetMeta($UserID, array('Warnings.' . time() => Gdn_Format::Serialize(array('Type' => $Type, 'Reason' => $Reason))));
Gdn::UserModel()->SaveAttribute($UserID, 'WarnLevel', $Type);
// get those notification sent
$this->SaveActivity($User, $Type, $Reason);
// Redirect after a successful save.
if ($Sender->Request->Get('Target')) {
$Sender->RedirectUrl = $Sender->Request->Get('Target');
} else {
$Sender->RedirectUrl = Url(UserUrl($User));
}
}
}
$Sender->SetData('User', $User);
$Sender->SetData('WarnLevel', array_combine($this->WarnLevel, array_map(array($this, 'WarnLevelFormat'), $this->WarnLevel)));
$Sender->AddSideMenu();
$Sender->Title(T('Warning.Warn', 'Warn'));
$Sender->View = $this->ThemeView('warning');
$Sender->Render();
}
示例11: ActivityHeadline
/**
* The ActivityType table has some special sprintf search/replace values in the
* FullHeadline and ProfileHeadline fields. The ProfileHeadline field is to be
* used on this page (the user profile page). The FullHeadline field is to be
* used on the main activity page. The replacement definitions are as follows:
* %1$s = ActivityName
* %2$s = ActivityName Possessive
* %3$s = RegardingName
* %4$s = RegardingName Possessive
* %5$s = Link to RegardingName's Wall
* %6$s = his/her
* %7$s = he/she
* %8$s = route & routecode
* %9$s = gender suffix (some languages require this).
*
* @param object $Activity An object representation of the activity being formatted.
* @param int $ProfileUserID If looking at a user profile, this is the UserID of the profile we are
* looking at.
* @return string
*/
public static function ActivityHeadline($Activity, $ProfileUserID = '', $ViewingUserID = '')
{
$Activity = (object) $Activity;
if ($ViewingUserID == '') {
$Session = Gdn::Session();
$ViewingUserID = $Session->IsValid() ? $Session->UserID : -1;
}
$GenderSuffixCode = 'First';
$GenderSuffixGender = $Activity->ActivityGender;
if ($ViewingUserID == $Activity->ActivityUserID) {
$ActivityName = $ActivityNameP = T('You');
} else {
$ActivityName = $Activity->ActivityName;
$ActivityNameP = FormatPossessive($ActivityName);
$GenderSuffixCode = 'Third';
}
if ($ProfileUserID != $Activity->ActivityUserID) {
// If we're not looking at the activity user's profile, link the name
$ActivityNameD = urlencode($Activity->ActivityName);
$ActivityName = Anchor($ActivityName, UserUrl($Activity, 'Activity'));
$ActivityNameP = Anchor($ActivityNameP, UserUrl($Activity, 'Activity'));
$GenderSuffixCode = 'Third';
}
$Gender = T('their');
//TODO: this isn't preferable but I don't know a better option
$Gender2 = T('they');
//TODO: this isn't preferable either
if ($Activity->ActivityGender == 'm') {
$Gender = T('his');
$Gender2 = T('he');
} else {
if ($Activity->ActivityGender == 'f') {
$Gender = T('her');
$Gender2 = T('she');
}
}
if ($ViewingUserID == $Activity->RegardingUserID || $Activity->RegardingUserID == '' && $Activity->ActivityUserID == $ViewingUserID) {
$Gender = $Gender2 = T('your');
}
$IsYou = FALSE;
if ($ViewingUserID == $Activity->RegardingUserID) {
$IsYou = TRUE;
$RegardingName = T('you');
$RegardingNameP = T('your');
$GenderSuffixGender = $Activity->RegardingGender;
} else {
$RegardingName = $Activity->RegardingName == '' ? T('somebody') : $Activity->RegardingName;
$RegardingNameP = FormatPossessive($RegardingName);
if ($Activity->ActivityUserID != $ViewingUserID) {
$GenderSuffixCode = 'Third';
}
}
$RegardingWall = '';
$RegardingWallLink = '';
if ($Activity->ActivityUserID == $Activity->RegardingUserID) {
// If the activityuser and regardinguser are the same, use the $Gender Ref as the RegardingName
$RegardingName = $RegardingProfile = $Gender;
$RegardingNameP = $RegardingProfileP = $Gender;
} else {
if ($Activity->RegardingUserID > 0 && $ProfileUserID != $Activity->RegardingUserID) {
// If there is a regarding user and we're not looking at his/her profile, link the name.
$RegardingNameD = urlencode($Activity->RegardingName);
if (!$IsYou) {
$RegardingName = Anchor($RegardingName, UserUrl($Activity, 'Regarding'));
$RegardingNameP = Anchor($RegardingNameP, UserUrl($Activity, 'Regarding'));
$GenderSuffixCode = 'Third';
$GenderSuffixGender = $Activity->RegardingGender;
}
$RegardingWallActivityPath = UserUrl($Activity, 'Regarding');
$RegardingWallLink = Url($RegardingWallActivityPath);
$RegardingWall = Anchor(T('wall'), $RegardingWallActivityPath);
}
}
if ($RegardingWall == '') {
$RegardingWall = T('wall');
}
if ($Activity->Route == '') {
$ActivityRouteLink = '';
if ($Activity->RouteCode) {
$Route = T($Activity->RouteCode);
//.........这里部分代码省略.........
示例12: BuildProfile
/**
* Build the user profile.
*
* Set the page title, add data to page modules, add modules to assets,
* add tabs to tab menu. $this->User must be defined, or this method will throw an exception.
*
* @since 2.0.0
* @access public
* @return bool Always true.
*/
public function BuildProfile()
{
if (!is_object($this->User)) {
throw new Exception(T('Cannot build profile information if user is not defined.'));
}
$Session = Gdn::Session();
if (strpos($this->CssClass, 'Profile') === FALSE) {
$this->CssClass .= ' Profile';
}
$this->Title(Gdn_Format::Text($this->User->Name));
if ($this->_DeliveryType != DELIVERY_TYPE_VIEW) {
// Javascript needed
// see note above about jcrop
$this->AddJsFile('jquery.jcrop.min.js');
$this->AddJsFile('profile.js');
$this->AddJsFile('jquery.gardenmorepager.js');
$this->AddJsFile('activity.js');
// Build activity URL
$ActivityUrl = 'profile/activity/';
if ($this->User->UserID != $Session->UserID) {
$ActivityUrl = UserUrl($this->User, '', 'activity');
}
// Show activity?
if (C('Garden.Profile.ShowActivities', TRUE)) {
$this->AddProfileTab(T('Activity'), $ActivityUrl, 'Activity', Sprite('SpActivity') . ' ' . T('Activity'));
}
// Show notifications?
if ($this->User->UserID == $Session->UserID) {
$Notifications = T('Notifications');
$NotificationsHtml = Sprite('SpNotifications') . ' ' . $Notifications;
$CountNotifications = $Session->User->CountNotifications;
if (is_numeric($CountNotifications) && $CountNotifications > 0) {
$NotificationsHtml .= ' <span class="Aside"><span class="Count">' . $CountNotifications . '</span></span>';
}
$this->AddProfileTab($Notifications, 'profile/notifications', 'Notifications', $NotificationsHtml);
}
// Show invitations?
if (C('Garden.Registration.Method') == 'Invitation') {
$this->AddProfileTab(T('Invitations'), 'profile/invitations', 'InvitationsLink');
}
$this->FireEvent('AddProfileTabs');
}
return TRUE;
}
示例13: ProfileConnecUrl
public static function ProfileConnecUrl()
{
return Url(UserUrl(Gdn::Session()->User, FALSE, 'twitterconnect'), TRUE);
}
示例14: ProfileController_Best_Create
/**
* This method shows the highest scoring discussions/comments a user has ever posted
*
* @param ProfileController $Sender
* @param int $UserReference
* @param string $Username
* @param int $Page
*/
public function ProfileController_Best_Create($Sender, $UserReference = '', $Username = '', $Page = 0)
{
if (!C('Yaga.Reactions.Enabled')) {
return;
}
list($Offset, $Limit) = OffsetLimit($Page, C('Yaga.BestContent.PerPage', 10));
if (!is_numeric($Offset) || $Offset < 0) {
$Offset = 0;
}
$Sender->EditMode(FALSE);
// Tell the ProfileController what tab to load
$Sender->GetUserInfo($UserReference, $Username);
$Sender->_SetBreadcrumbs(T('Yaga.BestContent'), UserUrl($Sender->User, '', 'best'));
$Sender->SetTabView(T('Yaga.BestContent'), 'best', 'profile', 'Yaga');
$Sender->AddJsFile('jquery.expander.js');
$Sender->AddJsFile('reactions.js', 'yaga');
$Sender->AddDefinition('ExpandText', T('(more)'));
$Sender->AddDefinition('CollapseText', T('(less)'));
$Model = new ActedModel();
$Data = $Model->GetBest($Sender->User->UserID, $Limit, $Offset);
$Sender->SetData('Content', $Data);
// Set the HandlerType back to normal on the profilecontroller so that it fetches it's own views
$Sender->HandlerType = HANDLER_TYPE_NORMAL;
// Do not show discussion options
$Sender->ShowOptions = FALSE;
if ($Sender->Head) {
$Sender->Head->AddTag('meta', array('name' => 'robots', 'content' => 'noindex,noarchive'));
}
// Build a pager
$PagerFactory = new Gdn_PagerFactory();
$Sender->Pager = $PagerFactory->GetPager('Pager', $Sender);
$Sender->Pager->ClientID = 'Pager';
$Sender->Pager->Configure($Offset, $Limit, FALSE, 'profile/best/' . $Sender->User->UserID . '/' . Gdn_Format::Url($Sender->User->Name) . '/%1$s/');
// Render the ProfileController
$Sender->Render();
}
示例15: userAnchor
/**
* Take a user object, and writes out an anchor of the user's name to the user's profile.
*/
function userAnchor($User, $CssClass = null, $Options = null)
{
static $NameUnique = null;
if ($NameUnique === null) {
$NameUnique = C('Garden.Registration.NameUnique');
}
if (is_array($CssClass)) {
$Options = $CssClass;
$CssClass = null;
} elseif (is_string($Options)) {
$Options = array('Px' => $Options);
}
$Px = GetValue('Px', $Options, '');
$Name = GetValue($Px . 'Name', $User, T('Unknown'));
// $UserID = GetValue($Px.'UserID', $User, 0);
$Text = GetValue('Text', $Options, htmlspecialchars($Name));
// Allow anchor text to be overridden.
$Attributes = array('class' => $CssClass, 'rel' => GetValue('Rel', $Options));
if (isset($Options['title'])) {
$Attributes['title'] = $Options['title'];
}
$UserUrl = UserUrl($User, $Px);
return '<a href="' . htmlspecialchars(Url($UserUrl)) . '"' . Attribute($Attributes) . '>' . $Text . '</a>';
}