Okay, I think the name of the MOD speaks for itself. I wasn't considering sharing it since I worked a lot on it, but since I love the 4images community I decided to share it and develop it further.
Please keep in mind that this is
v0.1 of the MOD - I will release v0.2 soon (after getting some
feedback of you).
WHATThis MOD created something like the notification feed on facebook. If user A comments, votes or add's a photo of user B, user B will get notifications (on the site, not by mail).
A "New Notifications" - count is displayed in the user login info, showng your unseen notifications. After you click on it (and see your new notifications) this number is being reset
(like on facebook) automatically - you don't have to click on anything to mark a notification as read (unlike other similar mod's to mine) . You can browse old notifications.
Please see attached screen-shots to get a feeling (at the end of this topic) (last screenshot is how it can look like with a little customization).
This MOD put's everything that happens to your user's pictures into one place.
WARNING1) This is the first release - I tested it, but it can contain bug's . Please post if you have any problems, I tested it with 4images 1.7.10 and PHP5.
2) I didn't use language tags, because I am too lazy to do it. If you want to use language tags you can add them yourself.
3)
This MOD won't work properly with guests (at least I didn't test it)4) The MOD assumes that all your userpic files are "*.jpg" - please check your upload settngs (for userpic) and don't allow other file types (only for userpicture)
NEEDED MODSThis MOD supposes you installed V@no's
[MOD] Member personal photo v1.1.3. If you want to use my MOD without it with, you can, but it just looks better with it.
Please make sure that you did the step's required to add default user-image, if no user-image is uploaded (otherwise you'll get broken images)
NOTEThe way I did this MOD is certainly not perfect, but it works for the purpose of my website. Please be patient for the
User Activity Feed, as of right now I am only uploading the
Notification part.
FIXES31.10.2011 - fixed comment formatting, please do STEP 9 31.10.2011 - fixed getting notifications when commenting on own pictures, please redo STEP 4 (code updated). ==================================================================Okay, be sure to make a backup of your database and your files that are being changed.
STEP 1run this query in your php-my-admin:
CREATE TABLE IF NOT EXISTS `4images_notifications` (
`id` int(12) unsigned NOT NULL AUTO_INCREMENT,
`from_id` int(10) unsigned NOT NULL DEFAULT '0',
`to_id` int(10) unsigned NOT NULL DEFAULT '0',
`from_username` varchar(255) NOT NULL,
`to_username` varchar(255) NOT NULL,
`what_pic` varchar(255) NOT NULL,
`text1` varchar(255) NOT NULL,
`text2` varchar(255) NOT NULL,
`text3` varchar(255) NOT NULL,
`content` text NOT NULL,
`content_link` varchar(255) NOT NULL,
`date` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `from_id` (`from_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=0 ;
then, run this sql in your php-my-admin:
ALTER TABLE `4images_users` ADD `user_notify` int(10) NOT NULL DEFAULT '0'
==================================================================STEP 2open includes/constants.php
find:
define('WORDMATCH_TABLE', $table_prefix.'wordmatch');
add below
define('NOTIFY_TABLE', $table_prefix.'notifications');
==================================================================STEP 3open includes/functions.php
//including FAVORITES (LIGHTBOX) to be shown
find:
if (!in_array($id, $lightbox_array)) {
add below:
//activity
$sql = "SELECT cat_id,image_media_file,image_name, image_id, user_id
FROM ".IMAGES_TABLE."
WHERE image_active = 1 AND image_id = $id";
$result = $site_db->query_firstrow($sql);
$cat = $result['cat_id'];
$media = $result['image_media_file'];
$name = $result['image_name'];
$image_id = $result['image_id'];
$user_id = $result['user_id'];
$sql = "INSERT INTO " . NOTIFY_TABLE . "
(id, from_id, to_id, from_username, to_username, what_pic, text1, text2, text3, content, content_link, date)
VALUES(NULL, '".$user_info['user_id']."', '" . $user_id . "', '".$user_info['user_name']."', '', '".$cat."' '/' '".$media."', 'added', '".$name."', 'as a favourite', '', 'details.php?image_id=' '".$image_id."', '" . time() . "')";
$site_db->query($sql);
$sql = "UPDATE ".USERS_TABLE."
SET user_notify=user_notify+1 WHERE user_id = ".$user_id;
$site_db->query($sql);
//activity
//now we are including the rating to be shown
find:
function update_image_rating($image_id, $rating) {
global $site_db;
$sql = "SELECT cat_id, image_votes, image_rating
replace with:
function update_image_rating($image_id, $rating) {
global $site_db, $user_info;
$sql = "SELECT cat_id, image_votes, image_rating, user_id, image_media_file, image_name, image_id
find:
$new_rating = sprintf("%.2f", $new_rating);
insert
below:
$rating_value = $rating;
find:
$sql = "UPDATE ".IMAGES_TABLE."
SET image_votes = ($old_votes + 1), image_rating = '$new_rating'
WHERE image_id = $image_id";
$site_db->query($sql);
add
below:
//activity
$cat = $image_row['cat_id'];
$to_id = $image_row['user_id'];
$media = $image_row['image_media_file'];
$name = $image_row['image_name'];
$image_id = $image_row['image_id'];
$user_name = $user_info['user_name'];
$sql = "UPDATE ".USERS_TABLE."
SET user_notify=user_notify+1 WHERE user_id = ".$to_id;
$site_db->query($sql);
$sql = "INSERT INTO " . NOTIFY_TABLE . "
(id, from_id, to_id, from_username, to_username, what_pic, text1, text2, text3, content, content_link, date)
VALUES(NULL, '".$user_info['user_id']."', '$to_id', '$user_name', '0', '".$cat."' '/' '".$media."' , 'rated', '".$name."', 'with' ' ' '<b>' '$rating_value' '</b>' , '', 'details.php?image_id=' '".$image_id."', '" . time() . "')";
$site_db->query($sql);
//activity
==================================================================STEP 4open details.php (or ajaxcomments.php if you installed
THIS MOD)
find:
update_comment_count($id, $user_info['user_id']);
add
below:
//activity
$sql = "SELECT cat_id,image_media_file,image_name, image_id, user_id
FROM ".IMAGES_TABLE."
WHERE image_active = 1 AND image_id = $id";
$result = $site_db->query_firstrow($sql);
$cat = $result['cat_id'];
$to_id = $result['user_id'];
$media = $result['image_media_file'];
$name = $result['image_name'];
$image_id = $result['image_id'];
if ($user_info['user_id'] != $result['user_id']) {
$sql = "UPDATE ".USERS_TABLE."
SET user_notify=user_notify+1 WHERE user_id = ".$to_id;
$site_db->query($sql);
$sql = "INSERT INTO " . NOTIFY_TABLE . "
(id, from_id, to_id, from_username, to_username, what_pic, text1, text2, text3, content, content_link, date)
VALUES(NULL, '".$user_info['user_id']."', '$to_id','$user_name', '0', '".$cat."' '/' '".$media."' , 'commented', '".$name."', '', '$comment_text', 'details.php?image_id=' '".$image_id."', '" . time() . "')";
$site_db->query($sql);
}
//activity
==================================================================STEP 5open includes/page_header.php
find:
"rss_url" => "",
add
below:
"sess_user_notify" => $user_info['user_notify'],
==================================================================STEP 6open your_template/header.html
find:
» <a href="{url_control_panel}">{lang_control_panel}</a><br />
add
below:
» Notifications <a href="notifications.php?action=new">{sess_user_notify}</a><br />
==================================================================STEP 7Upload notifications.php to your 4images root folder
Upload member_notifications.html, member_notifications_bit.html and member_notifications_new.html to your 4images template folder
Files are attached to this post.==================================================================STEP 8Do some testing. If everything works (yeah, it will) start customizing the *.html files to your personal design.
---------------------------------------------------------------------------------------
STEP 9 - FIXESa - fix comment formatting (bbcode etc).
open notifications.php and find:
"content" => $content,
replace with:
"comment_text" => format_text($comment_row[$i]['comment_text'], $config['html_comments'], $config['wordwrap_comments'], $config['bb_comments'], $config['bb_img_comments']),
---------------------------------------------------------------------------------------
PLANNED FOR V0.2- icons for each different notification
- activity wall
- paging for old notifications
- fix own notifications (when commenting own image) ---
DONE - support for guestbooks and various other MOD's