public function archive_cache($cache_id, $comment, $months = 0)
 {
     global $opt, $login, $translate;
     $log = cachelog::createNew($cache_id, $login->userid);
     if ($log === false) {
         echo $this->name . ": cannot create log for cache {$cache_id}\n";
     } else {
         $cache = new cache($cache_id);
         if (!$cache->setStatus(3) || !$cache->save()) {
             echo $this->name . ": cannot change status of cache {$cache_id}\n";
         } else {
             // create log
             $log->setType(cachelog::LOGTYPE_ARCHIVED, true);
             $log->setOcTeamComment(true);
             $log->setDate(date('Y-m-d'));
             // Log without time, so that owner reactions will always appear AFTER
             // the system log, no matter if logged with or without date.
             // create log text in appropriate language
             $translated_comment = $translate->t($comment, '', '', 0, '', 1, $cache->getDefaultDescLanguage());
             $translated_comment = str_replace('%1', $months, $translated_comment);
             $log->setText('<p>' . $translated_comment . '</p>');
             $log->setTextHtml(1);
             if (!$log->save()) {
                 echo $this->name . ": could not save archive log for cache {$cache_id}\n";
             }
         }
     }
 }
Example #2
0
 function disable()
 {
     global $login, $translate;
     if ($this->canDisable() == false) {
         return false;
     }
     // write old record to log
     $backup = array();
     $backup['username'] = $this->getUsername();
     $backup['email'] = $this->getEMail();
     $backup['last_name'] = $this->getLastName();
     $backup['first_name'] = $this->getFirstName();
     sql("INSERT INTO `logentries` (`module`, `eventid`, `userid`, `objectid1`, `objectid2`, `logtext`, `details`)\n\t\t                       VALUES ('user', 6, '&1', '&2', '&3', '&4', '&5')", $login->userid, $this->nUserId, 0, 'User ' . sql_escape($this->getUsername()) . ' disabled', serialize($backup));
     // delete private data
     sql("UPDATE `user` SET `password`=NULL, `email`=NULL, \n\t\t                       `is_active_flag`=0, \n\t\t                       `latitude`=0, `longitude`=0, \n\t\t                       `last_name`='', `first_name`='', `country`=NULL, `accept_mailing`=0, `pmr_flag`=0,\n\t\t                       `new_pw_code`=NULL, `new_pw_date`=NULL,\n\t\t                       `new_email`=NULL, `new_email_code`=NULL, `new_email_date`=NULL,\n\t\t                       `email_problems`=0, `first_email_problem`=NULL, `last_email_problem`=NULL,\n\t\t                       `permanent_login_flag`=0, `activation_code`='',\n\t\t                       `notify_radius`=0\n\t\t                 WHERE `user_id`='&1'", $this->nUserId);
     // Statpic and profile description texts are published under the data license
     // terms and therefore need not to be deleted.
     sql("DELETE FROM `user_options` WHERE `user_id`='&1'", $this->nUserId);
     $this->reload();
     sql("DELETE FROM `cache_lists`     WHERE `user_id`='&1'", $this->nUserId);
     // Triggers will do all the dependent clean-up.
     sql("DELETE FROM `cache_adoption`  WHERE `user_id`='&1'", $this->nUserId);
     sql("DELETE FROM `cache_ignore`    WHERE `user_id`='&1'", $this->nUserId);
     sql("DELETE FROM `cache_watches`   WHERE `user_id`='&1'", $this->nUserId);
     sql("DELETE FROM `watches_waiting` WHERE `user_id`='&1'", $this->nUserId);
     sql("DELETE FROM `notify_waiting`  WHERE `user_id`='&1'", $this->nUserId);
     // lock the user's caches
     $error = false;
     $rs = sql("SELECT `cache_id` FROM `caches` WHERE `user_id`='&1' AND `status` IN (1,2,3)", $this->nUserId);
     while (($rCache = sql_fetch_assoc($rs)) && !$error) {
         $error = true;
         $cache = new cache($rCache['cache_id']);
         if ($cache->setStatus(6) && $cache->save()) {
             $log = cachelog::createNew($rCache['cache_id'], $login->userid, true);
             if ($log !== false) {
                 $log->setType(cachelog::LOGTYPE_LOCKED, true);
                 $log->setOcTeamComment(true);
                 $log->setDate(date('Y-m-d'));
                 $log->setText($translate->t('The user account has been disabled.', '', '', 0, '', 1, $cache->getDefaultDescLanguage()));
                 $log->setTextHtml(false);
                 if ($log->save()) {
                     $error = false;
                 }
             }
         }
         echo "\n";
     }
     sql_free_result($rs);
     return !$error;
 }
Example #3
0
 public function disable()
 {
     global $login, $translate;
     if ($this->canDisable() == false) {
         return false;
     }
     // write old record to log
     $backup = array();
     $backup['username'] = $this->getUsername();
     $backup['email'] = $this->getEMail();
     $backup['last_name'] = $this->getLastName();
     $backup['first_name'] = $this->getFirstName();
     $backup['country'] = $this->getCountryCode();
     $backup['latitude'] = $this->getLatitude();
     $backup['longitude'] = $this->getLongitude();
     sql("INSERT INTO `logentries` (`module`, `eventid`, `userid`, `objectid1`, `objectid2`, `logtext`, `details`)\n             VALUES ('user', 6, '&1', '&2', '&3', '&4', '&5')", $login->userid, $this->nUserId, 0, 'User ' . sql_escape($this->getUsername()) . ' disabled', serialize($backup));
     // delete private and system data
     sql("UPDATE `user` SET `password`=NULL, `email`=NULL, `last_name`='', `first_name`='',\n                               `country`=NULL, `latitude`=0, `longitude`=0, `is_active_flag`=0, `activation_code`='',\n                               `new_pw_code`=NULL, `new_pw_date`=NULL, `new_email`=NULL, `new_email_code`=NULL,\n                               `new_email_date`=NULL, `email_problems`=0, `first_email_problem`=NULL,\n                               `last_email_problem`=NULL\n             WHERE `user_id`='&1'", $this->nUserId);
     // non-private data which need not to be deleted:
     //
     //   - Statpic and profile description texts - published under the data license
     //   - profile settings: accept_mailing, pmr_flag, permanent_login_flag, notify_radius,
     //                       user_options entries
     //   - watch and ignore lists
     //   - adoptions: may still be executed if offered to another user
     // Handling of cache lists is unclear. They may be deleted by the Opencaching team
     // if not considered useful.
     // lock the user's caches
     $error = false;
     $rs = sql("SELECT `cache_id` FROM `caches` WHERE `user_id`='&1' AND `status` IN (1,2,3)", $this->nUserId);
     while (($rCache = sql_fetch_assoc($rs)) && !$error) {
         $error = true;
         $cache = new cache($rCache['cache_id']);
         if ($cache->setStatus(6) && $cache->save()) {
             $log = cachelog::createNew($rCache['cache_id'], $login->userid, true);
             if ($log !== false) {
                 $log->setType(cachelog::LOGTYPE_LOCKED, true);
                 $log->setOcTeamComment(true);
                 $log->setDate(date('Y-m-d'));
                 $log->setText($translate->t('The user account has been disabled.', '', '', 0, '', 1, $cache->getDefaultDescLanguage()));
                 $log->setTextHtml(false);
                 if ($log->save()) {
                     $error = false;
                 }
             }
         }
         echo "\n";
     }
     sql_free_result($rs);
     return !$error;
 }
Example #4
0
$adminid = sql_value("SELECT `adminid` FROM `cache_reports` WHERE `id`=&1", 0, $rid);
if (isset($_REQUEST['assign']) && $rid > 0 && $adminid == 0) {
    sql("UPDATE `cache_reports` SET `status`=2, `adminid`=&2 WHERE `id`=&1", $rid, $login->userid);
    $tpl->redirect('adminreports.php?id=' . $rid);
} elseif (isset($_REQUEST['contact']) && $ownerid > 0) {
    $tpl->redirect('mailto.php?userid=' . urlencode($ownerid));
} elseif ((isset($_REQUEST['statusActive']) || isset($_REQUEST['statusTNA']) || isset($_REQUEST['statusArchived']) || isset($_REQUEST['statusLockedVisible']) || isset($_REQUEST['statusLockedInvisible'])) && $adminid == $login->userid) {
    $cache = new cache($cacheid);
    if ($cache->exist() == false) {
        $tpl->error(ERROR_CACHE_NOT_EXISTS);
    }
    if ($cache->allowView() == false) {
        $tpl->error(ERROR_NO_ACCESS);
    }
    if (isset($_REQUEST['statusActive'])) {
        $cache->setStatus(1);
    } else {
        if (isset($_REQUEST['statusTNA'])) {
            $cache->setStatus(2);
        } else {
            if (isset($_REQUEST['statusArchived'])) {
                $cache->setStatus(3);
            } else {
                if (isset($_REQUEST['statusLockedVisible'])) {
                    $cache->setStatus(6);
                } else {
                    if (isset($_REQUEST['statusLockedInvisible'])) {
                        $cache->setStatus(7);
                    }
                }
            }