|
From: <dai...@us...> - 2014-11-06 09:15:14
|
Revision: 6966
http://sourceforge.net/p/web-erp/reponame/6966
Author: daintree
Date: 2014-11-06 09:15:09 +0000 (Thu, 06 Nov 2014)
Log Message:
-----------
Fix login errors for automated scripts;
Modified Paths:
--------------
trunk/MailInventoryValuation.php
trunk/includes/ConnectDB.inc
trunk/includes/DateFunctions.inc
trunk/includes/MiscFunctions.php
trunk/includes/UserLogin.php
trunk/includes/session.inc
trunk/sql/mysql/upgrade4.11-4.12.sql
Modified: trunk/MailInventoryValuation.php
===================================================================
--- trunk/MailInventoryValuation.php 2014-11-06 08:41:58 UTC (rev 6965)
+++ trunk/MailInventoryValuation.php 2014-11-06 09:15:09 UTC (rev 6966)
@@ -17,6 +17,7 @@
include('includes/session.inc');
include ('includes/class.pdf.php');
$Recipients = GetMailList('InventoryValuationRecipients');
+
if (sizeOf($Recipients) == 0) {
$Title = _('Inventory Valuation') . ' - ' . _('Problem Report');
include('includes/header.inc');
@@ -242,7 +243,7 @@
echo '<br /><a href="' . $RootPath . '/index.php">' . _('Back to the menu') . '</a>';
include('includes/footer.inc');
exit;
-
+
}else{
$Title = _('Print Inventory Valuation Error');
include('includes/header.inc');
@@ -250,8 +251,8 @@
echo '<br /><a href="' . $RootPath . '/index.php">' . _('Back to the menu') . '</a>';
include('includes/footer.inc');
exit;
-
+
}
-
+
}
?>
Modified: trunk/includes/ConnectDB.inc
===================================================================
--- trunk/includes/ConnectDB.inc 2014-11-06 08:41:58 UTC (rev 6965)
+++ trunk/includes/ConnectDB.inc 2014-11-06 09:15:09 UTC (rev 6966)
@@ -9,7 +9,7 @@
require_once ($PathPrefix .'includes/MiscFunctions.php');
if (!isset($_SESSION['DatabaseName'])){ //need to get the database name from the file structure
if (isset($_POST['CompanyNameField'])){
- if (isset($CompanyList) && is_array($CompanyList)) {
+ if (isset($CompanyList) AND is_array($CompanyList)) {
foreach ($CompanyList as $CompanyEntryKey => $CompanyEntry){
if (is_dir('./companies/'. $CompanyEntry['database']) AND ($CompanyEntryKey == $_POST['CompanyNameField']) ) {
$_SESSION['DatabaseName'] = $CompanyEntry['database'];
@@ -45,15 +45,11 @@
prnMsg(_('The company name abbreviation entered at login must also have a company directory defined. See your system administrator'),'error');
}
} // end provision for old setup
-
+ include_once ($PathPrefix . 'includes/ConnectDB_' . $DBType . '.inc');
} elseif (isset($DatabaseName)) { /* Scripts that do not require a login must have the $DatabaseName variable set in hard code */
$_SESSION['DatabaseName'] = $DatabaseName;
$_SESSION['CompanyName']= $DatabaseName;
include_once ($PathPrefix . 'includes/ConnectDB_' . $DBType . '.inc');
}
-
-} else {
- include_once($PathPrefix .'includes/ConnectDB_' . $DBType . '.inc');
}
-
-?>
+?>
\ No newline at end of file
Modified: trunk/includes/DateFunctions.inc
===================================================================
--- trunk/includes/DateFunctions.inc 2014-11-06 08:41:58 UTC (rev 6965)
+++ trunk/includes/DateFunctions.inc 2014-11-06 09:15:09 UTC (rev 6966)
@@ -924,7 +924,7 @@
$EarliestDispatch = time();
/* If the hour is after Dispatch Cut Off Time default dispatch date to tomorrow */
$EarliestDispatch = (Date('H')>=$_SESSION['DispatchCutOffTime'])?($EarliestDispatch+24*60*60):$EarliestDispatch;
-
+
if ((Date('w',$EarliestDispatch)==0) AND ($_SESSION['WorkingDaysWeek'] != '7')){
/*if today is a sunday AND the company does NOT work 7 days a week, the dispatch date must be tomorrow (Monday) or after */
@@ -1081,4 +1081,4 @@
return $myrow[0];
}
-?>
+?>
\ No newline at end of file
Modified: trunk/includes/MiscFunctions.php
===================================================================
--- trunk/includes/MiscFunctions.php 2014-11-06 08:41:58 UTC (rev 6965)
+++ trunk/includes/MiscFunctions.php 2014-11-06 09:15:09 UTC (rev 6966)
@@ -419,10 +419,12 @@
return $result;
}
-function GetMailList($Recipients){
- global $db;
+function GetMailList($MailGroup){
$ToList = array();
- $sql = "SELECT email,realname FROM mailgroupdetails INNER JOIN www_users ON www_users.userid=mailgroupdetails.userid WHERE mailgroupdetails.groupname='".$Recipients."'";
+ $sql = "SELECT email,realname
+ FROM mailgroupdetails INNER JOIN www_users
+ ON www_users.userid=mailgroupdetails.userid
+ WHERE mailgroupdetails.groupname='" . $MailGroup . "'";
$ErrMsg = _('Failed to retrieve mail lists');
$result = DB_query($sql,$ErrMsg);
if(DB_num_rows($result) != 0){
Modified: trunk/includes/UserLogin.php
===================================================================
--- trunk/includes/UserLogin.php 2014-11-06 08:41:58 UTC (rev 6965)
+++ trunk/includes/UserLogin.php 2014-11-06 09:15:09 UTC (rev 6966)
@@ -42,8 +42,8 @@
}
/* The SQL to get the user info must use the * syntax because the field name could change between versions if the fields are specifed directly then the sql fails and the db upgrade will fail */
$sql = "SELECT *
- FROM www_users
- WHERE www_users.userid='" . $Name . "'";
+ FROM www_users
+ WHERE www_users.userid='" . $Name . "'";
$ErrMsg = _('Could not retrieve user details on login because');
$debug =1;
@@ -110,6 +110,7 @@
$_SESSION['SalesmanLogin'] = $myrow['salesman'];
$_SESSION['CanCreateTender'] = $myrow['cancreatetender'];
$_SESSION['AllowedDepartment'] = $myrow['department'];
+ $_SESSION['ShowDashboard'] = $myrow['dashboard'];
if (isset($myrow['pdflanguage'])) {
$_SESSION['PDFLanguage'] = $myrow['pdflanguage'];
Modified: trunk/includes/session.inc
===================================================================
--- trunk/includes/session.inc 2014-11-06 08:41:58 UTC (rev 6965)
+++ trunk/includes/session.inc 2014-11-06 09:15:09 UTC (rev 6966)
@@ -5,7 +5,6 @@
$PathPrefix='';
}
-
if (!file_exists($PathPrefix . 'config.php')){
$RootPath = dirname(htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8'));
if ($RootPath == '/' OR $RootPath == "\\") {
@@ -81,8 +80,16 @@
include($PathPrefix . 'includes/LanguageSetup.php');
$FirstLogin = False;
-if (!isset($AllowAnyone)){ /* only do security checks if AllowAnyone is not true */
+if(basename($_SERVER['SCRIPT_NAME'])=='Logout.php'){
+ header('Location: index.php');
+} elseif (isset($AllowAnyone)){ /* only do security checks if AllowAnyone is not true */
+ $_SESSION['AllowedPageSecurityTokens'] = array();
+ $_SESSION['DatabaseName'] = $DefaultDatabase;
+ $_SESSION['CompanyName'] = $DefaultDatabase;
+ include_once ($PathPrefix . 'includes/ConnectDB_' . $DBType . '.inc');
+ include($PathPrefix . 'includes/GetConfig.php');
+} else {
include $PathPrefix . 'includes/UserLogin.php'; /* Login checking and setup */
if (isset($_POST['UserNameEntryField']) AND isset($_POST['Password'])) {
@@ -125,9 +132,6 @@
die(include($PathPrefix . 'includes/Login.php'));
}
-} /* only do security checks if AllowAnyone is not true */
- elseif(basename($_SERVER['SCRIPT_NAME'])=='Logout.php'){
- header('Location: index.php');
}
/*If the Code $Version - held in ConnectDB.inc is > than the Database VersionNumber held in config table then do upgrades */
@@ -139,8 +143,11 @@
If (isset($_POST['Theme']) AND ($_SESSION['UsersRealName'] == $_POST['RealName'])) {
$_SESSION['Theme'] = $_POST['Theme'];
$Theme = $_POST['Theme'];
+} elseif (isset($_SESSION['Theme'])) {
+ $Theme = $_SESSION['Theme'];
} else {
- $Theme = $_SESSION['Theme'];
+ $Theme = 'xenos';
+ $_SESSION['Theme'] = 'xenos';
}
@@ -212,7 +219,8 @@
} else {
$debug = 0; //don't allow debug messages
}
-if ($FirstLogin AND !$SupplierLogin AND !$CustomerLogin) {
+
+if ($FirstLogin AND !$SupplierLogin AND !$CustomerLogin AND $_SESSION['ShowDashboard']==1) {
header('Location: ' . $PathPrefix .'Dashboard.php');
}
Modified: trunk/sql/mysql/upgrade4.11-4.12.sql
===================================================================
--- trunk/sql/mysql/upgrade4.11-4.12.sql 2014-11-06 08:41:58 UTC (rev 6965)
+++ trunk/sql/mysql/upgrade4.11-4.12.sql 2014-11-06 09:15:09 UTC (rev 6966)
@@ -1,7 +1,5 @@
INSERT INTO `config` VALUES ('InvoiceQuantityDefault','1');
-
-ALTER TABLE `stockcategory` ADD INDEX `CategoryDescription` (`categorydescription`);
-
+ALTER TABLE `www_users` ADD `dashboard` TINYINT NOT NULL DEFAULT '0';
UPDATE config SET confvalue='4.12' WHERE confname='VersionNumber';
|