Skip to content

Commit

Permalink
Fix first posts and show login to Public
Browse files Browse the repository at this point in the history
Fix first posts to create topic so Google is happy, add option to show
login to Public users.
  • Loading branch information
severdia committed Feb 1, 2015
1 parent be2cb13 commit ac0e49d
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 9 deletions.
22 changes: 21 additions & 1 deletion plugins/content/kunenadiscuss/css/discuss.css
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,24 @@ div.kdiscuss-content-cover .code {
font-family: Arial,Helvetica,sans-serif;
border-radius:5px;
padding:5px;
}
}

.kdiscuss-title.login-discuss {
margin-bottom: 40px;
}
.klogin-to-discuss {
background-color: #ffffff;
border: 1px solid #d5d5d5;
border-radius: 3px;
box-shadow: none;
box-sizing: border-box;
color: #6e6e6e;
padding: 12px 15px;
}
.klogin-to-discuss:hover {
color: #E35614;
border: 1px solid #E35614;
}
.kpublic {
border-bottom: 0 none !important;
}
53 changes: 46 additions & 7 deletions plugins/content/kunenadiscuss/kunenadiscuss.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,19 @@ public function onContentAfterDisplay($context, &$article, &$params, $limitstart
if (self::$inevent || !isset($article->id) || !isset(self::$plgDisplay[$article->id])) return '';

$this->debug("onAfterDisplayContent: Returning content for article {$article->id}");

$result = self::$plgDisplay[$article->id];

$user = JFactory::getUser();
if($user->guest){
$login_public = $this->params->get ( 'login_public', 0 );
if($login_public){
$guestHtml= "<div class='kunenadiscuss kpublic'>";
$guestHtml = $guestHtml. "<div class='kdiscuss-title login-discuss'>Discuss this article</div>";
$guestHtml = $guestHtml. "<a class='klogin-to-discuss' href='".JRoute::_('index.php?option=com_users&view=login&Itemid=1988')."' >Log in to comment</a>";
$guestHtml = $guestHtml. "</div>";
$result = $guestHtml. $result ;
}
}
return $result;
}

Expand Down Expand Up @@ -264,6 +275,7 @@ protected function prepare($context, &$article, &$params) {
if ($kunenaCategory || $kunenaTopic) {
self::$plgDisplay [$article->id] = $this->showPlugin ( $kunenaCategory, $kunenaTopic, $article, $show == 1 );
}

} // end of $ksource!='kunena' check
}

Expand Down Expand Up @@ -369,7 +381,7 @@ protected function showPlugin($catid, $topic_id, &$row, $linkOnly) {
}
}
}

// Do we allow answers into the topic?
$closeTime = $this->params->get ( 'close_time', 0 ) * 604800; // Weeks in seconds or 0 (forever)
if ($closeTime && $topic->exists()) {
Expand Down Expand Up @@ -399,12 +411,15 @@ protected function showPlugin($catid, $topic_id, &$row, $linkOnly) {
$linktopic = JText::_('PLG_KUNENADISCUSS_NEW_TOPIC_NOT_CREATED');
}


// ************************************************************************
// Process the QuickPost form

$quickPost = '';
$canPost = $this->canPost ( $category, $topic );

if ($canPost && $plgShowForm && (!$closeTime || $closeTime >= $now)) {

if (JFactory::getUser()->get('guest')) {
$this->debug ( "showPlugin: Guest can post: this feature doesn't work well if Joomla caching or Cache Plugin is enabled!" );
}
Expand All @@ -416,20 +431,21 @@ protected function showPlugin($catid, $topic_id, &$row, $linkOnly) {
$quickPost .= $this->showForm ( $row, $category, $topic, $subject );
}
}



// This will be used all the way through to tell users how many posts are in the forum.
$content = $this->showTopic ( $category, $topic, $linktopic );

if (!$content && !$quickPost) {
return $linktopic;
}

if ($formLocation) {
$content = '<div class="kunenadiscuss">' . $content . '<br />' . $quickPost . '</div>';
} else {
$content = '<div class="kunenadiscuss">' . $quickPost . "<br />" . $content . '</div>';
}

return $content;
}

Expand Down Expand Up @@ -477,6 +493,7 @@ protected function showTopic(KunenaForumCategory $category, KunenaForumTopic $to
* @return string
*/
protected function showForm($row, KunenaForumCategory $category, KunenaForumTopic $topic, $subject ) {

$canPost = $this->canPost ( $category, $topic );
if (! $canPost) {
if (! $this->user->exists()) {
Expand Down Expand Up @@ -560,15 +577,36 @@ protected function createTopic($row, KunenaForumCategory $category, $subject) {

$this->debug ( "showPlugin: Create topic!" );

$add_snippet = $this->params->get('add_article_snippet');
$textwords = implode(' ', array_slice(explode(' ', $row->fulltext), 0, 10));

if(empty($textwords))
{
$textwords = implode(' ', array_slice(explode(' ', $row->introtext), 0, 10));
}

$snippet = strip_tags($textwords)."..."."\n\n";


$type = $this->params->get('bbcode');
switch ($type) {
case 'full':
case 'intro':
case 'link':
{
if($add_snippet)
$contents = $snippet."[article={$type}]{$row->id}[/article]";
else
$contents = "[article={$type}]{$row->id}[/article]";
break;
}
break;
default:
{
if($add_snippet)
$contents= $snippet."[article]{$row->id}[/article]";
else
$contents= "[article]{$row->id}[/article]";
}
}
$params = array(
'subject' => $subject,
Expand Down Expand Up @@ -602,6 +640,7 @@ protected function createTopic($row, KunenaForumCategory $category, $subject) {
* @return bool|string
*/
protected function replyTopic($row, KunenaForumCategory $category, KunenaForumTopic $topic, $subject) {

if (JSession::checkToken() == false) {
$this->app->enqueueMessage ( JText::_ ( 'COM_KUNENA_ERROR_TOKEN' ), 'error' );
return false;
Expand Down
10 changes: 9 additions & 1 deletion plugins/content/kunenadiscuss/kunenadiscuss.xml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,15 @@
<option value="1">PLG_KUNENADISCUSS_OPTION_YES</option>
</field>
<field name="show_debug_userids" type="text" default="" description="PLG_KUNENADISCUSS_SHOW_DEBUG_USERIDS_DESC" label="PLG_KUNENADISCUSS_SHOW_DEBUG_USERIDS" />
<field name="login_public" type="radio" class="btn-group" default="1" label="PLG_KUNENADISCUSS_SHOW_LOGIN_PUBLIC_USERS" description="PLG_KUNENADISCUSS_SHOW_LOGIN_PUBLIC_USERS_DESC" >
<option value="0">PLG_KUNENADISCUSS_OPTION_NO</option>
<option value="1">PLG_KUNENADISCUSS_OPTION_YES</option>
</field>
<field name="add_article_snippet" type="radio" default="1" description="PLG_KUNENADISCUSS_ADD_SNIPPET_DESC" label="PLG_KUNENADISCUSS_ADD_SNIPPET">
<option value="0">PLG_KUNENADISCUSS_OPTION_NO</option>
<option value="1">PLG_KUNENADISCUSS_OPTION_YES</option>
</field>
</fieldset>
</fields>
</config>
</extension>
</extension>
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ PLG_KUNENADISCUSS_SHOW_DEBUG="Show Debug Information"
PLG_KUNENADISCUSS_SHOW_DEBUG_DESC="Show debugging information on the frontend."
PLG_KUNENADISCUSS_SHOW_DEBUG_USERIDS="Debug User IDs"
PLG_KUNENADISCUSS_SHOW_DEBUG_USERIDS_DESC="A comma delimited list of Joomla user IDs allowed to see debugging information. Leave this empty to allow all users see debugging information when Show Debug Information is active."
PLG_KUNENADISCUSS_SHOW_LOGIN_PUBLIC_USERS="Show Login to Public Users"


; Discuss 1.6.0
PLG_KUNENADISCUSS_CREATE="Create Topic on"
Expand Down Expand Up @@ -96,3 +98,7 @@ PLG_KUNENADISCUSS_OPTION_BBCODE_DEFAULT="Default"
PLG_KUNENADISCUSS_OPTION_BBCODE_FULL="Article"
PLG_KUNENADISCUSS_OPTION_BBCODE_INTRO="Introduction"
PLG_KUNENADISCUSS_OPTION_BBCODE_LINK="Link"
PLG_KUNENADISCUSS_ADD_SNIPPET="Add article snippet"
PLG_KUNENADISCUSS_ADD_SNIPPET_DESC="Add article snippet to message text before [article] tag on save."
PLG_KUNENADISCUSS_SHOW_LOGIN_PUBLIC_USERS="Show login button for public users"
PLG_KUNENADISCUSS_SHOW_LOGIN_PUBLIC_USERS_DESC="Enabling this will show the comment area and login button for public users."

0 comments on commit ac0e49d

Please sign in to comment.