From c2168196c7b8d62c242327ab6e3691eec3537e8a Mon Sep 17 00:00:00 2001 From: Jimako Date: Tue, 26 Aug 2014 21:39:16 +0200 Subject: [PATCH 01/46] using separator that you can set in admin area --- e107_plugins/tagwords/tagwords_class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/e107_plugins/tagwords/tagwords_class.php b/e107_plugins/tagwords/tagwords_class.php index c58a1ec36..15c94773e 100644 --- a/e107_plugins/tagwords/tagwords_class.php +++ b/e107_plugins/tagwords/tagwords_class.php @@ -199,7 +199,7 @@ class tagwords return implode($this->pref['tagwords_word_seperator'], $arr); } //return a \n seperated list of tagwords for the specific item - return implode("\n", $ret); + return implode($this->pref['tagwords_word_seperator'], $ret); } return; } @@ -295,10 +295,10 @@ class tagwords //get existing word records $existing_array = $this->getRecords($tag_type, $tag_itemid, false); - $existing = explode("\n", $existing_array); + $existing = explode($this->pref['tagwords_word_seperator'], $existing_array); //create array of new posted words - $new = explode("\n", $tag_word); + $new = explode($this->pref['tagwords_word_seperator'], $tag_word); //delete the differences (delete what has been removed) $delete_diff = array_diff($existing, $new); @@ -892,4 +892,4 @@ class tagwords } //end class -?> \ No newline at end of file +?> From a812d452d4fb29fa703015dfb3b512c81575d32f Mon Sep 17 00:00:00 2001 From: Cameron Date: Fri, 3 Oct 2014 16:39:21 -0700 Subject: [PATCH 02/46] Issue #756 - User Profile addon standard for v2 added. Not yet fully implemented. --- e107_plugins/chatbox_menu/e_user.php | 38 +++++++++++++++++++ .../languages/English/English_global.php | 1 + 2 files changed, 39 insertions(+) create mode 100644 e107_plugins/chatbox_menu/e_user.php diff --git a/e107_plugins/chatbox_menu/e_user.php b/e107_plugins/chatbox_menu/e_user.php new file mode 100644 index 000000000..4764c73c4 --- /dev/null +++ b/e107_plugins/chatbox_menu/e_user.php @@ -0,0 +1,38 @@ +count("chatbox"); + } + e107::setRegistry('total_chatposts', $chatposts); + } + + + $var = array( + 0 => array('label' => LAN_PLUGIN_CHATBOX_MENU_POST, 'text' => $chatposts) + ); + + return $var; + } + +} \ No newline at end of file diff --git a/e107_plugins/chatbox_menu/languages/English/English_global.php b/e107_plugins/chatbox_menu/languages/English/English_global.php index 63c3804f7..648a37cfb 100644 --- a/e107_plugins/chatbox_menu/languages/English/English_global.php +++ b/e107_plugins/chatbox_menu/languages/English/English_global.php @@ -3,6 +3,7 @@ define("LAN_PLUGIN_CHATBOX_MENU_NAME", "Chatbox"); define("LAN_PLUGIN_CHATBOX_MENU_DESCRIPTION", "Chatbox Menu"); +define("LAN_PLUGIN_CHATBOX_MENU_POSTS", "Chatbox Posts"); // Admin Log //FIXME - Global LANS must begin with LAN_PLUGIN_{FOLDER_NAME}_ From 740b8cf29acd10775d7fb6d4a5b72c861d16f009 Mon Sep 17 00:00:00 2001 From: Cameron Date: Fri, 3 Oct 2014 20:59:05 -0700 Subject: [PATCH 03/46] Issue #755 - resending of user activation email. Added fix. Requires testing. --- e107_admin/users.php | 5 +++-- e107_handlers/shortcode_handler.php | 8 +++++++- e107_handlers/user_model.php | 24 +++++++++++++++++++----- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/e107_admin/users.php b/e107_admin/users.php index 88259fcdc..303c8fec8 100644 --- a/e107_admin/users.php +++ b/e107_admin/users.php @@ -969,6 +969,7 @@ class users_admin_ui extends e_admin_ui // custom header now auto-added in email() method //$mailheader_e107id = $id; + $check = $sysuser->email('email', array( 'mail_subject' => LAN_SIGNUP_96." ".SITENAME, @@ -1257,7 +1258,7 @@ class users_admin_ui extends e_admin_ui // activate and send password $check = $sysuser->email('quickadd', array( 'user_password' => $savePassword, - 'email_subject' => USRLAN_187.SITENAME, + 'mail_subject' => USRLAN_187.SITENAME, // TODO lan 'activation_url' => 'Your current status is Active', )); @@ -1271,7 +1272,7 @@ class users_admin_ui extends e_admin_ui $check = $sysuser->email('quickadd', array( 'user_password' => $savePassword, - 'email_subject' => USRLAN_187.SITENAME, + 'mail_subject' => USRLAN_187.SITENAME, 'activation_url' => SITEURL."signup.php?activate.".$sysuser->getId().".".$sysuser->getValue('sess'), )); break; diff --git a/e107_handlers/shortcode_handler.php b/e107_handlers/shortcode_handler.php index 4c4e173f5..45374a7d1 100644 --- a/e107_handlers/shortcode_handler.php +++ b/e107_handlers/shortcode_handler.php @@ -1054,7 +1054,13 @@ class e_parse_shortcode if ($scCode) { - $ret = eval($scCode); + $ret = @eval($scCode); + + if($ret === false && E107_DEBUG_LEVEL > 0) // Error in Code. + { + $string = print_a($scCode,true); + e107::getMessage()->addDebug('Could not parse Shortcode '.$scFile.' :: {'.$code .'} '.$string); + } } if (isset($ret) && ($ret != '' || is_numeric($ret))) diff --git a/e107_handlers/user_model.php b/e107_handlers/user_model.php index 570c2ce1c..3ed0ad867 100644 --- a/e107_handlers/user_model.php +++ b/e107_handlers/user_model.php @@ -1055,7 +1055,8 @@ class e_system_user extends e_user_model { if($this->debug) { - echo '$eml returned nothing'; + echo '$eml returned nothing on Line 1050 of user_model.php using $type = '.$type; + print_a($userInfo); } return false; } @@ -1103,6 +1104,7 @@ class e_system_user extends e_user_model $pref = e107::getPref(); $ret = array(); $tp = e107::getParser(); + $mes = e107::getMessage(); // mailer options @@ -1166,7 +1168,11 @@ class e_system_user extends e_user_model break; } - if(!$template) return array(); + if(!$template) + { + $mes->addDebug('$template is empty in user_model.php line 1171.'); // Debug only, do not translate. + return array(); + } $pass_show = varset($userInfo['user_password']); @@ -1253,13 +1259,20 @@ class e_system_user extends e_user_model return $ret; } + + + // all other email types - if(!$userInfo['email_subject']) + if(!$userInfo['mail_subject']) { - return array(); + $mes->addDebug('No Email subject provided to renderEmail() method.'); // Debug only, do not translate. + return array(); } - $ret['email_subject'] = $userInfo['email_subject']; // $EMAIL_TEMPLATE['signup']['subject']; + + $templateName = $ret['template']; + + $ret['email_subject'] = varset($EMAIL_TEMPLATE[$templateName]['subject'], $EMAIL_TEMPLATE['default']['subject']) ; // $subject; $ret['e107_header'] = $userInfo['user_id']; if (vartrue($userInfo['email_copy_to'])) { $ret['email_copy_to'] = $userInfo['email_copy_to']; } @@ -1274,6 +1287,7 @@ class e_system_user extends e_user_model $sc['USERNAME'] = $userInfo['user_name']; $sc['USERURL'] = vartrue($userInfo['user_website']) ? $userInfo['user_website'] : ""; $sc['PASSWORD'] = $pass_show ? $pass_show : '******'; + $sc['SUBJECT'] = $userInfo['mail_subject']; /* From bc1356537ad1d9a9de449307ebe91e092a86f962 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sat, 4 Oct 2014 10:33:56 -0700 Subject: [PATCH 04/46] Fixes #763 - media manager category insert error. --- e107_admin/image.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/e107_admin/image.php b/e107_admin/image.php index 7d3e7ca60..18463a2e1 100644 --- a/e107_admin/image.php +++ b/e107_admin/image.php @@ -168,9 +168,9 @@ class media_cat_ui extends e_admin_ui 'media_cat_image' => array('title'=> LAN_IMAGE, 'type' => 'image', 'data' => 'str', 'width' => '100px', 'thclass' => 'center', 'class'=>'center', 'readParms'=>'thumb=60&thumb_urlraw=0&thumb_aw=60','readonly'=>FALSE, 'batch' => FALSE, 'filter'=>FALSE), 'media_cat_owner' => array('title'=> LAN_OWNER, 'type' => 'dropdown', 'width' => 'auto', 'thclass' => 'left', 'readonly'=>FALSE), - 'media_cat_type' => array('title'=> LAN_TYPE, 'type' => 'radio', 'data'=>false, 'width' => 'auto', 'thclass' => 'left', 'validate' => true, 'nolist'=>true), + 'media_cat_type' => array('title'=> LAN_TYPE, 'type' => 'radio', 'data'=>false, 'width' => 'auto', 'thclass' => 'left', 'validate' => true, 'nolist'=>true), - 'media_cat_category' => array('title'=> LAN_CATEGORY, 'type' => 'text', 'data'=>'str', 'width' => 'auto', 'thclass' => 'left', 'readonly'=>TRUE), + 'media_cat_category' => array('title'=> LAN_CATEGORY, 'type' => 'text', 'data'=>'str', 'width' => 'auto', 'thclass' => 'left', 'readonly'=>TRUE), 'media_cat_title' => array('title'=> LAN_TITLE, 'type' => 'text', 'width' => 'auto', 'thclass' => 'left', 'readonly'=>FALSE, 'validate' => true), 'media_cat_sef' => array('title'=> LAN_SEFURL, 'type' => 'text', 'width' => 'auto', 'thclass' => 'left', 'readonly'=>FALSE), 'media_cat_diz' => array('title'=> LAN_DESCRIPTION, 'type' => 'bbarea', 'width' => '30%', 'readParms' => 'expand=...&truncate=150&bb=1','readonly'=>FALSE), // Display name @@ -210,25 +210,31 @@ class media_cat_ui extends e_admin_ui $sql = e107::getDb(); - if($sql->db_Select_gen("SELECT media_cat_owner, count(media_cat_id) as number FROM `#core_media_cat` GROUP BY media_cat_owner")) + if($sql->gen("SELECT media_cat_owner, MAX(media_cat_category) as maxnum, count(media_cat_id) as number FROM `#core_media_cat` GROUP BY media_cat_owner")) { - while($row = $sql->db_Fetch()) + while($row = $sql->fetch()) { $this->ownerCount[$row['media_cat_owner']] = $row['number']; - $own = $row['media_cat_owner']; + $own = $row['media_cat_owner']; if(!in_array($own,$restricted)) - { - + { $this->fields['media_cat_owner']['writeParms'][$own] = $own; + list($tmp,$tmp2,$maxnum) = explode("_",$row['maxnum']); // check for highest value. + if($maxnum > 0) + { + $this->ownerCount[$row['media_cat_owner']] = $maxnum; + } } } } - } + + + public function createPage() { if(!count($this->fields['media_cat_owner']['writeParms'])) From 1495b56ab5b9f6a0192c2fd0c8705ccbe0c81c69 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sat, 4 Oct 2014 10:55:14 -0700 Subject: [PATCH 05/46] Fixes #739 - Contact page USER_WIDTH unknown problem. --- e107_core/templates/contact_template.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e107_core/templates/contact_template.php b/e107_core/templates/contact_template.php index b58460e02..ba0a30cc0 100644 --- a/e107_core/templates/contact_template.php +++ b/e107_core/templates/contact_template.php @@ -65,10 +65,10 @@ $CONTACT_TEMPLATE['menu'] = ' $CONTACT_WRAPPER['form']['CONTACT_EMAIL_COPY'] = "{---}".LANCONTACT_07.""; $CONTACT_WRAPPER['form']['CONTACT_PERSON'] = "".LANCONTACT_14."
{---}"; - + //FIXME Upgrade to bootstrap3 non-table format for phone/tablet compatibility. $CONTACT_TEMPLATE['form'] = "
- +
{CONTACT_PERSON} - @@ -868,7 +1794,7 @@ function show_prefs($mailAdmin)
".LANCONTACT_03."
{CONTACT_NAME} From b9007085689e51ea039afa358a7042c8aaafbd70 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sat, 4 Oct 2014 11:26:29 -0700 Subject: [PATCH 06/46] Fixes #707 - {CPAGERELATED: types=page} issue. --- e107_plugins/page/e_related.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e107_plugins/page/e_related.php b/e107_plugins/page/e_related.php index 15f900310..162b77e71 100644 --- a/e107_plugins/page/e_related.php +++ b/e107_plugins/page/e_related.php @@ -54,7 +54,7 @@ class page_related // replace 'e_' with 'plugin-folder_' $items = array(); - $tag_regexp = "'(^|, )(".str_replace(",", "|", $tags).")(,|$)'"; + $tag_regexp = "'(^|,)(".str_replace(",", "|", $tags).")(,|$)'"; $query = "SELECT * FROM #page WHERE page_id != ".$parm['current']." AND page_class REGEXP '".e_CLASS_REGEXP."' AND page_metakeys REGEXP ".$tag_regexp." ORDER BY page_datestamp DESC LIMIT ".$parm['limit']; From 6c9680d3c07aee126e1f615ab202c5a9281da691 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sat, 4 Oct 2014 11:37:43 -0700 Subject: [PATCH 07/46] Fixes #617 - Progress bar bootstrap 2/3 compatibility. --- e107_handlers/form_handler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index 0146f4623..67ff55c3c 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -1096,7 +1096,7 @@ class e_form $class = vartrue($options['class'],''); return "
-
+
"; } From abeb140fe6f5fa6a35db25aeaf9c8053aa58b64d Mon Sep 17 00:00:00 2001 From: Cameron Date: Sun, 5 Oct 2014 00:21:58 -0700 Subject: [PATCH 08/46] Fixes #592 Missing User-extended fields when using Bootstrap with usersettings page. Closes #539 Tabs view of user-extended categories when using Bootstrap. Added missing css classes to extended-fields. --- .../batch/usersettings_shortcodes.php | 77 +++++++++++++++---- e107_core/templates/usersettings_template.php | 13 +++- e107_core/xml/user_extended.xml | 14 ++-- e107_handlers/form_handler.php | 2 +- e107_handlers/user_extended_class.php | 28 +++---- e107_themes/bootstrap3/style.css | 2 +- 6 files changed, 94 insertions(+), 42 deletions(-) diff --git a/e107_core/shortcodes/batch/usersettings_shortcodes.php b/e107_core/shortcodes/batch/usersettings_shortcodes.php index d1864e105..d1075a0dc 100755 --- a/e107_core/shortcodes/batch/usersettings_shortcodes.php +++ b/e107_core/shortcodes/batch/usersettings_shortcodes.php @@ -17,6 +17,7 @@ if (!defined('e107_INIT')) { exit; } class usersettings_shortcodes extends e_shortcode { + private $extendedTabs = false; function sc_username($parm) // This is the 'display name' { @@ -262,8 +263,8 @@ class usersettings_shortcodes extends e_shortcode - function sc_userextended_all($parm) - { + function sc_userextended_all($parm='') + { $sql = e107::getDb(); $tp = e107::getParser(); @@ -276,28 +277,59 @@ class usersettings_shortcodes extends e_shortcode $ret=""; - if($sql->db_Select_gen($qry)) + if($sql->gen($qry)) { $catList = $sql->db_getList(); } + else + { + e107::getMessage()->addDebug("No extended fields found"); + } $catList[] = array("user_extended_struct_id" => 0, "user_extended_struct_name" => LAN_USET_7); + $tabs = array(); + + if($parm == 'tabs') + { + $this->extendedTabs = true; + } + + foreach($catList as $cat) { cachevars("extendedcat_{$cat['user_extended_struct_id']}", $cat); - $ret .= $this->sc_userextended_cat($cat['user_extended_struct_id']); - // $ret .= $tp->parseTemplate("{USEREXTENDED_CAT={$cat['user_extended_struct_id']}}", TRUE, $usersettings_shortcodes); + $text = $this->sc_userextended_cat($cat['user_extended_struct_id']); + $ret .= $text; + $catName = vartrue($cat['user_extended_struct_text'], $cat['user_extended_struct_name']); + $tabs[] = array('caption'=>$catName, 'text'=>$text); } + + if($parm == 'tabs' && deftrue('BOOTSTRAP')) + { + return e107::getForm()->tabs($tabs); + } + + + return $ret; } - function sc_userextended_cat($parm) + function sc_userextended_cat($parm='') { - global $sql, $tp, $usersettings_shortcodes, $USER_EXTENDED_CAT, $extended_showed; + global $usersettings_shortcodes, $USER_EXTENDED_CAT, $extended_showed; + + if(deftrue('BOOTSTRAP')) + { + $USER_EXTENDED_CAT = e107::getCoreTemplate('usersettings','extended-category'); + } + + $sql = e107::getDb(); + $tp = e107::getParser(); + if(isset($extended_showed['cat'][$parm])) { return ""; @@ -312,9 +344,9 @@ class usersettings_shortcodes extends e_shortcode AND user_extended_struct_write IN (".USERCLASS_LIST.") AND user_extended_struct_id = ".intval($parm)." "; - if($sql->db_Select_gen($qry)) + if($sql->gen($qry)) { - $catInfo = $sql->db_Fetch(); + $catInfo = $sql->fetch(); } } @@ -328,19 +360,20 @@ class usersettings_shortcodes extends e_shortcode AND user_extended_struct_type != 0 ORDER BY user_extended_struct_order ASC "; - if($sql->db_Select_gen($qry)) + if($sql->gen($qry)) { $fieldList = $sql->db_getList(); foreach($fieldList as $field) { cachevars("extendedfield_{$cat['user_extended_struct_name']}", $field); //TODO use $this instead of parseTemplate(); - $ret .= $tp->parseTemplate("{USEREXTENDED_FIELD={$field['user_extended_struct_name']}}", TRUE, $usersettings_shortcodes); + $ret .= $this->sc_userextended_field($field['user_extended_struct_name']); + // $ret .= $tp->parseTemplate("{USEREXTENDED_FIELD={$field['user_extended_struct_name']}}", TRUE, $usersettings_shortcodes); } } } - if($ret) + if($ret && $this->extendedTabs == false) { $catName = $catInfo['user_extended_struct_text'] ? $catInfo['user_extended_struct_text'] : $catInfo['user_extended_struct_name']; if(defined($catName)) $catName = constant($catName); @@ -353,13 +386,25 @@ class usersettings_shortcodes extends e_shortcode - function sc_userextended_field($parm) + function sc_userextended_field($parm='') { - global $sql, $tp, $usersettings_shortcodes, $extended_showed, $ue, $USEREXTENDED_FIELD, $REQUIRED_FIELD; + global $usersettings_shortcodes, $extended_showed, $ue, $USEREXTENDED_FIELD, $REQUIRED_FIELD; + + if(deftrue('BOOTSTRAP')) + { + $USEREXTENDED_FIELD = e107::getCoreTemplate('usersettings','extended-field'); + } + + if(isset($extended_showed['field'][$parm])) { return ""; } + + $sql = e107::getDb(); + $tp = e107::getParser(); + + $ret = ""; $fInfo = getcachedvars("extendeddata_{$parm}"); @@ -371,9 +416,9 @@ class usersettings_shortcodes extends e_shortcode AND user_extended_struct_write IN (".USERCLASS_LIST.") AND user_extended_struct_name = '".$tp -> toDB($parm, true)."' "; - if($sql->db_Select_gen($qry)) + if($sql->gen($qry)) { - $fInfo = $sql->db_Fetch(); + $fInfo = $sql->fetch(); } } diff --git a/e107_core/templates/usersettings_template.php b/e107_core/templates/usersettings_template.php index 14fe71a8f..bb7260f60 100755 --- a/e107_core/templates/usersettings_template.php +++ b/e107_core/templates/usersettings_template.php @@ -295,7 +295,7 @@ $USERSETTINGS_TEMPLATE['edit'] = " {PHOTO_UPLOAD} {USERCLASSES} - {USEREXTENDED_ALL} + {USEREXTENDED_ALL=tabs} {SIGNATURE=cols=58&rows=4} @@ -308,11 +308,16 @@ $USERSETTINGS_TEMPLATE['edit'] = " - - "; - +$USERSETTINGS_TEMPLATE['extended-category'] = "

{CATNAME}

"; +$USERSETTINGS_TEMPLATE['extended-field'] = "
+ +
+ {FIELDVAL} {HIDEFIELD} +
+
+ "; diff --git a/e107_core/xml/user_extended.xml b/e107_core/xml/user_extended.xml index 9b77ff694..296b242a3 100644 --- a/e107_core/xml/user_extended.xml +++ b/e107_core/xml/user_extended.xml @@ -17,42 +17,42 @@ text - class='tbox' size='40' maxlength='254' + class='form-control tbox' size='40' maxlength='254' 253 253 253 text - class='tbox' size='40' maxlength='254' + class='form-control tbox' size='40' maxlength='254' 253 253 253 text - class='tbox' size='40' maxlength='254' + class='form-control tbox' size='40' maxlength='254' 253 253 253 text - class='tbox' size='40' maxlength='254' + class='form-control tbox' size='40' maxlength='254' 253 253 253 text - class='tbox' size='40' maxlength='254' + class='form-control tbox' size='40' maxlength='254' 253 253 253 text - class='tbox' size='40' maxlength='254' + class='form-control tbox' size='40' maxlength='254' 253 253 253 @@ -66,7 +66,7 @@ text - class='tbox' size='40' maxlength='254' + class='form-control tbox' size='40' maxlength='254' #^[a-z0-9]+://#si 253 253 diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index 67ff55c3c..fd5bd7563 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -890,7 +890,7 @@ class e_form } else { - $text .= ""; + $text .= ""; } // $text .= "ValueFormat: ".$dateFormat." Value: ".$value; diff --git a/e107_handlers/user_extended_class.php b/e107_handlers/user_extended_class.php index 51a000911..61641f923 100644 --- a/e107_handlers/user_extended_class.php +++ b/e107_handlers/user_extended_class.php @@ -675,10 +675,11 @@ class e107_user_extended $regex = $tp->toText($parms[1]); $regexfail = $tp->toText($parms[2]); $fname = "ue[user_".$struct['user_extended_struct_name']."]"; + $required = vartrue($struct['user_extended_struct_required']) ? "required" : ""; if(strpos($include, 'class') === FALSE) { - $include .= " class='tbox' "; + $include .= " class='form-control tbox' "; } @@ -686,7 +687,8 @@ class e107_user_extended { case EUF_TEXT : //textbox case EUF_INTEGER : //integer - $ret = ""; + $ret = ""; + return $ret; break; @@ -715,12 +717,12 @@ class e107_user_extended if(deftrue('BOOTSTRAP')) { - $ret .= $frm->radio($fname,$val,($curval == $val),array('label'=>$label)); + $ret .= $frm->radio($fname,$val,($curval == $val),array('label'=>$label, 'required'=> $struct['user_extended_struct_required'])); } else { $chk = ($curval == $val)? " checked='checked' " : ""; - $ret .= " {$label}"; + $ret .= " {$label}"; } } @@ -751,7 +753,7 @@ class e107_user_extended if(deftrue('BOOTSTRAP')) { - $ret .= $frm->checkbox($fname,$val,($curval == $val),array('label'=>$label)); + $ret .= $frm->checkbox($fname,$val,($curval == $val),array('label'=>$label, 'required'=> $struct['user_extended_struct_required'])); } else { @@ -764,7 +766,7 @@ class e107_user_extended break; case EUF_DROPDOWN : //dropdown - $ret = "\n"; $ret .= "\n"; // ensures that the user chose it. foreach($choices as $choice) { @@ -788,7 +790,7 @@ class e107_user_extended if (!method_exists($className, 'getValue')) return '???-???'; $temp->pointerReset(); - $ret = "\n"; $ret .= "\n"; // ensures that the user chooses it. while (FALSE !== ($row = $temp->getValue(0, 'next'))) { @@ -808,7 +810,7 @@ class e107_user_extended if($sql->db_Select($tp -> toDB($choices[0], true), $tp -> toDB($choices[1], true).",".$tp -> toDB($choices[2], true), "1 $order")){ $choiceList = $sql->db_getList('ALL',FALSE); - $ret = "\n"; $ret .= "\n"; // ensures that the user chose it. foreach($choiceList as $cArray) { @@ -825,7 +827,7 @@ class e107_user_extended break; case EUF_TEXTAREA : //textarea - return ""; + return ""; break; case EUF_DATE : //date @@ -839,11 +841,10 @@ class e107_user_extended break; case EUF_LANGUAGE : // language - require_once(e_HANDLER."file_class.php"); - $fl = new e_file; - $lanlist = $fl->get_dirs(e_LANGUAGEDIR); + $lanlist = e107::getLanguage()->installed(); sort($lanlist); - $ret = "\n"; $ret .= "\n"; // ensures that the user chose it. foreach($lanlist as $choice) { @@ -852,6 +853,7 @@ class e107_user_extended $ret .= "\n"; } $ret .= "\n"; + break; } diff --git a/e107_themes/bootstrap3/style.css b/e107_themes/bootstrap3/style.css index 7a15abacd..b6eea70da 100644 --- a/e107_themes/bootstrap3/style.css +++ b/e107_themes/bootstrap3/style.css @@ -112,7 +112,7 @@ img.featurebox { border-radius: 5px } .btn-featurebox, .btn-cpage { margin-top:10px } - +.tab-pane { padding-top:15px } /* CUSTOM Responsive Styles */ From 877fad903a3af40f14928e579b7a664582cfbbcc Mon Sep 17 00:00:00 2001 From: Cameron Date: Mon, 6 Oct 2014 13:51:55 -0700 Subject: [PATCH 09/46] Removed unused hidden form element. --- e107_handlers/form_handler.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index fd5bd7563..3b81ad848 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -3390,11 +3390,15 @@ class e_form case 'textarea': $text = ""; - if(vartrue($parms['append'])) // similar to comments - TODO TBD. a 'comment' field type may be better. + if(vartrue($parms['append']) && vartrue($value)) // similar to comments - TODO TBD. a 'comment' field type may be better. { $attributes['readParms'] = 'bb=1'; - $text = $this->renderValue($key, $value, $attributes).$this->hidden($key, $value).'
'; + + $text = $this->renderValue($key, $value, $attributes); + $text .= '
'; $value = ""; + + // Appending needs is performed and customized using function: beforeUpdate($new_data, $old_data, $id) } $text .= $this->textarea($key, $value, vartrue($parms['rows'], 5), vartrue($parms['cols'], 40), vartrue($parms['__options'],$parms), varset($parms['counter'], false)); From ad0491c9018d0dd3f65bdc5159231d4a9c46fb10 Mon Sep 17 00:00:00 2001 From: Cameron Date: Mon, 6 Oct 2014 17:32:36 -0700 Subject: [PATCH 10/46] Issue #539 - validation of user-extended elements will automatically switch tabs when an error is found. --- .../batch/usersettings_shortcodes.php | 4 +- e107_handlers/form_handler.php | 10 +++ e107_handlers/user_extended_class.php | 15 ++-- e107_web/js/core/front.jquery.js | 70 +++++++++++++------ 4 files changed, 69 insertions(+), 30 deletions(-) diff --git a/e107_core/shortcodes/batch/usersettings_shortcodes.php b/e107_core/shortcodes/batch/usersettings_shortcodes.php index d1075a0dc..9287a8a98 100755 --- a/e107_core/shortcodes/batch/usersettings_shortcodes.php +++ b/e107_core/shortcodes/batch/usersettings_shortcodes.php @@ -267,6 +267,8 @@ class usersettings_shortcodes extends e_shortcode { $sql = e107::getDb(); $tp = e107::getParser(); + $frm = e107::getForm(); + $qry = " SELECT * FROM #user_extended_struct @@ -428,7 +430,7 @@ class usersettings_shortcodes extends e_shortcode if(defined($fname)) $fname = constant($fname); $fname = $tp->toHTML($fname, "", "emotes_off, defs"); - if($fInfo['user_extended_struct_required'] == 1) + if($fInfo['user_extended_struct_required'] == 1 && !deftrue('BOOTSTRAP')) { $fname = str_replace("{FIELDNAME}", $fname, $REQUIRED_FIELD); } diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index 3b81ad848..78ff2ef05 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -208,6 +208,11 @@ class e_form $c = 0; foreach($array as $key=>$tab) { + if(is_numeric($key)) + { + $key = 'tab-'.$this->name2id($tab['caption']); + } + $active = ($c == 0) ? ' class="active"' : ''; $text .= ''.$tab['caption'].''; $c++; @@ -222,6 +227,11 @@ class e_form $c=0; foreach($array as $key=>$tab) { + if(is_numeric($key)) + { + $key = 'tab-'.$this->name2id($tab['caption']); + } + $active = ($c == 0) ? ' active' : ''; $text .= '
'.$tab['text'].'
'; $c++; diff --git a/e107_handlers/user_extended_class.php b/e107_handlers/user_extended_class.php index 61641f923..b2b6bebfd 100644 --- a/e107_handlers/user_extended_class.php +++ b/e107_handlers/user_extended_class.php @@ -676,6 +676,7 @@ class e107_user_extended $regexfail = $tp->toText($parms[2]); $fname = "ue[user_".$struct['user_extended_struct_name']."]"; $required = vartrue($struct['user_extended_struct_required']) ? "required" : ""; + $fid = $frm->name2id($fname); if(strpos($include, 'class') === FALSE) { @@ -687,7 +688,7 @@ class e107_user_extended { case EUF_TEXT : //textbox case EUF_INTEGER : //integer - $ret = ""; + $ret = ""; return $ret; break; @@ -722,7 +723,7 @@ class e107_user_extended else { $chk = ($curval == $val)? " checked='checked' " : ""; - $ret .= " {$label}"; + $ret .= " {$label}"; } } @@ -766,7 +767,7 @@ class e107_user_extended break; case EUF_DROPDOWN : //dropdown - $ret = "\n"; $ret .= "\n"; // ensures that the user chose it. foreach($choices as $choice) { @@ -790,7 +791,7 @@ class e107_user_extended if (!method_exists($className, 'getValue')) return '???-???'; $temp->pointerReset(); - $ret = "\n"; $ret .= "\n"; // ensures that the user chooses it. while (FALSE !== ($row = $temp->getValue(0, 'next'))) { @@ -810,7 +811,7 @@ class e107_user_extended if($sql->db_Select($tp -> toDB($choices[0], true), $tp -> toDB($choices[1], true).",".$tp -> toDB($choices[2], true), "1 $order")){ $choiceList = $sql->db_getList('ALL',FALSE); - $ret = "\n"; $ret .= "\n"; // ensures that the user chose it. foreach($choiceList as $cArray) { @@ -827,7 +828,7 @@ class e107_user_extended break; case EUF_TEXTAREA : //textarea - return ""; + return ""; break; case EUF_DATE : //date @@ -844,7 +845,7 @@ class e107_user_extended $lanlist = e107::getLanguage()->installed(); sort($lanlist); - $ret = "\n"; $ret .= "\n"; // ensures that the user chose it. foreach($lanlist as $choice) { diff --git a/e107_web/js/core/front.jquery.js b/e107_web/js/core/front.jquery.js index 623fb7351..a1be14ec9 100644 --- a/e107_web/js/core/front.jquery.js +++ b/e107_web/js/core/front.jquery.js @@ -1,4 +1,4 @@ - +/* global $ */ $(document).ready(function() { @@ -37,8 +37,8 @@ $(document).ready(function() $(".e-comment-submit").live("click", function(){ - var url = $(this).attr("data-target"); - var sort = $(this).attr("data-sort"); + var url = $(this).attr("data-target"); + var sort = $(this).attr("data-sort"); var pid = parseInt($(this).attr("data-pid")); var formid = (pid != '0') ? "#e-comment-form-reply" : "#e-comment-form"; var data = $('form'+formid).serialize() ; @@ -231,7 +231,7 @@ $(document).ready(function() url: url + '?ajax_used=1&mode=delete', data: { itemid: sp[3] }, success: function(data) { - var a = $.parseJSON(data); + var a = $.parseJSON(data); if(!a.error) { @@ -248,23 +248,23 @@ $(document).ready(function() $(".e-comment-approve").live("click", function(){ - var url = $(this).attr("data-target"); - var sp = $(this).attr('id').split("-"); - var id = "#comment-status-" + sp[3]; + var url = $(this).attr("data-target"); + var sp = $(this).attr('id').split("-"); + var id = "#comment-status-" + sp[3]; $.ajax({ type: 'POST', url: url + '?ajax_used=1&mode=approve', data: { itemid: sp[3] }, success: function(data) { - + - var a = $.parseJSON(data); - - + var a = $.parseJSON(data); + + if(!a.error) { - //TODO modify status of html on page. + //TODO modify status of html on page $(id).text(a.html) .fadeIn('slow') .addClass('e-comment-edit-success'); //TODO another class? @@ -289,28 +289,28 @@ $(document).ready(function() $(".e-rate-thumb").live("click", function(){ - var src = $(this).attr("href"); - var thumb = $(this); - var tmp = src.split('#'); - var id = tmp[1]; - var src = tmp[0]; - + var src = $(this).attr("href"); + var thumb = $(this); + var tmp = src.split('#'); + var id = tmp[1]; + var src = tmp[0]; + - $.ajax({ + $.ajax({ type: "POST", url: src, data: { ajax_used: 1, mode: 'thumb' }, dataType: "html", success: function(html) { - if(html == '') + if(html === '') { return false; } var tmp = html.split('|'); - up= tmp[0]; - down = tmp[1]; + up= tmp[0]; + down = tmp[1]; $('#'+id +'-up').text(up); $('#'+id +'-down').text(down); @@ -323,4 +323,30 @@ $(document).ready(function() }); + + + + /* Switch to Tab containing invalid form field. */ + $('input[type=submit],button[type=submit]').on('click', function() { + + var id = $(this).closest('form').attr('id'), found = false; + + $('#'+ id).find(':invalid').each(function (index, node) { + + var tab = $('#'+node.id).closest('.tab-pane').attr('id'); + // console.log(node.id); + + if(tab && (found === false)) + { + $('a[href="#'+tab+'"]').tab('show'); + found = true; + } + + }); + + return true; + }); + + + }); \ No newline at end of file From e378c1697169da51f2753721bf92526ff0219742 Mon Sep 17 00:00:00 2001 From: Cameron Date: Fri, 10 Oct 2014 20:16:11 -0700 Subject: [PATCH 11/46] Admin -> Mail : upgraded GUI to v2 standards. Template still requires attention. --- e107_admin/mailout.php | 1146 +++++++++++++++-- e107_core/templates/email_template.php | 27 +- e107_handlers/form_handler.php | 24 +- e107_handlers/mail_manager_class.php | 8 +- e107_handlers/mailout_admin_class.php | 47 +- e107_handlers/mailout_class.php | 2 +- e107_languages/English/admin/help/mailout.php | 1 + e107_languages/English/admin/lan_mailout.php | 6 +- 8 files changed, 1124 insertions(+), 137 deletions(-) diff --git a/e107_admin/mailout.php b/e107_admin/mailout.php index 57bd802a8..8590cfdfb 100644 --- a/e107_admin/mailout.php +++ b/e107_admin/mailout.php @@ -74,6 +74,1018 @@ if (!getperms('W')) header('location:'.e_BASE.'index.php'); exit; } +include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_users.php'); +include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_mailout.php'); + +require_once(e_HANDLER.'ren_help.php'); + +require_once(e_HANDLER.'userclass_class.php'); +require_once(e_HANDLER.'mailout_class.php'); // Class handler for core mailout functions +require_once(e_HANDLER.'mailout_admin_class.php'); // Admin tasks handler +require_once(e_HANDLER.'mail_manager_class.php'); // Mail DB API + + + + +class mailout_admin extends e_admin_dispatcher +{ + + protected $modes = array( + 'main' => array( + 'controller' => 'mailout_main_ui', + 'path' => null, + 'ui' => 'mailout_admin_form_ui', + 'uipath' => null + ), + 'saved' => array( + 'controller' => 'mailout_main_ui', + 'path' => null, + 'ui' => 'mailout_admin_form_ui', + 'uipath' => null + ), + 'pending' => array( + 'controller' => 'mailout_main_ui', + 'path' => null, + 'ui' => 'mailout_admin_form_ui', + 'uipath' => null + ), + 'held' => array( + 'controller' => 'mailout_main_ui', + 'path' => null, + 'ui' => 'mailout_admin_form_ui', + 'uipath' => null + ), + 'sent' => array( + 'controller' => 'mailout_main_ui', + 'path' => null, + 'ui' => 'mailout_admin_form_ui', + 'uipath' => null + ), + 'prefs' => array( + 'controller' => 'mailout_main_ui', + 'path' => null, + 'ui' => 'mailout_admin_form_ui', + 'uipath' => null + ), + 'maint' => array( + 'controller' => 'mailout_main_ui', + 'path' => null, + 'ui' => 'mailout_admin_form_ui', + 'uipath' => null + ), + 'recipients' => array( + 'controller' => 'mailout_recipients_ui', + 'path' => null, + 'ui' => 'mailout_recipients_form_ui', + 'uipath' => null + ) + + ); + + protected $adminMenu = array( + // 'makemail/makemail' => array('caption'=> LAN_MAILOUT_190, 'perm' => 'W', 'url'=>e_SELF), + 'main/list' => array('caption'=> LAN_MANAGE, 'perm'=> 'W'), + 'main/create' => array('caption'=> LAN_MAILOUT_190, 'perm' => 'W'), + 'recipients/list' => array('caption'=> "Recipients", 'perm' => 'W'), + 'other' => array('divider'=> true), + 'saved/list' => array('caption'=> LAN_MAILOUT_191, 'perm' => 'W'), + 'pending/list' => array('caption'=> LAN_MAILOUT_193, 'perm' => 'W'), + 'held/list' => array('caption'=> LAN_MAILOUT_194, 'perm' => 'W'), + 'sent/list' => array('caption'=> LAN_MAILOUT_192, 'perm' => 'W'), + 'other2' => array('divider'=> true), + 'prefs/prefs' => array('caption'=> LAN_PREFS, 'perm' => '0'), + 'maint/maint' => array('caption'=> ADLAN_40, 'perm' => '0'), + + ); + + + + protected $adminMenuAliases = array( + // 'main/edit' => 'main/list', + ); + + protected $menuTitle = LAN_MAILOUT_15; +} + +class mailout_main_ui extends e_admin_ui +{ + + //TODO Move to Class above. + protected $pluginTitle = LAN_MAILOUT_15; + protected $pluginName = LAN_MAILOUT_15; + protected $table = "mail_content"; + + // protected $listQry = "SELECT * FROM #mail_content WHERE mail_content_status = 20 "; + + + // protected $editQry = "SELECT * FROM #mail_content WHERE cust_id = {ID}"; + + protected $pid = "mail_source_id"; + protected $perPage = 10; + protected $listOrder = "mail_source_id desc"; + + protected $batchDelete = true; + protected $batchCopy = true; + + protected $tabs = array('Basic','Advanced'); //TODO Add LAN_BASIC and LAN_ADVANCED to lan_admin.php + + protected $fields = array( + 'checkboxes' => array('title'=> '', 'type' => null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center'), + 'mail_source_id' => array('title' => LAN_MAILOUT_137, 'width' =>'5%', 'thclass' => 'center', 'class'=>'center', 'forced' => TRUE), + + 'mail_selectors' => array('title' => LAN_MAILOUT_03, 'type'=>'method', 'data'=>false, 'nolist' => true, 'writeParms'=>'nolabel=0'), + 'mail_title' => array('title' => LAN_MAILOUT_135, 'type'=>'text', 'forced' => TRUE, 'data'=>'str', 'inline'=>true, 'writeParms'=>'size=xxlarge&required=1', 'help'=>'whatever'), + 'mail_sender_name' => array('title' => LAN_MAILOUT_150, 'type'=>'method', 'data'=>false), + 'mail_sender_email' => array('title' => LAN_MAILOUT_149,'type'=>'method','data'=>false), + 'mail_copy_to' => array('title' => LAN_MAILOUT_151,'tab'=>1, 'type'=>'method','data'=>false), + 'mail_bcopy_to' => array('title' => LAN_MAILOUT_152,'tab'=>1, 'type'=>'method','data'=>false), + 'mail_subject' => array('title' => LAN_MAILOUT_06, 'type'=>'text', 'forced' => TRUE,'data'=>'str', 'inline'=>true, 'writeParms'=>'size=xxlarge&required=1'), + 'mail_content_status' => array('title' => LAN_MAILOUT_136, 'tab'=>1, 'type'=> 'dropdown', 'data'=>'int', 'filter'=>false, 'inline'=>true, 'thclass' => 'left', 'class'=>'left'), + 'mail_togo_count' => array('title' => LAN_MAILOUT_83, 'noedit'=>true, 'type'=>'number'), + 'mail_sent_count' => array('title' => LAN_MAILOUT_82, 'noedit'=>true, 'type'=>'number'), + 'mail_fail_count' => array('title' => LAN_MAILOUT_128, 'noedit'=>true, 'type'=>'number'), + 'mail_bounce_count' => array('title' => LAN_MAILOUT_144, 'noedit'=>true, 'type'=>'number'), + 'mail_start_send' => array('title' => LAN_MAILOUT_131,'noedit'=>true, 'type'=>'number', 'proc' => 'sdatetime'), + 'mail_end_send' => array('title' => LAN_MAILOUT_132, 'noedit'=>true, 'type'=>'number', 'proc' => 'sdatetime'), + 'mail_create_date' => array('title' => LAN_MAILOUT_130, 'noedit'=>true, 'type'=>'datestamp', 'proc' => 'sdatetime'), + 'mail_creator' => array('title' => LAN_MAILOUT_85, 'noedit'=>true, 'type'=>'user', 'proc' => 'username'), + 'mail_create_app' => array('title' => LAN_MAILOUT_133, 'noedit'=>true), + 'mail_e107_priority' => array('title' => LAN_MAILOUT_134, 'noedit'=>true), + 'mail_notify_complete' => array('title' => LAN_MAILOUT_243, 'noedit'=>true, 'nolist' => true), + 'mail_last_date' => array('title' => LAN_MAILOUT_129, 'noedit'=>true, 'type'=>'int', 'proc' => 'sdatetime'), + 'mail_attach' => array('title' => LAN_MAILOUT_153, 'tab'=>1, 'type'=>'method','data'=>false), + 'mail_include_images' => array('title' => LAN_MAILOUT_224, 'tab'=>1, 'type'=>'boolean','data'=>false, 'proc' => 'yesno'), + 'mail_send_style' => array('title' => LAN_MAILOUT_154,'type'=>'method','data'=>false), + 'mail_body' => array('title' => LAN_MAILOUT_100, 'type'=>'bbarea', 'proc' => 'trunc200'), + 'mail_body_templated' => array('title' => LAN_MAILOUT_257, 'noedit'=>true, 'proc' => 'chars'), + 'mail_other' => array('title' => LAN_MAILOUT_84, 'type'=>null, 'noedit'=>true, 'data'=>'array', 'nolist'=>true), + + 'options' => array('title' => LAN_OPTIONS, 'type'=>'method', 'width'=>'10%', 'forced' => TRUE) + + ); + + + + + protected $fieldpref = array('checkboxes', 'mail_source_id', 'mail_title', 'mail_subject', 'mail_content_status', 'options'); + + + // optional, if $pluginName == 'core', core prefs will be used, else e107::getPluginConfig($pluginName); + protected $prefs = array( + // 'after_submit' => array('title'=> 'Custom After Submit Text:', 'type'=>'bbarea') + // 'submit_question' => array('title'=> 'Allow submitting of Questions by:', 'type'=>'userclass'), + // 'classic_look' => array('title'=> 'Use Classic Layout', 'type'=>'boolean') + ); + + + + + public $mailAdmin = null; + + private $selectFields = array('email_to', + 'extended_1_name','extended_1_value', + 'extended_2_name', 'extended_2_value', + 'user_search_name', 'user_search_value', + 'last_visit_match', 'last_visit_date' + ); + + + private $mailOtherFields = array( + 'mail_sender_email', + 'mail_sender_name', + 'mail_copy_to', + 'mail_bcopy_to', + 'mail_attach', + 'mail_send_style', // HTML, text, template name etc + 'mail_selectors', // Only used internally + 'mail_include_images', // Used to determine whether to embed images, or link to them + 'mail_body_alt' , // If non-empty, use for alternate email text (generally the 'plain text' alternative) + 'mail_overrides' + ); + + + function init() + { + $action = varset($_GET['mode'], 'main'); + $this->mailAdmin = new mailoutAdminClass($action); + + if ($this->mailAdmin->loadMailHandlers() == 0) + { + e107::getMessage()->addDebug('No mail handlers loaded!!'); + + } + + /* + define('MAIL_STATUS_SENT', 0); // Mail sent. Email handler happy, but may have bounced (or may be yet to bounce) + define('MAIL_STATUS_BOUNCED', 1); + define('MAIL_STATUS_CANCELLED', 2); + define('MAIL_STATUS_PARTIAL', 3); // A run which was abandoned - errors, out of time etc + define('MAIL_STATUS_FAILED', 5); // Failure on initial send - rejected by selected email handler + // This must be the numerically highest 'processing complete' code + define('MAIL_STATUS_PENDING', 10); // Mail which is in the sending list (even if outside valid sending window) + // This must be the numerically lowest 'not sent' code + // E107_EMAIL_MAX_TRIES values used in here for retry counting + define('MAIL_STATUS_MAX_ACTIVE', 19); // Highest allowable 'not sent or processed' code + define('MAIL_STATUS_SAVED', 20); // Identifies an email which is just saved (or in process of update) + define('MAIL_STATUS_HELD',21); // Held pending release + define('MAIL_STATUS_TEMP', 22); // Tags entries which aren't yet in any list + */ + + $types = array(10=>'Pending',20=>"Saved", 21=>"Held", 0=>'Sent', 1=>'Bounced', 2=>'Cancelled', 3=> 'Partial', 5=>'Failed', 19 => "Max Active", 22=>"Temp"); + + + $qr = array('saved'=>20,'pending'=>10,'held'=>21,'sent'=>0); + + if($action !== 'main' ) + { + $this->listQry = "SELECT * FROM #mail_content WHERE mail_content_status = ".varset($qr[$action],20); + } + else + { + $this->fields['options']['type'] = ''; + } + + $this->fields['mail_content_status']['writeParms'] = $types; + + + if (getperms('0')) + { + if (isset($_POST['testemail'])) + { // Send test email - uses standard 'single email' handler + if(trim($_POST['testaddress']) == '') + { + $mes->addError(LAN_MAILOUT_19); + $subAction = 'error'; + } + else + { + $mailheader_e107id = USERID; + require_once(e_HANDLER.'mail.php'); + $add = ($pref['mailer']) ? " (".strtoupper($pref['mailer']).")" : ' (PHP)'; + $sendto = trim($_POST['testaddress']); + if (!sendemail($sendto, LAN_MAILOUT_113." ".SITENAME.$add, str_replace("[br]", "\n", LAN_MAILOUT_114),LAN_MAILOUT_189)) + { + $mes->addError(($pref['mailer'] == 'smtp') ? LAN_MAILOUT_67 : LAN_MAILOUT_106); + } + else + { + $mes->addSuccess(LAN_MAILOUT_81. ' ('.$sendto.')'); + $admin_log->log_event('MAIL_01',$sendto,E_LOG_INFORMATIVE,''); + } + } + } + elseif (isset($_POST['updateprefs'])) + { + $this->saveMailPrefs($mes); // TODO check if functional, $emessage -> $mes + } + } + + + + } + + + public function beforeCreate($new_data, $old_data) + { + $ret = $this->processData($new_data); + + $ret['mail_create_date'] = time(); + $ret['mail_creator'] = USERID; + $ret['mail_content_status'] = 20; // Default status is 'Saved'; + + return $ret; + + } + + + public function beforeUpdate($new_data, $old_data, $id) + { + return $this->processData($new_data); + } + + + /** + * Process Posted Data + */ + private function processData($new_data) + { + $other = array(); + + $ret = $new_data; + + foreach($new_data as $k=>$v) + { + if(in_array($k, $this->mailOtherFields)) + { + $other[$k] = $v; + unset($ret[$k]); + } + } + + $other['mail_selectors'] = $this->mailAdmin->getAllSelectors(); + + + $ret['mail_attach'] = trim($new_data['mail_attach']); + $ret['mail_send_style'] = varset($new_data['mail_send_style'],'textonly'); + $ret['mail_include_images'] = (isset($new_data['mail_include_images']) ? 1 : 0); + $ret['mail_other'] = $other; // type is set to 'array' in $fields. + + // e107::getMessage()->addInfo(print_a($ret,true)); + return $ret; + } + + + /* + function createPage() + { + if (!isset($mailData) || !is_array($mailData)) + { + $mailData = array(); // Empty array just in case + } + + if($id = $this->getId()) + { + $mailData = e107::getDB()->retrieve('mail_content','*','mail_source_id='.$id); + } + + return $this->mailAdmin->show_mailform($mailData); + + } + */ + + + + function maintPage() + { + if (!getperms('0')) + { + return; + } + + $mes = e107::getMessage(); + $ns = e107::getRender(); + $frm = e107::getForm(); + + $text = " + +
+ + + + + + + "; + + $text .= ""; + $text .= "
".LAN_MAILOUT_182." + + ".$frm->admin_button('email_dross','no-value','delete', LAN_RUN)." +
".LAN_MAILOUT_252."
\n
"; + + return $text; + + // return $ns->tablerender(ADLAN_136.SEP.ADLAN_40, $text, 'maint',true); + + } + + function prefsPage() + { + if (!getperms('0')) + { + return; + } + $pref = e107::getPref(); + $e107 = e107::getInstance(); + $frm = e107::getForm(); + $mes = e107::getMessage(); + $ns = e107::getRender(); + + + e107::getCache()->CachePageMD5 = '_'; + $lastload = e107::getCache()->retrieve('emailLastBounce',FALSE,TRUE,TRUE); + $lastBounce = round((time() - $lastload) / 60); + + $lastBounceText = ($lastBounce > 1256474) ? "Never" : "".$lastBounce . " minutes ago."; + + $text = " +
+
+ ".LAN_MAILOUT_110." + + + + + + + + + + + + + + + + + + + + + \n + + + + + + \n + + + + + \n"; + + if (isset($pref['e_mailout_list'])) // Allow selection of email address sources + { + $text .= " + + + \n"; + } + + list($mail_log_option,$mail_log_email) = explode(',',varset($pref['mail_log_options'],'0,0')); + + $check = ($mail_log_email == 1) ? " checked='checked'" : ""; + + + $logOptions = array(LAN_MAILOUT_73,LAN_MAILOUT_74,LAN_MAILOUT_75,LAN_MAILOUT_119); + + $text .= " + + \n"; + /* + $text .= " + \n + ".LAN_MAILOUT_76. + " + \n"; + */ + + + $text .= "
".LAN_MAILOUT_110."
".$frm->admin_button('testemail', LAN_MAILOUT_112,'other')."  + +
".LAN_MAILOUT_115."
+ ".LAN_MAILOUT_116."
"; + + + +// SMTP. --------------> + $smtp_opts = explode(',',varset($pref['smtp_options'],'')); + $smtpdisp = ($pref['mailer'] != 'smtp') ? "style='display:none;'" : ''; + $text .= "
+ + + + + + "; + $text .= " + + + + + + + + + + + + + + + + + "; + + $text .= " + + "; + + $checked = (in_array('useVERP',$smtp_opts) ? "checked='checked'" : ""); + $text .= " + + +
".LAN_MAILOUT_87.":   + +
".LAN_MAILOUT_88.": (".LAN_OPTIONAL.")   + +
".LAN_MAILOUT_89.": (".LAN_OPTIONAL.")   + +
".LAN_MAILOUT_90." + \n
".LAN_MAILOUT_94."
".LAN_MAILOUT_57." + "; + $checked = (varsettrue($pref['smtp_keepalive']) ) ? "checked='checked'" : ''; + $text .= " +
".LAN_MAILOUT_95." + +
"; + + + /* FIXME - posting SENDMAIL path triggers Mod-Security rules. + // Sendmail. --------------> + $senddisp = ($pref['mailer'] != 'sendmail') ? "style='display:none;'" : ''; + $text .= "
"; + $text .= " + + + + + +
".LAN_MAILOUT_20.":   + +
"; + */ + + $text .="
".LAN_MAILOUT_222.""; + $text .= $this->mailAdmin->sendStyleSelect(varset($pref['mail_sendstyle'], 'textonly'), 'mail_sendstyle'); + $text .= + "".LAN_MAILOUT_223." +
".LAN_MAILOUT_25." ".LAN_MAILOUT_26." + ".LAN_MAILOUT_27. + " ".LAN_MAILOUT_29.".
+ ".LAN_MAILOUT_30." +
".LAN_MAILOUT_156." + ".LAN_MAILOUT_157." +
".LAN_MAILOUT_77." "; + + $mail_enable = explode(',',$pref['mailout_enabled']); + + foreach ($pref['e_mailout_list'] as $mailer => $v) + { + $check = (in_array($mailer,$mail_enable)) ? "checked='checked'" : ""; + $text .= "  {$mailer}
"; + } + + $text .= "
".LAN_MAILOUT_72." + ".$frm->select('mail_log_option',$logOptions,$mail_log_option); + $text .= " ".$frm->checkbox('mail_log_email', 1, $check, 'label='.LAN_MAILOUT_76); + $text .= "
+
+ ".LAN_MAILOUT_31." + + + + + + + + +
".LAN_MAILOUT_231.""; + + // bounce divs = mail_bounce_none, mail_bounce_auto, mail_bounce_mail + $autoDisp = ($pref['mail_bounce'] != 'auto') ? "style='display:none;'" : ''; + $autoMail = ($pref['mail_bounce'] != 'mail') ? "style='display:none;'" : ''; + $bounceOpts = array('none' => LAN_MAILOUT_232, 'auto' => LAN_MAILOUT_233, 'mail' => LAN_MAILOUT_234); + $text .= "\n
+ + + + + + + + + + + + + +
".LAN_MAILOUT_32."
".LAN_MAILOUT_233."".(e_DOCROOT).e107::getFolder('handlers')."bounce_handler.php"; + + + if(!is_readable(e_HANDLER.'bounce_handler.php')) + { + $text .= "
".LAN_MAILOUT_161.''; + } + elseif(!is_executable(e_HANDLER.'bounce_handler.php')) // Seems to give wrong answers on Windoze + { + $text .= "
".LAN_MAILOUT_162.''; + } + $text .= "
".LAN_MAILOUT_235."
".LAN_MAILOUT_236."".$lastBounceText."
"; + + // Parameters for mail-account based bounce processing + $text .= " + + + + + + + + + + + \n + "; + + $check = ($pref['mail_bounce_delete']==1) ? " checked='checked'" : ""; + $text .= ""; + + $check = ($pref['mail_bounce_auto']==1) ? " checked='checked'" : ""; + $text .= " + + +
".LAN_MAILOUT_32."
".LAN_MAILOUT_33."
".LAN_MAILOUT_34."
".LAN_MAILOUT_35."
".LAN_MAILOUT_120."
".LAN_MAILOUT_36."
".LAN_MAILOUT_245." ".LAN_MAILOUT_246."
+ +
".$frm->admin_button('updateprefs',LAN_MAILOUT_28,'update')."
+ +
"; + + return $text; +// $caption = ADLAN_136.SEP.LAN_PREFS; +// $ns->tablerender($caption, $mes->render(). $text); + + } + + + + + + + + + // Update Preferences. (security handled elsewhere) + function saveMailPrefs(&$mes) // $emessage to $mes, working? + { + if(!getperms('0')) + { + return; + } + + //$pref = e107::getPref(); + $e107 = e107::getInstance(); + $tp = e107::getParser(); + $mes = e107::getMessage(); + + $bounceOpts = array('none' => LAN_MAILOUT_232, 'auto' => LAN_MAILOUT_233, 'mail' => LAN_MAILOUT_234); + unset($temp); + if (!in_array($_POST['mailer'], array('smtp', 'sendmail', 'php'))) $_POST['mailer'] = 'php'; + $temp['mailer'] = $_POST['mailer']; + // Allow qmail as an option as well - works much as sendmail + if ((strpos($_POST['sendmail'],'sendmail') !== FALSE) || (strpos($_POST['sendmail'],'qmail') !== FALSE)) + { + $temp['sendmail'] = $tp->toDB($_POST['sendmail']); + } + else + { + $temp['sendmail'] = ''; + } + $temp['smtp_server'] = $tp->toDB($_POST['smtp_server']); + $temp['smtp_username'] = $tp->toDB($_POST['smtp_username']); + $temp['smtp_password'] = $tp->toDB($_POST['smtp_password']); + + $smtp_opts = array(); + switch (trim($_POST['smtp_options'])) + { + case 'smtp_ssl' : + $smtp_opts[] = 'secure=SSL'; + break; + case 'smtp_tls' : + $smtp_opts[] = 'secure=TLS'; + break; + case 'smtp_pop3auth' : + $smtp_opts[] = 'pop3auth'; + break; + } + if (varsettrue($_POST['smtp_keepalive'])) $smtp_opts[] = 'keepalive'; + if (varsettrue($_POST['smtp_useVERP'])) $smtp_opts[] = 'useVERP'; + + $temp['smtp_options'] = implode(',',$smtp_opts); + + $temp['mail_sendstyle'] = $tp->toDB($_POST['mail_sendstyle']); + $temp['mail_pause'] = intval($_POST['mail_pause']); + $temp['mail_pausetime'] = intval($_POST['mail_pausetime']); + $temp['mail_workpertick'] = intval($_POST['mail_workpertick']); + $temp['mail_workpertick'] = min($temp['mail_workpertick'],1000); + $temp['mail_bounce'] = isset($bounceOpts[$_POST['mail_bounce']]) ? $_POST['mail_bounce'] : 'none'; + $temp['mail_bounce_auto'] = 0; // Make sure this is always defined + switch ($temp['mail_bounce']) + { + case 'none' : + $temp['mail_bounce_email'] = ''; + break; + case 'auto' : + $temp['mail_bounce_email'] = $tp->toDB($_POST['mail_bounce_email2']); + break; + case 'mail' : + $temp['mail_bounce_email'] = $tp->toDB($_POST['mail_bounce_email']); + $temp['mail_bounce_auto'] = intval($_POST['mail_bounce_auto']); + break; + } + $temp['mail_bounce_pop3'] = $tp->toDB($_POST['mail_bounce_pop3']); + $temp['mail_bounce_user'] = $tp->toDB($_POST['mail_bounce_user']); + $temp['mail_bounce_pass'] = $tp->toDB($_POST['mail_bounce_pass']); + $temp['mail_bounce_type'] = $tp->toDB($_POST['mail_bounce_type']); + $temp['mail_bounce_delete'] = intval(varset($_POST['mail_bounce_delete'], 0)); + + $temp['mailout_enabled'] = implode(',',varset($_POST['mail_mailer_enabled'], '')); + $temp['mail_log_options'] = intval($_POST['mail_log_option']).','.intval($_POST['mail_log_email']); + + foreach ($temp as &$t) + { + if ($t === NULL) $t = ''; + } + $pref = e107::pref('core'); // Core Prefs Array. + if (e107::getAdminLog()->logArrayDiffs($temp, $pref, 'MAIL_03')) + { + e107::getConfig()->updatePref($temp); + e107::getConfig()->save(false); // Only save if changes - generates its own message + } + else + { + $mes->addInfo(LAN_NO_CHANGE); + } + } + + + +} + +class mailout_admin_form_ui extends e_admin_form_ui +{ + + public function mail_selectors($curval, $mode) + { + $val = stripslashes($this->getController()->getModel()->get('mail_other')); + $data = e107::unserialize($val); + + switch($mode) + { + case 'read': + return varset($data['mail_send_style'], ''); + break; + + case 'write': + return $this->getController()->mailAdmin->emailSelector('all', varset($data['mail_selectors'], FALSE)); + break; + + case 'filter': + case 'batch': + // return $controller->getcustCategoryTree(); + break; + + } + + } + + + + + public function mail_send_style($curVal, $mode) + { + $val = stripslashes($this->getController()->getModel()->get('mail_other')); + $data = e107::unserialize($val); + + switch($mode) + { + case 'read': + return varset($data['mail_send_style'], ''); + break; + + case 'write': + return $this->getController()->mailAdmin->sendStyleSelect(varset($data['mail_send_style'], ''),'mail_send_style'); + break; + + case 'filter': + case 'batch': + // return $controller->getcustCategoryTree(); + break; + + } + + + } + + + private function mailDetails($field, $mode) + { + + switch($mode) + { + case 'read': + $val = stripslashes($this->getController()->getListModel()->get('mail_other')); + $data = e107::unserialize($val); + return $data[$field]; + break; + + case 'write': + $val = stripslashes($this->getController()->getModel()->get('mail_other')); + $data = e107::unserialize($val); + + if($field == 'mail_sender_name' && !vartrue($data['mail_sender_name'])) + { + $data['mail_sender_name'] = USERNAME; + } + + if($field == 'mail_sender_email' && !vartrue($data['mail_sender_email'])) + { + $data['mail_sender_email'] = USEREMAIL; + } + + + return $this->text($field, $data[$field],70, 'size=xxlarge'); + break; + + case 'filter': + case 'batch': + // return $controller->getcustCategoryTree(); + break; + + } + } + + + public function mail_sender_name($curVal,$mode) + { + return $this->mailDetails('mail_sender_name', $mode); + } + + public function mail_sender_email($curVal,$mode) + { + return $this->mailDetails('mail_sender_email', $mode); + } + + public function mail_copy_to($curVal,$mode) + { + return $this->mailDetails('mail_copy_to', $mode); + } + + public function mail_bcopy_to($curVal,$mode) + { + return $this->mailDetails('mail_bcopy_to', $mode); + } + + public function mail_attach($curVal,$mode) + { + if($mode == 'read') + { + $val = stripslashes($this->getController()->getListModel()->get('mail_other')); + $data = e107::unserialize($val); + return basename($data['mail_attach']); + } + + if($mode == 'write') + { + $val = stripslashes($this->getController()->getModel()->get('mail_other')); + $data = e107::unserialize($val); + return $this->filepicker('mail_attach',$data['mail_attach'], $mode); + } + + } + + + function options() + { + $controller = $this->getController(); + + $mode = $controller->getMode(); + $mailData = $controller->getListModel()->getData(); + + return $controller->mailAdmin->makeMailOptions($mode,$mailData); + + } + +} + + + + + +class mailout_recipients_ui extends e_admin_ui +{ + + //TODO Move to Class above. + protected $pluginTitle = LAN_MAILOUT_15; + protected $pluginName = LAN_MAILOUT_15; + protected $table = "mail_recipients"; + + // protected $listQry = "SELECT * FROM #mail_content WHERE mail_content_status = 20 "; + + + // protected $editQry = "SELECT * FROM #mail_content WHERE cust_id = {ID}"; + + protected $pid = "mail_target_id"; + protected $perPage = 10; + protected $listOrder = "mail_target_id desc"; + + protected $batchDelete = true; + + // protected $tabs = array('General','Details', 'Questionnaire', 'Correspondence'); + + protected $fields = array( + 'checkboxes' => array('title'=> '', 'type' => null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center'), + 'mail_target_id' => array('title' => LAN_MAILOUT_143, 'thclass' => 'center', 'forced' => TRUE), + 'mail_recipient_id' => array('title' => LAN_MAILOUT_142, 'thclass' => 'center'), + 'mail_recipient_name' => array('title' => LAN_MAILOUT_141, 'forced' => TRUE), + 'mail_recipient_email' => array('title' => LAN_MAILOUT_140, 'thclass' => 'left', 'forced' => TRUE), + 'mail_status' => array('title' => LAN_MAILOUT_138, 'thclass' => 'center', 'proc' => 'contentstatus'), + 'mail_detail_id' => array('title' => LAN_MAILOUT_137, 'type'=>'dropdown', 'filter'=>true), + 'mail_send_date' => array('title' => LAN_MAILOUT_139, 'proc' => 'sdatetime'), + 'mail_target_info' => array('title' => LAN_MAILOUT_148, 'proc' => 'array'), + 'options' => array('title' => LAN_OPTIONS, 'width'=>'10%', 'forced' => TRUE) + ); + + + protected $fieldpref = array('checkboxes', 'mail_target_id', 'mail_recipient_name', 'mail_recipient_email', 'mail_detail_id', 'mail_status', 'options'); + + + function init() + { + $sql = e107::getDb(); + $sql->gen("SELECT r.mail_detail_id,c.mail_title FROM #mail_recipients AS r LEFT JOIN #mail_content as c ON r.mail_detail_id = c.mail_source_id GROUP BY r.mail_detail_id"); + + while($row = $sql->fetch()) + { + $array[] = $row['mail_title']; + } + $this->fields['mail_detail_id']['writeParms'] = $array; + + + if(strpos($_GET['filter_options'],'mail_detail_id__')===false) + { + $ns = e107::getRender(); + e107::getMessage()->addInfo("Please select a mailing list from the filter menu below to view recipients."); + $this->listQry = "SELECT * FROM #mail_recipients WHERE mail_target_id = 0"; // simulated empty result. + return false; + } + + + + + } + + +} + + + +class mailout_recipients_form_ui extends e_admin_form_ui +{ + + + +} + + +new mailout_admin(); + + + + + + + + + + + + + + $e_sub_cat = 'mail'; @@ -84,15 +1096,7 @@ if(vartrue($_GET['mode']) == "progress") exit; } -require_once(e_HANDLER.'ren_help.php'); -include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_users.php'); -include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_mailout.php'); -require_once(e_HANDLER.'userclass_class.php'); -require_once(e_HANDLER.'mailout_class.php'); // Class handler for core mailout functions -require_once(e_HANDLER.'mailout_admin_class.php'); // Admin tasks handler -require_once(e_HANDLER.'mail_manager_class.php'); // Mail DB API -require_once (e_HANDLER.'message_handler.php'); $mes = e107::getMessage(); $tp = e107::getParser(); @@ -131,6 +1135,9 @@ if ($mailAdmin->loadMailHandlers() == 0) require_once(e_ADMIN.'auth.php'); +e107::getAdminUI()->runPage(); + +require_once(e_ADMIN.'footer.php'); @@ -174,6 +1181,8 @@ if (isset($_POST['targetaction'])) } } + +// e107::getMessage()->addDebug("Action=".$action); //echo "Action: {$action} MailId: {$mailId} Target: {$targetId}
"; // ----------------- Actions -------------------> @@ -181,6 +1190,7 @@ if (isset($_POST['targetaction'])) switch ($action) { + /* case 'prefs' : if (getperms('0')) { @@ -214,7 +1224,8 @@ switch ($action) } } break; - + */ + /* case 'mailcopy' : // Copy existing email and go to edit screen if (isset($_POST['mailaction'])) { @@ -228,7 +1239,7 @@ switch ($action) unset($mailData['mail_source_id']); } break; - + */ case 'mailedit' : // Edit existing mail if (isset($_POST['mailaction'])) { @@ -398,7 +1409,7 @@ switch ($action) case 'mailshowtemplate' : if (isset($_POST['etrigger_ecolumns'])) { - $mailAdmin->mailbodySaveColumnPref($action); + // $mailAdmin->mailbodySaveColumnPref($action); } break; @@ -424,8 +1435,8 @@ switch ($action) default : - $mes->addError('Code malfunction 23! ('.$action.')'); - $ns->tablerender(LAN_MAILOUT_97, $mes->render()); + // $mes->addError('Code malfunction 23! ('.$action.')'); + // $ns->tablerender(LAN_MAILOUT_97, $mes->render()); exit; // Could be a hack attempt } // switch($action) - end of 'executive' tasks @@ -548,7 +1559,7 @@ switch ($action) case 'sent' : case 'pending' : case 'held' : - $mailAdmin->showEmailList($action, -1, -1); + // $mailAdmin->showEmailList($action, -1, -1); break; case 'mailshowtemplate' : // Show the templated email @@ -564,7 +1575,7 @@ switch ($action) break; case 'recipients' : - $mailAdmin->showmailRecipients($mailId, $action); + // $mailAdmin->showmailRecipients($mailId, $action); break; case 'makemail' : @@ -670,101 +1681,16 @@ function sendProgress() } -// Update Preferences. (security handled elsewhere) -function saveMailPrefs(&$mes) // $emessage to $mes, working? -{ - //$pref = e107::getPref(); - $e107 = e107::getInstance(); - $tp = e107::getParser(); - - $bounceOpts = array('none' => LAN_MAILOUT_232, 'auto' => LAN_MAILOUT_233, 'mail' => LAN_MAILOUT_234); - unset($temp); - if (!in_array($_POST['mailer'], array('smtp', 'sendmail', 'php'))) $_POST['mailer'] = 'php'; - $temp['mailer'] = $_POST['mailer']; - // Allow qmail as an option as well - works much as sendmail - if ((strpos($_POST['sendmail'],'sendmail') !== FALSE) || (strpos($_POST['sendmail'],'qmail') !== FALSE)) - { - $temp['sendmail'] = $tp->toDB($_POST['sendmail']); - } - else - { - $temp['sendmail'] = ''; - } - $temp['smtp_server'] = $tp->toDB($_POST['smtp_server']); - $temp['smtp_username'] = $tp->toDB($_POST['smtp_username']); - $temp['smtp_password'] = $tp->toDB($_POST['smtp_password']); - - $smtp_opts = array(); - switch (trim($_POST['smtp_options'])) - { - case 'smtp_ssl' : - $smtp_opts[] = 'secure=SSL'; - break; - case 'smtp_tls' : - $smtp_opts[] = 'secure=TLS'; - break; - case 'smtp_pop3auth' : - $smtp_opts[] = 'pop3auth'; - break; - } - if (varsettrue($_POST['smtp_keepalive'])) $smtp_opts[] = 'keepalive'; - if (varsettrue($_POST['smtp_useVERP'])) $smtp_opts[] = 'useVERP'; - - $temp['smtp_options'] = implode(',',$smtp_opts); - - $temp['mail_sendstyle'] = $tp->toDB($_POST['mail_sendstyle']); - $temp['mail_pause'] = intval($_POST['mail_pause']); - $temp['mail_pausetime'] = intval($_POST['mail_pausetime']); - $temp['mail_workpertick'] = intval($_POST['mail_workpertick']); - $temp['mail_workpertick'] = min($temp['mail_workpertick'],1000); - $temp['mail_bounce'] = isset($bounceOpts[$_POST['mail_bounce']]) ? $_POST['mail_bounce'] : 'none'; - $temp['mail_bounce_auto'] = 0; // Make sure this is always defined - switch ($temp['mail_bounce']) - { - case 'none' : - $temp['mail_bounce_email'] = ''; - break; - case 'auto' : - $temp['mail_bounce_email'] = $tp->toDB($_POST['mail_bounce_email2']); - break; - case 'mail' : - $temp['mail_bounce_email'] = $tp->toDB($_POST['mail_bounce_email']); - $temp['mail_bounce_auto'] = intval($_POST['mail_bounce_auto']); - break; - } - $temp['mail_bounce_pop3'] = $tp->toDB($_POST['mail_bounce_pop3']); - $temp['mail_bounce_user'] = $tp->toDB($_POST['mail_bounce_user']); - $temp['mail_bounce_pass'] = $tp->toDB($_POST['mail_bounce_pass']); - $temp['mail_bounce_type'] = $tp->toDB($_POST['mail_bounce_type']); - $temp['mail_bounce_delete'] = intval(varset($_POST['mail_bounce_delete'], 0)); - - $temp['mailout_enabled'] = implode(',',varset($_POST['mail_mailer_enabled'], '')); - $temp['mail_log_options'] = intval($_POST['mail_log_option']).','.intval($_POST['mail_log_email']); - - foreach ($temp as &$t) - { - if ($t === NULL) $t = ''; - } - $pref = e107::pref('core'); // Core Prefs Array. - if (e107::getAdminLog()->logArrayDiffs($temp, $pref, 'MAIL_03')) - { - e107::getConfig()->updatePref($temp); - e107::getConfig()->save(false); // Only save if changes - generates its own message - } - else - { - $mes->addInfo(LAN_NO_CHANGE); - } -} - //---------------------------------------------------- // MAILER OPTIONS //---------------------------------------------------- - +/* function show_prefs($mailAdmin) { + return; + $pref = e107::getPref(); $e107 = e107::getInstance(); $frm = e107::getForm(); @@ -790,7 +1716,7 @@ function show_prefs($mailAdmin)
".LAN_MAILOUT_110."
".$frm->admin_button('testemail', LAN_MAILOUT_112,'other')."  + ".$frm->admin_button('testemail', LAN_MAILOUT_112,'other')." 
"; - +*/ /* FIXME - posting SENDMAIL path triggers Mod-Security rules. // Sendmail. --------------> $senddisp = ($pref['mailer'] != 'sendmail') ? "style='display:none;'" : ''; @@ -883,7 +1809,7 @@ function show_prefs($mailAdmin) "; */ - +/* $text .=" @@ -1036,7 +1962,7 @@ function show_prefs($mailAdmin) $caption = ADLAN_136.SEP.LAN_PREFS; $ns->tablerender($caption, $mes->render(). $text); } - +*/ //----------------------------------------------------------- @@ -1044,6 +1970,8 @@ function show_prefs($mailAdmin) //----------------------------------------------------------- function show_maint($debug = FALSE) { + return; + $mes = e107::getMessage(); $ns = e107::getRender(); $frm = e107::getForm(); @@ -1069,7 +1997,7 @@ function show_maint($debug = FALSE) } - +/* function mailout_adminmenu() { $tp = e107::getParser(); @@ -1111,6 +2039,8 @@ function mailout_adminmenu() } show_admin_menu(LAN_MAILOUT_15, $action, $var); } +*/ + function headerjs() diff --git a/e107_core/templates/email_template.php b/e107_core/templates/email_template.php index aecc3d9a9..c9e5e5304 100644 --- a/e107_core/templates/email_template.php +++ b/e107_core/templates/email_template.php @@ -297,6 +297,7 @@ $MONTHLYUPDATE_TEMPLATE = array( /** Standardized v2 template rewrite + * * Format for individual emails sent by e107 (not bulk emails for now) - a work in progress - bulk could be ported later. * @see e107Email::sendEmail(); * Aim: to make email templates follow the same spec. as other templates while remaining as intuitive as other v2 templates in e107. @@ -396,22 +397,35 @@ $EMAIL_TEMPLATE['quickadduser']['footer'] = $EMAIL_TEMPLATE['default']['footer' -// --------------------------------- +// ------- Notify (@see admin-> notify) - -// Notify (@see admin-> notify) $EMAIL_TEMPLATE['notify']['subject'] = '{SITENAME}: {SUBJECT} '; $EMAIL_TEMPLATE['notify']['header'] = $EMAIL_TEMPLATE['default']['header']; // will use default header above. $EMAIL_TEMPLATE['notify']['body'] = $EMAIL_TEMPLATE['default']['body']; // will use default header above. $EMAIL_TEMPLATE['notify']['footer'] = $EMAIL_TEMPLATE['default']['footer']; // will use default header above. -// --------------------------------- +// ------ User-Mailout Templates + + +$EMAIL_TEMPLATE['user-monthly']['name'] = 'Monthly Update'; +$EMAIL_TEMPLATE['user-monthly']['subject'] = '{SITENAME}: {SUBJECT} '; +$EMAIL_TEMPLATE['user-monthly']['header'] = $EMAIL_TEMPLATE['default']['header']; // will use default header above. +$EMAIL_TEMPLATE['user-monthly']['body'] = "Just to keep you up to date, here's a reminder of what's changed in the past month.
{BODY}
To find out more, simply click on the links!"; +$EMAIL_TEMPLATE['user-monthly']['footer'] = $EMAIL_TEMPLATE['default']['footer']; + + +$EMAIL_TEMPLATE['user-whatsnew']['name'] = "What's New"; +$EMAIL_TEMPLATE['user-whatsnew']['subject'] = '{SITENAME}: {SUBJECT} '; +$EMAIL_TEMPLATE['user-whatsnew']['header'] = $EMAIL_TEMPLATE['default']['header']; // will use default header above. +$EMAIL_TEMPLATE['user-whatsnew']['body'] = "All the latest news and updates.
{BODY}
To find out more, simply click on the links!"; +$EMAIL_TEMPLATE['user-whatsnew']['footer'] = $EMAIL_TEMPLATE['default']['footer']; -// A Dummy Example for theme developers. +// ------ A Dummy Example for theme developers. + $EMAIL_TEMPLATE['example']['subject'] = '{SITENAME}: {SUBJECT} '; $EMAIL_TEMPLATE['example']['header'] = $EMAIL_TEMPLATE['default']['header']; // will use default header above. $EMAIL_TEMPLATE['example']['body'] = $EMAIL_TEMPLATE['default']['body']; // will use default header above. @@ -422,4 +436,7 @@ $EMAIL_TEMPLATE['example']['footer'] = "

"; + + + ?> \ No newline at end of file diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index 78ff2ef05..7120b2e36 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -3984,12 +3984,21 @@ class e_form } } + if(!is_array($att['writeParms'])) + { + parse_str(varset($att['writeParms']), $writeParms); + } + else + { + $writeParms = $att['writeParms']; + } + + + if('hidden' === $att['type']) { - if(!is_array($att['writeParms'])) parse_str(varset($att['writeParms']), $tmp); - else $tmp = $att['writeParms']; - if(!vartrue($tmp['show'])) + if(!vartrue($writeParms['show'])) { continue; } @@ -4039,12 +4048,13 @@ class e_form $leftCell = $required."".defset(vartrue($att['title']), vartrue($att['title']))."".$label; $rightCell = $this->renderElement($keyName, $model->getIfPosted($valPath), $att, varset($model_required[$key], array()), $model->getId())." {$help}"; - if(vartrue($att['type']) == 'bbarea') + if(vartrue($att['type']) == 'bbarea' || $writeParms['nolabel'] == true) { $text .= " - -
".$leftCell."
". - $rightCell." + "; + + $text .= "
".$leftCell."
"; + $text .= $rightCell." diff --git a/e107_handlers/mail_manager_class.php b/e107_handlers/mail_manager_class.php index 55ba7b277..a7650e810 100644 --- a/e107_handlers/mail_manager_class.php +++ b/e107_handlers/mail_manager_class.php @@ -262,8 +262,8 @@ class e107MailManager $res[$f] = ''; } } - $array = new ArrayData; - $res['mail_other'] = $array->WriteArray($res1, TRUE); // Ready to write to DB + // $array = new ArrayData; + $res['mail_other'] = e107::serialize($res1, TRUE); // Ready to write to DB return $res; } @@ -296,8 +296,8 @@ class e107MailManager } if (isset($data['mail_other'])) { - $array = new ArrayData; - $tmp = $array->ReadArray(str_replace('\\\'', '\'',$data['mail_other'])); // May have escaped data + + $tmp = e107::unserialize(str_replace('\\\'', '\'',$data['mail_other'])); // May have escaped data if (is_array($tmp)) { $res = array_merge($res,$tmp); diff --git a/e107_handlers/mailout_admin_class.php b/e107_handlers/mailout_admin_class.php index 4877f0c6e..448c2f67e 100644 --- a/e107_handlers/mailout_admin_class.php +++ b/e107_handlers/mailout_admin_class.php @@ -473,7 +473,6 @@ class mailoutAdminClass extends e107MailManager $ret = ''; $tab = ''; $tabc = ''; - foreach ($this->mailHandlers as $key => $m) { @@ -489,7 +488,7 @@ class mailoutAdminClass extends e107MailManager if(is_array($content)) { - $tabc .= " + $tabc .= "
@@ -498,7 +497,7 @@ class mailoutAdminClass extends e107MailManager foreach($content as $var) { - $tabc .= ""; + $tabc .= ""; } $tabc .= "
".$var['caption']."".$var['html']."
".$var['caption']."".$var['html']."
"; } @@ -552,7 +551,7 @@ class mailoutAdminClass extends e107MailManager */ public function userClassesTotals($name, $curSel) { - $fixedClasses = array('all' => LAN_MAILOUT_12,'unverified' => LAN_MAILOUT_13, 'admin' => LAN_MAILOUT_53, 'self' => LAN_MAILOUT_54); + $fixedClasses = array('self' => LAN_MAILOUT_54, 'all' => LAN_MAILOUT_12,'unverified' => LAN_MAILOUT_13, 'admin' => LAN_MAILOUT_53 ); $ret = ''; $this->checkDB(2); // Make sure DB object created @@ -793,7 +792,7 @@ class mailoutAdminClass extends e107MailManager 'texttheme' => LAN_MAILOUT_127 ); - $text = "\n"; foreach ($emFormat as $key=>$val) { @@ -856,9 +855,12 @@ class mailoutAdminClass extends e107MailManager $text .= "
-
- ".$this->emailSelector('all', varset($mailSource['mail_selectors'], FALSE))." - + "; + + + $text .= $this->emailSelector('all', varset($mailSource['mail_selectors'], FALSE)); + + $text .= "
@@ -901,7 +903,7 @@ class mailoutAdminClass extends e107MailManager - + "; @@ -999,7 +1001,9 @@ class mailoutAdminClass extends e107MailManager "; - $ns->tablerender(ADLAN_136.SEP.LAN_MAILOUT_15, $mes->render(). $text); // Render the complete form + return $text; + + // $ns->tablerender(ADLAN_136.SEP.LAN_MAILOUT_15, $mes->render(). $text); // Render the complete form } @@ -1784,6 +1788,22 @@ class mailoutAdminClass extends e107MailManager public function getEmailTemplateNames($sel = 'all') { $ret = array(); + + $templates = e107::getCoreTemplate('email'); + + foreach($templates as $key=>$layout) + { + if(substr($key,0,5)== 'user-' || $key == 'default') + { + $ret[$key] = $layout['name']; + } + + + } + + return $ret; + /* + foreach (array(e_CORE.'templates/email_template.php', THEME.'templates/email_template.php') as $templateFileName ) // Override file then defaults if (is_readable($templateFileName)) { @@ -1805,7 +1825,14 @@ class mailoutAdminClass extends e107MailManager } } } + + + + + print_a($ret); return $ret; + + */ } } diff --git a/e107_handlers/mailout_class.php b/e107_handlers/mailout_class.php index 6a987e5d6..71c5317c9 100644 --- a/e107_handlers/mailout_class.php +++ b/e107_handlers/mailout_class.php @@ -268,7 +268,7 @@ class core_mailout $var = array(); - $var[0]['caption'] = LAN_MAILOUT_03; // User class select + $var[0]['caption'] = LAN_MAILOUT_260; // LAN_MAILOUT_03; // User class select if ($allow_edit) { diff --git a/e107_languages/English/admin/help/mailout.php b/e107_languages/English/admin/help/mailout.php index 20065ba08..49240c5d2 100644 --- a/e107_languages/English/admin/help/mailout.php +++ b/e107_languages/English/admin/help/mailout.php @@ -37,6 +37,7 @@ $action = e107::getParser()->toDB(varset($_GET['mode'],'makemail')); break; case 'savedmail' : case 'makemail' : + case 'main' : $text = 'Create an email, give it a meaningful title, and select the list of recipients. You can save everything as a template for later, or send immediately.
'; $text .= 'Email addresses may be contributed by plugins (such as newsletter), and duplicates are removed when the mail is sent
'; $text .= 'Any attachment is selected from the list of valid downloads.
'; diff --git a/e107_languages/English/admin/lan_mailout.php b/e107_languages/English/admin/lan_mailout.php index 32e89880d..b681d1495 100644 --- a/e107_languages/English/admin/lan_mailout.php +++ b/e107_languages/English/admin/lan_mailout.php @@ -22,8 +22,8 @@ define("LAN_MAILOUT_08", "Send Email"); define("LAN_MAILOUT_09", "Send format"); define("LAN_MAILOUT_10", "User Subscribed"); define("LAN_MAILOUT_11", "Insert Variables"); -define("LAN_MAILOUT_12", "All Members"); -define("LAN_MAILOUT_13", "All Unverified Members "); +define("LAN_MAILOUT_12", "All Users"); +define("LAN_MAILOUT_13", "All Unverified Users "); define("LAN_MAILOUT_14", "Display Name"); define("LAN_MAILOUT_15", "Mailout"); define("LAN_MAILOUT_16", "Username"); @@ -279,6 +279,8 @@ define("LAN_MAILOUT_259", ""); define("LAN_SEND", "Send"); define("LAN_HOLD", "Hold"); +define("LAN_MAILOUT_260", "User-Type"); + //define("LAN_SUBMIT", "Do it!"); LAN_RUN ?> \ No newline at end of file From 5d894149bb339817e74076f332d51711d5e6e377 Mon Sep 17 00:00:00 2001 From: Cameron Date: Fri, 10 Oct 2014 22:58:47 -0700 Subject: [PATCH 12/46] More Admin->Mail GUI and functionality fixes. --- e107_admin/mailout.php | 170 ++++++++++++++++++++++++-- e107_handlers/form_handler.php | 3 + e107_handlers/mail_manager_class.php | 2 +- e107_handlers/mailout_admin_class.php | 45 +++++-- 4 files changed, 197 insertions(+), 23 deletions(-) diff --git a/e107_admin/mailout.php b/e107_admin/mailout.php index 8590cfdfb..5386f85b3 100644 --- a/e107_admin/mailout.php +++ b/e107_admin/mailout.php @@ -146,7 +146,9 @@ class mailout_admin extends e_admin_dispatcher // 'makemail/makemail' => array('caption'=> LAN_MAILOUT_190, 'perm' => 'W', 'url'=>e_SELF), 'main/list' => array('caption'=> LAN_MANAGE, 'perm'=> 'W'), 'main/create' => array('caption'=> LAN_MAILOUT_190, 'perm' => 'W'), + 'recipients/list' => array('caption'=> "Recipients", 'perm' => 'W'), + // 'main/send' => array('caption'=> "Send", 'perm' => 'W'), 'other' => array('divider'=> true), 'saved/list' => array('caption'=> LAN_MAILOUT_191, 'perm' => 'W'), 'pending/list' => array('caption'=> LAN_MAILOUT_193, 'perm' => 'W'), @@ -161,7 +163,7 @@ class mailout_admin extends e_admin_dispatcher protected $adminMenuAliases = array( - // 'main/edit' => 'main/list', + 'main/send' => 'main/create', ); protected $menuTitle = LAN_MAILOUT_15; @@ -207,9 +209,9 @@ class mailout_main_ui extends e_admin_ui 'mail_bounce_count' => array('title' => LAN_MAILOUT_144, 'noedit'=>true, 'type'=>'number'), 'mail_start_send' => array('title' => LAN_MAILOUT_131,'noedit'=>true, 'type'=>'number', 'proc' => 'sdatetime'), 'mail_end_send' => array('title' => LAN_MAILOUT_132, 'noedit'=>true, 'type'=>'number', 'proc' => 'sdatetime'), - 'mail_create_date' => array('title' => LAN_MAILOUT_130, 'noedit'=>true, 'type'=>'datestamp', 'proc' => 'sdatetime'), - 'mail_creator' => array('title' => LAN_MAILOUT_85, 'noedit'=>true, 'type'=>'user', 'proc' => 'username'), - 'mail_create_app' => array('title' => LAN_MAILOUT_133, 'noedit'=>true), + 'mail_create_date' => array('title' => LAN_MAILOUT_130, 'type'=>null, 'noedit'=>true, 'data'=>'int', 'type'=>'number'), + 'mail_creator' => array('title' => LAN_MAILOUT_85, 'type'=>null, 'noedit'=>true, 'data'=>'int'), + 'mail_create_app' => array('title' => LAN_MAILOUT_133, 'type'=>null, 'noedit'=>true,'data'=>'str'), 'mail_e107_priority' => array('title' => LAN_MAILOUT_134, 'noedit'=>true), 'mail_notify_complete' => array('title' => LAN_MAILOUT_243, 'noedit'=>true, 'nolist' => true), 'mail_last_date' => array('title' => LAN_MAILOUT_129, 'noedit'=>true, 'type'=>'int', 'proc' => 'sdatetime'), @@ -302,11 +304,14 @@ class mailout_main_ui extends e_admin_ui } else { - $this->fields['options']['type'] = ''; + // $this->fields['options']['type'] = ''; } $this->fields['mail_content_status']['writeParms'] = $types; + $this->processSendActions(); + + if (getperms('0')) { @@ -351,6 +356,7 @@ class mailout_main_ui extends e_admin_ui $ret['mail_create_date'] = time(); $ret['mail_creator'] = USERID; + $ret['mail_create_app'] = 'core'; $ret['mail_content_status'] = 20; // Default status is 'Saved'; return $ret; @@ -360,10 +366,122 @@ class mailout_main_ui extends e_admin_ui public function beforeUpdate($new_data, $old_data, $id) { - return $this->processData($new_data); + $ret = $this->processData($new_data); + + return $ret; } + + + + private function processSendActions() + { + + if((vartrue($_POST['email_sendnow']) || vartrue($_POST['email_send']) || vartrue($_POST['email_hold']) || vartrue($_POST['email_cancel'])) && !vartrue($_POST['email_id'])) + { + e107::getMessage()->addError("No Message ID submitted"); + return; + } + + $id = intval($_POST['email_id']); + + if(vartrue($_POST['email_sendnow'])) + { + $this->emailSendNow($id); + } + + if(vartrue($_POST['email_send'])) + { + $this->emailSend($id); + } + + if(vartrue($_POST['email_hold'])) + { + $this->emailHold($id); + } + + if(vartrue($_POST['email_cancel'])) + { + $this->emailCancel($id); + } + + } + + private function checkForId() + { + + + } + + private function emailSendNow($mailId) + { + e107::getMessage()->addInfo("'Send Now' is Under Construction"); + } + + + + private function emailSend($mailId) + { + $log = e107::getAdminLog(); + + $notify = isset($_POST['mail_notify_complete']) ? 3 : 2; + $first = 0; + $last = 0; // Set defaults for earliest and latest send times. + // TODO: Save these fields + if (isset($_POST['mail_earliest_time'])) + { + $first = e107::getDateConvert()->decodeDateTime($_POST['mail_earliest_time'], 'datetime', CORE_DATE_ORDER, FALSE); + } + if (isset($_POST['mail_latest_time'])) + { + $last = e107::getDateConvert()->decodeDateTime($_POST['mail_earliest_time'], 'datetime', CORE_DATE_ORDER, TRUE); + } + if ($this->mailAdmin->activateEmail($mailId, FALSE, $notify, $first, $last)) + { + e107::getMessage()->addSuccess(LAN_MAILOUT_185); + $log->log_event('MAIL_06','ID: '.$mailId,E_LOG_INFORMATIVE,''); + } + else + { + $errors[] = str_replace('--ID--', $mailId, LAN_MAILOUT_188); + } + } + + + + private function emailHold($mailId) + { + if ($this->mailAdmin->activateEmail($mailId, TRUE)) + { + e107::getMessage()->addSuccess(str_replace('--ID--', $mailId, LAN_MAILOUT_187)); + } + else + { + $errors[] = str_replace('--ID--', $mailId, LAN_MAILOUT_166); + } + } + + + + private function emailCancel($mailId) + { + if ($this->mailAdmin->cancelEmail($mailId)) + { + e107::getMessage()->addSuccess(str_replace('--ID--', $mailId, LAN_MAILOUT_220)); + } + else + { + $errors[] = str_replace('--ID--', $mailId, LAN_MAILOUT_221); + } + } + + + + + + + /** * Process Posted Data */ @@ -413,7 +531,23 @@ class mailout_main_ui extends e_admin_ui } */ + function sendPage() + { + + $id = $this->getId(); + + $mailData = e107::getDb()->retrieve('mail_content','*','mail_source_id='.intval($id)); + + if(empty($mailData)) + { + e107::getMessage()->addError("Couldn't retrieve mail data for id: ".$id); + return ''; + } + return $this->mailAdmin->sendEmailCircular($mailData, $fromHold); + + + } function maintPage() { @@ -978,10 +1112,26 @@ class mailout_admin_form_ui extends e_admin_form_ui } - function options() + function options($parms, $value, $id, $attributes) { $controller = $this->getController(); + + + $mode = $this->getController()->getMode(); + + if($mode == 'main') + { + $text = ""; + + + $link = e_SELF."?mode=main&action=send&id=".$id; + $text .= "".E_32_MAIL.""; + $text .= $this->renderValue('options',$value,$att,$id); + + return $text; + } + $mode = $controller->getMode(); $mailData = $controller->getListModel()->getData(); @@ -1022,7 +1172,7 @@ class mailout_recipients_ui extends e_admin_ui 'mail_recipient_id' => array('title' => LAN_MAILOUT_142, 'thclass' => 'center'), 'mail_recipient_name' => array('title' => LAN_MAILOUT_141, 'forced' => TRUE), 'mail_recipient_email' => array('title' => LAN_MAILOUT_140, 'thclass' => 'left', 'forced' => TRUE), - 'mail_status' => array('title' => LAN_MAILOUT_138, 'thclass' => 'center', 'proc' => 'contentstatus'), + 'mail_status' => array('title' => LAN_MAILOUT_138, 'thclass' => 'left', 'class'=>'left', 'proc' => 'contentstatus'), 'mail_detail_id' => array('title' => LAN_MAILOUT_137, 'type'=>'dropdown', 'filter'=>true), 'mail_send_date' => array('title' => LAN_MAILOUT_139, 'proc' => 'sdatetime'), 'mail_target_info' => array('title' => LAN_MAILOUT_148, 'proc' => 'array'), @@ -1240,6 +1390,7 @@ switch ($action) } break; */ + /* case 'mailedit' : // Edit existing mail if (isset($_POST['mailaction'])) { @@ -1252,7 +1403,8 @@ switch ($action) } } break; - + */ + case 'makemail' : $newMail = TRUE; diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index 7120b2e36..68d076420 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -1944,6 +1944,7 @@ class e_form case 'create': case 'import': case 'submit': + case 'success': $options['class'] .= 'btn-success'; break; @@ -1956,6 +1957,7 @@ class e_form break; case 'delete': + case 'danger': $options['class'] .= 'btn-danger'; $options['other'] = 'data-confirm="'.LAN_JSCONFIRM.'"'; break; @@ -1966,6 +1968,7 @@ class e_form case 'other': case 'login': + case 'primary': $options['class'] .= 'btn-primary'; break; diff --git a/e107_handlers/mail_manager_class.php b/e107_handlers/mail_manager_class.php index a7650e810..fc51bc3e4 100644 --- a/e107_handlers/mail_manager_class.php +++ b/e107_handlers/mail_manager_class.php @@ -123,7 +123,7 @@ class e107MailManager const E107_EMAIL_MAX_TRIES = 3; // Maximum number of tries by us (mail server may do more) // - max allowable value is MAIL_STATUS_MAX_ACTIVE - MAIL_STATUS_PENDING - private $debugMode = 0; + private $debugMode = 1; protected $e107; protected $db = NULL; // Use our own database object - this one for reading data protected $db2 = NULL; // Use our own database object - this one for updates diff --git a/e107_handlers/mailout_admin_class.php b/e107_handlers/mailout_admin_class.php index 448c2f67e..23fe3c022 100644 --- a/e107_handlers/mailout_admin_class.php +++ b/e107_handlers/mailout_admin_class.php @@ -297,6 +297,7 @@ class mailoutAdminClass extends e107MailManager * @param $target - display mode * @return none */ + /* public function mailbodySaveColumnPref($target) { global $user_pref; @@ -313,7 +314,7 @@ class mailoutAdminClass extends e107MailManager $this->fieldPref = $user_pref['admin_mailout_columns'][$target]; } } - + */ /** * Get the user name associated with a user ID. * The result is cached in case required again @@ -819,6 +820,7 @@ class mailoutAdminClass extends e107MailManager * @param $mailSource - array of mail information * @return text for display */ + /* function show_mailform(&$mailSource) { global $HANDLERS_DIRECTORY; @@ -882,14 +884,14 @@ class mailoutAdminClass extends e107MailManager // Add in the core and any plugin selectors here - + */ /*$text .= " ";*/ - + /* $text .= " @@ -1005,7 +1007,7 @@ class mailoutAdminClass extends e107MailManager // $ns->tablerender(ADLAN_136.SEP.LAN_MAILOUT_15, $mes->render(). $text); // Render the complete form } - + */ /** * Helper function manages the shortcodes which can be inserted @@ -1115,6 +1117,7 @@ class mailoutAdminClass extends e107MailManager * @param $nextPage - 'mode' specification for page to return to following delete * @return text for display */ + /* public function showDeleteConfirm($mailID, $nextPage = 'saved') { $mailData = $this->retrieveEmail($mailID); @@ -1157,7 +1160,8 @@ class mailoutAdminClass extends e107MailManager $ns->tablerender(ADLAN_136.SEP.LAN_MAILOUT_171, $text); } - + */ + /** @@ -1168,6 +1172,7 @@ class mailoutAdminClass extends e107MailManager * @param $amount - number to return * @return text for display */ + /* public function showEmailList($type, $from = 0, $amount = 10) { // Need to select main email entries; count number of addresses attached to each @@ -1269,8 +1274,18 @@ class mailoutAdminClass extends e107MailManager $text .= ''; $ns->tablerender(ADLAN_136.SEP.$this->tasks[$type]['title'], $text); } + */ + - + + + + + + + + + /** * Generate a list of emails to send * Returns various information to display in a confirmation screen @@ -1345,12 +1360,12 @@ class mailoutAdminClass extends e107MailManager // $this->e107->admin_log->log_event('MAIL_02','ID: '.$mailMainID.' '.$counters['add'].'[!br!]'.$_POST['email_from_name']." <".$_POST['email_from_email'],E_LOG_INFORMATIVE,''); } - // We've got all the email addresses here - display a confirmation form // Include start/end dates for send - + // $text = ""; + $text = " - +
".LAN_MAILOUT_51.": ".$frm->text('email_subject',varset($email_subject,''))."".$frm->text('email_subject',varset($email_subject,''),255,'required=1&size=xxlarge')."
".LAN_MAILOUT_03.": ".$this->emailSelector('all', varset($mailSource['mail_selectors'], FALSE))."
".LAN_MAILOUT_04.":
@@ -1387,23 +1402,27 @@ class mailoutAdminClass extends e107MailManager $text .= "
"; - $text .= $frm->admin_button('email_sendnow',"Send Now"); + $text .= $frm->admin_button('email_sendnow',"Send Now", 'primary'); $text .= $frm->admin_button('email_send',"Send Later"); // $text .= ""; if (!$fromHold) { - $text .= $frm->admin_button('email_hold',LAN_HOLD); - $text .= $frm->admin_button('email_cancel',LAN_CANCEL); + $text .= $frm->admin_button('email_hold',LAN_HOLD, 'warning'); + $text .= $frm->admin_button('email_cancel',LAN_CANCEL, 'delete'); // $text .= " "; // $text .= " "; } + + $text .= $frm->hidden('email_id',$mailMainID); + $text .= "
"; - e107::getRender()->tablerender(ADLAN_136.SEP.LAN_MAILOUT_179, $mes->render(). $text); + return $text; + // e107::getRender()->tablerender(ADLAN_136.SEP.LAN_MAILOUT_179, $mes->render(). $text); } // End of previewed email From 4fca7b7f1218f7e2c015f749b18e6b79e1fde671 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sat, 11 Oct 2014 12:54:16 -0700 Subject: [PATCH 13/46] More Admin->Mail Fixes. --- e107_admin/mailout.php | 26 +- e107_handlers/mail_manager_class.php | 12 +- e107_handlers/mailout_admin_class.php | 1985 ++++++++++++++----------- 3 files changed, 1119 insertions(+), 904 deletions(-) diff --git a/e107_admin/mailout.php b/e107_admin/mailout.php index 5386f85b3..30c6e9cf5 100644 --- a/e107_admin/mailout.php +++ b/e107_admin/mailout.php @@ -357,7 +357,7 @@ class mailout_main_ui extends e_admin_ui $ret['mail_create_date'] = time(); $ret['mail_creator'] = USERID; $ret['mail_create_app'] = 'core'; - $ret['mail_content_status'] = 20; // Default status is 'Saved'; + $ret['mail_content_status'] = 22; // Default status is 'Saved'; return $ret; @@ -408,11 +408,6 @@ class mailout_main_ui extends e_admin_ui } - private function checkForId() - { - - - } private function emailSendNow($mailId) { @@ -423,12 +418,14 @@ class mailout_main_ui extends e_admin_ui private function emailSend($mailId) { - $log = e107::getAdminLog(); + $log = e107::getAdminLog(); - $notify = isset($_POST['mail_notify_complete']) ? 3 : 2; - $first = 0; - $last = 0; // Set defaults for earliest and latest send times. - // TODO: Save these fields + $notify = isset($_POST['mail_notify_complete']) ? 3 : 2; + $first = 0; + $last = 0; // Set defaults for earliest and latest send times. + + + if (isset($_POST['mail_earliest_time'])) { $first = e107::getDateConvert()->decodeDateTime($_POST['mail_earliest_time'], 'datetime', CORE_DATE_ORDER, FALSE); @@ -437,6 +434,7 @@ class mailout_main_ui extends e_admin_ui { $last = e107::getDateConvert()->decodeDateTime($_POST['mail_earliest_time'], 'datetime', CORE_DATE_ORDER, TRUE); } + if ($this->mailAdmin->activateEmail($mailId, FALSE, $notify, $first, $last)) { e107::getMessage()->addSuccess(LAN_MAILOUT_185); @@ -544,7 +542,11 @@ class mailout_main_ui extends e_admin_ui return ''; } - return $this->mailAdmin->sendEmailCircular($mailData, $fromHold); + $fromHold = false; + + $mailData = $this->mailAdmin->dbToMail($mailData); + + return $this->mailAdmin->sendEmailCircular($mailData, $fromHold); } diff --git a/e107_handlers/mail_manager_class.php b/e107_handlers/mail_manager_class.php index fc51bc3e4..b10a3fbe1 100644 --- a/e107_handlers/mail_manager_class.php +++ b/e107_handlers/mail_manager_class.php @@ -262,8 +262,8 @@ class e107MailManager $res[$f] = ''; } } - // $array = new ArrayData; - $res['mail_other'] = e107::serialize($res1, TRUE); // Ready to write to DB + + $res['mail_other'] = e107::serialize($res1,false); // Ready to write to DB return $res; } @@ -348,8 +348,7 @@ class e107MailManager } if (isset($data['mail_target_info']) && is_array($data['mail_target_info'])) { - $array = new ArrayData; - $tmp = $array->WriteArray($data['mail_target_info'], TRUE); + $tmp = e107::serialize($data['mail_target_info'], TRUE); $res['mail_target_info'] = $tmp; } return $res; @@ -896,9 +895,10 @@ class e107MailManager $this->checkDB(2); // Make sure we have a DB object to use $dbData = $this->mailToDB($emailData, FALSE); // Convert array formats -// print_a($dbData); + // print_a($dbData); - if ($isNew) + + if ($isNew === true) { unset($dbData['mail_source_id']); // Just in case - there are circumstances where might be set $result = $this->db2->db_Insert('mail_content', array('data' => $dbData, diff --git a/e107_handlers/mailout_admin_class.php b/e107_handlers/mailout_admin_class.php index 23fe3c022..4d26f9585 100644 --- a/e107_handlers/mailout_admin_class.php +++ b/e107_handlers/mailout_admin_class.php @@ -11,31 +11,35 @@ */ /** - * Various admin-related mailout functions, mostly to do with creating and handling forms. - * + * Various admin-related mailout functions, mostly to do with creating and + * handling forms. + * * @package e107 * @subpackage e107_handlers -*/ - + */ /* -TODO: - 1. Use API to downloads plugin to get available files (when available) - 2. Fuller checking prior to send - 3. May want more control over date display format - 4. Use new date picker -*/ + TODO: + 1. Use API to downloads plugin to get available files (when available) + 2. Fuller checking prior to send + 3. May want more control over date display format + 4. Use new date picker + */ -if (!defined('e107_INIT')) { exit; } +if(!defined('e107_INIT')) +{ + exit ; +} define('MAIL_ADMIN_DEBUG', TRUE); -require_once(e_HANDLER.'mail_manager_class.php'); +require_once (e_HANDLER . 'mail_manager_class.php'); class mailoutAdminClass extends e107MailManager { - public $_cal = array(); - protected $mode; // So we know what the current task is + public $_cal = array(); + protected $mode; + // So we know what the current task is protected $mailHandlers = array(); protected $showFrom = 0; protected $showCount = 10; @@ -43,124 +47,252 @@ class mailoutAdminClass extends e107MailManager protected $sortOrder = 'asc'; protected $fieldPref = array(); protected $userCache = array(); - - // Definitions associated with each column which might be displayed. (Compatible with forms-based display) + // Definitions associated with each column which might be displayed. (Compatible + // with forms-based display) // Fields are displayed in the order listed. // Can also have: width // type // thclass protected $fields = array( - 'mail_recipients' => array - ( 'mail_target_id' => array('title' => LAN_MAILOUT_143, 'thclass' => 'center', 'forced' => TRUE), - 'mail_recipient_id' => array('title' => LAN_MAILOUT_142, 'thclass' => 'center'), - 'mail_recipient_name' => array('title' => LAN_MAILOUT_141, 'forced' => TRUE), - 'mail_recipient_email' => array('title' => LAN_MAILOUT_140, 'thclass' => 'left', 'forced' => TRUE), - 'mail_status' => array('title' => LAN_MAILOUT_138, 'thclass' => 'center', 'proc' => 'contentstatus'), - 'mail_detail_id' => array('title' => LAN_MAILOUT_137), - 'mail_send_date' => array('title' => LAN_MAILOUT_139, 'proc' => 'sdatetime'), - 'mail_target_info' => array('title' => LAN_MAILOUT_148, 'proc' => 'array'), - 'options' => array('title' => LAN_OPTIONS, 'forced' => TRUE) + 'mail_recipients' => array( + 'mail_target_id' => array( + 'title' => LAN_MAILOUT_143, + 'thclass' => 'center', + 'forced' => TRUE + ), + 'mail_recipient_id' => array( + 'title' => LAN_MAILOUT_142, + 'thclass' => 'center' + ), + 'mail_recipient_name' => array( + 'title' => LAN_MAILOUT_141, + 'forced' => TRUE + ), + 'mail_recipient_email' => array( + 'title' => LAN_MAILOUT_140, + 'thclass' => 'left', + 'forced' => TRUE + ), + 'mail_status' => array( + 'title' => LAN_MAILOUT_138, + 'thclass' => 'center', + 'proc' => 'contentstatus' + ), + 'mail_detail_id' => array('title' => LAN_MAILOUT_137), + 'mail_send_date' => array( + 'title' => LAN_MAILOUT_139, + 'proc' => 'sdatetime' + ), + 'mail_target_info' => array( + 'title' => LAN_MAILOUT_148, + 'proc' => 'array' + ), + 'options' => array( + 'title' => LAN_OPTIONS, + 'forced' => TRUE + ) ), 'mail_content' => array( - 'mail_source_id' => array('title' => LAN_MAILOUT_137, 'thclass' => 'center', 'forced' => TRUE), - 'mail_title' => array('title' => LAN_MAILOUT_135, 'forced' => TRUE), - 'mail_subject' => array('title' => LAN_MAILOUT_06, 'forced' => TRUE), - 'mail_content_status' => array('title' => LAN_MAILOUT_136, 'thclass' => 'center', 'proc' => 'contentstatus'), - 'mail_togo_count' => array('title' => LAN_MAILOUT_83), - 'mail_sent_count' => array('title' => LAN_MAILOUT_82), - 'mail_fail_count' => array('title' => LAN_MAILOUT_128), + 'mail_source_id' => array( + 'title' => LAN_MAILOUT_137, + 'thclass' => 'center', + 'forced' => TRUE + ), + 'mail_title' => array( + 'title' => LAN_MAILOUT_135, + 'forced' => TRUE + ), + 'mail_subject' => array( + 'title' => LAN_MAILOUT_06, + 'forced' => TRUE + ), + 'mail_content_status' => array( + 'title' => LAN_MAILOUT_136, + 'thclass' => 'center', + 'proc' => 'contentstatus' + ), + 'mail_togo_count' => array('title' => LAN_MAILOUT_83), + 'mail_sent_count' => array('title' => LAN_MAILOUT_82), + 'mail_fail_count' => array('title' => LAN_MAILOUT_128), 'mail_bounce_count' => array('title' => LAN_MAILOUT_144), - 'mail_start_send' => array('title' => LAN_MAILOUT_131, 'proc' => 'sdatetime'), - 'mail_end_send' => array('title' => LAN_MAILOUT_132, 'proc' => 'sdatetime'), - 'mail_create_date' => array('title' => LAN_MAILOUT_130, 'proc' => 'sdatetime'), - 'mail_creator' => array('title' => LAN_MAILOUT_85, 'proc' => 'username'), - 'mail_create_app' => array('title' => LAN_MAILOUT_133), + 'mail_start_send' => array( + 'title' => LAN_MAILOUT_131, + 'proc' => 'sdatetime' + ), + 'mail_end_send' => array( + 'title' => LAN_MAILOUT_132, + 'proc' => 'sdatetime' + ), + 'mail_create_date' => array( + 'title' => LAN_MAILOUT_130, + 'proc' => 'sdatetime' + ), + 'mail_creator' => array( + 'title' => LAN_MAILOUT_85, + 'proc' => 'username' + ), + 'mail_create_app' => array('title' => LAN_MAILOUT_133), 'mail_e107_priority' => array('title' => LAN_MAILOUT_134), - 'mail_notify_complete' => array('title' => LAN_MAILOUT_243, 'nolist' => 'TRUE'), - 'mail_last_date' => array('title' => LAN_MAILOUT_129, 'proc' => 'sdatetime'), - 'mail_body' => array('title' => LAN_MAILOUT_100, 'proc' => 'trunc200'), - 'mail_body_templated' => array('title' => LAN_MAILOUT_257, 'proc' => 'chars'), - // 'mail_other' = array('title' => LAN_MAILOUT_84), + 'mail_notify_complete' => array( + 'title' => LAN_MAILOUT_243, + 'nolist' => 'TRUE' + ), + 'mail_last_date' => array( + 'title' => LAN_MAILOUT_129, + 'proc' => 'sdatetime' + ), + 'mail_body' => array( + 'title' => LAN_MAILOUT_100, + 'proc' => 'trunc200' + ), + 'mail_body_templated' => array( + 'title' => LAN_MAILOUT_257, + 'proc' => 'chars' + ), + // 'mail_other' = array('title' => LAN_MAILOUT_84), 'mail_sender_email' => array('title' => LAN_MAILOUT_149), - 'mail_sender_name' => array('title' => LAN_MAILOUT_150), - 'mail_copy_to' => array('title' => LAN_MAILOUT_151), - 'mail_bcopy_to' => array('title' => LAN_MAILOUT_152), - 'mail_attach' => array('title' => LAN_MAILOUT_153), - 'mail_send_style' => array('title' => LAN_MAILOUT_154), - 'mail_selectors' => array('title' => LAN_MAILOUT_155, 'proc' => 'selectors', 'nolist' => 'TRUE'), - 'mail_include_images' => array('title' => LAN_MAILOUT_224, 'proc' => 'yesno'), - 'options' => array('title' => LAN_OPTIONS, 'forced' => TRUE) + 'mail_sender_name' => array('title' => LAN_MAILOUT_150), + 'mail_copy_to' => array('title' => LAN_MAILOUT_151), + 'mail_bcopy_to' => array('title' => LAN_MAILOUT_152), + 'mail_attach' => array('title' => LAN_MAILOUT_153), + 'mail_send_style' => array('title' => LAN_MAILOUT_154), + 'mail_selectors' => array( + 'title' => LAN_MAILOUT_155, + 'proc' => 'selectors', + 'nolist' => 'TRUE' + ), + 'mail_include_images' => array( + 'title' => LAN_MAILOUT_224, + 'proc' => 'yesno' + ), + 'options' => array( + 'title' => LAN_OPTIONS, + 'forced' => TRUE + ) ) ); // List of fields to be hidden for each action ('nolist' attribute true) protected $hideFields = array( 'orphans' => array(), - 'saved' => 'mail_content_status,mail_togo_count,mail_sent_count,mail_fail_count,mail_bounce_count,mail_start_send,mail_end_send,mail_e107_priority,mail_notify_complete,mail_last_date,mail_selectors', - 'sent' => 'mail_togo_count,mail_last_date,mail_selectors,mail_notify_complete', -// 'pending' => 'mail_togo_count,mail_sent_count,mail_fail_count,mail_bounce_count,mail_start_send,mail_end_send,mail_e107_priority,mail_last_date,mail_selectors', - 'pending' => 'mail_start_send,mail_end_send,mail_e107_priority,mail_notify_complete,mail_last_date,mail_selectors', - 'held' => 'mail_sent_count,mail_fail_count,mail_bounce_count,mail_start_send,mail_end_send,mail_e107_priority,mail_notify_complete,mail_last_date,mail_selectors', - 'resend' => 'mail_Selectors,mail_notify_complete', + 'saved' => 'mail_content_status,mail_togo_count,mail_sent_count,mail_fail_count,mail_bounce_count,mail_start_send,mail_end_send,mail_e107_priority,mail_notify_complete,mail_last_date,mail_selectors', + 'sent' => 'mail_togo_count,mail_last_date,mail_selectors,mail_notify_complete', + // 'pending' => + // 'mail_togo_count,mail_sent_count,mail_fail_count,mail_bounce_count,mail_start_send,mail_end_send,mail_e107_priority,mail_last_date,mail_selectors', + 'pending' => 'mail_start_send,mail_end_send,mail_e107_priority,mail_notify_complete,mail_last_date,mail_selectors', + 'held' => 'mail_sent_count,mail_fail_count,mail_bounce_count,mail_start_send,mail_end_send,mail_e107_priority,mail_notify_complete,mail_last_date,mail_selectors', + 'resend' => 'mail_Selectors,mail_notify_complete', 'recipients' => 'mail_detail_id' - ); + ); // Array of info associated with each task we might do protected $tasks = array( - 'makemail' => array('title' => LAN_MAILOUT_190, 'defaultSort' => '', 'defaultTable' => ''), - 'saved' => array('title' => LAN_MAILOUT_191, 'defaultSort' => 'mail_source_id', 'defaultTable' => 'mail_content'), - 'marksend' => array('title' => 'Internal: marksend', 'defaultSort' => 'mail_source_id', 'defaultTable' => 'mail_content'), - 'sent' => array('title' => LAN_MAILOUT_192, 'defaultSort' => 'mail_source_id', 'defaultTable' => 'mail_content'), - 'pending' => array('title' => LAN_MAILOUT_193, 'defaultSort' => 'mail_source_id', 'defaultTable' => 'mail_content'), - 'held' => array('title' => LAN_MAILOUT_194, 'defaultSort' => 'mail_source_id', 'defaultTable' => 'mail_content'), - 'recipients' => array('title' => LAN_MAILOUT_173, 'defaultSort' => 'mail_recipient_email', 'defaultTable' => 'mail_recipients'), - 'mailtargets' => array('title' => LAN_MAILOUT_173, 'defaultSort' => 'mail_recipient_email', 'defaultTable' => 'mail_recipients'), - 'prefs' => array('title' => ADLAN_40, 'defaultSort' => '', 'defaultTable' => ''), - 'maint' => array('title' => ADLAN_40, 'defaultSort' => '', 'defaultTable' => '') - ); - + 'makemail' => array( + 'title' => LAN_MAILOUT_190, + 'defaultSort' => '', + 'defaultTable' => '' + ), + 'saved' => array( + 'title' => LAN_MAILOUT_191, + 'defaultSort' => 'mail_source_id', + 'defaultTable' => 'mail_content' + ), + 'marksend' => array( + 'title' => 'Internal: marksend', + 'defaultSort' => 'mail_source_id', + 'defaultTable' => 'mail_content' + ), + 'sent' => array( + 'title' => LAN_MAILOUT_192, + 'defaultSort' => 'mail_source_id', + 'defaultTable' => 'mail_content' + ), + 'pending' => array( + 'title' => LAN_MAILOUT_193, + 'defaultSort' => 'mail_source_id', + 'defaultTable' => 'mail_content' + ), + 'held' => array( + 'title' => LAN_MAILOUT_194, + 'defaultSort' => 'mail_source_id', + 'defaultTable' => 'mail_content' + ), + 'recipients' => array( + 'title' => LAN_MAILOUT_173, + 'defaultSort' => 'mail_recipient_email', + 'defaultTable' => 'mail_recipients' + ), + 'mailtargets' => array( + 'title' => LAN_MAILOUT_173, + 'defaultSort' => 'mail_recipient_email', + 'defaultTable' => 'mail_recipients' + ), + 'prefs' => array( + 'title' => ADLAN_40, + 'defaultSort' => '', + 'defaultTable' => '' + ), + 'maint' => array( + 'title' => ADLAN_40, + 'defaultSort' => '', + 'defaultTable' => '' + ) + ); // Options for mail listing dropdown - actions apertaining to a stored email protected $modeOptions = array( 'saved' => array( - 'mailedit' => LAN_MAILOUT_163, - 'maildelete' => LAN_DELETE, + 'mailedit' => LAN_MAILOUT_163, + 'maildelete' => LAN_DELETE, 'mailshowtemplate' => LAN_MAILOUT_254 - ), + ), 'pending' => array( 'mailsendimmediately' => "Send Immediately", - 'mailhold' => LAN_MAILOUT_159, - 'mailcancel' => LAN_MAILOUT_160, - 'mailtargets' => LAN_MAILOUT_181 - ), + 'mailhold' => LAN_MAILOUT_159, + 'mailcancel' => LAN_MAILOUT_160, + 'mailtargets' => LAN_MAILOUT_181 + ), 'held' => array( - 'mailsendnow' => LAN_MAILOUT_158, - 'mailcancel' => LAN_MAILOUT_160, - 'mailtargets' => LAN_MAILOUT_181 - ), + 'mailsendnow' => LAN_MAILOUT_158, + 'mailcancel' => LAN_MAILOUT_160, + 'mailtargets' => LAN_MAILOUT_181 + ), 'sent' => array( - 'mailcopy' => LAN_MAILOUT_251, - 'maildelete' => LAN_DELETE, - 'mailtargets' => LAN_MAILOUT_181 - ), - 'recipients' => array( - 'mailonedelete' => LAN_DELETE - ) + 'mailcopy' => LAN_MAILOUT_251, + 'maildelete' => LAN_DELETE, + 'mailtargets' => LAN_MAILOUT_181 + ), + 'recipients' => array('mailonedelete' => LAN_DELETE) ); - // List of fields to be included in email display for various options protected $mailDetailDisplay = array( - 'basic' => array('mail_source_id' => 1, 'mail_title' => 1, 'mail_subject' => 1, 'mail_body' => 200), - 'send' => array('mail_source_id' => 1, 'mail_title' => 1, 'mail_subject' => 1, 'mail_body' => 500, 'mail_send_style' => 1), - 'template' => array('mail_source_id' => 1, 'mail_title' => 1, 'mail_subject' => 1, 'mail_body' => 200, 'mail_body_templated' => 'chars'), + 'basic' => array( + 'mail_source_id' => 1, + 'mail_title' => 1, + 'mail_subject' => 1, + 'mail_body' => 200 + ), + 'send' => array( + 'mail_source_id' => 1, + 'mail_title' => 1, + 'mail_subject' => 1, + 'mail_body' => 500, + 'mail_send_style' => 1 + ), + 'template' => array( + 'mail_source_id' => 1, + 'mail_title' => 1, + 'mail_subject' => 1, + 'mail_body' => 200, + 'mail_body_templated' => 'chars' + ), ); - /** * Constructor - * + * * * @return void */ @@ -169,34 +301,37 @@ class mailoutAdminClass extends e107MailManager parent::__construct(); $dbTable = ''; - if (isset($this->tasks[$mode])) + if(isset($this->tasks[$mode])) { $dbTable = $this->tasks[$mode]['defaultTable']; } if(isset($_GET['frm'])) { $temp = intval($_GET['frm']); - if ($temp < 0) $temp = 0; + if($temp < 0) + $temp = 0; $this->showFrom = $temp; } if(isset($_GET['count'])) { - $temp = min(intval($_GET['count']), 50); // Limit to 50 per page - $temp = max($temp, 5); // ...and minimum 5 per page + $temp = min(intval($_GET['count']), 50); + // Limit to 50 per page + $temp = max($temp, 5); + // ...and minimum 5 per page $this->showCount = $temp; } - if (isset($_GET['fld'])) + if(isset($_GET['fld'])) { $temp = e107::getParser()->toDB($_GET['fld']); - if (is_array($this->fields[$dbTable][$temp])) + if(is_array($this->fields[$dbTable][$temp])) { $this->sortField = $temp; } } - if (isset($_GET['asc'])) + if(isset($_GET['asc'])) { $temp = strtolower(e107::getParser()->toDB($_GET['asc'])); - if (($temp == 'asc') || ($temp == 'desc')) + if(($temp == 'asc') || ($temp == 'desc')) { $this->sortOrder = $temp; } @@ -204,7 +339,6 @@ class mailoutAdminClass extends e107MailManager $this->newMode($mode); } - /** * Set up new mode * @@ -216,18 +350,20 @@ class mailoutAdminClass extends e107MailManager global $user_pref; $this->mode = $mode; $curTable = $this->tasks[$this->mode]['defaultTable']; - if ($curTable) + if($curTable) { - if (isset($user_pref['admin_mailout_columns'][$mode]) && is_array($user_pref['admin_mailout_columns'][$mode])) - { // Use saved list of fields to view if it exists + if(isset($user_pref['admin_mailout_columns'][$mode]) && is_array($user_pref['admin_mailout_columns'][$mode])) + { + // Use saved list of fields to view if it exists $this->fieldPref = $user_pref['admin_mailout_columns'][$mode]; } else - { // Default list is minimal fields only + { + // Default list is minimal fields only $this->fieldPref = array(); - foreach ($this->fields[$curTable] as $f => $v) + foreach($this->fields[$curTable] as $f => $v) { - if (vartrue($v['forced'])) + if(vartrue($v['forced'])) { $this->fieldPref[] = $f; } @@ -236,22 +372,23 @@ class mailoutAdminClass extends e107MailManager } // Possibly the sort field needs changing - if (!isset($this->fields[$curTable][$this->sortField])) + if(!isset($this->fields[$curTable][$this->sortField])) { $this->sortField = $this->tasks[$mode]['defaultSort']; } - + // Now hide any fields that need to be for this mode - if (isset($this->hideFields[$mode])) + if(isset($this->hideFields[$mode])) { - $hideList = array_flip(explode(',',$this->hideFields[$mode])); - foreach ($this->fields[$curTable] as $f => $v) + $hideList = array_flip(explode(',', $this->hideFields[$mode])); + foreach($this->fields[$curTable] as $f => $v) { $this->fields[$curTable][$f]['nolist'] = isset($hideList[$f]); } - foreach ($this->fieldPref as $k => $v) // Remove from list of active fields (shouldn't often do anything) + foreach($this->fieldPref as $k => $v)// Remove from list of active fields + // (shouldn't often do anything) { - if (isset($hideList[$v])) + if(isset($hideList[$v])) { unset($this->fieldPref[$k]); } @@ -259,29 +396,28 @@ class mailoutAdminClass extends e107MailManager } } - - /** * Calculate the list of fields (columns) to be displayed for a given mode * * @param string $mode - display mode - * @param boolean $noOptions - set TRUE to suppress inclusion of any 'options' column. FALSE to include 'options' (default) + * @param boolean $noOptions - set TRUE to suppress inclusion of any 'options' + * column. FALSE to include 'options' (default) * @return array of field definitions */ protected function calcFieldSpec($mode, $noOptions = FALSE) { - if (!isset($this->tasks[$mode])) + if(!isset($this->tasks[$mode])) { echo "CalcfieldSpec({$mode}) - programming bungle
"; return FALSE; } $ret = array(); $curTable = $this->tasks[$this->mode]['defaultTable']; - foreach ($this->fields[$curTable] as $f => $v) + foreach($this->fields[$curTable] as $f => $v) { - if ((vartrue($v['forced']) && !vartrue($v['nolist'])) || in_array($f, $this->fieldPref)) + if((vartrue($v['forced']) && !vartrue($v['nolist'])) || in_array($f, $this->fieldPref)) { - if (($f != 'options') || ($noOptions === FALSE)) + if(($f != 'options') || ($noOptions === FALSE)) { $ret[] = $f; } @@ -290,31 +426,30 @@ class mailoutAdminClass extends e107MailManager return $ret; } - /** * Save the column visibility prefs for this mode * * @param $target - display mode * @return none */ - /* - public function mailbodySaveColumnPref($target) - { - global $user_pref; - if (!$target) return; - if (!isset($this->tasks[$target])) - { - echo "Invalid prefs target: {$target}
"; - return; - } - if (isset ($_POST['etrigger_ecolumns'])) - { - $user_pref['admin_mailout_columns'][$target] = $_POST['e-columns']; - save_prefs('user'); - $this->fieldPref = $user_pref['admin_mailout_columns'][$target]; - } - } - */ + /* + public function mailbodySaveColumnPref($target) + { + global $user_pref; + if (!$target) return; + if (!isset($this->tasks[$target])) + { + echo "Invalid prefs target: {$target}
"; + return; + } + if (isset ($_POST['etrigger_ecolumns'])) + { + $user_pref['admin_mailout_columns'][$target] = $_POST['e-columns']; + save_prefs('user'); + $this->fieldPref = $user_pref['admin_mailout_columns'][$target]; + } + } + */ /** * Get the user name associated with a user ID. * The result is cached in case required again @@ -325,35 +460,36 @@ class mailoutAdminClass extends e107MailManager */ protected function getUserName($uid) { - if (!isset($this->userCache[$uid])) + if(!isset($this->userCache[$uid])) { // Look up user - $this->checkDB(2); // Make sure DB object created - if ($this->db2->select('user','user_name, user_loginname', 'user_id='.intval($uid))) + $this->checkDB(2); + // Make sure DB object created + if($this->db2->select('user', 'user_name, user_loginname', 'user_id=' . intval($uid))) { $row = $this->db2->fetch(MYSQL_ASSOC); - $this->userCache[$uid] = $row['user_name'].' ('.$row['user_loginname'].')'; + $this->userCache[$uid] = $row['user_name'] . ' (' . $row['user_loginname'] . ')'; } else { - $this->userCache[$uid] = 'UID: '.$uid; + $this->userCache[$uid] = 'UID: ' . $uid; } } return $this->userCache[$uid]; } - /** * Generate the HTML for displaying actions box for emails - * - * Options given depend on $mode (saved|sent|pending|held), and also values in the email data. + * + * Options given depend on $mode (saved|sent|pending|held), and also values in + * the email data. * * @param array $mailData - array of email-related info * @return string HTML for display */ - public function makeMailOptions($mode,$mailData) + public function makeMailOptions($mode, $mailData) { - if (!is_numeric($mailData['mail_source_id']) || ($mailData['mail_source_id'] == 0)) + if(!is_numeric($mailData['mail_source_id']) || ($mailData['mail_source_id'] == 0)) { echo "makeMailOptions ({$mode}): Programming bungle!"; print_a($mailData); @@ -361,7 +497,7 @@ class mailoutAdminClass extends e107MailManager } $text = "\n \n"; - foreach ($this->modeOptions[$mode] as $key => $val) + foreach($this->modeOptions[$mode] as $key => $val) { $text .= "\n"; } @@ -396,10 +531,9 @@ class mailoutAdminClass extends e107MailManager return $text; } - /** * Generate the HTML for displaying email selection fields - * + * * @param $options - comma-separate string of handlers to load * 'core' - core handler * plugin name - obvious! @@ -412,37 +546,41 @@ class mailoutAdminClass extends e107MailManager $ret = 0; $toLoad = explode(',', $options); - if (in_array('core', $toLoad) || ($options == 'all')) + if(in_array('core', $toLoad) || ($options == 'all')) { - require_once(e_HANDLER.'mailout_class.php'); - $this->mailHandlers['core'] = new core_mailout; // Start by loading the core mailout class + require_once (e_HANDLER . 'mailout_class.php'); + $this->mailHandlers['core'] = new core_mailout; + // Start by loading the core mailout class $ret++; } - - $active_mailers = explode(',',varset($pref['mailout_enabled'],'')); + + $active_mailers = explode(',', varset($pref['mailout_enabled'], '')); // Load additional configured handlers - foreach ($pref['e_mailout_list'] as $mailer => $v) + foreach($pref['e_mailout_list'] as $mailer => $v) { - if (isset($pref['plug_installed'][$mailer]) && in_array($mailer,$active_mailers) && (($options == 'all') || in_array($mailer, $toLoad))) - { // Could potentially use this handler - its installed and enabled - if (!is_readable(e_PLUGIN.$mailer.'/e_mailout.php')) + if(isset($pref['plug_installed'][$mailer]) && in_array($mailer, $active_mailers) && (($options == 'all') || in_array($mailer, $toLoad))) + { + // Could potentially use this handler - its installed and enabled + if(!is_readable(e_PLUGIN . $mailer . '/e_mailout.php')) { - echo 'Invalid mailer selected: '.$mailer.'
'; - exit; + echo 'Invalid mailer selected: ' . $mailer . '
'; + exit ; } - require_once(e_PLUGIN.$mailer.'/e_mailout.php'); - if (varset($mailerIncludeWithDefault,TRUE)) - { // Definitely need this plugin - $mailClass = $mailer.'_mailout'; + require_once (e_PLUGIN . $mailer . '/e_mailout.php'); + if(varset($mailerIncludeWithDefault, TRUE)) + { + // Definitely need this plugin + $mailClass = $mailer . '_mailout'; $temp = new $mailClass; - if ($temp->mailerEnabled) + if($temp->mailerEnabled) { $this->mailHandlers[$mailer] = $temp; $ret++; - if (varset($mailerExcludeDefault,FALSE) && isset($this->mailHandlers['core'])) + if(varset($mailerExcludeDefault, FALSE) && isset($this->mailHandlers['core'])) { - $this->mailHandlers['core']->mailerEnabled = FALSE; // Don't need default (core) handler + $this->mailHandlers['core']->mailerEnabled = FALSE; + // Don't need default (core) handler $ret--; } } @@ -457,10 +595,9 @@ class mailoutAdminClass extends e107MailManager return $ret; } - /** * Generate the HTML for displaying email selection fields - * + * * @param $options - comma-separated string of areas to display: * plugins - selectors from any available plugins * cc - field for 'cc' options @@ -474,19 +611,19 @@ class mailoutAdminClass extends e107MailManager $ret = ''; $tab = ''; $tabc = ''; - - foreach ($this->mailHandlers as $key => $m) + + foreach($this->mailHandlers as $key => $m) { - if ($m->mailerEnabled) + if($m->mailerEnabled) { - $lactive = ($key == 'core') ? " class='active'" : ''; - $tab .= "".$m->mailerName.""; - - $pactive = ($key == 'core') ? 'active' : ''; - $tabc .= "
"; - + $lactive = ($key == 'core')? " class='active'": ''; + $tab .= "" . $m->mailerName . ""; + + $pactive = ($key == 'core')? 'active': ''; + $tabc .= "
"; + $content = $m->showSelect(TRUE, varset($selectorInfo[$key], FALSE)); - + if(is_array($content)) { $tabc .= "
@@ -495,44 +632,46 @@ class mailoutAdminClass extends e107MailManager "; - + foreach($content as $var) { - $tabc .= ""; + $tabc .= ""; } - $tabc .= "
".$var['caption']."".$var['html']."
" . $var['caption'] . "" . $var['html'] . "
"; + $tabc .= ""; } else { - $tabc .= $content; //BC (0.8 only) but should be deprecated + $tabc .= $content; + //BC (0.8 only) but should be deprecated } - - $tabc .= "
"; + + $tabc .= ""; } } -// $ret .= "
    ".$tab."
"; // This hides tabs! - $ret .= ""; - $ret .= "
\n"; - $ret .= $tabc; + // $ret .= "
    ".$tab."
"; // + // This hides tabs! + $ret .= ""; + $ret .= "
\n"; + $ret .= $tabc; $ret .= "
"; - + return $ret; } - /** * Get the selector details from each mail plugin (to add to mail data) - * - * @return array of selectors - key is the plugin name, value is the selector data (often itself an array) + * + * @return array of selectors - key is the plugin name, value is the selector + * data (often itself an array) */ public function getAllSelectors() { $ret = array(); - foreach ($this->mailHandlers as $key => $m) + foreach($this->mailHandlers as $key => $m) { - if ($m->mailerEnabled) + if($m->mailerEnabled) { $ret[$key] = $m->returnSelectors(); } @@ -540,110 +679,118 @@ class mailoutAdminClass extends e107MailManager return $ret; } - /** - * Creates a 'select' dropdown of userclasses, including the number of members in each class. - * + * Creates a 'select' dropdown of userclasses, including the number of members in + * each class. + * * @param string $name - name for \n"; - - foreach ($fixedClasses as $k => $v) + + foreach($fixedClasses as $k => $v) { - $sel = ($k == $curSel) ? " selected='selected'" : ''; + $sel = ($k == $curSel)? " selected='selected'": ''; $ret .= "\n"; } $query = "SELECT uc.*, count(u.user_id) AS members FROM #userclass_classes AS uc LEFT JOIN #user AS u ON u.user_class REGEXP concat('(^|,)',uc.userclass_id,'(,|$)') - WHERE NOT uc.userclass_id IN (".e_UC_PUBLIC.','.e_UC_NOBODY.','.e_UC_READONLY.','.e_UC_BOTS.") + WHERE NOT uc.userclass_id IN (" . e_UC_PUBLIC . ',' . e_UC_NOBODY . ',' . e_UC_READONLY . ',' . e_UC_BOTS . ") GROUP BY uc.userclass_id "; $this->db2->gen($query); - while ($row = $this->db2->fetch()) + while($row = $this->db2->fetch()) { - $public = ($row['userclass_editclass'] == e_UC_PUBLIC)? "(".LAN_MAILOUT_10.")" : ""; - $selected = ($row['userclass_id'] == $curSel) ? " selected='selected'" : ''; - $ret .= "\n"; + $public = ($row['userclass_editclass'] == e_UC_PUBLIC)? "(" . LAN_MAILOUT_10 . ")": ""; + $selected = ($row['userclass_id'] == $curSel)? " selected='selected'": ''; + $ret .= "\n"; } $ret .= " \n"; return $ret; } - - /** * Creates a 'select' dropdown of non-system user fields - * + * * @param string $list_name - name for \n"; - if ($add_blank) $ret .= "\n"; + if($add_blank) + $ret .= "\n"; - foreach ($ue->fieldDefinitions as $fd) + foreach($ue->fieldDefinitions as $fd) { - if ($fd['user_extended_struct_text'] != '_system_') + if($fd['user_extended_struct_text'] != '_system_') { - $value = 'ue.user_'.$fd['user_extended_struct_name']; - $selected = ($value == $curval) ? " selected='selected'" : ''; - $ret .= "\n"; + $value = 'ue.user_' . $fd['user_extended_struct_name']; + $selected = ($value == $curval)? " selected='selected'": ''; + $ret .= "\n"; } } $ret .= "\n"; return $ret; } - - /** * Creates an array of data from standard $_POST fields - * + * * @param $newMail - set TRUE for initial creation, FALSE when updating * @return array of data */ public function parseEmailPost($newMail = TRUE) { $tp = e107::getParser(); - - $ret = array( 'mail_title' => $_POST['email_title'], - 'mail_subject' => $_POST['email_subject'], - 'mail_body' => $_POST['email_body'], - 'mail_sender_email' => $_POST['email_from_email'], - 'mail_sender_name' => $_POST['email_from_name'], - 'mail_copy_to' => $_POST['email_cc'], - 'mail_bcopy_to' => $_POST['email_bcc'], - 'mail_attach' => trim($_POST['email_attachment']), - 'mail_send_style' => varset($_POST['email_send_style'],'textonly'), - 'mail_include_images' => (isset($_POST['email_include_images']) ? 1 : 0) - ); - - $ret = $tp->toDB($ret); // recursive - - if (isset($_POST['mail_source_id'])) + + $ret = array( + 'mail_title' => $_POST['email_title'], + 'mail_subject' => $_POST['email_subject'], + 'mail_body' => $_POST['email_body'], + 'mail_sender_email' => $_POST['email_from_email'], + 'mail_sender_name' => $_POST['email_from_name'], + 'mail_copy_to' => $_POST['email_cc'], + 'mail_bcopy_to' => $_POST['email_bcc'], + 'mail_attach' => trim($_POST['email_attachment']), + 'mail_send_style' => varset($_POST['email_send_style'], 'textonly'), + 'mail_include_images' => (isset($_POST['email_include_images'])? 1: 0) + ); + + $ret = $tp->toDB($ret); + // recursive + + if(isset($_POST['mail_source_id'])) { $ret['mail_source_id'] = intval($_POST['mail_source_id']); } - if ($newMail) + if($newMail) { $ret['mail_creator'] = USERID; $ret['mail_create_date'] = time(); @@ -651,139 +798,142 @@ class mailoutAdminClass extends e107MailManager return $ret; } - - /** * Does some basic checking on email data. - * + * * @param $email - array of data in parseEmailPost() format - * @param $fullCheck - TRUE to check all fields that are required (immediately prior to sending); FALSE to just check a few basics (prior to save) + * @param $fullCheck - TRUE to check all fields that are required (immediately + * prior to sending); FALSE to just check a few basics (prior to save) * @return TRUE if OK. Array of error messages if any errors found */ public function checkEmailPost(&$email, $fullCheck = FALSE) { $errList = array(); - if (count($email) < 3) + if(count($email) < 3) { $errList[] = LAN_MAILOUT_201; return $errList; } - if (!trim($email['mail_subject'])) $errList[] = LAN_MAILOUT_200; - if (!trim($email['mail_body'])) $errList[] = LAN_MAILOUT_202; - if (!trim($email['mail_sender_name'])) $errList[] = LAN_MAILOUT_203; - if (!trim($email['mail_sender_email'])) $errList[] = LAN_MAILOUT_204; - if (strlen($email['mail_send_style']) == 0) - { // Can be a template name now + if(!trim($email['mail_subject'])) + $errList[] = LAN_MAILOUT_200; + if(!trim($email['mail_body'])) + $errList[] = LAN_MAILOUT_202; + if(!trim($email['mail_sender_name'])) + $errList[] = LAN_MAILOUT_203; + if(!trim($email['mail_sender_email'])) + $errList[] = LAN_MAILOUT_204; + if(strlen($email['mail_send_style']) == 0) + { + // Can be a template name now $errList[] = LAN_MAILOUT_205; break; } else { // Get template data, override email settings as appropriate - require_once(e_HANDLER.'mail_template_class.php'); + require_once (e_HANDLER . 'mail_template_class.php'); $ourTemplate = new e107MailTemplate(); $templateName = $email['mail_send_style']; - if (!$ourTemplate->setNewTemplate($templateName)) + if(!$ourTemplate->setNewTemplate($templateName)) { - $errList[] = LAN_MAILOUT_207.':'.$templateName; - print_a($ourTemplate); // Probably template not found if error + $errList[] = LAN_MAILOUT_207 . ':' . $templateName; + print_a($ourTemplate); + // Probably template not found if error } - if (!$ourTemplate->makeEmailBody($email['mail_body'], $email['mail_include_images'])) + if(!$ourTemplate->makeEmailBody($email['mail_body'], $email['mail_include_images'])) { - $errList[] = LAN_MAILOUT_205.':'.$templateName; + $errList[] = LAN_MAILOUT_205 . ':' . $templateName; print_a($ourTemplate); } else { $email['mail_body_templated'] = $ourTemplate->mainBodyText; $email['mail_body_alt'] = $ourTemplate->altBodyText; - if (count($ourTemplate->lastTemplateData['email_overrides'])) + if(count($ourTemplate->lastTemplateData['email_overrides'])) { $email['mail_overrides'] = $ourTemplate->lastTemplateData['email_overrides']; } } } - if (count($errList) == 0) + if(count($errList) == 0) { return TRUE; } return $errList; } - /** * Generate a table which shows some information about an email. - * Intended to be part of a 2-column table - includes the row detail, but not the surrounding table definitions - * + * Intended to be part of a 2-column table - includes the row detail, but not the + * surrounding table definitions + * * @param $mailSource - array of mail information * @param $options - controls how much information is displayed * @return text for display */ - public function showMailDetail(&$mailSource, $options='basic') + public function showMailDetail(&$mailSource, $options = 'basic') { $tp = e107::getParser(); - - - if (!isset($this->mailDetailDisplay[$options])) + + if(!isset($this->mailDetailDisplay[$options])) { return "Programming bungle - invalid option value: {$options}"; } $text = ''; - foreach ($this->mailDetailDisplay[$options] as $k => $v) + foreach($this->mailDetailDisplay[$options] as $k => $v) { - $text .= ''.$this->fields['mail_content'][$k]['title'].''; + $text .= '' . $this->fields['mail_content'][$k]['title'] . ''; $val = $mailSource[$k]; - if (is_numeric($v)) + if(is_numeric($v)) { - $text .= ($v > 1) ? $tp->text_truncate($val, $v, '...') : $val; + $text .= ($v > 1)? $tp->text_truncate($val, $v, '...'): $val; } else { switch ($v) { - case 'username' : + case 'username': $text .= $this->getUserName($val); - break; - case 'sdatetime' : + break; + case 'sdatetime': $text .= $gen->convert_date($val, 'short'); - break; - case 'trunc200' : + break; + case 'trunc200': $text .= e107::getParser()->text_truncate($val, 200, '...'); - break; - case 'chars' : // Show generated html as is + break; + case 'chars': + // Show generated html as is $text .= htmlspecialchars($val, ENT_COMPAT, 'UTF-8'); - break; - case 'contentstatus' : + break; + case 'contentstatus': $text .= $this->statusToText($val); - break; - case 'selectors' : + break; + case 'selectors': $text .= 'cannot display'; - break; - case 'yesno' : - $text .= $val ? LAN_YES : LAN_NO; - break; - case 'default' : - default : + break; + case 'yesno': + $text .= $val? LAN_YES: LAN_NO; + break; + case 'default': + default: $text .= $val; } } - $text .= ''."\n"; + $text .= '' . "\n"; } return $text; } - - /** * Generate the HTML for dropdown to select mail sending style (text/HTML/styled - * + * * @param $curval - current value * @param $name name of item * @return text for display */ - //FIXME use $frm->select() instead. + //FIXME use $frm->select() instead. public function sendStyleSelect($curval = '', $name = 'email_send_style', $incTemplates = TRUE) { @@ -795,226 +945,228 @@ class mailoutAdminClass extends e107MailManager $text = "\n"; + $text .= "\n"; return $text; } - /** * Generate the HTML to show the mailout form. Used for both sending and editing - * + * * @param $mailSource - array of mail information * @return text for display */ - /* - function show_mailform(&$mailSource) - { - global $HANDLERS_DIRECTORY; - global $mailAdmin; - - $sql = e107::getDb(); - $ns = e107::getRender(); - $tp = e107::getParser(); - $frm = e107::getForm(); - $mes = e107::getMessage(); - $pref = e107::getPref(); - - if (!is_array($mailSource)) - { - $mes->addError('Coding error - mail not array (521)'); - //$ns->tablerender('ERROR!!', ); - //exit; - } + /* + function show_mailform(&$mailSource) + { + global $HANDLERS_DIRECTORY; + global $mailAdmin; - $email_subject = varset($mailSource['mail_subject'], ''); - $email_body = $tp->toForm(varset($mailSource['mail_body'],'')); - $email_id = varset($mailSource['mail_source_id'],''); - - $text = ''; + $sql = e107::getDb(); + $ns = e107::getRender(); + $tp = e107::getParser(); + $frm = e107::getForm(); + $mes = e107::getMessage(); + $pref = e107::getPref(); - if(strpos($_SERVER['SERVER_SOFTWARE'],'mod_gzip') && !is_readable(e_HANDLER.'phpmailer/.htaccess')) - { - $warning = LAN_MAILOUT_40.' '.$HANDLERS_DIRECTORY.'phpmailer/ '.LAN_MAILOUT_41; - $ns->tablerender(LAN_MAILOUT_42, $mes->render().$warning); - } + if (!is_array($mailSource)) + { + $mes->addError('Coding error - mail not array (521)'); + //$ns->tablerender('ERROR!!', ); + //exit; + } - $debug = (e_MENU == "debug") ? "?[debug]" : ""; - - - - $text .= "
-
"; - - - $text .= $this->emailSelector('all', varset($mailSource['mail_selectors'], FALSE)); - - $text .= " - - - - - - - - + $email_subject = varset($mailSource['mail_subject'], ''); + $email_body = $tp->toForm(varset($mailSource['mail_body'],'')); + $email_id = varset($mailSource['mail_source_id'],''); - - - - + $text = ''; - - - - "; + if(strpos($_SERVER['SERVER_SOFTWARE'],'mod_gzip') && + !is_readable(e_HANDLER.'phpmailer/.htaccess')) + { + $warning = LAN_MAILOUT_40.' '.$HANDLERS_DIRECTORY.'phpmailer/ '.LAN_MAILOUT_41; + $ns->tablerender(LAN_MAILOUT_42, $mes->render().$warning); + } + $debug = (e_MENU == "debug") ? "?[debug]" : ""; - // Add in the core and any plugin selectors here - */ - /*$text .= " - - - - - ";*/ - /* - $text .= " - - - - + $text .= "
+ "; -
- - - + $text .= $this->emailSelector('all', varset($mailSource['mail_selectors'], + FALSE)); - - - - "; + $text .= "
".LAN_MAILOUT_111.": ".$frm->text('email_title',varset($mailSource['mail_title'],''))."
".LAN_MAILOUT_01.": ".$frm->text('email_from_name',varset($mailSource['mail_from_name'],USERNAME))."
".LAN_MAILOUT_02.": ".$frm->text('email_from_email',varset($mailSource['mail_from_email'],USEREMAIL))."
".LAN_MAILOUT_03.": ".$this->emailSelector('all', varset($mailSource['mail_selectors'], FALSE))."
".LAN_MAILOUT_04.": ".$frm->text('email_cc',varset($mailSource['mail_cc'],''))."
".LAN_MAILOUT_05.": ".$frm->text('email_bcc',varset($mailSource['mail_bcc'],''))."
".LAN_MAILOUT_51.": ".$frm->text('email_subject',varset($email_subject,''),255,'required=1&size=xxlarge')."
+ + + + + + + + + + + + - // Attachment. - if (e107::isInstalled('download')) - { - // TODO - use download plugin API - - if($sql->select("download", "download_url,download_name", "download_id !='' ORDER BY download_name")) - { - $text .= " - - - "; - } + + + + "; - - } - // TODO File-Picker from Media-Manager. - + // Add in the core and any plugin selectors here + */ + /*$text .= " - $text .= " - - - + + + ";*/ + /* + $text .= " + + + + - global $eplug_bb; + + + + - $eplug_bb[] = array( - 'name' => 'shortcode', - 'onclick' => 'expandit', - 'onclick_var' => 'sc_selector', - 'icon' => e_IMAGE.'generic/bbcode/shortcode.png', - 'helptext' => LAN_MAILOUT_11, - 'function' => array($this,'sc_Select'), - 'function_var' => 'sc_selector' - ); + + + + "; + // Attachment. + if (e107::isInstalled('download')) + { + // TODO - use download plugin API - $text .= $this->sendStyleSelect(varset($mailSource['mail_send_style'], '')); - $checked = (isset($mailSource['mail_include_images']) && $mailSource['mail_include_images']) ? " checked='checked'" : ''; - $text .= "  ".LAN_MAILOUT_225; - $text .=" - \n - - - - "; + if($sql->select("download", "download_url,download_name", "download_id !='' + ORDER BY download_name")) + { + $text .= " + + - + "; + } - $text .=" - - -
".LAN_MAILOUT_111.": ".$frm->text('email_title',varset($mailSource['mail_title'],''))."
".LAN_MAILOUT_01.": ".$frm->text('email_from_name',varset($mailSource['mail_from_name'],USERNAME))."
".LAN_MAILOUT_07.": "; - $text .= ""; - - $text .= "
".LAN_MAILOUT_02.": ".$frm->text('email_from_email',varset($mailSource['mail_from_email'],USEREMAIL))."
".LAN_MAILOUT_09.": \n"; +
".LAN_MAILOUT_03.": ".$this->emailSelector('all', varset($mailSource['mail_selectors'], + FALSE))."
".LAN_MAILOUT_04.": ".$frm->text('email_cc',varset($mailSource['mail_cc'],''))."
".LAN_MAILOUT_05.": ".$frm->text('email_bcc',varset($mailSource['mail_bcc'],''))."
".LAN_MAILOUT_51.": ".$frm->text('email_subject',varset($email_subject,''),255,'required=1&size=xxlarge')."
".$frm->bbarea('email_body',$email_body,'mailout','helpb')."
".LAN_MAILOUT_07.": "; + $text .= "
-
"; + while ($row = $sql->fetch()) + { + $selected = ($mailSource['mail_attach'] == $row['download_url']) ? + "selected='selected'" : ''; + // $text .= "\n"; + $text .= "\n"; + } + $text .= " "; - // $text .= display_help('helpb','mailout'); - + $text .= "
"; + } + // TODO File-Picker from Media-Manager. + $text .= " + + ".LAN_MAILOUT_09.": + \n"; - $text .= "
"; - - if($email_id) - { - $text .= $frm->hidden('mail_source_id',$email_id); - $text .= $frm->admin_button('update_email',LAN_UPDATE); - //$text .= ""; - //$text .= ""; - } - else - { - $text .= $frm->admin_button('save_email',LAN_SAVE,'other'); - } - - - $text .= $frm->admin_button('send_email',LAN_MAILOUT_08); // + global $eplug_bb; - $text .= "
+ $eplug_bb[] = array( + 'name' => 'shortcode', + 'onclick' => 'expandit', + 'onclick_var' => 'sc_selector', + 'icon' => e_IMAGE.'generic/bbcode/shortcode.png', + 'helptext' => LAN_MAILOUT_11, + 'function' => array($this,'sc_Select'), + 'function_var' => 'sc_selector' + ); -
-
"; + $text .= $this->sendStyleSelect(varset($mailSource['mail_send_style'], '')); + $checked = (isset($mailSource['mail_include_images']) && + $mailSource['mail_include_images']) ? " checked='checked'" : ''; + $text .= "  ".LAN_MAILOUT_225; + $text .=" + \n + - return $text; - - // $ns->tablerender(ADLAN_136.SEP.LAN_MAILOUT_15, $mes->render(). $text); // Render the complete form - } - */ + ".$frm->bbarea('email_body',$email_body,'mailout','helpb')." + "; + + $text .=" + + +
"; + + // $text .= display_help('helpb','mailout'); + + $text .=" +
+ + "; + + $text .= "
"; + + if($email_id) + { + $text .= $frm->hidden('mail_source_id',$email_id); + $text .= $frm->admin_button('update_email',LAN_UPDATE); + //$text .= ""; + //$text .= ""; + } + else + { + $text .= $frm->admin_button('save_email',LAN_SAVE,'other'); + } + + $text .= $frm->admin_button('send_email',LAN_MAILOUT_08); // + + $text .= "
+ + +
"; + + return $text; + + // $ns->tablerender(ADLAN_136.SEP.LAN_MAILOUT_15, $mes->render(). $text); // + // Render the complete form + } + */ /** * Helper function manages the shortcodes which can be inserted */ - function sc_Select($container='sc_selector') + function sc_Select($container = 'sc_selector') { - $text =" + $text = " \n \n @@ -1044,50 +1196,50 @@ class mailoutAdminClass extends e107MailManager return $text; } - - - /** * Return dropdown for arithmetic comparisons - * + * * @param $name string name of select structure * @param $curval string current value * @return text for display */ public function comparisonSelect($name, $curval = '') { - $compVals = array(' ' => ' ', '<' => LAN_MAILOUT_175, '=' => LAN_MAILOUT_176, '>' => LAN_MAILOUT_177); + $compVals = array( + ' ' => ' ', + '<' => LAN_MAILOUT_175, + '=' => LAN_MAILOUT_176, + '>' => LAN_MAILOUT_177 + ); $ret = "\n"; return $ret; } - - /** * Show the generated template of a saved email */ public function showEmailTemplate($mailId) { - $mes = e107::getMessage(); - $ns = e107::getRender(); + $mes = e107::getMessage(); + $ns = e107::getRender(); $mailData = $this->retrieveEmail($mailId); - - if ($mailData === FALSE) + + if($mailData === FALSE) { $mes->addInfo(LAN_MAILOUT_79); - $ns-> tablerender(ADLAN_136.SEP.LAN_MAILOUT_171, $mes->render().$text); - exit; + $ns->tablerender(ADLAN_136 . SEP . LAN_MAILOUT_171, $mes->render() . $text); + exit ; } $text .= " -
+
@@ -1097,203 +1249,202 @@ class mailoutAdminClass extends e107MailManager "; $text .= $this->showMailDetail($mailData, 'template'); - $text .= '"; + $text .= '"; $text .= "
'.LAN_MAILOUT_172.''.$this->statusToText($mailData['mail_content_status'])."
' . LAN_MAILOUT_172 . '' . $this->statusToText($mailData['mail_content_status']) . "
\n
"; $text .= "
- ".$frm->admin_button('email_delete', LAN_MAILOUT_256, 'other')." + " . $frm->admin_button('email_delete', LAN_MAILOUT_256, 'other') . "
"; $text .= "
"; - $ns->tablerender(ADLAN_136.SEP.LAN_MAILOUT_255.$mailId, $text); + $ns->tablerender(ADLAN_136 . SEP . LAN_MAILOUT_255 . $mailId, $text); } - /** * Show a screen to confirm deletion of an email - * + * * @param $mailid - number of email * @param $nextPage - 'mode' specification for page to return to following delete * @return text for display */ /* - public function showDeleteConfirm($mailID, $nextPage = 'saved') - { - $mailData = $this->retrieveEmail($mailID); - $frm = e107::getForm(); - $ns = e107::getRender(); - $mes = e107::getMessage(); - - if ($mailData === FALSE) - { - $mes->addInfo(LAN_MAILOUT_79); - $ns-> tablerender(ADLAN_136.SEP.LAN_MAILOUT_171, $mes->render().$text); - exit; - } + public function showDeleteConfirm($mailID, $nextPage = 'saved') + { + $mailData = $this->retrieveEmail($mailID); + $frm = e107::getForm(); + $ns = e107::getRender(); + $mes = e107::getMessage(); - $text .= " -
-
- - - - - - - "; + if ($mailData === FALSE) + { + $mes->addInfo(LAN_MAILOUT_79); + $ns-> tablerender(ADLAN_136.SEP.LAN_MAILOUT_171, $mes->render().$text); + exit; + } - $text .= $this->showMailDetail($mailData, 'basic'); - $text .= '"; - if ($mailData['mail_content_status'] != MAIL_STATUS_SAVED) - { - $text .= ''; - } + $text .= " + +
+
'.LAN_MAILOUT_172.''.$this->statusToText($mailData['mail_content_status'])."
'.LAN_MAILOUT_173.''.($mailData['mail_togo_count'] + $mailData['mail_sent_count'] + $mailData['mail_fail_count']).'
+ + + + - $text .= "
\n
"; + "; - $text .= "
- ".$frm->admin_button('email_delete', LAN_DELETE, 'delete')." - ".$frm->admin_button('email_cancel', LAN_CANCEL, 'cancel')." -
-
"; + $text .= $this->showMailDetail($mailData, 'basic'); + $text .= + ''.LAN_MAILOUT_172.''.$this->statusToText($mailData['mail_content_status']).""; + if ($mailData['mail_content_status'] != MAIL_STATUS_SAVED) + { + $text .= ''.LAN_MAILOUT_173.''.($mailData['mail_togo_count'] + + $mailData['mail_sent_count'] + $mailData['mail_fail_count']).''; + } - $ns->tablerender(ADLAN_136.SEP.LAN_MAILOUT_171, $text); - } - */ - + $text .= "\n"; + $text .= "
+ ".$frm->admin_button('email_delete', LAN_DELETE, 'delete')." + ".$frm->admin_button('email_cancel', LAN_CANCEL, 'cancel')." +
+ "; + + $ns->tablerender(ADLAN_136.SEP.LAN_MAILOUT_171, $text); + } + */ /** - * Generate the HTML to show a list of emails of a particular type, in tabular form - * + * Generate the HTML to show a list of emails of a particular type, in tabular + * form + * * @param $type - type of email to display (saved|sent|pending|held) * @param $from - offset into table of candidates * @param $amount - number to return * @return text for display */ /* - public function showEmailList($type, $from = 0, $amount = 10) - { - // Need to select main email entries; count number of addresses attached to each - $gen = new convert; - $frm = e107::getForm(); - $ns = e107::getRender(); - $mes = e107::getMessage(); - $tp = e107::getParser(); + public function showEmailList($type, $from = 0, $amount = 10) + { + // Need to select main email entries; count number of addresses attached to each + $gen = new convert; + $frm = e107::getForm(); + $ns = e107::getRender(); + $mes = e107::getMessage(); + $tp = e107::getParser(); - switch ($type) - { - case 'sent' : - $searchType = 'allcomplete'; - break; - default : - $searchType = $type; - } + switch ($type) + { + case 'sent' : + $searchType = 'allcomplete'; + break; + default : + $searchType = $type; + } - if ($from < 0) { $from = $this->showFrom; } - if ($amount < 0) { $amount = $this->showCount; } - // in $_GET, so = sort order, sf = sort field - $count = $this->selectEmailStatus($from, $amount, '*', $searchType, $this->sortField, $this->sortOrder); - $totalCount = $this->getEmailCount(); - - $emails_found = array(); // Log ID and count for later + if ($from < 0) { $from = $this->showFrom; } + if ($amount < 0) { $amount = $this->showCount; } + // in $_GET, so = sort order, sf = sort field + $count = $this->selectEmailStatus($from, $amount, '*', $searchType, + $this->sortField, $this->sortOrder); + $totalCount = $this->getEmailCount(); - if (!$count) - { - $mes->addInfo(LAN_MAILOUT_79); - $ns->tablerender($this->tasks[$type]['title'], $mes->render() . $text); - return; - } + $emails_found = array(); // Log ID and count for later - $text = " -
-
- "; + if (!$count) + { + $mes->addInfo(LAN_MAILOUT_79); + $ns->tablerender($this->tasks[$type]['title'], $mes->render() . $text); + return; + } - $fieldPrefs = $this->calcFieldSpec($type, TRUE); // Get columns to display + $text = " + +
+
"; - // Must use '&' rather than '&' in query pattern - $text .= $frm->colGroup($this->fields['mail_content'],$this->fieldPref).$frm->thead($this->fields['mail_content'],$this->fieldPref,'mode='.$type."&fld=[FIELD]&asc=[ASC]&frm=[FROM]").""; + $fieldPrefs = $this->calcFieldSpec($type, TRUE); // Get columns to display - while ($row = $this->getNextEmailStatus(FALSE)) - { - //print_a($row); - $text .= ''; - foreach ($fieldPrefs as $fieldName) - { // Output column data value - $text .= ''; - } - // Add in options here - $text .= ''; - $text .= ''; - } - $text .= "
'; - if (isset($row[$fieldName])) - { - $proctype = varset($this->fields['mail_content'][$fieldName]['proc'], 'default'); - switch ($proctype) - { - case 'username' : - $text .= $this->getUserName($row[$fieldName]); - break; - case 'sdatetime' : - $text .= $gen->convert_date($row[$fieldName], 'short'); - break; - case 'trunc200' : - $text .= $tp->text_truncate($row[$fieldName], 200, '...'); - break; - case 'chars' : // Show generated html as is - $text .= htmlspecialchars($row[$fieldName], ENT_COMPAT, 'UTF-8'); - break; - case 'contentstatus' : - $text .= $this->statusToText($row[$fieldName]); - break; - case 'selectors' : - $text .= 'cannot display'; - break; - case 'yesno' : - $text .= $row[$fieldName] ? LAN_YES : LAN_NO; - break; - case 'default' : - default : - $text .= $row[$fieldName]; - } - } - else - { // Special stuff - } - $text .= ''.$this->makeMailOptions($type,$row).'


\n"; + // Must use '&' rather than '&' in query pattern + $text .= + $frm->colGroup($this->fields['mail_content'],$this->fieldPref).$frm->thead($this->fields['mail_content'],$this->fieldPref,'mode='.$type."&fld=[FIELD]&asc=[ASC]&frm=[FROM]").""; - if ($totalCount > $count) - { - $parms = "{$totalCount},{$amount},{$from},".e_SELF."?mode={$type}&count={$amount}&frm=[FROM]&fld={$this->sortField}&asc={$this->sortOrder}"; - $text .= $tp->parseTemplate("{NEXTPREV={$parms}}"); - } + while ($row = $this->getNextEmailStatus(FALSE)) + { + //print_a($row); + $text .= ''; + foreach ($fieldPrefs as $fieldName) + { // Output column data value + $text .= ''; + if (isset($row[$fieldName])) + { + $proctype = varset($this->fields['mail_content'][$fieldName]['proc'], + 'default'); + switch ($proctype) + { + case 'username' : + $text .= $this->getUserName($row[$fieldName]); + break; + case 'sdatetime' : + $text .= $gen->convert_date($row[$fieldName], 'short'); + break; + case 'trunc200' : + $text .= $tp->text_truncate($row[$fieldName], 200, '...'); + break; + case 'chars' : // Show generated html as is + $text .= htmlspecialchars($row[$fieldName], ENT_COMPAT, 'UTF-8'); + break; + case 'contentstatus' : + $text .= $this->statusToText($row[$fieldName]); + break; + case 'selectors' : + $text .= 'cannot display'; + break; + case 'yesno' : + $text .= $row[$fieldName] ? LAN_YES : LAN_NO; + break; + case 'default' : + default : + $text .= $row[$fieldName]; + } + } + else + { // Special stuff + } + $text .= ''; + } + // Add in options here + $text .= ''.$this->makeMailOptions($type,$row).''; + $text .= ''; + } + $text .= "

\n"; - $text .= '
'; - $ns->tablerender(ADLAN_136.SEP.$this->tasks[$type]['title'], $text); - } - */ - + if ($totalCount > $count) + { + $parms = + "{$totalCount},{$amount},{$from},".e_SELF."?mode={$type}&count={$amount}&frm=[FROM]&fld={$this->sortField}&asc={$this->sortOrder}"; + $text .= $tp->parseTemplate("{NEXTPREV={$parms}}"); + } + + $text .= ''; + $ns->tablerender(ADLAN_136.SEP.$this->tasks[$type]['title'], $text); + } + */ - - - - - - - - - /** * Generate a list of emails to send * Returns various information to display in a confirmation screen * - * The email and its recipients are stored in the DB with a tag of 'MAIL_STATUS_TEMP' if its a new email (no change if already on hold) - * + * The email and its recipients are stored in the DB with a tag of + * 'MAIL_STATUS_TEMP' if its a new email (no change if already on hold) + * * @param array $mailData - Details of the email, selection criteria etc - * @param boolean $fromHold - FALSE if this is a 'new' email to send, TRUE if its already been put on hold (selects processing path) + * @param boolean $fromHold - FALSE if this is a 'new' email to send, TRUE if its + * already been put on hold (selects processing path) * @return text for display */ public function sendEmailCircular($mailData, $fromHold = FALSE) @@ -1301,17 +1452,19 @@ class mailoutAdminClass extends e107MailManager $sql = e107::getDb(); $mes = e107::getMessage(); $frm = e107::getForm(); - - - if ($fromHold) - { // Email data already generated + + if($fromHold) + { + // Email data already generated $mailMainID = $mailData['mail_source_id']; - if ($mailMainID == 0) return FALSE; - if (FALSE === ($mailData = $this->retrieveEmail($mailMainID))) // Get the new data + if($mailMainID == 0) + return FALSE; + if(FALSE === ($mailData = $this->retrieveEmail($mailMainID)))// Get the new data { return FALSE; } - $counters['add'] = $mailData['mail_togo_count']; // Set up the counters + $counters['add'] = $mailData['mail_togo_count']; + // Set up the counters $counters['dups'] = 0; } else @@ -1320,52 +1473,64 @@ class mailoutAdminClass extends e107MailManager $mailData['mail_content_status'] = MAIL_STATUS_TEMP; $mailData['mail_create_app'] = 'core'; $result = $this->saveEmail($mailData, TRUE); - if (is_numeric($result)) + // $result = $this->saveEmail($mailData, false); // false = update, not insert. + if(is_numeric($result)) { $mailMainID = $mailData['mail_source_id'] = $result; } else { - // TODO: Handle error + e107::getMessage()->addDebug("Couldn't save email. (".__FILE__." Line: ".__LINE__.")"); } - + + - $this->mailInitCounters($mailMainID); // Initialise counters for emails added - - foreach ($this->mailHandlers as $key => $m) - { // Get email addresses from each handler in turn. Do them one at a time, so that all can use the $sql data object - if ($m->mailerEnabled && isset($mailData['mail_selectors'][$key])) + $this->mailInitCounters($mailMainID); + // Initialise counters for emails added + + foreach($this->mailHandlers as $key => $m) + { + // Get email addresses from each handler in turn. Do them one at a time, so that + // all can use the $sql data object + if($m->mailerEnabled && isset($mailData['mail_selectors'][$key])) { // Initialise $mailerCount = $m->selectInit($mailData['mail_selectors'][$key]); - if ($mailerCount > 0) + if($mailerCount > 0) { // Get email addresses - add to list, strip duplicates - while ($row = $m->selectAdd()) - { // Add email addresses to the database ready for sending (the body is never saved in the DB - it gets passed as a $_POST value) + while($row = $m->selectAdd()) + { + // Add email addresses to the database ready for sending (the body is never saved + // in the DB - it gets passed as a $_POST value) $result = $this->mailAddNoDup($mailMainID, $row, MAIL_STATUS_TEMP); - if ($result === FALSE) + if($result === FALSE) { // Error + e107::getMessage()->addDebug("Couldn't add receipients (".__FILE__." Line: ".__LINE__.")"); } } } - $m->select_close(); // Close + $m->select_close(); + // Close // Update the stats after each handler $this->mailUpdateCounters($mailMainID); } } $counters = $this->mailRetrieveCounters($mailMainID); - // $this->e107->admin_log->log_event('MAIL_02','ID: '.$mailMainID.' '.$counters['add'].'[!br!]'.$_POST['email_from_name']." <".$_POST['email_from_email'],E_LOG_INFORMATIVE,''); + // $this->e107->admin_log->log_event('MAIL_02','ID: '.$mailMainID.' + // '.$counters['add'].'[!br!]'.$_POST['email_from_name']." + // <".$_POST['email_from_email'],E_LOG_INFORMATIVE,''); } // We've got all the email addresses here - display a confirmation form // Include start/end dates for send - // $text = "
"; - + // $text = ""; + $text = " - +
@@ -1376,57 +1541,57 @@ class mailoutAdminClass extends e107MailManager $text .= $this->showMailDetail($mailData, 'send'); - // Add in core and any plugin selectors here - foreach ($this->mailHandlers as $key => $m) + foreach($this->mailHandlers as $key => $m) { - if ($m->mailerEnabled && ($contentArray = $m->showSelect(FALSE,$mailData['mail_selectors'][$key]))) + if($m->mailerEnabled && ($contentArray = $m->showSelect(FALSE, $mailData['mail_selectors'][$key]))) { - $text .= ''; + $text .= ''; $text .= ''; } } // Figures - number of emails to send, number of duplicates stripped - $text .= '"; - $text .= ''; + $text .= '"; + $text .= ''; $text .= "
'.LAN_MAILOUT_180.'
'.$m->mailerName.'
' . LAN_MAILOUT_180 . '
' . $m->mailerName . '
    '; foreach($contentArray as $val) { - $text .= "
  • ".$val['caption']." : ".$val['html']."
  • "; + $text .= "
  • " . $val['caption'] . " : " . $val['html'] . "
  • "; } $text .= '
'.LAN_MAILOUT_173.''.($mailData['mail_togo_count'])."
'.LAN_MAILOUT_71.' '.$counters['add'].' '.LAN_MAILOUT_69.$counters['dups'].LAN_MAILOUT_70.'
' . LAN_MAILOUT_173 . '' . ($mailData['mail_togo_count']) . "
' . LAN_MAILOUT_71 . ' ' . $counters['add'] . ' ' . LAN_MAILOUT_69 . $counters['dups'] . LAN_MAILOUT_70 . '
\n
"; - $text .= $this->makeAdvancedOptions(TRUE); // Show the table of advanced options + $text .= $this->makeAdvancedOptions(TRUE); + // Show the table of advanced options $text .= "
"; - - $text .= $frm->admin_button('email_sendnow',"Send Now", 'primary'); - $text .= $frm->admin_button('email_send',"Send Later"); - + + $text .= $frm->admin_button('email_sendnow', "Send Now", 'primary'); + $text .= $frm->admin_button('email_send', "Send Later"); + // $text .= ""; - - if (!$fromHold) + + if(!$fromHold) { - $text .= $frm->admin_button('email_hold',LAN_HOLD, 'warning'); - $text .= $frm->admin_button('email_cancel',LAN_CANCEL, 'delete'); - // $text .= " "; - // $text .= " "; + $text .= $frm->admin_button('email_hold', LAN_HOLD, 'warning'); + $text .= $frm->admin_button('email_cancel', LAN_CANCEL, 'delete'); + // $text .= " "; + // $text .= " "; } - - $text .= $frm->hidden('email_id',$mailMainID); - + + $text .= $frm->hidden('email_id', $mailMainID); + $text .= "
"; - - return $text; - // e107::getRender()->tablerender(ADLAN_136.SEP.LAN_MAILOUT_179, $mes->render(). $text); - } // End of previewed email - - + return $text; + // e107::getRender()->tablerender(ADLAN_136.SEP.LAN_MAILOUT_179, $mes->render(). + // $text); + }// End of previewed email /** * @@ -1436,7 +1601,7 @@ class mailoutAdminClass extends e107MailManager // Separate table for advanced mailout options // mail_notify_complete field $text = " - ".LAN_MAILOUT_242." + " . LAN_MAILOUT_242 . "
@@ -1445,18 +1610,21 @@ class mailoutAdminClass extends e107MailManager "; - $text .= ""; - $text .= ""; - // Can comment the two lines above, uncomment two lines below, and default time/date is shown. May or may not be preferable -// $text .= ""; -// $text .= ""; - $text .= ""; + $text .= ""; + $text .= ""; + // Can comment the two lines above, uncomment two lines below, and default + // time/date is shown. May or may not be preferable + // $text .= + // ""; + // $text .= + // ""; + $text .= ""; $text .= "
".LAN_MAILOUT_238."".$this->makeCalendar('mail_earliest_time', '', CORE_DATE_ORDER)."
".LAN_MAILOUT_239."".$this->makeCalendar('mail_latest_time', '', CORE_DATE_ORDER)."
".LAN_MAILOUT_238."".$this->makeCalendar('mail_earliest_time', time(), CORE_DATE_ORDER)."
".LAN_MAILOUT_239."".$this->makeCalendar('mail_latest_time', time()+86400, CORE_DATE_ORDER)."
".LAN_MAILOUT_240."".LAN_MAILOUT_241."
" . LAN_MAILOUT_238 . "" . $this->makeCalendar('mail_earliest_time', '', CORE_DATE_ORDER) . "
" . LAN_MAILOUT_239 . "" . $this->makeCalendar('mail_latest_time', '', CORE_DATE_ORDER) . "
".LAN_MAILOUT_238."".$this->makeCalendar('mail_earliest_time', + // time(), CORE_DATE_ORDER)."
".LAN_MAILOUT_239."".$this->makeCalendar('mail_latest_time', + // time()+86400, CORE_DATE_ORDER)."
" . LAN_MAILOUT_240 . "" . LAN_MAILOUT_241 . "
\n
"; return $text; } - - /** * */ @@ -1465,37 +1633,36 @@ class mailoutAdminClass extends e107MailManager // Determine formatting strings this way, to give sensible default switch ($dateOrder) { - case 'mdy' : + case 'mdy': $dFormat = '%m/%d/%y'; $tFormat = '%H:%M'; - break; - case 'ymd' : + break; + case 'ymd': $dFormat = '%Y/%m/%d'; $tFormat = ' %H:%M'; - break; - case 'dmy' : - default : + break; + case 'dmy': + default: $dFormat = '%d/%m/%Y'; $tFormat = ' %H:%M'; } $options = array( 'type' => 'datetime', - 'format' => $dFormat." ".$tFormat, - // 'timeformat' => $tFormat, - 'firstDay' => 1, // 0 = Sunday. + 'format' => $dFormat . " " . $tFormat, + // 'timeformat' => $tFormat, + 'firstDay' => 1, // 0 = Sunday. 'size' => 12 - ); -// $options['dateFormat'] = $dformat; -// $options['timeFormat'] = $tformat; - - return e107::getForm()->datepicker($calName,$calVal,$options); - } + ); + // $options['dateFormat'] = $dformat; + // $options['timeFormat'] = $tformat; + return e107::getForm()->datepicker($calName, $calVal, $options); + } /** * Show recipients of an email - * + * * @param $mailid - number of email * @param $nextPage - 'mode' specification for page to return to following delete * @return text for display @@ -1509,16 +1676,16 @@ class mailoutAdminClass extends e107MailManager $ns = e107::getRender(); $mailData = $this->retrieveEmail($mailID); - - if ($mailData === FALSE) + + if($mailData === FALSE) { $mes->addInfo(LAN_MAILOUT_79); - $ns-> tablerender(ADLAN_136.SEP.LAN_MAILOUT_171, $mes->render().$text); - exit; + $ns->tablerender(ADLAN_136 . SEP . LAN_MAILOUT_171, $mes->render() . $text); + exit ; } $text .= " -
+
@@ -1529,76 +1696,77 @@ class mailoutAdminClass extends e107MailManager "; $text .= $this->showMailDetail($mailData, 'basic'); - $text .= '"; - if ($mailData['mail_content_status'] != MAIL_STATUS_SAVED) + $text .= '"; + if($mailData['mail_content_status'] != MAIL_STATUS_SAVED) { - $text .= ''; + $text .= ''; } $text .= "
'.LAN_MAILOUT_172.''.$this->statusToText($mailData['mail_content_status'])."
' . LAN_MAILOUT_172 . '' . $this->statusToText($mailData['mail_content_status']) . "
'.LAN_MAILOUT_173.''.($mailData['mail_togo_count'] + $mailData['mail_sent_count'] + $mailData['mail_fail_count']).'
' . LAN_MAILOUT_173 . '' . ($mailData['mail_togo_count'] + $mailData['mail_sent_count'] + $mailData['mail_fail_count']) . '
\n
"; - // List of recipients // in $_GET, asc = sort order, fld = sort field $count = $this->selectTargetStatus($mailID, $this->showFrom, $this->showCount, '*', FALSE, $this->sortField, $this->sortOrder); $totalCount = $this->getTargetCount(); - if ($count == 0) + if($count == 0) { - $text .= "".LAN_MAILOUT_253.''; + $text .= "" . LAN_MAILOUT_253 . ''; } else { $text .= " -
+
"; - - $fieldPrefs = $this->calcFieldSpec('recipients', TRUE); // Get columns to display + $fieldPrefs = $this->calcFieldSpec('recipients', TRUE); + // Get columns to display // Must use '&' rather than '&' in query pattern - $text .= $frm->colGroup($this->fields['mail_recipients'],$this->fieldPref).$frm->thead($this->fields['mail_recipients'],$this->fieldPref,'mode='.'recipients&m='.$mailID."&fld=[FIELD]&asc=[ASC]&frm=[FROM]").""; + $text .= $frm->colGroup($this->fields['mail_recipients'], $this->fieldPref) . $frm->thead($this->fields['mail_recipients'], $this->fieldPref, 'mode=' . 'recipients&m=' . $mailID . "&fld=[FIELD]&asc=[ASC]&frm=[FROM]") . ""; - while ($row = $this->getNextTargetStatus(FALSE)) + while($row = $this->getNextTargetStatus(FALSE)) { // print_a($row); $text .= ''; - foreach ($fieldPrefs as $fieldName) - { // Output column data value + foreach($fieldPrefs as $fieldName) + { + // Output column data value $text .= ''; } // Add in options here - $text .= ''; + $text .= ''; $text .= ''; } $text .= "
'; - if (isset($row[$fieldName])) + if(isset($row[$fieldName])) { $proctype = varset($this->fields['mail_recipients'][$fieldName]['proc'], 'default'); switch ($proctype) { - case 'username' : + case 'username': $text .= $this->getUserName($row[$fieldName]); - break; - case 'sdatetime' : + break; + case 'sdatetime': $text .= $gen->convert_date($row[$fieldName], 'short'); - break; - case 'trunc200' : + break; + case 'trunc200': $text .= $tp->text_truncate($row[$fieldName], 200, '...'); - break; - case 'chars' : // Show generated html as is + break; + case 'chars': + // Show generated html as is $text .= htmlspecialchars($row[$fieldName], ENT_COMPAT, 'UTF-8'); - break; - case 'contentstatus' : + break; + case 'contentstatus': $text .= $this->statusToText($row[$fieldName]); - break; - case 'selectors' : + break; + case 'selectors': $text .= 'cannot display'; - break; - case 'array' : - if (is_array($row[$fieldName])) + break; + case 'array': + if(is_array($row[$fieldName])) { $nl = ''; - foreach ($row[$fieldName] as $k => $v) + foreach($row[$fieldName] as $k => $v) { - if ($v) + if($v) { - $text .= $nl.$k.' => '.$v; + $text .= $nl . $k . ' => ' . $v; $nl = '
'; } } @@ -1607,253 +1775,298 @@ class mailoutAdminClass extends e107MailManager { $text .= 'bad data: '; } - break; - case 'default' : - default : + break; + case 'default': + default: $text .= $row[$fieldName]; } } else - { // Special stuff + { + // Special stuff $text .= 'special'; } $text .= '
'.$this->makeTargetOptions('recipients',$row).'' . $this->makeTargetOptions('recipients', $row) . '
\n


"; - if ($totalCount > $count) + if($totalCount > $count) { - $parms = "{$totalCount},{$this->showCount},{$this->showFrom},".e_SELF."?mode=recipients&m={$mailID}&count={$this->showCount}&frm=[FROM]&fld={$this->sortField}&asc={$this->sortOrder}&savepage={$nextPage}"; + $parms = "{$totalCount},{$this->showCount},{$this->showFrom}," . e_SELF . "?mode=recipients&m={$mailID}&count={$this->showCount}&frm=[FROM]&fld={$this->sortField}&asc={$this->sortOrder}&savepage={$nextPage}"; $text .= $tp->parseTemplate("{NEXTPREV={$parms}}"); } } - $ns->tablerender(ADLAN_136.SEP.LAN_MAILOUT_181, $mes->render() . $text); + $ns->tablerender(ADLAN_136 . SEP . LAN_MAILOUT_181, $mes->render() . $text); } - /** * Clean up mailout DB * Dump array of results to admin log - * + * * @return boolean TRUE if no errors, FALSE if errors */ public function dbTidy() { $noError = TRUE; $results = array(); - $this->checkDB(2); // Make sure DB object created - + $this->checkDB(2); + // Make sure DB object created + // First thing, delete temporary records from both tables - if (($res = $this->db2->db_Delete('mail_content', '`mail_content_status` = '.MAIL_STATUS_TEMP)) === FALSE) + if(($res = $this->db2->db_Delete('mail_content', '`mail_content_status` = ' . MAIL_STATUS_TEMP)) === FALSE) { - $results[] = 'Error '.$this->db2->mySQLlastErrNum.':'.$this->db2->mySQLlastErrText.' deleting temporary records from mail_content'; + $results[] = 'Error ' . $this->db2->mySQLlastErrNum . ':' . $this->db2->mySQLlastErrText . ' deleting temporary records from mail_content'; $noError = FALSE; } else { - if ($res) $results[] = str_replace(array('--COUNT--', '--TABLE--'), array($res, 'mail_content'), LAN_MAILOUT_227); + if($res) + $results[] = str_replace(array( + '--COUNT--', + '--TABLE--' + ), array( + $res, + 'mail_content' + ), LAN_MAILOUT_227); } - if (($res = $this->db2->delete('mail_recipients', '`mail_status` = '.MAIL_STATUS_TEMP)) === FALSE) + if(($res = $this->db2->delete('mail_recipients', '`mail_status` = ' . MAIL_STATUS_TEMP)) === FALSE) { - $results[] = 'Error '.$this->db2->mySQLlastErrNum.':'.$this->db2->mySQLlastErrText.' deleting temporary records from mail_recipients'; + $results[] = 'Error ' . $this->db2->mySQLlastErrNum . ':' . $this->db2->mySQLlastErrText . ' deleting temporary records from mail_recipients'; $noError = FALSE; } else { - if ($res) $results[] = str_replace(array('--COUNT--', '--TABLE--'), array($res, 'mail_recipients'), LAN_MAILOUT_227); + if($res) + $results[] = str_replace(array( + '--COUNT--', + '--TABLE--' + ), array( + $res, + 'mail_recipients' + ), LAN_MAILOUT_227); } // Now look for 'orphaned' recipient records - if (($res = $this->db2->gen("DELETE `#mail_recipients` FROM `#mail_recipients` + if(($res = $this->db2->gen("DELETE `#mail_recipients` FROM `#mail_recipients` LEFT JOIN `#mail_content` ON `#mail_recipients`.`mail_detail_id` = `#mail_content`.`mail_source_id` WHERE `#mail_content`.`mail_source_id` IS NULL")) === FALSE) { - $results[] = 'Error '.$this->db2->mySQLlastErrNum.':'.$this->db2->mySQLlastErrText.' deleting orphaned records from mail_recipients'; + $results[] = 'Error ' . $this->db2->mySQLlastErrNum . ':' . $this->db2->mySQLlastErrText . ' deleting orphaned records from mail_recipients'; $noError = FALSE; } - elseif ($res) + elseif($res) { - if ($res) $results[] = str_replace('--COUNT--', $res, LAN_MAILOUT_226); + if($res) + $results[] = str_replace('--COUNT--', $res, LAN_MAILOUT_226); } // Scan content table for anomalies, out of time records - if (($res = $this->db2->gen("SELECT * FROM `#mail_content` - WHERE (`mail_content_status` >".MAIL_STATUS_FAILED.") AND (`mail_content_status` <=".MAIL_STATUS_MAX_ACTIVE.") - AND ((`mail_togo_count`=0) OR ( (`mail_last_date` != 0) AND (`mail_last_date` < ".time().")))")) === FALSE) + if(($res = $this->db2->gen("SELECT * FROM `#mail_content` + WHERE (`mail_content_status` >" . MAIL_STATUS_FAILED . ") AND (`mail_content_status` <=" . MAIL_STATUS_MAX_ACTIVE . ") + AND ((`mail_togo_count`=0) OR ( (`mail_last_date` != 0) AND (`mail_last_date` < " . time() . ")))")) === FALSE) { - $results[] = 'Error '.$this->db2->mySQLlastErrNum.':'.$this->db2->mySQLlastErrText.' checking bad status in mail_content'; + $results[] = 'Error ' . $this->db2->mySQLlastErrNum . ':' . $this->db2->mySQLlastErrText . ' checking bad status in mail_content'; $noError = FALSE; } else { - $items = array(); // Store record number of any content record that needs to be changed - while ($row = $this->db2->fetch(MYSQL_ASSOC)) + $items = array(); + // Store record number of any content record that needs to be changed + while($row = $this->db2->fetch(MYSQL_ASSOC)) { $items[] = $row['mail_source_id']; - if ($row['mail_source_id']) + if($row['mail_source_id']) { - if (FALSE == $this->cancelEmail($row['mail_source_id'])) + if(FALSE == $this->cancelEmail($row['mail_source_id'])) { - $results[] = 'Error cancelling email ref: '.$row['mail_source_id']; + $results[] = 'Error cancelling email ref: ' . $row['mail_source_id']; } else { - $results[] = 'Email cancelled: '.$row['mail_source_id']; + $results[] = 'Email cancelled: ' . $row['mail_source_id']; } } } - if (count($items)) $results[] = str_replace(array('--COUNT--', '--RECORDS--'), array(count($items), implode(', ', $items)), LAN_MAILOUT_228); + if(count($items)) + $results[] = str_replace(array( + '--COUNT--', + '--RECORDS--' + ), array( + count($items), + implode(', ', $items) + ), LAN_MAILOUT_228); } - - //Finally - check for inconsistent recipient and content status records - basically verify counts - if (($res = $this->db2->db_Select_gen("SELECT COUNT(mr.`mail_status`) AS mr_count, mr.`mail_status`, + //Finally - check for inconsistent recipient and content status records - + // basically verify counts + if(($res = $this->db2->db_Select_gen("SELECT COUNT(mr.`mail_status`) AS mr_count, mr.`mail_status`, mc.`mail_source_id`, mc.`mail_togo_count`, mc.`mail_sent_count`, mc.`mail_fail_count`, mc.`mail_bounce_count`, mc.`mail_source_id` FROM `#mail_recipients` AS mr LEFT JOIN `#mail_content` AS mc ON mr.`mail_detail_id` = mc.`mail_source_id` - WHERE mc.`mail_content_status` <= ".MAIL_STATUS_MAX_ACTIVE." + WHERE mc.`mail_content_status` <= " . MAIL_STATUS_MAX_ACTIVE . " GROUP BY mr.`mail_status`, mc.`mail_source_id` ORDER BY mc.`mail_source_id` ")) === FALSE) { - $results[] = 'Error '.$this->db2->mySQLlastErrNum.':'.$this->db2->mySQLlastErrText.' assembling email counts'; + $results[] = 'Error ' . $this->db2->mySQLlastErrNum . ':' . $this->db2->mySQLlastErrText . ' assembling email counts'; $noError = FALSE; } else { - $lastMail = 0; // May get several rows per mail - $notLast = TRUE; // This forces one more loop, so we can clean up for last record read + $lastMail = 0; + // May get several rows per mail + $notLast = TRUE; + // This forces one more loop, so we can clean up for last record read $changeCount = 0; $saveRow = array(); - while (($row = $this->db2->fetch(MYSQL_ASSOC)) || $notLast) + while(($row = $this->db2->fetch(MYSQL_ASSOC)) || $notLast) { - if (($lastMail > 0 && $row === FALSE) || ($lastMail != $row['mail_source_id'])) - { // Change of mail ID here - handle any accumulated info - if ($lastMail > 0) - { // Need to verify counts for mail just read + if(($lastMail > 0 && $row === FALSE) || ($lastMail != $row['mail_source_id'])) + { + // Change of mail ID here - handle any accumulated info + if($lastMail > 0) + { + // Need to verify counts for mail just read $changes = array(); - foreach ($counters as $k => $v) + foreach($counters as $k => $v) { - if ($saveRow[$k] != $v) + if($saveRow[$k] != $v) { - $changes[$k] = $v; // Assume the counters have got it right + $changes[$k] = $v; + // Assume the counters have got it right } } - if (count($changes)) + if(count($changes)) { - // *************** Update mail record here ********************* + // *************** Update mail record here ********************* $this->checkDB(1); - $this->db->update('mail_content', array('data' => $changes, 'WHERE' => '`mail_source_id` = '.$lastMail, '_FIELDS' => $this->dbTypes['mail_content'])); + $this->db->update('mail_content', array( + 'data' => $changes, + 'WHERE' => '`mail_source_id` = ' . $lastMail, + '_FIELDS' => $this->dbTypes['mail_content'] + )); $line = "Count update for {$saveRow['mail_source_id']} - {$saveRow['mail_togo_count']}, {$saveRow['mail_sent_count']}, {$saveRow['mail_fail_count']}, {$saveRow['mail_bounce_count']} => "; - $line .= implode (', ', $counters); + $line .= implode(', ', $counters); $results[] = $line; $changeCount++; //echo $line.'
'; } } - + // Now reset for current mail $lastMail = $row['mail_source_id']; - $counters = array('mail_togo_count' => 0, 'mail_sent_count' => 0, 'mail_fail_count' => 0, 'mail_bounce_count' => 0); + $counters = array( + 'mail_togo_count' => 0, + 'mail_sent_count' => 0, + 'mail_fail_count' => 0, + 'mail_bounce_count' => 0 + ); $saveRow = $row; } - if ($row === FALSE) $notLast = FALSE; - // We get one record for each mail_status value for a given email - use them to update counts - if ($notLast) + if($row === FALSE) + $notLast = FALSE; + // We get one record for each mail_status value for a given email - use them to + // update counts + if($notLast) { switch ($row['mail_status']) { - case MAIL_STATUS_SENT : // Mail sent. Email handler happy, but may have bounced (or may be yet to bounce) + case MAIL_STATUS_SENT: + // Mail sent. Email handler happy, but may have bounced (or may be yet to bounce) $counters['mail_sent_count'] += $row['mr_count']; - break; - case MAIL_STATUS_BOUNCED : - $counters['mail_sent_count'] += $row['mr_count']; // It was sent, so increment that counter - $counters['mail_bounce_count'] += $row['mr_count']; //...but bounced, so extra status - break; - case MAIL_STATUS_CANCELLED : // Cancelled email - treat as a failure - case MAIL_STATUS_FAILED : - $counters['mail_fail_count'] += $row['mr_count']; // Never sent at all - break; - case MAIL_STATUS_PARTIAL : // Shouldn't get this on individual emails - ignore if we do - break; - default : - if (($row['mail_status'] >= MAIL_STATUS_PENDING) && ($row['mail_status'] <= MAIL_STATUS_MAX_ACTIVE)) + break; + case MAIL_STATUS_BOUNCED: + $counters['mail_sent_count'] += $row['mr_count']; + // It was sent, so increment that counter + $counters['mail_bounce_count'] += $row['mr_count']; + //...but bounced, so extra status + break; + case MAIL_STATUS_CANCELLED: + // Cancelled email - treat as a failure + case MAIL_STATUS_FAILED: + $counters['mail_fail_count'] += $row['mr_count']; + // Never sent at all + break; + case MAIL_STATUS_PARTIAL: + // Shouldn't get this on individual emails - ignore if we do + break; + default: + if(($row['mail_status'] >= MAIL_STATUS_PENDING) && ($row['mail_status'] <= MAIL_STATUS_MAX_ACTIVE)) { - $counters['mail_togo_count'] += $row['mr_count']; // Still in the queue + $counters['mail_togo_count'] += $row['mr_count']; + // Still in the queue } } } } - if ($changeCount) $results[] = str_replace('--COUNT--', $changeCount, LAN_MAILOUT_237); + if($changeCount) + $results[] = str_replace('--COUNT--', $changeCount, LAN_MAILOUT_237); } $this->e107->admin_log->log_event('MAIL_05', implode('[!br!]', $results), E_LOG_INFORMATIVE, ''); return $noError; } - - /** * Get a list of all the available email templates, by name and variable name * * @param string $sel - currently (all|system|user) - selects template type * - * @return array - key is the variable name of the template, value is the stored template name + * @return array - key is the variable name of the template, value is the stored + * template name */ public function getEmailTemplateNames($sel = 'all') { $ret = array(); - + $templates = e107::getCoreTemplate('email'); - - foreach($templates as $key=>$layout) + + foreach($templates as $key => $layout) { - if(substr($key,0,5)== 'user-' || $key == 'default') + if(substr($key, 0, 5) == 'user-' || $key == 'default') { - $ret[$key] = $layout['name']; + $ret[$key] = $layout['name']; } - - + } return $ret; /* - - foreach (array(e_CORE.'templates/email_template.php', THEME.'templates/email_template.php') as $templateFileName ) // Override file then defaults - if (is_readable($templateFileName)) - { - require($templateFileName); - $tVars = get_defined_vars(); - if (isset($tVars['GLOBALS'])) unset($tVars['GLOBALS']); - foreach ($tVars as $tKey => $tData) - { - if (is_array($tData) && isset($tData['template_name'])) - { - if (!isset($tData['template_type']) || ($tData['template_type'] == 'all') || ($tData['template_type'] == $sel)) - { - $ret[$tKey] = $tData['template_name']; - } - } - if ($tKey != 'ret') - { - unset($tVars[$tKey]); - } - } - } - - - - - print_a($ret); - return $ret; - + + foreach (array(e_CORE.'templates/email_template.php', + THEME.'templates/email_template.php') as $templateFileName ) // Override file + then defaults + if (is_readable($templateFileName)) + { + require($templateFileName); + $tVars = get_defined_vars(); + if (isset($tVars['GLOBALS'])) unset($tVars['GLOBALS']); + foreach ($tVars as $tKey => $tData) + { + if (is_array($tData) && isset($tData['template_name'])) + { + if (!isset($tData['template_type']) || ($tData['template_type'] == 'all') || + ($tData['template_type'] == $sel)) + { + $ret[$tKey] = $tData['template_name']; + } + } + if ($tKey != 'ret') + { + unset($tVars[$tKey]); + } + } + } + + print_a($ret); + return $ret; + */ } + } - - ?> \ No newline at end of file From 5e867b378e7004f4d858c78363334eec7a176194 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sun, 12 Oct 2014 02:37:43 -0700 Subject: [PATCH 14/46] Corrected Admin->Mail 'Send now' functionality - replacing old prototype.js code. --- e107_admin/mailout.php | 179 +++++++++++++++----------- e107_handlers/form_handler.php | 19 ++- e107_handlers/mail.php | 17 ++- e107_handlers/mail_manager_class.php | 60 ++++++--- e107_handlers/mailout_admin_class.php | 28 ++-- e107_plugins/forum/forum_update.php | 2 +- e107_web/js/core/admin.jquery.js | 10 +- 7 files changed, 199 insertions(+), 116 deletions(-) diff --git a/e107_admin/mailout.php b/e107_admin/mailout.php index 30c6e9cf5..3b0fb8823 100644 --- a/e107_admin/mailout.php +++ b/e107_admin/mailout.php @@ -66,7 +66,7 @@ Valid subparameters (where required): $_GET['m'] - id of mail info in db $_GET['t'] - id of target info in db */ -header('Content-Encoding: none'); // turn off gzip. +// header('Content-Encoding: none'); // turn off gzip. require_once('../class2.php'); if (!getperms('W')) @@ -85,6 +85,73 @@ require_once(e_HANDLER.'mailout_admin_class.php'); // Admin tasks handler require_once(e_HANDLER.'mail_manager_class.php'); // Mail DB API +/** + * Display Progress-bar of real-time mail-out. + * @return + */ +function sendProgress($id) +{ + $pref = e107::getPref(); + + $mailManager = new e107MailManager(); + $mailManager->doEmailTask(varset($pref['mail_workpertick'],5)); + + $sqld = e107::getDb(); + + $sqld->select("mail_content","mail_togo_count,mail_sent_count,mail_fail_count","mail_source_id= ".intval($id) ); + $row = $sqld->fetch(); + + $rand = ($row['mail_sent_count'] + $row['mail_fail_count']); + $total = ($row['mail_togo_count'] + $row['mail_sent_count'] + $row['mail_fail_count']); + + // $rand = rand(90,100); + // return $rand; + + $inc = round(($rand / $total) * 100); + + return $inc; + + +} + +if(e_AJAX_REQUEST) +{ + $id = intval($_GET['mode']); + // echo rand(92,100); + echo sendProgress($id); + exit; + +} + + + +if(vartrue($_GET['mode']) == "progress") +{ +// session_write_close(); +// sendProgress(); +// exit; +} + + +$mes = e107::getMessage(); +$tp = e107::getParser(); +/* +if($_GET['mode']=="process") +{ + session_write_close(); // allow other scripts to run in parallel. + header('Content-Encoding: none'); + ignore_user_abort(true); + set_time_limit(0); + + header("Content-Length: $size"); + header('Connection: close'); + + $mailManager = new e107MailManager(); + $mailManager->doEmailTask(999999); + echo "Completed Mailout ID: ".$_GET['id']; + exit; +} +*/ class mailout_admin extends e_admin_dispatcher @@ -354,10 +421,10 @@ class mailout_main_ui extends e_admin_ui { $ret = $this->processData($new_data); - $ret['mail_create_date'] = time(); - $ret['mail_creator'] = USERID; - $ret['mail_create_app'] = 'core'; - $ret['mail_content_status'] = 22; // Default status is 'Saved'; + $ret['mail_create_date'] = time(); + $ret['mail_creator'] = USERID; + $ret['mail_create_app'] = 'core'; + $ret['mail_content_status'] = MAIL_STATUS_TEMP; return $ret; @@ -409,9 +476,15 @@ class mailout_main_ui extends e_admin_ui } - private function emailSendNow($mailId) + private function emailSendNow($id) { - e107::getMessage()->addInfo("'Send Now' is Under Construction"); + $mes = e107::getMessage(); + $text = e107::getForm()->progressBar('mail-progress',1, array('btn-label'=>'Start', 'url'=> e_SELF)); + + $mes->setTitle('Ready to Process Mail Queue', E_MESSAGE_INFO)->addInfo($text); + return ''; + + //; e107::getRender()->tablerender("Sending...", $mes->render()); } @@ -1174,7 +1247,7 @@ class mailout_recipients_ui extends e_admin_ui 'mail_recipient_id' => array('title' => LAN_MAILOUT_142, 'thclass' => 'center'), 'mail_recipient_name' => array('title' => LAN_MAILOUT_141, 'forced' => TRUE), 'mail_recipient_email' => array('title' => LAN_MAILOUT_140, 'thclass' => 'left', 'forced' => TRUE), - 'mail_status' => array('title' => LAN_MAILOUT_138, 'thclass' => 'left', 'class'=>'left', 'proc' => 'contentstatus'), + 'mail_status' => array('title' => LAN_MAILOUT_138, 'type'=>'method', 'thclass' => 'left', 'class'=>'left', 'proc' => 'contentstatus'), 'mail_detail_id' => array('title' => LAN_MAILOUT_137, 'type'=>'dropdown', 'filter'=>true), 'mail_send_date' => array('title' => LAN_MAILOUT_139, 'proc' => 'sdatetime'), 'mail_target_info' => array('title' => LAN_MAILOUT_148, 'proc' => 'array'), @@ -1184,15 +1257,22 @@ class mailout_recipients_ui extends e_admin_ui protected $fieldpref = array('checkboxes', 'mail_target_id', 'mail_recipient_name', 'mail_recipient_email', 'mail_detail_id', 'mail_status', 'options'); + public $mailManager = null; function init() { + + $this->mailManager = new e107MailManager; + + + $sql = e107::getDb(); $sql->gen("SELECT r.mail_detail_id,c.mail_title FROM #mail_recipients AS r LEFT JOIN #mail_content as c ON r.mail_detail_id = c.mail_source_id GROUP BY r.mail_detail_id"); - + while($row = $sql->fetch()) { - $array[] = $row['mail_title']; + $id = $row['mail_detail_id']; + $array[$id] = varset($row['mail_title'], "(No Name)"); } $this->fields['mail_detail_id']['writeParms'] = $array; @@ -1218,7 +1298,19 @@ class mailout_recipients_ui extends e_admin_ui class mailout_recipients_form_ui extends e_admin_form_ui { - + public function mail_status($curVal,$mode) + { + if($mode == 'read') + { + return $this->getController()->mailManager->statusToText($curVal); + } + + if($mode == 'write') + { + return $curVal; + } + + } } @@ -1241,33 +1333,8 @@ new mailout_admin(); $e_sub_cat = 'mail'; -if(vartrue($_GET['mode']) == "progress") -{ - session_write_close(); - sendProgress(); - exit; -} -$mes = e107::getMessage(); -$tp = e107::getParser(); - -if($_GET['mode']=="process") -{ - session_write_close(); // allow other scripts to run in parallel. - header('Content-Encoding: none'); - ignore_user_abort(true); - set_time_limit(0); - - header("Content-Length: $size"); - header('Connection: close'); - - $mailManager = new e107MailManager(); - $mailManager->doEmailTask(999999); - echo "Completed Mailout ID: ".$_GET['id']; - exit; -} - @@ -1751,6 +1818,7 @@ require_once(e_ADMIN.'footer.php'); * @param integer $id (mailing id) * @return */ + /* function sendImmediately($id) { $mes = e107::getMessage(); @@ -1794,45 +1862,8 @@ function sendImmediately($id) e107::getRender()->tablerender("Sending...", $mes->render()); } +*/ -/** - * Display Progress-bar of real-time mail-out. - * @return - */ -function sendProgress() -{ - $sqld = e107::getDb(); - - $sqld->db_Select("mail_content","mail_togo_count,mail_sent_count,mail_fail_count","mail_source_id= ".intval($_GET['id']) ); - $row = $sqld -> db_Fetch(); - - $rand = $row['mail_sent_count'] + $row['mail_fail_count']; - - $total = $row['mail_togo_count'] + $row['mail_sent_count'] + $row['mail_fail_count']; - - // $rand = rand(1,20); - //$total = 20; - - $inc = round(($rand / $total) * 100); - - if($rand >= $total && $total !=0) - { - echo ""; - echo "
- Complete
"; - echo "
".$rand." / ".$total."
"; - return; - } - - echo "
"; - for($j=1;$j<=$inc;$j++) - { - echo ""; - } - echo " $inc %
"; - echo "
".$rand." / ".$total."
"; - return; -} diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index 68d076420..802eb13f4 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -1104,11 +1104,24 @@ class e_form } $class = vartrue($options['class'],''); + $target = $this->name2id($name); - return "
-
+ $striped = (vartrue($options['btn-label'])) ? ' progress-striped active' : ''; + + $text = "
+
"; - + + $loading = vartrue($options['loading'],'Please wait...'); + + if(vartrue($options['btn-label'])) + { + $text .= ''.$options['btn-label'].''; + } + + + return $text; + } diff --git a/e107_handlers/mail.php b/e107_handlers/mail.php index 4e76e6900..1f6252126 100644 --- a/e107_handlers/mail.php +++ b/e107_handlers/mail.php @@ -138,7 +138,7 @@ define('MAIL_LOG_PATH',e_LOG); class e107Email extends PHPMailer { private $general_opts = array(); - private $logEnable = 0; // 0 = log disabled, 1 = 'dry run' (debug and log, no send). 2 = 'log all' (send, and log result) + private $logEnable = 1; // 0 = log disabled, 1 = 'dry run' (debug and log, no send). 2 = 'log all' (send, and log result) private $logHandle = FALSE; // Save handle of log file if opened private $localUseVerp = FALSE; // Use our own variable - PHPMailer one doesn't work with all mailers @@ -601,8 +601,6 @@ class e107Email extends PHPMailer */ public function arraySet($eml) { - - $tp = e107::getParser(); if(vartrue($eml['template'])) // @see e107_core/templates/email_template.php @@ -637,6 +635,8 @@ class e107Email extends PHPMailer { echo "

Couldn't find email template: ".$eml['template']."

"; } + $emailBody = $eml['email_body']; + if (vartrue($eml['email_subject'])) $this->Subject = $tp->parseTemplate($eml['email_subject'], true, varset($eml['shortcodes'],null)); e107::getMessage()->addDebug("Couldn't find email template: ".$eml['template']); } @@ -645,6 +645,7 @@ class e107Email extends PHPMailer else { if (vartrue($eml['email_subject'])) $this->Subject = $tp->parseTemplate($eml['email_subject'], true, varset($eml['shortcodes'],null)); + // $eml['email_body'] = ($tp->toEmail($tmpl['header']). str_replace('{BODY}', $eml['email_body'], $tmpl['body']). $tp->toEmail($tmpl['footer'])); } @@ -695,6 +696,8 @@ class e107Email extends PHPMailer if (varset($eml['wordwrap'])) $this->WordWrap = $eml['wordwrap']; if (vartrue($eml['split'])) $this->SingleTo = ($eml['split'] != FALSE); + $this->logLine("ArraySet Data:".print_r($eml,true)); + return 0; // No error } @@ -741,7 +744,7 @@ class e107Email extends PHPMailer { if (count($eml)) { // Set parameters from list - $ret = $this->arraySet($eml); + $ret = $this->arraySet($eml); // returns error on fail and nothing if all is okay. if ($ret) return $ret; } @@ -785,6 +788,12 @@ class e107Email extends PHPMailer $this->logLine("Send to {$to_name} at {$send_to} Mail-ID={$this->MessageID} - ".($result ? 'Success' : 'Fail')); + if(!$result) + { + $this->logLine(print_r($eml,true)); + } + + $this->ClearAddresses(); // In case we send another email $this->ClearCustomHeaders(); diff --git a/e107_handlers/mail_manager_class.php b/e107_handlers/mail_manager_class.php index b10a3fbe1..dc9f2c6d0 100644 --- a/e107_handlers/mail_manager_class.php +++ b/e107_handlers/mail_manager_class.php @@ -422,10 +422,9 @@ class e107MailManager } // Now array fields - $array = new ArrayData; if (isset($data['mail_other'])) { - $tmp = $array->ReadArray(str_replace('\\\'', '\'',$data['mail_other'])); // May have escaped data + $tmp = e107::unserialize(str_replace('\\\'', '\'',$data['mail_other'])); // May have escaped data if (is_array($tmp)) { $res = array_merge($res,$tmp); @@ -441,7 +440,7 @@ class e107MailManager } if (isset($data['mail_target_info'])) { - $tmp = $array->ReadArray(str_replace('\\\'', '\'',$data['mail_target_info'])); // May have escaped data + $tmp = e107::unserialize(str_replace('\\\'', '\'',$data['mail_target_info'])); // May have escaped data $res['mail_target_info'] = $tmp; } return $res; @@ -853,6 +852,9 @@ class e107MailManager } } if (isset($email['mail_overrides']) && is_array($email['mail_overrides'])) $result = array_merge($result, $email['mail_overrides']); + + e107::getAdminLog()->addDebug(print_a($email,true),false); + return $result; } @@ -878,6 +880,10 @@ class e107MailManager $this->mailer->allSent(); // Tidy up on completion } } + else + { + e107::getAdminLog()->addDebug("Couldn't select emails", false); + } } @@ -902,8 +908,7 @@ class e107MailManager { unset($dbData['mail_source_id']); // Just in case - there are circumstances where might be set $result = $this->db2->db_Insert('mail_content', array('data' => $dbData, - '_FIELD_TYPES' => $this->dbTypes['mail_content'], - '_NOTNULL' => $this->dbNull['mail_content'])); + '_FIELD_TYPES' => $this->dbTypes['mail_content'], '_NOTNULL' => $this->dbNull['mail_content'])); } else { @@ -1483,30 +1488,47 @@ class e107MailManager public function sendEmails($templateName, $emailData, $recipientData, $extra = FALSE) { - if (!is_array($emailData)) return FALSE; + $log = e107::getAdminLog(); + $log->addDebug(print_a($emailData, true),false); + $log->addDebug(print_a($recipientData, true),false); + $log->toFile('mail_manager','Main Manager Log',true); + + + if (!is_array($emailData)) + { + return FALSE; + } + if (!is_array($recipientData)) { $recipientData = array('mail_recipient_email' => $recipientData, 'mail_recipient_name' => $recipientData); } + $emailData['mail_content_status'] = MAIL_STATUS_TEMP; if ($templateName == '') { - $templateName = varset($email['mail_send_style'], 'textonly'); // Safest default if nothing specified + $templateName = varset($emailData['mail_send_style'], 'textonly'); // Safest default if nothing specified } + + $templateName = trim($templateName); if ($templateName == '') return FALSE; - + // Get template data, override email settings as appropriate - require_once(e_HANDLER.'mail_template_class.php'); - $ourTemplate = new e107MailTemplate(); - if (!$ourTemplate->setNewTemplate($templateName) && empty($emailData['template'])) return FALSE; // Probably template not found if error - if (!$ourTemplate->makeEmailBody($emailData['mail_body'], varset($emailData['mail_include_images'], TRUE))) return FALSE; // Create body text - $emailData['mail_body_templated'] = $ourTemplate->mainBodyText; - $this->currentMailBody = $emailData['mail_body_templated']; // In case we send immediately - $emailData['mail_body_alt'] = $ourTemplate->altBodyText; - $this->currentTextBody = $emailData['mail_body_alt']; + // require_once(e_HANDLER.'mail_template_class.php'); + // $ourTemplate = new e107MailTemplate(); + // if (!$ourTemplate->setNewTemplate($templateName) && empty($emailData['template'])) return FALSE; // Probably template not found if error + // if (!$ourTemplate->makeEmailBody($emailData['mail_body'], varset($emailData['mail_include_images'], TRUE))) return FALSE; // Create body text + + + +// $emailData['mail_body_templated'] = $ourTemplate->mainBodyText; + $this->currentMailBody = $emailData['mail_body']; // In case we send immediately +// $emailData['mail_body_alt'] = $ourTemplate->altBodyText; + $this->currentTextBody = strip_tags($emailData['mail_body']); + if (!isset($emailData['mail_overrides'])) { $emailData['mail_overrides'] = $ourTemplate->lastTemplateData['email_overrides']; @@ -1522,9 +1544,13 @@ class e107MailManager echo "

".$emailData['template']." Template detected

"; } } + + + - $forceQueue = FALSE; + + if (is_array($extra) && isset($extra['mail_force_queue'])) { $forceQueue = $extra['mail_force_queue']; diff --git a/e107_handlers/mailout_admin_class.php b/e107_handlers/mailout_admin_class.php index 4d26f9585..6edccb8e5 100644 --- a/e107_handlers/mailout_admin_class.php +++ b/e107_handlers/mailout_admin_class.php @@ -1470,6 +1470,7 @@ class mailoutAdminClass extends e107MailManager else { // Start by saving the email + /* $mailData['mail_content_status'] = MAIL_STATUS_TEMP; $mailData['mail_create_app'] = 'core'; $result = $this->saveEmail($mailData, TRUE); @@ -1482,11 +1483,11 @@ class mailoutAdminClass extends e107MailManager { e107::getMessage()->addDebug("Couldn't save email. (".__FILE__." Line: ".__LINE__.")"); } + */ - + $mailMainID = $mailData['mail_source_id']; - $this->mailInitCounters($mailMainID); - // Initialise counters for emails added + $this->mailInitCounters($mailMainID); // Initialise counters for emails added foreach($this->mailHandlers as $key => $m) { @@ -1494,16 +1495,15 @@ class mailoutAdminClass extends e107MailManager // all can use the $sql data object if($m->mailerEnabled && isset($mailData['mail_selectors'][$key])) { - // Initialise - $mailerCount = $m->selectInit($mailData['mail_selectors'][$key]); + + $mailerCount = $m->selectInit($mailData['mail_selectors'][$key]); // Initialise if($mailerCount > 0) { - // Get email addresses - add to list, strip duplicates - while($row = $m->selectAdd()) - { - // Add email addresses to the database ready for sending (the body is never saved - // in the DB - it gets passed as a $_POST value) - $result = $this->mailAddNoDup($mailMainID, $row, MAIL_STATUS_TEMP); + + while($row = $m->selectAdd()) // Get email addresses - add to list, strip duplicates + { + $result = $this->mailAddNoDup($mailMainID, $row, MAIL_STATUS_TEMP); // Add email addresses to the database ready for sending (the body is never saved // in the DB - it gets passed as a $_POST value) + if($result === FALSE) { // Error @@ -1660,6 +1660,7 @@ class mailoutAdminClass extends e107MailManager return e107::getForm()->datepicker($calName, $calVal, $options); } + /** * Show recipients of an email * @@ -1667,6 +1668,7 @@ class mailoutAdminClass extends e107MailManager * @param $nextPage - 'mode' specification for page to return to following delete * @return text for display */ + /* public function showmailRecipients($mailID, $nextPage = 'saved') { $gen = new convert; @@ -1804,7 +1806,9 @@ class mailoutAdminClass extends e107MailManager $ns->tablerender(ADLAN_136 . SEP . LAN_MAILOUT_181, $mes->render() . $text); } - + */ + + /** * Clean up mailout DB * Dump array of results to admin log diff --git a/e107_plugins/forum/forum_update.php b/e107_plugins/forum/forum_update.php index 849ca103e..db6d8b1be 100644 --- a/e107_plugins/forum/forum_update.php +++ b/e107_plugins/forum/forum_update.php @@ -547,7 +547,7 @@ function renderProgress($caption, $step)
- '.$caption.' + '.$caption.' '; diff --git a/e107_web/js/core/admin.jquery.js b/e107_web/js/core/admin.jquery.js index 947a819fa..6b24ca0aa 100644 --- a/e107_web/js/core/admin.jquery.js +++ b/e107_web/js/core/admin.jquery.js @@ -205,12 +205,12 @@ $(document).ready(function() - + $('.e-progress').on('click', function(e) { // alert('Process Started'); - - var target = 'progress'; + + var target = $(this).attr('data-progress-target'); var script = $(this).attr('data-progress'); var show = $(this).attr('data-progress-show'); var hide = $(this).attr('data-progress-hide'); @@ -235,8 +235,8 @@ $(document).ready(function() if(data > 99.999) { clearInterval(progresspump); - - $("#progressouter").removeClass("active"); + $("#"+target).closest('.progress').removeClass("active"); + $("#"+target).html("Done"); if(hide !== 'undefined') From 01f0751c04a434dd86b0b061d27790d1c0e1e8d5 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sun, 12 Oct 2014 18:01:19 -0700 Subject: [PATCH 15/46] Mail and progressBar fixes. --- e107_admin/mailout.php | 96 +++++++++++++++++++-------- e107_core/sql/core_sql.php | 1 + e107_handlers/form_handler.php | 7 +- e107_handlers/mail.php | 23 +++++-- e107_handlers/mail_manager_class.php | 41 ++++++++++-- e107_handlers/mailout_admin_class.php | 25 +++++-- e107_plugins/newsletter/e_mailout.php | 7 +- e107_web/js/core/admin.jquery.js | 69 +++++++++++-------- 8 files changed, 190 insertions(+), 79 deletions(-) diff --git a/e107_admin/mailout.php b/e107_admin/mailout.php index 3b0fb8823..3b30859d6 100644 --- a/e107_admin/mailout.php +++ b/e107_admin/mailout.php @@ -91,11 +91,16 @@ require_once(e_HANDLER.'mail_manager_class.php'); // Mail DB API */ function sendProgress($id) { + +// return rand(92,100); + $pref = e107::getPref(); + ob_start(); + $mailManager = new e107MailManager(); $mailManager->doEmailTask(varset($pref['mail_workpertick'],5)); - + $sqld = e107::getDb(); $sqld->select("mail_content","mail_togo_count,mail_sent_count,mail_fail_count","mail_source_id= ".intval($id) ); @@ -104,10 +109,14 @@ function sendProgress($id) $rand = ($row['mail_sent_count'] + $row['mail_fail_count']); $total = ($row['mail_togo_count'] + $row['mail_sent_count'] + $row['mail_fail_count']); - // $rand = rand(90,100); - // return $rand; + $errors = ob_get_clean(); + + e107::getMessage()->addDebug($errors); +// file_put_contents(e_LOG.'send-mail-progress.txt',$errors); + $inc = round(($rand / $total) * 100); + e107::getMessage()->addDebug("Returned: ".$inc); return $inc; @@ -117,7 +126,6 @@ function sendProgress($id) if(e_AJAX_REQUEST) { $id = intval($_GET['mode']); - // echo rand(92,100); echo sendProgress($id); exit; @@ -212,12 +220,12 @@ class mailout_admin extends e_admin_dispatcher protected $adminMenu = array( // 'makemail/makemail' => array('caption'=> LAN_MAILOUT_190, 'perm' => 'W', 'url'=>e_SELF), 'main/list' => array('caption'=> LAN_MANAGE, 'perm'=> 'W'), - 'main/create' => array('caption'=> LAN_MAILOUT_190, 'perm' => 'W'), + 'main/create' => array('caption'=> LAN_CREATE, 'perm' => 'W'), 'recipients/list' => array('caption'=> "Recipients", 'perm' => 'W'), // 'main/send' => array('caption'=> "Send", 'perm' => 'W'), 'other' => array('divider'=> true), - 'saved/list' => array('caption'=> LAN_MAILOUT_191, 'perm' => 'W'), + // 'saved/list' => array('caption'=> LAN_MAILOUT_191, 'perm' => 'W'), 'pending/list' => array('caption'=> LAN_MAILOUT_193, 'perm' => 'W'), 'held/list' => array('caption'=> LAN_MAILOUT_194, 'perm' => 'W'), 'sent/list' => array('caption'=> LAN_MAILOUT_192, 'perm' => 'W'), @@ -244,7 +252,7 @@ class mailout_main_ui extends e_admin_ui protected $pluginName = LAN_MAILOUT_15; protected $table = "mail_content"; - // protected $listQry = "SELECT * FROM #mail_content WHERE mail_content_status = 20 "; + // protected $listQry = null; // protected $editQry = "SELECT * FROM #mail_content WHERE cust_id = {ID}"; @@ -269,9 +277,11 @@ class mailout_main_ui extends e_admin_ui 'mail_copy_to' => array('title' => LAN_MAILOUT_151,'tab'=>1, 'type'=>'method','data'=>false), 'mail_bcopy_to' => array('title' => LAN_MAILOUT_152,'tab'=>1, 'type'=>'method','data'=>false), 'mail_subject' => array('title' => LAN_MAILOUT_06, 'type'=>'text', 'forced' => TRUE,'data'=>'str', 'inline'=>true, 'writeParms'=>'size=xxlarge&required=1'), - 'mail_content_status' => array('title' => LAN_MAILOUT_136, 'tab'=>1, 'type'=> 'dropdown', 'data'=>'int', 'filter'=>false, 'inline'=>true, 'thclass' => 'left', 'class'=>'left'), - 'mail_togo_count' => array('title' => LAN_MAILOUT_83, 'noedit'=>true, 'type'=>'number'), + 'mail_content_status' => array('title' => LAN_MAILOUT_136, 'tab'=>1, 'type'=> 'dropdown', 'data'=>'int', 'filter'=>false, 'inline'=>false, 'thclass' => 'left', 'class'=>'left'), + 'mail_total_count' => array('title' => "Total Recipients", 'noedit'=>true, 'type'=>'number'), 'mail_sent_count' => array('title' => LAN_MAILOUT_82, 'noedit'=>true, 'type'=>'number'), + 'mail_togo_count' => array('title' => LAN_MAILOUT_83, 'noedit'=>true, 'type'=>'number'), + 'mail_fail_count' => array('title' => LAN_MAILOUT_128, 'noedit'=>true, 'type'=>'number'), 'mail_bounce_count' => array('title' => LAN_MAILOUT_144, 'noedit'=>true, 'type'=>'number'), 'mail_start_send' => array('title' => LAN_MAILOUT_131,'noedit'=>true, 'type'=>'number', 'proc' => 'sdatetime'), @@ -369,9 +379,15 @@ class mailout_main_ui extends e_admin_ui { $this->listQry = "SELECT * FROM #mail_content WHERE mail_content_status = ".varset($qr[$action],20); } - else + else { - // $this->fields['options']['type'] = ''; + $this->listQry = "SELECT * FROM #mail_content WHERE (mail_content_status = ".MAIL_STATUS_TEMP ." OR mail_content_status = ".MAIL_STATUS_SAVED.")"; + } + + + if($action == 'sent' || $action == 'pending' || $action == 'held') + { + $this->fieldpref = array('checkboxes', 'mail_source_id', 'mail_title', 'mail_subject','mail_total_count', 'mail_togo_count', 'mail_sent_count', 'mail_fail_count', 'mail_bounce_count', 'options'); } $this->fields['mail_content_status']['writeParms'] = $types; @@ -445,19 +461,14 @@ class mailout_main_ui extends e_admin_ui private function processSendActions() { - if((vartrue($_POST['email_sendnow']) || vartrue($_POST['email_send']) || vartrue($_POST['email_hold']) || vartrue($_POST['email_cancel'])) && !vartrue($_POST['email_id'])) + if((vartrue($_POST['email_send']) || vartrue($_POST['email_hold']) || vartrue($_POST['email_cancel'])) && !vartrue($_POST['email_id'])) { e107::getMessage()->addError("No Message ID submitted"); return; } $id = intval($_POST['email_id']); - - if(vartrue($_POST['email_sendnow'])) - { - $this->emailSendNow($id); - } - + if(vartrue($_POST['email_send'])) { $this->emailSend($id); @@ -478,13 +489,7 @@ class mailout_main_ui extends e_admin_ui private function emailSendNow($id) { - $mes = e107::getMessage(); - $text = e107::getForm()->progressBar('mail-progress',1, array('btn-label'=>'Start', 'url'=> e_SELF)); - - $mes->setTitle('Ready to Process Mail Queue', E_MESSAGE_INFO)->addInfo($text); - return ''; - - //; e107::getRender()->tablerender("Sending...", $mes->render()); + } @@ -601,7 +606,29 @@ class mailout_main_ui extends e_admin_ui } */ + + function sendnowPage() + { + $id = $this->getId(); + e107::getDb()->update('mail_content', 'mail_content_status='.MAIL_STATUS_PENDING.' WHERE mail_source_id = '.intval($id)); + e107::getDb()->update('mail_recipients', 'mail_status='.MAIL_STATUS_PENDING.' WHERE mail_detail_id = '.intval($id)); + + if(E107_DEBUG_LEVEL > 0) + { + echo "

Debug Mode : Mail is sent and data displayed below.

"; + sendProgress($id); + } + else + { + $text = "

Ready to Process Mail Queue

"; + $text .= e107::getForm()->progressBar('mail-progress',1, array('btn-label'=>'Start', 'url'=> e_SELF)); + } + + return $text; + } + + function sendPage() { @@ -618,6 +645,10 @@ class mailout_main_ui extends e_admin_ui $fromHold = false; $mailData = $this->mailAdmin->dbToMail($mailData); + + e107::getMessage()->addDebug("Regenerating recipient list"); + + e107::getDb()->delete('mail_recipients','mail_detail_id='.intval($id)); return $this->mailAdmin->sendEmailCircular($mailData, $fromHold); @@ -1206,6 +1237,15 @@ class mailout_admin_form_ui extends e_admin_form_ui return $text; } + + if($mode == 'sent' || $mode == 'pending' || $mode == 'held') + { + $link = e_SELF."?searchquery=&filter_options=mail_detail_id__".$id."&mode=recipients&action=list"; + $text .= "".E_32_USER.""; + $att['readParms']['editClass'] = e_UC_NOBODY; + $text .= $this->renderValue('options',$value,$att,$id); + return $text; + } $mode = $controller->getMode(); $mailData = $controller->getListModel()->getData(); @@ -1272,7 +1312,7 @@ class mailout_recipients_ui extends e_admin_ui while($row = $sql->fetch()) { $id = $row['mail_detail_id']; - $array[$id] = varset($row['mail_title'], "(No Name)"); + $array[$id] = vartrue($row['mail_title'], "(No Name)"); } $this->fields['mail_detail_id']['writeParms'] = $array; @@ -1729,7 +1769,7 @@ switch ($midAction) if(isset($_POST['email_sendnow'])) { - sendImmediately($mailId); +// sendImmediately($mailId); } // --------------------- Display errors and results ------------------------ @@ -1805,7 +1845,7 @@ switch ($action) { $mailData = array(); // Empty array just in case } - $mailAdmin->show_mailform($mailData); + // $mailAdmin->show_mailform($mailData); break; } diff --git a/e107_core/sql/core_sql.php b/e107_core/sql/core_sql.php index b48f4aec3..f185b9b52 100644 --- a/e107_core/sql/core_sql.php +++ b/e107_core/sql/core_sql.php @@ -255,6 +255,7 @@ CREATE TABLE mail_recipients ( CREATE TABLE mail_content ( mail_source_id int(10) unsigned NOT NULL auto_increment, mail_content_status tinyint(1) unsigned NOT NULL default '0', + mail_total_count int(10) unsigned NOT NULL default '0', mail_togo_count int(10) unsigned NOT NULL default '0', mail_sent_count int(10) unsigned NOT NULL default '0', mail_fail_count int(10) unsigned NOT NULL default '0', diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index 802eb13f4..9f1002ca2 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -1095,6 +1095,7 @@ class e_form * @param string $name * @param number $value * @param array $options + * @example Use */ public function progressBar($name,$value,$options=array()) { @@ -1114,9 +1115,13 @@ class e_form $loading = vartrue($options['loading'],'Please wait...'); + $buttonId = $target.'-start'; + if(vartrue($options['btn-label'])) { - $text .= ''.$options['btn-label'].''; + $text .= ''.$options['btn-label'].''; + $text .= ' '.LAN_CANCEL.''; + } diff --git a/e107_handlers/mail.php b/e107_handlers/mail.php index 1f6252126..77c3ebef5 100644 --- a/e107_handlers/mail.php +++ b/e107_handlers/mail.php @@ -138,7 +138,7 @@ define('MAIL_LOG_PATH',e_LOG); class e107Email extends PHPMailer { private $general_opts = array(); - private $logEnable = 1; // 0 = log disabled, 1 = 'dry run' (debug and log, no send). 2 = 'log all' (send, and log result) + private $logEnable = 2; // 0 = log disabled, 1 = 'dry run' (debug and log, no send). 2 = 'log all' (send, and log result) private $logHandle = FALSE; // Save handle of log file if opened private $localUseVerp = FALSE; // Use our own variable - PHPMailer one doesn't work with all mailers @@ -154,7 +154,7 @@ class e107Email extends PHPMailer private $pause_time = 1; // Time to pause after sending a block of emails public $legacyBody = false; // TRUE enables legacy conversion of plain text body to HTML in HTML emails - private $debug = false; // echos various debug info when set to true. + private $debug = true; // echos various debug info when set to true. private $pref = array(); // Store code prefs. /** @@ -196,7 +196,12 @@ class e107Email extends PHPMailer $this->allow_html = varset($pref['mail_sendstyle'],'textonly') == 'texthtml' ? true : 1; if (varsettrue($pref['mail_options'])) $this->general_opts = explode(',',$pref['mail_options'],''); - if ($this->debug) echo 'Mail_options: '.$pref['mail_options'].' Count: '.count($this->general_opts).'
'; + + if ($this->debug) + { + echo 'Mail_options: '.$pref['mail_options'].' Count: '.count($this->general_opts).'
'; + } + foreach ($this->general_opts as $k => $v) { $v = trim($v); @@ -609,7 +614,7 @@ class e107Email extends PHPMailer if($tmpl = e107::getCoreTemplate('email', $eml['template'], 'front', true)) //FIXME - Core template is failing with template 'notify'. Works with theme template. Issue with core template registry? { - $eml['shortcodes']['BODY'] = $eml['email_body']; + $eml['shortcodes']['BODY'] = $tp->toEmail($eml['email_body']); $eml['shortcodes']['SUBJECT'] = $eml['email_subject']; $eml['shortcodes']['THEME'] = e_THEME.$this->pref['sitetheme'].'/'; // Always use front-end theme path. @@ -732,6 +737,7 @@ class e107Email extends PHPMailer $eml['wordwrap'] - Set wordwrap value $eml['split'] - If true, sends an individual email to each recipient $eml['template'] - template to use. 'default' + $eml['shortcodes'] - array of shortcode values. eg. array('MY_SHORTCODE'=>'12345'); * @param string $send_to - recipient email address * @param string $to_name - recipient name @@ -743,9 +749,12 @@ class e107Email extends PHPMailer public function sendEmail($send_to, $to_name, $eml = '', $bulkmail = FALSE) { if (count($eml)) - { // Set parameters from list - $ret = $this->arraySet($eml); // returns error on fail and nothing if all is okay. - if ($ret) return $ret; + { + if($error = $this->arraySet($eml)) // Set parameters from list + { + return $error; + } + } if ($bulkmail && $this->localUseVerp && $this->save_bouncepath && (strpos($this->save_bouncepath,'@') !== FALSE)) diff --git a/e107_handlers/mail_manager_class.php b/e107_handlers/mail_manager_class.php index dc9f2c6d0..3a5ba7ce6 100644 --- a/e107_handlers/mail_manager_class.php +++ b/e107_handlers/mail_manager_class.php @@ -797,8 +797,8 @@ class e107MailManager //'extra_header' - additional headers (format is name: value //'wordwrap' - Set wordwrap value //'split' - If true, sends an individual email to each recipient - 'template' => 'template', // required - 'shortcodes' => 'shortcodes' // required + 'template' => 'mail_send_style', // required + 'shortcodes' => 'mail_target_info' // required ); $result = array(); if (!isset($email['mail_source_id'])) $email['mail_source_id'] = 0; @@ -853,8 +853,14 @@ class e107MailManager } if (isset($email['mail_overrides']) && is_array($email['mail_overrides'])) $result = array_merge($result, $email['mail_overrides']); - e107::getAdminLog()->addDebug(print_a($email,true),false); + e107::getAdminLog()->addDebug(print_a($email,true),true); + print_a($email); + + // $result['template'] = $email['mail_send_style']; + + echo "

".__METHOD__." Line: ".__LINE__."

"; + print_a($result); return $result; } @@ -882,7 +888,7 @@ class e107MailManager } else { - e107::getAdminLog()->addDebug("Couldn't select emails", false); + e107::getAdminLog()->addDebug("Couldn't select emails", true); } } @@ -1046,6 +1052,11 @@ class e107MailManager if (($handle <= 0) || !is_numeric($handle)) return FALSE; if (!isset($this->mailCounters[$handle])) return 'nocounter'; $this->checkDB(2); // Make sure DB object created + + + + + $query = '`mail_togo_count`='.intval($this->mailCounters[$handle]['add']).' WHERE `mail_source_id`='.$handle; if ($this->db2->db_Update('mail_content', $query)) { @@ -1055,6 +1066,22 @@ class e107MailManager } + public function updateCounter($id, $type, $count) + { + if(empty($id) || empty($type)) + { + return false; + } + + $update = array( + 'mail_'.$type.'_count' => intval($count), + 'WHERE' => "mail_source_id=".intval($id) + ); + + return e107::getDb('mail')->update('mail_content', $update) ? $count : false; + } + + /** * Retrieve the counters for a mail record @@ -1489,8 +1516,8 @@ class e107MailManager public function sendEmails($templateName, $emailData, $recipientData, $extra = FALSE) { $log = e107::getAdminLog(); - $log->addDebug(print_a($emailData, true),false); - $log->addDebug(print_a($recipientData, true),false); + $log->addDebug(print_a($emailData, true),true); + $log->addDebug(print_a($recipientData, true),true); $log->toFile('mail_manager','Main Manager Log',true); @@ -1559,6 +1586,8 @@ class e107MailManager if($this->debugMode) { + + echo "

".__CLASS__." :: ".__METHOD__." - Line ".__LINE__."

"; print_a($emailData); print_a($recipientData); diff --git a/e107_handlers/mailout_admin_class.php b/e107_handlers/mailout_admin_class.php index 6edccb8e5..6ae199246 100644 --- a/e107_handlers/mailout_admin_class.php +++ b/e107_handlers/mailout_admin_class.php @@ -886,6 +886,13 @@ class mailoutAdminClass extends e107MailManager { $text .= '' . $this->fields['mail_content'][$k]['title'] . ''; $val = $mailSource[$k]; + + if($k == 'mail_body') + { + $text .= $tp->toHtml($val,true); + continue; + } + if(is_numeric($v)) { $text .= ($v > 1)? $tp->text_truncate($val, $v, '...'): $val; @@ -901,6 +908,7 @@ class mailoutAdminClass extends e107MailManager $text .= $gen->convert_date($val, 'short'); break; case 'trunc200': + $text .= e107::getParser()->text_truncate($val, 200, '...'); break; case 'chars': @@ -1541,33 +1549,40 @@ class mailoutAdminClass extends e107MailManager $text .= $this->showMailDetail($mailData, 'send'); + $text .= '' . LAN_MAILOUT_03 . ''; // TO + // Add in core and any plugin selectors here foreach($this->mailHandlers as $key => $m) { if($m->mailerEnabled && ($contentArray = $m->showSelect(FALSE, $mailData['mail_selectors'][$key]))) { - $text .= '' . LAN_MAILOUT_180 . '
' . $m->mailerName . ''; - $text .= '
    '; + + $text .= $m->mailerName.':
      '; foreach($contentArray as $val) { $text .= "
    • " . $val['caption'] . " : " . $val['html'] . "
    • "; } - $text .= '
    '; + $text .= '
'; } } + $text .= ''; + // Figures - number of emails to send, number of duplicates stripped $text .= '' . LAN_MAILOUT_173 . '' . ($mailData['mail_togo_count']) . ""; $text .= '' . LAN_MAILOUT_71 . ' ' . $counters['add'] . ' ' . LAN_MAILOUT_69 . $counters['dups'] . LAN_MAILOUT_70 . ''; $text .= "\n"; + $this->updateCounter($mailMainID,'total',$counters['add']); + $text .= $this->makeAdvancedOptions(TRUE); // Show the table of advanced options $text .= "
"; - - $text .= $frm->admin_button('email_sendnow', "Send Now", 'primary'); + $text .= "Send Now"; + + // $text .= $frm->admin_button('email_sendnow', "Send Now", 'primary'); $text .= $frm->admin_button('email_send', "Send Later"); // $text .= ""; diff --git a/e107_plugins/newsletter/e_mailout.php b/e107_plugins/newsletter/e_mailout.php index 5c9abf73a..8b39391de 100644 --- a/e107_plugins/newsletter/e_mailout.php +++ b/e107_plugins/newsletter/e_mailout.php @@ -197,7 +197,7 @@ class newsletter_mailout $selects = array_flip(explode(',', $selectVals)); - if ($sql->db_Select('newsletter', 'newsletter_id, newsletter_title', '`newsletter_parent`=0')) + if ($sql->select('newsletter', 'newsletter_id, newsletter_title', '`newsletter_parent`=0')) { $c=0; while ($row = $sql->db_Fetch(MYSQL_ASSOC)) @@ -219,8 +219,9 @@ class newsletter_mailout } else { - $var[$c]['caption'] = NLLAN_50; - $var[$c]['html'] = ''; + return false; // Return Nothing to avoid confusion. + // $var[$c]['caption'] = NLLAN_50; + // $var[$c]['html'] = ''; } return $var; diff --git a/e107_web/js/core/admin.jquery.js b/e107_web/js/core/admin.jquery.js index 6b24ca0aa..19e034175 100644 --- a/e107_web/js/core/admin.jquery.js +++ b/e107_web/js/core/admin.jquery.js @@ -5,31 +5,32 @@ $(document).ready(function() var hash = event.target.href.toString().split('#')[1], form = $(event.target).parents('form')[0]; window.location.hash = '/' + hash; if(form) { - $(form).attr('action', $(form).attr('action').split('#')[0] + '#/' + hash); + $(form).attr('action', $(form).attr('action').split('#')[0] + '#/' + hash); } }); // tabs hash if(/^#\/\w+/.test(window.location.hash)) { var hash = window.location.hash.substr(2); - if(hash.match('^tab')) $('.nav-tabs a[href=#' + hash + ']').tab('show'); + if(hash.match('^tab')){ $('.nav-tabs a[href=#' + hash + ']').tab('show'); } } - $('.e-typeahead').each(function() { - + $('.e-typeahead').each( function(){ + var id = $(this).attr("id"); var name = '#' + id.replace('-usersearch', ''); var newval = $(this).attr("data-value"); - $(this).typeahead({ - source: $(this).attr("data-source"), - updater: function(text, type){ - if(type == 'value') - { - $(name).val(text); - } - return text; - } - }) + + $(this).typeahead({ + source: $(this).attr("data-source"), + updater: function(text, type){ + if(type === 'value') + { + $(name).val(text); + } + return text; + } + }); }); /* Switch to Tab containing invalid form field. */ @@ -48,8 +49,8 @@ $(document).ready(function() found = true; //alert(node.id+' : '+tab); } - // var label = $('label[for=' + node.id + ']'); - }) + // var label = $('label[for=' + node.id + ']'); + }); return true; }); @@ -124,7 +125,8 @@ $(document).ready(function() $('button[data-loading-text],a[data-loading-text]').on('click', function() { var caption = $(this).attr('data-loading-text'); - $(this).removeClass('btn-success'); + $(this).removeClass('btn-success'); + $(this).removeClass('btn-primary'); $(this).html(caption); if($(this).attr('data-disable') == 'true') { @@ -139,6 +141,7 @@ $(document).ready(function() var caption = $(this).attr('data-loading-text'); $(this).val(caption); $(this).removeClass('btn-success'); + $(this).removeClass('btn-primary'); //$(this).attr('disabled', 'disabled').val(caption); return true; } @@ -203,8 +206,16 @@ $(document).ready(function() + var progresspump = null; - + $('.e-progress-cancel').on('click', function(e) + { + clearInterval(progresspump); + var target = $(this).attr('data-progress-target'); + $("#"+target).closest('.progress').removeClass("active"); + progresspump = null; + alert('stopped'); + }); $('.e-progress').on('click', function(e) { @@ -224,33 +235,33 @@ $(document).ready(function() $("#"+target).css('width','1%'); // so we know it's running. - var progresspump = setInterval(function(){ - + progresspump = setInterval(function(){ + $.get(script, { mode: mode }).done( function(data){ - // alert(data); - $("#"+target).css('width',data+'%'); // update the progress bar width */ - $("#"+target).html(data+'%'); // display the numeric value */ + // alert(data); + $("#"+target).css('width', data+'%'); // update the progress bar width */ + $("#"+target).html(data+'%'); // display the numeric value */ if(data > 99.999) { - - clearInterval(progresspump); + + clearInterval(progresspump); $("#"+target).closest('.progress').removeClass("active"); $("#"+target).html("Done"); if(hide !== 'undefined') { - $('#'+hide).hide(); + $('#'+hide).hide(); } if(show !== 'undefined') { - $('#'+show).show('slow'); + $('#'+show).show('slow'); } - } + } }); @@ -695,7 +706,7 @@ $(document).ready(function() // Text-area AutoGrow // $("textarea.e-autoheight").elastic(); -}) +}); From f644b7b8a3caaad96c7e7c7a7fd575316ded4f4c Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 14 Oct 2014 02:09:53 -0700 Subject: [PATCH 16/46] Fixes #544 - Extended user fields not visible. --- .../shortcodes/batch/user_shortcodes.php | 68 +++++++++++++++++-- e107_core/templates/user_template.php | 40 +++++++++-- e107_handlers/e107_class.php | 7 +- e107_handlers/plugin_class.php | 5 +- user.php | 19 ++++-- 5 files changed, 118 insertions(+), 21 deletions(-) diff --git a/e107_core/shortcodes/batch/user_shortcodes.php b/e107_core/shortcodes/batch/user_shortcodes.php index 8a18c748a..258c01fd5 100644 --- a/e107_core/shortcodes/batch/user_shortcodes.php +++ b/e107_core/shortcodes/batch/user_shortcodes.php @@ -599,7 +599,13 @@ class user_shortcodes extends e_shortcode $sql = e107::getDb(); $tp = e107::getParser(); - global $EXTENDED_CATEGORY_START, $EXTENDED_CATEGORY_END, $EXTENDED_CATEGORY_TABLE; + $template = e107::getCoreTemplate('user','extended'); + + + $EXTENDED_CATEGORY_START = $template['start']; + $EXTENDED_CATEGORY_END = $template['end']; + $EXTENDED_CATEGORY_TABLE = $template['item'];; + $qry = "SELECT f.*, c.user_extended_struct_name AS category_name, c.user_extended_struct_id AS category_id FROM #user_extended_struct as f LEFT JOIN #user_extended_struct as c ON f.user_extended_struct_parent = c.user_extended_struct_id ORDER BY c.user_extended_struct_order ASC, f.user_extended_struct_order ASC @@ -607,23 +613,37 @@ class user_shortcodes extends e_shortcode + require_once(e_HANDLER."user_extended_class.php"); $ue = new e107_user_extended; $ueCatList = $ue->user_extended_get_categories(); $ueFieldList = $ue->user_extended_get_fields(); + + + $ueCatList[0][0] = array('user_extended_struct_name' => LAN_USER_44, 'user_extended_struct_text' => ''); + + // print_a($ueFieldList); + $ret = ""; foreach($ueCatList as $catnum => $cat) { + + + $key = $cat[0]['user_extended_struct_text'] ? $cat[0]['user_extended_struct_text'] : $cat[0]['user_extended_struct_name']; - $cat_name = $tp->parseTemplate("{USER_EXTENDED={$key}.text.{$this->var['user_id']}}", TRUE); + $cat_name = $tp->parseTemplate("{USER_EXTENDED={$key}.text.{$this->var['user_id']}}", TRUE); //XXX FIXME Fails + + $cat_name = true; //XXX TEMP Fix. + if($cat_name != FALSE && count($ueFieldList[$catnum])) { - + $ret .= str_replace("{EXTENDED_NAME}", $key, $EXTENDED_CATEGORY_START); foreach($ueFieldList[$catnum] as $f) { + $key = $f['user_extended_struct_name']; if($ue_name = $tp->parseTemplate("{USER_EXTENDED={$key}.text.{$this->var['user_id']}}", TRUE)) { @@ -739,11 +759,47 @@ class user_shortcodes extends e_shortcode } - - function sc_user_embed_userprofile($parm) + function sc_user_addons($parm='') { - global $pref, $USER_EMBED_USERPROFILE_TEMPLATE, $embed_already_rendered; + $template = e107::getCoreTemplate('user','addon'); + $tp = e107::getParser(); + $data = e107::getAddonConfig('e_user',null,'profile'); + if(empty($data)) + { + return; + } + + $text = ''; + + foreach($data as $plugin=>$val) + { + foreach($val as $v) + { + $array = array( + 'USER_ADDON_LABEL' => $v['label'], + 'USER_ADDON_TEXT' => $v['text'] + ); + + $text .= $tp->parseTemplate($template, true, $array); + } + + } + + return $text; + + } + + + + + /** + * @Deprecated Use {USER_ADDONS} instead. + */ + function sc_user_embed_userprofile($parm='') + { + + return $this->sc_user_addons($parm); //if no parm, it means we render ALL embedded contents //so we're preloading all registerd e_userprofile files $key = varset($pref['e_userprofile_list']); diff --git a/e107_core/templates/user_template.php b/e107_core/templates/user_template.php index cd57f6066..367076a24 100644 --- a/e107_core/templates/user_template.php +++ b/e107_core/templates/user_template.php @@ -25,11 +25,9 @@ $EXTENDED_CATEGORY_START = "{EXTE $EXTENDED_CATEGORY_TABLE = " - - {EXTENDED_ICON}  - {EXTENDED_NAME} + {EXTENDED_ICON}{EXTENDED_NAME} - {EXTENDED_VALUE} + {EXTENDED_VALUE} "; @@ -96,6 +94,9 @@ $sc_style['USER_RATING']['post'] = "
"; $sc_style['USER_LOGINNAME']['pre'] = " : "; + + + //FIXME TODO - Remove IF statements from template. if(isset($pref['photo_upload']) && $pref['photo_upload']) { @@ -192,7 +193,7 @@ $USER_FULL_TEMPLATE = "{SETIMAGE: w=250} ".LAN_USER_66." {USER_VISITS} -{USER_EMBED_USERPROFILE} +{USER_ADDONS} {USER_UPDATE_LINK} @@ -210,7 +211,32 @@ $USER_FULL_TEMPLATE = "{SETIMAGE: w=250} "; $USER_EMBED_USERPROFILE_TEMPLATE = " -{USER_EMBED_USERPROFILE_CAPTION} -{USER_EMBED_USERPROFILE_TEXT}"; + + {USER_ADDON_LABEL} + {USER_ADDON_TEXT} +"; + +// Convert v1 to v2 Standards. + +$USER_TEMPLATE['view'] = $USER_FULL_TEMPLATE; +$USER_TEMPLATE['extended']['start'] = $EXTENDED_CATEGORY_START; +$USER_TEMPLATE['extended']['item'] = $EXTENDED_CATEGORY_TABLE ; +$USER_TEMPLATE['extended']['start'] = $EXTENDED_CATEGORY_END; +$USER_TEMPLATE['addon'] = $USER_EMBED_USERPROFILE_TEMPLATE; + +$USER_TEMPLATE['list']['start'] = $USER_SHORT_TEMPLATE_START; +$USER_TEMPLATE['list']['item'] = $USER_SHORT_TEMPLATE; +$USER_TEMPLATE['list']['end'] = $USER_SHORT_TEMPLATE_END; + +// Convert Shortcode Wrappres from v1.x to v2.x standards. + +$USER_WRAPPER['view']['USER_COMMENTS_LINK'] = $sc_style['USER_COMMENTS_LINK']['pre']."{---}".$sc_style['USER_COMMENTS_LINK']['post']; +$USER_WRAPPER['view']['USER_SIGNATURE'] = $sc_style['USER_SIGNATURE']['pre']."{---}".$sc_style['USER_SIGNATURE']['post']; +$USER_WRAPPER['view']['USER_UPDATE_LINK'] = $sc_style['USER_UPDATE_LINK']['pre']."{---}".$sc_style['USER_UPDATE_LINK']['post']; +$USER_WRAPPER['view']['USER_FORUM_LINK'] = $sc_style['USER_FORUM_LINK']['pre']."{---}".$sc_style['USER_FORUM_LINK']['post']; +$USER_WRAPPER['view']['USER_RATING'] = $sc_style['USER_RATING']['pre']."{---}".$sc_style['USER_RATING']['post']; +$USER_WRAPPER['view']['USER_SENDPM'] = $sc_style['USER_SENDPM']['pre']."{---}".$sc_style['USER_SENDPM']['post']; + + ?> diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php index ca9d3c1e4..01e865fac 100644 --- a/e107_handlers/e107_class.php +++ b/e107_handlers/e107_class.php @@ -1803,9 +1803,10 @@ class e107 * Retrieves config() from all plugins for addons such as e_url.php, e_cron.php, e_sitelink.php * @param string $addonName eg. e_cron, e_url * @param string $className [optional] (if different from addonName) + * @param string $methodName [optional] (if different from 'config') * @return none */ - public function getAddonConfig($addonName, $className = '') + public function getAddonConfig($addonName, $className = '', $methodName='config' ) { $new_addon = array(); $sql = e107::getDb(); // Might be used by older plugins. @@ -1827,7 +1828,7 @@ class e107 include_once(e_PLUGIN.$key.'/'.$filename.'.php'); $class_name = $key.'_'.$className; - $array = self::callMethod($class_name, 'config'); + $array = self::callMethod($class_name, $methodName); if($array) { @@ -2250,6 +2251,8 @@ class e107 //FIXME XXX URGENT - Add support for _WRAPPER and $sc_style BC. - save in registry and retrieve in getScBatch()? // Use: list($pre,$post) = explode("{---}",$text,2); + + $tp = self::getParser(); // BC FIx - avoid breaking old templates due to missing globals. if(null === self::getRegistry($regPath)) { diff --git a/e107_handlers/plugin_class.php b/e107_handlers/plugin_class.php index d37c8299e..d9e49e1d7 100644 --- a/e107_handlers/plugin_class.php +++ b/e107_handlers/plugin_class.php @@ -44,9 +44,9 @@ class e107plugin 'e_event', 'e_comment', 'e_sql', - 'e_userprofile', + // 'e_userprofile', @deprecated @see e_user 'e_header', - 'e_userinfo', + // 'e_userinfo', @deprecated @see e_user 'e_tagwords', 'e_url', @@ -56,6 +56,7 @@ class e107plugin 'e_featurebox', 'e_related', 'e_rss', + 'e_user' ); diff --git a/user.php b/user.php index 4c3bf13b1..7dfca69f1 100644 --- a/user.php +++ b/user.php @@ -68,10 +68,21 @@ if (isset($_POST['delp'])) $qs = explode(".", e_QUERY); $self_page =($qs[0] == 'id' && intval($qs[1]) == USERID); -include_once(e107::coreTemplatePath('user')); //correct way to load a core template. + +$USER_TEMPLATE = e107::getCoreTemplate('user'); +e107::scStyle($sc_style); + +if(empty($USER_TEMPLATE)) // BC Fix for loading old templates. +{ + echo "DEBUG: Using v1.x user template"; + include_once(e107::coreTemplatePath('user')); //correct way to load a core template. +} + + +$TEMPLATE = str_replace('{USER_EMBED_USERPROFILE}','{USER_ADDONS}', $TEMPLATE); // BC Fix $user_shortcodes = e107::getScBatch('user'); - +$user_shortcodes->wrapper('user/view'); @@ -214,7 +225,7 @@ echo "
 ".$tp->parseTemplate("{NEXTPREV={$parms}}")."< function renderuser($uid, $mode = "verbose") { global $sql, $pref, $tp, $sc_style, $user_shortcodes; - global $EXTENDED_START, $EXTENDED_TABLE, $EXTENDED_END, $USER_SHORT_TEMPLATE, $USER_FULL_TEMPLATE; + global $EXTENDED_START, $EXTENDED_TABLE, $EXTENDED_END, $USER_SHORT_TEMPLATE, $USER_FULL_TEMPLATE, $USER_TEMPLATE; global $user; if(is_array($uid)) @@ -233,7 +244,7 @@ function renderuser($uid, $mode = "verbose") if($mode == 'verbose') { - return $tp->parseTemplate($USER_FULL_TEMPLATE, TRUE, $user_shortcodes); + return $tp->parseTemplate($USER_TEMPLATE['view'], TRUE, $user_shortcodes); } else { From ca3be147700d54dbfa0a754212ed35e58c9a483d Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 14 Oct 2014 02:12:13 -0700 Subject: [PATCH 17/46] More Admin->Mailout fixes and form inline fix for apostrophes. --- e107_handlers/form_handler.php | 19 ++++++++++++++++--- e107_handlers/mailout_class.php | 25 +++++++++++++++++++------ e107_plugins/newsletter/e_mailout.php | 18 +++++++++++++----- 3 files changed, 48 insertions(+), 14 deletions(-) diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index 9f1002ca2..8ab5e7700 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -2690,7 +2690,15 @@ class e_form */ private function renderInline($dbField, $pid, $fieldName, $curVal, $linkText, $type='text', $array=null) { - $source = str_replace('"',"'",json_encode($array, JSON_FORCE_OBJECT)); // SecretR - force object, fix number of bugs + $jsonArray = array(); + foreach($array as $k=>$v) + { + $jsonArray[$k] = str_replace("'", "`", $v); + } + + $source = str_replace('"',"'",json_encode($jsonArray, JSON_FORCE_OBJECT)); // SecretR - force object, fix number of bugs + + $mode = preg_replace('/[^\w]/', '', vartrue($_GET['mode'], '')); $text = "".$value.""; + $xtype = 'select'; + + $value = $this->renderInline($field, $id, $attributes['title'], $_value, $value, $xtype, $methodParms); + + // $source = str_replace('"',"'",json_encode($methodParms, JSON_FORCE_OBJECT)); + // $value = "".$value.""; } break; diff --git a/e107_handlers/mailout_class.php b/e107_handlers/mailout_class.php index 71c5317c9..3db883d20 100644 --- a/e107_handlers/mailout_class.php +++ b/e107_handlers/mailout_class.php @@ -113,11 +113,10 @@ class core_mailout $where = array(); $incExtended = array(); - if ($selectVals === FALSE) - { - $selectVals = array('email_to' => 'all'); - } - switch (varset($selectVals['email_to'], 'all')) + + $emailTo = vartrue($selectVals['email_to'], false); + + switch ($emailTo) { // Build the query for the user database case 'all' : @@ -137,7 +136,7 @@ class core_mailout { $where[] = "u.`user_class` REGEXP concat('(^|,)',{$selectVals['email_to']},'(,|$)')"; } - $where[] = "u.`user_ban`=0"; + } if (vartrue($selectVals['extended_1_name']) && vartrue($selectVals['extended_1_value'])) @@ -183,8 +182,19 @@ class core_mailout } } } + + if(empty($where) && empty($incExtended)) + { + $this->mail_read = 0; + $this->mail_count = 0; + return $this->mail_count; + } + + $where[] = "u.`user_email` != ''"; // Ignore all records with empty email address + + // Now assemble the query from the pieces // Determine which fields we actually need (u.user_sess is the signup link) $qry = 'SELECT u.user_id, u.user_name, u.user_email, u.user_loginname, u.user_sess, u.user_lastvisit'; @@ -203,6 +213,9 @@ class core_mailout $qry .= ' WHERE '.implode(' AND ',$where).' ORDER BY u.user_name'; // echo "Selector query: ".$qry.'
'; + + e107::getMessage()->addDebug("Selector query: ".$qry); + if (!( $this->mail_count = $sql->db_Select_gen($qry))) return FALSE; $this->mail_read = 0; return $this->mail_count; diff --git a/e107_plugins/newsletter/e_mailout.php b/e107_plugins/newsletter/e_mailout.php index 8b39391de..fd7e398dd 100644 --- a/e107_plugins/newsletter/e_mailout.php +++ b/e107_plugins/newsletter/e_mailout.php @@ -216,15 +216,23 @@ class newsletter_mailout } $c++; } + + return $var; } - else + elseif($allow_edit == true) { - return false; // Return Nothing to avoid confusion. - // $var[$c]['caption'] = NLLAN_50; - // $var[$c]['html'] = ''; + + $var[0]['caption'] = "No newsletters found"; + $var[0]['html'] = ''; + + return $var; + } + else + { + return false; // Return Nothing to avoid confusion. } - return $var; + } } From 69c69f14ae62a4ca8a329804c5356bdd7c77f0ac Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 14 Oct 2014 12:51:51 -0700 Subject: [PATCH 18/46] Closes #756 v2 standards for user profile. --- .../shortcodes/batch/user_shortcodes.php | 30 +++++++--- e107_core/templates/user_template.php | 58 +++++++++---------- e107_handlers/e107_class.php | 4 +- e107_plugins/chatbox_menu/e_user.php | 6 +- e107_plugins/forum/e_user.php | 41 +++++++++++++ .../languages/English/English_global.php | 2 +- 6 files changed, 99 insertions(+), 42 deletions(-) create mode 100644 e107_plugins/forum/e_user.php diff --git a/e107_core/shortcodes/batch/user_shortcodes.php b/e107_core/shortcodes/batch/user_shortcodes.php index 258c01fd5..1d7ce1f77 100644 --- a/e107_core/shortcodes/batch/user_shortcodes.php +++ b/e107_core/shortcodes/batch/user_shortcodes.php @@ -60,7 +60,7 @@ class user_shortcodes extends e_shortcode function sc_user_commentposts($parm) { - return $this->var['user_comments']; + return "".$this->var['user_comments'].""; } @@ -110,7 +110,7 @@ class user_shortcodes extends e_shortcode $commentposts = intval($sql->count("comments")); e107::setRegistry('total_commentposts', $commentposts); } - return ($commentposts > 0) ? round(($this->var['user_comments']/$commentposts) * 100, 2) : 0; + return ($commentposts > 0) ? "".round(($this->var['user_comments']/$commentposts) * 100, 2)."" : 0; } @@ -505,11 +505,11 @@ class user_shortcodes extends e_shortcode if (USERID == $this->var['user_id']) { //return "".LAN_USER_38.""; - return "".LAN_USER_38.""; // TODO: repair dirty fix for usersettings + return "".LAN_USER_38.""; // TODO: repair dirty fix for usersettings } else if(ADMIN && getperms("4") && !$this->var['user_admin']) { - return " $this->var['user_id'], 'name' => $this->var['user_name']))."'>".LAN_USER_39.""; + return " $this->var['user_id'], 'name' => $this->var['user_name']))."'>".LAN_USER_39.""; } } @@ -519,6 +519,8 @@ class user_shortcodes extends e_shortcode { global $full_perms; $sql = e107::getDb(); + $tp = e107::getParser(); + if (!$full_perms) return; $url = e107::getUrl(); if(!$userjump = e107::getRegistry('userjump')) @@ -539,13 +541,23 @@ class user_shortcodes extends e_shortcode } e107::setRegistry('userjump', $userjump); } + + + if($parm == 'prev') { - return isset($userjump['prev']['id']) ? "<< ".LAN_USER_40." [ ".$userjump['prev']['name']." ]" : " "; + + $icon = (deftrue('BOOTSTRAP')) ? $tp->toGlyph('chevron-left') : '<<'; + return isset($userjump['prev']['id']) ? "".$icon." ".LAN_USER_40."\n" : " "; + + // return isset($userjump['prev']['id']) ? "<< ".LAN_USER_40." [ ".$userjump['prev']['name']." ]" : " "; + } else { - return isset($userjump['next']['id']) ? "[ ".$userjump['next']['name']." ] ".LAN_USER_41." >>" : " "; + $icon = (deftrue('BOOTSTRAP')) ? $tp->toGlyph('chevron-right') : '>>'; + return isset($userjump['next']['id']) ? "".LAN_USER_41." ".$icon."\n" : " "; + // return isset($userjump['next']['id']) ? "[ ".$userjump['next']['name']." ] ".LAN_USER_41." >>" : " "; } } @@ -763,7 +775,7 @@ class user_shortcodes extends e_shortcode { $template = e107::getCoreTemplate('user','addon'); $tp = e107::getParser(); - $data = e107::getAddonConfig('e_user',null,'profile'); + $data = e107::getAddonConfig('e_user',null,'profile',$this->var); if(empty($data)) { @@ -776,9 +788,11 @@ class user_shortcodes extends e_shortcode { foreach($val as $v) { + $value = vartrue($v['url']) ? "".$v['text']."" : $v['text']; + $array = array( 'USER_ADDON_LABEL' => $v['label'], - 'USER_ADDON_TEXT' => $v['text'] + 'USER_ADDON_TEXT' => $value ); $text .= $tp->parseTemplate($template, true, $array); diff --git a/e107_core/templates/user_template.php b/e107_core/templates/user_template.php index 367076a24..a5b94a82e 100644 --- a/e107_core/templates/user_template.php +++ b/e107_core/templates/user_template.php @@ -15,7 +15,11 @@ */ if (!defined('e107_INIT')) { exit; } -if (!defined("USER_WIDTH")){ define("USER_WIDTH", "width:95%"); } +if (!defined("USER_WIDTH")) +{ + $legacyWidth = deftrue('BOOTSTRAP') ? "" : "width:95%"; + define("USER_WIDTH", $legacyWidth); +} global $user_shortcodes, $pref, $user; //Set this to TRUE if you would like any extended user field that is empty to NOT be shown on the profile page @@ -174,38 +178,33 @@ $USER_FULL_TEMPLATE = "{SETIMAGE: w=250} - ".LAN_USER_67." - {USER_CHATPOSTS} ( {USER_CHATPER}% ) + ".LAN_USER_66." + {USER_VISITS} +{USER_ADDONS} + + ".LAN_USER_68." {USER_COMMENTPOSTS} ( {USER_COMMENTPER}% ) -{USER_COMMENTS_LINK} - - ".LAN_USER_69." - {USER_FORUMPOSTS} ( {USER_FORUMPER}% ) - -{USER_FORUM_LINK} - - ".LAN_USER_66." - {USER_VISITS} - -{USER_ADDONS} + {USER_UPDATE_LINK} - - - - - - - -
{USER_JUMP_LINK=prev}{USER_JUMP_LINK=next}
- - -
+ +
    + +
  • + +
  • + +
+ {PROFILE_COMMENTS} {PROFILE_COMMENT_FORM} "; @@ -216,7 +215,9 @@ $USER_EMBED_USERPROFILE_TEMPLATE = " {USER_ADDON_TEXT} "; -// Convert v1 to v2 Standards. + + +// Convert Templates from v1.x to v2.x Standards. $USER_TEMPLATE['view'] = $USER_FULL_TEMPLATE; $USER_TEMPLATE['extended']['start'] = $EXTENDED_CATEGORY_START; @@ -228,7 +229,7 @@ $USER_TEMPLATE['list']['start'] = $USER_SHORT_TEMPLATE_START; $USER_TEMPLATE['list']['item'] = $USER_SHORT_TEMPLATE; $USER_TEMPLATE['list']['end'] = $USER_SHORT_TEMPLATE_END; -// Convert Shortcode Wrappres from v1.x to v2.x standards. +// Convert Shortcode Wrappers from v1.x to v2.x standards. $USER_WRAPPER['view']['USER_COMMENTS_LINK'] = $sc_style['USER_COMMENTS_LINK']['pre']."{---}".$sc_style['USER_COMMENTS_LINK']['post']; $USER_WRAPPER['view']['USER_SIGNATURE'] = $sc_style['USER_SIGNATURE']['pre']."{---}".$sc_style['USER_SIGNATURE']['post']; @@ -236,7 +237,6 @@ $USER_WRAPPER['view']['USER_UPDATE_LINK'] = $sc_style['USER_UPDATE_LINK']['pre' $USER_WRAPPER['view']['USER_FORUM_LINK'] = $sc_style['USER_FORUM_LINK']['pre']."{---}".$sc_style['USER_FORUM_LINK']['post']; $USER_WRAPPER['view']['USER_RATING'] = $sc_style['USER_RATING']['pre']."{---}".$sc_style['USER_RATING']['post']; $USER_WRAPPER['view']['USER_SENDPM'] = $sc_style['USER_SENDPM']['pre']."{---}".$sc_style['USER_SENDPM']['post']; - - +$USER_WRAPPER['view']['USER_LOGINNAME'] = $sc_style['USER_LOGINNAME']['pre']."{---}"; ?> diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php index 01e865fac..3fdb4d9e5 100644 --- a/e107_handlers/e107_class.php +++ b/e107_handlers/e107_class.php @@ -1806,7 +1806,7 @@ class e107 * @param string $methodName [optional] (if different from 'config') * @return none */ - public function getAddonConfig($addonName, $className = '', $methodName='config' ) + public function getAddonConfig($addonName, $className = '', $methodName='config', $param=null ) { $new_addon = array(); $sql = e107::getDb(); // Might be used by older plugins. @@ -1828,7 +1828,7 @@ class e107 include_once(e_PLUGIN.$key.'/'.$filename.'.php'); $class_name = $key.'_'.$className; - $array = self::callMethod($class_name, $methodName); + $array = self::callMethod($class_name, $methodName,$param); if($array) { diff --git a/e107_plugins/chatbox_menu/e_user.php b/e107_plugins/chatbox_menu/e_user.php index 4764c73c4..686b7b810 100644 --- a/e107_plugins/chatbox_menu/e_user.php +++ b/e107_plugins/chatbox_menu/e_user.php @@ -14,7 +14,7 @@ if (!defined('e107_INIT')) { exit; } class chatbox_menu_user // plugin-folder + '_user' { - function profile() + function profile($udata) { if(!$chatposts = e107::getRegistry('total_chatposts')) @@ -27,9 +27,11 @@ class chatbox_menu_user // plugin-folder + '_user' e107::setRegistry('total_chatposts', $chatposts); } + $perc = ($chatposts > 0) ? round(($udata['user_chats']/$chatposts) * 100, 2) : 0; + $var = array( - 0 => array('label' => LAN_PLUGIN_CHATBOX_MENU_POST, 'text' => $chatposts) + 0 => array('label' => LAN_PLUGIN_CHATBOX_MENU_POSTS, 'text' => $udata['user_chats']." ( ".$perc."% )") ); return $var; diff --git a/e107_plugins/forum/e_user.php b/e107_plugins/forum/e_user.php new file mode 100644 index 000000000..d3720759e --- /dev/null +++ b/e107_plugins/forum/e_user.php @@ -0,0 +1,41 @@ +count("forum_post")); + e107::setRegistry('total_forumposts', $total_forumposts); + } + + $count = $sql->retrieve('user_extended', 'user_plugin_forum_posts', 'user_extended_id = '.$udata['user_id']); + + $perc = ($total_forumposts > 0 && $count) ? round(($count / $total_forumposts) * 100, 2) : 0; + + $url = ($count> 0) ? e_HTTP."userposts.php?0.forums.".$udata['user_id'] : null; + + $var = array( + 0 => array('label' => LAN_PLUGIN_FORUM_POSTS, 'text' => intval($count)." ( ".$perc."% )", 'url'=> $url) + ); + + return $var; + } + +} \ No newline at end of file diff --git a/e107_plugins/forum/languages/English/English_global.php b/e107_plugins/forum/languages/English/English_global.php index 674b435f7..8976f3e3b 100644 --- a/e107_plugins/forum/languages/English/English_global.php +++ b/e107_plugins/forum/languages/English/English_global.php @@ -2,7 +2,7 @@ define("LAN_PLUGIN_FORUM_NAME", "Forum"); define("LAN_PLUGIN_FORUM_DESC", "This plugin is a fully featured forum system."); - +define("LAN_PLUGIN_FORUM_POSTS", "Forum posts"); // Notify // TODO - LAN cleanup (see e_notify) From 38a583f4290764e34cb772faffb72f21be1efba3 Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 14 Oct 2014 13:03:58 -0700 Subject: [PATCH 19/46] issue #780 - debug info added. --- e107_admin/image.php | 1 + 1 file changed, 1 insertion(+) diff --git a/e107_admin/image.php b/e107_admin/image.php index 18463a2e1..5957905dc 100644 --- a/e107_admin/image.php +++ b/e107_admin/image.php @@ -229,6 +229,7 @@ class media_cat_ui extends e_admin_ui } } + e107::getMessage()->addDebug("Max value for category names: ".print_a($this->ownerCount,true)); } From d99c03f39d2e47a3bfa146cf5e415abdd1e6704b Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 14 Oct 2014 14:56:12 -0700 Subject: [PATCH 20/46] Fixes #774 - Download comments. --- e107_handlers/comment_class.php | 10 +++++----- e107_plugins/download/handlers/download_class.php | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/e107_handlers/comment_class.php b/e107_handlers/comment_class.php index d912ff331..8bcdb2166 100644 --- a/e107_handlers/comment_class.php +++ b/e107_handlers/comment_class.php @@ -921,12 +921,12 @@ class comment /** * Displays existing comments, and a comment entry form * - * @param unknown_type $table - the source table for the associated item - * @param unknown_type $action - usually 'comment' or 'reply' - * @param unknown_type $id - ID of item associated with comments (e.g. news ID) + * @param string $table - the source table for the associated item + * @param string $action - usually 'comment' or 'reply' + * @param integer $id - ID of item associated with comments (e.g. news ID) * @param unknown_type $width - appears to not be used - * @param unknown_type $subject - * @param unknown_type $rate + * @param string $subject + * @param boolean $rate */ function compose_comment($table, $action, $id, $width, $subject, $rate = FALSE, $return = FALSE, $tablerender = TRUE) { diff --git a/e107_plugins/download/handlers/download_class.php b/e107_plugins/download/handlers/download_class.php index 46bc75871..35cb4d59a 100644 --- a/e107_plugins/download/handlers/download_class.php +++ b/e107_plugins/download/handlers/download_class.php @@ -379,8 +379,8 @@ class download unset($text); if ($dlrow['download_comment']) - { - $comments = e107::getComment()->compose_comment("download", "comment", $id, $width,$dlrow['download_name'], FALSE, true); + { + $comments = e107::getComment()->compose_comment("download", "comment", $dlrow['download_id'], $width, $dlrow['download_name'], FALSE, true); $ret .= $ns->tablerender($comments['caption'], $comments['comment'].$comments['comment_form'], 'download-comments', true); } From dc4a6c938f6aeef7c7edc6d75521762d208a70e8 Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 14 Oct 2014 15:35:53 -0700 Subject: [PATCH 21/46] Fixes #780 - Media Manager category insert issue when greater than 10. --- e107_admin/image.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/e107_admin/image.php b/e107_admin/image.php index 5957905dc..90834b412 100644 --- a/e107_admin/image.php +++ b/e107_admin/image.php @@ -210,7 +210,7 @@ class media_cat_ui extends e_admin_ui $sql = e107::getDb(); - if($sql->gen("SELECT media_cat_owner, MAX(media_cat_category) as maxnum, count(media_cat_id) as number FROM `#core_media_cat` GROUP BY media_cat_owner")) + if($sql->gen("SELECT media_cat_owner, MAX(CAST(SUBSTRING_INDEX(media_cat_category, '_', -1 ) AS UNSIGNED)) as maxnum, count(media_cat_id) as number FROM `#core_media_cat` GROUP BY media_cat_owner")) { while($row = $sql->fetch()) { @@ -220,10 +220,9 @@ class media_cat_ui extends e_admin_ui { $this->fields['media_cat_owner']['writeParms'][$own] = $own; - list($tmp,$tmp2,$maxnum) = explode("_",$row['maxnum']); // check for highest value. - if($maxnum > 0) + if($row['maxnum'] > 0) { - $this->ownerCount[$row['media_cat_owner']] = $maxnum; + $this->ownerCount[$row['media_cat_owner']] = $row['maxnum']; // $maxnum; } } } From 238864b66a0f049b06741d3fa47ebd6aa3477bc1 Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 14 Oct 2014 16:23:16 -0700 Subject: [PATCH 22/46] Fixes #771 - System Log preferences not being saved. --- e107_admin/admin_log.php | 21 ++++++++++++--------- e107_admin/auth.php | 3 ++- e107_handlers/admin_log_class.php | 5 +++-- usersettings.php | 2 +- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/e107_admin/admin_log.php b/e107_admin/admin_log.php index 9cd4521ff..588108d51 100644 --- a/e107_admin/admin_log.php +++ b/e107_admin/admin_log.php @@ -123,7 +123,7 @@ class admin_log_ui extends e_admin_ui { protected $pluginTitle = ADLAN_155; - protected $pluginName = 'adminlog'; + protected $pluginName = 'core'; protected $table = 'admin_log'; protected $pid = 'dblog_id'; protected $perPage = 10; @@ -159,7 +159,7 @@ class admin_log_ui extends e_admin_ui 'user_audit_class' => array('title'=> RL_LAN_123, 'type'=>'userclass', 'data' => 'int','help'=>''), 'user_audit_opts' => array('title'=> RL_LAN_031, 'type'=>'method', 'data' => 'array','help'=>''), 'roll_log_active' => array('title'=> RL_LAN_008, 'type'=>'boolean', 'data' => 'int','help'=>''), - 'roll_log_days' => array('title'=> RL_LAN_009, 'type'=>'text', 'data' => 'string','help'=>''), + 'roll_log_days' => array('title'=> RL_LAN_009, 'type'=>'number', 'data' => 'string','help'=>''), // 'Delete admin log events older than ' => array('title'=> RL_LAN_045, 'type'=>'method', 'data' => 'string','help'=>'Help Text goes here'), // 'Delete user audit trail log events older' => array('title'=> 'Delete user audit trail log events older', 'type'=>'method', 'data' => 'string','help'=>'Help Text goes here'), ); @@ -184,7 +184,10 @@ class admin_log_ui extends e_admin_ui // optional public function init() { - $this->prefs['sys_log_perpage']['writeParms'] = array(10, 20, 30, 40, 50); + $perPage = e107::getConfig()->get('sys_log_perpage'); + $this->perPage = vartrue($perPage,10); + + $this->prefs['sys_log_perpage']['writeParms'] = array(10=>10, 20=>20, 30=>30, 40=>40, 50=>50); $sql = e107::getDb(); @@ -382,7 +385,7 @@ class admin_log_form_ui extends e_admin_form_ui function user_audit_opts($curVal,$mode) { - $pref = e107::getPref(); + $frm = e107::getForm(); // User Audit log options (for info) @@ -407,15 +410,14 @@ class admin_log_form_ui extends e_admin_form_ui USER_AUDIT_ADD_ADMIN => RL_LAN_080, USER_AUDIT_MAIL_BOUNCE => RL_LAN_081, USER_AUDIT_BANNED => RL_LAN_082, USER_AUDIT_BOUNCE_RESET => RL_LAN_083, USER_AUDIT_TEMP_ACCOUNT => RL_LAN_084); - - $user_signup_opts = array_flip(explode(',', varset($pref['user_audit_opts'], ''))); + $userAuditOpts = e107::getConfig()->get('user_audit_opts'); $text = ""; foreach($audit_checkboxes as $k => $t) { - $checked = isset($user_signup_opts[$k]) ? true : false; - $text .= $frm->checkbox('user_audit_opts[]',$k, $checked, array('label'=>$t)); + $checked = isset($userAuditOpts[$k]) ? true : false; + $text .= $frm->checkbox('user_audit_opts['.$k.']',$k, $checked, array('label'=>$t)); } $text .= $frm->admin_button('check_all', 'jstarget:user_audit_opts', 'checkall', LAN_CHECKALL).$frm->admin_button('uncheck_all', 'jstarget:user_audit_opts', 'checkall', LAN_UNCHECKALL); @@ -807,7 +809,7 @@ $mes = e107::getMessage(); $frm = e107::getForm(); define('AL_DATE_TIME_FORMAT', 'y-m-d H:i:s'); - +/* if(isset($_POST['setoptions'])) { unset($temp); @@ -839,6 +841,7 @@ if(isset($_POST['setoptions'])) } } +*/ $ns->tablerender($caption, $mes->render() . $text); diff --git a/e107_admin/auth.php b/e107_admin/auth.php index be6ec6df9..28b02a1da 100644 --- a/e107_admin/auth.php +++ b/e107_admin/auth.php @@ -151,7 +151,8 @@ else $class_list[] = e_UC_MEMBER; $class_list[] = e_UC_PUBLIC; - $user_logging_opts = array_flip(explode(',', varset($pref['user_audit_opts'], ''))); + + $user_logging_opts = e107::getConfig()->get('user_audit_opts'); if (isset($user_logging_opts[USER_AUDIT_LOGIN]) && in_array(varset($pref['user_audit_class'], ''), $class_list)) { // Need to note in user audit trail e107::getAdminLog()->user_audit(USER_AUDIT_LOGIN, '', $user_id, $user_name); diff --git a/e107_handlers/admin_log_class.php b/e107_handlers/admin_log_class.php index 027547b3d..e388aa544 100644 --- a/e107_handlers/admin_log_class.php +++ b/e107_handlers/admin_log_class.php @@ -383,12 +383,13 @@ class e_admin_log */ function user_audit($event_type, $event_data, $id = '', $u_name = '') { - global $e107,$tp,$pref; + global $e107,$tp; list($time_usec, $time_sec) = explode(" ", microtime()); // Log event time immediately to minimise uncertainty $time_usec = $time_usec * 1000000; // See whether we should log this - $user_logging_opts = array_flip(explode(',', varset($pref['user_audit_opts'], ''))); + $user_logging_opts = e107::getConfig()->get('user_audit_opts'); + if (!isset($user_logging_opts[$event_type])) return; // Finished if not set to log this event type diff --git a/usersettings.php b/usersettings.php index bdbd12f10..c9fe5307f 100644 --- a/usersettings.php +++ b/usersettings.php @@ -629,7 +629,7 @@ if ($dataToSave && !$promptPassword) // Now see if we need to log anything. First check the options and class membership // (Normally we would leave logging decision to the log class. But this one's a bit more complicated) - $user_logging_opts = array_flip(explode(',', varset($pref['user_audit_opts'], ''))); + $user_logging_opts = e107::getConfig()->get('user_audit_opts'); $do_log = array(); $log_action = ''; if ($_uid) From 04435e10e61a2c4387977f94052fc7848fd3bd5a Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 14 Oct 2014 18:19:51 -0700 Subject: [PATCH 23/46] Issue #771 - now decodes user-log preference correctly. --- e107_admin/admin_log.php | 3 ++- e107_handlers/login.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/e107_admin/admin_log.php b/e107_admin/admin_log.php index 588108d51..ed6b4accd 100644 --- a/e107_admin/admin_log.php +++ b/e107_admin/admin_log.php @@ -1107,7 +1107,7 @@ if(! defined("USER_WIDTH")) // CONFIGURATION OPTIONS MENU //==================================================================== - +/* if($action == "config") { // User Audit log options (for info) @@ -1246,6 +1246,7 @@ if($action == "config") $ns->tablerender(ADLAN_155.SEP.LAN_OPTIONS, $mes->render().$text); } +*/ //==================================================================== // LOG VIEW MENU diff --git a/e107_handlers/login.php b/e107_handlers/login.php index 1df37ed27..a7c4e3d7c 100644 --- a/e107_handlers/login.php +++ b/e107_handlers/login.php @@ -243,7 +243,7 @@ class userlogin // Problem is that USERCLASS_LIST just contains 'guest' and 'everyone' at this point $class_list = $this->userMethods->addCommonClasses($this->userData, TRUE); - $user_logging_opts = array_flip(explode(',',varset($pref['user_audit_opts'],''))); + $user_logging_opts = e107::getConfig()->get('user_audit_opts'); if (isset($user_logging_opts[USER_AUDIT_LOGIN]) && in_array(varset($pref['user_audit_class'],''),$class_list)) { // Need to note in user audit trail $this->e107->admin_log->user_audit(USER_AUDIT_LOGIN,'', $user_id,$user_name); From 26944fbbb71d1b3c338d0916d278465d985f8f8c Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 14 Oct 2014 19:02:56 -0700 Subject: [PATCH 24/46] Disable debug on mail handler. --- e107_handlers/mail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e107_handlers/mail.php b/e107_handlers/mail.php index 77c3ebef5..575435782 100644 --- a/e107_handlers/mail.php +++ b/e107_handlers/mail.php @@ -154,7 +154,7 @@ class e107Email extends PHPMailer private $pause_time = 1; // Time to pause after sending a block of emails public $legacyBody = false; // TRUE enables legacy conversion of plain text body to HTML in HTML emails - private $debug = true; // echos various debug info when set to true. + private $debug = false; // echos various debug info when set to true. private $pref = array(); // Store code prefs. /** From 7a7a98cb5df456422a7c4efdff832a907089cfce Mon Sep 17 00:00:00 2001 From: Cameron Date: Wed, 15 Oct 2014 15:38:50 -0700 Subject: [PATCH 25/46] Fixes #782 - Missing extended fields on usersettings page when using Bootstrap 2 theme. --- .../shortcodes/batch/usersettings_shortcodes.php | 13 +++++++------ e107_core/templates/usersettings_template.php | 4 ++-- e107_handlers/user_extended_class.php | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/e107_core/shortcodes/batch/usersettings_shortcodes.php b/e107_core/shortcodes/batch/usersettings_shortcodes.php index 9287a8a98..9a0b5ef5f 100755 --- a/e107_core/shortcodes/batch/usersettings_shortcodes.php +++ b/e107_core/shortcodes/batch/usersettings_shortcodes.php @@ -292,7 +292,7 @@ class usersettings_shortcodes extends e_shortcode $tabs = array(); - if($parm == 'tabs') + if($parm == 'tabs' && deftrue('BOOTSTRAP')) { $this->extendedTabs = true; } @@ -308,13 +308,13 @@ class usersettings_shortcodes extends e_shortcode } - if($parm == 'tabs' && deftrue('BOOTSTRAP')) + + if($parm == 'tabs' && deftrue('BOOTSTRAP')===3) { return e107::getForm()->tabs($tabs); } - return $ret; } @@ -324,11 +324,12 @@ class usersettings_shortcodes extends e_shortcode { global $usersettings_shortcodes, $USER_EXTENDED_CAT, $extended_showed; - if(deftrue('BOOTSTRAP')) + if(deftrue('BOOTSTRAP')===3) { $USER_EXTENDED_CAT = e107::getCoreTemplate('usersettings','extended-category'); } + $sql = e107::getDb(); $tp = e107::getParser(); @@ -389,10 +390,10 @@ class usersettings_shortcodes extends e_shortcode function sc_userextended_field($parm='') - { + { global $usersettings_shortcodes, $extended_showed, $ue, $USEREXTENDED_FIELD, $REQUIRED_FIELD; - if(deftrue('BOOTSTRAP')) + if(deftrue('BOOTSTRAP')===3) { $USEREXTENDED_FIELD = e107::getCoreTemplate('usersettings','extended-field'); } diff --git a/e107_core/templates/usersettings_template.php b/e107_core/templates/usersettings_template.php index bb7260f60..33ca024f1 100755 --- a/e107_core/templates/usersettings_template.php +++ b/e107_core/templates/usersettings_template.php @@ -181,7 +181,7 @@ $USERSETTINGS_EDIT = " -// e107 v2. bootstrap3 compatible. +// e107 v2. bootstrap3 compatible template. $USERSETTINGS_WRAPPER['edit']['USERNAME'] = "
@@ -246,7 +246,7 @@ $USERSETTINGS_WRAPPER['edit']['SIGNATURE'] = "
- +// Bootstrap 3 only. $USERSETTINGS_TEMPLATE['edit'] = " diff --git a/e107_handlers/user_extended_class.php b/e107_handlers/user_extended_class.php index b2b6bebfd..9873762ef 100644 --- a/e107_handlers/user_extended_class.php +++ b/e107_handlers/user_extended_class.php @@ -688,7 +688,7 @@ class e107_user_extended { case EUF_TEXT : //textbox case EUF_INTEGER : //integer - $ret = ""; + $ret = ""; return $ret; break; From 28db46022bc937003c9d22b5445312ab9095c58a Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 16 Oct 2014 17:31:38 -0700 Subject: [PATCH 26/46] Issue #684 Disabled drop-down restyling due to validation alert issues. --- e107_handlers/admin_ui.php | 6 ++++-- e107_handlers/form_handler.php | 25 +++++++++++++++++-------- e107_web/js/core/admin.jquery.js | 18 +++++++++--------- 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/e107_handlers/admin_ui.php b/e107_handlers/admin_ui.php index 2ff2c34d4..578d4b853 100644 --- a/e107_handlers/admin_ui.php +++ b/e107_handlers/admin_ui.php @@ -5559,8 +5559,9 @@ class e_admin_form_ui extends e_form // TODO - core ui-batch-option class!!! REMOVE INLINE STYLE! // XXX Quick Fix for styling - correct. $text = " -