From 86f13e4b25d927dfb4426ff2f03bcf4f420dbf32 Mon Sep 17 00:00:00 2001 From: Konrad Rosenbaum Date: Sat, 14 Jan 2017 23:49:12 +0100 Subject: [PATCH] add server type HTML to status bar; add demo mode for email Change-Id: I9f908e9db9e400dd76bdd92b77ce494813cec735 --- Makefile | 10 +++--- commonlib/misc/sclock.cpp | 2 +- commonlib/smoke-common_de.ts | 7 ++++ commonlib/smoke-common_en.ts | 6 +++ iface/msinterface.cpp | 1 + iface/msinterface.h | 5 ++- src/mwin/tabwin.cpp | 6 +++ wob/transact/basics.wolf | 3 ++ wob/transact/user.wolf | 14 ++++++-- www/config.php.template | 31 +++++++++++++++++- www/inc/machine/translation.php | 66 +++++++++++++++++++++----------------- www/inc/wext/customer.php | 7 +++- www/inc/wext/order.php | 9 +++-- 13 files changed, 121 insertions(+), 46 deletions(-) diff --git a/Makefile b/Makefile index ddadd70..6d00a1b 100644 --- a/Makefile +++ b/Makefile @@ -193,13 +193,13 @@ install-doc: sdoc clean: -rm -rf src/.ctmp src/Makefile* src/msmoke -rm -rf src/wob www/inc/wob doc/wob wob/core* - -$(MAKE) -C pack clean - -$(MAKE) -C taurus clean - -$(MAKE) -C mainapp clean - -$(MAKE) -C plugins clean + -$(MAKE) -C pack distclean + -$(MAKE) -C taurus distclean + -$(MAKE) -C mainapp distclean + -$(MAKE) -C plugins distclean -rm -rf tzone/zoneinfo* tzone/libQtTzData* tzone/Makefile* tzone/.ctmp -rm -rf doc/source-php doc/source-cpp - -rm -rf taurus/lib/* + -rm -rf taurus/lib/* taurus/bin/* -rm -rf `find . -name '*~'` -rm -rf `find . -name '*.bak'` -rm -rf `find . -name 'core*'` diff --git a/commonlib/misc/sclock.cpp b/commonlib/misc/sclock.cpp index 3284d12..6aca2a5 100644 --- a/commonlib/misc/sclock.cpp +++ b/commonlib/misc/sclock.cpp @@ -68,7 +68,7 @@ void MServerClock::updateClock() if(showtime->isChecked())fm=showtime->data().toString(); if(showiso->isChecked())fm=showiso->data().toString(); //set it - setText(MLocalFormat().formatDateTime(ts,fm)); + setText(tr("Current Server Time:\n%1").arg(MLocalFormat().formatDateTime(ts,fm))); //make sure tool tip is up to date int off=ts.offsetFromUTC()/60; QString tz=tr("Server Time Zone: %1\nOffset from UTC: %2 minutes %3") diff --git a/commonlib/smoke-common_de.ts b/commonlib/smoke-common_de.ts index 7a18a06..abc721f 100644 --- a/commonlib/smoke-common_de.ts +++ b/commonlib/smoke-common_de.ts @@ -1248,6 +1248,13 @@ At least %1 Bits of random are required. %w %Y-%M-%D %h:%I %t + + Current Server Time: +%1 + Aktueller Theater/Server-Zeit: +%1 + + Server Time Zone: %1 Offset from UTC: %2 minutes %3 diff --git a/commonlib/smoke-common_en.ts b/commonlib/smoke-common_en.ts index b7b7b37..aa67991 100644 --- a/commonlib/smoke-common_en.ts +++ b/commonlib/smoke-common_en.ts @@ -1151,6 +1151,12 @@ At least %1 Bits of random are required. + + Current Server Time: +%1 + + + Server Time Zone: %1 Offset from UTC: %2 minutes %3 diff --git a/iface/msinterface.cpp b/iface/msinterface.cpp index c8d655a..d3da893 100644 --- a/iface/msinterface.cpp +++ b/iface/msinterface.cpp @@ -253,6 +253,7 @@ void MSInterface::initialize() qApp->installTranslator(trn); qDebug("MSInterface: successfully loaded server language %s",lang.toLatin1().data()); MLocalFormat::setDefaultFormat(gl.getformats().value()); + m_statusbartext=gl.getstatusBarText(); } } diff --git a/iface/msinterface.h b/iface/msinterface.h index e3fdb72..6735575 100644 --- a/iface/msinterface.h +++ b/iface/msinterface.h @@ -122,6 +122,9 @@ class MSIFACE_EXPORT MSInterface:public MInterface ///the string $APP is resolved as the directory the application is installed in ///any other component starting with $ resolves to the environment variable of the same name static QString resolveDir(const QString&dir); + + ///returns the status bar text + QString statusBarText()const{return m_statusbartext;} public slots: /**logs into the server, returns true on success*/ @@ -143,7 +146,7 @@ class MSIFACE_EXPORT MSInterface:public MInterface /// emitted when a re-login would be necessary void needRelogin(); private: - QString profileid,m_sessid,m_uname,m_passwd,m_host,m_hostkey; + QString profileid,m_sessid,m_uname,m_passwd,m_host,m_hostkey,m_statusbartext; mutable QListuserrights; mutable QStringList userroles,userflags; QByteArray servertranslation; diff --git a/src/mwin/tabwin.cpp b/src/mwin/tabwin.cpp index 0fffed0..b59e68d 100644 --- a/src/mwin/tabwin.cpp +++ b/src/mwin/tabwin.cpp @@ -72,6 +72,12 @@ MTabWin::MTabWin(QString pk,QWidget*parent) //status bar QStatusBar *sb=statusBar(); sb->setSizeGripEnabled(true); + const QString sbtxt=req->statusBarText().trimmed(); + if(!sbtxt.isEmpty()){ + QLabel*l=new QLabel(sbtxt); + l->setFrameStyle(QFrame::Panel|QFrame::Sunken); + sb->addPermanentWidget(l); + } sb->addPermanentWidget(new MServerClock); } diff --git a/wob/transact/basics.wolf b/wob/transact/basics.wolf index f1a368b..e139a8a 100644 --- a/wob/transact/basics.wolf +++ b/wob/transact/basics.wolf @@ -17,6 +17,9 @@ The Qt translation file to translate string from the server. All strings are found in the virtual class "::php". The formatting as requested by the server. Please note that the names of days and months does not necessarily correspond to the language that has been request but, to the language that the server wants to set for all printouts. + + Text (plain or HTML) shown on the client's status bar. + diff --git a/wob/transact/user.wolf b/wob/transact/user.wolf index e24df09..3fd2cc0 100644 --- a/wob/transact/user.wolf +++ b/wob/transact/user.wolf @@ -12,9 +12,15 @@ - - - + + Human readable version of the server software. + + + Minimum communication protocol version that the server needs from the client. + + + Protocol version that the server provides. + @@ -278,4 +284,4 @@ - \ No newline at end of file + diff --git a/www/config.php.template b/www/config.php.template index bc5b1b7..5185570 100644 --- a/www/config.php.template +++ b/www/config.php.template @@ -67,10 +67,15 @@ $olddb->setCharacterSet("utf8"); /////////// -//Development Options (comment these away in production systems) +//Development Options (should be disabled in production systems) +//un-comment to insert in XML transactions //WobTransaction::setDebugLevel(WobTransaction::DebugAll); +//set to true to redirect all mail to a demo account +//set to false for production, mail goes to real recipient +$IsDemoSystem=true; +$DemoMailAddr="konrad@localhost"; //////////// @@ -80,6 +85,30 @@ $olddb->setCharacterSet("utf8"); // this should usually be a few hours (3600s per hour) $ClientSessionTimeout=2*3600; +//Status-Display for the client's bottom status bar +// this can be either plain text or HTML, links are relative to machine.php +$StatusBarText="
". +"Local Development System
Have fun! No productivity here.". +"
"; + /////////// //Web-Client Configuration diff --git a/www/inc/machine/translation.php b/www/inc/machine/translation.php index f5d8e09..eabe444 100644 --- a/www/inc/machine/translation.php +++ b/www/inc/machine/translation.php @@ -1,43 +1,49 @@ getlanguage())); - //set format object - if(count($nlst)>0) - $trans->setformats(new WOServerFormat($nlst[0])); - else - $trans->setformats(new WOServerFormat()); - //if this is "C", abort parsing and return - if(strtolower(trim($trans->getlanguage()))=="c") - return; - //continue to parse language request - $form=$trans->getformat(); - if($form!="ts" && $form!="qm") - $trans->abortWithError(translate("Translation","Format must be either 'ts' or 'qm'.")); - //does the syntax match? - foreach($nlst as $nm) - if(!preg_match("/^[a-zA-Z]{1,3}$/",$nm)) - $trans->abortWithError(translate("Translation","Language invalid.")); - //find the longest match for language - for($i=count($nlst);$i>0;$i--){ - $name=implode("_",array_slice($nlst,0,$i)); - $fn="translations/_server_".$name.".".$form; - if(file_exists($fn)){ - $trans->setfile(file_get_contents($fn,FILE_BINARY)); + static public function getFile($trans) + { + //status bar display + global $StatusBarText; + if(isset($StatusBarText)) + $trans->setStatusBarText($StatusBarText); + + //split language string into components + $nlst=explode("_",trim($trans->getlanguage())); + //set format object + if(count($nlst)>0) + $trans->setformats(new WOServerFormat($nlst[0])); + else + $trans->setformats(new WOServerFormat()); + //if this is "C", abort parsing and return + if(strtolower(trim($trans->getlanguage()))=="c") return; + //continue to parse language request + $form=$trans->getformat(); + if($form!="ts" && $form!="qm") + $trans->abortWithError(translate("Translation","Format must be either 'ts' or 'qm'.")); + //does the syntax match? + foreach($nlst as $nm) + if(!preg_match("/^[a-zA-Z]{1,3}$/",$nm)) + $trans->abortWithError(translate("Translation","Language invalid.")); + //find the longest match for language + for($i=count($nlst);$i>0;$i--){ + $name=implode("_",array_slice($nlst,0,$i)); + $fn="translations/_server_".$name.".".$form; + if(file_exists($fn)){ + $trans->setfile(file_get_contents($fn,FILE_BINARY)); + return; + } } + + //none found. sadly. + $trans->abortWithError(translate("Translation","Language unknown.")); } - //none found. sadly. - $trans->abortWithError(translate("Translation","Language unknown.")); - } }; //eof diff --git a/www/inc/wext/customer.php b/www/inc/wext/customer.php index 23e7989..4f23041 100644 --- a/www/inc/wext/customer.php +++ b/www/inc/wext/customer.php @@ -310,7 +310,12 @@ class WOCustomer extends WOCustomerAbstract } } //send mail - mail($ct->email,$subject,$mailtext,$mailheader); + global $IsDemoSystem,$DemoMailAddr; + if(isset($IsDemoSystem) && $IsDemoSystem==true && isset($DemoMailAddr)) + $tmail=$DemoMailAddr; + else + $tmail=$ct->email; + mail($tmail,$subject,$mailtext,$mailheader); } /**page shown to the customer after clicking the password reset link above*/ diff --git a/www/inc/wext/order.php b/www/inc/wext/order.php index 6113309..91e5501 100644 --- a/www/inc/wext/order.php +++ b/www/inc/wext/order.php @@ -879,12 +879,11 @@ class WOOrder extends WOOrderAbstract if(!isEmail($ct->email)){ return; } - //set reset parameters - global $MailFrom; //init twig BaseVars::initTwig(); BaseVars::init(); //gather basics and render mail + global $IsDemoSystem,$DemoMailAddr; global $twig,$basevars; $p=$twig->loadTemplate("ordermail.txt"); $list['customer']=WOCustomer::fromTablecustomer($ct); @@ -904,7 +903,11 @@ class WOOrder extends WOOrderAbstract } } //send mail - mail($ct->email,$subject,$mailtext,$mailheader); + if(isset($IsDemoSystem) && $IsDemoSystem==true && isset($DemoMailAddr)) + $tmail=$DemoMailAddr; + else + $tmail=$ct->email; + mail($tmail,$subject,$mailtext,$mailheader); } ///change the addresses on the order, called by ChangeOrderAddress transaction -- 1.7.2.5