[Customisation Database Commits] r1783 [33/63] - in /branches/stable: language/en/acp/ language/en/mods/ language/pt_br/ language/pt_br/acp/ language/pt_br/mods/ titania/ titania/authors/ titania/contributions/ titania/docs/ titania/download/ titania/download/modx/ titania/files/contrib_temp/ titania/files/modx_files/ titania/images/ titania/includes/ titania/includes/core/ titania/includes/hooks/ titania/includes/library/Zend/ titania/includes/library/Zend/Search/ titania/includes/library/Zend/Search/Lucene/ titania/includes/library/Zend/Search/Lucene/Analysis/ titania/includes/library/Zend/Search/Lucene/Analysis/Analyzer/ titania/includes/library/Zend/Search/Lucene/Analysis/Analyzer/Common/ titania/includes/library/Zend/Search/Lucene/Analysis/Analyzer/Common/Text/ titania/includes/library/Zend/Search/Lucene/Analysis/Analyzer/Common/TextNum/ titania/includes/library/Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8/ titania/includes/library/Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8Num/ titania/includes/library/Zend/Search/Lucene/Analysis/TokenFilter/ titania/includes/library/Zend/Search/Lucene/Document/ titania/includes/library/Zend/Search/Lucene/Index/ titania/includes/library/Zend/Search/Lucene/Index/SegmentWriter/ titania/includes/library/Zend/Search/Lucene/Index/TermsStream/ titania/includes/library/Zend/Search/Lucene/Search/ titania/includes/library/Zend/Search/Lucene/Search/Highlighter/ titania/includes/library/Zend/Search/Lucene/Search/Query/ titania/includes/library/Zend/Search/Lucene/Search/Query/Preprocessing/ titania/includes/library/Zend/Search/Lucene/Search/QueryEntry/ titania/includes/library/Zend/Search/Lucene/Search/Similarity/ titania/includes/library/Zend/Search/Lucene/Search/Weight/ titania/includes/library/Zend/Search/Lucene/Storage/ titania/includes/library/Zend/Search/Lucene/Storage/Directory/ titania/includes/library/Zend/Search/Lucene/Storage/File/ titania/includes/library/automod/ titania/includes/library/ezcomponents/ titania/includes/library/ezcomponents/Base/ titania/includes/library/ezcomponents/Base/interfaces/ titania/includes/library/translations/ titania/includes/manage_tools/ titania/includes/objects/ titania/includes/overlords/ titania/includes/tools/ titania/includes/types/ titania/js/ titania/language/ titania/language/en/ titania/language/en/email/ titania/language/en/manage_tools/ titania/language/en/types/ titania/language/pt_br/ titania/language/pt_br/email/ titania/language/pt_br/manage_tools/ titania/language/pt_br/types/ titania/manage/ titania/store/ titania/store/phpbb_packages/ titania/store/phpbb_packages/extracted/ titania/store/search/ titania/styles/default/template/ titania/styles/default/template/authors/ titania/styles/default/template/common/ titania/styles/default/template/contributions/ titania/styles/default/template/manage/ titania/styles/default/template/posting/ titania/styles/default/template/posting/attachments/ titania/styles/default/template/posting/panels/ titania/styles/default/theme/ titania/styles/default/theme/en-gb/ titania/styles/prosilver/template/ titania/styles/prosilver/template/authors/ titania/styles/prosilver/template/common/ titania/styles/prosilver/theme/ titania/styles/prosilver/theme/en-gb/ umil/ umil/error_files/ umil/language/en/ umil/style/
Nathan Guse
exreaction at phpbb.com
Sat Nov 20 18:23:23 GMT 2010
Modified: branches/stable/titania/includes/library/translations/translation_validation.php
==============================================================================
*** branches/stable/titania/includes/library/translations/translation_validation.php (original)
--- branches/stable/titania/includes/library/translations/translation_validation.php Sat Nov 20 18:23:22 2010
***************
*** 1,287 ****
! <?php
! /**
! *
! * @package Titania
! * @version $Id$
! * @copyright (c) 2010 phpBB Customisation Database Team
! * @license http://opensource.org/licenses/gpl-license.php GNU Public License
! *
! */
!
! /**
! * @ignore
! */
! if (!defined('IN_TITANIA'))
! {
! exit;
! }
!
! /**
! * Description of translation_validation
! *
! * @author VojtÄch Vondra
! * @package Titania
! */
! class translation_validation extends titania_contrib_tools
! {
!
! const NOT_REQUIRED = 0;
! const REQUIRED = 1;
! const REQUIRED_EMPTY = 2;
! const REQUIRED_DEFAULT = 3;
!
! /**
! * Array of files to ignore in language pack
! *
! * @var array
! */
! protected $ignore_files = array('AUTHORS', 'README');
!
! public function __construct($original_zip, $new_dir_name)
! {
! parent::__construct($original_zip, $new_dir_name);
! }
!
! /**
! * Checks the file for the array contents
! * Make sure it has all the keys present in the newest version
! *
! * @param string $reference_filepath The path to the files against I want to validate the uploaded package
! * @return array Returns an array of error messages encountered
! */
! public function check_package($reference_filepath)
! {
! $error = $missing_keys = array();
!
! // Basically the individual parts of the translation, we check them separately, because they have colliding filenames
! $types = array(
! 'language' => 'language/',
! 'prosilver' => 'styles/prosilver/imageset/',
! 'subsilver2' => 'styles/subsilver2/imageset/',
! );
!
! // Do the check for all types
! foreach ($types as $type => $path)
! {
! // Get all the files present in the uploaded package for the currently iterated type
! $uploaded_files = $this->lang_filelist($this->unzip_dir);
! $reference_files = $this->lang_filelist($reference_filepath);
! ksort($uploaded_files);
! ksort($reference_files);
!
! switch ($type)
! {
! case 'language':
! // The uploaded files array has keys prefixed with the upload path of the contribution
! // Have it stored in the variable so we can work with it
! $uploaded_files_prefix = explode('/', key($uploaded_files));
! $iso_code = $uploaded_files_prefix[2];
! $uploaded_files_prefix = $this->unzip_dir . $uploaded_files_prefix[0];
!
! // This goes directly to the root of the uploaded language pack, like /upload_path/language/cs/
! $uploaded_lang_root = $uploaded_files_prefix . '/language/' . $iso_code . '/';
!
! // Just perform a basic check if the common file is there
! if (!is_file($uploaded_lang_root . 'common.php'))
! {
! return array(phpbb::$user->lang('NO_TRANSLATION'));
! }
!
! // Loop through the reference files
! foreach ($reference_files as $dir => $files)
! {
! // Do not loop through files which are in non-language directories
! if (strpos($dir, $path) === 0)
! {
! // Loop through the files in the language/, language/adm etc. directories
! foreach ($files as $file)
! {
! $exists = true;
! $uploaded_file_path = str_replace('/en/', '/' . $iso_code . '/', $uploaded_files_prefix . '/' . $dir . $file);
!
! $ext = strtolower(substr($file, -3));
! // Require php and txt files
! if ($ext == 'php' || $ext == 'txt')
! {
! if (!is_file($uploaded_file_path))
! {
! $error[] = sprintf(phpbb::$user->lang('MISSING_FILE'), str_replace('/en/', '/' . $iso_code . '/', $dir. $file)); // report a missing file
! $exists = false;
! }
! }
!
! // If the file is a php file and actually exists, no point in checking keys in a nonexistent one
! if ($ext == 'php' && $exists)
! {
! $missing_keys[$dir . $file] = $this->check_missing_keys($reference_filepath . '' . $dir . $file, $uploaded_file_path);
! }
!
! if (!in_array(strtoupper($file), $this->ignore_files) && !in_array($ext, array('php', 'txt')) && is_file($uploaded_file_path))
! {
! // remove any files that aren't in the above stated extension list, this will delete index.htm files and LICENSE files
! unlink($uploaded_file_path);
! }
!
! // In the last step we have removed the license and index files if there were any. We'll just put a new one instead
! $this->add_license_files($uploaded_lang_root . '/LICENSE', $reference_filepath);
! $this->add_htm_files($uploaded_lang_root, $reference_filepath);
! }
! }
! }
!
! if (sizeof($missing_keys))
! {
! foreach ($missing_keys as $file => $keys)
! {
! if (sizeof($keys))
! {
! $error[] = sprintf(phpbb::$user->lang['MISSING_KEYS'], $file, implode('<br />', $keys));
! }
! }
! }
!
! if (sizeof($error))
! {
! return $error;
! }
!
! break;
!
! case 'prosilver':
! case 'subsilver2':
! // just let them go through atm...
! break;
! }
!
! }
!
! $this->replace_zip(); // we have made changes to the package, so replace the original zip file
! return $error;
! }
!
! /**
! * Compares two phpBB 3.0.x language files and computes the missing keys in the uploaded file
! * Does not include the uploaded file for security and uses string check on the file contents
! *
! * @param string $uploaded_file
! * @param string $reference_file
! * @return array returns an array with the missing keys
! */
! private function check_missing_keys($reference_file, $uploaded_file)
! {
! // Check original file by including the language entries...
! $lang = $missing_keys = array();
!
! $contents = file_get_contents($uploaded_file);
!
! include($reference_file);
! //$lang_keys = $this->multiarray_keys($lang);
!
! // General cleanup
! $file_data = trim(str_replace(array("\r", "\t", ' '), '', $contents));
! $file_data = explode("\n", $file_data);
!
! $file_data = str_replace("\n", '', implode("\n", $file_data));
!
! // Now we have all array keys... let us have a look within $contents if all keys are there...
! // This can take a bit because we check every key... luckily with strpos...
! foreach (array_keys($lang) as $current_key)
! {
! if (is_string($current_key) && !is_array($lang[$current_key]) && strpos($file_data, "'{$current_key}'=>") === false)
! {
! if (empty($lang[$current_key]))
! {
! continue;
! }
!
! $missing_keys[] = $current_key;
! }
! }
!
! return $missing_keys;
! }
!
! private function add_license_files($license_file, $reference_path)
! {
! $res = fopen($license_file, 'w');
! fwrite($res, file_get_contents($reference_path . '/docs/COPYING'));
! fclose($res);
! }
!
! private function add_htm_files($lang_root_path, $reference_path)
! {
! $htm_files = array('', 'acp/', 'mods/');
!
! if (!is_dir($lang_root_path . 'mods'))
! {
! mkdir($lang_root_path . 'mods');
! phpbb_chmod($lang_root_path . 'mods', CHMOD_READ | CHMOD_WRITE);
! }
!
! foreach ($htm_files as $htm_file)
! {
! $res = fopen($lang_root_path . $htm_file . 'index.htm', 'w');
! fwrite($res, file_get_contents($reference_path . '/language/en/index.htm'));
! fclose($res);
! }
! }
!
! /**
! * Basically flattens the files from all subdirectories of $root_dir into an array
! *
! * @param string $root_dir
! * @param string $dir DO NOT USE, recursive!
! * @return array
! */
! private function lang_filelist($root_dir, $dir = '')
! {
! clearstatcache();
! $matches = array();
!
! // Add closing / if present
! $root_dir = ($root_dir && substr($root_dir, -1) != '/') ? $root_dir . '/' : $root_dir;
!
! // Remove initial / if present
! $dir = (substr($dir, 0, 1) == '/') ? substr($dir, 1) : $dir;
! // Add closing / if present
! $dir = ($dir && substr($dir, -1) != '/') ? $dir . '/' : $dir;
!
! $dp = opendir($root_dir . $dir);
! while (($fname = readdir($dp)))
! {
! if (is_file("$root_dir$dir$fname") && !in_array(strtoupper($fname), $this->ignore_files))
! {
! $matches[$dir][] = $fname;
! }
! else if ($fname[0] != '.' && is_dir("$root_dir$dir$fname"))
! {
! $matches += $this->lang_filelist($root_dir, "$dir$fname");
! }
! }
! closedir($dp);
!
! return $matches;
! }
!
! /**
! * array_keys for a multidimensional array
! *
! * @param array $array
! * @return array
! */
! private function multiarray_keys($array)
! {
! $keys = array();
!
! foreach($array as $k => $v)
! {
! $keys[] = $k;
! if (is_array($array[$k]))
! {
! $keys = array_merge($keys, $this->multiarray_keys($array[$k]));
! }
! }
! return $keys;
! }
! }
! ?>
--- 1,287 ----
! <?php
! /**
! *
! * @package Titania
! * @version $Id$
! * @copyright (c) 2010 phpBB Customisation Database Team
! * @license http://opensource.org/licenses/gpl-license.php GNU Public License
! *
! */
!
! /**
! * @ignore
! */
! if (!defined('IN_TITANIA'))
! {
! exit;
! }
!
! /**
! * Description of translation_validation
! *
! * @author VojtÄch Vondra
! * @package Titania
! */
! class translation_validation extends titania_contrib_tools
! {
!
! const NOT_REQUIRED = 0;
! const REQUIRED = 1;
! const REQUIRED_EMPTY = 2;
! const REQUIRED_DEFAULT = 3;
!
! /**
! * Array of files to ignore in language pack
! *
! * @var array
! */
! protected $ignore_files = array('AUTHORS', 'README');
!
! public function __construct($original_zip, $new_dir_name)
! {
! parent::__construct($original_zip, $new_dir_name);
! }
!
! /**
! * Checks the file for the array contents
! * Make sure it has all the keys present in the newest version
! *
! * @param string $reference_filepath The path to the files against I want to validate the uploaded package
! * @return array Returns an array of error messages encountered
! */
! public function check_package($reference_filepath)
! {
! $error = $missing_keys = array();
!
! // Basically the individual parts of the translation, we check them separately, because they have colliding filenames
! $types = array(
! 'language' => 'language/',
! 'prosilver' => 'styles/prosilver/imageset/',
! 'subsilver2' => 'styles/subsilver2/imageset/',
! );
!
! // Do the check for all types
! foreach ($types as $type => $path)
! {
! // Get all the files present in the uploaded package for the currently iterated type
! $uploaded_files = $this->lang_filelist($this->unzip_dir);
! $reference_files = $this->lang_filelist($reference_filepath);
! ksort($uploaded_files);
! ksort($reference_files);
!
! switch ($type)
! {
! case 'language':
! // The uploaded files array has keys prefixed with the upload path of the contribution
! // Have it stored in the variable so we can work with it
! $uploaded_files_prefix = explode('/', key($uploaded_files));
! $iso_code = $uploaded_files_prefix[2];
! $uploaded_files_prefix = $this->unzip_dir . $uploaded_files_prefix[0];
!
! // This goes directly to the root of the uploaded language pack, like /upload_path/language/cs/
! $uploaded_lang_root = $uploaded_files_prefix . '/language/' . $iso_code . '/';
!
! // Just perform a basic check if the common file is there
! if (!is_file($uploaded_lang_root . 'common.php'))
! {
! return array(phpbb::$user->lang('NO_TRANSLATION'));
! }
!
! // Loop through the reference files
! foreach ($reference_files as $dir => $files)
! {
! // Do not loop through files which are in non-language directories
! if (strpos($dir, $path) === 0)
! {
! // Loop through the files in the language/, language/adm etc. directories
! foreach ($files as $file)
! {
! $exists = true;
! $uploaded_file_path = str_replace('/en/', '/' . $iso_code . '/', $uploaded_files_prefix . '/' . $dir . $file);
!
! $ext = strtolower(substr($file, -3));
! // Require php and txt files
! if ($ext == 'php' || $ext == 'txt')
! {
! if (!is_file($uploaded_file_path))
! {
! $error[] = sprintf(phpbb::$user->lang('MISSING_FILE'), str_replace('/en/', '/' . $iso_code . '/', $dir. $file)); // report a missing file
! $exists = false;
! }
! }
!
! // If the file is a php file and actually exists, no point in checking keys in a nonexistent one
! if ($ext == 'php' && $exists)
! {
! $missing_keys[$dir . $file] = $this->check_missing_keys($reference_filepath . '' . $dir . $file, $uploaded_file_path);
! }
!
! if (!in_array(strtoupper($file), $this->ignore_files) && !in_array($ext, array('php', 'txt')) && is_file($uploaded_file_path))
! {
! // remove any files that aren't in the above stated extension list, this will delete index.htm files and LICENSE files
! unlink($uploaded_file_path);
! }
!
! // In the last step we have removed the license and index files if there were any. We'll just put a new one instead
! $this->add_license_files($uploaded_lang_root . '/LICENSE', $reference_filepath);
! $this->add_htm_files($uploaded_lang_root, $reference_filepath);
! }
! }
! }
!
! if (sizeof($missing_keys))
! {
! foreach ($missing_keys as $file => $keys)
! {
! if (sizeof($keys))
! {
! $error[] = sprintf(phpbb::$user->lang['MISSING_KEYS'], $file, implode('<br />', $keys));
! }
! }
! }
!
! if (sizeof($error))
! {
! return $error;
! }
!
! break;
!
! case 'prosilver':
! case 'subsilver2':
! // just let them go through atm...
! break;
! }
!
! }
!
! $this->replace_zip(); // we have made changes to the package, so replace the original zip file
! return $error;
! }
!
! /**
! * Compares two phpBB 3.0.x language files and computes the missing keys in the uploaded file
! * Does not include the uploaded file for security and uses string check on the file contents
! *
! * @param string $uploaded_file
! * @param string $reference_file
! * @return array returns an array with the missing keys
! */
! private function check_missing_keys($reference_file, $uploaded_file)
! {
! // Check original file by including the language entries...
! $lang = $missing_keys = array();
!
! $contents = file_get_contents($uploaded_file);
!
! include($reference_file);
! //$lang_keys = $this->multiarray_keys($lang);
!
! // General cleanup
! $file_data = trim(str_replace(array("\r", "\t", ' '), '', $contents));
! $file_data = explode("\n", $file_data);
!
! $file_data = str_replace("\n", '', implode("\n", $file_data));
!
! // Now we have all array keys... let us have a look within $contents if all keys are there...
! // This can take a bit because we check every key... luckily with strpos...
! foreach (array_keys($lang) as $current_key)
! {
! if (is_string($current_key) && !is_array($lang[$current_key]) && strpos($file_data, "'{$current_key}'=>") === false)
! {
! if (empty($lang[$current_key]))
! {
! continue;
! }
!
! $missing_keys[] = $current_key;
! }
! }
!
! return $missing_keys;
! }
!
! private function add_license_files($license_file, $reference_path)
! {
! $res = fopen($license_file, 'w');
! fwrite($res, file_get_contents($reference_path . '/docs/COPYING'));
! fclose($res);
! }
!
! private function add_htm_files($lang_root_path, $reference_path)
! {
! $htm_files = array('', 'acp/', 'mods/');
!
! if (!is_dir($lang_root_path . 'mods'))
! {
! mkdir($lang_root_path . 'mods');
! phpbb_chmod($lang_root_path . 'mods', CHMOD_READ | CHMOD_WRITE);
! }
!
! foreach ($htm_files as $htm_file)
! {
! $res = fopen($lang_root_path . $htm_file . 'index.htm', 'w');
! fwrite($res, file_get_contents($reference_path . '/language/en/index.htm'));
! fclose($res);
! }
! }
!
! /**
! * Basically flattens the files from all subdirectories of $root_dir into an array
! *
! * @param string $root_dir
! * @param string $dir DO NOT USE, recursive!
! * @return array
! */
! private function lang_filelist($root_dir, $dir = '')
! {
! clearstatcache();
! $matches = array();
!
! // Add closing / if present
! $root_dir = ($root_dir && substr($root_dir, -1) != '/') ? $root_dir . '/' : $root_dir;
!
! // Remove initial / if present
! $dir = (substr($dir, 0, 1) == '/') ? substr($dir, 1) : $dir;
! // Add closing / if present
! $dir = ($dir && substr($dir, -1) != '/') ? $dir . '/' : $dir;
!
! $dp = opendir($root_dir . $dir);
! while (($fname = readdir($dp)))
! {
! if (is_file("$root_dir$dir$fname") && !in_array(strtoupper($fname), $this->ignore_files))
! {
! $matches[$dir][] = $fname;
! }
! else if ($fname[0] != '.' && is_dir("$root_dir$dir$fname"))
! {
! $matches += $this->lang_filelist($root_dir, "$dir$fname");
! }
! }
! closedir($dp);
!
! return $matches;
! }
!
! /**
! * array_keys for a multidimensional array
! *
! * @param array $array
! * @return array
! */
! private function multiarray_keys($array)
! {
! $keys = array();
!
! foreach($array as $k => $v)
! {
! $keys[] = $k;
! if (is_array($array[$k]))
! {
! $keys = array_merge($keys, $this->multiarray_keys($array[$k]));
! }
! }
! return $keys;
! }
! }
! ?>
Modified: branches/stable/titania/includes/manage_tools/categories.php
==============================================================================
*** branches/stable/titania/includes/manage_tools/categories.php (original)
--- branches/stable/titania/includes/manage_tools/categories.php Sat Nov 20 18:23:22 2010
***************
*** 1,44 ****
! <?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;
! }
!
! class categories
! {
! /**
! * Tool Info
! *
! * @return Returns an array with the info about this tool.
! */
! function info()
! {
! global $user;
!
! return array(
! 'NAME' => $user->lang['MANAGE_CATEGORIES'],
! );
! }
!
! /**
! * Display Options
! *
! * Output the options available
! */
! function display_options()
! {
! redirect(titania_url::build_url('manage/categories'));
! }
}
\ No newline at end of file
--- 1,44 ----
! <?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;
! }
!
! class categories
! {
! /**
! * Tool Info
! *
! * @return Returns an array with the info about this tool.
! */
! function info()
! {
! global $user;
!
! return array(
! 'NAME' => $user->lang['MANAGE_CATEGORIES'],
! );
! }
!
! /**
! * Display Options
! *
! * Output the options available
! */
! function display_options()
! {
! redirect(titania_url::build_url('manage/categories'));
! }
}
\ No newline at end of file
Modified: branches/stable/titania/includes/manage_tools/fix_left_right_ids.php
==============================================================================
*** branches/stable/titania/includes/manage_tools/fix_left_right_ids.php (original)
--- branches/stable/titania/includes/manage_tools/fix_left_right_ids.php Sat Nov 20 18:23:22 2010
***************
*** 1,105 ****
! <?php
! /**
! *
! * @package Support Toolkit - Fix Left/Right ID's
! * @version $Id$
! * @copyright (c) 2009 phpBB Group
! * @license http://opensource.org/licenses/gpl-license.php GNU Public License
! *
! */
!
! /**
! * @ignore
! */
! if (!defined('IN_PHPBB'))
! {
! exit;
! }
!
! class fix_left_right_ids
! {
! function tool_active()
! {
! return false;
! }
!
! /**
! * Display Options
! *
! * Output the options available
! */
! function display_options()
! {
! return 'FIX_LEFT_RIGHT_IDS';
! }
!
! /**
! * Run Tool
! *
! * Does the actual stuff we want the tool to do after submission
! */
! function run_tool()
! {
! global $cache, $db;
!
! $changes_made = false;
!
! /**
! * Fix Left/Right ID's for the categories table
! */
! $i = 1;
! $changes_made = (($this->fixem($i, 'category_id', TITANIA_CATEGORIES_TABLE)) || $changes_made) ? true : false;
!
! // Purge the cache so the next time a page with modules is viewed it is not getting an old version from the cache
! $cache->purge();
!
! if ($changes_made)
! {
! trigger_back('LEFT_RIGHT_IDS_FIX_SUCCESS');
! }
! else
! {
! trigger_back('LEFT_RIGHT_IDS_NO_CHANGE');
! }
! }
!
! // I <3 recursion.
! function fixem(&$i, $pkey, $table, $parent_id = 0, $where = array())
! {
! global $db;
!
! $changes_made = false;
!
! $sql = 'SELECT * FROM ' . $table . '
! WHERE parent_id = ' . (int) $parent_id .
! ((!empty($where)) ? ' AND ' . implode(' AND ', $where) : '') . '
! ORDER BY left_id ASC';
! $result = $db->sql_query($sql);
! while ($row = $db->sql_fetchrow($result))
! {
! // First we update the left_id for this module
! if ($row['left_id'] != $i)
! {
! $db->sql_query('UPDATE ' . $table . ' SET ' . $db->sql_build_array('UPDATE', array('left_id' => $i)) . " WHERE $pkey = {$row[$pkey]}");
! $changes_made = true;
! }
! $i++;
!
! // Then we go through any children and update their left/right id's
! $changes_made = (($this->fixem($i, $pkey, $table, $row[$pkey], $where)) || $changes_made) ? true : false;
!
! // Then we come back and update the right_id for this module
! if ($row['right_id'] != $i)
! {
! $db->sql_query('UPDATE ' . $table . ' SET ' . $db->sql_build_array('UPDATE', array('right_id' => $i)) . " WHERE $pkey = {$row[$pkey]}");
! $changes_made = true;
! }
! $i++;
! }
! $db->sql_freeresult($result);
!
! return $changes_made;
! }
! }
!
?>
\ No newline at end of file
--- 1,105 ----
! <?php
! /**
! *
! * @package Support Toolkit - Fix Left/Right ID's
! * @version $Id$
! * @copyright (c) 2009 phpBB Group
! * @license http://opensource.org/licenses/gpl-license.php GNU Public License
! *
! */
!
! /**
! * @ignore
! */
! if (!defined('IN_PHPBB'))
! {
! exit;
! }
!
! class fix_left_right_ids
! {
! function tool_active()
! {
! return false;
! }
!
! /**
! * Display Options
! *
! * Output the options available
! */
! function display_options()
! {
! return 'FIX_LEFT_RIGHT_IDS';
! }
!
! /**
! * Run Tool
! *
! * Does the actual stuff we want the tool to do after submission
! */
! function run_tool()
! {
! global $cache, $db;
!
! $changes_made = false;
!
! /**
! * Fix Left/Right ID's for the categories table
! */
! $i = 1;
! $changes_made = (($this->fixem($i, 'category_id', TITANIA_CATEGORIES_TABLE)) || $changes_made) ? true : false;
!
! // Purge the cache so the next time a page with modules is viewed it is not getting an old version from the cache
! $cache->purge();
!
! if ($changes_made)
! {
! trigger_back('LEFT_RIGHT_IDS_FIX_SUCCESS');
! }
! else
! {
! trigger_back('LEFT_RIGHT_IDS_NO_CHANGE');
! }
! }
!
! // I <3 recursion.
! function fixem(&$i, $pkey, $table, $parent_id = 0, $where = array())
! {
! global $db;
!
! $changes_made = false;
!
! $sql = 'SELECT * FROM ' . $table . '
! WHERE parent_id = ' . (int) $parent_id .
! ((!empty($where)) ? ' AND ' . implode(' AND ', $where) : '') . '
! ORDER BY left_id ASC';
! $result = $db->sql_query($sql);
! while ($row = $db->sql_fetchrow($result))
! {
! // First we update the left_id for this module
! if ($row['left_id'] != $i)
! {
! $db->sql_query('UPDATE ' . $table . ' SET ' . $db->sql_build_array('UPDATE', array('left_id' => $i)) . " WHERE $pkey = {$row[$pkey]}");
! $changes_made = true;
! }
! $i++;
!
! // Then we go through any children and update their left/right id's
! $changes_made = (($this->fixem($i, $pkey, $table, $row[$pkey], $where)) || $changes_made) ? true : false;
!
! // Then we come back and update the right_id for this module
! if ($row['right_id'] != $i)
! {
! $db->sql_query('UPDATE ' . $table . ' SET ' . $db->sql_build_array('UPDATE', array('right_id' => $i)) . " WHERE $pkey = {$row[$pkey]}");
! $changes_made = true;
! }
! $i++;
! }
! $db->sql_freeresult($result);
!
! return $changes_made;
! }
! }
!
?>
\ No newline at end of file
Modified: branches/stable/titania/includes/manage_tools/index.htm
==============================================================================
*** branches/stable/titania/includes/manage_tools/index.htm (original)
--- branches/stable/titania/includes/manage_tools/index.htm Sat Nov 20 18:23:22 2010
***************
*** 1,10 ****
! <html>
! <head>
! <title></title>
! <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
! </head>
!
! <body bgcolor="#FFFFFF" text="#000000">
!
! </body>
! </html>
--- 1,10 ----
! <html>
! <head>
! <title></title>
! <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
! </head>
!
! <body bgcolor="#FFFFFF" text="#000000">
!
! </body>
! </html>
Modified: branches/stable/titania/includes/manage_tools/manage_plugin.php
==============================================================================
*** branches/stable/titania/includes/manage_tools/manage_plugin.php (original)
--- branches/stable/titania/includes/manage_tools/manage_plugin.php Sat Nov 20 18:23:22 2010
***************
*** 1,196 ****
! <?php
! /**
! *
! * @package Support Toolkit - Plugin handler
! * @version $Id$
! * @copyright (c) 2009 phpBB Group
! * @license http://opensource.org/licenses/gpl-license.php GNU Public License
! *
! */
!
! /**
! * @ignore
! */
! if (!defined('IN_PHPBB'))
! {
! exit;
! }
!
! // Load functions_admin.php if required
! if (!function_exists('filelist'))
! {
! include(PHPBB_ROOT_PATH . 'includes/functions_admin.' . PHP_EXT);
! }
!
! class manage_plugin
! {
! /**
! * A list containing file and directory names that should be ignored
! *
! * @var array
! * @access private
! */
! var $ignore_tools = array('index.htm', 'manage_plugin.php');
!
! /**
! * List containing all available tools and in which category they belong.
! * On default it contains the "main" category
! *
! * @var array
! * @access private
! */
! var $plugin_list = array();
!
! /**
! * Path to the tools directory
! *
! * @var String
! * @access public
! */
! var $tool_box_path = '';
!
! var $tool_id = '';
!
! /**
! * Constructor
! * Load the list with available plugins and assign them in the correct category
! */
! function manage_plugin()
! {
! // Set the path
! $this->tool_box_path = TITANIA_ROOT . 'includes/manage_tools/';
!
! // Create a list with tools
! $filelist = filelist($this->tool_box_path, '', PHP_EXT);
!
! // Need to do some sanitization on the result of filelist
! foreach ($filelist as $tools)
! {
! // Don't want the extension
! foreach ($tools as $tool)
! {
! if (in_array($tool, $this->ignore_tools))
! {
! continue;
! }
!
! $this->plugin_list[] = (($pos = strpos($tool, '.' . PHP_EXT)) !== false) ? substr($tool, 0, $pos) : $tool;
! }
! }
!
! // Get the requested cat and tool
! $this->tool_id = request_var('t', '');
!
! // Check if they want to use a tool or not, make sure that the tool name is legal, and make sure the tool exists
! if (!$this->tool_id || preg_match('#([^a-zA-Z0-9_])#', $this->tool_id) || !file_exists($this->tool_box_path . $this->tool_id . '.' . PHP_EXT))
! {
! $this->tool_id = '';
! }
!
! // Make sure the form_key is set
! add_form_key($this->tool_id);
!
! // Assign the two menus to the template
! $this->gen_left_nav();
! }
!
! /**
! * Load the requested tool
! *
! * @param String $tool_name The name of this tool
! * @param Boolean $return Specify whether an object of this tool will be returned
! * @return The object of the requested tool if $return is set to true else this method will return true
! */
! function load_tool($tool_name, $return = true)
! {
! global $user;
!
! static $tools_loaded = array();
!
! if (isset($tools_loaded[$tool_name]))
! {
! return ($return) ? $tools_loaded[$tool_name] : true;
! }
!
! $tool_path = $this->tool_box_path . $tool_name . '.' . PHP_EXT;
! if (false === (@include $tool_path))
! {
! trigger_error(sprintf($user->lang['TOOL_INCLUTION_NOT_FOUND'], $tool_path), E_USER_ERROR);
! }
!
! if (!class_exists($tool_name))
! {
! trigger_error(sprintf($user->lang['INCORRECT_CLASS'], $tool_name, PHP_EXT), E_USER_ERROR);
! }
!
! // Construct the class
! $tools_loaded[$tool_name] = new $tool_name();
!
! // Add the language file
! titania::add_lang('manage_tools/' . $tool_name);
!
! // Return
! return ($return) ? $tools_loaded[$tool_name] : true;
! }
!
! /**
! * Build the left "tool" navigation for every page
! * This is based upon the active tool
! */
! function gen_left_nav()
! {
! global $template, $user;
!
! // Grep the correct category
! $tool_list = $this->plugin_list;
!
! // Run through the tools and collect all info we need
! $tpl_data = array();
! foreach ($tool_list as $tool)
! {
! $class = $this->load_tool($tool);
!
! // Can this tool be used?
! if (method_exists($class, 'tool_active'))
! {
! if ($class->tool_active() !== true)
! {
! continue;
! }
! }
!
! // Get the info
! if (method_exists($class, 'info'))
! {
! $info = $class->info();
! }
! else
! {
! // For us lazy people
! $info = array(
! 'NAME' => (isset($user->lang[strtoupper($tool)])) ? $user->lang[strtoupper($tool)] : strtoupper($tool),
! );
! }
!
! $tpl_data[$tool] = $info['NAME'];
! }
!
! // Sort the data based on the tool name. This way we'll keep the menu sorted correctly for translations
! asort($tpl_data);
!
! // Now go ahead and build the template
! foreach ($tpl_data as $tool => $name)
! {
! $_s_active = ($tool == $this->tool_id) ? true : false;
!
! // Assign to the template
! $template->assign_block_vars('tools', array(
! 'L_TITLE' => $name,
! 'TOOL' => $tool,
! 'S_SELECTED' => $_s_active,
! 'U_TITLE' => titania_url::build_url('manage/administration', array('t' => $tool)),
! ));
! }
! }
! }
?>
\ No newline at end of file
--- 1,196 ----
! <?php
! /**
! *
! * @package Support Toolkit - Plugin handler
! * @version $Id$
! * @copyright (c) 2009 phpBB Group
! * @license http://opensource.org/licenses/gpl-license.php GNU Public License
! *
! */
!
! /**
! * @ignore
! */
! if (!defined('IN_PHPBB'))
! {
! exit;
! }
!
! // Load functions_admin.php if required
! if (!function_exists('filelist'))
! {
! include(PHPBB_ROOT_PATH . 'includes/functions_admin.' . PHP_EXT);
! }
!
! class manage_plugin
! {
! /**
! * A list containing file and directory names that should be ignored
! *
! * @var array
! * @access private
! */
! var $ignore_tools = array('index.htm', 'manage_plugin.php');
!
! /**
! * List containing all available tools and in which category they belong.
! * On default it contains the "main" category
! *
! * @var array
! * @access private
! */
! var $plugin_list = array();
!
! /**
! * Path to the tools directory
! *
! * @var String
! * @access public
! */
! var $tool_box_path = '';
!
! var $tool_id = '';
!
! /**
! * Constructor
! * Load the list with available plugins and assign them in the correct category
! */
! function manage_plugin()
! {
! // Set the path
! $this->tool_box_path = TITANIA_ROOT . 'includes/manage_tools/';
!
! // Create a list with tools
! $filelist = filelist($this->tool_box_path, '', PHP_EXT);
!
! // Need to do some sanitization on the result of filelist
! foreach ($filelist as $tools)
! {
! // Don't want the extension
! foreach ($tools as $tool)
! {
! if (in_array($tool, $this->ignore_tools))
! {
! continue;
! }
!
! $this->plugin_list[] = (($pos = strpos($tool, '.' . PHP_EXT)) !== false) ? substr($tool, 0, $pos) : $tool;
! }
! }
!
! // Get the requested cat and tool
! $this->tool_id = request_var('t', '');
!
! // Check if they want to use a tool or not, make sure that the tool name is legal, and make sure the tool exists
! if (!$this->tool_id || preg_match('#([^a-zA-Z0-9_])#', $this->tool_id) || !file_exists($this->tool_box_path . $this->tool_id . '.' . PHP_EXT))
! {
! $this->tool_id = '';
! }
!
! // Make sure the form_key is set
! add_form_key($this->tool_id);
!
! // Assign the two menus to the template
! $this->gen_left_nav();
! }
!
! /**
! * Load the requested tool
! *
! * @param String $tool_name The name of this tool
! * @param Boolean $return Specify whether an object of this tool will be returned
! * @return The object of the requested tool if $return is set to true else this method will return true
! */
! function load_tool($tool_name, $return = true)
! {
! global $user;
!
! static $tools_loaded = array();
!
! if (isset($tools_loaded[$tool_name]))
! {
! return ($return) ? $tools_loaded[$tool_name] : true;
! }
!
! $tool_path = $this->tool_box_path . $tool_name . '.' . PHP_EXT;
! if (false === (@include $tool_path))
! {
! trigger_error(sprintf($user->lang['TOOL_INCLUTION_NOT_FOUND'], $tool_path), E_USER_ERROR);
! }
!
! if (!class_exists($tool_name))
! {
! trigger_error(sprintf($user->lang['INCORRECT_CLASS'], $tool_name, PHP_EXT), E_USER_ERROR);
! }
!
! // Construct the class
! $tools_loaded[$tool_name] = new $tool_name();
!
! // Add the language file
! titania::add_lang('manage_tools/' . $tool_name);
!
! // Return
! return ($return) ? $tools_loaded[$tool_name] : true;
! }
!
! /**
! * Build the left "tool" navigation for every page
! * This is based upon the active tool
! */
! function gen_left_nav()
! {
! global $template, $user;
!
! // Grep the correct category
! $tool_list = $this->plugin_list;
!
! // Run through the tools and collect all info we need
! $tpl_data = array();
! foreach ($tool_list as $tool)
! {
! $class = $this->load_tool($tool);
!
! // Can this tool be used?
! if (method_exists($class, 'tool_active'))
! {
! if ($class->tool_active() !== true)
! {
! continue;
! }
! }
!
! // Get the info
! if (method_exists($class, 'info'))
! {
! $info = $class->info();
! }
! else
! {
! // For us lazy people
! $info = array(
! 'NAME' => (isset($user->lang[strtoupper($tool)])) ? $user->lang[strtoupper($tool)] : strtoupper($tool),
! );
! }
!
! $tpl_data[$tool] = $info['NAME'];
! }
!
! // Sort the data based on the tool name. This way we'll keep the menu sorted correctly for translations
! asort($tpl_data);
!
! // Now go ahead and build the template
! foreach ($tpl_data as $tool => $name)
! {
! $_s_active = ($tool == $this->tool_id) ? true : false;
!
! // Assign to the template
! $template->assign_block_vars('tools', array(
! 'L_TITLE' => $name,
! 'TOOL' => $tool,
! 'S_SELECTED' => $_s_active,
! 'U_TITLE' => titania_url::build_url('manage/administration', array('t' => $tool)),
! ));
! }
! }
! }
?>
\ No newline at end of file
Modified: branches/stable/titania/includes/manage_tools/organize_lang.php
==============================================================================
*** branches/stable/titania/includes/manage_tools/organize_lang.php (original)
--- branches/stable/titania/includes/manage_tools/organize_lang.php Sat Nov 20 18:23:22 2010
***************
*** 1,278 ****
! <?php
! /**
! *
! * @package Support Tool Kit - Organize Language Files
! * @version $Id$
! * @copyright (c) 2009 phpBB Group
! * @license http://opensource.org/licenses/gpl-license.php GNU Public License
! *
! */
!
! if (!defined('IN_PHPBB'))
! {
! exit;
! }
!
! class organize_lang
! {
! /**
! * Tool Info
! *
! * @return Returns an array with the info about this tool.
! */
! function info()
! {
! global $user;
!
! return array(
! 'NAME' => $user->lang['ORGANIZE_LANG'],
! 'NAME_EXPLAIN' => $user->lang['ORGANIZE_LANG_EXPLAIN'],
! );
! }
!
! /**
! * Display Options
! *
! * Output the options available
! */
! function display_options()
! {
! return array(
! 'title' => 'ORGANIZE_LANG',
! 'vars' => array(
! 'legend1' => 'ORGANIZE_LANG',
! 'file' => array('lang' => 'ORGANIZE_LANG_FILE', 'default' => 'en/', 'type' => 'text:40:255', 'explain' => true),
! )
! );
! }
!
! /**
! * Run Tool
! *
! * Does the actual stuff we want the tool to do after submission
! */
! function run_tool(&$error)
! {
! if (!check_form_key('organize_lang'))
! {
! $error[] = 'FORM_INVALID';
! return;
! }
!
! $file = request_var('file', '');
! if (!$file || (!file_exists(TITANIA_ROOT . 'language/' . $file) && !file_exists(TITANIA_ROOT . 'language/' . $file . '.' . PHP_EXT)))
! {
! $error[] = 'NO_FILE';
! return;
! }
!
! organize_lang($file);
!
! trigger_back('ORGANIZE_LANG_SUCCESS');
! }
! }
!
! /**
! * For finding the max string length for the organize_lang function
! */
! function find_max_length($lang, &$max_length, $start = 0)
! {
! $start_length = $start * 4;
!
! foreach($lang as $name => $value)
! {
! if (is_array($value))
! {
! find_max_length($value, $max_length, ($start + 1));
! }
!
! if ((utf8_strlen($name) + $start_length) > $max_length)
! {
! $max_length = (utf8_strlen($name) + $start_length);
! }
! }
! }
!
! /**
! * For outputting the lines for the organize_lang function
! */
! function lang_lines($lang, $max_length, &$output, $start = 0)
! {
! $last_letter = '';
! $total_tabs = ceil(($max_length + 3) / 4) - $start;
!
! if ($start != 0)
! {
! //ksort($lang);
! }
!
! $last_name = '';
! foreach($lang as $name => $value)
! {
! if ($name == $last_name)
! {
! echo 'Lang Duplicate: ' . $name . '<br />';
! }
! $last_name = $name;
!
! // make sure to add slashes to single quotes!
! $name = addcslashes($name, "'");
!
! // add an extra end line if the next word starts with a different letter then the last
! if (substr($name, 0, 1) != $last_letter && $start == 0)
! {
! $output .= "\n";
! $last_letter = substr($name, 0, 1);
! }
!
! // add the beggining tabs
! for ($i=0; $i <= $start; $i++)
! {
! $output .= "\t";
! }
!
! // add the beginning of the lang section and add slashes to single quotes for the name
! $output .= "'" . $name . "'";
!
! // figure out the number of tabs we need to add to the middle, then add them
! $tabs = ($total_tabs - ceil((utf8_strlen($name) + 3) / 4));
!
! for($i=0; $i <= $tabs; $i++)
! {
! $output .= "\t";
! }
!
! if (is_array($value))
! {
! $output .= "=> array(\n";
! lang_lines($value, $max_length, $output, ($start + 1));
!
! for ($i=0; $i <= $start; $i++)
! {
! $output .= "\t";
! }
! $output .= "),\n\n";
! }
! else
! {
! // add =>, then slashes to single quotes and add to the output
! $output .= "=> '" . addcslashes($value, "'") . "',\n";
! }
! }
! }
!
! /**
! * Organize the language file by the lang keys, then re-output the data to the file
! */
! function organize_lang($file, $skip_errors = false)
! {
! if (substr($file, -1) == '/')
! {
! $file = substr($file, 0, -1);
! }
!
! // If the user submitted a directory, do every language file in that directory
! if (is_dir(TITANIA_ROOT . 'language/' . $file))
! {
! if ($handle = opendir(TITANIA_ROOT . 'language/' . $file))
! {
! while (false !== ($file1 = readdir($handle)))
! {
! if ($file1 == '.' || $file1 == '..' || $file1 == '.svn')
! {
! continue;
! }
!
! if (strpos($file1, '.' . PHP_EXT))
! {
! organize_lang($file . '/' . substr($file1, 0, strpos($file1, '.' . PHP_EXT)), true);
! }
! else if (is_dir(TITANIA_ROOT . 'language/' . $file . '/' . $file1))
! {
! organize_lang($file . '/' . $file1);
! }
! }
! closedir($handle);
! }
!
! // if we went to a subdirectory, return
! if ($file != request_var('file', '') && $file . '/' != request_var('file', ''))
! {
! return;
! }
!
! // Finished entire directory
! return;
! }
!
! // include the file
! @include(TITANIA_ROOT . 'language/' . $file . '.' . PHP_EXT);
!
! // make sure it is a valid language file
! if (!isset($lang) || !is_array($lang))
! {
! if ($skip_errors)
! {
! return;
! }
!
! trigger_back('Bad Language File. language/' . $file);
! }
!
! // setup the $output var
! $output = '';
!
! // lets get the header of the file...
! $handle = @fopen(TITANIA_ROOT . 'language/' . $file . '.' . PHP_EXT, "r");
! if ($handle)
! {
! $stopped = false;
!
! while (!feof($handle))
! {
! $line = fgets($handle, 4096);
!
! // if the line is $lang = array_merge($lang, array( break out of the while loop
! if ($line == '$lang = array_merge($lang, array(' . "\n")
! {
! $stopped = true;
! break;
! }
!
! $output .= $line;
! }
! fclose($handle);
!
! if (!$stopped)
! {
! if ($skip_errors)
! {
! echo 'Bad line endings in ' . TITANIA_ROOT . 'language/' . $file . '.' . PHP_EXT . '<br />';
! return;
! }
!
! trigger_back('Please make sure you are using UNIX line endings.');
! }
! }
!
! // sort the languages by keys
! ksort($lang);
!
! // get the maximum length of the name string so we can format the page nicely when we output it
! $max_length = 1;
!
! find_max_length($lang, $max_length);
!
! // now add $lang = array_merge($lang, array( to the output
! $output .= '$lang = array_merge($lang, array(';
!
! lang_lines($lang, $max_length, $output);
!
! // add the end
! $output .= '));
! ';
!
! // write the contents to the specified file
! file_put_contents(TITANIA_ROOT . 'language/' . $file . '.' . PHP_EXT, $output);
! }
?>
\ No newline at end of file
--- 1,278 ----
! <?php
! /**
! *
! * @package Support Tool Kit - Organize Language Files
! * @version $Id$
! * @copyright (c) 2009 phpBB Group
! * @license http://opensource.org/licenses/gpl-license.php GNU Public License
! *
! */
!
! if (!defined('IN_PHPBB'))
! {
! exit;
! }
!
! class organize_lang
! {
! /**
! * Tool Info
! *
! * @return Returns an array with the info about this tool.
! */
! function info()
! {
! global $user;
!
! return array(
! 'NAME' => $user->lang['ORGANIZE_LANG'],
! 'NAME_EXPLAIN' => $user->lang['ORGANIZE_LANG_EXPLAIN'],
! );
! }
!
! /**
! * Display Options
! *
! * Output the options available
! */
! function display_options()
! {
! return array(
! 'title' => 'ORGANIZE_LANG',
! 'vars' => array(
! 'legend1' => 'ORGANIZE_LANG',
! 'file' => array('lang' => 'ORGANIZE_LANG_FILE', 'default' => 'en/', 'type' => 'text:40:255', 'explain' => true),
! )
! );
! }
!
! /**
! * Run Tool
! *
! * Does the actual stuff we want the tool to do after submission
! */
! function run_tool(&$error)
! {
! if (!check_form_key('organize_lang'))
! {
! $error[] = 'FORM_INVALID';
! return;
! }
!
! $file = request_var('file', '');
! if (!$file || (!file_exists(TITANIA_ROOT . 'language/' . $file) && !file_exists(TITANIA_ROOT . 'language/' . $file . '.' . PHP_EXT)))
! {
! $error[] = 'NO_FILE';
! return;
! }
!
! organize_lang($file);
!
! trigger_back('ORGANIZE_LANG_SUCCESS');
! }
! }
!
! /**
! * For finding the max string length for the organize_lang function
! */
! function find_max_length($lang, &$max_length, $start = 0)
! {
! $start_length = $start * 4;
!
! foreach($lang as $name => $value)
! {
! if (is_array($value))
! {
! find_max_length($value, $max_length, ($start + 1));
! }
!
! if ((utf8_strlen($name) + $start_length) > $max_length)
! {
! $max_length = (utf8_strlen($name) + $start_length);
! }
! }
! }
!
! /**
! * For outputting the lines for the organize_lang function
! */
! function lang_lines($lang, $max_length, &$output, $start = 0)
! {
! $last_letter = '';
! $total_tabs = ceil(($max_length + 3) / 4) - $start;
!
! if ($start != 0)
! {
! //ksort($lang);
! }
!
! $last_name = '';
! foreach($lang as $name => $value)
! {
! if ($name == $last_name)
! {
! echo 'Lang Duplicate: ' . $name . '<br />';
! }
! $last_name = $name;
!
! // make sure to add slashes to single quotes!
! $name = addcslashes($name, "'");
!
! // add an extra end line if the next word starts with a different letter then the last
! if (substr($name, 0, 1) != $last_letter && $start == 0)
! {
! $output .= "\n";
! $last_letter = substr($name, 0, 1);
! }
!
! // add the beggining tabs
! for ($i=0; $i <= $start; $i++)
! {
! $output .= "\t";
! }
!
! // add the beginning of the lang section and add slashes to single quotes for the name
! $output .= "'" . $name . "'";
!
! // figure out the number of tabs we need to add to the middle, then add them
! $tabs = ($total_tabs - ceil((utf8_strlen($name) + 3) / 4));
!
! for($i=0; $i <= $tabs; $i++)
! {
! $output .= "\t";
! }
!
! if (is_array($value))
! {
! $output .= "=> array(\n";
! lang_lines($value, $max_length, $output, ($start + 1));
!
! for ($i=0; $i <= $start; $i++)
! {
! $output .= "\t";
! }
! $output .= "),\n\n";
! }
! else
! {
! // add =>, then slashes to single quotes and add to the output
! $output .= "=> '" . addcslashes($value, "'") . "',\n";
! }
! }
! }
!
! /**
! * Organize the language file by the lang keys, then re-output the data to the file
! */
! function organize_lang($file, $skip_errors = false)
! {
! if (substr($file, -1) == '/')
! {
! $file = substr($file, 0, -1);
! }
!
! // If the user submitted a directory, do every language file in that directory
! if (is_dir(TITANIA_ROOT . 'language/' . $file))
! {
! if ($handle = opendir(TITANIA_ROOT . 'language/' . $file))
! {
! while (false !== ($file1 = readdir($handle)))
! {
! if ($file1 == '.' || $file1 == '..' || $file1 == '.svn')
! {
! continue;
! }
!
! if (strpos($file1, '.' . PHP_EXT))
! {
! organize_lang($file . '/' . substr($file1, 0, strpos($file1, '.' . PHP_EXT)), true);
! }
! else if (is_dir(TITANIA_ROOT . 'language/' . $file . '/' . $file1))
! {
! organize_lang($file . '/' . $file1);
! }
! }
! closedir($handle);
! }
!
! // if we went to a subdirectory, return
! if ($file != request_var('file', '') && $file . '/' != request_var('file', ''))
! {
! return;
! }
!
! // Finished entire directory
! return;
! }
!
! // include the file
! @include(TITANIA_ROOT . 'language/' . $file . '.' . PHP_EXT);
!
! // make sure it is a valid language file
! if (!isset($lang) || !is_array($lang))
! {
! if ($skip_errors)
! {
! return;
! }
!
! trigger_back('Bad Language File. language/' . $file);
! }
!
! // setup the $output var
! $output = '';
!
! // lets get the header of the file...
! $handle = @fopen(TITANIA_ROOT . 'language/' . $file . '.' . PHP_EXT, "r");
! if ($handle)
! {
! $stopped = false;
!
! while (!feof($handle))
! {
! $line = fgets($handle, 4096);
!
! // if the line is $lang = array_merge($lang, array( break out of the while loop
! if ($line == '$lang = array_merge($lang, array(' . "\n")
! {
! $stopped = true;
! break;
! }
!
! $output .= $line;
! }
! fclose($handle);
!
! if (!$stopped)
! {
! if ($skip_errors)
! {
! echo 'Bad line endings in ' . TITANIA_ROOT . 'language/' . $file . '.' . PHP_EXT . '<br />';
! return;
! }
!
! trigger_back('Please make sure you are using UNIX line endings.');
! }
! }
!
! // sort the languages by keys
! ksort($lang);
!
! // get the maximum length of the name string so we can format the page nicely when we output it
! $max_length = 1;
!
! find_max_length($lang, $max_length);
!
! // now add $lang = array_merge($lang, array( to the output
! $output .= '$lang = array_merge($lang, array(';
!
! lang_lines($lang, $max_length, $output);
!
! // add the end
! $output .= '));
! ';
!
! // write the contents to the specified file
! file_put_contents(TITANIA_ROOT . 'language/' . $file . '.' . PHP_EXT, $output);
! }
?>
\ No newline at end of file
Modified: branches/stable/titania/includes/manage_tools/phpbb_version_add.php
==============================================================================
*** branches/stable/titania/includes/manage_tools/phpbb_version_add.php (original)
--- branches/stable/titania/includes/manage_tools/phpbb_version_add.php Sat Nov 20 18:23:22 2010
***************
*** 1,186 ****
! <?php
! /**
! *
! * @package Titania
! * @version $Id$
! * @copyright (c) 2008 phpBB Customisation Database Team
! * @license http://opensource.org/licenses/gpl-license.php GNU Public License
! *
! */
!
! if (!defined('IN_PHPBB'))
! {
! exit;
! }
!
! class phpbb_version_add
! {
! function display_options()
! {
! return array(
! 'title' => 'PHPBB_VERSION_ADD',
! 'vars' => array(
! 'new_phpbb_version' => array('lang' => 'NEW_PHPBB_VERSION', 'type' => 'text:40:255', 'explain' => true),
! 'limit_phpbb_version' => array('lang' => 'VERSION_RESTRICTION', 'type' => 'select_multiple', 'function' => 'pva_generate_phpbb_version_select', 'explain' => true, 'default' => ''),
! 'category' => array('lang' => 'CATEGORY', 'type' => 'select_multiple', 'function' => 'pva_generate_category_select', 'explain' => true),
! )
! );
! }
!
! function run_tool()
! {
! $new_phpbb_version = request_var('new_phpbb_version', '');
! $limit_phpbb_versions = request_var('limit_phpbb_version', array(''));
! $categories = request_var('category', array(0));
!
! if (!$new_phpbb_version || strlen($new_phpbb_version) < 5 || $new_phpbb_version[1] != '.' || $new_phpbb_version[3] != '.')
! {
! trigger_back('NO_VERSION_SELECTED');
! }
!
! $phpbb_version_branch = (int) $new_phpbb_version[0] . (int) $new_phpbb_version[2];
! $phpbb_version_revision = get_real_revision_version(substr($new_phpbb_version, 4));
!
! // Is it in our version cache?
! $versions = titania::$cache->get_phpbb_versions();
! if (!isset($versions[$phpbb_version_branch . $phpbb_version_revision]))
! {
! titania::$cache->destroy('_titania_phpbb_versions');
! }
!
! // Categories limiter
! $contribs = $revisions = array();
! if (sizeof($categories) > 1 || (sizeof($categories) && $categories[0] != 0))
! {
! $sql = 'SELECT contrib_id FROM ' . TITANIA_CONTRIB_IN_CATEGORIES_TABLE . '
! WHERE ' . phpbb::$db->sql_in_set('category_id', array_map('intval', $categories));
! $result = phpbb::$db->sql_query($sql);
! while ($row = phpbb::$db->sql_fetchrow($result))
! {
! $contribs[] = $row['contrib_id'];
! }
! phpbb::$db->sql_freeresult($result);
!
! if (!sizeof($contribs))
! {
! trigger_back('NO_REVISIONS_UPDATED');
! }
! }
!
! if (sizeof($limit_phpbb_versions) > 1 || (sizeof($limit_phpbb_versions) && $limit_phpbb_versions[0] != 0))
! {
! // phpBB versions limiter
! foreach ($limit_phpbb_versions as $limit_phpbb_version)
! {
! $sql = 'SELECT rp.contrib_id, rp.revision_id, r.revision_status FROM ' . TITANIA_REVISIONS_PHPBB_TABLE . ' rp, ' . TITANIA_REVISIONS_TABLE . ' r
! WHERE rp.phpbb_version_branch = ' . (int) substr($limit_phpbb_version, 0, 2) . '
! AND rp.phpbb_version_revision = \'' . phpbb::$db->sql_escape(substr($limit_phpbb_version, 2)) . '\'' .
! ((sizeof($contribs)) ? ' AND ' . phpbb::$db->sql_in_set('rp.contrib_id', array_map('intval', $contribs)) : '') . '
! AND r.revision_id = rp.revision_id';
! $result = phpbb::$db->sql_query($sql);
! while ($row = phpbb::$db->sql_fetchrow($result))
! {
! $revisions[$row['revision_id']] = $row;
! }
! phpbb::$db->sql_freeresult($result);
! }
! }
! else if (sizeof($categories) > 1 || (sizeof($categories) && $categories[0] != 0))
! {
! // Only category limited
! $sql = 'SELECT contrib_id, revision_id, revision_status FROM ' . TITANIA_REVISIONS_TABLE . '
! WHERE ' . phpbb::$db->sql_in_set('contrib_id', array_map('intval', $contribs));
! $result = phpbb::$db->sql_query($sql);
! while ($row = phpbb::$db->sql_fetchrow($result))
! {
! $revisions[$row['revision_id']] = $row;
! }
! phpbb::$db->sql_freeresult($result);
! }
! else
! {
! // All
! $sql = 'SELECT contrib_id, revision_id, revision_status FROM ' . TITANIA_REVISIONS_TABLE;
! $result = phpbb::$db->sql_query($sql);
! while ($row = phpbb::$db->sql_fetchrow($result))
! {
! $revisions[$row['revision_id']] = $row;
! }
! phpbb::$db->sql_freeresult($result);
! }
!
! if (!sizeof($revisions))
! {
! trigger_back('NO_REVISIONS_UPDATED');
! }
!
! // Don't include those which already are marked for this phpBB version
! $sql = 'SELECT revision_id FROM ' . TITANIA_REVISIONS_PHPBB_TABLE . '
! WHERE ' . phpbb::$db->sql_in_set('revision_id', array_map('intval', array_keys($revisions))) . '
! AND phpbb_version_branch = ' . $phpbb_version_branch . '
! AND phpbb_version_revision = \'' . phpbb::$db->sql_escape($phpbb_version_revision) . '\'';
! $result = phpbb::$db->sql_query($sql);
! while ($row = phpbb::$db->sql_fetchrow($result))
! {
! unset($revisions[$row['revision_id']]);
! }
! phpbb::$db->sql_freeresult($result);
!
! if (!sizeof($revisions))
! {
! trigger_back('NO_REVISIONS_UPDATED');
! }
!
! $sql_ary = array();
! foreach ($revisions as $revision_id => $row)
! {
! $sql_ary[] = array(
! 'contrib_id' => (int) $row['contrib_id'],
! 'revision_id' => (int) $revision_id,
! 'phpbb_version_branch' => $phpbb_version_branch,
! 'phpbb_version_revision' => $phpbb_version_revision,
! 'revision_validated' => ($row['revision_status'] == TITANIA_REVISION_APPROVED) ? true : false,
! );
! }
!
! phpbb::$db->sql_multi_insert(TITANIA_REVISIONS_PHPBB_TABLE, $sql_ary);
!
! trigger_back(sprintf(phpbb::$user->lang['REVISIONS_UPDATED'], sizeof($revisions)));
! }
! }
!
! if (!function_exists('pva_generate_phpbb_version_select'))
! {
! function pva_generate_phpbb_version_select()
! {
! $versions = titania::$cache->get_phpbb_versions();
!
! $select = '<option value="0" selected="selected">-----</option>';
!
! foreach ($versions as $version => $name)
! {
! $select .= '<option value="' . $version . '">' . $name . '</option>';
! }
!
! return $select;
! }
! }
!
! if (!function_exists('pva_generate_category_select'))
! {
! function pva_generate_category_select()
! {
! titania::_include('functions_posting', 'generate_category_select');
!
! phpbb::$template->destroy_block_vars('category_select');
! generate_category_select();
!
! phpbb::$template->set_filenames(array(
! 'generate_category_select' => 'manage/generate_category_select.html',
! ));
!
! $select = phpbb::$template->assign_display('generate_category_select');
!
! return $select;
! }
}
\ No newline at end of file
--- 1,186 ----
! <?php
! /**
! *
! * @package Titania
! * @version $Id$
! * @copyright (c) 2008 phpBB Customisation Database Team
! * @license http://opensource.org/licenses/gpl-license.php GNU Public License
! *
! */
!
! if (!defined('IN_PHPBB'))
! {
! exit;
! }
!
! class phpbb_version_add
! {
! function display_options()
! {
! return array(
! 'title' => 'PHPBB_VERSION_ADD',
! 'vars' => array(
! 'new_phpbb_version' => array('lang' => 'NEW_PHPBB_VERSION', 'type' => 'text:40:255', 'explain' => true),
! 'limit_phpbb_version' => array('lang' => 'VERSION_RESTRICTION', 'type' => 'select_multiple', 'function' => 'pva_generate_phpbb_version_select', 'explain' => true, 'default' => ''),
! 'category' => array('lang' => 'CATEGORY', 'type' => 'select_multiple', 'function' => 'pva_generate_category_select', 'explain' => true),
! )
! );
! }
!
! function run_tool()
! {
! $new_phpbb_version = request_var('new_phpbb_version', '');
! $limit_phpbb_versions = request_var('limit_phpbb_version', array(''));
! $categories = request_var('category', array(0));
!
! if (!$new_phpbb_version || strlen($new_phpbb_version) < 5 || $new_phpbb_version[1] != '.' || $new_phpbb_version[3] != '.')
! {
! trigger_back('NO_VERSION_SELECTED');
! }
!
! $phpbb_version_branch = (int) $new_phpbb_version[0] . (int) $new_phpbb_version[2];
! $phpbb_version_revision = get_real_revision_version(substr($new_phpbb_version, 4));
!
! // Is it in our version cache?
! $versions = titania::$cache->get_phpbb_versions();
! if (!isset($versions[$phpbb_version_branch . $phpbb_version_revision]))
! {
! titania::$cache->destroy('_titania_phpbb_versions');
! }
!
! // Categories limiter
! $contribs = $revisions = array();
! if (sizeof($categories) > 1 || (sizeof($categories) && $categories[0] != 0))
! {
! $sql = 'SELECT contrib_id FROM ' . TITANIA_CONTRIB_IN_CATEGORIES_TABLE . '
! WHERE ' . phpbb::$db->sql_in_set('category_id', array_map('intval', $categories));
! $result = phpbb::$db->sql_query($sql);
! while ($row = phpbb::$db->sql_fetchrow($result))
! {
! $contribs[] = $row['contrib_id'];
! }
! phpbb::$db->sql_freeresult($result);
!
! if (!sizeof($contribs))
! {
! trigger_back('NO_REVISIONS_UPDATED');
! }
! }
!
! if (sizeof($limit_phpbb_versions) > 1 || (sizeof($limit_phpbb_versions) && $limit_phpbb_versions[0] != 0))
! {
! // phpBB versions limiter
! foreach ($limit_phpbb_versions as $limit_phpbb_version)
! {
! $sql = 'SELECT rp.contrib_id, rp.revision_id, r.revision_status FROM ' . TITANIA_REVISIONS_PHPBB_TABLE . ' rp, ' . TITANIA_REVISIONS_TABLE . ' r
! WHERE rp.phpbb_version_branch = ' . (int) substr($limit_phpbb_version, 0, 2) . '
! AND rp.phpbb_version_revision = \'' . phpbb::$db->sql_escape(substr($limit_phpbb_version, 2)) . '\'' .
! ((sizeof($contribs)) ? ' AND ' . phpbb::$db->sql_in_set('rp.contrib_id', array_map('intval', $contribs)) : '') . '
! AND r.revision_id = rp.revision_id';
! $result = phpbb::$db->sql_query($sql);
! while ($row = phpbb::$db->sql_fetchrow($result))
! {
! $revisions[$row['revision_id']] = $row;
! }
! phpbb::$db->sql_freeresult($result);
! }
! }
! else if (sizeof($categories) > 1 || (sizeof($categories) && $categories[0] != 0))
! {
! // Only category limited
! $sql = 'SELECT contrib_id, revision_id, revision_status FROM ' . TITANIA_REVISIONS_TABLE . '
! WHERE ' . phpbb::$db->sql_in_set('contrib_id', array_map('intval', $contribs));
! $result = phpbb::$db->sql_query($sql);
! while ($row = phpbb::$db->sql_fetchrow($result))
! {
! $revisions[$row['revision_id']] = $row;
! }
! phpbb::$db->sql_freeresult($result);
! }
! else
! {
! // All
! $sql = 'SELECT contrib_id, revision_id, revision_status FROM ' . TITANIA_REVISIONS_TABLE;
! $result = phpbb::$db->sql_query($sql);
! while ($row = phpbb::$db->sql_fetchrow($result))
! {
! $revisions[$row['revision_id']] = $row;
! }
! phpbb::$db->sql_freeresult($result);
! }
!
! if (!sizeof($revisions))
! {
! trigger_back('NO_REVISIONS_UPDATED');
! }
!
! // Don't include those which already are marked for this phpBB version
! $sql = 'SELECT revision_id FROM ' . TITANIA_REVISIONS_PHPBB_TABLE . '
! WHERE ' . phpbb::$db->sql_in_set('revision_id', array_map('intval', array_keys($revisions))) . '
! AND phpbb_version_branch = ' . $phpbb_version_branch . '
! AND phpbb_version_revision = \'' . phpbb::$db->sql_escape($phpbb_version_revision) . '\'';
! $result = phpbb::$db->sql_query($sql);
! while ($row = phpbb::$db->sql_fetchrow($result))
! {
! unset($revisions[$row['revision_id']]);
! }
! phpbb::$db->sql_freeresult($result);
!
! if (!sizeof($revisions))
! {
! trigger_back('NO_REVISIONS_UPDATED');
! }
!
! $sql_ary = array();
! foreach ($revisions as $revision_id => $row)
! {
! $sql_ary[] = array(
! 'contrib_id' => (int) $row['contrib_id'],
! 'revision_id' => (int) $revision_id,
! 'phpbb_version_branch' => $phpbb_version_branch,
! 'phpbb_version_revision' => $phpbb_version_revision,
! 'revision_validated' => ($row['revision_status'] == TITANIA_REVISION_APPROVED) ? true : false,
! );
! }
!
! phpbb::$db->sql_multi_insert(TITANIA_REVISIONS_PHPBB_TABLE, $sql_ary);
!
! trigger_back(sprintf(phpbb::$user->lang['REVISIONS_UPDATED'], sizeof($revisions)));
! }
! }
!
! if (!function_exists('pva_generate_phpbb_version_select'))
! {
! function pva_generate_phpbb_version_select()
! {
! $versions = titania::$cache->get_phpbb_versions();
!
! $select = '<option value="0" selected="selected">-----</option>';
!
! foreach ($versions as $version => $name)
! {
! $select .= '<option value="' . $version . '">' . $name . '</option>';
! }
!
! return $select;
! }
! }
!
! if (!function_exists('pva_generate_category_select'))
! {
! function pva_generate_category_select()
! {
! titania::_include('functions_posting', 'generate_category_select');
!
! phpbb::$template->destroy_block_vars('category_select');
! generate_category_select();
!
! phpbb::$template->set_filenames(array(
! 'generate_category_select' => 'manage/generate_category_select.html',
! ));
!
! $select = phpbb::$template->assign_display('generate_category_select');
!
! return $select;
! }
}
\ No newline at end of file
Modified: branches/stable/titania/includes/manage_tools/phpbb_version_test.php
==============================================================================
*** branches/stable/titania/includes/manage_tools/phpbb_version_test.php (original)
--- branches/stable/titania/includes/manage_tools/phpbb_version_test.php Sat Nov 20 18:23:22 2010
***************
*** 1,172 ****
! <?php
! /**
! *
! * @package Titania
! * @version $Id$
! * @copyright (c) 2008 phpBB Customisation Database Team
! * @license http://opensource.org/licenses/gpl-license.php GNU Public License
! *
! */
!
! if (!defined('IN_PHPBB'))
! {
! exit;
! }
!
! class phpbb_version_test
! {
! function display_options()
! {
! return array(
! 'title' => 'PHPBB_VERSION_TEST',
! 'vars' => array(
! 'new_phpbb_version' => array('lang' => 'NEW_PHPBB_VERSION', 'type' => 'text:40:255', 'explain' => true),
! 'limit_phpbb_version' => array('lang' => 'VERSION_RESTRICTION', 'type' => 'select_multiple', 'function' => 'pva_generate_phpbb_version_select', 'explain' => true, 'default' => ''),
! )
! );
! }
!
! function run_tool()
! {
! $new_phpbb_version = request_var('new_phpbb_version', '');
! $limit_phpbb_versions = request_var('limit_phpbb_version', array(''));
!
! if (!$new_phpbb_version || strlen($new_phpbb_version) < 5 || $new_phpbb_version[1] != '.' || $new_phpbb_version[3] != '.')
! {
! trigger_back('NO_VERSION_SELECTED');
! }
!
! // Does the zip for this exist?
! $version = preg_replace('#[^a-zA-Z0-9\.\-]+#', '', $new_phpbb_version);
! if (!file_exists(TITANIA_ROOT . 'store/phpbb_packages/phpBB-' . $version . '.zip'))
! {
! trigger_back(sprintf(phpbb::$user->lang['FILE_NOT_EXIST'], 'store/phpbb_packages/phpBB-' . $version . '.zip'));
! }
!
! $phpbb_version_branch = (int) $new_phpbb_version[0] . (int) $new_phpbb_version[2];
! $phpbb_version_revision = get_real_revision_version(substr($new_phpbb_version, 4));
!
! // Is it in our version cache?
! $versions = titania::$cache->get_phpbb_versions();
! if (!isset($versions[$phpbb_version_branch . $phpbb_version_revision]))
! {
! titania::$cache->destroy('_titania_phpbb_versions');
! }
!
! $testable_types = array();
! foreach (titania_types::$types as $type_id => $type)
! {
! if ($type->automod_test)
! {
! $testable_types[] = $type_id;
! }
! }
! if (!sizeof($testable_types))
! {
! trigger_back('NO_REVISIONS_UPDATED');
! }
!
! $revisions = array();
! $sql = 'SELECT DISTINCT(c.contrib_id), r.revision_id FROM ' . TITANIA_REVISIONS_TABLE . ' r, ' . TITANIA_CONTRIBS_TABLE . ' c
! WHERE c.contrib_id = r.contrib_id
! AND ' . phpbb::$db->sql_in_set('c.contrib_type', $testable_types) . '
! GROUP BY c.contrib_id
! ORDER BY r.revision_time DESC';
! $result = phpbb::$db->sql_query($sql);
! while ($row = phpbb::$db->sql_fetchrow($result))
! {
! $revisions[$row['revision_id']] = $row['contrib_id'];
! }
! phpbb::$db->sql_freeresult($result);
!
! if (sizeof($limit_phpbb_versions) > 1 || (sizeof($limit_phpbb_versions) && $limit_phpbb_versions[0] != 0))
! {
! $revisions_selected = array();
!
! // phpBB versions limiter
! foreach ($limit_phpbb_versions as $limit_phpbb_version)
! {
! $sql = 'SELECT revision_id
! FROM ' . TITANIA_REVISIONS_PHPBB_TABLE . '
! WHERE phpbb_version_branch = ' . (int) substr($limit_phpbb_version, 0, 2) . '
! AND phpbb_version_revision = \'' . phpbb::$db->sql_escape(substr($limit_phpbb_version, 2)) . '\'';
! $result = phpbb::$db->sql_query($sql);
! while ($row = phpbb::$db->sql_fetchrow($result))
! {
! if (isset($revisions[$row['revision_id']]))
! {
! $revisions_selected[$row['revision_id']] = $revisions[$row['revision_id']];
! }
! }
! phpbb::$db->sql_freeresult($result);
! }
!
! // swap
! $revisions = $revisions_selected;
! }
!
! if (!sizeof($revisions))
! {
! trigger_back('NO_REVISIONS_UPDATED');
! }
!
! // Don't include those which already are marked for this phpBB version
! $sql = 'SELECT revision_id FROM ' . TITANIA_REVISIONS_PHPBB_TABLE . '
! WHERE ' . phpbb::$db->sql_in_set('revision_id', array_map('intval', array_keys($revisions))) . '
! AND phpbb_version_branch = ' . $phpbb_version_branch . '
! AND phpbb_version_revision = \'' . phpbb::$db->sql_escape($phpbb_version_revision) . '\'';
! $result = phpbb::$db->sql_query($sql);
! while ($row = phpbb::$db->sql_fetchrow($result))
! {
! unset($revisions[$row['revision_id']]);
! }
! phpbb::$db->sql_freeresult($result);
!
! // Don't include those which already are in the automod queue
! $sql = 'SELECT revision_id FROM ' . TITANIA_AUTOMOD_QUEUE_TABLE . '
! WHERE phpbb_version_branch = ' . $phpbb_version_branch . '
! AND phpbb_version_revision = \'' . phpbb::$db->sql_escape($phpbb_version_revision) . '\'';
! $result = phpbb::$db->sql_query($sql);
! while ($row = phpbb::$db->sql_fetchrow($result))
! {
! unset($revisions[$row['revision_id']]);
! }
! phpbb::$db->sql_freeresult($result);
!
! if (!sizeof($revisions))
! {
! trigger_back('NO_REVISIONS_UPDATED');
! }
!
! $sql_ary = array();
! foreach ($revisions as $revision_id => $contrib_id)
! {
! $sql_ary[] = array(
! 'revision_id' => (int) $revision_id,
! 'phpbb_version_branch' => $phpbb_version_branch,
! 'phpbb_version_revision' => $phpbb_version_revision,
! );
! }
!
! phpbb::$db->sql_multi_insert(TITANIA_AUTOMOD_QUEUE_TABLE, $sql_ary);
!
! trigger_back(sprintf(phpbb::$user->lang['REVISIONS_ADDED_TO_QUEUE'], sizeof($revisions)));
! }
! }
!
! if (!function_exists('pva_generate_phpbb_version_select'))
! {
! function pva_generate_phpbb_version_select()
! {
! $versions = titania::$cache->get_phpbb_versions();
!
! $select = '<option value="0" selected="selected">-----</option>';
!
! foreach ($versions as $version => $name)
! {
! $select .= '<option value="' . $version . '">' . $name . '</option>';
! }
!
! return $select;
! }
! }
--- 1,172 ----
! <?php
! /**
! *
! * @package Titania
! * @version $Id$
! * @copyright (c) 2008 phpBB Customisation Database Team
! * @license http://opensource.org/licenses/gpl-license.php GNU Public License
! *
! */
!
! if (!defined('IN_PHPBB'))
! {
! exit;
! }
!
! class phpbb_version_test
! {
! function display_options()
! {
! return array(
! 'title' => 'PHPBB_VERSION_TEST',
! 'vars' => array(
! 'new_phpbb_version' => array('lang' => 'NEW_PHPBB_VERSION', 'type' => 'text:40:255', 'explain' => true),
! 'limit_phpbb_version' => array('lang' => 'VERSION_RESTRICTION', 'type' => 'select_multiple', 'function' => 'pva_generate_phpbb_version_select', 'explain' => true, 'default' => ''),
! )
! );
! }
!
! function run_tool()
! {
! $new_phpbb_version = request_var('new_phpbb_version', '');
! $limit_phpbb_versions = request_var('limit_phpbb_version', array(''));
!
! if (!$new_phpbb_version || strlen($new_phpbb_version) < 5 || $new_phpbb_version[1] != '.' || $new_phpbb_version[3] != '.')
! {
! trigger_back('NO_VERSION_SELECTED');
! }
!
! // Does the zip for this exist?
! $version = preg_replace('#[^a-zA-Z0-9\.\-]+#', '', $new_phpbb_version);
! if (!file_exists(TITANIA_ROOT . 'store/phpbb_packages/phpBB-' . $version . '.zip'))
! {
! trigger_back(sprintf(phpbb::$user->lang['FILE_NOT_EXIST'], 'store/phpbb_packages/phpBB-' . $version . '.zip'));
! }
!
! $phpbb_version_branch = (int) $new_phpbb_version[0] . (int) $new_phpbb_version[2];
! $phpbb_version_revision = get_real_revision_version(substr($new_phpbb_version, 4));
!
! // Is it in our version cache?
! $versions = titania::$cache->get_phpbb_versions();
! if (!isset($versions[$phpbb_version_branch . $phpbb_version_revision]))
! {
! titania::$cache->destroy('_titania_phpbb_versions');
! }
!
! $testable_types = array();
! foreach (titania_types::$types as $type_id => $type)
! {
! if ($type->automod_test)
! {
! $testable_types[] = $type_id;
! }
! }
! if (!sizeof($testable_types))
! {
! trigger_back('NO_REVISIONS_UPDATED');
! }
!
! $revisions = array();
! $sql = 'SELECT DISTINCT(c.contrib_id), r.revision_id FROM ' . TITANIA_REVISIONS_TABLE . ' r, ' . TITANIA_CONTRIBS_TABLE . ' c
! WHERE c.contrib_id = r.contrib_id
! AND ' . phpbb::$db->sql_in_set('c.contrib_type', $testable_types) . '
! GROUP BY c.contrib_id
! ORDER BY r.revision_time DESC';
! $result = phpbb::$db->sql_query($sql);
! while ($row = phpbb::$db->sql_fetchrow($result))
! {
! $revisions[$row['revision_id']] = $row['contrib_id'];
! }
! phpbb::$db->sql_freeresult($result);
!
! if (sizeof($limit_phpbb_versions) > 1 || (sizeof($limit_phpbb_versions) && $limit_phpbb_versions[0] != 0))
! {
! $revisions_selected = array();
!
! // phpBB versions limiter
! foreach ($limit_phpbb_versions as $limit_phpbb_version)
! {
! $sql = 'SELECT revision_id
! FROM ' . TITANIA_REVISIONS_PHPBB_TABLE . '
! WHERE phpbb_version_branch = ' . (int) substr($limit_phpbb_version, 0, 2) . '
! AND phpbb_version_revision = \'' . phpbb::$db->sql_escape(substr($limit_phpbb_version, 2)) . '\'';
! $result = phpbb::$db->sql_query($sql);
! while ($row = phpbb::$db->sql_fetchrow($result))
! {
! if (isset($revisions[$row['revision_id']]))
! {
! $revisions_selected[$row['revision_id']] = $revisions[$row['revision_id']];
! }
! }
! phpbb::$db->sql_freeresult($result);
! }
!
! // swap
! $revisions = $revisions_selected;
! }
!
! if (!sizeof($revisions))
! {
! trigger_back('NO_REVISIONS_UPDATED');
! }
!
! // Don't include those which already are marked for this phpBB version
! $sql = 'SELECT revision_id FROM ' . TITANIA_REVISIONS_PHPBB_TABLE . '
! WHERE ' . phpbb::$db->sql_in_set('revision_id', array_map('intval', array_keys($revisions))) . '
! AND phpbb_version_branch = ' . $phpbb_version_branch . '
! AND phpbb_version_revision = \'' . phpbb::$db->sql_escape($phpbb_version_revision) . '\'';
! $result = phpbb::$db->sql_query($sql);
! while ($row = phpbb::$db->sql_fetchrow($result))
! {
! unset($revisions[$row['revision_id']]);
! }
! phpbb::$db->sql_freeresult($result);
!
! // Don't include those which already are in the automod queue
! $sql = 'SELECT revision_id FROM ' . TITANIA_AUTOMOD_QUEUE_TABLE . '
! WHERE phpbb_version_branch = ' . $phpbb_version_branch . '
! AND phpbb_version_revision = \'' . phpbb::$db->sql_escape($phpbb_version_revision) . '\'';
! $result = phpbb::$db->sql_query($sql);
! while ($row = phpbb::$db->sql_fetchrow($result))
! {
! unset($revisions[$row['revision_id']]);
! }
! phpbb::$db->sql_freeresult($result);
!
! if (!sizeof($revisions))
! {
! trigger_back('NO_REVISIONS_UPDATED');
! }
!
! $sql_ary = array();
! foreach ($revisions as $revision_id => $contrib_id)
! {
! $sql_ary[] = array(
! 'revision_id' => (int) $revision_id,
! 'phpbb_version_branch' => $phpbb_version_branch,
! 'phpbb_version_revision' => $phpbb_version_revision,
! );
! }
!
! phpbb::$db->sql_multi_insert(TITANIA_AUTOMOD_QUEUE_TABLE, $sql_ary);
!
! trigger_back(sprintf(phpbb::$user->lang['REVISIONS_ADDED_TO_QUEUE'], sizeof($revisions)));
! }
! }
!
! if (!function_exists('pva_generate_phpbb_version_select'))
! {
! function pva_generate_phpbb_version_select()
! {
! $versions = titania::$cache->get_phpbb_versions();
!
! $select = '<option value="0" selected="selected">-----</option>';
!
! foreach ($versions as $version => $name)
! {
! $select .= '<option value="' . $version . '">' . $name . '</option>';
! }
!
! return $select;
! }
! }
Modified: branches/stable/titania/includes/manage_tools/reindex.php
==============================================================================
*** branches/stable/titania/includes/manage_tools/reindex.php (original)
--- branches/stable/titania/includes/manage_tools/reindex.php Sat Nov 20 18:23:22 2010
***************
*** 1,91 ****
! <?php
! /**
! *
! * @package Titania
! * @version $Id$
! * @copyright (c) 2008 phpBB Customisation Database Team
! * @license http://opensource.org/licenses/gpl-license.php GNU Public License
! *
! */
!
! if (!defined('IN_PHPBB'))
! {
! exit;
! }
!
! class reindex
! {
! function display_options()
! {
! return 'REINDEX';
! }
!
! function run_tool()
! {
! $section = request_var('section', 0);
! $start = request_var('start', 0);
! $limit = (titania::$config->search_backend == 'solr') ? 1000 : 100;
! $total = 0;
!
! $sync = new titania_sync;
!
! switch ($section)
! {
! case 0 :
! titania_search::truncate();
!
! $display_message = 'Truncating Search';
! break;
!
! case 1 :
! $sql = 'SELECT COUNT(contrib_id) AS cnt FROM ' . TITANIA_CONTRIBS_TABLE;
! phpbb::$db->sql_query($sql);
! $total = phpbb::$db->sql_fetchfield('cnt');
! phpbb::$db->sql_freeresult();
!
! $sync->contribs('index', false, $start, $limit);
!
! $display_message = 'Indexing Contributions';
! break;
!
! case 2 :
! $sql = 'SELECT COUNT(post_id) AS cnt FROM ' . TITANIA_POSTS_TABLE;
! phpbb::$db->sql_query($sql);
! $total = phpbb::$db->sql_fetchfield('cnt');
! phpbb::$db->sql_freeresult();
!
! $sync->posts('index', $start, $limit);
!
! $display_message = 'Indexing Posts';
! break;
!
! case 3 :
! $sql = 'SELECT COUNT(faq_id) AS cnt FROM ' . TITANIA_CONTRIB_FAQ_TABLE;
! phpbb::$db->sql_query($sql);
! $total = phpbb::$db->sql_fetchfield('cnt');
! phpbb::$db->sql_freeresult();
!
! $sync->faqs('index', $start, $limit);
!
! $display_message = 'Indexing FAQ';
! break;
!
! case 4 :
! trigger_back('Done!');
! break;
! }
!
! if (($start + $limit) >= $total)
! {
! // Move to the next step
! meta_refresh(0, titania_url::build_url('manage/administration', array('t' => 'reindex', 'section' => ($section + 1), 'submit' => 1, 'hash' => generate_link_hash('manage'))));
! }
! else
! {
! // Move to the next step
! meta_refresh(0, titania_url::build_url('manage/administration', array('t' => 'reindex', 'section' => $section, 'start' => ($start + $limit), 'submit' => 1, 'hash' => generate_link_hash('manage'))));
! }
!
! trigger_error($display_message . ' - section ' . $section . ' of 3 - ' . ((($start + $limit) < $total) ? 'part ' . ($start + $limit) . ' of ' . $total : 'Done'));
! }
}
\ No newline at end of file
--- 1,91 ----
! <?php
! /**
! *
! * @package Titania
! * @version $Id$
! * @copyright (c) 2008 phpBB Customisation Database Team
! * @license http://opensource.org/licenses/gpl-license.php GNU Public License
! *
! */
!
! if (!defined('IN_PHPBB'))
! {
! exit;
! }
!
! class reindex
! {
! function display_options()
! {
! return 'REINDEX';
! }
!
! function run_tool()
! {
! $section = request_var('section', 0);
! $start = request_var('start', 0);
! $limit = (titania::$config->search_backend == 'solr') ? 1000 : 100;
! $total = 0;
!
! $sync = new titania_sync;
!
! switch ($section)
! {
! case 0 :
! titania_search::truncate();
!
! $display_message = 'Truncating Search';
! break;
!
! case 1 :
! $sql = 'SELECT COUNT(contrib_id) AS cnt FROM ' . TITANIA_CONTRIBS_TABLE;
! phpbb::$db->sql_query($sql);
! $total = phpbb::$db->sql_fetchfield('cnt');
! phpbb::$db->sql_freeresult();
!
! $sync->contribs('index', false, $start, $limit);
!
! $display_message = 'Indexing Contributions';
! break;
!
! case 2 :
! $sql = 'SELECT COUNT(post_id) AS cnt FROM ' . TITANIA_POSTS_TABLE;
! phpbb::$db->sql_query($sql);
! $total = phpbb::$db->sql_fetchfield('cnt');
! phpbb::$db->sql_freeresult();
!
! $sync->posts('index', $start, $limit);
!
! $display_message = 'Indexing Posts';
! break;
!
! case 3 :
! $sql = 'SELECT COUNT(faq_id) AS cnt FROM ' . TITANIA_CONTRIB_FAQ_TABLE;
! phpbb::$db->sql_query($sql);
! $total = phpbb::$db->sql_fetchfield('cnt');
! phpbb::$db->sql_freeresult();
!
! $sync->faqs('index', $start, $limit);
!
! $display_message = 'Indexing FAQ';
! break;
!
! case 4 :
! trigger_back('Done!');
! break;
! }
!
! if (($start + $limit) >= $total)
! {
! // Move to the next step
! meta_refresh(0, titania_url::build_url('manage/administration', array('t' => 'reindex', 'section' => ($section + 1), 'submit' => 1, 'hash' => generate_link_hash('manage'))));
! }
! else
! {
! // Move to the next step
! meta_refresh(0, titania_url::build_url('manage/administration', array('t' => 'reindex', 'section' => $section, 'start' => ($start + $limit), 'submit' => 1, 'hash' => generate_link_hash('manage'))));
! }
!
! trigger_error($display_message . ' - section ' . $section . ' of 3 - ' . ((($start + $limit) < $total) ? 'part ' . ($start + $limit) . ' of ' . $total : 'Done'));
! }
}
\ No newline at end of file
Modified: branches/stable/titania/includes/manage_tools/update_release_topics.php
==============================================================================
*** branches/stable/titania/includes/manage_tools/update_release_topics.php (original)
--- branches/stable/titania/includes/manage_tools/update_release_topics.php Sat Nov 20 18:23:22 2010
***************
*** 1,142 ****
! <?php
! /**
! *
! * @version $Id: update_release_topics.php 321 2010-03-06 06:27:41Z erikfrerejean $
! * @copyright (c) 2009 phpBB Group
! * @license http://opensource.org/licenses/gpl-license.php GNU Public License
! *
! */
!
! /**
! * @ignore
! */
! if (!defined('IN_PHPBB'))
! {
! exit;
! }
!
! class update_release_topics
! {
! /**
! * Tool overview page
! */
! function display_options()
! {
! return 'UPDATE_RELEASE_TOPICS';
! }
!
! /**
! * Run the tool
! */
! function run_tool()
! {
! // Define some vars that we'll need
! $start = request_var('start', 0);
! $limit = 100;
!
! // Create topic if it does not exist?
! $create_topic = true;
!
! titania::_include('functions_posting', 'phpbb_posting');
! titania::add_lang('contributions');
!
! $types = array();
! foreach (titania_types::$types as $id => $class)
! {
! if ($class->forum_robot && $class->forum_database)
! {
! $types[] = $id;
! }
! }
!
! if (!sizeof($types))
! {
! trigger_back('UPDATE_RELEASE_TOPICS_COMPLETE');
! }
!
! $sql = 'SELECT COUNT(contrib_id) AS cnt FROM ' . TITANIA_CONTRIBS_TABLE . '
! WHERE ' . phpbb::$db->sql_in_set('contrib_status', array(TITANIA_CONTRIB_APPROVED, TITANIA_CONTRIB_DOWNLOAD_DISABLED)) . '
! AND ' . phpbb::$db->sql_in_set('contrib_type', $types);
! phpbb::$db->sql_query($sql);
! $total = phpbb::$db->sql_fetchfield('cnt');
! phpbb::$db->sql_freeresult();
!
! // Grab our batch
! $sql_ary = array(
! 'SELECT' => 'c.contrib_id, c.contrib_user_id, c.contrib_type, c.contrib_name, c.contrib_name_clean, c.contrib_desc, c.contrib_desc_uid, c.contrib_release_topic_id,
! t.topic_first_post_id,
! u.user_id, u.username, u.username_clean, u.user_colour',
!
! 'FROM' => array(
! TITANIA_CONTRIBS_TABLE => 'c',
! USERS_TABLE => 'u',
! ),
!
! 'LEFT_JOIN' => array(
! array(
! 'FROM' => array(TOPICS_TABLE => 't'),
! 'ON' => 't.topic_id = c.contrib_release_topic_id',
! ),
! ),
!
! 'GROUP_BY' => 'c.contrib_id',
!
! 'WHERE' => phpbb::$db->sql_in_set('c.contrib_status', array(TITANIA_CONTRIB_APPROVED, TITANIA_CONTRIB_DOWNLOAD_DISABLED)) . '
! AND u.user_id = c.contrib_user_id
! AND ' . phpbb::$db->sql_in_set('contrib_type', $types),
!
! 'ORDER_BY' => 'c.contrib_id DESC',
! );
!
! $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary);
! $result = phpbb::$db->sql_query_limit($sql, $limit, $start);
!
! while ($row = phpbb::$db->sql_fetchrow($result))
! {
! // Grab the revisions
! $revisions = array();
! $sql = 'SELECT r.revision_id, r.attachment_id, r.revision_version, a.real_filename, a.filesize
! FROM ' . TITANIA_REVISIONS_TABLE . ' r, ' . TITANIA_ATTACHMENTS_TABLE . ' a
! WHERE r.contrib_id = ' . $row['contrib_id'] . '
! AND r.revision_status = ' . TITANIA_REVISION_APPROVED . '
! AND a.attachment_id = r.attachment_id';
! $rev_result = phpbb::$db->sql_query($sql);
! while ($rev_row = phpbb::$db->sql_fetchrow($rev_result))
! {
! $revisions[$rev_row['revision_version']] = $rev_row;
! }
! phpbb::$db->sql_freeresult($rev_result);
!
! // Sort the revisions by their version, put the newest one in $revision
! uksort($revisions, 'reverse_version_compare');
!
! if (!sizeof($revisions))
! {
! continue;
! }
!
! $revision = array_shift($revisions);
!
! users_overlord::$users[$row['user_id']] = $row;
!
! $contrib = new titania_contribution();
! $contrib->__set_array($row);
! $contrib->download = $row;
!
! // Update the release topic
! $contrib->update_release_topic();
! }
!
! phpbb::$db->sql_freeresult($result);
!
! if (($start + $limit) >= $total)
! {
! trigger_back('UPDATE_RELEASE_TOPICS_COMPLETE');
! }
! else
! {
! meta_refresh(0, titania_url::build_url('manage/administration', array('t' => 'update_release_topics', 'start' => ($start + $limit), 'submit' => 1, 'hash' => generate_link_hash('manage'))));
! trigger_error(phpbb::$user->lang('UPDATE_RELEASE_TOPICS_PROGRESS', ($start + $limit), $total));
! }
! }
}
\ No newline at end of file
--- 1,142 ----
! <?php
! /**
! *
! * @version $Id: update_release_topics.php 321 2010-03-06 06:27:41Z erikfrerejean $
! * @copyright (c) 2009 phpBB Group
! * @license http://opensource.org/licenses/gpl-license.php GNU Public License
! *
! */
!
! /**
! * @ignore
! */
! if (!defined('IN_PHPBB'))
! {
! exit;
! }
!
! class update_release_topics
! {
! /**
! * Tool overview page
! */
! function display_options()
! {
! return 'UPDATE_RELEASE_TOPICS';
! }
!
! /**
! * Run the tool
! */
! function run_tool()
! {
! // Define some vars that we'll need
! $start = request_var('start', 0);
! $limit = 100;
!
! // Create topic if it does not exist?
! $create_topic = true;
!
! titania::_include('functions_posting', 'phpbb_posting');
! titania::add_lang('contributions');
!
! $types = array();
! foreach (titania_types::$types as $id => $class)
! {
! if ($class->forum_robot && $class->forum_database)
! {
! $types[] = $id;
! }
! }
!
! if (!sizeof($types))
! {
! trigger_back('UPDATE_RELEASE_TOPICS_COMPLETE');
! }
!
! $sql = 'SELECT COUNT(contrib_id) AS cnt FROM ' . TITANIA_CONTRIBS_TABLE . '
! WHERE ' . phpbb::$db->sql_in_set('contrib_status', array(TITANIA_CONTRIB_APPROVED, TITANIA_CONTRIB_DOWNLOAD_DISABLED)) . '
! AND ' . phpbb::$db->sql_in_set('contrib_type', $types);
! phpbb::$db->sql_query($sql);
! $total = phpbb::$db->sql_fetchfield('cnt');
! phpbb::$db->sql_freeresult();
!
! // Grab our batch
! $sql_ary = array(
! 'SELECT' => 'c.contrib_id, c.contrib_user_id, c.contrib_type, c.contrib_name, c.contrib_name_clean, c.contrib_desc, c.contrib_desc_uid, c.contrib_release_topic_id,
! t.topic_first_post_id,
! u.user_id, u.username, u.username_clean, u.user_colour',
!
! 'FROM' => array(
! TITANIA_CONTRIBS_TABLE => 'c',
! USERS_TABLE => 'u',
! ),
!
! 'LEFT_JOIN' => array(
! array(
! 'FROM' => array(TOPICS_TABLE => 't'),
! 'ON' => 't.topic_id = c.contrib_release_topic_id',
! ),
! ),
!
! 'GROUP_BY' => 'c.contrib_id',
!
! 'WHERE' => phpbb::$db->sql_in_set('c.contrib_status', array(TITANIA_CONTRIB_APPROVED, TITANIA_CONTRIB_DOWNLOAD_DISABLED)) . '
! AND u.user_id = c.contrib_user_id
! AND ' . phpbb::$db->sql_in_set('contrib_type', $types),
!
! 'ORDER_BY' => 'c.contrib_id DESC',
! );
!
! $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary);
! $result = phpbb::$db->sql_query_limit($sql, $limit, $start);
!
! while ($row = phpbb::$db->sql_fetchrow($result))
! {
! // Grab the revisions
! $revisions = array();
! $sql = 'SELECT r.revision_id, r.attachment_id, r.revision_version, a.real_filename, a.filesize
! FROM ' . TITANIA_REVISIONS_TABLE . ' r, ' . TITANIA_ATTACHMENTS_TABLE . ' a
! WHERE r.contrib_id = ' . $row['contrib_id'] . '
! AND r.revision_status = ' . TITANIA_REVISION_APPROVED . '
! AND a.attachment_id = r.attachment_id';
! $rev_result = phpbb::$db->sql_query($sql);
! while ($rev_row = phpbb::$db->sql_fetchrow($rev_result))
! {
! $revisions[$rev_row['revision_version']] = $rev_row;
! }
! phpbb::$db->sql_freeresult($rev_result);
!
! // Sort the revisions by their version, put the newest one in $revision
! uksort($revisions, 'reverse_version_compare');
!
! if (!sizeof($revisions))
! {
! continue;
! }
!
! $revision = array_shift($revisions);
!
! users_overlord::$users[$row['user_id']] = $row;
!
! $contrib = new titania_contribution();
! $contrib->__set_array($row);
! $contrib->download = $row;
!
! // Update the release topic
! $contrib->update_release_topic();
! }
!
! phpbb::$db->sql_freeresult($result);
!
! if (($start + $limit) >= $total)
! {
! trigger_back('UPDATE_RELEASE_TOPICS_COMPLETE');
! }
! else
! {
! meta_refresh(0, titania_url::build_url('manage/administration', array('t' => 'update_release_topics', 'start' => ($start + $limit), 'submit' => 1, 'hash' => generate_link_hash('manage'))));
! trigger_error(phpbb::$user->lang('UPDATE_RELEASE_TOPICS_PROGRESS', ($start + $limit), $total));
! }
! }
}
\ No newline at end of file
Modified: branches/stable/titania/includes/objects/attention.php
==============================================================================
*** branches/stable/titania/includes/objects/attention.php (original)
--- branches/stable/titania/includes/objects/attention.php Sat Nov 20 18:23:22 2010
***************
*** 1,154 ****
! <?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 attention items
! * @package Titania
! */
! class titania_attention extends titania_database_object
! {
! /**
! * Database table to be used
! *
! * @var string
! */
! protected $sql_table = TITANIA_ATTENTION_TABLE;
!
! /**
! * Primary sql identifier
! *
! * @var string
! */
! protected $sql_id_field = 'attention_id';
!
! /**
! * Constructor class for the attention object
! */
! public function __construct()
! {
! // Configure object properties
! $this->object_config = array_merge($this->object_config, array(
! 'attention_id' => array('default' => 0),
! 'attention_type' => array('default' => 0), // attention type constants (reported, needs approval, etc)
! 'attention_object_type' => array('default' => 0),
! 'attention_object_id' => array('default' => 0),
! 'attention_poster_id' => array('default' => 0),
! 'attention_post_time' => array('default' => 0),
! 'attention_url' => array('default' => ''),
! 'attention_requester' => array('default' => (int) phpbb::$user->data['user_id']),
! 'attention_time' => array('default' => titania::$time),
! 'attention_close_time' => array('default' => 0),
! 'attention_close_user' => array('default' => 0),
! 'attention_title' => array('default' => ''),
! 'attention_description' => array('default' => ''),
! ));
! }
!
! public function submit()
! {
! $this->attention_url = titania_url::unbuild_url($this->attention_url);
!
! // Subscriptions
! if (!$this->attention_id)
! {
! $email_vars = array(
! 'NAME' => $this->attention_title,
! 'U_VIEW' => titania_url::build_url('manage/attention', array('type' => $this->attention_type, 'id' => $this->attention_object_id)),
! );
! titania_subscriptions::send_notifications(TITANIA_ATTENTION, 0, 'subscribe_notify.txt', $email_vars, $this->attention_poster_id);
! }
!
! parent::submit();
! }
!
! /**
! * Close the attention
! */
! public function close()
! {
! $this->attention_close_time = titania::$time;
! $this->attention_close_user = phpbb::$user->data['user_id'];
!
! $this->submit();
! }
!
! /**
! * Get the URL for the item needing attention
! *
! * @return string the built url
! */
! public function get_url()
! {
! $base = $append = false;
! titania_url::split_base_params($base, $append, $this->attention_url);
!
! return titania_url::build_url($base, $append);
! }
!
! /**
! * Assign the details for the attention object
! *
! * @param bool $return True to return the data, false to display it
! */
! public function assign_details($return = false)
! {
! $output = array(
! 'ATTENTION_ID' => $this->attention_id,
! 'ATTENTION_TYPE' => $this->attention_type,
! 'ATTENTION_TIME' => phpbb::$user->format_date($this->attention_time),
! 'ATTENTION_POST_TIME' => phpbb::$user->format_date($this->attention_post_time),
! 'ATTENTION_CLOSE_TIME' => ($this->attention_close_time) ? phpbb::$user->format_date($this->attention_close_time) : '',
! 'ATTENTION_TITLE' => $this->attention_title,
! 'ATTENTION_REASON' => $this->get_reason_string(),
! 'ATTENTION_DESCRIPTION' => $this->attention_description,
!
! 'U_VIEW_ATTENTION' => $this->get_url(),
! 'U_VIEW_DETAILS' => titania_url::append_url(titania_url::$current_page_url, array('a' => $this->attention_id)),
!
! 'S_CLOSED' => ($this->attention_close_time) ? true : false,
! 'S_UNAPPROVED' => ($this->attention_type == TITANIA_ATTENTION_UNAPPROVED) ? true : false,
! 'S_REPORTED' => ($this->attention_type == TITANIA_ATTENTION_REPORTED) ? true : false,
! );
!
! if ($return)
! {
! return $output;
! }
!
! phpbb::$template->assign_vars($output);
! }
!
! public function get_reason_string()
! {
! switch ((int) $this->attention_type)
! {
! case TITANIA_ATTENTION_REPORTED :
! return phpbb::$user->lang['REPORTED'];
! break;
!
! case TITANIA_ATTENTION_UNAPPROVED :
! return phpbb::$user->lang['UNAPPROVED'];
! break;
! }
! }
! }
--- 1,154 ----
! <?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 attention items
! * @package Titania
! */
! class titania_attention extends titania_database_object
! {
! /**
! * Database table to be used
! *
! * @var string
! */
! protected $sql_table = TITANIA_ATTENTION_TABLE;
!
! /**
! * Primary sql identifier
! *
! * @var string
! */
! protected $sql_id_field = 'attention_id';
!
! /**
! * Constructor class for the attention object
! */
! public function __construct()
! {
! // Configure object properties
! $this->object_config = array_merge($this->object_config, array(
! 'attention_id' => array('default' => 0),
! 'attention_type' => array('default' => 0), // attention type constants (reported, needs approval, etc)
! 'attention_object_type' => array('default' => 0),
! 'attention_object_id' => array('default' => 0),
! 'attention_poster_id' => array('default' => 0),
! 'attention_post_time' => array('default' => 0),
! 'attention_url' => array('default' => ''),
! 'attention_requester' => array('default' => (int) phpbb::$user->data['user_id']),
! 'attention_time' => array('default' => titania::$time),
! 'attention_close_time' => array('default' => 0),
! 'attention_close_user' => array('default' => 0),
! 'attention_title' => array('default' => ''),
! 'attention_description' => array('default' => ''),
! ));
! }
!
! public function submit()
! {
! $this->attention_url = titania_url::unbuild_url($this->attention_url);
!
! // Subscriptions
! if (!$this->attention_id)
! {
! $email_vars = array(
! 'NAME' => $this->attention_title,
! 'U_VIEW' => titania_url::build_url('manage/attention', array('type' => $this->attention_type, 'id' => $this->attention_object_id)),
! );
! titania_subscriptions::send_notifications(TITANIA_ATTENTION, 0, 'subscribe_notify.txt', $email_vars, $this->attention_poster_id);
! }
!
! parent::submit();
! }
!
! /**
! * Close the attention
! */
! public function close()
! {
! $this->attention_close_time = titania::$time;
! $this->attention_close_user = phpbb::$user->data['user_id'];
!
! $this->submit();
! }
!
! /**
! * Get the URL for the item needing attention
! *
! * @return string the built url
! */
! public function get_url()
! {
! $base = $append = false;
! titania_url::split_base_params($base, $append, $this->attention_url);
!
! return titania_url::build_url($base, $append);
! }
!
! /**
! * Assign the details for the attention object
! *
! * @param bool $return True to return the data, false to display it
! */
! public function assign_details($return = false)
! {
! $output = array(
! 'ATTENTION_ID' => $this->attention_id,
! 'ATTENTION_TYPE' => $this->attention_type,
! 'ATTENTION_TIME' => phpbb::$user->format_date($this->attention_time),
! 'ATTENTION_POST_TIME' => phpbb::$user->format_date($this->attention_post_time),
! 'ATTENTION_CLOSE_TIME' => ($this->attention_close_time) ? phpbb::$user->format_date($this->attention_close_time) : '',
! 'ATTENTION_TITLE' => $this->attention_title,
! 'ATTENTION_REASON' => $this->get_reason_string(),
! 'ATTENTION_DESCRIPTION' => $this->attention_description,
!
! 'U_VIEW_ATTENTION' => $this->get_url(),
! 'U_VIEW_DETAILS' => titania_url::append_url(titania_url::$current_page_url, array('a' => $this->attention_id)),
!
! 'S_CLOSED' => ($this->attention_close_time) ? true : false,
! 'S_UNAPPROVED' => ($this->attention_type == TITANIA_ATTENTION_UNAPPROVED) ? true : false,
! 'S_REPORTED' => ($this->attention_type == TITANIA_ATTENTION_REPORTED) ? true : false,
! );
!
! if ($return)
! {
! return $output;
! }
!
! phpbb::$template->assign_vars($output);
! }
!
! public function get_reason_string()
! {
! switch ((int) $this->attention_type)
! {
! case TITANIA_ATTENTION_REPORTED :
! return phpbb::$user->lang['REPORTED'];
! break;
!
! case TITANIA_ATTENTION_UNAPPROVED :
! return phpbb::$user->lang['UNAPPROVED'];
! break;
! }
! }
! }
More information about the customisationdb-commits
mailing list