From 716678a3b716f1bf4f274ec3068d776cc7356207 Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 19 Apr 2016 16:57:44 -0700 Subject: [PATCH 01/34] PHP Notice and BC Fixes. --- .../shortcodes/batch/news_shortcodes.php | 27 ++++++++++++++----- e107_plugins/download/download.php | 18 +++++++++++++ e107_plugins/news/news_carousel_menu.php | 4 ++- e107_plugins/news/other_news2_menu.php | 6 ++++- e107_plugins/news/other_news_menu.php | 5 +++- e107_plugins/newsfeed/newsfeed_functions.php | 2 +- 6 files changed, 51 insertions(+), 11 deletions(-) diff --git a/e107_core/shortcodes/batch/news_shortcodes.php b/e107_core/shortcodes/batch/news_shortcodes.php index 24e598455..813674033 100644 --- a/e107_core/shortcodes/batch/news_shortcodes.php +++ b/e107_core/shortcodes/batch/news_shortcodes.php @@ -34,6 +34,8 @@ class news_shortcodes extends e_shortcode protected $commentsEngine = 'e107'; private $imageItem; + + public $param = array(); function __construct($eVars = null) @@ -80,7 +82,10 @@ class news_shortcodes extends e_shortcode { $tp = e107::getParser(); e107::getBB()->setClass("news"); // For automatic bbcode image resizing. - + + + $news_body = ''; + if($parm != 'extended') { $news_body = $tp->toHTML($this->news_item['news_body'], true, 'BODY, fromadmin', $this->news_item['news_author']); @@ -90,7 +95,9 @@ class news_shortcodes extends e_shortcode { $news_body .= $tp->toHTML($this->news_item['news_extended'], true, 'BODY, fromadmin', $this->news_item['news_author']); } + e107::getBB()->clearClass(); + return $news_body; } @@ -511,7 +518,8 @@ class news_shortcodes extends e_shortcode { $tp = e107::getParser(); $text = $tp->toHtml($this->news_item['news_body'],true); - $text = str_replace("
","\n",$text); + $breaks = array('
','
'); + $text = str_replace($breaks,"\n",$text); $text = strip_tags($text); $tmp = preg_split('/(\.\s|!|\r|\n|\?)/i', trim($text)); $tmp = array_filter($tmp); @@ -597,18 +605,23 @@ class news_shortcodes extends e_shortcode $_src = $src = ($newsThumb[0] == '{' || $parms[1] == 'placeholder') ? e107::getParser()->replaceConstants($newsThumb, 'abs') : e_IMAGE_ABS."newspost_images/".$newsThumb; - if($parms[2] || $parms[1] == 'placeholder') + if(!empty($parms[2]) || $parms[1] == 'placeholder') { // $srcset = "srcset='".$tp->thumbSrcSet($src,'all')."' size='100vw' "; - $src = e107::getParser()->thumbUrl($src, $parms[2]); + $attr = !empty($parms[2]) ? $parms[2] : null; + $src = e107::getParser()->thumbUrl($src, $attr); $dimensions = e107::getParser()->thumbDimensions(); } } - - - + + if(empty($parms[1])) + { + $parms = array(1 => null); + } + + switch($parms[1]) { case 'src': diff --git a/e107_plugins/download/download.php b/e107_plugins/download/download.php index f9528ba43..2daaec3b2 100644 --- a/e107_plugins/download/download.php +++ b/e107_plugins/download/download.php @@ -19,6 +19,24 @@ if (!e107::isInstalled('download')) } e107::lan('download',false, true); // Loads e_PLUGIN.'download/languages/'.e_LANGUAGE.'/English_front.php' + + $bcList = array( + 'LAN_dl_19' => 'LAN_CATEGORY', + 'LAN_dl_17' => 'LAN_FILES', + "LAN_dl_20" => "LAN_FILES", + "LAN_dl_21" => "LAN_SIZE", + "LAN_dl_22" => "LAN_DATE", + "LAN_dl_23" => "LAN_FILE", + "LAN_dl_24" => "LAN_AUTHOR", + "LAN_dl_25" => "LAN_ASCENDING", + "LAN_dl_26" => "LAN_DESCENDING", + "LAN_dl_27" => "LAN_GO", + "LAN_dl_28" => "LAN_NAME" + ); + + e107::getLanguage()->bcDefs($bcList); + + require_once(e_PLUGIN.'download/handlers/download_class.php'); require_once(e_PLUGIN.'download/handlers/category_class.php'); diff --git a/e107_plugins/news/news_carousel_menu.php b/e107_plugins/news/news_carousel_menu.php index 1851c3cb6..02387dd8a 100644 --- a/e107_plugins/news/news_carousel_menu.php +++ b/e107_plugins/news/news_carousel_menu.php @@ -23,9 +23,11 @@ if(isset($parms['caption'][e_LANGUAGE])) $limit = vartrue($parms['count'],5); $tp = e107::getParser(); -$template = e107::getTemplate('news', 'news_menu', 'carousel'); +$template = e107::getTemplate('news', 'news_menu', 'carousel', false, true); $nobody_regexp = "'(^|,)(".str_replace(",", "|", e_UC_NOBODY).")(,|$)'"; + +e107::getDebug()->log("News Carousel Menu ".print_a($parms,true)); $query = " SELECT n.*, nc.category_id, nc.category_name, nc.category_sef, nc.category_icon, diff --git a/e107_plugins/news/other_news2_menu.php b/e107_plugins/news/other_news2_menu.php index 44baf4852..918951dcd 100644 --- a/e107_plugins/news/other_news2_menu.php +++ b/e107_plugins/news/other_news2_menu.php @@ -39,7 +39,11 @@ if(!$OTHERNEWS2_STYLE) { if(deftrue('BOOTSTRAP')) // v2.x { - define("OTHERNEWS_COLS",false); + if(!defined("OTHERNEWS_COLS")) + { + define("OTHERNEWS_COLS",false); + } + $template = e107::getTemplate('news', 'news_menu', 'other2'); $OTHERNEWS2_STYLE = $template['item']; diff --git a/e107_plugins/news/other_news_menu.php b/e107_plugins/news/other_news_menu.php index fc02371f5..8ce2186eb 100644 --- a/e107_plugins/news/other_news_menu.php +++ b/e107_plugins/news/other_news_menu.php @@ -51,7 +51,10 @@ if(!$OTHERNEWS_STYLE) { if(deftrue('BOOTSTRAP')) // v2.x { - define("OTHERNEWS_COLS",false); + if(!defined("OTHERNEWS_COLS")) + { + define("OTHERNEWS_COLS",false); + } $template = e107::getTemplate('news', 'news_menu', 'other'); $item_selector = '
diff --git a/e107_plugins/newsfeed/newsfeed_functions.php b/e107_plugins/newsfeed/newsfeed_functions.php index 11000e7b3..ee4a79b89 100644 --- a/e107_plugins/newsfeed/newsfeed_functions.php +++ b/e107_plugins/newsfeed/newsfeed_functions.php @@ -387,7 +387,7 @@ class newsfeedClass if($which == 'all') { - $ret['title'] = $NEWSFEED_MENU_CAPTION; + $ret['title'] = (!empty($NEWSFEED_MENU_CAPTION)) ? $NEWSFEED_MENU_CAPTION : ''; } else { From f6ca9f8883031c5ba89c3d252ba35ce7e577f403 Mon Sep 17 00:00:00 2001 From: Cameron Date: Wed, 20 Apr 2016 17:25:32 -0700 Subject: [PATCH 02/34] Newsfeeds: Fixes #1495. Admin-area rewrite using admin-ui. Newsfeed class is now compatible with PHP7. --- e107_admin/plugin.php | 17 +- e107_admin/prefs.php | 7 + e107_handlers/cache_handler.php | 2 +- e107_handlers/form_handler.php | 13 +- e107_handlers/magpie_rss.php | 2 +- e107_plugins/news/news_carousel_menu.php | 2 +- e107_plugins/newsfeed/admin_config.php | 467 +++++++++++-------- e107_plugins/newsfeed/newsfeed_functions.php | 123 ++--- e107_plugins/poll/poll_class.php | 1 + 9 files changed, 376 insertions(+), 258 deletions(-) diff --git a/e107_admin/plugin.php b/e107_admin/plugin.php index 22f8f0c78..e535644d2 100644 --- a/e107_admin/plugin.php +++ b/e107_admin/plugin.php @@ -2213,8 +2213,13 @@ class pluginBuilder { $this->createFiles = true; } - - + + if(vartrue($_POST['step']) == 4) + { + $this->step4(); + return null; + } + if(vartrue($_GET['step']) == 3) { @@ -2222,11 +2227,7 @@ class pluginBuilder return null; } - if(vartrue($_POST['step']) == 4) - { - $this->step4(); - return null; - } + if(vartrue($_GET['newplugin']) && $_GET['step']==2) @@ -2856,7 +2857,7 @@ class pluginBuilder case 'summary-summary': $help = EPL_ADLAN_142."
".EPL_ADLAN_143; $required = true; - $size = 100; + $size = 130; $placeholder= " "; $pattern = "[A-Za-z \.0-9]*"; $xsize = 'block-level'; diff --git a/e107_admin/prefs.php b/e107_admin/prefs.php index 10994619f..c80588cd5 100644 --- a/e107_admin/prefs.php +++ b/e107_admin/prefs.php @@ -363,6 +363,13 @@ $text .= "
".$tp->parseTemplate("{IMAGESELECTOR={$parms $sLogo = siteinfo_shortcodes::sc_logo(); */ +if(!empty($pref['sitebutton']) && strpos($pref['sitebutton'],'{')===false && file_exists(e_IMAGE.$pref['sitebutton'])) +{ + $pref['sitebutton'] = '{e_IMAGE}'.$pref['sitebutton']; +} + + + $text .= $frm->imagepicker('sitebutton',$pref['sitebutton'],'','help='.PRFLAN_225); $text .= " diff --git a/e107_handlers/cache_handler.php b/e107_handlers/cache_handler.php index b60a5d48e..8fa033799 100644 --- a/e107_handlers/cache_handler.php +++ b/e107_handlers/cache_handler.php @@ -172,7 +172,7 @@ class ecache { /** * * @param string $CacheTag - name of tag for future retrieval - should NOT contain an MD5. - * @param data $Data - data to be cached + * @param string $Data - data to be cached * @param boolean $ForceCache [optional] if TRUE, writes cache even when disabled in admin prefs. * @param boolean $bRaw [optional] if TRUE, writes data exactly as provided instead of prefacing with php leadin * @param boolean $syscache [optional] diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index 7df277edd..a508dba22 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -3570,7 +3570,18 @@ class e_form } if(!is_array($attributes['writeParms'])) parse_str($attributes['writeParms'], $attributes['writeParms']); - $value = vartrue($attributes['writeParms']['__options']['pre']).vartrue($attributes['writeParms'][$value]).vartrue($attributes['writeParms']['__options']['post']); + + if(!empty($attributes['writeParms']['optArray'])) + { + $radioValue = $attributes['writeParms']['optArray'][$value]; + } + else + { + $radioValue = vartrue($attributes['writeParms'][$value]); + } + + + $value = vartrue($attributes['writeParms']['__options']['pre']).$radioValue.vartrue($attributes['writeParms']['__options']['post']); break; case 'tags': diff --git a/e107_handlers/magpie_rss.php b/e107_handlers/magpie_rss.php index 828d66f20..1ac56ab27 100644 --- a/e107_handlers/magpie_rss.php +++ b/e107_handlers/magpie_rss.php @@ -151,7 +151,7 @@ class MagpieRSS { // check for a namespace, and split if found $ns = false; if ( strpos( $element, ':' ) ) { - list($ns, $el) = split( ':', $element, 2); + list($ns, $el) = explode( ':', $element, 2); } if ( $ns and $ns != 'rdf' ) { $this->current_namespace = $ns; diff --git a/e107_plugins/news/news_carousel_menu.php b/e107_plugins/news/news_carousel_menu.php index 02387dd8a..4d4fd4a63 100644 --- a/e107_plugins/news/news_carousel_menu.php +++ b/e107_plugins/news/news_carousel_menu.php @@ -23,7 +23,7 @@ if(isset($parms['caption'][e_LANGUAGE])) $limit = vartrue($parms['count'],5); $tp = e107::getParser(); -$template = e107::getTemplate('news', 'news_menu', 'carousel', false, true); +$template = e107::getTemplate('news', 'news_menu', 'carousel', true, true); $nobody_regexp = "'(^|,)(".str_replace(",", "|", e_UC_NOBODY).")(,|$)'"; diff --git a/e107_plugins/newsfeed/admin_config.php b/e107_plugins/newsfeed/admin_config.php index 00b6271f9..050931e2c 100644 --- a/e107_plugins/newsfeed/admin_config.php +++ b/e107_plugins/newsfeed/admin_config.php @@ -1,217 +1,310 @@ array( + 'controller' => 'newsfeed_ui', + 'path' => null, + 'ui' => 'newsfeed_form_ui', + 'uipath' => null + ), + + + ); + + + protected $adminMenu = array( + + 'main/list' => array('caption'=> LAN_MANAGE, 'perm' => 'P'), + 'main/create' => array('caption'=> LAN_CREATE, 'perm' => 'P'), + + // 'main/custom' => array('caption'=> 'Custom Page', 'perm' => 'P') + ); + + protected $adminMenuAliases = array( + 'main/edit' => 'main/list' + ); + + protected $menuTitle = LAN_PLUGIN_NEWSFEEDS_NAME; } -if (isset($_POST['createFeed']) || isset($_POST['updateFeed'])) + + + + +class newsfeed_ui extends e_admin_ui { - if ($_POST['newsfeed_url'] && $_POST['newsfeed_name']) - { - $feed['newsfeed_name'] = $tp->toDB($_POST['newsfeed_name']); - $feed['newsfeed_description'] = $tp->toDB($_POST['newsfeed_description']); - $feed['newsfeed_image'] = $tp->toDB($_POST['newsfeed_image'])."::".intval($_POST['newsfeed_showmenu'])."::".intval($_POST['newsfeed_showmain']); - $feed['newsfeed_url'] = $tp->toDB($_POST['newsfeed_url']); - $feed['newsfeed_active'] = intval($_POST['newsfeed_active']); - $feed['newsfeed_updateint'] = intval($_POST['newsfeed_updateint']); - $feed['newsfeed_data'] = ''; // Start with blank data feed - $feed['newsfeed_timestamp'] = 0; // This should force an immediate update - - if (isset($_POST['createFeed'])) + + protected $pluginTitle = LAN_PLUGIN_NEWSFEEDS_NAME; + protected $pluginName = 'newsfeed'; + // protected $eventName = 'newsfeed-newsfeed'; // remove comment to enable event triggers in admin. + protected $table = 'newsfeed'; + protected $pid = 'newsfeed_id'; + protected $perPage = 10; + protected $batchDelete = true; + protected $batchCopy = true; + // protected $sortField = 'somefield_order'; + // protected $orderStep = 10; + // protected $tabs = array('Tabl 1','Tab 2'); // Use 'tab'=>0 OR 'tab'=>1 in the $fields below to enable. + + // protected $listQry = "SELECT * FROM `#tableName` WHERE field != '' "; // Example Custom Query. LEFT JOINS allowed. Should be without any Order or Limit. + + protected $listOrder = 'newsfeed_id DESC'; + + protected $fields = array ( 'checkboxes' => array ( 'title' => '', 'type' => null, 'data' => null, 'width' => '5%', 'thclass' => 'center', 'forced' => '1', 'class' => 'center', 'toggle' => 'e-multiselect', ), + 'newsfeed_id' => array ( 'title' => LAN_ID, 'data' => 'int', 'width' => '5%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), + 'newsfeed_name' => array ( 'title' => LAN_TITLE, 'type' => 'text', 'data' => 'str', 'required'=>true, 'width' => 'auto', 'inline' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), + 'newsfeed_url' => array ( 'title' => LAN_URL, 'type' => 'url', 'data' => 'str', 'required'=>true, 'inline'=>true, 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => array('size'=>'xxlarge'), 'class' => 'left', 'thclass' => 'left', ), + 'newsfeed_data' => array ( 'title' => 'Data', 'type' => 'hidden', 'data' => false, 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), + 'newsfeed_timestamp' => array ( 'title' => 'Timestamp', 'type' => 'hidden', 'data' => 'int', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), + 'newsfeed_description' => array ( 'title' => LAN_DESCRIPTION, 'type' => 'textarea', 'data' => 'str', 'width' => '40%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), + 'newsfeed_image' => array ( 'title' => NFLAN_11, 'type' => 'method', 'data' => 'str', 'width' => 'auto', 'help' => LAN_OPTIONAL, 'readParms' => 'thumb=80x80', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), + + 'newsfeed_updateint' => array ( 'title' => NFLAN_18, 'type' => 'text', 'data' => 'int', 'inline'=>true, 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => array('default'=>3600), 'class' => 'left', 'thclass' => 'left', ), + + 'newsfeed_active' => array ( 'title' => NFLAN_12, 'type' => 'radio', 'data' => 'int', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => array('default'=>3, 'optArray'=>array(NFLAN_13,NFLAN_14,NFLAN_20,NFLAN_21)), 'class' => 'left', 'thclass' => 'left', ), + + 'newsfeed_showmenu' => array('title'=>NFLAN_45, 'type'=>'method', 'data'=>false, 'class'=>'center', 'thclass'=>'center' ), + 'newsfeed_showmain' => array('title'=>NFLAN_46, 'type'=>'method', 'data'=>false, 'class'=>'center', 'thclass'=>'center'), + + 'options' => array ( 'title' => LAN_OPTIONS, 'type' => null, 'data' => null, 'width' => '8%', 'thclass' => 'center last', 'class' => 'center last', 'forced' => '1', ), + ); + + protected $fieldpref = array('newsfeed_name', 'newsfeed_url', 'newsfeed_updateint', 'newsfeed_active', 'newsfeed_showmenu', 'newsfeed_showmain'); + + + // protected $preftabs = array('General', 'Other' ); + protected $prefs = array( + ); + + + public function init() { - if ($sql->insert('newsfeed',$feed)) + if($this->getAction() == 'edit' || $this->getAction() == 'create') { - $admin_log->logArrayAll('NEWSFD_01', $feed); - $mes->addSuccess(LAN_CREATED); - } - else - { - $mes->addError(LAN_CREATED_FAILED.': '.$sql->mySQLerror); + $this->fields['newsfeed_updateint']['type'] = 'number'; } + // Set drop-down values (if any). + } - elseif (isset($_POST['updateFeed'])) + + + // ------- Customize Create -------- + + public function beforeCreate($new_data) { - $feed['WHERE'] = "newsfeed_id=".intval($_POST['newsfeed_id']); - - if($sql->update('newsfeed',$feed)) + if(isset($new_data['newsfeed_showmenu'])) { - $admin_log->logArrayAll('NEWSFD_02', $feed); - $mes->addSuccess(LAN_UPDATED); - } - else - { - $mes->addInfo(LAN_NO_CHANGE.': '.$sql->mySQLerror); + $new_data['newsfeed_image'] = e107::getParser()->toDB($new_data['newsfeed_image'])."::".intval($new_data['newsfeed_showmenu'])."::".intval($new_data['newsfeed_showmain']); } + + return $new_data; } - e107::getCache()->clear(NEWSFEED_LIST_CACHE_TAG); // This should actually clear all the newsfeed data in one go - } - else + + public function afterCreate($new_data, $old_data, $id) + { + // do something + e107::getCache()->clear(NEWSFEED_LIST_CACHE_TAG); + e107::getCache()->clear(NEWSFEED_NEWS_CACHE_TAG); + } + + public function onCreateError($new_data, $old_data) + { + // do something + } + + + // ------- Customize Update -------- + + public function beforeUpdate($new_data, $old_data, $id) + { + if(isset($new_data['newsfeed_showmenu'])) + { + $new_data['newsfeed_image'] = e107::getParser()->toDB($new_data['newsfeed_image'])."::".intval($new_data['newsfeed_showmenu'])."::".intval($new_data['newsfeed_showmain']); + } + + return $new_data; + } + + public function afterUpdate($new_data, $old_data, $id) + { + // do something + e107::getCache()->clear(NEWSFEED_LIST_CACHE_TAG); + e107::getCache()->clear(NEWSFEED_NEWS_CACHE_TAG); + } + + public function onUpdateError($new_data, $old_data, $id) + { + // do something + } + + + /* + // optional - a custom page. + public function customPage() + { + $text = 'Hello World!'; + return $text; + + } + */ + +} + + + +class newsfeed_form_ui extends e_admin_form_ui +{ + + + // Custom Method/Function + function newsfeed_active($curVal,$mode) { - $mes->addError(LAN_REQUIRED_BLANK); + $frm = e107::getForm(); + + switch($mode) + { + case 'read': // List Page + return $curVal; + break; + + case 'write': // Edit Page + return $frm->text('newsfeed_active',$curVal, 255, 'size=large'); + break; + + case 'filter': + case 'batch': + return array(); + break; + } + } + + + function newsfeed_image($curVal,$mode) + { + $frm = e107::getForm(); + + switch($mode) + { + case 'read': // List Page + return $curVal; + break; + + case 'write': // Edit Page + + $tmp = explode('::',$curVal); + + return $frm->text('newsfeed_image',$tmp[0], 255, 'size=large'); + break; + + case 'filter': + case 'batch': + return array(); + break; + } + } + + + + function newsfeed_showmain($curVal,$mode) + { + $frm = e107::getForm(); + + switch($mode) + { + case 'read': // List Page + $data = $this->getController()->getListModel()->get('newsfeed_image'); + list($image,$menu,$main) = explode('::',$data); + + return intval($main); + break; + + case 'write': // Edit Page + + $data = $this->getController()->getModel()->get('newsfeed_image'); + list($image,$menu,$main) = explode('::',$data); + + if(empty($main)) + { + $main = 10; + } + + return $frm->number('newsfeed_showmain',$main, 3); + break; + + case 'filter': + case 'batch': + return array(); + break; + } + } + + + + function newsfeed_showmenu($curVal,$mode) + { + $frm = e107::getForm(); + + switch($mode) + { + case 'read': // List Page + $data = $this->getController()->getListModel()->get('newsfeed_image'); + list($image,$menu,$main) = explode('::',$data); + + return intval($menu); + break; + + case 'write': // Edit Page + $data = $this->getController()->getModel()->get('newsfeed_image'); + list($image,$menu,$main) = explode('::',$data); + + if(empty($menu)) + { + $menu = 10; + } + + return $frm->number('newsfeed_showmenu',$menu, 3); + break; + + case 'filter': + case 'batch': + return array(); + break; + } } } -$ns->tablerender($caption, $mes->render() . $text); -if($action == "delete") -{ - $sql->db_Delete('newsfeed', 'newsfeed_id='.$id); - e107::getLog()->add('NEWSFD_03','ID: '.$id,E_LOG_INFORMATIVE,''); - $mes->addSuccess(LAN_DELETED); -} +new newsfeed_adminArea(); -$ns->tablerender($caption, $mes->render() . $text); - - -if($headline_total = $sql->db_Select("newsfeed")) -{ - $nfArray = $sql->rows(); - - $text = " - - - - - - - - - - - - - - - - - \n"; - - $active = array(NFLAN_13,NFLAN_14,NFLAN_20,NFLAN_21); - - foreach($nfArray as $newsfeed) - { - extract($newsfeed); // FIXME - - $text .= " - - - - - - - "; - } - - $text .= "
".LAN_ID."".LAN_NAME."".NFLAN_26."".NFLAN_12."".LAN_OPTIONS."
$newsfeed_id$newsfeed_name".($newsfeed_updateint ? $newsfeed_updateint : "3600")."".$active[$newsfeed_active]." - ".ADMIN_EDIT_ICON." - ".ADMIN_DELETE_ICON." -
"; -} -else -{ - $mes->addInfo(NFLAN_41); -} - -$ns->tablerender(NFLAN_07, $mes->render(). $text); - -if($action == "edit") -{ - if($sql->select("newsfeed", "*", "newsfeed_id=$id")) - { - $row = $sql->fetch(); - extract($row); // FIX - list($newsfeed_image, $newsfeed_showmenu, $newsfeed_showmain) = explode("::", $newsfeed_image); - } -} -else -{ - unset($newsfeed_showmenu, $newsfeed_showmain, $newsfeed_name, $newsfeed_url, $newsfeed_image, $newsfeed_description, $newsfeed_updateint, $newsfeed_active); -} - - $text = " -
\n - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
".LAN_NAME."".$frm->text('newsfeed_name', $newsfeed_name, '200')."
".LAN_URL."".$frm->text('newsfeed_url', $newsfeed_url, '250', 'size=xxlarge')."".NFLAN_10."
".NFLAN_11."".$frm->text('newsfeed_image', $newsfeed_image, '200') /* TODO imagepicker? */."".NFLAN_17."
".LAN_DESCRIPTION."".$frm->text('newsfeed_description', $newsfeed_description, '200')."".NFLAN_37."
".NFLAN_18."".$frm->number('newsfeed_updateint',($newsfeed_updateint ? $newsfeed_updateint : 3600),5)."".NFLAN_19."
".NFLAN_12.""; - $array = array(NFLAN_13,NFLAN_14,NFLAN_20,NFLAN_21); - $text .= - $frm->radio('newsfeed_active', $array, ($newsfeed_active ? $newsfeed_active : 0), true, NFLAN_22)." -
".NFLAN_45."".$frm->number('newsfeed_showmenu', $newsfeed_showmenu ,5)."".NFLAN_47."
".NFLAN_46."".$frm->number('newsfeed_showmain', $newsfeed_showmain ,5)."".NFLAN_47."
-
- ".$frm->admin_button(($action == "edit" ? "updateFeed" : "createFeed"),($action == "edit" ? LAN_UPDATE : LAN_CREATE),'update')." -
- ".($action == "edit" ? "" : "")." -
- "; - -$ns->tablerender(NFLAN_09, $mes->render() . $text); +require_once(e_ADMIN."auth.php"); +e107::getAdminUI()->runPage(); require_once(e_ADMIN."footer.php"); -?> \ No newline at end of file +exit; diff --git a/e107_plugins/newsfeed/newsfeed_functions.php b/e107_plugins/newsfeed/newsfeed_functions.php index ee4a79b89..69e90ba3c 100644 --- a/e107_plugins/newsfeed/newsfeed_functions.php +++ b/e107_plugins/newsfeed/newsfeed_functions.php @@ -47,9 +47,8 @@ class newsfeedClass var $useCache; // Set if cache is available // Constructor - function newsfeedClass() + function __construct() { - global $e107; $this->validFeedList = FALSE; $this->newsList = array(); $this->feedList = array(); @@ -57,7 +56,7 @@ class newsfeedClass $this->lastProcessed = 0; $this->truncateCount = 150; // Set a pref for these two later $this->truncateMore = '...'; - $this->useCache = $e107->ecache->UserCacheActive; // Have our own local copy - should be faster to access + $this->useCache = e107::getCache()->UserCacheActive; // Have our own local copy - should be faster to access } // Ensures the feed list is loaded - uses cache if available @@ -71,13 +70,8 @@ class newsfeedClass } if($this->useCache) // Cache enabled - try to read from that first { - - $eArrayStorage = e107::getArrayStorage(); - - global $e107; - - - if (!$force && $temp = $e107->ecache->retrieve(NEWSFEED_LIST_CACHE_TAG)) + + if (!$force && $temp = e107::getCache()->retrieve(NEWSFEED_LIST_CACHE_TAG)) { $this->feedList = e107::unserialize($temp); return; @@ -97,7 +91,7 @@ class newsfeedClass { $nfID = $row['newsfeed_id']; - if (isset($row['newsfeed_data'])) + if (!empty($row['newsfeed_data'])) { $this->newsList[$nfID]['newsfeed_data'] = $row['newsfeed_data']; // Pull out the actual news - might as well since we're here $this->newsList[$nfID]['newsfeed_timestamp'] = $row['newsfeed_timestamp']; @@ -110,8 +104,8 @@ class newsfeedClass $this->validFeedList = TRUE; } - if ($this->useCache) - { // Cache enabled - we need to save some updated info + if ($this->useCache) // Cache enabled - we need to save some updated info + { $temp = e107::serialize($this->feedList, FALSE); e107::getCache()->set(NEWSFEED_LIST_CACHE_TAG,$temp); } @@ -121,14 +115,13 @@ class newsfeedClass // Returns the info for a single feed - from cache or memory as appropriate. If time expired, updates the feed. function getFeed($feedID, $force = FALSE) { - global $e107, $admin_log; - $tp = e107::getParser(); $sql = e107::getDb(); - $eArrayStorage = e107::getArrayStorage(); $this->readFeedList(); // Make sure we've got the feed data. + // $force = true; + if (!isset($this->feedList[$feedID])) { if (NEWSFEED_DEBUG) echo "Invalid feed number: {$feedID}
"; @@ -140,14 +133,14 @@ class newsfeedClass $force = true; } - if ($force || !isset($this->newsList[$feedID]['newsfeed_data']) || !$this->newsList[$feedID]['newsfeed_data']) - { // No data already in memory - if ($force || !($this->newsList[$feedID]['newsfeed_data'] = $e107->ecache->retrieve(NEWSFEED_NEWS_CACHE_TAG.$feedID, $this->feedList[$feedID]['newsfeed_updateint']/60))) + if ($force || !isset($this->newsList[$feedID]['newsfeed_data']) || !$this->newsList[$feedID]['newsfeed_data']) // No data already in memory + { + if ($force || !($this->newsList[$feedID]['newsfeed_data'] = e107::getCache()->retrieve(NEWSFEED_NEWS_CACHE_TAG.$feedID, $this->feedList[$feedID]['newsfeed_updateint']/60))) { // Need to re-read from source - either no cached data yet, or cache expired if (NEWSFEED_DEBUG) { - $admin_log->e_log_event(10,debug_backtrace(),"DEBUG","Newsfeed update","Refresh item: ".$feedID,FALSE,LOG_TO_ROLLING); + e107::getLog()->e_log_event(10,debug_backtrace(),"DEBUG","Newsfeed update","Refresh item: ".$feedID,FALSE,LOG_TO_ROLLING); } require_once(e_HANDLER.'xml_class.php'); @@ -195,7 +188,7 @@ class newsfeedClass $dbData['newsfeed_description'] = $temp['newsfeed_description']; if ($this->useCache) { - $e107->ecache->clear(NEWSFEED_LIST_CACHE_TAG); // Clear the newsfeed cache so its re-read next time + e107::getCache()->clear(NEWSFEED_LIST_CACHE_TAG); // Clear the newsfeed cache so its re-read next time } } } @@ -206,10 +199,10 @@ class newsfeedClass } else { - $temp['newsfeed_image_link'] = ""; + $temp['newsfeed_image_link'] = !empty($newsfeed_image) ? "" : ''; } - $serializedArray = $eArrayStorage->WriteArray($temp, FALSE); + $serializedArray = e107::serialize($temp, false); $now = time(); $this->newsList[$feedID]['newsfeed_data'] = $serializedArray; @@ -217,17 +210,20 @@ class newsfeedClass if ($this->useCache) { - $e107->ecache->set(NEWSFEED_NEWS_CACHE_TAG.$feedID,$serializedArray); + e107::getCache()->set(NEWSFEED_NEWS_CACHE_TAG.$feedID, $serializedArray); } else { - $dbData['newsfeed_data'] =addslashes($serializedArray); + $dbData['newsfeed_data'] = $serializedArray; $dbData['newsfeed_timestamp'] = $now; } if (count($dbData)) // Only write the feed data to DB if not using cache. Write description if changed - { - if(FALSE === $sql->db_UpdateArray('newsfeed', $dbData, " WHERE newsfeed_id=".$feedID)) + { + + $dbData['WHERE'] = "newsfeed_id=".$feedID; + + if(FALSE === $sql->update('newsfeed', $dbData)) { if (NEWSFEED_DEBUG) echo NFLAN_48."

".var_dump($dbData); } @@ -254,8 +250,7 @@ class newsfeedClass { $tp = e107::getParser(); - $sql = e107::getDb(); - + global $NEWSFEED_MAIN_START, $NEWSFEED_MAIN, $NEWSFEED_MAIN_END; global $NEWSFEED_MENU_START, $NEWSFEED_MENU, $NEWSFEED_MENU_END; @@ -272,7 +267,12 @@ class newsfeedClass $this->readFeedList(); // Make sure we've got all the news feeds loaded /* get template */ - if (file_exists(THEME."newsfeed_menu_template.php")) + + if(file_exists(THEME."templates/newsfeed/newsfeed_menu_template.php")) //v2.x + { + include(THEME."templates/newsfeed/newsfeed_menu_template.php"); + } + elseif(file_exists(THEME."newsfeed_menu_template.php")) //v1.x { include(THEME."newsfeed_menu_template.php"); } @@ -281,6 +281,8 @@ class newsfeedClass include(e_PLUGIN."newsfeed/templates/newsfeed_menu_template.php"); } + $vars = array(); + foreach($this->feedList as $nfID => $feed) { if (($filter == 0) || ($filter == $feed['newsfeed_id'])) @@ -292,10 +294,10 @@ class newsfeedClass $numtoshow = intval($where == 'main' ? $newsfeed_showmain : $newsfeed_showmenu); $numtoshow = ($numtoshow > 0 ? $numtoshow : 999); - $FEEDNAME = "".$tp->toHtml($feed['newsfeed_name'],false,'TITLE').""; - $FEEDDESCRIPTION = $feed['newsfeed_description']; - $FEEDIMAGE = $rss['newsfeed_image_link']; - $FEEDLANGUAGE = $rss['channel']['language']; + $vars['FEEDNAME'] = "".$tp->toHtml($feed['newsfeed_name'],false,'TITLE').""; + $vars['FEEDDESCRIPTION'] = $feed['newsfeed_description']; + $vars['FEEDIMAGE'] = $rss['newsfeed_image_link']; + $vars['FEEDLANGUAGE'] = $rss['channel']['language']; if($rss['channel']['lastbuilddate']) { @@ -310,18 +312,18 @@ class newsfeedClass $pubbed = NFLAN_34; } - $FEEDLASTBUILDDATE = NFLAN_33.$pubbed; - $FEEDCOPYRIGHT = $tp -> toHTML(vartrue($rss['channel']['copyright']), FALSE); - $FEEDTITLE = "".vartrue($rss['channel']['title']).""; - $FEEDLINK = $rss['channel']['link']; + $vars['FEEDLASTBUILDDATE'] = NFLAN_33.$pubbed; + $vars['FEEDCOPYRIGHT'] = $tp -> toHTML(vartrue($rss['channel']['copyright']), FALSE); + $vars['FEEDTITLE'] = "".vartrue($rss['channel']['title']).""; + $vars['FEEDLINK'] = $rss['channel']['link']; if($feed['newsfeed_active'] == 2 or $feed['newsfeed_active'] == 3) { - $LINKTOMAIN = "".NFLAN_39.""; + $vars['LINKTOMAIN'] = "".NFLAN_39.""; } else { - $LINKTOMAIN = ""; + $vars['LINKTOMAIN'] = ""; } $data = ""; @@ -332,42 +334,43 @@ class newsfeedClass { $item = $rss['items'][$i]; - $FEEDITEMLINK = "".$tp -> toHTML($item['title'], FALSE)."\n"; - $FEEDITEMLINK = str_replace('&', '&', $FEEDITEMLINK); - $feeditemtext = preg_replace("#\[[a-z0-9=]+\]|\[\/[a-z]+\]|\{[A-Z_]+\}#si", "", strip_tags($item['description'])); - $FEEDITEMCREATOR = $tp -> toHTML(vartrue($item['author']), FALSE); + $vars['FEEDITEMLINK'] = "".$tp -> toHTML($item['title'], FALSE)."\n"; + $vars['FEEDITEMLINK'] = str_replace('&', '&', $vars['FEEDITEMLINK']); + $feeditemtext = preg_replace("#\[[a-z0-9=]+\]|\[\/[a-z]+\]|\{[A-Z_]+\}#si", "", strip_tags($item['description'])); + $vars['FEEDITEMCREATOR'] = $tp -> toHTML(vartrue($item['author']), FALSE); if ($where == 'main') { - if($NEWSFEED_COLLAPSE) + if(!empty($NEWSFEED_COLLAPSE)) { - $FEEDITEMLINK = "".$tp -> toHTML($item['title'], FALSE)." + $vars['FEEDITEMLINK'] = "".$tp -> toHTML($item['title'], FALSE)."
"; - $FEEDITEMTEXT = preg_replace("/[.*]/", "", $tp -> toHTML($item['description'], FALSE))." + + $vars['FEEDITEMTEXT'] = preg_replace("/[.*]/", "", $tp -> toHTML($item['description'], FALSE))."

".NFLAN_44."

"; } else { - $FEEDITEMLINK = "".$tp -> toHTML($item['title'], FALSE)."\n"; - $FEEDITEMLINK = str_replace('&', '&', $FEEDITEMLINK); - $feeditemtext = preg_replace("#\[[a-z0-9=]+\]|\[\/[a-z]+\]|\{[A-Z_]+\}#si", "", $item['description']); - $FEEDITEMTEXT = $tp -> toHTML($feeditemtext, FALSE)."\n"; + $vars['FEEDITEMLINK'] = "".$tp -> toHTML($item['title'], FALSE)."\n"; + $vars['FEEDITEMLINK'] = str_replace('&', '&', $vars['FEEDITEMLINK']); + $feeditemtext = preg_replace("#\[[a-z0-9=]+\]|\[\/[a-z]+\]|\{[A-Z_]+\}#si", "", $item['description']); + $vars['FEEDITEMTEXT'] = $tp -> toHTML($feeditemtext, FALSE)."\n"; } - $data .= preg_replace("/\{(.*?)\}/e", '$\1', $NEWSFEED_MAIN); + $data .= $tp->simpleParse( $NEWSFEED_MAIN, $vars); } else { if ($this->truncateCount) { - $FEEDITEMTEXT = $tp->text_truncate($feeditemtext, $this->truncateCount, $this->truncateMore); + $vars['FEEDITEMTEXT'] = $tp->text_truncate($feeditemtext, $this->truncateCount, $this->truncateMore); } else { - $FEEDITEMTEXT = ''; // Might just want title + $vars['FEEDITEMTEXT'] = ''; // Might just want title } - $data .= preg_replace("/\{(.*?)\}/e", '$\1', $NEWSFEED_MENU); + $data .= $tp->simpleParse($NEWSFEED_MENU, $vars); } $i++; } @@ -376,13 +379,15 @@ class newsfeedClass if ($where == 'main') { - $BACKLINK = "".NFLAN_31.""; - $text = preg_replace("/\{(.*?)\}/e", '$\1', $NEWSFEED_MAIN_START).$data.preg_replace("/\{(.*?)\}/e", '$\1', $NEWSFEED_MAIN_END); + $vars['BACKLINK'] = "".NFLAN_31.""; + $text = $tp->simpleParse($NEWSFEED_MAIN_START, $vars).$data.$tp->simpleParse( $NEWSFEED_MAIN_END, $vars); } else { - $text .= preg_replace("/\{(.*?)\}/e", '$\1', $NEWSFEED_MENU_START) . $data . preg_replace("/\{(.*?)\}/e", '$\1', $NEWSFEED_MENU_END); + $text .= $tp->simpleParse($NEWSFEED_MENU_START, $vars) . $data . $tp->simpleParse($NEWSFEED_MENU_END, $vars); } + + //TODO Move the $vars into their own shortcode class and change simpleParse to parseTemplate(); } if($which == 'all') @@ -391,7 +396,7 @@ class newsfeedClass } else { - $ret['title'] = $feed['newsfeed_name']." ".$NEWSFEED_MAIN_CAPTION; + $ret['title'] = $feed['newsfeed_name']." ".varset($NEWSFEED_MAIN_CAPTION); } $ret['text'] = $text; diff --git a/e107_plugins/poll/poll_class.php b/e107_plugins/poll/poll_class.php index ec4addeb5..014a255bb 100644 --- a/e107_plugins/poll/poll_class.php +++ b/e107_plugins/poll/poll_class.php @@ -888,6 +888,7 @@ class poll_shortcodes extends e_shortcode public $answerOption = array(); public $answerCount = 0; public $pollRenderType = null; // type + public $pollRenderMode = null; public $pollPreview = false; public $pollVoteTotal = 0; public $pollCommentTotal = 0; From 42191db50925312409a8d5d9f3b5f38fafa50f03 Mon Sep 17 00:00:00 2001 From: Cameron Date: Wed, 20 Apr 2016 17:37:46 -0700 Subject: [PATCH 03/34] Poll notice removal. --- e107_handlers/db_debug_class.php | 30 +++++++++++++++--------------- e107_plugins/poll/poll_class.php | 21 +++++++++++++++------ 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/e107_handlers/db_debug_class.php b/e107_handlers/db_debug_class.php index 94b31c0b1..73280d6aa 100644 --- a/e107_handlers/db_debug_class.php +++ b/e107_handlers/db_debug_class.php @@ -72,25 +72,22 @@ class e107_db_debug { $this->ShowIf('Shortcodes / BBCode',$this->Show_SC_BB()); $this->ShowIf('Paths', $this->Show_PATH()); $this->ShowIf('Deprecated Function Usage', $this->Show_DEPRECATED()); + if(E107_DBG_INCLUDES) { $this->aIncList = get_included_files(); - } + } + $this->ShowIf('Included Files: '.count($this->aIncList), $this->Show_Includes()); } function ShowIf($title,$str) { - global $ns,$style; - $style='debug'; - - if (!isset($ns)) { - echo "Why did ns go away?
"; - $ns = new e107table; - } - - if (strlen($str)) { - $ns->tablerender($title, $str); + + if(!empty($str)) + { + e107::getRender()->setStyle('debug'); + e107::getRender()->tablerender($title, $str); } } @@ -683,8 +680,10 @@ class e107_db_debug { } } - function Show_Log(){ - if (!E107_DBG_BASIC || !count($this->aLog)){ + function Show_Log() + { + if (empty($this->aLog)) + { return FALSE; } // @@ -697,8 +696,9 @@ class e107_db_debug { foreach ($this->aLog as $curLog) { - if (!$bRowHeaders) { - $bRowHeaders=TRUE; + if (!$bRowHeaders) + { + $bRowHeaders = true; $text .= "".implode("", array_keys($curLog))."\n"; } diff --git a/e107_plugins/poll/poll_class.php b/e107_plugins/poll/poll_class.php index 014a255bb..ceaf9c93f 100644 --- a/e107_plugins/poll/poll_class.php +++ b/e107_plugins/poll/poll_class.php @@ -41,14 +41,23 @@ class poll function remove_poll_cookies() { $arr_polls_cookies = array(); - foreach($_COOKIE as $cookie_name => $cookie_val) - { // Collect poll cookies - list($str, $int) = explode('_', $cookie_name, 2); - if (($str == 'poll') && is_numeric($int)) - { // Yes, its poll's cookie - $arr_polls_cookies[] = $int; + if(!empty($_COOKIE)) + { + foreach($_COOKIE as $cookie_name => $cookie_val) + { // Collect poll cookies + + if(substr($cookie_name,0,5) == 'poll_') + { + // e107::getDebug()->log("Poll: ".$cookie_name); + list($str, $int) = explode('_', $cookie_name, 2); + if (($str == 'poll') && is_numeric($int)) + { // Yes, its poll's cookie + $arr_polls_cookies[] = $int; + } + } } } + if (count($arr_polls_cookies) > 1) { // Remove all except first (assumption: there is always only one active poll) rsort($arr_polls_cookies); From f6026fe1ec2441bc61088e9e96d0bc926757c9e3 Mon Sep 17 00:00:00 2001 From: Cameron Date: Wed, 20 Apr 2016 18:08:52 -0700 Subject: [PATCH 04/34] Added filter by template to News admin area list. --- e107_handlers/admin_ui.php | 14 +++++++++++--- e107_plugins/poll/poll_class.php | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/e107_handlers/admin_ui.php b/e107_handlers/admin_ui.php index a88237ac2..825689589 100644 --- a/e107_handlers/admin_ui.php +++ b/e107_handlers/admin_ui.php @@ -3693,6 +3693,7 @@ class e_admin_controller_ui extends e_admin_controller $tableSJoinArr = array(); // FROM for join tables $filter = array(); + $searchQuery = $tp->toDB($request->getQuery('searchquery', '')); $searchFilter = $this->_parseFilterRequest($request->getQuery('filter_options', '')); @@ -3703,7 +3704,7 @@ class e_admin_controller_ui extends e_admin_controller if($searchFilter && is_array($searchFilter)) { - + list($filterField, $filterValue) = $searchFilter; if($filterField && $filterValue !== '' && isset($this->fields[$filterField])) @@ -3711,7 +3712,7 @@ class e_admin_controller_ui extends e_admin_controller $_dataType = $this->fields[$filterField]['data']; $_fieldType = $this->fields[$filterField]['type']; - if($_fieldType === 'comma' || $_fieldType === 'checkboxes' || $_fieldType == 'userclasses') + if($_fieldType === 'comma' || $_fieldType === 'checkboxes' || $_fieldType == 'userclasses' || ($_fieldType == 'dropdown' && !empty($this->fields[$filterField]['writeParms']['multiple']))) { $_dataType = 'set'; } @@ -6328,6 +6329,9 @@ class e_admin_form_ui extends e_form case 'dropdown': // use the array $parm; + + + if(!empty($parms['optArray'])) { $fopts = $parms; @@ -6339,12 +6343,16 @@ class e_admin_form_ui extends e_form if(!is_array(varset($parms['__options']))) parse_str($parms['__options'], $parms['__options']); $opts = $parms['__options']; - if(vartrue($opts['multiple'])) + if(vartrue($opts['multiple']) && $type == 'batch') { // no batch support for multiple, should have some for filters soon continue; } + unset($parms['__options']); //remove element options if any + + + foreach($parms as $k => $name) { $option[$key.'__'.$k] = $name; diff --git a/e107_plugins/poll/poll_class.php b/e107_plugins/poll/poll_class.php index ceaf9c93f..c725f412e 100644 --- a/e107_plugins/poll/poll_class.php +++ b/e107_plugins/poll/poll_class.php @@ -57,7 +57,7 @@ class poll } } } - + if (count($arr_polls_cookies) > 1) { // Remove all except first (assumption: there is always only one active poll) rsort($arr_polls_cookies); From 12151013ea35ed1c112d1c6c1a5fdefdf593387d Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 21 Apr 2016 09:22:47 -0700 Subject: [PATCH 05/34] Config update --- .codeclimate.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.codeclimate.yml b/.codeclimate.yml index 8bbb412af..e7226ac03 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -2,8 +2,11 @@ engines: csslint: enabled: false - duplication: + duplication: enabled: true + checks: + Identical code: + enabled: false config: languages: - javascript From 6c4c5bd6e3f7014c56b9159c429aa8a87f9b020f Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 21 Apr 2016 10:39:00 -0700 Subject: [PATCH 06/34] Newsfeed Plugin: Added SEF URLs. PHP7 compatibility fix. --- e107_plugins/newsfeed/admin_config.php | 8 ++- e107_plugins/newsfeed/e_url.php | 50 +++++++++++++++++++ e107_plugins/newsfeed/newsfeed.php | 41 ++++++++++++--- e107_plugins/newsfeed/newsfeed_functions.php | 10 ++-- e107_plugins/newsfeed/plugin.xml | 4 +- .../newsfeed/templates/newsfeed_template.php | 8 +-- 6 files changed, 99 insertions(+), 22 deletions(-) create mode 100644 e107_plugins/newsfeed/e_url.php diff --git a/e107_plugins/newsfeed/admin_config.php b/e107_plugins/newsfeed/admin_config.php index 050931e2c..f3d142b8b 100644 --- a/e107_plugins/newsfeed/admin_config.php +++ b/e107_plugins/newsfeed/admin_config.php @@ -81,7 +81,7 @@ class newsfeed_ui extends e_admin_ui 'newsfeed_id' => array ( 'title' => LAN_ID, 'data' => 'int', 'width' => '5%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), 'newsfeed_name' => array ( 'title' => LAN_TITLE, 'type' => 'text', 'data' => 'str', 'required'=>true, 'width' => 'auto', 'inline' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), 'newsfeed_url' => array ( 'title' => LAN_URL, 'type' => 'url', 'data' => 'str', 'required'=>true, 'inline'=>true, 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => array('size'=>'xxlarge'), 'class' => 'left', 'thclass' => 'left', ), - 'newsfeed_data' => array ( 'title' => 'Data', 'type' => 'hidden', 'data' => false, 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), + 'newsfeed_data' => array ( 'title' => 'Data', 'type' => 'hidden', 'noedit'=>true, 'data' => false, 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), 'newsfeed_timestamp' => array ( 'title' => 'Timestamp', 'type' => 'hidden', 'data' => 'int', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), 'newsfeed_description' => array ( 'title' => LAN_DESCRIPTION, 'type' => 'textarea', 'data' => 'str', 'width' => '40%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), 'newsfeed_image' => array ( 'title' => NFLAN_11, 'type' => 'method', 'data' => 'str', 'width' => 'auto', 'help' => LAN_OPTIONAL, 'readParms' => 'thumb=80x80', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), @@ -124,6 +124,8 @@ class newsfeed_ui extends e_admin_ui $new_data['newsfeed_image'] = e107::getParser()->toDB($new_data['newsfeed_image'])."::".intval($new_data['newsfeed_showmenu'])."::".intval($new_data['newsfeed_showmain']); } + $new_data['newsfeed_timestamp'] = 0; + return $new_data; } @@ -147,8 +149,12 @@ class newsfeed_ui extends e_admin_ui if(isset($new_data['newsfeed_showmenu'])) { $new_data['newsfeed_image'] = e107::getParser()->toDB($new_data['newsfeed_image'])."::".intval($new_data['newsfeed_showmenu'])."::".intval($new_data['newsfeed_showmain']); + } + $new_data['newsfeed_timestamp'] = 0; // reset so the feed data refreshes. + + return $new_data; } diff --git a/e107_plugins/newsfeed/e_url.php b/e107_plugins/newsfeed/e_url.php new file mode 100644 index 000000000..c36f86e88 --- /dev/null +++ b/e107_plugins/newsfeed/e_url.php @@ -0,0 +1,50 @@ + 'newsfeed', + 'regex' => '^{alias}/(\d*)/(.*)', // matched against url, and if true, redirected to 'redirect' below. + 'sef' => '{alias}/{newsfeed_id}/{newsfeed_sef}', // used by e107::url(); to create a url from the db table. + 'redirect' => '{e_PLUGIN}newsfeed/newsfeed.php?id=$1', // file-path of what to load when the regex returns true. + + ); + + $config['index'] = array( + 'alias' => 'newsfeed', + 'regex' => '^{alias}/?', // matched against url, and if true, redirected to 'redirect' below. + 'sef' => '{alias}', // used by e107::url(); to create a url from the db table. + 'redirect' => '{e_PLUGIN}newsfeed/newsfeed.php', // file-path of what to load when the regex returns true. + + ); + + return $config; + } + + + +} \ No newline at end of file diff --git a/e107_plugins/newsfeed/newsfeed.php b/e107_plugins/newsfeed/newsfeed.php index aec03c609..543af12e3 100644 --- a/e107_plugins/newsfeed/newsfeed.php +++ b/e107_plugins/newsfeed/newsfeed.php @@ -35,16 +35,30 @@ if (!is_object($newsFeed)) { $newsFeed = new newsfeedClass; } + +e107::css('inline', " + +.newsfeed ul { max-width:100% } +.newsfeed img { max-width:100% } + + +"); + + require_once(HEADERF); /* get template */ -if (file_exists(THEME."newsfeed_template.php")) +if(file_exists(THEME."templates/newsfeed/newsfeed_template.php")) { - require_once(THEME."newsfeed_template.php"); + include(THEME."templates/newsfeed/newsfeed_template.php"); +} +elseif (file_exists(THEME."newsfeed_template.php")) +{ + include(THEME."newsfeed_template.php"); } else if(!varset($NEWSFEED_LIST_START, FALSE)) { - require_once(e_PLUGIN."newsfeed/templates/newsfeed_template.php"); + include(e_PLUGIN."newsfeed/templates/newsfeed_template.php"); } $action = FALSE; @@ -55,12 +69,18 @@ if(e_QUERY) $id = intval(varset($qs[1], 0)); } +if(!empty($_GET['id'])) //v2.x +{ + $id = intval($_GET['id']); + $action = 'show'; +} + if($action == "show") { /* 'show' action - show feed */ $data = $newsFeed->newsfeedInfo($id == 0 ? 'all' : $id, 'main'); - $ns->tablerender($data['title'], $data['text']); + $ns->tablerender($data['title'], $data['text']); require_once(FOOTERF); exit; } @@ -68,6 +88,7 @@ if($action == "show") /* no action - display feed list ... */ $newsFeed->readFeedList(); +$vars = array(); if (count($newsFeed->feedList)) { $data = ""; @@ -75,10 +96,15 @@ if (count($newsFeed->feedList)) { if (($feed['newsfeed_active'] == 2) || ($feed['newsfeed_active'] == 3)) { - $FEEDNAME = "{$feed['newsfeed_name']}"; - $FEEDDESCRIPTION = ((!$feed['newsfeed_description'] || $feed['newsfeed_description'] == "default") ? " " : $feed['newsfeed_description']); + + $feed['newsfeed_sef'] = eHelper::title2sef($feed['newsfeed_name'], 'dashl'); + + $url = e107::url('newsfeed', 'source', $feed); // e_SELF."?show.{$feed['newsfeed_id']} + + $vars['FEEDNAME'] = "{$feed['newsfeed_name']}"; + $vars['FEEDDESCRIPTION'] = ((!$feed['newsfeed_description'] || $feed['newsfeed_description'] == "default") ? " " : $feed['newsfeed_description']); // $FEEDIMAGE = $feed['newsfeed_image']; // This needs splitting up. Not used ATM anyway, so disable for now - $data .= preg_replace("/\{(.*?)\}/e", '$\1', $NEWSFEED_LIST); + $data .= $tp->simpleParse($NEWSFEED_LIST, $vars); } } } @@ -87,4 +113,3 @@ $text = $NEWSFEED_LIST_START . vartrue($data) . $NEWSFEED_LIST_END; $ns->tablerender(NFLAN_29, $text); require_once(FOOTERF); -?> diff --git a/e107_plugins/newsfeed/newsfeed_functions.php b/e107_plugins/newsfeed/newsfeed_functions.php index 69e90ba3c..5132fbd86 100644 --- a/e107_plugins/newsfeed/newsfeed_functions.php +++ b/e107_plugins/newsfeed/newsfeed_functions.php @@ -120,20 +120,18 @@ class newsfeedClass $this->readFeedList(); // Make sure we've got the feed data. - // $force = true; - if (!isset($this->feedList[$feedID])) { if (NEWSFEED_DEBUG) echo "Invalid feed number: {$feedID}
"; return FALSE; } - - if(strpos($this->newsList[$feedID]['newsfeed_data'],'MagpieRSS')) //BC Fix to update newsfeed_data from v1 to v2 spec. + + if(empty($this->newsList[$feedID]['newsfeed_timestamp']) || empty($this->newsList[$feedID]['newsfeed_data']) || strpos($this->newsList[$feedID]['newsfeed_data'],'MagpieRSS')) //BC Fix to update newsfeed_data from v1 to v2 spec. { $force = true; } - - if ($force || !isset($this->newsList[$feedID]['newsfeed_data']) || !$this->newsList[$feedID]['newsfeed_data']) // No data already in memory + + if($force) // No data already in memory { if ($force || !($this->newsList[$feedID]['newsfeed_data'] = e107::getCache()->retrieve(NEWSFEED_NEWS_CACHE_TAG.$feedID, $this->feedList[$feedID]['newsfeed_updateint']/60))) { // Need to re-read from source - either no cached data yet, or cache expired diff --git a/e107_plugins/newsfeed/plugin.xml b/e107_plugins/newsfeed/plugin.xml index 9c2fec8fd..15ae2ffd9 100644 --- a/e107_plugins/newsfeed/plugin.xml +++ b/e107_plugins/newsfeed/plugin.xml @@ -8,8 +8,6 @@ Configure Newsfeeds - Newsfeeds + LAN_PLUGIN_NEWSFEEDS_NAME - - \ No newline at end of file diff --git a/e107_plugins/newsfeed/templates/newsfeed_template.php b/e107_plugins/newsfeed/templates/newsfeed_template.php index 12c91a9e3..585f4e66b 100644 --- a/e107_plugins/newsfeed/templates/newsfeed_template.php +++ b/e107_plugins/newsfeed/templates/newsfeed_template.php @@ -20,7 +20,7 @@ if (!defined('e107_INIT')) { exit; } $NEWSFEED_MAIN_CAPTION = NFLAN_38; $NEWSFEED_LIST_START = " -\n"; +
\n"; $NEWSFEED_LIST = " @@ -32,16 +32,16 @@ $NEWSFEED_LIST_END = "
\n"; $NEWSFEED_MAIN_START = " - +
- +\n"; - $description = array(1=>'Bbcode',2=>'Shortcode',3=>'Wrapper'); - $style = array(1 => 'label-info', 2=>'label-primary', 3=>'label-warning'); + $description = array(1=>'Bbcode',2=>'Shortcode',3=>'Wrapper', 4=>'Shortcode Override'); + $style = array(1 => 'label-info', 2=>'label-primary', 3=>'label-warning', 'label-danger'); foreach($this -> scbbcodes as $codes) { diff --git a/e107_handlers/shortcode_handler.php b/e107_handlers/shortcode_handler.php index 064e3ab88..cc27b5d87 100644 --- a/e107_handlers/shortcode_handler.php +++ b/e107_handlers/shortcode_handler.php @@ -70,6 +70,7 @@ class e_parse_shortcode protected $scOverride = array(); // Array of codes found in override/shortcodes dir protected $scBatchOverride = array(); // Array of codes found in override/shortcodes/batch dir protected $ignoreCodes = array(); // Shortcodes to be ignored and remain unchanged. (ie. {THEME}, {e_PLUGIN} etc. ) + protected $addonOverride = array(); // Overrides coming from e_shortcode.php /** * @var e_vars */ @@ -161,7 +162,7 @@ class e_parse_shortcode else { $codes = strtoupper($codes); - if ((!$this->isRegistered($code) || $force == true) && !$this->isOverride($code)) + if ((!$this->isRegistered($codes) || $force == true) && !$this->isOverride($codes)) { $this->registered_codes[$codes] = array('type' => 'func', 'path' => $path, 'function' => $classFunc); } @@ -245,12 +246,29 @@ class e_parse_shortcode if (class_exists($class, false) && ($force || !$this->isScClass($class))) { $this->scClasses[$class] = new $class(); + if(method_exists($this->scClasses[$class], 'init')) { $this->scClasses[$class]->init(); } + + if(!empty($this->scClasses[$class]->override)) + { + $methods = get_class_methods($class); + foreach($methods as $meth) + { + if(substr($meth,0,3) == 'sc_') + { + $this->addonOverride[$meth] = $class; + + + } + } + } + return $this->scClasses[$class]; } + return null; } @@ -754,6 +772,8 @@ class e_parse_shortcode $this->addedCodes = &$extraCodes; + + // e107::getDebug()->log("Codes".print_a($this->addedCodes,true)); // TEMPLATEID_WRAPPER support - see contact template // must be registered in e_shortcode object (batch) via () method before parsing @@ -918,15 +938,26 @@ class e_parse_shortcode $_path = ''; $ret = ''; $_method = 'sc_'.strtolower($code); - if (is_object($this->addedCodes) && method_exists($this->addedCodes, $_method)) //It is class-based batch shortcode. Class already loaded; call the method + + // Display e_shortcode.php override info. + if((E107_DBG_BBSC || E107_DBG_SC) && isset($this->addonOverride[$_method]) && is_object($this->addedCodes) && method_exists($this->addedCodes, $_method)) + { + $debugArr = array('class_original'=>get_class($this->addedCodes), 'class_override'=>$this->addonOverride[$_method], 'function'=>$_method); + e107::getDebug()->logCode(4, $code, null, print_a($debugArr,true)); + } + + + if (!isset($this->addonOverride[$_method]) && is_object($this->addedCodes) && method_exists($this->addedCodes, $_method)) //It is class-based batch shortcode. Class already loaded; call the method { $ret = $this->addedCodes->$_method($parm, $sc_mode); + if(E107_DBG_BBSC || E107_DBG_SC || E107_DBG_TIMEDETAILS) { $_class = get_class($this->addedCodes); // "(class loaded)"; // debug. $_function = $_method; $_path = "(already loaded)"; + } } elseif (is_array($this->addedCodes) && array_key_exists($code, $this->addedCodes)) // Its array-based shortcode. Load the code for evaluation later. @@ -1308,7 +1339,8 @@ class e_shortcode protected $mode = 'view'; // or edit. Used within shortcodes for form elements vs values only. protected $wrapper = null; // holds template/key value of the currently used wrapper (if any) - see contact_template.php for an example. - + + protected $override = false; /** * Storage for shortcode values * @var e_vars @@ -1327,7 +1359,8 @@ class e_shortcode * Startup code for child class */ public function init() {} - + + /** * Sets wrapper id (to be retrieved from the registry while parsing) * Example e107::getScBatch('contact')->wrapper('contact/form'); diff --git a/e107_plugins/_blank/e_shortcode.php b/e107_plugins/_blank/e_shortcode.php index 659f07910..bb30a2f43 100644 --- a/e107_plugins/_blank/e_shortcode.php +++ b/e107_plugins/_blank/e_shortcode.php @@ -15,6 +15,7 @@ if(!defined('e107_INIT')) class _blank_shortcodes extends e_shortcode { + public $override = false; // when set to true, existing core/plugin shortcodes matching methods below will be overridden. // Example: {_BLANK_CUSTOM} shortcode - available site-wide. function sc__blank_custom($parm = null) // Naming: "sc_" + [plugin-directory] + '_uniquename' From 0b78deb22a52c937552222b64ff6c6f5efc58759 Mon Sep 17 00:00:00 2001 From: Miroslav Yovchev Date: Sat, 23 Apr 2016 00:29:14 +0300 Subject: [PATCH 16/34] More strict user fields validation --- e107_handlers/user_handler.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e107_handlers/user_handler.php b/e107_handlers/user_handler.php index ec0f9c112..ecb41581a 100644 --- a/e107_handlers/user_handler.php +++ b/e107_handlers/user_handler.php @@ -90,8 +90,8 @@ class UserHandler $this->userVettingInfo = array( 'user_name' => array('niceName'=> LAN_USER_01, 'fieldType' => 'string', 'vetMethod' => '1,2', 'vetParam' => 'signup_disallow_text', 'srcName' => 'username', 'stripTags' => TRUE, 'stripChars' => '/ |\#|\=|\$/', 'fixedBlock' => 'anonymous', 'minLength' => 2, 'maxLength' => varset($pref['displayname_maxlength'],15)), // Display name 'user_loginname' => array('niceName'=> LAN_USER_02, 'fieldType' => 'string', 'vetMethod' => '1', 'vetParam' => '', 'srcName' => 'loginname', 'stripTags' => TRUE, 'stripChars' => '#[^a-z0-9_\.]#i', 'minLength' => 2, 'maxLength' => varset($pref['loginname_maxlength'],30)), // User name - 'user_login' => array('niceName'=> LAN_USER_03, 'fieldType' => 'string', 'vetMethod' => '0', 'vetParam' => '', 'srcName' => 'realname', 'dbClean' => 'toDB'), // Real name (no real vetting) - 'user_customtitle' => array('niceName'=> LAN_USER_04, 'fieldType' => 'string', 'vetMethod' => '0', 'vetParam' => '', 'srcName' => 'customtitle', 'dbClean' => 'toDB', 'enablePref' => 'signup_option_customtitle'), // No real vetting + 'user_login' => array('niceName'=> LAN_USER_03, 'fieldType' => 'string', 'vetMethod' => '0', 'vetParam' => '', 'srcName' => 'realname', 'dbClean' => 'toDB', 'stripTags' => TRUE, 'stripChars' => '#<|>#i'), // Real name (no real vetting) + 'user_customtitle' => array('niceName'=> LAN_USER_04, 'fieldType' => 'string', 'vetMethod' => '0', 'vetParam' => '', 'srcName' => 'customtitle', 'dbClean' => 'toDB', 'enablePref' => 'signup_option_customtitle', 'stripTags' => TRUE, 'stripChars' => '#<|>#i'), // No real vetting 'user_password' => array('niceName'=> LAN_PASSWORD, 'fieldType' => 'string', 'vetMethod' => '0', 'vetParam' => '', 'srcName' => 'password1', 'dataType' => 2, 'minLength' => varset($pref['signup_pass_len'],1)), 'user_sess' => array('niceName'=> LAN_USER_06, 'fieldType' => 'string', 'vetMethod' => '0', 'vetParam' => '', 'stripChars' => "#\"|'|(|)#", 'dbClean' => 'image', 'imagePath' => e_AVATAR_UPLOAD, 'maxHeight' => varset($pref['im_height'], 100), 'maxWidth' => varset($pref['im_width'], 120)), // Photo 'user_image' => array('niceName'=> LAN_USER_07, 'fieldType' => 'string', 'vetMethod' => '0', 'vetParam' => '', 'srcName' => 'image', 'stripChars' => "#\"|'|(|)#", 'dbClean' => 'avatar'), //, 'maxHeight' => varset($pref['im_height'], 100), 'maxWidth' => varset($pref['im_width'], 120) resized on-the-fly // Avatar From 3c0f501e43c99fa59bb5f8f923f151eaf5644367 Mon Sep 17 00:00:00 2001 From: Cameron Date: Fri, 22 Apr 2016 16:10:18 -0700 Subject: [PATCH 17/34] Extra bootstrap styles added to default mail template. Precautions for legacy sitebutton resize. PM notify template clean up. --- e107_admin/banlist.php | 6 ++-- e107_admin/eurl.php | 8 +++--- e107_core/templates/email_template.php | 38 ++++++++++++++++++++++++-- e107_handlers/mail.php | 28 ++++++++++++------- e107_handlers/media_class.php | 5 ++++ e107_plugins/pm/languages/English.php | 2 ++ e107_plugins/pm/pm_class.php | 3 +- e107_plugins/pm/pm_template.php | 9 +++--- 8 files changed, 74 insertions(+), 25 deletions(-) diff --git a/e107_admin/banlist.php b/e107_admin/banlist.php index 24ab51199..8271461c0 100644 --- a/e107_admin/banlist.php +++ b/e107_admin/banlist.php @@ -269,7 +269,7 @@ class banlist_ui extends e_admin_ui - public function timesPage() + protected function timesPage() { if (!getperms('0')) { @@ -349,12 +349,12 @@ class banlist_ui extends e_admin_ui } - public function optionsPage() + protected function optionsPage() { //FIXME Put Options code in here. } - public function banlogPage() + protected function banlogPage() { //FIXME Put LogPage code in here. } diff --git a/e107_admin/eurl.php b/e107_admin/eurl.php index 420d01d77..dac7eae5f 100644 --- a/e107_admin/eurl.php +++ b/e107_admin/eurl.php @@ -204,7 +204,7 @@ class eurl_admin_ui extends e_admin_controller_ui } //TODO Checkbox for each plugin to enable/disable - public function simplePage() + protected function simplePage() { // $this->addTitle("Simple Redirects"); $eUrl =e107::getAddonConfig('e_url'); @@ -320,7 +320,7 @@ class eurl_admin_ui extends e_admin_controller_ui } } - public function SettingsPage() + protected function SettingsPage() { //$this->addTitle(LAN_EURL_NAME_SETTINGS); return $this->getUI()->urlSettings(); @@ -356,7 +356,7 @@ class eurl_admin_ui extends e_admin_controller_ui } } - public function AliasPage() + protected function AliasPage() { // $this->addTitle(LAN_EURL_NAME_ALIASES); @@ -411,7 +411,7 @@ class eurl_admin_ui extends e_admin_controller_ui } } - public function ConfigPage() + protected function ConfigPage() { // $this->addTitle(LAN_EURL_NAME_CONFIG); $active = e107::getPref('url_config'); diff --git a/e107_core/templates/email_template.php b/e107_core/templates/email_template.php index 20bb708d8..2b969d23f 100644 --- a/e107_core/templates/email_template.php +++ b/e107_core/templates/email_template.php @@ -112,6 +112,8 @@ $EMAIL_TEMPLATE['default']['header'] = " @@ -146,7 +180,7 @@ $EMAIL_TEMPLATE['default']['body'] = "{BODY}
{MEDIA1}{MEDIA2}{MEDIA3}{MED $EMAIL_TEMPLATE['default']['footer'] = "

{FEEDIMAGE} {FEEDTITLE}

{FEEDIMAGE} {FEEDTITLE}

    \n"; $NEWSFEED_MAIN = " -
  • {FEEDITEMLINK} {FEEDITEMCREATOR}
    {FEEDITEMTEXT}

  • \n"; +
  • {FEEDITEMLINK}

    {FEEDITEMCREATOR}
    {FEEDITEMTEXT}
  • \n"; $NEWSFEED_MAIN_END = " From 7487f9e919912583501c7cced811cc9f46d30fa4 Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 21 Apr 2016 10:46:57 -0700 Subject: [PATCH 07/34] Newsfeed admin area configuration fix. --- e107_plugins/newsfeed/admin_config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e107_plugins/newsfeed/admin_config.php b/e107_plugins/newsfeed/admin_config.php index f3d142b8b..98b3e9669 100644 --- a/e107_plugins/newsfeed/admin_config.php +++ b/e107_plugins/newsfeed/admin_config.php @@ -81,7 +81,7 @@ class newsfeed_ui extends e_admin_ui 'newsfeed_id' => array ( 'title' => LAN_ID, 'data' => 'int', 'width' => '5%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), 'newsfeed_name' => array ( 'title' => LAN_TITLE, 'type' => 'text', 'data' => 'str', 'required'=>true, 'width' => 'auto', 'inline' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), 'newsfeed_url' => array ( 'title' => LAN_URL, 'type' => 'url', 'data' => 'str', 'required'=>true, 'inline'=>true, 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => array('size'=>'xxlarge'), 'class' => 'left', 'thclass' => 'left', ), - 'newsfeed_data' => array ( 'title' => 'Data', 'type' => 'hidden', 'noedit'=>true, 'data' => false, 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), + 'newsfeed_data' => array ( 'title' => 'Data', 'type' => null, 'data' => false, 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), 'newsfeed_timestamp' => array ( 'title' => 'Timestamp', 'type' => 'hidden', 'data' => 'int', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), 'newsfeed_description' => array ( 'title' => LAN_DESCRIPTION, 'type' => 'textarea', 'data' => 'str', 'width' => '40%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), 'newsfeed_image' => array ( 'title' => NFLAN_11, 'type' => 'method', 'data' => 'str', 'width' => 'auto', 'help' => LAN_OPTIONAL, 'readParms' => 'thumb=80x80', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), From 6a91e5abfbb22292415ec9b5a32227dc162fb936 Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 21 Apr 2016 11:55:54 -0700 Subject: [PATCH 08/34] Config update --- .codeclimate.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.codeclimate.yml b/.codeclimate.yml index e7226ac03..039d8b81e 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -7,6 +7,8 @@ engines: checks: Identical code: enabled: false + Design/TooManyPublicMethods: + enabled: false config: languages: - javascript From fd4c707fce42b13016473267099bb17bf878c05f Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 21 Apr 2016 12:04:09 -0700 Subject: [PATCH 09/34] PHP7 Warnings Fix - requires testing. --- e107_handlers/pref_class.php | 2 +- e107_handlers/user_model.php | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/e107_handlers/pref_class.php b/e107_handlers/pref_class.php index 0626a061a..60215be4a 100644 --- a/e107_handlers/pref_class.php +++ b/e107_handlers/pref_class.php @@ -440,7 +440,7 @@ class e_pref extends e_front_model * @param boolean $force * @return e_pref */ - public function load($force = false) + public function load($id=null, $force = false) { global $pref; if($force || !$this->hasData()) diff --git a/e107_handlers/user_model.php b/e107_handlers/user_model.php index 7f565c192..f16a816f6 100644 --- a/e107_handlers/user_model.php +++ b/e107_handlers/user_model.php @@ -952,7 +952,7 @@ class e_user_model extends e_admin_model if(false !== $ret && null !== $this->_extended_model) // don't load extended fields if not already used { - $ret_e = $this->_extended_model->save($force, $session); + $ret_e = $this->_extended_model->save(true, $force, $session); if(false !== $ret_e) { return ($ret_e + $ret); @@ -2290,7 +2290,7 @@ class e_user_extended_model extends e_admin_model * @see e_model#load($id, $force) * @return e_user_extended_model */ - public function load($force = false) + public function load($id=null, $force = false) { if ($this->getId() && !$force) return $this; @@ -2434,7 +2434,7 @@ class e_user_extended_model extends e_admin_model * Build data types and rules on the fly and save * @see e_front_model::save() */ - public function save($force = false, $session = false) + public function save($from_post = true, $force = false, $session = false) { // when not loaded from db, see the construct check if(!$this->getId()) @@ -2730,7 +2730,7 @@ class e_user_pref extends e_front_model * @param boolean $force * @return e_user_pref */ - public function load($force = false) + public function load($id = null, $force = false) { if($force || !$this->hasData()) { @@ -2785,13 +2785,13 @@ class e_user_pref extends e_front_model } /** - * Remove & apply user prefeferences, optionally - save to DB + * Remove & apply user preferences, optionally - save to DB * @return boolean success */ - public function delete($save = false) + public function delete($ids, $destroy = true, $session_messages = false) // replaced $save = false for PHP7 fix. { $this->removeData()->apply(); - if($save) return $this->save(); + // if($save) return $this->save(); //FIXME adjust within the context of the variables in the method. return true; } } From 798d1d4c9109fa0b5498d2e601d0da9c6b34ddf2 Mon Sep 17 00:00:00 2001 From: Cameron Date: Fri, 22 Apr 2016 08:45:11 -0700 Subject: [PATCH 10/34] Corrected Forum event data. --- e107_plugins/forum/forum_class.php | 23 ++++++++++++++----- .../forum/templates/forum_post_template.php | 5 ++++ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/e107_plugins/forum/forum_class.php b/e107_plugins/forum/forum_class.php index 85a7bd00a..cc6e4fdb3 100644 --- a/e107_plugins/forum/forum_class.php +++ b/e107_plugins/forum/forum_class.php @@ -710,8 +710,8 @@ class e107forum $info['data']['post_id'] = $postId; // Append last inserted ID to data array for passing it to event callbacks. - - e107::getEvent()->trigger('user_forum_post_created', $info); + $triggerData = $info['data']; + e107::getEvent()->trigger('user_forum_post_created', $triggerData); ob_start(); // precaution so json doesn't break. $this->trackEmail($info['data']); @@ -757,8 +757,8 @@ class e107forum e107::getMessage()->addDebug("Updating Thread with: ".print_a($info,true)); - - e107::getEvent()->trigger('user_forum_topic_updated', $info); + $triggerData = $info['data']; + e107::getEvent()->trigger('user_forum_topic_updated', $triggerData); } if(($result || !$updateThread) && $updateForum) @@ -824,7 +824,7 @@ class e107forum if($newThreadId = e107::getDb()->insert('forum_thread', $info)) { - e107::getEvent()->trigger('user_forum_topic_created', $info); + $postInfo['post_thread'] = $newThreadId; if(!$newPostId = $this->postAdd($postInfo, false)) @@ -835,6 +835,13 @@ class e107forum $this->threadMarkAsRead($newThreadId); $threadInfo['thread_sef'] = $this->getThreadsef($threadInfo); + $triggerData = $info['data']; + $triggerData['thread_id'] = $newThreadId; + $triggerData['thread_sef'] = $threadInfo['thread_sef']; + $triggerData['post_id'] = $newPostId; + + e107::getEvent()->trigger('user_forum_topic_created', $triggerData); + return array('postid' => $newPostId, 'threadid' => $newThreadId, 'threadsef'=>$threadInfo['thread_sef']); } return false; @@ -902,7 +909,9 @@ class e107forum e107::getMessage()->addDebug("Thread Update Failed: ".print_a($info,true)); } - e107::getEvent()->trigger('user_forum_topic_updated', $info); + $triggerData = $threadInfo; + $triggerData['thread_id'] = intval($threadId); + e107::getEvent()->trigger('user_forum_topic_updated', $triggerData); } @@ -919,6 +928,8 @@ class e107forum e107::getMessage()->addDebug("Post Update Failed: ".print_a($info,true)); } + $triggerData = $postInfo; + $triggerData['post_id'] = intval($postId); e107::getEvent()->trigger('user_forum_post_updated', $info); } diff --git a/e107_plugins/forum/templates/forum_post_template.php b/e107_plugins/forum/templates/forum_post_template.php index 60b4ea61a..f2d2e5f76 100644 --- a/e107_plugins/forum/templates/forum_post_template.php +++ b/e107_plugins/forum/templates/forum_post_template.php @@ -261,6 +261,11 @@ $THREADTOPIC_REPLY = " "; +$js = << Date: Fri, 22 Apr 2016 08:46:34 -0700 Subject: [PATCH 11/34] Issue #1185 - Possible fix for broken FAQs loop. --- e107_plugins/faqs/faqs.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e107_plugins/faqs/faqs.php b/e107_plugins/faqs/faqs.php index df1e46b6d..c508b3a98 100644 --- a/e107_plugins/faqs/faqs.php +++ b/e107_plugins/faqs/faqs.php @@ -370,7 +370,7 @@ class faq $query = "SELECT f.*,cat.* FROM #faqs AS f LEFT JOIN #faqs_info AS cat ON f.faq_parent = cat.faq_info_id WHERE cat.faq_info_class IN (".USERCLASS_LIST.") ".$insert." ORDER BY cat.faq_info_order, f.".$orderBy." ".$ascdesc." "; - if(!$sql->gen($query)) + if(!$data = $sql->retrieve($query, true)) { $message = (!empty($srch)) ? "".$srch." was not found in search results. Reset" : LAN_FAQS_NONE_AVAILABLE; return "
    ".$message."
    " ; //TODO LAN @@ -416,7 +416,7 @@ class faq } - while ($rw = $sql->fetch()) + foreach ($data as $rw) { $rw['faq_sef'] = eHelper::title2sef($tp->toText($rw['faq_question']),'dashl'); From 699257e3c3eec667a368124e68216dc41367b585 Mon Sep 17 00:00:00 2001 From: Cameron Date: Fri, 22 Apr 2016 09:01:18 -0700 Subject: [PATCH 12/34] Forum triggerData fix. --- e107_admin/plugin.php | 2 +- e107_plugins/forum/forum_class.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/e107_admin/plugin.php b/e107_admin/plugin.php index e535644d2..242d57b69 100644 --- a/e107_admin/plugin.php +++ b/e107_admin/plugin.php @@ -3792,7 +3792,7 @@ $text .= " // ------- Customize Create -------- - public function beforeCreate(\$new_data) + public function beforeCreate(\$new_data,\$old_data) { return \$new_data; } diff --git a/e107_plugins/forum/forum_class.php b/e107_plugins/forum/forum_class.php index cc6e4fdb3..a9d3a8a7a 100644 --- a/e107_plugins/forum/forum_class.php +++ b/e107_plugins/forum/forum_class.php @@ -758,6 +758,7 @@ class e107forum e107::getMessage()->addDebug("Updating Thread with: ".print_a($info,true)); $triggerData = $info['data']; + $triggerData['thread_id'] = $postInfo['post_thread']; e107::getEvent()->trigger('user_forum_topic_updated', $triggerData); } From 9cf18a2708d930d0ce169bbcc70ccd6286a704a8 Mon Sep 17 00:00:00 2001 From: Cameron Date: Fri, 22 Apr 2016 09:03:21 -0700 Subject: [PATCH 13/34] Fixes #1567 - Addon validation. --- e107_plugins/banner/e_shortcode.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e107_plugins/banner/e_shortcode.php b/e107_plugins/banner/e_shortcode.php index 331f3168f..b6707a257 100644 --- a/e107_plugins/banner/e_shortcode.php +++ b/e107_plugins/banner/e_shortcode.php @@ -108,4 +108,4 @@ class banner_shortcodes extends e_shortcode return $text; } } -?> + From 16d0417b706f7be482d65eb8dbfdd5b85974acdb Mon Sep 17 00:00:00 2001 From: Cameron Date: Fri, 22 Apr 2016 09:44:01 -0700 Subject: [PATCH 14/34] Third-party compatibility for forum shortcode vars. --- e107_handlers/shortcode_handler.php | 3 ++- e107_plugins/forum/forum_viewtopic.php | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/e107_handlers/shortcode_handler.php b/e107_handlers/shortcode_handler.php index 4ee0b9c8b..064e3ab88 100644 --- a/e107_handlers/shortcode_handler.php +++ b/e107_handlers/shortcode_handler.php @@ -1366,7 +1366,8 @@ class e_shortcode } /** - * Alias of setParserVars - Preferred use by Plugins. + * Alias of setParserVars - Preferred use by Plugins. + * Sets the value of $sc->var */ public function setVars($eVars) // Alias of setParserVars(); { diff --git a/e107_plugins/forum/forum_viewtopic.php b/e107_plugins/forum/forum_viewtopic.php index 08b618b80..4d25d18a9 100644 --- a/e107_plugins/forum/forum_viewtopic.php +++ b/e107_plugins/forum/forum_viewtopic.php @@ -474,6 +474,7 @@ foreach ($postList as $postInfo) $alt = !$alt; $sc->setScVar('postInfo', $postInfo); + $sc->setVars($postInfo); // compatibility if($postInfo['post_status']) { @@ -493,6 +494,7 @@ foreach ($postList as $postInfo) { $postInfo['thread_start'] = true; $sc->setScVar('postInfo', $postInfo); + $sc->setVars($postInfo); // compatibility $sc->wrapper('forum_viewtopic/thread'); // $forum_shortcodes = e107::getScBatch('view', 'forum')->setScVar('postInfo', $postInfo)->wrapper('forum/viewtopic'); $forthr = $tp->parseTemplate($FORUMTHREADSTYLE, true, vartrue($sc)) . "\n"; From 58a3926c54827c6755c86b54d5082dc70c6b28e1 Mon Sep 17 00:00:00 2001 From: Cameron Date: Fri, 22 Apr 2016 11:54:18 -0700 Subject: [PATCH 15/34] Issue #690 - Option added to enable e_shortcode.php to override other core/plugin shortcodes. --- e107_handlers/db_debug_class.php | 4 +-- e107_handlers/shortcode_handler.php | 41 ++++++++++++++++++++++++++--- e107_plugins/_blank/e_shortcode.php | 1 + 3 files changed, 40 insertions(+), 6 deletions(-) diff --git a/e107_handlers/db_debug_class.php b/e107_handlers/db_debug_class.php index 73280d6aa..612d2ea58 100644 --- a/e107_handlers/db_debug_class.php +++ b/e107_handlers/db_debug_class.php @@ -514,8 +514,8 @@ class e107_db_debug {
+ {SITEURL}
{SITEBUTTON: type=email&h=60}

{SITENAME=link}

- {SITEURL}
diff --git a/e107_handlers/mail.php b/e107_handlers/mail.php index b8bcdf2ac..4e0e9e796 100644 --- a/e107_handlers/mail.php +++ b/e107_handlers/mail.php @@ -566,7 +566,7 @@ class e107Email extends PHPMailer } $message = str_replace("\t", "", $message); // filter out tabs from templates; - + if ($want_HTML !== FALSE) { // $message = e107::getParser()->toHtml("[html]".$message."[/html]",true); // using toHtml will break media attachment links. (need to retain {e_XXXX ) @@ -598,7 +598,7 @@ class e107Email extends PHPMailer $message = str_replace("\n", "
\n", $message); } - + $this->MsgHTML($message); // Theoretically this should do everything, including handling of inline images. } @@ -863,11 +863,11 @@ class e107Email extends PHPMailer $identifier = deftrue('MAIL_IDENTIFIER', 'X-e107-id'); - - if (isset($eml['SMTPDebug'])) { $this->SMTPDebug = $eml['SMTPDebug']; } // 'FALSE' is a valid value! + + if (isset($eml['SMTPDebug'])) { $this->SMTPDebug = $eml['SMTPDebug']; } // 'FALSE' is a valid value! if (!empty($eml['sender_email'])) { $this->From = $eml['sender_email']; } if (!empty($eml['sender_name'])) { $this->FromName = $eml['sender_name']; } - if (!empty($eml['replyto'])) { $this->AddAddressList('replyto',$eml['replyto'],vartrue($eml['replytonames'],'')); } + if (!empty($eml['replyto'])) { $this->AddAddressList('replyto',$eml['replyto'],vartrue($eml['replytonames'],'')); } if (isset($eml['html'])) { $this->allow_html = $eml['html']; } // 'FALSE' is a valid value! if (isset($eml['html_header'])) { $this->add_HTML_header = $eml['html_header']; } // 'FALSE' is a valid value! if (!empty($eml['body'])) { $this->makeBody($eml['body'], $this->allow_html, $this->add_HTML_header); } @@ -882,7 +882,7 @@ class e107Email extends PHPMailer if (!empty($eml['split'])) { $this->SingleTo = ($eml['split'] != FALSE); } if (!empty($eml['smtp_username'])) { $this->Username = $eml['smtp_username']; } if (!empty($eml['smtp_password'])) { $this->Password = $eml['smtp_password']; } - + if (!empty($eml['bouncepath'])) { $this->Sender = $eml['bouncepath']; // Bounce path @@ -968,12 +968,12 @@ class e107Email extends PHPMailer public function sendEmail($send_to, $to_name, $eml = array(), $bulkmail = false) { if (count($eml)) - { + { if($error = $this->arraySet($eml)) // Set parameters from list { return $error; } - + } if (($bulkmail == true) && $this->localUseVerp && $this->save_bouncepath && (strpos($this->save_bouncepath,'@') !== false)) @@ -1002,7 +1002,7 @@ class e107Email extends PHPMailer $_SERVER['REMOTE_ADDR'] = $_SERVER['SERVER_ADDR']; $_SERVER["HTTP_X_FORWARDED_FOR"] = $_SERVER['SERVER_ADDR']; $_SERVER["HTTP_CF_CONNECTING_IP"] = $_SERVER['SERVER_ADDR']; - + $result = $this->Send(); // Actually send email @@ -1122,10 +1122,18 @@ class e107Email extends PHPMailer $url = $tp->replaceConstants($url); // resize on the fly. + if($this->debug) + { + echo "
Attempting Resize...".$url; + } if($resized = e107::getMedia()->resizeImage($url, e_TEMP.basename($url),'w=800')) { $url = $resized; } + elseif($this->debug) + { + echo "
Couldn't resize ".$url; + } $delim = $images[2][$i]; // Will be single or double quote $filename = basename($url); @@ -1139,7 +1147,7 @@ class e107Email extends PHPMailer if ($this->debug) { - echo "
CID file {$filename} in {$directory}. Base = ".SERVERBASE."< BaseDir = {$basedir}
"; + echo "
CID file {$filename} in {$directory}. Base = ".SERVERBASE."
BaseDir = {$basedir}
"; } $cid = 'cid:' . md5($filename); diff --git a/e107_handlers/media_class.php b/e107_handlers/media_class.php index a59596db4..6a36cdd1e 100644 --- a/e107_handlers/media_class.php +++ b/e107_handlers/media_class.php @@ -1472,6 +1472,11 @@ class e_media $src = $tp->replaceConstants($src); $dest = $tp->replaceConstants($dest); + if(!file_exists($src)) + { + return false; + } + $maxWidth = varset($opts['w'], 800); $maxHeight = varset($opts['h'], 800); diff --git a/e107_plugins/pm/languages/English.php b/e107_plugins/pm/languages/English.php index 8229517aa..d1ae0a849 100755 --- a/e107_plugins/pm/languages/English.php +++ b/e107_plugins/pm/languages/English.php @@ -86,4 +86,6 @@ define("LAN_PM_108", "Message sent on: "); define("LAN_PM_109", "New Message(s)"); define("LAN_PM_111", "Read"); define("LAN_PM_112", "User(s)"); + +define("LAN_PM_113", "Read Message"); ?> \ No newline at end of file diff --git a/e107_plugins/pm/pm_class.php b/e107_plugins/pm/pm_class.php index 44259476a..27f086d57 100755 --- a/e107_plugins/pm/pm_class.php +++ b/e107_plugins/pm/pm_class.php @@ -407,7 +407,8 @@ class private_message $data['PM_DATE'] = e107::getParser()->toDate($pmInfo['pm_sent'], 'long'); $data['SITENAME'] = SITENAME; $data['USERNAME'] = USERNAME; - $data['PM_URL'] = "".$url."";// e107::url('pm','index', null, array('mode'=>'full')).'?show.'.$pmid; + $data['PM_URL'] = $url;// e107::url('pm','index', null, array('mode'=>'full')).'?show.'.$pmid; + $data['PM_BUTTON'] = "".LAN_PM_113."";// e107::url('pm','index', null, array('mode'=>'full')).'?show.'.$pmid; $text = e107::getParser()->simpleParse($template, $data); diff --git a/e107_plugins/pm/pm_template.php b/e107_plugins/pm/pm_template.php index 1c16c7b41..0846c6113 100755 --- a/e107_plugins/pm/pm_template.php +++ b/e107_plugins/pm/pm_template.php @@ -276,10 +276,9 @@ $PM_NOTIFY = ".LAN_PM_103."{PM_SUBJECT} ".LAN_PM_108."{PM_DATE} ".LAN_PM_104."{PM_ATTACHMENTS} - -
-
".LAN_PM_105.": {PM_URL}
-
+ + +

+".LAN_PM_113."
"; -?> \ No newline at end of file From 691c2ef170897bfacd21f4edc9b0f5065b0c4e57 Mon Sep 17 00:00:00 2001 From: Michael Waskosky Date: Fri, 22 Apr 2016 21:29:00 -0600 Subject: [PATCH 18/34] boostrap modal options for frontend A way to configure modal options documented here http://getbootstrap.com/javascript/#modals-methods --- e107_web/js/core/front.jquery.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/e107_web/js/core/front.jquery.js b/e107_web/js/core/front.jquery.js index 03e9efe4b..418dc5149 100644 --- a/e107_web/js/core/front.jquery.js +++ b/e107_web/js/core/front.jquery.js @@ -402,7 +402,6 @@ $(document).ready(function() /* Bootstrap Modal window within an iFrame for frontend */ $('.e-modal').on('click', function(e) { - e.preventDefault(); if($(this).attr('data-cache') == 'false') @@ -414,8 +413,22 @@ $(document).ready(function() var url = $(this).attr('href'); var caption = $(this).attr('data-modal-caption'); + var backdrop = $(this).attr('data-modal-backdrop'); + var keyboard = $(this).attr('data-modal-keyboard'); var height = ($(window).height() * 0.7) - 120; + var modalOptions = {show: true}; + + if(backdrop !== undefined) + { + modalOptions['backdrop'] = backdrop; + } + + if(keyboard !== undefined) + { + modalOptions['keyboard'] = keyboard; + } + if(caption === undefined) { caption = ''; @@ -428,7 +441,7 @@ $(document).ready(function() $('.modal-body').html('
'); $('.modal-caption').html(caption + ' '); - $('.modal').modal('show'); + $('.modal').modal(modalOptions); $("#e-modal-iframe").on("load", function () { $('#e-modal-loading').hide(); @@ -438,4 +451,4 @@ $(document).ready(function() -}); \ No newline at end of file +}); From 3e0f7d4540c35b61d98c11f3af3d954abc9debe5 Mon Sep 17 00:00:00 2001 From: Jimmi08 Date: Sat, 23 Apr 2016 16:59:29 +0200 Subject: [PATCH 19/34] possibility to use lang string in placeholder --- e107_handlers/form_handler.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index a508dba22..66db25abf 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -2626,7 +2626,10 @@ class e_form break; case 'placeholder': - if($optval) $ret .= " placeholder='{$optval}'"; + if($optval) { + $optval = deftrue($optval, $optval); + $ret .= " placeholder='{$optval}'"; + } break; case 'wrap': From dfa7521fd9d3fd760e6819fd584e95c33f6c05f6 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sat, 23 Apr 2016 08:14:46 -0700 Subject: [PATCH 20/34] PHP Notice removal --- e107_core/shortcodes/batch/news_shortcodes.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/e107_core/shortcodes/batch/news_shortcodes.php b/e107_core/shortcodes/batch/news_shortcodes.php index 813674033..31171cc0c 100644 --- a/e107_core/shortcodes/batch/news_shortcodes.php +++ b/e107_core/shortcodes/batch/news_shortcodes.php @@ -621,6 +621,8 @@ class news_shortcodes extends e_shortcode $parms = array(1 => null); } + $style = !empty($this->param['thumbnail']) ? $this->param['thumbnail'] : ''; + switch($parms[1]) { @@ -629,15 +631,15 @@ class news_shortcodes extends e_shortcode break; case 'tag': - return ""; + return ""; break; case 'img': - return ""; + return ""; break; default: - return "news_item)."'>"; + return "news_item)."'>"; break; } } @@ -813,6 +815,8 @@ class news_shortcodes extends e_shortcode $parm['type'] = 'tag'; } + $style = !empty($this->param['thumbnail']) ? $this->param['thumbnail'] : ''; + switch(vartrue($parm['type'])) { case 'src': @@ -820,12 +824,12 @@ class news_shortcodes extends e_shortcode break; case 'tag': - return ""; + return ""; break; case 'url': default: - return "news_item)."'>"; + return "news_item)."'>"; break; } } From 5453be3ccd7d08d977e604a9cd0e5dcd8f9a7b15 Mon Sep 17 00:00:00 2001 From: Michael Waskosky Date: Sat, 23 Apr 2016 14:51:45 -0600 Subject: [PATCH 21/34] Allow full screen iframed elements in modal This tag allows videos in modals to be full screen. --- e107_web/js/core/front.jquery.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e107_web/js/core/front.jquery.js b/e107_web/js/core/front.jquery.js index 418dc5149..d32548323 100644 --- a/e107_web/js/core/front.jquery.js +++ b/e107_web/js/core/front.jquery.js @@ -439,7 +439,7 @@ $(document).ready(function() height = $(this).attr('data-modal-height'); } - $('.modal-body').html('
'); + $('.modal-body').html('
'); $('.modal-caption').html(caption + ' '); $('.modal').modal(modalOptions); From a21d351cd225c1652deef982aa3554981d562f9f Mon Sep 17 00:00:00 2001 From: Cameron Date: Sat, 23 Apr 2016 14:13:31 -0700 Subject: [PATCH 22/34] PM Notification datestamp fix. --- e107_handlers/form_handler.php | 12 ++++++++++-- e107_plugins/pm/pm_class.php | 22 ++++++++++++++-------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index 66db25abf..34f6aa14b 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -1180,7 +1180,7 @@ class e_form /** * User auto-complete search - * + * XXX EXPERIMENTAL - subject to change. * @param string $name_fld field name for user name * @param string $id_fld field name for user id * @param string $default_name default user name value @@ -4667,7 +4667,7 @@ class e_form if(!isset($parms['__options'])) $parms['__options'] = array(); if(!is_array($parms['__options'])) parse_str($parms['__options'], $parms['__options']); - if((empty($value) && varset($parms['currentInit'],USERID)!=0) || vartrue($parms['current'])) // include current user by default. + if((empty($value) && varset($parms['currentInit'],USERID)!=0 && varset($parms['default']) !=0) || vartrue($parms['current'])) // include current user by default. { $value = USERID; if(vartrue($parms['current'])) @@ -4687,6 +4687,14 @@ class e_form if(!$value) $value = array(); $uname = varset($value[$colname]); $value = varset($value['user_id'], 0); + + if(!empty($parms['max'])) + { + $parms['__options']['selectize']['maxItems'] = intval($parms['max']); + } + + + $ret = $this->userpicker(vartrue($parms['nameField'], $key), $key, $uname, $value, vartrue($parms['__options'])); break; diff --git a/e107_plugins/pm/pm_class.php b/e107_plugins/pm/pm_class.php index 27f086d57..c51b59de5 100755 --- a/e107_plugins/pm/pm_class.php +++ b/e107_plugins/pm/pm_class.php @@ -272,6 +272,7 @@ class private_message if(check_class($this->pmPrefs['notify_class'], null, $vars['to_info']['user_id'])) { set_time_limit(20); + $vars['pm_sent'] = $timestamp; $this->pm_send_notify($vars['to_info']['user_id'], $vars, $pmid, count($a_list)); } $ret .= LAN_PM_40.": {$vars['to_info']['user_name']}
"; @@ -435,8 +436,7 @@ class private_message * Send PM read receipt * * @param array $pmInfo - PM details - * - * @return none + * @return boolean */ function pm_send_receipt($pmInfo) //TODO Add Template and combine with method above.. { @@ -450,16 +450,20 @@ class private_message $txt .= LAN_PM_103.$pmInfo['pm_subject']."\n"; $txt .= LAN_PM_105."\n".$pmlink."\n"; - sendemail($pmInfo['from_email'], $subject, $txt, $pmInfo['from_name']); + if(sendemail($pmInfo['from_email'], $subject, $txt, $pmInfo['from_name'])) + { + return true; + } + + return false; } /** - * Get list of users blocked from sending to a specific user ID. + * Get list of users blocked from sending to a specific user ID. * - * @param integer $to - user ID - * - * @return array of blocked users as user IDs + * @param int|mixed $to - user ID + * @return array of blocked users as user IDs */ function block_get($to = USERID) { @@ -643,7 +647,9 @@ class private_message $regex = "(^|,)(".e107::getParser()->toDB($class).")(,|$)"; $qry = "SELECT user_id, user_name, user_email, user_class FROM `#user` WHERE user_class REGEXP '{$regex}'"; } - if($sql->gen($qry)) + + + if(!empty($qry) && $sql->gen($qry)) { $ret = $sql->db_getList(); return $ret; From b4a5a0b573bd0faaee65d3a0c300a1ff7aaf202d Mon Sep 17 00:00:00 2001 From: Cameron Date: Sat, 23 Apr 2016 15:23:45 -0700 Subject: [PATCH 23/34] Closes #1484 - theme shortcodes are now registered globally by default. Shortcode handler cleanup. --- e107_handlers/shortcode_handler.php | 126 ++++++++++++++-------------- 1 file changed, 65 insertions(+), 61 deletions(-) diff --git a/e107_handlers/shortcode_handler.php b/e107_handlers/shortcode_handler.php index cc27b5d87..dd2db5e43 100644 --- a/e107_handlers/shortcode_handler.php +++ b/e107_handlers/shortcode_handler.php @@ -100,6 +100,8 @@ class e_parse_shortcode $this->loadPluginSCFiles(); //$this->loadCoreShortcodes(); DEPRECATED + + } /** @@ -479,25 +481,16 @@ class e_parse_shortcode { global $register_sc; - // $this->registered_codes[$code]['type'] = 'plugin'; - // $this->registered_codes[$code]['function'] = strtolower($code).'_shortcode'; - // $this->registered_codes[$code]['path'] = e_PLUGIN.$path.'/shortcodes/single/'; - // $this->registered_codes[$code]['perms'] = $uclass; - - - if(deftrue('e_DEVELOPER')) // experimental, could break something. - use theme shortcodes in other templates. + if(file_exists(THEME."theme_shortcodes.php")) { - if(file_exists(THEME."theme_shortcodes.php")) - { - $classFunc = 'theme_shortcodes'; - $path = THEME."theme_shortcodes.php"; - include_once($path); - $this->registerClassMethods($classFunc, $path, false); - - } + $classFunc = 'theme_shortcodes'; + $path = THEME."theme_shortcodes.php"; + include_once($path); + $this->registerClassMethods($classFunc, $path, false); } + - if (isset($register_sc) && is_array($register_sc)) + if (isset($register_sc) && is_array($register_sc)) // legacy load. { foreach ($register_sc as $code) { @@ -659,33 +652,15 @@ class e_parse_shortcode return $this; } - /** - * DEPRECATED admin_shortcodes now loaded inside admin parse function (see boot.php) - * Register Core Shortcode Batches. - * FIXME - make it smarter - currently loaded all the time (even on front-end) - * - * @return e_parse_shortcode - */ - // function loadCoreShortcodes() - // { - // $coreBatchList = array('admin_shortcodes'); -// - // foreach ($coreBatchList as $cb) - // { - // $path = e_CORE.'shortcodes/batch/'.$cb.".php"; - // if (include_once($path)) - // { - // $this->registerClassMethods($cb, $path); - // } - // } - // return $this; - // } + function isRegistered($code) { return array_key_exists($code, $this->registered_codes); } + + public function resetScClass($className, $object) { if(null === $object) @@ -939,6 +914,7 @@ class e_parse_shortcode $ret = ''; $_method = 'sc_'.strtolower($code); + // Display e_shortcode.php override info. if((E107_DBG_BBSC || E107_DBG_SC) && isset($this->addonOverride[$_method]) && is_object($this->addedCodes) && method_exists($this->addedCodes, $_method)) { @@ -963,12 +939,13 @@ class e_parse_shortcode elseif (is_array($this->addedCodes) && array_key_exists($code, $this->addedCodes)) // Its array-based shortcode. Load the code for evaluation later. { - $scCode = $this->addedCodes[$code]; - // $_path = print_a($this->backTrace,true); - //XXX $_path = print_a($this,true); - + $ret = $this->addedCodes[$code]; + // $_class = "n/a"; + // $_function = "n/a"; + $_type = 'array'; + $_path = "(direct to parser)"; + } - elseif (array_key_exists($code, $this->scList)) // Check to see if we've already loaded the .sc file contents { @@ -1093,17 +1070,21 @@ class e_parse_shortcode $_path = $scFile; } } - if ($scFile && file_exists($scFile)) + + if(!empty($scFile)) { - $scCode = file_get_contents($scFile); - $this->scList[$code] = $scCode; - $_path = $scFile; - } - else - { - // $ret = 'Missing!'; - $_path .= " MISSING!"; + if(file_exists($scFile)) + { + $scCode = file_get_contents($scFile); + $this->scList[$code] = $scCode; + $_path = $scFile; + } + else + { + $_path .= $scFile." MISSING!"; + } } + } if (!isset($scCode)) @@ -1115,21 +1096,37 @@ class e_parse_shortcode return $matches[0]; } - if (E107_DBG_SC && $scFile) - { + // if (E107_DBG_SC && $scFile) + // { // echo (isset($scFile)) ? "
sc_file= ".str_replace(e_CORE.'shortcodes/single/', '', $scFile).'
' : ''; // echo "
sc= $code"; - } + // } } - if ($scCode) + if ($scCode) // legacy shortode to be evaluated. { - $ret = @eval($scCode); + try + { + $ret = @eval($scCode); + } + catch (Throwable $t) { // Executed only in PHP 7, will not match in PHP 5.x + + $string = print_a($scCode,true); + $string .= "

Added Coded

"; + $string .= print_a($this->addedCodes,true); + e107::getMessage()->addDebug('Could not parse Shortcode '.$scFile.' :: {'.$code .'} '.$string); + + } + catch (Exception $e) + { + echo $e->getMessage(); + } + 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); + // $string = print_a($scCode,true); + // e107::getMessage()->addDebug('Could not parse Shortcode '.$scFile.' :: {'.$code .'} '.$string); } } @@ -1206,19 +1203,26 @@ class e_parse_shortcode global $db_debug; $other = array(); + + if(!empty($_type)) + { + $other['type'] = $_type; + } - if($_class) + if(!empty($_class)) { $other['class'] = $_class; } - if(vartrue($_function)) + if(!empty($_function)) { $other['function'] = $_function; } - if(vartrue($_path)) + if(!empty($_path)) { $other['path'] = str_replace('../','',$_path); } + + if($this->debug_legacy) { From 7ee707190e931b70291916d43db32634849fbdec Mon Sep 17 00:00:00 2001 From: Jimmi08 Date: Sun, 24 Apr 2016 08:44:40 +0200 Subject: [PATCH 24/34] added parameters to some signup shortcodes --- .../shortcodes/batch/signup_shortcodes.php | 73 ++++++++++++++----- 1 file changed, 55 insertions(+), 18 deletions(-) diff --git a/e107_core/shortcodes/batch/signup_shortcodes.php b/e107_core/shortcodes/batch/signup_shortcodes.php index d27f2ebd6..07e40eda9 100755 --- a/e107_core/shortcodes/batch/signup_shortcodes.php +++ b/e107_core/shortcodes/batch/signup_shortcodes.php @@ -185,8 +185,12 @@ class signup_shortcodes extends e_shortcode } } - - function sc_signup_loginname() + /* example {SIGNUP_LOGINNAME} */ + /* example {SIGNUP_LOGINNAME: class=btn input-lg} */ + /* example {SIGNUP_LOGINNAME: placeholder=LAN_LOGINNAME} */ + /* example {SIGNUP_LOGINNAME: class=input-lg&placeholder=LAN_LOGINNAME} */ + + function sc_signup_loginname($parm=null) { $pref = e107::getPref(); @@ -194,20 +198,26 @@ class signup_shortcodes extends e_shortcode { return LAN_SIGNUP_67; } - + // if ($pref['signup_option_loginname']) { $log_name_length = varset($pref['loginname_maxlength'],30); $options = array('size'=>30,'required'=>1); $options['title'] = str_replace("[x]",$log_name_length,LAN_SIGNUP_109); // Password must be at least $options['pattern'] = '[\S]*'; - + $options['class'] = vartrue($parm['class'],''); + $options['placeholder'] = vartrue($parm['placeholder']) ? $parm['placeholder'] : ''; + return e107::getForm()->text('loginname', ($_POST['loginname'] ? $_POST['loginname'] : ''), $log_name_length, $options); } } + /* example {SIGNUP_REALNAME} */ + /* example {SIGNUP_REALNAME: class=btn input-lg} */ + /* example {SIGNUP_REALNAME: placeholder=LAN_SIGNUP_91} */ + /* example {SIGNUP_REALNAME: class=input-lg&placeholder=LAN_SIGNUP_91} */ - function sc_signup_realname() + function sc_signup_realname($parm=null) { $pref = e107::getPref('signup_option_realname'); if($pref < 1){ return; } @@ -215,13 +225,19 @@ class signup_shortcodes extends e_shortcode $options = array('size'=>30); $options['required'] = ($pref==2) ? 1 : 0; $options['title'] = LAN_SIGNUP_110; - + $options['class'] = vartrue($parm['class'],''); + $options['placeholder'] = vartrue($parm['placeholder'],''); + return e107::getForm()->text('realname', ($_POST['realname'] ? $_POST['realname'] : ''), 100, $options); } - - function sc_signup_password1() + /* example {SIGNUP_PASSWORD1} */ + /* example {SIGNUP_PASSWORD1: class=btn input-lg} */ + /* example {SIGNUP_PASSWORD1: placeholder=LAN_PASSWORD} */ + /* example {SIGNUP_PASSWORD1: class=input-lg&placeholder=LAN_PASSWORD} */ + + function sc_signup_password1($parm=null) { $pref = e107::getPref('signup_option_password', 2); @@ -239,14 +255,20 @@ class signup_shortcodes extends e_shortcode $options['required'] = true; $options['pattern'] = '(?=^.{'.$len.',}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$'; $options['autocomplete'] = 'off'; + $options['class'] = vartrue($parm['class'],''); + $options['placeholder'] = vartrue($parm['placeholder'],''); // $options['pattern'] = '\w{'.$len.',}'; // word of minimum length - + return e107::getForm()->password('password1', '', 20, $options); } + /* example {SIGNUP_PASSWORD2} */ + /* example {SIGNUP_PASSWORD2: class=btn input-lg} */ + /* example {SIGNUP_PASSWORD2: placeholder=LAN_SIGNUP_84} */ + /* example {SIGNUP_PASSWORD2: class=input-lg&placeholder=LAN_SIGNUP_84} */ - function sc_signup_password2() + function sc_signup_password2($parm=null) { $pref = e107::getPref('signup_option_password', 2); @@ -255,8 +277,11 @@ class signup_shortcodes extends e_shortcode { return false; } - - return e107::getForm()->password('password2', '', 20, array('size'=>30,'class'=>'tbox','required'=>1)); + $options = array('size'=>30,'class'=>'e-password tbox','required'=>1); + $options['class'] = vartrue($parm['class'],''); + $options['placeholder'] = vartrue($parm['placeholder'],''); + + return e107::getForm()->password('password2', '', 20, $options); } @@ -269,11 +294,17 @@ class signup_shortcodes extends e_shortcode } } - - function sc_signup_email() + /* example {SIGNUP_EMAIL} */ + /* example {SIGNUP_EMAIL: class=btn input-lg} */ + /* example {SIGNUP_EMAIL: placeholder=LAN_USER_60} */ + /* example {SIGNUP_EMAIL: class=input-lg&placeholder=LAN_USER_60} */ + + function sc_signup_email($parm=null) { $options = array('size'=>30,'required'=>1,'class'=>'tbox form-control input-text e-email'); $options['title'] = LAN_SIGNUP_108; // Must be a valid email address. + $options['class'] = vartrue($parm['class'],''); + $options['placeholder'] = vartrue($parm['placeholder'],''); $text = e107::getForm()->email('email',vartrue($_POST['email'], ''),100,$options); $text .= ""; @@ -281,16 +312,22 @@ class signup_shortcodes extends e_shortcode return $text; } - - function sc_signup_email_confirm() + /* example {SIGNUP_EMAIL_CONFIRM} */ + /* example {SIGNUP_EMAIL_CONFIRM: class=btn input-lg} */ + /* example {SIGNUP_EMAIL_CONFIRM: placeholder=LAN_SIGNUP_39} */ + /* example {SIGNUP_EMAIL_CONFIRM: class=input-lg&placeholder=LAN_SIGNUP_39} */ + + function sc_signup_email_confirm($parm=null) { $pref = e107::getPref('signup_option_email_confirm'); if($pref < 1){ return; } $options = array('size'=>30); $options['required'] = ($pref==2) ? 1 : 0; - $options['class'] = 'tbox input-text e-email'; - + $options['class'] = 'tbox input-text e-email'; + $options['class'] = vartrue($parm['class'],'tbox input-text e-email'); + $options['placeholder'] = vartrue($parm['placeholder'],''); + return e107::getForm()->email('email_confirm', vartrue($_POST['email_confirm']), 100, $options); } From 4125d04371bdd0911790f3a26a38f847dc15e2c1 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sun, 24 Apr 2016 10:45:27 -0700 Subject: [PATCH 25/34] Issue #1582 - Simplification and rewrite of userpicker() method. --- e107_handlers/form_handler.php | 133 ++++++++++++++++++++++--- e107_plugins/pm/pm_shortcodes.php | 3 +- e107_themes/bootstrap3/admin_style.css | 7 +- 3 files changed, 124 insertions(+), 19 deletions(-) diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index 34f6aa14b..7e5dce66b 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -1188,6 +1188,7 @@ class e_form * @param array|string $options [optional] 'readonly' (make field read only), 'name' (db field name, default user_name) * @return string HTML text for display */ + /* function userpicker($name_fld, $id_fld='', $default_name, $default_id, $options = array()) { if(!is_array($options)) @@ -1225,7 +1226,106 @@ class e_form return $ret; } - + */ + + + /** + * User Field - auto-complete search + * @param string $name form element name + * @param string|array $value comma separated list of user ids or array of userid=>username pairs. + * @param array|string $options [optional] + * @param int $options['limit'] Maximum number of users + * @param string $options['id'] Custom id + * @param string $options['inline'] Inline ID. + * + * @example $frm->userpicker('author', 1); + * @example $frm->userpicker('authors', "1,2,3"); + * @example $frm->userpicker('author', array('user_id'=>1, 'user_name'=>'Admin'); + * @example $frm->userpicker('authors', array(0=>array('user_id'=>1, 'user_name'=>'Admin', 1=>array('user_id'=>2, 'user_name'=>'John')); + * + * @todo $options['type'] = 'select' - dropdown selections box with data returned as array instead of comma-separated. + * @return string HTML text for display + */ + function userpicker($name, $value, $options = array()) + { + if(!is_array($options)) + { + parse_str($options, $options); + } + + $defaultItems = array(); + + if(is_array($value)) + { + if(isset($value[0]))// multiple users. + { + foreach($value as $val) + { + $defaultItems[] = array('value'=>$val['user_id'], 'label'=>$val['user_name']); + } + + } + else // single user + { + $defaultItems[] = array('value'=>$value['user_id'], 'label'=>$value['user_name']); + } + + } + elseif(!empty($value)) /// comma separated with user-id lookup. + { + $tmp = explode(",", $value); + foreach($tmp as $uid) + { + if($user = e107::user($uid)) + { + $defaultItems[] = array('value'=>$user['user_id'], 'label'=>$user['user_name']); + } + } + } + + $parms = array( + 'selectize' => array( + 'loadPath' => e_BASE . 'user.php', + 'create' => false, + 'maxItems' => 1, + 'mode' => 'multi', + 'options' => $defaultItems + ) + ); + + if(!empty($options['limit'])) + { + $parms['selectize']['maxItems'] = intval($options['limit']); + } + + if(!empty($options['id'])) + { + $parms['id'] = $options['id']; + } + + if(!empty($options['inline'])) + { + $parms['selectize']['e_editable'] = $options['inline']; + } + + //TODO FIXME Filter by userclass. - see $frm->userlist(). + + $defValues = array(); + + foreach($defaultItems as $val) + { + $defValues[] = $val['value']; + } + + $ret = $this->text($name, implode(",",$defValues), 100, $parms); + + return $ret; + } + + + + + /** * A Rating element @@ -4048,7 +4148,9 @@ class e_form $fieldID = $this->name2id($field . '_' . microtime(true)); // Unique ID for each rows. $eEditableID = $this->name2id($fieldID . '_' . $row_id); - $tpl = $this->userpicker($field, '', $ttl, $id, array('id' => $fieldID, 'selectize' => array('e_editable' => $eEditableID))); + // $tpl = $this->userpicker($field, '', $ttl, $id, array('id' => $fieldID, 'selectize' => array('e_editable' => $eEditableID))); + + $tpl = $this->userpicker($fieldID, array('user_id'=>$id, 'user_name'=>$ttl), array('id' => $fieldID, 'inline' => $eEditableID)); $mode = preg_replace('/[^\w]/', '', vartrue($_GET['mode'], '')); $value = "" . $ttl . ""; } @@ -4664,38 +4766,41 @@ class e_form case 'user': //user_id expected // Just temporary solution, could be changed soon + + if(!isset($parms['__options'])) $parms['__options'] = array(); if(!is_array($parms['__options'])) parse_str($parms['__options'], $parms['__options']); - if((empty($value) && varset($parms['currentInit'],USERID)!=0 && varset($parms['default']) !=0) || vartrue($parms['current'])) // include current user by default. + if((empty($value) && !empty($parms['currentInit']) && !isset($parms['default']) ) || !empty($parms['current']) || (vartrue($parms['default']) == 'USERID')) // include current user by default. { $value = USERID; if(vartrue($parms['current'])) { $parms['__options']['readonly'] = true; } + } - if(!is_array($value)) - { - $value = $value ? e107::getSystemUser($value, true)->getUserData() : array();// e107::user($value); - } + // if(!is_array($value)) + // { + // $value = $value ? e107::getSystemUser($value, true)->getUserData() : array();// e107::user($value); + // } $colname = vartrue($parms['nameType'], 'user_name'); $parms['__options']['name'] = $colname; - if(!$value) $value = array(); - $uname = varset($value[$colname]); - $value = varset($value['user_id'], 0); + // if(!$value) $value = array(); + // $uname = varset($value[$colname]); + // $value = varset($value['user_id'], 0); - if(!empty($parms['max'])) + if(!empty($parms['limit'])) { - $parms['__options']['selectize']['maxItems'] = intval($parms['max']); + $parms['__options']['limit'] = intval($parms['limit']); } + $ret = $this->userpicker(vartrue($parms['nameField'], $key), $value, vartrue($parms['__options'])); - - $ret = $this->userpicker(vartrue($parms['nameField'], $key), $key, $uname, $value, vartrue($parms['__options'])); + // $ret = $this->userpicker(vartrue($parms['nameField'], $key), $key, $uname, $value, vartrue($parms['__options'])); break; case 'bool': diff --git a/e107_plugins/pm/pm_shortcodes.php b/e107_plugins/pm/pm_shortcodes.php index a1579898a..76965567d 100644 --- a/e107_plugins/pm/pm_shortcodes.php +++ b/e107_plugins/pm/pm_shortcodes.php @@ -170,8 +170,7 @@ if(!class_exists('plugin_pm_pm_shortcodes')) if(check_class($this->pmPrefs['multi_class'])) { - $selectize = array('maxItems'=>10); - $ret = e107::getForm()->userpicker('pm_to', null, null, null, array('selectize'=>$selectize)); + $ret = e107::getForm()->userpicker('pm_to', null, array('limit'=>10)); } else { diff --git a/e107_themes/bootstrap3/admin_style.css b/e107_themes/bootstrap3/admin_style.css index ecbe37819..e53634220 100644 --- a/e107_themes/bootstrap3/admin_style.css +++ b/e107_themes/bootstrap3/admin_style.css @@ -1011,6 +1011,10 @@ span.tag button.close { .selectize-control.multi .selectize-input > div { cursor: pointer; margin: 1px 5px 0 0; padding: 1px 3px; background: #3a87ad; color: #ffffff; border: 0 solid rgba(0, 0, 0, 0); text-shadow: 1px 1px 0 black; box-shadow: 1px 1px 0 black; font-size: 12px; font-weight: bold; } .selectize-control.single .selectize-input, .selectize-control.single .selectize-input.input-active, .selectize-control.single .selectize-input.input-active:hover, .selectize-control.single .selectize-input.focus, .selectize-control.multi .selectize-input, .selectize-control.multi .selectize-input.input-active, .selectize-control.multi .selectize-input.input-active:hover, .selectize-control.multi .selectize-input.focus { padding: 5px 5px 5px 5px !important; } +div.selectize-control .form-control { background-color: #212121; border: none; box-shadow: 2px 2px 2px rgba(0, 0, 0,0.5); } +div.selectize-dropdown .option.active { color: #fff; background-color: #337ab7; } + + /* Theme Manager - Find online */ .form-search > div > div > div > i.icon-search { @@ -1258,9 +1262,6 @@ li.rssRow > div { - - - /* body { background-color: rgb(68, 68, 68); } From a14b3baff7301342d9e1cfd26499a809f37eb7ea Mon Sep 17 00:00:00 2001 From: Michael Waskosky Date: Sun, 24 Apr 2016 16:08:57 -0600 Subject: [PATCH 26/34] New method to post attachment related data directly Allows posting new attachment file data directly with the $_POST request so that uploads and attachment data can be handled before the post is submitted. Alternate types of attachments also become possible then when overriding the forum attachment shortcodes. Data is posted with JSON instead of PHP Array to avoid the chance of eval() related security issues. --- e107_plugins/forum/forum_post.php | 39 +++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/e107_plugins/forum/forum_post.php b/e107_plugins/forum/forum_post.php index bcb27ac82..68e4e4dc9 100644 --- a/e107_plugins/forum/forum_post.php +++ b/e107_plugins/forum/forum_post.php @@ -796,6 +796,18 @@ class forum_post_handler $postInfo['post_attachments'] = e107::serialize($newValues); } + + //Allows directly overriding the method of adding files (or other data) as attachments + if(isset($_POST['post_attachments_json']) && trim($_POST['post_attachments_json'])) + { + $posted_attachments = json_decode($_POST['post_attachments_json'], true); + $attachments_json_errors = json_last_error(); + if($attachments_json_errors === JSON_ERROR_NONE) + { + $postInfo['post_attachments'] = e107::serialize($posted_attachments); + } + } + // var_dump($uploadResult); switch($this->action) @@ -1005,7 +1017,19 @@ class forum_post_handler $postVals['post_attachments'] = e107::serialize($newValues); // $postVals['post_attachments'] = implode(',', $attachments); } - + + //Allows directly overriding the method of adding files (or other data) as attachments + if(isset($_POST['post_attachments_json']) && trim($_POST['post_attachments_json'])) + { + $existingValues = e107::unserialize($this->data['post_attachments']); + $posted_attachments = json_decode($_POST['post_attachments_json'], true); + $attachments_json_errors = json_last_error(); + if($attachments_json_errors === JSON_ERROR_NONE) + { + $postVals['post_attachments'] = e107::serialize(array_merge_recursive($existingValues,$posted_attachments)); + } + } + $postVals['post_edit_datestamp'] = time(); $postVals['post_edit_user'] = USERID; $postVals['post_entry'] = $_POST['post']; @@ -1071,7 +1095,18 @@ class forum_post_handler $postVals['post_attachments'] = e107::serialize($newValues); } - + + //Allows directly overriding the method of adding files (or other data) as attachments + if(isset($_POST['post_attachments_json']) && trim($_POST['post_attachments_json'])) + { + $existingValues = e107::unserialize($this->data['post_attachments']); + $posted_attachments = json_decode($_POST['post_attachments_json'], true); + $attachments_json_errors = json_last_error(); + if($attachments_json_errors === JSON_ERROR_NONE) + { + $postVals['post_attachments'] = e107::serialize(array_merge_recursive($existingValues,$posted_attachments)); + } + } $this->forumObj->postUpdate($this->data['post_id'], $postVals); From 611ba198384666a201a0d52518dd58ca968f6903 Mon Sep 17 00:00:00 2001 From: Michael Waskosky Date: Sun, 24 Apr 2016 16:56:06 -0600 Subject: [PATCH 27/34] New method to post forum attachment related data directly (cleaned) Allows posting new forum attachment file data directly with the $_POST request so that uploads and attachment data can be handled before the post is submitted. Alternate types of attachments also become possible then when overriding the forum attachment shortcodes. Data is posted with JSON instead of PHP Array to avoid the chance of eval() related security issues. --- e107_plugins/forum/forum_post.php | 60 +++++++++++++++++-------------- 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/e107_plugins/forum/forum_post.php b/e107_plugins/forum/forum_post.php index 68e4e4dc9..f6c2d6d53 100644 --- a/e107_plugins/forum/forum_post.php +++ b/e107_plugins/forum/forum_post.php @@ -798,15 +798,10 @@ class forum_post_handler } //Allows directly overriding the method of adding files (or other data) as attachments - if(isset($_POST['post_attachments_json']) && trim($_POST['post_attachments_json'])) + if($attachmentsPosted = $this->processAttachmentsPosted()) { - $posted_attachments = json_decode($_POST['post_attachments_json'], true); - $attachments_json_errors = json_last_error(); - if($attachments_json_errors === JSON_ERROR_NONE) - { - $postInfo['post_attachments'] = e107::serialize($posted_attachments); - } - } + $postInfo['post_attachments'] = $attachmentsPosted; + } // var_dump($uploadResult); @@ -1019,16 +1014,10 @@ class forum_post_handler } //Allows directly overriding the method of adding files (or other data) as attachments - if(isset($_POST['post_attachments_json']) && trim($_POST['post_attachments_json'])) + if($attachmentsPosted = $this->processAttachmentsPosted($this->data['post_attachments'])) { - $existingValues = e107::unserialize($this->data['post_attachments']); - $posted_attachments = json_decode($_POST['post_attachments_json'], true); - $attachments_json_errors = json_last_error(); - if($attachments_json_errors === JSON_ERROR_NONE) - { - $postVals['post_attachments'] = e107::serialize(array_merge_recursive($existingValues,$posted_attachments)); - } - } + $postVals['post_attachments'] = $attachmentsPosted; + } $postVals['post_edit_datestamp'] = time(); $postVals['post_edit_user'] = USERID; @@ -1097,16 +1086,10 @@ class forum_post_handler } //Allows directly overriding the method of adding files (or other data) as attachments - if(isset($_POST['post_attachments_json']) && trim($_POST['post_attachments_json'])) + if($attachmentsPosted = $this->processAttachmentsPosted($this->data['post_attachments'])) { - $existingValues = e107::unserialize($this->data['post_attachments']); - $posted_attachments = json_decode($_POST['post_attachments_json'], true); - $attachments_json_errors = json_last_error(); - if($attachments_json_errors === JSON_ERROR_NONE) - { - $postVals['post_attachments'] = e107::serialize(array_merge_recursive($existingValues,$posted_attachments)); - } - } + $postVals['post_attachments'] = $attachmentsPosted; + } $this->forumObj->postUpdate($this->data['post_id'], $postVals); @@ -1258,6 +1241,31 @@ class forum_post_handler } */ } + + + //Allows directly overriding the method of adding files (or other data) as attachments + function processAttachmentsPosted($existingValues = false) + { + if(isset($_POST['post_attachments_json']) && trim($_POST['post_attachments_json'])) + { + $postedAttachments = json_decode($_POST['post_attachments_json'], true); + $attachmentsJsonErrors = json_last_error(); + if($attachmentsJsonErrors === JSON_ERROR_NONE) + { + if($existingValues) + { + $existingValues = e107::unserialize($existingValues); + return e107::serialize(array_merge_recursive($existingValues,$postedAttachments)); + } + else + { + return e107::serialize($postedAttachments); + } + } + } + + return false; + } } From 89264b0259d6db8acfac53bc64227c3940a9e818 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sun, 24 Apr 2016 16:13:05 -0700 Subject: [PATCH 28/34] Fix for user-extended permissions on user page. Corrected wrapper ID for user/member list. --- .../shortcodes/batch/user_shortcodes.php | 18 +++++++++++-- e107_handlers/db_debug_class.php | 6 +++++ e107_handlers/mail.php | 8 +++--- e107_handlers/user_extended_class.php | 26 ++++++++++++++----- e107_plugins/pm/admin_config.php | 22 ++++++++++++++++ user.php | 4 ++- 6 files changed, 70 insertions(+), 14 deletions(-) diff --git a/e107_core/shortcodes/batch/user_shortcodes.php b/e107_core/shortcodes/batch/user_shortcodes.php index cbc752dc4..650292877 100644 --- a/e107_core/shortcodes/batch/user_shortcodes.php +++ b/e107_core/shortcodes/batch/user_shortcodes.php @@ -672,16 +672,30 @@ class user_shortcodes extends e_shortcode if(!empty($parm['field'])) { + + $ext = e107::getUserExt(); + $fld = 'user_'.$parm['field']; + + if(!$ext->hasPermission($fld,'read')) + { + return false; + } + $val = $this->var[$fld]; - return e107::getUserExt()->renderValue($val); //TODO auto-detect type, from within the user-extended class. + + // e107::getDebug()->log(print_a($ext,true)); + + return $ext->renderValue($val); //TODO auto-detect type, from within the user-extended class. } - return ' '; + return false; } + + function sc_user_extended_all($parm) { $sql = e107::getDb(); diff --git a/e107_handlers/db_debug_class.php b/e107_handlers/db_debug_class.php index 612d2ea58..028f03e98 100644 --- a/e107_handlers/db_debug_class.php +++ b/e107_handlers/db_debug_class.php @@ -658,6 +658,12 @@ class e107_db_debug { // function log($message,$TraceLev=1) { + + if(is_array($message)) + { + $message = "
".print_r($message,true)."
"; + } + if (!E107_DBG_BASIC){ return FALSE; } diff --git a/e107_handlers/mail.php b/e107_handlers/mail.php index 4e0e9e796..a9b6f1ffe 100644 --- a/e107_handlers/mail.php +++ b/e107_handlers/mail.php @@ -947,10 +947,10 @@ class e107Email extends PHPMailer * @param bool $eml['add_html_header'] - if TRUE, adds the 2-line DOCTYPE declaration to the front of the HTML part (but doesn't add ...) * @param string $eml['body'] - message body. May be HTML or text. Added according to the current state of the HTML enable flag * @param string|array $eml['attach'] - string if one file, array of filenames if one or more. - * @param string $eml['copy_to'] - comma-separated list of cc addresses. - * @param string $eml['cc_names'] - comma-separated list of cc names. Optional, used only if $eml['copy_to'] specified - * @param string $eml['bcopy_to'] - comma-separated list - * @param string $eml['bcc_names'] - comma-separated list of bcc names. Optional, used only if $eml['copy_to'] specified + * @param string $eml['cc'] - comma-separated list of cc addresses. + * @param string $eml['cc_names'] - comma-separated list of cc names. Optional, used only if $eml['cc'] specified + * @param string $eml['bcc'] - comma-separated list + * @param string $eml['bcc_names'] - comma-separated list of bcc names. Optional, used only if $eml['bcc'] specified * @param string $eml['bouncepath'] - Sender field (used for bounces) * @param string $eml['returnreceipt'] - email address for notification of receipt (reading) * @param array $eml['inline_images'] - array of files for inline images diff --git a/e107_handlers/user_extended_class.php b/e107_handlers/user_extended_class.php index 149cd717f..e314b19f4 100644 --- a/e107_handlers/user_extended_class.php +++ b/e107_handlers/user_extended_class.php @@ -45,11 +45,12 @@ class e107_user_extended private $extended_xml = FALSE; public $typeArray; // Cross-reference between names of field types, and numeric ID (must be public) private $reserved_names; // List of field names used in main user DB - not allowed in extended DB - public $fieldDefinitions; // Array initialised from DB by constructor - currently all fields + public $fieldDefinitions = array(); // Array initialised from DB by constructor - currently all fields public $catDefinitions; // Categories - private $nameIndex; // Array for field name lookup - initialised by constructor - public $systemCount = 0; // Count of system fields - always zero ATM - public $userCount = 0; // Count of non-system fields + private $nameIndex = array(); // Array for field name lookup - initialised by constructor + public $systemCount = 0; // Count of system fields - always zero ATM + public $userCount = 0; // Count of non-system fields + private $fieldPermissions = array(); // Field Permissionss with field name as key. public function __construct() { @@ -109,7 +110,6 @@ class e107_user_extended // Read in all the field and category fields // At present we load all fields into common array - may want to split system and non-system $this ->catDefinitions = array(); // Categories array - $this->fieldDefinitions = array(); // Field definitions array $this->nameIndex = array(); // Index of names => field IDs $this->systemCount = 0; $this->userCount = 0; @@ -125,6 +125,8 @@ class e107_user_extended else { // Its a field definition $this->fieldDefinitions[$row['user_extended_struct_id']] = $row; + $id = 'user_'.$row['user_extended_struct_name']; + $this->fieldPermissions[$id] = array('read'=>$row['user_extended_struct_read'], 'write'=>$row['user_extended_struct_write']); $this->nameIndex['user_'.$row['user_extended_struct_name']] = $row['user_extended_struct_id']; // Create name to ID index if ($row['user_extended_struct_text'] == '_system_') { @@ -139,14 +141,24 @@ class e107_user_extended } } + /** + * Check read/write access on extended user-fields + * @param string $field eg. user_something + * @param string $type read|write + * @return boolean true if + */ + public function hasPermission($field, $type='read') + { + $class = ($type == 'read') ? $this->fieldPermissions[$field]['read'] : $this->fieldPermissions[$field]['write']; + return check_class($class); + } + /** * Check for reserved field names. * (Names which clash with the 'normal' user table aren't allowed) - * * @param string $name - name of field bweing checked (no 'user_' prefix) - * * @return boolean TRUE if disallowed name */ public function user_extended_reserved($name) diff --git a/e107_plugins/pm/admin_config.php b/e107_plugins/pm/admin_config.php index 7bc652022..86d8786b1 100644 --- a/e107_plugins/pm/admin_config.php +++ b/e107_plugins/pm/admin_config.php @@ -35,6 +35,7 @@ class pm_admin extends e_admin_dispatcher 'ui' => 'private_msg_form_ui', 'uipath' => null ), + /* 'block' => array( 'controller' => 'private_msg_block_ui', @@ -52,6 +53,7 @@ class pm_admin extends e_admin_dispatcher 'main/limits' => array('caption'=> ADLAN_PM_55, 'perm' => 'P'), 'main/maint' => array('caption'=> ADLAN_PM_59, 'perm' => 'P'), + 'main/null' => array('divider'=> true), 'inbox/list' => array('caption'=> "Inbox", 'perm' => 'P'), 'outbox/list' => array('caption'=> "Outbox", 'perm' => 'P'), @@ -71,6 +73,17 @@ class pm_admin extends e_admin_dispatcher ); protected $menuTitle = LAN_PLUGIN_PM_NAME; + + function init() + { + + if(e_DEBUG == true) + { + $this->adminMenu['main/null2'] = array('divider'=> true); + $this->adminMenu['main/list'] = array('caption'=> "Log", 'perm' => 'P'); + } + + } } @@ -831,6 +844,15 @@ class private_msg_ui extends e_admin_ui $this->fields['options']['readParms'] = 'editClass='.e_UC_NOBODY; } + if($this->getMode() == 'main') + { + $this->listQry = 'SELECT p.*, u.user_name, f.user_name AS fromuser FROM #private_msg AS p LEFT JOIN #user AS u ON u.user_id = p.pm_to + LEFT JOIN #user as f on f.user_id = p.pm_from WHERE 1 '; + // $this->fields['pm_from']['nolist'] = true; + $this->fields['options']['readParms'] = 'editClass='.e_UC_NOBODY; + $this->perPage = 20; + } + if($this->getAction() == 'create') { $this->fields['pm_to']['writeParms']['default'] = 99999999; diff --git a/user.php b/user.php index 847a6f219..48110fce1 100644 --- a/user.php +++ b/user.php @@ -261,12 +261,14 @@ if (isset($id)) // $userList = $sql->db_getList(); $text = $tp->parseTemplate($USER_SHORT_TEMPLATE_START, TRUE, $user_shortcodes); + $sc = e107::getScBatch('user'); foreach ($data as $row) { $loop_uid = $row['user_id']; // $text .= renderuser($row, "short"); - e107::getScBatch('user')->setVars($row); + $sc->setVars($row); + $sc->wrapper('user/list'); $text .= $tp->parseTemplate($USER_SHORT_TEMPLATE, TRUE, $user_shortcodes); } From c46809de92aca80a02068a0f8beeb71a9a5518a4 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sun, 24 Apr 2016 17:02:34 -0700 Subject: [PATCH 29/34] Config update --- .codeclimate.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.codeclimate.yml b/.codeclimate.yml index 039d8b81e..cbdf341fd 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -9,6 +9,7 @@ engines: enabled: false Design/TooManyPublicMethods: enabled: false + config: languages: - javascript @@ -30,6 +31,8 @@ engines: enabled: false Design/TooManyFields: enabled: false + CleanCode/BooleanArgumentFlag: + enabled: false config: file_extensions: "php" rulesets: "cleancode,unusedcode,codesize" From c11d58724323eecebf3ce673365b274ca2b51220 Mon Sep 17 00:00:00 2001 From: Michael Waskosky Date: Sun, 24 Apr 2016 18:07:11 -0600 Subject: [PATCH 30/34] Fix to bot's boolean misperceptions --- e107_plugins/forum/forum_post.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e107_plugins/forum/forum_post.php b/e107_plugins/forum/forum_post.php index f6c2d6d53..2c6d59662 100644 --- a/e107_plugins/forum/forum_post.php +++ b/e107_plugins/forum/forum_post.php @@ -1244,7 +1244,7 @@ class forum_post_handler //Allows directly overriding the method of adding files (or other data) as attachments - function processAttachmentsPosted($existingValues = false) + function processAttachmentsPosted($existingValues = '') { if(isset($_POST['post_attachments_json']) && trim($_POST['post_attachments_json'])) { From 8762cf82ca6017015e92aebefd261c5f3ef1c31d Mon Sep 17 00:00:00 2001 From: Cameron Date: Sun, 24 Apr 2016 19:40:01 -0700 Subject: [PATCH 31/34] PM Message limits. --- e107_plugins/pm/admin_config.php | 2 +- e107_plugins/pm/languages/English_admin.php | 2 ++ e107_plugins/pm/pm_shortcodes.php | 14 +++++++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/e107_plugins/pm/admin_config.php b/e107_plugins/pm/admin_config.php index 86d8786b1..ce1f05fb6 100644 --- a/e107_plugins/pm/admin_config.php +++ b/e107_plugins/pm/admin_config.php @@ -142,7 +142,7 @@ class private_msg_ui extends e_admin_ui 'attach_size' => array('title'=> ADLAN_PM_28, 'tab'=>1, 'type' => 'number', 'data' => 'int', 'help'=>'', 'writeParms'=>'tdClassRight=form-inline&post=Kb'), 'pm_max_send' => array('title'=> ADLAN_PM_81, 'tab'=>1, 'type' => 'number', 'data' => 'int', 'help'=>''), 'perpage' => array('title'=> ADLAN_PM_24, 'tab'=>0, 'type' => 'number', 'data' => 'int', 'help'=>''), - + 'maxlength' => array('title'=> ADLAN_PM_84, 'tab'=>1, 'type' => 'number', 'data' => 'int', 'help'=>ADLAN_PM_85, 'writeParms'=>array('post'=>'chars.')), ); diff --git a/e107_plugins/pm/languages/English_admin.php b/e107_plugins/pm/languages/English_admin.php index 14f5c6f4e..9c39661f6 100644 --- a/e107_plugins/pm/languages/English_admin.php +++ b/e107_plugins/pm/languages/English_admin.php @@ -76,6 +76,8 @@ define("ADLAN_PM_80", "Preference formats updated"); define("ADLAN_PM_81", "Maximum number of PMs to send immediately"); define("ADLAN_PM_82", "If sending more than this, they are added to a queue and sent out using the cron task"); define("ADLAN_PM_83", "Users may only send messages to users in this class"); +define("ADLAN_PM_84", "Maximum message length"); +define("ADLAN_PM_85", "0 = unlimited"); ?> \ No newline at end of file diff --git a/e107_plugins/pm/pm_shortcodes.php b/e107_plugins/pm/pm_shortcodes.php index 76965567d..27f4428bd 100644 --- a/e107_plugins/pm/pm_shortcodes.php +++ b/e107_plugins/pm/pm_shortcodes.php @@ -245,6 +245,9 @@ if(!class_exists('plugin_pm_pm_shortcodes')) public function sc_pm_form_message() { $value = ''; + $maxlength = ''; + $placeholder = ''; + if(vartrue($this->var['pm_text'])) { if(isset($_POST['quote'])) @@ -253,7 +256,16 @@ if(!class_exists('plugin_pm_pm_shortcodes')) $value = "\n\n\n\n\n\n\n[quote{$t}={$this->var['from_name']}]\n".trim($this->var['pm_text'])."[/quote{$t}]"; } } - return ""; + + + if(!empty($this->pmPrefs['maxlength'])) + { + $length = intval($this->pmPrefs['maxlength']); + $maxlength = "maxlength=".$length; + $placeholder = "placeholder='Max. ".$length." chars.'"; // TODO LAN + } + + return ""; } From 79c6e80c4f00ccd540341f03f7f3440f899028bd Mon Sep 17 00:00:00 2001 From: Cameron Date: Mon, 25 Apr 2016 09:31:55 -0700 Subject: [PATCH 32/34] Fix for PM Send permissions. --- e107_handlers/userclass_class.php | 2 +- e107_plugins/pm/e_shortcode.php | 12 ++++++--- e107_plugins/pm/languages/English.php | 1 + e107_plugins/pm/pm.php | 8 ++++++ e107_plugins/pm/pm_class.php | 39 ++++++++++++++++++++++++++- 5 files changed, 57 insertions(+), 5 deletions(-) diff --git a/e107_handlers/userclass_class.php b/e107_handlers/userclass_class.php index 206f88be0..e2df6d302 100644 --- a/e107_handlers/userclass_class.php +++ b/e107_handlers/userclass_class.php @@ -531,7 +531,7 @@ class user_class if (count($opt_arr) == 0) { - $opt_arr = array('public' => 1, 'guest' => 1, 'nobody' => 1, 'member' => 1, 'classes' => 1); + $opt_arr = array('public' => 1, 'guest' => 1, 'new'=>1, 'nobody' => 1, 'member' => 1, 'classes' => 1); } if (isset($opt_arr['all'])) diff --git a/e107_plugins/pm/e_shortcode.php b/e107_plugins/pm/e_shortcode.php index 890f5e57b..62ee34983 100644 --- a/e107_plugins/pm/e_shortcode.php +++ b/e107_plugins/pm/e_shortcode.php @@ -75,8 +75,10 @@ class pm_shortcodes extends e_shortcode } - - + /** + * @param int $parm - User ID. + * @return null|string + */ function sc_sendpm($parm='') { @@ -86,8 +88,12 @@ class pm_shortcodes extends e_shortcode $url = e107::url('pm','index').'?send.'.$parm; + require_once(e_PLUGIN."pm/pm_class.php"); - if(check_class($pm_prefs['pm_class'])) + $pm = new private_message; + + + if(check_class($pm_prefs['pm_class']) && $pm->canSendTo($parm)) // check $this->pmPrefs['send_to_class']. { if(deftrue('FONTAWESOME') && deftrue('BOOTSTRAP')) { diff --git a/e107_plugins/pm/languages/English.php b/e107_plugins/pm/languages/English.php index d1ae0a849..53b2f5032 100755 --- a/e107_plugins/pm/languages/English.php +++ b/e107_plugins/pm/languages/English.php @@ -88,4 +88,5 @@ define("LAN_PM_111", "Read"); define("LAN_PM_112", "User(s)"); define("LAN_PM_113", "Read Message"); +define("LAN_PM_114", "You do not have access to send to this user."); ?> \ No newline at end of file diff --git a/e107_plugins/pm/pm.php b/e107_plugins/pm/pm.php index e3b323814..ed3a355ca 100755 --- a/e107_plugins/pm/pm.php +++ b/e107_plugins/pm/pm.php @@ -148,8 +148,16 @@ class pm_extended extends private_message $to_uid = $pm_info['pm_from']; } + + if(!empty($to_uid)) { + + if($this->canSendTo($to_uid) == false) + { + return "
".LAN_PM_114."
";// sending to this user is not permitted. + } + $sql2 = e107::getDb('sql2'); if($sql2->select('user', 'user_name', 'user_id = '.intval($to_uid))) //TODO add a check for userclass. { diff --git a/e107_plugins/pm/pm_class.php b/e107_plugins/pm/pm_class.php index c51b59de5..ceb4f55d7 100755 --- a/e107_plugins/pm/pm_class.php +++ b/e107_plugins/pm/pm_class.php @@ -35,7 +35,8 @@ class private_message public function __construct($prefs=null) { $this->e107 = e107::getInstance(); - $this->pmPrefs = $prefs; } + $this->pmPrefs = e107::pref('pm'); + } /** @@ -262,6 +263,10 @@ class private_message else { // Sending to a single person $info['pm_to'] = intval($vars['to_info']['user_id']); // Sending to a single user now + + + + if($pmid = $sql->insert('private_msg', $info)) { $info['pm_id'] = $pmid; @@ -634,6 +639,7 @@ class private_message function get_users_inclass($class) { $sql = e107::getDb(); + if($class == e_UC_MEMBER) { $qry = "SELECT user_id, user_name, user_email, user_class FROM `#user` WHERE 1"; @@ -658,6 +664,37 @@ class private_message } + /** + * Check permission to send a PM to someone. + * @param int $uid user_id of the person to send to + * @return bool + */ + function canSendTo($uid) + { + if(empty($uid)) + { + return false; + } + + $user = e107::user($uid); + + $uclass = explode(",", $user['user_class']); + + if($this->pmPrefs['send_to_class'] == 'matchclass') + { + $tmp = explode(",", USERCLASS); + $result = array_intersect($uclass, $tmp); + + return !empty($result); + } + + return in_array($this->pmPrefs['send_to_class'], $uclass); + + } + + + + /** * Get inbox - up to $limit messages from $from * From b2771fa00a19dda4d643b072f1f65d49dbbd3df5 Mon Sep 17 00:00:00 2001 From: Cameron Date: Mon, 25 Apr 2016 19:06:37 -0700 Subject: [PATCH 33/34] Added new user to the default userclass selection. Improved userclass() method docs. --- e107_handlers/form_handler.php | 20 ++++++++++++++------ e107_handlers/userclass_class.php | 2 +- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index 7e5dce66b..488f339d6 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -2134,11 +2134,15 @@ class e_form /** * Universal Userclass selector - checkboxes, dropdown, everything. - * @param $name - form element name - * @param $curval - current userclass value(s) as array or comma separated. - * @param $type - 'checkbox', 'dropdown', - * @param options - query string or array. 'options=admin,mainadmin,classes&vetted=1&exclusions=0' etc. - * @return the userclass form element + * @param string $name - form element name + * @param int $curval - current userclass value(s) as array or comma separated. + * @param string $type - checkbox|dropdown default is dropdown. + * @param string|array $options - classlist or query string or key=value pair. + * @param string $options['options'] comma-separated list of display options. 'options=admin,mainadmin,classes&vetted=1&exclusions=0' etc. + * + * @example $frm->userclass('name', 0, 'dropdown', 'classes'); // display all userclasses + * @example $frm->userclass('name', 0, 'dropdown', 'classes,matchclass'); // display only classes to which the user belongs. + * @return string form element(s) */ function userclass($name, $curval=255, $type=null, $options=null) { @@ -2148,10 +2152,14 @@ class e_form { $opt = $options; } - else + elseif(strpos($options,'=')!==false) { parse_str($options,$opt); } + else + { + $opt = array('options'=>$options); + } } else diff --git a/e107_handlers/userclass_class.php b/e107_handlers/userclass_class.php index e2df6d302..206f88be0 100644 --- a/e107_handlers/userclass_class.php +++ b/e107_handlers/userclass_class.php @@ -531,7 +531,7 @@ class user_class if (count($opt_arr) == 0) { - $opt_arr = array('public' => 1, 'guest' => 1, 'new'=>1, 'nobody' => 1, 'member' => 1, 'classes' => 1); + $opt_arr = array('public' => 1, 'guest' => 1, 'nobody' => 1, 'member' => 1, 'classes' => 1); } if (isset($opt_arr['all'])) From 23efdfd972e4f139ba07e216d7b1c8b399914c82 Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 26 Apr 2016 09:03:25 -0700 Subject: [PATCH 34/34] Fixes #1585 - hard-coded language in TinyMce. --- e107_plugins/tinymce4/wysiwyg.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e107_plugins/tinymce4/wysiwyg.php b/e107_plugins/tinymce4/wysiwyg.php index 929fbcc8e..307a633bd 100644 --- a/e107_plugins/tinymce4/wysiwyg.php +++ b/e107_plugins/tinymce4/wysiwyg.php @@ -217,7 +217,7 @@ class wysiwyg function tinymce_lang() { - $lang = 'English'; //Quick Fix e_LANGUAGE + $lang = e_LANGUAGE; // 'English'; //Quick Fix e_LANGUAGE $tinylang = array( "Arabic" => "ar", "Bulgarian" => "bg",