Beispiel #1
0
 /**
  * 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();
 }
Beispiel #2
0
 /**
  * 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();
 }
Beispiel #3
0
 /**
  * Adds email notification options to profiles.
  * 
  * @since 2.0.0
  * @package Vanilla
  * 
  * @param ProfileController $Sender
  */
 public function ProfileController_AfterPreferencesDefined_Handler($Sender)
 {
     $Sender->Preferences['Notifications']['Email.DiscussionComment'] = T('Notify me when people comment on my discussions.');
     $Sender->Preferences['Notifications']['Email.BookmarkComment'] = T('Notify me when people comment on my bookmarked discussions.');
     $Sender->Preferences['Notifications']['Email.Mention'] = T('Notify me when people mention me.');
     $Sender->Preferences['Notifications']['Popup.DiscussionComment'] = T('Notify me when people comment on my discussions.');
     $Sender->Preferences['Notifications']['Popup.BookmarkComment'] = T('Notify me when people comment on my bookmarked discussions.');
     $Sender->Preferences['Notifications']['Popup.Mention'] = T('Notify me when people mention me.');
     //      if (Gdn::Session()->CheckPermission('Garden.AdvancedNotifications.Allow')) {
     //         $Sender->Preferences['Notifications']['Email.NewDiscussion'] = array(T('Notify me when people start new discussions.'), 'Meta');
     //         $Sender->Preferences['Notifications']['Email.NewComment'] = array(T('Notify me when people comment on a discussion.'), 'Meta');
     ////      $Sender->Preferences['Notifications']['Popup.NewDiscussion'] = T('Notify me when people start new discussions.');
     //      }
     if (Gdn::Session()->CheckPermission('Garden.AdvancedNotifications.Allow')) {
         $PostBack = $Sender->Form->IsPostBack();
         $Set = array();
         // Add the category definitions to for the view to pick up.
         $DoHeadings = C('Vanilla.Categories.DoHeadings');
         // Grab all of the categories.
         $Categories = array();
         $Prefixes = array('Email.NewDiscussion', 'Popup.NewDiscussion', 'Email.NewComment', 'Popup.NewComment');
         foreach (CategoryModel::Categories() as $Category) {
             if (!$Category['PermsDiscussionsView'] || $Category['Depth'] <= 0 || $Category['Depth'] > 2 || $Category['Archived']) {
                 continue;
             }
             $Category['Heading'] = $DoHeadings && $Category['Depth'] <= 1;
             $Categories[] = $Category;
             if ($PostBack) {
                 foreach ($Prefixes as $Prefix) {
                     $FieldName = "{$Prefix}.{$Category['CategoryID']}";
                     $Value = $Sender->Form->GetFormValue($FieldName, NULL);
                     if (!$Value) {
                         $Value = NULL;
                     }
                     $Set[$FieldName] = $Value;
                 }
             }
         }
         $Sender->SetData('CategoryNotifications', $Categories);
         if ($PostBack) {
             UserModel::SetMeta($Sender->User->UserID, $Set, 'Preferences.');
         }
     }
 }
 /**
  * @param ProfileController $Sender
  * @param array $Args
  * @param array $Where
  * @param int $Limit
  * @return bool
  */
 public function JoinAttachmentsToUser($Sender, $Args, $Where = array(), $Limit = 20)
 {
     $User = $Sender->User;
     if (!is_object($User)) {
         return FALSE;
     }
     $Where = array_merge(array('ForeignUserID' => $User->UserID), $Where);
     $Attachments = $this->GetWhere($Where, '', 'desc', $Limit)->ResultArray();
     $Sender->SetData('Attachments', $Attachments);
     return TRUE;
 }