[pLog-svn] r1953 - in plog/branches/plog-1.0.1: . templates/wizard
francesc at devel.plogworld.net
francesc at devel.plogworld.net
Fri May 6 15:44:26 GMT 2005
Author: francesc
Date: 2005-05-06 15:44:26 +0000 (Fri, 06 May 2005)
New Revision: 1953
Modified:
plog/branches/plog-1.0.1/templates/wizard/header.template
plog/branches/plog-1.0.1/wizard.php
Log:
Fixed a bug preventing post migration by steps from 0.3 to 1.0 to work on any browser but Safari. And some minor changes to improve the process.
Modified: plog/branches/plog-1.0.1/templates/wizard/header.template
===================================================================
--- plog/branches/plog-1.0.1/templates/wizard/header.template 2005-05-06 12:36:45 UTC (rev 1952)
+++ plog/branches/plog-1.0.1/templates/wizard/header.template 2005-05-06 15:44:26 UTC (rev 1953)
@@ -7,7 +7,7 @@
<link rel="stylesheet" href="styles/admin.css" type="text/css" media="screen" />
<link rel="stylesheet" href="styles/wizard.css" type="text/css" media="screen" />
</head>
-<body>
+<body {if $multipleSteps}onload="document.update2.submit();"{/if}>
<div id="container" >
@@ -28,21 +28,21 @@
<div id="menu">
{if $mode=="install"}
<ul>
- <li {if $step==1}class="currentStep"{/if}>1 Welcome</li>
- <li {if $step==2}class="currentStep"{/if}>» 2 Confirm</li>
- <li {if $step==3}class="currentStep"{/if}>» 3 Database</li>
- <li {if $step==4}class="currentStep"{/if}>» 4 User Creation</li>
- <li {if $step==5}class="currentStep"{/if}>» 5 Blog Configuration</li>
- <li {if $step==6}class="currentStep"{/if}>» 6 Done!</li>
- </ul>
- {else}
- <ul>
- <li {if $step==1}class="currentStep"{/if}>1 Update</li>
- <li {if $step==2}class="currentStep"{/if}>» 2 Database Changes</li>
- <li {if $step==3}class="currentStep"{/if}>» 3 Data changes</li>
- <li {if $step==4}class="currentStep"{/if}>» 4 Done!</li>
- </ul>
- {/if}
+ <li {if $step==1}class="currentStep"{/if}>1 Welcome</li>
+ <li {if $step==2}class="currentStep"{/if}>» 2 Confirm</li>
+ <li {if $step==3}class="currentStep"{/if}>» 3 Database</li>
+ <li {if $step==4}class="currentStep"{/if}>» 4 User Creation</li>
+ <li {if $step==5}class="currentStep"{/if}>» 5 Blog Configuration</li>
+ <li {if $step==6}class="currentStep"{/if}>» 6 Done!</li>
+ </ul>
+ {else}
+ <ul>
+ <li {if $step==1}class="currentStep"{/if}>1 Update</li>
+ <li {if $step==2}class="currentStep"{/if}>» 2 Database Changes</li>
+ <li {if $step==3}class="currentStep"{/if}>» 3 Data changes</li>
+ <li {if $step==4}class="currentStep"{/if}>» 4 Done!</li>
+ </ul>
+ {/if}
<br style="clear:both;"/>
</div>
@@ -53,5 +53,4 @@
<h2>{$title}</h2>
</div>
<br style="clear:both;" />
- </div>
-
\ No newline at end of file
+ </div>
Modified: plog/branches/plog-1.0.1/wizard.php
===================================================================
--- plog/branches/plog-1.0.1/wizard.php 2005-05-06 12:36:45 UTC (rev 1952)
+++ plog/branches/plog-1.0.1/wizard.php 2005-05-06 15:44:26 UTC (rev 1953)
@@ -3,24 +3,26 @@
if (!defined( "PLOG_CLASS_PATH" )) {
define( "PLOG_CLASS_PATH", dirname(__FILE__)."/");
}
-
- //
- // enable this for debugging purposes
- //
- define( "DB_WIZARD_DEBUG", false );
-
- //
- // in case you're having problems with time outs while upgrading (probably too
- // many records) lower this figure
- //
- define( "WIZARD_MAX_RECORDS_PER_STEP", 500 );
-
- //
- // threshold that defines up to how many records we should not divide the
- // transformations in more than one step
- //
- define( "WIZARD_MAX_RECORDS_THRESHOLD", 1000 );
+ set_time_limit (5 * 3600);
+
+ //
+ // enable this for debugging purposes
+ //
+ define( "DB_WIZARD_DEBUG", false );
+
+ //
+ // in case you're having problems with time outs while upgrading (probably too
+ // many records) lower this figure
+ //
+ define( "WIZARD_MAX_RECORDS_PER_STEP", 50 );
+
+ //
+ // threshold that defines up to how many records we should not divide the
+ // transformations in more than one step
+ //
+ define( "WIZARD_MAX_RECORDS_THRESHOLD", 100 );
+
// many hosts don't have this enabled and we, for the time being, need it...
ini_set("arg_seperator.output", "&");
@@ -32,7 +34,7 @@
include_once( PLOG_CLASS_PATH."class/database/adodb/adodb.inc.php" );
include_once( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
include_once( PLOG_CLASS_PATH."class/data/validator/emailvalidator.class.php" );
- include_once( PLOG_CLASS_PATH."class/data/validator/passwordvalidator.class.php" );
+ include_once( PLOG_CLASS_PATH."class/data/validator/passwordvalidator.class.php" );
include_once( PLOG_CLASS_PATH."class/dao/users.class.php" );
include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
include_once( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );
@@ -64,9 +66,9 @@
$_actionMap["Update2"] = "UpdateStepTwo";
$_actionMap["Update3"] = "UpdateStepThree";
$_actionMap["Update4"] = "UpdateStepFour";
-
+
$Tables[0]["desc"] = "Articles";
$Tables[0]["code"] = "CREATE TABLE {dbprefix}articles (
id int(10) unsigned NOT NULL auto_increment,
@@ -130,7 +132,7 @@
KEY article_id (article_id),
FULLTEXT KEY normalized_fields (normalized_text,normalized_topic),
FULLTEXT KEY normalized_text (normalized_text),
- FULLTEXT KEY normalized_topic (normalized_topic)
+ FULLTEXT KEY normalized_topic (normalized_topic)
) TYPE=MyISAM;";
$Tables[3]["desc"] = "Notifications";
@@ -142,7 +144,7 @@
PRIMARY KEY (id),
KEY article_id (article_id),
KEY user_id (user_id),
- KEY blog_id (blog_id)
+ KEY blog_id (blog_id)
) TYPE=MyISAM;";
$Tables[4]["desc"] = "Blogs";
@@ -350,7 +352,7 @@
KEY owner_id_mangled_name (owner_id, mangled_name),
FULLTEXT KEY normalized_name (normalized_name),
FULLTEXT KEY normalized_description (normalized_description),
- FULLTEXT KEY normalized_fields (normalized_name, normalized_description)
+ FULLTEXT KEY normalized_fields (normalized_name, normalized_description)
) TYPE=MyISAM;";
$Tables[19]["desc"] = "Bayesian Filter data table";
@@ -360,7 +362,7 @@
total_spam int(10) unsigned default NULL,
total_nonspam int(10) unsigned default NULL,
PRIMARY KEY (id),
- KEY blog_id (blog_id)
+ KEY blog_id (blog_id)
) TYPE=MyISAM;";
$Tables[20]["desc"] = "Bayesian Filter Information";
@@ -412,7 +414,7 @@
KEY field_id (field_id),
KEY blog_id_article_id (blog_id, article_id)
) TYPE=MyISAM;";
-
+
$Tables[24]["desc"] = "Text of the articles";
$Tables[24]["code"] = "CREATE TABLE {dbprefix}articles_text (
id int(10) NOT NULL auto_increment,
@@ -421,7 +423,7 @@
topic TEXT NOT NULL DEFAULT '',
normalized_text TEXT NOT NULL DEFAULT '',
normalized_topic TEXT NOT NULL DEFAULT '',
- mangled_topic text NOT NULL,
+ mangled_topic text NOT NULL,
PRIMARY KEY (id),
KEY article_id (article_id),
FULLTEXT KEY normalized_text (normalized_text),
@@ -434,94 +436,94 @@
// ---
// changes needed to update from 0.3 to 1.0
$Changes["Articles"] = Array( "ALTER TABLE {dbprefix}articles CHANGE status old_status ENUM('published', 'draft', 'deleted' )",
- "ALTER TABLE {dbprefix}articles ADD COLUMN status INTEGER(5) NOT NULL DEFAULT 1",
- "ALTER TABLE {dbprefix}articles ADD COLUMN slug VARCHAR(255) NOT NULL DEFAULT ''",
- "ALTER TABLE {dbprefix}articles ADD KEY num_reads(num_reads)",
- "ALTER TABLE {dbprefix}articles ADD KEY category_id(category_id)",
- "ALTER TABLE {dbprefix}articles ADD KEY blog_id(blog_id)",
- "ALTER TABLE {dbprefix}articles ADD KEY slug(slug)",
- "ALTER TABLE {dbprefix}articles ADD KEY user_id(user_id)",
- "ALTER TABLE {dbprefix}articles ADD KEY blog_id_slug(blog_id,slug)",
- "ALTER TABLE {dbprefix}articles ADD KEY blog_id_slug_category_id(blog_id,slug,category_id)");
-
- $Changes["Article Categories"] = Array( "ALTER TABLE {dbprefix}articles_categories ADD COLUMN parent_id INTEGER(10) NOT NULL DEFAULT 0",
- "ALTER TABLE {dbprefix}articles_categories ADD COLUMN mangled_name VARCHAR(255) NOT NULL DEFAULT ''",
- "ALTER TABLE {dbprefix}articles_categories ADD COLUMN properties TEXT NOT NULL DEFAULT ''",
- "ALTER TABLE {dbprefix}articles_categories ADD COLUMN description TEXT NOT NULL DEFAULT ''",
- "ALTER TABLE {dbprefix}articles_categories ADD KEY parent_id(parent_id)",
- "ALTER TABLE {dbprefix}articles_categories ADD KEY blog_id(blog_id)",
- "ALTER TABLE {dbprefix}articles_categories ADD KEY mangled_name(mangled_name)");
-
-
- $Changes["User Comments"] = Array( "ALTER TABLE {dbprefix}articles_comments ADD COLUMN normalized_text TEXT NOT NULL DEFAULT ''",
- "ALTER TABLE {dbprefix}articles_comments ADD COLUMN normalized_topic TEXT NOT NULL DEFAULT ''",
- "ALTER TABLE {dbprefix}articles_comments ADD FULLTEXT normalized_text(normalized_text)",
- "ALTER TABLE {dbprefix}articles_comments ADD FULLTEXT normalized_topic(normalized_topic)",
- "ALTER TABLE {dbprefix}articles_comments ADD FULLTEXT normalized_text_topic(normalized_topic,normalized_text)",
- "ALTER TABLE {dbprefix}articles_comments ADD KEY parent_id(parent_id)",
- "ALTER TABLE {dbprefix}articles_comments ADD KEY article_id(article_id)");
-
- $Changes["Notifications"] = Array( "ALTER TABLE {dbprefix}articles_notifications ADD KEY article_id(article_id)",
- "ALTER TABLE {dbprefix}articles_notifications ADD KEY user_id(user_id)",
- "ALTER TABLE {dbprefix}articles_notifications ADD KEY blog_id(blog_id)");
-
- $Changes["Blogs"] = Array( "ALTER TABLE {dbprefix}blogs ADD COLUMN mangled_blog VARCHAR(50) NOT NULL DEFAULT ''",
- "ALTER TABLE {dbprefix}blogs ADD COLUMN properties TEXT NOT NULL DEFAULT ''",
- "ALTER TABLE {dbprefix}blogs ADD COLUMN status INTEGER(4) NOT NULL DEFAULT '1'",
- "ALTER TABLE {dbprefix}blogs ADD COLUMN show_in_summary INTEGER(4) NOT NULL DEFAULT '1'",
- "ALTER TABLE {dbprefix}blogs ADD KEY owner_id(owner_id)",
- "ALTER TABLE {dbprefix}blogs ADD KEY mangled_blog(mangled_blog)");
-
- $Changes["Referrers"] = Array( "ALTER TABLE {dbprefix}referers ADD KEY article_id(article_id)",
- "ALTER TABLE {dbprefix}referers ADD KEY blog_id(blog_id)",
- "ALTER TABLE {dbprefix}referers ADD KEY blog_id_article_id (blog_id, article_id)");
-
- $Changes["Trackbacks"] = Array( "ALTER TABLE {dbprefix}trackbacks ADD KEY article_id(article_id)" );
-
- $Changes["Filtered Content"] = Array( "ALTER TABLE {dbprefix}filtered_content ADD KEY blog_id(blog_id)" );
-
- $Changes["Blocked hosts"] = Array( "ALTER TABLE {dbprefix}host_blocking_rules ADD KEY blog_id(blog_id)" );
-
- $Changes["Gallery Albums"] = Array( "ALTER TABLE {dbprefix}gallery_albums ADD COLUMN normalized_name VARCHAR(255) NOT NULL DEFAULT ''",
- "ALTER TABLE {dbprefix}gallery_albums ADD COLUMN normalized_description TEXT NOT NULL DEFAULT ''",
- "ALTER TABLE {dbprefix}gallery_albums ADD COLUMN mangled_name VARCHAR(255) NOT NULL DEFAULT ''",
- "ALTER TABLE {dbprefix}gallery_albums ADD FULLTEXT normalized_name(normalized_name)",
- "ALTER TABLE {dbprefix}gallery_albums ADD FULLTEXT normalized_description(normalized_description)",
- "ALTER TABLE {dbprefix}gallery_albums ADD FULLTEXT normalized_name_description(normalized_name, normalized_description)",
- "ALTER TABLE {dbprefix}gallery_albums ADD KEY parent_id(parent_id)",
- "ALTER TABLE {dbprefix}gallery_albums ADD KEY owner_id(owner_id)",
- "ALTER TABLE {dbprefix}gallery_albums ADD KEY mangled_name(mangled_name)",
- "ALTER TABLE {dbprefix}gallery_albums ADD KEY owner_id_mangled_name(owner_id,mangled_name)");
-
- $Changes["Gallery Resources"] = Array( "ALTER TABLE {dbprefix}gallery_resources ADD COLUMN normalized_description TEXT NOT NULL DEFAULT ''",
- "ALTER TABLE {dbprefix}gallery_resources ADD FULLTEXT normalized_description(normalized_description)",
- "ALTER TABLE {dbprefix}gallery_resources ADD KEY album_id(album_id)",
- "ALTER TABLE {dbprefix}gallery_resources ADD KEY owner_id(owner_id)",
- "ALTER TABLE {dbprefix}gallery_resources ADD KEY file_name(file_name)",
- "ALTER TABLE {dbprefix}gallery_resources ADD KEY album_id_owner_id(album_id,owner_id)",
- "ALTER TABLE {dbprefix}gallery_resources ADD KEY resource_type(resource_type)");
-
-
- $Changes["Links"] = Array( "ALTER TABLE {dbprefix}mylinks ADD COLUMN properties TEXT NOT NULL DEFAULT ''",
- "ALTER TABLE {dbprefix}mylinks ADD COLUMN date TIMESTAMP(14)",
- "ALTER TABLE {dbprefix}mylinks ADD COLUMN rss_feed VARCHAR(255) NOT NULL DEFAULT ''",
- "ALTER TABLE {dbprefix}mylinks ADD KEY blog_id(blog_id)",
- "ALTER TABLE {dbprefix}mylinks ADD KEY category_id(category_id)");
-
- $Changes["Links Categories"] = Array( "ALTER TABLE {dbprefix}mylinks_categories ADD COLUMN properties TEXT NOT NULL DEFAULT ''",
- "ALTER TABLE {dbprefix}mylinks_categories ADD KEY blog_id(blog_id)");
-
- $Changes["Users"] = Array( "ALTER TABLE {dbprefix}users ADD COLUMN full_name VARCHAR(255) NOT NULL DEFAULT ''",
- "ALTER TABLE {dbprefix}users ADD COLUMN properties TEXT NOT NULL DEFAULT ''",
- "ALTER TABLE {dbprefix}users ADD COLUMN resource_picture_id INTEGER(10) NOT NULL DEFAULT 0",
- "ALTER TABLE {dbprefix}users ADD COLUMN status INTEGER(4) NOT NULL DEFAULT 1" );
-
- $Changes["Bayesian Filter data table"] = Array( "ALTER TABLE {dbprefix}bayesian_filter_info ADD KEY blog_id(blog_id)" );
-
- $Changes["Permissions"] = Array( "ALTER TABLE {dbprefix}users_permissions ADD KEY user_id(user_id)",
- "ALTER TABLE {dbprefix}users_permissions ADD KEY blog_id(blog_id)",
- "ALTER TABLE {dbprefix}users_permissions ADD KEY user_id_permission_id(user_id,permission_id)");
-
+ "ALTER TABLE {dbprefix}articles ADD COLUMN status INTEGER(5) NOT NULL DEFAULT 1",
+ "ALTER TABLE {dbprefix}articles ADD COLUMN slug VARCHAR(255) NOT NULL DEFAULT ''",
+ "ALTER TABLE {dbprefix}articles ADD KEY num_reads(num_reads)",
+ "ALTER TABLE {dbprefix}articles ADD KEY category_id(category_id)",
+ "ALTER TABLE {dbprefix}articles ADD KEY blog_id(blog_id)",
+ "ALTER TABLE {dbprefix}articles ADD KEY slug(slug)",
+ "ALTER TABLE {dbprefix}articles ADD KEY user_id(user_id)",
+ "ALTER TABLE {dbprefix}articles ADD KEY blog_id_slug(blog_id,slug)",
+ "ALTER TABLE {dbprefix}articles ADD KEY blog_id_slug_category_id(blog_id,slug,category_id)");
+
+ $Changes["Article Categories"] = Array( "ALTER TABLE {dbprefix}articles_categories ADD COLUMN parent_id INTEGER(10) NOT NULL DEFAULT 0",
+ "ALTER TABLE {dbprefix}articles_categories ADD COLUMN mangled_name VARCHAR(255) NOT NULL DEFAULT ''",
+ "ALTER TABLE {dbprefix}articles_categories ADD COLUMN properties TEXT NOT NULL DEFAULT ''",
+ "ALTER TABLE {dbprefix}articles_categories ADD COLUMN description TEXT NOT NULL DEFAULT ''",
+ "ALTER TABLE {dbprefix}articles_categories ADD KEY parent_id(parent_id)",
+ "ALTER TABLE {dbprefix}articles_categories ADD KEY blog_id(blog_id)",
+ "ALTER TABLE {dbprefix}articles_categories ADD KEY mangled_name(mangled_name)");
+
+
+ $Changes["User Comments"] = Array( "ALTER TABLE {dbprefix}articles_comments ADD COLUMN normalized_text TEXT NOT NULL DEFAULT ''",
+ "ALTER TABLE {dbprefix}articles_comments ADD COLUMN normalized_topic TEXT NOT NULL DEFAULT ''",
+ "ALTER TABLE {dbprefix}articles_comments ADD FULLTEXT normalized_text(normalized_text)",
+ "ALTER TABLE {dbprefix}articles_comments ADD FULLTEXT normalized_topic(normalized_topic)",
+ "ALTER TABLE {dbprefix}articles_comments ADD FULLTEXT normalized_text_topic(normalized_topic,normalized_text)",
+ "ALTER TABLE {dbprefix}articles_comments ADD KEY parent_id(parent_id)",
+ "ALTER TABLE {dbprefix}articles_comments ADD KEY article_id(article_id)");
+
+ $Changes["Notifications"] = Array( "ALTER TABLE {dbprefix}articles_notifications ADD KEY article_id(article_id)",
+ "ALTER TABLE {dbprefix}articles_notifications ADD KEY user_id(user_id)",
+ "ALTER TABLE {dbprefix}articles_notifications ADD KEY blog_id(blog_id)");
+
+ $Changes["Blogs"] = Array( "ALTER TABLE {dbprefix}blogs ADD COLUMN mangled_blog VARCHAR(50) NOT NULL DEFAULT ''",
+ "ALTER TABLE {dbprefix}blogs ADD COLUMN properties TEXT NOT NULL DEFAULT ''",
+ "ALTER TABLE {dbprefix}blogs ADD COLUMN status INTEGER(4) NOT NULL DEFAULT '1'",
+ "ALTER TABLE {dbprefix}blogs ADD COLUMN show_in_summary INTEGER(4) NOT NULL DEFAULT '1'",
+ "ALTER TABLE {dbprefix}blogs ADD KEY owner_id(owner_id)",
+ "ALTER TABLE {dbprefix}blogs ADD KEY mangled_blog(mangled_blog)");
+
+ $Changes["Referrers"] = Array( "ALTER TABLE {dbprefix}referers ADD KEY article_id(article_id)",
+ "ALTER TABLE {dbprefix}referers ADD KEY blog_id(blog_id)",
+ "ALTER TABLE {dbprefix}referers ADD KEY blog_id_article_id (blog_id, article_id)");
+
+ $Changes["Trackbacks"] = Array( "ALTER TABLE {dbprefix}trackbacks ADD KEY article_id(article_id)" );
+
+ $Changes["Filtered Content"] = Array( "ALTER TABLE {dbprefix}filtered_content ADD KEY blog_id(blog_id)" );
+
+ $Changes["Blocked hosts"] = Array( "ALTER TABLE {dbprefix}host_blocking_rules ADD KEY blog_id(blog_id)" );
+
+ $Changes["Gallery Albums"] = Array( "ALTER TABLE {dbprefix}gallery_albums ADD COLUMN normalized_name VARCHAR(255) NOT NULL DEFAULT ''",
+ "ALTER TABLE {dbprefix}gallery_albums ADD COLUMN normalized_description TEXT NOT NULL DEFAULT ''",
+ "ALTER TABLE {dbprefix}gallery_albums ADD COLUMN mangled_name VARCHAR(255) NOT NULL DEFAULT ''",
+ "ALTER TABLE {dbprefix}gallery_albums ADD FULLTEXT normalized_name(normalized_name)",
+ "ALTER TABLE {dbprefix}gallery_albums ADD FULLTEXT normalized_description(normalized_description)",
+ "ALTER TABLE {dbprefix}gallery_albums ADD FULLTEXT normalized_name_description(normalized_name, normalized_description)",
+ "ALTER TABLE {dbprefix}gallery_albums ADD KEY parent_id(parent_id)",
+ "ALTER TABLE {dbprefix}gallery_albums ADD KEY owner_id(owner_id)",
+ "ALTER TABLE {dbprefix}gallery_albums ADD KEY mangled_name(mangled_name)",
+ "ALTER TABLE {dbprefix}gallery_albums ADD KEY owner_id_mangled_name(owner_id,mangled_name)");
+
+ $Changes["Gallery Resources"] = Array( "ALTER TABLE {dbprefix}gallery_resources ADD COLUMN normalized_description TEXT NOT NULL DEFAULT ''",
+ "ALTER TABLE {dbprefix}gallery_resources ADD FULLTEXT normalized_description(normalized_description)",
+ "ALTER TABLE {dbprefix}gallery_resources ADD KEY album_id(album_id)",
+ "ALTER TABLE {dbprefix}gallery_resources ADD KEY owner_id(owner_id)",
+ "ALTER TABLE {dbprefix}gallery_resources ADD KEY file_name(file_name)",
+ "ALTER TABLE {dbprefix}gallery_resources ADD KEY album_id_owner_id(album_id,owner_id)",
+ "ALTER TABLE {dbprefix}gallery_resources ADD KEY resource_type(resource_type)");
+
+
+ $Changes["Links"] = Array( "ALTER TABLE {dbprefix}mylinks ADD COLUMN properties TEXT NOT NULL DEFAULT ''",
+ "ALTER TABLE {dbprefix}mylinks ADD COLUMN date TIMESTAMP(14)",
+ "ALTER TABLE {dbprefix}mylinks ADD COLUMN rss_feed VARCHAR(255) NOT NULL DEFAULT ''",
+ "ALTER TABLE {dbprefix}mylinks ADD KEY blog_id(blog_id)",
+ "ALTER TABLE {dbprefix}mylinks ADD KEY category_id(category_id)");
+
+ $Changes["Links Categories"] = Array( "ALTER TABLE {dbprefix}mylinks_categories ADD COLUMN properties TEXT NOT NULL DEFAULT ''",
+ "ALTER TABLE {dbprefix}mylinks_categories ADD KEY blog_id(blog_id)");
+
+ $Changes["Users"] = Array( "ALTER TABLE {dbprefix}users ADD COLUMN full_name VARCHAR(255) NOT NULL DEFAULT ''",
+ "ALTER TABLE {dbprefix}users ADD COLUMN properties TEXT NOT NULL DEFAULT ''",
+ "ALTER TABLE {dbprefix}users ADD COLUMN resource_picture_id INTEGER(10) NOT NULL DEFAULT 0",
+ "ALTER TABLE {dbprefix}users ADD COLUMN status INTEGER(4) NOT NULL DEFAULT 1" );
+
+ $Changes["Bayesian Filter data table"] = Array( "ALTER TABLE {dbprefix}bayesian_filter_info ADD KEY blog_id(blog_id)" );
+
+ $Changes["Permissions"] = Array( "ALTER TABLE {dbprefix}users_permissions ADD KEY user_id(user_id)",
+ "ALTER TABLE {dbprefix}users_permissions ADD KEY blog_id(blog_id)",
+ "ALTER TABLE {dbprefix}users_permissions ADD KEY user_id_permission_id(user_id,permission_id)");
+
// ---
// ---
@@ -643,9 +645,9 @@
$Inserts[112] = "INSERT INTO {dbprefix}config (config_key, config_value, value_type) VALUES('template_cache_lifetime', '-1', 3);";
- /**
- * Open a connection to the database
- */
+ /**
+ * Open a connection to the database
+ */
function connectDb( $ignoreError = false , $selectDatabase = true )
{
$config = new ConfigFileStorage();
@@ -656,7 +658,7 @@
} else {
$res = $db->Connect($config->getValue( "db_host" ), $config->getValue( "db_username" ), $config->getValue( "db_password" ));
}
-
+
if( DB_WIZARD_DEBUG )
$db->debug = true;
@@ -669,44 +671,44 @@
return $db;
}
-
- /**
- * Returns the database prefix
- */
- function getDbPrefix()
- {
+
+ /**
+ * Returns the database prefix
+ */
+ function getDbPrefix()
+ {
$config = new ConfigFileStorage();
- return $config->getValue( "db_prefix" );
- }
-
- /**
- * some useful little functions
- */
- class WizardTools extends Object
- {
- /**
- * returns true if plog has already been installed before or
- * false otherwise
- */
- function isNewInstallation()
- {
- $configFile = new ConfigFileStorage();
- // if plog hasn't been installed, this file will have empty settings
- if( $configFile->getValue( "db_host") == "" && $configFile->getValue( "db_username") == "" &&
- $configFile->getValue( "db_database") == "" && $configFile->getValue( "db_prefix" ) == "" &&
- $configFile->getValue( "db_password" ) == "" )
- $isNew = true;
- else
- $isNew = false;
-
- return( $isNew );
- }
- }
+ return $config->getValue( "db_prefix" );
+ }
/**
+ * some useful little functions
+ */
+ class WizardTools extends Object
+ {
+ /**
+ * returns true if plog has already been installed before or
+ * false otherwise
+ */
+ function isNewInstallation()
+ {
+ $configFile = new ConfigFileStorage();
+ // if plog hasn't been installed, this file will have empty settings
+ if( $configFile->getValue( "db_host") == "" && $configFile->getValue( "db_username") == "" &&
+ $configFile->getValue( "db_database") == "" && $configFile->getValue( "db_prefix" ) == "" &&
+ $configFile->getValue( "db_password" ) == "" )
+ $isNew = true;
+ else
+ $isNew = false;
+
+ return( $isNew );
+ }
+ }
+
+ /**
* Renders a template file.
*/
- class WizardView extends View
+ class WizardView extends View
{
var $_templateName;
@@ -742,7 +744,7 @@
/**
* Gets the information about the database from the user.
*/
- class WizardIntro extends Action
+ class WizardIntro extends Action
{
function WizardIntro( $actionInfo, $request )
{
@@ -753,15 +755,15 @@
{
// we can detect whether plog is already installed or not and direct users to the right
// place
- if( WizardTools::isNewInstallation())
+ if( WizardTools::isNewInstallation())
$this->_view = new WizardView( "intro" );
else {
Controller::setForwardAction( "Update1" );
return false;
}
-
+
$this->setCommonData();
- return true;
+ return true;
}
}
@@ -770,7 +772,7 @@
* Saves data to the configuration file
*
*/
- class WizardStepOne extends Action
+ class WizardStepOne extends Action
{
var $_dbServer;
@@ -778,11 +780,11 @@
var $_dbPassword;
var $_dbName;
var $_dbPrefix;
-
+
function WizardStepOne( $actionInfo, $request )
{
$this->Action( $actionInfo, $request );
-
+
// data validation
$this->registerFieldValidator( "dbServer", new StringValidator());
$this->registerFieldValidator( "dbUser", new StringValidator());
@@ -802,8 +804,8 @@
$this->_dbPassword = $this->_request->getValue( "dbPassword" );
$this->_dbName = $this->_request->getValue( "dbName" );
$this->_skipThis = $this->_request->getValue( "skipDbInfo" );
- $this->_dbPrefix = $this->_request->getValue( "dbPrefix", DEFAULT_DB_PREFIX );
-
+ $this->_dbPrefix = $this->_request->getValue( "dbPrefix", DEFAULT_DB_PREFIX );
+
// we should now save the data to the configuration file, just before
// we read it
$configFile = new ConfigFileStorage();
@@ -845,13 +847,13 @@
!$configFile->saveValue( "db_prefix", $this->_dbPrefix )) {
$errors = true;
}
-
+
if( $errors ) {
- $message = "Could not save values to the configuration file. Please make sure it is available and
- that has write permissions for the user under your web server is running.";
+ $message = "Could not save values to the configuration file. Please make sure it is available and
+ that has write permissions for the user under your web server is running.";
$this->_view = new WizardView( "intro" );
$this->_view->setErrorMessage( $message );
-
+
return( false );
}
else {
@@ -871,13 +873,13 @@
* Second step where we connect to the database and create the tables.
*
*/
- class WizardStepTwo extends Action
+ class WizardStepTwo extends Action
{
var $_db;
var $_database;
var $_createDatabase;
-
+
function setDbConfigValues( &$view )
{
$configFile = new ConfigFileStorage();
@@ -886,24 +888,24 @@
$view->setValue( "dbPassword", $configFile->getValue( "db_password" ));
$view->setValue( "dbServer", $configFile->getValue( "db_host" ));
$view->setValue( "dbName", $configFile->getValue( "db_database" ));
- $view->setValue( "dbPrefix", $configFile->getValue( "db_prefix" ));
+ $view->setValue( "dbPrefix", $configFile->getValue( "db_prefix" ));
return true;
}
-
+
function perform()
{
global $Tables;
global $Inserts;
-
+
$createDb = $this->_request->getValue( "createDatabase" );
// only check for errors in case the database table should already exist!
if( !$createDb ) {
$connectionEsablished = false;
- // Lets check the 'everything is fine' case first..
+ // Lets check the 'everything is fine' case first..
$this->_db = connectDb();
- if( $this->_db ) {
+ if( $this->_db ) {
$connectionEsablished = true;
} else {
$connectionEsablished = false;
@@ -915,7 +917,7 @@
// user did not check the appropriate box).
if ( !$connectionEsablished ) {
$this->_db = connectDb( true, false );
- if( !$this->_db ) {
+ if( !$this->_db ) {
$message = "There was an error connecting to the database. Please check your settings.";
}
}
@@ -923,7 +925,7 @@
if ( !$connectionEsablished ) {
$this->_view = new WizardView( "step1" );
$this->setDbConfigValues( $this->_view );
- $this->_view->setErrorMessage( $message );
+ $this->_view->setErrorMessage( $message );
$this->setCommonData( true );
return false;
}
@@ -1037,13 +1039,13 @@
if( $errors ) {
$this->_view = new WizardView( "step1" );
$this->setDbConfigValues( $this->_view );
- $message = "There was an error initializing some of the tables. Please make sure that the user chosen to connect to the database has enough permissions to add records to the database.<br/><br/>$message";
+ $message = "There was an error initializing some of the tables. Please make sure that the user chosen to connect to the database has enough permissions to add records to the database.<br/><br/>$message";
$this->_view->setErrorMessage( $message );
$this->setCommonData();
}
else {
$this->_view = new WizardView( "step2" );
- $this->_view->setValue( "message", $message );
+ $this->_view->setValue( "message", $message );
}
// Scan for locales
@@ -1056,7 +1058,7 @@
$res = $locales->addLocale( $newLocaleCode );
}
- return true;
+ return true;
}
}
@@ -1065,7 +1067,7 @@
* this action only shows some feedback
*
*/
- class WizardStepThree extends Action
+ class WizardStepThree extends Action
{
function perform()
{
@@ -1079,7 +1081,7 @@
* Create the first user in the database
*
*/
- class WizardStepFour extends Action
+ class WizardStepFour extends Action
{
var $_userName;
@@ -1087,15 +1089,15 @@
var $_confirmPassword;
var $_userEmail;
var $_userFullName;
-
+
function WizardStepFour( $actionInfo, $request )
{
$this->Action( $actionInfo, $request );
-
+
$this->registerFieldValidator( "userName", new StringValidator());
$this->registerFieldValidator( "userPassword", new PasswordValidator());
$this->registerFieldValidator( "userPasswordCheck", new PasswordValidator());
- $this->registerFieldValidator( "userEmail", new EmailValidator());
+ $this->registerFieldValidator( "userEmail", new EmailValidator());
$this->registerField( "userFullName" );
$view = new WizardView( "step3" );
$view->setErrorMessage( "Some data is missing or incorrect" );
@@ -1110,7 +1112,7 @@
$this->_confirmPassword = $this->_request->getValue( "userPasswordCheck" );
$this->_userEmail = $this->_request->getValue( "userEmail" );
$this->_userFullName = $this->_request->getValue( "userFullName" );
-
+
$db = connectDb();
if( !$db ) {
@@ -1119,7 +1121,7 @@
$this->setCommonData();
return false;
}
-
+
if( $this->_confirmPassword != $this->_userPassword ) {
$this->_view = new WizardView( "step3" );
$this->_form->setFieldValidationStatus( "userPasswordCheck", false );
@@ -1130,11 +1132,11 @@
$dbPrefix = Db::getPrefix();
$users = new Users();
- $user = new UserInfo( $this->_userName,
- $this->_userPassword,
- $this->_userEmail,
- "",
- $this->_userFullName);
+ $user = new UserInfo( $this->_userName,
+ $this->_userPassword,
+ $this->_userEmail,
+ "",
+ $this->_userFullName);
$userId = $users->addUser( $user );
if( !$userId ) {
$this->_view = new WizardView( "step3" );
@@ -1160,55 +1162,55 @@
}
- class WizardStepFive extends Action
+ class WizardStepFive extends Action
{
var $_blogName;
var $_ownerId;
- var $_blogProperties;
-
- function WizardStepFive( $actionInfo, $request )
- {
- $this->Action( $actionInfo, $request );
-
- $this->registerFieldValidator( "blogName", new StringValidator());
- $this->registerFieldValidator( "ownerid", new IntegerValidator());
- $this->registerFieldValidator( "blogTemplate", new StringValidator());
- $this->registerFieldValidator( "blogLocale", new StringValidator());
- $view = new WizardView( "step4" );
- $view->setErrorMessage( "Some data is missing or incorrect" );
+ var $_blogProperties;
+
+ function WizardStepFive( $actionInfo, $request )
+ {
+ $this->Action( $actionInfo, $request );
+
+ $this->registerFieldValidator( "blogName", new StringValidator());
+ $this->registerFieldValidator( "ownerid", new IntegerValidator());
+ $this->registerFieldValidator( "blogTemplate", new StringValidator());
+ $this->registerFieldValidator( "blogLocale", new StringValidator());
+ $view = new WizardView( "step4" );
+ $view->setErrorMessage( "Some data is missing or incorrect" );
$view->setValue( "siteLocales", Locales::getLocales());
$ts = new TemplateSets();
- $view->setValue( "siteTemplates", $ts->getGlobalTemplateSets());
- $this->setValidationErrorView( $view );
- }
+ $view->setValue( "siteTemplates", $ts->getGlobalTemplateSets());
+ $this->setValidationErrorView( $view );
+ }
function perform()
{
// retrieve the values from the view
$this->_blogName = $this->_request->getValue( "blogName" );
$this->_ownerId = $this->_request->getValue( "ownerid" );
- $this->_blogProperties = $this->_request->getValue( "properties" );
- $this->_blogTemplate = $this->_request->getValue( "blogTemplate" );
- $this->_blogLocale = $this->_request->getValue( "blogLocale" );
+ $this->_blogProperties = $this->_request->getValue( "properties" );
+ $this->_blogTemplate = $this->_request->getValue( "blogTemplate" );
+ $this->_blogLocale = $this->_request->getValue( "blogLocale" );
// configure the blog
$blogs = new Blogs();
$blog = new BlogInfo( $this->_blogName, $this->_ownerId, "", "" );
- $blog->setProperties( $this->_blogProperties );
- $blog->setStatus( BLOG_STATUS_ACTIVE );
- $blogSettings = $blog->getSettings();
- $blogSettings->setValue( "locale", $this->_blogLocale );
- $blogSettings->setValue( "template", $this->_blogTemplate );
- $blog->setSettings( $blogSettings );
-
- // and now save it to the database
+ $blog->setProperties( $this->_blogProperties );
+ $blog->setStatus( BLOG_STATUS_ACTIVE );
+ $blogSettings = $blog->getSettings();
+ $blogSettings->setValue( "locale", $this->_blogLocale );
+ $blogSettings->setValue( "template", $this->_blogTemplate );
+ $blog->setSettings( $blogSettings );
+
+ // and now save it to the database
$newblogId = $blogs->addBlog( $blog );
if( !$newblogId ) {
$this->_view = new WizardView( "step4" );
$this->_view->setValue( "siteLocales", Locales::getLocales());
$ts = new TemplateSets();
- $this->_view->setValue( "siteTemplates", $ts->getGlobalTemplateSets());
+ $this->_view->setValue( "siteTemplates", $ts->getGlobalTemplateSets());
$this->_view->setErrorMessage( "There was an error creating the new blog" );
$this->setCommonData( true );
return false;
@@ -1239,7 +1241,7 @@
$config->saveValue( "default_locale", $this->_blogLocale );
// and finally, the default template
$config->saveValue( "default_template", $this->_blogTemplate );
-
+
//
// detect wether we have GD available and set the blog to use it
//
@@ -1268,86 +1270,86 @@
//
// The following classes take care of updating the database to the last release
- //
- // Things that need to be done when going from 0.3.x to 1.0:
- //
- // - add the new tables:
- // plog_article_categories_link
- // plog_custom_fields_definition
- // plog_custom_fields_values
- //
- // - make modifications to some of the old tables:
- // plog_articles
- // normalized_text: TEXT
- // normalized_topic: TEXT
- // mangled_topic: TEXT
- // category_id: DROP
- // FULLTEXT(normalized_text)
- // FULLTEXT(normalized_topic)
- // FULLTEXT(normalized_text, normalized_topic)
- // plog_articles_categories
- // parent_id: INTEGER
- // mangled_name: TEXT
- // properties: TEXT
- // plog_articles_comments
- // normalized_text: TEXT
- // normalized_topic: TEXT
- // FULLTEXT(normalized_text)
- // FULLTEXT(normalized_topic)
- // FULLTEXT(normalized_text, normalized_topic)
- // plog_blogs
- // mangled_blog: TEXT
- // properties: TEXT
- // plog_gallery_albums
- // normalized_name: VARCHAR
- // normalized_description: TEXT
- // mangled_name: VARCHAR
- // FULLTEXT(normalized_name)
- // FULLTEXT(normalized_description)
- // FULLTEXT(normalized_name, normalized_description)
- // plog_gallery_resources
- // normalized_description: TEXT
- // FULLTEXT(normalized_description)
- // plog_mylinks
- // properties: TEXT
- // plog_mylinks_categories
- // properties: TEXT
- // plog_users
- // properties: TEXT
- // full_name: VARCHAR
- //
- // - for all the articles in the db, fill in the normalized_text, normalized_topic and mangled_topic
- // fields using the TextFilter class
- //
- // - for all articles in the db, change the status from a string ('published', 'draft', 'deleted') to
- // an integer (POST_STATUS_{PUBLISHED|DELETED|DRAFT}
- //
- // - for all articles and categories, arrange the plog_article_categories_link table so that everything works
- // as before
- //
- // - for all article categories, fill in the mangled_name field
- //
- // - for all comments, fill in the normalized_text and normalized_topic fields
- //
- // - for all blogs, fill in the mangled_blog field
- //
- // - for all albums, fill in the normalized_name, normalized_description and mangled_name fields
- //
- // - for all resources, fill in the normalized_description field
-
-
- class UpdateStepOne extends Action
+ //
+ // Things that need to be done when going from 0.3.x to 1.0:
+ //
+ // - add the new tables:
+ // plog_article_categories_link
+ // plog_custom_fields_definition
+ // plog_custom_fields_values
+ //
+ // - make modifications to some of the old tables:
+ // plog_articles
+ // normalized_text: TEXT
+ // normalized_topic: TEXT
+ // mangled_topic: TEXT
+ // category_id: DROP
+ // FULLTEXT(normalized_text)
+ // FULLTEXT(normalized_topic)
+ // FULLTEXT(normalized_text, normalized_topic)
+ // plog_articles_categories
+ // parent_id: INTEGER
+ // mangled_name: TEXT
+ // properties: TEXT
+ // plog_articles_comments
+ // normalized_text: TEXT
+ // normalized_topic: TEXT
+ // FULLTEXT(normalized_text)
+ // FULLTEXT(normalized_topic)
+ // FULLTEXT(normalized_text, normalized_topic)
+ // plog_blogs
+ // mangled_blog: TEXT
+ // properties: TEXT
+ // plog_gallery_albums
+ // normalized_name: VARCHAR
+ // normalized_description: TEXT
+ // mangled_name: VARCHAR
+ // FULLTEXT(normalized_name)
+ // FULLTEXT(normalized_description)
+ // FULLTEXT(normalized_name, normalized_description)
+ // plog_gallery_resources
+ // normalized_description: TEXT
+ // FULLTEXT(normalized_description)
+ // plog_mylinks
+ // properties: TEXT
+ // plog_mylinks_categories
+ // properties: TEXT
+ // plog_users
+ // properties: TEXT
+ // full_name: VARCHAR
+ //
+ // - for all the articles in the db, fill in the normalized_text, normalized_topic and mangled_topic
+ // fields using the TextFilter class
+ //
+ // - for all articles in the db, change the status from a string ('published', 'draft', 'deleted') to
+ // an integer (POST_STATUS_{PUBLISHED|DELETED|DRAFT}
+ //
+ // - for all articles and categories, arrange the plog_article_categories_link table so that everything works
+ // as before
+ //
+ // - for all article categories, fill in the mangled_name field
+ //
+ // - for all comments, fill in the normalized_text and normalized_topic fields
+ //
+ // - for all blogs, fill in the mangled_blog field
+ //
+ // - for all albums, fill in the normalized_name, normalized_description and mangled_name fields
+ //
+ // - for all resources, fill in the normalized_description field
+
+
+ class UpdateStepOne extends Action
{
function perform()
{
- $this->_view = new WizardView( "update1" );
+ $this->_view = new WizardView( "update1" );
WizardStepTwo::setDbConfigValues( $this->_view );
$this->setCommonData();
}
}
- class UpdateStepTwo extends Action
+ class UpdateStepTwo extends Action
{
var $_db;
@@ -1414,14 +1416,14 @@
$errors = true;
}
}
-
+
if( !$errors )
$message .= "Changes to table <strong>$tableId</strong> executed successfully.<br/>";
else {
$message .= "Error modifying table $tableId: ".$this->_db->ErrorMsg()."<br/>";
}
}
-
+
if( !$errors ) {
$message .= "** Modifications to old tables carried out successfully **<br/><br/>";
}
@@ -1451,318 +1453,318 @@
WizardStepTwo::setDbConfigValues( $this->_view );
$this->_view->setErrorMessage( $message );
}
-
- return true;
+
+ return true;
}
}
- /**
- * this is the first step of the transformations to some of the fields in the tables.
- * Precisely, it is in this step where we regenerate the indexes for the search engine... However, it
- * could take it a while...
- */
- class UpdateStepThree extends Action
- {
- function UpdateStepThree( $actionInfo, $httpRequest )
- {
- $this->Action( $actionInfo, $httpRequest );
-
- // load the current step, if any
- $this->_curStep = $this->_request->getValue( "curStep" );
- $this->_numPosts = $this->_request->getValue( "numPosts" );
-
- //print("cur step = ".$this->_curStep." - num posts = ".$this->_numPosts."<br/>");
- }
-
- function getStatusId( $statusStr )
- {
- if( $statusStr == 'published' ) return POST_STATUS_PUBLISHED;
- if( $statusStr == 'draft' ) return POST_STATUS_DRAFT;
- if( $statusStr == 'deleted' ) return POST_STATUS_DELETED;
-
- return false;
- }
-
+ /**
+ * this is the first step of the transformations to some of the fields in the tables.
+ * Precisely, it is in this step where we regenerate the indexes for the search engine... However, it
+ * could take it a while...
+ */
+ class UpdateStepThree extends Action
+ {
+ function UpdateStepThree( $actionInfo, $httpRequest )
+ {
+ $this->Action( $actionInfo, $httpRequest );
+
+ // load the current step, if any
+ $this->_curStep = $this->_request->getValue( "curStep" );
+ $this->_numPosts = $this->_request->getValue( "numPosts" );
+
+ //print("cur step = ".$this->_curStep." - num posts = ".$this->_numPosts."<br/>");
+ }
+
+ function getStatusId( $statusStr )
+ {
+ if( $statusStr == 'published' ) return POST_STATUS_PUBLISHED;
+ if( $statusStr == 'draft' ) return POST_STATUS_DRAFT;
+ if( $statusStr == 'deleted' ) return POST_STATUS_DELETED;
+
+ return false;
+ }
+
function perform()
{
- // get a connection to the db
- $db = connectDb();
- $dbPrefix = getDbPrefix();
- $db->debug=false;
-
- // no errors here
- $errors = false;
-
- // see how many records we have
- $queryCount = "SELECT COUNT(*) AS total FROM {$dbPrefix}articles";
- $result = $db->Execute( $queryCount );
- $row = $result->FetchRow();
- $numRecords = $row["total"];
- $this->_totalPosts = $numRecords;
- // check whether we should use multiple steps
- $multipleSteps = ( $numRecords > WIZARD_MAX_RECORDS_THRESHOLD );
- if( $multipleSteps ) {
- // how many steps do we need?
- $numSteps = ceil( $numRecords / WIZARD_MAX_RECORDS_PER_STEP );
- $this->_numSteps = $numSteps;
- //print("using different steps! numSteps = $numSteps<br/>");
- }
-
- // run the query and loop through the results
- $query = "SELECT * FROM {$dbPrefix}articles";
- if( $multipleSteps ) {
- // generate the LIMIT condition for this page
- $query .= " LIMIT ".$this->_curStep*WIZARD_MAX_RECORDS_PER_STEP.", ".WIZARD_MAX_RECORDS_PER_STEP;
- }
-
- //print("query = $query<br/>");
-
- $result = $db->Execute( $query );
-
- $tf = new TextFilter();
-
- $numPosts = $result->RowCount();
-
- while( $row = $result->FetchRow()) {
- // for each one of the articles, fill in the mangled_topic, normalized_text and normalized_value
- $normalizedTopic = Db::qstr($tf->normalizeText( $row["topic"] ));
- $postTopic = Db::qstr($row["topic"]);
- $normalizedText = Db::qstr($tf->normalizeText( $row["text"] ));
- $postText = Db::qstr($row["text"]);
- $mangledTopic = Db::qstr($tf->urlize( $row["topic"] ));
- $status = $this->getStatusId( $row["old_status"] );
- $artId = $row["id"];
- $catId = $row["category_id"];
-
- $query = "UPDATE {$dbPrefix}articles SET slug = '$mangledTopic', date = date, status = $status
- WHERE id = $artId";
-
- $query2= "INSERT INTO {$dbPrefix}article_categories_link(article_id, category_id)
- VALUES ( $artId, $catId )";
-
- $query3= "INSERT INTO {$dbPrefix}articles_text (article_id,text,topic,normalized_text,normalized_topic,mangled_topic)
- VALUES('$artId','$postText','$postTopic','$normalizedTopic','$normalizedText','$mangledTopic')";
-
-
- // execute the two queries
- $res = $db->Execute( $query );
- $res2 = $db->Execute( $query2 );
- $res3 = $db->Execute( $query3 );
-
- /*if( !$res || !$res2 || !$res3 )
- $errors = true;*/
- }
+ // get a connection to the db
+ $db = connectDb();
+ $dbPrefix = getDbPrefix();
+ $db->debug=false;
- // check whether we've already done the last step or not
- $lastStepDone = ( $this->_curStep >= $this->_numSteps );
-
- // if error
- if( $errors ) {
+ // no errors here
+ $errors = false;
+
+ // see how many records we have
+ $queryCount = "SELECT COUNT(*) AS total FROM {$dbPrefix}articles";
+ $result = $db->Execute( $queryCount );
+ $row = $result->FetchRow();
+ $numRecords = $row["total"];
+ $this->_totalPosts = $numRecords;
+ // check whether we should use multiple steps
+ $multipleSteps = ( $numRecords > WIZARD_MAX_RECORDS_THRESHOLD );
+ if( $multipleSteps ) {
+ // how many steps do we need?
+ $numSteps = ceil( $numRecords / WIZARD_MAX_RECORDS_PER_STEP );
+ $this->_numSteps = $numSteps;
+ //print("using different steps! numSteps = $numSteps<br/>");
+ }
+
+ // run the query and loop through the results
+ $query = "SELECT * FROM {$dbPrefix}articles";
+ if( $multipleSteps ) {
+ // generate the LIMIT condition for this page
+ $query .= " LIMIT ".$this->_curStep*WIZARD_MAX_RECORDS_PER_STEP.", ".WIZARD_MAX_RECORDS_PER_STEP;
+ }
+
+ //print("query = $query<br/>");
+
+ $result = $db->Execute( $query );
+
+ $tf = new TextFilter();
+
+ $numPosts = $result->RowCount();
+
+ while( $row = $result->FetchRow()) {
+ // for each one of the articles, fill in the mangled_topic, normalized_text and normalized_value
+ $normalizedTopic = Db::qstr($tf->normalizeText( $row["topic"] ));
+ $postTopic = Db::qstr($row["topic"]);
+ $normalizedText = Db::qstr($tf->normalizeText( $row["text"] ));
+ $postText = Db::qstr($row["text"]);
+ $mangledTopic = Db::qstr($tf->urlize( $row["topic"] ));
+ $status = $this->getStatusId( $row["old_status"] );
+ $artId = $row["id"];
+ $catId = $row["category_id"];
+
+ $query = "UPDATE {$dbPrefix}articles SET slug = '$mangledTopic', date = date, status = $status
+ WHERE id = $artId";
+
+ $query2= "INSERT INTO {$dbPrefix}article_categories_link(article_id, category_id)
+ VALUES ( $artId, $catId )";
+
+ $query3= "INSERT INTO {$dbPrefix}articles_text (article_id,text,topic,normalized_text,normalized_topic,mangled_topic)
+ VALUES('$artId','$postText','$postTopic','$normalizedTopic','$normalizedText','$mangledTopic')";
+
+
+ // execute the two queries
+ $res = $db->Execute( $query );
+ $res2 = $db->Execute( $query2 );
+ $res3 = $db->Execute( $query3 );
+
+ /*if( !$res || !$res2 || !$res3 )
+ $errors = true;*/
+ }
+
+ // check whether we've already done the last step or not
+ $lastStepDone = ( $this->_curStep >= $this->_numSteps );
+
+ // if error
+ if( $errors ) {
$this->_view = new WizardView( "update2" );
$this->_view->setErrorMessage( "There was an error updating the articles table." );
$this->setCommonData();
return false;
- }
-
- //$query1 = "ALTER TABLE {$dbPrefix}articles DROP COLUMN old_status, DROP COLUMN category_id";
- //$db->Execute( $query1 );
-
- // if everyhting's fine, say so...
- if( !$multipleSteps || $lastStepDone ) {
- $this->_view = new WizardView( "update3" );
- $this->_view->setValue( "totalPosts", $this->_totalPosts );
- }
- else {
- // if we're using multiple steps, show the same page
- $this->_view = new WizardView( "update2" );
- $this->_view->setValue( "numPosts", $numPosts );
- $this->_view->setValue( "curStep", $this->_curStep+1 );
- $this->_view->setValue( "totalPosts", $this->_totalPosts );
- $this->_view->setValue( "numSteps", $this->_numSteps );
- $this->_view->setValue( "multipleSteps", true );
- }
-
- return true;
+ }
+
+ //$query1 = "ALTER TABLE {$dbPrefix}articles DROP COLUMN old_status, DROP COLUMN category_id";
+ //$db->Execute( $query1 );
+
+ // if everyhting's fine, say so...
+ if( !$multipleSteps || $lastStepDone ) {
+ $this->_view = new WizardView( "update3" );
+ $this->_view->setValue( "totalPosts", $this->_totalPosts );
+ }
+ else {
+ // if we're using multiple steps, show the same page
+ $this->_view = new WizardView( "update2" );
+ $this->_view->setValue( "numPosts", $numPosts );
+ $this->_view->setValue( "curStep", $this->_curStep+1 );
+ $this->_view->setValue( "totalPosts", $this->_totalPosts );
+ $this->_view->setValue( "numSteps", $this->_numSteps );
+ $this->_view->setValue( "multipleSteps", true );
+ }
+
+ return true;
}
}
-
- // ---
- // this action will do the same as before but for the rest of the tables that need some data to
- // be normalized/mangled
- // ---
- class UpdateStepFour extends Action
- {
-
- var $dbPrefix;
- var $db;
- var $t;
-
- function validate()
- {
- $this->db = connectDb();
- $this->dbPrefix = getDbPrefix();
- $this->t = new TextFilter();
-
- return true;
- }
- //
- // process the article categories
- //
- function updateArticleCategories()
- {
- $dbPrefix = $this->dbPrefix;
- $query = "SELECT * FROM {$dbPrefix}articles_categories";
- $result = $this->db->Execute( $query );
-
- while( $row = $result->FetchRow()) {
- $catId = $row["id"];
- $mangledName = $this->t->urlize( $row["name"] );
- $query = "UPDATE {$dbPrefix}articles_categories
- SET mangled_name = '$mangledName', last_modification = last_modification
- WHERE id = $catId";
-
- $res = $this->db->Execute( $query );
-
- // this is not very nice to see but it works... :)
- if( !$res ) {
- $this->message .= "There was an error updating the article categories table.<br/>";
- return false;
- }
- }
-
- $this->message .= "Article Categories table updated successfully!<br/>";
-
- return true;
- }
+ // ---
+ // this action will do the same as before but for the rest of the tables that need some data to
+ // be normalized/mangled
+ // ---
+ class UpdateStepFour extends Action
+ {
- //
- // process the comments
- //
- function updateArticleComments()
- {
- $dbPrefix = $this->dbPrefix;
- $query = "SELECT * FROM {$dbPrefix}articles_comments";
- $result = $this->db->Execute( $query );
-
- while( $row = $result->FetchRow()) {
- $commentId = $row["id"];
- $normText = Db::qstr($this->t->normalizeText( $row["text"] ));
- $normTopic = Db::qstr($this->t->normalizeText( $row["topic"] ));
- $query = "UPDATE {$dbPrefix}articles_comments
- SET normalized_text = '$normText', normalized_topic = '$normTopic', date = date
- WHERE id = $commentId";
-
- $res = $this->db->Execute( $query );
-
- if( !$res ) {
- $this->message .= "There was an error updating the comments table.<br/>";
- return false;
- }
- }
-
- $this->message .= "Comments table updated successfully!<br/>";
-
- return true;
- }
+ var $dbPrefix;
+ var $db;
+ var $t;
- //
- // process the blogs
- //
- function updateBlogs()
- {
- $dbPrefix = $this->dbPrefix;
- $query = "SELECT * FROM {$dbPrefix}blogs";
- $result = $this->db->Execute( $query );
-
- while( $row = $result->FetchRow()) {
- $blogId = $row["id"];
- $mangledBlog = $this->t->urlize( $row["blog"] );
- $query = "UPDATE {$dbPrefix}blogs
- SET mangled_blog = '$mangledBlog' WHERE id = $blogId";
-
- $res = $this->db->Execute( $query );
-
- if( !$res ) {
- $this->message .= "There wasn an error updaing the blogs table.<br/>";
- return false;
- }
- }
-
- $this->message .= "Blogs table updated successfully!<br/>";
-
- return true;
- }
+ function validate()
+ {
+ $this->db = connectDb();
+ $this->dbPrefix = getDbPrefix();
+ $this->t = new TextFilter();
- //
- // process the albums
- //
- function updateAlbums()
- {
- $dbPrefix = $this->dbPrefix;
- $query = "SELECT * FROM {$dbPrefix}gallery_albums";
- $result = $this->db->Execute( $query );
-
- while( $row = $result->FetchRow()) {
- $albumId = $row["id"];
- $mangledName = Db::qstr($this->t->urlize( $row["name"] ));
- $normName = Db::qstr($this->t->normalizeText( $row["name"] ));
- $normDescription = Db::qstr($this->t->normalizeText( $row["description"] ));
- $query = "UPDATE {$dbPrefix}gallery_albums
- SET mangled_name = '$mangledName', normalized_name = '$normName',
- normalized_description = '$normDescription', date = date
- WHERE id = $albumId";
-
- $res = $this->db->Execute( $query );
-
- if( !$res ) {
- $this->message .= "There was an error updating the albums table.<br/>";
- return false;
- }
- }
-
- $this->message .= "Resource Albums table updated successfully!<br/>";
-
- return true;
- }
-
- //
- // and finally, the resources...
- //
- function updateResources()
- {
- $dbPrefix = $this->dbPrefix;
- $query = "SELECT * FROM {$dbPrefix}gallery_resources";
- $result = $this->db->Execute( $query );
-
- while( $row = $result->FetchRow()) {
+ return true;
+ }
+
+ //
+ // process the article categories
+ //
+ function updateArticleCategories()
+ {
+ $dbPrefix = $this->dbPrefix;
+ $query = "SELECT * FROM {$dbPrefix}articles_categories";
+ $result = $this->db->Execute( $query );
+
+ while( $row = $result->FetchRow()) {
+ $catId = $row["id"];
+ $mangledName = $this->t->urlize( $row["name"] );
+ $query = "UPDATE {$dbPrefix}articles_categories
+ SET mangled_name = '$mangledName', last_modification = last_modification
+ WHERE id = $catId";
+
+ $res = $this->db->Execute( $query );
+
+ // this is not very nice to see but it works... :)
+ if( !$res ) {
+ $this->message .= "There was an error updating the article categories table.<br/>";
+ return false;
+ }
+ }
+
+ $this->message .= "Article Categories table updated successfully!<br/>";
+
+ return true;
+ }
+
+ //
+ // process the comments
+ //
+ function updateArticleComments()
+ {
+ $dbPrefix = $this->dbPrefix;
+ $query = "SELECT * FROM {$dbPrefix}articles_comments";
+ $result = $this->db->Execute( $query );
+
+ while( $row = $result->FetchRow()) {
+ $commentId = $row["id"];
+ $normText = Db::qstr($this->t->normalizeText( $row["text"] ));
+ $normTopic = Db::qstr($this->t->normalizeText( $row["topic"] ));
+ $query = "UPDATE {$dbPrefix}articles_comments
+ SET normalized_text = '$normText', normalized_topic = '$normTopic', date = date
+ WHERE id = $commentId";
+
+ $res = $this->db->Execute( $query );
+
+ if( !$res ) {
+ $this->message .= "There was an error updating the comments table.<br/>";
+ return false;
+ }
+ }
+
+ $this->message .= "Comments table updated successfully!<br/>";
+
+ return true;
+ }
+
+ //
+ // process the blogs
+ //
+ function updateBlogs()
+ {
+ $dbPrefix = $this->dbPrefix;
+ $query = "SELECT * FROM {$dbPrefix}blogs";
+ $result = $this->db->Execute( $query );
+
+ while( $row = $result->FetchRow()) {
+ $blogId = $row["id"];
+ $mangledBlog = $this->t->urlize( $row["blog"] );
+ $query = "UPDATE {$dbPrefix}blogs
+ SET mangled_blog = '$mangledBlog' WHERE id = $blogId";
+
+ $res = $this->db->Execute( $query );
+
+ if( !$res ) {
+ $this->message .= "There wasn an error updaing the blogs table.<br/>";
+ return false;
+ }
+ }
+
+ $this->message .= "Blogs table updated successfully!<br/>";
+
+ return true;
+ }
+
+ //
+ // process the albums
+ //
+ function updateAlbums()
+ {
+ $dbPrefix = $this->dbPrefix;
+ $query = "SELECT * FROM {$dbPrefix}gallery_albums";
+ $result = $this->db->Execute( $query );
+
+ while( $row = $result->FetchRow()) {
+ $albumId = $row["id"];
+ $mangledName = Db::qstr($this->t->urlize( $row["name"] ));
+ $normName = Db::qstr($this->t->normalizeText( $row["name"] ));
+ $normDescription = Db::qstr($this->t->normalizeText( $row["description"] ));
+ $query = "UPDATE {$dbPrefix}gallery_albums
+ SET mangled_name = '$mangledName', normalized_name = '$normName',
+ normalized_description = '$normDescription', date = date
+ WHERE id = $albumId";
+
+ $res = $this->db->Execute( $query );
+
+ if( !$res ) {
+ $this->message .= "There was an error updating the albums table.<br/>";
+ return false;
+ }
+ }
+
+ $this->message .= "Resource Albums table updated successfully!<br/>";
+
+ return true;
+ }
+
+ //
+ // and finally, the resources...
+ //
+ function updateResources()
+ {
+ $dbPrefix = $this->dbPrefix;
+ $query = "SELECT * FROM {$dbPrefix}gallery_resources";
+ $result = $this->db->Execute( $query );
+
+ while( $row = $result->FetchRow()) {
$resId = $row["id"];
- //$normName = $this->t->normalizeText( $row["name"] );
- $normDescription = Db::qstr($this->t->normalizeText( $row["description"] ));
- $query = "UPDATE {$dbPrefix}gallery_resources
- SET normalized_description = '$normDescription', date = date
- WHERE id = $resId";
-
- $res = $this->db->Execute( $query );
- if( !$res ) {
- $this->message .= "There was an error updating the resources table.<br/>";
- return false;
- }
- }
-
- $this->message .= "Resources table updated successfully!<br/>";
-
- return true;
-
- }
-
- //
- // process the articles' text
- //
- function updateArticleText()
- {
- $dbPrefix = $this->dbPrefix;
+ //$normName = $this->t->normalizeText( $row["name"] );
+ $normDescription = Db::qstr($this->t->normalizeText( $row["description"] ));
+ $query = "UPDATE {$dbPrefix}gallery_resources
+ SET normalized_description = '$normDescription', date = date
+ WHERE id = $resId";
+
+ $res = $this->db->Execute( $query );
+ if( !$res ) {
+ $this->message .= "There was an error updating the resources table.<br/>";
+ return false;
+ }
+ }
+
+ $this->message .= "Resources table updated successfully!<br/>";
+
+ return true;
+
+ }
+
+ //
+ // process the articles' text
+ //
+ function updateArticleText()
+ {
+ $dbPrefix = $this->dbPrefix;
// drop unneeded columns from articles table
$alter_query[] = "ALTER TABLE ".$dbPrefix."articles DROP COLUMN text";
$alter_query[] = "ALTER TABLE ".$dbPrefix."articles DROP COLUMN topic";
@@ -1771,37 +1773,37 @@
$this->db->Execute($value);
}
-
- $this->message .= "articles_text table updated successfully!<br/>";
-
- return true;
- }
-
+
+ $this->message .= "articles_text table updated successfully!<br/>";
+
+ return true;
+ }
+
function perform()
{
$updaters = Array( "updateArticleCategories", "updateArticleComments",
"updateBlogs", "updateAlbums", "updateResources", "updateArticleText" );
-
+
// loop through each one of the methods to take care of updating one of the tables
foreach( $updaters as $method ) {
$result = $this->$method();
-
+
if( !$result ) {
$this->_view = new WizardView( "update3" );
$this->_view->setErrorMessage( $this->message );
- return false;
+ return false;
}
}
-
+
// everything went fine so we can show the final page!
$this->_view = new WizardView( "update4" );
$this->_view->setValue( "message", $this->message );
-
- return true;
+
+ return true;
}
-
- }
+ }
+
// check if the "./tmp" folder is writable by us, otherwise
// throw an error before the user gets countless errors
// from Smarty
More information about the pLog-svn
mailing list