public function removeLog(GeoCacheLog $log, $request = null)
 {
     $result = false;
     if ($log === false) {
         $this->errors[] = 'No such log';
         return false;
     }
     if ($log->getNode() != OcConfig::instance()->getOcNodeId()) {
         $this->errors[] = 'Wrong Node';
         return false;
     }
     $loggedUser = \lib\Objects\ApplicationContainer::Instance()->getLoggedUser();
     if ($loggedUser === false) {
         $this->errors[] = 'User is not looged-in';
         return false;
     }
     if ($log->getUser()->getUserId() === $loggedUser->getUserId() || $log->getGeoCache()->getOwner()->getUserId() == $loggedUser->getUserId() || $loggedUser->getIsAdmin()) {
         if ($log->getUser()->getUserId() !== $loggedUser->getUserId()) {
             EmailSender::sendRemoveLogNotification(__DIR__ . '/../../tpl/stdstyle/email/removed_log.email.html', $log, $loggedUser);
         }
         $updateQuery = "UPDATE `cache_logs` SET deleted = 1, `del_by_user_id` = :1 , `last_modified`=NOW(), `last_deleted`=NOW() WHERE `cache_logs`.`id`=:2 LIMIT 1";
         $db = OcDb::instance();
         $db->multiVariableQuery($updateQuery, $loggedUser->getUserId(), $log->getId());
         $log->getUser()->recalculateAndUpdateStats();
         if ($log->getType() == GeoCacheLog::LOGTYPE_MOVED) {
             $this->handleMobileGeocachesAfterLogDelete($log);
         }
         if ($log->getType() == GeoCacheLog::LOGTYPE_FOUNDIT || $log->getType() == GeoCacheLog::LOGTYPE_ATTENDED) {
             $this->cacheScoreHandlingAfterRemoveLog($log);
         }
         //call eventhandler
         require_once __DIR__ . '/../eventhandler.inc.php';
         event_remove_log($log->getGeoCache()->getCacheId(), $loggedUser->getUserId());
         $this->updateGeocacheAfterLogRemove($log, $db);
         $result = true;
     } else {
         $this->errors[] = 'User has no privileages to delete this log';
     }
     return $result;
 }
Esempio n. 2
0
function auth_user()
{
    global $usr, $login;
    $login->verify();
    $applicationContainer = \lib\Objects\ApplicationContainer::Instance();
    if ($login->userid != 0) {
        //set up $usr array
        $applicationContainer->setLoggedUser(new lib\Objects\User\User(array('userId' => $login->userid)));
        $userRow = getUserRow($login->userid);
        $usr['username'] = $userRow['username'];
        $usr['hiddenCacheCount'] = $userRow['hidden_count'];
        $usr['logNotesCount'] = $userRow['log_notes_count'];
        $usr['userFounds'] = $userRow['founds_count'];
        $usr['notFoundsCount'] = $userRow['notfounds_count'];
        $usr['userid'] = $login->userid;
        $usr['email'] = $userRow['email'];
        $usr['country'] = $userRow['country'];
        $usr['latitude'] = $userRow['latitude'];
        $usr['longitude'] = $userRow['longitude'];
    } else {
        $usr = false;
    }
    return;
}
Esempio n. 3
0
}
global $titled_cache_period_prefix;
//include template handling
require_once $rootpath . 'lib/common.inc.php';
require_once $rootpath . 'lib/calculation.inc.php';
require_once $rootpath . 'lib/cache_icon.inc.php';
require_once $stylepath . '/lib/icons.inc.php';
//require_once($rootpath . '/powerTrail/PowerTrailBase.php');
//Preprocessing
if ($error == false) {
    //user logged in?
    if ($usr == false) {
        $target = urlencode(tpl_get_current_page());
        tpl_redirect('login.php?target=' . $target);
    } else {
        $applicationContainer = \lib\Objects\ApplicationContainer::Instance();
        $db = $applicationContainer->db;
        //get user record
        $user_id = $usr['userid'];
        tpl_set_var('userid', $user_id);
        if (isset($_REQUEST['logs'])) {
            $logs = $_REQUEST['logs'];
        } else {
            $logs = 1;
        }
        //get the news
        $tplname = 'myneighborhood';
        $fixed_google_map_link = '';
        $marker_offset = 0;
        function get_zoom($latitude, $lonMin, $lonMax, $latMin, $latMax)
        {
Esempio n. 4
0
 /**
  *
  * Check if this power trail meet criteria to be opened
  *
  * Criteria:
  * - percent required > minimum percent required
  * - active geocahes Count >= required geocache count
  * - minimum geocaches count >= required geocaches count set in settings.inc.php
  *
  * @return boolean
  */
 public function canBeOpened()
 {
     $this->getGeocaches();
     if ($this->perccentRequired < \lib\Controllers\PowerTrailController::MINIMUM_PERCENT_REQUIRED) {
         return false;
     }
     if ($this->activeGeocacheCount < $this->caclulateRequiredGeocacheCount()) {
         return false;
     }
     $appContainer = \lib\Objects\ApplicationContainer::Instance();
     if ($this->status === self::STATUS_CLOSED && $appContainer->getLoggedUser()->getIsAdmin() === false) {
         return false;
     }
     return true;
 }