diff --git a/e107_admin/admin_log.php b/e107_admin/admin_log.php
index f57ef8480..364853e62 100644
--- a/e107_admin/admin_log.php
+++ b/e107_admin/admin_log.php
@@ -422,7 +422,7 @@ if($action == "config")
".RL_LAN_123."
- ".$e_userclass->vetted_tree('user_audit_class', array($e_userclass, 'select'), varset($pref['user_audit_class'], ''), 'nobody,admin,member,new,mods,main,classes')."
+ ".$e_userclass->vetted_tree('user_audit_class', array($e_userclass, 'select'), varset($pref['user_audit_class'], ''), 'nobody,admin,member,new,mods,main,classes, no-excludes')."
".RL_LAN_026."
diff --git a/e107_admin/upload.php b/e107_admin/upload.php
index 011275625..3a57d40b8 100644
--- a/e107_admin/upload.php
+++ b/e107_admin/upload.php
@@ -404,7 +404,7 @@ switch ($action)
$text .= "
@@ -415,7 +415,7 @@ switch ($action)
$text .= "
diff --git a/e107_admin/userclass2.php b/e107_admin/userclass2.php
index 875980449..f2143dfa1 100644
--- a/e107_admin/userclass2.php
+++ b/e107_admin/userclass2.php
@@ -36,6 +36,7 @@ $e_sub_cat = 'userclass';
require_once(e_HANDLER.'userclass_class.php'); // Modified class handler
$e_userclass = new user_class_admin; // Admin functions - should just obliterate any previous object created in class2.php
+ // @TODO: Does core object manager need to know somehow?
require_once(e_HANDLER.'form_handler.php');
@@ -496,7 +497,7 @@ switch ($action)
".UCSLAN_24."
";
- $text .= "".$e_userclass->vetted_tree('userclass_editclass',array($e_userclass,'select'), $userclass_editclass,'nobody,public,main,admin,classes,matchclass,member').' ';
+ $text .= "".$e_userclass->vetted_tree('userclass_editclass',array($e_userclass,'select'), $userclass_editclass,'nobody,public,main,admin,classes,matchclass,member, no-excludes').' ';
$text .= "".UCSLAN_32."
";
@@ -525,7 +526,7 @@ switch ($action)
".UCSLAN_35."
";
- $text .= "".$e_userclass->vetted_tree('userclass_parent',array($e_userclass,'select'), $userclass_parent,'main,admin,nobody,public,classes,matchclass,member').' ';
+ $text .= "".$e_userclass->vetted_tree('userclass_parent',array($e_userclass,'select'), $userclass_parent,'main,admin,nobody,public,classes,matchclass,member, no-excludes').' ';
// .r_userclass("userclass_parent", $userclass_parent, "off", "admin,classes,matchclass,public,member").
$text .= "".UCSLAN_36."
@@ -1020,7 +1021,7 @@ require_once(e_ADMIN.'footer.php');
-// @TODO: Is this function still required?
+// @TODO: Is this function still required? - Yes - setGroupStatus() used on class add/edit page
function headerjs()
{
$params = e107::getRegistry('pageParams');
diff --git a/e107_admin/users.php b/e107_admin/users.php
index 986e0e6af..2a8cd4410 100644
--- a/e107_admin/users.php
+++ b/e107_admin/users.php
@@ -773,7 +773,7 @@ class users_admin_ui extends e_admin_ui
";
- $text .= $e_userclass->vetted_tree('userclass', array($e_userclass,'checkbox_desc'), $sysuser->getValue('class'), 'classes');
+ $text .= $e_userclass->vetted_tree('userclass', array($e_userclass,'checkbox_desc'), $sysuser->getValue('class'), 'classes, no-excludes');
$text .= '
@@ -1259,7 +1259,7 @@ class users_admin_ui extends e_admin_ui
// TODO lan above
if (!isset ($user_data['user_class'])) $user_data['user_class'] = varset($pref['initial_user_classes']);
- $temp = $e_userclass->vetted_tree('class', array($e_userclass, 'checkbox_desc'), $user_data['user_class'], 'classes');
+ $temp = $e_userclass->vetted_tree('class', array($e_userclass, 'checkbox_desc'), $user_data['user_class'], 'classes, no-excludes');
if ($temp)
{
diff --git a/e107_core/shortcodes/batch/signup_shortcodes.php b/e107_core/shortcodes/batch/signup_shortcodes.php
index c282daabb..9216259ee 100755
--- a/e107_core/shortcodes/batch/signup_shortcodes.php
+++ b/e107_core/shortcodes/batch/signup_shortcodes.php
@@ -270,7 +270,7 @@ class signup_shortcodes extends e_shortcode
}*/
$ret = $USERCLASS_SUBSCRIBE_START;
- $ret .= $e_userclass->vetted_tree('class',array($this,show_signup_class),varset($signupData['user_class'],''),'editable');
+ $ret .= $e_userclass->vetted_tree('class',array($this,show_signup_class),varset($signupData['user_class'],''),'editable, no-excludes');
$ret .= $USERCLASS_SUBSCRIBE_END;
return $ret;
}
diff --git a/e107_core/shortcodes/batch/usersettings_shortcodes.php b/e107_core/shortcodes/batch/usersettings_shortcodes.php
index c6cd5bab3..dacae583c 100755
--- a/e107_core/shortcodes/batch/usersettings_shortcodes.php
+++ b/e107_core/shortcodes/batch/usersettings_shortcodes.php
@@ -175,7 +175,7 @@ class usersettings_shortcodes extends e_shortcode
$inclass = implode(',',$is_checked);
// $ret = "";
- $ret .= $e_userclass->vetted_tree('class',array($e_userclass,checkbox_desc),$inclass,'editable');
+ $ret .= $e_userclass->vetted_tree('class',array($e_userclass,checkbox_desc),$inclass,'editable, no-excludes');
// $ret .= "
\n";
return $ret;
diff --git a/e107_plugins/download/admin_download.php b/e107_plugins/download/admin_download.php
index 66a13e101..4089b94e8 100644
--- a/e107_plugins/download/admin_download.php
+++ b/e107_plugins/download/admin_download.php
@@ -637,7 +637,7 @@ if ($action == "uopt")
- ".$e_userclass->vetted_tree('file_class_select',array($e_userclass,'select'), $uclass,'member,main,classes,admin')."
+ ".$e_userclass->vetted_tree('file_class_select',array($e_userclass,'select'), $uclass,'member,main,classes,admin, no-excludes')."
@@ -653,7 +653,7 @@ if ($action == "uopt")
- ".$e_userclass->vetted_tree('file_class_select',array($e_userclass,'select'), '','member,main,classes,admin,blank')."
+ ".$e_userclass->vetted_tree('file_class_select',array($e_userclass,'select'), '','member,main,classes,admin,blank, no-excludes')."
diff --git a/e107_plugins/download/handlers/adminDownload_class.php b/e107_plugins/download/handlers/adminDownload_class.php
index 771a74b5c..56f8460d1 100644
--- a/e107_plugins/download/handlers/adminDownload_class.php
+++ b/e107_plugins/download/handlers/adminDownload_class.php
@@ -1785,7 +1785,7 @@ class adminDownload extends download
- ".$e_userclass->vetted_tree('file_class_select',array($e_userclass,'select'), $uclass,'member,main,classes,admin')."
+ ".$e_userclass->vetted_tree('file_class_select',array($e_userclass,'select'), $uclass,'member,main,classes,admin, no-excludes')."
@@ -1801,7 +1801,7 @@ class adminDownload extends download
- ".$e_userclass->vetted_tree('file_class_select',array($e_userclass,'select'), '','member,main,classes,admin,blank')."
+ ".$e_userclass->vetted_tree('file_class_select',array($e_userclass,'select'), '','member,main,classes,admin,blank, no-excludes')."
diff --git a/e107_plugins/import/admin_import.php b/e107_plugins/import/admin_import.php
index 11ce97cca..1d7648c12 100644
--- a/e107_plugins/import/admin_import.php
+++ b/e107_plugins/import/admin_import.php
@@ -1,866 +1,866 @@
- array('message' => LAN_CONVERT_25, 'classfile' => 'import_user_class.php', 'classname' => 'user_import'),
- 'news' => array('message' => LAN_CONVERT_28, 'classfile' => 'import_news_class.php', 'classname' => 'news_import'),
- 'page' => array('message' => "Pages", 'classfile' => 'import_page_class.php', 'classname' => 'page_import'),
- 'links' => array('message' => "Links", 'classfile' => 'import_links_class.php', 'classname' => 'links_import'),
- 'media' => array('message' => "Media", 'classfile' => 'import_media_class.php', 'classname' => 'media_import'),
- 'comments' => array('message'=> "Comments"),
-// 'forumdefs' => array('message' => LAN_CONVERT_26),
-// 'forumposts' => array('message' => LAN_CONVERT_48),
-// 'polls' => array('message' => LAN_CONVERT_27)
-);
-
-
-// See what DB-based imports are available (don't really want it here, but gets it into the header script)
-require_once(e_HANDLER.'file_class.php');
-
-$fl = new e_file;
-$importClassList = $fl->get_files(e_PLUGIN.'import/providers', "^.+?_import_class\.php$", "standard", 1);
-foreach($importClassList as $file)
-{
- $tag = str_replace('_class.php','',$file['fname']);
- include_once($file['path'].$file['fname']); // This will set up the variables
-}
-unset($importClassList);
-unset($fl);
-asort($import_class_names);
-
-
-
-if(varset($_POST['import_source']))
-{
- $import_source = varset($_POST['import_source'],'csv');
- if(varset($_POST['classes_select']))
- {
- $checked_class_list = implode(',',$_POST['classes_select']);
- }
- $import_delete_existing_data = varset($_POST['import_delete_existing_data'],0);
-
- $current_csv = varset($_POST['csv_format'],'default');
- $csv_pw_not_encrypted = varset($_POST['csv_pw_not_encrypted'],0);
- $csv_data_file = varset($_POST['csv_data_file'],'import.csv');
-
- $current_db_type = varset($_POST['db_import_type'],key($import_class_names));
-}
-
-$db_blocks_to_import = array();
-
-
-foreach ($db_import_blocks as $k => $v)
-{
- if (isset($_POST['import_block_'.$k]))
- {
- $db_blocks_to_import[$k] = 1;
- }
-}
-
-require_once(e_ADMIN."auth.php");
-
-if (!is_object($e_userclass))
-{
- require_once(e_HANDLER."userclass_class.php"); // Modified class handler
- $e_userclass = new user_class;
-}
-
-
-
-
-define('CSV_DEF_FILE','csv_import.txt'); // Supplementary CSV format definitions
-
-// Definitions of available CSV-based imports
-$csv_formats = array('default' => 'user_name,user_password');
-$csv_names = array('default' => LAN_CONVERT_12);
-$csv_options = array('default' => 'simple');
-$csv_option_settings = array(
- 'simple' => array('separator' => ',', 'envelope' => ''),
- 'simple_sq' => array('separator' => ',', 'envelope' => "'"),
- 'simple_dq' => array('separator' => ',', 'envelope' => '"'),
- 'simple_semi' => array('separator' => ',', 'envelope' => ';'),
- 'simple_bar' => array('separator' => ',', 'envelope' => '|')
- );
-
-// See what CSV format definitions are available
-if (is_readable(CSV_DEF_FILE))
-{
- $csv_temp = file(CSV_DEF_FILE);
- foreach ($csv_temp as $line)
- {
- $line = trim(str_replace("\n","",$line));
- if ($line)
- {
- list($temp,$name,$options,$line) = explode(',',$line,4);
- $temp = trim($temp);
- $name = trim($name);
- $options = trim($options);
- $line = trim($line);
- if ($temp && $name && $options && $line)
- {
- $csv_formats[$temp] = $line; // Add any new definitions
- $csv_names[$temp] = $name;
- $csv_options[$temp] = $options;
- }
- }
- }
- unset($csv_temp);
-}
-
-
-
-$msg = '';
-
-//======================================================
-// Executive routine - actually do conversion
-//======================================================
-if(isset($_POST['do_conversion']))
-{
- $abandon = TRUE;
-
- switch ($import_source)
- {
- case 'csv' :
- if (!isset($csv_formats[$current_csv])) $msg = "CSV File format error ";
- if (!is_readable($csv_data_file)) $msg = LAN_CONVERT_31;
- if (!isset($csv_options[$current_csv])) $msg = LAN_CONVERT_37.' '.$current_csv;
- if (!isset($csv_option_settings[$csv_options[$current_csv]]))
- {
- $msg = LAN_CONVERT_37.' '.$csv_options[$current_csv];
- }
-
- if (!$msg)
- {
- $field_list = explode(',',$csv_formats[$current_csv]);
- $separator = $csv_option_settings[$csv_options[$current_csv]]['separator'];
- $enveloper = $csv_option_settings[$csv_options[$current_csv]]['envelope'];
- if (IMPORT_DEBUG) echo "CSV import: {$current_csv} Fields: {$csv_formats[$current_csv]} ";
- require_once('import_user_class.php');
- $usr = new user_import;
- $usr->overrideDefault('user_class',$checked_class_list);
- if (($source_data = file($csv_data_file)) === FALSE) $msg = LAN_CONVERT_32;
- if ($import_delete_existing_data) $usr->emptyTargetDB(); // Delete existing users - reasonably safe now
- $line_counter = 0;
- $error_counter = 0;
- $write_counter = 0;
- foreach ($source_data as $line)
- {
- $line_counter++;
- $line_error = FALSE;
- if ($line = trim($line))
- {
- $usr_data = $usr->getDefaults(); // Reset user data
- $line_data = csv_split($line, $separator, $enveloper);
- $field_data = current($line_data);
- foreach ($field_list as $f)
- {
- if ($field_data === FALSE) $line_error = TRUE;
- if ($f != 'dummy') $usr_data[$f] = $field_data;
- $field_data = next($line_data);
- }
- if ($line_error)
- {
- if ($msg) $msg .= " ";
- $msg .= LAN_CONVERT_33.$line_counter;
- $error_counter++;
- }
- else
- {
- if ($csv_pw_not_encrypted)
- {
- $usr_data['user_password'] = md5($usr_data['user_password']);
- }
- $line_error = $usr->saveData($usr_data);
- if ($line_error === TRUE)
- {
- $write_counter++;
- }
- else
- {
- $line_error = $usr->getErrorText($line_error);
- if ($msg) $msg .= " ";
- $msg .= str_replace('--ERRNUM--',$line_error,LAN_CONVERT_34).$line_counter;
- $error_counter++;
- }
- }
- }
- }
-
- if ($msg) $msg .= " ";
- if ($import_delete_existing_data) $msg .= LAN_CONVERT_40.' ';
- $msg .= str_replace(array('--LINES--','--USERS--', '--ERRORS--'),array($line_counter,$write_counter,$error_counter),LAN_CONVERT_35);
- }
- break;
-
- case 'db' :
- if(dbImport() == false)
- {
- $abandon = true;
- }
- break;
-
- case 'rss' :
- if(rssImport() == false)
- {
- $abandon = true;
- }
- break;
- }
-
- if ($msg)
- {
- $emessage->add($msg, E_MESSAGE_INFO); // $ns -> tablerender(LAN_CONVERT_30, $msg);
- $msg = '';
- }
-
- if ($abandon)
- {
- // unset($_POST['do_conversion']);
- $text = "
- ";
- $ns -> tablerender(LAN_CONVERT_30,$emessage->render(). $text);
- require_once(e_ADMIN."footer.php");
- exit;
- }
-}
-
-
-function rssImport()
-{
- global $current_db_type, $db_import_blocks, $import_delete_existing_data,$db_blocks_to_import;
-
- $mes = e107::getMessage();
- $mes->addDebug("Loading: RSS");
- if(!varset($_POST['do_conversion']))
- {
- $mes->addWarning("Under Construction");
- }
-
- return dbImport('xml');
-
-}
-
-function dbImport($mode='db')
-{
- global $current_db_type, $db_import_blocks, $import_delete_existing_data,$db_blocks_to_import;
-
- $mes = e107::getMessage();
-
- // if (IMPORT_DEBUG) echo "Importing: {$current_db_type} ";
- $mes->addDebug("Loading: ".$current_db_type);
-
- if (class_exists($current_db_type))
- {
- $mes->addDebug("Class Available: ".$current_db_type);
- $converter = new $current_db_type;
- $converter->init();
- }
- else
- {
- $mes->addError(LAN_CONVERT_42. "[".$current_db_type."]");
- return false;
- }
-
- if($mode == 'db') // Don't do DB check on RSS/XML
- {
- if (!isset($_POST['dbParamHost']) || !isset($_POST['dbParamUsername']) || !isset($_POST['dbParamPassword']) || !isset($_POST['dbParamDatabase']))
- {
- $mes->addError(LAN_CONVERT_41);
- return false;
- }
-
- $result = $converter->db_Connect($_POST['dbParamHost'], $_POST['dbParamUsername'], $_POST['dbParamPassword'], $_POST['dbParamDatabase'], $_POST['dbParamPrefix']);
- if ($result !== TRUE)
- {
- $mes->addError(LAN_CONVERT_43.": ".$result); // db connect failed
- return false;
- }
- }
-
- if(!is_array($db_import_blocks))
- {
- $mes->addError("No areas selected for import"); // db connect failed
- return false;
- }
-
- if(vartrue($converter->override))
- {
- return;
- }
-
-
-
- foreach ($db_import_blocks as $k => $v)
- {
- if (isset($db_blocks_to_import[$k]))
- {
- $loopCounter = 0;
- $errorCounter = 0;
-
- if (is_readable($v['classfile']))
- {
- require_once($v['classfile']);
- }
- else
- {
- $mes->addError(LAN_CONVERT_45.': '.$v['classfile']); // can't read class file.
- return false;
- }
-
- if (varset($_POST["import_block_{$k}"],0) == 1)
- {
- //if (IMPORT_DEBUG) echo "Importing: {$k} ";
- $mes->addDebug("Importing: ".$k);
-
- $result = $converter->setupQuery($k,!$import_delete_existing_data);
-
- if ($result !== TRUE)
- {
- $mes->addError(LAN_CONVERT_44.' '.$k); // couldn't set query
- // $msg .= "Prefix = ".$converter->DBPrefix;
- break;
- }
-
- $exporter = new $v['classname']; // Writes the output data
-
- switch ($k) // Do any type-specific default setting
- {
- case 'users' :
- $exporter->overrideDefault('user_class',$checked_class_list);
- break;
- }
-
- if ($import_delete_existing_data)
- {
- $exporter->emptyTargetDB(); // Clean output DB - reasonably safe now
- }
-
- while ($row = $converter->getNext($exporter->getDefaults(),$mode))
- {
- $loopCounter++;
- $result = $exporter->saveData($row);
- if ($result !== TRUE)
- {
- $errorCounter++;
- $line_error = $exporter->getErrorText($result);
- // if ($msg) $msg .= " ";
- $msg = str_replace(array('--ERRNUM--','--DB--'),array($line_error,$k),LAN_CONVERT_46).$loopCounter;
- $mes->addError($msg); // couldn't set query
- }
- }
-
- $converter->endQuery();
-
- unset($exporter);
-
-
- $msg = str_replace(array('--LINES--','--USERS--', '--ERRORS--','--BLOCK--'),
- array($loopCounter,$loopCounter-$errorCounter,$errorCounter, $k),LAN_CONVERT_47);
- $mes->addSuccess($msg); // couldn't set query
- }
- else
- {
- $mes->addDebug("Error: _POST['import_block_{$k}'] = ".$_POST['import_block_{$k}']); // cou
-
- }
- }
- else
- {
- $mes->addDebug("\$db_blocks_to_import doesn't contain key: ".$k); // cou
-
- }
- }
-
-// $msg = LAN_CONVERT_29;
- return true;
- // $abandon = FALSE;
-}
-
-//======================================================
-// Display front page
-//======================================================
-
-
-
-if(varset($_GET['import_type']) || varset($_POST['do_conversion']))
-{
- showImportOptions($_GET['import_type']);
-}
-else
-{
- showStartPage();
-}
-
- require_once(e_ADMIN."footer.php");
- exit;
-
-
-
-
-/*
- * Currently unused function - shows available import methods and capabilities
- */
-function showStartPage()
-{
- global $ns, $emessage, $frm, $import_class_names, $import_class_support, $db_import_blocks, $import_class_comment;
-
- $text = "
- ";
-
- $ns->tablerender(LAN_CONVERT_01, $emessage->render().$text);
-
-}
-
-
-
-
-function showImportOptions($mode='csv')
-{
- global $text, $emessage, $csv_names, $import_class_names, $e_userclass, $db_import_blocks, $import_class_support, $import_default_prefix;
-
- $frm = e107::getForm();
- $ns = e107::getRender();
-
- $mes = e107::getMessage();
-
- if (class_exists($mode))
- {
- $mes->addDebug("Class Available: ".$mode);
- $proObj = new $mode;
- if($proObj->init()===FALSE)
- {
- return;
- }
- }
-
- $message = LAN_CONVERT_02."".LAN_CONVERT_05." ";
- $emessage->add($message, E_MESSAGE_WARNING);
-
- $text = "
- ";
-
- // Now a little bit of JS to initialise some of the display divs etc
- $temp = '';
- if(varset($import_source)) { $temp .= "disp('{$import_source}');"; }
- if (varset($current_db_type)) $temp .= " flagbits('{$current_db_type}');";
- if (varset($temp)) $text .= "";
-
- $ns -> tablerender(LAN_CONVERT_01." :: ".$importType, $emessage->render().$text);
-
-}
-
-
-
-
-
-
-function csv_split(&$data,$delim=',',$enveloper='')
-{
- $ret_array = array();
- $fldval='';
- $enclosed = false;
-// $fldcount=0;
-// $linecount=0;
- for($i=0;$i $val)
- {
- $blocks .= "block_names[{$i}]='{$it}';\n";
- $i++;
- }
-
- $i = 0;
- foreach ($import_class_support as $k => $v)
- {
- $vals .= "db_names[$i] = '{$k}';\n";
- $comments .= "comment_text[$i] = '{$import_class_comment[$k]}';\n";
-// $temp = $import_class_support[$k]; // Array of import types supported
- $j = 0;
- $m = 1; // Mask bit
- foreach ($db_import_blocks as $it => $val)
- {
- if (in_array($it,$v)) $j = $j + $m;
- $m = $m + $m;
- }
- $texts .= "db_options[{$i}] = {$j};\n";
- $i++;
- }
-
- $text = "
- ";
-
- return $text;
-}
-
-
-
+ array('message' => LAN_CONVERT_25, 'classfile' => 'import_user_class.php', 'classname' => 'user_import'),
+ 'news' => array('message' => LAN_CONVERT_28, 'classfile' => 'import_news_class.php', 'classname' => 'news_import'),
+ 'page' => array('message' => "Pages", 'classfile' => 'import_page_class.php', 'classname' => 'page_import'),
+ 'links' => array('message' => "Links", 'classfile' => 'import_links_class.php', 'classname' => 'links_import'),
+ 'media' => array('message' => "Media", 'classfile' => 'import_media_class.php', 'classname' => 'media_import'),
+ 'comments' => array('message'=> "Comments"),
+// 'forumdefs' => array('message' => LAN_CONVERT_26),
+// 'forumposts' => array('message' => LAN_CONVERT_48),
+// 'polls' => array('message' => LAN_CONVERT_27)
+);
+
+
+// See what DB-based imports are available (don't really want it here, but gets it into the header script)
+require_once(e_HANDLER.'file_class.php');
+
+$fl = new e_file;
+$importClassList = $fl->get_files(e_PLUGIN.'import/providers', "^.+?_import_class\.php$", "standard", 1);
+foreach($importClassList as $file)
+{
+ $tag = str_replace('_class.php','',$file['fname']);
+ include_once($file['path'].$file['fname']); // This will set up the variables
+}
+unset($importClassList);
+unset($fl);
+asort($import_class_names);
+
+
+
+if(varset($_POST['import_source']))
+{
+ $import_source = varset($_POST['import_source'],'csv');
+ if(varset($_POST['classes_select']))
+ {
+ $checked_class_list = implode(',',$_POST['classes_select']);
+ }
+ $import_delete_existing_data = varset($_POST['import_delete_existing_data'],0);
+
+ $current_csv = varset($_POST['csv_format'],'default');
+ $csv_pw_not_encrypted = varset($_POST['csv_pw_not_encrypted'],0);
+ $csv_data_file = varset($_POST['csv_data_file'],'import.csv');
+
+ $current_db_type = varset($_POST['db_import_type'],key($import_class_names));
+}
+
+$db_blocks_to_import = array();
+
+
+foreach ($db_import_blocks as $k => $v)
+{
+ if (isset($_POST['import_block_'.$k]))
+ {
+ $db_blocks_to_import[$k] = 1;
+ }
+}
+
+require_once(e_ADMIN."auth.php");
+
+if (!is_object($e_userclass))
+{
+ require_once(e_HANDLER."userclass_class.php"); // Modified class handler
+ $e_userclass = new user_class;
+}
+
+
+
+
+define('CSV_DEF_FILE','csv_import.txt'); // Supplementary CSV format definitions
+
+// Definitions of available CSV-based imports
+$csv_formats = array('default' => 'user_name,user_password');
+$csv_names = array('default' => LAN_CONVERT_12);
+$csv_options = array('default' => 'simple');
+$csv_option_settings = array(
+ 'simple' => array('separator' => ',', 'envelope' => ''),
+ 'simple_sq' => array('separator' => ',', 'envelope' => "'"),
+ 'simple_dq' => array('separator' => ',', 'envelope' => '"'),
+ 'simple_semi' => array('separator' => ',', 'envelope' => ';'),
+ 'simple_bar' => array('separator' => ',', 'envelope' => '|')
+ );
+
+// See what CSV format definitions are available
+if (is_readable(CSV_DEF_FILE))
+{
+ $csv_temp = file(CSV_DEF_FILE);
+ foreach ($csv_temp as $line)
+ {
+ $line = trim(str_replace("\n","",$line));
+ if ($line)
+ {
+ list($temp,$name,$options,$line) = explode(',',$line,4);
+ $temp = trim($temp);
+ $name = trim($name);
+ $options = trim($options);
+ $line = trim($line);
+ if ($temp && $name && $options && $line)
+ {
+ $csv_formats[$temp] = $line; // Add any new definitions
+ $csv_names[$temp] = $name;
+ $csv_options[$temp] = $options;
+ }
+ }
+ }
+ unset($csv_temp);
+}
+
+
+
+$msg = '';
+
+//======================================================
+// Executive routine - actually do conversion
+//======================================================
+if(isset($_POST['do_conversion']))
+{
+ $abandon = TRUE;
+
+ switch ($import_source)
+ {
+ case 'csv' :
+ if (!isset($csv_formats[$current_csv])) $msg = "CSV File format error ";
+ if (!is_readable($csv_data_file)) $msg = LAN_CONVERT_31;
+ if (!isset($csv_options[$current_csv])) $msg = LAN_CONVERT_37.' '.$current_csv;
+ if (!isset($csv_option_settings[$csv_options[$current_csv]]))
+ {
+ $msg = LAN_CONVERT_37.' '.$csv_options[$current_csv];
+ }
+
+ if (!$msg)
+ {
+ $field_list = explode(',',$csv_formats[$current_csv]);
+ $separator = $csv_option_settings[$csv_options[$current_csv]]['separator'];
+ $enveloper = $csv_option_settings[$csv_options[$current_csv]]['envelope'];
+ if (IMPORT_DEBUG) echo "CSV import: {$current_csv} Fields: {$csv_formats[$current_csv]} ";
+ require_once('import_user_class.php');
+ $usr = new user_import;
+ $usr->overrideDefault('user_class',$checked_class_list);
+ if (($source_data = file($csv_data_file)) === FALSE) $msg = LAN_CONVERT_32;
+ if ($import_delete_existing_data) $usr->emptyTargetDB(); // Delete existing users - reasonably safe now
+ $line_counter = 0;
+ $error_counter = 0;
+ $write_counter = 0;
+ foreach ($source_data as $line)
+ {
+ $line_counter++;
+ $line_error = FALSE;
+ if ($line = trim($line))
+ {
+ $usr_data = $usr->getDefaults(); // Reset user data
+ $line_data = csv_split($line, $separator, $enveloper);
+ $field_data = current($line_data);
+ foreach ($field_list as $f)
+ {
+ if ($field_data === FALSE) $line_error = TRUE;
+ if ($f != 'dummy') $usr_data[$f] = $field_data;
+ $field_data = next($line_data);
+ }
+ if ($line_error)
+ {
+ if ($msg) $msg .= " ";
+ $msg .= LAN_CONVERT_33.$line_counter;
+ $error_counter++;
+ }
+ else
+ {
+ if ($csv_pw_not_encrypted)
+ {
+ $usr_data['user_password'] = md5($usr_data['user_password']);
+ }
+ $line_error = $usr->saveData($usr_data);
+ if ($line_error === TRUE)
+ {
+ $write_counter++;
+ }
+ else
+ {
+ $line_error = $usr->getErrorText($line_error);
+ if ($msg) $msg .= " ";
+ $msg .= str_replace('--ERRNUM--',$line_error,LAN_CONVERT_34).$line_counter;
+ $error_counter++;
+ }
+ }
+ }
+ }
+
+ if ($msg) $msg .= " ";
+ if ($import_delete_existing_data) $msg .= LAN_CONVERT_40.' ';
+ $msg .= str_replace(array('--LINES--','--USERS--', '--ERRORS--'),array($line_counter,$write_counter,$error_counter),LAN_CONVERT_35);
+ }
+ break;
+
+ case 'db' :
+ if(dbImport() == false)
+ {
+ $abandon = true;
+ }
+ break;
+
+ case 'rss' :
+ if(rssImport() == false)
+ {
+ $abandon = true;
+ }
+ break;
+ }
+
+ if ($msg)
+ {
+ $emessage->add($msg, E_MESSAGE_INFO); // $ns -> tablerender(LAN_CONVERT_30, $msg);
+ $msg = '';
+ }
+
+ if ($abandon)
+ {
+ // unset($_POST['do_conversion']);
+ $text = "
+ ";
+ $ns -> tablerender(LAN_CONVERT_30,$emessage->render(). $text);
+ require_once(e_ADMIN."footer.php");
+ exit;
+ }
+}
+
+
+function rssImport()
+{
+ global $current_db_type, $db_import_blocks, $import_delete_existing_data,$db_blocks_to_import;
+
+ $mes = e107::getMessage();
+ $mes->addDebug("Loading: RSS");
+ if(!varset($_POST['do_conversion']))
+ {
+ $mes->addWarning("Under Construction");
+ }
+
+ return dbImport('xml');
+
+}
+
+function dbImport($mode='db')
+{
+ global $current_db_type, $db_import_blocks, $import_delete_existing_data,$db_blocks_to_import;
+
+ $mes = e107::getMessage();
+
+ // if (IMPORT_DEBUG) echo "Importing: {$current_db_type} ";
+ $mes->addDebug("Loading: ".$current_db_type);
+
+ if (class_exists($current_db_type))
+ {
+ $mes->addDebug("Class Available: ".$current_db_type);
+ $converter = new $current_db_type;
+ $converter->init();
+ }
+ else
+ {
+ $mes->addError(LAN_CONVERT_42. "[".$current_db_type."]");
+ return false;
+ }
+
+ if($mode == 'db') // Don't do DB check on RSS/XML
+ {
+ if (!isset($_POST['dbParamHost']) || !isset($_POST['dbParamUsername']) || !isset($_POST['dbParamPassword']) || !isset($_POST['dbParamDatabase']))
+ {
+ $mes->addError(LAN_CONVERT_41);
+ return false;
+ }
+
+ $result = $converter->db_Connect($_POST['dbParamHost'], $_POST['dbParamUsername'], $_POST['dbParamPassword'], $_POST['dbParamDatabase'], $_POST['dbParamPrefix']);
+ if ($result !== TRUE)
+ {
+ $mes->addError(LAN_CONVERT_43.": ".$result); // db connect failed
+ return false;
+ }
+ }
+
+ if(!is_array($db_import_blocks))
+ {
+ $mes->addError("No areas selected for import"); // db connect failed
+ return false;
+ }
+
+ if(vartrue($converter->override))
+ {
+ return;
+ }
+
+
+
+ foreach ($db_import_blocks as $k => $v)
+ {
+ if (isset($db_blocks_to_import[$k]))
+ {
+ $loopCounter = 0;
+ $errorCounter = 0;
+
+ if (is_readable($v['classfile']))
+ {
+ require_once($v['classfile']);
+ }
+ else
+ {
+ $mes->addError(LAN_CONVERT_45.': '.$v['classfile']); // can't read class file.
+ return false;
+ }
+
+ if (varset($_POST["import_block_{$k}"],0) == 1)
+ {
+ //if (IMPORT_DEBUG) echo "Importing: {$k} ";
+ $mes->addDebug("Importing: ".$k);
+
+ $result = $converter->setupQuery($k,!$import_delete_existing_data);
+
+ if ($result !== TRUE)
+ {
+ $mes->addError(LAN_CONVERT_44.' '.$k); // couldn't set query
+ // $msg .= "Prefix = ".$converter->DBPrefix;
+ break;
+ }
+
+ $exporter = new $v['classname']; // Writes the output data
+
+ switch ($k) // Do any type-specific default setting
+ {
+ case 'users' :
+ $exporter->overrideDefault('user_class',$checked_class_list);
+ break;
+ }
+
+ if ($import_delete_existing_data)
+ {
+ $exporter->emptyTargetDB(); // Clean output DB - reasonably safe now
+ }
+
+ while ($row = $converter->getNext($exporter->getDefaults(),$mode))
+ {
+ $loopCounter++;
+ $result = $exporter->saveData($row);
+ if ($result !== TRUE)
+ {
+ $errorCounter++;
+ $line_error = $exporter->getErrorText($result);
+ // if ($msg) $msg .= " ";
+ $msg = str_replace(array('--ERRNUM--','--DB--'),array($line_error,$k),LAN_CONVERT_46).$loopCounter;
+ $mes->addError($msg); // couldn't set query
+ }
+ }
+
+ $converter->endQuery();
+
+ unset($exporter);
+
+
+ $msg = str_replace(array('--LINES--','--USERS--', '--ERRORS--','--BLOCK--'),
+ array($loopCounter,$loopCounter-$errorCounter,$errorCounter, $k),LAN_CONVERT_47);
+ $mes->addSuccess($msg); // couldn't set query
+ }
+ else
+ {
+ $mes->addDebug("Error: _POST['import_block_{$k}'] = ".$_POST['import_block_{$k}']); // cou
+
+ }
+ }
+ else
+ {
+ $mes->addDebug("\$db_blocks_to_import doesn't contain key: ".$k); // cou
+
+ }
+ }
+
+// $msg = LAN_CONVERT_29;
+ return true;
+ // $abandon = FALSE;
+}
+
+//======================================================
+// Display front page
+//======================================================
+
+
+
+if(varset($_GET['import_type']) || varset($_POST['do_conversion']))
+{
+ showImportOptions($_GET['import_type']);
+}
+else
+{
+ showStartPage();
+}
+
+ require_once(e_ADMIN."footer.php");
+ exit;
+
+
+
+
+/*
+ * Currently unused function - shows available import methods and capabilities
+ */
+function showStartPage()
+{
+ global $ns, $emessage, $frm, $import_class_names, $import_class_support, $db_import_blocks, $import_class_comment;
+
+ $text = "
+ ";
+
+ $ns->tablerender(LAN_CONVERT_01, $emessage->render().$text);
+
+}
+
+
+
+
+function showImportOptions($mode='csv')
+{
+ global $text, $emessage, $csv_names, $import_class_names, $e_userclass, $db_import_blocks, $import_class_support, $import_default_prefix;
+
+ $frm = e107::getForm();
+ $ns = e107::getRender();
+
+ $mes = e107::getMessage();
+
+ if (class_exists($mode))
+ {
+ $mes->addDebug("Class Available: ".$mode);
+ $proObj = new $mode;
+ if($proObj->init()===FALSE)
+ {
+ return;
+ }
+ }
+
+ $message = LAN_CONVERT_02."".LAN_CONVERT_05." ";
+ $emessage->add($message, E_MESSAGE_WARNING);
+
+ $text = "
+ ";
+
+ // Now a little bit of JS to initialise some of the display divs etc
+ $temp = '';
+ if(varset($import_source)) { $temp .= "disp('{$import_source}');"; }
+ if (varset($current_db_type)) $temp .= " flagbits('{$current_db_type}');";
+ if (varset($temp)) $text .= "";
+
+ $ns -> tablerender(LAN_CONVERT_01." :: ".$importType, $emessage->render().$text);
+
+}
+
+
+
+
+
+
+function csv_split(&$data,$delim=',',$enveloper='')
+{
+ $ret_array = array();
+ $fldval='';
+ $enclosed = false;
+// $fldcount=0;
+// $linecount=0;
+ for($i=0;$i $val)
+ {
+ $blocks .= "block_names[{$i}]='{$it}';\n";
+ $i++;
+ }
+
+ $i = 0;
+ foreach ($import_class_support as $k => $v)
+ {
+ $vals .= "db_names[$i] = '{$k}';\n";
+ $comments .= "comment_text[$i] = '{$import_class_comment[$k]}';\n";
+// $temp = $import_class_support[$k]; // Array of import types supported
+ $j = 0;
+ $m = 1; // Mask bit
+ foreach ($db_import_blocks as $it => $val)
+ {
+ if (in_array($it,$v)) $j = $j + $m;
+ $m = $m + $m;
+ }
+ $texts .= "db_options[{$i}] = {$j};\n";
+ $i++;
+ }
+
+ $text = "
+ ";
+
+ return $text;
+}
+
+
+
?>
\ No newline at end of file