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(); }
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(); }
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; }
/** * 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')); } }
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')); } }
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; }
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); } }
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(); }
<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>
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(); }
/** * 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); } else { $Route = ''; } } else { $ActivityRouteLink = Url($Activity->Route); $Route = Anchor(T($Activity->RouteCode), $Activity->Route); } // Translate the gender suffix. $GenderSuffixCode = "GenderSuffix.{$GenderSuffixCode}.{$GenderSuffixGender}"; $GenderSuffix = T($GenderSuffixCode, ''); if ($GenderSuffix == $GenderSuffixCode) { $GenderSuffix = ''; } // in case translate doesn't support empty strings. /* Debug: return $ActivityName .'/'.$ActivityNameP .'/'.$RegardingName .'/'.$RegardingNameP .'/'.$RegardingWall .'/'.$Gender .'/'.$Gender2 .'/'.$Route .'/'.$GenderSuffix.($GenderSuffixCode) */ $FullHeadline = T("Activity.{$Activity->ActivityType}.FullHeadline", T($Activity->FullHeadline)); $ProfileHeadline = T("Activity.{$Activity->ActivityType}.ProfileHeadline", T($Activity->ProfileHeadline)); $MessageFormat = $ProfileUserID == $Activity->ActivityUserID || $ProfileUserID == '' || !$ProfileHeadline ? $FullHeadline : $ProfileHeadline; return sprintf($MessageFormat, $ActivityName, $ActivityNameP, $RegardingName, $RegardingNameP, $RegardingWall, $Gender, $Gender2, $Route, $GenderSuffix, $RegardingWallLink, $ActivityRouteLink); }
/** * 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; }
public static function ProfileConnecUrl() { return Url(UserUrl(Gdn::Session()->User, FALSE, 'twitterconnect'), TRUE); }
/** * 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(); }
/** * 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>'; }
/** * 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')); // $Text = GetValue('Text', $Options, htmlspecialchars($Name)); // Allow anchor text to be overridden. $Text = GetValue('Text', $Options, ''); if ($Text == '') { // get all fields since that is better for caching! $profileFields = Gdn::userMetaModel()->getUserMeta($User->UserID, 'Profile.%', 'Profile.'); $Text = $profileFields['Profile.' . c('Nickname.Fieldname')]; if ($Text == '') { $Text = htmlspecialchars($Name); } // return } else { $Text = htmlspecialchars($Name); } $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>'; }
<?php if (!defined('APPLICATION')) { exit; } echo '<h2 class="H">' . T('Activity') . '</h2>'; $Session = Gdn::Session(); if ($Session->IsValid() && CheckPermission('Garden.Profiles.Edit')) { $this->FireEvent('BeforeStatusForm'); $ButtonText = $Session->UserID == $this->User->UserID ? 'Share' : 'Add Comment'; echo $this->Form->Open(array('action' => Url("/activity/post/{$this->User->UserID}?Target=" . urlencode(UserUrl($this->User))), 'class' => 'Activity')); echo $this->Form->Errors(); echo Wrap($this->Form->TextBox('Comment', array('MultiLine' => TRUE)), 'div', array('class' => 'TextBoxWrapper')); echo $this->Form->Button($ButtonText, array('class' => 'Button Primary')); echo $this->Form->Close(); } // Include the activities include $this->FetchViewLocation('index', 'activity', 'dashboard');
?> </title> <link><?php echo Url(UserUrl($Author, '', 'activity'), TRUE); ?> </link> <pubDate><?php echo date('r', Gdn_Format::ToTimeStamp(GetValue('DateUpdated', $Activity))); ?> </pubDate> <dc:creator><?php echo Gdn_Format::Text($Author->Name); ?> </dc:creator> <guid isPermaLink="false"><?php echo GetValue('ActivityID', $Activity) . '@' . Url(UserUrl($Author, '', 'activity')); ?> </guid> <?php if ($Story = GetValue('Story', $Activity)) { ?> <description><![CDATA[<?php echo Gdn_Format::RssHtml($Story, GetValue('Format', $Activity)); ?> ]]></description> <?php } ?> </item> <?php }
/** * Creates virtual 'Discussions' method in ProfileController. * * @since 2.0.0 * @package Vanilla * * @param ProfileController $Sender ProfileController. */ public function ProfileController_Discussions_Create($Sender, $UserReference = '', $Username = '', $Page = '', $UserID = '') { $Sender->EditMode(FALSE); // Tell the ProfileController what tab to load $Sender->GetUserInfo($UserReference, $Username, $UserID); $Sender->_SetBreadcrumbs(T('Discussions'), '/profile/discussions'); $Sender->SetTabView('Discussions', 'Profile', 'Discussions', 'Vanilla'); $Sender->CountCommentsPerPage = C('Vanilla.Comments.PerPage', 30); list($Offset, $Limit) = OffsetLimit($Page, Gdn::Config('Vanilla.Discussions.PerPage', 30)); $DiscussionModel = new DiscussionModel(); $Discussions = $DiscussionModel->GetByUser($Sender->User->UserID, $Limit, $Offset, FALSE, Gdn::Session()->UserID); $CountDiscussions = $Offset + $DiscussionModel->LastDiscussionCount + 1; $Sender->DiscussionData = $Sender->SetData('Discussions', $Discussions); // Build a pager $PagerFactory = new Gdn_PagerFactory(); $Sender->Pager = $PagerFactory->GetPager('MorePager', $Sender); $Sender->Pager->MoreCode = 'More Discussions'; $Sender->Pager->LessCode = 'Newer Discussions'; $Sender->Pager->ClientID = 'Pager'; $Sender->Pager->Configure($Offset, $Limit, $CountDiscussions, UserUrl($Sender->User, '', 'discussions') . '/{Page}'); // Deliver JSON data if necessary if ($Sender->DeliveryType() != DELIVERY_TYPE_ALL && $Offset > 0) { $Sender->SetJson('LessRow', $Sender->Pager->ToString('less')); $Sender->SetJson('MoreRow', $Sender->Pager->ToString('more')); $Sender->View = 'discussions'; } // 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) { // These pages offer only duplicate content to search engines and are a bit slow. $Sender->Head->AddTag('meta', array('name' => 'robots', 'content' => 'noindex,noarchive')); } // Render the ProfileController $Sender->Render(); }
function UserPhoto($User, $Options = array()) { $User = (object) $User; if (is_string($Options)) { $Options = array('LinkClass' => $Options); } $LinkClass = GetValue('LinkClass', $Options, 'ProfileLink'); $ImgClass = GetValue('ImageClass', $Options, 'ProfilePhotoMedium'); $LinkClass = $LinkClass == '' ? '' : ' class="' . $LinkClass . '"'; $Photo = $User->Photo; if (!$Photo && function_exists('UserPhotoDefaultUrl')) { $Photo = UserPhotoDefaultUrl($User); } if ($Photo) { if (!preg_match('`^https?://`i', $Photo)) { $PhotoUrl = Gdn_Upload::Url(ChangeBasename($Photo, 'n%s')); } else { $PhotoUrl = $Photo; } $Href = Url(UserUrl($User)); return '<a title="' . $User->Name . '" href="' . $Href . '"' . $LinkClass . '>' . Img($PhotoUrl, array('alt' => $User->Name, 'class' => $ImgClass)) . '</a>'; } else { return ''; } }
echo T('Thumbnail'); ?> </td> </tr> </thead> <tbody> <tr> <td><?php echo $Picture; if ($this->User->Photo != '' && $AllowImages && !$RemotePhoto) { echo Wrap(Anchor(T('Remove Picture'), CombinePaths(array(UserUrl($this->User, '', 'removepicture'), $Session->TransientKey())), 'Button Danger PopConfirm'), 'p'); ?> </td> <td><?php echo $Thumbnail; echo Wrap(Anchor(T('Edit Thumbnail'), UserUrl($this->User, '', 'thumbnail'), 'Button'), 'p'); } ?> </td> </tr> </tbody> </table> </li> <?php } ?> <li> <p><?php echo T('Select an image on your computer (2mb max)'); ?> </p>
/** * @param SiteNavModule $sender */ public function SiteNavModule_profile_handler($sender) { $user = Gdn::Controller()->Data('Profile'); $user_id = val('UserID', $user); // Show the activity. if (C('Garden.Profile.ShowActivities', TRUE)) { $sender->addLink('main.activity', array('text' => t('Activity'), 'url' => UserUrl($user, '', 'activity'), 'icon' => icon('time'))); } // Display the notifications for the current user. if (Gdn::Controller()->Data('Profile.UserID') == Gdn::Session()->UserID) { $sender->addLink('main.notifications', array('text' => t('Notifications'), 'url' => UserUrl($user, '', 'notifications'), 'icon' => icon('globe'), 'badge' => Gdn::Controller()->Data('Profile.CountNotifications'))); } // Show the invitations if we're using the invite registration method. if (strcasecmp(C('Garden.Registration.Method'), 'invitation') === 0) { $sender->addLink('main.invitations', array('text' => t('Invitations'), 'url' => UserUrl($User, '', 'invitations'), 'icon' => icon('ticket'))); } // Users can edit their own profiles and moderators can edit any profile. if (checkPermission(array('Garden.Users.Edit', 'Moderation.Profiles.Edit')) || $user_id == Gdn::Session()->UserID && C('Garden.UserAccount.AllowEdit') && C('Garden.Registration.Method') != 'Connect') { $sender->addLink('main.editprofile', array('text' => t('Edit Profile'), 'url' => UserUrl($user, '', 'edit'), 'icon' => icon('edit'))); } // Add a stub group for moderation. $sender->addGroup('moderation', array('text' => t('Moderation'), 'sort' => 90)); }
function WriteClassic($Results, $WriteText, $CssClass) { if (sizeof($Results) == 0) { //make sure there is something here return ''; } ob_start(); ?> <div class="SphinxSearch"> <ul class="DataList"> <?php foreach ($Results as $Row) { ?> <?php $Author->Photo = $Row->UserPhoto; $Author->Name = $Row->UserName; $Author->UserID = $Row->UserID; $TitleURL = $Row->IsComment ? 'discussion/comment/' . $Row->CommentID . '/#Comment_' . $Row->CommentID : DiscussionLink($Row, FALSE); //if the comment is from the orignal discussion poster, simply link to the front page of that ?> <li class="Item"> <div class="ItemContent"> <h4 class="Title"><?php echo Anchor($Row->Title . Wrap(htmlspecialchars(SliceString($Row->DiscussionBody, SS_PREVIEW_BODY_LIMIT)), 'span', array('class' => 'ToolTip')), $TitleURL, FALSE, array('class' => 'HasToolTip')); ?> </h4> <?php if ($WriteText) { ?> <div class="Message Excerpt"> <?php //echo nl2br(SliceString($Row->Body, SS_BODY_LIMIT)); This seemed to make MARKDOWN posts look correct - JJB ?> <?php echo SliceString($Row->Body, SS_BODY_LIMIT); ?> </div> <?php } ?> <div class="Meta"> <span class="MItem"><?php echo UserPhoto($Author, array('LinkClass' => '', 'ImageClass' => 'ProfilePhotoSmall PhotoWrap')); ?> </span> <span class="MItem"><?php echo Anchor($Row->UserName, UserUrl($Author)); ?> </span> <span class="MItem"><?php echo Anchor(Gdn_Format::Date($Row->DateInserted), 'discussion/' . $Row->DiscussionID . '/' . Gdn_Format::Url($Row->Title) . '/p1'); ?> </span> <span class="MItem"><?php echo Anchor($Row->CatName, 'discussion/' . $Row->DiscussionID . '/' . Gdn_Format::Url($Row->Title) . '/p1'); ?> </span> </div> </div> </li> <?php } ?> </ul> </div> <?php $String = ob_get_contents(); @ob_end_clean(); return $String; }
/** * Takes a user object, and writes out an anchor of the user's icon to the user's profile. * * @param object|array $User A user object or array. * @param array $Options */ function userPhoto($User, $Options = array()) { if (is_string($Options)) { $Options = array('LinkClass' => $Options); } if ($Px = GetValue('Px', $Options)) { $User = UserBuilder($User, $Px); } else { $User = (object) $User; } $LinkClass = ConcatSep(' ', GetValue('LinkClass', $Options, ''), 'PhotoWrap'); $ImgClass = GetValue('ImageClass', $Options, 'ProfilePhoto'); $Size = GetValue('Size', $Options); if ($Size) { $LinkClass .= " PhotoWrap{$Size}"; $ImgClass .= " {$ImgClass}{$Size}"; } else { $ImgClass .= " {$ImgClass}Medium"; // backwards compat } $FullUser = Gdn::UserModel()->GetID(GetValue('UserID', $User), DATASET_TYPE_ARRAY); $UserCssClass = GetValue('_CssClass', $FullUser); if ($UserCssClass) { $LinkClass .= ' ' . $UserCssClass; } $LinkClass = $LinkClass == '' ? '' : ' class="' . $LinkClass . '"'; $Photo = GetValue('Photo', $User); $Name = GetValue('Name', $User); $Title = htmlspecialchars(GetValue('Title', $Options, $Name)); if ($FullUser && $FullUser['Banned']) { $Photo = C('Garden.BannedPhoto', 'http://cdn.vanillaforums.com/images/banned_large.png'); $Title .= ' (' . T('Banned') . ')'; } if (!$Photo && function_exists('UserPhotoDefaultUrl')) { $Photo = UserPhotoDefaultUrl($User, $ImgClass); } if ($Photo) { if (!isUrl($Photo)) { $PhotoUrl = Gdn_Upload::Url(ChangeBasename($Photo, 'n%s')); } else { $PhotoUrl = $Photo; } $Href = Url(UserUrl($User)); return '<a title="' . $Title . '" href="' . $Href . '"' . $LinkClass . '>' . Img($PhotoUrl, array('alt' => $Name, 'class' => $ImgClass)) . '</a>'; } else { return ''; } }
protected function NotifyWallPost($WallPost) { $NotifyUser = Gdn::UserModel()->GetID($WallPost['ActivityUserID']); $Activity = array('ActivityType' => 'WallPost', 'ActivityUserID' => $WallPost['RegardingUserID'], 'Format' => $WallPost['Format'], 'NotifyUserID' => $WallPost['ActivityUserID'], 'RecordType' => 'Activity', 'RecordID' => $WallPost['ActivityID'], 'RegardingUserID' => $WallPost['ActivityUserID'], 'Route' => UserUrl($NotifyUser, ''), 'Story' => $WallPost['Story'], 'HeadlineFormat' => T('HeadlineFormat.NotifyWallPost', '{ActivityUserID,User} posted on your <a href="{Url,url}">wall</a>.')); $this->Save($Activity, 'WallComment'); }
/** * * * @param $Filename * @param $Get * @return bool|string */ public function filenameRedirect($Filename, $Get) { trace(['Filename' => $Filename, 'Get' => $Get], 'Testing'); $Filename = strtolower($Filename); array_change_key_case($Get); if (!isset(self::$Files[$Filename])) { return false; } $Row = self::$Files[$Filename]; if (is_callable($Row)) { // Use a callback to determine the translation. $Row = call_user_func_array($Row, [&$Get]); } trace($Get, 'New Get'); // Translate all of the get parameters into new parameters. $Vars = array(); foreach ($Get as $Key => $Value) { if (!isset($Row[$Key])) { continue; } $Opts = (array) $Row[$Key]; if (isset($Opts['Filter'])) { // Call the filter function to change the value. $R = call_user_func($Opts['Filter'], $Value, $Opts[0]); if (is_array($R)) { if (isset($R[0])) { // The filter can change the column name too. $Opts[0] = $R[0]; $Value = $R[1]; } else { // The filter can return return other variables too. $Vars = array_merge($Vars, $R); $Value = null; } } else { $Value = $R; } } if ($Value !== null) { $Vars[$Opts[0]] = $Value; } } trace($Vars, 'Translated Arguments'); // Now let's see what kind of record we have. // We'll check the various primary keys in order of importance. $Result = false; if (isset($Vars['CommentID'])) { trace("Looking up comment {$Vars['CommentID']}."); $CommentModel = new CommentModel(); // If a legacy slug is provided (assigned during a merge), attempt to lookup the comment using it if (isset($Get['legacy']) && Gdn::Structure()->Table('Comment')->ColumnExists('ForeignID')) { $Comment = $CommentModel->GetWhere(['ForeignID' => $Get['legacy'] . '-' . $Vars['CommentID']])->FirstRow(); } else { $Comment = $CommentModel->GetID($Vars['CommentID']); } if ($Comment) { $Result = CommentUrl($Comment, '//'); } } elseif (isset($Vars['DiscussionID'])) { trace("Looking up discussion {$Vars['DiscussionID']}."); $DiscussionModel = new DiscussionModel(); $DiscussionID = $Vars['DiscussionID']; $Discussion = false; if (is_numeric($DiscussionID)) { // If a legacy slug is provided (assigned during a merge), attempt to lookup the discussion using it if (isset($Get['legacy']) && Gdn::Structure()->Table('Discussion')->ColumnExists('ForeignID')) { $Discussion = $DiscussionModel->GetWhere(['ForeignID' => $Get['legacy'] . '-' . $DiscussionID])->FirstRow(); } else { $Discussion = $DiscussionModel->GetID($Vars['DiscussionID']); } } else { // This is a slug style discussion ID. Let's see if there is a UrlCode column in the discussion table. $DiscussionModel->DefineSchema(); if ($DiscussionModel->Schema->FieldExists('Discussion', 'UrlCode')) { $Discussion = $DiscussionModel->GetWhere(['UrlCode' => $DiscussionID])->FirstRow(); } } if ($Discussion) { $Result = DiscussionUrl($Discussion, self::pageNumber($Vars, 'Vanilla.Comments.PerPage'), '//'); } } elseif (isset($Vars['UserID'])) { trace("Looking up user {$Vars['UserID']}."); $User = Gdn::UserModel()->GetID($Vars['UserID']); if ($User) { $Result = Url(UserUrl($User), '//'); } } elseif (isset($Vars['TagID'])) { $Tag = TagModel::instance()->GetID($Vars['TagID']); if ($Tag) { $Result = TagUrl($Tag, self::pageNumber($Vars, 'Vanilla.Discussions.PerPage'), '//'); } } elseif (isset($Vars['CategoryID'])) { trace("Looking up category {$Vars['CategoryID']}."); // If a legacy slug is provided (assigned during a merge), attempt to lookup the category ID based on it if (isset($Get['legacy']) && Gdn::Structure()->Table('Category')->ColumnExists('ForeignID')) { $CategoryModel = new CategoryModel(); $Category = $CategoryModel->GetWhere(['ForeignID' => $Get['legacy'] . '-' . $Vars['CategoryID']])->FirstRow(); } else { $Category = CategoryModel::Categories($Vars['CategoryID']); } if ($Category) { $Result = categoryUrl($Category, self::pageNumber($Vars, 'Vanilla.Discussions.PerPage'), '//'); } } elseif (isset($Vars['CategoryCode'])) { trace("Looking up category {$Vars['CategoryCode']}."); $category = CategoryModel::instance()->getByCode($Vars['CategoryCode']); if ($category) { $pageNumber = self::pageNumber($Vars, 'Vanilla.Discussions.PerPage'); if ($pageNumber > 1) { $pageParam = '?Page=' . $pageNumber; } else { $pageParam = null; } $Result = categoryUrl($category, '', '//') . $pageParam; } } return $Result; }
if ($Session->CheckPermission('Garden.Applicants.Manage')) { $RoleModel = new RoleModel(); $ApplicantCount = $RoleModel->GetApplicantCount(); $DashboardCount += $ApplicantCount; } if ($Session->IsValid()) { echo '<div class="MeBox' . $CssClass . '">'; echo UserPhoto($User); echo '<div class="WhoIs">'; echo UserAnchor($User, 'Username'); echo '<div class="MeMenu">'; // Notifications $CountNotifications = $User->CountNotifications; $CNotifications = is_numeric($CountNotifications) && $CountNotifications > 0 ? '<span class="Alert">' . $CountNotifications . '</span>' : ''; echo '<span class="ToggleFlyout" rel="/profile/notificationspopin">'; echo Anchor(Sprite('SpNotifications', 'Sprite Sprite16') . Wrap(T('Notifications'), 'em') . $CNotifications, UserUrl($User), 'MeButton FlyoutButton', array('title' => T('Notifications'))); echo Sprite('SpFlyoutHandle', 'Arrow'); echo '<div class="Flyout FlyoutMenu"></div></span>'; // Inbox if (Gdn::ApplicationManager()->CheckApplication('Conversations')) { $CountInbox = GetValue('CountUnreadConversations', Gdn::Session()->User); $CInbox = is_numeric($CountInbox) && $CountInbox > 0 ? ' <span class="Alert">' . $CountInbox . '</span>' : ''; echo '<span class="ToggleFlyout" rel="/messages/popin">'; echo Anchor(Sprite('SpInbox', 'Sprite Sprite16') . Wrap(T('Inbox'), 'em') . $CInbox, '/messages/all', 'MeButton FlyoutButton', array('title' => T('Inbox'))); echo Sprite('SpFlyoutHandle', 'Arrow'); echo '<div class="Flyout FlyoutMenu"></div></span>'; } // Bookmarks if (Gdn::ApplicationManager()->CheckApplication('Vanilla')) { echo '<span class="ToggleFlyout" rel="/discussions/bookmarkedpopin">'; echo Anchor(Sprite('SpBookmarks', 'Sprite Sprite16') . Wrap(T('Bookmarks'), 'em'), '/discussions/bookmarked', 'MeButton FlyoutButton', array('title' => T('Bookmarks')));
public function DeleteContent($UserID) { $this->Permission('Garden.Moderation.Manage'); $User = Gdn::UserModel()->GetID($UserID); if (!$User) { throw NotFoundException('User'); } if ($this->Form->AuthenticatedPostBack()) { Gdn::UserModel()->DeleteContent($UserID, array('Log' => TRUE)); if ($this->Request->Get('Target')) { $this->RedirectUrl = Url($this->Request->Get('Target')); } else { $this->RedirectUrl = Url(UserUrl($User)); } } else { $this->SetData('Title', T('Are you sure you want to do this?')); } $this->SetData('User', $User); $this->Render(); }
<?php if (!defined('APPLICATION')) { exit; } ?> <div class="Box InThisConversation"> <?php echo panelHeading(T('In this Conversation')); ?> <ul class="PanelInfo"> <?php foreach ($this->Data->Result() as $User) { ?> <li> <?php $Username = htmlspecialchars(GetValue('Name', $User)); $Photo = GetValue('Photo', $User); if (GetValue('Deleted', $User)) { echo Anchor(Wrap(Img($Photo, array('class' => 'ProfilePhoto ProfilePhotoSmall')) . ' ' . Wrap($Username, 'del', array('class' => 'Username')), 'span', array('class' => 'Conversation-User')), UserUrl($User), array('title' => sprintf(T('%s has left this conversation.'), $Username))); } else { echo Anchor(Wrap(Img($Photo, array('class' => 'ProfilePhoto ProfilePhotoSmall')) . ' ' . Wrap($Username, 'span', array('class' => 'Username')), 'span', array('class' => 'Conversation-User')), UserUrl($User)); } ?> </li> <?php } ?> </ul> </div>
/** * You can manually award badges to users for special cases * * @param int $UserID * @throws Gdn_UserException */ public function Award($UserID) { // Check permission $this->Permission('Yaga.Badges.Add'); $this->AddSideMenu('badge/settings'); // Only allow awarding if some badges exist if (!$this->BadgeModel->GetCount()) { throw new Gdn_UserException(T('Yaga.Error.NoBadges')); } $UserModel = Gdn::UserModel(); $User = $UserModel->GetID($UserID); $this->SetData('Username', $User->Name); $Badges = $this->BadgeModel->Get(); $Badgelist = array(); foreach ($Badges as $Badge) { $Badgelist[$Badge->BadgeID] = $Badge->Name; } $this->SetData('Badges', $Badgelist); if ($this->Form->IsPostBack() == FALSE) { // Add the user id field $this->Form->AddHidden('UserID', $User->UserID); } else { $Validation = new Gdn_Validation(); $Validation->ApplyRule('UserID', 'ValidateRequired'); $Validation->ApplyRule('BadgeID', 'ValidateRequired'); if ($Validation->Validate($this->Request->Post())) { $FormValues = $this->Form->FormValues(); if ($this->BadgeAwardModel->Exists($FormValues['UserID'], $FormValues['BadgeID'])) { $this->Form->AddError(sprintf(T('Yaga.Badge.AlreadyAwarded'), $User->Name), 'BadgeID'); // Need to respecify the user id $this->Form->AddHidden('UserID', $User->UserID); } if ($this->Form->ErrorCount() == 0) { $this->BadgeAwardModel->Award($FormValues['BadgeID'], $FormValues['UserID'], Gdn::Session()->UserID, $FormValues['Reason']); if ($this->Request->Get('Target')) { $this->RedirectUrl = $this->Request->Get('Target'); } elseif ($this->DeliveryType() == DELIVERY_TYPE_ALL) { $this->RedirectUrl = Url(UserUrl($User)); } else { $this->JsonTarget('', '', 'Refresh'); } } } else { $this->Form->SetValidationResults($Validation->Results()); } } $this->Render(); }