/** * * @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; }
/** * * @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; }
/** * * @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(); } }
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']); }
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(); } } }
/** * 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); } } }
private function areAdvertsToShow() { if (defined('PLANCAKE_PUBLIC_RELEASE')) { return false; } $user = PcUserPeer::getLoggedInUser(); if (is_object($user) && $user->isSupporter()) { return false; } return true; }
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(); } } }
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; } } }
/** * 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(); }
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(); }
/** * 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(); } }
</div> </div> <ul id="tags"> </ul> <form id="hackToScrollToBottomTag"><input type="text" /></form> <div class="hidden noPrint allowanceAlert" id="maxTagsAllowanceAlert"></div> <div style="margin-bottom: 15px"> </div> <br style="clear: both" /> <?php if (!PcUserPeer::getLoggedInUser()->isSupporter()) { ?> <div id="mainAd"> <a class="removeAd" class="inboundLink" href="/account.php/upgrade?feature=ad"><span class="lang lang_ACCOUNT_MISC_REMOVE_THIS_AD"></span></a> <!-- place ad here --> <div> Would you like to get things done with a team? <br /> Check out the <a target="_blank" href="http://team.plancake.com">other product</a> we have been developing for you. </div> </div> <?php } ?> <br style="clear: both" />
public static function getMainNavigationKey() { return PcLanguagePeer::getUserPreferredLanguage()->getId() . '-' . PcUserPeer::getLoggedInUser()->getId(); }
* Danyuki Software Limited is registered in England and Wales (Company No. 07554549) * ************************************************************************************** * Plancake is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Affero General Public License for more details. * * * * You should have received a copy of the GNU Affero General Public License * * along with this program. If not, see <http://www.gnu.org/licenses/>. * * * **************************************************************************************/ ?> <select name="dueTimeHour" class="dueTimeHour"> <?php if (!PcUserPeer::getLoggedInUser()->getTimeFormat()) { ?> <option value=""></option> <option value="0">12am</option> <option value="1">1am</option> <option value="2">2am</option> <option value="3">3am</option> <option value="4">4am</option> <option value="5">5am</option> <option value="6">6am</option> <option value="7">7am</option> <option value="8">8am</option> <option value="9">9am</option> <option value="10">10am</option> <option value="11">11am</option> <option value="12">12pm</option>
/** * @param myUser $user * @param sfAction $action */ public static function redirectLoggedInUser(myUser $user, sfAction $action) { // not redirecting if the user is a member of the staff or a translator as // they may need to debug something $loggedInUser = PcUserPeer::getLoggedInUser(); if ($loggedInUser) { if ($loggedInUser->isStaffMember() || $loggedInUser->isTranslator()) { return; } } if ($loggedInUser && $user->isAuthenticated()) { self::redirectToApp($action); } }
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); } } */ }
/** * * @param string $localDueDate - in the format Y-m-d (the local one for the user) * @param string $localDueTime - in the format (H)H:mm (the local one for the user) * @return array ($dueDate, $dueTime) - same format as the input */ public static function fromLocalDateAndTime2GMTDateAndTime($localDueDate, $localDueTime) { $dueDate = ''; $dueTime = ''; if (!is_numeric($localDueTime)) { $dueDate = $localDueDate; } else { list($year, $month, $day) = explode('-', $localDueDate); $hour = floor($localDueTime / 100); $minute = $localDueTime % 100; $localTimestamp = mktime($hour, $minute, 0, $month, $day, $year); $gmtTimestamp = $localTimestamp - PcUserPeer::getLoggedInUser()->getRealOffsetFromGMT(); $dueDate = date('Y-m-d', $gmtTimestamp); $dueTime = (int) date('Gi', $gmtTimestamp); } return array($dueDate, $dueTime); }
$authSubUrl = Zend_Gdata_AuthSub::getAuthSubTokenUri($next, $scope, $secure, $session); header("HTTP/1.0 307 Temporary redirect"); header("Location: " . $authSubUrl); exit; } else { try { $client = new Zend_Gdata_HttpClient(); $pathToKey = sfConfig::get('sf_root_dir') . '/' . sfConfig::get('app_googleCalendarIntegration_privateKeyPath'); $client->setAuthSubPrivateKeyFile($pathToKey, null, true); $sessionToken = Zend_Gdata_AuthSub::getAuthSubSessionToken($_GET['token'], $client); } catch (Exception $e) { sfErrorNotifier::alert("Google Calendar Init: " . $e->getMessage()); $this->redirect('default', array('module' => 'googleCalendarIntegration', 'action' => 'step3Error')); } $redirectUrl = ''; if ($sessionToken) { $loggedInUser = PcUserPeer::getLoggedInUser(); if ($loggedInUser) { $googleCalendarInterface = new GoogleCalendarInterface($loggedInUser); $googleCalendarInterface->resetDbEntry(); $googleCalendarInterface->setSessionToken($sessionToken); } $configuration->loadHelpers('Url'); $redirectUrl = 'http://' . sfConfig::get('app_site_url') . '/' . sfConfig::get('app_accountApp_frontController') . '/googleCalendarIntegration/step3'; } else { // something wrong $configuration->loadHelpers('Url'); $redirectUrl = 'http://' . sfConfig::get('app_site_url') . ($redirectUrl = 'http://' . sfConfig::get('app_site_url') . '/' . sfConfig::get('app_accountApp_frontController') . '/googleCalendarIntegration/step3Error'); } header("Location: {$redirectUrl}"); }
<li><?php echo __('ACCOUNT_SETTINGS_PLANCAKE_EMAIL_ADDRESS'); ?> <em><?php echo $user->getPlancakeEmailAddress(); ?> </em> <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 } ?>
* Licensed under the AGPL version 3 license. * * * Danyuki Software Limited is registered in England and Wales (Company No. 07554549) * ************************************************************************************** * Plancake is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Affero General Public License for more details. * * * * You should have received a copy of the GNU Affero General Public License * * along with this program. If not, see <http://www.gnu.org/licenses/>. * * * **************************************************************************************/ if (PcUserPeer::getLoggedInUser()) { ?> <form action="https://www.paypal.com/cgi-bin/webscr" method="post" style="margin-top: 5px;"> <input type="hidden" name="cmd" value="_s-xclick"> <input type="hidden" name="custom" value="<?php echo PcUserPeer::getLoggedInUser()->getEmail(); ?> "> <input type="hidden" name="hosted_button_id" value="<?php echo $buttonCode; ?> "> <input type="image" src="https://www.paypalobjects.com/en_GB/i/btn/btn_buynow_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online."> <img alt="" border="0" src="https://www.paypal.com/en_GB/i/scr/pixel.gif" width="1" height="1"> </form> <?php }
public function executeGetTasks(sfWebRequest $request) { 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 = urldecode($request->getParameter('extraParam')); $filters = array(); $filters['completed'] = (int) $doneParam; if ($typeParam == "list") { $filters['list_id'] = (int) $extraParam; $user = PcUserPeer::getLoggedInUser(); /* // This was to hide scheduled tasks from the Todo list if ( $user->getTodo()->getId() == $filters['list_id']) { $filters['only_without_due_date'] = 1; } */ } else { if ($typeParam == "tag") { $filters['tag_id'] = (int) $extraParam; } else { if ($typeParam == "starred") { $filters['only_starred'] = 1; } else { if ($typeParam == "today") { $filters['only_due_today_or_tomorrow'] = 1; } else { if ($typeParam == "calendar") { $filters['by_date'] = $extraParam; } else { if ($typeParam == "search") { $filters['search_query'] = $extraParam; } } } } } } $tasks = PlancakeApiServer::getTasks(array_merge($filters, array('api_ver' => $apiVersion, 'camel_case_keys' => 1))); if ($request->isXmlHttpRequest()) { return $this->renderJson($tasks); } }
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')); }
<link type="text/css" rel="stylesheet" href="https://fonts.googleapis.com/css?family=Comfortaa"></link> <link rel="shortcut icon" href="/favicon.ico" /> </head> <body id="pc_loginPage"> <div id="pc_content"> <?php echo $sf_content; ?> </div> <?php if ($sf_params->get('module') == 'plans' && PcUserPeer::getLoggedInUser() || $sf_params->get('module') == 'registration' || $sf_params->get('module') == 'customAuth') { ?> <?php } else { ?> <?php include_component('templateParts', 'footer'); ?> <?php } ?> <?php include_javascripts(); ?>