Ejemplo n.º 1
0
 /**
  *
  * @param PostController $sender Sending controller instance.
  * @param array $args Event arguments.
  */
 public function postController_render_before($sender, $args)
 {
     $data = $sender->data('Comments');
     if (is_object($data)) {
         RoleModel::setUserRoles($data->result(), 'InsertUserID');
     }
 }
Ejemplo n.º 2
0
 /**
  * Override the PostController->Discussion() method before render to use our view instead.
  *
  * @param PostController $sender Sending controller instance.
  */
 public function postController_beforeDiscussionRender_handler($sender)
 {
     // Override if we are looking at the question url.
     if ($sender->RequestMethod == 'question') {
         $sender->Form->addHidden('Type', 'Question');
         $sender->title(t('Ask a Question'));
         $sender->setData('Breadcrumbs', array(array('Name' => $sender->data('Title'), 'Url' => '/post/question')));
     }
 }
Ejemplo n.º 3
0
 /**
  * Add javascript to the post/edit discussion page so that tagging autocomplete works.
  *
  * @param PostController $Sender
  */
 public function postController_render_before($Sender)
 {
     $Sender->addDefinition('PluginsTaggingAdd', Gdn::session()->checkPermission('Plugins.Tagging.Add'));
     $Sender->addDefinition('PluginsTaggingSearchUrl', Gdn::request()->Url('plugin/tagsearch'));
     // Make sure that detailed tag data is available to the form.
     $TagModel = TagModel::instance();
     $DiscussionID = $Sender->data('Discussion.DiscussionID');
     if ($DiscussionID) {
         $Tags = $TagModel->getDiscussionTags($DiscussionID, TagModel::IX_EXTENDED);
         $Sender->setData($Tags);
     } elseif (!$Sender->Request->isPostBack() && ($tagString = $Sender->Request->get('tags'))) {
         $tags = explodeTrim(',', $tagString);
         $types = array_column(TagModel::instance()->defaultTypes(), 'key');
         // Look up the tags by name.
         $tagData = Gdn::sql()->getWhere('Tag', array('Name' => $tags, 'Type' => $types))->resultArray();
         // Add any missing tags.
         $tagNames = array_change_key_case(array_column($tagData, 'Name', 'Name'));
         foreach ($tags as $tag) {
             $tagKey = strtolower($tag);
             if (!isset($tagNames[$tagKey])) {
                 $tagData[] = array('TagID' => $tag, 'Name' => $tagKey, 'FullName' => $tag, 'Type' => '');
             }
         }
         $Sender->setData('Tags', $tagData);
     }
 }