ONE quick way to add the Discussion title to the email subject line:
Open Notify's default.php: Hit ctrl+F and search the page for the line (#Remove double inserted users) minus the parentheses: paste the code below just under the following default line "$e->HtmlOn = 0;":
$result = mysql_query("SELECT Name FROM ".$DiscussionForm->Context->Configuration['DATABASE_TABLE_PREFIX']."Discussion WHERE DiscussionID = '$DiscussionID'");
$row = mysql_fetch_row($result);
$mTitle = $row[0];
just for reference: the end of the code above should end just above this deafult line "foreach($Notifieusers as $val) {"
THEN REPLACE: $e->Subject = $DiscussionForm->Context->Configuration['APPLICATION_TITLE'].' '.$DiscussionForm->Context->GetDefinition('Notification');
Thanks for a nice extension! However, there is one thing that seems to be wrong.
Users seem to be notified about discussions in categories to which they do not have access to. This should definitely be checked when sending notifications. I do not want users who do not have access to some restricted categories to get notifications about messages posted into those categories.
Please correct me if I'm wrong, but I think this is quite a critical fault in this extension.
Oh well, I already added the missing functionality myself.
On row 224, in default.php of the Notify-extension, I added CategoryID to the query: $result = mysql_query("SELECT WhisperUserID,CategoryID FROM ...
And then stored the result in a variable and build check lists for blocks: $WhisperUserID = $row[0];
$CategoryID = $row[1];
// Check for users who have blocked this category (do not notify them)
$usersWithCategoryBlock = array();
$result = mysql_query("SELECT UserID FROM ".$DiscussionForm->Context->Configuration['DATABASE_TABLE_PREFIX']."CategoryBlock WHERE CategoryID = '$CategoryID'");
while(1) {
$row = mysql_fetch_row($result);
if(!$row)
break;
$usersWithCategoryBlock[] = $row[0];
}
// Check for roles for which this category is blocked (do not notify them)
$rolesWithCategoryBlock = array();
$result = mysql_query("SELECT RoleID FROM ".$DiscussionForm->Context->Configuration['DATABASE_TABLE_PREFIX']."CategoryRoleBlock WHERE CategoryID = '$CategoryID'");
while(1) {
$row = mysql_fetch_row($result);
if(!$row)
break;
$rolesWithCategoryBlock[] = $row[0];
}
Then, starting from about row 276, the if statements in... while ($row = mysql_fetch_row($result))
if (($Whispered == 1 AND $WhisperUserID == $row[0]) OR ($Whispered == 0))
array_push($Notifieusers,array($row[0],$row[1],$row[2],$row[3]));
...should be surrounded with an additional if-statement: while ($row = mysql_fetch_row($result))
if(!in_array($row[0], $usersWithCategoryBlock) && !in_array($row[4], $rolesWithCategoryBlock)) {
if (($Whispered == 1 AND $WhisperUserID == $row[0]) OR ($Whispered == 0))
array_push($Notifieusers,array($row[0],$row[1],$row[2],$row[3]));
}
Note, that there four of these if-statements to be completed and also note that some of the $row-variables are called $row2 instead of just $row.
Ah, I almost forgot. Also add RoleID to the all the queries just before these if-statements:
$result = mysql_query("SELECT UserID,Email,FirstName, LastName, RoleID FROM ...
That should do it... Hope this helps to fix the issue.
Added the fix which Dinoboff posted above to prevent this extension from causing faults with the rest of the forum. I have not added any of the potential new features as posted above as i am not aware of them having been fully tested. If someone wants to package them and test them then they are welcome to take over the extension with hutsteins agreement.
In my humble opinion, if it is not deemed worthy enough to be in the core, at least the developer (Hutstein) should be given full cooperation and assistance to make it work and work reliably.
it causes trying to add script tags where it is not needed and it causes to break ajax if enabled extensions during ajax call (check last lines of appg/init_ajax.php) and therefore it is not possible to disable any extension then - it displays alert with error message about $Head not defined because it is not defined in init_ajax and it doesn't uninstall the extension
This extension gives problems to manage categories: it is not possible to change the order any more. The javascript error is:
uncaught exception: script.aculo.us requires the Phototype JavaScript framework >= 1.5.0
Looking at the source of the page, I see that the order of the script tag in the head is:
- scriptaculous.js
- /extensions/Notify/functions.js
- /js/prototype.js
So scriptaculous.js is loaded before prototype.js and doesn't work.
Is there a way to solve this problem ?
Thanks.
A link to the server could not be established in /home/.batzi/cbabas/cbabaseball.com/board/extensions/Notify/default.php on line 435
That line is:
if ($Context->Session->UserID > 0) mysql_query("UPDATE ".$Context->Configuration['DATABASE_TABLE_PREFIX']."User SET Notified = 0 WHERE UserID = '".$Context->Session->UserID."'");
Comments
Open Notify's default.php:
Hit ctrl+F and search the page for the line (#Remove double inserted users) minus the parentheses:
paste the code below just under the following default line "$e->HtmlOn = 0;":
$result = mysql_query("SELECT Name FROM ".$DiscussionForm->Context->Configuration['DATABASE_TABLE_PREFIX']."Discussion WHERE DiscussionID = '$DiscussionID'"); $row = mysql_fetch_row($result); $mTitle = $row[0];
just for reference: the end of the code above should end just above this deafult line "foreach($Notifieusers as $val)
{"
THEN REPLACE: $e->Subject = $DiscussionForm->Context->Configuration['APPLICATION_TITLE'].' '.$DiscussionForm->Context->GetDefinition('Notification');
WITH:
$e->Subject = $DiscussionForm->Context->Configuration[''APPLICATION_TITLE''].' "'.$mTitle.'" ';
In the email_notify.txt in the Notify extension folder you can then ALSO include the title reference (something structured like):
Hello {name}, A new comment/discussion was posted within the following topic to which you are subscribed. {title}: {topic_url}
If it helps someone else
Thanks for a nice extension! However, there is one thing that seems to be wrong.
Users seem to be notified about discussions in categories to which they do not have access to. This should definitely be checked when sending notifications. I do not want users who do not have access to some restricted categories to get notifications about messages posted into those categories.
Please correct me if I'm wrong, but I think this is quite a critical fault in this extension.
BR,
Johan
On row 224, in default.php of the Notify-extension, I added CategoryID to the query:
$result = mysql_query("SELECT WhisperUserID,CategoryID FROM ...
And then stored the result in a variable and build check lists for blocks:
$WhisperUserID = $row[0]; $CategoryID = $row[1]; // Check for users who have blocked this category (do not notify them) $usersWithCategoryBlock = array(); $result = mysql_query("SELECT UserID FROM ".$DiscussionForm->Context->Configuration['DATABASE_TABLE_PREFIX']."CategoryBlock WHERE CategoryID = '$CategoryID'"); while(1) { $row = mysql_fetch_row($result); if(!$row) break; $usersWithCategoryBlock[] = $row[0]; } // Check for roles for which this category is blocked (do not notify them) $rolesWithCategoryBlock = array(); $result = mysql_query("SELECT RoleID FROM ".$DiscussionForm->Context->Configuration['DATABASE_TABLE_PREFIX']."CategoryRoleBlock WHERE CategoryID = '$CategoryID'"); while(1) { $row = mysql_fetch_row($result); if(!$row) break; $rolesWithCategoryBlock[] = $row[0]; }
Then, starting from about row 276, the if statements in...
while ($row = mysql_fetch_row($result)) if (($Whispered == 1 AND $WhisperUserID == $row[0]) OR ($Whispered == 0)) array_push($Notifieusers,array($row[0],$row[1],$row[2],$row[3]));
...should be surrounded with an additional if-statement:
while ($row = mysql_fetch_row($result)) if(!in_array($row[0], $usersWithCategoryBlock) && !in_array($row[4], $rolesWithCategoryBlock)) { if (($Whispered == 1 AND $WhisperUserID == $row[0]) OR ($Whispered == 0)) array_push($Notifieusers,array($row[0],$row[1],$row[2],$row[3])); }
Note, that there four of these if-statements to be completed and also note that some of the $row-variables are called $row2 instead of just $row.
Ah, I almost forgot. Also add RoleID to the all the queries just before these if-statements:
$result = mysql_query("SELECT UserID,Email,FirstName, LastName, RoleID FROM ...
That should do it... Hope this helps to fix the issue.
BR,
Johan
In my humble opinion, if it is not deemed worthy enough to be in the core, at least the developer (Hutstein) should be given full cooperation and assistance to make it work and work reliably.
I only wish my skill set allowed me to help out.
it causes trying to add script tags where it is not needed
and it causes to break ajax if enabled extensions during ajax call (check last lines of appg/init_ajax.php) and therefore it is not possible to disable any extension then - it displays alert with error message about $Head not defined because it is not defined in init_ajax and it doesn't uninstall the extension
this:
if (in_array($Context->SelfUrl, array('comments.php','index.php','account.php','categories.php'))) $Head->AddScript('js/prototype.js'); $Head->AddScript('js/scriptaculous.js'); $Head->AddScript('extensions/Notify/functions.js');
should beif (in_array($Context->SelfUrl, array('comments.php','index.php','account.php','categories.php'))) { $Head->AddScript('js/prototype.js'); $Head->AddScript('js/scriptaculous.js'); $Head->AddScript('extensions/Notify/functions.js'); }
A link to the server could not be established in /home/.batzi/cbabas/cbabaseball.com/board/extensions/Notify/default.php on line 435
That line is:
Also, {topic_url} refers to an "ugly" permalink, rather than the "pretty" mod_rewrite permalinks I have set up. Any ideas?
If I can get all the code worked out, I may be able to continue some development on this.
Just have had no time to find the cause