function newSubscriber($name, $email, $confirm = false) { if (ACA_CMSTYPE) { // joomla 15 $database =& JFactory::getDBO(); $acl =& JFactory::getACL(); $rHTML = JRequest::getVar('receive_html', '0', 'request'); $timezone = JRequest::getVar('timezone', '00:00:00'); $lang6 = JRequest::getVar('lang', 'eng'); } else { //joomla 1x global $database, $acl; $rHTML = intval(mosGetParam($_REQUEST, 'receive_html', 0)); $timezone = mosGetParam($_REQUEST, 'timezone', '00:00:00'); $lang6 = mosGetParam($_REQUEST, 'lang', 'eng'); } //endif $erro = new xerr(__FILE__, __FUNCTION__, __CLASS__); $newSubscriber = new stdClass(); $newSubscriber->id = 0; $newSubscriber->user_id = 0; $newSubscriber->name = $name; $newSubscriber->email = $email; $newSubscriber->receive_html = $rHTML; if ($GLOBALS[ACA . 'require_confirmation'] and !$confirm) { $newSubscriber->confirmed = 0; } else { $newSubscriber->confirmed = 1; } $newSubscriber->blacklist = 0; $newSubscriber->timezone = $timezone; $newSubscriber->language_iso = $lang6; $newSubscriber->params = ''; $newSubscriber->subscribe_date = acajoom::getNow(); $dontParse[] = 'params'; acajoom::objectHTMLSafe($newSubscriber, ENT_QUOTES, $dontParse); $confirmation = true; $d['email'] = $newSubscriber->email; $erro->ck = subscribers::insertSubscriber($newSubscriber, $subscriberId); if (!$erro->Eck(__LINE__, '8280')) { $erro->ck = subscribers::getSubscriberIdFromEmail($d); if ($erro->Eck(__LINE__, '8270')) { $confirmation = false; } else { return acajoom::printM('blue', _ACA_ERROR); } } if ($GLOBALS[ACA . 'require_confirmation'] and $confirmation and !$confirm and !subscribers::userConfirmed($newSubscriber->email)) { $erro->ck = acajoom_mail::sendConfirmationEmail($subscriberId); $erro->Eck(__LINE__, '8281'); $needConfirm = true; } else { $needConfirm = false; } $erro->ck = queue::updateOneSuscription($subscriberId); if (!$erro->Eck(__LINE__, '8272')) { return acajoom::printM('blue', _ACA_ERROR); } if ($needConfirm) { $queues = queue::getSubscriberLists($subscriberId); $qids = acajoom::convertObjectToIdList($queues, 'qid'); $erro->ck = queue::updateSuspend($qids, 1); if (!$erro->Eck(__LINE__, '8273')) { return $erro->mess; } $message = acajoom::printM('blue', _ACA_COMFIRM_SUBSCRIPTION); } else { $message = acajoom::printM('green', _ACA_SUCCESS_ADD_LIST); } return $message; }
function updateOneSubscriber($userId = 0, $user = null, $confirmed = '0') { $erro = new xerr(__FILE__, __FUNCTION__, __CLASS__); $oneSubscriber = ''; $oneSubscriber->name = mosGetParam($_REQUEST, 'name', ''); $oneSubscriber->receive_html = intval(mosGetParam($_REQUEST, 'receive_html', 0)); $oneSubscriber->confirmed = intval(mosGetParam($_REQUEST, 'confirmed', 0)); $oneSubscriber->blacklist = mosGetParam($_REQUEST, 'blacklist', 0); $oneSubscriber->timezone = mosGetParam($_REQUEST, 'timezone', ''); $oneSubscriber->language_iso = mosGetParam($_REQUEST, 'language_iso', ''); $oneSubscriber->params = mosGetParam($_REQUEST, 'params', ''); $oneSubscriber->email = mosGetParam($_REQUEST, 'email', ''); if (isset($user)) { $oneSubscriber->email = $user->email; if (empty($oneSubscriber->email) or !subscribers::validEmail($oneSubscriber->email)) { echo '<br />' . acajoom::printM('red', _ACA_EMAIL_INVALID); echo "<script> alert('" . addslashes(_ACA_EMAIL_INVALID) . "'); window.history.go(-1);</script>\n"; return false; } $oneSubscriber->user_id = $user->id; $oneSubscriber->id = subscribers::getSubscriberIdFromUserId($user->id); $subscriberId = $oneSubscriber->id; if (!empty($user->name)) { $oneSubscriber->name = $user->name; } if ($oneSubscriber->confirmed or $confirmed) { $oneSubscriber->confirmed = 1; } if (isset($user->receive_html)) { $oneSubscriber->receive_html = $user->receive_html; } } elseif ($userId != 0) { $oneSubscriber->user_id = $userId; $subscriberId = subscribers::getSubscriberIdFromUserId($userId); $oneSubscriber->id = $subscriberId; } else { $oneSubscriber->user_id = mosGetParam($_REQUEST, 'id', ''); $subscriberId = intval(mosGetParam($_REQUEST, 'subscriber_id', 0)); $oneSubscriber->id = $subscriberId; } $dontParse[] = 'params'; acajoom::objectHTMLSafe($oneSubscriber, ENT_QUOTES, $dontParse); $erro->ck = subscribers::updateSubscriber($oneSubscriber, $subscriberId); $erro->Eck(__LINE__, '8635'); if ($erro->ck) { $erro->ck = queue::updateOneSuscription($subscriberId); $erro->Eck(__LINE__, '8636'); } return $erro->R(); }