Ejemplo n.º 1
0
 /**
  *
  * @return Store
  */
 protected function getStore($key)
 {
     if (array_key_exists($key, $this->store_cache)) {
         return $this->store_cache[$key];
     }
     $meta = $this->getOption('meta');
     $store = isset($meta['i18n']) ? StoreTable::getInstance()->findByKeyAndLanguage($key, $this->getOption('language_id')) : StoreTable::getInstance()->findByKey($key);
     if ($store) {
         return $this->store_cache[$key] = $store;
     }
     $this->store_cache[$key] = new Store();
     $this->store_cache[$key]->setKey($key);
     if (isset($meta['i18n'])) {
         $this->store_cache[$key]->setLanguageId($this->getOption('language_id'));
     }
     return $this->store_cache[$key];
 }
Ejemplo n.º 2
0
 public function executeFooter()
 {
     $store = StoreTable::getInstance();
     $terms = $store->findByKeyCached(StoreTable::TERMS_FOOTER);
     $terms_title = $store->findByKeyCached(StoreTable::TERMS_TITLE);
     $contact = $store->findByKeyCached(StoreTable::CONTACT_FOOTER);
     $contact_title = $store->findByKeyCached(StoreTable::CONTACT_TITLE);
     $imprint = $store->findByKeyCached(StoreTable::IMPRINT_FOOTER);
     $imprint_title = $store->findByKeyCached(StoreTable::IMPRINT_TITLE);
     $footer_title = $store->findByKeyCached(StoreTable::FOOTER_TITLE);
     $footer_link = $store->findByKeyCached(StoreTable::FOOTER_LINK);
     if ($terms) {
         $this->setContentTags($terms);
     }
     if ($terms_title) {
         $this->addContentTags($terms_title);
     }
     if ($contact) {
         $this->setContentTags($contact);
     }
     if ($contact_title) {
         $this->addContentTags($contact_title);
     }
     if ($imprint) {
         $this->setContentTags($imprint);
     }
     if ($imprint_title) {
         $this->addContentTags($imprint_title);
     }
     if ($footer_title) {
         $this->addContentTags($footer_title);
     }
     if ($footer_link) {
         $this->addContentTags($footer_link);
     }
     $this->terms = $terms ? $terms->getValue() : '';
     $this->terms_title = $terms_title ? $terms_title->getValue() : '';
     $this->contact = $contact ? $contact->getValue() : '';
     $this->contact_title = $contact_title ? $contact_title->getValue() : '';
     $this->imprint = $imprint ? $imprint->getValue() : '';
     $this->imprint_title = $imprint_title ? $imprint_title->getValue() : '';
     $this->footer_title = $footer_title ? $footer_title->getValue() : '';
     $this->footer_link = $footer_link ? $footer_link->getValue() : '';
 }
Ejemplo n.º 3
0
 protected function fetchWidget()
 {
     $id = $this->getRequest()->getParameter('id');
     if (!is_numeric($id)) {
         return $this->showError('Invalid ID');
     }
     $this->widget = WidgetTable::getInstance()->fetch($id);
     $this->widget->getPetition()->state(Doctrine_Record::STATE_CLEAN);
     // petition can not have changed yet, stupid doctrine
     if (empty($this->widget)) {
         return $this->forward404('No widget found');
     }
     $this->setContentTags($this->widget);
     $this->addContentTags($this->widget->getCampaign());
     $this->addContentTags($this->widget->getPetition());
     $this->addContentTags($this->widget->getPetitionText());
     $donations_paypal_strore = StoreTable::getInstance()->findByKeyCached(StoreTable::DONATIONS_PAYPAL);
     if ($donations_paypal_strore) {
         $this->addContentTags($donations_paypal_strore);
     }
 }
Ejemplo n.º 4
0
 public function executePrivacyLang(sfWebRequest $request)
 {
     $this->campaign = CampaignTable::getInstance()->findById($request->getParameter('id'), $this->userIsAdmin());
     /* @var $this->campaign Campaign */
     if (!$this->campaign) {
         return $this->notFound();
     }
     if (!$this->getGuardUser()->isCampaignAdmin($this->campaign)) {
         return $this->noAccess();
     }
     $this->languages = LanguageTable::getInstance()->queryAll()->execute();
     $this->language = LanguageTable::getInstance()->find($request->getParameter('lang'));
     if (!$this->language) {
         return $this->notFound();
     }
     $campaign_store = CampaignStoreTable::getInstance()->findByCampaignLanguageKey($this->campaign, $this->language, CampaignStoreTable::KEY_PRIVACY_POLICY);
     if (!$campaign_store) {
         $campaign_store = new CampaignStore();
         $campaign_store->setCampaign($this->campaign);
         $campaign_store->setLanguage($this->language);
         $campaign_store->setKey(CampaignStoreTable::KEY_PRIVACY_POLICY);
         $store = StoreTable::getInstance()->findByKeyAndLanguage(StoreTable::ACTION_PRIVACY_POLICY, $campaign_store->getLanguage()->getId());
         if (!$store) {
             $store = StoreTable::getInstance()->findByKeyAndLanguage(StoreTable::ACTION_PRIVACY_POLICY, 'en');
         }
         if ($store) {
             $campaign_store->setValue($store->getField('body'));
         }
     }
     $this->form = new CampaignStoreForm($campaign_store);
     if ($request->isMethod('post')) {
         $this->form->bind($request->getPostParameter($this->form->getName()));
         if ($this->form->isValid()) {
             $before = $campaign_store->getValue();
             $this->form->save();
             $data_owner = $this->campaign->getDataOwnerId() ? $this->campaign->getDataOwner() : null;
             /* @var $data_owner sfGuardUser */
             if ($data_owner && $this->getGuardUser()->getId() != $data_owner->getId()) {
                 $ticket = TicketTable::getInstance()->generate(array(TicketTable::CREATE_AUTO_FROM => true, TicketTable::CREATE_TO => $data_owner, TicketTable::CREATE_CAMPAIGN => $this->campaign, TicketTable::CREATE_KIND => TicketTable::KIND_PRIVACY_POLICY_CHANGED, TicketTable::CREATE_TEXT => $this->getGuardUser()->getFullName() . ' (' . $this->getGuardUser()->getOrganisation() . ") modified the privacy policy text '" . $this->language->getName() . "'\n" . "BEFORE:\n" . $before . "\n\nAFTER:\n" . $campaign_store->getValue()));
                 $ticket->save();
                 $ticket->notifyAdmin();
             }
             return $this->ajax()->remove('#no_text')->alert('Saved.', '', '#campaign_privacy_form .form-actions', 'before')->render();
         }
         return $this->ajax()->form($this->form)->render();
     }
     $this->includeMarkdown();
     $this->includeHighlight();
 }
Ejemplo n.º 5
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();
 }
Ejemplo n.º 6
0
 public function executeReset(sfWebRequest $request)
 {
     if (!StoreTable::getInstance()->getValueCached(StoreTable::REGISTER_ON)) {
         return $this->notFound();
     }
     $id = $request->getParameter('id');
     $code = $request->getParameter('code');
     if ($this->getUser()->isAuthenticated() && $this->getGuardUser()->getId() == $id) {
         return $this->redirect($this->generateUrl('dashboard'));
     }
     $user = sfGuardUserTable::getInstance()->getByPasswordForgottenCode($id, $code);
     if ($user) {
         $this->user = $user;
         $form = new sfGuardChangeUserPasswordForm($user);
         $this->form = $form;
         if ($request->isMethod('post')) {
             $form->bind($request->getParameter($form->getName()));
             if ($form->isValid()) {
                 $this->_deleteOldUserForgotPasswordRecords($user->getId());
                 $form->save();
                 $login_url = $this->generateUrl('ajax_signin');
                 return $this->ajax()->form($form)->attr('#reset_form input, #reset_form button', 'disabled', 'disabled')->alert('Password changed. You may <a class="ajax_link" href="' . $login_url . '">login</a> now', '', '#reset_form .form-actions', 'before', true)->render();
             } else {
                 return $this->ajax()->form($form)->render();
             }
         }
     }
 }
Ejemplo n.º 7
0
 public function executeImprint(sfWebRequest $request)
 {
     $store = StoreTable::getInstance();
     $imprint_content = $store->findByKeyCached(StoreTable::IMPRINT_CONTENT);
     $imprint_title = $store->findByKeyCached(StoreTable::IMPRINT_TITLE);
     if ($imprint_content) {
         $this->setContentTags($imprint_content);
     }
     if ($imprint_title) {
         $this->addContentTags($imprint_title);
     }
     $this->imprint_content = $imprint_content ? $imprint_content->getValue() : '';
     $this->imprint_title = $imprint_title ? $imprint_title->getValue() : '';
 }
Ejemplo n.º 8
0
 public static function useSender()
 {
     return StoreTable::getInstance()->getValueCached(StoreTable::EMAIL_SENDER) ? true : false;
 }
Ejemplo n.º 9
0
 public function executeEdit(sfWebRequest $request)
 {
     $id = $request->getParameter('id');
     if (is_numeric($id)) {
         $user = sfGuardUserTable::getInstance()->find($id);
         /* @var $user sfGuardUser */
         if (!$user) {
             return $this->notFound();
         }
     } else {
         $user = new sfGuardUser();
         $user->setIsActive(false);
     }
     if (!$this->getGuardUser()->getIsSuperAdmin() && $user->getIsSuperAdmin()) {
         $this->noAccess();
     }
     if ($user->isNew()) {
         $this->form = new UserNewForm($user);
     } else {
         $this->form = new UserForm($user);
     }
     if ($request->isMethod('post')) {
         $this->form->bind($request->getPostParameter($this->form->getName()));
         if ($this->form->isValid()) {
             $con = sfGuardUserTable::getInstance()->getConnection();
             $con->beginTransaction();
             try {
                 $this->form->updateGroupsList($this->form->getValues());
                 $user = $this->form->updateObject();
                 $user->setUsername($user->getEmailAddress());
                 if ($user->isNew()) {
                     $user->setValidationKind(sfGuardUserTable::VALIDATION_KIND_BACKEND_LINK);
                     $user->randomValidationCode();
                     $user->save();
                     $subject = 'validate activation';
                     $body = "#VALIDATION-URL#";
                     $store = StoreTable::getInstance()->findByKeyAndLanguageWithFallback(StoreTable::NEW_USER_ADMIN_MAIL, $user->getLanguageId());
                     if ($store) {
                         $subject = $store->getField('subject');
                         $body = $store->getField('body');
                     }
                     $subst = array('#VALIDATION-URL#' => $this->generateUrl('user_validation', array('id' => $user->getId(), 'code' => $user->getValidationCode()), true), '#USER-NAME#' => $user->getFullName());
                     UtilMail::send(null, null, $user->getEmailAddress(), $subject, $body, null, $subst);
                 } else {
                     $user->save();
                 }
                 $con->commit();
             } catch (Exception $e) {
                 $con->rollback();
                 throw $e;
             }
             return $this->ajax()->redirectRotue('user_idx')->render();
         } else {
             return $this->ajax()->form($this->form)->render();
         }
     }
     if (!$user->isNew()) {
         $this->campaign_rights_list = CampaignRightsTable::getInstance()->queryByUser($user)->execute();
         $this->petition_rights_list = PetitionRightsTable::getInstance()->queryByUser($user)->execute();
     }
 }
 protected function doSave($con = null)
 {
     $wasNew = $this->getObject()->isNew();
     parent::doSave($con);
     if ($wasNew) {
         $widget = $this->getObject();
         $petition = $widget->getPetition();
         $petition_text = $widget->getPetitionText();
         $subject = 'Validate your widget';
         $body = "Validate: VALIDATION\nEdit: EDITCODE";
         $store = StoreTable::getInstance()->findByKeyAndLanguageWithFallback(StoreTable::EMBED_WIDGET_MAIL, $petition_text->getLanguageId());
         if ($store) {
             $subject = $store->getField('subject');
             $body = $store->getField('body');
         }
         $validation = UtilLink::widgetValidation($this->getObject()->getId(), $this->getObject()->getValidationData());
         $edit_code = UtilLink::widgetEdit($this->getObject()->getId(), $this->getObject()->getEditCode());
         $from = $petition->getFrom();
         $to = $this->getObject()->getEmail();
         $additional_subst = array('VALIDATION' => $validation, 'EDITCODE' => $edit_code, '#VALIDATION-URL#' => $validation, '#EDIT-URL#' => $edit_code);
         UtilMail::sendWithSubst(null, $from, $to, $subject, $body, $petition_text, $widget, $additional_subst);
     }
 }