diff --git a/e107_plugins/chatbox_menu/chat.php b/e107_plugins/chatbox_menu/chat.php
old mode 100644
new mode 100755
index cda750cb1..b06bc9971
--- a/e107_plugins/chatbox_menu/chat.php
+++ b/e107_plugins/chatbox_menu/chat.php
@@ -1,201 +1,184 @@
-select("menus", "*", "menu_name='chatbox_menu'");
-$row = $sql->fetch();
-
-if (!check_class(intval($row['menu_class'])))
-{
- $mes->addError(CHATBOX_L24);
- $ns->tablerender(LAN_ERROR, $mes->render());
- require_once(FOOTERF);
- exit;
-}
-
-if(!isset($pref['cb_mod']))
-{
- $pref['cb_mod'] = e_UC_ADMIN;
-}
-
-
-define("CB_MOD", check_class($pref['cb_mod']));
-
-
-if(!empty($_POST['moderate']) && CB_MOD)
-{
- if(isset($_POST['block']))
- {
- foreach(array_keys($_POST['block']) as $k){ $kk[] = intval($k); }
- $blocklist = implode(",", $kk);
- $sql->gen("UPDATE #chatbox SET cb_blocked=1 WHERE cb_id IN ({$blocklist})");
- }
-
- if(isset($_POST['unblock']))
- {
- foreach(array_keys($_POST['unblock']) as $k){ $kk[] = intval($k); }
- $unblocklist = implode(",", $kk);
- $sql->gen("UPDATE #chatbox SET cb_blocked=0 WHERE cb_id IN ({$unblocklist})");
- }
-
- if(isset($_POST['delete']))
- {
- $deletelist = implode(",", array_keys($_POST['delete']));
- $sql -> db_Select_gen("SELECT c.cb_id, u.user_id FROM #chatbox AS c
- LEFT JOIN #user AS u ON SUBSTRING_INDEX(c.cb_nick,'.',1) = u.user_id
- WHERE c.cb_id IN (".$deletelist.")");
- $rowlist = $sql -> db_getList();
- foreach ($rowlist as $row) {
- $sql->gen("UPDATE #user SET user_chats=user_chats-1 where user_id = ".intval($row['user_id']));
- }
- $sql->gen("DELETE FROM #chatbox WHERE cb_id IN ({$deletelist})");
- }
- e107::getCache()->clear("nq_chatbox");
- $mes->addSuccess(CHATBOX_L18);
-}
-
-// when coming from search.php
-
-$fs = false;
-
-if (strstr(e_QUERY, "fs"))
-{
- $cgtm = intval(str_replace(".fs", "", e_QUERY));
- $fs = true;
-}
-// end search
-
-if (e_QUERY ? $from = intval(e_QUERY) : $from = 0);
-
-$chat_total = $sql->count('chatbox');
-
-$qry_where = (CB_MOD ? "1" : "cb_blocked=0");
-
-// when coming from search.php calculate page number
-if ($fs)
-{
- $page_count = 0;
- $row_count = 0;
- $sql->select("chatbox", "*", "{$qry_where} ORDER BY cb_datestamp DESC");
- while ($row = $sql->fetch())
- {
- if ($row['cb_id'] == $cgtm)
- {
- $from = $page_count;
- break;
- }
- $row_count++;
- if ($row_count == 30)
- {
- $row_count = 0;
- $page_count += 30;
- }
- }
-}
-// end search
-
-$sql->select("chatbox", "*", "{$qry_where} ORDER BY cb_datestamp DESC LIMIT ".intval($from).", 30");
-$obj2 = new convert;
-
-$chatList = $sql->db_getList();
-$frm = e107::getForm();
-$vars = array();
-$flag = false;
-
-if (empty($CHAT_TABLE))
-{
- if (file_exists(THEME."chat_template.php"))
- {
- require_once(THEME."chat_template.php");
- }
- else
- {
- require_once(e_PLUGIN."chatbox_menu/chat_template.php");
- }
-}
-
-$textstring = '';
-
-foreach ($chatList as $row)
-{
- $vars['CHAT_TABLE_DATESTAMP'] = $tp->toDate($row['cb_datestamp'], "relative");
- $vars['CHAT_TABLE_NICK'] = preg_replace("/[0-9]+\./", "", $row['cb_nick']);
-
- $cb_message = $tp->toHTML($row['cb_message'], TRUE,'USER_BODY');
-
- if($row['cb_blocked'])
- {
- $cb_message .= "
".CHATBOX_L25;
- }
-
- if(CB_MOD)
- {
- $id = $row['cb_id'];
- $cb_message .= "
";
-
- $cb_message .= $frm->checkbox('delete['.$id.']',1, false, array('inline'=>true,'label'=>LAN_DELETE));
-
- if($row['cb_blocked'])
- {
- $cb_message .= $frm->checkbox('unblock['.$id.']',1, false, array('inline'=>true, 'label'=> CHATBOX_L7));
- }
- else
- {
- $cb_message .= $frm->checkbox('block['.$id.']',1, false, array('inline'=>true, 'label'=> CHATBOX_L9));
- }
-
- $cb_message .= "
";
- }
-
- $vars['CHAT_TABLE_MESSAGE'] = $cb_message;
- $vars['CHAT_TABLE_FLAG'] = ($flag ? "forumheader3" : "forumheader4");
-
-
-// $textstring .= preg_replace("/\{(.*?)\}/e", '$\1', $CHAT_TABLE);
- $textstring .= $tp->parseTemplate($CHAT_TABLE, true, $vars);
- $flag = (!$flag ? true : false);
-}
-
-
-//print_a($CHAT_TABLE);
-
-
-//$textstart = preg_replace("/\{(.*?)\}/e", '$\1', $CHAT_TABLE_START);
-//$textend = preg_replace("/\{(.*?)\}/e", '$\1', $CHAT_TABLE_END);
-
-$textstart = $tp->parseTemplate($CHAT_TABLE_START, true, $vars);
-$textend = $tp->parseTemplate($CHAT_TABLE_END, true, $vars);
-$text = $textstart.$textstring.$textend;
-
-if(CB_MOD)
-{
- $text = "";
-}
-
-$parms = "{$chat_total},30,{$from},".e_SELF.'?[FROM]';
-$text .= "".$tp->parseTemplate("{NEXTPREV={$parms}}").'
';
-
-
-$ns->tablerender(CHATBOX_L20, $mes->render().$text);
-
-
-
-require_once(FOOTERF);
-?>
\ No newline at end of file
+select('menus', "*", "menu_name='chatbox_menu'");
+$row = $sql->fetch();
+
+if ( ! check_class((int)$row['menu_class'])) {
+ $mes->addError(CHATBOX_L24);
+ $ns->tablerender(LAN_ERROR, $mes->render());
+ require_once(FOOTERF);
+ exit;
+}
+
+if ( ! isset($pref['cb_mod'])) {
+ $pref['cb_mod'] = e_UC_ADMIN;
+}
+
+define('CB_MOD', check_class($pref['cb_mod']));
+
+if ( ! empty($_POST['moderate']) && CB_MOD) {
+
+ if (isset($_POST['block'])) {
+
+ foreach (array_keys($_POST['block']) as $k) {
+ $kk[] = intval($k);
+ }
+
+ $blocklist = implode(",", $kk);
+ $sql->gen("UPDATE #chatbox SET cb_blocked=1 WHERE cb_id IN ({$blocklist})");
+ }
+
+
+ if (isset($_POST['unblock'])) {
+
+ foreach (array_keys($_POST['unblock']) as $k) {
+ $kk[] = intval($k);
+ }
+
+ $unblocklist = implode(",", $kk);
+ $sql->gen("UPDATE #chatbox SET cb_blocked=0 WHERE cb_id IN ({$unblocklist})");
+ }
+
+
+ if (isset($_POST['delete'])) {
+
+ $deletelist = implode(",", array_keys($_POST['delete']));
+
+ $query = "SELECT c.cb_id, u.user_id FROM #chatbox AS c
+ LEFT JOIN #user AS u ON SUBSTRING_INDEX(c.cb_nick,'.',1) = u.user_id
+ WHERE c.cb_id IN (" . $deletelist . ")";
+
+ $sql->gen($query);
+
+ $rowlist = $sql->rows();
+
+ foreach ($rowlist as $row) {
+ $userId = (int)$row['user_id'];
+ $sql->gen("UPDATE #user SET user_chats=user_chats-1 WHERE user_id = {$userId} ");
+ }
+
+ $sql->gen("DELETE FROM #chatbox WHERE cb_id IN ({$deletelist})");
+ }
+
+ e107::getCache()->clear("nq_chatbox");
+ $mes->addSuccess(CHATBOX_L18);
+}
+
+// when coming from search.php
+
+$fs = false;
+
+if (strstr(e_QUERY, "fs")) {
+ $cgtm = intval(str_replace(".fs", "", e_QUERY));
+ $fs = true;
+}
+// end search
+
+if (e_QUERY ? $from = intval(e_QUERY) : $from = 0) {
+ ;
+}
+
+$chat_total = $sql->count('chatbox');
+
+$qry_where = (CB_MOD ? "1" : "cb_blocked=0");
+
+
+
+// when coming from search.php calculate page number
+if ($fs) {
+
+ $page_count = 0;
+ $row_count = 0;
+
+ $sql->select("chatbox", "*", "{$qry_where} ORDER BY cb_datestamp DESC");
+
+ while ($row = $sql->fetch()) {
+
+ if ($row['cb_id'] == $cgtm) {
+ $from = $page_count;
+ break;
+ }
+
+ $row_count++;
+ if ($row_count == 30) {
+ $row_count = 0;
+ $page_count += 30;
+ }
+
+ }
+}
+// end search
+
+
+/** Render chat posts **/
+$sql->select("chatbox", "*",
+ "{$qry_where} ORDER BY cb_datestamp DESC LIMIT " . intval($from) . ", 30");
+
+$obj2 = new convert;
+
+$chatList = $sql->rows();
+
+$frm = e107::getForm();
+$vars = [];
+$flag = false;
+
+
+
+$CHATBOX_LIST_TEMPLATE =
+ e107::getTemplate('chatbox_menu', 'chatbox_menu', 'list');
+
+$sc = e107::getScBatch('chatbox_menu', true);
+
+
+$textstring = '';
+
+foreach ($chatList as $row) {
+
+ $sc->setVars($row);
+
+ $textstring .= $tp->parseTemplate($CHATBOX_LIST_TEMPLATE['item'], false, $sc);
+}
+
+
+$textstart = $tp->parseTemplate($CHATBOX_LIST_TEMPLATE['start'], true, $sc);
+$textend = $tp->parseTemplate($CHATBOX_LIST_TEMPLATE['end'], true, $sc);
+
+$text = $textstart . $textstring . $textend;
+
+
+if (CB_MOD) {
+
+ $text =
+ "";
+
+}
+
+$parms = "{$chat_total},30,{$from}," . e_SELF . '?[FROM]';
+
+$text .= "" . $tp->parseTemplate("{NEXTPREV={$parms}}") . '
';
+
+$ns->tablerender(CHATBOX_L20, $mes->render() . $text);
+
+require_once(FOOTERF);
diff --git a/e107_plugins/chatbox_menu/chatbox_menu.php b/e107_plugins/chatbox_menu/chatbox_menu.php
old mode 100644
new mode 100755
index a4a52930c..bbf14ed2d
--- a/e107_plugins/chatbox_menu/chatbox_menu.php
+++ b/e107_plugins/chatbox_menu/chatbox_menu.php
@@ -6,380 +6,302 @@
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
- */
+ * e107 chatbox_menu Plugin
+ *
+*/
-if(isset($_POST['chatbox_ajax']))
-{
- define('e_MINIMAL',true);
- if(!defined('e107_INIT')) require_once('../../class2.php');
+if (isset($_POST['chatbox_ajax'])) {
+ define('e_MINIMAL', true);
+ if ( ! defined('e107_INIT')) {
+ require_once('../../class2.php');
+ }
}
global $e107cache, $e_event, $e107;
$tp = e107::getParser();
-$pref = e107::getPref();
+$pref = e107::getPref();
-
-if (!e107::isInstalled('chatbox_menu'))
-{
+if ( ! e107::isInstalled('chatbox_menu')) {
return '';
}
-
e107::lan('chatbox_menu', e_LANGUAGE);
-// FIXME - start - LAN is not loaded
-/*
-if(($pref['cb_layer']==2) || isset($_POST['chatbox_ajax']))
-{
- if(isset($_POST['chat_submit']))
- {
-
- //Normally the menu.sc file will auto-load the language file, this is needed in case
- //ajax is turned on and the menu is not loaded from the menu.sc
- inclXXXude_lan(e_PLUGIN.'chatbox_menu/languages/'.e_LANGUAGE.'/'.e_LANGUAGE.'.php');
- }
-}
-// FIXME - end
-*/
-// if(!defined('e_HANDLER')){ exit; }
-// require_once(e_HANDLER.'emote.php');
-
-$emessage='';
-
-/**
- * Chatbox Menu Shortcodes.
- */
-if(!class_exists('chatbox_shortcodes'))
-{
- class chatbox_shortcodes extends e_shortcode
- {
-
- function sc_cb_username($parm='')
- {
- list($cb_uid, $cb_nick) = explode(".", $this->var['cb_nick'], 2);
- if($this->var['user_name'])
- {
- //$cb_nick = "".$this->var['user_name']."";
- $uparams = array('id' => $cb_uid, 'name' => $this->var['user_name']);
- $link = e107::getUrl()->create('user/profile/view', $uparams);
- $cb_nick = "".$this->var['user_name']."";
- }
- else
- {
- $tp = e107::getParser();
- $cb_nick = $tp -> toHTML($cb_nick,FALSE,'USER_TITLE, emotes_off, no_make_clickable');
- $cb_nick = str_replace("Anonymous", LAN_ANONYMOUS, $cb_nick);
- }
-
- return $cb_nick;
- }
-
- function sc_cb_timedate($parm='')
- {
- return e107::getDate()->convert_date($this->var['cb_datestamp'], "relative");
- }
-
-
- function sc_cb_message($parm = '')
- {
- if($this->var['cb_blocked'])
- {
- return CHATBOX_L6;
- }
-
- $pref = e107::getPref();
- $emotes_active = $pref['cb_emote'] ? 'USER_BODY, emotes_on' : 'USER_BODY, emotes_off';
-
- list($cb_uid, $cb_nick) = explode(".", $this->var['cb_nick'], 2);
-
- $cb_message = e107::getParser()->toHTML($this->var['cb_message'], false, $emotes_active, $cb_uid, $pref['menu_wordwrap']);
-
- return $cb_message;
- /*
- $replace[0] = "["; $replace[1] = "]";
- $search[0] = "["; $search[1] = "]";
- $cb_message = str_replace($search, $replace, $cb_message);
- */
- }
-
- function sc_cb_avatar($parm='')
- {
- return e107::getParser()->toAvatar($this->var); // parseTemplate("{USER_AVATAR=".vartrue($this->var['user_image'])."}");
- }
-
- function sc_cb_bullet($parm = '')
- {
- $bullet = "";
-
- if(defined('BULLET'))
- {
- $bullet = '
';
- }
- elseif(file_exists(THEME.'images/bullet2.gif'))
- {
- $bullet = '
';
- }
-
- return $bullet;
- }
-
- }
-}
+$emessage = '';
-if((isset($_POST['chat_submit']) || e_AJAX_REQUEST) && $_POST['cmessage'] != '')
-{
- if(!USER && !$pref['anon_post'])
- {
+if ((isset($_POST['chat_submit']) || e_AJAX_REQUEST) && $_POST['cmessage'] !== '') {
+
+ if ( ! USER && ! $pref['anon_post']) {
// disallow post
- }
- else
- {
- $nick = trim(preg_replace("#\[.*\]#si", "", $tp -> toDB($_POST['nick'])));
+ } else {
+ $nick = trim(preg_replace("#\[.*\]#si", "", $tp->toDB($_POST['nick'])));
$cmessage = $_POST['cmessage'];
$cmessage = preg_replace("#\[.*?\](.*?)\[/.*?\]#s", "\\1", $cmessage);
+
$fp = new floodprotect;
- if($fp -> flood("chatbox", "cb_datestamp"))
- {
- if((strlen(trim($cmessage)) < 1000) && trim($cmessage) != "")
- {
- $cmessage = $tp -> toDB($cmessage);
- if($sql->select("chatbox", "*", "cb_message='$cmessage' AND cb_datestamp+84600>".time()))
- {
+
+ if ($fp->flood('chatbox', 'cb_datestamp')) {
+ if ((strlen(trim($cmessage)) < 1000) && trim($cmessage) !== '') {
+
+ $cmessage = $tp->toDB($cmessage);
+
+ if ($sql->select('chatbox', '*',
+ "cb_message='{$cmessage}' AND cb_datestamp+84600>" . time())) {
+
$emessage = CHATBOX_L17;
- }
- else
- {
+
+ } else {
+
$datestamp = time();
- $ip = e107::getIPHandler()->getIP(FALSE);
- if(USER)
- {
- $nick = USERID.".".USERNAME;
- $sql -> db_Update("user", "user_chats=user_chats+1, user_lastpost='".time()."' WHERE user_id='".USERID."' ");
- }
- else if(!$nick)
- {
- $nick = "0.Anonymous";
- }
- else
- {
- if($sql->select("user", "*", "user_name='$nick' ")){
+ $ip = e107::getIPHandler()->getIP(false);
+
+ if (USER) {
+
+ $nick = USERID . "." . USERNAME;
+
+ $postTime = time();
+ $sql->update('user', "user_chats = user_chats + 1, user_lastpost = {$postTime} WHERE user_id = " . USERID);
+
+ } else if ( ! $nick) {
+
+ $nick = '0.Anonymous';
+
+ } else {
+
+ if ($sql->select('user', '*', "user_name='$nick' ")) {
+
$emessage = CHATBOX_L1;
+
+ } else {
+
+ $nick = "0." . $nick;
+
}
- else
- {
- $nick = "0.".$nick;
- }
+
}
- if(!$emessage)
- {
- $insertId = $sql->insert("chatbox", "0, '{$nick}', '{$cmessage}', '{$datestamp}', '0' , '{$ip}' ");
-
- if($insertId)
- {
- $edata_cb = array("id" => $insertId, "nick" => $nick, "cmessage" => $cmessage, "datestamp" => $datestamp, "ip" => $ip);
+ if ( ! $emessage) {
+ $insertId = $sql->insert('chatbox',
+ "0, '{$nick}', '{$cmessage}', '{$datestamp}', 0, '{$ip}' ");
+
+ if ($insertId) {
+
+ $edata_cb = [
+ 'id' => $insertId,
+ 'nick' => $nick,
+ 'cmessage' => $cmessage,
+ 'datestamp' => $datestamp,
+ 'ip' => $ip,
+ ];
+
$e_event->trigger("cboxpost", $edata_cb); // deprecated
+
e107::getEvent()->trigger('user_chatbox_post_created', $edata_cb);
- $e107cache->clear("nq_chatbox");
+ $e107cache->clear('nq_chatbox');
}
+
}
}
- }
- else
- {
+ } else {
$emessage = CHATBOX_L15;
}
- }
- else
- {
+ } else {
$emessage = CHATBOX_L19;
}
}
}
-if(!USER && !$pref['anon_post']){
- if($pref['user_reg'])
- {
- $text1 = str_replace(array('[',']'), array("", ""), CHATBOX_L3);
- if($pref['user_reg'] == 1 ){
- $text1 .= str_replace(array('[',']'), array("", ""), CHATBOX_L3b);
- }
- $texta = "".$text1."
";
- }
-}
-else
-{
- $cb_width = (defined("CBWIDTH") ? CBWIDTH : "");
- if($pref['cb_layer'] == 2)
- {
- $texta = "\n\n";
+ $texta .= "\n\n";
}
-if($emessage != ""){
- $texta .= "".$emessage."
";
+
+if ($emessage !== '') {
+ $texta .= "" . $emessage . "
";
}
-if(!$text = $e107cache->retrieve("nq_chatbox"))
-{
- global $pref,$tp;
- $pref['chatbox_posts'] = ($pref['chatbox_posts'] ? $pref['chatbox_posts'] : 10);
+
+if ( ! $text = $e107cache->retrieve("nq_chatbox")) {
+
+ global $pref, $tp;
+
+ $pref['chatbox_posts'] =
+ ($pref['chatbox_posts'] ? $pref['chatbox_posts'] : 10);
+
$chatbox_posts = $pref['chatbox_posts'];
- if(!isset($pref['cb_mod']))
- {
+
+ if ( ! isset($pref['cb_mod'])) {
$pref['cb_mod'] = e_UC_ADMIN;
}
- if(!defined('CB_MOD'))
- {
+ if ( ! defined('CB_MOD')) {
define("CB_MOD", check_class($pref['cb_mod']));
}
- $qry = "
- SELECT c.*, u.user_name, u.user_image FROM #chatbox AS c
- LEFT JOIN #user AS u ON SUBSTRING_INDEX(c.cb_nick,'.',1) = u.user_id
- ORDER BY c.cb_datestamp DESC LIMIT 0, ".intval($chatbox_posts);
+ $qry = "SELECT c.*, u.user_name, u.user_image FROM #chatbox AS c
+ LEFT JOIN #user AS u ON SUBSTRING_INDEX(c.cb_nick, '.', 1) = u.user_id
+ ORDER BY c.cb_datestamp DESC LIMIT 0, " . (int)$chatbox_posts;
global $CHATBOXSTYLE;
-
- if($CHATBOXSTYLE)
+
+ if($CHATBOXSTYLE) // legacy chatbox style
{
- $legacySrch = array('{USERNAME}','{MESSAGE}','{TIMEDATE}');
- $legacyRepl = array('{CB_USERNAME}','{CB_MESSAGE}','{CB_TIMEDATE}');
-
-
- $CHATBOX_TEMPLATE['start'] = "";
- $CHATBOX_TEMPLATE['item'] = str_replace($legacySrch,$legacyRepl,$CHATBOXSTYLE);
- $CHATBOX_TEMPLATE['end'] = "";
+ $legacyIconSrc = e_IMAGE_ABS . 'admin_images/chatbox_16.png';
+ $currentIconSrc = e_PLUGIN . 'chatbox_menu/images/chatbox_16.png';
+
+ $legacySrch = array($legacyIconSrc, '{USERNAME}', '{MESSAGE}', '{TIMEDATE}');
+ $legacyRepl = array($currentIconSrc, '{CB_USERNAME}','{CB_MESSAGE}','{CB_TIMEDATE}');
+
+
+ $CHATBOX_TEMPLATE['start'] = '';
+ $CHATBOX_TEMPLATE['item'] = str_replace($legacySrch, $legacyRepl, $CHATBOXSTYLE);
+ $CHATBOX_TEMPLATE['end'] = '';
}
else // default chatbox style
{
- $tp->parseTemplate("{SETIMAGE: w=40}",true); // set thumbnail size.
- // FIXME - move to template
- $CHATBOX_TEMPLATE['start'] = "";
+ $CHATBOX_TEMPLATE = e107::getTemplate('chatbox_menu', null, 'menu');
}
-
+
// FIX - don't call getScBatch() if don't need to globally register the methods
// $sc = e107::getScBatch('chatbox');
-
- // the good way in this case - it works with any object having sc_*, models too
- $sc = new chatbox_shortcodes();
- if($sql->gen($qry))
- {
- $cbpost = $sql->db_getList();
+ // the good way in this case - it works with any object having sc_*, models too
+ //$sc = new chatbox_shortcodes();
+
+ $sc = e107::getScBatch('chatbox_menu', true);
+
+ if ($sql->gen($qry)) {
+
+ $cbpost = $sql->rows();
+
$text .= "\n";
$text .= $tp->parseTemplate($CHATBOX_TEMPLATE['start'], false, $sc);
- foreach($cbpost as $cb)
- {
+ foreach ($cbpost as $cb) {
$sc->setVars($cb);
$text .= $tp->parseTemplate($CHATBOX_TEMPLATE['item'], false, $sc);
}
-
+
$text .= $tp->parseTemplate($CHATBOX_TEMPLATE['end'], false, $sc);
$text .= "
";
+
+ } else {
+ $text .= "" . CHATBOX_L11 . "";
}
- else
- {
- $text .= "".CHATBOX_L11."";
- }
-
-
+
$total_chats = $sql->count("chatbox");
- if($total_chats > $chatbox_posts || CB_MOD)
- {
- $text .= "
";
+
+ if ($total_chats > $chatbox_posts || CB_MOD) {
+ $text .= "
";
}
+
$e107cache->set("nq_chatbox", $text);
}
+$caption = (file_exists(THEME . "images/chatbox_menu.png")
+ ? "
" . LAN_PLUGIN_CHATBOX_MENU_NAME
+ : LAN_PLUGIN_CHATBOX_MENU_NAME);
+if ($pref['cb_layer'] === 1) {
-$caption = (file_exists(THEME."images/chatbox_menu.png") ? "
".LAN_PLUGIN_CHATBOX_MENU_NAME : LAN_PLUGIN_CHATBOX_MENU_NAME);
+ $text =
+ $texta . "" . $text . "
";
-if($pref['cb_layer'] == 1)
-{
- $text = $texta."".$text."
";
- $ns -> tablerender($caption, $text, 'chatbox');
-}
-elseif($pref['cb_layer'] == 2 && e_AJAX_REQUEST)
-{
- $text = $texta.$text;
+ $ns->tablerender($caption, $text, 'chatbox');
+
+} elseif ($pref['cb_layer'] === 2 && e_AJAX_REQUEST) {
+
+ $text = $texta . $text;
$text = str_replace(e_IMAGE, e_IMAGE_ABS, $text);
echo $text;
-}
-else
-{
- $text = $texta.$text;
- if($pref['cb_layer'] == 2)
- {
- $text = "".$text."
";
+
+} else {
+
+ $text = $texta . $text;
+
+ if ($pref['cb_layer'] === 2) {
+ $text = "" . $text . "
";
}
- $ns -> tablerender($caption, $text, 'chatbox');
+
+ $ns->tablerender($caption, $text, 'chatbox');
}
-//$text = ($pref['cb_layer'] ? $texta."".$text."
" : $texta.$text);
-//if(ADMIN && getperms("C")){$text .= "
";}
-//$ns -> tablerender($caption, $text, 'chatbox');
-
-
-?>
diff --git a/e107_plugins/chatbox_menu/chatbox_menu_shortcodes.php b/e107_plugins/chatbox_menu/chatbox_menu_shortcodes.php
new file mode 100644
index 000000000..d7a16ba8d
--- /dev/null
+++ b/e107_plugins/chatbox_menu/chatbox_menu_shortcodes.php
@@ -0,0 +1,214 @@
+var['user_image'] ) {
+ $this->addVars($this->retrieveUserDataByNick($this->var['cb_nick']));
+ }
+
+ }
+
+
+ /**
+ * Returns extended user data from user object
+ *
+ * @param $nick string
+ *
+ * @return array user data
+ */
+ protected function retrieveUserDataByNick($nick)
+ {
+
+ $tmp = explode('.', $nick);
+ $userId = (int)$tmp[0];
+
+ return e107::user($userId);
+
+ }
+
+
+ /**
+ * Returns user avatar
+ *
+ * @param $parm
+ *
+ * @return \
+ */
+ public function sc_cb_avatar($parm = null)
+ {
+ $this->init();
+
+ $size = $parm['size'] ?: 40;
+ $tp = e107::getParser();
+
+ return $tp->toAvatar($this->var, ['h' => $size, 'w' => $size, 'crop' => 'C']);
+ }
+
+
+ /**
+ * Returns user profile link
+ *
+ * @param null $parm
+ *
+ * @return mixed|string
+ */
+ public function sc_cb_username($parm = null)
+ {
+
+ if (! $this->var['user_id'] && ! $this->var['user_name']) {
+
+ $tmp = explode('.', $this->var['cb_nick']);
+
+ $link = e107::getUrl()->create('user/profile/view', array('id' => $tmp[0], 'name' => $tmp[1]));
+
+ $userName = str_replace('Anonymous', LAN_ANONYMOUS, $tmp[1]);
+
+ return '' . $userName . '';
+
+ }
+
+ $this->init();
+
+ $userData = [
+ 'id' => $this->var['user_id'],
+ 'name' => $this->var['user_name'],
+ ];
+
+ $link = e107::getUrl()->create('user/profile/view', $userData);
+
+ return '' . $this->var['user_name'] . '';
+ }
+
+
+ /**
+ * Returns relative timestamp
+ *
+ * @param null $parm
+ *
+ * @return string
+ */
+ public function sc_cb_timedate($parm = null)
+ {
+
+ return e107::getDate()
+ ->convert_date($this->var['cb_datestamp'], 'relative');
+ }
+
+
+ /**
+ * Returns chatbox message
+ *
+ * @param null $parm
+ *
+ * @return string
+ */
+ public function sc_cb_message($parm = null)
+ {
+ $this->init();
+
+ if ($this->var['cb_blocked']) {
+ return CHATBOX_L6;
+ }
+
+ $pref = e107::getPref();
+ $emotes_active = $pref['cb_emote'] ? 'USER_BODY, emotes_on'
+ : 'USER_BODY, emotes_off';
+
+ $cb_message = e107::getParser()
+ ->toHTML($this->var['cb_message'], false, $emotes_active,
+ $this->var['user_id'], $pref['menu_wordwrap']);
+
+ return $cb_message;
+ }
+
+
+ /**
+ * Returns bullet image
+ *
+ * @param null $parm
+ *
+ * @return string
+ */
+ public function sc_cb_bullet($parm = null)
+ {
+ $bullet = '';
+
+ if (defined('BULLET')) {
+ $bullet =
+ '
';
+ } elseif (file_exists(THEME . 'images/bullet2.gif')) {
+ $bullet =
+ '
';
+ }
+
+ return $bullet;
+ }
+
+
+ /**
+ * Returns moderator options
+ *
+ * @param null $parm
+ *
+ * @return string
+ */
+ public function sc_cb_mod($parm = null)
+ {
+ $frm = e107::getForm();
+ $modControls = '';
+
+ if (CB_MOD) {
+ $id = $this->var['cb_id'];
+
+ $modControls .= "";
+
+ $modControls .= $frm->checkbox('delete[' . $id . ']', 1, false,
+ ['inline' => true, 'label' => LAN_DELETE]);
+
+ if ($this->var['cb_blocked']) {
+ $modControls .= $frm->checkbox('unblock[' . $id . ']', 1, false,
+ ['inline' => true, 'label' => CHATBOX_L7]);
+ } else {
+ $modControls .= $frm->checkbox('block[' . $id . ']', 1, false,
+ ['inline' => true, 'label' => CHATBOX_L9]);
+ }
+
+ $modControls .= '';
+ }
+
+ return $modControls;
+ }
+
+
+ /**
+ * Returns moderator block message
+ *
+ * @param null $parm
+ *
+ * @return string
+ */
+ public function sc_cb_blocked($parm = null)
+ {
+ return $this->var['cb_blocked'] ? '' . CHATBOX_L25 . '' : '';
+ }
+
+}
diff --git a/e107_plugins/chatbox_menu/templates/chatbox_menu_template.php b/e107_plugins/chatbox_menu/templates/chatbox_menu_template.php
new file mode 100644
index 000000000..5715d0b30
--- /dev/null
+++ b/e107_plugins/chatbox_menu/templates/chatbox_menu_template.php
@@ -0,0 +1,60 @@
+' . PHP_EOL;
+
+$CHATBOX_MENU_TEMPLATE['menu']['item'] = '
+
+
+ {CB_AVATAR}
+
+
+
{CB_USERNAME}
+
{CB_TIMEDATE}
+
{CB_MESSAGE}
+
+' . PHP_EOL;
+
+$CHATBOX_MENU_TEMPLATE['menu']['end'] = ''. PHP_EOL;
+
+
+//---------------------------------LIST-----------------------------------------
+
+$CHATBOX_MENU_TEMPLATE['list']['start'] =
+ ''. PHP_EOL;
+
+
+