Esempio n. 1
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $files = $request->getFiles();
     $userPhoto = $files['users']['photo']['name'];
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $user = $this->getUser()->getAttribute('user');
         $this->checkUser($form['email']->getValue(), $user->getId());
         $form->setFieldValue('users_group_id', $user->getUsersGroupId());
         $form->setFieldValue('active', $user->getActive());
         if (isset($form['new_password'])) {
             if (strlen($form['new_password']->getValue()) > 0) {
                 $form->setFieldValue('password', md5($form['new_password']->getValue()));
             }
         }
         if (strlen($userPhoto) > 0) {
             $userPhoto = rand(111111, 999999) . '-' . $userPhoto;
             $filename = sfConfig::get('sf_upload_dir') . '/users/' . $userPhoto;
             move_uploaded_file($files['users']['photo']['tmp_name'], $filename);
             $form->setFieldValue('photo', $userPhoto);
             app::image_resize($filename, $filename);
         } else {
             $form->setFieldValue('photo', $form['photo_preview']->getValue());
         }
         if ($form['remove_photo']->getValue() == 1 && strlen($form['photo_preview']->getValue()) > 0) {
             unlink(sfConfig::get('sf_upload_dir') . '/users/' . $form['photo_preview']->getValue());
             $form->setFieldValue('photo', '');
         }
         $users = $form->save();
         $this->getUser()->setAttribute('user', $users);
         $this->getUser()->setCulture($users->getCulture());
         ExtraFieldsList::setValues($request->getParameter('extra_fields'), $users->getId(), 'users', $this->getUser());
         $this->getUser()->setFlash('userNotices', t::__('Account Updated'));
         $this->redirect('myAccount/index');
     }
 }
Esempio n. 2
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $files = $request->getFiles();
     $userPhoto = $files['users']['photo']['name'];
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $this->checkUser($form['email']->getValue(), $request->getParameter('id'));
         if (isset($form['password'])) {
             $form->setFieldValue('password', md5($form['password']->getValue()));
         }
         if (isset($form['new_password'])) {
             if (strlen($form['new_password']->getValue()) > 0) {
                 $form->setFieldValue('password', md5($form['new_password']->getValue()));
             }
         }
         if (strlen($userPhoto) > 0) {
             $userPhoto = rand(111111, 999999) . '-' . $userPhoto;
             $filename = sfConfig::get('sf_upload_dir') . '/users/' . $userPhoto;
             if (getimagesize($files['users']['photo']['tmp_name'])) {
                 move_uploaded_file($files['users']['photo']['tmp_name'], $filename);
                 $form->setFieldValue('photo', $userPhoto);
                 app::image_resize($filename, $filename);
             } else {
                 $form->setFieldValue('photo', $form['photo_preview']->getValue());
             }
         } else {
             $form->setFieldValue('photo', $form['photo_preview']->getValue());
         }
         if ($form['remove_photo']->getValue() == 1 && strlen($form['photo_preview']->getValue()) > 0) {
             unlink(sfConfig::get('sf_upload_dir') . '/users/' . $form['photo_preview']->getValue());
             $form->setFieldValue('photo', '');
         }
         $users = $form->save();
         ExtraFieldsList::setValues($request->getParameter('extra_fields'), $users->getId(), 'users', $this->getUser(), $request);
         if ($form['notify']->getValue() == 1) {
             $this->notifyUser($users, $form['password']->getValue());
         }
         $this->redirect('users/index');
     }
 }
Esempio n. 3
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         if ($form->getObject()->isNew()) {
             $previeous_status = false;
         } else {
             $previeous_status = $form->getObject()->getTicketsStatusId();
         }
         if ($form->getObject()->isNew()) {
             $previeous_departmnet = false;
         } else {
             $previeous_departmnet = $form->getObject()->getDepartmentsId();
         }
         $send_to = $this->getSendTo($form);
         if ($form->getObject()->isNew()) {
             $form->setFieldValue('created_at', date('Y-m-d H:i:s'));
         }
         $tickets = $form->save();
         ExtraFieldsList::setValues($request->getParameter('extra_fields'), $tickets->getId(), 'tickets', $this->getUser(), $request);
         Attachments::insertAttachments($request->getFiles(), 'tickets', $tickets->getId(), $request->getParameter('attachments_info'), $this->getUser());
         $tickets = $this->addCommentIfStatusChanged($previeous_status, $previeous_departmnet, $tickets);
         $this->addRelatedItems($tickets, $request);
         if ($tickets->getUsersId() > 0) {
             Tickets::sendNotification($this, $tickets, $send_to, $this->getUser(), $request->getParameter('extra_notification', array()));
         }
         $this->redirect_to($request->getParameter('redirect_to'), $tickets->getProjectsId(), $tickets->getId(), $request);
     }
 }
Esempio n. 4
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $form->setFieldValue('assigned_to', implode(',', $form['assigned_to']->getValue()));
         $send_to = $this->getSendTo($form);
         if ($form->getObject()->isNew()) {
             $previeous_status = false;
         } else {
             $previeous_status = $form->getObject()->getDiscussionsStatusId();
         }
         if ($form->getObject()->isNew()) {
             $form->setFieldValue('created_at', date('Y-m-d H:i:s'));
         }
         $discussions = $form->save();
         ExtraFieldsList::setValues($request->getParameter('extra_fields'), $discussions->getId(), 'discussions', $this->getUser(), $request);
         Attachments::insertAttachments($request->getFiles(), 'discussions', $discussions->getId(), $request->getParameter('attachments_info'), $this->getUser());
         $discussions = $this->addCommentIfStatusChanged($previeous_status, $discussions);
         $discussions = $this->checkIfAssignedToChanged($send_to, $discussions);
         $this->addRelatedItems($discussions, $request);
         Discussions::sendNotification($this, $discussions, $send_to, $this->getUser());
         $this->redirect_to($request->getParameter('redirect_to'), $discussions->getProjectsId(), $discussions->getId(), $request);
     }
 }
Esempio n. 5
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $events = $form->save();
         ExtraFieldsList::setValues($request->getParameter('extra_fields'), $events->getEventId(), 'events', $this->getUser());
         Attachments::insertAttachments($request->getFiles(), 'events', $events->getEventId(), $request->getParameter('attachments_info'), $this->getUser());
         if ($events->getUsersId() > 0) {
             $this->redirect('scheduler/personal');
         } else {
             $this->redirect('scheduler/index');
         }
     }
 }