|
From: <ir...@us...> - 2013-02-12 01:49:58
|
Revision: 11025
http://sourceforge.net/p/xoops/svn/11025
Author: irmtfan
Date: 2013-02-12 01:49:55 +0000 (Tue, 12 Feb 2013)
Log Message:
-----------
improve: add multi topic poster and multi last poster
fix: multi status and multi display header in NewbbTopicRenderer class
Modified Paths:
--------------
XoopsModules/newbb/branches/irmtfan/newbb/blocks/list_topic.php
XoopsModules/newbb/branches/irmtfan/newbb/changelog-rev10109.txt
XoopsModules/newbb/branches/irmtfan/newbb/class/topic.renderer.php
XoopsModules/newbb/branches/irmtfan/newbb/list.topic.php
XoopsModules/newbb/branches/irmtfan/newbb/xoops_version.php
Modified: XoopsModules/newbb/branches/irmtfan/newbb/blocks/list_topic.php
===================================================================
--- XoopsModules/newbb/branches/irmtfan/newbb/blocks/list_topic.php 2013-02-12 00:36:10 UTC (rev 11024)
+++ XoopsModules/newbb/branches/irmtfan/newbb/blocks/list_topic.php 2013-02-12 01:49:55 UTC (rev 11025)
@@ -29,16 +29,17 @@
// options[0] - Status in WHERE claus: all(by default), sticky, digest,lock, poll, voted, viewed, replied, read, (UN_) , active, pending, deleted (admin) (It is multi-select)
// options[1] - Uid in WHERE claus: uid of the topic poster : 0 - all users (by default)
-// options[2] - Type in WHERE claus: topic type in the forum : 0 - none (by default)
-// options[3] - Sort in ORDER claus: topic, forum, poster, replies, views, lastpost(by default), lastposttime, lastposter, lastpostmsgicon, ratings, votes, publish, digest, sticky, lock, poll, type (if exist), approve(admin mode)
-// options[4] - Order in ORDER claus: Descending(by default), Ascending
-// options[5] - NumberToDisplay: any positive integer
-// options[6] - TimeDuration: negative for hours, positive for days, for instance, -5 for 5 hours and 5 for 5 days
-// options[7] - DisplayMode: all fields in sort PLUS attachment, read, pagenav
-// options[8] - Display Navigator: 1 (by default), 0 (No)
-// options[9] - Title Length : 0 - no limit and show complete title
-// options[10] - Post text Length: 0 - dont show post text
-// options[11] - SelectedForumIDs: multi-select ngative values for categories and positive values for forums: null for all(by default)
+// options[2] - Lastposter in WHERE claus: uid of the lastposter in topic : 0 - all users (by default)
+// options[3] - Type in WHERE claus: topic type in the forum : 0 - none (by default)
+// options[4] - Sort in ORDER claus: topic, forum, poster, replies, views, lastpost(by default), lastposttime, lastposter, lastpostmsgicon, ratings, votes, publish, digest, sticky, lock, poll, type (if exist), approve(admin mode)
+// options[5] - Order in ORDER claus: Descending(by default), Ascending
+// options[6] - NumberToDisplay: any positive integer
+// options[7] - TimeDuration: negative for hours, positive for days, for instance, -5 for 5 hours and 5 for 5 days
+// options[8] - DisplayMode: all fields in sort PLUS attachment, read, pagenav
+// options[9] - Display Navigator: 1 (by default), 0 (No)
+// options[10] - Title Length : 0 - no limit and show complete title
+// options[11] - Post text Length: 0 - dont show post text
+// options[12] - SelectedForumIDs: multi-select ngative values for categories and positive values for forums: null for all(by default)
function newbb_list_topic_show($options)
{
@@ -51,37 +52,36 @@
$topicRenderer->is_multiple = true; // is it for multiple forums
$topicRenderer->config =& $newbbConfig; // get all configs
- if (!empty($options[5])) {
- $topicRenderer->config['topics_per_page'] = intval($options[5]); // number of topics (items) to display
+ if (!empty($options[6])) {
+ $topicRenderer->config['topics_per_page'] = intval($options[6]); // number of topics (items) to display
}
- $topicRenderer->config['topic_title_excerpt'] = intval($options[9]); // topic title length 0 = dont excerpt
- $topicRenderer->config['post_excerpt'] = intval($options[10]); // post text excerpt 0 = no post text
+ $topicRenderer->config['topic_title_excerpt'] = intval($options[10]); // topic title length 0 = dont excerpt
+ $topicRenderer->config['post_excerpt'] = intval($options[11]); // post text excerpt 0 = no post text
$options_status = explode(',', $options[0]); // status in where claus
- $options_forum = explode(',', $options[11]);
+ $options_forum = explode(',', $options[12]);
// set and parse values:
// forum: parse positive values to forum IDs and negative values to category IDs. value=0 => all valid forums
$topicRenderer->setVars(array(
'status' => $options_status,
'uid' => $options[1],
- 'type' => $options[2],
- 'sort' => $options[3],
- 'order' => $options[4],
- 'since' => $options[6],
+ 'lastposter' => $options[2],
+ 'type' => $options[3],
+ 'sort' => $options[4],
+ 'order' => $options[5],
+ 'since' => $options[7],
'forum' => $options_forum,
));
$block = array();
- $options_headers = explode(',', $options[7]);// headers to display in block
- // get the title for each header
- foreach ($options_headers as $header) {
- $block['headers'][$header] = $topicRenderer->getHeader($header);
- }
+ // headers to display in block
+ $block['headers'] = $topicRenderer->getHeader($options[8]);
+
// render a list of topics using all above criterias
list($block['topics'], $block['sticky']) = $topicRenderer->renderTopics();
// show index navigation
- $block['indexNav'] = !empty($options[8]);
+ $block['indexNav'] = !empty($options[9]);
return $block;
}
@@ -106,11 +106,24 @@
$statusEle->setDescription(_MB_NEWBB_CRITERIA_DESC);
// topic_poster element
- $topicPosterEle = new XoopsFormSelectUser(_MB_NEWBB_AUTHOR, 'options[1]', true, $options[1], 1, false);
+ $topicPosterRadioEle = new XoopsFormRadio(_MB_NEWBB_AUTHOR, 'options[1]', !empty($options[1]));
+ $topicPosterRadioEle->addOption(0,_MD_TOTALUSER);
+ $topicPosterRadioEle->addOption(!empty($options[1]) ? $options[1] : 1,_SELECT); // if no user in selection box it select uid=1
+ $topicPosterRadioEle->setExtra("onchange=\"var el=document.getElementById('options[1]'); el.disabled=(this.id == 'options[1]1'); if (!el.value) {el.value= this.value}\""); // if user dont select any option it select "all"
+ $topicPosterSelectEle = new XoopsFormSelectUser(_MB_NEWBB_AUTHOR, 'options[1]', false, explode(',', $options[1]), 5, true);
+ $topicPosterEle = new XoopsFormLabel(_MB_NEWBB_AUTHOR, $topicPosterRadioEle->render().$topicPosterSelectEle->render());
+
+ // lastposter element
+ $lastPosterRadioEle = new XoopsFormRadio(_MD_POSTER, 'options[2]', !empty($options[2]));
+ $lastPosterRadioEle->addOption(0,_MD_TOTALUSER);
+ $lastPosterRadioEle->addOption(!empty($options[2]) ? $options[2] : 1,_SELECT); // if no user in selection box it select uid=1
+ $lastPosterRadioEle->setExtra("onchange=\"var el=document.getElementById('options[2]'); el.disabled=(this.id == 'options[2]1'); if (!el.value) {el.value= this.value}\""); // if user dont select any option it select "all"
+ $lastPosterSelectEle = new XoopsFormSelectUser(_MD_POSTER, 'options[2]', false, explode(',', $options[2]), 5, true);
+ $lastPosterEle = new XoopsFormLabel(_MD_POSTER, $lastPosterRadioEle->render().$lastPosterSelectEle->render());
// type element
$types = $topicRenderer -> getTypes(); // get all available types in all forums
- $typeEle = new XoopsFormSelect(_MD_NEWBB_TYPE, 'options[2]', $options[2]);
+ $typeEle = new XoopsFormSelect(_MD_NEWBB_TYPE, 'options[3]', $options[3]);
$typeEle->addOption(0, _NONE);
if (!empty($types)) {
foreach ($types as $type_id => $type) {
@@ -119,50 +132,50 @@
}
// sort element
- $sortEle = new XoopsFormSelect(_MD_SORTBY, 'options[3]', $options[3]);
+ $sortEle = new XoopsFormSelect(_MD_SORTBY, 'options[4]', $options[4]);
$sortEle->setDescription(_MB_NEWBB_CRITERIA_SORT_DESC);
$sorts = $topicRenderer -> getSort("", "title");
$sortEle->addOptionArray($sorts);
// order element
- $orderEle = new XoopsFormSelect(_MB_NEWBB_CRITERIA_ORDER, 'options[4]', $options[4]);
+ $orderEle = new XoopsFormSelect(_MB_NEWBB_CRITERIA_ORDER, 'options[5]', $options[5]);
$orderEle->addOption(0, _DESCENDING);
$orderEle->addOption(1, _ASCENDING);
// number of topics to display element
- $numdispEle = new XoopsFormText(_MB_NEWBB_DISPLAY, 'options[5]', 10, 255, intval($options[5]));
+ $numdispEle = new XoopsFormText(_MB_NEWBB_DISPLAY, 'options[6]', 10, 255, intval($options[6]));
- $timeEle = new XoopsFormText(_MB_NEWBB_TIME, 'options[6]', 10, 255, $options[6]);
+ $timeEle = new XoopsFormText(_MB_NEWBB_TIME, 'options[7]', 10, 255, $options[7]);
$timeEle->setDescription(_MB_NEWBB_TIME_DESC);
// mode disp element
- $options_headers = explode(',', $options[7]);
- $modeEle = new XoopsFormCheckBox(_MB_NEWBB_DISPLAYMODE, 'options[7][]', $options_headers);
+ $options_headers = explode(',', $options[8]);
+ $modeEle = new XoopsFormCheckBox(_MB_NEWBB_DISPLAYMODE, 'options[8][]', $options_headers);
$modeEle->setDescription(_MB_NEWBB_DISPLAYMODE_DESC);
$modeEle->columns = 4;
$disps = $topicRenderer -> getHeader();
$modeEle->addOptionArray($disps);
- $modeEle->setExtra("onchange = \"validate('options[7][]','checkbox', true)\""); // prevent user select no option
+ $modeEle->setExtra("onchange = \"validate('options[8][]','checkbox', true)\""); // prevent user select no option
// Index navigation element
- $navEle = new XoopsFormRadioYN(_MB_NEWBB_INDEXNAV, 'options[8]', !empty($options[8]));
+ $navEle = new XoopsFormRadioYN(_MB_NEWBB_INDEXNAV, 'options[9]', !empty($options[9]));
// Topic title element
- $lengthEle = new XoopsFormText( _MB_NEWBB_TITLE_LENGTH, 'options[9]', 10, 255, intval($options[9]));
+ $lengthEle = new XoopsFormText( _MB_NEWBB_TITLE_LENGTH, 'options[10]', 10, 255, intval($options[10]));
$lengthEle->setDescription(_MB_NEWBB_TITLE_LENGTH_DESC);
// Post text element
- $postExcerptEle = new XoopsFormText( _MB_NEWBB_POST_EXCERPT, 'options[10]', 10, 255, intval($options[10]));
+ $postExcerptEle = new XoopsFormText( _MB_NEWBB_POST_EXCERPT, 'options[11]', 10, 255, intval($options[11]));
$postExcerptEle->setDescription(_MB_NEWBB_POST_EXCERPT_DESC);
// forum element
- $options_forum = explode(',', $options[11]);
+ $options_forum = explode(',', $options[12]);
mod_loadFunctions("forum", "newbb");
$forum_handler = xoops_getmodulehandler('forum', 'newbb');
//get forum Ids by values. parse positive values to forum IDs and negative values to category IDs. value=0 => all valid forums
// Get accessible forums
$access_forums = $forum_handler->getIdsByValues(array_map("intval", $options_forum));
$isAll = (count($options_forum) == 0 || empty($options_forum[0]));
- $forumSel = "<select name=\"options[11][]\" multiple=\"multiple\" onchange = \"validate('options[11][]','select', true)\">";// if user dont select any it select "0"
+ $forumSel = "<select name=\"options[12][]\" multiple=\"multiple\" onchange = \"validate('options[12][]','select', true)\">";// if user dont select any it select "0"
$forumSel .= "<option value=\"0\" ";
if ($isAll) {
$forumSel .= " selected";
@@ -176,6 +189,7 @@
// add all elements to form
$form->addElement($statusEle);
$form->addElement($topicPosterEle);
+ $form->addElement($lastPosterEle);
$form->addElement($typeEle);
$form->addElement($sortEle);
$form->addElement($orderEle);
Modified: XoopsModules/newbb/branches/irmtfan/newbb/changelog-rev10109.txt
===================================================================
--- XoopsModules/newbb/branches/irmtfan/newbb/changelog-rev10109.txt 2013-02-12 00:36:10 UTC (rev 11024)
+++ XoopsModules/newbb/branches/irmtfan/newbb/changelog-rev10109.txt 2013-02-12 01:49:55 UTC (rev 11025)
@@ -1,3 +1,12 @@
+date 2013-02-11
+===================================
+1- improve: add multi topic poster and multi last poster to NewbbTopicRenderer class (used in block and list.topic.php)
+newbb/class/topic.renderer.php, newbb/xoops_version.php,
+newbb/list.topic.php, newbb/blocks/list_topic.php
+
+2- improve and fix: multi status and multi display header in NewbbTopicRenderer class
+newbb/class/topic.renderer.php, newbb/list.topic.php, newbb/blocks/list_topic.php
+
date 2013-02-07
===================================
1- improve: enhance the advance block. add more sorts: lastposttime, lastposter, lastpostmsgicon . add more display mode: attachment, read, pagenav
Modified: XoopsModules/newbb/branches/irmtfan/newbb/class/topic.renderer.php
===================================================================
--- XoopsModules/newbb/branches/irmtfan/newbb/class/topic.renderer.php 2013-02-12 00:36:10 UTC (rev 11024)
+++ XoopsModules/newbb/branches/irmtfan/newbb/class/topic.renderer.php 2013-02-12 01:49:55 UTC (rev 11025)
@@ -43,7 +43,7 @@
/**
* query variables
*/
- var $args = array("forum", "uid", "type", "status", "mode", "sort", "order", "start", "since");
+ var $args = array("forum", "uid", "lastposter", "type", "status", "mode", "sort", "order", "start", "since");// irmtfan add multi lastposter
var $vars = array();
/**
@@ -115,7 +115,6 @@
// END irmtfan - if the forum is array
break;
- case "uid":
case "type":
case "mode":
case "order":
@@ -123,7 +122,11 @@
case "since":
$val = intval($val);
break;
-
+
+ case "uid": // irmtfan add multi topic poster
+ case "lastposter": // irmtfan add multi lastposter
+ break;
+
case "status":
// START irmtfan to accept multiple status
$val = is_array($val) ? $val : array($val);
@@ -340,25 +343,32 @@
}
break;
- case "uid":
+ case "uid": // irmtfan add multi topic poster
if (!empty($val)) {
- $this->query["where"][] = "t.topic_poster = ". $val;
+ $val = implode(",",array_map("intval", explode(",", $val)));
+ $this->query["where"][] = "t.topic_poster IN ( ". $val ." )";
}
break;
+ case "lastposter": // irmtfan add multi lastposter
+ if (!empty($val)) {
+ $val = implode(",",array_map("intval", explode(",", $val)));
+ $this->query["where"][] = "p.uid IN ( ". $val ." )";
+ }
+ break;
case "since":
if (!empty($val)) {
- // START irmtfan if unread && read_mode = 1 and last_visit > startdate do not add where query
+ // START irmtfan if unread && read_mode = 1 and last_visit > startdate do not add where query | to accept multiple status
$startdate = time() - newbb_getSinceTime($val);
- if ( $this->vars["status"] == "unread" && $this->config["read_mode"] == 1 && $GLOBALS['last_visit'] > $startdate )
+ if ( in_array("unread", explode(",",$this->vars["status"])) && $this->config["read_mode"] == 1 && $GLOBALS['last_visit'] > $startdate )
break;
- // irmtfan digest_time
- if ($this->vars["status"] == "digest") {
+ // irmtfan digest_time | to accept multiple status
+ if (in_array("digest", explode(",",$this->vars["status"]))) {
$this->query["where"][] = "t.digest_time > ". $startdate;
}
// irmtfan - should be >= instead of =
$this->query["where"][] = "p.post_time >= ". $startdate;
- // START irmtfan if unread && read_mode = 1 and last_visit > startdate do not add where query
+ // END irmtfan if unread && read_mode = 1 and last_visit > startdate do not add where query
}
break;
@@ -523,10 +533,7 @@
"read" => _MD_MARK_UNREAD.'|'._MD_MARK_READ, // read/unread show topic_folder smarty
"pagenav" => _MD_PAGENAV_DISPLAY, // show topic_page_jump smarty - sort by topic_replies?
));
- if (empty($header)) {
- return $headers;
- }
- return @$headers[$header];
+ return $this->getFromKeys($headers, $header);
}
// END irmtfan add Display topic headers function
function getStatus($type = null, $status = null)
@@ -558,23 +565,11 @@
"deleted" => _MD_TYPE_DELETED,
);
- // specified status
- if ($status !== null) {
- if (isset($links[$status])) return $links[$status];
- return @$links_admin[$status];
- }
-
// all status, for admin
if ($type > 1) {
- return array_merge($links, $links_admin);
+ $links = array_merge($links, $links_admin);// irmtfan to accept multiple status
}
-
- // for regular users
- //if ($type == 1) {
- return $links;
- //}
-
- //return $links_admin;
+ return $this->getFromKeys($links, $status); // irmtfan to accept multiple status
}
function buildSelection(&$xoopsTpl)
@@ -702,7 +697,7 @@
}
$status = array();
- $status["title"] = $this->getStatus(0, empty($this->vars["status"]) ? "all" : $this->vars["status"]);
+ $status["title"] = implode(",",$this->getStatus($this->userlevel, $this->vars["status"])); // irmtfan to accept multiple status
//$status["link"] = $this->page.(empty($this->vars["status"]) ? "" : "?status=".$this->vars["status"]);
$status["link"] = $this->page.(empty($args) ? "" : "?".implode("&", $args));
@@ -1026,6 +1021,19 @@
}
return array($topics, $sticky);
}
+ // START irmtfan to create an array from selected keys of an array
+ function getFromKeys($array, $keys = null)
+ {
+ if (empty($keys)) return $array; // all keys
+ $keyarr = is_string($keys) ? explode(",",$keys) : $keys;
+ $keyarr = array_intersect(array_keys($array),$keyarr); // keys should be in array
+ $ret = array();
+ foreach ($keyarr as $key) {
+ $ret[$key] = $array[$key];
+ }
+ return $ret;
+ }
+ // END irmtfan to create an array from selected keys of an array
}
?>
\ No newline at end of file
Modified: XoopsModules/newbb/branches/irmtfan/newbb/list.topic.php
===================================================================
--- XoopsModules/newbb/branches/irmtfan/newbb/list.topic.php 2013-02-12 00:36:10 UTC (rev 11024)
+++ XoopsModules/newbb/branches/irmtfan/newbb/list.topic.php 2013-02-12 01:49:55 UTC (rev 11025)
@@ -41,14 +41,15 @@
$topic_renderer->setVars( @$_GET );
$type = intval( @$_GET['type'] );
-$status = (!empty($_GET['status']) && in_array($_GET['status'], array("active", "pending", "deleted", "digest", "unreplied", "unread")))? $_GET['status'] : "all";
+$status = explode(",",$topic_renderer->vars["status"]); // irmtfan to accept multiple status
//irmtfan parse status for rendering topic correctly - remove here and move to topic.renderer.php
//$topic_renderer->parseVar('status',$status);
-$mode = (!empty($status) && in_array($status, array("active", "pending", "deleted"))) ? 2 : (!empty($_GET['mode']) ? intval($_GET['mode']) : 0);
+// irmtfan to accept multiple status
+$mode = count(array_intersect($status, array("active", "pending", "deleted"))) > 0 ? 2 : (!empty($_GET['mode']) ? intval($_GET['mode']) : 0);
-$isadmin = $GLOBALS["xoopsUserIsAdmin"];
+//$isadmin = $GLOBALS["xoopsUserIsAdmin"];
/* Only admin has access to admin mode */
-if (!$isadmin) {
+if ($topic_renderer->userlevel < 2) { // irmtfan use userlevel
$mode = 0;
}
@@ -92,7 +93,7 @@
$xoopsTpl->assign('mode', $mode);
$xoopsTpl->assign('status', $status);
-$xoopsTpl->assign('viewer_level', ($isadmin) ? 2 : is_object($xoopsUser) );
+$xoopsTpl->assign('viewer_level', $topic_renderer->userlevel );// irmtfan use userlevel
$pagetitle = sprintf(_MD_FORUMINDEX, htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES));
$xoopsTpl->assign('forum_index_title', $pagetitle);
Modified: XoopsModules/newbb/branches/irmtfan/newbb/xoops_version.php
===================================================================
--- XoopsModules/newbb/branches/irmtfan/newbb/xoops_version.php 2013-02-12 00:36:10 UTC (rev 11024)
+++ XoopsModules/newbb/branches/irmtfan/newbb/xoops_version.php 2013-02-12 01:49:55 UTC (rev 11025)
@@ -222,23 +222,24 @@
// irmtfan START add list topic block
// options[0] - Status in WHERE claus: all(by default), sticky, digest,lock, poll, voted, viewed, replied, read, (UN_) , active, pending, deleted (admin) (It is multi-select)
// options[1] - Uid in WHERE claus: uid of the topic poster : 0 - all users (by default)
-// options[2] - Type in WHERE claus: topic type in the forum : 0 - none (by default)
-// options[3] - Sort in ORDER claus: topic, forum, poster, replies, views, lastpost(by default),ratings, votes, publish, digest, sticky, lock, poll, type (if exist), approve(admin mode), attachment
-// options[4] - Order in ORDER claus: Descending(by default), Ascending
-// options[5] - NumberToDisplay: any positive integer
-// options[6] - TimeDuration: negative for hours, positive for days, for instance, -5 for 5 hours and 5 for 5 days
-// options[7] - DisplayMode: all fields same as sort
-// options[8] - Display Navigator: 1 (by default), 0 (No)
-// options[9] - Title Length : 0 - no limit and show complete title
-// options[10] - Post text Length: 0 - dont show post text
-// options[11] - SelectedForumIDs: multi-select ngative values for categories and positive values for forums: null for all(by default)
+// options[2] - Lastposter in WHERE claus: uid of the lastposter in topic : 0 - all users (by default)
+// options[3] - Type in WHERE claus: topic type in the forum : 0 - none (by default)
+// options[4] - Sort in ORDER claus: topic, forum, poster, replies, views, lastpost(by default), lastposttime, lastposter, lastpostmsgicon, ratings, votes, publish, digest, sticky, lock, poll, type (if exist), approve(admin mode)
+// options[5] - Order in ORDER claus: Descending(by default), Ascending
+// options[6] - NumberToDisplay: any positive integer
+// options[7] - TimeDuration: negative for hours, positive for days, for instance, -5 for 5 hours and 5 for 5 days
+// options[8] - DisplayMode: all fields in sort PLUS attachment, read, pagenav
+// options[9] - Display Navigator: 1 (by default), 0 (No)
+// options[10] - Title Length : 0 - no limit and show complete title
+// options[11] - Post text Length: 0 - dont show post text
+// options[12] - SelectedForumIDs: multi-select ngative values for categories and positive values for forums: null for all(by default)
$modversion['blocks'][] = array(
'file' => "list_topic.php",
'name' => _MI_NEWBB_BLOCK_LIST_TOPIC,
'description' => "Shows a list of topics (advance renderer)",
'show_func' => "newbb_list_topic_show",
- 'options' => "all|0|0|lastpost|0|5|360|topic,forum,replies,lastpost,lastposttime,lastposter,lastpostmsgicon,publish|1|0|200|0",
+ 'options' => "all|0|0|0|lastpost|0|5|360|topic,forum,replies,lastpost,lastposttime,lastposter,lastpostmsgicon,publish|1|0|200|0",
'edit_func' => "newbb_list_topic_edit",
'template' => 'newbb_block_list_topic.html');
// irmtfan END add list topic block
|