function upgrade_News3() { global $my, $database; $xf = new xonfig(); $newLists = array(); $idImportedList = array(); $i = 0; $database->setQuery("SELECT * FROM #__newsletter_letters"); $newsletters = $database->loadObjectList(); $error = $database->getErrorMsg(); if (!empty($error)) { echo '<p><b>Error (class.upgrade.php->upgrade_News3 () line ' . __LINE__ . '):</b> Error getting newsletters. Database error: <br />' . $error . '</p>'; return false; } else { foreach ($newsletters as $newsletter) { $list->list_name = $newsletter->list_name; $list->list_desc = $newsletter->list_desc; $list->sendername = $newsletter->sendername; $list->senderemail = $newsletter->senderemail; $list->bounceadres = $newsletter->bounceadres; $list->layout = $newsletter->layout; $list->template = 0; $list->subscribemessage = $newsletter->subscribemessage; $list->unsubscribemessage = $newsletter->unsubscribemessage; $list->html = $newsletter->html; $list->hidden = !$newsletter->hidden; $list->unsubscribesend = 1; $list->list_type = '1'; $list->auto_add = 0; $list->user_choose = 0; $list->cat_id = 0; $list->delay_min = 0; $list->delay_max = 0; $list->follow_up = 0; $list->owner = $my->id; $list->auto_add = 0; $list->acc_level = $newsletter->aid; $list->acc_id = 29; $list->published = 1; $list->createdate = acajoom::getNow(); $list->footer = 1; $list->notify_id = 0; $list->notification = 0; $query = 'INSERT INTO `#__acajoom_lists` (`list_name`) VALUES (\'' . $list->list_name . '\' )'; $database->setQuery($query); $database->query(); $error = $database->getErrorMsg(); if (!empty($error)) { echo '<p><b>Error (class.upgrade.php->upgrade_News3() line ' . __LINE__ . '):</b> Error adding list to database. Database error: <br />' . $error . '</p><br /><br />Are you trying to insert a list name which is already in use? The list name has to be different for each list! <br /><br />'; } else { $query = 'SELECT * FROM `#__acajoom_lists` WHERE `list_name`= \'' . $list->list_name . '\''; $database->setQuery($query); $database->loadObject($mynewlist); $error = $database->getErrorMsg(); $xf->plus('totallist0', 1); $xf->plus('act_totallist0', 1); $xf->plus('totallist1', 1); $xf->plus('act_totallist1', 1); if (!empty($error)) { echo '<p><b>Error (class.upgrade.php->upgrade_News3() line ' . __LINE__ . '):</b> Error getting listname. Database error: <br />' . $error . '</p>'; return false; } else { $idImportedList[$newsletter->id] = $mynewlist->id; $newLists[$i] = $mynewlist->id; $i++; $list->id = $mynewlist->id; $error = lists::updateListData($list); if (!$error) { echo '<p><b>Error (class.upgrade.php->upgrade_News3 () line ' . __LINE__ . '):</b> Error inserting list. Database error: <br />' . $error . '</p>'; } else { echo '<br /><b>' . @constant($GLOBALS[ACA . 'listnames1']) . ': </b>' . $list->list_name . ': ' . acajoom::printM('green', _ACA_IMPORT_SUCCESS); $database->setQuery("SELECT * FROM #__newsletter_mailing WHERE `list_id`=" . $newsletter->id); $mailingsImports = $database->loadObjectList(); $error = $database->getErrorMsg(); if (!empty($error)) { echo '<p><b>Error (class.upgrade.php->upgrade_News3() line ' . __LINE__ . '):</b> Error getting mailings. Database error: <br />' . $error . '</p>'; return false; } else { $issue_nb = 1; foreach ($mailingsImports as $mailingsImport) { $mailings->list_id = $mynewlist->id; $mailings->list_type = '1'; $mailings->send_date = $mailingsImport->send_date; $mailings->subject = $mailingsImport->subject; $mailings->htmlcontent = $mailingsImport->htmlcontent; $mailings->textonly = $mailingsImport->textonly; $mailings->attachments = $mailingsImport->attachments; $mailings->images = $mailingsImport->images; $mailings->published = $mailingsImport->published; $mailings->visible = $mailingsImport->visible; $mailings->html = $mynewlist->html; $mailings->fromname = $list->sendername; $mailings->fromemail = $list->senderemail; $mailings->frombounce = $list->bounceadres; $mailings->author_id = $my->id; $mailings->delay = 0; $mailings->issue_nb = $issue_nb; $mailings->acc_level = 25; $mailings->createdate = $list->createdate; $issue_nb++; $error = xmailing::insertMailingData($mailings); if (!$error) { echo '<p><b>Error (class.upgrade.php->upgrade_News3() line ' . __LINE__ . '):</b> Error inserting mailing. Database error: <br />' . $error . '</p>'; } else { echo '<br /><b>' . _ACA_MENU_MAILING_TITLE . ': </b>' . $mailingsImport->subject . ': ' . acajoom::printM('green', _ACA_IMPORT_SUCCESS); } } } } } } } $database->setQuery("SELECT * FROM #__newsletter_subscribers"); $subscribers = $database->loadObjectList(); $error = $database->getErrorMsg(); if (!empty($error)) { echo '<p><b>Error (class.upgrade.php->upgrade_News3() line ' . __LINE__ . '):</b> Error getting subscribers. Database error: <br />' . $error . '</p>'; return false; } else { foreach ($subscribers as $subscriber) { $newSubs = true; $acajoomsubscribers = subscribers::getSubscribers(-1, -1, '', $total, 0, '', '', '', ''); foreach ($acajoomsubscribers as $acajoomsubscriber) { if ($subscriber->subscriber_email == $acajoomsubscriber->email) { $newSubs = false; $subId[0] = $acajoomsubscriber->id; } } if ($newSubs) { $newSubscriber->user_id = $subscriber->userid; $newSubscriber->name = $subscriber->subscriber_name; $newSubscriber->email = $subscriber->subscriber_email; $newSubscriber->receive_html = $subscriber->receive_html; $newSubscriber->confirmed = $subscriber->confirmed; $newSubscriber->subscribe_date = $subscriber->subscribe_date; $newSubscriber->blacklist = 0; $newSubscriber->timezone = '00:00:00'; $newSubscriber->language_iso = 'eng'; $newSubscriber->params = ''; $error = subscribers::insertSubscriber($newSubscriber, $subscriberId); if (!empty($error)) { if ($subscriberId < 1) { echo ' Error inserting subscriber:' . $newSubscriber->name; } $error = ''; $subId[0] = $subscriberId; } else { echo '<br /><b>' . _ACA_MENU_SUBSCRIBERS . ': </b>' . $newSubscriber->name . ': ' . acajoom::printM('green', _ACA_IMPORT_SUCCESS); $d['email'] = $subscriber->email; $erro->ck = subscribers::getSubscriberIdFromEmail($d); $erro->Eck(__LINE__, '8304'); $subId[0] = $d['subscriberId']; } } else { echo '<br /><b>' . _ACA_MENU_SUBSCRIBERS . ': </b>' . $subscriber->subscriber_name . ': ' . acajoom::printM('red', _ACA_IMPORT_EXIST); } $j = 0; $queue = queue::suscriptionExist($subId[0], $idImportedList[$subscriber->list_id]); if (empty($queue)) { $error = queue::insertQueuesForNews($subId, $idImportedList[$subscriber->list_id], 29); if (!$error) { echo '<p><b>Error (class.upgrade.php->upgrade_News3 () line ' . __LINE__ . '):</b> Error inserting queue. Database error: <br />' . $error . '</p>'; } } } } } return true; }
function updateSuscription($suscription) { $erro = new xerr(__FILE__, __FUNCTION__, __CLASS__); //$i = 0; //do { //$i++; foreach ($suscription->sub_list_id as $i => $value) { $queues = queue::suscriptionExist($suscription->user_id, $suscription->sub_list_id[$i]); if (!empty($queues)) { if (isset($suscription->subscribed[$i])) { if ($suscription->subscribed[$i] == 0) { $erro->ck = queue::deleteSubsQueue($suscription->user_id, $suscription->sub_list_id[$i]); $erro->Eck(__LINE__, '8520'); } else { $updatedQueue = $queues; $updatedQueue->acc_level = $suscription->acc_level[$i]; if ($queues->mailing_id < 1) { $mailingId = xmailing::getFirstMailingId($queues->list_id); if (!empty($mailingId)) { $list = lists::getOneList($queues->list_id); $mailing = queue::getValidMailing($list, $mailingId); if (!empty($mailing)) { $updatedQueue->type = $mailing->list_type; $updatedQueue->list_id = $list->id; $updatedQueue->mailing_id = $mailing->id; $updatedQueue->published = $list->published; $updatedQueue->send_date = acajoom::getNow(); if ($mailing->list_type == 1 or $mailing->list_type == 7) { $updatedQueue->issue_nb = 0; $updatedQueue->send_date = '0000-00-00 00:00:00'; $updatedQueue->delay = 0; } else { $updatedQueue->issue_nb = $mailing->issue_nb; $updatedQueue->send_date = acajoom::getNow(); $updatedQueue->delay = $mailing->delay; } } } $qid = ''; $qid[0] = $updatedQueue->qid; $erro->ck = queue::updateQueueData($qid, '', $updatedQueue->type, $updatedQueue->list_id, $updatedQueue->mailing_id, $updatedQueue->issue_nb, $updatedQueue->send_date, $updatedQueue->delay, $updatedQueue->acc_level, $updatedQueue->published); $erro->Eck(__LINE__, '8521'); } else { queue::updateAccessLevel($updatedQueue); } } } } else { if (isset($suscription->subscribed[$i])) { if ($suscription->subscribed[$i] == 1) { $subId = array(); $subId[0] = $suscription->user_id; $subList = isset($suscription->sub_list_id[$i]) ? $suscription->sub_list_id[$i] : 0; $subLevel = isset($suscription->acc_level[$i]) ? $suscription->acc_level[$i] : 29; $erro->ck = queue::updateQueues($subId, '', $subList, $subLevel, true); $erro->Eck(__LINE__, '8522'); } } } } //while (count($suscription->sub_list_id ) > $i ); return $erro->R(); }