Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Stuff
Wednesday, June 6th, 2007 at 3:34:18pm MDT 

  1. <?php
  2.  
  3. class Default_RegisterAction extends ProjectBaseAction
  4. {
  5.         /**
  6.          * This Action does not yet serve any Request methods.
  7.          * When a request comes in and this Action is used, execution will be skipped
  8.          * and the View returned by getDefaultViewName() will be used.
  9.          *
  10.          * If an Action has an execute() method, this means it serves all methods.
  11.          * Alternatively, you can implement executeRead() and executeWrite() methods,
  12.          * because "read" and "write" are the default names for Web Request methods.
  13.          * Other request methods may be explicitely served via execcuteReqmethname().
  14.          *
  15.          * Keep in mind that if an Action serves a Request method, validation will be
  16.          * performed prior to execution.
  17.          *
  18.          * Usually, for example for an AddProduct form, your Action should only be run
  19.          * when a POST request comes in, which is mapped to the "write" method by
  20.          * default. Therefor, you'd only implement executeWrite() and put the logic to
  21.          * add the new product to the database there, while for GET (o.e. "read")
  22.          * requests, execution would be skipped, and the View name would be determined
  23.          * using getDefaultViewName().
  24.          *
  25.          * We strongly recommend to prefer specific executeWhatever() methods over the
  26.          * "catchall" execute().
  27.          *
  28.          * Besides execute() and execute*(), there are other methods that might either
  29.          * be generic or specific to a request method. These are:
  30.          * registerValidators() and register*Validators()
  31.          * validate() and validate*()
  32.          * handleError() and handle*Error()
  33.          *
  34.          * The execution of these methods is not dependent on the respective specific
  35.          * execute*() being present, e.g. for a "write" Request, validateWrite() will
  36.          * be run even if there is no executeWrite() method.
  37.          */
  38.        
  39.         public function executeWrite(AgaviRequestDataHolder $rd)
  40.         {
  41.                 $registerDetails = $rd->getParameter('register');
  42.                 /*$userInstance = $this->getContext()->getUser();
  43.                 $userSecretWord = $userInstance->getAttribute('secretWord');
  44.                
  45.                 //      die($userSecretWord." = ".$registerDetails['secretword']);
  46.                
  47.                 if ($userSecretWord !== $registerDetails['secretword'])
  48.                 {
  49.                         $this->setAttribute('errorMsg', "Security word was invalid, please try again.");
  50.                         return 'Success'; // returns to input form
  51.                 }
  52.                 */
  53.                 die();
  54.                 $fieldArray = array(
  55.                         "uid" => "null",
  56.                         "username" => '"'.$registerDetails['username'].'"',
  57.                         "password" => '"'.substr(md5(time()), 5, 10).'"',
  58.                         "forname" => '"'.$registerDetails['forname'].'"',
  59.                         "surname" => '"'.$registerDetails['surname'].'"',
  60.                         "email" => '"'.$registerDetails['email'].'"',
  61.                         "location" => '"'.$registerDetails['location'].'"',
  62.                         "dateofbirth" => '"'.$registerDetails['dobyear'].'-'.$registerDetails['dobmonth'].'-'.$registerDetails['dobday'].'"',
  63.                         "regdate" => "null",
  64.                         "lastlogin" => "null"
  65.                 );
  66.                
  67.                 $dbConn = qcPdoDatabase::getDbObject(qcPdoDatabase::USERS);
  68.                 $result = $dbConn->submitRegistration($fieldArray);
  69.                
  70.                 // All validation successed... now database results will says Complete or Error
  71.                 if ($result === true) //$rd->getParameter('username') == 'E_mE'
  72.                 {
  73.                         return 'Complete';
  74.                 }
  75.                 else
  76.                 {
  77.                         if ($result instanceof qcPdoSqlData) {
  78.                                 $this->setAttribute('errorMsg', $result->getErrorMessage());
  79.                         }
  80.                         return 'Error';
  81.                 }
  82.         }
  83.        
  84.        
  85.         public function executeRead(AgaviRequestDataHolder $rd)
  86.         {
  87.                 /* Process AJAX username validation request */
  88.                 if ($rd->hasParameter('username')) {
  89.                         // define database connection to the user class
  90.                         $userConn = qcPdoDatabase::getDbObject(qcPdoDatabase::USERS);
  91.                        
  92.                         $this->setAttribute('userexists', $userConn->userExists($rd->getParameter('username')));
  93.                        
  94.                         return 'Json';
  95.                 }
  96.                 else
  97.                 {
  98.                         return 'Success';
  99.                 }
  100.                
  101.         }
  102.         /*
  103.         public function execute(AgaviRequestDataHolder $rd)
  104.         {
  105.                 if ($rd->hasParameter('username')) {
  106.                         $username = $rd->getParameter('username');
  107.                        
  108.                        
  109.                        
  110.                         $this->setAttribute('username.exists', $userConn->userExists($username));
  111.                 }
  112.                
  113.                
  114.                 return 'Success';
  115.         }
  116. */
  117.         /**
  118.          * This method returns the View name in case the Action doesn't serve the
  119.          * current Request method.
  120.          *
  121.          * !!!!!!!!!! DO NOT PUT ANY LOGIC INTO THIS METHOD !!!!!!!!!!
  122.          *
  123.          * @return     mixed - A string containing the view name associated with this
  124.          *                     action, or...
  125.          *                   - An array with two indices:
  126.          *                     0. The parent module of the view that will be executed.
  127.          *                     1. The view that will be executed.
  128.          *
  129.          */
  130.         //public function getDefaultViewName()
  131.         //{
  132.         //      return 'Success';
  133.         //}
  134. }
  135.  
  136. ?>

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.