예제 #1
0
 /** Edit one of your social media accounts
  * @access public
  * @return void
  * @throws Pas_Exception_Param
  */
 public function editAction()
 {
     if ($this->getParam('id', false)) {
         $form = new SocialAccountsForm();
         $form->submit->setLabel('Save profile');
         $this->view->form = $form;
         if ($this->_request->isPost()) {
             if ($form->isValid($this->_request->getPost())) {
                 $where = array();
                 $where[] = $this->_accounts->getAdapter()->quoteInto('id = ?', $this->getParam('id'));
                 $where[] = $this->_accounts->getAdapter()->quoteInto('userID = ?', $this->getIdentityForForms());
                 $this->_accounts->update($form->getValues(), $where);
                 $this->getFlash()->addMessage('Webservice details updated.');
                 $this->redirect('/users/social');
             } else {
                 $form->populate($this->_request->getPost());
             }
         } else {
             // find id is expected in $params['id']
             $id = (int) $this->_request->getParam('id', 0);
             if ($id > 0) {
                 $service = $this->_accounts->fetchRow('userID = ' . $this->getIdentityForForms() . ' AND id=' . $id);
                 if (count($service)) {
                     $form->populate($service->toArray());
                 } else {
                     throw new Pas_Exception_Param($this->_nothingFound, 404);
                 }
             }
         }
     } else {
         throw new Pas_Exception_Param($this->_missingParameter, 500);
     }
 }
예제 #2
0
 /** Edit one of your social media accounts
  */
 public function editAction()
 {
     if ($this->_getParam('id', false)) {
         $form = new SocialAccountsForm();
         $form->submit->setLabel('Save profile');
         $this->view->form = $form;
         if ($this->_request->isPost()) {
             $formData = $this->_request->getPost();
             if ($form->isValid($formData)) {
                 $services = new OnlineAccounts();
                 $updateData = array('accountName' => $form->getValue('accountName'), 'account' => $form->getValue('account'), 'public' => $form->getValue('public'), 'userID' => $this->getIdentityForForms(), 'updated' => $this->getTimeForForms(), 'updatedBy' => $this->getIdentityForForms());
                 $where = array();
                 $where[] = $services->getAdapter()->quoteInto('id = ?', $this->_getParam('id'));
                 $where[] = $services->getAdapter()->quoteInto('userID = ?', $this->getIdentityForForms());
                 $update = $services->update($updateData, $where);
                 $this->_flashMessenger->addMessage('Webservice details updated.');
                 $this->_redirect('/users/');
             } else {
                 $form->populate($formData);
             }
         } else {
             // find id is expected in $params['id']
             $id = (int) $this->_request->getParam('id', 0);
             if ($id > 0) {
                 $services = new OnlineAccounts();
                 $service = $services->fetchRow('userID = ' . $this->getIdentityForForms() . ' AND id=' . $id);
                 if (count($service)) {
                     $form->populate($service->toArray());
                 } else {
                     throw new Exception($this->_nothingFound);
                 }
             }
         }
     } else {
         throw new Exception($this->_missingParameter);
     }
 }