- Stuff
- Wednesday, June 6th, 2007 at 3:34:18pm MDT
- <?php
- class Default_RegisterAction extends ProjectBaseAction
- {
- /**
- * This Action does not yet serve any Request methods.
- * When a request comes in and this Action is used, execution will be skipped
- * and the View returned by getDefaultViewName() will be used.
- *
- * If an Action has an execute() method, this means it serves all methods.
- * Alternatively, you can implement executeRead() and executeWrite() methods,
- * because "read" and "write" are the default names for Web Request methods.
- * Other request methods may be explicitely served via execcuteReqmethname().
- *
- * Keep in mind that if an Action serves a Request method, validation will be
- * performed prior to execution.
- *
- * Usually, for example for an AddProduct form, your Action should only be run
- * when a POST request comes in, which is mapped to the "write" method by
- * default. Therefor, you'd only implement executeWrite() and put the logic to
- * add the new product to the database there, while for GET (o.e. "read")
- * requests, execution would be skipped, and the View name would be determined
- * using getDefaultViewName().
- *
- * We strongly recommend to prefer specific executeWhatever() methods over the
- * "catchall" execute().
- *
- * Besides execute() and execute*(), there are other methods that might either
- * be generic or specific to a request method. These are:
- * registerValidators() and register*Validators()
- * validate() and validate*()
- * handleError() and handle*Error()
- *
- * The execution of these methods is not dependent on the respective specific
- * execute*() being present, e.g. for a "write" Request, validateWrite() will
- * be run even if there is no executeWrite() method.
- */
- public function executeWrite(AgaviRequestDataHolder $rd)
- {
- $registerDetails = $rd->getParameter('register');
- /*$userInstance = $this->getContext()->getUser();
- $userSecretWord = $userInstance->getAttribute('secretWord');
- // die($userSecretWord." = ".$registerDetails['secretword']);
- if ($userSecretWord !== $registerDetails['secretword'])
- {
- $this->setAttribute('errorMsg', "Security word was invalid, please try again.");
- return 'Success'; // returns to input form
- }
- */
- "uid" => "null",
- "username" => '"'.$registerDetails['username'].'"',
- "forname" => '"'.$registerDetails['forname'].'"',
- "surname" => '"'.$registerDetails['surname'].'"',
- "email" => '"'.$registerDetails['email'].'"',
- "location" => '"'.$registerDetails['location'].'"',
- "dateofbirth" => '"'.$registerDetails['dobyear'].'-'.$registerDetails['dobmonth'].'-'.$registerDetails['dobday'].'"',
- "regdate" => "null",
- "lastlogin" => "null"
- );
- $dbConn = qcPdoDatabase::getDbObject(qcPdoDatabase::USERS);
- $result = $dbConn->submitRegistration($fieldArray);
- // All validation successed... now database results will says Complete or Error
- if ($result === true) //$rd->getParameter('username') == 'E_mE'
- {
- return 'Complete';
- }
- else
- {
- if ($result instanceof qcPdoSqlData) {
- $this->setAttribute('errorMsg', $result->getErrorMessage());
- }
- return 'Error';
- }
- }
- public function executeRead(AgaviRequestDataHolder $rd)
- {
- /* Process AJAX username validation request */
- if ($rd->hasParameter('username')) {
- // define database connection to the user class
- $userConn = qcPdoDatabase::getDbObject(qcPdoDatabase::USERS);
- $this->setAttribute('userexists', $userConn->userExists($rd->getParameter('username')));
- return 'Json';
- }
- else
- {
- return 'Success';
- }
- }
- /*
- public function execute(AgaviRequestDataHolder $rd)
- {
- if ($rd->hasParameter('username')) {
- $username = $rd->getParameter('username');
- $this->setAttribute('username.exists', $userConn->userExists($username));
- }
- return 'Success';
- }
- */
- /**
- * This method returns the View name in case the Action doesn't serve the
- * current Request method.
- *
- * !!!!!!!!!! DO NOT PUT ANY LOGIC INTO THIS METHOD !!!!!!!!!!
- *
- * @return mixed - A string containing the view name associated with this
- * action, or...
- * - An array with two indices:
- * 0. The parent module of the view that will be executed.
- * 1. The view that will be executed.
- *
- */
- //public function getDefaultViewName()
- //{
- // return 'Success';
- //}
- }
- ?>
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.
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.