/** * we get the subscribers info using the the id of the user. * @param int $id id of the user * @retrun object $subscriber info of the subscriber */ function _getSubscriberInfo($id) { $subscriber = ''; $subscriber = jNews_Subscribers::getSubscriberInfoFromUserId($id); //we get subscriber info if this user is a subscriber of jnews if (empty($subscriber)) { //if there is no record for the user jNews_Subscribers::syncSubscribers(true); //we sync the user as subscriber $subscriber = jNews_Subscribers::getSubscriberInfoFromUserId($id); //we get the subscriber info } return $subscriber; }
function configuration($action, $task) { $db = JFactory::getDBO(); $config = array(); $redirect = true; $xf = new jNews_Config(); $message = JRequest::getVar('message', ''); $clear_log = JRequest::getVar('clear_log', '0'); switch ($task) { case 'syncUsers': echo jnews::printYN(jNews_Subscribers::syncSubscribers(), _JNEWS_SYNC_USERS_SUCCESS, _JNEWS_ERROR); backHTML::_header(_JNEWS_MENU_CONF, 'configuration.png', $message, $task, $action); jNews_ConfigHTML::showConfigEdit(); break; case 'sendtest': $my = JFactory::getUser(); $mailing = new stdClass(); $status = false; $mailing->id = 1; $mailing->images = ''; $mailing->attachments = ''; $mailing->fromname = trim($GLOBALS[JNEWS . 'sendmail_name']); $mailing->fromemail = trim($GLOBALS[JNEWS . 'sendmail_email']); if (empty($mailing->fromemail)) { $mailing->fromemail = trim($GLOBALS[JNEWS . 'sendmail_from']); } ### create the mail $mail = jNews_ProcessMail::getMailer($mailing); ### create content $mail->IsHTML(true); $mail->Body = '<p>This message has been sent at ' . date('l, j F Y h:i:s', jnews::getNow(0, true)) . ' from ' . JNEWS_JPATH_LIVE . ' to test your mail configuration.</p><br/><p style="color:green;">' . _JNEWS_SENDTEST_CONFIGSUCC . '</p>'; $mail->AddAddress($my->email, $my->name); $mail->Subject = 'Test Email from ' . JNEWS_JPATH_LIVE; $status = $mail->Send(); $success = 'Email "' . $mail->Subject . '" successfully sent to ' . $my->name . ' (' . $my->email . ')'; $error = 'Failed sending "' . $mail->Subject . '" to ' . $my->name . ' (' . $my->email . '). <br/>' . _JNEWS_SENDTEST_CONFIGERROR; $message = is_bool($status) && $status ? jnews::printM('ok', $success) : jnews::printM('error', $error); backHTML::_header(_JNEWS_MENU_CONF, 'configuration.png', $message, $task, $action); jNews_ConfigHTML::showConfigEdit(); echo $message; break; case 'apply': case 'save': JRequest::checkToken() or die('Invalid Token'); if ($clear_log != 0) { @unlink(JNEWS_JPATH_ROOT_NO_ADMIN . $GLOBALS[JNEWS . 'save_log_file']); } $config = JRequest::getVar('config'); $message = jnews::printYN($xf->saveConfig($config), _JNEWS_CONFIG_UPDATED, _JNEWS_ERROR); $listCreator = JRequest::getVar('list_creatorfe', '', 'post'); if (!empty($listCreator)) { $xf->update('list_creatorfe', $listCreator); } //we update the active list $xf->updateActiveList(); if ($GLOBALS[JNEWS . 'level'] > 1) { //we require the cron controller require_once JNEWSPATH_ADMIN . 'controllers' . DS . 'cron.jnews.php'; //we update the published/enabld of the jnews cron plugin according to what is selected if (version_compare(JVERSION, '1.6.0', '<')) { //j15 $db->setQuery("UPDATE `#__plugins` SET `published` = " . $config['jnewscronplugin'] . " WHERE `element`='jnewscron' "); } else { //j16 $db->setQuery("UPDATE `#__extensions` SET `enabled` = " . $config['jnewscronplugin'] . " WHERE `type` = 'plugin' AND `element`='jnewscron' "); } $db->query(); //Joobi Cron System $cron = $GLOBALS[JNEWS . 'j_cron']; if ($cron == 2) { joobiCron('Yes'); } else { joobiCron('No'); } } if ($task == 'apply') { backHTML::_header(_JNEWS_MENU_CONF, 'configuration.png', $message, $task, $action); jNews_ConfigHTML::showConfigEdit(); echo $message; } else { backHTML::controlPanel(); } break; case 'cancel': jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION); break; case 'cpanel': backHTML::controlPanel(); break; case 'acaupdate': // update jnews datas from acajoom $msg = jNews_TableUpdate::executeUpdate(); echo $msg . '<br><br>'; default: backHTML::_header(_JNEWS_MENU_CONF, 'configuration.png', $message, $task, $action); jNews_ConfigHTML::showConfigEdit(); break; } return true; }