public function ToString() { $String = ''; ob_start(); ?> <div class="Box"> <h4><?php echo Gdn::Translate('In this Discussion'); ?> </h4> <ul class="PanelInfo"> <?php foreach ($this->_UserData->Result() as $User) { ?> <li> <strong><?php echo Anchor($User->Name, '/profile/' . urlencode($User->Name), 'UserLink'); ?> </strong> <?php echo Format::Date($User->DateLastActive); ?> </li> <?php } ?> </ul> </div> <?php $String = ob_get_contents(); @ob_end_clean(); return $String; }
function WriteComment($Comment, &$Sender, &$Session, $CurrentOffset) { $Author = UserBuilder($Comment, 'Insert'); $Sender->EventArguments['Comment'] =& $Comment; $Sender->Options = ''; $CssClass = 'Item Comment'; $CssClass .= $Comment->InsertUserID == $Session->UserID ? ' Mine' : ''; ?> <li class="<?php echo $CssClass; ?> " id="Comment_<?php echo $Comment->CommentID; ?> "> <?php WriteOptions($Comment, $Sender, $Session); ?> <div class="Comment"> <div class="Meta"> <span class="Author"> <?php echo UserPhoto($Author); echo UserAnchor($Author); ?> </span> <span class="DateCreated"> <?php echo Format::Date($Comment->DateInserted); ?> </span> <span class="Permalink"> <?php echo Anchor(T('Permalink'), '/discussion/comment/' . $Comment->CommentID . '/#Comment_' . $Comment->CommentID, 'Permalink', array('name' => 'Item_' . $CurrentOffset)); ?> </span> <?php $Sender->FireEvent('AfterCommentMeta'); ?> </div> <div class="Message"><?php echo Format::To($Comment->Body, $Comment->Format); ?> </div> <?php $Sender->FireEvent('AfterCommentBody'); ?> </div> </li> <?php }
public static function WriteReply(&$Sender, &$Session) { ?> <li class="Reply" id="Comment_<?php echo $Sender->CurrentReply->CommentID; ?> "> <?php // Delete comment if ($Session->CheckPermission('Vanilla.Comments.Delete', $Sender->Discussion->CategoryID)) { echo Anchor(Gdn::Translate('Delete'), 'vanilla/discussion/deletecomment/' . $Sender->CurrentReply->CommentID . '/' . $Session->TransientKey(), 'DeleteReply'); } ?> <ul class="Info<?php echo $Sender->CurrentReply->InsertUserID == $Session->UserID ? ' Author' : ''; ?> "> <li class="Author"><?php $Author = UserBuilder($Sender->CurrentReply, 'Insert'); echo UserPhoto($Author); echo UserAnchor($Author); ?> </li> <li class="Created"><?php echo Format::Date($Sender->CurrentReply->DateInserted); ?> </li> <li class="Permalink"><?php echo Anchor(Gdn::Translate('Permalink'), '/discussion/comment/' . (isset($Sender->CurrentComment) ? $Sender->CurrentComment->CommentID : $Sender->ReplyCommentID) . '/#Comment_' . $Sender->CurrentReply->CommentID, Gdn::Translate('Permalink')); ?> </li> </ul> <div class="Body"><?php echo Format::To($Sender->CurrentReply->Body, $Sender->CurrentReply->Format); ?> </div> </li> <?php }
public function GetInvitationCount($UserID) { // If this user is master admin, they should have unlimited invites. if ($this->SQL->Select('UserID')->From('User')->Where('UserID', $UserID)->Where('Admin', '1')->Get()->NumRows() > 0) { return -1; } // Get the Registration.InviteRoles settings: $InviteRoles = Gdn::Config('Garden.Registration.InviteRoles', array()); if (!is_array($InviteRoles) || count($InviteRoles) == 0) { return 0; } // Build an array of roles that can send invitations $CanInviteRoles = array(); foreach ($InviteRoles as $RoleID => $Invites) { if ($Invites > 0 || $Invites == -1) { $CanInviteRoles[] = $RoleID; } } if (count($CanInviteRoles) == 0) { return 0; } // See which matching roles the user has $UserRoleData = $this->SQL->Select('RoleID')->From('UserRole')->Where('UserID', $UserID)->WhereIn('RoleID', $CanInviteRoles)->Get(); if ($UserRoleData->NumRows() == 0) { return 0; } // Define the maximum number of invites the user is allowed to send $InviteCount = 0; foreach ($UserRoleData->Result() as $UserRole) { $Count = $InviteRoles[$UserRole->RoleID]; if ($Count == -1) { $InviteCount = -1; } else { if ($InviteCount != -1 && $Count > $InviteCount) { $InviteCount = $Count; } } } // If the user has unlimited invitations, return that value if ($InviteCount == -1) { return -1; } // Get the user's current invitation settings from their profile $User = $this->SQL->Select('CountInvitations, DateSetInvitations')->From('User')->Where('UserID', $UserID)->Get()->FirstRow(); // If CountInvitations is null (ie. never been set before) or it is a new month since the DateSetInvitations if ($User->CountInvitations == '' || is_null($User->DateSetInvitations) || Format::Date($User->DateSetInvitations, 'n Y') != Format::Date('', 'n Y')) { // Reset CountInvitations and DateSetInvitations $this->SQL->Put($this->Name, array('CountInvitations' => $InviteCount, 'DateSetInvitations' => Format::Date('', 'Y-m-01')), array('UserID' => $UserID)); return $InviteCount; } else { // Otherwise return CountInvitations return $User->CountInvitations; } }
// If this was a status update or a wall comment, don't bother with activity strings $ActivityType = explode(' ', $Activity->ActivityType); // Make sure you strip out any extra css classes munged in here $ActivityType = $ActivityType[0]; $Author = UserBuilder($Activity, 'Activity'); if (in_array($ActivityType, array('WallComment', 'AboutUpdate'))) { echo UserAnchor($Author, 'Name'); if ($Activity->ActivityType == 'WallComment' && $Activity->RegardingUserID > 0) { $Author = UserBuilder($Activity, 'Regarding'); echo '<span>→</span>' . UserAnchor($Author, 'Name'); } echo Format::Display($Activity->Story); echo '<em>' . Format::Date($Activity->DateInserted) . '</em>'; } else { echo Format::ActivityHeadline($Activity); echo '<em>' . Format::Date($Activity->DateInserted) . '</em>'; if ($Activity->Story != '') { echo '<div class="Story">'; echo $Activity->Story; echo '</div>'; } } echo '</li>'; } ?> <li class="ShowAll"><?php echo Anchor(T('↳ Show All'), 'activity'); ?> </li> </ul> </div>
?> <li class="Item"> <div class="ItemContent"> <?php echo Anchor(Format::Text($Row->Title), $Row->Url, 'Title'); ?> <div class="Excerpt"><?php echo Anchor(Format::Text(SliceString($Row->Summary, 250)), $Row->Url); ?> </div> <div class="Meta"> <span><?php printf(T('Comment by %s'), UserAnchor($Row)); ?> </span> <span><?php echo Format::Date($Row->DateInserted); ?> </span> <span><?php echo Anchor(T('permalink'), $Row->Url); ?> </span> </div> </div> </li> <?php } } ?> </ul>
if (!defined('APPLICATION')) { exit; } if (property_exists($this, 'Discussion')) { ?> <h2><?php echo Format::Text($this->Discussion->Name); ?> </h2> <?php } ?> <ul class="Discussion Preview"> <li class="Comment"> <ul class="Info"> <li class="Author"><?php echo UserPhoto($this->Comment->InsertName, $this->Comment->InsertPhoto); echo UserAnchor($this->Comment->InsertName); ?> </li> <li class="Created"><?php echo Format::Date($this->Comment->DateInserted); ?> </li> </ul> <div class="Body"><?php echo Format::To($this->Comment->Body, Gdn::Config('Garden.InputFormatter')); ?> </div> </li> </ul>
<li class="five"><a href="../post/discussion">Start your first discussion</a></li> </ul> */ ?> <h3><?php echo Gdn::Translate("What's the Buzz?"); ?> </h3> <dl> <?php $Count = count($this->BuzzData); foreach ($this->BuzzData as $Name => $Value) { echo '<dt>' . $Value . '</dt> <dd>' . $Name . '</dd>'; } ?> </dl> <h3><?php echo Gdn::Translate('Recently Active Users'); ?> </h3> <ul class="DataList RecentUsers"> <?php $i = 0; foreach ($this->ActiveUserData as $User) { $Css = $User->Photo != '' ? 'HasPhoto' : ''; echo '<li' . ($Css != '' ? ' class="' . $Css . '"' : '') . '>', UserPhoto($User->Name, $User->Photo), UserAnchor($User->Name), sprintf(Gdn::Translate('Last active %s'), Format::Date($User->DateLastActive)), '</li>'; } ?> </ul>
function WriteActivityComment($Comment, &$Sender, &$Session) { ?> <li id="Activity_<?php echo $Comment->ActivityID; ?> " class="<?php echo $Comment->ActivityType; ?> "><?php if ($Comment->ActivityPhoto != '') { if ($Comment->InsertUserID == $Session->UserID) { echo '<a href="' . Url('/garden/profile/' . urlencode($Comment->ActivityName)) . '">' . $Sender->Html->Image('uploads/n' . $Comment->ActivityPhoto) . '</a>'; } else { echo $Sender->Html->Image('uploads/n' . $Comment->ActivityPhoto); } } ?> <h3><?php echo $Session->UserID == $Comment->InsertUserID || $Session->CheckPermission('Garden.Activity.Delete') ? Anchor('Delete', 'garden/activity/delete/' . $Comment->ActivityID . '/' . $Session->TransientKey() . '?Return=' . urlencode(Gdn_Url::Request()), 'Delete') : ''; ?> <strong><?php echo Format::ActivityHeadline($Comment, $Sender->ProfileUserID); ?> <em><?php echo Format::Date($Comment->DateInserted); ?> </em></strong></h3> <blockquote><?php echo Format::Display($Comment->Story); ?> </blockquote> </li> <?php }
function WriteActivityComment($Comment, &$Sender, &$Session) { $Author = UserBuilder($Comment, 'Activity'); $PhotoAnchor = UserPhoto($Author, 'Photo'); $CssClass = 'Item ActivityComment Condensed ' . $Comment->ActivityType; if ($PhotoAnchor != '') { $CssClass .= ' HasPhoto'; } ?> <li id="Activity_<?php echo $Comment->ActivityID; ?> " class="<?php echo $CssClass; ?> "> <?php if ($PhotoAnchor != '') { ?> <div class="Photo"><?php echo $PhotoAnchor; ?> </div> <?php } ?> <div class="ItemContent ActivityComment"> <?php echo UserAnchor($Author, 'Title Name'); ?> <div class="Excerpt"><?php echo Format::Display($Comment->Story); ?> </div> <div class="Meta"> <span class="DateCreated"><?php echo Format::Date($Comment->DateInserted); ?> </span> <?php if ($Session->UserID == $Comment->InsertUserID || $Session->CheckPermission('Garden.Activity.Delete')) { echo Anchor(T('Delete'), 'garden/activity/delete/' . $Comment->ActivityID . '/' . $Session->TransientKey() . '?Return=' . urlencode(Gdn_Url::Request()), 'DeleteComment'); } ?> </div> </div> </li> <?php }
function WriteDiscussion($Discussion, &$Sender, &$Session, $Alt) { $CssClass = 'Item'; $CssClass .= $Discussion->Bookmarked == '1' ? ' Bookmarked' : ''; $CssClass .= $Alt . ' '; $CssClass .= $Discussion->Announce == '1' ? ' Announcement' : ''; $CssClass .= $Discussion->InsertUserID == $Session->UserID ? ' Mine' : ''; $CountUnreadComments = $Discussion->CountComments - $Discussion->CountCommentWatch; $CssClass .= $CountUnreadComments > 0 && $Session->IsValid() ? ' New' : ''; $Sender->EventArguments['Discussion'] =& $Discussion; $Last = UserBuilder($Discussion, 'Last'); ?> <li class="<?php echo $CssClass; ?> "> <?php WriteOptions($Discussion, $Sender, $Session); ?> <div class="ItemContent Discussion"> <?php echo Anchor(Format::Text($Discussion->Name), '/discussion/' . $Discussion->DiscussionID . '/' . Format::Url($Discussion->Name) . ($Discussion->CountCommentWatch > 0 ? '/#Item_' . $Discussion->CountCommentWatch : ''), 'Title'); ?> <?php $Sender->FireEvent('AfterDiscussionTitle'); ?> <div class="Meta"> <?php if ($Discussion->Announce == '1') { ?> <span class="Announcement"><?php echo T('Announcement'); ?> </span> <?php } ?> <span><?php printf(Plural($Discussion->CountComments, '%s comment', '%s comments'), $Discussion->CountComments); ?> </span> <?php if ($CountUnreadComments > 0 && $Session->IsValid()) { echo '<strong>', sprintf(T('%s new'), $CountUnreadComments), '</strong>'; } ?> <span><?php printf(T('Most recent by %1$s %2$s'), UserAnchor($Last), Format::Date($Discussion->LastDate)); ?> </span> <span><?php echo Anchor($Discussion->Category, '/categories/' . $Discussion->CategoryUrlCode, 'Category'); ?> </span> <?php $Sender->FireEvent('DiscussionMeta'); ?> </div> </div> </li> <?php }
?> </th> </tr> </thead> <tbody> <?php foreach ($this->UserData->Result('Text') as $User) { ?> <tr> <td><?php echo $this->Form->CheckBox('Applicants[]', '', array('value' => $User->UserID)); ?> </td> <td class="Alt"> <?php printf(Gdn::Translate('<strong>%1$s</strong> (%2$s) %3$s'), $User->Name, Format::Email($User->Email), Format::Date($User->DateInserted)); echo '<blockquote>' . $User->DiscoveryText . '</blockquote>'; ?> </td> <td><?php echo Anchor('Approve', '/user/approve/' . $User->UserID . '/' . $Session->TransientKey()) . ', ' . Anchor('Decline', '/user/decline/' . $User->UserID . '/' . $Session->TransientKey()); ?> </td> </tr> <?php } ?> </tbody> </table> <?php echo $this->Form->Button('Approve', array('name' => $this->Form->EscapeFieldName('Submit'), 'class' => 'SmallButton'));
function WriteComment($Comment, &$Sender, &$Session, $CurrentOffset) { ?> <li class="Comment<?php echo $Comment->InsertUserID == $Session->UserID ? ' Mine' : ''; ?> " id="Comment_<?php echo $Comment->CommentID; ?> "> <?php $Sender->EventArguments['Comment'] =& $Comment; $Sender->Options = ''; $IsFirstComment = $Comment->CommentID == $Sender->Discussion->FirstCommentID; if ($IsFirstComment && ($Session->UserID == $Comment->InsertUserID || $Session->CheckPermission('Vanilla.Discussions.Edit', $Sender->Discussion->CategoryID))) { // User can edit the discussion topic/first comment $Sender->Options .= '<li>' . Anchor('Edit', '/vanilla/post/editdiscussion/' . $Comment->DiscussionID, 'EditDiscussion') . '</li>'; } else { if ($Session->UserID == $Comment->InsertUserID || $Session->CheckPermission('Vanilla.Comments.Edit', $Sender->Discussion->CategoryID)) { // User can edit the comment $Sender->Options .= '<li>' . Anchor('Edit', '/vanilla/post/editcomment/' . $Comment->CommentID, 'EditComment') . '</li>'; } } if ($IsFirstComment) { // Announce discussion if ($Session->CheckPermission('Vanilla.Discussions.Announce', $Sender->Discussion->CategoryID)) { $Sender->Options .= '<li>' . Anchor($Sender->Discussion->Announce == '1' ? 'Unannounce' : 'Announce', 'vanilla/discussion/announce/' . $Comment->DiscussionID . '/' . $Session->TransientKey(), 'AnnounceDiscussion') . '</li>'; } // Sink discussion if ($Session->CheckPermission('Vanilla.Discussions.Sink', $Sender->Discussion->CategoryID)) { $Sender->Options .= '<li>' . Anchor($Sender->Discussion->Sink == '1' ? 'Unsink' : 'Sink', 'vanilla/discussion/sink/' . $Comment->DiscussionID . '/' . $Session->TransientKey() . '?Target=' . urlencode($Sender->SelfUrl), 'SinkDiscussion') . '</li>'; } // Close discussion if ($Session->CheckPermission('Vanilla.Discussions.Close', $Sender->Discussion->CategoryID)) { $Sender->Options .= '<li>' . Anchor($Sender->Discussion->Closed == '1' ? 'Reopen' : 'Close', 'vanilla/discussion/close/' . $Comment->DiscussionID . '/' . $Session->TransientKey() . '?Target=' . urlencode($Sender->SelfUrl), 'CloseDiscussion') . '</li>'; } // Delete discussion if ($Session->CheckPermission('Vanilla.Discussions.Delete', $Sender->Discussion->CategoryID)) { $Sender->Options .= '<li>' . Anchor('Delete Discussion', 'vanilla/discussion/delete/' . $Comment->DiscussionID . '/' . $Session->TransientKey(), 'DeleteDiscussion') . '</li>'; } } else { // Delete comment if ($Session->CheckPermission('Vanilla.Comments.Delete', $Sender->Discussion->CategoryID)) { $Sender->Options .= '<li>' . Anchor('Delete', 'vanilla/discussion/deletecomment/' . $Comment->CommentID . '/' . $Session->TransientKey() . '/?Target=' . urlencode($Sender->SelfUrl), 'DeleteComment') . '</li>'; } } // Allow plugins to add options $Sender->FireEvent('CommentOptions'); if ($Sender->Options != '') { ?> <ul class="Options"> <li><strong><?php echo Gdn::Translate('Options'); ?> </strong> <ul> <?php echo $Sender->Options; ?> </ul> </li> </ul> <?php } ?> <ul class="Info"> <li class="Author"> <?php $Author = UserBuilder($Comment, 'Insert'); echo UserPhoto($Author); echo UserAnchor($Author); ?> </li> <li class="Created"> <?php echo Format::Date($Comment->DateInserted); ?> </li> <li class="Permalink"> <?php echo Anchor(Gdn::Translate('Permalink'), '/discussion/comment/' . $Comment->CommentID . '/#Comment_' . $Comment->CommentID, 'Permalink', array('name' => 'Item_' . $CurrentOffset)); ?> </li> <?php $Sender->FireEvent('AfterCommentMeta'); ?> </ul> <div class="Body"><?php echo Format::To($Comment->Body, $Comment->Format); ?> </div> <?php $Sender->FireEvent('AfterCommentBody'); ?> </li> <?php }
<?php if (!defined('APPLICATION')) { exit; } // An individual discussion record for all panel modules to use when rendering a discussion list. ?> <li id="<?php echo 'Bookmark_' . $Discussion->DiscussionID; ?> "> <strong><?php echo Anchor($Discussion->Name, '/discussion/' . $Discussion->DiscussionID . '/' . Format::Url($Discussion->Name) . ($Discussion->CountCommentWatch > 0 ? '/#Item_' . $Discussion->CountCommentWatch : ''), 'DiscussionLink'); ?> </strong> <div class="Meta"> <?php echo '<span>' . $Discussion->CountComments . '</span>'; $CountUnreadComments = $Discussion->CountComments - $Discussion->CountCommentWatch; if ($CountUnreadComments > 0) { echo '<strong>' . sprintf('%s new', $CountUnreadComments) . '</strong>'; } $Last = new stdClass(); $Last->UserID = $Discussion->LastUserID; $Last->Name = $Discussion->LastName; echo '<span>' . Format::Date($Discussion->LastDate) . ' ' . UserAnchor($Last) . '</span>'; ?> </div> </li>
function WriteActivityComment($Comment, &$Sender, &$Session) { ?> <li id="Activity_<?php echo $Comment->ActivityID; ?> " class="<?php echo $Comment->ActivityType; if ($Comment->ActivityPhoto != '') { echo ' HasPhoto'; } ?> "><?php if ($Comment->ActivityPhoto != '') { echo '<a href="' . Url('/garden/profile/' . urlencode($Comment->ActivityName)) . '" class="Photo">' . $Sender->Html->Image('uploads/n' . $Comment->ActivityPhoto) . '</a>'; } echo '<div>'; echo UserAnchor($Comment->ActivityName, 'Name'); echo Format::Display($Comment->Story); echo '<div class="Meta">'; echo Format::Date($Comment->DateInserted); echo $Session->UserID == $Comment->InsertUserID || $Session->CheckPermission('Garden.Activity.Delete') ? '<span>•</span>' . Anchor('Delete', 'garden/activity/delete/' . $Comment->ActivityID . '/' . $Session->TransientKey() . '?Return=' . urlencode(Gdn_Url::Request())) : ''; echo '</div>'; echo '</div>'; ?> </li> <?php }
echo $Invitation->Code; ?> </td> <td class="Alt"><?php if ($Invitation->AcceptedName == '') { echo $Invitation->Email; } else { echo Anchor($Invitation->AcceptedName, '/profile/' . $Invitation->AcceptedUserID); } if ($Invitation->AcceptedName == '') { echo '<div>' . Anchor(Gdn::Translate('Uninvite'), '/profile/uninvite/' . $Invitation->InvitationID . '/' . $Session->TransientKey(), 'Uninvite') . ' | ' . Anchor(Gdn::Translate('Send Again'), '/profile/sendinvite/' . $Invitation->InvitationID . '/' . $Session->TransientKey(), 'SendAgain') . '</div>'; } ?> </td> <td><?php echo Format::Date($Invitation->DateInserted); ?> </td> <td class="Alt"><?php if ($Invitation->AcceptedName == '') { echo Gdn::Translate('Pending'); } else { echo Gdn::Translate('Accepted'); } ?> </td> </tr> <?php } ?> </tbody>
echo ' ' . $Activity->ActivityType; ?> "><?php if ($Activity->ActivityPhoto != '' && $Activity->ShowIcon == '1') { if ($Activity->InsertUserID == $Session->UserID) { echo '<a href="' . Url('/garden/profile/' . urlencode($Activity->ActivityName)) . '">' . $this->Html->Image('uploads/n' . $Activity->ActivityPhoto) . '</a>'; } else { echo $this->Html->Image('uploads/n' . $Activity->ActivityPhoto); } } ?> <h3><strong><?php echo Format::ActivityHeadline($Activity, $Session->UserID); ?> <em><?php echo Format::Date($Activity->DateInserted); ?> </em></strong></h3> <?php if ($Activity->Story != '') { ?> <blockquote><?php echo Format::Html($Activity->Story); ?> </blockquote> <?php } ?> </li> <?php }
function WriteDiscussion($Discussion, &$Sender, &$Session, $Alt) { $CssClass = 'DiscussionRow'; $CssClass .= $Discussion->Bookmarked == '1' ? ' Bookmarked' : ''; $CssClass .= $Alt . ' '; $CssClass .= $Discussion->Announce == '1' ? ' Announcement' : ''; $CssClass .= $Discussion->InsertUserID == $Session->UserID ? ' Mine' : ''; $CountUnreadComments = $Discussion->CountComments - $Discussion->CountCommentWatch; $CssClass .= $CountUnreadComments > 0 && $Session->IsValid() ? ' New' : ''; ?> <li class="<?php echo $CssClass; ?> "> <ul class="Discussion"> <?php if ($Sender->ShowOptions) { ?> <li class="Options"> <?php // Build up the options that the user has for each discussion if ($Session->IsValid()) { // Bookmark link echo Anchor('<span>*</span>', '/vanilla/discussion/bookmark/' . $Discussion->DiscussionID . '/' . $Session->TransientKey() . '?Target=' . urlencode($Sender->SelfUrl), 'Bookmark' . ($Discussion->Bookmarked == '1' ? ' Bookmarked' : ''), array('title' => Gdn::Translate($Discussion->Bookmarked == '1' ? 'Unbookmark' : 'Bookmark'))); $Sender->Options = ''; // Dismiss an announcement if ($Discussion->Announce == '1' && $Discussion->Dismissed != '1') { $Sender->Options .= '<li>' . Anchor('Dismiss', 'vanilla/discussion/dismissannouncement/' . $Discussion->DiscussionID . '/' . $Session->TransientKey(), 'DismissAnnouncement') . '</li>'; } // Edit discussion if ($Discussion->FirstUserID == $Session->UserID || $Session->CheckPermission('Vanilla.Discussions.Edit', $Discussion->CategoryID)) { $Sender->Options .= '<li>' . Anchor('Edit', 'vanilla/post/editdiscussion/' . $Discussion->DiscussionID, 'EditDiscussion') . '</li>'; } // Announce discussion if ($Session->CheckPermission('Vanilla.Discussions.Announce', $Discussion->CategoryID)) { $Sender->Options .= '<li>' . Anchor($Discussion->Announce == '1' ? 'Unannounce' : 'Announce', 'vanilla/discussion/announce/' . $Discussion->DiscussionID . '/' . $Session->TransientKey(), 'AnnounceDiscussion') . '</li>'; } // Sink discussion if ($Session->CheckPermission('Vanilla.Discussions.Sink', $Discussion->CategoryID)) { $Sender->Options .= '<li>' . Anchor($Discussion->Sink == '1' ? 'Unsink' : 'Sink', 'vanilla/discussion/sink/' . $Discussion->DiscussionID . '/' . $Session->TransientKey() . '?Target=' . urlencode($Sender->SelfUrl), 'SinkDiscussion') . '</li>'; } // Close discussion if ($Session->CheckPermission('Vanilla.Discussions.Close', $Discussion->CategoryID)) { $Sender->Options .= '<li>' . Anchor($Discussion->Closed == '1' ? 'Reopen' : 'Close', 'vanilla/discussion/close/' . $Discussion->DiscussionID . '/' . $Session->TransientKey() . '?Target=' . urlencode($Sender->SelfUrl), 'CloseDiscussion') . '</li>'; } // Delete discussion if ($Session->CheckPermission('Vanilla.Discussions.Delete', $Discussion->CategoryID)) { $Sender->Options .= '<li>' . Anchor('Delete', 'vanilla/discussion/delete/' . $Discussion->DiscussionID . '/' . $Session->TransientKey() . '?Target=' . urlencode($Sender->SelfUrl), 'DeleteDiscussion') . '</li>'; } // Allow plugins to add options $Sender->FireEvent('DiscussionOptions'); if ($Sender->Options != '') { ?> <ul class="Options"> <li><strong><?php echo Gdn::Translate('Options'); ?> </strong> <ul> <?php echo $Sender->Options; ?> </ul> </li> </ul> <?php } } ?> </li> <?php } ?> <li class="Title"> <strong><?php echo Anchor(Format::Text($Discussion->Name), '/discussion/' . $Discussion->DiscussionID . '/' . Format::Url($Discussion->Name) . ($Discussion->CountCommentWatch > 0 ? '/#Item_' . $Discussion->CountCommentWatch : ''), 'DiscussionLink'); ?> </strong> </li> <li class="Meta"> <?php echo '<span>'; echo sprintf(Plural($Discussion->CountComments, '%s comment', '%s comments'), $Discussion->CountComments); echo '</span>'; if ($CountUnreadComments > 0 && $Session->IsValid()) { echo '<strong>', sprintf(Gdn::Translate('%s new'), $CountUnreadComments), '</strong>'; } echo '<span>'; printf(Gdn::Translate('Most recent by %1$s %2$s'), UserAnchor($Discussion->LastName), Format::Date($Discussion->LastDate)); echo '</span>'; echo Anchor($Discussion->Category, '/categories/' . urlencode($Discussion->Category), 'Category'); $Sender->FireEvent('DiscussionMeta'); ?> </li> </ul> </li> <?php }
/** * Formats a date. * * @see Format::Date() */ function smarty_modifier_date($Date, $Format = '') { return Format::Date($Date, $Format); }
/** * Create a comment. * * @param int The DiscussionID to add the comment to. If blank, this method will throw an error. */ public function Comment($DiscussionID = '') { $this->AddJsFile('js/library/jquery.autogrow.js'); $this->AddJsFile('post.js'); $this->AddJsFile('autosave.js'); $Session = Gdn::Session(); $this->Form->SetModel($this->CommentModel); $CommentID = isset($this->Comment) && property_exists($this->Comment, 'CommentID') ? $this->Comment->CommentID : ''; $DraftID = isset($this->Comment) && property_exists($this->Comment, 'DraftID') ? $this->Comment->DraftID : ''; $this->EventArguments['CommentID'] = $CommentID; $Editing = $CommentID > 0 || $DraftID > 0; $this->EventArguments['Editing'] = $Editing; $DiscussionID = is_numeric($DiscussionID) ? $DiscussionID : $this->Form->GetFormValue('DiscussionID', 0); $this->Form->AddHidden('DiscussionID', $DiscussionID); $this->Form->AddHidden('CommentID', $CommentID); $this->Form->AddHidden('DraftID', $DraftID, TRUE); $this->DiscussionID = $DiscussionID; $Discussion = $this->DiscussionModel->GetID($DiscussionID); if ($Editing) { if ($this->Comment->InsertUserID != $Session->UserID) { $this->Permission('Vanilla.Comments.Edit', $Discussion->CategoryID); } } else { $this->Permission('Vanilla.Comments.Add', $Discussion->CategoryID); } if ($this->Form->AuthenticatedPostBack() === FALSE) { if (isset($this->Comment)) { $this->Form->SetData($this->Comment); } } else { // Save as a draft? $FormValues = $this->Form->FormValues(); if ($DraftID == 0) { $DraftID = $this->Form->GetFormValue('DraftID', 0); } $Draft = $this->Form->ButtonExists('Save Draft') ? TRUE : FALSE; $this->EventArguments['Draft'] = $Draft; $Preview = $this->Form->ButtonExists('Preview') ? TRUE : FALSE; if ($Draft) { $DraftID = $this->DraftModel->Save($FormValues); $this->Form->AddHidden('DraftID', $DraftID, TRUE); $this->Form->SetValidationResults($this->DraftModel->ValidationResults()); } else { if (!$Preview) { $CommentID = $this->CommentModel->Save($FormValues); $this->Form->SetValidationResults($this->CommentModel->ValidationResults()); if ($CommentID > 0 && $DraftID > 0) { $this->DraftModel->Delete($DraftID); } } } // Handle non-ajax requests first: if ($this->_DeliveryType == DELIVERY_TYPE_ALL) { if ($this->Form->ErrorCount() == 0) { // Make sure that this form knows what comment we are editing. if ($CommentID > 0) { $this->Form->AddHidden('CommentID', $CommentID); } // If the comment was not a draft if (!$Draft) { // Redirect redirect to the new comment $Discussion = $this->DiscussionModel->GetID($DiscussionID); Redirect('/vanilla/discussion/' . $DiscussionID . '/' . Format::Url($Discussion->Name) . '/#Comment_' . $CommentID); } elseif ($Preview) { // If this was a preview click, create a comment shell with the values for this comment $this->Comment = new stdClass(); $this->Comment->InsertUserID = $Session->User->UserID; $this->Comment->InsertName = $Session->User->Name; $this->Comment->InsertPhoto = $Session->User->Photo; $this->Comment->DateInserted = Format::Date(); $this->Comment->Body = ArrayValue('Body', $FormValues, ''); $this->AddAsset('Content', $this->FetchView('preview')); } else { // If this was a draft save, notify the user about the save $this->StatusMessage = sprintf(Gdn::Translate('Draft saved at %s'), Format::Date()); } } } else { // Handle ajax-based requests if ($this->Form->ErrorCount() > 0) { // Return the form errors $this->StatusMessage = $this->Form->Errors(); } else { // Make sure that the ajax request form knows about the newly created comment or draft id $this->SetJson('CommentID', $CommentID); $this->SetJson('DraftID', $DraftID); if ($Preview) { // If this was a preview click, create a comment shell with the values for this comment $this->Comment = new stdClass(); $this->Comment->InsertUserID = $Session->User->UserID; $this->Comment->InsertName = $Session->User->Name; $this->Comment->InsertPhoto = $Session->User->Photo; $this->Comment->DateInserted = Format::Date(); $this->Comment->Body = ArrayValue('Body', $FormValues, ''); $this->View = 'preview'; } elseif (!$Draft) { // If the comment was not a draft // If adding a comment if ($Editing) { // Just reload the comment in question $this->Offset = $this->CommentModel->GetOffset($CommentID); $this->CommentData = $this->CommentModel->Get($DiscussionID, 1, $this->Offset - 1); // Load the discussion $this->Discussion = $this->DiscussionModel->GetID($DiscussionID); $this->ControllerName = 'discussion'; $this->View = 'comments'; // Also define the discussion url in case this request came from the post screen and needs to be redirected to the discussion $this->SetJson('DiscussionUrl', Url('/discussion/' . $DiscussionID . '/' . Format::Url($this->Discussion->Name) . '/#Comment_' . $CommentID)); } else { // Otherwise load all new comments that the user hasn't seen yet $LastCommentID = $this->Form->GetFormValue('LastCommentID'); if (!is_numeric($LastCommentID)) { $LastCommentID = $CommentID - 1; } // Failsafe back to this new comment if the lastcommentid was not defined properly // Make sure the view knows the current offset $this->Offset = $this->CommentModel->GetOffset($LastCommentID); // Make sure to load all new comments since the page was last loaded by this user $this->CommentData = $this->CommentModel->GetNew($DiscussionID, $LastCommentID); // Load the discussion $this->Discussion = $this->DiscussionModel->GetID($DiscussionID); $this->ControllerName = 'discussion'; $this->View = 'comments'; // Make sure to set the user's discussion watch records $CountComments = $this->CommentModel->GetCount($DiscussionID); $Limit = $this->CommentData->NumRows(); $Offset = $CountComments - $Limit; $this->CommentModel->SetWatch($this->Discussion, $Limit, $Offset, $CountComments); } } else { // If this was a draft save, notify the user about the save $this->StatusMessage = sprintf(Gdn::Translate('Draft saved at %s'), Format::Date()); } // And update the draft count $UserModel = Gdn::UserModel(); $CountDrafts = $UserModel->GetAttribute($Session->UserID, 'CountDrafts', 0); $MyDrafts = Gdn::Translate('My Drafts'); if (is_numeric($CountDrafts) && $CountDrafts > 0) { $MyDrafts .= '<span>' . $CountDrafts . '</span>'; } $this->SetJson('MyDrafts', $MyDrafts); } } } $this->FireEvent('BeforeCommentRender'); $this->Render(); }
?> </dd> <dt class="Label Visits"><?php echo Gdn::Translate('Visits'); ?> <dt> <dd class="Value Visits"><?php echo $this->User->CountVisits; ?> </dd> <dt class="Label LastActive"><?php echo Gdn::Translate('Last Active'); ?> <dt> <dd class="Value LastActive"><?php echo Format::Date($this->User->DateLastActive); ?> </dd> <dt class="Label Roles"><?php echo Gdn::Translate('Roles'); ?> <dt> <dd class="Value Roles"><?php echo implode(', ', $this->Roles); ?> </dd> <?php if ($this->User->InviteUserID > 0) { $Inviter = new stdClass(); $Inviter->UserID = $this->User->InviteUserID; $Inviter->Name = $this->User->InviteName;
echo $Message->MessageID; ?> "<?php echo $Class == '' ? '' : ' class="' . $Class . '"'; ?> > <div class="ConversationMessage"> <div class="Meta"> <span class="Author"> <?php echo UserPhoto($Author, 'Photo'); echo UserAnchor($Author, 'Name'); ?> </span> <span class="DateCreated"><?php echo Format::Date($Message->DateInserted); ?> </span> <span class="ItemLink"><a name="Item_<?php echo $CurrentOffset; ?> " class="Item"></a></span> </div> <div class="Message"><?php echo Format::To($Message->Body, $Format); ?> </div> </div> </li> <?php }
$Name = $Session->UserID == $Conversation->LastMessageUserID ? 'You' : $Conversation->LastMessageName; $JumpToItem = $Conversation->CountMessages - $Conversation->CountNewMessages; ?> <li<?php echo $Class == '' ? '' : ' class="' . $Class . '"'; ?> > <?php $LastAuthor = UserBuilder($Conversation, 'LastMessage'); echo UserPhoto($LastAuthor, 'Photo'); ?> <div> <?php echo UserAnchor($LastAuthor, 'Name'); echo Anchor(SliceString(Format::Text($Conversation->LastMessage), 100), '/messages/' . $Conversation->ConversationID . '/#Item_' . $JumpToItem, 'Message'); echo '<div class="Meta">'; echo Format::Date($Conversation->DateLastMessage); echo '<span>•</span>'; printf(Gdn::Translate(Plural($Conversation->CountMessages, '%s message', '%s messages')), $Conversation->CountMessages); if ($Conversation->CountNewMessages > 0) { echo '<span>•</span>'; echo '<em>'; printf(Gdn::Translate('%s new'), $Conversation->CountNewMessages); echo '</em>'; } echo '</div>'; ?> </div> </li> <?php }
echo Url('/profile/' . $User->Name); ?> "><?php echo $User->Name; ?> </a></td> <td class="Alt"><?php echo Format::Email($User->Email); ?> </td> <td><?php echo Format::Date($User->DateFirstVisit); ?> </td> <td class="Alt"><?php echo Format::Date($User->DateLastActive); ?> </td> <?php if ($EditUser) { ?> <td><?php echo Anchor('Edit', '/user/edit/' . $User->UserID, 'Popup'); ?> </td> <?php } ?> </tr> <?php }
function WriteActivityComment($Comment, &$Sender, &$Session) { $Author = UserBuilder($Comment, 'Activity'); ?> <li id="Activity_<?php echo $Comment->ActivityID; ?> " class="<?php echo $Comment->ActivityType; if ($Comment->ActivityPhoto != '') { echo ' HasPhoto'; } ?> "><?php echo UserPhoto($Author, 'Photo'); echo '<div>'; echo UserAnchor($Author, 'Name'); echo Format::Display($Comment->Story); echo '<div class="Meta">'; echo Format::Date($Comment->DateInserted); echo $Session->UserID == $Comment->InsertUserID || $Session->CheckPermission('Garden.Activity.Delete') ? '<span>•</span>' . Anchor('Delete', 'garden/activity/delete/' . $Comment->ActivityID . '/' . $Session->TransientKey() . '?Return=' . urlencode(Gdn_Url::Request())) : ''; echo '</div>'; echo '</div>'; ?> </li> <?php }