Kunena 6.3.0 released

The Kunena team has announce the arrival of Kunena 6.3.0 [K 6.3.0] in stable which is now available for download as a native Joomla extension for J! 4.4.x/5.0.x/5.1.x. This version addresses most of the issues that were discovered in K 6.2 and issues discovered during the last development stages of K 6.3

Question Category Subscriptions - Default Subscribed?

More
13 years 6 months ago #1 by DesoWV
Hi, I am looking forward to the Category Subscriptions, however I have one very important question.

Will it be possible to set Category Subscriptions by default for new all users? Also for the initial setup after the upgrade? Currently I am not seeing this in RC3?

Naturally they would be able to change their subscriptions if they want, but by default I need everyone subscribed. We use our forums as a mailing list to ensure everyone is up to date if they dont log into the website. But as noted, if they want to remove their subscriptions they can.

Thank You.

Please Log in or Create an account to join the conversation.

More
13 years 6 months ago #2 by Matias
There's System - Kunena plugin that can be used for this when user registers. Unfortunately it needs some custom coding to get it to work. :(

Please Log in or Create an account to join the conversation.

More
13 years 6 months ago #3 by DesoWV
Ok, found the plugin and looked in the Kunena.php file it points to, but I did not see anything in it to edit for category subscriptions, what code would need to be added? Is this not going to be a built in Kunena feature with the final release?

Also, I subscribed to this topic when I posted it, and I just now confirmed it in my profile, but I did not receive a email saying you replied?

Please Log in or Create an account to join the conversation.

More
13 years 6 months ago #4 by Matias
Final version (1.6.0) will be out very soon. So no, there's no time to make it happen.

Please Log in or Create an account to join the conversation.

More
13 years 6 months ago #5 by DesoWV
Ok, I am by no means a coder, but occasionally I get lucky and scramble things together. If anyone can help me that would be great, in the mean time I will "attempt" to edit the system - kunena plugin file and see if I can get it to auto subscribe new users to categories.

For this example to make it easy to locate the info I would need to change we will use the following info:
Category Name: KingKong
Category ID: 234987

Now, from my looking in the **/components/com_kunena/kunena.php file I located the following code which I believe is used to subscribe to a category:

lines 526-549
Code:
case 'subscribecat' : if (!JRequest::checkToken('get')) { $kunena_app->enqueueMessage ( JText::_ ( 'COM_KUNENA_ERROR_TOKEN' ), 'error' ); if ($userid == 0) { $kunena_app->redirect ( CKunenaLink::GetCategoryURL('showcat' , $catid, false ) ); } else { $kunena_app->redirect ( CKunenaLink::GetProfileURL($userid, false) ); } } $success_msg = ''; if ( $catid && $kunena_my->id ) { $query = "INSERT INTO #__kunena_subscriptions_categories (catid, userid) VALUES ('$catid','$kunena_my->id')"; $kunena_db->setQuery ( $query ); if (@$kunena_db->query () && $kunena_db->getAffectedRows () == 1) { $success_msg = JText::_('COM_KUNENA_GEN_CATEGORY_SUBCRIBED'); } KunenaError::checkDatabaseError(); } $kunena_app->redirect ( CKunenaLink::GetCategoryURL('showcat' , $catid, false ), $success_msg ); break;

How would this be edited and placed into the system - kunena plugin file (**/plugins/system/kunena.php) ?? I will work on it and if I happen to stumble across it I will post the solution here. In the mean time I am reaching out for help. :silly:

Thanks a ton!

Please Log in or Create an account to join the conversation.

More
13 years 6 months ago - 13 years 6 months ago #6 by DesoWV
Ok, so I did quite a bit of research and came to the conclusion that if I did:
Code:
$query="INSERT INTO jos_kunena_subscriptions_categories VALUES ('234987','325')";

it would work, however it did not.... note I did use a real category ID but reguardless if I had not it still should have put it in the mysql table, which it did not.

So I then went as far as to do a complete login to the database (yes I changed the values to real values), and this still did not work. For the life of me I can not seem to get ANYTHING to insert into the table.... wth????
Code:
$username="username"; $password="password"; $database="database"; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="INSERT INTO jos_kunena_subscriptions_categories VALUES ('234987','325')"; mysql_query($query); mysql_close();

of course I am able to manually enter values into the table, so that will solve my migration issue, but I still need it to automatically add new users.

Any of you coding gods have an idea???

Thanks!
Last edit: 13 years 6 months ago by DesoWV. Reason: forgot to change a value to the demo values.... ops!

Please Log in or Create an account to join the conversation.

More
13 years 6 months ago #7 by DesoWV
ok, so I have been able to get it to insert the data for whichever user is logged in by:
Code:
$user = &JFactory::getUser (); $query = "INSERT INTO jos_kunena_subscriptions_categories (catid, userid) VALUES ('234987','$user->id')"; mysql_query($query);

now, obviously we dont want this to run every single time a user changes pages on the website (which is what its doing right now with the above code). So I have tried to implement a check on the user's last login seeing as I dont know any other way to check for the user being new.


what I have to attempt this is:
Code:
$user = &JFactory::getUser (); $visitq = "SELECT lastvisitDate FROM jos_users WHEN (id==$user->id)"; $visit = mysql_query($visitq); if ($visit=="0000-00-00 00:00:00") { $query = "INSERT INTO jos_kunena_subscriptions_categories (catid, userid) VALUES ('234987','$user->id')"; mysql_query($query); }

Now, this is stopping it from setting the logged in user subscribed to the category whenever they change pages on the website, in fact its not subscribing at all right now because it is not finding a match for the if statement.... That is where something is wrong, its not catching when the user has a lastvisitDate of 0000-00-00 00:00:00 to which my theory is that this is set to the current time/date the instant you log in, before the "system - kunena plugin" even runs the php file with the above code....

any thoughts?

Please Log in or Create an account to join the conversation.

More
13 years 6 months ago - 13 years 6 months ago #8 by Matias
You need to play with phpMyAdmin a bit:
Code:
-- Find all categories where user can subscribe (not a section and published): SELECT c.id FROM jos_kunena_categories AS c WHERE c.parent>0 AND c.published=1 -- Find all categories where user is already subscribed: SELECT * FROM jos_kunena_subscriptions_categories AS s WHERE s.userid=62 -- Find all categories where user is NOT subscribed: SELECT c.id, s.userid FROM jos_kunena_categories AS c LEFT JOIN jos_kunena_subscriptions_categories AS s ON c.id=s.catid AND s.userid=62 WHERE parent>0 AND s.userid IS NULL -- Insert user into category: INSERT INTO jos_kunena_subscriptions_categories (catid, userid) VALUES ('123','62') -- Do it for all categories (use static value for userid): INSERT INTO jos_kunena_subscriptions_categories (catid, userid) SELECT c.id, 62 AS userid FROM jos_kunena_categories AS c LEFT JOIN jos_kunena_subscriptions_categories AS s ON c.id=s.catid AND s.userid=62 WHERE parent>0 AND s.userid IS NULL

So you will need to do something like this when user gets created:
Code:
if ($isNew) { // Subscribe user to selected categories: $selectedCategories = '1,2,3,4,5,6,7,8,9,10'; $db = Jfactory::getDBO(); $query = "INSERT INTO #__kunena_subscriptions_categories (catid, userid) SELECT c.id, {$user->id} AS userid FROM #__kunena_categories AS c LEFT JOIN #__kunena_subscriptions_categories AS s ON c.id=s.catid AND s.userid={$user->id} WHERE c.parent>0 AND c.id IN ({$selectedCategories}) AND s.userid IS NULL"; $db->setQuery ( $query ); $db->query (); KunenaError::checkDatabaseError(); }

That will subscribe user to all selected categories, including those he cannot see. Well, that should be OK as they are not counted if user doesn't have permissions..
Last edit: 13 years 6 months ago by Matias.

Please Log in or Create an account to join the conversation.

More
13 years 6 months ago - 13 years 6 months ago #9 by Matias
Here's query to add subscriptions to all users to selected categories: c.id IN (ADD YOUR LIST INTO HERE):
Code:
INSERT INTO jos_kunena_subscriptions_categories (catid, userid) SELECT c.id, u.id AS userid FROM jos_users AS u JOIN jos_kunena_categories AS c LEFT JOIN jos_kunena_subscriptions_categories AS s ON u.id=s.userid WHERE c.id IN (1,2,3,4,5) AND s.userid IS NULL

WARNING: Never use this for large sites with many users. Sending email is pretty slow and even if you use this for one category, it may make posting messages into it REALLY SLOW.

So this feature may be useful for small sites having maybe up to 50-100 users. Well, maybe we will have better emailing system for the next version. :)
Last edit: 13 years 6 months ago by Matias.

Please Log in or Create an account to join the conversation.

More
13 years 6 months ago #10 by Matias
If you have really small site with only few friends using it, you may remove c.id IN (...) to subscribe users to every category.

PS. this subject belongs into hacks category..

Please Log in or Create an account to join the conversation.

Time to create page: 0.626 seconds