function getInput() { $fields = acymailing_getColumns('#__virtuemart_userinfos'); $dropdown = array(); foreach($fields as $oneField => $fieldType){ $dropdown[] = JHTML::_('select.option', $oneField,$oneField); } return JHTML::_('select.genericlist', $dropdown, $this->name , 'size="1"', 'value', 'text', $this->value); }
function export() { $listClass = acymailing_get('class.list'); $db = JFactory::getDBO(); $fields = acymailing_getColumns('#__acymailing_subscriber'); $config = acymailing_config(); $selectedFields = explode(',', $config->get('export_fields', 'email,name')); $selectedLists = explode(',', $config->get('export_lists')); acymailing_setTitle(JText::_('ACY_EXPORT'), 'acyexport', 'data&task=export'); $bar = JToolBar::getInstance('toolbar'); JToolBarHelper::custom('doexport', 'acyexport', '', JText::_('ACY_EXPORT'), false); $bar->appendButton('Link', 'cancel', JText::_('ACY_CANCEL'), acymailing_completeLink('subscriber')); JToolBarHelper::divider(); $bar->appendButton('Pophelp', 'data-export'); $charsetType = acymailing_get('type.charset'); $this->assignRef('charset', $charsetType); $lists = $listClass->getLists(); $this->assignRef('lists', $lists); $this->assignRef('fields', $fields); $this->assignRef('selectedfields', $selectedFields); $this->assignRef('selectedlists', $selectedLists); $this->assignRef('config', $config); $whereSubscribers = ''; if (JRequest::getInt('sessionvalues') and !empty($_SESSION['acymailing']['exportusers'])) { $i = 1; $subids = array(); foreach ($_SESSION['acymailing']['exportusers'] as $subid) { $subids[] = (int) $subid; $i++; if ($i > 10) { break; } } $whereSubscribers = implode(',', $subids); } if (JRequest::getInt('sessionquery')) { $currentSession = JFactory::getSession(); $exportQuery = $currentSession->get('acyexportquery'); if (!empty($exportQuery)) { $whereSubscribers = $exportQuery; } } if (!empty($whereSubscribers)) { $db->setQuery('SELECT `name`,`email` FROM `#__acymailing_subscriber` WHERE `subid` IN (' . $whereSubscribers . ') LIMIT 10'); $users = $db->loadObjectList(); $this->assignRef('users', $users); } }
function acymailingtagcb_show() { ?> <script language="javascript" type="text/javascript"> function applyTag(tagname){ var string = '{cbtag:'+tagname; for(var i=0; i < document.adminForm.typeinfo.length; i++){ if (document.adminForm.typeinfo[i].checked){ string += '|info:'+document.adminForm.typeinfo[i].value; } } string += '}'; setTag(string); insertTag(); } </script> <?php $typeinfo = array(); $typeinfo[] = JHTML::_('select.option', "receiver", JText::_('RECEIVER_INFORMATION')); $typeinfo[] = JHTML::_('select.option', "sender", JText::_('SENDER_INFORMATIONS')); echo JHTML::_('acyselect.radiolist', $typeinfo, 'typeinfo', '', 'value', 'text', 'receiver'); $text = '<table class="adminlist table table-striped table-hover" cellpadding="1">'; $db = JFactory::getDBO(); $fields = acymailing_getColumns('#__comprofiler'); $db->setQuery('SELECT name,type FROM #__comprofiler_fields'); $fieldType = $db->loadObjectList('name'); $k = 0; $text .= '<tr style="cursor:pointer" class="row1" onclick="applyTag(\'thumb\');" ><td class="acytdcheckbox"></td><td>Thumb Avatar</td></tr>'; foreach ($fields as $fieldname => $oneField) { $type = ''; if (strpos(strtolower($oneField), 'date') !== false) { $type = '|type:date'; } if (!empty($fieldType[$fieldname]) and $fieldType[$fieldname]->type == 'image') { $type = '|type:image'; } $text .= '<tr style="cursor:pointer" class="row' . $k . '" onclick="applyTag(\'' . $fieldname . $type . '\');" ><td class="acytdcheckbox"></td><td>' . $fieldname . '</td></tr>'; $k = 1 - $k; } $db->setQuery("SELECT * FROM #__comprofiler_fields WHERE tablecolumns = '' AND published = 1"); $otherFields = $db->loadObjectList(); foreach ($otherFields as $oneField) { $text .= '<tr style="cursor:pointer" class="row' . $k . '" onclick="applyTag(\'cbapi_' . $oneField->name . '\');" ><td class="acytdcheckbox"></td><td>' . $oneField->name . '</td></tr>'; $k = 1 - $k; } $text .= '</table>'; echo $text; }
echo $this->escape($this->config->get('zoho_cv')); ?> "> </td> </tr> </table> </fieldset> <fieldset class="adminform"> <legend><?php echo JText::_('FIELD'); ?> </legend> <?php $db = JFactory::getDBO(); $subfields = acymailing_getColumns('#__acymailing_subscriber'); $acyfields = array(); $acyfields[] = JHTML::_('select.option', '', ' - - - '); if (!empty($subfields)) { foreach ($subfields as $oneField => $typefield) { if (in_array($oneField, array('subid', 'confirmed', 'enabled', 'key', 'userid', 'accept', 'html', 'created', 'zohoid', 'zoholist', 'email'))) { continue; } $acyfields[] = JHTML::_('select.option', $oneField, $oneField); } } ?> <table class="admintable table" cellspacing="1"> <?php echo '<tr><td class="key">' . JText::_('ACY_LOADZOHOFIELDS') . '</td><td>'; if (!ACYMAILING_J30) {
} $fieldAssignment = array(); $fieldAssignment[] = JHTML::_('select.option', "0", '- - -'); $fieldAssignment[] = JHTML::_('select.option', "1", JText::_('ACY_IGNORE')); if (acymailing_isAllowed($this->config->get('acl_extra_fields_import', 'all'))) { $createField = JHTML::_('select.option', "2", JText::_('ACY_CREATE_FIELD')); if (!acymailing_level(3)) { $createField->disable = true; $createField->text .= ' (' . JText::_('ONLY_FROM_ENTERPRISE') . ')'; } $fieldAssignment[] = $createField; } $separator = JHTML::_('select.option', "3", '-------------------------------------'); $separator->disable = true; $fieldAssignment[] = $separator; $fields = array_keys(acymailing_getColumns('#__acymailing_subscriber')); $fields[] = 'listids'; $fields[] = 'listname'; foreach ($fields as $oneField) { $fieldAssignment[] = JHTML::_('select.option', $oneField, $oneField); } $fields[] = '1'; echo '<tr class="row0"><td align="center" valign="top"><strong>' . acymailing_tooltip(JText::_('ACY_ASSIGN_COLUMNS_DESC'), null, null, JText::_('ACY_ASSIGN_COLUMNS')) . '</strong>' . ($nbColumns > 5 ? '<br/><a style="text-decoration:none;" href="#" onclick="ignoreAllOthers();">' . JText::_('ACY_IGNORE_UNASSIGNED') . '</a>' : '') . '</td>'; $alreadyFound = array(); foreach ($columnNames as $key => &$oneColumn) { $oneColumn = strtolower(trim($oneColumn, '\'" ')); $customValue = ''; $default = JRequest::getCmd('fieldAssignment' . $key); if (empty($default) && $default !== 0) { $default = in_array($oneColumn, $fields) ? $oneColumn : '0'; if (!$default && !empty($firstValueLine)) {
function onAcyDisplayFilters(&$type, $context = "massactions") { if ($this->params->get('displayfilter_' . $context, true) == false) { return; } $db = JFactory::getDBO(); $fields = acymailing_getColumns('#__users'); if (empty($fields)) { return; } $type['joomlafield'] = JText::_('JOOMLA_FIELD'); $type['joomlagroup'] = JText::_('ACY_GROUP'); $field = array(); foreach ($fields as $oneField => $fieldType) { $field[] = JHTML::_('select.option', $oneField, $oneField); } if (ACYMAILING_J16) { $db->setQuery('SELECT DISTINCT `profile_key` FROM `#__user_profiles`'); $extraFields = $db->loadObjectList(); if (!empty($extraFields)) { foreach ($extraFields as $oneField) { $field[] = JHTML::_('select.option', 'customfield_' . $oneField->profile_key, $oneField->profile_key); } } } $operators = acymailing_get('type.operators'); $operators->extra = 'onchange="countresults(__num__)"'; $return = '<div id="filter__num__joomlafield">' . JHTML::_('select.genericlist', $field, "filter[__num__][joomlafield][map]", 'class="inputbox" size="1" onchange="countresults(__num__)"', 'value', 'text'); $return .= ' ' . $operators->display("filter[__num__][joomlafield][operator]") . ' <input onchange="countresults(__num__)" class="inputbox" type="text" name="filter[__num__][joomlafield][value]" style="width:200px" value=""></div>'; if (!ACYMAILING_J16) { $acl = JFactory::getACL(); $groups = $acl->get_group_children_tree(null, 'USERS', false); } else { $db = JFactory::getDBO(); $db->setQuery('SELECT a.*, a.title as text, a.id as value FROM #__usergroups AS a ORDER BY a.lft ASC'); $groups = $db->loadObjectList('id'); foreach ($groups as $id => $group) { if (isset($groups[$group->parent_id])) { $groups[$id]->level = intval(@$groups[$group->parent_id]->level) + 1; $groups[$id]->text = str_repeat('- - ', $groups[$id]->level) . $groups[$id]->text; } } } $inoperator = acymailing_get('type.operatorsin'); $inoperator->js = 'onchange="countresults(__num__)"'; $return .= '<div id="filter__num__joomlagroup">' . $inoperator->display("filter[__num__][joomlagroup][type]") . ' ' . JHTML::_('select.genericlist', $groups, "filter[__num__][joomlagroup][group]", 'class="inputbox" size="1" onchange="countresults(__num__)"', 'value', 'text') . '</div>'; return $return; }
function onAcyDisplayActions(&$type) { $type['acymailingfield'] = JText::_('BOUNCE_ACTION'); $status = array(); $status[] = JHTML::_('select.option', 'confirm', JText::_('CONFIRM_USERS')); $status[] = JHTML::_('select.option', 'unconfirm', JText::_('ACY_ACTION_UNCONFIRM')); $status[] = JHTML::_('select.option', 'enable', JText::_('ENABLE_USERS')); $status[] = JHTML::_('select.option', 'block', JText::_('BLOCK_USERS')); $status[] = JHTML::_('select.option', 'delete', JText::_('DELETE_USERS')); $content = '<div id="action__num__acymailingfield">' . JHTML::_('select.genericlist', $status, "action[__num__][acymailingfield][action]", 'class="inputbox" size="1"', 'value', 'text') . '</div>'; if (!acymailing_level(3)) { return $content; } $db = JFactory::getDBO(); $fields = acymailing_getColumns('#__acymailing_subscriber'); if (empty($fields)) { return $content; } $field = array(); $field[] = JHTML::_('select.option', 0, '- - -'); foreach ($fields as $oneField => $fieldType) { if (in_array($oneField, array('name', 'email', 'subid', 'created', 'ip'))) { continue; } $field[] = JHTML::_('select.option', $oneField, $oneField); } $jsOnChange = "if(document.getElementById('action__num__acymailingfieldvalvalue')!= undefined){ currentVal=document.getElementById('action__num__acymailingfieldvalvalue').value;} else{currentVal='';}\n\t\t\tdisplayCondFilter('displayFieldPossibleValues', 'toChangeAction__num__',__num__,'map='+document.getElementById('action__num__acymailingfieldvalmap').value+'&value='+currentVal); "; $content .= '<div id="action__num__acymailingfieldval">' . JHTML::_('select.genericlist', $field, "action[__num__][acymailingfieldval][map]", 'onchange="' . $jsOnChange . '" class="inputbox" size="1"', 'value', 'text'); $content .= ' = <span id="toChangeAction__num__"><input class="inputbox" type="text" id="action__num__acymailingfieldvalvalue" name="action[__num__][acymailingfieldval][value]" style="width:200px" value=""></span></div>'; $type['acymailingfieldval'] = JText::_('SET_SUBSCRIBER_VALUE'); return $content; }
function onAcyDisplayActions(&$type) { $type['acymailingfield'] = JText::_('BOUNCE_ACTION'); $status = array(); $status[] = JHTML::_('select.option', 'confirm', JText::_('CONFIRM_USERS')); $status[] = JHTML::_('select.option', 'enable', JText::_('ENABLE_USERS')); $status[] = JHTML::_('select.option', 'block', JText::_('BLOCK_USERS')); $status[] = JHTML::_('select.option', 'delete', JText::_('DELETE_USERS')); $content = ''; if (acymailing_level(3)) { $db = JFactory::getDBO(); $fields = acymailing_getColumns('#__acymailing_subscriber'); if (empty($fields)) { return; } $field = array(); foreach ($fields as $oneField => $fieldType) { if (in_array($oneField, array('name', 'email', 'confirmed', 'subid', 'created', 'ip'))) { continue; } $field[] = JHTML::_('select.option', $oneField, $oneField); } $content .= '<div id="action__num__acymailingfieldval">' . JHTML::_('select.genericlist', $field, "action[__num__][acymailingfieldval][map]", 'class="inputbox" size="1"', 'value', 'text'); $content .= ' = <input class="inputbox" type="text" name="action[__num__][acymailingfieldval][value]" style="width:200px" value=""></div>'; $type['acymailingfieldval'] = JText::_('SET_SUBSCRIBER_VALUE'); } $content .= '<div id="action__num__acymailingfield">' . JHTML::_('select.genericlist', $status, "action[__num__][acymailingfield][action]", 'class="inputbox" size="1"', 'value', 'text') . '</div>'; return $content; }
function export() { $listClass = acymailing_get('class.list'); $db = JFactory::getDBO(); $fields = acymailing_getColumns('#__acymailing_subscriber'); $fieldsList = array(); $fieldsList['listid'] = 'smallint unsigned'; $fieldsList['listname'] = 'varchar'; $config = acymailing_config(); $selectedFields = explode(',', $config->get('export_fields', 'email,name')); $selectedLists = explode(',', $config->get('export_lists')); $selectedFilters = explode(',', $config->get('export_filters', 'subscribed')); $app = JFactory::getApplication(); if ($app->isAdmin()) { acymailing_setTitle(JText::_('ACY_EXPORT'), 'acyexport', 'data&task=export'); $bar = JToolBar::getInstance('toolbar'); JToolBarHelper::custom('doexport', 'acyexport', '', JText::_('ACY_EXPORT'), false); $bar->appendButton('Link', 'cancel', JText::_('ACY_CANCEL'), acymailing_completeLink('subscriber')); JToolBarHelper::divider(); $bar->appendButton('Pophelp', 'data-export'); } $charsetType = acymailing_get('type.charset'); $this->assignRef('charset', $charsetType); if ($app->isAdmin()) { $lists = $listClass->getLists(); } else { $lists = $listClass->getFrontendLists(); } $this->assignRef('lists', $lists); $this->assignRef('fields', $fields); $this->assignRef('fieldsList', $fieldsList); $this->assignRef('selectedfields', $selectedFields); $this->assignRef('selectedlists', $selectedLists); $this->assignRef('selectedFilters', $selectedFilters); $this->assignRef('config', $config); $whereSubscribers = ''; if (JRequest::getInt('sessionvalues')) { if (!empty($_SESSION['acymailing']['exportusers'])) { $i = 1; $subids = array(); foreach ($_SESSION['acymailing']['exportusers'] as $subid) { $subids[] = (int) $subid; $i++; if ($i > 10) { break; } } if (!empty($subids)) { $db->setQuery('SELECT `name`,`email` FROM `#__acymailing_subscriber` WHERE `subid` IN (' . implode(',', $subids) . ') LIMIT 10'); $users = $db->loadObjectList(); $this->assignRef('users', $users); } } elseif (!empty($_SESSION['acymailing']['exportlist'])) { $filterList = $_SESSION['acymailing']['exportlist']; $this->assignRef('exportlist', $filterList); } } if (JRequest::getInt('sessionquery')) { $currentSession = JFactory::getSession(); $exportQuery = $currentSession->get('acyexportquery'); if (!empty($exportQuery)) { $db->setQuery('SELECT s.`name`,s.`email` ' . $exportQuery . ' LIMIT 10'); $users = $db->loadObjectList(); $this->assignRef('users', $users); if (strpos($exportQuery, 'userstats')) { $otherFields = array('userstats.senddate', 'userstats.open', 'userstats.opendate', 'userstats.bounce', 'userstats.ip', 'userstats.html', 'userstats.fail', 'userstats.sent'); $this->assignRef('otherfields', $otherFields); } if (strpos($exportQuery, 'urlclick')) { $otherFields = array('url.name', 'url.url', 'urlclick.date', 'urlclick.ip', 'urlclick.click'); $this->assignRef('otherfields', $otherFields); } if (strpos($exportQuery, 'history')) { $otherFields = array('hist.data', 'hist.date'); $this->assignRef('otherfields', $otherFields); } } } if (acymailing_level(3)) { $geolocFields = acymailing_getColumns('#__acymailing_geolocation'); $this->assign('geolocfields', $geolocFields); } }
function zohocrm($action = '') { $app = JFactory::getApplication(); $db = JFactory::getDBO(); $zohoHelper = acymailing_get('helper.zoho'); $listClass = acymailing_get('class.list'); $subscriberClass = acymailing_get('class.subscriber'); $tableInfos = array_keys(acymailing_getColumns('#__acymailing_subscriber')); $config =& acymailing_config(); if (!in_array('zohoid', $tableInfos)) { $query = 'ALTER TABLE #__acymailing_subscriber ADD COLUMN zohoid VARCHAR(255)'; $db->setQuery($query); $db->query(); } if (!in_array('zoholist', $tableInfos)) { $query = 'ALTER TABLE #__acymailing_subscriber ADD COLUMN zoholist CHAR(1)'; $db->setQuery($query); $db->query(); } if ($action == 'update') { $lists = unserialize($config->get('zoho_lists')); $zohoHelper->authtoken = $authtoken = $config->get('zoho_apikey'); $fields = unserialize($config->get('zoho_fields')); $confirmedUsers = $config->get('zoho_confirmed'); $delete = $config->get('zoho_delete'); $importlists = array(); } else { $lists = JRequest::getVar('zoho_lists'); $fields = JRequest::getVar('zoho_fields'); $zohoHelper->authtoken = $authtoken = JRequest::getVar('zoho_apikey'); $importlists = JRequest::getVar('importlists'); $overwrite = JRequest::getVar('zoho_overwrite'); $confirmedUsers = JRequest::getVar('zoho_confirmed'); $delete = JRequest::getVar('zoho_delete'); $newConfig = new stdClass(); $newConfig->zoho_fields = serialize($fields); $newConfig->zoho_lists = serialize($lists); $newConfig->zoho_apikey = $zohoHelper->authtoken; $newConfig->zoho_overwrite = $overwrite; $newConfig->zoho_confirmed = $confirmedUsers; $newConfig->zoho_delete = $delete; $config->save($newConfig); } if ($config->get('zoho_overwrite', false)) { $this->overwrite = true; } if (empty($authtoken)) { $app->enqueueMessage('Pleaser enter a valid API key', 'notice'); return false; } $done = false; foreach ($lists as $list => $listid) { if (empty($listid)) { continue; } $done = true; $this->allSubid = array(); $res = $zohoHelper->sendInfo($list); if (!empty($zohoHelper->conn)) { $zohoHelper->close(); } if ($res != false) { $zohoUsers = $zohoHelper->parseXML($res, $list, $fields, $confirmedUsers); } if (empty($zohoUsers)) { continue; } $this->_insertUsers($zohoUsers); $affectedUsers = $zohoHelper->subscribe($listid, $list); if (empty($this->subscribedUsers[$listid])) { $this->subscribedUsers[$listid] = $listClass->get($listid); } $this->subscribedUsers[$listid]->nbusers += $affectedUsers; foreach ($importlists as $importlistid => $selected) { if ($selected == '1') { $importUserInLists[] = $importlistid; } } $this->_subscribeUsers(); if (JRequest::getInt('zoho_delete') == '1') { $zohoHelper->deleteAddress($this->allSubid, $list); } else { $query = 'SELECT DISTINCT b.subid FROM #__acymailing_subscriber AS a JOIN #__acymailing_subscriber AS b ON a.zohoid = b.zohoid WHERE a.zohoid IS NOT NULL AND b.subid < a.subid'; $db->setQuery($query); $result = acymailing_loadResultArray($db); $subscriberClass->delete($result); } } $this->_displaySubscribedResult(); if ($done == false) { $app->enqueueMessage('Please select at least one list to import your Zoho users', 'notice'); } if (!empty($zohoHelper->error)) { $app->enqueueMessage(JText::sprintf($zohoHelper->error), 'notice'); } }
function onAcyProcessAction_acymailingfieldval($cquery, $action, $num) { $value = is_array($action['value']) ? implode(',', $action['value']) : $action['value']; $replace = array('{year}', '{month}', '{weekday}', '{day}'); $replaceBy = array(date('Y'), date('m'), date('N'), date('d')); $value = str_replace($replace, $replaceBy, $value); if (empty($action['operator'])) { $action['operator'] = '='; } preg_match_all('#(?:{|%7B)field:(.*)(?:}|%7D)#Ui', $value, $tags); $fields = array_keys(acymailing_getColumns('#__acymailing_subscriber')); if (!in_array($action['map'], $fields)) { return 'Unexisting field: ' . $action['map'] . ' | The available fields are: ' . implode(', ', $fields); } if (in_array($action['operator'], array('+', '-'))) { if (empty($tags) || empty($tags[1])) { $value = intval($value); } else { if (count($tags[1]) > 1 || substr($value, 0, 1) != '{' || substr($value, strlen($value) - 1, 1) != '}') { return 'You can\'t use more than one tag for the + and - operators (you also can\'t add or remove a value from the inserted tag for these two operators)'; } if (!in_array($tags[1][0], $fields)) { return 'Unexisting field: ' . $tags[1][0] . ' | The available fields are: ' . implode(', ', $fields); } $value = 'sub.`' . acymailing_secureField($tags[1][0]) . '`'; } } else { $value = $cquery->db->Quote($value); if (!empty($tags)) { foreach ($tags[1] as $i => $oneField) { if (!in_array($oneField, $fields)) { return 'Unexisting field: ' . $oneField . ' | The available fields are: ' . implode(', ', $fields); } $value = str_replace($tags[0][$i], "', sub.`" . acymailing_secureField($oneField) . "`, '", $value); } $value = "CONCAT(" . $value . ")"; } } $query = 'UPDATE #__acymailing_subscriber AS sub'; if (!empty($cquery->join)) { $query .= ' JOIN ' . implode(' JOIN ', $cquery->join); } if (!empty($cquery->leftjoin)) { $query .= ' LEFT JOIN ' . implode(' LEFT JOIN ', $cquery->leftjoin); } if ($action['operator'] == '=') { $newValue = $value; } elseif (in_array($action['operator'], array('+', '-'))) { $newValue = "sub.`" . acymailing_secureField($action['map']) . "` " . $action['operator'] . " " . $value; } elseif ($action['operator'] == 'addend') { $newValue = "CONCAT(sub.`" . acymailing_secureField($action['map']) . "`, " . $value . ")"; } elseif ($action['operator'] == 'addbegin') { $newValue = "CONCAT(" . $value . ", sub.`" . acymailing_secureField($action['map']) . "`)"; } else { return 'Non existing operator: ' . $action['operator']; } $query .= " SET sub.`" . acymailing_secureField($action['map']) . "` = " . $newValue; if (!empty($cquery->where)) { $query .= ' WHERE (' . implode(') AND (', $cquery->where) . ')'; } $cquery->db->setQuery($query); $cquery->db->query(); $nbAffected = $cquery->db->getAffectedRows(); return JText::sprintf('NB_MODIFIED', $nbAffected); }
function zohocrm($action = '') { $db = JFactory::getDBO(); $zohoHelper = acymailing_get('helper.zoho'); $subscriberClass = acymailing_get('class.subscriber'); $tableInfos = array_keys(acymailing_getColumns('#__acymailing_subscriber')); $config =& acymailing_config(); if (!in_array('zohoid', $tableInfos)) { $query = 'ALTER TABLE #__acymailing_subscriber ADD COLUMN zohoid VARCHAR(255)'; $db->setQuery($query); $db->query(); $qery = 'ALTER TABLE `#__acymailing_subscriber` ADD INDEX(`zohoid`)'; $db->setQuery($query); $db->query(); } if (!in_array('zoholist', $tableInfos)) { $query = 'ALTER TABLE #__acymailing_subscriber ADD COLUMN zoholist CHAR(1)'; $db->setQuery($query); $db->query(); } if ($action == 'update') { $list = $config->get('zoho_list'); $zohoHelper->authtoken = $authtoken = $config->get('zoho_apikey'); $zohoHelper->customView = $config->get('zoho_cv'); $fields = unserialize($config->get('zoho_fields')); $confirmedUsers = $config->get('zoho_confirmed'); $delete = $config->get('zoho_delete'); $generateName = $config->get('zoho_generate_name', 'fromemail'); $importnew = $config->get('zoho_importnew', 0); } else { $list = JRequest::getVar('zoho_list'); $fields = JRequest::getVar('zoho_fields'); $zohoHelper->authtoken = $authtoken = JRequest::getVar('zoho_apikey'); $zohoHelper->customView = JRequest::getVar('zoho_cv'); $overwrite = JRequest::getVar('zoho_overwrite'); $confirmedUsers = JRequest::getVar('zoho_confirmed'); $delete = JRequest::getVar('zoho_delete'); $newConfig = new stdClass(); $newConfig->zoho_fields = serialize($fields); $newConfig->zoho_list = $list; $newConfig->zoho_apikey = $zohoHelper->authtoken; $newConfig->zoho_cv = $zohoHelper->customView; $newConfig->zoho_overwrite = $overwrite; $newConfig->zoho_confirmed = $confirmedUsers; $newConfig->zoho_delete = $delete; $newConfig->zoho_generate_name = $generateName = JRequest::getVar('zoho_generate_name', 'fromemail'); $newConfig->zoho_importnew = $importnew = JRequest::getVar('zoho_importnew', 0); $newConfig->zoho_importdate = date('Y-m-d H:i:s'); $config->save($newConfig); } if ($config->get('zoho_overwrite', false)) { $this->overwrite = true; } if (empty($authtoken)) { acymailing_enqueueMessage('Pleaser enter a valid API key', 'notice'); return false; } $this->allSubid = array(); $indexDec = 200; $res = $zohoHelper->sendInfo($list); while (!empty($res)) { $zohoUsers = $zohoHelper->parseXML($res, $list, $fields, $confirmedUsers, $generateName); if (empty($zohoUsers) && $zohoHelper->nbUserRead == 0) { break; } $this->_insertUsers($zohoUsers); if ($zohoHelper->nbUserRead < 200) { break; } // No further iteration needed $zohoUsers = array(); $zohoHelper->fromIndex = $zohoHelper->fromIndex + $indexDec; $zohoHelper->toIndex = $zohoHelper->toIndex + $indexDec; if (!empty($zohoHelper->conn)) { $zohoHelper->close(); } $res = $zohoHelper->sendInfo($list); } $this->_subscribeUsers(); if (JRequest::getInt('zoho_delete') == '1') { $zohoHelper->deleteAddress($this->allSubid, $list); } else { $query = 'SELECT DISTINCT b.subid FROM #__acymailing_subscriber AS a JOIN #__acymailing_subscriber AS b ON a.zohoid = b.zohoid WHERE a.zohoid IS NOT NULL AND b.subid < a.subid'; $db->setQuery($query); $result = acymailing_loadResultArray($db); $subscriberClass->delete($result); } if (!empty($zohoHelper->conn)) { $zohoHelper->close(); } $this->_displaySubscribedResult(); if (!empty($zohoHelper->error)) { acymailing_enqueueMessage(JText::sprintf($zohoHelper->error), 'notice'); } }
function doexport() { if (!$this->isAllowed('subscriber', 'export')) { return; } JRequest::checkToken() or die('Invalid Token'); acymailing_increasePerf(); $filtersExport = JRequest::getVar('exportfilter', array(), '', 'array'); $listsToExport = JRequest::getVar('exportlists'); $fieldsToExport = JRequest::getVar('exportdata'); $tableFields = acymailing_getColumns('#__acymailing_subscriber'); $notAllowedFields = array_diff_key($fieldsToExport, $tableFields); if (!empty($notAllowedFields)) { die('The field ' . implode(', ', array_keys($notAllowedFields)) . ' is not in the allowed fields: ' . implode(', ', array_keys($tableFields))); } $fieldsToExportList = JRequest::getVar('exportdatalist'); $notAllowedFields = array_diff(array_keys($fieldsToExportList), array('listid', 'listname')); if (!empty($notAllowedFields)) { die('The field ' . implode(', ', $notAllowedFields) . ' is not in the allowed fields: listid, listname'); } $fieldsToExportOthers = JRequest::getVar('exportdataother'); $fieldsToExportGeoloc = JRequest::getVar('exportdatageoloc'); $tableFields = acymailing_getColumns('#__acymailing_geolocation'); $notAllowedFields = array_diff_key($fieldsToExportGeoloc, $tableFields); if (!empty($notAllowedFields)) { die('The field ' . implode(', ', array_keys($notAllowedFields)) . ' is not in the allowed fields: ' . implode(', ', array_keys($tableFields))); } $inseparator = JRequest::getString('exportseparator'); $inseparator = str_replace(array('semicolon', 'colon', 'comma'), array(';', ',', ','), $inseparator); $exportFormat = JRequest::getString('exportformat'); if (!in_array($inseparator, array(',', ';'))) { $inseparator = ';'; } $exportUnsubLists = array(); $exportWaitLists = array(); $exportLists = array(); if (!empty($filtersExport['subscribed'])) { foreach ($listsToExport as $listid => $status) { if ($status == -1) { $exportUnsubLists[] = (int) $listid; } elseif ($status == 2) { $exportWaitLists[] = (int) $listid; } elseif (!empty($status)) { $exportLists[] = (int) $listid; } } } $app = JFactory::getApplication(); if (!$app->isAdmin() && (empty($filtersExport['subscribed']) || empty($exportLists) && empty($exportUnsubLists) && empty($exportWaitLists))) { $listClass = acymailing_get('class.list'); $frontLists = $listClass->getFrontendLists(); foreach ($frontLists as $frontList) { $exportLists[] = (int) $frontList->listid; } } $exportFields = array(); $exportFieldsList = array(); $exportFieldsOthers = array(); $exportFieldsGeoloc = array(); foreach ($fieldsToExport as $fieldName => $checked) { if (!empty($checked)) { $exportFields[] = acymailing_secureField($fieldName); } } foreach ($fieldsToExportList as $fieldName => $checked) { if (!empty($checked)) { $exportFieldsList[] = acymailing_secureField($fieldName); } } if (!empty($fieldsToExportOthers)) { foreach ($fieldsToExportOthers as $fieldName => $checked) { if (!empty($checked)) { $exportFieldsOthers[] = acymailing_secureField($fieldName); } } } if (!empty($fieldsToExportGeoloc)) { foreach ($fieldsToExportGeoloc as $fieldName => $checked) { if (!empty($checked)) { $exportFieldsGeoloc[] = acymailing_secureField($fieldName); } } } $selectFields = 's.`' . implode('`, s.`', $exportFields) . '`'; $config = acymailing_config(); $newConfig = new stdClass(); $newConfig->export_fields = implode(',', array_merge($exportFields, $exportFieldsOthers, $exportFieldsList, $exportFieldsGeoloc)); $newConfig->export_lists = implode(',', $exportLists); $newConfig->export_separator = JRequest::getString('exportseparator'); $newConfig->export_format = $exportFormat; $filterActive = array(); foreach ($filtersExport as $filterKey => $value) { if ($value == 1) { $filterActive[] = $filterKey; } } $newConfig->export_filters = implode(',', $filterActive); $config->save($newConfig); $where = array(); if (empty($exportLists) && empty($exportUnsubLists) && empty($exportWaitLists)) { $querySelect = 'SELECT s.`subid`, ' . $selectFields . ' FROM ' . acymailing_table('subscriber') . ' as s'; } else { $querySelect = 'SELECT DISTINCT s.`subid`, ' . $selectFields . ' FROM ' . acymailing_table('listsub') . ' as a JOIN ' . acymailing_table('subscriber') . ' as s on a.subid = s.subid'; if (!empty($exportLists)) { $conditions[] = 'a.status = 1 AND a.listid IN (' . implode(',', $exportLists) . ')'; } if (!empty($exportUnsubLists)) { $conditions[] = 'a.status = -1 AND a.listid IN (' . implode(',', $exportUnsubLists) . ')'; } if (!empty($exportWaitLists)) { $conditions[] = 'a.status = 2 AND a.listid IN (' . implode(',', $exportWaitLists) . ')'; } if (count($conditions) == 1) { $where[] = $conditions[0]; } else { $where[] = '(' . implode(') OR (', $conditions) . ')'; } } if (!empty($filtersExport['confirmed'])) { $where[] = 's.confirmed = 1'; } if (!empty($filtersExport['registered'])) { $where[] = 's.userid > 0'; } if (!empty($filtersExport['enabled'])) { $where[] = 's.enabled = 1'; } if (JRequest::getInt('sessionvalues') and !empty($_SESSION['acymailing']['exportusers'])) { $where[] = 's.subid IN (' . implode(',', $_SESSION['acymailing']['exportusers']) . ')'; } if (JRequest::getInt('fieldfilters')) { foreach ($_SESSION['acymailing']['fieldfilter'] as $field => $value) { $where[] = 's.' . acymailing_secureField($field) . ' LIKE "%' . acymailing_getEscaped($value, true) . '%"'; } } $query = $querySelect; if (!empty($where)) { $query .= ' WHERE (' . implode(') AND (', $where) . ')'; } if (JRequest::getInt('sessionquery')) { $currentSession = JFactory::getSession(); $selectOthers = ''; if (!empty($exportFieldsOthers)) { foreach ($exportFieldsOthers as $oneField) { $selectOthers .= ' , ' . $oneField . ' AS ' . str_replace('.', '_', $oneField); } } $query = 'SELECT DISTINCT s.`subid`, ' . $selectFields . $selectOthers . ' ' . $currentSession->get('acyexportquery'); } $query .= ' ORDER BY s.subid'; $db = JFactory::getDBO(); $encodingClass = acymailing_get('helper.encoding'); $exportHelper = acymailing_get('helper.export'); $fileName = 'export_' . date('Y-m-d'); if (!empty($exportLists)) { $fileName = ''; $db->setQuery('SELECT name FROM #__acymailing_list WHERE listid IN (' . implode(',', $exportLists) . ')'); $allExportedLists = $db->loadObjectList(); foreach ($allExportedLists as $oneList) { $fileName .= '__' . $oneList->name; } $fileName = trim($fileName, '__'); } $exportHelper->addHeaders($fileName); acymailing_displayErrors(); $eol = "\r\n"; $before = '"'; $separator = '"' . $inseparator . '"'; $after = '"'; $allFields = array_merge($exportFields, $exportFieldsOthers); if (!empty($exportFieldsList)) { $allFields = array_merge($allFields, $exportFieldsList); $selectFields = 'l.`' . implode('`, l.`', $exportFieldsList) . '`'; $selectFields = str_replace('listname', 'name', $selectFields); } if (!empty($exportFieldsGeoloc)) { $allFields = array_merge($allFields, $exportFieldsGeoloc); } $titleLine = $before . implode($separator, $allFields) . $after . $eol; $titleLine = str_replace('listid', 'listids', $titleLine); echo $titleLine; if (acymailing_bytes(ini_get('memory_limit')) > 150000000) { $nbExport = 50000; } elseif (acymailing_bytes(ini_get('memory_limit')) > 80000000) { $nbExport = 15000; } else { $nbExport = 5000; } if (!empty($exportFieldsList)) { $nbExport = 500; } $valDep = 0; $dateFields = array('created', 'confirmed_date', 'lastopen_date', 'lastclick_date', 'lastsent_date', 'userstats_opendate', 'userstats_senddate', 'urlclick_date', 'hist_date'); do { $db->setQuery($query . ' LIMIT ' . $valDep . ', ' . $nbExport); $valDep += $nbExport; $allData = $db->loadAssocList('subid'); if ($allData === false) { echo $eol . $eol . 'Error : ' . $db->getErrorMsg(); } if (empty($allData)) { break; } foreach ($allData as $subid => &$oneUser) { if (!in_array('subid', $exportFields)) { unset($allData[$subid]['subid']); } foreach ($dateFields as &$fieldName) { if (isset($allData[$subid][$fieldName])) { $allData[$subid][$fieldName] = acymailing_getDate($allData[$subid][$fieldName], '%Y-%m-%d %H:%M:%S'); } } } if (!empty($exportFieldsList) && !empty($allData)) { $queryList = 'SELECT ' . $selectFields . ', s.subid FROM #__acymailing_subscriber AS s LEFT JOIN #__acymailing_listsub AS ls ON ls.subid = s.subid AND ls.status = 1 '; if (!empty($exportLists)) { $queryList .= 'AND ls.listid IN (' . implode(',', $exportLists) . ') '; } $queryList .= 'LEFT JOIN #__acymailing_list AS l ON ls.listid = l.listid WHERE s.subid IN (' . implode(',', array_keys($allData)) . ')'; $db->setQuery($queryList); $resList = $db->loadObjectList(); foreach ($resList as &$listsub) { if (in_array('listid', $exportFieldsList)) { $allData[$listsub->subid]['listid'] = empty($allData[$listsub->subid]['listid']) ? $listsub->listid : $allData[$listsub->subid]['listid'] . ' - ' . $listsub->listid; } if (in_array('listname', $exportFieldsList)) { $allData[$listsub->subid]['listname'] = empty($allData[$listsub->subid]['listname']) ? $listsub->name : $allData[$listsub->subid]['listname'] . ' - ' . $listsub->name; } } unset($resList); } if (!empty($exportFieldsGeoloc) && !empty($allData)) { $orderGeoloc = JRequest::getCmd('exportgeolocorder'); if (strtolower($orderGeoloc) !== 'desc') { $orderGeoloc = 'asc'; } $db->setQuery('SELECT geolocation_subid,' . implode(', ', $exportFieldsGeoloc) . ' FROM (SELECT * FROM #__acymailing_geolocation WHERE geolocation_subid IN (' . implode(',', array_keys($allData)) . ') ORDER BY geolocation_id ' . $orderGeoloc . ') as geoloc GROUP BY geolocation_subid'); $resGeol = $db->loadObjectList('geolocation_subid'); foreach ($allData as $subid => $oneSubscriber) { foreach ($exportFieldsGeoloc as $geolField) { $value = empty($resGeol[$subid]) ? '' : $resGeol[$subid]->{$geolField}; $allData[$subid][$geolField] = $geolField == 'geolocation_created' ? acymailing_getDate($value, '%Y-%m-%d %H:%M:%S') : $value; } } unset($resGeol); } foreach ($allData as $subid => &$oneUser) { $dataexport = implode($separator, $oneUser); echo $before . $encodingClass->change($dataexport, 'UTF-8', $exportFormat) . $after . $eol; } unset($allData); } while (true); exit; }
function onAcyDisplayFilters(&$type, $context = 'massactions') { if (!$this->loadAcymailing()) { return ''; } if ($this->params->get('displayfilter_' . $context, true) == false) { return ''; } $this->db->setQuery("SELECT `product_id` as value, CONCAT(`product_name`,' ( ',`product_code`,' ) ') as text FROM " . acymailing_table('hikashop_product', false) . " ORDER BY `product_code` ASC LIMIT 1000"); $allProducts = $this->db->loadObjectList(); if (!empty($allProducts)) { $selectOne = new stdClass(); $selectOne->value = 0; $selectOne->text = JText::_('ACY_ONE_PRODUCT'); array_unshift($allProducts, $selectOne); } $hikaBuy = array(); $hikaBuy[] = JHTML::_('select.option', '1', JText::_('ACY_BOUGHT')); $hikaBuy[] = JHTML::_('select.option', '0', JText::_('ACY_DIDNOTBOUGHT')); $hikaGroupsParams = acymailing_get('type.operatorsin'); $hikaGroupsParams->js = 'onchange="countresults(__num__)"'; $operators = acymailing_get('type.operators'); $operators->extra = 'onchange="countresults(__num__)"'; $fields = acymailing_getColumns('#__hikashop_user'); $hikaFields = array(); if (!empty($fields)) { foreach ($fields as $oneField => $fieldType) { $hikaFields[] = JHTML::_('select.option', $oneField, $oneField); } } $return = ''; $return .= '<div id="filter__num__hikaallorders">'; $return .= $hikaGroupsParams->display("filter[__num__][hikaallorders][type]") . ' '; $category = hikashop_get('type.categorysub'); $category->type = 'status'; $return .= $category->display("filter[__num__][hikaallorders][status]", '', 'size="1" onchange="countresults(__num__)" ', false); $payment = hikashop_get('type.payment'); $payment->extra = 'onchange="countresults(__num__)"'; $return .= $payment->display("filter[__num__][hikaallorders][payment]", '', false); $return .= '<br/> <input onclick="displayDatePicker(this,event)" name="filter[__num__][hikaallorders][cdateinf]" type="text" onchange="countresults(__num__)" /> < ' . JText::_('CREATED_DATE') . ' < <input onclick="displayDatePicker(this,event)" type="text" name="filter[__num__][hikaallorders][cdatesup]" onchange="countresults(__num__)" />'; $return .= '<br/> <input onclick="displayDatePicker(this,event)" name="filter[__num__][hikaallorders][mdateinf]" type="text" onchange="countresults(__num__)" /> < ' . JText::_('MODIFIED_DATE') . ' < <input onclick="displayDatePicker(this,event)" type="text" name="filter[__num__][hikaallorders][mdatesup]" onchange="countresults(__num__)" />'; $return .= '<br/> <input onclick="displayDatePicker(this,event)" name="filter[__num__][hikaallorders][idateinf]" type="text" onchange="countresults(__num__)" /> < ' . JText::_('INVOICE_DATE') . ' < <input onclick="displayDatePicker(this,event)" type="text" name="filter[__num__][hikaallorders][idatesup]" onchange="countresults(__num__)" />'; $return .= '</div>'; $type['hikaallorders'] = 'HikaShop ' . JText::_('ORDERS'); if (!empty($allProducts)) { $dateFilters = array(); $dateFilters[] = JHTML::_('select.option', 'order_created', JText::_('CREATED_DATE')); $dateFilters[] = JHTML::_('select.option', 'order_modified', JText::_('MODIFIED_DATE')); $dateFilters[] = JHTML::_('select.option', 'order_invoice_created', JText::_('INVOICE_DATE')); $return .= '<div id="filter__num__hikaorder">' . JHTML::_('select.genericlist', $hikaBuy, "filter[__num__][hikaorder][type]", 'class="inputbox" size="1" onchange="countresults(__num__)" ', 'value', 'text') . ' '; $return .= JHTML::_('select.genericlist', $allProducts, "filter[__num__][hikaorder][product]", 'class="inputbox" style="max-width:200px" size="1" onchange="countresults(__num__)" ', 'value', 'text'); $this->db->setQuery('SELECT `category_id` AS value, `category_name` AS text FROM ' . acymailing_table('hikashop_category', false) . ' WHERE `category_type` = "product" ORDER BY `category_name` ASC LIMIT 1000'); $allCats = $this->db->loadObjectList(); if (!empty($allCats)) { $selectOne = new stdClass(); $selectOne->value = 0; $selectOne->text = JText::_('ACY_ANY_CATEGORY'); array_unshift($allCats, $selectOne); } $return .= ' ' . JHTML::_('select.genericlist', $allCats, "filter[__num__][hikaorder][cat]", 'class="inputbox" style="max-width:200px" size="1" onchange="countresults(__num__)" ', 'value', 'text'); $return .= '<br/> <input onclick="displayDatePicker(this,event)" type="text" name="filter[__num__][hikaorder][creationdateinf]" onchange="countresults(__num__)" /> < ' . JHTML::_('select.genericlist', $dateFilters, "filter[__num__][hikaorder][datefield]", 'class="inputbox" size="1" onchange="countresults(__num__)" ', 'value', 'text') . ' < <input onclick="displayDatePicker(this,event)" type="text" name="filter[__num__][hikaorder][creationdatesup]" onchange="countresults(__num__)" />'; $return .= '</div>'; $type['hikaorder'] = 'HikaShop ' . JText::_('CUSTOMERS'); } if (!empty($hikaFields)) { $return .= '<div id="filter__num__hikafield">' . JHTML::_('select.genericlist', $hikaFields, "filter[__num__][hikafield][map]", 'class="inputbox" onchange="countresults(__num__)" size="1"', 'value', 'text'); $return .= ' ' . $operators->display("filter[__num__][hikafield][operator]") . ' <input class="inputbox" type="text" name="filter[__num__][hikafield][value]" size="50" value="" onchange="countresults(__num__)" />'; $return .= '</div>'; $type['hikafield'] = 'HikaShop ' . JText::_('FIELD'); } $this->db->setQuery("SELECT `zone_namekey` AS value, CONCAT(`zone_name`,' ( ',`zone_name_english`,' )') AS text FROM " . acymailing_table('hikashop_zone', false) . " WHERE `zone_type` = 'country' ORDER BY `zone_name_english` ASC LIMIT 1000"); $allCountries = $this->db->loadObjectList(); $selectOne = new stdClass(); $selectOne->value = 0; $selectOne->text = JText::_('COUNTRYCAPTION'); array_unshift($allCountries, $selectOne); $jsOnChange = "displayCondFilter('displayStates', 'toChange__num__',__num__,'country='+this.value); "; $return .= '<div id="filter__num__hikaaddress">'; $return .= $hikaGroupsParams->display("filter[__num__][hikaaddress][type]") . ' '; $return .= JHTML::_('select.genericlist', $allCountries, "filter[__num__][hikaaddress][country]", 'class="inputbox" onchange="' . $jsOnChange . 'countresults(__num__)" size="1"', 'value', 'text'); $return .= ' <span id="toChange__num__"></span>'; $return .= '</div>'; $type['hikaaddress'] = 'HikaShop ' . JText::_('ADDRESSCAPTION'); $return .= '<div id="filter__num__hikareminder">'; $val = '<input class="inputbox" type="text" name="filter[__num__][hikareminder][nbdays]" style="width:50px" value="1" onchange="countresults(__num__)" />'; $return .= JText::sprintf('DAYS_AFTER_ORDERING', $val) . '</br>'; $payment = hikashop_get('type.payment'); $payment->extra = 'onchange="countresults(__num__)"'; $return .= $payment->display("filter[__num__][hikareminder][payment]", '', false); $return .= '</div>'; $type['hikareminder'] = 'HikaShop Reminder'; $acyconfig = acymailing_config(); if (version_compare($acyconfig->get('version'), '4.9.4', '<')) { echo 'Please update AcyMailing, the HikaShop plugin may not work properly with this version'; } return $return; }
function saveForm() { $app = JFactory::getApplication(); $field = new stdClass(); $field->fieldid = acymailing_getCID('fieldid'); $formData = JRequest::getVar('data', array(), '', 'array'); foreach ($formData['fields'] as $column => $value) { acymailing_secureField($column); if (is_array($value)) { if (isset($value['day']) || isset($value['month']) || isset($value['year'])) { $value = (empty($value['year']) ? '0000' : intval($value['year'])) . '-' . (empty($value['month']) ? '00' : intval($value['month'])) . '-' . (empty($value['day']) ? '00' : intval($value['day'])); } else { $value = implode(',', $value); } } $field->{$column} = strip_tags($value); } $fieldValues = JRequest::getVar('fieldvalues', array(), '', 'array'); if (!empty($fieldValues)) { $field->value = array(); foreach ($fieldValues['title'] as $i => $title) { $title = trim(strip_tags($title)); $value = trim(strip_tags($value)); if (strlen($title) < 1 and strlen($fieldValues['value'][$i]) < 1) { continue; } $value = strlen($fieldValues['value'][$i]) < 1 ? $title : $fieldValues['value'][$i]; $extra = ''; if (!empty($fieldValues['disabled'][$i])) { $extra .= '::disabled'; } $field->value[] = $title . '::' . $value . $extra; } $field->value = implode("\n", $field->value); } $fieldsOptions = JRequest::getVar('fieldsoptions', array(), '', 'array'); foreach ($fieldsOptions as $column => $value) { if (!in_array($value, array('<', '<='))) { $fieldsOptions[$column] = strip_tags($value); } else { $fieldsOptions[$column] = $value; } } if ($field->type == "customtext") { $fieldsOptions['customtext'] = JRequest::getVar('fieldcustomtext', '', '', 'string', JREQUEST_ALLOWHTML); if (empty($field->fieldid)) { $field->namekey = 'customtext_' . date('z_G_i_s'); } } if ($field->type == 'category') { if (empty($field->fieldid)) { $field->namekey = 'category_' . date('z_G_i_s'); } } if (in_array($field->type, array('birthday', 'date')) && !empty($fieldsOptions['format']) && strpos($fieldsOptions['format'], '%') === false) { $app->enqueueMessage('Invalid Format: "' . $fieldsOptions['format'] . '"<br /><br />Please use a combination of:<br /> - %d (which will be replaced by days)<br /> - %m (which will be replaced by months)<br /> - %Y (which will be replaced by years)', 'notice'); $fieldsOptions['format'] = ''; } $field->options = serialize($fieldsOptions); if (empty($field->fieldid) && !in_array($field->type, array('customtext', 'category'))) { if (empty($field->namekey)) { $field->namekey = $field->fieldname; } $field->namekey = substr(preg_replace('#[^a-z0-9_]#i', '', strtolower($field->namekey)), 0, 50); if (empty($field->namekey) || !preg_match('#^[a-z]#', $field->namekey)) { $this->errors[] = 'Please specify a valid Column Name'; return false; } $columns = acymailing_getColumns('#__acymailing_subscriber'); if (isset($columns[$field->namekey])) { $this->errors[] = 'The field "' . $field->namekey . '" already exists'; return false; } if ($field->type == 'textarea') { $query = 'ALTER TABLE `#__acymailing_subscriber` ADD `' . $field->namekey . '` TEXT NOT NULL DEFAULT ""'; } else { $query = 'ALTER TABLE `#__acymailing_subscriber` ADD `' . $field->namekey . '` VARCHAR ( 250 ) NOT NULL DEFAULT ""'; } $this->database->setQuery($query); if (!$this->database->query()) { return false; } } $fieldid = $this->save($field); if (!$fieldid) { return false; } if (empty($field->fieldid)) { $orderClass = acymailing_get('helper.order'); $orderClass->pkey = 'fieldid'; $orderClass->table = 'fields'; $orderClass->reOrder(); } JRequest::setVar('fieldid', $fieldid); return true; }