Hello everyone.
Does anyone know how to get an email notification when:
1) a new Category is suggested
2) a Comment has been add it.
It shows up in the admin control panel, but you would not know it unless you log in.
Thanks
jfk
Dave Baker
01-31-2007, 01:16 AM
Don't forget to make backup copy of your database and files.
***Open file classes/Dir.php and find a function ***
function addLinkComment($aLink, $aComment, $aAuthor = '', $aEmail = '', $aRating = '', $aEditor = '')
{
$sql = "INSERT INTO `{$this->mPrefix}link_comments` ";
$cause = $aRating ? ' , `rating`' : '';
$cause .= $aEditor ? ' , `id_editor`' : '';
$sql .= "(`id_link`, `body`, `date`, `status`, `author`, `email`, `ip_address`{$cause}) ";
$status = ($this->mConfig['comments_approval']) ? 'active' : 'approval';
$cause = $aRating ? " , '{$aRating}'" : '';
$cause .= $aEditor ? " , '{$aEditor}'" : '';
$sql .= "VALUES('{$aLink}', '{$aComment}', NOW(), '{$status}', '{$aAuthor}', '{$aEmail}', '{$_SERVER['REMOTE_ADDR']}'{$cause})";
$this->mDb->query($sql);
$this->syncLinkComments($aLink);
}
***Replace with this function***
function addLinkComment($aLink, $aComment, $aAuthor = '', $aEmail = '', $aRating = '', $aEditor = '')
{
$sql = "INSERT INTO `{$this->mPrefix}link_comments` ";
$cause = $aRating ? ' , `rating`' : '';
$cause .= $aEditor ? ' , `id_editor`' : '';
$sql .= "(`id_link`, `body`, `date`, `status`, `author`, `email`, `ip_address`{$cause}) ";
$status = ($this->mConfig['comments_approval']) ? 'active' : 'approval';
$cause = $aRating ? " , '{$aRating}'" : '';
$cause .= $aEditor ? " , '{$aEditor}'" : '';
$sql .= "VALUES('{$aLink}', '{$aComment}', NOW(), '{$status}', '{$aAuthor}', '{$aEmail}', '{$_SERVER['REMOTE_ADDR']}'{$cause})";
$this->mDb->query($sql);
/** sends email to administrator **/
$admin =& $this->getAdmin();
if ($admin['submit_notif'])
{
$aLink =& $this->getLinkById($aLink);
$id_category = $aLink['id_category'];
$categoty =& $this->getCategoryById($id_category);
$this->mMailer->sendSubmissionNotif($admin, $aLink, $category, "1");
}
$this->syncLinkComments($aLink);
}
***Find a function****
function addCategory($aCategory)
{
// Get new category level.
// New category level == Parent category level + 1
$parent = $aCategory['id_parent'];
$parent_category = $this->getCategoryById($aCategory['id_parent']);
$aCategory['level'] = $parent_category['level'] + 1;
// Prepare and execute the query for inserting new
// category into the database.
$sql = "INSERT INTO `{$this->mPrefix}categories` (";
foreach($aCategory as $key=>$value)
{
$sql .= "`{$key}`,";
}
$sql .= "`status`) VALUES (";
foreach($aCategory as $key=>$value)
{
$sql .= "'{$value}',";
}
$sql .= "'approval')";
$this->mDb->query($sql);
return (int)mysql_insert_id();
}
***Replace with this function***
function addCategory($aCategory)
{
// Get new category level.
// New category level == Parent category level + 1
$parent = $aCategory['id_parent'];
$parent_category = $this->getCategoryById($aCategory['id_parent']);
$aCategory['level'] = $parent_category['level'] + 1;
// Prepare and execute the query for inserting new
// category into the database.
$sql = "INSERT INTO `{$this->mPrefix}categories` (";
foreach($aCategory as $key=>$value)
{
$sql .= "`{$key}`,";
}
$sql .= "`status`) VALUES (";
foreach($aCategory as $key=>$value)
{
$sql .= "'{$value}',";
}
$sql .= "'approval')";
$this->mDb->query($sql);
/** sends email to administrator **/
$admin =& $this->getAdmin();
if ($admin['submit_notif'])
{
$this->mMailer->sendSubmissionNotif($admin, $aLink, $category, "2");
}
return (int)mysql_insert_id();
}
***Save file***
***Open file classes/DirMailer.php and find a function***
function sendSubmissionNotif($aAdmin, $aLink, $aCategory)
{
$subject = $this->mConfig['admin_notif_subject'];
$body = $this->mConfig['admin_notif_body'];
$subject = str_replace('{own_site}', $this->mConfig['site'], $subject);
$body = str_replace('{admin_name}', $aAdmin['fullname'], $body);
$body = str_replace('{your_site_url}', $aLink['url'], $body);
$body = str_replace('{your_site_title}', $aLink['title'], $body);
$body = str_replace('{your_site_desc}', $aLink['description'], $body);
$body = str_replace('{your_site_email}', $aLink['email'], $body);
$body = str_replace('{own_site}', $this->mConfig['site'], $body);
$body = str_replace('{own_url}', $this->mConfig['base'], $body);
$body = str_replace('{own_email}', $this->mConfig['site_email'], $body);
$body = str_replace('{own_dir_url}', $this->mConfig['base'].$this->mConfig['dir'], $body);
$body = str_replace('{dir_link}', "{$this->mConfig['base']}{$this->mConfig['dir']}{$aCategory['path']}/", $body);
return $this->sendEmail($aAdmin['email'], $subject, $body, $this->mConfig['site_email'], $this->mConfig['site_email']);
}
***Replace with this function***
function sendSubmissionNotif($aAdmin, $aLink, $aCategory, $aWhat = 0)
{
if ($aWhat == 1)
{
$subject = $this->mConfig['comment_add_subject'];
$body = $this->mConfig['comment_add_body'];
}
elseif ($aWhat == 2)
{
$subject = $this->mConfig['category_add_subject'];
$body = $this->mConfig['category_add_body'];
}
else
{
$subject = $this->mConfig['admin_notif_subject'];
$body = $this->mConfig['admin_notif_body'];
}
$subject = str_replace('{own_site}', $this->mConfig['site'], $subject);
$body = str_replace('{admin_name}', $aAdmin['fullname'], $body);
$body = str_replace('{your_site_url}', $aLink['url'], $body);
$body = str_replace('{your_site_title}', $aLink['title'], $body);
$body = str_replace('{your_site_desc}', $aLink['description'], $body);
$body = str_replace('{your_site_email}', $aLink['email'], $body);
$body = str_replace('{own_site}', $this->mConfig['site'], $body);
$body = str_replace('{own_url}', $this->mConfig['base'], $body);
$body = str_replace('{own_email}', $this->mConfig['site_email'], $body);
$body = str_replace('{own_dir_url}', $this->mConfig['base'].$this->mConfig['dir'], $body);
$body = str_replace('{dir_link}', "{$this->mConfig['base']}{$this->mConfig['dir']}{$aCategory['path']}/", $body);
return $this->sendEmail($aAdmin['email'], $subject, $body, $this->mConfig['site_email'], $this->mConfig['site_email']);
}
***Save file***
Download attachment file from my post, unzip and upload to "updates/" folder in your directory. Go to Admin Panel » Manage Database » Import » choose file "add_emails.sql" to import » "Go" button.
After that you can find templates here: Admin Panel » Configuration » Email Templates » Submission Notification Email for Admin
Dave.
Thank you very much for your help. I will try it tomorrow.
I just want it to thank for being so quick and helpful.
(Especially when I know I'm not the only one here.)
Thank you again.
Kindly;
jfk
p.s I won't ask you any more question. (( today))
guarez
05-10-2007, 05:47 PM
hi!
i need these function in my esyndicat 1.5 free version, this modification work ? or i need the PRO version?
Dave Baker
05-10-2007, 06:03 PM
guarez,
This functionality was intended for Pro version.
For what Pro Version ?
2.1.0.3 ?
Hope this feature will be in 2.2.
:)
Dave Baker
05-22-2007, 04:55 PM
Hello osr,
AFAIR this modification intended for Pro1.2 and Pro2.0 version.
We will try to implement it in our future version.
Dave Baker
05-23-2007, 12:40 AM
Always at your services osr!
vBulletin® v3.7.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.