Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ public function initialize() {
$this->addCssFile('style.css');
$this->addCssFile('vanillicon.css', 'static');
$this->addModule('GuestModule');
$this->addModule('NewDiscussionModule');
//$this->addModule('NewDiscussionModule');
$this->addModule('DiscussionFilterModule');
$this->addModule('CategoriesModule');
//$this->addModule('CategoriesModule');
$this->addModule('BookmarkedModule');
parent::initialize();
$this->setData('Breadcrumbs', [['Name' => t('Search'), 'Url' => '/search']]);
Expand Down
58 changes: 58 additions & 0 deletions vanilla/applications/dashboard/modules/class.guestmodule.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php
/**
* Guest module.
*
* @copyright 2009-2019 Vanilla Forums Inc.
* @license GPL-2.0-only
* @package Dashboard
* @since 2.0
*/

/**
* Renders the "You should register or sign in" panel box.
*/
class GuestModule extends Gdn_Module {

/** @var string */
public $MessageCode = 'GuestModule.Message';

/** @var string */
public $MessageDefault = "Looks like you are new or aren't currently signed in.";

/**
*
*
* @param string $sender
* @param bool $applicationFolder
*/
public function __construct($sender = '', $applicationFolder = false) {
if (!$applicationFolder) {
$applicationFolder = 'Dashboard';
}
parent::__construct($sender, $applicationFolder);

$this->Visible = c('Garden.Modules.ShowGuestModule');
}

/**
*
*
* @return string
*/
public function assetTarget() {
return 'Panel';
}

/**
* Render.
*
* @return string
*/
public function toString() {
if (!Gdn::session()->isValid()) {
return parent::toString();
}

return '';
}
}
25 changes: 25 additions & 0 deletions vanilla/applications/dashboard/views/modules/guest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php if (!defined('APPLICATION')) exit(); ?>
<div class="Box GuestBox">
<h4><?php echo t('Welcome to Topcoder!'); ?></h4>

<p><?php echo t($this->MessageCode, $this->MessageDefault); ?></p>

<p><?php $this->fireEvent('BeforeSignInButton'); ?></p>

<?php
$signInUrl = signInUrl($this->_Sender->SelfUrl);

if ($signInUrl) {
echo '<div class="P">';

echo anchor(t('Login'), signInUrl($this->_Sender->SelfUrl), 'Button Primary SignIn BigButton'.(signInPopup() ? ' SignInPopup' : ''), ['rel' => 'nofollow']);
// $Url = registerUrl($this->_Sender->SelfUrl);
// if (!empty($Url)) {
// echo ' '.anchor(t('Register', t('Apply for Membership', 'Register')), $Url, 'Button ApplyButton', ['rel' => 'nofollow']);
// }

echo '</div>';
}
?>
<?php $this->fireEvent('AfterSignInButton'); ?>
</div>
17 changes: 17 additions & 0 deletions vanilla/applications/dashboard/views/search/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php if (!defined('APPLICATION')) exit(); ?>
<h1 class="H HomepageTitle">Search</h1>
<div class="SearchForm">
<?php
$Form = $this->Form;
echo $Form->open(['action' => url('/search'), 'method' => 'get']),
'<div class="SiteSearch InputAndButton">',
$Form->textBox('Search', ['aria-label' => t('Enter your search term.'), 'title' => t('Enter your search term.') ]),
$Form->button('Search', ['aria-label' => t('Search'), 'Name' => '']),
'</div>',
$Form->errors(),
$Form->close();
?>
</div>
<?php
$ViewLocation = $this->fetchViewLocation('results');
include($ViewLocation);
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class CategoriesController extends VanillaController {
const SORT_LAST_POST = 'new';
const SORT_OLDEST_POST = 'old';

const ROOT_CATEGORY = ['Name' => 'Roundtables', 'Url'=>'/'];
/**
* @var \Closure $categoriesCompatibilityCallback A backwards-compatible callback to get `$this->data('Categories')`.
*/
Expand Down Expand Up @@ -332,7 +333,11 @@ public function index($categoryIdentifier = '', $page = '0') {
}

// Load the breadcrumbs.
$this->setData('Breadcrumbs', CategoryModel::getAncestors(val('CategoryID', $category)));

$ancestors = CategoryModel::getAncestors(val('CategoryID', $category));
array_unshift ( $ancestors , self::ROOT_CATEGORY);
$this->setData('Breadcrumbs', $ancestors);


$this->setData('Category', $category, true);
// Set CategoryID
Expand Down Expand Up @@ -406,7 +411,7 @@ public function index($categoryIdentifier = '', $page = '0') {
// Add modules
$this->addModule('NewDiscussionModule');
$this->addModule('DiscussionFilterModule');
$this->addModule('CategoriesModule');
// $this->addModule('CategoriesModule');
$this->addModule('BookmarkedModule');
$this->addModule('TagModule');

Expand Down Expand Up @@ -535,7 +540,7 @@ public function all($Category = '', $displayAs = '') {
if ($Title) {
$this->title($Title, '');
} else {
$this->title(t('All Categories'));
$this->title(t('Roundtables'));
}
}
Gdn_Theme::section('CategoryList');
Expand All @@ -544,7 +549,10 @@ public function all($Category = '', $displayAs = '') {
$this->description(c('Garden.Description', null));
}

$this->setData('Breadcrumbs', CategoryModel::getAncestors(val('CategoryID', $this->data('Category'))));
$ancestors = CategoryModel::getAncestors(val('CategoryID', $this->data('Category')));
array_unshift ( $ancestors , self::ROOT_CATEGORY);
$this->setData('Breadcrumbs', $ancestors);


// Set the category follow toggle before we load category data so that it affects the category query appropriately.
$CategoryFollowToggleModule = new CategoryFollowToggleModule($this);
Expand Down Expand Up @@ -630,10 +638,12 @@ public function all($Category = '', $displayAs = '') {
$this->setData('CategoryTree', $categoryTree);

// Add modules
$this->addModule('NewDiscussionModule');
if($Category) {
$this->addModule('NewDiscussionModule');
}
$this->addModule('DiscussionFilterModule');
$this->addModule('BookmarkedModule');
$this->addModule('CategoriesModule');
// $this->addModule('CategoriesModule');
$this->addModule($CategoryFollowToggleModule);
$this->addModule('TagModule');

Expand Down Expand Up @@ -669,7 +679,7 @@ public function discussions($Category = '') {
if ($Title) {
$this->title($Title, '');
} else {
$this->title(t('All Categories'));
$this->title(t('Roundtables'));
}
}

Expand Down Expand Up @@ -725,7 +735,7 @@ public function discussions($Category = '') {
// Add modules
$this->addModule('NewDiscussionModule');
$this->addModule('DiscussionFilterModule');
$this->addModule('CategoriesModule');
// $this->addModule('CategoriesModule');
$this->addModule('BookmarkedModule');
$this->addModule($CategoryFollowToggleModule);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ public function index($DiscussionID = '', $DiscussionStub = '', $Page = '') {
Gdn_Theme::section($CategoryCssClass);
}

$this->setData('Breadcrumbs', CategoryModel::getAncestors($this->CategoryID));
$ancestors = CategoryModel::getAncestors($this->CategoryID);
array_unshift ( $ancestors , CategoriesController::ROOT_CATEGORY);
$this->setData('Breadcrumbs', $ancestors);

// Setup
$this->title($this->Discussion->Name);
Expand Down Expand Up @@ -294,7 +296,7 @@ public function index($DiscussionID = '', $DiscussionStub = '', $Page = '') {
// Add modules
$this->addModule('DiscussionFilterModule');
$this->addModule('NewDiscussionModule');
$this->addModule('CategoriesModule');
// $this->addModule('CategoriesModule');
$this->addModule('BookmarkedModule');

$this->CanEditComments = Gdn::session()->checkPermission('Vanilla.Comments.Edit', true, 'Category', 'any') && c('Vanilla.AdminCheckboxes.Use');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function index($Page = false) {
// Add modules
$this->addModule('DiscussionFilterModule');
$this->addModule('NewDiscussionModule');
$this->addModule('CategoriesModule');
// $this->addModule('CategoriesModule');
$this->addModule('BookmarkedModule');
$this->addModule('TagModule');

Expand Down Expand Up @@ -282,7 +282,7 @@ public function unread($page = '0') {
// Add modules
$this->addModule('DiscussionFilterModule');
$this->addModule('NewDiscussionModule');
$this->addModule('CategoriesModule');
// $this->addModule('CategoriesModule');
$this->addModule('BookmarkedModule');
$this->addModule('TagModule');

Expand Down Expand Up @@ -459,7 +459,7 @@ public function bookmarked($page = '0') {
// Add modules
$this->addModule('DiscussionFilterModule');
$this->addModule('NewDiscussionModule');
$this->addModule('CategoriesModule');
// $this->addModule('CategoriesModule');
$this->addModule('TagModule');

// Render default view (discussions/bookmarked.php)
Expand Down Expand Up @@ -560,7 +560,7 @@ public function mine($page = 'p1') {
// Add modules
$this->addModule('DiscussionFilterModule');
$this->addModule('NewDiscussionModule');
$this->addModule('CategoriesModule');
// $this->addModule('CategoriesModule');
$this->addModule('BookmarkedModule');
$this->addModule('TagModule');

Expand Down
124 changes: 124 additions & 0 deletions vanilla/applications/vanilla/controllers/class.draftscontroller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<?php
/**
* Drafts controller
*
* @copyright 2009-2019 Vanilla Forums Inc.
* @license GPL-2.0-only
* @package Vanilla
* @since 2.0
*/

/**
* Handles displaying saved drafts of unposted comments via /drafts endpoint.
*/
class DraftsController extends VanillaController {

/** @var array Models to include. */
public $Uses = ['Database', 'DraftModel'];

/**
* Default all drafts view: chronological by time saved.
*
* @since 2.0.0
* @access public
*
* @param int $offset Number of drafts to skip.
*/
public function index($offset = '0') {
Gdn_Theme::section('DiscussionList');

// Setup head
$this->permission('Garden.SignIn.Allow');
$this->addJsFile('jquery.gardenmorepager.js');
$this->addJsFile('discussions.js');
$this->title(t('My Drafts'));

// Validate $Offset
if (!is_numeric($offset) || $offset < 0) {
$offset = 0;
}

// Set criteria & get drafts data
$limit = Gdn::config('Vanilla.Discussions.PerPage', 30);
$session = Gdn::session();
$wheres = ['d.InsertUserID' => $session->UserID];
$this->DraftData = $this->DraftModel->getByUser($session->UserID, $offset, $limit);
$countDrafts = $this->DraftModel->getCountByUser($session->UserID);

// Build a pager
$pagerFactory = new Gdn_PagerFactory();
$this->Pager = $pagerFactory->getPager('MorePager', $this);
$this->Pager->MoreCode = 'More drafts';
$this->Pager->LessCode = 'Newer drafts';
$this->Pager->ClientID = 'Pager';
$this->Pager->configure(
$offset,
$limit,
$countDrafts,
'drafts/%1$s'
);

// Deliver JSON data if necessary
if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
$this->setJson('LessRow', $this->Pager->toString('less'));
$this->setJson('MoreRow', $this->Pager->toString('more'));
$this->View = 'drafts';
}

// Add modules
$this->addModule('DiscussionFilterModule');
//$this->addModule('NewDiscussionModule');
//$this->addModule('CategoriesModule');
$this->addModule('BookmarkedModule');

// Render default view (drafts/index.php)
$this->render();
}

/**
* Delete a single draft.
*
* Redirects user back to Index unless DeliveryType is set.
*
* @since 2.0.0
* @access public
*
* @param int $draftID Unique ID of draft to be deleted.
* @param string $transientKey Single-use hash to prove intent.
*/
public function delete($draftID = '', $transientKey = '') {
$form = Gdn::factory('Form');
$session = Gdn::session();
if (is_numeric($draftID) && $draftID > 0) {
$draft = $this->DraftModel->getID($draftID);
}
if ($draft) {
if ($session->validateTransientKey($transientKey)
&& ((val('InsertUserID', $draft) == $session->UserID) || checkPermission('Garden.Community.Manage'))
) {
// Delete the draft
if (!$this->DraftModel->deleteID($draftID)) {
$form->addError('Failed to delete draft');
}
} else {
throw permissionException('Garden.Community.Manage');
}
} else {
throw notFoundException('Draft');
}

// Redirect
if ($this->_DeliveryType === DELIVERY_TYPE_ALL) {
$target = getIncomingValue('Target', '/drafts');
redirectTo($target);
}

// Return any errors
if ($form->errorCount() > 0) {
$this->setJson('ErrorMessage', $form->errors());
}

// Render default view
$this->render();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ public function discussion($categoryUrlCode = '') {
'Url' => val('AddUrl', val($this->data('Type'), DiscussionModel::discussionTypes()), '/post/discussion')
];

array_unshift ( $breadcrumbs , CategoriesController::ROOT_CATEGORY);
$this->setData('Breadcrumbs', $breadcrumbs);

// FIX: Hide Announce options
Expand Down Expand Up @@ -1022,7 +1023,7 @@ public function initialize() {
// Add modules
$this->addModule('NewDiscussionModule');
$this->addModule('DiscussionFilterModule');
$this->addModule('CategoriesModule');
// $this->addModule('CategoriesModule');
$this->addModule('BookmarkedModule');

parent::initialize();
Expand Down
Loading