Page 1 of 1

New photo since last visit & you photo number

Posted: 11. January 2010 16:26
by steelhomework
Your Portal Version: 3.0.6
Your phpBB Type: Standard phpBB3
MODs installed: Yes
Your knowledge: Basic Knowledge

What have you done before the problem was there?


What have you already tryed to solve the problem?


Description and Message
All greetings.

How to do would be to block User Menu be read new photos (number)? As New messages (0).
I should Board3 1.0.4 and phpBB Gallery 1.0.4.

Here's the code:

Code: Select all

//
// + new photo since last visit & you photo number
//
if ($user->data['is_registered'])
{
	$ex_fid_ary = array_unique(array_merge(array_keys($auth->acl_getf('!f_read', true)), array_keys($auth->acl_getf('!f_search', true))));
	
	if ($auth->acl_get('m_approve'))
	{
		$m_approve_fid_ary = array(-1);
		$m_approve_fid_sql = '';
	}
	else if ($auth->acl_getf_global('m_approve'))
	{
		$m_approve_fid_ary = array_diff(array_keys($auth->acl_getf('!m_approve', true)), $ex_fid_ary);
		$m_approve_fid_sql = ' AND (p.post_approved = 1' . ((sizeof($m_approve_fid_ary)) ? ' OR ' . $db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) : '') . ')';
	}
	else
	{
		$m_approve_fid_ary = array();
		$m_approve_fid_sql = ' AND p.post_approved = 1';
	}

	$sql = 'SELECT COUNT(distinct t.image_id) as total
				FROM phpbb_gallery_images t
				WHERE t.image_time > ' . $user->data['user_lastvisit'] . '
					AND t.topic_moved_id = 0
					' . str_replace(array('p.', 'post_'), array('t.', 'topic_'), $m_approve_fid_sql) . '
					' . ((sizeof($ex_fid_ary)) ? 'AND ' . $db->sql_in_set('t.image_id', $ex_fid_ary, true) : '');
	$result = $db->sql_query($sql);
	$new_photo_count = (int) $db->sql_fetchfield('total');

	// your photo number
	$sql = "SELECT user_images
		FROM phpbb_gallery_users
		WHERE user_id = " . $user->data['user_id'];
	$result = $db->sql_query($sql);
	$you_photo_count = (int) $db->sql_fetchfield('user_images');
}
//
// - new photo since last visit & you photo number
//
How to calculate the photos, I did. But how to calculate new photos from the last visit?[/i]

Re: New photo since last visit & you photo number

Posted: 11. January 2010 16:40
by steelhomework
I made code newphotos for search. Everything okay?

Code: Select all

			case 'newphotos':
				$template->assign_block_vars('navlinks', array(
					'FORUM_NAME'	=> $user->lang['NEW_PHOTO'],
					'U_VIEW_FORUM'	=> append_sid("{$phpbb_root_path}{$gallery_root_path}search.$phpEx", 'search_id=' . $search_id),
				));

				$l_search_title = $user->lang['NEW_PHOTO'];
				$search_results = 'image';

				$sql_order = 'image_time DESC';
				$sql_limit = SEARCH_PAGES_NUMBER * $per_page;
				$sql = 'SELECT image_id
					FROM ' . GALLERY_IMAGES_TABLE . '
					WHERE image_time > ' . $user->data['user_lastvisit'] . '
						AND ((' . $db->sql_in_set('image_album_id', gallery_acl_album_ids('i_view'), false, true) . ' AND image_status <> ' . IMAGE_UNAPPROVED . ' AND image_contest = ' . IMAGE_NO_CONTEST . ')
							OR ' . $db->sql_in_set('image_album_id', gallery_acl_album_ids('m_status'), false, true) . ')
					ORDER BY ' . $sql_order;
			break;