Skip to content
Permalink
Browse files

fixed bad translation SQLs; updaes #141, updates #817

  • Loading branch information...
following5 committed Sep 8, 2015
1 parent 16f348a commit 9ddde26953832bd2dd3236feb9d9cd1e19324520
@@ -0,0 +1,45 @@
<?php
/****************************************************************************
./lib/clicompatbase.inc.php
Unicode Reminder メモ
some common lib1 functions
****************************************************************************/
// These functions are needed for notification emails in the recipient's
// language. Looks like there is no way to query this "inline" in LEFT-JOIN-
// statements (the ON clause cannot access user.language).
function get_cachetype_name($cachetype, $language)
{
return sqlValue("
SELECT IFNULL(`stt`.`text`, `cache_type`.`en`)
FROM `cache_type`
LEFT JOIN `sys_trans_text` `stt` ON `stt`.`trans_id`=`cache_type`.`trans_id` AND `stt`.`lang`='" . sql_escape($language) . "'
WHERE `cache_type`.`id`='" . sql_escape($cachetype) . "'",
'');
}
function get_cachesize_name($cachesize, $language)
{
return sqlValue("
SELECT IFNULL(`stt`.`text`, `cache_size`.`en`)
FROM `cache_size`
LEFT JOIN `sys_trans_text` `stt` ON `stt`.`trans_id`=`cache_size`.`trans_id` AND `stt`.`lang`='" . sql_escape($language) . "'
WHERE `cache_size`.`id`='" . sql_escape($cachesize) . "'",
'');
}
function get_logtype_name($logtype, $language)
{
return sqlValue("
SELECT IFNULL(`stt`.`text`, `log_types`.`en`)
FROM `log_types`
LEFT JOIN `sys_trans_text` `stt` ON `stt`.`trans_id`=`log_types`.`trans_id` AND `stt`.`lang`='" . sql_escape($language) . "'
WHERE `log_types`.`id`='" . sql_escape($logtype) . "'",
'');
}
?>
@@ -26,9 +26,8 @@
INNER JOIN `cache_type` ON `cache_type`.`id`=`caches`.`type`
LEFT JOIN `caches_attributes` AS `tbloconly`
ON `caches`.`cache_id`=`tbloconly`.`cache_id` AND `tbloconly`.`attrib_id`=6
LEFT JOIN `sys_trans_text` `stt` ON `stt`.`trans_id`=`cache_type`.`trans_id`';
$sAddWhere .= ' AND `stt`.`lang`=\'' . sql_escape($opt['template']['locale']) . '\'';
LEFT JOIN `sys_trans_text` `stt` ON `stt`.`trans_id`=`cache_type`.`trans_id`
AND `stt`.`lang`=\'' . sql_escape($opt['template']['locale']) . '\'';
function search_output()
@@ -68,7 +68,6 @@ function search_output()
&searchtmp.`cache_id` `cacheid`,
&searchtmp.`longitude`,
&searchtmp.`latitude`,
&searchtmp.`type`,
`caches`.`date_hidden`,
`caches`.`name`,
`caches`.`status`,
@@ -81,12 +80,12 @@ function search_output()
`user`.`username`
FROM &searchtmp
JOIN `caches` ON &searchtmp.`cache_id`=`caches`.`cache_id`
JOIN `cache_type` ON &searchtmp.`type`=`cache_type`.`id`
JOIN `cache_size` ON &searchtmp.`type`=`cache_size`.`id`
JOIN `cache_type` ON `caches`.`type`=`cache_type`.`id`
JOIN `cache_size` ON `caches`.`size`=`cache_size`.`id`
LEFT JOIN `user` ON &searchtmp.`user_id`=`user`.`user_id`
LEFT JOIN `sys_trans_text` `stt_type` ON `stt_type`.`trans_id`=`cache_type`.`trans_id`
LEFT JOIN `sys_trans_text` `stt_size` ON `stt_size`.`trans_id`=`cache_size`.`trans_id`
WHERE `stt_type`.`lang`='&1' and `stt_size`.`lang`='&1'",
LEFT JOIN `sys_trans_text` `stt_type` ON `stt_type`.`trans_id`=`cache_type`.`trans_id` AND `stt_type`.`lang`='&1'
LEFT JOIN `sys_trans_text` `stt_size` ON `stt_size`.`trans_id`=`cache_size`.`trans_id` AND `stt_size`.`lang`='&1'
",
$opt['template']['locale']);
while ($r = sql_fetch_array($rs))
@@ -18,10 +18,11 @@
****************************************************************************/
//prepare the templates and include all neccessary
require_once('./lib/common.inc.php');
require_once('lib/common.inc.php');
require_once($stylepath . '/lib/icons.inc.php');
require_once($rootpath . 'lib2/html2text.class.php');
require_once('./lib/recommendation.inc.php');
require_once('lib2/html2text.class.php');
require_once('lib/recommendation.inc.php');
require_once('lib/logic.inc.php');
//Preprocessing
if ($error == false)
@@ -53,16 +54,13 @@
`user`.`username` as `log_username`,
IFNULL(`user`.`language`,'&2') AS `log_user_language`,
`caches`.`wp_oc`,
`cache_status`.`allow_user_view`,
IFNULL(`sys_trans_text`.`text`,`log_types`.`en`) AS `logtype_name`
`cache_status`.`allow_user_view`
FROM `cache_logs`, `caches`, `user`, `cache_status`, `log_types`
LEFT JOIN `sys_trans_text` ON `sys_trans_text`.`trans_id`=`log_types`.`trans_id`
WHERE `cache_logs`.`id`='&1'
AND `cache_logs`.`user_id`=`user`.`user_id`
AND `caches`.`cache_id`=`cache_logs`.`cache_id`
AND `caches`.`status`=`cache_status`.`id`
AND `log_types`.`id`=`cache_logs`.`type`
AND `sys_trans_text`.`lang`=IFNULL(`user`.`language`,'&2')
", $log_id, $opt['template']['default']['locale']);
//log exists?
@@ -140,7 +138,7 @@
$email_content = mb_ereg_replace('%cache_name%', $log_record['cache_name'], $email_content);
$email_content = mb_ereg_replace('%cache_wp%', $log_record['wp_oc'], $email_content);
$email_content = mb_ereg_replace('%log_date%', date($opt['locale'][$locale]['format']['phpdate'], strtotime($log_record['log_date'])), $email_content);
$email_content = mb_ereg_replace('%log_type%', $log_record['logtype_name'], $email_content);
$email_content = mb_ereg_replace('%log_type%', get_logtype_name($log_record['log_type'], $log_record['log_user_language']), $email_content);
$email_content = mb_ereg_replace('%log_text%', $logtext, $email_content);
$email_content = mb_ereg_replace('%comment%', $message, $email_content);
@@ -17,6 +17,7 @@
require_once('settings.inc.php');
require_once($rootpath . 'lib/consts.inc.php');
require_once($rootpath . 'lib2/ProcessSync.class.php');
require_once($rootpath . 'lib/logic.inc.php');
// db connect
db_connect();
@@ -34,10 +35,10 @@
SELECT
`notify_waiting`.`id`, `notify_waiting`.`cache_id`, `notify_waiting`.`type`,
`user`.`username`,
`user2`.`email`, `user2`.`username` as `recpname`, `user2`.`latitude` AS `lat1`, `user2`.`longitude` as `lon1`, `user2`.`user_id` as `recid`, IFNULL(`user2`.`language`,'&1') as `recp_lang`,
`user2`.`email`, `user2`.`username` as `recpname`, `user2`.`latitude` AS `lat1`,
`user2`.`longitude` as `lon1`, `user2`.`user_id` as `recid`, IFNULL(`user2`.`language`,'&1') as `recp_lang`,
`caches`.`name` as `cachename`, `caches`.`latitude` AS `lat2`, `caches`.`longitude` as `lon2`, `caches`.`wp_oc`, `caches`.`date_hidden`,
IFNULL(`stt_type`.`text`, `cache_type`.`en`) AS `cachetype`,
IFNULL(`stt_size`.`text`, `cache_size`.`en`) AS `cachesize`,
`caches`.`type` AS `cachetype`, `caches`.`size` AS `cachesize`,
`cache_status`.`allow_user_view`,
`ca`.`attrib_id` IS NOT NULL AS `oconly`
FROM `notify_waiting`
@@ -46,12 +47,8 @@
INNER JOIN `user` `user2` ON `notify_waiting`.`user_id`=`user2`.`user_id`
INNER JOIN `cache_type` ON `caches`.`type`=`cache_type`.`id`
INNER JOIN `cache_size` ON `caches`.`size`=`cache_size`.`id`
LEFT JOIN `sys_trans_text` `stt_type` ON `stt_type`.`trans_id`=`cache_type`.`trans_id`
LEFT JOIN `sys_trans_text` `stt_size` ON `stt_size`.`trans_id`=`cache_size`.`trans_id`
INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id`
LEFT JOIN `caches_attributes` `ca` ON `ca`.`cache_id`=`caches`.`cache_id` AND `ca`.`attrib_id`=6
WHERE `stt_type`.`lang`=IFNULL(`user2`.`language`,'&1') AND
`stt_size`.`lang`=IFNULL(`user2`.`language`,'&1')",
LEFT JOIN `caches_attributes` `ca` ON `ca`.`cache_id`=`caches`.`cache_id` AND `ca`.`attrib_id`=6",
$opt['template']['default']['locale']);
while ($rNotify = sql_fetch_array($rsNotify))
@@ -108,8 +105,8 @@ function process_new_cache($notify)
$mailbody = mb_ereg_replace('{distance}', round(calcDistance($notify['lat1'], $notify['lon1'], $notify['lat2'], $notify['lon2'], 1), 1), $mailbody);
$mailbody = mb_ereg_replace('{unit}', 'km', $mailbody);
$mailbody = mb_ereg_replace('{bearing}', Bearing2Text(calcBearing($notify['lat1'], $notify['lon1'], $notify['lat2'], $notify['lon2'])), $mailbody);
$mailbody = mb_ereg_replace('{cachetype}', $notify['cachetype'], $mailbody);
$mailbody = mb_ereg_replace('{cachesize}', $notify['cachesize'], $mailbody);
$mailbody = mb_ereg_replace('{cachetype}', get_cachetype_name($notify['cachetype'], $notify['recp_lang']), $mailbody);
$mailbody = mb_ereg_replace('{cachesize}', get_cachesize_name($notify['cachesize'], $notify['recp_lang']), $mailbody);
$mailbody = mb_ereg_replace('{oconly-}', $notify['oconly'] ? $translate->t('OConly-', '', basename(__FILE__), __LINE__, '', 1, $notify['recp_lang']) : '', $mailbody);
/* begin send out everything that has to be sent */
@@ -26,6 +26,7 @@
require_once('settings.inc.php');
require_once($rootpath . 'lib/consts.inc.php');
require_once($rootpath . 'lib2/html2text.class.php');
require_once($rootpath . 'lib/logic.inc.php');
// use posix pid-files to lock process
if (!CreatePidFile($watchpid))
@@ -256,7 +257,7 @@ function process_owner_log($user_id, $log_id)
$watchtext = mb_ereg_replace('{text}', $logtext, $watchtext);
$watchtext = mb_ereg_replace('{user}', $rLog['username'], $watchtext);
$watchtext = mb_ereg_replace('{cachename}', $rLog['cachename'], $watchtext);
$watchtext = mb_ereg_replace('{action}', get_log_action($rLog['type'], $language), $watchtext);
$watchtext = mb_ereg_replace('{action}', get_logtype_name($rLog['type'], $language), $watchtext);
sql("INSERT IGNORE INTO watches_waiting (`user_id`, `object_id`, `object_type`, `date_created`, `watchtext`, `watchtype`) VALUES (
'&1', '&2', 1, NOW(), '&3', 1)", $user_id, $log_id, $watchtext);
@@ -305,24 +306,13 @@ function process_log_watch($user_id, $log_id)
$watchtext = mb_ereg_replace('{text}', $logtext, $watchtext);
$watchtext = mb_ereg_replace('{user}', $rLog['username'], $watchtext);
$watchtext = mb_ereg_replace('{cachename}', $rLog['cachename'], $watchtext);
$watchtext = mb_ereg_replace('{action}', get_log_action($rLog['type'], $language), $watchtext);
$watchtext = mb_ereg_replace('{action}', get_logtype_name($rLog['type'], $language), $watchtext);
sql("INSERT IGNORE INTO watches_waiting (`user_id`, `object_id`, `object_type`, `date_created`, `watchtext`, `watchtype`) VALUES (
'&1', '&2', 1, NOW(), '&3', 2)", $user_id, $log_id, $watchtext);
}
function get_log_action($logtype, $language)
{
return sqlValue("
SELECT IFNULL(`stt`.`text`, `log_types`.`en`)
FROM `log_types`
LEFT JOIN `sys_trans_text` `stt` ON `stt`.`trans_id`=`log_types`.`trans_id`
WHERE `log_types`.`id`='" . sql_escape($logtype) . "' AND `stt`.`lang`='" . sql_escape($language) . "'",
'');
}
function is_existent_maildomain($domain)
{
$smtp_serverlist = array();

0 comments on commit 9ddde26

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