public function testGetUserDetails() { $user = new Default_Model_User(); $data['vchUsername'] = '******'; $data['vchPassword'] = '******'; $data['vchFirstname'] = 'Sreenath'; $data['vchLastname'] = 'Kalathil'; $data['vchPlace'] = 'Trivandrum'; $data['intUserId'] = '3'; $this->assertEquals($data, $user->getUserDetails(3)); }
/** Displays the details of the user in a form to be edited and posts the data to Editprofileform controller. * * @return NULL * */ public function init() { $userdetails = new Default_Model_User(); $session = new Zend_Session_Namespace('user'); $row = $userdetails->getUserDetails($session->user_id); $this->setMethod('post'); $this->addElement('text', 'username', array('label' => 'Username:'******'value' => $row[vchUsername], 'required' => true, 'filters' => array('StringTrim'), 'validators' => array('EmailAddress'))); $this->addElement('text', 'password', array('label' => 'Password:'******'value' => $row[vchPassword], 'filters' => array('StringTrim'), 'required' => true)); $this->addElement('text', 'firstname', array('label' => 'Firstname:', 'value' => $row[vchFirstname], 'required' => true, 'validators' => array(array('validator' => 'StringLength', 'options' => array(0, 20))))); $this->addElement('text', 'lastname', array('label' => 'Lastname:', 'value' => $row[vchLastname], 'required' => true, 'validators' => array(array('validator' => 'StringLength', 'options' => array(0, 20))))); $this->addElement('text', 'place', array('label' => 'Place:', 'value' => $row[vchPlace], 'required' => true, 'validators' => array(array('validator' => 'StringLength', 'options' => array(0, 20))))); $this->addElement('submit', 'submit', array('ignore' => true, 'label' => 'Edit')); }
/** Displays the edit profile form and posts the edited data to database. * * @return NULL */ public function indexAction() { $request = $this->getRequest(); $form = new Default_Form_Editprofileform(); if ($this->getRequest()->isPost()) { if ($form->isValid($request->getPost())) { $user = new Default_Model_User(); $session = new Zend_Session_Namespace('user'); $user->getUserDetails(); $data['username'] = $request->username; $data['password'] = $request->password; $data['firstname'] = $request->firstname; $data['lastname'] = $request->lastname; $data['place'] = $request->place; $user->setUserDetails($data); $user->update(); $this->view->entries = 1; } else { $this->view->form = $form; } } $this->view->form = $form; }