Permalink
Browse files

Uploaded for archiving purposes

  • Loading branch information...
rickterheide committed Apr 18, 2012
0 parents commit 1b47152001ec57fdadcdceb77a8600cb355174e3
@@ -0,0 +1,51 @@
+<?php
+/**
+* Mass Mail outs.
+*
+* Get the progress of sending all the mails
+*
+* @package mass_mailouts
+* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+* @author ColdTrick IT Solutions
+* @copyright ColdTrick 2009
+* @link http://www.coldtrick.com/
+*/
+
+ admin_gatekeeper();
+
+ $user = get_loggedin_user();
+
+ $progress = $user->mass_mailouts_progress;
+
+ $result = array();
+
+ if(!empty($progress)){
+ $ts = time();
+ $token = generate_action_token($ts);
+
+ list($progress, $text) = explode("|", $progress);
+
+ if($progress == 100){
+ remove_metadata($user->guid, "mass_mailouts_progress");
+ }
+
+ $result["result"] = true;
+ $result["progress"] = $progress;
+ $result["text"] = $text;
+ } else {
+ $result["result"] = false;
+ }
+
+ // Need new security tokens
+ $result["ts"] = $ts;
+ $result["token"] = $token;
+
+ // Sent correct headers
+ header("Content-Type: application/json; charset=UTF-8");
+ header("Cache-Control: no-cache");
+ header("Pragma: no-cache");
+
+ echo json_encode($result);
+
+ exit();
+?>
@@ -0,0 +1,73 @@
+<?php
+ /**
+ * Mass Mail outs.
+ *
+ * @package mass_mailouts
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author ColdTrick IT Solutions
+ * @copyright ColdTrick 2009
+ * @link http://www.coldtrick.com/
+ */
+
+ global $CONFIG;
+
+ action_gatekeeper();
+ admin_gatekeeper();
+
+ $subject = get_input('email_subject');
+ $text = get_input("email_text", "", false);
+ $methods_override = get_input("methods_override", ""); // override default notify
+
+ if (!empty($subject) && !empty($text)) {
+ $count = get_entities("user", "", 0, null, null, null, true);
+ $users = get_entities("user", "", 0, null, $count);
+
+ $failure = 0;
+ $succes = 0;
+
+ $curUser = get_loggedin_user();
+ unset($curUser->mass_mailouts_progress);
+
+ foreach($users as $user){
+ set_time_limit(5);
+
+ $newSubject = str_ireplace("[displayname]", $user->name, $subject);
+ $newSubject = str_ireplace("[profile]", "<a href='" . $user->getUrl() . "'>" . $user->getUrl() . "</a>", $newSubject);
+ $newSubject = str_ireplace("[username]", $user->username, $newSubject);
+ $newSubject = str_ireplace("[email]", $user->email, $newSubject);
+ $newSubject = str_ireplace("&nbsp;", "", $newSubject);
+
+ $newText = str_ireplace("[displayname]", $user->name, $text);
+ $newText = str_ireplace("[profile]", "<a href='" . $user->getUrl() . "'>" . $user->getUrl() . "</a>", $newText);
+ $newText = str_ireplace("[username]", $user->username, $newText);
+ $newText = str_ireplace("[email]", $user->email, $newText);
+ $newText = str_ireplace("&nbsp;", "", $newText);
+
+ $result = notify_user($user->guid, $user->site_guid, $newSubject, $newText, null, $methods_override);
+
+ if($result["email"] === false){
+ $failure++;
+ } else {
+ $succes++;
+ }
+
+ $percentage = round((($succes + $failure) / $count) * 100);
+
+ $curUser->mass_mailouts_progress = $percentage . "|" . sprintf(elgg_echo("mass_mailouts:progress:text"), ($succes + $failure), $count);
+ }
+
+ if($failure == 0){
+ system_message(sprintf(elgg_echo("mass_mailouts:success"), $succes));
+ } else {
+ if($failure == $count){
+ register_error(elgg_echo("mass_mailouts:failure"));
+ } else {
+ register_error(sprintf(elgg_echo("mass_mailouts:some_errors"), $failure, $count));
+ }
+ }
+ } else {
+ register_error(elgg_echo("mass_mailouts:invalid_input"));
+ }
+
+ exit();
+?>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,28 @@
+<?php
+/**
+* Mass Mail outs.
+*
+* @package mass_mailouts
+* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+* @author ColdTrick IT Solutions
+* @copyright ColdTrick 2009
+* @link http://www.coldtrick.com/
+*/
+
+require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
+
+admin_gatekeeper();
+set_context('admin');
+
+// Set admin user for user block
+set_page_owner($_SESSION['guid']);
+
+$title = elgg_view_title(elgg_echo('mass_mailouts'));
+$form = elgg_view('mass_mailouts/form');
+
+$page_data = $title . $form;
+
+// Display main admin menu
+page_draw(elgg_echo('mass_mailouts'), elgg_view_layout("two_column_left_sidebar", '', $page_data));
+
+?>
@@ -0,0 +1,144 @@
+/*
+ * jQuery Progress Bar plugin
+ * Version 1.1.0 (06/20/2008)
+ * @requires jQuery v1.2.1 or later
+ *
+ * Copyright (c) 2008 Gary Teo
+ * http://t.wits.sg
+
+USAGE:
+ $(".someclass").progressBar();
+ $("#progressbar").progressBar();
+ $("#progressbar").progressBar(45); // percentage
+ $("#progressbar").progressBar({showText: false }); // percentage with config
+ $("#progressbar").progressBar(45, {showText: false }); // percentage with config
+*/
+(function($) {
+ $.extend({
+ progressBar: new function() {
+
+ this.defaults = {
+ increment : 2,
+ speed : 15,
+ showText : true, // show text with percentage in next to the progressbar? - default : true
+ width : 120, // Width of the progressbar - don't forget to adjust your image too!!!
+ boxImage : 'images/progressbar.gif', // boxImage : image around the progress bar
+ barImage : {
+ 0: 'images/progressbg_red.gif',
+ 30: 'images/progressbg_orange.gif',
+ 70: 'images/progressbg_green.gif'
+ }, // Image to use in the progressbar. Can be a single image too: 'images/progressbg_green.gif'
+ height : 12 // Height of the progressbar - don't forget to adjust your image too!!!
+ };
+
+ /* public methods */
+ this.construct = function(arg1, arg2) {
+ var argpercentage = null;
+ var argconfig = null;
+
+ if (arg1 != null) {
+ if (!isNaN(arg1)) {
+ argpercentage = arg1;
+ if (arg2 != null) {
+ argconfig = arg2; }
+ } else {
+ argconfig = arg1;
+ }
+ }
+
+ return this.each(function(child) {
+ var pb = this;
+ if (argpercentage != null && this.bar != null && this.config != null) {
+ this.config.tpercentage = argpercentage;
+ if (argconfig != null)
+ pb.config = $.extend(this.config, argconfig);
+ } else {
+ var $this = $(this);
+ var config = $.extend({}, $.progressBar.defaults, argconfig);
+ var percentage = argpercentage;
+ if (argpercentage == null)
+ var percentage = $this.html().replace("%",""); // parsed percentage
+
+
+ $this.html("");
+ var bar = document.createElement('img');
+ var text = document.createElement('span');
+ bar.id = this.id + "_percentImage";
+ text.id = this.id + "_percentText";
+ bar.title = percentage + "%";
+ bar.alt = percentage + "%";
+ bar.src = config.boxImage;
+ bar.width = config.width;
+ var $bar = $(bar);
+ var $text = $(text);
+
+ this.bar = $bar;
+ this.ntext = $text;
+ this.config = config;
+ this.config.cpercentage = 0;
+ this.config.tpercentage = percentage;
+
+ $bar.css("width", config.width + "px");
+ $bar.css("height", config.height + "px");
+ $bar.css("background-image", "url(" + getBarImage(this.config.cpercentage, config) + ")");
+ $bar.css("padding", "0");
+ $bar.css("margin", "0");
+ $this.append($bar);
+ $this.append($text);
+ }
+
+ function getBarImage (percentage, config) {
+ var image = config.barImage;
+ if (typeof(config.barImage) == 'object') {
+ for (var i in config.barImage) {
+ if (percentage >= parseInt(i)) {
+ image = config.barImage[i];
+ } else { break; }
+ }
+ }
+ return image;
+ }
+
+ var t = setInterval(function() {
+ var config = pb.config;
+ var cpercentage = parseInt(config.cpercentage);
+ var tpercentage = parseInt(config.tpercentage);
+ var increment = parseInt(config.increment);
+ var bar = pb.bar;
+ var text = pb.ntext;
+ var pixels = config.width / 100; // Define how many pixels go into 1%
+
+ bar.css("background-image", "url(" + getBarImage(cpercentage, config) + ")");
+ bar.css("background-position", (((config.width * -1)) + (cpercentage * pixels)) + 'px 50%');
+
+ if (config.showText)
+ text.html(" " + Math.round(cpercentage) + "%");
+
+ if (cpercentage > tpercentage) {
+ if (cpercentage - increment < tpercentage) {
+ pb.config.cpercentage = 0 + tpercentage
+ } else {
+ pb.config.cpercentage -= increment;
+ }
+ }
+ else if (pb.config.cpercentage < pb.config.tpercentage) {
+ if (cpercentage + increment > tpercentage) {
+ pb.config.cpercentage = tpercentage
+ } else {
+ pb.config.cpercentage += increment;
+ }
+ }
+ else {
+ clearInterval(t);
+ }
+ }, pb.config.speed);
+ });
+ };
+ }
+ });
+
+ $.fn.extend({
+ progressBar: $.progressBar.construct
+ });
+
+})(jQuery);
@@ -0,0 +1,42 @@
+<?php
+ /**
+ * Mass Mail outs.
+ *
+ * @package mass_mailouts
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author ColdTrick IT Solutions
+ * @copyright ColdTrick 2009
+ * @link http://www.coldtrick.com/
+ */
+
+ $english = array(
+ /**
+ * Menu items and titles
+ */
+ 'mass_mailouts' => 'Mass Mailing',
+ 'mass_mailouts:email_text' => 'E-mail Message:',
+ 'mass_mailouts:subject' => 'E-mail Subject:',
+ 'mass_mailouts:methods_override' => 'Select the method used for sending this message',
+ 'mass_mailouts:methods_override:site' => 'Send to site',
+ 'mass_mailouts:methods_override:email' => 'Send to mail',
+ 'mass_mailouts:methods_override:user_preference' => 'User defined method',
+
+ 'mass_mailouts:send' => 'Send E-mail',
+
+ 'mass_mailouts:footnote' => "You can use the following tags to personalize the emails (can be used is Subject and in Text):",
+ 'mass_mailouts:footnote:displayname' => "for the user's full name (display name)",
+ 'mass_mailouts:footnote:profile' => "for the link to the user's Profile page",
+ 'mass_mailouts:footnote:username' => "for the user's username",
+ 'mass_mailouts:footnote:email' => "for the user's e-mail address",
+
+ 'mass_mailouts:invalid_input' => "Incorrect input provided, you need a Subject and some Text",
+ 'mass_mailouts:success' => 'E-mail has been sent succesfully to %s users',
+ 'mass_mailouts:some_errors' => 'E-mail failed to be send to some of the users (failure: %s / succes: %s)',
+ 'mass_mailouts:failure' => 'E-mail failed to be send',
+
+ 'mass_mailouts:progress:text' => "Send %s of %s",
+ 'mass_mailouts:progress:window_title' => "Mass Mailouts progress",
+ );
+
+ add_translation("en", $english);
+?>
@@ -0,0 +1,36 @@
+<?php
+ /**
+ * Mass Mail outs.
+ *
+ * @package mass_mailouts
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author ColdTrick IT Solutions
+ * @copyright ColdTrick 2009
+ * @link http://www.coldtrick.com/
+ */
+
+ $dutch = array(
+ /**
+ * Menu items and titles
+ */
+ 'mass_mailouts' => 'Mass Mailouts',
+ 'mass_mailouts:email_text' => 'E-mail Bericht:',
+ 'mass_mailouts:subject' => 'E-mail Onderwerp:',
+ 'mass_mailouts:send' => 'Verstuur E-mail',
+ 'mass_mailouts:footnote' => "Je kunt de volgende tags gebruiken om de e-mails te personalizeren (kan worden gebruikt in Onderwerp en Tekst):",
+ 'mass_mailouts:footnote:displayname' => "voor de volledige naam van de gebruiker (weergave naam)",
+ 'mass_mailouts:footnote:profile' => "voor de link naar het profiel van de gebruiker",
+ 'mass_mailouts:footnote:username' => "voor de gebruikernaam",
+ 'mass_mailouts:footnote:email' => "voor het e-mailadres van de gebruiker",
+
+ 'mass_mailouts:invalid_input' => "Onjuiste invoer, je moet een Onderwerp en Text opgeven",
+ 'mass_mailouts:success' => 'E-mail is succesvol verstuurd aan %s gebruikers',
+ 'mass_mailouts:some_errors' => 'E-mail is niet aan alle gebruikers verstuurd (fouten: %s / succes: %s)',
+ 'mass_mailouts:failure' => 'E-mail is niet verstuurd',
+
+ 'mass_mailouts:progress:text' => "%s van %s verzonden",
+ 'mass_mailouts:progress:window_title' => "Mass Mailouts voortgang",
+ );
+
+ add_translation("nl", $dutch);
+?>
Oops, something went wrong.

0 comments on commit 1b47152

Please sign in to comment.