Exemplo n.º 1
0
 /**
  *
  * @param array $params require:
  * 'prizedTime' => (datetime) date time when user were awarded with this medal
  * 'type' => medal type
  */
 public function __construct($params)
 {
     $this->medalId = $params['medalId'];
     $details = \lib\Controllers\MedalsController::getMedalConfigByMedalId($this->medalId);
     $this->conditions = $details['conditions'];
     $this->name = $details['name'];
     $this->description = $details['description'];
     $this->dateIntroduced = $details['dateIntroduced'];
     if (isset($params['prizedTime'])) {
         $this->prizedTime = $params['prizedTime'];
         $this->level = (int) $params['level'];
         $this->setImage();
     }
     $this->config = \lib\Objects\OcConfig\OcConfig::Instance();
 }
Exemplo n.º 2
0
 private function userMedals()
 {
     /* lang test */
     /* get locale from browser */
     $userPrefferedLanguages = explode(';', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
     $mostPrefferedLanguage = explode(',', $userPrefferedLanguages[0]);
     $locale = str_replace('-', '_', $mostPrefferedLanguage[0]);
     if (isset($_REQUEST['locale'])) {
         /* get locale from $_REQUEST*/
         $locale = $_REQUEST['locale'];
     }
     $putenv = putenv("LANG={$locale}");
     $setlocale = setlocale(LC_ALL, $locale);
     //        d($locale, $putenv, $setlocale);
     bindtextdomain("medals", __DIR__ . '/../languages');
     bind_textdomain_codeset('medals', 'UTF-8');
     textdomain("medals");
     //        print gettext('level');
     //        print '<BR>';
     /* end lang test*/
     $ocConfig = \lib\Objects\OcConfig\OcConfig::Instance();
     $smarty = new \Smarty();
     $smarty->setCompileDir($ocConfig->getDynamicFilesPath() . 'tmp/templates_c');
     $smarty->debugging = false;
     $smarty->caching = false;
     $smarty->setTemplateDir(__DIR__ . '/../../tpl/smarty');
     $smarty->setCacheDir($ocConfig->getDynamicFilesPath() . 'tmp/smarty_cache');
     $user = new \lib\Objects\User\User(array('userId' => $this->request['userId']));
     $user->loadMedalsFromDb();
     //        d($user, $user->getMedals());
     /* @var $medal \lib\Objects\Medals\Medal */
     foreach ($user->getMedals() as $medal) {
         $medal->checkConditionsForUser($user);
         $smartyMedals['medals'][] = array('imgSrc' => $medal->getImage(), 'name' => $medal->getName(), 'profile' => $medal->getMedalProfile(), 'level' => $medal->getLevel(), 'levelName' => $medal->getLevelName(), 'currentLevelInfo' => $medal->getLevelInfo(), 'nextLevelInfo' => $medal->getLevelInfo($medal->getLevel() + 1));
     }
     $smartyMedals['tr'] = array('level' => _('level'), 'user' => _('user'), 'medals' => _('medals'), 'nextLevelRequirements' => _('Next level Requirements'), 'currentLevelRequirements' => _('Level achievements'), 'medalInfo' => _('Medal Profile'), 'cacheTypes' => _('Geocache types'));
     $smarty->assign('geocacheIcons', \cache::getCacheIconsSet());
     $smarty->assign('user', $user->getUserInformation());
     $smarty->assign("smartyMedals", $smartyMedals);
     $smarty->assign("bgImage", $this->shuffleBackgroundImage());
     $smarty->display('medals.tpl');
 }
 public function __construct()
 {
     $this->config = \lib\Objects\OcConfig\OcConfig::Instance();
 }
Exemplo n.º 4
0
 /**
  * Function to check if current cache is part of any PowerTrail.
  * On success PowerTrail object is created.
  *
  * @return boolean true if this cache belongs to any PowerTrail;
  */
 public function isPowerTrailPart()
 {
     if (!OcConfig::Instance()->getPowerTrailModuleSwitchOn()) {
         return false;
     }
     if (is_null($this->isPowerTrailPart)) {
         $ptArr = PowerTrail::CheckForPowerTrailByCache($this->id);
         if (count($ptArr) > 0) {
             // TODO: ASSUMPTION: cache belongs to ONLY one PT
             $this->isPowerTrailPart = true;
             $this->powerTrail = new PowerTrail(array('dbRow' => $ptArr[0]));
         } else {
             $this->isPowerTrailPart = false;
         }
     }
     return $this->isPowerTrailPart;
 }