Exemplo n.º 1
0
 public function find($id, Application_Model_Member $member)
 {
     $result = $this->getDbTable()->find($id);
     if (0 === count($result)) {
         return;
     }
     $member->setOptions($result->current()->toArray());
 }
Exemplo n.º 2
0
 public function find($userId, Application_Model_Member $member)
 {
     $select = $this->getDbTable()->select()->where('member_login = ?', $userId);
     $resultSet = $this->getDbTable()->fetchRow($select);
     if (0 == count($resultSet)) {
         return;
     }
     $row = $resultSet;
     $member->setId($row->member_id)->setMemberLogin($row->member_login)->setMemberPassword($row->member_password)->setEmail($row->email)->setFirstName($row->first_name)->setLastName($row->last_name);
 }
Exemplo n.º 3
0
 public function fetchByDestination($destination, $isPartial)
 {
     //For debugging
     $this->_logger = new Zend_Log();
     $writer = new Zend_Log_Writer_Stream('sample.log');
     $this->_logger->addWriter($writer);
     $this->_logger->log('Ajax fetch idea by destination start', Zend_Log::INFO);
     $ideas = array();
     try {
         $select = $this->getDbTable()->select()->from(array('i' => 'ideas'))->join(array('m' => 'members'), 'i.author_id = m.member_id');
         if ($isPartial == 'true') {
             $destination = "%" . $destination . "%";
             $select->where('i.destination like ?', $destination);
             $this->_logger->log('Ajax fetch idea by destination partial, isPartial=' . $isPartial, Zend_Log::INFO);
         } else {
             $select->where('i.destination = ?', $destination);
             $this->_logger->log('Ajax fetch idea by destination NOT partial, isPartial=' . $isPartial, Zend_Log::INFO);
         }
         $select->setIntegrityCheck(false);
         $resultSet = $this->getDbTable()->fetchAll($select);
         foreach ($resultSet as $row) {
             $author = new Application_Model_Member();
             $author->setId($row->member_id)->setMemberLogin($row->member_login)->setEmail($row->email)->setFirstName($row->first_name)->setLastName($row->last_name);
             $idea = new Application_Model_Idea();
             $idea->setId($row->idea_id)->setDestination($row->destination)->setTitle($row->title)->setStartDate($row->start_date)->setEndDate($row->end_date)->setAuthor($author)->setCreateDatetime($row->create_datetime)->setLastUpdateDatetime($row->last_update_datetime);
             $ideas[] = $idea;
         }
         $this->_logger->log('Ajax fetch idea by destination end.  no. of result=' . count($ideas), Zend_Log::INFO);
     } catch (Exception $ex) {
         $this->_logger->log($ex->getMessage(), Zend_Log::ERROR);
     }
     return $ideas;
 }
Exemplo n.º 4
0
 public function editAction()
 {
     $request = $this->getRequest();
     $authns = new Zend_Session_Namespace('AuthNameSpace');
     if (!isset($authns->userId)) {
         return;
     }
     $form = new Application_Form_Signup();
     $mapper = new Application_Model_MemberMapper();
     $member = new Application_Model_Member();
     $mapper->find($authns->userId, $member);
     //reuse member_id in post
     $id = $member->getId();
     //handle changes to member info
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getPost())) {
             //get the newly updated form value
             $member = new Application_Model_Member($form->getValues());
             //set the id of the form in order to make changes to the same member in database
             $member->setId($id);
             //Verify user password before updating user information
             $oldPassword = $form->getValue('oldPassword');
             if ($mapper->verifyPassword($member, $oldPassword)) {
                 $mapper->save($member);
                 $this->_helper->FlashMessenger()->setNamespace('success')->addMessage('Update Successful!');
                 $this->_logger->log('Update: Password Verified!', Zend_Log::INFO);
                 return $this->_redirect('/');
             } else {
                 $this->_helper->FlashMessenger()->setNamespace('error')->addMessage('Incorrect password. Failed to save changes.');
                 $this->_logger->log('Update: Incorrect Password!', Zend_Log::INFO);
                 return $this->_redirect('/members/edit');
             }
         }
     }
     //form data array to populate signup form with existing data
     $data = array('memberLogin' => $member->getMemberLogin(), 'memberPassword' => $member->getMemberPassword(), 'firstName' => $member->getFirstName(), 'lastName' => $member->getLastName(), 'email' => $member->getEmail());
     $form->populate($data);
     $this->view->form = $form;
 }