Ejemplo n.º 1
0
 /**
  * get all today's active users
  */
 public function checkAllUsersMedals()
 {
     $query = 'SELECT user_id, username, founds_count, notfounds_count, hidden_count, latitude, longitude, country, email FROM `user` WHERE (`last_login` BETWEEN DATE_SUB(NOW(), INTERVAL 24 HOUR) AND NOW()) ';
     $db = OcDb::instance();
     $s = $db->simpleQuery($query);
     d($db->rowCount($s));
     $timeStart = microtime();
     $usersToCheck = $db->dbResultFetchAll($s);
     foreach ($usersToCheck as $userDbRow) {
         $user = new \lib\Objects\User\User(array('userDbRow' => $userDbRow));
         $user->loadMedalsFromDb();
         $this->checkMedalConditions($user);
     }
     $timeEnd = microtime() - $timeStart;
     d($timeEnd);
 }
Ejemplo 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');
 }