Added two new functions CT#191

skala
Arthur Portugal 16 years ago
parent 0741c2f321
commit bbb58731b8
  1. 38
      main/forum/forumfunction.inc.php

@ -15,7 +15,7 @@
* - new view option: nested view
* - quoting a message
*
* @package dokeos.forum
* @package chamilo.forum
*
* @todo several functions have to be moved to the itemmanager library
* @todo displaying icons => display library
@ -26,6 +26,7 @@ require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php';
require_once api_get_path(LIBRARY_PATH).'text.lib.php';
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.php';
get_notifications_of_user();
/*
@ -3969,3 +3970,38 @@ function get_thread_user_post_limit($course_db, $thread_id, $user_id, $limit=10)
}
return $post_list;
}
/**
* This function builds an array of all the posts in a given thread where the key of the array is the post_id
* It also adds an element children to the array which itself is an array that contains all the id's of the first-level children
* @return an array containing all the information on the posts of a thread
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
*/
function calculate_children($rows) {
foreach($rows as $row) {
$rows_with_children[$row["post_id"]]=$row;
$rows_with_children[$row["post_parent_id"]]["children"][]=$row["post_id"];
}
$rows=$rows_with_children;
$sorted_rows=array(0=>array());
_phorum_recursive_sort($rows, $sorted_rows);
unset($sorted_rows[0]);
return $sorted_rows;
}
function _phorum_recursive_sort($rows, &$threads, $seed=0, $indent=0) {
if($seed>0) {
$threads[$rows[$seed]["post_id"]]=$rows[$seed];
$threads[$rows[$seed]["post_id"]]["indent_cnt"]=$indent;
$indent++;
}
if(isset($rows[$seed]["children"])) {
foreach($rows[$seed]["children"] as $child) {
_phorum_recursive_sort($rows, $threads, $child, $indent);
}
}
}

Loading…
Cancel
Save