$queryError = $this->wpdb->last_error;
if ($queryError) {
glmMembersAdmin::addNotice('<b>Error when adding the default member type: Check following message.</b><br><pre>'.$queryError.'</pre>', 'AdminError');
+ return false;
}
/*
$queryError = $this->wpdb->last_error;
if ($queryError) {
glmMembersAdmin::addNotice('<b>Error when adding the default region: Check following message.</b><br><pre>'.$queryError.'</pre>', 'AdminError');
+ return false;
+ }
+
+ /*
+ * Get category names from Connections
+ */
+
+ // Get the category items from the term taxonomy table in Connections
+ $sql = "
+ SELECT *
+ FROM ".$this->wpdb->prefix."connections_term_taxonomy;
+ ;";
+ $rawCats = $this->wpdb->get_results($sql, ARRAY_A);
+ $queryError = $this->wpdb->last_error;
+ if ($queryError) {
+ glmMembersAdmin::addNotice('<b>Error when reading cateory data from Connections.</b><br><pre>'.$queryError.'</pre>', 'AdminError');
+ return false;
+ }
+
+ // Start building a clean category table
+ $cats = array();
+ foreach ($rawCats as $c) {
+ if ($c['taxonomy'] == 'category') {
+ $cats[$c['term_id']] = array(
+ 'id' => $c['term_taxonomy_id'],
+ 'term_id' => $c['term_id'],
+ 'descr' => $c['description'],
+ 'parent' => $c['parent']
+ );
+ }
+ }
+
+ // get the category terms (names) from Connections
+ // Get the category items from the term taxonomy table in Connections
+ $sql = "
+ SELECT *
+ FROM ".$this->wpdb->prefix."connections_terms;
+ ;";
+ $rawTerms = $this->wpdb->get_results($sql, ARRAY_A);
+ $queryError = $this->wpdb->last_error;
+ if ($queryError) {
+ glmMembersAdmin::addNotice('<b>Error when reading cateory terms from Connections.</b><br><pre>'.$queryError.'</pre>', 'AdminError');
+ return false;
+ }
+
+ // Add terms to category table
+ foreach ($rawTerms as $t) {
+ $cats[$t['term_id']]['name'] = $t['name'];
+ }
+
+ // Store all categories and collect the new IDs
+ reset($cats);
+ while (list($k, $c) = each($cats)) {
+ $sql = "
+ INSERT INTO ".GLM_MEMBERS_PLUGIN_DB_PREFIX."categories
+ (
+ name,
+ descr,
+ short_descr,
+ parent
+ )
+ VALUES
+ (
+ '".$c['name']."',
+ '".$c['descr']."',
+ '',
+ 0
+ )
+ ;";
+ $this->wpdb->query($sql);
+ $catID = $this->wpdb->insert_id;
+ $queryError = $this->wpdb->last_error;
+ if ($queryError) {
+ glmMembersAdmin::addNotice('<b>Error when creating member: Check following message.</b><br><pre>'.$queryError.'</pre>', 'AdminError');
+ }
+ $cats[$k]['new_id'] = $catID;
+ }
+
+ // Re-scan categories and populate parents with updated id
+ reset($cats);
+ foreach ($cats as $c) {
+
+ // If the category has a parent ID
+ if ($c['parent'] > 0) {
+
+ $newParent = $cats[$c['parent']]['new_id'];
+ $sql = "
+ UPDATE ".GLM_MEMBERS_PLUGIN_DB_PREFIX."categories
+ SET parent = $newParent
+ WHERE id = ".$c['new_id']."
+ ;";
+ $this->wpdb->query($sql);
+ $queryError = $this->wpdb->last_error;
+ if ($queryError) {
+ glmMembersAdmin::addNotice('<b>Error when creating member: Check following message.</b><br><pre>'.$queryError.'</pre>', 'AdminError');
+ }
+ }
+ }
+
+ // Get member/category mapping
+ $sql = "
+ SELECT *
+ FROM ".$this->wpdb->prefix."connections_term_relationships
+ ;";
+ $memberCats = $this->wpdb->get_results($sql, ARRAY_A);
+ $queryError = $this->wpdb->last_error;
+ if ($queryError) {
+ glmMembersAdmin::addNotice('<b>Error when reading term relationships from Connections.</b><br><pre>'.$queryError.'</pre>', 'AdminError');
+ return false;
}
/*
// If we're not skipping this entry
if (!isset($_REQUEST['skip'][$m['id']])) {
- echo "123 ".$m['id'];
-
-
/*
* Create base Member Record
*/
glmMembersAdmin::addNotice('<b>Error when creating member: Check following message.</b><br><pre>'.$queryError.'</pre>', 'AdminError');
}
+ // Scan member/category mapping array for any for this member
+ reset ($memberCats);
+ foreach ($memberCats as $mc) {
+
+ // If there's a mapping for this member
+ if ($mc['entry_id'] == $m['id']) {
+
+ // Add to category_member_info table
+ $sql = "
+ INSERT INTO ".GLM_MEMBERS_PLUGIN_DB_PREFIX."category_member_info
+ (
+ category,
+ member_info
+ )
+ VALUES
+ (
+ ".$cats[$mc['term_taxonomy_id']]['new_id'].",
+ $membID
+ )
+ ;";
+ $this->wpdb->query($sql);
+ $queryError = $this->wpdb->last_error;
+ if ($queryError) {
+ glmMembersAdmin::addNotice('<b>Error when creating member/category entry: Check following message.</b><br><pre>'.$queryError.'</pre>', 'AdminError');
+ }
+ }
+ }
+
// Check for additional image
/*
$image = '';