Skip to content
Permalink
Browse files

generate status-change logs for Ocprop actions and account-disabling; f…

…ixes #207
  • Loading branch information...
following5 committed Jun 5, 2013
1 parent 4408abe commit 0eeb9c1d2163dcd27605dc644cf4657374d705ca
@@ -474,10 +474,32 @@ function getWaypoints($cacheid)
}
// save to DB
// status update will trigger touching the last_modified date of all depending records
// Status update will trigger touching the last_modified date of all depending records.
// Status change via editcache.php is no longer available via the user interface,
// but still used by Ocprop and maybe other tools.
sql("SET @STATUS_CHANGE_USER_ID='&1'", $usr['userid']);
sql("UPDATE `caches` SET `name`='&1', `longitude`='&2', `latitude`='&3', `type`='&4', `date_hidden`='&5', `country`='&6', `size`='&7', `difficulty`='&8', `terrain`='&9', `status`='&10', `search_time`='&11', `way_length`='&12', `logpw`='&13', `wp_gc`='&14', `wp_nc`='&15', `date_activate` = $activation_date WHERE `cache_id`='&16'", $cache_name, $cache_lon, $cache_lat, $cache_type, date('Y-m-d', mktime(0, 0, 0, $cache_hidden_month, $cache_hidden_day, $cache_hidden_year)), $cache_country, $sel_size, $cache_difficulty, $cache_terrain, $status, $search_time, $way_length, $log_pw, $wp_gc, $wp_nc, $cache_id);
// generate status-change log
if ($status != $status_old && $status_old != 5)
{
switch ($status)
{
case 1: $logtype = 10; break;
case 2: $logtype = 11; break;
case 3: $logtype = 9; break;
case 6: $logtype = 13; break;
default: $logtype = 0; // ???
}
if ($logtype > 0)
{
sql("INSERT INTO `cache_logs` (`node`, `cache_id`, `user_id`, `type`, `date`)
VALUES ('&1','&2','&3','&4','&5')",
$oc_nodeid, $cache_id, $usr['userid'], $logtype, date('Y-m-d'));
// notifications will be automatically generated
}
}
// do not use slave server for the next time ...
db_slave_exclude();
@@ -457,7 +457,7 @@ function allowLog()
global $login;
$login->verify();
if ($this->getUserId() == $login->userid)
if ($this->getUserId() == $login->userid || $login->hasAdminPriv(ADMIN_USER))
return true;
return (sql_value("SELECT `allow_user_log` FROM `cache_status` WHERE `id`='&1'", 0, $this->getStatus()) == 1);
@@ -162,15 +162,15 @@ function getTextHtml()
}
function setTextHtml($value)
{
return $this->reCacheLog->setValue('text_html', $value);
return $this->reCacheLog->setValue('text_html', $value ? 1 : 0);
}
function getTextHtmlEdit()
{
return $this->reCacheLog->getValue('text_html');
}
function setTextHtmlEdit($value)
{
return $this->reCacheLog->setValue('text_htmledit', $value);
return $this->reCacheLog->setValue('text_htmledit', $value ? 1 : 0);
}
function getUUID()
{
@@ -13,6 +13,7 @@
require_once($opt['rootpath'] . 'lib2/logic/statpic.class.php');
require_once($opt['rootpath'] . 'lib2/logic/countriesList.class.php');
require_once($opt['rootpath'] . 'lib2/logic/picture.class.php');
require_once($opt['rootpath'] . 'lib2/logic/cache.class.php');
require_once($opt['rootpath'] . 'lib2/logic/cracklib.inc.php');
require_once($opt['rootpath'] . 'lib2/translate.class.php');
@@ -696,7 +697,7 @@ function canDisable()
function disable()
{
global $login;
global $login, $translate;
if ($this->canDisable() == false)
return false;
@@ -714,8 +715,7 @@ function disable()
'User ' . sql_escape($this->getUsername()) . ' disabled',
serialize($backup));
sql("SET @STATUS_CHANGE_USER_ID='&1'", $login->userid);
sql("UPDATE `caches` SET `status`=6 WHERE `user_id`='&1' AND `status` IN (1, 2, 3)", $this->nUserId);
// delete private data
sql("UPDATE `user` SET `password`=NULL, `email`=NULL,
`is_active_flag`=0,
`latitude`=0, `longitude`=0,
@@ -729,7 +729,32 @@ function disable()
sql("DELETE FROM `user_options` WHERE `user_id`='&1'", $this->nUserId);
$this->reload();
return true;
// 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);
$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;
}
@@ -85,7 +85,7 @@ function archive_cache($cache_id, $comment)
global $opt, $login, $translate;
$log = cachelog::createNew($cache_id,$login->userid);
if (!$log)
if ($log === false)
echo $this->name . ": cannot create log for cache $cache_id\n";
else
{

0 comments on commit 0eeb9c1

Please sign in to comment.
You can’t perform that action at this time.