[Customisation Database Commits] r236 - in /trunk/titania: common.php includes/constants.php includes/core/config.php includes/core/titania.php includes/objects/post.php includes/objects/topic.php

Nathan Guse exreaction at phpbb.com
Fri Jun 19 08:10:40 UTC 2009


Author: EXreaction
Date: Fri Jun 19 08:10:36 2009
New Revision: 236

Log:
Start of the topic/post backend and of the access lists

Added:
    trunk/titania/includes/objects/post.php
    trunk/titania/includes/objects/topic.php
Modified:
    trunk/titania/common.php
    trunk/titania/includes/constants.php
    trunk/titania/includes/core/config.php
    trunk/titania/includes/core/titania.php

Modified: trunk/titania/common.php
==============================================================================
*** trunk/titania/common.php (original)
--- trunk/titania/common.php Fri Jun 19 08:10:36 2009
***************
*** 18,23 ****
--- 18,28 ----
  
  define('TITANIA_VERSION', '0.1.3');
  
+ // Include titania constants and functions
+ require TITANIA_ROOT . 'includes/constants.' . PHP_EXT;
+ require TITANIA_ROOT . 'includes/functions.' . PHP_EXT;
+ require TITANIA_ROOT . 'includes/functions_display.' . PHP_EXT;
+ 
  // Include titania class
  require TITANIA_ROOT . 'includes/core/titania.' . PHP_EXT;
  require TITANIA_ROOT . 'includes/core/phpbb.' . PHP_EXT;
***************
*** 25,35 ****
  // Read config.php file
  titania::read_config_file(TITANIA_ROOT . 'config.' . PHP_EXT);
  
- // Include titania constants
- require TITANIA_ROOT . 'includes/constants.' . PHP_EXT;
- require TITANIA_ROOT . 'includes/functions.' . PHP_EXT;
- require TITANIA_ROOT . 'includes/functions_display.' . PHP_EXT;
- 
  // We need this for compatibility reasons
  $phpEx = PHP_EXT;
  $phpbb_root_path = PHPBB_ROOT_PATH;
--- 30,35 ----

Modified: trunk/titania/includes/constants.php
==============================================================================
*** trunk/titania/includes/constants.php (original)
--- trunk/titania/includes/constants.php Fri Jun 19 08:10:36 2009
***************
*** 39,45 ****
  define('TITANIA_TAG_TYPES_TABLE',				$table_prefix . 'tag_types');
  define('TITANIA_WATCH_TABLE',					$table_prefix . 'watch');
  
! // Customisation/Queue (contrib) status
  define('TITANIA_STATUS_NEW', 0);
  define('TITANIA_STATUS_APPROVED', 1);
  define('TITANIA_STATUS_DENIED', 2);
--- 39,45 ----
  define('TITANIA_TAG_TYPES_TABLE',				$table_prefix . 'tag_types');
  define('TITANIA_WATCH_TABLE',					$table_prefix . 'watch');
  
! // Contribution revision status
  define('TITANIA_STATUS_NEW', 0);
  define('TITANIA_STATUS_APPROVED', 1);
  define('TITANIA_STATUS_DENIED', 2);
***************
*** 57,62 ****
--- 57,91 ----
  define('TITANIA_ERROR', 1);
  define('TITANIA_SUCCESS', 2);
  
+ // Contribution type
+ define('TITANIA_TYPE_CATEGORY', 0); // Used in categories
+ define('TITANIA_TYPE_MOD', 1);
+ define('TITANIA_TYPE_STYLE', 2);
+ define('TITANIA_TYPE_SNIPPET', 3);
+ define('TITANIA_TYPE_LANG_PACK', 4);
+ 
+ // Author constants
+ define('TITANIA_AUTHOR_HIDDEN', 0);
+ define('TITANIA_AUTHOR_VISIBLE', 1);
+ 
+ // Rating Type Constants
+ define('TITANIA_RATING_AUTHOR', 1);
+ define('TITANIA_RATING_CONTRIB', 2);
+ 
+ // Download types
+ define('TITANIA_DOWNLOAD_CONTRIB', 1);
+ define('TITANIA_DOWNLOAD_POST', 2);
+ 
+ // Post types
+ define('TITANIA_POST_DEFAULT', 1);
+ define('TITANIA_POST_QUEUE', 2);
+ define('TITANIA_POST_TRACKER', 3);
+ 
+ // Access Levels
+ define('TITANIA_ACCESS_TEAMS', 0);
+ define('TITANIA_ACCESS_AUTHORS', 1);
+ define('TITANIA_ACCESS_PUBLIC', 2);
+ 
  // Header status codes
  define('HEADER_OK',						200);
  define('HEADER_CREATED',				201);
***************
*** 79,101 ****
  define('HEADER_INTERNAL_SERVER_ERROR',	500);
  define('HEADER_NOT_IMPLEMENTED',		501);
  define('HEADER_BAD_GATEWAY',			502);
! define('HEADER_SERVICE_UNAVAILABLE',	503);
! 
! // Customisation (contrib) type
! define('TITANIA_TYPE_CATEGORY', 0); // Used in categories
! define('TITANIA_TYPE_MOD', 1);
! define('TITANIA_TYPE_STYLE', 2);
! define('TITANIA_TYPE_SNIPPET', 3);
! define('TITANIA_TYPE_LANG_PACK', 4);
! 
! // Author constants
! define('TITANIA_AUTHOR_HIDDEN', 0);
! define('TITANIA_AUTHOR_VISIBLE', 1);
! 
! // Rating Type Constants
! define('TITANIA_RATING_AUTHOR', 1);
! define('TITANIA_RATING_CONTRIB', 2);
! 
! // Download types
! define('TITANIA_DOWNLOAD_CONTRIB', 1);
! define('TITANIA_DOWNLOAD_POST', 2);
--- 108,111 ----
  define('HEADER_INTERNAL_SERVER_ERROR',	500);
  define('HEADER_NOT_IMPLEMENTED',		501);
  define('HEADER_BAD_GATEWAY',			502);
! define('HEADER_SERVICE_UNAVAILABLE',	503);
\ No newline at end of file

Modified: trunk/titania/includes/core/config.php
==============================================================================
*** trunk/titania/includes/core/config.php (original)
--- trunk/titania/includes/core/config.php Fri Jun 19 08:10:36 2009
***************
*** 42,47 ****
--- 42,49 ----
  			'table_prefix'				=> array('default' => 'customisation_'),
  			'style'						=> array('default' => 'default'),
  
+ 			'team_groups'				=> array('default' => array(5)),
+ 
  			'max_rating'				=> array('default' => 5),
  		));
  	}

Modified: trunk/titania/includes/core/titania.php
==============================================================================
*** trunk/titania/includes/core/titania.php (original)
--- trunk/titania/includes/core/titania.php Fri Jun 19 08:10:36 2009
***************
*** 50,55 ****
--- 50,62 ----
  	public static $time;
  
  	/**
+ 	* Current User's Access level
+ 	*
+ 	* @var int $access_level Check TITANIA_ACCESS_ constants
+ 	*/
+ 	public static $access_level = TITANIA_ACCESS_PUBLIC;
+ 
+ 	/**
  	 * Style, Template, and Theme Path
  	 *
  	 * @var string
***************
*** 91,96 ****
--- 98,109 ----
  		phpbb::$template->set_custom_template(self::$template_path, 'titania_' . self::$config->style);
  		phpbb::$user->theme['template_storedb'] = false;
  
+ 		// Access Level check for teams access
+ 		if (in_array(phpbb::$user->data['user_group'], self::$config->team_groups))
+ 		{
+ 			self::$access_level = TITANIA_ACCESS_TEAMS;
+ 		}
+ 
  		// Add common titania language file
  		self::add_lang('common');
  	}

Added: trunk/titania/includes/objects/post.php
==============================================================================
*** trunk/titania/includes/objects/post.php (added)
--- trunk/titania/includes/objects/post.php Fri Jun 19 08:10:36 2009
***************
*** 0 ****
--- 1,110 ----
+ <?php
+ /**
+ *
+ * @package Titania
+ * @version $Id$
+ * @copyright (c) 2008 phpBB Customisation Database Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ *
+ */
+ 
+ /**
+ * @ignore
+ */
+ if (!defined('IN_TITANIA'))
+ {
+ 	exit;
+ }
+ 
+ if (!class_exists('titania_database_object'))
+ {
+ 	require TITANIA_ROOT . 'includes/core/object_database.' . PHP_EXT;
+ }
+ 
+ /**
+ * Class to abstract titania posts
+ * @package Titania
+ */
+ class titania_post extends titania_database_object
+ {
+ 	/**
+ 	 * SQL Table
+ 	 *
+ 	 * @var string
+ 	 */
+ 	protected $sql_table			= TITANIA_POSTS_TABLE;
+ 
+ 	/**
+ 	 * SQL identifier field
+ 	 *
+ 	 * @var string
+ 	 */
+ 	protected $sql_id_field			= 'post_id';
+ 
+ 	/**
+ 	* Post Type
+ 	*
+ 	* @var string ('tracker', 'queue', 'normal')
+ 	*/
+ 	protected $type = '';
+ 
+ 	/**
+ 	 * Constructor class for titania posts
+ 	 *
+ 	 * @param string $type The type of post ('tracker', 'queue', 'normal').  Normal/default meaning support/discussion
+ 	 * @param int $post_id The post_id, 0 for making a new post
+ 	 */
+ 	public function __construct($type, $post_id = 0)
+ 	{
+ 		// Configure object properties
+ 		$this->object_config = array_merge($this->object_config, array(
+ 			'post_id'				=> array('default' => 0),
+ 			'topic_id'				=> array('default' => 0),
+ 			'post_type'				=> array('default' => 0), // Post Type, TITANIA_POST_ constants
+ 			'post_access'			=> array('default' => 0), // Access level, TITANIA_ACCESS_ constants
+ 
+ 			'post_locked'			=> array('default' => false),
+ 			'post_approved'			=> array('default' => true),
+ 			'post_reported'			=> array('default' => false),
+ 
+ 			'post_user_id'			=> array('default' => 0),
+ 			'post_ip'				=> array('default' => 0),
+ 
+ 			'post_time'				=> array('default' => 0),
+ 			'post_edited'			=> array('default' => 0), // Post edited; 0 for not edited, timestamp if (when) last edited
+ 			'post_deleted'			=> array('default' => 0), // Post soft deleted; 0 for not deleted, timestamp if (when) last deleted
+ 
+ 			'post_subject'			=> array('default' => ''),
+ 			'post_text'				=> array('default' => ''),
+ 			'post_text_bitfield'	=> array('default' => ''),
+ 			'post_text_uid'			=> array('default' => ''),
+ 			'post_text_options'		=> array('default' => 7),
+ 			'post_reason'			=> array('default' => ''), // Reason for deleting/editing
+ 		));
+ 
+ 		switch ($type)
+ 		{
+ 			case 'tracker' :
+ 			case 'queue' :
+ 				$this->type = $type;
+ 			break;
+ 
+ 			default :
+ 				$this->type = 'normal';
+ 			break;
+ 		}
+ 
+ 		$this->post_id = $post_id;
+ 	}
+ 
+ 	/**
+ 	* @todo
+ 	*
+ 	* self reminder - check umil::remove_table, it could give an error during uninstallations
+ 	*
+ 	* Access Lists cache system (for authors)
+ 	* 0-1000 in one file, 1001-2000 in another, etc
+ 	* contrib_id => array(author_ids),
+ 	* contrib_id => false, // For non-existing items (so we can skip the SQL query to recache the item if it is requested again)
+ 	*/
+ }
\ No newline at end of file

Added: trunk/titania/includes/objects/topic.php
==============================================================================
*** trunk/titania/includes/objects/topic.php (added)
--- trunk/titania/includes/objects/topic.php Fri Jun 19 08:10:36 2009
***************
*** 0 ****
--- 1,112 ----
+ <?php
+ /**
+ *
+ * @package Titania
+ * @version $Id$
+ * @copyright (c) 2008 phpBB Customisation Database Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ *
+ */
+ 
+ /**
+ * @ignore
+ */
+ if (!defined('IN_TITANIA'))
+ {
+ 	exit;
+ }
+ 
+ if (!class_exists('titania_database_object'))
+ {
+ 	require TITANIA_ROOT . 'includes/core/object_database.' . PHP_EXT;
+ }
+ 
+ /**
+ * Class to abstract titania posts
+ * @package Titania
+ */
+ class titania_post extends titania_database_object
+ {
+ 	/**
+ 	 * SQL Table
+ 	 *
+ 	 * @var string
+ 	 */
+ 	protected $sql_table			= TITANIA_TOPICS_TABLE;
+ 
+ 	/**
+ 	 * SQL identifier field
+ 	 *
+ 	 * @var string
+ 	 */
+ 	protected $sql_id_field			= 'topic_id';
+ 
+ 	/**
+ 	* Topic Type
+ 	*
+ 	* @var string ('tracker', 'queue', 'normal')
+ 	*/
+ 	protected $type = '';
+ 
+ 	/**
+ 	 * Constructor class for titania topics
+ 	 *
+ 	 * @param string $type The type of topic ('tracker', 'queue', 'normal').  Normal/default meaning support/discussion
+ 	 * @param int $topic_id The topic_id, 0 for making a new topic
+ 	 */
+ 	public function __construct($type, $topic_id = 0)
+ 	{
+ 		// Configure object properties
+ 		$this->object_config = array_merge($this->object_config, array(
+ 			'topic'					=> array('default' => 0),
+ 			'topic_type'			=> array('default' => 0), // Post Type, TITANIA_POST_ constants
+ 			'topic_access'			=> array('default' => 0), // Access level, TITANIA_ACCESS_ constants
+ 
+ 			'topic_status'			=> array('default' => 0), // Topic Status, use tags from the DB
+ 			'topic_sticky'			=> array('default' => false),
+ 			'topic_locked'			=> array('default' => false),
+ 			'topic_approved'		=> array('default' => true),
+ 			'topic_reported'		=> array('default' => false), // True if any posts in the topic are reported
+ 
+ 			'topic_user_id'			=> array('default' => 0),
+ 
+ 			'topic_time'			=> array('default' => 0),
+ 			'topic_deleted'			=> array('default' => 0), // Topic soft deleted; 0 for not deleted, timestamp if (when) last deleted
+ 
+ 			'topic_posts'			=> array('default' => ''), // Post count; separated by : between access levels ('10:9:8' = 10 team; 9 Mod Author; 8 Public)
+ 
+ 			'topic_subject'			=> array('default' => ''),
+ 		));
+ 
+ 		switch ($type)
+ 		{
+ 			case 'tracker' :
+ 			case 'queue' :
+ 				$this->type = $type;
+ 			break;
+ 
+ 			default :
+ 				$this->type = 'normal';
+ 			break;
+ 		}
+ 
+ 		$this->topic_id = $topic_id;
+ 	}
+ 
+ 	/**
+ 	* Get the postcount for displaying
+ 	*
+ 	* @return int The post count for the current user's access level
+ 	*/
+ 	public function get_postcount()
+ 	{
+ 		$postcount = explode(':', $this->topic_posts);
+ 
+ 		if (!isset($postcount[titania::$access_level]))
+ 		{
+ 			return 0;
+ 		}
+ 
+ 		return $postcount[$access_level];
+ 	}
+ }




More information about the customisationdb-commits mailing list