[pLog-svn] r3593 - in plog/trunk: class/action/admin
class/view/admin templates/admin
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Fri Jun 16 19:36:39 GMT 2006
Author: oscar
Date: 2006-06-16 19:36:38 +0000 (Fri, 16 Jun 2006)
New Revision: 3593
Modified:
plog/trunk/class/action/admin/adminaddblogaction.class.php
plog/trunk/class/view/admin/admincreateblogview.class.php
plog/trunk/templates/admin/createblog.template
Log:
now it is possible to select the custom subdomain when creating the blog via the admin interface
Modified: plog/trunk/class/action/admin/adminaddblogaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminaddblogaction.class.php 2006-06-16 19:35:43 UTC (rev 3592)
+++ plog/trunk/class/action/admin/adminaddblogaction.class.php 2006-06-16 19:36:38 UTC (rev 3593)
@@ -5,6 +5,7 @@
include_once( PLOG_CLASS_PATH."class/view/admin/adminsiteblogslistview.class.php" );
include_once( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
include_once( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
+ include_once( PLOG_CLASS_PATH."class/data/validator/domainvalidator.class.php" );
include_once( PLOG_CLASS_PATH."class/dao/users.class.php" );
include_once( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );
include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
@@ -29,6 +30,10 @@
// data validation
$this->registerFieldValidator( "blogName", new StringValidator());
$this->registerFieldValidator( "userId", new IntegerValidator());
+ if( Subdomains::getSubdomainsEnabled()) {
+ $this->registerFieldValidator( "blogSubDomain", new DomainValidator());
+ $this->registerFieldValidator( "blogMainDomain", new DomainValidator());
+ }
$this->registerField( "userName" );
$this->setValidationErrorView( new AdminCreateBlogView( $this->_blogInfo ));
}
@@ -56,6 +61,42 @@
$blog = new BlogInfo( $this->_blogName, $this->_ownerId, "", "" );
$blog->setProperties( $this->_blogProperties );
+ // 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" ));
+
+ if( !Subdomains::isDomainAvailable( $mainDomain )) {
+ $this->_view = new AdminCreateBlogView( $this->_blogInfo );
+ $this->_view->setErrorMessage( $this->_locale->tr("error_updating_blog_subdomain"));
+ $this->_form->setFieldValidationStatus( "blogMainDomain", false );
+ $this->setCommonData();
+ return false;
+ }
+
+ if( !Subdomains::isValidDomainName( $subDomain )) {
+ $this->_view = new AdminCreateBlogView( $this->_blogInfo );
+ $this->_view->setErrorMessage( $this->_locale->tr("error_updating_blog_subdomain"));
+ $this->_form->setFieldValidationStatus( "blogSubDomain", false );
+ $this->setCommonData();
+ return false;
+ }
+
+ if($mainDomain == "?"){
+ $blog_domain = $subDomain;
+ }
+ else{
+ $blog_domain = $subDomain . "." . $mainDomain;
+ }
+
+ $blog->setCustomDomain( $blog_domain );
+ }
+
+ // save the blog
$this->notifyEvent( EVENT_PRE_BLOG_ADD, Array( "blog" => &$blog ));
$newBlogId = $blogs->addBlog( $blog );
if( !$newBlogId) {
@@ -78,7 +119,7 @@
else {
$globalArticleCategoryId = 0;
}
-
+
// Get the defaul locale object
$config =& Config::getConfig();
$locale =& Locales::getLocale( $config->getValue( "default_locale" ));
Modified: plog/trunk/class/view/admin/admincreateblogview.class.php
===================================================================
--- plog/trunk/class/view/admin/admincreateblogview.class.php 2006-06-16 19:35:43 UTC (rev 3592)
+++ plog/trunk/class/view/admin/admincreateblogview.class.php 2006-06-16 19:36:38 UTC (rev 3593)
@@ -1,7 +1,8 @@
<?php
include_once( PLOG_CLASS_PATH."class/view/admin/admintemplatedview.class.php" );
- include_once( PLOG_CLASS_PATH."class/dao/users.class.php" );
+ include_once( PLOG_CLASS_PATH."class/dao/blogcategories.class.php" );
+ include_once( PLOG_CLASS_PATH."class/net/http/subdomains.class.php" );
/**
* \ingroup View
@@ -12,7 +13,23 @@
function AdminCreateBlogView( $blogInfo )
{
- $this->AdminTemplatedView( $blogInfo, "createblog" );
+ $this->AdminTemplatedView( $blogInfo, "createblog" );
}
+
+ function render()
+ {
+ // get a list of blog categories, so we can let user to choose
+ $blogCategories = new BlogCategories();
+ $categories = $blogCategories->getBlogCategories();
+ $this->setValue( "blogCategories", $categories );
+
+ // enable or disable the drop-down list to select subdomains
+ if( Subdomains::getSubdomainsEnabled()) {
+ $this->setValue( "blogDomainsEnabled", true );
+ $this->setValue( "blogAvailableDomains", Subdomains::getAvailableDomains());
+ }
+
+ return( parent::render());
+ }
}
?>
\ No newline at end of file
Modified: plog/trunk/templates/admin/createblog.template
===================================================================
--- plog/trunk/templates/admin/createblog.template 2006-06-16 19:35:43 UTC (rev 3592)
+++ plog/trunk/templates/admin/createblog.template 2006-06-16 19:36:38 UTC (rev 3593)
@@ -38,7 +38,7 @@
message=$locale->tr("error_invalid_domain")}
</div>
{/if}
-
+
<div class="field">
<label for="blogOwner">{$locale->tr("owner")}</label>
<span class="required">*</span>
More information about the pLog-svn
mailing list