completed data license functions, picture fixes, public profile link

+ menu option "my profile/public profile"
- enlargit log pics
- short date format for some locales
- data license constants
* dont display license-disabled log pics
* delete log pics on declined license instead replacing
+ delete waypoint descriptions on declined license
* no cache desc replacement message if it was empty
+ license-content-disable-function for old-disabled users
+ script to process all old-deleted users due to incompatible license
+ settings for license admin functions and for license disclaimer
- fixed CC license link on english tos page
* update caches.last_modified with changes of additional waypoints
+ XML interface license disclaimer
This commit is contained in:
following
2013-03-18 10:44:53 +01:00
parent cc2fc6c25e
commit 37b5268a7e
33 changed files with 505 additions and 126 deletions

View File

@@ -140,10 +140,10 @@ class OcSmarty extends Smarty
global $opt, $db, $cookie, $login, $menu, $sqldebugger, $translate;
$cookie->close();
// // if the user is an admin, dont cache the content
// if (isset($login))
// if ($login->admin)
// $this->caching = false;
// if the user is an admin, dont cache the content
if (isset($login))
if ($login->admin)
$this->caching = false;
//Give Smarty access to the whole options array.
$this->assign('siteSettings', $opt);
@@ -152,13 +152,15 @@ class OcSmarty extends Smarty
//access using the siteSettings above?
// assign main template vars
// ... and some of the $opt
$locale = $opt['template']['locale'];
$optn['debug'] = $opt['debug'];
$optn['template']['locales'] = $opt['template']['locales'];
$optn['template']['locale'] = $opt['template']['locale'];
$optn['template']['style'] = $opt['template']['style'];
$optn['template']['country'] = $login->getUserCountry();
$optn['page']['subtitle1'] = isset($opt['locale'][$opt['template']['locale']]['page']['subtitle1']) ? $opt['locale'][$opt['template']['locale']]['page']['subtitle1'] : $opt['page']['subtitle1'];
$optn['page']['subtitle2'] = isset($opt['locale'][$opt['template']['locale']]['page']['subtitle2']) ? $opt['locale'][$opt['template']['locale']]['page']['subtitle2'] : $opt['page']['subtitle2'];
$optn['page']['subtitle1'] = isset($opt['locale'][$locale]['page']['subtitle1']) ? $opt['locale'][$locale]['page']['subtitle1'] : $opt['page']['subtitle1'];
$optn['page']['subtitle2'] = isset($opt['locale'][$locale]['page']['subtitle2']) ? $opt['locale'][$locale]['page']['subtitle2'] : $opt['page']['subtitle2'];
$optn['page']['headimagepath'] = $opt['page']['headimagepath'];
$optn['page']['max_logins_per_hour'] = $opt['page']['max_logins_per_hour'];
$optn['page']['absolute_url'] = $opt['page']['absolute_url'];
@@ -221,6 +223,24 @@ class OcSmarty extends Smarty
if ($this->title == '')
$optn['template']['title'] = $menu->GetMenuTitle();
if ($opt['logic']['license']['disclaimer'])
{
if (isset($opt['locale'][$locale]['page']['license_url']))
$lurl = $opt['locale'][$locale]['page']['license_url'];
else
$lurl = $opt['locale']['EN']['page']['license_url'];
if (isset($opt['locale'][$locale]['page']['license']))
$ltext = $opt['locale'][$locale]['page']['license'];
else
$ltext = $opt['locale']['EN']['page']['license'];
$this->assign('license_disclaimer', mb_ereg_replace('%1', $lurl, $ltext));
}
else
$this->assign('license_disclaimer','');
$this->assign('opt', $optn);
$this->assign('login', $loginn);

View File

@@ -46,6 +46,7 @@
define('OBJECT_TRAVELER', 5);
define('OBJECT_PICTURE', 6);
define('OBJECT_REMOVEDOBJECT', 7);
define('OBJECT_WAYPOINT', 8);
// coordinate types
define('COORDINATE_WAYPOINT', 1);
@@ -66,8 +67,10 @@
define('USR_OPT_TRANSLANG', 12);
// user.data_license values
define('OLD_DATA_LICSENSE',0); // deadline not reached
define('NEW_DATA_LICENSE_DECLINED',1); // declined license
define('NEW_DATA_LICSENSE_ACTIVELY_ACCEPTED',1); // accepted new license on registration
define('NEW_DATA_LICSENSE_PASSIVELY_ACCEPTED',2); // did not decline license until deadline
define('OLD_DATA_LICSENSE',0); // before deadline
define('NEW_DATA_LICENSE_ACTIVELY_DECLINED',1); // declined license
define('NEW_DATA_LICENSE_ACTIVELY_ACCEPTED',2); // accepted new license on registration
define('NEW_DATA_LICENSE_PASSIVELY_ACCEPTED',3); // did not decline license until deadline
define('NEW_DATA_LICENSE_PASSIVELY_DECLINED',4); // could accept/decline because disabled
?>

View File

@@ -133,19 +133,21 @@ function get_logpics($purpose, $userid=0, $cacheid=0)
break;
case LOGPICS_FOR_CACHE_STAT:
// all pictures for a cache
// all pictures for a cache except license-replacement pics
// need not to exclude invisible caches, as this is only displayed in listing view
$result = sql_value(
"SELECT COUNT(*)
FROM `pictures` AS `pics`
$join_logs
WHERE `object_type`=1 AND `logs`.`cache_id`='&1'",
0, $cacheid);
$join_user
WHERE `object_type`=1 AND `logs`.`cache_id`='&1'
AND NOT (`data_license` IN ('&2','&3'))",
0, $cacheid, NEW_DATA_LICENSE_ACTIVELY_DECLINED, NEW_DATA_LICENSE_PASSIVELY_DECLINED);
break;
case LOGPICS_FOR_CACHE_GALLERY:
// all picture for a cache
// all picture for a cache except license-replacement pics
// for all users except owner: also excluding invisble caches
$rs = sql("SELECT $fields, `user`.`username`, `logs`.`date` AS `picdate`
@@ -154,7 +156,9 @@ function get_logpics($purpose, $userid=0, $cacheid=0)
($userid == $login->userid ? "" : "$join_caches $join_cachestatus") . "
$join_user
WHERE `object_type`=1 AND `logs`.`cache_id`='&1'
ORDER BY `logs`.`date` DESC", $cacheid);
AND NOT (`data_license` IN ('&2','&3'))
ORDER BY `logs`.`date` DESC",
$cacheid, NEW_DATA_LICENSE_ACTIVELY_DECLINED, NEW_DATA_LICENSE_PASSIVELY_DECLINED);
break;
default:

View File

@@ -12,6 +12,7 @@ require_once($opt['rootpath'] . 'lib2/mail.class.php');
require_once($opt['rootpath'] . 'lib2/logic/rowEditor.class.php');
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/cracklib.inc.php');
require_once($opt['rootpath'] . 'lib2/translate.class.php');
@@ -744,32 +745,39 @@ class user
* disables user (if not disabled), removes all licensed content from db and
* replaces every picture with a dummy one
*
* @return bool false, if anything went wrong, true otherwise
* @return string error message, if anything went wrong, true otherwise
*
* old_disabled: the user was disabled already before license transition
* and therefore could not accept/decline the license
*/
function disduelicense() {
function disduelicense($old_disabled=false) {
// get translation-object
global $translate;
// check if disabled, disable if not
if (!$this->canDisableDueLicense())
return 'this user must not be disabled';
if ($this->canDisable())
if (!$this->disable())
return 'disable user failed';
if (!$old_disabled)
if ($this->canDisable())
if (!$this->disable())
return 'disable user failed';
// remember that data license was declined
sql("UPDATE user SET data_license=1 WHERE user_id='&1'", $this->getUserId());
sql("UPDATE user SET data_license='&2' WHERE user_id='&1'",
$this->getUserId(),
$old_disabled ? NEW_DATA_LICENSE_PASSIVELY_DECLINED : NEW_DATA_LICENSE_ACTIVELY_DECLINED);
/*
* set all cache_desc and hint to ''
* set all cache_desc and hint to '', save old texts
*/
// check if there are caches
$num_caches = sql_value("SELECT COUNT(*) FROM `caches` WHERE `user_id`='&1'",
0, $this->getUserId());
if ($num_caches > 0) {
$cache_descs = array();
$rs = sql("SELECT `cache_desc`.`id`,`cache_desc`.`language` " .
$rs = sql("SELECT `id`, `language`, `desc`, `hint` " .
"FROM `cache_desc`,`caches` " .
"WHERE `caches`.`cache_id`=`cache_desc`.`cache_id` " .
"AND `caches`.`user_id`='&1'",
@@ -782,41 +790,96 @@ class user
// walk through cache_descs and set message for each language
foreach ($cache_descs as $desc)
{
// save text - added 2013/03/18 to be enable restoring data on reactivation
// of accounts that were disabled before license transition
if ($desc['desc'] != "")
sql("INSERT IGNORE INTO `saved_texts` (`object_type`, `object_id`, `subtype`, `text`)
VALUES ('&1', '&2', '&3', '&4')",
OBJECT_CACHEDESC, $desc['id'], 1, $desc['desc'] );
if ($desc['hint'] != "")
sql("INSERT IGNORE INTO `saved_texts` (`object_type`, `object_id`, `subtype`, `text`)
VALUES ('&1', '&2', '&3', '&4')",
OBJECT_CACHEDESC, $desc['id'], 2, $desc['hint'] );
if ($desc['desc'] != "")
if ($old_disabled)
$descmsg = $translate->t('cache description was removed because the owner\'s account was inactive when the <a href="articles.php?page=impressum#datalicense">new content license</a> was launched', '', basename(__FILE__), __LINE__, '', 1, $desc['language']);
else
$descmsg = $translate->t('cache description was removed because owner declined content license', '', basename(__FILE__), __LINE__, '', 1, $desc['language']);
else
$descmsg = "";
sql("UPDATE `cache_desc` " .
"SET `desc`='&1',`hint`='&2' " .
"WHERE `id`='&3'",
"<em>" . $translate->t('cache description was removed because owner declined content license', '', basename(__FILE__), __LINE__, '', 1, $desc['language']) . "</em>",
"<em>" . $descmsg . "</em>",
'',
$desc['id']
);
);
}
// replace pictures
$errmesg = $this->replace_pictures(OBJECT_CACHE);
if ($errmesg !== true)
return "removing cache pictures: $errmesg";
}
}
// delete additional waypoint texts
$rs = sql("SELECT `id`, `description` FROM `coordinates`
WHERE `type`='&1'
AND `cache_id` IN (SELECT `cache_id` FROM `caches` WHERE `user_id`='&2')",
COORDINATE_WAYPOINT, $this->getUserId());
while ($wp = sql_fetch_assoc($rs))
{
if ($wp['description'] != "")
sql("INSERT IGNORE INTO `saved_texts` (`object_type`, `object_id`, `subtype`, `text`)
VALUES ('&1', '&2', '&3', '&4')",
OBJECT_WAYPOINT, $wp['id'], 0, $wp['description'] );
sql("UPDATE `coordinates` SET `description`=''
WHERE `id`='&1'",
$wp['id']);
}
sql_free_result($rs);
/*
* set all cache_logs ''
* set all cache_logs '', save old texts and delete pictures
*/
// check if there are cache_logs
$num_cache_logs = sql_value("SELECT COUNT(*) " .
"FROM `cache_logs` " .
"WHERE `user_id`='&1'",
0,
$this->getUserId()
);
$rs = sql("SELECT `id`, `text`
FROM `cache_logs`
WHERE `user_id`='&1'",
$this->getUserId()
);
while ($log = sql_fetch_array($rs,MYSQL_ASSOC))
{
// save text - added 2013/03/18 to be enable restoring data on reactivation
// of accounts that were disabled before license transition
sql("INSERT IGNORE INTO `saved_texts` (`object_type`, `object_id`, `subtype`, `text`)
VALUES ('&1', '&2', '&3', '&4')",
OBJECT_CACHELOG, $log['id'], 0, $log['text']);
if ($num_cache_logs > 0) {
// set text ''
sql("UPDATE `cache_logs` SET `text`='' WHERE `user_id`='&1'", $this->getUserId());
sql("UPDATE `cache_logs` SET `text`='' WHERE `id`='&1'", $log['id']);
/*
// replace pictures
$errmesg = $this->replace_pictures(OBJECT_CACHELOG);
if ($errmesg !== true)
return "removing log pictures: $errmesg";
*/
// delete log pictures
$rsp = sql("SELECT `id` FROM `pictures`
WHERE `object_type`='&1' AND `object_id`='&2'",
OBJECT_CACHELOG, $log['id']);
while ($pic = sql_fetch_assoc($rsp))
{
$picture = new picture($pic['id']);
$picture->delete();
}
sql_free_result($rsp);
}
sql_free_result($rs);
// success
return true;
@@ -892,8 +955,8 @@ class user
$filenames[] = substr($url['url'],-40);
// free result
sql_free_result($rs);
sql_free_result($rs);
/*
* walk through filenames and replace original
*/
@@ -1125,6 +1188,17 @@ class user
return $this->reUser->getValue('email_problems') % 1000000;
}
function getDataLicense()
{
return $this->reUser->getValue('data_license');
}
function getLicenseDeclined()
{
return $this->getDataLicense() == NEW_DATA_LICENSE_ACTIVELY_DECLINED ||
$this->getDataLicense() == NEW_DATA_LICENSE_PASSIVELY_DECLINED;
}
function missedDataLicenseMail()
{
return $this->reUser->getValue('email_problems') > 1000000;

View File

@@ -45,10 +45,18 @@ class translate
if (($lang === null) || ($lang == $opt['template']['locale']))
$trans = gettext($search);
else
$trans = sql_value("SELECT IFNULL(`sys_trans_text`.`text`, '&3')
FROM `sys_trans`
LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&1'
WHERE `sys_trans`.`text`='&2' LIMIT 1", '', $lang, $search, $message);
{
// do not use sql_value(), as this is also used from lib1
$rs = sql("SELECT IFNULL(`sys_trans_text`.`text`, '&3')
FROM `sys_trans`
LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&1'
WHERE `sys_trans`.`text`='&2' LIMIT 1", $lang, $search, $message);
if ($r = sql_fetch_array($rs))
$trans = $r[0];
else
$trans = '';
sql_free_result($rs);
}
// safe w/o mb because asc(%) < 128
if (strpos($trans, "%")>=0)