site = $site; if (!is_array($conf)) { $conf = array(); } $this->_configuration = $conf; if (!empty($ism)) { // Configuration mode $this->ism = $ism; require_once('modules/'.$this->_parent_module.'/common.inc.php'); eval('$this->_module = new '.$this->_parent_classname.'($this->ism);'); } return true; } // Run function... constrained by a width public function run($width) { if (!empty($this->_configuration['categories'])) { $sm = $this->site->smarty(); $s = 0; $err = array(); if (!empty($_REQUEST['s'])) { $s = $_REQUEST['s']; } if (!empty($_REQUEST['frm'])) { $frm = $_REQUEST['frm']; } if (empty($frm['country'])) { $frm['country'] = 1; } // Cell providers $sms = new SMS(); $sm->assign('cellproviders', $sms->cellproviders); // States $states = array(); $state_query = $this->site->sdb_query("SELECT * FROM ISM3.db_states ORDER BY country_id, name"); while ($state = $this->site->sdb_fetch_array($state_query)) { array_push($states, $state); } // Countries $countries = array(); $country_query = $this->site->sdb_query("SELECT * FROM ISM3.db_countries ORDER BY name"); while ($country = $this->site->sdb_fetch_array($country_query)) { array_push($countries, $country); } // Load the newsletter types $newsletters = array(); foreach ($this->_configuration as $key => $conf) { if (preg_match("/^emcats_([0-9]+)$/", $key, $matches) && is_array($conf)) { $newsletters[$matches[1]] = 0; } } if (sizeof($newsletters) > 0) { $newsletter_query = $this->site->sdb_query("SELECT id, name FROM `emailer1_compose_categories` WHERE ". " id IN (".join(', ', array_keys($newsletters)).") "); while ($newsletter = $this->site->sdb_fetch_array($newsletter_query)) { $newsletters[$newsletter['id']] = array('name' => htmlspecialchars($newsletter['name'])); } $sm->assign('newsletters', $newsletters); $sm->assign('enable_multiple', 1); } // Load custom fields $cf = new CustomFields($this->site); $custom = $cf->get('emailer1-members', $s); // Load configuration data $enable = array(); foreach (array('enable_name', 'enable_address', 'enable_dob', 'enable_gender', 'enable_cell', 'enable_cellprovider', 'enable_email', 'enable_password', 'enable_billing', 'enable_shipping', 'enable_emailerstatus', 'enable_homephone', 'enable_workphone', 'enable_retypeemail') as $conf) { $enable[$conf] = (empty($this->_configuration[$conf])) ? '' : $this->_configuration[$conf]; $sm->assign($conf, $enable[$conf]); } switch ($s) { case 2: // Modify existing subscription $group_subscribe = array(); // Place user in these groups $group_total = $this->_configuration['categories']; // Possible groups to be placed in foreach ($this->_configuration as $key => $val) { if (preg_match("/^emcats_([0-9]+)$/", $key, $matches)) { $group_total = array_merge($group_total, $val); } } if (isset($frm['newsletters'])) { foreach ($frm['newsletters'] as $newsletter_id => $null) { if (isset($this->_configuration['emcats_'.$newsletter_id])) { foreach ($this->_configuration['emcats_'.$newsletter_id] as $gid) { if (!in_array($gid, $this->_configuration['categories'])) { array_push($this->_configuration['categories'], $gid); } } } } } // Get user ID $email = addslashes($frm['email']); $user_query = $this->site->sdb_query("SELECT id FROM `std_core_siteusers` WHERE ". " email='$email' "); $user = $this->site->sdb_fetch_array($user_query); if (isset($user['id'])) { // Flush out possible groups $this->site->sdb_query("DELETE FROM `std_core_siteusergroups` WHERE ". " siteuser_id='$user[id]' AND ". " group_id IN ('".join("', '", $group_total)."') "); // Add user to the member groups inside $this->_configuration['categories'] if (!empty($this->_configuration['categories'])) { foreach ($this->_configuration['categories'] as $group_id) { $this->site->sdb_query("INSERT INTO `std_core_siteusergroups` (siteuser_id, group_id) ". " VALUES ('$user[id]', '$group_id')"); } } // Set flags $is_noemail = (!empty($frm['is_noemail'])) ? 1 : 0; $this->site->sdb_query("UPDATE `std_core_siteusers` SET is_noemail='$is_noemail' ". " WHERE id='$user[id]'"); echo '
Email subscription options saved.
'; } else { echo 'Invalid email address.
'; } break; case 1: // Verify & subscribe $fields = array(); // Full name check if ($enable['enable_name'] == 1 && empty($frm['name_first'])) { $err['name_first'] = 'Must not be empty.'; } elseif (!empty($frm['name_first'])) { array_push($fields, "name_first='".addslashes($frm['name_first'])."'"); } if ($enable['enable_name'] == 1 && empty($frm['name_last'])) { $err['name_last'] = 'Must not be empty.'; } elseif (!empty($frm['name_last'])) { array_push($fields, "name_last='".addslashes($frm['name_last'])."'"); } if (!empty($frm['name_mi'])) { array_push($fields, "name_mi='".addslashes($frm['name_mi'])."'"); } // Cell check if ($enable['enable_cell']) { if ($enable['enable_cell'] == 1 && empty($frm['number_cell'])) { $err['number_cell'] = 'Please include your cell phone number.'; } else { array_push($fields, "phone_cell='".addslashes($frm['number_cell'])."'"); } } // Email retype check if ($enable['enable_retypeemail']) { if (empty($frm['email2']) || $frm['email'] != $frm['email2']) { $err['email2'] = 'Email addresses do not match.'; } } // Home number check if ($enable['enable_homephone']) { if ($enable['enable_homephone'] == 1 && empty($frm['number_home'])) { $err['number_home'] = 'Please include your home phone number.'; } else { array_push($fields, "phone_home='".addslashes($frm['number_home'])."'"); } } // Home number check if ($enable['enable_workphone']) { if ($enable['enable_workphone'] == 1 && empty($frm['number_work'])) { $err['number_work'] = 'Please include your work phone number.'; } else { array_push($fields, "phone_work='".addslashes($frm['number_work'])."'"); } } // Cell provider check if ($enable['enable_cellprovider']) { if ($enable['enable_cellprovider'] == 1 && empty($frm['number_cellprovider'])) { $err['number_cellprovider'] = 'Please include your cell phone provider.'; } else { array_push($fields, "phone_cellprovider='".addslashes($frm['number_cellprovider'])."'"); } } // Address check if ($enable['enable_address'] == 1 && empty($frm['address'])) { $err['address'] = 'Must not be empty.'; } elseif (!empty($frm['address'])) { array_push($fields, "address='".addslashes($frm['address'])."'"); } if ($enable['enable_address'] == 1 && empty($frm['city'])) { $err['city'] = 'Must not be empty.'; } elseif (!empty($frm['city'])) { array_push($fields, "city='".addslashes($frm['city'])."'"); } if ($enable['enable_address'] == 1 && empty($frm['state'])) { $err['state'] = 'Please select a state.'; } elseif (!empty($frm['state'])) { array_push($fields, "state='".addslashes($frm['state'])."'"); } if ($enable['enable_address'] == 1 && empty($frm['zip'])) { $err['zip'] = 'Must not be empty.'; } elseif (!empty($frm['zip'])) { array_push($fields, "zip='".addslashes($frm['zip'])."'"); } if ($enable['enable_address'] == 1 && empty($frm['country'])) { $err['country'] = 'Must not be empty.'; } elseif (!empty($frm['country'])) { array_push($fields, "country='".addslashes($frm['country'])."'"); } // Date of birth check if (!empty($frm['dob_Year']) && !empty($frm['dob_Month']) && !empty($frm['dob_Day'])) { $frm['dob'] = $frm['dob_Year'].'-'.$frm['dob_Month'].'-'.$frm['dob_Day']; array_push($fields, "dob='".addslashes($frm['dob'])."'"); } // Email check if (empty($frm['email']) || !preg_match("/^[a-zA-Z0-9_\-\.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$/i", $frm['email'])) { $err['email'] = 'Invalid email address.'; } else { array_push($fields, "email='".addslashes($frm['email'])."'"); } // Check for duplicate email addresses $email_query = $this->site->sdb_query("SELECT count(*) AS 'count' FROM ". " `std_core_siteusers` WHERE username='' AND email='$frm[email]'"); $emailc = $this->site->sdb_fetch_array($email_query); if ($emailc['count'] > 0) { //$err['email'] = 'This Email address is already registered.'; } // Gender check if (!empty($frm['gender'])) { array_push($fields, "gender='".addslashes($frm['gender'])."'"); } elseif ($enable['enable_gender'] == 1) { $err['gender'] = 'Please specify your gender.'; } // Check for duplicate email addresses $email_query = $this->site->sdb_query("SELECT count(*) AS 'count' FROM ". " `std_core_siteusers` WHERE username='0' AND email='$frm[email]'"); $emailc = $this->site->sdb_fetch_array($email_query); if ($emailc['count'] > 0) { //$err['email'] = 'This address is already in our system; please contact us to register.'; } if (sizeof($err) > 0) { $s = 0; echo 'Please correct the highlighted fields below:
'; } else { foreach ($frm as $var => $val) { if (!is_array($val)) { $frm[$var] = addslashes($val); } } // Get user id $this->site->sdb_query("INSERT INTO `std_core_siteusers` (id) VALUES ('')"); $user_id = $this->site->sdb_insert_id(); /** * Add user to the selected newsletter groups * * added 10/23/2006 */ /* if (isset($frm['newsletters'])) { if (isset($this->_configuration['emcats'])) { foreach ($this->_configuration['emcats'] as $gid) { if (!in_array($gid, $this->_configuration['categories'])) { array_push($this->_configuration['categories'], $gid); } } } } */ if (isset($frm['newsletters'])) { foreach ($frm['newsletters'] as $newsletter_id => $null) { if (isset($this->_configuration['emcats_'.$newsletter_id])) { foreach ($this->_configuration['emcats_'.$newsletter_id] as $gid) { if (!in_array($gid, $this->_configuration['categories'])) { array_push($this->_configuration['categories'], $gid); } } } } } // Add user to the member groups inside $this->_configuration['categories'] if (!empty($this->_configuration['categories'])) { foreach ($this->_configuration['categories'] as $group_id) { $this->site->sdb_query("INSERT INTO `std_core_siteusergroups` (siteuser_id, group_id) ". " VALUES ('$user_id', '$group_id')"); } } $sql = 'UPDATE `std_core_siteusers` SET date_created=now(), '.join(', ', $fields)." WHERE id='".$user_id."'"; $this->site->sdb_query($sql); // Custom fields $cf->set('emailer1-members', $user_id, $custom); // Send confirmation email to end user $nwtext_query = $this->site->sdb_query("SELECT * FROM `std_core_config` WHERE ". " id='emailer1-config_registernotify' "); $nwtext = $this->site->sdb_fetch_array($nwtext_query); if (!empty($nwtext['value'])) { $this->site->sendemail($frm['email'], 'Welcome to '.$this->site->config['site_name'].'!', $nwtext['value']); } // Send notification email to client $ntext_query = $this->site->sdb_query("SELECT * FROM `std_core_config` WHERE id='emailer1-config_registernotify' "); $ntext = $this->site->sdb_fetch_array($ntext_query); if (!empty($ntext['value'])) { $state = $this->site->frm('state'); $country = $this->site->frm('country'); $emt = 'New site member!
'. ''.$this->site->frm('username').'
'.
''.$this->site->frm('email').'
Thanks for registering!
'; } } break; } $sm->assign('config', $this->_configuration); $sm->assign('custom', $custom); $sm->assign('countries', $countries); $sm->assign('states', $states); $sm->assign('frm', $frm); $sm->assign('err', $err); $sm->display($this->templates[0]); } else { $this->site->error('No member categories have been selected to place new registrations in.'); } } /** * Get all available configuration options for this module. See the ISMHTMLFormTable class * for information about the datatype returned. */ public function getconfformtablearray() { require_once('./modules/emailer1-compose/common.inc.php'); $emc = new ISMModuleEmailer1Compose($this->ism); $emcats = $emc->getcategorieshash(); $sb = new ISMModuleStdSiteBuilder($this->ism); $rows = array(); array_push($rows, array( array('type' => 'field', 'value' => 'Redirect successful registrations to this page'), array('type' => 'select', 'name' => 'plugin_rdpage', 'size' => 3, 'selected' => ((empty($this->_configuration['rdpage'])) ? 0 : $this->_configuration['rdpage']), 'values' => array('' => '') + $sb->getpageshash()), )); array_push($rows, array( array('type' => 'section', 'value' => 'Newsletters & Group Assignment'), )); array_push($rows, array( array('type' => 'field', 'colspan' => 2, 'value' => 'By default, visitors to this page will not be given the '. 'option to select which newsletters to subscribe to. If this site has multiple newsletters, '. ' select the appropriate groups associated with each subscription '. 'below.'), )); array_push($rows, array( array('type' => 'field', 'value' => 'Add all sign-ups to these groups:'), array('type' => 'checkboxarray', 'values' => $this->_module->getmembergroupshash(), 'selected_ar' => ((!empty($this->_configuration['categories'])) ? $this->_configuration['categories'] : ''), 'name' => 'plugin_categories') )); foreach ($emcats as $category_id => $name) { array_push($rows, array( array('type' => 'field', 'value' => ''.$name.''), array('type' => 'checkboxarray', 'values' => $this->_module->getmembergroupshash(), 'selected_ar' => ((!empty($this->_configuration['emcats_'.$category_id])) ? $this->_configuration['emcats_'.$category_id] : ''), 'name' => 'plugin_emcats_'.$category_id) )); } array_push($rows, array( array('type' => 'section', 'value' => 'Field Configuration'), )); array_push($rows, array( array('type' => 'field', 'value' => 'Force user to retype email address?'), array('type' => 'select', 'name' => 'plugin_enable_retypeemail', 'values' => array('' => 'No', '1' => 'Yes'), 'selected' => ((!empty($this->_configuration['enable_retypeemail'])) ? $this->_configuration['enable_retypeemail'] : '')) )); array_push($rows, array( array('type' => 'field', 'value' => 'Name'), array('type' => 'select', 'name' => 'plugin_enable_name', 'values' => array('' => 'Hidden', '1' => 'Required', '2' => 'Optional'), 'selected' => ((!empty($this->_configuration['enable_name'])) ? $this->_configuration['enable_name'] : '')) )); array_push($rows, array( array('type' => 'field', 'value' => 'Address'), array('type' => 'select', 'name' => 'plugin_enable_address', 'values' => array('' => 'Hidden', '1' => 'Required', '2' => 'Optional'), 'selected' => ((!empty($this->_configuration['enable_address'])) ? $this->_configuration['enable_address'] : '')) )); array_push($rows, array( array('type' => 'field', 'value' => 'Date of Birth'), array('type' => 'select', 'name' => 'plugin_enable_dob', 'values' => array('' => 'Hidden', '1' => 'Required', '2' => 'Optional'), 'selected' => ((!empty($this->_configuration['enable_dob'])) ? $this->_configuration['enable_dob'] : '')) )); array_push($rows, array( array('type' => 'field', 'value' => 'Gender'), array('type' => 'select', 'name' => 'plugin_enable_gender', 'values' => array('' => 'Hidden', '1' => 'Required', '2' => 'Optional'), 'selected' => ((!empty($this->_configuration['enable_gender'])) ? $this->_configuration['enable_gender'] : '')) )); array_push($rows, array( array('type' => 'field', 'value' => 'Home Phone'), array('type' => 'select', 'name' => 'plugin_enable_homephone', 'values' => array('' => 'Hidden', '1' => 'Required', '2' => 'Optional'), 'selected' => ((!empty($this->_configuration['enable_homephone'])) ? $this->_configuration['enable_homephone'] : '')) )); array_push($rows, array( array('type' => 'field', 'value' => 'Work Phone'), array('type' => 'select', 'name' => 'plugin_enable_workphone', 'values' => array('' => 'Hidden', '1' => 'Required', '2' => 'Optional'), 'selected' => ((!empty($this->_configuration['enable_workphone'])) ? $this->_configuration['enable_workphone'] : '')) )); array_push($rows, array( array('type' => 'field', 'value' => 'Cell Phone'), array('type' => 'select', 'name' => 'plugin_enable_cell', 'values' => array('' => 'Hidden', '1' => 'Required', '2' => 'Optional'), 'selected' => ((!empty($this->_configuration['enable_cell'])) ? $this->_configuration['enable_cell'] : '')) )); array_push($rows, array( array('type' => 'field', 'value' => 'Cell Phone Provider