Пример #1
0
/**
 * 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))));
}
Пример #2
0
    echo t('Name of the theme');
    ?>
</div>
			<div class="formfieldcontrols"><?php 
    gu_theme_text_control('theme_name');
    ?>
</div>		
		</div>

		<div class="formfield">
			<div class="formfieldcomment"><?php 
    echo t('List of valid users');
    ?>
</div>
		<?php 
    $users = unserialize(str_replace('\\"', '"', gu_config::get('users')));
    asort($users);
    $noUser = true;
    foreach ($users as $key => $value) {
        if ($plxPlugin->getParam('user_' . $value['id']) == 'activé') {
            $noUser = false;
            ?>

			<div class="formfieldlabel"><?php 
            echo t('Login of user') . ' ' . $value['id'];
            ?>
</div>
			<div class="formfieldcontrols"><input type="text" name="user_<?php 
            echo $key;
            ?>
" class="textfield users" value="<?php 
Пример #3
0
 */
/* Gutama plugin package
 * @version 1.6
 * @date	01/10/2013
 * @author	Cyril MAGUIRE
*/
include_once 'inc/gutuma.php';
include_once 'inc/newsletter.php';
include_once 'inc/mailer.php';
// Initialize Gutuma without validation or redirection
gu_init(FALSE, FALSE);
// Get all newsletters in the outbox
$mailbox = gu_newsletter::get_mailbox();
if ($mailbox == FALSE || !isset($mailbox['outbox'])) {
    die(utf8_decode(t('Unable to access mailbox')));
}
// Create mailer
$mailer = new gu_mailer();
if (!$mailer->init()) {
    die(utf8_decode(t('Unable to initialize mailer')));
}
// Start timer
$start_time = time();
// Process outbox
foreach ($mailbox['outbox'] as $newsletter) {
    $newsletter->send_batch($mailer, $start_time);
    // Check batch time limit
    if (time() - $start_time > (int) gu_config::get('batch_time_limit')) {
        break;
    }
}
Пример #4
0
 * @author	Cyril MAGUIRE
*/
$u = gu_config::getUsers();
foreach ($u as $k => $v) {
    if ($v['id'] == $_SESSION['user']) {
        $u['connect'] = $k;
    }
}
if (gu_session_is_valid()) {
    ?>
			<div id="headerwelcome"><?php 
    echo gu_config::get('collective_name');
    ?>
 | <?php 
    echo t('Welcome ');
    echo isset($u['connect']) ? $u['connect'] : gu_config::get('admin_name');
    ?>
 | <a href="login.php?action=logout"><?php 
    echo t('Logout');
    ?>
</a></div>
			<?php 
}
?>
			
		</div>	
		<div id="mainmenu">
			<?php 
if (gu_session_is_valid()) {
    ?>
			
Пример #5
0
/**
 * Outputs a dropdown list control for the specified config setting
 * @param string $setting_name The config setting name
 * @param array $options The 2D array of possible options - [n][0] is the value of the nth option and [n][1] is the display name
 */
function gu_theme_list_control($setting_name, $options)
{
    $val = is_post_var($setting_name) ? get_post_var($setting_name) : gu_config::get($setting_name);
    echo '<select name="' . $setting_name . '" id="' . $setting_name . '">';
    foreach ($options as $option) {
        echo '<option value="' . $option[0] . '" ' . ($val == $option[0] ? 'selected="selected"' : '') . '>' . $option[1] . '</option>';
    }
    echo '</select>';
}
Пример #6
0
<div id="sidebar">
<ul>
	<li class="nav">
		<a href="<?php 
        echo $plxMotor->urlRewrite();
        ?>
" class="homepage" title="<?php 
        echo t('Back to site');
        ?>
"><?php 
        echo t('Back to site');
        ?>
</a>
		<br/>
		<?php 
        echo gu_config::get('application_name');
        ?>

	</li>
	<li class="user">
		<?php 
        echo plxUtils::strCheck($plxMotor->aUsers[$_SESSION['user']]['name']);
        ?>

	</li>
	<li class="profil">
		<?php 
        if ($_SESSION['profil'] == PROFIL_ADMIN) {
            printf('%s', L_PROFIL_ADMIN);
        } elseif ($_SESSION['profil'] == PROFIL_MANAGER) {
            printf('%s', L_PROFIL_MANAGER);
Пример #7
0
");    
			mysack.execute = 1;
			mysack.method = "POST";
			mysack.setVar("action", "list_delete");
			mysack.setVar("list", list_id);
			mysack.onError = function() { gu_error("<?php 
echo t('An error occured whilst making AJAX request');
?>
"); gu_messages_display(0); };
			mysack.onCompletion = function() { gu_messages_display(1000); }
			mysack.runAJAX();
		}
	}
	function gu_ajax_on_list_delete(list_id, msg)
	{
		gu_element_set_background("row_" + list_id, '#FFDDDD');
		gu_element_fade_out("row_" + list_id, 1000);
		
		var count = parseInt(document.lists_form.num_lists.value) - 1;
		document.lists_form.num_lists.value = count;
		
		if (count == 0)
			setTimeout('gu_element_set_display("row_empty", "table-row")', 1000);
	}
/* ]]> */
</script>

<?php 
//Body
include_once 'themes/' . gu_config::get('theme_name') . '/_lists.php';
gu_theme_end();
Пример #8
0
)</a></li>
			<li><a href="newsletters.php?box=outbox"><?php 
echo t('Outbox');
?>
 (<?php 
echo count($mailbox['outbox']);
?>
)</a></li>
		</ul>
	</div>
</div>
<?php 
if (count($lists) == 0) {
    gu_error(t("A address list must be created before a newsletter can be sent"));
}
if (gu_config::get('admin_email') == '') {
    gu_error(t("A valid admin email must be specified before a newsletter can be sent"));
}
gu_theme_messages();
?>
<form enctype="multipart/form-data" id="send_form" name="send_form" method="post" action="compose.php<?php 
echo gu_is_debugging() ? '?DEBUG' : '';
?>
"><input type="hidden" id="msg_id" name="msg_id" value="<?php 
echo $newsletter->get_id();
?>
" /><input type="hidden" id="is_modified" name="is_modified" value="<?php 
echo $is_modified;
?>
" />
	<div class="menubar">
Пример #9
0
    }
    $list = gu_list::get($list_id, FALSE);
} else {
    // Load all non-private lists
    $lists = gu_list::get_all(FALSE, FALSE);
}
if ($address == '' && $posted_address != '') {
    $address = $posted_address;
}
?>

<script type="text/javascript">
/* <![CDATA[ */
	function checkSubmit(form)
	{
		if (form.subscribe_address.value == "" || !gu_check_email(form.subscribe_address.value)) {
			alert("<?php 
echo t('You must enter a valid email address');
?>
");
			return false;
		}
		return true;
	}
/* ]]> */
</script>

<?php 
//Body
include_once 'themes/' . gu_config::get('theme_name') . '/_subscribe.php';
gu_theme_end();
Пример #10
0
/************************************************************************
 * @project Gutuma Newsletter Managment
 * @author Rowan Seymour
 * @copyright This source is distributed under the GPL
 * @file The home page
 * @modifications Cyril Maguire
 */
/* Gutama plugin package
 * @version 1.6
 * @date	01/10/2013
 * @author	Cyril MAGUIRE
*/
include_once 'inc/gutuma.php';
include_once 'inc/newsletter.php';
if ($_SESSION['profil'] != PROFIL_ADMIN) {
    header('Location:compose.php');
    exit;
}
gu_init();
gu_theme_start();
// Calculate some stats
$lists = gu_list::get_all();
$total_addresses = 0;
foreach ($lists as $list) {
    $total_addresses += $list->get_size();
}
$mailbox = gu_newsletter::get_mailbox();
//Body
include_once 'themes/' . gu_config::get('theme_name') . '/_index.php';
gu_theme_end();
Пример #11
0
/**
 * Checks the specified username and password against the stored admin credentials
 * @param string $username The username
 * @param string $password The MD5 encrypted password 
 * @return bool TRUE if username and password match stored admin credentials
 */
function plx_gu_session_check_credentials($name, $username, $password, $user = FALSE)
{
    if ($user == FALSE) {
        return $username == gu_config::get('admin_username') && $password == gu_config::get('admin_password');
    } else {
        $users = gu_config::getUsers();
        if (isset($users[$name])) {
            return $username == $users[$name]['login'] && $password == $users[$name]['password'];
        } else {
            return FALSE;
        }
    }
}
Пример #12
0
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'))));
}
Пример #13
0
			mysack.onError = function() { gu_error("<?php 
echo t('An error occured whilst making AJAX request');
?>
"); gu_messages_display(0); };
			mysack.onCompletion = function() { gu_messages_display(1000); }
			mysack.runAJAX();
		}
	}
	function gu_ajax_on_newsletter_delete(id)
	{
		gu_element_set_background("row_" + id, '#FFDDDD');
		gu_element_fade_out("row_" + id, 1000);
		
		var count = parseInt(document.newsletters_form.num_newsletters.value) - 1;
		document.newsletters_form.num_newsletters.value = count;
		
		if (count == 0)
			setTimeout('gu_element_set_display("row_empty", "table-row")', 1000);
			
		gu_element_set_inner_html("mailbox_<?php 
echo $box;
?>
_count", count);
	}
/* ]]> */
</script>

<?php 
//Body
include_once 'themes/' . gu_config::get('theme_name') . '/_newsletters.php';
gu_theme_end();
Пример #14
0
 /**
  * Creates a Swift message from a Gutuma newsletter
  * @param gu_newsletter $newsletter The newsletter
  * @param string $recipient The recipient address
  * @param string $list_name The name of the list holding the recipient
  * @return mixed The Swift message if successful, else FALSE
  */
 private function create_message(gu_newsletter $newsletter, $address, $list_name)
 {
     if (!gu_config::get('msg_prefix_subject')) {
         $subject = $newsletter->get_subject();
     } elseif ($list_name != '') {
         $subject = '[' . $list_name . '] ' . $newsletter->get_subject();
     } else {
         $subject = '[' . gu_config::get('collective_name') . '] ' . $newsletter->get_subject();
     }
     if ($list_name != '' && gu_config::get('msg_append_signature')) {
         $text = $newsletter->get_text() . "\n-------------------------------------------------\n" . t('Unsubscribe') . ": " . absolute_url('subscribe.php') . "?addr=" . $address . "\n" . t('Powered by Gutuma') . " (" . GUTUMA_URL . ")\n";
         $html = $newsletter->get_html() . '<hr /><p><a href="' . absolute_url('subscribe.php') . '?addr=' . $address . '">' . t('Unsubscribe') . '</a> ' . t('from this newsletter.') . t(' Powered by') . ' <a href="' . GUTUMA_URL . '">' . t('Gutuma') . '</a></p>';
     } else {
         $text =& $newsletter->get_text();
         $html =& $newsletter->get_html();
     }
     // Add text and html as separate MIME parts
     $message = new Swift_Message($subject);
     $message->attach(new Swift_Message_Part($text));
     $message->attach(new Swift_Message_Part($html, "text/html"));
     // Add message attachments
     foreach ($newsletter->get_attachments() as $attachment) {
         if (!$message->attach(new Swift_Message_Attachment(new Swift_File($attachment['path']), $attachment['name']))) {
             return gu_error(t("Unable to attach '") . $attachment['name'] . "'");
         }
     }
     return $message;
 }
Пример #15
0
		txtRecips.value += lstRecips.value;
	}
	
	window.onbeforeunload = function (ev)
	{
		var is_modified = document.getElementById('is_modified').value;
		
		if (!is_post_back && is_modified)
			return "<?php 
echo t('Your message has not been sent or saved, and will be lost if you leave this page.');
?>
";
	}	
	
	function gu_cancel_unsaved_warning()
	{
		is_post_back = true;
	}
	
	function gu_set_modified(modified)
	{
		document.getElementById('is_modified').value = (modified ? 1 : 0);
	}	
	
/* ]]> */
</script>

<?php 
//Body
include_once 'themes/' . gu_config::get('theme_name') . '/_compose.php';
gu_theme_end();
Пример #16
0
            $script_create = 'gu_gadgets_create_ajax_form(' . $gadget_list . ', "' . $gadget_btn_text . '", "' . $gadget_email_hint . '", "' . $gadget_prefix . '")';
            $script_write = '<script type="text/javascript">gu_gadgets_write_ajax_form(' . $gadget_list . ', "' . $gadget_btn_text . '", "' . $gadget_email_hint . '", "' . $gadget_prefix . '")</script>';
            $gadget_params = array('list', 'btn_text', 'email_hint', 'prefix');
            $gadget_requires_import = TRUE;
            break;
    }
}
function create_list_control($name, $value, $all_option)
{
    global $lists;
    $html = '<select id="' . $name . '" name="' . $name . '">';
    if ($all_option) {
        $html .= '<option value="0" ' . ($value == 0 ? 'selected="selected"' : '') . '>(' . t('All') . ')</option>';
    }
    foreach ($lists as $l) {
        $html .= '<option value="' . $l->get_id() . '" ' . ($value == $l->get_id() ? 'selected="selected"' : '') . '>' . $l->get_name() . '</option>';
    }
    $html .= '</select>';
    return $html;
}
function create_text_control($name, $value)
{
    return '<input id="' . $name . '" name="' . $name . '" type="text" class="textfield" style="width: 95%" value="' . $value . '" />';
}
?>
<script type="text/javascript" src="js/gadgets.js.php?noajax"></script>

<?php 
//Body
include_once 'themes/' . gu_config::get('theme_name') . '/_integrate.php';
gu_theme_end();
Пример #17
0
?>
</b> <?php 
echo t('draft%', array(count($mailbox['drafts']) < 2 ? '' : 's'));
?>
, <b><?php 
echo count($mailbox['outbox']);
?>
</b> <?php 
echo t('sending', array(count($mailbox['outbox']) < 2 ? '' : 's'));
?>
</li>
			<li><?php 
echo t('SMTP server:');
?>
 <?php 
echo gu_config::get('use_smtp') ? '<b>' . (gu_config::get('smtp_server') != '' ? gu_config::get('smtp_server') : 'AUTO') . '</b>' : '<span class="no">Not enabled</span>';
?>
</li>	
		</ul>
	</div>
</div>
<div style="clear: both">
	<h3><?php 
echo t('Licence');
?>
</h3>
	<div style="float: right; margin-left: 10px"><form action="https://www.paypal.com/cgi-bin/webscr" method="post">
	<input type="hidden" name="cmd" value="_s-xclick">
	<input type="image" src="https://www.paypal.com/en_GB/i/btn/x-click-but04.gif" border="0" name="submit" alt="<?php 
echo t('PayPal - The safer, easier way to pay online.');
?>
Пример #18
0
">
		<td><?php 
        echo $address;
        ?>
</td> 
		<td style="text-align: right"><a href="javascript:gu_remove_address('<?php 
        echo $address;
        ?>
', <?php 
        echo $address_id;
        ?>
)" class="imglink" title="<?php 
        echo t('Delete');
        ?>
"><img src="themes/<?php 
        echo gu_config::get('theme_name');
        ?>
/images/icon_delete.png" /></a></td>
	</tr>	
<?php 
    }
}
?>
	<tr id="row_empty" style="display: <?php 
echo $list->get_size() == 0 ? 'table-row' : 'none';
?>
"><td colspan="2" class="emptyresults"><?php 
echo t('No addresses');
?>
</td></tr>	
</table>
Пример #19
0
 /**
  * Parses this newsletter's recipient list into an array of addresss and list names
  * @return array The array of email addresses and list names
  */
 public function parse_recipients()
 {
     $list_names = array();
     $addresses = array();
     $items = explode(';', $this->recipients);
     foreach ($items as $r) {
         $recip = trim($r);
         if (strlen($recip) == 0) {
             continue;
         } elseif (strpos($recip, '@') === FALSE) {
             $list_names[] = $recip;
         } else {
             $addresses[$recip] = '';
         }
     }
     // Add addresses from each list, in reverse order, so that duplicates for addresses on more than one list, come from the first occuring lists
     for ($l = count($list_names) - 1; $l >= 0; $l--) {
         if ($list = gu_list::get_by_name($list_names[$l], TRUE)) {
             foreach ($list->get_addresses() as $address) {
                 $addresses[$address] = $list->get_name();
             }
         } else {
             return gu_error(t('Unrecognized list name <i>%</i>', array($list_names[$l])));
         }
     }
     // If admin wants a copy, add the admin address as well
     if (gu_config::get('msg_admin_copy')) {
         $addresses[gu_config::get('admin_email')] = '';
     }
     return $addresses;
 }