| [ Index ] |
|
Code source de LifeType 1.2.4 |
1 <?php 2 3 lt_include(PLOG_CLASS_PATH.'class/summary/action/summaryaction.class.php'); 4 lt_include(PLOG_CLASS_PATH.'class/data/validator/stringvalidator.class.php'); 5 lt_include(PLOG_CLASS_PATH.'class/dao/users.class.php'); 6 lt_include(PLOG_CLASS_PATH.'class/dao/blogs.class.php'); 7 lt_include(PLOG_CLASS_PATH.'class/summary/view/summarymessageview.class.php'); 8 9 class ActiveAccountAction extends SummaryAction 10 { 11 12 var $username; 13 var $activeCode; 14 15 function ActiveAccountAction($actionInfo,$httpRequest) 16 { 17 $this->SummaryAction($actionInfo,$httpRequest); 18 19 $this->registerFieldValidator("username",new StringValidator()); 20 $this->registerFieldValidator("activeCode",new StringValidator()); 21 } 22 23 function perform(){ 24 $this->username = $this->_request->getValue("username"); 25 $this->activeCode = $this->_request->getValue("activeCode"); 26 27 $users = new Users(); 28 $userInfo = $users->getUserInfoFromUsername($this->username); 29 30 if(!$userInfo){ 31 $this->_view = new SummaryView( "summaryerror" ); 32 $this->_view->setErrorMessage( $this->_locale->tr("error_invalid_user")); 33 return false; 34 } 35 36 $activeCode = $userInfo->getValue("activeCode"); 37 if($activeCode != $this->activeCode){ 38 $this->_view = new SummaryView( "summaryerror"); 39 $this->_view->setErrorMessage( $this->_locale->tr("error_invalid_activation_code")); 40 return false; 41 } 42 43 // active user 44 $userInfo->setStatus(USER_STATUS_ACTIVE); 45 $users->updateUser($userInfo); 46 // also active the blog that user owned 47 // FIXME: how about other blogs that this user take part in? 48 $userBlogs = $userInfo->getBlogs(); 49 foreach( $userBlogs as $blog ) { 50 if( $blog->getOwnerId() == $userInfo->getId()) { 51 break; 52 } 53 } 54 55 if( $blog->getStatus() != BLOG_STATUS_UNCONFIRMED ) { 56 // we should only activate blogs whose status is 'unconfirmed' 57 $this->_view = new SummaryView( "summaryerror"); 58 $this->_view->setErrorMessage( $this->_locale->tr("error_invalid_activation_code")); 59 return false; 60 } 61 62 $blogs = new Blogs(); 63 $blog->setStatus(BLOG_STATUS_ACTIVE); 64 $blogs->updateBlog($blog); 65 $blogUrl = $blog->getBlogRequestGenerator(); 66 67 // create the message that we're going to show 68 $message = "<p>".$this->_locale->tr("blog_activated_ok")."</p><p>". 69 $this->_locale->pr("register_blog_link", $blog->getBlog(), $blogUrl->blogLink())."</p><p>". 70 $this->_locale->tr("register_blog_admin_link")."</p>"; 71 72 $this->_view = new SummaryMessageView($message); 73 $this->setCommonData(); 74 return true; 75 } 76 } 77 ?>
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 |
|