[pLog-svn] r4331 - in plog/branches/lifetype-1.1.3/class: net/http
summary/action
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Fri Nov 24 22:22:50 GMT 2006
Author: oscar
Date: 2006-11-24 22:22:48 +0000 (Fri, 24 Nov 2006)
New Revision: 4331
Modified:
plog/branches/lifetype-1.1.3/class/net/http/subdomains.class.php
plog/branches/lifetype-1.1.3/class/summary/action/doblogregistration.class.php
Log:
fixed an issue with custom subdomains not being properly saved as well as another issue with duplicate custom subdomains being allowed (mantis case http://bugs.lifetype.net/view.php?id=1129)
Modified: plog/branches/lifetype-1.1.3/class/net/http/subdomains.class.php
===================================================================
--- plog/branches/lifetype-1.1.3/class/net/http/subdomains.class.php 2006-11-24 18:42:41 UTC (rev 4330)
+++ plog/branches/lifetype-1.1.3/class/net/http/subdomains.class.php 2006-11-24 22:22:48 UTC (rev 4331)
@@ -130,5 +130,20 @@
$val = new DomainValidator();
return( $val->validate( $domain ));
}
+
+ /**
+ * Returns true if the domain is unique or false otherwise
+ *
+ * @param domain
+ * @return true if successful and false otherwise
+ */
+ function domainNameExists( $domain )
+ {
+ include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
+ $blogs = new Blogs();
+ $valid = is_object( $blogs->getBlogInfoByDomain( $domain ));
+
+ return( $valid );
+ }
}
?>
\ No newline at end of file
Modified: plog/branches/lifetype-1.1.3/class/summary/action/doblogregistration.class.php
===================================================================
--- plog/branches/lifetype-1.1.3/class/summary/action/doblogregistration.class.php 2006-11-24 18:42:41 UTC (rev 4330)
+++ plog/branches/lifetype-1.1.3/class/summary/action/doblogregistration.class.php 2006-11-24 22:22:48 UTC (rev 4331)
@@ -9,6 +9,7 @@
include_once( PLOG_CLASS_PATH."class/locale/locales.class.php" );
include_once( PLOG_CLASS_PATH."class/data/validator/domainvalidator.class.php" );
include_once( PLOG_CLASS_PATH."class/net/http/subdomains.class.php" );
+ include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
/**
* registers a blog
@@ -25,8 +26,9 @@
$this->registerFieldValidator( "blogName", new StringValidator());
$this->registerFieldValidator( "blogCategoryId", new IntegerValidator());
$this->registerFieldValidator( "blogLocale", new StringValidator());
- $this->registerFieldValidator( "blogSubDomain", new DomainValidator(), true );
- $this->registerFieldValidator( "blogMainDomain", new DomainValidator(), true );
+ $config =& Config::getConfig();
+ $this->registerField( "blogSubDomain" );
+ $this->registerField( "blogMainDomain" );
$view = new doBlogRegistrationView();
$view->setErrorMessage( $this->_locale->tr("register_error_creating_blog"));
$this->setValidationErrorView( $view );
@@ -34,12 +36,9 @@
function validate()
{
- // if the other fields did not validate, no need to continue
- if( !parent::validate())
- return false;
-
+ $valid = parent::validate();
+
// check to see whether we are going to save subdomain information
- $valid = true;
if( Subdomains::getSubdomainsEnabled()) {
// Translate a few characters to valid names, and remove the rest
@@ -50,19 +49,25 @@
// get list of allowed domains
$available_domains = Subdomains::getAvailableDomains();
+
+ if($mainDomain == "?")
+ $this->blogDomain = $subDomain;
+ else {
+ $this->blogDomain = $subDomain . "." . $mainDomain;
+ }
// make sure the mainDomain parameter is one of the blogAvailableDomains and if not,
// force a validation error
if( !Subdomains::isDomainAvailable( $mainDomain ) || !Subdomains::isValidDomainName( $subDomain )) {
$valid = false;
$this->_form->setFieldValidationStatus( "blogSubDomain", false );
- $this->validationErrorProcessing();
+ $this->validationErrorProcessing();
}
-
- if($mainDomain == "?")
- $this->blogDomain = $subDomain;
- else
- $this->blogDomain = $subDomain . "." . $mainDomain;
+ if( Subdomains::domainNameExists( $this->blogDomain )) {
+ $valid = false;
+ $this->_form->setFieldValidationStatus( "blogSubDomain", false );
+ $this->validationErrorProcessing();
+ }
}
return( $valid );
@@ -80,6 +85,7 @@
SessionManager::setSessionValue( "blogLocale", $this->_request->getValue( "blogLocale" ));
SessionManager::setSessionValue( "blogSubDomain", $this->_request->getValue( "blogSubDomain" ));
SessionManager::setSessionValue( "blogMainDomain", $this->_request->getValue( "blogMainDomain" ));
+ SessionManager::setSessionValue( "blogDomain", $this->blogDomain );
return( true );
}
More information about the pLog-svn
mailing list