[pLog-svn] r4332 - plog/branches/lifetype-1.1.3/class/action/admin

oscar at devel.lifetype.net oscar at devel.lifetype.net
Fri Nov 24 22:39:36 GMT 2006


Author: oscar
Date: 2006-11-24 22:39:35 +0000 (Fri, 24 Nov 2006)
New Revision: 4332

Modified:
   plog/branches/lifetype-1.1.3/class/action/admin/adminupdateblogsettingsaction.class.php
Log:
the same changes for the domain validation should also be applied when users change the blog settings


Modified: plog/branches/lifetype-1.1.3/class/action/admin/adminupdateblogsettingsaction.class.php
===================================================================
--- plog/branches/lifetype-1.1.3/class/action/admin/adminupdateblogsettingsaction.class.php	2006-11-24 22:22:48 UTC (rev 4331)
+++ plog/branches/lifetype-1.1.3/class/action/admin/adminupdateblogsettingsaction.class.php	2006-11-24 22:39:35 UTC (rev 4332)
@@ -52,16 +52,53 @@
 			$this->registerField( "blogEnableAutosaveDrafts" );
 			$this->registerField( "blogShowInSummary" );
 			$this->registerField( "blogSendNotification" );			
-			if( Subdomains::getSubdomainsEnabled()) {
-				$this->registerFieldValidator( "blogSubDomain", new DomainValidator());
-				$this->registerFieldValidator( "blogMainDomain", new DomainValidator());			
-			}
+			$this->registerField( "blogSubDomain" );
+			$this->registerField( "blogMainDomain" );
 			// set the view that we're going to use
 			$view = new AdminBlogSettingsView( $this->_blogInfo );
 			$view->setErrorMessage( $this->_locale->tr("error_updating_settings"));
 			$this->setValidationErrorView( $view );
         }
 
+		function validate()
+		{
+			$valid = parent::validate();
+			
+            // check to see whether we are going to save subdomain information
+            if( Subdomains::getSubdomainsEnabled()) {
+
+				// Translate a few characters to valid names, and remove the rest
+                $mainDomain = Textfilter::domainize($this->_request->getValue( "blogMainDomain" ));
+                if(!$mainDomain)
+                    $mainDomain = "?";
+                $subDomain = Textfilter::domainize($this->_request->getValue( "blogSubDomain" ));
+
+                // 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();					
+                }
+				if( Subdomains::domainNameExists( $this->blogDomain )) {
+					$valid = false;
+					$this->_form->setFieldValidationStatus( "blogSubDomain", false );					
+					$this->validationErrorProcessing();					
+				}				
+            }
+
+			return( $valid );			
+		}
+
         /**
          * Carries out the specified action
          */



More information about the pLog-svn mailing list