From eecbfbd61dc61e2633aa26b2948cb21dcc41ae4a Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 30 Aug 2016 14:22:47 -0700 Subject: [PATCH] News: {NEWS_VISIBILITY} shortcode added - returns text version of userclass for use in CSS class styling if needed. --- e107_admin/newspost.php | 3 ++- .../shortcodes/batch/news_shortcodes.php | 8 ++++++ e107_handlers/userclass_class.php | 26 +++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/e107_admin/newspost.php b/e107_admin/newspost.php index 46759261e..295c0da7a 100644 --- a/e107_admin/newspost.php +++ b/e107_admin/newspost.php @@ -1335,7 +1335,7 @@ class news_admin_ui extends e_admin_ui if($mediaData = $this->processSubmittedMedia($row['submitnews_media'])) { - $data['news_body'] .= "\n\n".$mediaData; + $data['news_body'] .= "\n\n---\n\n".$mediaData; } if(e107::getPref('wysiwyg',false)!==false) @@ -1343,6 +1343,7 @@ class news_admin_ui extends e_admin_ui $data['news_body'] = nl2br($data['news_body']); } + $data['news_author'] = $row['submitnews_user']; $data['news_thumbnail'] = $row['submitnews_file']; // implode(",",$thumbs); $data['news_sef'] = eHelper::dasherize($data['news_title']); diff --git a/e107_core/shortcodes/batch/news_shortcodes.php b/e107_core/shortcodes/batch/news_shortcodes.php index 63f7d2e28..5ed2b8084 100644 --- a/e107_core/shortcodes/batch/news_shortcodes.php +++ b/e107_core/shortcodes/batch/news_shortcodes.php @@ -357,6 +357,14 @@ class news_shortcodes extends e_shortcode return $this->sc_newsimage($parm); } + public function sc_news_visibility($parm=null) + { + $string= e107::getUserClass()->getIdentifier($this->news_item['news_class']); + return $string; + + } + + // ----------------------------------- BC compatible Shortcodes ------------------------------------------- // function sc_newscategory($parm=null) diff --git a/e107_handlers/userclass_class.php b/e107_handlers/userclass_class.php index 206f88be0..b73471a84 100644 --- a/e107_handlers/userclass_class.php +++ b/e107_handlers/userclass_class.php @@ -935,6 +935,32 @@ class user_class + /** + * Return a key-name identifier for given class ID + * @param integer $id - class number. A negative number indicates 'not a member of...' + * @return string class name ke + */ + public function getIdentifier($id) + { + $cn = abs($id); + + $ucString = ''; + + $fixedClasses = array_flip($this->text_class_link); + + if(isset($fixedClasses[$cn])) + { + return $fixedClasses[$cn]; + } + + if(isset($this->class_tree[$cn])) + { + return e107::getForm()->name2id($this->class_tree[$cn]['userclass_name']); + } + + return $ucString; + } + /** * Return class description for given class ID