[MODDB] Smartfeed for phpBB 3

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment!
Ideas Centre
Locked
User avatar
MarkDHamill
Registered User
Posts: 4298
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: [RC6] Smartfeed for phpBB 3

Post by MarkDHamill »

Thanks Mickey, will amend.

As you can imagine putting these instructions together with a complex mod is both time consuming and error prone. I did go through the build instructions on a test server so I know they are good.
Need phpBB services or a phpBB consultant? I offer most phpBB services. Getting lost managing phpBB? Buy my book, Mastering phpBB Administration. eBook and paper versions available.
Mickey14
Registered User
Posts: 88
Joined: Sat Mar 05, 2005 10:45 am

Re: [RC6] Smartfeed for phpBB 3

Post by Mickey14 »

Yes, I may imagine.

In the "contrib/french_install.xml" file, I found this, on section "Open: language/fr/help_faq.php"

Code: Select all

// phpBB Smartfeed MOD - Addition begin -------------------------------------------------------
$lang = array_merge($lang, array(
   'ACP_SMARTFEED_SETTINGS'               => 'Réglages de Smartfeed',
   'SMARTFEED_PRIMARY_PERFORMANCE_THROTTLES'   => 'Limites liées aux performances',
   'SMARTFEED_SECURITY_SETTINGS'            => 'Réglages de sécurité',
   'SMARTFEED_ADDITIONAL_SETTINGS'            => 'Réglages supplémentaires',
));
// phpBB Smartfeed MOD - Addition end ---------------------------------------------------------
       // Begin Smartfeed Mod
       ,
       array(
          0 => '--',
          1 => 'Flux de nouvelles'
       ),
       array(
          0 => 'Vos forums sont-ils accessibles via un flux de nouvelles utilisant les protocoles RSS et Atom ?',
          1 => 'Oui. Sur ce site est installé le MOD Smartfeed phpBB pour phpBB 3, qui permet l’accès à nos forums aussi bien publics que privés. L’accès aux forums privés nécessite les autorisations appropriées. <a href="' . append_sid("{$phpbb_root_path}smartfeed_url.$phpEx") . '">Plus d’informations</a>.'
       ),
       // End Smartfeed Mod
Should be (in fact, some lines were left from the edit just above):

Code: Select all

       // Begin Smartfeed Mod
       ,
       array(
          0 => '--',
          1 => 'Flux de nouvelles'
       ),
       array(
          0 => 'Vos forums sont-ils accessibles via un flux de nouvelles utilisant les protocoles RSS et Atom ?',
          1 => 'Oui. Sur ce site est installé le MOD Smartfeed phpBB pour phpBB 3, qui permet l’accès à nos forums aussi bien publics que privés. L’accès aux forums privés nécessite les autorisations appropriées. <a href="' . append_sid("{$phpbb_root_path}smartfeed_url.$phpEx") . '">Plus d’informations</a>.'
       ),
       // End Smartfeed Mod
Mickey14
Registered User
Posts: 88
Joined: Sat Mar 05, 2005 10:45 am

Re: [RC6] Smartfeed for phpBB 3

Post by Mickey14 »

One last thing (sorry, I wrote the posts when doing the upgrade):

The encoding of file "contrib/language/fr/mods/smartfeed.php" is Windows Latin 1, it should be UTF-8 No BOM.
Mickey14
Registered User
Posts: 88
Joined: Sat Mar 05, 2005 10:45 am

Re: [RC6] Smartfeed for phpBB 3

Post by Mickey14 »

... Was not the last one, sorry...

In fact, I have a board where there is currently no post to feed...

So I think in Smartfeed.php, in the function "handle_error", the "default" case should better be:

Code: Select all

		default:
			$error_msg = $user->lang['SMARTFEED_ERROR'][$error_code];
			break;
for "error_msg" to be filled in case the error code is neither "SMARTFEED_BAD_PASSWORD_ERROR" or "SMARTFEED_COUNT_LIMIT_MAX_ERROR".
Mickey14
Registered User
Posts: 88
Joined: Sat Mar 05, 2005 10:45 am

Re: [RC6] Smartfeed for phpBB 3

Post by Mickey14 »

Also, I am not sure, in Smartffed.php, that such a non constant switch case is valid:

Code: Select all

	case $smartfeed['SMARTFEED_SORT_BY_VALUES'][SMARTFEED_BOARD]:
(same for all the cases in "switch($sort_by)")
My PHP complaints (with a notice) that

Code: Select all

<b>[phpBB Debug] PHP Notice</b>: in file <b>/smartfeed.php</b> on line <b>557</b>: <b>Undefined index:  user</b><br />
I think it is sufficient to have

Code: Select all

switch($sort_by)
{
	case SMARTFEED_BOARD:
(...)
	case SMARTFEED_STANDARD:
(...)
	case SMARTFEED_STANDARD_DESC:
(...)
	case SMARTFEED_POSTDATE:
(...)
	case SMARTFEED_POSTDATE_DESC:
(...)
}
for each case respectively.
User avatar
IPB_Refugee
Registered User
Posts: 1290
Joined: Fri Jul 07, 2006 2:25 pm
Location: Austria
Name: Wolfgang Weber

Re: [RC6] Smartfeed for phpBB 3

Post by IPB_Refugee »

Hi Mark,

first of all thanks a lot for your hard work! This MOD is getting better and better and will hopefully be validated soon.

But there are still some problems. E.g. I can confirm this:
Mickey14 wrote:Also, I am not sure, in Smartffed.php, that such a non constant switch case is valid:

Code: Select all

	case $smartfeed['SMARTFEED_SORT_BY_VALUES'][SMARTFEED_BOARD]:
(same for all the cases in "switch($sort_by)")
My PHP complaints (with a notice) that

Code: Select all

<b>[phpBB Debug] PHP Notice</b>: in file <b>/smartfeed.php</b> on line <b>557</b>: <b>Undefined index:  user</b><br />
In fact all the case lines Mickey14 mentioned cause a phpBB Debug notice (please remember that I have debug mode enabled):
[phpBB Debug] PHP Notice: in file /smartfeed.php on line 558: Undefined index: user
[phpBB Debug] PHP Notice: in file /smartfeed.php on line 592: Undefined index: standard
[phpBB Debug] PHP Notice: in file /smartfeed.php on line 595: Undefined index: standard_desc
[phpBB Debug] PHP Notice: in file /smartfeed.php on line 598: Undefined index: postdate
[phpBB Debug] PHP Notice: in file /smartfeed.php on line 601: Undefined index: postdate_desc
[phpBB Debug] PHP Notice: in file /smartfeed.php on line 667: Undefined variable: order_by_sql
Please note the last line which is different: In the following query the variable $order_by_sql is not defined, according to phpBB's debugger:

Code: Select all

$sql_array = array(

	'SELECT'	=> 'f.*, t.*, p.*, u.*',

	'FROM'		=> array(
		POSTS_TABLE => 'p',
		USERS_TABLE => 'u',
		TOPICS_TABLE => 't'	),

	'WHERE'		=> "$topics_posts_join_sql
				AND p.poster_id = u.user_id
				$date_limit_sql
				$fetched_forums_str
				$new_topics_sql
				$remove_mine_sql
				$filter_foes_sql
				AND p.post_approved = 1",

	'ORDER_BY'	=> $order_by_sql
);
The mentioned problems make it impossible to get a valid feed.

One more problem I noticed: I admit to have many forums in my board (they are all well organized), and when I visit the smartfeed_url page it takes 209 Queries . I really hope there is a potential for reducing this high number of queries. Does it also take 209 queries to get the feed? If yes, it would be impossible for me to keep your MOD installed. :(

Not a problem, just a question: What is better in functions.php?

Code: Select all

$user->setup('mods/smartfeed');
or

Code: Select all

$user->add_lang('mods/smartfeed');
Don't let these problems frustrate you, Mark! I'm sure they will be solved.

Regards
Wolfgang
User avatar
MarkDHamill
Registered User
Posts: 4298
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: [RC6] Smartfeed for phpBB 3

Post by MarkDHamill »

Thanks for the feedback. I guess I was a bit hasty in my testing, as I was anxious to get this out.

Mickey, are there any other pages where encoding is a problem? I had to revert to Notetab Light as Dreamweaver was crashing, and I think that was the problem.

The missing statement in handle_error() was an error on my part. It will be added.

I will repackage things tomorrow, but yes, the suggested changes work. I will add $user->add_lang to the changes to functions.php (I thought I had it at one point, wonder what happened.)

Also, this code does not seem to generate any PHP Notices and the sorting seems to work right when I test.

Code: Select all

// Create the SQL stub for the sort order
switch($sort_by)
{
	case SMARTFEED_BOARD:
		$topic_asc_desc = ($user_topic_sortby_dir == 'd') ? 'DESC' : '';
		switch($user_topic_sortby_type)
		{
			case 'a':
				$order_by_sql = "t.topic_first_poster_name $topic_asc_desc, ";
				break;
			case 't':
				$order_by_sql = "t.topic_last_post_time $topic_asc_desc, ";
				break;
			case 'r':
				$order_by_sql = "t.topic_replies $topic_asc_desc, ";
				break;
			case 's':
				$order_by_sql = "t.topic_title $topic_asc_desc, " ; 
				break;
			case 'v':
				$order_by_sql = "t.topic_views $topic_asc_desc, ";
				break;
		}
		$post_asc_desc = ($user_post_sortby_dir == 'd') ? 'DESC' : '';
		switch($user_post_sortby_type)
		{
			case 'a':
				$order_by_sql .= "u.username_clean $post_asc_desc";
				break;
			case 't':
				$order_by_sql .= "p.post_time $post_asc_desc";
				break;
			case 's':
				$order_by_sql .= "p.post_subject $post_asc_desc" ; 
				break;
		}
		break;
	case SMARTFEED_STANDARD:
		$order_by_sql = 'f.left_id, f.right_id, t.topic_last_post_time, p.post_time';
		break;
	case SMARTFEED_STANDARD_DESC:
		$order_by_sql = 'f.left_id, f.right_id, t.topic_last_post_time, p.post_time DESC';
		break;
	case SMARTFEED_POSTDATE:
		$order_by_sql = 'p.post_time';
		break;
	case SMARTFEED_POSTDATE_DESC:
		$order_by_sql = 'p.post_time DESC';
		break;
}
Discouraged? The only discouraging part is going through the phpBB Mod Team hoops over and over again (it seems like there is no exit criteria) and waiting weeks sometimes for feedback.

Let me know if you see other errors.
Need phpBB services or a phpBB consultant? I offer most phpBB services. Getting lost managing phpBB? Buy my book, Mastering phpBB Administration. eBook and paper versions available.
Mickey14
Registered User
Posts: 88
Joined: Sat Mar 05, 2005 10:45 am

Re: [RC6] Smartfeed for phpBB 3

Post by Mickey14 »

Hi, Mark!

I did not see any other problems in the code.

Regarding the encodings, I saw that the br file in "contrib/language/br/mods/smartfeed.php" is also encoded in Windows latin 1 instead of UTF-8 no BOM. No problem for the "de" on the contrary.

Maybe highlight in red that the feed URL needs to be updated for the "limit" parameter: the "%20" should become "_" (for those not willing to rebuild it in smartfeed_url.php, retransfer it to their phone for instance.

(I forgot to thank you for your patience and for your wonderful mod! Tahnks, and keep up the good work!)
User avatar
MarkDHamill
Registered User
Posts: 4298
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: [RC6] Smartfeed for phpBB 3

Post by MarkDHamill »

Archive has been repacked with requested changes, and I believe all the file encodings are now correct. Thanks everyone for working out the installation bugs!
Need phpBB services or a phpBB consultant? I offer most phpBB services. Getting lost managing phpBB? Buy my book, Mastering phpBB Administration. eBook and paper versions available.
User avatar
MarkDHamill
Registered User
Posts: 4298
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: [RC6] Smartfeed for phpBB 3

Post by MarkDHamill »

IPB_Refugee wrote:One more problem I noticed: I admit to have many forums in my board (they are all well organized), and when I visit the smartfeed_url page it takes 209 Queries . I really hope there is a potential for reducing this high number of queries. Does it also take 209 queries to get the feed? If yes, it would be impossible for me to keep your MOD installed. :(
There is this code in smartfeed_url.php where SQL is issues inside a loop.

Code: Select all

		while ($there_are_parents)
		{
			$sql = 'SELECT parent_id 
					FROM ' . FORUMS_TABLE . "
					WHERE forum_id = $this_forum_id";
			$result = $db->sql_query($sql);
			$row = $db->sql_fetchrow($result);
			if ((int) $row['parent_id'] == 0)
			{
				$there_are_parents = false;
			}
			else
			{
				// Do not add this parent to the list of allowed forums if it is already in the array
				if (!in_array((int) $row['parent_id'], $allowed_forums))
				{
					$allowed_forums[] = (int) $row['parent_id'];
				} 
				$this_forum_id = (int) $row['parent_id'];	// Keep looping...
			}
		}
This is used to generate a hierarchy of categories and forums. I don't know how many forums and categories you have on your board but if there were hundreds this could cause an issue. There may be more optimal ways to write this. I do not see anything else that would come close to causing a problem with SQL queries.
Need phpBB services or a phpBB consultant? I offer most phpBB services. Getting lost managing phpBB? Buy my book, Mastering phpBB Administration. eBook and paper versions available.
Mickey14
Registered User
Posts: 88
Joined: Sat Mar 05, 2005 10:45 am

Re: [RC6] Smartfeed for phpBB 3

Post by Mickey14 »

Thanks, Mark.

I will check thoroughly tonight, but I saw already that the "/Volumes/Michel\ G5\ Docs\ 2/FTP\ Recipient/smartfeed_2.2.3/contrib/language/br/mods/smartfeed.php" file is still Windows Latin 1 encoded, but maybe it is normal (I don't speak Bulgarian).

Anything else should be OK so far.

Mickey
User avatar
MarkDHamill
Registered User
Posts: 4298
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: [RC6] Smartfeed for phpBB 3

Post by MarkDHamill »

Thanks. I thought I checked that. Will repack archive.
Need phpBB services or a phpBB consultant? I offer most phpBB services. Getting lost managing phpBB? Buy my book, Mastering phpBB Administration. eBook and paper versions available.
User avatar
IPB_Refugee
Registered User
Posts: 1290
Joined: Fri Jul 07, 2006 2:25 pm
Location: Austria
Name: Wolfgang Weber

Re: [RC6] Smartfeed for phpBB 3

Post by IPB_Refugee »

Hi Mark,

really glad to hear you took it easy! :)
MarkDHamill wrote:This is used to generate a hierarchy of categories and forums. I don't know how many forums and categories you have on your board but if there were hundreds this could cause an issue. There may be more optimal ways to write this. I do not see anything else that would come close to causing a problem with SQL queries.
The bitter truth is that I really have m_a_n_y forums on my board and due to an idea of my co-admin many more forums are to come. And I can't change it.

For example think about a board with these categories and forums (it's just an example):

New Authors

...Alaska
...Alabama
...Arkansas
...
...

New Singers

...Alaska
...Alabama
...Arkansas
...
...

New Performance Artists

...Alaska
...Alabama
...Arkansas
...
...

That makes 150 forums. Add a category or two and you have 200 respectively 250 forums... I really can't reduce the number of forums on my board.
Hmm, I don't need a beautiful list of forums and categories on the smartfeed_url page. Is there a way to get the same functionality a little bit uglier but without so many queries? That would be really great!

(And to just make it sure: the problem with the SQL query inside a loop exists only in smartfeed_url.php, not in smartfeed.php too, right?)

Regards
Wolfgang
User avatar
MarkDHamill
Registered User
Posts: 4298
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: [RC6] Smartfeed for phpBB 3

Post by MarkDHamill »

Wolfgang, I will just have to ponder whether this can be done more efficiently. It took a long time to figure out the logic to get the forums to display dynamically and in a hierarchy. I will look into it for a future version.

I suspect most boards have a modest number of forums so it is not an issue. Also note that while these calls are done in smartfeed_url.php, it should get run only occasionally when a user is setting up a feed. smartfeed.php has no similar issue that I am aware of and it should get called much more often.
Need phpBB services or a phpBB consultant? I offer most phpBB services. Getting lost managing phpBB? Buy my book, Mastering phpBB Administration. eBook and paper versions available.
mamisano
Registered User
Posts: 5
Joined: Fri Aug 08, 2008 3:56 pm
Location: Long Island, New York
Contact:

Re: [RC6] Smartfeed for phpBB 3

Post by mamisano »

I am having a problem getting this mod up and running no matter what I try. I just upgraded from 2.2.2 to 2.2.3 and can not get either to work. Can someone help me out?

When I click on the Smartfeed link, I receive the following error:

Top of page:

Code: Select all

[phpBB Debug] PHP Notice: in file /smartfeed_url.php on line 186: Invalid argument supplied for foreach()
Message in body:

Code: Select all

Sorry, due to your user status you cannot access any forums

Powered by
This version of Smartfeed is up-to-date, no update available. 
The board is running 3.0.2, no other mods installed. Using LDAP for user authentication.

Thanks!
-Michael
Locked

Return to “[3.0.x] MODs in Development”