class_WebResendLinkCommand.php

Go to the documentation of this file.
00001 <?php
00024 class WebResendLinkCommand extends BaseCommand implements Commandable {
00030         protected function __construct () {
00031                 // Call parent constructor
00032                 parent::__construct(__CLASS__);
00033         }
00034 
00041         public final static function createWebResendLinkCommand (CommandResolver $resolverInstance) {
00042                 // Get new instance
00043                 $commandInstance = new WebResendLinkCommand();
00044 
00045                 // Set the application instance
00046                 $commandInstance->setResolverInstance($resolverInstance);
00047 
00048                 // Return the prepared instance
00049                 return $commandInstance;
00050         }
00051 
00060         public function execute (Requestable $requestInstance, Responseable $responseInstance) {
00061                 // Get user instance from registry
00062                 $userInstance = Registry::getRegistry()->getInstance('user');
00063 
00064                 // Does the user instance implement ManageableMember?
00065                 if (!$userInstance instanceof ManageableMember) {
00066                         // Throw exception here
00067                         throw new InvalidInterfaceException(array($userInstance, 'ManageableMember'), self::EXCEPTION_REQUIRED_INTERFACE_MISSING);
00068                 } // END - if
00069 
00070                 // Get an application instance
00071                 $appInstance = $this->getResolverInstance()->getApplicationInstance();
00072 
00073                 // Get a RNG instance (Random Number Generator)
00074                 $rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class');
00075 
00076                 // Generate a pseudo-random string
00077                 $randomString = $rngInstance->randomString(255);
00078 
00079                 // Get a crypto instance
00080                 $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class');
00081 
00082                 // Hash and encrypt the string
00083                 $hashedString = $cryptoInstance->hashString($cryptoInstance->encryptString($randomString));
00084 
00085                 // Update the user class
00086                 $userInstance->updateDatabaseField(UserDatabaseWrapper::DB_COLUMN_CONFIRM_HASH, $hashedString);
00087 
00088                 // Re-set config entry to mailer engine
00089                 $this->getConfigInstance()->setConfigEntry('template_class', $this->getConfigInstance()->readConfig('mail_template_class'));
00090 
00091                 // Prepare the template engine
00092                 $templateInstance = $this->prepareTemplateInstance($appInstance);
00093 
00094                 // Assign the application data with the template engine
00095                 $templateInstance->assignApplicationData($appInstance);
00096 
00097                 // Get a mailer class
00098                 $mailerInstance = ObjectFactory::createObjectByConfiguredName('mailer_class', array($templateInstance, $appInstance, 'resend_link'));
00099 
00100                 // Set this mailer in our template engine
00101                 $templateInstance->setMailerInstance($mailerInstance);
00102 
00103                 // Add template variables we shall get
00104                 $mailerInstance->addConfigTemplateVariable('base_url');
00105                 $mailerInstance->addConfigTemplateVariable('admin_email');
00106                 $mailerInstance->addValueTemplateVariable('confirm_hash');
00107                 $mailerInstance->addValueTemplateVariable('username');
00108                 $mailerInstance->addValueTemplateVariable('email');
00109 
00110                 // Add the value instance for the confirmation hash
00111                 $mailerInstance->addValueInstance('confirm_hash', $userInstance);
00112                 $mailerInstance->addValueInstance('username', $userInstance);
00113                 $mailerInstance->addValueInstance('email', $userInstance);
00114 
00115                 // Add the recipient
00116                 $mailerInstance->addRecipientByUserInstance($userInstance);
00117 
00118                 // Use subject line from template
00119                 $mailerInstance->useSubjectFromTemplate();
00120 
00121                 // Send the email out
00122                 $mailerInstance->deliverEmail($responseInstance);
00123 
00124                 // Send out notification to admin (depends on settings)
00125                 $mailerInstance->sendAdminNotification($responseInstance);
00126         }
00127 
00135         public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
00136                 // Filter for checking if account is unconfirmed
00137                 $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_unconfirmed_filter'));
00138         }
00139 }
00140 
00141 // [EOF]
00142 ?>

Generated on Mon Dec 8 01:06:45 2008 for Ship-Simulator by  doxygen 1.5.6