private function getPlacedCount(User $user) { $db = OcDb::instance(); $placedCountQuery = 'SELECT count(*) as cacheCount FROM `caches_additions`, caches WHERE caches_additions.`altitude` > :1 AND caches.cache_id = caches_additions.cache_id AND caches.user_id = :2 AND caches.type IN (:3) AND status = :4 AND `caches`.`date_created` > :5'; $s = $db->multiVariableQuery($placedCountQuery, $this->conditions['minimumAltitude'], $user->getUserId(), $this->buildCacheTypesSqlString(), \lib\Objects\GeoCache\GeoCache::STATUS_READY, $this->dateIntroduced); $dbResult = $db->dbResultFetchOneRowOnly($s); return $dbResult['cacheCount']; }
private function getGeocacherDays(User $user) { $db = OcDb::instance(); $query = 'SELECT period_diff(date_format(now(), "%Y%m"), date_format( `date_created`, "%Y%m")) as months FROM `user` WHERE user_id = :1 LIMIT 1'; $s = $db->multiVariableQuery($query, $user->getUserId()); $dbResult = $db->dbResultFetchOneRowOnly($s); return $dbResult['months']; }
private function getPlacedCacheCount(User $user) { $query = 'SELECT count(caches.cache_id) as cacheCount FROM `caches` ' . 'WHERE `caches`.`user_id` = :1 AND `caches`.`status` IN ( :2 ) AND `caches`.`date_created` > :3 ' . 'AND `caches`.`type` IN ( :4 ) '; $db = DataBaseSingleton::Instance(); $db->multiVariableQuery($query, $user->getUserId(), $this->buildCacheStatusSqlString(), $this->dateIntroduced, $this->buildCacheTypesSqlString()); $dbResult = $db->dbResultFetchOneRowOnly(); return $dbResult['cacheCount']; }
private function getPlacedCacheCount(User $user) { $query = 'SELECT count(caches.cache_id) as cacheCount FROM `caches`, `cache_location` ' . 'WHERE `caches`.`user_id` = :1 ' . $this->buildLocationCode4QueryString(5) . ' ' . 'AND `caches`.`status` = :2 AND `caches`.`date_created` > :3 AND cache_location.code3 = :4 ' . 'AND `caches`.`type` IN (' . $this->buildCacheTypesSqlString() . ') ' . 'AND cache_location.cache_id = caches.cache_id '; $db = DataBaseSingleton::Instance(); $code4 = isset($this->conditions['cacheLocation']['code4']) ? $this->conditions['cacheLocation']['code4'] : false; if ($code4) { $db->multiVariableQuery($query, $user->getUserId(), \cache::STATUS_READY, $this->dateIntroduced, $this->conditions['cacheLocation']['code3'], $code4); } else { $db->multiVariableQuery($query, $user->getUserId(), \cache::STATUS_READY, $this->dateIntroduced, $this->conditions['cacheLocation']['code3']); } $dbResult = $db->dbResultFetchOneRowOnly(); return $dbResult['cacheCount']; }
public function checkConditionsForUser(\lib\Objects\User\User $user) { if (!in_array($this->config->getOcNodeId(), $this->conditions['ocNodeId'])) { /* this medal is not available in current node */ return; } $query = 'SELECT count(`id`) as `completedLogCount` FROM `PowerTrail_comments` WHERE `deleted` = 0 AND `userId` = :1 AND `PowerTrailId` = :2 '; $db = OcDb::instance(); $s = $db->multiVariableQuery($query, $user->getUserId(), $this->conditions['geoPath']['geoPathId']); $cacheCountArr = $db->dbResultFetchOneRowOnly($s); if ($cacheCountArr['completedLogCount'] == 1) { $this->prizedTime = date($this->config->getDbDateTimeFormat()); $this->level = 0; } else { $this->prizedTime = false; } $this->storeMedalStatus($user); }
public function checkConditionsForUser(User $user) { if (!in_array($this->config->getOcNodeId(), $this->conditions['ocNodeId'])) { /* this medal is not available in current node */ return; } $db = OcDb::instance(); $queryFound = 'SELECT MAX(`altitude`) as maxAltitude FROM `caches`, `caches_additions`, cache_logs WHERE caches.`cache_id` = caches_additions.`cache_id` AND cache_logs.cache_id = caches.`cache_id` AND cache_logs.type = 1 AND cache_logs.user_id = :1 AND caches.type IN(:2)'; $cacheTypes = $this->buildCacheTypesSqlString(); $s = $db->multiVariableQuery($queryFound, $user->getUserId(), $cacheTypes); $foundMaxAltitudeRaw = $db->dbResultFetchOneRowOnly($s); $foundMaxAltitude = (int) $foundMaxAltitudeRaw['maxAltitude']; $queryPlaced = 'SELECT MAX(`altitude`) as maxAltitude FROM `caches`, `caches_additions` WHERE caches.`cache_id` = caches_additions.`cache_id` AND cache.user_id = :1 AND caches.type IN(:2) AND cache.status = :3'; $s = $db->multiVariableQuery($queryPlaced, $user->getUserId(), $cacheTypes, \cache::STATUS_READY); $placedMaxAltitudeRaw = $db->dbResultFetchOneRowOnly($s); $placedMaxAltitude = (int) $placedMaxAltitudeRaw['maxAltitude']; $this->findLevel($foundMaxAltitude, $placedMaxAltitude); $this->storeMedalStatus($user); }
public function storeInDb() { $db = OcDb::instance(); if ($_REQUEST['type'] == Log::TYPE_CONQUESTED && $this->powerTrail->isAlreadyConquestedByUser($this->user)) { /* atempt to add second 'conquested' log */ return false; } if ($this->id) { ddd('TODO'); } else { if ($this->type === self::TYPE_ADD_WARNING && $this->user->getIsAdmin() === false) { return false; /* regular user is not allowed to add entery of this type */ } $query = 'INSERT INTO `PowerTrail_comments`(`userId`, `PowerTrailId`, `commentType`, `commentText`, `logDateTime`, `dbInsertDateTime`, `deleted`) VALUES (:1, :2, :3, :4, :5, NOW(),0)'; $db->multiVariableQuery($query, $this->user->getUserId(), $this->powerTrail->getId(), $this->type, $this->text, $this->dateTime->format('Y-m-d H:i:s')); if ($this->type == self::TYPE_CONQUESTED) { $this->powerTrail->increaseConquestedCount(); } } $this->changePowerTrailStatusAfterLog(); return true; }
require $stylepath . '/lib/icons.inc.php'; $tplname = 'viewprofile'; if ($user_id != $usr['userid']) { // do not highlight My stats menu item if browsing other users stats $mnu_siteid = 'start'; } $stat_menu = array('title' => tr('Statictics'), 'menustring' => tr('Statictics'), 'siteid' => 'statlisting', 'navicolor' => '#E8DDE4', 'visible' => false, 'filename' => 'viewprofile.php?userid=' . $user_id, 'submenu' => array(array('title' => tr('graph_find'), 'menustring' => tr('graph_find'), 'visible' => true, 'filename' => 'ustatsg2.php?userid=' . $user_id, 'newwindow' => false, 'siteid' => 'findstat', 'icon' => 'images/actions/stat'), array('title' => tr('graph_created'), 'menustring' => tr('graph_created'), 'visible' => true, 'filename' => 'ustatsg1.php?userid=' . $user_id, 'newwindow' => false, 'siteid' => 'createstat', 'icon' => 'images/actions/stat'))); $content = ""; $database = OcDb::instance(); $rddQuery = "select TO_DAYS(NOW()) - TO_DAYS(`date_created`) `diff` from `user` WHERE user_id=:1 LIMIT 1"; $s = $database->multiVariableQuery($rddQuery, $user_id); $ddays = $database->dbResultFetchOneRowOnly($s); $query = "SELECT user_id, admin, guru, hidden_count, founds_count, is_active_flag, email, password, log_notes_count, notfounds_count, username, last_login, country, date_created, description, hide_flag\n FROM user WHERE user_id=:1 LIMIT 1"; $s = $database->multiVariableQuery($query, $user_id); $user_record = $database->dbResultFetchOneRowOnly($s); $user = new User(array('userDbRow' => $user_record)); tpl_set_var('username', $user_record['username']); if (date('m') == 4 and date('d') == 1) { tpl_set_var('username', tr('primaAprilis1')); } tpl_set_var('country', tr($user_record['country'])); tpl_set_var('registered', fixPlMonth(strftime($dateformat, strtotime($user_record['date_created'])))); $description = $user_record['description']; tpl_set_var('description', nl2br($description)); if ($description != "") { tpl_set_var('description_start', ''); tpl_set_var('description_end', ''); } else { tpl_set_var('description_start', '<!--'); tpl_set_var('description_end', '-->'); }
public static function sendRemoveLogNotification($emailTemplateFile, GeoCacheLog $log, User $loggedUser) { $formattedMessage = new EmailFormatter($emailTemplateFile); $formattedMessage->setVariable("log_owner", $log->getUser()->getUserName()); $formattedMessage->setVariable("waypointId", $log->getGeoCache()->getWaypointId()); $formattedMessage->setVariable("serviceUrl", OcConfig::getAbsolute_server_URI()); $formattedMessage->setVariable("logRemover", $loggedUser->getUserName()); $formattedMessage->setVariable("logRemoverId", $loggedUser->getUserId()); $formattedMessage->setVariable("cache_name", $log->getGeoCache()->getCacheName()); $formattedMessage->setVariable("log_entry", $log->getText()); $formattedMessage->setVariable("removedLog_01", tr('removedLog_01')); $formattedMessage->setVariable("removedLog_02", tr('removedLog_02')); $formattedMessage->addFooterAndHeader($log->getUser()->getUserName()); $email = new Email(); $email->addToAddr($log->getUser()->getEmail()); $email->setReplyToAddr(OcConfig::getNoreplyEmailAddress()); $email->setFromAddr(OcConfig::getNoreplyEmailAddress()); $email->setSubject(tr('removed_log_title')); $email->setBody($formattedMessage->getEmailContent(), true); $email->send(); }
private function isCurrentMedalAlreadyPrized(User $user) { $userMedals = $user->getMedals(); $iterator = $userMedals->getIterator(); /* @var $currentMedal \lib\Objects\Medals\Medal */ while ($iterator->valid()) { $currentMedal = $iterator->current(); if ($currentMedal->getMedalId() === $this->medalId) { /* current medal */ return $currentMedal; } $iterator->next(); } return false; }
public function isAlreadyConquestedByUser(\lib\Objects\User\User $user) { $db = OcDb::instance(); $mySqlRequest = 'SELECT count(*) AS `ptConquestCount` FROM `PowerTrail_comments` WHERE `commentType` =2 AND `deleted` =0 AND `userId` =:1 AND `PowerTrailId` = :2'; $s = $db->multiVariableQuery($mySqlRequest, $user->getUserId(), $this->getId()); $mySqlResult = $db->dbResultFetch($s); if ($mySqlResult['ptConquestCount'] > 0) { return true; } else { return false; } }