[Customisation Database Commits] r447 - in /trunk/titania: common.php contributions/details.php includes/constants.php includes/functions_display.php includes/objects/contribution.php includes/objects/topic.php includes/tools/tracking.php install.php

Nathan Guse exreaction at phpbb.com
Mon Dec 21 22:48:55 GMT 2009


Author: exreaction
Date: Mon Dec 21 22:48:54 2009
New Revision: 447

Log:
Tracking of contribution items

Modified:
    trunk/titania/common.php
    trunk/titania/contributions/details.php
    trunk/titania/includes/constants.php
    trunk/titania/includes/functions_display.php
    trunk/titania/includes/objects/contribution.php
    trunk/titania/includes/objects/topic.php
    trunk/titania/includes/tools/tracking.php
    trunk/titania/install.php

Modified: trunk/titania/common.php
==============================================================================
*** trunk/titania/common.php (original)
--- trunk/titania/common.php Mon Dec 21 22:48:54 2009
***************
*** 17,23 ****
  }
  
  // Version number (only used for the installer)
! define('TITANIA_VERSION', '0.1.20');
  
  define('PHPBB_MSG_HANDLER', 'titania_msg_handler');
  define('PHPBB_USE_BOARD_URL_PATH', true);
--- 17,23 ----
  }
  
  // Version number (only used for the installer)
! define('TITANIA_VERSION', '0.1.21');
  
  define('PHPBB_MSG_HANDLER', 'titania_msg_handler');
  define('PHPBB_USE_BOARD_URL_PATH', true);

Modified: trunk/titania/contributions/details.php
==============================================================================
*** trunk/titania/contributions/details.php (original)
--- trunk/titania/contributions/details.php Mon Dec 21 22:48:54 2009
***************
*** 22,27 ****
--- 22,31 ----
  load_contrib();
  titania::$contrib->assign_details();
  
+ // Set tracking
+ // @todo tracking currently only handles initial creation, should work for updates to mods as well
+ titania_tracking::track(TITANIA_TRACK_CONTRIB, titania::$contrib->contrib_id);
+ 
  // Get the attachments
  $attachment = new titania_attachments(TITANIA_DOWNLOAD_CONTRIB, titania::$contrib->contrib_id);
  

Modified: trunk/titania/includes/constants.php
==============================================================================
*** trunk/titania/includes/constants.php (original)
--- trunk/titania/includes/constants.php Mon Dec 21 22:48:54 2009
***************
*** 96,101 ****
--- 96,102 ----
  // Tracking types
  define('TITANIA_TRACK_TOPICS', 1);
  define('TITANIA_TRACK_FAQ', 2);
+ define('TITANIA_TRACK_CONTRIB', 3);
  
  // Header status codes
  define('HEADER_OK',						200);

Modified: trunk/titania/includes/functions_display.php
==============================================================================
*** trunk/titania/includes/functions_display.php (original)
--- trunk/titania/includes/functions_display.php Mon Dec 21 22:48:54 2009
***************
*** 110,115 ****
--- 110,122 ----
  					USERS_TABLE				=> 'u',
  				),
  
+ 				'LEFT_JOIN'	=> array(
+ 					array(
+ 						'FROM'	=> array(TITANIA_TRACK_TABLE => 'tt'),
+ 						'ON'	=> 'tt.track_type = ' . TITANIA_TRACK_CONTRIB . ' AND tt.track_id = c.contrib_id',
+ 					),
+ 				),
+ 
  				'WHERE'		=> 'c.contrib_user_id = ' . (int) $id . '
  					AND u.user_id = c.contrib_user_id
  					AND c.contrib_visible = 1',
***************
*** 125,131 ****
  
  			$sql_ary = array(
  				// DO NOT change to *, we do not need all rows from ANY table with the query!
! 				'SELECT'	=> 'c.contrib_name, c.contrib_name_clean, c.contrib_status, c.contrib_downloads, c.contrib_views, c.contrib_rating, c.contrib_rating_count, c.contrib_type, u.username, u.user_colour, u.username_clean',
  
  				'FROM'		=> array(
  					TITANIA_CONTRIB_IN_CATEGORIES_TABLE 	=> 'cic',
--- 132,140 ----
  
  			$sql_ary = array(
  				// DO NOT change to *, we do not need all rows from ANY table with the query!
! 				'SELECT'	=> 'c.contrib_name, c.contrib_name_clean, c.contrib_status, c.contrib_downloads, c.contrib_views, c.contrib_rating, c.contrib_rating_count, c.contrib_type, c.contrib_last_update,
! 					u.username, u.user_colour, u.username_clean,
! 					tt.track_time',
  
  				'FROM'		=> array(
  					TITANIA_CONTRIB_IN_CATEGORIES_TABLE 	=> 'cic',
***************
*** 134,144 ****
  				'LEFT_JOIN'	=> array(
  					array(
  						'FROM'	=> array(TITANIA_CONTRIBS_TABLE	=> 'c'),
! 						'ON'	=> 'cic.contrib_id = c.contrib_id'
  					),
  					array(
  						'FROM'	=> array(USERS_TABLE	=> 'u'),
! 						'ON'	=> 'u.user_id = c.contrib_user_id'
  					),
  				),
  
--- 143,157 ----
  				'LEFT_JOIN'	=> array(
  					array(
  						'FROM'	=> array(TITANIA_CONTRIBS_TABLE	=> 'c'),
! 						'ON'	=> 'cic.contrib_id = c.contrib_id',
  					),
  					array(
  						'FROM'	=> array(USERS_TABLE	=> 'u'),
! 						'ON'	=> 'u.user_id = c.contrib_user_id',
! 					),
! 					array(
! 						'FROM'	=> array(TITANIA_TRACK_TABLE => 'tt'),
! 						'ON'	=> 'tt.track_type = ' . TITANIA_TRACK_CONTRIB . ' AND tt.track_id = c.contrib_id',
  					),
  				),
  
***************
*** 174,179 ****
--- 187,199 ----
  
  		$author->__set_array($row);
  
+ 		// Store the tracking info we grabbed in the tool
+ 		titania_tracking::store_track(TITANIA_TRACK_CONTRIB, $contrib->contrib_id, $row['track_time']);
+ 
+ 		// Get the folder image
+ 		$folder_img = $folder_alt = '';
+ 		titania_topic_folder_img($folder_img, $folder_alt, 0, titania_tracking::is_unread(TITANIA_TRACK_CONTRIB, $contrib->contrib_id, $contrib->contrib_last_update));
+ 
  		phpbb::$template->assign_block_vars($blockname, array(
  			'CONTRIB_USERNAME'			=> $contrib->username,
  			'CONTRIB_USERNAME_FULL'		=> $author->get_username_string(),
***************
*** 188,193 ****
--- 208,220 ----
  			'U_VIEW_CONTRIB'			=> $contrib->get_url(),
  
  			'S_CONTRIB_TYPE'			=> $contrib->contrib_type,
+ 
+ 			'FOLDER_IMG'				=> phpbb::$user->img($folder_img, $folder_alt),
+ 			'FOLDER_IMG_SRC'			=> phpbb::$user->img($folder_img, $folder_alt, false, '', 'src'),
+ 			'FOLDER_IMG_ALT'			=> phpbb::$user->lang[$folder_alt],
+ 			'FOLDER_IMG_ALT'			=> phpbb::$user->lang[$folder_alt],
+ 			'FOLDER_IMG_WIDTH'			=> phpbb::$user->img($folder_img, '', false, '', 'width'),
+ 			'FOLDER_IMG_HEIGHT'			=> phpbb::$user->img($folder_img, '', false, '', 'height'),
  		));
  
  		$contrib_type = $row['contrib_type'];

Modified: trunk/titania/includes/objects/contribution.php
==============================================================================
*** trunk/titania/includes/objects/contribution.php (original)
--- trunk/titania/includes/objects/contribution.php Mon Dec 21 22:48:54 2009
***************
*** 105,110 ****
--- 105,113 ----
  
  			'contrib_rating'				=> array('default' => 0.0),
  			'contrib_rating_count'			=> array('default' => 0),
+ 			
+ 			// Last time the contrib item was updated (created or added a new revision, etc).  Used for tracking
+ 			'contrib_last_update'			=> array('default' => titania::$time),
  		));
  	}
  
***************
*** 144,167 ****
  		{
  			$error[] = phpbb::$user->lang['EMPTY_CONTRIB_TYPE'];
  		}
- 
- 		if (!$contrib_categories)
- 		{
- 			$error[] = phpbb::$user->lang['EMPTY_CATEGORY'];
- 		}
  		else
  		{
! 			$categories	= titania::$cache->get_categories();
! 
! 			foreach ($contrib_categories as $category)
  			{
! 				if (!isset($categories[$category]))
! 				{
! 					$error[] = phpbb::$user->lang['NO_CATEGORY'];
! 				}
! 				else if ($categories[$category]['category_type'] != $this->contrib_type)
  				{
! 					$error[] = phpbb::$user->lang['WRONG_CATEGORY'];
  				}
  			}
  		}
--- 147,172 ----
  		{
  			$error[] = phpbb::$user->lang['EMPTY_CONTRIB_TYPE'];
  		}
  		else
  		{
! 			if (!$contrib_categories)
  			{
! 				$error[] = phpbb::$user->lang['EMPTY_CATEGORY'];
! 			}
! 			else
! 			{
! 				$categories	= titania::$cache->get_categories();
! 
! 				foreach ($contrib_categories as $category)
  				{
! 					if (!isset($categories[$category]))
! 					{
! 						$error[] = phpbb::$user->lang['NO_CATEGORY'];
! 					}
! 					else if ($categories[$category]['category_type'] != $this->contrib_type)
! 					{
! 						$error[] = phpbb::$user->lang['WRONG_CATEGORY'];
! 					}
  				}
  			}
  		}

Modified: trunk/titania/includes/objects/topic.php
==============================================================================
*** trunk/titania/includes/objects/topic.php (original)
--- trunk/titania/includes/objects/topic.php Mon Dec 21 22:48:54 2009
***************
*** 285,295 ****
  	public function assign_details()
  	{
  		// Check read status
! 		$this->unread = true;
! 		if (titania_tracking::get_track(TITANIA_TRACK_TOPICS, $this->topic_id, true) >= $this->topic_last_post_time)
! 		{
! 			$this->unread = false;
! 		}
  
  		$folder_img = $folder_alt = '';
  		$this->topic_folder_img($folder_img, $folder_alt);
--- 285,291 ----
  	public function assign_details()
  	{
  		// Check read status
! 		$this->unread = titania_tracking::is_unread(TITANIA_TRACK_TOPICS, $this->topic_id, $this->topic_last_post_time);
  
  		$folder_img = $folder_alt = '';
  		$this->topic_folder_img($folder_img, $folder_alt);
***************
*** 309,321 ****
  			'TOPIC_VIEWS'					=> $this->topic_views,
  			'TOPIC_SUBJECT'					=> censor_text($this->topic_subject),
  
- 			'TOPIC_FOLDER_IMG'				=> phpbb::$user->img($folder_img, $folder_alt),
- 			'TOPIC_FOLDER_IMG_SRC'			=> phpbb::$user->img($folder_img, $folder_alt, false, '', 'src'),
- 			'TOPIC_FOLDER_IMG_ALT'			=> phpbb::$user->lang[$folder_alt],
- 			'TOPIC_FOLDER_IMG_ALT'			=> phpbb::$user->lang[$folder_alt],
- 			'TOPIC_FOLDER_IMG_WIDTH'		=> phpbb::$user->img($folder_img, '', false, '', 'width'),
- 			'TOPIC_FOLDER_IMG_HEIGHT'		=> phpbb::$user->img($folder_img, '', false, '', 'height'),
- 
  			'TOPIC_FIRST_POST_ID'			=> $this->topic_first_post_id,
  			'TOPIC_FIRST_POST_USER_ID'		=> $this->topic_first_post_user_id,
  			'TOPIC_FIRST_POST_USER_COLOUR'	=> $this->topic_first_post_user_colour,
--- 305,310 ----
***************
*** 334,339 ****
--- 323,335 ----
  			'U_VIEW_LAST_POST'				=> titania_url::append_url($this->get_url(), array('p' => $this->topic_last_post_id, '#' => $this->topic_last_post_id)),
  
  			'S_UNREAD_TOPIC'				=> ($this->unread) ? true : false,
+ 
+ 			'TOPIC_FOLDER_IMG'				=> phpbb::$user->img($folder_img, $folder_alt),
+ 			'TOPIC_FOLDER_IMG_SRC'			=> phpbb::$user->img($folder_img, $folder_alt, false, '', 'src'),
+ 			'TOPIC_FOLDER_IMG_ALT'			=> phpbb::$user->lang[$folder_alt],
+ 			'TOPIC_FOLDER_IMG_ALT'			=> phpbb::$user->lang[$folder_alt],
+ 			'TOPIC_FOLDER_IMG_WIDTH'		=> phpbb::$user->img($folder_img, '', false, '', 'width'),
+ 			'TOPIC_FOLDER_IMG_HEIGHT'		=> phpbb::$user->img($folder_img, '', false, '', 'height'),
  		);
  
  		return $details;

Modified: trunk/titania/includes/tools/tracking.php
==============================================================================
*** trunk/titania/includes/tools/tracking.php (original)
--- trunk/titania/includes/tools/tracking.php Mon Dec 21 22:48:54 2009
***************
*** 79,84 ****
--- 79,98 ----
  		self::$store[$type][$id] = ($time === false) ? titania::$time : (int) $time;
  	}
  
+ 	/**
+ 	 * Check if an item is unread
+ 	 *
+ 	 * @param <int> $type The type id of the item
+ 	 * @param <int> $id The id of the item
+ 	 * @param <int> $last_update The last time the item was updated
+ 	 * @param <bool> $no_query True if we
+ 	 * @return <bool> True if the item is unread, false if it is read
+ 	 */
+ 	public static function is_unread($type, $id, $last_update, $no_query = true)
+ 	{
+ 		return ($last_update >= self::get_track($type, $id, $no_query)) ? true : false;
+ 	}
+ 
  	public static function get_track($type, $id, $no_query = false)
  	{
  		// Ignore
***************
*** 107,127 ****
  		return self::$store[$type][$id];
  	}
  
- 	/**
- 	 * Put the data in self::$store, for when you've already grabbed the info yourself
- 	 *
- 	 * @param <int> $type The type id of the item
- 	 * @param <int> $id The id of the item
- 	 * @param <int> $track_time The time it was last marked
- 	 */
- 	public static function store_track($type, $id, $track_time)
- 	{
- 		// Ignore
- 		self::get_track_cookie();
- 
- 		self::$store[$type][(int) $id] = (int) $track_time;
- 	}
- 
  	public static function get_tracks($type, $ids)
  	{
  		// Ignore
--- 121,126 ----
***************
*** 142,151 ****
  		{
  			self::$store[$type][$row['track_id']] = $row['track_time'];
  		}
- 
  		phpbb::$db->sql_freeresult($result);
  	}
  
  	public static function clear_track($type, $id)
  	{
  		$sql = 'DELETE FROM ' . self::$sql_table . '
--- 141,164 ----
  		{
  			self::$store[$type][$row['track_id']] = $row['track_time'];
  		}
  		phpbb::$db->sql_freeresult($result);
  	}
  
+ 	/**
+ 	 * Put the data in self::$store, for when you've already grabbed the info yourself
+ 	 *
+ 	 * @param <int> $type The type id of the item
+ 	 * @param <int> $id The id of the item
+ 	 * @param <int> $track_time The time it was last marked
+ 	 */
+ 	public static function store_track($type, $id, $track_time)
+ 	{
+ 		// Ignore
+ 		self::get_track_cookie();
+ 
+ 		self::$store[$type][(int) $id] = (int) $track_time;
+ 	}
+ 
  	public static function clear_track($type, $id)
  	{
  		$sql = 'DELETE FROM ' . self::$sql_table . '

Modified: trunk/titania/install.php
==============================================================================
*** trunk/titania/install.php (original)
--- trunk/titania/install.php Mon Dec 21 22:48:54 2009
***************
*** 547,552 ****
--- 547,558 ----
  		),
  	),
  
+ 	'0.1.21' => array(
+ 		'table_column_add' => array(
+ 			array(TITANIA_CONTRIBS_TABLE, 'contrib_last_update', array('TIMESTAMP', 0)),
+ 		),
+ 	),
+ 
  	// IF YOU ADD A NEW VERSION DO NOT FORGET TO INCREMENT THE VERSION NUMBER IN common.php!
  );
  




More information about the customisationdb-commits mailing list