/**
  * Result URL
  */
 public function executeResult(sfWebRequest $request)
 {
     $invoiceId = (int) $request->getParameter('LMI_PAYMENT_NO');
     $invoice = Doctrine::getTable('Invoice')->findOneById($invoiceId);
     if (!$invoice) {
         return $this->renderText('INVOICE NOT FOUND');
         return sfView::NONE;
     }
     $wallets = $this->getWallets($invoice);
     // Предварительный запрос
     if ($request->getParameter('LMI_PREREQUEST')) {
         $form = new WebmoneyPreResultForm($invoice, $wallets);
         $form->bind($params = $request->getPostParameters());
         if ($form->isValid()) {
             return $this->renderText('YES');
         } else {
             return $this->renderText('INVALID');
         }
         return sfView::NONE;
     }
     // Оповещение о платеже
     $form = new WebmoneyResultForm($invoice, $wallets);
     $form->bind($params = $request->getPostParameters());
     if ($form->isValid()) {
         $this->complete($invoice, $params);
         return $this->renderText('YES');
     }
     return sfView::NONE;
 }
 /**
  * Update existing text
  * @param sfWebRequest $request
  * @return <type>
  */
 public function executeUpdateText(sfWebRequest $request) {
     $data = $request->getPostParameters();
     $data['content'] = $data['contenttype'] == 'plain' ? $data['content_textarea'] : $data['content_htmleditor'];        
     $result = AdditionalTextTable::instance()->updateText($data,$request->getParameter('id'));
     $this->renderText('{success:true}');
     return sfView::NONE;
 }
Beispiel #3
0
 /**
  * Saves new or update role. Echoes error/success message
  */
 public function executeSave(sfWebRequest $request)
 {
     if (!$this->getUser()->hasCredential(array('Administrator'), false)) {
         $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer());
         $this->redirect('dashboard/index');
     }
     $id = $request->getParameter('id');
     if ($id) {
         $role = RolePeer::retrieveByPK($id);
         if (!$role instanceof Role) {
             return $this->renderText('<span style="color:red;">Role not found or is removed!</span>');
         }
         $form = new RoleForm($role);
     } else {
         $form = new RoleForm();
     }
     unset($form['_csrf_token']);
     $form->bind($request->getPostParameters());
     if ($form->isValid()) {
         $form->save();
         return $this->renderText('Role has been successfully saved!');
     } else {
         # FIXME display other field errors
         echo 'e1';
         # has error
         echo '<span style="color:red;">' . $form['title']->getError()->getMessage() . '</span>';
     }
     return sfView::NONE;
 }
Beispiel #4
0
 public function executeListBooking(sfWebRequest $request)
 {
     $this->form = new BookingForm();
     if ($request->isMethod('post')) {
         $this->form->bind($request->getPostParameters());
         if ($this->form->isValid()) {
             $values = $this->form->getValues();
             $emails = $values['input'];
             $tournament = TournamentTable::getInstance()->findOneById($values['tournament']);
             $num = 0;
             foreach ($emails as $email => $nick) {
                 $count = PlayerTable::getInstance()->findOneByEmail($email);
                 if ($count) {
                     $num++;
                     $this->getUser()->setFlash('error', $num . " joueurs déja inscrit(s).", false);
                 } else {
                     $player = $this->createBookedPlayer($email, $nick, $tournament);
                     $this->sendConfirmationMail($player);
                 }
             }
             $this->getUser()->setFlash('notice', count($emails) - $num . " joueurs inscrits.", false);
         } else {
             $this->getUser()->setFlash('error', "Erreurs dans le formulaire.", false);
         }
     }
 }
    /**
     * Create the config file with the database settings and write email settings
     *
     * @param sfWebRequest $request
     * @return <type>
     */
    public function executeSaveData(sfWebRequest $request) {
        $sysObj = new SystemSetting();
        $installer = new Installer();
        $data = $request->getPostParameters();
        $installer->createConfigFile($data); // write settings in database.yml
        // create DB
        $task = new sfDoctrineBuildAllReLoadTask(sfContext::getInstance()->getEventDispatcher(), new sfFormatter());
        chdir(sfConfig::get('sf_root_dir'));
        $task->run(array(),array('--no-confirmation', '--env=all', '--dir='.sfConfig::get('sf_root_dir').'/data/fixtures/'.$data['productive_data'].''));
        $data = $sysObj->buildEmailSetting($data);
        UserLoginTable::instance()->updateEmail($data['productive_emailadresse']);
        EmailConfigurationTable::instance()->updateEmailConfiguration($data);
        // clear cache
        $taskCC = new sfCacheClearTask(sfContext::getInstance()->getEventDispatcher(), new sfFormatter());
        $taskCC->run(array(), array());
        // create JS Cache
        $ccCache = new TemplateCaching();
        $ccCache->checkCacheDir();
        $ccCache->setFiles();
        $lastModified = $ccCache->getLastModifiedFile();
        $cacheCreated = $ccCache->getCurrentCacheStamp();

        if($lastModified > $cacheCreated OR $cacheCreated == '') {
            if($cacheCreated == '') {
                $cacheCreated = $lastModified;
            }
            $ccCache->createCache($lastModified, $cacheCreated);
        }
        // return success, then JS redirect
        $this->renderText('{success:true}');
        return sfView::NONE;
    }
 /**
  * Saving project
  *
  * @param sfWebRequest $request 
  * @author Sergey Startsev
  */
 public function executeSave(sfWebRequest $request)
 {
     $params = $request->getPostParameters();
     unset($params['latest']);
     unset($params['path']);
     $parameters = array('params' => $request->getParameter('params'));
     $response = afStudioCommand::process('project', 'save', $parameters);
     return $this->renderJson($response);
 }
 /**
  * Action called by the Paypal server to confirm the client's transaction.
  *
  * @param sfWebRequest $request
  * @return void
  */
 public function executeIpn(sfWebRequest $request)
 {
     //--------------------------------------------------------------------------
     // instanciate application specific Paypal Interface
     //--------------------------------------------------------------------------
     $pp_class = sfConfig::get('app_es_paypal_plugin_handler', 'esPaypalHandler');
     $pp = new $pp_class();
     //--------------------------------------------------------------------------
     // handle data posted by Paypal (store as transaction)
     //--------------------------------------------------------------------------
     $pp->handleIpn($request->getPostParameters());
     return sfView::NONE;
 }
 /**
  * Update a documenttemplate, and create a new version
  * @param sfWebRequest $request
  * @return <type>
  */
 public function executeUpdateDocumenttemplate(sfWebRequest $request) {
     $docObj = new Documenttemplate();
     $data = $request->getPostParameters();
     DocumenttemplateVersionTable::instance()->setTemplateInactiveById($request->getParameter('id')); // set old template inactive
     $template_array = DocumenttemplateVersionTable::instance()->getDocumentTemplateId($request->getParameter('id'))->toArray(); // get old template
     $template_id = $template_array[0]['documenttemplate_id'];
     $version = $template_array[0]['version']+1;// create the nexte version of the template
     $version_id = $docObj->storeVersion($template_id, $version); // write new version
     $slots = $data['slot'];
     $docObj->storeData($slots, $version_id); // store slots
     $this->renderText('{success:true}');
     return sfView::NONE;
 }
Beispiel #9
0
 public function executeRating(sfWebRequest $request)
 {
     if ($request->isXmlHttpRequest()) {
         $postParam = $request->getRequestParameters();
         $postParam2 = $request->getPostParameters();
         if ((array_key_exists('rating', $postParam) || array_key_exists('rating', $postParam2)) && array_key_exists('querytrackid', $postParam) && array_key_exists('resulttrackid', $postParam) && array_key_exists('resultposition', $postParam) && array_key_exists('featurevectortypeid', $postParam) && array_key_exists('distancetypeid', $postParam)) {
             $rating = array_key_exists('rating', $postParam) ? $postParam['rating'] : $postParam2['rating'];
             QueryCommentTrackPeer::updateRating($rating, $postParam['querytrackid'], $postParam['resulttrackid'], $postParam['resultposition'], $postParam['featurevectortypeid'], $postParam['distancetypeid']);
             return $this->renderText($postParam['rating']);
         }
     }
     $this->getResponse()->setStatusCode(500);
     return $this->renderText("Comment was not saved! Please contact us about the problem." . print_r($postParam, true) . print_r($postParam2, true));
 }
 public function executeResult(sfWebRequest $request)
 {
     $transactionId = (int) $request->getParameter('OrderID');
     $invoice = Doctrine::getTable('Invoice')->findOneByTransactionId($transactionId);
     $this->forward404Unless($invoice, 'Invoice not found.');
     // Оповещение о платеже
     $form = new SentryResultForm($invoice);
     $form->bind($params = $request->getPostParameters());
     if ($form->isValid()) {
         $this->complete($invoice, $params);
     }
     $this->responseCode = @$params['ResponseCode'];
     $this->reasonCode = @$params['ReasonCode'];
     $this->reasonCodeDesc = @$params['ReasonCodeDesc'];
 }
Beispiel #11
0
 /**
  *
  * @param sfWebRequest $request 
  * @return WSRequestParameters
  */
 public function extractParameters(sfWebRequest $request)
 {
     $webRequestParameters = new WSRequestParameters();
     $logger = Logger::getLogger('core.webservices');
     $requestMethod = $request->getMethod();
     $contentType = $request->getContentType();
     $logger->debug("HTTP Method: {$requestMethod}, Content-Type: {$contentType}");
     $requestParameters = $request->getRequestParameters();
     $logger->debug("Request Parameters: " . print_r($requestParameters, true));
     if (!isset($requestParameters['ws_method'])) {
         throw new WebServiceException('Web service method is not specified', 400);
     }
     $webServiceMethod = $requestParameters['ws_method'];
     $methodParameters = array();
     // Checking for deprecated method of sending parameters using an http header
     $header = $request->getHttpHeader('ohrm_ws_method_parameters');
     if (!empty($header)) {
         $methodParameters = json_decode($header, true);
         if (!is_array($methodParameters)) {
             throw new WebServiceException("header ohrm_ws_method_parameters should be json encoded", 400);
         }
     } else {
         // get request parameters in URL (eg: /empNumber/11) after removing the default parameters
         $methodParameters = array_diff_key($requestParameters, array_flip(array('action', 'module', 'ws_method', '_sf_route')));
         // Merge with GET parameters
         $methodParameters = array_merge($methodParameters, $request->getGetParameters());
         // Check for JSON encoded body
         if ($contentType === 'application/json') {
             $postParams = json_decode(file_get_contents('php://input'), true);
             $methodParameters = array_merge($methodParameters, $postParams);
         } else {
             if ($requestMethod === 'POST') {
                 $methodParameters = array_merge($methodParameters, $request->getPostParameters());
             }
         }
     }
     //        $arrayName = $this->getArrayNameForFunction($function);
     //        if(!array_key_exists($arrayName, $methodParameters)) {
     //            throw new WebServiceException('Required array name not provided', 404);
     //        }
     $webRequestParameters->setRequestMethod($requestMethod);
     $webRequestParameters->setMethod($webServiceMethod);
     $webRequestParameters->setParameters($methodParameters);
     //        $webRequestParameters->setAppId($authenticationParamerters['app_id']);
     //        $webRequestParameters->setAppToken($authenticationParamerters['app_token']);
     //        $webRequestParameters->setSessionToken($authenticationParamerters['session_token']);
     return $webRequestParameters;
 }
Beispiel #12
0
 /**
  * Executes showLecture action
  *
  * @param sfRequest $request A request object
  */
 public function executeShowLecture(sfWebRequest $request)
 {
     $this->lecture = $this->getRoute()->getObject();
     $this->course = $this->lecture->Course;
     $this->forms['homework'] = new HomeworkForm();
     $this->forms['aid'] = new AidForm();
     if ($request->isMethod('POST')) {
         $types = array_keys($request->getPostParameters());
         $this->executeUploadFile($request, $types[0]);
     }
     $this->setVar('lecture', $this->lecture);
     $this->setVar('course', $this->course);
     $this->setVar('form', $this->forms['homework']);
     $this->setVar('aidForm', $this->forms['aid']);
     $this->setVar('user', $this->user);
 }
 /**
  * Result URL
  */
 public function executeResult(sfWebRequest $request)
 {
     $invoiceId = (int) $request->getParameter('WMI_PAYMENT_NO');
     $invoice = Doctrine::getTable('Invoice')->findOneById($invoiceId);
     if (!$invoice) {
         return $this->renderText('WMI_RESULT=RETRY&WMI_DESCRIPTION=INVOICE NOT FOUND');
         return sfView::NONE;
     }
     $form = new W1ResultForm($invoice);
     $form->bind($params = $request->getPostParameters());
     if ($form->isValid()) {
         $this->complete($invoice, $params);
         return $this->renderText('WMI_RESULT=OK');
     }
     return $this->renderText('WMI_RESULT=RETRY&WMI_DESCRIPTION=INVALID FORM');
 }
Beispiel #14
0
 public function executeUpdateEquivalence(sfWebRequest $request)
 {
     $parametrs = $request->getPostParameters();
     $this->career_school_year = CareerSchoolYearPeer::retrieveByPK($parametrs['career_school_year_id']);
     $this->career = $this->career_school_year->getCareer();
     $this->career_subject_school_years = array();
     $this->years = array();
     $this->forms = array();
     for ($y = 1; $y <= $this->career->getQuantityYears(); $y++) {
         $this->years[] = $y;
         $this->career_subject_school_years[$y] = $this->career->getCareerSubjectsForYear($y, true);
     }
     unset($parametrs['_save']);
     unset($parametrs['career_school_year_id']);
     $valid = true;
     foreach ($parametrs as $parameter) {
         $career_subject_id = $parameter['career_subject_id'];
         $student_id = $parameter['student_id'];
         $school_year_id = $parameter['school_year'];
         $career_subject = CareerSubjectPeer::retrieveByPK($career_subject_id);
         $student = StudentPeer::retrieveByPK($student_id);
         $student_approved_career_subject = StudentApprovedCareerSubjectPeer::retrieveOrCreateByCareerSubjectAndStudent($career_subject->getId(), $student->getId());
         $student_approved_career_subject->setSchoolYearId($school_year_id);
         $parameter['career_subject_id'] = $student_approved_career_subject->getCareerSubjectId();
         $this->form = new EquivalenceForm($student_approved_career_subject);
         $this->form->setCareerSubjectAndStudent($career_subject, $student);
         if (isset($parameter['mark']) && $parameter['mark'] != "") {
             $this->form->bind($parameter);
             if ($this->form->isValid()) {
                 $this->form->save();
             } else {
                 $valid = false;
             }
         }
         $this->form = new EquivalenceForm($student_approved_career_subject);
         $this->form->setCareerSubjectAndStudent($career_subject, $student);
         $this->forms[$career_subject->getId()] = $this->form;
         $parameter['career_subject_id'] = $career_subject_id;
     }
     if ($valid) {
         $this->getUser()->setFlash('notice', 'subjects are updated correctly');
     } else {
         $this->setProcessFormErrorFlash();
     }
     $this->module = $this->getModuleName();
     $this->setTemplate('makeUpEquivalence');
 }
 public function executeResult(sfWebRequest $request)
 {
     $invoiceId = (int) $request->getParameter('order_id');
     $invoice = Doctrine::getTable('Invoice')->findOneById(intval($orderId));
     $this->forward404Unless($invoice, 'Invoice not found.');
     // Оповещение о платеже
     $form = new LiqpayResultForm($invoice);
     $form->bind($params = $request->getPostParameters());
     if ($form->isValid()) {
         $this->status = $request->getParameter('status');
         if ($this->status == 'success') {
             $this->complete($invoice, $params);
         }
     } else {
         $this->status = 'failure';
     }
 }
Beispiel #16
0
 public function executeAddSubject(sfWebRequest $request)
 {
     if ($request->isMethod('POST')) {
         $params = $request->getPostParameters();
         $this->course = CoursePeer::retrieveByPk($params['course']['id']);
         $this->form = new SubjectForPathwayCommissionForm($this->course);
         $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName()));
         if ($this->form->isValid()) {
             $this->form->save();
             $this->getUser()->setFlash("notice", "New subject added to commission successfully");
             $this->redirect("@pathway_commission");
         }
     } else {
         $this->course = $this->getRoute()->getObject();
         $this->course_subjects = $this->course->getCourseSubjects();
         $this->form = new SubjectForPathwayCommissionForm($this->course);
     }
 }
 public function executeSearch(sfWebRequest $request)
 {
     $form = $request->getPostParameters();
     $this->searchForm = new GcrSearchEschoolForm();
     $this->eschoolList = '';
     if ($request->isMethod(sfRequest::POST)) {
         $form['eschoolPattern'] = stripslashes(trim($form['eschoolPattern']));
         $this->searchForm->bind($form);
         if ($this->searchForm->isValid()) {
             $exact_matches_start_of_first_word = array();
             $exact_matches_start_of_word = array();
             $exact_matches_middle_of_word = array();
             $inexact_matches = array();
             $pattern = strtolower($form['eschoolPattern']);
             $search = new Approximate_Search($pattern, 1);
             $institutions = Doctrine::getTable('GcrInstitution')->findAll();
             foreach ($institutions as $institution) {
                 if (!$institution->is_internal) {
                     $full_name = strtolower($institution->getFullName());
                     $matches = $search->search($full_name);
                     if (count($matches) > 0) {
                         $index = strpos($full_name, $pattern);
                         if ($index || $index === 0) {
                             if ($index == 0) {
                                 $exact_matches_start_of_first_word[$institution->getShortName()] = $institution;
                             } else {
                                 if ($full_name[$index - 1] == ' ') {
                                     $exact_matches_start_of_word[$institution->getShortName()] = $institution;
                                 } else {
                                     $exact_matches_middle_of_word[$institution->getShortName()] = $institution;
                                 }
                             }
                         } else {
                             $inexact_matches[$institution->getShortName()] = $institution;
                         }
                     }
                 }
             }
             $this->eschoolList = array($exact_matches_start_of_first_word, $exact_matches_start_of_word, $exact_matches_middle_of_word, $inexact_matches);
         }
     }
     $this->getResponse()->setTitle('Global Classroom - Search for a Community');
     $this->getResponse()->addMeta('description', 'Search for a Community on the Global Classroom platform');
 }
Beispiel #18
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $files = $request->getFiles();
     $params = $request->getPostParameters();
     $this->forward404if(!isset($params['guid']) || !isset($params['from_date_sync']) || !isset($params['to_date_sync']) || !isset($params['origin']) || !isset($files['dump_intranet']));
     $dump_intranet = sfConfig::get('sf_root_dir') . '/' . sfConfig::get('app_sync_dump_dir') . '/' . $files['dump_intranet']['name'];
     rename($files['dump_intranet']['tmp_name'], $dump_intranet);
     $sync_log = new SyncLog();
     $sync_log->setGuid($params['guid']);
     $sync_log->setFromDatetimeSync($params['from_date_sync']);
     $sync_log->setToDatetimeSync($params['to_date_sync']);
     $sync_log->setOrigin($params['origin']);
     $sync = new ServerVipSync($this->getContext()->getConfiguration(), $sync_log, 'internet');
     $dump_internet = $sync->internetSync();
     $file = fopen($dump_internet, 'r');
     $data = fread($file, filesize($dump_internet));
     fclose($file);
     $this->getResponse()->setContent($data);
     return sfView::NONE;
 }
Beispiel #19
0
 public function executeStep2(sfWebRequest $request)
 {
     $this->forwardClosedIfNoEventUpcoming();
     $tournament = $this->getUser()->getAttribute('tournament');
     $this->forward404Unless($tournament and $tournament instanceof Tournament);
     $this->forwardIf($tournament->isFull(), "registration", "full");
     $this->form = new TournamentSignupForm(array(), array('tournament' => $tournament));
     if ($request->isMethod('post')) {
         $this->form->bind($request->getPostParameters());
         if ($this->form->isValid()) {
             $this->form->save();
             $players = $this->form->getPlayers();
             $this->getUser()->setAttribute('players', $players);
             $this->getUser()->setFlash('notice', "Inscription prise en compte !", false);
             $this->redirect("registration/confirm");
         } else {
             $this->getUser()->setFlash('error', "Erreurs dans le formulaire.", false);
         }
     }
 }
Beispiel #20
0
 public function executeUpdatePassword(sfWebRequest $request)
 {
     $form = $request->getPostParameters();
     if (md5($form['cpw']) == $form['user_pw']) {
         $dao = new DAO();
         $dao->query("UPDATE be_user SET password=MD5('{$form['npw']}') WHERE email='{$form['user_email']}'");
         if ($dao->updateOK()) {
             $html = 'Your password has been changed successfully.';
         } else {
             $err = $dao->getError();
             $html = "Your password has not been changed.<br />{$err}";
         }
     } else {
         $html = 'Your supplied current password is invalid.  Your password was not changed.';
     }
     $response = $this->getResponse();
     $response->setContentType('text/html');
     $response->sendHttpHeaders();
     return $this->renderText($html);
 }
Beispiel #21
0
 public function executeApply_api(sfWebRequest $request)
 {
     $this->pUser = $this->getUser()->getGuardUser();
     $this->pPaymentMethods = $this->getUser()->getGuardUser()->getPaymentMethods();
     $this->pPaymentMethodForm = new PaymentMethodForm();
     if ($request->getMethod() == 'POST') {
         $lParams = $request->getPostParameters();
         $lIsNew = true;
         $lParams['sf_guard_user_id'] = $this->getUser()->getUserId();
         //check if the user selected an old address or if he inserted a new
         //if he selected an old, overwrite the form-values with the database-data -> needet for validation
         if (isset($lParams['existing_pm_id']) && $lParams['existing_pm_id'] != 'false') {
             //find the selected pm object
             $lSelectedPM = PaymentMethodTable::getInstance()->find($lParams['existing_pm_id']);
             //fill the values for validation
             $lParams['company'] = $lSelectedPM->getCompany();
             $lParams['contact_name'] = $lSelectedPM->getContactName();
             $lParams['address'] = $lSelectedPM->getAddress();
             $lParams['zip'] = $lSelectedPM->getZip();
             $lParams['city'] = $lSelectedPM->getCity();
             //$lParams['payment_method_id'] = $lParams['existing_pm_id'];
             //bind the object to the form -> needed for update (if you don't do this, symfony always inserts a new db entry)
             $this->pPaymentMethodForm = new PaymentMethodForm($lSelectedPM);
         }
         $lParams['api_method'] = true;
         //unset the param, that check, if user selected an existent payment method
         unset($lParams['existing_pm_id']);
         $this->pPaymentMethodForm->bind($lParams);
         if ($this->pPaymentMethodForm->isValid()) {
             $lPm = $this->pPaymentMethodForm->save();
             $lText = "Der User " . $this->pUser->getFirstName() . " " . $this->pUser->getLastName() . " (" . $this->pUser->getUsername() . ") ";
             $lText .= "mit der Email-Adresse " . $this->pUser->getEmailAddress() . " hat einen API Key beantragt. Um ihn zu bearbeiten bitte folgenden Link klicken: \n\n";
             $lText .= sfConfig::get("app_settings_url") . "/backend.php/guard/users/" . $this->pUser->getId() . "/edit";
             //backend/guard/users/2/edit
             //app_settings_support_email
             sfContext::getInstance()->getMailer()->composeAndSend(array(sfConfig::get("app_email_address") => sfConfig::get("app_email_sender")), sfConfig::get("app_settings_support_email"), 'Neue Api Anfrage', $lText);
             $this->redirect('advertiser/apply_api_thanks');
         }
     }
 }
Beispiel #22
0
 public function executeUpdateConfiguration(sfWebRequest $request)
 {
     $this->career_subject_school_year = CareerSubjectSchoolYearPeer::retrieveByPK($request->getParameter('id'));
     if (null === $this->career_school_year) {
         $this->getUser()->setFlash('error', 'Debe seleccionar una carrera para editar su configuracion');
         $this->redirect('@career_school_year');
     }
     $subject_configuration = $this->career_subject_school_year->getSubjectConfigurationOrCreate();
     $this->career_subject_school_year->setSubjectConfiguration($subject_configuration);
     $parameters = $request->getPostParameters();
     $parameter = $parameters["subject_configuration"];
     if ($this->career_subject_school_year->hasChoices()) {
         $course_subjects = array();
         foreach ($this->career_subject_school_year->getChoices() as $option) {
             $course_subjects = array_merge($course_subjects, CourseSubjectPeer::retrieveByCareerSubjectSchoolYear($option->getChoiceCareerSubjectSchoolYearId()));
         }
     } else {
         $course_subjects = CourseSubjectPeer::retrieveByCareerSubjectSchoolYear($this->career_subject_school_year->getId());
     }
     //actualización de las notas para los cursos
     $this->updateCourseMarksConfiguration($parameter, $subject_configuration, $course_subjects);
     //actualización del tipo de curso para los cursos
     $this->updateCourseTypeConfiguration($parameter, $subject_configuration, $course_subjects);
     //actualización del tipo de asistencia para los cursos y las asistencias de los alumnos
     $this->updateStudentAssistanceConfiguration($parameter, $subject_configuration, $course_subjects);
     $form_name = SchoolBehaviourFactory::getInstance()->getFormFactory()->getCareerSubjectSchoolYearConfigurationForm();
     $this->form = new $form_name($subject_configuration);
     $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName()));
     if ($this->form->isValid()) {
         $notice = $this->getProcessFormNotice($this->form->getObject()->isNew());
         $subject_configuration = $this->form->save();
         $this->getUser()->setFlash('notice', $notice);
     } else {
         $this->setProcessFormErrorFlash();
     }
     $this->setTemplate('configuration');
 }
 /**
  * Add first step
  *
  * @author Guillermo Rauch
  **/
 public function executeAdd(sfWebRequest $request)
 {
     $this->form = new PluginAddStep1Form();
     if ($request->isMethod('post')) {
         $addid = uniqid(time() . rand(555555, 666666));
         if ($request->getParameter('id')) {
             $plugin = PluginPeer::retrieveBySlug($request->getParameter('id'));
             $this->forward404Unless($plugin && $this->getUser()->ownsPlugin($plugin));
             $this->getUser()->setAttribute('step', 1, 'plugin.add.' . $addid);
             $this->getUser()->setAttribute('id', $plugin->getId(), 'plugin.add.' . $addid);
             $this->getUser()->setAttribute('github.user', $plugin->getGithubuser(), 'plugin.add.' . $addid);
             $this->getUser()->setAttribute('github.repository', $plugin->getGithubrepo(), 'plugin.add.' . $addid);
             return $this->renderJson(array('success' => true, 'addid' => $addid, 'status' => 'Verifying GIT Tags'));
         }
         $this->form->bind($request->getPostParameters());
         if ($this->form->isValid()) {
             $this->getUser()->setAttribute('step', 1, 'plugin.add.' . $addid);
             $this->getUser()->setAttribute('github.user', $this->form->getGitHubUser(), 'plugin.add.' . $addid);
             $this->getUser()->setAttribute('github.repository', $this->form->getGitHubRepository(), 'plugin.add.' . $addid);
             return $this->renderJson(array('success' => true, 'addid' => $addid, 'status' => 'Verifying GIT Tags'));
         }
         return $this->renderJson($this->form->toJson());
     }
 }
Beispiel #24
0
 /**
  * Saves new or update role. Echoes error/success message
  */
 public function executeSave(sfWebRequest $request)
 {
     $id = $request->getParameter('id');
     if ($id) {
         $role = PermissionPeer::retrieveByPK($id);
         if (!$role instanceof Permission) {
             return $this->renderText('<span style="color:red;">Right not found or is removed!</span>');
         }
         $form = new PermissionForm($role);
     } else {
         $form = new PermissionForm();
     }
     unset($form['_csrf_token']);
     $form->bind($request->getPostParameters());
     if ($form->isValid()) {
         $form->save();
         return $this->renderText('Right has been successfully saved!');
     } else {
         echo 'e1';
         # has error
         echo '<span style="color:red;">';
         $i = 0;
         if ($form['title']->hasError()) {
             echo $form['title']->getError()->getMessage();
             $i++;
         }
         if ($form['code']->hasError()) {
             if ($i) {
                 echo '<br/>';
             }
             echo $form['code']->getError()->getMessage();
         }
         echo '</span>';
     }
     return sfView::NONE;
 }
 public function getPostParameter($name, $default = null, $isStripNullbyte = true)
 {
     if ($isStripNullbyte) {
         return opToolkit::stripNullByteDeep(parent::getPostParameter($name, $default));
     } else {
         return parent::getPostParameters($name, $default);
     }
 }
 public function executeCreate(sfWebRequest $request)
 {
     global $CFG;
     $CFG->current_app->requireMahara();
     $current_user = $CFG->current_app->getCurrentUser();
     if (!$current_user->getRoleManager()->HasPrivilege('GCUser')) {
         $CFG->current_app->gcError("Unauthorized attempt to access eschool/create.", 'gcpageaccessdenied');
     }
     $this->formErrors = array();
     $this->eschoolForm = new GcrEschoolForm();
     $form = $request->getPostParameters();
     // validate form values
     $this->validateShortName($form['short_name']);
     if (!GcrEschoolTypeTable::validateEschoolType($form['eschool_type'])) {
         $this->formErrors['eschool_type'] = 'eSchool type is invalid.';
     }
     // make an address object to insert in to the address table for the address submitted
     $addressObject = new GcrAddress();
     $addressObject->setStreet1($form['street1']);
     $addressObject->setStreet2($form['street2']);
     $addressObject->setCity($form['city']);
     $addressObject->setState($form['state']);
     $addressObject->setCountry($form['country']);
     $addressObject->setZipcode($form['zipcode']);
     // Try to add the eschool's address to the address table
     $addressObject->save();
     // make a person object to insert in to the person table for contact 1
     $personObject = new GcrPerson();
     $personObject->setFirstName($form['first_name']);
     $personObject->setLastName($form['last_name']);
     $personObject->setAddress($addressObject->getId());
     $personObject->setPhone1($form['phone1']);
     $personObject->setPhone2($form['phone2']);
     $personObject->setEmail($form['email']);
     // Try to add the contact 1 to the person table
     $personObject->save();
     // make a person object to insert in to the person table for contact 2
     $person2Object = new GcrPerson();
     $person2Object->setFirstName($form['first_name_2']);
     $person2Object->setLastName($form['last_name_2']);
     $person2Object->setAddress($addressObject->getId());
     $person2Object->setPhone1($form['phone1_2']);
     $person2Object->setPhone2($form['phone2_2']);
     $person2Object->setEmail($form['email_2']);
     // try to add the contact 2 to the person table
     $person2Object->save();
     // make an array of values to validate as the eschool form
     $eschoolFields = array('id' => '', 'full_name' => $form['full_name'], 'short_name' => strtolower($form['short_name']), 'external_url' => $form['external_url'], 'logo' => $CFG->current_app->getLogo(), 'suspended' => '', 'can_sell' => '', 'contact1' => $personObject->getId(), 'contact2' => $person2Object->getId(), 'address' => $addressObject->getId(), 'eschool_type' => $form['eschool_type'], 'eschool_creator' => $CFG->current_app->getId(), 'admin_password' => GcrEschoolTable::generateAdminPassword(), 'password_salt' => GcrEschoolTable::generateRandomString(), 'creation_date' => time(), 'organization_id' => $CFG->current_app->getId(), 'visible' => '1', 'street1' => $form['street1'], 'street2' => $form['street2'], 'city' => $form['city'], 'state' => $form['state'], 'country' => $form['country'], 'zipcode' => $form['zipcode'], 'first_name' => $form['first_name'], 'last_name' => $form['last_name'], 'phone1' => $form['phone1'], 'phone2' => $form['phone2'], 'email' => $form['email'], 'first_name_2' => $form['first_name_2'], 'last_name_2' => $form['last_name_2'], 'phone1_2' => $form['phone1_2'], 'phone2_2' => $form['phone2_2'], 'email_2' => $form['email_2'], '_csrf_token' => $form['_csrf_token']);
     // try to add the eschool data to the eschool table
     if (!($eschoolRecord = $this->processForm($eschoolFields, $this->eschoolForm, $request->getFiles()))) {
         $this->formErrors['eschoolRecord'] = 'Some Field(s) Have Missing or Incorrect Data';
     }
     // If the eschool record was saved, we need to also add a trial record for it
     if (count($this->formErrors) == 0) {
         // create the eschool if everything is valid
         $eschoolRecord->create();
         $this->emailNewEschoolGC($eschoolRecord, $personObject, $person2Object);
         // send user to the newly created eschool
         $this->redirect($eschoolRecord->getUrl());
     } else {
         $addressObject->delete();
         $personObject->delete();
         $person2Object->delete();
         $this->getResponse()->setTitle('Create a Trial eSchool');
         $this->setTemplate('new');
     }
 }
 /**
  * Created by: Ron Stewart
  * Date: 9/8/2011
  * This function was designed to set all non-siteadmin accounts to not receive emails (internal)
  * This was used to prevent spamming where bulk uploaded users were assigned random email
  * addresses at globalclassroom.us
  */
 public function executeTurnOffEmails(sfWebRequest $request)
 {
     global $CFG;
     $this->checkAuthorization();
     $this->forward404Unless($request->isMethod(sfRequest::POST));
     $form = $request->getPostParameters();
     if ($institution = Doctrine::getTable('GcrInstitution')->find($form['institution'])) {
         $i = 0;
         foreach ($institution->selectFromMhrTable('usr') as $mhr_user_obj) {
             $mhr_user = new GcrMhrUser($mhr_user_obj, $institution);
             if (!$mhr_user->getRoleManager()->hasPrivilege('EschoolStaff') && $mhr_user_obj->id != 0) {
                 $filters = array();
                 $filters[] = new GcrDatabaseQueryFilter('field', '=', 'maildisabled');
                 $filters[] = new GcrDatabaseQueryFilter('usr', '=', $mhr_user_obj->id);
                 $q = new GcrDatabaseQuery($institution, 'usr_account_preference', 'select * from', $filters);
                 if ($q->executeQuery(true)) {
                     $institution->updateMhrTable('usr_account_preference', array('value' => '1'), array('usr' => $mhr_user_obj->id, 'field' => 'maildisabled'));
                 } else {
                     $institution->insertIntoMhrTable('usr_account_preference', array('usr' => $mhr_user_obj->id, 'field' => 'maildisabled', 'value' => '1'));
                 }
                 $i++;
             }
         }
         $_SESSION['adminEschoolActionMessage'] = $institution->getFullName() . ' (' . $institution->getShortName() . '): ' . $i . ' users had emailing turned off';
     } else {
         $CFG->current_app->gcError('Invalid Institution Id: ' . $form['institution'], 'gcdatabaseerror');
     }
     $this->redirect($CFG->current_app->getUrl() . '/admin/eschool');
 }
 /**
  * Executes render action
  *
  * @param sfWebRequest $request
  */
 public function executeRender(sfWebRequest $request)
 {
     include_once sfConfig::get('sf_lib_dir') . '/vendor/OAuth/OAuth.php';
     $this->memberApplication = Doctrine::getTable('MemberApplication')->findOneByApplicationAndMember($this->application, $this->member);
     $this->redirectUnless($this->memberApplication, '@application_info?id=' . $this->application->getId());
     $views = $this->application->getViews();
     $this->forward404Unless(isset($views['mobile']) && isset($views['mobile']['type']) && isset($views['mobile']['href']) && 'URL' === strtoupper($views['mobile']['type']));
     $url = $request->getParameter('url', $views['mobile']['href']);
     $zendUri = Zend_Uri_Http::fromString($url);
     $queryString = $zendUri->getQuery();
     $zendUri->setQuery('');
     $zendUri->setFragment('');
     $url = $zendUri->getUri();
     $query = array();
     parse_str($queryString, $query);
     $params = array('opensocial_app_id' => $this->application->getId(), 'opensocial_owner_id' => $this->member->getId());
     $params = array_merge($query, $params);
     $method = $request->isMethod(sfWebRequest::POST) ? 'POST' : 'GET';
     $consumer = new OAuthConsumer(opOpenSocialToolKit::getOAuthConsumerKey(), null, null);
     $signatureMethod = new OAuthSignatureMethod_RSA_SHA1_opOpenSocialPlugin();
     $httpOptions = opOpenSocialToolKit::getHttpOptions();
     $client = new Zend_Http_Client();
     if ('POST' !== $method) {
         $client->setMethod(Zend_Http_Client::GET);
         $url .= '?' . OAuthUtil::build_http_query($params);
     } else {
         $params = array_merge($params, $request->getPostParameters());
         $client->setMethod(Zend_Http_Client::POST);
         $client->setHeaders(Zend_Http_Client::CONTENT_TYPE, Zend_Http_Client::ENC_URLENCODED);
         $client->setRawData(OAuthUtil::build_http_query($params));
     }
     $oauthRequest = OAuthRequest::from_consumer_and_token($consumer, null, $method, $url, $params);
     $oauthRequest->sign_request($signatureMethod, $consumer, null);
     $client->setConfig($httpOptions);
     $client->setUri($url);
     $client->setHeaders($oauthRequest->to_header());
     $client->setHeaders(opOpenSocialToolKit::getProxyHeaders($request, sfConfig::get('op_opensocial_is_strip_uid', true)));
     $response = $client->request();
     if ($response->isSuccessful()) {
         $contentType = $response->getHeader('Content-Type');
         if (preg_match('#^(text/html|application/xhtml\\+xml|application/xml|text/xml)#', $contentType, $match)) {
             header('Content-Type: ' . $match[0] . '; charset=Shift_JIS');
             echo opOpenSocialToolKit::rewriteBodyForMobile($this, $response->getBody());
             exit;
         } else {
             header('Content-Type: ' . $response->getHeader('Content-Type'));
             echo $response->getBody();
             exit;
         }
     }
     return sfView::ERROR;
 }
Beispiel #29
0
 public function executeRepeatResult(sfWebRequest $request)
 {
     // print 'executeRepeatList<br />';
     $this->forward404Unless($request->isMethod('post'));
     $this->forward404Unless($this->reservation = ReservationPeer::retrieveByPk($request->getParameter('id')), sprintf('Object reservation does not exist (%s).', $request->getParameter('id')));
     $this->room = $this->reservation->getRoomprofile()->getRoom();
     $next_id = $this->reservation->getId();
     $result = true;
     //
     $formRepeat = $this->getUser()->getAttribute('form_tmp');
     // --------------------
     $formRepeat->bind($request->getParameter($formRepeat->getName()), $request->getFiles($formRepeat->getName()));
     $this->forms = $formRepeat->getReservationForms();
     $checked_list = $request->getPostParameters();
     // var_dump($checked_list);
     // var_dump($forms);
     $ids = array();
     foreach ($checked_list as $id) {
         array_push($ids, $id);
     }
     // var_dump($ids);
     if (empty($ids) || is_null($ids)) {
         $this->setTemplate('processRepeat');
     }
     $j = 0;
     $this->formsResult = array();
     foreach ($this->forms as $form) {
         // print '============><br />'.$j.' '.count($this->forms).'<br />';
         $i = 0;
         $checked = false;
         while (!$checked && $i < count($ids)) {
             // print $i.' : '.$ids[$i].'<br />';
             // if($this->forms[$j]->getObject()->getId() == $ids[$i])
             if ($form->getObject()->getId() == $ids[$i]) {
                 // print 'FORM '.$this->forms[$j]->getObject()->getId().' is checked<br />';
                 $checked = true;
             }
             $i++;
         }
         if ($checked) {
             // $reservation = $this->forms[$j]->getObject()->copy();
             $reservation = $form->getObject()->copy();
             $reservation->setReservationparentId($next_id);
             $resDate = $reservation->getDate();
             // $this->forms[$j] = new ReservationForm($reservation);
             // $this->forms[$j]->bindObject($reservation);
             $form = new ReservationForm($reservation);
             $form->bindObject($reservation);
             // if ($this->forms[$j]->isValid())
             if ($form->isValid()) {
                 // print 'IS VALID<br />';
                 // var_dump($this->forms[$j]->getObject());
                 // var_dump($form->getObject());
                 // $reservation = $this->forms[$j]->save();
                 $reservation = $form->save();
                 $next_id = $reservation->getId();
                 foreach ($this->reservation->getReservationOtherMemberss() as $value) {
                     $other_members = new ReservationOtherMembers();
                     $other_members->setReservationId($next_id);
                     $other_members->setUserId($value->getUserId());
                     $other_members->save();
                     // print('Reservation : '.$value.'<br/>Id user : '******'<br/>');
                 }
             } else {
                 // print 'NOT VALID<br />';
                 $result = false;
             }
             if ($checked) {
                 $form->getObject()->setDate($resDate);
             }
             $this->formsResult[] = $form;
             // print $this->forms[$j]->renderErrors();
             // print $form->renderErrors();
         }
         $j++;
     }
     if ($result) {
         $this->redirect('reservation/index?roomId=' . $this->reservation->getRoomprofile()->getRoomId());
     }
 }
 public function executeDeleteUserStorageFile(sfWebRequest $request)
 {
     global $CFG;
     $CFG->current_app->requireMahara();
     $CFG->current_app->requireLogin();
     $form = $request->getPostParameters();
     if ($file = $request->getParameter('file')) {
         $user_storage = new GcrUserStorageAccessS3();
         $user_storage->deleteObject($file);
     }
     $url = $CFG->current_app->getUrl() . '/institution/viewUserStorage';
     $folder = $request->getParameter('key');
     if (isset($folder)) {
         $url .= '?folder=' . $folder;
     }
     $this->redirect($url);
 }