[ Index ] |
|
Code source de LifeType 1.2.4 |
1 <?php 2 3 lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" ); 4 lt_include( PLOG_CLASS_PATH."class/view/admin/adminsiteblogslistview.class.php" ); 5 lt_include( PLOG_CLASS_PATH."class/view/admin/admineditsiteblogview.class.php" ); 6 lt_include( PLOG_CLASS_PATH."class/dao/blogs.class.php" ); 7 lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" ); 8 lt_include( PLOG_CLASS_PATH."class/dao/userpermissions.class.php" ); 9 lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" ); 10 lt_include( PLOG_CLASS_PATH."class/data/validator/blognamevalidator.class.php" ); 11 lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" ); 12 lt_include( PLOG_CLASS_PATH."class/data/validator/domainvalidator.class.php" ); 13 lt_include( PLOG_CLASS_PATH."class/data/validator/arrayvalidator.class.php" ); 14 15 /** 16 * \ingroup Action 17 * @private 18 * 19 * Action that shows a form to change the settings of the current blog. 20 */ 21 class AdminUpdateEditBlogAction extends AdminAction 22 { 23 24 var $_blogLocale; 25 var $_editBlogId; 26 var $_blogOwner; 27 var $_blogTemplate; 28 var $_blogTimeOffset; 29 var $_blogProperties; 30 var $_blogUsers; 31 var $_blogQuota; 32 var $_blogName; 33 var $_blogStatus; 34 35 /** 36 * Constructor. If nothing else, it also has to call the constructor of the parent 37 * class, BlogAction with the same parameters 38 */ 39 function AdminUpdateEditBlogAction( $actionInfo, $request ) 40 { 41 $this->AdminAction( $actionInfo, $request ); 42 43 // data validation 44 $this->registerFieldValidator( "blogUsers", new ArrayValidator(), true ); 45 $this->registerFieldValidator( "blogName", new BlogNameValidator()); 46 $this->registerFieldValidator( "blogId", new IntegerValidator()); 47 $this->registerFieldValidator( "blogStatus", new IntegerValidator()); 48 $this->registerFieldValidator( "blogLocale", new StringValidator()); 49 $this->registerFieldValidator( "blogTemplate", new StringValidator()); 50 $this->registerFieldValidator( "blogResourcesQuota", new IntegerValidator(), true ); 51 $this->registerFieldValidator( "userId", new IntegerValidator()); 52 $this->registerFieldValidator( "userName", new StringValidator()); 53 $this->registerField( "blogTimeOffset" ); 54 if( Subdomains::getSubdomainsEnabled()) { 55 $this->registerFieldValidator( "blogSubDomain", new DomainValidator()); 56 $this->registerFieldValidator( "blogMainDomain", new DomainValidator()); 57 } 58 $view = new AdminEditSiteBlogView( $this->_blogInfo ); 59 $view->setErrorMessage( $this->_locale->tr("error_updating_blog_settings2" )); 60 $this->setValidationErrorView( $view ); 61 62 $this->requireAdminPermission( "update_site_blog" ); 63 } 64 65 /** 66 * Carries out the specified action 67 */ 68 function perform() 69 { 70 // fetch the values from the form which have already been validated 71 $this->_blogName = Textfilter::filterAllHTML($this->_request->getValue( "blogName" )); 72 $this->_blogLocale = $this->_request->getValue( "blogLocale" ); 73 $this->_blogTemplate = $this->_request->getValue( "blogTemplate" ); 74 $this->_blogOwner = $this->_request->getValue( "blogOwner" ); 75 $this->_editBlogId = $this->_request->getValue( "blogId" ); 76 $this->_blogTimeOffset = $this->_request->getValue( "blogTimeOffset" ); 77 $this->_blogProperties = $this->_request->getValue( "properties" ); 78 $this->_blogQuota = $this->_request->getValue( "blogResourcesQuota" ); 79 $this->_blogUsers = $this->_request->getValue( "blogUsers" ); 80 $this->_blogStatus = $this->_request->getValue( "blogStatus" ); 81 $this->_blogOwner = $this->_request->getValue( "userId" ); 82 83 // get the blog we're trying to update 84 $blogs = new Blogs(); 85 $blogInfo = $blogs->getBlogInfo( $this->_editBlogId ); 86 if( !$blogInfo ) { 87 $this->_view = new AdminSiteBlogsListView( $this->_blogInfo ); 88 $this->_view->setErrorMessage( $this->_locale->tr("error_fetching_blog")); 89 $this->setCommonData(); 90 91 return false; 92 } 93 94 $this->notifyEvent( EVENT_BLOG_LOADED, Array( "blog" => &$blogInfo )); 95 96 // make sure that the user we'd like to set as owner exists 97 $users = new Users(); 98 $userInfo = $users->getUserInfoFromId( $this->_blogOwner ); 99 if( !$userInfo ) { 100 $this->_view = new AdminSiteBlogsListView( $this->_blogInfo ); 101 $this->_view->setErrorMessage( $this->_locale->tr("error_incorrect_blog_owner")); 102 $this->setCommonData(); 103 return false; 104 } 105 106 $this->notifyEvent( EVENT_USER_LOADED, Array( "user" => &$userInfo )); 107 108 // set the different settings 109 $blogSettings = $blogInfo->getSettings(); 110 $blogSettings->setValue( "locale", $this->_blogLocale ); 111 $blogSettings->setValue( "template", $this->_blogTemplate ); 112 $blogSettings->setValue( "time_offset", $this->_blogTimeOffset ); 113 $blogInfo->setSettings( $blogSettings ); 114 $blogInfo->setResourcesQuota( $this->_blogQuota ); 115 $blogInfo->setBlog( $this->_blogName ); 116 $blogInfo->setProperties( $this->_blogProperties ); 117 $blogInfo->setOwner( $this->_blogOwner ); 118 $blogInfo->setStatus( $this->_blogStatus ); 119 $blogInfo->setMangledBlogName( $blogInfo->getBlog(), true ); 120 121 // check to see whether we are going to save subdomain information 122 if( Subdomains::getSubdomainsEnabled()) { 123 124 // Translate a few characters to valid names, and remove the rest 125 $mainDomain = Textfilter::domainize($this->_request->getValue( "blogMainDomain" )); 126 if(!$mainDomain) 127 $mainDomain = "?"; 128 $subDomain = Textfilter::domainize($this->_request->getValue( "blogSubDomain" )); 129 130 131 132 if( !Subdomains::isDomainAvailable( $mainDomain )) { 133 $this->_view = new AdminEditSiteBlogView( $this->_blogInfo ); 134 $this->_view->setErrorMessage( $this->_locale->tr("error_updating_blog_subdomain")); 135 $this->_form->setFieldValidationStatus( "blogMainDomain", false ); 136 $this->setCommonData(); 137 return false; 138 } 139 140 if( !Subdomains::isValidDomainName( $subDomain )) { 141 $this->_view = new AdminEditSiteBlogView( $this->_blogInfo ); 142 $this->_view->setErrorMessage( $this->_locale->tr("error_updating_blog_subdomain")); 143 $this->_form->setFieldValidationStatus( "blogSubDomain", false ); 144 $this->setCommonData(); 145 return false; 146 } 147 148 if($mainDomain == "?"){ 149 $blog_domain = $subDomain; 150 } 151 else{ 152 $blog_domain = $subDomain . "." . $mainDomain; 153 } 154 155 $blogInfo->setCustomDomain( $blog_domain ); 156 } 157 158 $this->notifyEvent( EVENT_PRE_BLOG_UPDATE, Array( "blog" => &$blogInfo )); 159 if( !$blogs->updateBlog( $blogInfo )) { 160 $this->_view = new AdminSiteBlogsListView( $this->_blogInfo ); 161 $this->_view->setErrorMessage( $this->_locale->pr( "error_updating_blog_settings", $blogInfo->getBlog())); 162 $this->setCommonData(); 163 return false; 164 } 165 166 $this->notifyEvent( EVENT_POST_BLOG_UPDATE, Array( "blog" => &$blogInfo )); 167 168 // do it again, baby :))) 169 if( $this->_blogInfo->getId() == $blogInfo->getId()) { 170 $this->_blogInfo->setSettings( $blogSettings ); 171 $blogInfo->setProperties( $this->_blogProperties ); 172 $this->_session->setValue( "blogInfo", $this->_blogInfo ); 173 $this->saveSession(); 174 } 175 176 // if everything went fine, we can show a nice message 177 $this->_view = new AdminSiteBlogsListView( $this->_blogInfo ); 178 $this->_view->setSuccessMessage( $this->_locale->pr( "edit_blog_settings_updated_ok", $blogInfo->getBlog())); 179 $this->setCommonData(); 180 181 // clear the cache 182 CacheControl::resetBlogCache( $blogInfo->getId()); 183 184 // better to return true if everything fine 185 return true; 186 } 187 } 188 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 21:04:15 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |