/**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     require_once dirname(__FILE__) . '/../../../config/ProjectConfiguration.class.php';
     $configuration = ProjectConfiguration::getApplicationConfiguration('public', 'prod', true);
     sfContext::createInstance($configuration);
     $liveLang = $arguments['live_lang'];
     $langToDeploy = $arguments['lang_to_deploy'];
     $liveLangs = SfConfig::get('app_site_langs');
     $langsUnderDev = SfConfig::get('app_site_langsUnderDev');
     if (in_array($liveLang, $liveLangs) === false) {
         die("The live lang doesn't seem to be live!");
     }
     if (in_array($langToDeploy, $langsUnderDev) === false) {
         die("You can deploy only a language under development");
     }
     $c = new Criteria();
     $c->add(PcTranslationPeer::LANGUAGE_ID, $langToDeploy);
     $translationsToDeploy = PcTranslationPeer::doSelect($c);
     $i = 0;
     foreach ($translationsToDeploy as $translationToDeploy) {
         $this->log("Deploying the string " . $translationToDeploy->getStringId() . " from {$langToDeploy} to {$liveLang}");
         $liveTranslation = PcTranslationPeer::retrieveByPK($liveLang, $translationToDeploy->getStringId());
         $liveTranslation->setString($translationToDeploy->getString())->save();
         $translationToDeploy->delete();
         $i++;
     }
     $this->log("All done. {$i} strings deployed.");
 }
 function __($stringId)
 {
     if (!defined('PLANCAKE_PUBLIC_RELEASE')) {
         $lang = PcLanguagePeer::getUserPreferredLanguage()->getId();
         $key = '';
         if ($cache = PcCache::getInstance()) {
             $key = PcCache::generateKeyForTranslation($lang, $stringId);
             if ($cache->has($key)) {
                 return $cache->get($key);
             }
         }
         $translation = PcTranslationPeer::retrieveByPK($lang, $stringId);
         if (!is_object($translation) || !strlen(trim($translation->getString())) > 0) {
             $translation = PcTranslationPeer::retrieveByPK(SfConfig::get('app_site_defaultLang'), $stringId);
         }
         if (!$translation) {
             throw new Exception("Couldn't find the string {$stringId} for the language {$lang}");
         }
         $ret = $translation->getString();
         if ($cache) {
             $cache->set($key, $ret);
         }
     } else {
         global $pc_lang;
         if (!array_key_exists($stringId, $pc_lang)) {
             throw new Exception("Couldn't find the string {$stringId}");
         }
         $ret = $pc_lang[$stringId];
     }
     return $ret;
 }
예제 #3
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $lang = PcLanguagePeer::getUserPreferredLanguage()->getId();
     if (!$lang) {
         $lang = SfConfig::get('app_site_defaultLang');
     }
     $this->lang = $lang;
     $this->baseUrl = sfConfig::get('app_site_url') . (sfConfig::get('sf_environment') == 'prod' ? '' : '/') . sfConfig::get('app_publicApp_frontController');
     if (defined('PLANCAKE_PUBLIC_RELEASE')) {
         $this->baseUrl = 'http://www.plancake.com';
     }
     $userCulture = $this->getUser()->getCulture();
     $this->cultureUrlPart = '';
     if ($userCulture != SfConfig::get('app_site_defaultLang')) {
         $this->cultureUrlPart = '/' . $userCulture;
     }
     // this is a "backdoor" to avoid redirection: just append ?redirect=no to the URL
     if ($request->getParameter('redirect') == 'no') {
         return;
     }
     // if the user is authenticated, they will be redirected
     // to their account
     if ($this->getUser()->isAuthenticated()) {
         $this->redirect('/' . sfConfig::get('app_accountApp_frontController'));
     }
 }
예제 #4
0
 /**
  * @return PcLanguage
  */
 public static function getUserPreferredLanguage()
 {
     $c = new Criteria();
     $c->add(self::ID, strtolower(sfContext::getInstance()->getUser()->getCulture()));
     $lang = self::doSelectOne($c);
     if (!is_object($lang)) {
         $lang = PcLanguagePeer::retrieveByPk(SfConfig::get('app_site_defaultLang'));
     }
     return $lang;
 }
 public function execute($filterChain)
 {
     $context = $this->getContext();
     $request = $context->getRequest();
     $user = $context->getUser();
     $availableLangs = PcLanguagePeer::getAvailableLanguageAbbreviations();
     if ($preferredLang = $request->getParameter('pc_preferred_lang')) {
         $loggedInUser = PcUserPeer::getLoggedInUser();
         if ($loggedInUser) {
             if (in_array($preferredLang, $availableLangs)) {
                 $user->setCulture($preferredLang);
                 $loggedInUser->setPreferredLanguage($preferredLang)->save();
             }
         }
     }
     // fallback to default language
     if (!$user->getCulture()) {
         $user->setCulture(SfConfig::get('app_site_defaultLang'));
     }
     $filterChain->execute();
 }
 public function execute($filterChain)
 {
     $context = $this->getContext();
     $request = $context->getRequest();
     $user = $context->getUser();
     $availableLangs = PcLanguagePeer::getAvailableLanguageAbbreviations();
     $preferredLang = $request->getParameter('pc_preferred_lang');
     sfContext::getInstance()->getConfiguration()->loadHelpers(array('Url'));
     $loggedInUser = PcUserPeer::getLoggedInUser();
     if ($loggedInUser && !$preferredLang) {
         $user->setCulture($loggedInUser->getPreferredLanguage());
     } else {
         if ($preferredLang) {
             if (in_array($preferredLang, $availableLangs)) {
                 $user->setCulture($preferredLang);
                 if ($loggedInUser) {
                     $loggedInUser->setPreferredLanguage($preferredLang)->save();
                 }
             }
         } else {
             if (!$user->getAttribute('after_user_first_request')) {
                 $culture = strtolower($request->getPreferredCulture($availableLangs));
                 $user->setCulture($culture);
                 if ($context->getModuleName() == 'homepage' && $context->getActionName() == 'index') {
                     if ($culture != SfConfig::get('app_site_defaultLang')) {
                         header('Location: ' . url_for('@localized_homepage', true));
                     }
                 }
                 $user->setAttribute('after_user_first_request', true);
             }
         }
     }
     // fallback to default language
     if (!$user->getCulture()) {
         $user->setCulture(SfConfig::get('app_site_defaultLang'));
     }
     $filterChain->execute();
 }
예제 #7
0
 /**
  *
  * @return bool
  */
 public function isUnderDevelopment()
 {
     $langsUnderDev = SfConfig::get('app_site_langsUnderDev');
     return in_array($this->getId(), $langsUnderDev);
 }
 /**
  * Inserts or updates an event to the specific calendar.
  * If we try to edit a task without due date, it deletes it
  *
  * @param PcTask $task
  * @param string $calendarUrl
  * @param bool $updateEmailAddress (=false)
  * @return int|bool the id of the event - false if the event we try to add/edit hasn't got due date
  */
 public function createOrUpdateEvent(PcTask $task, $updateEmailAddress = false)
 {
     $event = null;
     $googleCalendarEventId = $task->getGoogleCalendarEventId();
     $mode = self::EVENT_CREATE_MODE;
     if (strlen($googleCalendarEventId)) {
         $event = $this->getEvent($googleCalendarEventId);
         if (is_object($event)) {
             $mode = self::EVENT_UPDATE_MODE;
         }
         if ($this->hasEventBeenDeleted($event)) {
             return;
         }
     }
     if (SfConfig::get('app_gcal_debug')) {
         if ($mode == self::EVENT_CREATE_MODE) {
             error_log('Creating task on GCal for the Plancake task ' . $task->getId() . ' ' . $task->getDescription());
         } else {
             error_log('Editing task on GCal for the Plancake task ' . $task->getId() . ' ' . $task->getDescription());
         }
     }
     if ($mode == self::EVENT_CREATE_MODE) {
         $event = $this->service->newEventEntry();
     }
     if (!$task->getDueDate() || $task->isCompleted()) {
         // A task without due date or completed shouldn't be on Google Calendar
         $this->deleteEventById($googleCalendarEventId);
         $task->removeGoogleCalendarEventId();
         return false;
     }
     // {{{ Adding extended property to patch a problem we have this the integration:
     // search 'EVENT_EXTENDED_PROPERTY_TASK_ID' in this file
     $this->setExtendedProperty($event, self::EVENT_EXTENDED_PROPERTY_TASK_ID, $task->getId());
     // }}}
     $event->title = $this->service->newTitle($task->getDescription());
     $event->where = array($this->service->newWhere(""));
     $event->content = $this->service->newContent($task->getNote());
     // Setting the date using RFC 3339 format
     list($startDate, $startTime) = DateFormat::fromLocalDateAndTime2GMTDateAndTime($task->getDueDate("Y-m-d"), $task->getDueTime());
     $timeObject = new PcTime();
     if ($startTime > 0) {
         $startTime = $timeObject->createFromIntegerValue($startTime)->get5CharsRepresentation();
     } else {
         $startTime = null;
     }
     //$endDate = "2011-01-20";
     //$endTime = "16:00";
     //$userTimezone = $this->user->getPcTimezone();
     //$tzOffset = ($userTimezone->getOffset()/60);
     // right now, $tzOffset can be -8, but we need -08
     //$tzOffset = "-08";
     if ($task->getRepetitionId() > 0) {
         //            $recurrence = "DTSTART;VALUE=DATE:20110501\r\n" .
         //                    "DTEND;VALUE=DATE:20110502\r\n" .
         //                    "RRULE:FREQ=WEEKLY;BYDAY=Tu;UNTIL=20110904\r\n";
         $dtStart = $task->getDueDate("Ymd");
         if ($startTime !== null) {
             $dtStart = $dtStart . 'T' . str_replace(':', '', $startTime) . '00Z';
         }
         $recurrence = "DTSTART:{$dtStart}\r\n" . "RRULE:{$task->getRepetitionICalRrule()}\r\n";
         $event->recurrence = $this->service->newRecurrence($recurrence);
     } else {
         $when = $this->service->newWhen();
         if ($startTime !== null) {
             $when->startTime = "{$startDate}T{$startTime}:00.000Z";
         } else {
             $when->startTime = $startDate;
         }
         // $when->endTime = "{$endDate}T{$endTime}:00.000{$tzOffset}:00";
         $event->when = array($when);
     }
     if ($mode == self::EVENT_CREATE_MODE) {
         $newEvent = null;
         try {
             $newEvent = $this->service->insertEvent($event, $this->getCalendarUrl());
         } catch (Exception $e) {
             $newEvent = $this->service->insertEvent($event, $this->getCalendarUrl());
         }
     } else {
         // {{{ rather then running just $event->save() ,
         // we try many times, as sometimes the updating is a bit
         //quirky on Google Calendar end
         try {
             $event->save();
         } catch (Exception $e) {
             try {
                 $event->save();
             } catch (Exception $e) {
                 $event->save();
             }
         }
         // }}}
         $newEvent = $event;
     }
     if ($updateEmailAddress) {
         $dbEntry = PcGoogleCalendarPeer::retrieveByUser($this->user);
         $dbEntry->setEmailAddress($newEvent->author[0]->email->text)->save();
     }
     $eventId = $this->getEventId($newEvent);
     if ($mode == self::EVENT_CREATE_MODE) {
         $task->setGoogleCalendarEventId($eventId);
     }
     return $eventId;
 }
예제 #9
0
 public function executeSubscriptionContent()
 {
     $inputDiscountCode = trim($this->getContext()->getRequest()->getParameter('codeForDiscount'));
     $discount = PcPromotionCodePeer::getDiscountByCode($inputDiscountCode, $promotionErrorCode);
     $c = new Criteria();
     $c->add(PcPaypalProductPeer::SUBSCRIPTION_TYPE_ID, 3);
     $c->add(PcPaypalProductPeer::ITEM_PRICE_CURRENCY, 'USD');
     $this->oneYearUsdSubscription = PcPaypalProductPeer::doSelectOne($c);
     $c = new Criteria();
     $c->add(PcPaypalProductPeer::SUBSCRIPTION_TYPE_ID, 3);
     $c->add(PcPaypalProductPeer::ITEM_PRICE_CURRENCY, 'GBP');
     $this->oneYearGbpSubscription = PcPaypalProductPeer::doSelectOne($c);
     $c = new Criteria();
     $c->add(PcPaypalProductPeer::SUBSCRIPTION_TYPE_ID, 3);
     $c->add(PcPaypalProductPeer::ITEM_PRICE_CURRENCY, 'EUR');
     $this->oneYearEurSubscription = PcPaypalProductPeer::doSelectOne($c);
     $c = new Criteria();
     $c->add(PcPaypalProductPeer::SUBSCRIPTION_TYPE_ID, 3);
     $c->add(PcPaypalProductPeer::ITEM_PRICE_CURRENCY, 'JPY');
     $this->oneYearJpySubscription = PcPaypalProductPeer::doSelectOne($c);
     $c = new Criteria();
     $c->add(PcPaypalProductPeer::SUBSCRIPTION_TYPE_ID, 2);
     $c->add(PcPaypalProductPeer::ITEM_PRICE_CURRENCY, 'USD');
     $this->threeMonthUsdSubscription = PcPaypalProductPeer::doSelectOne($c);
     $c = new Criteria();
     $c->add(PcPaypalProductPeer::SUBSCRIPTION_TYPE_ID, 2);
     $c->add(PcPaypalProductPeer::ITEM_PRICE_CURRENCY, 'GBP');
     $this->threeMonthGbpSubscription = PcPaypalProductPeer::doSelectOne($c);
     $c = new Criteria();
     $c->add(PcPaypalProductPeer::SUBSCRIPTION_TYPE_ID, 2);
     $c->add(PcPaypalProductPeer::ITEM_PRICE_CURRENCY, 'EUR');
     $this->threeMonthEurSubscription = PcPaypalProductPeer::doSelectOne($c);
     $c = new Criteria();
     $c->add(PcPaypalProductPeer::SUBSCRIPTION_TYPE_ID, 2);
     $c->add(PcPaypalProductPeer::ITEM_PRICE_CURRENCY, 'JPY');
     $this->threeMonthJpySubscription = PcPaypalProductPeer::doSelectOne($c);
     $c = new Criteria();
     $c->add(PcPaypalProductPeer::ID, 7);
     $this->testSubscription = PcPaypalProductPeer::doSelectOne($c);
     $this->yearlyUsdSaving = $this->threeMonthUsdSubscription->getItemPrice() * 4 - $this->oneYearUsdSubscription->getItemPrice();
     $this->yearlyGbpSaving = $this->threeMonthGbpSubscription->getItemPrice() * 4 - $this->oneYearGbpSubscription->getItemPrice();
     $this->yearlyEurSaving = $this->threeMonthEurSubscription->getItemPrice() * 4 - $this->oneYearEurSubscription->getItemPrice();
     $this->yearlyJpySaving = $this->threeMonthJpySubscription->getItemPrice() * 4 - $this->oneYearJpySubscription->getItemPrice();
     $this->niceExpiryDate = '';
     $this->niceExpiryDateThreeMonthExtended = '';
     $this->niceExpiryDateOneYearExtended = '';
     $this->oneYearUsdDiscountedSubscription = null;
     $this->oneYearGbpDiscountedSubscription = null;
     $this->oneYearEurDiscountedSubscription = null;
     $this->oneYearJpyDiscountedSubscription = null;
     $loggedInUser = PcUserPeer::getLoggedInUser();
     $this->promotionErrorCode = $promotionErrorCode;
     $this->discount = $discount;
     $this->hasDiscountCodeBeenEntered = false;
     if ($inputDiscountCode) {
         $this->hasDiscountCodeBeenEntered = true;
     }
     $this->isDiscountCodeValid = false;
     if ($discount > 0) {
         $this->isDiscountCodeValid = true;
         if ($loggedInUser) {
             $loggedInUser->setLastPromotionalCodeInserted($inputDiscountCode)->save();
         }
         $c = new Criteria();
         $c->add(PcPaypalProductPeer::SUBSCRIPTION_TYPE_ID, 3);
         $c->add(PcPaypalProductPeer::ITEM_PRICE_CURRENCY, 'USD');
         $c->add(PcPaypalProductPeer::DISCOUNT_PERCENTAGE, $discount);
         $this->oneYearUsdDiscountedSubscription = PcPaypalProductPeer::doSelectOne($c);
         $c = new Criteria();
         $c->add(PcPaypalProductPeer::SUBSCRIPTION_TYPE_ID, 3);
         $c->add(PcPaypalProductPeer::ITEM_PRICE_CURRENCY, 'GBP');
         $c->add(PcPaypalProductPeer::DISCOUNT_PERCENTAGE, $discount);
         $this->oneYearGbpDiscountedSubscription = PcPaypalProductPeer::doSelectOne($c);
         $c = new Criteria();
         $c->add(PcPaypalProductPeer::SUBSCRIPTION_TYPE_ID, 3);
         $c->add(PcPaypalProductPeer::ITEM_PRICE_CURRENCY, 'EUR');
         $c->add(PcPaypalProductPeer::DISCOUNT_PERCENTAGE, $discount);
         $this->oneYearEurDiscountedSubscription = PcPaypalProductPeer::doSelectOne($c);
         $c = new Criteria();
         $c->add(PcPaypalProductPeer::SUBSCRIPTION_TYPE_ID, 3);
         $c->add(PcPaypalProductPeer::ITEM_PRICE_CURRENCY, 'JPY');
         $c->add(PcPaypalProductPeer::DISCOUNT_PERCENTAGE, $discount);
         $this->oneYearJpyDiscountedSubscription = PcPaypalProductPeer::doSelectOne($c);
     }
     $this->isSupporter = false;
     if ($loggedInUser) {
         $this->isSupporter = $loggedInUser->isSupporter();
         $supporterAccount = PcSupporterPeer::retrieveByPK($loggedInUser->getId());
         if ($this->isSupporter) {
             $this->niceExpiryDate = $supporterAccount->getExpiryDate('j') . ' ' . PcUtils::fromIndexToMonth($supporterAccount->getExpiryDate('n')) . ' ' . $supporterAccount->getExpiryDate('Y');
             $newExpiryTimestamp = $supporterAccount->getNewExpiryDateAfterSubscription(PcSubscriptionTypePeer::retrieveByPK(2), $supporterAccount->getExpiryDate('Y-m-d'));
             $this->niceExpiryDateThreeMonthExtended = date('j', $newExpiryTimestamp) . ' ' . PcUtils::fromIndexToMonth(date('n', $newExpiryTimestamp)) . ' ' . date('Y', $newExpiryTimestamp);
             $newExpiryTimestamp = $supporterAccount->getNewExpiryDateAfterSubscription(PcSubscriptionTypePeer::retrieveByPK(3), $supporterAccount->getExpiryDate('Y-m-d'));
             $this->niceExpiryDateOneYearExtended = date('j', $newExpiryTimestamp) . ' ' . PcUtils::fromIndexToMonth(date('n', $newExpiryTimestamp)) . ' ' . date('Y', $newExpiryTimestamp);
         }
     }
     $userCulture = $this->getUser()->getCulture();
     $this->cultureUrlPart = '';
     if ($userCulture != SfConfig::get('app_site_defaultLang')) {
         $this->cultureUrlPart = '/' . $userCulture;
     }
     $this->isOnRegistration = $this->getContext()->getRequest()->getParameter('onRegistration') == '1';
     /*
         if ($this->promoCode = $request->getParameter('promoCode'))
         {
        $this->hasPromoCodeBeenSubmitted = true;
     
        $promoCodeEntry = PcPromotionCodePeer::getValidPromoCodeEntry($this->promoCode);
     
        if (is_object($promoCodeEntry))
        {
            $this->isPromoCodeValid = true;
            $buttonCode = $promoCodeEntry->getPaypalButtonCode();
            $this->price *= 1 - ($promoCodeEntry->getDiscountPercentage() / 100);
        }
         }
     */
 }
예제 #10
0
 /**
  * Register a new user
  *
  * @param string $email - the email address
  * @param string $password - the plain password (no encryption)
  * @param string $lang - if it is null or empty, the language will be detected from the header of the request
  * @param string $preferredLang - this should be a 2-char abbreviation of the lang the user wants,
  *         among the ones in the main app.yml config file
  * @param string $tzLabel - a timezone label as in the PcTimezone db table
  * @param integer $dstOn (1 or 0) - whether or not the dst for the user is on
  * @param boolen $joinNewsletter(=false) - whether the user decided to join our newsletter
  * @param boolen $sendActivationEmail(=true) - whether to send the activation email  
  * @return boolean|PcUser false is a user with that email already exists, the PcUser object otherwise
  */
 public static function registerNewUser($email, $password, $lang, $preferredLang, $tzLabel, $dstOn, $joinNewsletter = false, $sendActivationEmail = true)
 {
     if (self::emailExist($email)) {
         return false;
     }
     $newUser = new PcUser();
     $newUser->setEmail($email);
     $newUser->setPassword($password);
     $newUser->setAwaitingActivation(1);
     if ($joinNewsletter) {
         $newUser->setNewsletter(1);
     }
     $newUser->save();
     // Dealing with timezone
     $newUser->setDstActive($dstOn);
     $c = new Criteria();
     $c->add(PcTimezonePeer::LABEL, $tzLabel, Criteria::EQUAL);
     $timezone = PcTimezonePeer::doSelectOne($c);
     if (!is_object($timezone)) {
         // set to a default one
         $timezone = PcTimezonePeer::retrieveByPK(21);
     }
     $newUser->setTimezoneId($timezone->getId());
     // Dealing with formats
     // _ time format: the countries with the majority of our users are using the
     //   12H format, thus we can leave the default
     // _ for the date format we check whether they are in USA
     // _ for the first day of the week, we check whether they are in USA
     $dateFormatId = 3;
     $weekStart = 1;
     // from Monday
     $tzOffset = $timezone->getOffset();
     if ($tzOffset <= -300 && $tzOffset >= -450) {
         $dateFormatId = 4;
         $weekStart = 0;
         // from Sunday
     }
     $newUser->setDateFormat($dateFormatId);
     $newUser->setWeekStart($weekStart);
     if ($lang != null && $lang !== '') {
         $newUser->setLanguage($lang);
     } else {
         $newUser->setLanguage(PcUtils::getVisitorAcceptLanguage());
     }
     $availableLangs = PcLanguagePeer::getAvailableLanguageAbbreviations();
     if (in_array($preferredLang, $availableLangs)) {
         $newUser->setPreferredLanguage($preferredLang);
     } else {
         $newUser->setPreferredLanguage(SfConfig::get('app_site_defaultLang'));
     }
     $newUser->setIpAddress(PcUtils::getVisitorIPAddress());
     if ($sessionEntryPoint = sfContext::getInstance()->getUser()->getAttribute('session_entry_point')) {
         $newUser->setSessionEntryPoint($sessionEntryPoint);
     }
     if ($sessionReferral = sfContext::getInstance()->getUser()->getAttribute('session_referral')) {
         $newUser->setSessionReferral($sessionReferral);
     }
     $newUser->save();
     // Creating system lists
     $inboxList = new PcList();
     $inboxList->setIsInbox(1)->setTitle(__('ACCOUNT_LISTS_INBOX'))->setCreator($newUser)->save();
     $todoList = new PcList();
     $todoList->setIsTodo(1)->setTitle(__('ACCOUNT_LISTS_TODO'))->setCreator($newUser)->save();
     // Creating default contexts
     $context = new PcUsersContexts();
     $context->setPcUser($newUser)->setContext(__('ACCOUNT_TAGS_DEFAULT_HOME'))->save();
     $context = new PcUsersContexts();
     $context->setPcUser($newUser)->setContext(__('ACCOUNT_TAGS_DEFAULT_ERRANDS'))->save();
     $context = new PcUsersContexts();
     $context->setPcUser($newUser)->setContext(__('ACCOUNT_TAGS_DEFAULT_COMPUTER'))->save();
     // Creating some tasks for the inbox
     $newUser->addToInbox(__('ACCOUNT_MISC_WELCOME_TASK'));
     // creating Plancake email address
     $newUser->generateAndStorePlancakeEmailAddress();
     // I need to use a token for the activation of their account
     $token = '';
     $c = new Criteria();
     $c->add(PcActivationTokenPeer::USER_ID, $newUser->getId(), Criteria::EQUAL);
     $tokenEntry = PcActivationTokenPeer::doSelectOne($c);
     if (is_object($tokenEntry)) {
         $token = $tokenEntry->getToken();
     } else {
         $secret = sfConfig::get('app_registration_secret');
         // token doesn't need to be 32-char long. It is better to keep it short
         // so there will be less chance the email client will break the link into 2 lines
         $token = substr(md5($newUser->getId() . $secret . time()), 0, 14);
         $tokenEntry = new PcActivationToken();
         $tokenEntry->setUserId($newUser->getId());
         $tokenEntry->setToken($token);
         $tokenEntry->save();
     }
     // now we can send the email
     if ($sendActivationEmail) {
         $link = sfContext::getInstance()->getController()->genUrl('@activation?t=' . $token, true);
         $from = sfConfig::get('app_emailAddress_contact');
         $subject = 'Plancake - ' . __('WEBSITE_REGISTRATION_EMAIL_SUBJECT');
         $body = sprintf(__('WEBSITE_REGISTRATION_EMAIL_BODY'), $link);
         PcUtils::sendEmail($email, $subject, $body, $from);
     }
     $newUser->refreshLatestBlogAccess();
     sfContext::getInstance()->getEventDispatcher()->notify(new sfEvent($newUser, 'user.sign_up', array('user' => $newUser, 'plainPassword' => $password)));
     return $newUser;
 }