From: Matteo Nastasi (mop) Date: Tue, 10 Dec 2013 16:58:32 +0000 (+0100) Subject: js: add confirm function attributes to notify_document class, php: add document downl... X-Git-Tag: v4.11.0~1 X-Git-Url: http://mop.ddnsfree.com/gitweb/?p=brisk.git;a=commitdiff_plain;h=f341c32413c83788cf6cf23fe911c401c2f9adad js: add confirm function attributes to notify_document class, php: add document download manager, php: add alert about TOS switch date --- diff --git a/INSTALL.sh b/INSTALL.sh index aae8e21..6ed3fa7 100755 --- a/INSTALL.sh +++ b/INSTALL.sh @@ -328,7 +328,7 @@ for i in $(find web -type d | sed 's/^....//g'); do install -d ${web_path}__/$i done -for i in $(find web -name '.htaccess' -o -name '*.php' -o -name '*.phh' -o -name '*.pho' -o -name '*.css' -o -name '*.js' -o -name '*.mp3' -o -name '*.swf' -o -name 'terms-of-service*.txt' | sed 's/^....//g'); do +for i in $(find web -name '.htaccess' -o -name '*.php' -o -name '*.phh' -o -name '*.pho' -o -name '*.css' -o -name '*.js' -o -name '*.mp3' -o -name '*.swf' -o -name 'terms-of-service*' | sed 's/^....//g'); do install -m 644 "web/$i" "${web_path}__/$i" done chmod 755 "${web_path}__/spush/brisk-spush.php" diff --git a/TODO.txt b/TODO.txt index c7591ef..44d21cb 100644 --- a/TODO.txt +++ b/TODO.txt @@ -5,6 +5,7 @@ ----------+ - AUTO-MAINTENANCE . Terms Of Service acceptance + DONE . print date of hard switch DONE . TOS version DONE . user TOS acceptance (db field) DONE . show TOS ([show me later, yes, no]/[yes, no]) @@ -14,14 +15,12 @@ DONE . show current TOS DONE . disable user reason integer field and remove SUSPEND state (db, php) DONE . fix tos layout - . opt - download TOS - . checkbox for anonimous users with message when not checked - . opt - button on when arrived to the bottom of the TOS - . min - check TOS version between config file and TOS file + DONE . opt - download TOS + . opt - checkbox for anonimous users with message when not checked + . opt - button enabled when arrived to the bottom of the TOS only + . opt - check TOS version between config file and TOS file . show guaranteer - . email validation - . account expiration diff --git a/web/Obj/brisk.conf-templ.pho b/web/Obj/brisk.conf-templ.pho index 78e4fbb..946df99 100644 --- a/web/Obj/brisk.conf-templ.pho +++ b/web/Obj/brisk.conf-templ.pho @@ -84,6 +84,9 @@ $G_black_list = array(); // this is the prefix path to remove from backtrace $G_btrace_pref_sub = "/home/nastasi/web/"; +// where documents are stored +$G_doc_path = "Obj/doc/"; + // licence related stuff $G_tos_vers = "2.0"; $G_tos_fname = "Obj/doc/terms-of-service_%s_%s.txt"; diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index 5fb98fb..a0b7556 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -2880,7 +2880,7 @@ function show_notify_ex($text, $tout, $butt, $w, $h, $is_opaque, $block_time) return sprintf('var noti = new notify_ex(gst,"%s",%d,"%s",%d,%d, %s, %d);', $text, $tout, $butt, $w, $h, ($is_opaque ? "true" : "false"), $block_time); } -function show_notify_document($text, $tout, $butt_arr, $confirm_func, $w, $h, $is_opaque, $block_time) +function show_notify_document($text, $tout, $butt_arr, $confirm_func, $confirm_func_args, $w, $h, $is_opaque, $block_time) { log_main("SHOW_NOTIFY OPAQUE: ".$text); @@ -2889,8 +2889,8 @@ function show_notify_document($text, $tout, $butt_arr, $confirm_func, $w, $h, $i $butts .= sprintf("%s'%s'", ($i == 0 ? "" : ","), $butt_arr[$i]); } - return sprintf('g_nd = new notify_document(gst, "%s", %d, [ %s ], %s, %d, %d, %s, %d);|', - escpush($text), $tout, $butts, ($confirm_func == NULL ? "null" : $confirm_func), $w, $h, ($is_opaque ? "true" : "false"), $block_time); + return sprintf('g_nd = new notify_document(gst, "%s", %d, [ %s ], %s, %s, %d, %d, %s, %d);|', + escpush($text), $tout, $butts, ($confirm_func == NULL ? "null" : $confirm_func), (($confirm_func == NULL|| $confirm_func_args == NULL) ? "[]" : $confirm_func_args), $w, $h, ($is_opaque ? "true" : "false"), $block_time); } diff --git a/web/Obj/doc/terms-of-service_V1.1_it.pdf b/web/Obj/doc/terms-of-service_V1.1_it.pdf new file mode 100644 index 0000000..9300e3c Binary files /dev/null and b/web/Obj/doc/terms-of-service_V1.1_it.pdf differ diff --git a/web/Obj/sac-a-push.phh b/web/Obj/sac-a-push.phh index 08ced76..5a525bb 100644 --- a/web/Obj/sac-a-push.phh +++ b/web/Obj/sac-a-push.phh @@ -611,7 +611,7 @@ class Sac_a_push { GLOBAL $G_splash_w, $G_topbanner, $G_with_donors, $G_with_poll; GLOBAL $G_with_sidebanner, $G_with_sidebanner2, $G_with_splash; GLOBAL $G_with_topbanner; - GLOBAL $G_tos_vers, $G_tos_fname, $G_tos_dtsoft, $G_tos_dthard, $G_tos_idx; + GLOBAL $G_tos_vers, $G_tos_fname, $G_tos_dtsoft, $G_tos_dthard, $G_tos_idx, $G_doc_path; if ($this->main_loop) { return (FALSE); diff --git a/web/Obj/user.phh b/web/Obj/user.phh index 94df362..a31765f 100644 --- a/web/Obj/user.phh +++ b/web/Obj/user.phh @@ -89,8 +89,12 @@ $mlang_user = array( 'en' => ' agree '), 'btn_refuse' => array('it' => ' rifiuto ', 'en' => ' refuse '), - 'btn_after' => array('it' => ' leggo poi ', - 'en' => ' read later ') + 'btn_dload' => array('it' => ' scarico ', + 'en' => ' download '), + 'btn_later' => array('it' => ' leggo poi ', + 'en' => ' read later '), + 'toc_date_dscl' => array('it' => 'I nuovi termini di servizio entreranno in vigore il %s.', + 'en' => 'EN I nuovi termini di servizio entreranno in vigore il %s.') ); class User { @@ -564,7 +568,7 @@ class User { protected function maincheck($get, $post, $cookie) { - GLOBAL $G_lang, $G_base, $mlang_user; + GLOBAL $G_lang, $G_base, $G_doc_path, $mlang_user; // GLOBAL $first_loop; GLOBAL $G_with_splash, $G_splash_content, $G_splash_interval, $G_splash_idx; GLOBAL $G_splash_w, $G_splash_h, $G_splash_timeout; @@ -618,24 +622,31 @@ class User { log_rd("roomma ".$this->step); $curtime = time(); if ($this->rec !== FALSE) { + $doc_filepath = $G_base.$G_doc_path.sprintf($G_tos_fname, $G_tos_vers, $G_lang); + $doc_filename = basename($doc_filepath); if ($curtime > $G_tos_dtsoft || $curtime > $G_tos_dthard) { if (versions_cmp($this->rec->tos_vers_get(), $G_tos_vers) < 0) { // comparison between user version and current version - if ($curtime > $G_tos_dtsoft) { - // call notify soft - $ret .= show_notify_document(esclfhtml(file_get_contents($G_base.sprintf($G_tos_fname, $G_tos_vers, $G_lang))), - 0, array($mlang_user['btn_agree'][$G_lang], $mlang_user['btn_refuse'][$G_lang], $mlang_user['btn_after'][$G_lang] /* , "Scarico." */), - "tos_confirm", 600, 600, TRUE, 0); - $ret .= sprintf("act_tosmgr('soft', g_nd.ret_get(), '%s', '%s');", - xcape($this->rec->tos_vers_get()), xcape($G_tos_vers)); + $buttons = array($mlang_user['btn_agree'][$G_lang], $mlang_user['btn_refuse'][$G_lang], + $mlang_user['btn_dload'][$G_lang]); + if ($curtime > $G_tos_dtsoft && $curtime < $G_tos_dthard) { + // call notify soft (same as soft + later button) + array_push($buttons, $mlang_user['btn_later'][$G_lang]); + $type = "soft"; + $preface = sprintf("
%s
", + sprintf($mlang_user['toc_date_dscl'][$G_lang], + strftime("%e/%m/%Y", $G_tos_dthard))); } - else if ($curtime > $G_tos_dthard) { + else { // call notify hard - $ret .= show_notify_document(esclfhtml(file_get_contents($G_base.sprintf($G_tos_fname, $G_tos_vers, $G_lang))), - 0, array($mlang_user['btn_agree'][$G_lang], $mlang_user['btn_refuse'][$G_lang] /* , "Scarico." */), - "tos_confirm", 600, 600, TRUE, 0); - $ret .= sprintf("act_tosmgr('hard', g_nd.ret_get(), '%s', '%s');", - xcape($this->rec->tos_vers_get()), xcape($G_tos_vers)); + $type = "hard"; + $preface = ""; } + $ret .= show_notify_document($preface.esclfhtml(file_get_contents($doc_filepath)), 0, $buttons, + "tos_confirm", sprintf("[ '%s/doc_download.php?doc=%s' ]", SITE_PREFIX, + basename($doc_filename, ".txt")), 600, 600, TRUE, 0); + + $ret .= sprintf("act_tosmgr('%s', g_nd.ret_get(), '%s', '%s');", $type, + xcape($this->rec->tos_vers_get()), xcape($G_tos_vers)); } } } diff --git a/web/brisk.css b/web/brisk.css index ba9b454..89bf298 100644 --- a/web/brisk.css +++ b/web/brisk.css @@ -144,6 +144,16 @@ div.notify_clo { bottom: 4px; } +div.doc_alert { + color: #ff5400; + background-color: #ffd780; + font-family: monospace; + font-weight: bold; + text-align: center; + margin: 8px; + padding: 8px; +} + .input_text { background-color: #f8f8f8; border: 1px solid gray; diff --git a/web/commons.js b/web/commons.js index 566ffa7..9d07b5d 100644 --- a/web/commons.js +++ b/web/commons.js @@ -45,8 +45,8 @@ var mlang_commons = { 'imgload_a' : { 'it' : 'Immagini caricate ', 'en' : '(only aut.)' }, '2' : { 'it' : '(isolam.to)', 'en' : '(isolation)' } }, - 'tos_refu' : { 'it' : 'Rifiutando di sottoscrivere i nuovi termini del servizio non ti sarà più possibile accedere col tuo utente registrato al sito, sei proprio sicuro di non voler accettare le nuove condizioni d\'uso ?', - 'en' : 'EN Rifiutando di sottoscrivere i nuovi termini del servizio non ti sarà più possibile accedere col tuo utente registrato al sito, sei proprio sicuro di non voler accettare le nuove condizioni d\'uso ?', + 'tos_refu' : { 'it' : 'Rifiutando di sottoscrivere i nuovi termini del servizio non ti sarà più possibile accedere come utente registrato al sito, sei proprio sicuro di voler rifiutare le nuove condizioni d\'uso ?', + 'en' : 'EN Rifiutando di sottoscrivere i nuovi termini del servizio non ti sarà più possibile accedere come utente registrato al sito, sei proprio sicuro di voler rifiutare le nuove condizioni d\'uso ?' } }; @@ -478,8 +478,8 @@ function postact_logout() /* type - 'hard' or 'soft' - code - if soft: accept (0), refuse (1), after (2) - if hard: accept (0), refuse (1) + code - if soft: accept (0), refuse (1), download (2), later (3) + if hard: accept (0), refuse (1), download (2) */ function act_tosmgr(type, code, tos_curr, tos_vers) { @@ -496,16 +496,26 @@ function act_tosmgr(type, code, tos_curr, tos_vers) default: break; } + return true; } -function tos_confirm(val) +function tos_confirm(val, url) { - if (val == 1) { + var dlm; + + switch (val) { + case 1: return (window.confirm(mlang_commons['tos_refu'][g_lang])); + break; + case 2: + dlm = new download_mgr(url); + return false; + break; + default: + return true; + break; } - - return true; } /* @@ -659,7 +669,7 @@ function div_show(div) block_time: */ -function notify_document(st, text, tout, butt, confirm_func, w, h, is_opa, block_time) +function notify_document(st, text, tout, butt, confirm_func, confirm_func_args, w, h, is_opa, block_time) { var i, clo, clodiv_ctx, clodiv_wai, box; @@ -667,7 +677,7 @@ function notify_document(st, text, tout, butt, confirm_func, w, h, is_opa, block this.ancestor = document.body; this.confirm_func = confirm_func; - + this.confirm_func_args = confirm_func_args; this.st.st_loc_new++; clodiv_ctx = document.createElement("div"); @@ -744,6 +754,7 @@ notify_document.prototype = { tblkid: null, confirm_func: null, + confirm_func_args: [], ret: -1, @@ -792,7 +803,11 @@ notify_document.prototype = { hide: function(val) { if (this.confirm_func != null) { - if (this.confirm_func(val) == false) { + var args; + + args = [ val ].concat(this.confirm_func_args); + + if (this.confirm_func.apply(null, args) == false) { return false; } } @@ -1385,3 +1400,23 @@ function url_complete(parent, url) return (host+path+url); } } + +function download_mgr(url) +{ + var ifra; + + if ((ifra = $('the_downloader')) == null) { + ifra = document.createElement("iframe"); + ifra.style.display = "none"; + ifra.id = 'the_downloader'; + document.body.appendChild(ifra); + } + + ifra.contentWindow.location.href = url; + + this.ifra = ifra; +} + +download_mgr.prototype = { + ifra: null +} diff --git a/web/doc_download.php b/web/doc_download.php new file mode 100644 index 0000000..d447c19 --- /dev/null +++ b/web/doc_download.php @@ -0,0 +1,24 @@ + \ No newline at end of file