/** * Processes (un)subscription requests to multiple lists * @param string $address The email address * @param array $list_ids The ids of the lists * @param bool $subscribe TRUE if addresss should be subscribed to the lists, FALSE if it should be unsubscribed * @return bool TRUE if operation was successful, else FALSE */ function gu_subscription_process($address, &$list_ids, $subscribe) { if (!check_email($address)) { return gu_error(t("Invalid email address")); } $succ_list_names = array(); $fail_list_names = array(); // For each list we need to load it with all addresses foreach ($list_ids as $list_id) { $list = gu_list::get($list_id, TRUE); // Don't allow subscriptions to private lists if ($list->is_private()) { $res = FALSE; } else { if ($subscribe) { $res = $list->add($address, TRUE); } else { $res = $list->remove($address, TRUE); } } if ($res) { $succ_list_names[] = $list->get_name(); } else { $fail_list_names[] = $list->get_name(); } } // Check if there were any successful if (count($succ_list_names) < 1) { return FALSE; } // Work out if we need to send any emails now, and if so create a sender if (gu_config::get('list_send_welcome') || gu_config::get('list_send_goodbye') || gu_config::get('list_subscribe_notify') || gu_config::get('list_unsubscribe_notify')) { $mailer = new gu_mailer(); if ($mailer->init()) { $subject_prefix = count($succ_list_names) == 1 ? $succ_list_names[0] : gu_config::get('collective_name'); // Send welcome / goodbye message if ($subscribe && gu_config::get('list_send_welcome') || !$subscribe && gu_config::get('list_send_goodbye')) { $subject = '[' . $subject_prefix . '] ' . ($subscribe ? t('Subscription') : t('Unsubscription')) . t(' confirmation'); $action = $subscribe ? t('subscribed to') : t('unsubscribed from'); $text = t("This is an automated message to confirm that you have been % the following lists:", array($action)) . "\n\n* " . implode("\n* ", $succ_list_names) . "\n\n"; $text .= t('To change your subscriptions visit: ') . absolute_url('subscribe.php') . '?addr=' . $address . "\n\n"; $text .= t('Please do not reply to this message. Thank you.'); $mailer->send_mail($address, $subject, $text); } // Send admin notifications if ($subscribe && gu_config::get('list_subscribe_notify') || !$subscribe && gu_config::get('list_unsubscribe_notify')) { $subject = '[' . $subject_prefix . '] ' . ($subscribe ? t('Subscription') : t('Unsubscription')) . t(' notification'); $action = $subscribe ? t('subscribed to') : t('unsubscribed from'); $text = t("This is an automated message to notify you that % has been % the following lists:", array($address, $action)) . "\n\n* " . implode("\n* ", $succ_list_names) . "\n\n"; $mailer->send_admin_mail($subject, $text); } } } $action = $subscribe ? t('subscribed to') : t('unsubscribed from'); return gu_success(t('You have been % lists: <i>%</i>', array($action, implode('</i>, <i>', $succ_list_names)))); }
/** * Deletes the specified newsletter * @param gu_newsletter $newsletter The newsletter to delete */ function gu_ajax_newsletter_delete($newsletter) { if (!$newsletter) { return gu_error(t('Invalid newsletter')); } if ($newsletter->delete()) { gu_success(t('Newsletter deleted')); gu_ajax_return('gu_ajax_on_newsletter_delete(' . $newsletter->get_id() . ')'); } }
$newsletter = new gu_newsletter(); $is_modified = FALSE; } } elseif (is_post_var('attach_submit') && $_FILES['attach_file']['name'] != '') { if ($newsletter->store_attachment($_FILES['attach_file']['tmp_name'], $_FILES['attach_file']['name'])) { gu_success(t('Attachment <b><i>%</i></b> added', array($_FILES['attach_file']['name']))); } } elseif (is_post_var('remove_submit')) { $attachment = get_post_var('msg_attachments'); if ($newsletter->delete_attachment($attachment)) { gu_success(t('Attachment <i>%</i> removed', array($attachment))); } } elseif (is_post_var('save_submit')) { if ($newsletter->save()) { $is_modified = FALSE; gu_success(t('Newsletter saved as draft')); } } // Get all newsletters as mailbox $mailbox = gu_newsletter::get_mailbox(); // Get list of attachments $attachments = $newsletter->get_attachments(); if (!$preview_mode) { // Only enable the TinyMCE compressor if zlib compression is disabled on the server if (!ini_get('zlib.output_compression') && GUTUMA_TINYMCE_COMPRESSION) { ?> <script type="text/javascript" src="js/tiny_mce/tiny_mce_gzip.js"></script> <script type="text/javascript"> tinyMCE_GZ.init({ plugins : 'safari,pagebreak,emotions,iespell,media,print,contextmenu,paste,noneditable,nonbreaking,xhtmlxtras,inlinepopups', themes : 'advanced',
/* Gutama plugin package * @version 1.6 * @date 01/10/2013 * @author Cyril MAGUIRE */ include 'inc/gutuma.php'; gu_init(); gu_theme_start(); // Import CSV into new list if one has been uploaded if (isset($_FILES['import_file'])) { $name = remove_ext(basename($_FILES['import_file']['name'])); if ($_FILES['import_file']['type'] == 'text/csv') { $csv = $_FILES['import_file']['tmp_name']; if ($list = gu_list::import_csv($name, $csv)) { if ($list->update()) { gu_success(t('List <b><i>%</i></b> imported from CSV file', array($name))); } } // Delete file if (is_file($csv)) { unlink($csv); } } else { gu_error(t('Uploaded file is not a csv file')); } } $lists = gu_list::get_all(); ?> <script type="text/javascript"> /* <![CDATA[ */
$list_id = is_get_var('list') ? (int) get_get_var('list') : 0; $start = is_get_var('start') ? (int) get_get_var('start') : 0; $filter = is_get_var('filter') ? get_get_var('filter') : ''; // Load list data $list = gu_list::get($list_id, TRUE); // Make updates if (is_post_var('list_update')) { $list->set_name(get_post_var('list_name')); $list->set_private(is_post_var('list_private')); if ($list->update()) { gu_success(t('List updated')); } } elseif (is_post_var('new_address')) { $address = trim(get_post_var('new_address')); if ($list->add($address, TRUE)) { gu_success(t('Address <b><i>%</i></b> added to list', array($address))); } } ?> <script type="text/javascript"> /* <![CDATA[ */ gu_status_message_delay = 1000; function filter_addresses(form) { var filter = form.filter_list_name.value; window.location = "editlist.php?list=" + <?php echo $list->get_id(); ?>
function gu_sender_test() { // Get current settings, which may not have been saved $use_smtp = is_post_var('use_smtp'); $smtp_server = get_post_var('smtp_server'); $smtp_port = (int) get_post_var('smtp_port'); $smtp_encryption = get_post_var('smtp_encryption'); $smtp_username = get_post_var('smtp_username'); $smtp_password = get_post_var('smtp_password'); $use_sendmail = is_post_var('use_sendmail'); $use_phpmail = is_post_var('use_phpmail'); if (!($use_smtp || $use_sendmail || $use_phpmail)) { return gu_error(t('No method of mail transportation has been configured')); } $test_msg = t('If you have received this email then your settings clearly work!'); // Test SMTP settings first if ($use_smtp) { $mailer = new gu_mailer(); if ($mailer->init(TRUE, $smtp_server, $smtp_port, $smtp_encryption, $smtp_username, $smtp_password, FALSE, FALSE)) { if (!$mailer->send_admin_mail('[' . gu_config::get('collective_name') . '] Testing SMTP', $test_msg)) { return gu_error(t('Unable to send test message using SMTP')); } } else { return gu_error(t('Unable to initialize mailer with the SMTP settings')); } $mailer->disconnect(); } // Test Sendmail next if ($use_sendmail) { $mailer = new gu_mailer(); if ($mailer->init(FALSE, '', '', '', '', '', FALSE, FALSE)) { if (!$mailer->send_admin_mail('[' . gu_config::get('collective_name') . '] Testing Sendmail', $test_msg)) { return gu_error(t('Unable to send test message using Sendmail')); } } else { return gu_error(t('Unable to initialize mailer with Sendmail')); } $mailer->disconnect(); } // Test PHP mail next if ($use_phpmail) { $mailer = new gu_mailer(); if ($mailer->init(FALSE, '', '', '', '', '', FALSE, TRUE)) { if (!$mailer->send_admin_mail('[' . gu_config::get('collective_name') . '] Testing PHP mail', $test_msg)) { return gu_error(t('Unable to send test message using PHP mail')); } } else { return gu_error(t('Unable to initialize mailer with PHP mail')); } $mailer->disconnect(); } gu_success(t('Test messages sent to <br><i>%</i></b>', array(gu_config::get('admin_email')))); }
* @author Cyril MAGUIRE */ include_once 'inc/gutuma.php'; if (isset($_GET['token'])) { list($name, $username, $password, $salt, $userProfile, $id, $new_record) = explode('[::]', unserialize(base64_decode($_GET['token']))); list($user_name, $user_login, $user_password, $user_salt, $user_userProfile, $user_id) = explode('[::]', unserialize(base64_decode($new_record))); $user_salt = substr($user_salt, 1, -2); } else { header('Location:./index.php'); } gu_init(); $users = gu_config::getUsers(); if (isset($users[$user_name])) { header('location:' . str_replace('plugins/gutuma/news', 'core/admin', absolute_url('plugin.php?p=gutuma&rec=done&u=' . $users[$user_name]['id']))); } // Save settings if (is_post_var('save_settings')) { if (isset($users[$user_name])) { gu_error(t('<span style="color:red;">User already exists !</span>')); } else { gu_config::setUsers(get_post_var('id'), get_post_var('name'), get_post_var('login'), get_post_var('password'), base64_decode(get_post_var('salt')), get_post_var('userProfile')); if (gu_config::save()) { $ok = ''; } gu_success(t('New user successfully saved.')); } } gu_theme_start(); //Body include_once 'themes/' . gu_config::get('theme_name') . '/_users.php'; gu_theme_end();