Пример #1
0
 public function executeQuery(sfWebRequest $request)
 {
     if ($request->isXmlHttpRequest()) {
         if ($request->isMethod(sfRequest::GET)) {
             $startDate = $request->getGetParameter('startDate');
             $endDate = $request->getGetParameter('endDate');
             $page = $request->getGetParameter('page');
             $start = $request->getGetParameter('start');
             $limit = $request->getGetParameter('limit');
             $this->convertParamToDateTime($startDate);
             $this->convertParamToDateTime($endDate);
             $result = Doctrine_Core::getTable('Appointment')->getBetween($startDate, $endDate);
             $response = $this->buildResponse($result, "Loading Record");
         } else {
             if ($request->isMethod(sfRequest::POST)) {
                 $form_data = json_decode(file_get_contents('php://input'));
                 $location = $form_data->loc;
                 $title = $form_data->title;
                 $notes = $form_data->notes;
                 $url = $form_data->url;
                 $reminder = $form_data->rem;
                 $cid = $form_data->cid;
                 $startDate = str_replace('T', ' ', $form_data->start);
                 $endDate = str_replace('T', ' ', $form_data->end);
                 $this->convertParamToDateTime($startDate, 'Y-m-d H:i:s');
                 $this->convertParamToDateTime($endDate, 'Y-m-d H:i:s');
                 $a = new Appointment();
                 $a->fromArray(array('coach_id' => 1, 'client_id' => 1, 'calendar_type_id' => $cid, 'scheduled' => $startDate, 'started_at' => $startDate, 'finished_at' => $endDate, 'title' => $title, 'location' => $location, 'notes' => $notes, 'web_link' => $url, 'reminder' => $reminder));
                 $a->save();
                 $response = $this->buildResponse($a, "Creating Record");
             } else {
                 if ($request->isMethod(sfRequest::PUT)) {
                     $form_data = json_decode(file_get_contents('php://input'));
                     $location = $form_data->loc;
                     $title = $form_data->title;
                     $notes = $form_data->notes;
                     $url = $form_data->url;
                     $reminder = $form_data->rem;
                     $cid = $form_data->cid;
                     $startDate = str_replace('T', ' ', $form_data->start);
                     $endDate = str_replace('T', ' ', $form_data->end);
                     $this->convertParamToDateTime($startDate, 'Y-m-d H:i:s');
                     $this->convertParamToDateTime($endDate, 'Y-m-d H:i:s');
                     $a = Doctrine_Core::getTable('Appointment')->find(array($request->getParameter('id')));
                     $a->fromArray(array('coach_id' => 1, 'client_id' => 1, 'calendar_type_id' => $cid, 'scheduled' => $startDate, 'started_at' => $startDate, 'finished_at' => $endDate, 'title' => $title, 'location' => $location, 'notes' => $notes, 'web_link' => $url, 'reminder' => $reminder));
                     $a->save();
                     $response = $this->buildResponse($a, "Updating Record");
                 } else {
                     if ($request->isMethod(sfRequest::DELETE)) {
                         $app = Doctrine_Core::getTable('Appointment')->find(array($request->getParameter('id')));
                         $app->delete();
                         $response = array('success' => true, 'message' => 'Destroyed Record', 'data' => array());
                     }
                 }
             }
         }
         sfConfig::set('sf_web_debug', false);
         return $this->renderPartial('global/ajax', array('ajax' => json_encode($response)));
     }
 }
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $this->class = $request->getParameter('class');
     if (empty($this->class)) {
         $this->class = $request->getGetParameter('class');
     }
     $this->method = $request->getParameter('method');
     if (empty($this->method)) {
         $this->method = $request->getGetParameter('method');
     }
     if (!empty($this->method)) {
         $this->class = array($this->class, $this->method);
     }
     $this->viewer = new sfCodeViewer($this->class);
     if ($request->isXmlHttpRequest()) {
         sfProjectConfiguration::getActive()->loadHelpers('Url');
         $this->renderText($this->viewer->render(url_for('sfCodeView')));
         return sfView::NONE;
     } else {
         // maintain history
         $this->history = $this->getUser()->getAttribute('history', array());
         if (false !== ($index = array_search($this->class, $this->history))) {
             unset($this->history[$index]);
         }
         array_unshift($this->history, $this->class);
         array_splice($this->history, 10);
         $this->getUser()->setAttribute('history', $this->history);
     }
 }
Пример #3
0
 public function executeIndex(sfWebRequest $request)
 {
     $pageNumber = (int) $request->getGetParameter('page');
     $limit = 100;
     $offset = $limit * ($pageNumber > 1) ? $pageNumber - 1 : $pageNumber;
     $this->reservations = Doctrine_Core::getTable('Reservation')->createQuery('a')->where('deleted=false')->orderBy('a.arrival_date DESC')->limit($limit)->offset($offset)->execute();
 }
Пример #4
0
 /**
  * Executes matrix action
  *
  * @param sfRequest $request A request object
  */
 public function executeMatrix(sfWebRequest $request)
 {
     $dateFrom = $request->getGetParameter('dateFrom', date('Y-m-01'));
     $dateTo = $request->getGetParameter('dateTo', date('Y-m-01'));
     $currency = $request->getGetParameter('currency', 1);
     $account = $request->getGetParameter('account', null);
     $type = $request->getGetParameter('type', null);
     $dateFrom = new DateTime(preg_replace("/(\\d{2}).(\\d{2}).(\\d{4})/", "\$3-\$2-\$1", $dateFrom));
     $dateTo = new DateTime(preg_replace("/(\\d{2}).(\\d{2}).(\\d{4})/", "\$3-\$2-\$1", $dateTo));
     $currency = Doctrine::getTable('Currency')->findOneById($currency);
     $user = $this->getUser()->getUserRecord();
     $account = $account ? Doctrine::getTable('Account')->findOneById($account) : null;
     $report = new myReportMatrix($currency);
     $report->buildReport($user, $account, $dateFrom, $dateTo, $type);
     $result = array('headerLeft' => $report->getHeaderLeft(), 'headerTop' => $report->getHeaderTop(), 'matrix' => $report->getMatrix());
     return $this->renderJson($result);
 }
Пример #5
0
 public function executeIndex(sfWebRequest $request)
 {
     $this->getUser()->setAttribute('redirect_back', $this->getRequest()->getUri());
     $uid = $request->getParameter('uid');
     if ($uid == null) {
         $this->profile = Doctrine_Core::getTable('profile')->findOneByUsername($this->getUser()->getAttribute('username'));
     } else {
         $this->profile = Doctrine_Core::getTable('profile')->findOneByUid($uid);
     }
     $this->show_edit_link = !$request->hasParameter('uid') || $request->getGetParameter('uid') == $this->getUser()->getAttribute('id');
     $this->getUser()->setAttribute('viewing_profile_id', $this->profile->uid);
     $this->form = new WallpostForm();
 }
Пример #6
0
 public function executeAjaxSearch(sfWebRequest $request)
 {
     $query = $request->getGetParameter('query');
     $profiles = ProfileTable::findProfilesByNameSimilarTo($query);
     $display_string = "<table>";
     foreach ($profiles as $profile) {
         $display_string .= "<tr>";
         $url = $this->generateUrl('profile', array('uid' => $profile['uid']));
         $display_string .= "<td><img src = http://rks.ath.cx:8080/nexus+/web/images/" . $profile['pic'] . " width = '30' height = '30'/><a class = 'ajax_search_result' href = {$url}>" . $profile['name'] . "</a></td>";
         $display_string .= "</tr>";
     }
     $display_string .= "</table>";
     $this->renderText($display_string);
     //sleep(1);
     return sfView::NONE;
 }
Пример #7
0
 /**
  * Executes register action
  *
  * @param sfWebRequest $request A request object
  */
 public function executeRegister(sfWebRequest $request)
 {
     if (!StoreTable::getInstance()->getValueCached(StoreTable::REGISTER_ON)) {
         return $this->notFound();
     }
     $user = new sfGuardUser();
     $this->form = new RegisterForm($user);
     if ($request->getGetParameter('widgetval')) {
         $storage = sfContext::getInstance()->getStorage();
         if ($storage instanceof policatSessionStorage) {
             $storage->needSession();
         }
         $this->getUser()->setAttribute(myUser::SESSION_WIDGETVAL_ON, 1);
     }
     if ($request->isMethod('post')) {
         if (!$this->getUser()->human()) {
             return $this->captchaModal();
         }
         $this->form->bind($request->getPostParameter($this->form->getName()));
         if ($this->form->isValid()) {
             $user->setIsActive(false);
             $user = $this->form->updateObject();
             $user->setUsername($user->getEmailAddress());
             $user->setValidationKind(sfGuardUserTable::VALIDATION_KIND_REGISTER_LINK);
             $user->randomValidationCode();
             $user->save();
             $user->addPermissionByName(myUser::CREDENTIAL_USER);
             $subject = 'validate register';
             $body = "#VALIDATION-URL#";
             $store = StoreTable::getInstance()->findByKeyAndLanguageWithFallback(StoreTable::REGISTER_MAIL, $user->getLanguageId());
             if ($store) {
                 $subject = $store->getField('subject');
                 $body = $store->getField('body');
             }
             $subst = array('#VALIDATION-URL#' => $this->generateUrl('register_validation', array('id' => $user->getId(), 'code' => $user->getValidationCode()), true), '#USER-NAME#' => $user->getFullName());
             UtilMail::send(null, null, $user->getEmailAddress(), $subject, $body, null, $subst);
             return $this->ajax()->form($this->form)->attr('#register_form input, #register_form select, #register_form button', 'disabled', 'disabled')->scroll()->alert('Congratulations! You have created a new account. For your first login, you need to check your inbox ' . 'and click the account validation link in the e-mail we have sent to you.', 'Please check your inbox now!', '.page-header', 'after')->render();
         } else {
             return $this->ajax()->form($this->form)->render();
         }
     }
     $this->includeChosen();
 }
Пример #8
0
 public function executePetition(sfWebRequest $request)
 {
     $petition = PetitionTable::getInstance()->findById($request->getParameter('id'), $this->userIsAdmin());
     /* @var $petition Petition */
     if (!$petition) {
         return $this->notFound();
     }
     if (!$petition->isGeoKind()) {
         return $this->notFound();
     }
     if (!$petition->isEditableBy($this->getGuardUser())) {
         return $this->noAccess();
     }
     $target_list_id = $petition->getMailingListId();
     if ($target_list_id) {
         $target_list = $petition->getMailingList();
         if ($this->getGuardUser()->isTargetListMember($target_list, true)) {
             $this->csrf_token = UtilCSRF::gen('target_activate');
             $this->metas = $target_list->getMailingListMeta();
             if ($target_list->getCampaignId()) {
                 $this->campaign = $target_list->getCampaign();
                 if (!$this->userIsAdmin() && $this->campaign->getStatus() == CampaignTable::STATUS_DELETED) {
                     return $this->notFound();
                 }
                 $this->target_list = $target_list;
                 $this->form = new MailingListForm($target_list);
             }
         }
     }
     $this->petition = $petition;
     $this->target_form = new EditPetitionTargetForm($petition, array(EditPetitionTargetForm::USER => $this->getGuardUser()));
     $this->open_edit = $request->getGetParameter('e') ? true : false;
     $this->setTemplate('edit');
     $this->includeIframeTransport();
     $this->includeChosen();
 }
Пример #9
0
 public function executeExportRestApiDownloadCsv(sfWebRequest $request)
 {
     // Retrieve $_GET
     $test_session_id = $request->getGetParameter("id");
     $product_type = $request->getGetParameter("product");
     $project = $request->getGetParameter("release_version");
     $environment = $request->getGetParameter("target");
     $testset = $request->getGetParameter("testset");
     // Check test session id
     if (empty($test_session_id)) {
         echo "ERROR : test session id is not valid";
         exit;
     }
     $testSession = Doctrine_Core::getTable('TestSession')->findOneById($test_session_id);
     if (empty($testSession)) {
         echo "ERROR : test session id doesn't exist";
         exit;
     }
     Import::exportAsCsv($test_session_id);
 }
Пример #10
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $this->includeChosen();
     $this->no_campaign = $request->getGetParameter('no_campaign', 0) ? true : false;
 }
Пример #11
0
 public function executeTranslationDefaultText(sfWebRequest $request)
 {
     $campaign = CampaignTable::getInstance()->findById($request->getParameter('id'), $this->userIsAdmin());
     if (!$campaign) {
         return $this->notFound();
     }
     if (!$this->getGuardUser()->isCampaignMember($campaign)) {
         return $this->noAccess();
     }
     $form = new TranslationForm();
     $form_name = $form->getName();
     $value = $request->getGetParameter('value');
     if (!is_string($value)) {
         return $this->notFound();
     }
     $language = LanguageTable::getInstance()->find($value);
     if (!$language) {
         return $this->notFound();
     }
     $validation_email = StoreTable::getInstance()->findByKeyAndLanguageCached(StoreTable::SIGNING_VALIDATION_EMAIL, $value);
     if ($validation_email) {
         $this->ajax()->val('#' . $form_name . '_email_validation_subject', $validation_email->getField('subject', ''));
         $this->ajax()->val('#' . $form_name . '_email_validation_body', $validation_email->getField('body', ''));
     }
     $tellyourfriend_email = StoreTable::getInstance()->findByKeyAndLanguageCached(StoreTable::ACTION_TELL_YOUR_FRIEND_EMAIL, $value);
     if ($tellyourfriend_email) {
         $this->ajax()->val('#' . $form_name . '_email_tellyour_subject', $tellyourfriend_email->getField('subject', ''));
         $this->ajax()->val('#' . $form_name . '_email_tellyour_body', $tellyourfriend_email->getField('body', ''));
     }
     $default_campaign_privacy = CampaignStoreTable::getInstance()->findByCampaignLanguageKey($campaign, $language, CampaignStoreTable::KEY_PRIVACY_POLICY);
     if ($default_campaign_privacy) {
         $this->ajax()->val('#' . $form_name . '_privacy_policy_body', $default_campaign_privacy->getValue());
     } else {
         $privacy = StoreTable::getInstance()->findByKeyAndLanguageCached(StoreTable::ACTION_PRIVACY_POLICY, $value);
         if ($privacy) {
             $this->ajax()->val('#' . $form_name . '_privacy_policy_body', $privacy->getField('body', ''));
         }
     }
     return $this->ajax()->render();
 }
Пример #12
0
 public function executeOnpay(sfWebRequest $request)
 {
     $pay_for = $request->getGetParameter('pay_for');
     if (!is_numeric($pay_for)) {
         throw new sfException('wrong argument for onpay');
     }
     $transaction = TransactionTable::getInstance()->findOneById($pay_for);
     $onpay = OnPay::forTransaction($transaction);
     $result = $onpay->processApiRequest($request->getGetParameter('type'), $request->getGetParameter('order_amount'), $request->getGetParameter('order_currency'), $pay_for, $request->getGetParameter('md5'), $request->getGetParameter('onpay_id'), $request->getGetParameter('balance_amount'), $request->getGetParameter('balance_currency'), $request->getGetParameter('exchange_rate'), $request->getGetParameter('paymentDateTime'));
     $this->getResponse()->setContentType('text/plain');
     return $this->renderText($result);
 }
Пример #13
0
  public function executeAttendance(sfWebRequest $request)
  {

    // todo: Handle NON-AJAX requests
    #$this->forward404Unless( $request->isXmlHttpRequest() );

    $this->class = $this->enrolment->getClass();
    $this->lessons = $this->class->getLessons();

    $this->form = true;


   if ($request->getGetParameter('form') == 'false')
    {

      /* saving */

          $this->redirect( 'danceTrackAttendance', 
            array(
              'dance_slug' => $dance_slug
            )
          );

    } else {


    }

      return $this->renderPartial(
        'attendance_form', 
    array(
      'enrolment' => $this->enrolment,
      'class' => $this->class,
      'lessons' => $this->lessons
    )
      );


  }
Пример #14
0
 public function executeGetConfigs(sfWebRequest $request)
 {
     $c = new Criteria();
     $c->add(ConfigPeer::MODEL_ID, $request->getGetParameter('model_id'));
     $this->configs = ConfigPeer::doSelect($c);
 }
Пример #15
0
 public function executeView(sfWebRequest $request)
 {
     $ticket = TicketTable::getInstance()->find($request->getParameter('id'));
     if (!$ticket) {
         return $this->notFound();
     }
     if (!$this->hasTicketRight($ticket)) {
         return $this->ajax()->alert('You have no rights to handle this ticket.', 'Error', '#todo', 'append')->render();
     }
     $csrf_token = in_array($ticket->getStatus(), array(TicketTable::STATUS_APPROVED, TicketTable::STATUS_DENIED)) ? null : UtilCSRF::gen('tickets');
     return $this->ajax()->appendPartial('body', 'view', array('ticket' => $ticket, 'csrf_token' => $csrf_token, 'campaign_id' => $request->getGetParameter('campaign_id'), 'petition_id' => $request->getGetParameter('petition_id')))->modal('#ticket_view_modal')->render();
 }
Пример #16
0
 public function getGetParameter($name, $default = null, $isStripNullbyte = true)
 {
     if ($isStripNullbyte) {
         return opToolkit::stripNullByteDeep(parent::getGetParameter($name, $default));
     } else {
         return parent::getGetParameter($name, $default);
     }
 }
Пример #17
0
 public function executeIndex(sfWebRequest $request)
 {
     $petiion_id = $request->getParameter('petition_id');
     $contact_id = $request->getParameter('contact_id');
     $this->show_thankyou = false;
     if ($contact_id) {
         $petition_contact = PetitionContactTable::getInstance()->findOneByPetitionIdAndContactId($petiion_id, $contact_id);
         if (!$petition_contact) {
             return $this->notFound();
         }
         if ($petition_contact->getSecret() != $request->getParameter('secret')) {
             return $this->notFound();
         }
         $contact = $petition_contact->getContact();
         $petition = $petition_contact->getPetition();
         /* @var $petition Petition */
     } else {
         $petition = PetitionTable::getInstance()->find($petiion_id);
         if (!$petition) {
             return $this->notFound();
         }
         $contact = new Contact();
         $contact->setFirstname('John');
         $contact->setLastname('Doe');
         $contact->setGender(Contact::GENDER_MALE);
         $petition_contact = new PetitionContact();
         $petition_contact->setPetition($petition);
         $petition_contact->setContact($contact);
         $this->show_thankyou = true;
     }
     $languages = LanguageTable::getInstance()->queryByActivePetitionTexts($petition)->execute();
     $this->languages = $languages;
     $language_ids = array();
     foreach ($languages as $language) {
         $language_ids[] = $language->getId();
     }
     $contact_lang = $contact->getLanguageId() ?: 'en';
     if (!in_array($contact_lang, $language_ids)) {
         $contact_lang = in_array('en', $language_ids) ? 'en' : reset($language_ids);
     }
     $lang = $request->getGetParameter('lang');
     if ($lang && in_array($lang, $language_ids)) {
         $contact_lang = $lang;
     }
     $contact->setLanguageId($contact_lang);
     $petition_text = $contact->getPetitionTextForPetition($petition);
     $this->getUser()->setCulture($contact_lang);
     if (!$petition_text) {
         return $this->notFound();
     }
     /* @var $petition_text PetitionText */
     $i18n = $this->getContext()->getI18N();
     $i18n->setCulture($petition_text->getLanguageId());
     $salutation = $contact->generateSalutation($i18n);
     $this->salutation = $salutation;
     $this->petition_text = $petition_text;
     $this->petition = $petition;
     $this->petition_contact = $petition_contact;
     $this->ask_password = false;
     $this->wrong_password = false;
     $this->session = null;
     $this->password_no_match = false;
     $this->password_too_short = false;
     if ($petition_contact->getPassword()) {
         $session = $request->getPostParameter('session');
         if ($session && is_string($session) && $session == crypt($petition_contact->getPassword(), $session)) {
             $this->session = $session;
         } else {
             if ($request->isMethod('post')) {
                 $password = trim($request->getPostParameter('password'));
                 if ($password) {
                     if ($petition_contact->checkPassword($password)) {
                         $this->session = crypt($petition_contact->getPassword(), '$6$' . PetitionContactTable::salt());
                     } else {
                         $this->wrong_password = true;
                         $this->ask_password = true;
                         return;
                     }
                 } else {
                     $this->ask_password = true;
                     return;
                 }
             } else {
                 $this->ask_password = true;
                 return;
             }
         }
     }
     $pledge_table = PledgeTable::getInstance();
     $pledge_items = $petition->getPledgeItems();
     $pledges = array();
     foreach ($pledge_items as $pledge_item) {
         /* @var $pledge_item PledgeItem */
         if ($pledge_item->getStatus() == PledgeItemTable::STATUS_ACTIVE) {
             $pledge = $pledge_table->findOneByPledgeItemAndContact($pledge_item, $contact);
             if (!$pledge) {
                 $pledge = new Pledge();
                 $pledge->setPledgeItem($pledge_item);
                 $pledge->setContact($contact);
                 if (!$contact->isNew()) {
                     $pledge->save();
                 }
             } else {
                 $pledge->setPledgeItem($pledge_item);
             }
             $pledges[] = $pledge;
         }
     }
     if ($request->isMethod('post')) {
         $this->show_thankyou = true;
         $pledge_changed = false;
         foreach ($pledges as $pledge) {
             $status = $request->getPostParameter('status_' . $pledge->getPledgeItem()->getId());
             if (in_array($status, array(PledgeTable::STATUS_YES, PledgeTable::STATUS_NO, PledgeTable::STATUS_NO_COMMENT))) {
                 $pledge_changed = $pledge_changed || $pledge->getStatus() != $status;
                 if ($pledge->getStatus() != PledgeTable::STATUS_YES) {
                     if ($pledge->getStatus() != $status) {
                         $pledge->setStatusAt(gmdate('Y-m-d H:i:s'));
                     }
                     $pledge->setStatus($status);
                 }
             }
             $pledge->save();
         }
         if ($petition->getPledgeWithComments()) {
             $comment = $request->getPostParameter('comment');
             if (is_string($comment)) {
                 $petition_contact->setComment(trim($comment));
                 $petition_contact->save();
             }
         }
         if ($pledge_changed) {
             $petition->state(Doctrine_Record::STATE_DIRTY);
             // trigger widget update
             $petition->save();
         }
         $password1 = trim($request->getPostParameter('new_password1'));
         $password2 = trim($request->getPostParameter('new_password2'));
         if ($password1) {
             if ($password1 !== $password2) {
                 $this->password_no_match = true;
                 $this->show_thankyou = false;
             } else {
                 if (strlen($password1) < 8) {
                     $this->password_too_short = true;
                     $this->show_thankyou = false;
                 } else {
                     $petition_contact->setHashPassword($password1);
                     $petition_contact->save();
                     $this->session = crypt($petition_contact->getPassword(), '$6$' . PetitionContactTable::salt());
                 }
             }
         }
     }
     $this->pledges = $pledges;
 }