diff --git a/main/course_home/activity.php b/main/course_home/activity.php
index 5f25e95092..146d881b09 100644
--- a/main/course_home/activity.php
+++ b/main/course_home/activity.php
@@ -44,21 +44,20 @@ require_once '../../main/inc/global.inc.php';
*/
/**
- * Displays the tools of a certain category.
- *
- * @return void
- * @param string $course_tool_category contains the category of tools to display:
- * "toolauthoring", "toolinteraction", "tooladmin", "tooladminplatform"
+ * Gets the tools of a certain category. Returns an array expected
+ * by show_tools_category()
+ * @param string $course_tool_category contains the category of tools to
+ * display: "toolauthoring", "toolinteraction", "tooladmin", "tooladminplatform"
+ * @return array
*/
-
-function show_tools_category($course_tool_category)
-{
+function get_tools_category($course_tool_category) {
global $_user;
$web_code_path = api_get_path(WEB_CODE_PATH);
$course_tool_table = Database::get_course_table(TABLE_TOOL_LIST);
$is_allowed_to_edit = api_is_allowed_to_edit();
$is_platform_admin = api_is_platform_admin();
-
+ $all_tools_list = array();
+
//condition for the session
$session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id,true,true);
@@ -93,15 +92,14 @@ function show_tools_category($course_tool_category)
$result = Database::query("SELECT * FROM $course_tool_table WHERE category = 'admin' $condition_session ORDER BY id",__FILE__,__LINE__);
$colLink ="##003399";
break;
-
+
}
- while ($temp_row = Database::fetch_array($result))
- {
+ while ($temp_row = Database::fetch_array($result)) {
$all_tools_list[]=$temp_row;
}
-
+
/*if(api_is_course_coach())
{
$result = Database::query("SELECT * FROM $course_tool_table WHERE name='tracking'",__FILE__,__LINE__);
@@ -113,8 +111,7 @@ function show_tools_category($course_tool_category)
$course_link_table = Database::get_course_table(TABLE_LINK);
$course_item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
- switch ($course_tool_category)
- {
+ switch ($course_tool_category) {
case TOOL_AUTHORING:
$sql_links="SELECT tl.*, tip.visibility
FROM $course_link_table tl
@@ -153,13 +150,11 @@ function show_tools_category($course_tool_category)
}
//edit by Kevin Van Den Haute (kevin@develop-it.be) for integrating Smartblogs
- if($sql_links != null)
- {
+ if ($sql_links != null) {
$result_links = Database::query($sql_links,__FILE__,__LINE__);
$properties = array();
if (Database::num_rows($result_links) > 0) {
- while($links_row = Database::fetch_array($result_links))
- {
+ while ($links_row = Database::fetch_array($result_links)) {
unset($properties);
$properties['name'] = $links_row['title'];
$properties['session_id'] = $links_row['session_id'];
@@ -173,13 +168,9 @@ function show_tools_category($course_tool_category)
}
}
- if(isset($tmp_all_tools_list))
- {
- foreach($tmp_all_tools_list as $toolsRow)
- {
-
- if($toolsRow['image'] == 'blog.gif')
- {
+ if (isset($tmp_all_tools_list)) {
+ foreach ($tmp_all_tools_list as $toolsRow) {
+ if ($toolsRow['image'] == 'blog.gif') {
// Init
$tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
@@ -187,15 +178,12 @@ function show_tools_category($course_tool_category)
$blog_id = substr($toolsRow['link'], strrpos($toolsRow['link'], '=') + 1, strlen($toolsRow['link']));
// Get blog members
- if($is_platform_admin)
- {
+ if($is_platform_admin) {
$sql_blogs = "
SELECT *
FROM " . $tbl_blogs_rel_user . " blogs_rel_user
WHERE blog_id = " . $blog_id;
- }
- else
- {
+ } else {
$sql_blogs = "
SELECT *
FROM " . $tbl_blogs_rel_user . " blogs_rel_user
@@ -206,176 +194,174 @@ function show_tools_category($course_tool_category)
$result_blogs = Database::query($sql_blogs, __FILE__, __LINE__);
- if(Database::num_rows($result_blogs) > 0)
+ if (Database::num_rows($result_blogs) > 0) {
$all_tools_list[] = $toolsRow;
- }
- else
+ }
+ } else {
$all_tools_list[] = $toolsRow;
+ }
}
}
+ return $all_tools_list;
+}
- if(isset($all_tools_list))
- {
- $lnk = '';
- foreach($all_tools_list as $toolsRow)
- {
+/**
+ * Displays the tools of a certain category.
+ * @param array List of tools as returned by get_tools_category()
+ * @return void
+ */
+function show_tools_category($all_tools_list)
+{
+ global $_user;
+ $web_code_path = api_get_path(WEB_CODE_PATH);
+ $course_tool_table = Database::get_course_table(TABLE_TOOL_LIST);
+ $is_allowed_to_edit = api_is_allowed_to_edit();
+ $is_platform_admin = api_is_platform_admin();
+
+ if (isset($all_tools_list)) {
+ $lnk = '';
+ foreach ($all_tools_list as $toolsRow) {
if (api_get_session_id()!=0 && in_array($toolsRow['name'],array('course_maintenance','course_setting'))) {
continue;
}
- if(!($i%2))
- {echo "
\n";}
+ if (!($i%2)) {
+ echo "
\n";
+ }
// This part displays the links to hide or remove a tool.
// These links are only visible by the course manager.
unset($lnk);
echo '| ' . "\n";
- if($is_allowed_to_edit)
- {
- if($toolsRow['visibility'] == '1' && $toolsRow['admin'] !='1')
- {
-
+ if ($is_allowed_to_edit) {
+ if ($toolsRow['visibility'] == '1' && $toolsRow['admin'] !='1') {
$link['name'] = Display::return_icon('visible.gif', get_lang('Deactivate'),array('id'=>'linktool_'.$toolsRow["id"]));
$link['cmd'] = "hide=yes";
$lnk[] = $link;
}
- if($toolsRow['visibility'] == '0' && $toolsRow['admin'] !='1')
- {
+ if ($toolsRow['visibility'] == '0' && $toolsRow['admin'] !='1') {
$link['name'] = Display::return_icon('invisible.gif', get_lang('Activate'),array('id'=>'linktool_'.$toolsRow["id"]));
$link['cmd'] = "restore=yes";
$lnk[] = $link;
}
- if(!empty($toolsRow['adminlink']))
- {
+ if (!empty($toolsRow['adminlink'])) {
echo ''.Display::return_icon('edit.gif', get_lang('Edit')).'';
}
}
// Both checks are necessary as is_platform_admin doesn't take student view into account
- if( $is_platform_admin && $is_allowed_to_edit)
- {
- if($toolsRow['admin'] !='1')
- {
+ if ($is_platform_admin && $is_allowed_to_edit) {
+ if ($toolsRow['admin'] !='1') {
$link['cmd'] = "hide=yes";
}
-
}
- if(isset($lnk) && is_array($lnk))
- {
- foreach($lnk as $this_link)
- {
- if(empty($toolsRow['adminlink']))
- {
+ if (isset($lnk) && is_array($lnk)) {
+ foreach ($lnk as $this_link) {
+ if (empty($toolsRow['adminlink'])) {
echo "" . $this_link['name'] . "";
//echo "" . $this_link['name'] . "";
}
}
- }
- else{ echo ' ';}
+ } else { echo ' ';}
// NOTE : table contains only the image file name, not full path
- if(!stristr($toolsRow['link'], 'http://') && !stristr($toolsRow['link'], 'https://') && !stristr($toolsRow['link'],'ftp://'))
+ if (!stristr($toolsRow['link'], 'http://')
+ && !stristr($toolsRow['link'], 'https://')
+ && !stristr($toolsRow['link'],'ftp://')) {
$toolsRow['link'] = $web_code_path . $toolsRow['link'];
-
- if($toolsRow['visibility'] == '0' && $toolsRow['admin'] != '1')
- {
+ }
+ if ($toolsRow['visibility'] == '0' && $toolsRow['admin'] != '1') {
$class="class=\"invisible\"";
$info = pathinfo($toolsRow['image']);
$basename = basename ($toolsRow['image'],'.'.$info['extension']); // $file is set to "index"
$toolsRow['image'] = $basename.'_na.'.$info['extension'];
- }
- else
+ } else {
$class='';
+ }
$qm_or_amp = ((strpos($toolsRow['link'], '?') === FALSE) ? '?' : '&');
//If it's a link, we don't add the cidReq
- if($toolsRow['image'] == 'file_html.gif' || $toolsRow['image'] == 'file_html_na.gif'){
+ if ($toolsRow['image'] == 'file_html.gif' || $toolsRow['image'] == 'file_html_na.gif') {
$toolsRow['link'] = $toolsRow['link'].$qm_or_amp;
- }
- else{
+ } else {
$toolsRow['link'] = $toolsRow['link'].$qm_or_amp.api_get_cidreq();
}
- if(strpos($toolsRow['name'],'visio_')!==false) {
-
- /*
- $toollink = "\t" . '';
- */
+ if (strpos($toolsRow['name'],'visio_')!==false) {
+ /*
+ $toollink = "\t" . '';
+ */
- $toollink = "\t" . '';
- $my_tool_link = "\t" . '';
- } else if(strpos($toolsRow['name'],'chat')!==false && api_get_course_setting('allow_open_chat_window')==true) {
- /*
- $toollink = "\t" . '';
- */
- $toollink = "\t" . '';
- $my_tool_link="\t" . '';
+ $toollink = "\t" . '';
+ $my_tool_link = "\t" . '';
+ } elseif (strpos($toolsRow['name'],'chat')!==false && api_get_course_setting('allow_open_chat_window')==true) {
+ /*
+ $toollink = "\t" . '';
+ */
+ $toollink = "\t" . '';
+ $my_tool_link="\t" . '';
- } else {
+ } else {
- if (count(explode('type=classroom',$toolsRow['link']))==2 || count(explode('type=conference',$toolsRow['link']))==2) {
- //$toollink = "\t" . '';
- $toollink = "\t" . '';
- $my_tool_link = "\t" . '';
+ if (count(explode('type=classroom',$toolsRow['link']))==2 || count(explode('type=conference',$toolsRow['link']))==2) {
+ //$toollink = "\t" . '';
+ $toollink = "\t" . '';
+ $my_tool_link = "\t" . '';
- } else {
- //$toollink = "\t" . '';
- $toollink = "\t" . '';
- $my_tool_link = "\t" . '';
+ } else {
+ //$toollink = "\t" . '';
+ $toollink = "\t" . '';
+ $my_tool_link = "\t" . '';
- }
-
- }
- echo $toollink;
- //var_dump($toollink);
- /*
- Display::display_icon($toolsRow['image'], get_lang(ucfirst($toolsRow['name'])));
- */
- if ($toolsRow['image'] == 'file_html.gif' || $toolsRow['image'] == 'file_html_na.gif'
- || $toolsRow['image'] == 'scormbuilder.gif' || $toolsRow['image'] == 'scormbuilder_na.gif'
- || $toolsRow['image'] == 'blog.gif' || $toolsRow['image'] == 'blog_na.gif'
- || $toolsRow['image'] == 'external.gif' || $toolsRow['image'] == 'external_na.gif')
- {
- $tool_name = stripslashes($toolsRow['name']);
- } else {
- $tool_name = get_lang(ucfirst($toolsRow['name']));
}
- Display::display_icon($toolsRow['image'], $tool_name, array('class'=>'tool-icon','id'=>'toolimage_'.$toolsRow["id"]));
- //validacion when belongs to a session
- $session_img = api_get_session_image($toolsRow['session_id'], $_user['status']);
+ }
+ echo $toollink;
+ //var_dump($toollink);
+ /*
+ Display::display_icon($toolsRow['image'], get_lang(ucfirst($toolsRow['name'])));
+ */
+ if ($toolsRow['image'] == 'file_html.gif' || $toolsRow['image'] == 'file_html_na.gif'
+ || $toolsRow['image'] == 'scormbuilder.gif' || $toolsRow['image'] == 'scormbuilder_na.gif'
+ || $toolsRow['image'] == 'blog.gif' || $toolsRow['image'] == 'blog_na.gif'
+ || $toolsRow['image'] == 'external.gif' || $toolsRow['image'] == 'external_na.gif')
+ {
+ $tool_name = stripslashes($toolsRow['name']);
+ } else {
+ $tool_name = get_lang(ucfirst($toolsRow['name']));
+ }
+ Display::display_icon($toolsRow['image'], $tool_name, array('class'=>'tool-icon','id'=>'toolimage_'.$toolsRow["id"]));
+
+ //validacion when belongs to a session
+ $session_img = api_get_session_image($toolsRow['session_id'], $_user['status']);
- echo ' ';
+ echo ' ';
- echo $my_tool_link;
- /*
- echo ($toolsRow['image'] == 'file_html_na.gif' || $toolsRow['image'] == 'file_html.gif' || $toolsRow['image'] == 'scormbuilder.gif' || $toolsRow['image'] == 'scormbuilder_na.gif' || $toolsRow['image'] == 'blog.gif' || $toolsRow['image'] == 'blog_na.gif' || $toolsRow['image'] == 'external.gif' || $toolsRow['image'] == 'external_na.gif') ? ' '.stripslashes($toolsRow['name']) : ' '.get_lang(ucfirst($toolsRow['name']));
- */
- echo "{$tool_name}$session_img";
- echo "\t" . '';
- echo ' | ';
- if($i%2)
- {
+ echo $my_tool_link;
+ /*
+ echo ($toolsRow['image'] == 'file_html_na.gif' || $toolsRow['image'] == 'file_html.gif' || $toolsRow['image'] == 'scormbuilder.gif' || $toolsRow['image'] == 'scormbuilder_na.gif' || $toolsRow['image'] == 'blog.gif' || $toolsRow['image'] == 'blog_na.gif' || $toolsRow['image'] == 'external.gif' || $toolsRow['image'] == 'external_na.gif') ? ' '.stripslashes($toolsRow['name']) : ' '.get_lang(ucfirst($toolsRow['name']));
+ */
+ echo "{$tool_name}$session_img";
+ echo "\t" . '';
+ echo '';
+ if ($i%2) {
echo "
";
}
-
$i++;
}
}
- if($i%2)
- {
+ if ($i%2) {
echo " | \n",
"\n";
}
-
}
//End of functions show tools
@@ -478,27 +464,24 @@ if (isset($_GET['sent_http_request']) && $_GET['sent_http_request']==1) {
// work with data post askable by admin of course
-if(api_is_platform_admin())
-{
- // Show message to confirm that a tools must be hide from available tools
+if (api_is_platform_admin()) {
+ // Show message to confirm that a tools must be hidden from available tools
// visibility 0,1->2
- if(!empty($_GET['askDelete']))
- {
- ?>
+ if (!empty($_GET['askDelete'])) {
+?>
-
0) {
+ if (api_get_setting('show_session_data') === 'true' && $id_session > 0) {
?>
@@ -607,31 +589,31 @@ if(api_is_allowed_to_edit())
0) {
+ if (api_get_setting('show_session_data') === 'true' && $id_session > 0) {
?>
@@ -640,11 +622,11 @@ if(api_is_allowed_to_edit())
0) {
?>
+ }
+}
\ No newline at end of file