/**
  *
  * @param string $discountCode
  * @param int &$errorCode > 0 if error occurred (see top of the file)
  * @return int - discount (e.g.: 20) - 0 if error occurred
  */
 public static function getDiscountByCode($discountCode, &$errorCode)
 {
     $errorCode = 0;
     $discount = 0;
     if (strlen($discountCode) === 0) {
         return 0;
     }
     $c = new Criteria();
     $c->add(self::CODE, trim($discountCode));
     $promotionObj = self::doSelectOne($c);
     $loggedInUser = PcUserPeer::getLoggedInUser();
     if (!$promotionObj) {
         $errorCode = self::PROMOTION_CODE_ERROR_INVALID_CODE;
     } else {
         if (date('Ymd') > str_replace('-', '', $promotionObj->getExpiryDate())) {
             $errorCode = self::PROMOTION_CODE_ERROR_EXPIRED_CODE;
         }
         if ($promotionObj->getMaxUses() && $promotionObj->getUsesCount() >= $promotionObj->getMaxUses()) {
             $errorCode = self::PROMOTION_CODE_ERROR_MAX_USES_REACHED;
         }
         if ($promotionObj->getOnlyForNewCustomers() && $loggedInUser && $loggedInUser->isSupporter()) {
             $errorCode = self::PROMOTION_CODE_ERROR_ONLY_FOR_NEW_CUSTOMERS;
         }
     }
     if ($errorCode == 0) {
         $discount = $promotionObj->getDiscountPercentage();
     }
     return $discount;
 }
Пример #2
0
 /**
  *
  * @param string $query
  * @return array of integers - taskIds
  */
 public static function searchTasks($query)
 {
     $fieldWeights = array('description' => 10, 'note' => 6);
     $indexName = 'plancake_tasks';
     $client = new SphinxClient();
     // $client->SetServer (sfConfig::get('app_sphinx_host'), sfConfig::get('app_sphinx_port'));
     $client->SetFilter("author_id", array(PcUserPeer::getLoggedInUser()->getId()));
     $client->SetConnectTimeout(1);
     $client->SetMatchMode(SPH_MATCH_ANY);
     $client->SetSortMode(SPH_SORT_RELEVANCE);
     $client->SetRankingMode(SPH_RANK_PROXIMITY_BM25);
     $client->SetArrayResult(true);
     $client->SetFieldWeights($fieldWeights);
     $client->setLimits(0, 100);
     $results = $client->query($client->EscapeString($query), $indexName);
     if ($results === false) {
         $error = "Sphinx Error - " . $client->GetLastError();
         sfErrorNotifier::alert($error);
     }
     $ids = array();
     if (isset($results['matches']) && count($results['matches'])) {
         foreach ($results['matches'] as $match) {
             $ids[] = $match['id'];
         }
     }
     return PcTaskPeer::retrieveByPKs($ids);
 }
 /**
  * @return PcQuoteOfTheDay|null|false
  */
 public static function getUserTodayQuote()
 {
     $loggedInUser = PcUserPeer::getLoggedInUser();
     $hideableHintsSetting = $loggedInUser->getHideableHintsSetting();
     if ($hideableHintsSetting[PcHideableHintsSettingPeer::QUOTE_HINT] === 1) {
         return false;
     }
     $localTimestamp = $loggedInUser->getTime();
     $today = date('Ymd', $localTimestamp);
     $c = new Criteria();
     $c->add(self::SHOWN_ON, $today);
     $todayQuote = self::doSelectOne($c);
     if (!$todayQuote) {
         $c = new Criteria();
         $c->add(self::SHOWN_ON, null, Criteria::ISNULL);
         $c->addAscendingOrderByColumn('rand()');
         $c->setLimit(1);
         $todayQuote = self::doSelectOne($c);
         if ($todayQuote) {
             $todayQuote->setShownOn($today)->save();
         } else {
             sfErrorNotifier::alert("There are no quotes available anymore.");
         }
     }
     return $todayQuote;
 }
Пример #4
0
 /**
  * N.B.: if the user passed as input is a supporter, the method prefix '1'
  * to the token, making it 41-character long, rather than 40
  *
  * @param PcApiApp $apiApp
  * @param int $userId
  * @return string
  */
 public static function createToken(PcApiApp $apiApp, $userId)
 {
     $apiAppId = $apiApp->getId();
     // if there is already a token entry for the application and the user, we delete it
     $c = new Criteria();
     $c->add(PcApiTokenPeer::API_APP_ID, $apiAppId);
     $c->add(PcApiTokenPeer::USER_ID, $userId);
     PcApiTokenPeer::doDelete($c);
     $apiTokenEntry = new PcApiToken();
     $tokenPrefix = PcUserPeer::retrieveByPK($userId)->isSupporter() ? '1' : '';
     // we want to be extra-sure the token is unique
     $token = '';
     $safetyCounter = 0;
     // to avoid infinite loop under any circumstances
     do {
         $token = $tokenPrefix . PcUtils::generate40CharacterRandomHash();
         $c = new Criteria();
         $c->add(PcApiTokenPeer::TOKEN, $token);
         $alreadyExisting = PcApiTokenPeer::doSelectOne($c);
         $safetyCounter++;
         if ($safetyCounter == 100) {
             throw new Exception("Detected possible infinite loop while creating API token");
         }
     } while (is_object($alreadyExisting));
     $apiTokenEntry->setToken($token)->setApiAppId($apiAppId)->setUserId($userId)->setExpiryTimestamp(time() + sfConfig::get('app_api_tokenValidity') * 3600)->save();
     return $token;
 }
Пример #5
0
 /**
  *
  * @param string $note
  */
 public function createNewNote($note)
 {
     $note = trim($note);
     if (strlen($note)) {
         $noteObj = new PcContactNote();
         $noteObj->setContactId($this->getId())->setContent($note)->setPcUser(PcUserPeer::getLoggedInUser())->save();
     }
 }
Пример #6
0
 public static function getAvailableLanguageAbbreviations()
 {
     $langAbbrs = array();
     if (PcUserPeer::getLoggedInUser() && (PcUserPeer::getLoggedInUser()->isStaffMember() || PcUserPeer::getLoggedInUser()->isTranslator())) {
         $langsUnderDev = is_array(SfConfig::get('app_site_langsUnderDev')) ? SfConfig::get('app_site_langsUnderDev') : array();
         $langAbbrs = array_merge($langAbbrs, $langsUnderDev);
     }
     return array_merge($langAbbrs, SfConfig::get('app_site_langs'));
 }
 public function configure()
 {
     parent::configure();
     $this->setWidget('comment', new sfWidgetFormTextarea());
     $this->setValidator('user_id', new sfValidatorInteger());
     $this->setDefault('user_id', PcUserPeer::getLoggedInUser()->getId());
     $this->widgetSchema->setLabels(array('name' => "Your full name *", 'job_position' => "Your profession or your position in the company *", 'company' => "The company you work for (if applicable)", 'city' => 'Your city *', 'country' => 'Your country *', 'comment' => 'Your testimonial *', 'photo_link' => 'Link to your picture, from your website, LinkedIn, Twitter, ... *'));
     $this->widgetSchema->setNameFormat('testimonial[%s]');
     unset($this['created_at'], $this['updated_at']);
 }
Пример #8
0
 public function executeAddEdit(sfWebRequest $request)
 {
     $op = $request->getParameter('op');
     $contextId = $request->getParameter('id');
     $contextName = trim($request->getParameter('name'));
     $newContext = null;
     if ($contextName && strpos($contextName, ' ') !== FALSE) {
         die("ERROR: " . __('ACCOUNT_ERROR_TAG_CANT_HAVE_SPACE'));
     }
     $existingContexts = PcUserPeer::getLoggedInUser()->getContextsArray(true);
     if (count($existingContexts)) {
         if (in_array(strtolower($contextName), $existingContexts)) {
             die("ERROR: " . __('ACCOUNT_ERROR_TAG_ALREADY_EXIST'));
         }
     }
     if ($op == 'delete' && $contextId) {
         $contextToDelete = PcUsersContextsPeer::retrieveByPk($contextId);
         PcUtils::checkLoggedInUserPermission(PcUserPeer::retrieveByPk($contextToDelete->getUserId()));
         $contextToDelete->delete();
     } else {
         if ($op == 'edit' && $contextId && $contextName) {
             $contextToEdit = PcUsersContextsPeer::retrieveByPk($contextId);
             PcUtils::checkLoggedInUserPermission(PcUserPeer::retrieveByPk($contextToEdit->getUserId()));
             $contextToEdit->setContext($contextName)->save();
             // {{{
             // this lines to make sure the list details we sent back via AJAX
             // are the ones stored in the database
             $contextToEdit = PcUsersContextsPeer::retrieveByPk($contextId);
             // }}}
         } else {
             if ($op == 'add' && $contextName) {
                 // getting max sortOrder
                 $c = new Criteria();
                 $c->addDescendingOrderByColumn(PcUsersContextsPeer::SORT_ORDER);
                 $maxSortOrder = PcUsersContextsPeer::doSelectOne($c)->getSortOrder();
                 $context = new PcUsersContexts();
                 $context->setContext($contextName)->setPcUser(PcUserPeer::getLoggedInUser())->setSortOrder($maxSortOrder + 1)->save();
                 // {{{
                 // this lines to make sure the list details we sent back via AJAX
                 // are the ones stored in the database
                 $newContext = PcUsersContextsPeer::retrieveByPk($context->getId());
                 // }}}
             }
         }
     }
     $tag = isset($contextToEdit) && $contextToEdit ? $contextToEdit : $newContext;
     if ($request->isXmlHttpRequest()) {
         if ($tag) {
             $ret = array('id' => $tag->getId(), 'name' => $tag->getContext());
             return $this->renderJson($ret);
         } else {
             return $this->renderDefault();
         }
     }
 }
Пример #9
0
 /**
  * Clears the cache relevant for contexts
  */
 private function clearRelevantCache()
 {
     if (sfContext::getInstance()->getUser()->isAuthenticated()) {
         $userId = PcUserPeer::getLoggedInUser()->getId();
         $cache = PcCache::getInstance();
         if (is_object($cache)) {
             $cache->remove('PcUser::getContexts' . $userId);
             $cache->remove('PcUser::getContextsArray' . $userId);
         }
     }
 }
Пример #10
0
 private function areAdvertsToShow()
 {
     if (defined('PLANCAKE_PUBLIC_RELEASE')) {
         return false;
     }
     $user = PcUserPeer::getLoggedInUser();
     if (is_object($user) && $user->isSupporter()) {
         return false;
     }
     return true;
 }
Пример #11
0
 public function executeReorder(sfWebRequest $request)
 {
     $tagIds = $request->getParameter('tag');
     $i = 1;
     foreach ($tagIds as $tagId) {
         $tag = PcUsersContextsPeer::retrieveByPk($tagId);
         PcUtils::checkLoggedInUserPermission(PcUserPeer::retrieveByPK($tag->getUserId()));
         $tag->setSortOrder($i)->save();
         $i++;
     }
     return $this->renderDefault();
 }
 /**
  * Automatically logs users in who have a valid rememberme cookie
  * 
  * @param $filterChain
  */
 public function execute($filterChain)
 {
     if ($this->getContext()->getUser()->isAuthenticated()) {
         return $filterChain->execute();
     }
     if ($this->isFirstCall()) {
         if ($userId = CustomAuth::isRememberMeCookieValid()) {
             $userToLogin = PcUserPeer::retrieveByPk($userId);
             CustomAuth::login($this->getContext()->getUser(), $userToLogin, true, true);
         }
     }
     $filterChain->execute();
 }
Пример #13
0
 public function saveUserSuccess()
 {
     $variantId = $this->getVariant();
     $user = PcUserPeer::getLoggedInUser();
     if ($user && $variantId > 0) {
         $variantUserResult = PcSplitTestUserResultPeer::retrieveByPK($user->getId(), $this->getId(), $variantId);
         if (!$variantUserResult) {
             // the result hasn't been recorded yet
             $variantUserResult = new PcSplitTestUserResult();
             $variantUserResult->setUserId($user->getId())->setTestId($this->getId())->setVariantId($variantId)->save();
         }
     }
 }
 /**
  * @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);
     $email = $arguments['email_address'];
     $password = $arguments['password'];
     $newUser = PcUserPeer::registerNewUser($email, $password, 'en', 'en', '+01:00,1', 0, false, false);
     if ($newUser) {
         $newUser->setAwaitingActivation(0)->save();
         $supporter = new PcSupporter();
         $supporter->setUserId($newUser->getId())->setExpiryDate(2100000000)->save();
         $this->log("The user has been created successfully in the pc_user table. \n You may need to set up the correct timezone in the account settings.");
         $this->log("The new user can reset their password following the link 'forgotten password' on the Login page.");
     } else {
         $this->log("An error occurred - probably the user already exists.");
     }
 }
Пример #15
0
 public function executeStep3(sfWebRequest $request)
 {
     if (PcUserPeer::getLoggedInUser()->hasGoogleCalendarIntegrationActive()) {
         $this->redirect('default', array('module' => 'main', 'action' => 'index'));
     }
     $googleCalendarInterface = new GoogleCalendarInterface(PcUserPeer::getLoggedInUser());
     $googleCalendarInterface->init();
     $calendars = $googleCalendarInterface->getAllCalendars();
     $oldCalendarUrl = $googleCalendarInterface->getCalendarUrl();
     $plancakeCalendarName = GoogleCalendarInterface::PLANCAKE_SPECIFIC_CALENDAR_NAME;
     $this->calendarAlreadyExist = false;
     foreach ($calendars as $calendar) {
         if ($calendar->title == $plancakeCalendarName || $calendar->content->src == $oldCalendarUrl) {
             $this->calendarAlreadyExist = true;
             break;
         }
     }
 }
Пример #16
0
 /**
  * It is used for both editing and adding
  */
 public function executeSave(sfWebRequest $request)
 {
     $noteId = $request->getParameter('noteId');
     $noteTitle = $request->getParameter('noteTitle');
     $noteContent = $request->getParameter('noteContent');
     $noteId = (int) $noteId;
     $note = null;
     if ($noteId > 0) {
         $mode = self::EDIT_MODE;
         $note = PcNotePeer::retrieveByPK($noteId);
         PcUtils::checkLoggedInUserPermission($note->getCreator());
     } else {
         $note = new PcNote();
     }
     $note->setCreatorId(PcUserPeer::getLoggedInUser()->getId())->setTitle($noteTitle)->setContent($noteContent)->save();
     if ($request->isXmlHttpRequest()) {
         return $this->renderText($note->getId());
     }
 }
 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 configure()
 {
     $tags = array();
     foreach (PcContactTagPeer::doSelect(new Criteria()) as $c) {
         $tags[$c->getId()] = $c->getName();
     }
     $this->setWidget('description', new sfWidgetFormTextarea());
     $this->setWidget('language', new sfWidgetFormChoice(array('choices' => $this->langs, 'expanded' => false)));
     $this->setWidget('pc_contacts_tags_list', new sfWidgetFormChoice(array('choices' => $tags, 'expanded' => true, 'multiple' => true)));
     $defaultLang = null;
     if (PcUserPeer::getLoggedInUser()->getEmail() == '*****@*****.**') {
         $defaultLang = 'en';
     } else {
         $defaultLang = 'it';
     }
     $this->setDefault('language', $defaultLang);
     unset($this['updated_at']);
     unset($this['created_at']);
     unset($this['creator_id']);
     unset($this['id']);
     $this->widgetSchema->setNameFormat('contact[%s]');
 }
 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();
 }
Пример #20
0
 public function executeScheduledTasksForTodo(sfWebRequest $request)
 {
     $loggedInUser = PcUserPeer::getLoggedInUser();
     if ($loggedInUser->hasGoogleCalendarIntegrationActive()) {
         $gcal = new GoogleCalendarInterface($loggedInUser);
         $gcal->init();
         $gcal->syncPlancake();
     }
     include_once sfConfig::get('sf_root_dir') . '/apps/api/lib/PlancakeApiServer.class.php';
     $apiVersion = sfConfig::get('app_api_version');
     $doneParam = $request->getParameter('done');
     $typeParam = $request->getParameter('type');
     $extraParam = $request->getParameter('extraParam');
     $filters = array();
     $filters['list_id'] = $loggedInUser->getTodo()->getId();
     $filters['only_with_due_date'] = 1;
     $tasks = PlancakeApiServer::getTasks(array_merge($filters, array('api_ver' => $apiVersion, 'camel_case_keys' => 1)));
     $tasks['tasks'] = array_reverse($tasks['tasks']);
     // to make them easier to show on the UI
     if ($request->isXmlHttpRequest()) {
         return $this->renderJson($tasks);
     }
 }
 public function execute($filterChain)
 {
     if (!defined('PLANCAKE_PUBLIC_RELEASE')) {
         $context = $this->getContext();
         $request = $context->getRequest();
         $moduleName = $request->getParameter('module');
         $actionName = $request->getParameter('action');
         $loggedInUser = PcUserPeer::getLoggedInUser();
         $inMobileApp = $moduleName == "mobile";
         if ($loggedInUser && ($loggedInUser->isSupporter() || $inMobileApp)) {
             if (!$request->isSecure()) {
                 $secureUrl = str_replace('http', 'https', $request->getUri());
                 if (stripos($secureUrl, 'http') !== 0) {
                     $secureUrl = 'https://' . $secureUrl;
                 }
                 return $context->getController()->redirect($secureUrl);
                 // We don't continue the filter chain
             }
         } else {
             // 6 Feb 2012 - after launching mobile app we have commented out this block - Why?
             // Mobile app needs to run on HTTPS for everybody (free and Premium) otherwise we don't know
             // what to put in the cache manifest file and offline wouldn't work.
             // So, well, we all the AJAX call from the mobile app must run on HTTPS, then.
             // If you uncomment this back - mobile app may still work on some browsers, but not in others, e.g.: Firefox, Android
             /*
             if ($request->isSecure())
             {
               $secureUrl = str_replace('https', 'http', $request->getUri());
             
               return $context->getController()->redirect($secureUrl);
               // We don't continue the filter chain
             }
             */
         }
     }
     $filterChain->execute();
 }
Пример #22
0
 /**
  * Clears the cache relevant for lists
  */
 private function clearRelevantCache()
 {
     if ($this->getId()) {
         if (sfContext::getInstance()->getUser()->isAuthenticated()) {
             $userId = PcUserPeer::getLoggedInUser()->getId();
             $cacheManager = sfContext::getInstance()->getViewCacheManager();
             if (is_object($cacheManager)) {
                 $cacheManager->remove('@sf_cache_partial?module=lists&action=_mainNavigation&sf_cache_key=' . PcCache::getMainNavigationKey());
             }
             $cache = PcCache::getInstance();
             if (is_object($cache)) {
                 $cache->remove('PcUser::getLists' . $userId);
                 $cache->remove('PcUser::getSystemLists' . $userId);
                 $cache->remove('PcUser::getAllLists' . $userId);
             }
         }
     }
     // we need to clear the cache of each task as its partial will probably
     // contain the list name
     $tasks = $this->getIncompletedTasks();
     foreach ($tasks as $task) {
         $task->save();
     }
 }
Пример #23
0
 /**
  * Get the associated PcUser object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     PcUser The associated PcUser object.
  * @throws     PropelException
  */
 public function getPcUser(PropelPDO $con = null)
 {
     if ($this->aPcUser === null && $this->creator_id !== null) {
         $this->aPcUser = PcUserPeer::retrieveByPk($this->creator_id);
         /* The following can be used additionally to
         		   guarantee the related object contains a reference
         		   to this object.  This level of coupling may, however, be
         		   undesirable since it could result in an only partially populated collection
         		   in the referenced object.
         		   $this->aPcUser->addPcContactNotes($this);
         		 */
     }
     return $this->aPcUser;
 }
 /**
  * Selects a collection of PcBlogComment objects pre-filled with all related objects except PcBlogPost.
  *
  * @param      Criteria  $criteria
  * @param      PropelPDO $con
  * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  * @return     array Array of PcBlogComment objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAllExceptPcBlogPost(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $criteria = clone $criteria;
     // Set the correct dbName if it has not been overridden
     // $criteria->getDbName() will return the same object if not set to another value
     // so == check is okay and faster
     if ($criteria->getDbName() == Propel::getDefaultDB()) {
         $criteria->setDbName(self::DATABASE_NAME);
     }
     PcBlogCommentPeer::addSelectColumns($criteria);
     $startcol2 = PcBlogCommentPeer::NUM_COLUMNS - PcBlogCommentPeer::NUM_LAZY_LOAD_COLUMNS;
     PcUserPeer::addSelectColumns($criteria);
     $startcol3 = $startcol2 + (PcUserPeer::NUM_COLUMNS - PcUserPeer::NUM_LAZY_LOAD_COLUMNS);
     $criteria->addJoin(PcBlogCommentPeer::USER_ID, PcUserPeer::ID, $join_behavior);
     // symfony_behaviors behavior
     foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook) {
         call_user_func($sf_hook, 'BasePcBlogCommentPeer', $criteria, $con);
     }
     $stmt = BasePeer::doSelect($criteria, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = PcBlogCommentPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = PcBlogCommentPeer::getInstanceFromPool($key1))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://propel.phpdb.org/trac/ticket/509
             // $obj1->hydrate($row, 0, true); // rehydrate
         } else {
             $cls = PcBlogCommentPeer::getOMClass(false);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             PcBlogCommentPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined PcUser rows
         $key2 = PcUserPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = PcUserPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $cls = PcUserPeer::getOMClass(false);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 PcUserPeer::addInstanceToPool($obj2, $key2);
             }
             // if $obj2 already loaded
             // Add the $obj1 (PcBlogComment) to the collection in $obj2 (PcUser)
             $obj2->addPcBlogComment($obj1);
         }
         // if joined row is not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
Пример #25
0
 public function getUserEmail()
 {
     return PcUserPeer::retrieveByPK($this->getUserId())->getEmail();
 }
Пример #26
0
 public function getAuthor()
 {
     return PcUserPeer::retrieveByPK($this->getUserId());
 }
Пример #27
0
 public function executeGenerateUserKey(sfWebRequest $request)
 {
     $userId = PcUserPeer::getLoggedInUser()->getId();
     $userKey = PcUserKeyPeer::retrieveByPK($userId);
     if (!is_object($userKey)) {
         $userKey = new PcUserKey();
         $userKey->setUserId($userId)->setKey(PcUtils::generate32CharacterRandomHash())->save();
     }
     $this->getUser()->setFlash('settingSuccess', __('ACCOUNT_SETTINGS_USER_KEY_SUCCESS'));
     $this->redirect(sfContext::getInstance()->getController()->genUrl('settings/index'));
 }
Пример #28
0
 /**
  * Get the associated PcUser object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     PcUser The associated PcUser object.
  * @throws     PropelException
  */
 public function getPcUser(PropelPDO $con = null)
 {
     if ($this->aPcUser === null && $this->user_id !== null) {
         $this->aPcUser = PcUserPeer::retrieveByPk($this->user_id);
         // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association.
         $this->aPcUser->setPcSupporter($this);
     }
     return $this->aPcUser;
 }
Пример #29
0
 /**
  * Returns the number of related PcUser objects.
  *
  * @param      Criteria $criteria
  * @param      boolean $distinct
  * @param      PropelPDO $con
  * @return     int Count of related PcUser objects.
  * @throws     PropelException
  */
 public function countPcUsers(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(PcTimezonePeer::DATABASE_NAME);
     } else {
         $criteria = clone $criteria;
     }
     if ($distinct) {
         $criteria->setDistinct();
     }
     $count = null;
     if ($this->collPcUsers === null) {
         if ($this->isNew()) {
             $count = 0;
         } else {
             $criteria->add(PcUserPeer::TIMEZONE_ID, $this->id);
             $count = PcUserPeer::doCount($criteria, false, $con);
         }
     } else {
         // criteria has no effect for a new object
         if (!$this->isNew()) {
             // the following code is to determine if a new query is
             // called for.  If the criteria is the same as the last
             // one, just return count of the collection.
             $criteria->add(PcUserPeer::TIMEZONE_ID, $this->id);
             if (!isset($this->lastPcUserCriteria) || !$this->lastPcUserCriteria->equals($criteria)) {
                 $count = PcUserPeer::doCount($criteria, false, $con);
             } else {
                 $count = count($this->collPcUsers);
             }
         } else {
             $count = count($this->collPcUsers);
         }
     }
     return $count;
 }
Пример #30
0
      <li><?php 
echo __('ACCOUNT_SETTINGS_PLANCAKE_EMAIL_ADDRESS');
?>
 <em><?php 
echo $user->getPlancakeEmailAddress();
?>
</em> &nbsp;<a href="http://www.plancake.com/about/emailToInbox" class="help" ><?php 
echo __('ACCOUNT_SETTINGS_PLANCAKE_EMAIL_ADDRESS_WHATS_FOR');
?>
</a></li>
      <li><b>User key</b>:
          <?php 
if (PcUserPeer::getLoggedInUser()->getKey()) {
    ?>
            <em><?php 
    echo PcUserPeer::getLoggedInUser()->getKey();
    ?>
</em>
          <?php 
} else {
    ?>
            <a href="<?php 
    echo url_for('settings/generateUserKey');
    ?>
"><?php 
    echo __('ACCOUNT_SETTINGS_GENERATE_USER_KEY');
    ?>
</a>
          <?php 
}
?>