Summary:
SELFREG CSV export fixes - patch included
Detailed Description:
SelfRef fixes:
Commas in output no longer cause column alignment problems in Excel due to split
fields.
Checkbox fileds with false values no longer cause column alignment problems
(missing fields) in CSV export.
Add "confirm" link column in output. Note that there's a problem with the
CreateLink - the "m6" is hardcoded because I couldn't figure out how to select
the correct ID for a user when this is called from the admin panel.
Index: SelfRegistration.module.php
===================================================================
--- SelfRegistration.module.php (revision 92)
+++ SelfRegistration.module.php (working copy)
@@ -1158,23 +1158,48 @@
function CSVOldTempUsers($expirycode)
{
$db = $this->GetDb();
- $expires = $db->DbTimeStamp(strtotime( $expirycode ));
+
+ // Look for all users who registered before the relative time defined
+ // in expirycode (eg -24H)
+ $expires = trim($db->DbTimeStamp(strtotime( $expirycode )) , "'");
// find all the user id's that match
$q = "SELECT * FROM ".cms_db_prefix()."module_selfreg_users
WHERE createdate < ?";
$dbresult = $db->Execute( $q, array( $expires ) );
$result = '';
- while( $row = $dbresult->FetchRow() )
+ while( $dbresult && $row = $dbresult->FetchRow() )
{
$vals = array_values( $row );
$result .=
$row['id'].",".$row['username'].",".$row['code'].",".$row['createdate'].",";
- $q2 = "SELECT * FROM ".cms_db_prefix()."module_selfreg_properties
- WHERE user = ? ORDER by id";
- $dbresult2 = $db->Execute( $q2, array( $row['id'] ) );
+ // Tag on the "click here to confirm" link
+ $parms = array( 'mode' => 'verify',
+ 'input_username' => $row['username'],
+ 'input_group_id' => $row['group_id'],
+ 'input_code' => $row['code'] );
+ $url = $this->CreateLink('m6','default',128,'',$parms,'',true,true);
+ $url = htmlspecialchars_decode($url);
+ $result .= '"'.$url.'"'.",";
+
+ // Select all of the selfreg properties for this user
+ // A right join is used to complete any missing values which should
+ // be presented for this group (the selfreg user can only be in one
group)
+ // The select from selfreg properties is done first as a sub-query
+ // to avoid using the filter on the joined table (this doesn't
+ // work since fields from other users which may not have missing
+ // fields would then be used to perform the right join and
+ // not include enough of the fields for this user.
+ $innerq2 = "SELECT * FROM ".cms_db_prefix()."module_selfreg_properties
+ WHERE user = ?";
+ $q2 = "SELECT * FROM (".$innerq2.") AS derived
+ RIGHT JOIN ".cms_db_prefix()."module_feusers_grouppropmap
+ ON ".cms_db_prefix()."module_feusers_grouppropmap.name =
derived.title
+ where group_id=?
+ ORDER by sort_key";
+ $dbresult2 = $db->Execute( $q2, array( $row['id'], $row['group_id'] ) );
while( $row2 = $dbresult2->FetchRow() )
{
- $result .= $row2['data'].",";
+ $result .= '"'.$row2['data'].'"'.",";
}
$result .= "end\n";
}