summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLester Caine <lsces@lsces.co.uk>2010-12-08 09:39:21 +0000
committerLester Caine <lsces@lsces.co.uk>2010-12-08 09:39:21 +0000
commitf87fa0e8af6da30a49d800faae8d8f8df1ddacf0 (patch)
treea708a9ddb62e4a99b6ea8386d0b21f22608e6c34
parent3ed47300ef7580e05a5bc088f989037323ff956b (diff)
downloadcontact-f87fa0e8af6da30a49d800faae8d8f8df1ddacf0.tar.gz
contact-f87fa0e8af6da30a49d800faae8d8f8df1ddacf0.tar.bz2
contact-f87fa0e8af6da30a49d800faae8d8f8df1ddacf0.zip
Increment xorder where multiple source items are allowed
xorder number may not equal the number displayed as historic records are also numbered but not displayed
-rw-r--r--ContactXref.php10
1 files changed, 8 insertions, 2 deletions
diff --git a/ContactXref.php b/ContactXref.php
index e73f2ae..6d46ec8 100644
--- a/ContactXref.php
+++ b/ContactXref.php
@@ -80,8 +80,14 @@ class ContactXref extends BitBase {
$pParamHash['xref_store']['source'] = $pParamHash['Array_xref_type_list']['Array.source'];
}
$pParamHash['xref_store']['content_id'] = $pParamHash['content_id'];
- $sql = "SELECT x`.multi` FROM `".BIT_DB_PREFIX."contact_xref_source` x WHERE x.`source` = ?";
- $pParamHash['xref_store']['xorder'] = $this->mDb->getOne( $sql, array( $pParamHash['xref_store']['source'] ) );
+ $sql = "SELECT x.`multi` FROM `".BIT_DB_PREFIX."contact_xref_source` x WHERE x.`source` = ?";
+ $next = $this->mDb->getOne( $sql, array( $pParamHash['xref_store']['source'] ) );
+ if ( $next > 0 ) {
+ $sql = "SELECT MAX(x.`xorder`) + 1 FROM `".BIT_DB_PREFIX."contact_xref` x
+ WHERE x.`content_id` = ? AND x.`source` = ?";
+ $next = $this->mDb->getOne( $sql, array( $pParamHash['xref_store']['content_id'], $pParamHash['xref_store']['source'] ) );
+ }
+ $pParamHash['xref_store']['xorder'] = $next;
}
if ( isset ( $pParamHash['fStepXref'] ) ) {