Skip to content

Commit c16fc5f

Browse files
committed
Forum: Fix SQL queries with c_id + convert all icons to MDI
1 parent 86faf1e commit c16fc5f

File tree

10 files changed

+96
-171
lines changed

10 files changed

+96
-171
lines changed

public/main/forum/editpost.php

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Chamilo\CourseBundle\Entity\CForum;
77
use Chamilo\CourseBundle\Entity\CForumPost;
88
use Chamilo\CourseBundle\Entity\CForumThread;
9+
use Chamilo\CoreBundle\Component\Utils\ActionIcon;
910

1011
/**
1112
* These files are a complete rework of the forum. The database structure is
@@ -194,7 +195,7 @@ function setFocus() {
194195
name: 'user_upload[]'
195196
});
196197
$('[name="user_upload[]"]').parent().append(newInputFile);
197-
});
198+
})
198199
});
199200
</script>
200201
JS;
@@ -248,30 +249,15 @@ function setFocus() {
248249
//$actions .= '<span style="float:right;">'.search_link().'</span>';
249250
if ('group' === $origin) {
250251
$actions .= '<a href="../group/group_space.php?'.api_get_cidreq().'">'.
251-
Display::return_icon(
252-
'back.png',
253-
get_lang('Back to').' '.get_lang('Groups'),
254-
'',
255-
ICON_SIZE_MEDIUM
256-
).
252+
Display::getMdiIcon(ActionIcon::BACK, 'ch-tool-icon', null, ICON_SIZE_MEDIUM, get_lang('Back to').' '.get_lang('Groups')).
257253
'</a>';
258254
} else {
259255
$actions .= '<a href="index.php?'.api_get_cidreq().'">'.
260-
Display::return_icon(
261-
'back.png',
262-
get_lang('Back toForumOverview'),
263-
'',
264-
ICON_SIZE_MEDIUM
265-
).
256+
Display::getMdiIcon(ActionIcon::BACK, 'ch-tool-icon', null, ICON_SIZE_MEDIUM, get_lang('Back toForumOverview')).
266257
'</a>';
267258
}
268259
$actions .= '<a href="viewforum.php?forum='.$forumId.'&'.api_get_cidreq().'">'.
269-
Display::return_icon(
270-
'forum.png',
271-
get_lang('Back toForum'),
272-
'',
273-
ICON_SIZE_MEDIUM
274-
).
260+
Display::getMdiIcon('comment-quote', 'ch-tool-icon', null, ICON_SIZE_MEDIUM, get_lang('Back toForum')).
275261
'</a>';
276262
echo Display::toolbarAction('toolbar', [$actions]);
277263
}

public/main/forum/editthread.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
use Chamilo\CoreBundle\Framework\Container;
66
use Chamilo\CourseBundle\Entity\CForum;
7+
use Chamilo\CoreBundle\Component\Utils\ActionIcon;
8+
79

810
/**
911
* Edit a Forum Thread.
@@ -200,15 +202,15 @@ function setFocus() {
200202
$("[name='weight_calification']").val(0);
201203
$("[name='thread_peer_qualify'][value='0']").prop('checked', true);
202204
}
203-
});
205+
})
204206
});
205207
</script>
206208
JS;
207209

208210
// Action links
209211
$actions = [
210212
Display::url(
211-
Display::return_icon('back.png', get_lang('Back to forum'), '', ICON_SIZE_MEDIUM),
213+
Display::getMdiIcon(ActionIcon::BACK, 'ch-tool-icon', null, ICON_SIZE_MEDIUM, get_lang('Back to forum')),
212214
'viewforum.php?forum='.$forumId.'&'.$cidreq
213215
),
214216
search_link(),

public/main/forum/forumfunction.inc.php

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
use ChamiloSession as Session;
2020
use Doctrine\Common\Collections\Criteria;
2121
use Symfony\Component\HttpFoundation\File\UploadedFile;
22+
use Chamilo\CoreBundle\Component\Utils\ActionIcon;
23+
2224

2325
/**
2426
* @todo convert this library into a class
@@ -918,7 +920,7 @@ function returnVisibleInvisibleIcon(
918920
}
919921
}
920922
$html .= 'action=invisible&content='.$content.'&id='.$id.'">'.
921-
Display::return_icon('visible.png', get_lang('MakeInvisible'), [], ICON_SIZE_SMALL).'</a>';
923+
Display::getMdiIcon(ActionIcon::VISIBLE, 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang('MakeInvisible')).'</a>';
922924
}
923925
if (0 == $current_visibility_status) {
924926
$html .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&';
@@ -928,7 +930,7 @@ function returnVisibleInvisibleIcon(
928930
}
929931
}
930932
$html .= 'action=visible&content='.$content.'&id='.$id.'">'.
931-
Display::return_icon('invisible.png', get_lang('Make Visible'), [], ICON_SIZE_SMALL).'</a>';
933+
Display::getMdiIcon(ActionIcon::INVISIBLE, 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang('Make Visible')).'</a>';
932934
}
933935

934936
return $html;
@@ -952,13 +954,14 @@ function returnLockUnlockIcon(
952954
//check if the forum is blocked due
953955
if ('thread' === $content) {
954956
if (api_resource_is_locked_by_gradebook($id, LINK_FORUM_THREAD)) {
955-
return $html.Display::return_icon(
956-
'lock_na.png',
957+
return $html.Display::getMdiIcon(
958+
ActionIcon::LOCK,
959+
'ch-tool-icon-disabled',
960+
'',
961+
ICON_SIZE_SMALL,
957962
get_lang(
958963
'This option is not available because this activity is contained by an assessment, which is currently locked. To unlock the assessment, ask your platform administrator.'
959-
),
960-
[],
961-
ICON_SIZE_SMALL
964+
)
962965
);
963966
}
964967
}
@@ -970,7 +973,7 @@ function returnLockUnlockIcon(
970973
}
971974
}
972975
$html .= 'action=unlock&content='.$content.'&id='.$id.'">'.
973-
Display::return_icon('lock.png', get_lang('Unlock'), [], ICON_SIZE_SMALL).'</a>';
976+
Display::getMdiIcon(ActionIcon::LOCK, 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang('Unlock')).'</a>';
974977
}
975978
if ('0' == $current_lock_status) {
976979
$html .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&';
@@ -980,7 +983,7 @@ function returnLockUnlockIcon(
980983
}
981984
}
982985
$html .= 'action=lock&content='.$content.'&id='.$id.'">'.
983-
Display::return_icon('unlock.png', get_lang('Lock'), [], ICON_SIZE_SMALL).'</a>';
986+
Display::getMdiIcon(ActionIcon::UNLOCK, 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang('Lock')).'</a>';
984987
}
985988

986989
return $html;
@@ -1017,10 +1020,10 @@ function returnUpDownIcon(string $content, int $id, array $list): string
10171020
$return_value = '<a
10181021
href="'.api_get_self().'?'.api_get_cidreq().'&action=move&direction=up&content='.$content.'&forumcategory='.$forumCategory.'&id='.$id.'"
10191022
title="'.get_lang('Move up').'">'.
1020-
Display::return_icon('up.png', get_lang('Move up'), [], ICON_SIZE_SMALL).'</a>';
1023+
Display::getMdiIcon(ActionIcon::UP, 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang('Move up')).'</a>';
10211024
} else {
10221025
$return_value = Display::url(
1023-
Display::return_icon('up_na.png', '-', [], ICON_SIZE_SMALL),
1026+
Display::getMdiIcon(ActionIcon::UP, 'ch-tool-icon-disabled', null, ICON_SIZE_SMALL, ''),
10241027
'javascript:void(0)'
10251028
);
10261029
}
@@ -1029,10 +1032,10 @@ function returnUpDownIcon(string $content, int $id, array $list): string
10291032
$return_value .= '<a
10301033
href="'.api_get_self().'?'.api_get_cidreq().'&action=move&direction=down&content='.$content.'&forumcategory='.$forumCategory.'&id='.$id.'"
10311034
title="'.get_lang('Move down').'" >'.
1032-
Display::return_icon('down.png', get_lang('Move down'), [], ICON_SIZE_SMALL).'</a>';
1035+
Display::getMdiIcon(ActionIcon::DOWN, 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang('Move down')).'</a>';
10331036
} else {
10341037
$return_value = Display::url(
1035-
Display::return_icon('down_na.png', '-', [], ICON_SIZE_SMALL),
1038+
Display::getMdiIcon(ActionIcon::DOWN, 'ch-tool-icon-disabled', null, ICON_SIZE_SMALL, ''),
10361039
'javascript:void(0)'
10371040
);
10381041
}
@@ -1483,7 +1486,6 @@ function get_thread_users_details(int $thread_id)
14831486
AND course_user.relation_type <> ".COURSE_RELATION_TYPE_RRHH."
14841487
AND p.thread_id = $thread_id
14851488
AND course_user.status != '1' AND
1486-
p.c_id = $course_id AND
14871489
course_user.c_id = $course_id $orderby";
14881490
}
14891491

@@ -3381,7 +3383,6 @@ function handle_mail_cue($content, $id)
33813383
$sql = "SELECT users.firstname, users.lastname, users.id as user_id, users.email, posts.forum_id
33823384
FROM $table_mailcue mailcue, $table_posts posts, $table_users users
33833385
WHERE
3384-
posts.c_id = $course_id AND
33853386
mailcue.c_id = $course_id AND
33863387
posts.thread_id = $id AND
33873388
posts.post_notification = '1' AND
@@ -4000,7 +4001,7 @@ function search_link()
40004001
$origin = api_get_origin();
40014002
if ('learnpath' != $origin) {
40024003
$return = '<a href="forumsearch.php?'.api_get_cidreq().'&action=search"> ';
4003-
$return .= Display::return_icon('search.png', get_lang('Search'), '', ICON_SIZE_MEDIUM).'</a>';
4004+
$return .= Display::getMdiIcon('magnify-plus-outline ', 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang('Search')).'</a>';
40044005

40054006
if (!empty($_GET['search'])) {
40064007
$return .= ': '.Security::remove_XSS($_GET['search']).' ';
@@ -4012,7 +4013,7 @@ function search_link()
40124013
}
40134014
}
40144015
$url .= implode('&', $url_parameter);
4015-
$return .= '<a href="'.$url.'">'.Display::return_icon('delete.gif', get_lang('Clean search results')).'</a>';
4016+
$return .= '<a href="'.$url.'">'.Display::getMdiIcon(ActionIcon::DELETE, 'ch-tool-icon', '', ICON_SIZE_SMALL, get_lang('Clean search results')).'</a>';
40164017
}
40174018
}
40184019

@@ -4638,20 +4639,20 @@ function get_thread_user_post(Course $course, $thread_id, $user_id)
46384639
/**
46394640
* This function get the name of an thread by id.
46404641
*
4641-
* @param int $thread_id
4642+
* @param int $threadId
46424643
*
46434644
* @return string
46444645
*
46454646
* @author Christian Fasanando
46464647
* @author Julio Montoya <gugli100@gmail.com> Adding security
46474648
*/
4648-
function get_name_thread_by_id($thread_id)
4649+
function get_name_thread_by_id(int $threadId): string
46494650
{
4650-
$t_forum_thread = Database::get_course_table(TABLE_FORUM_THREAD);
4651+
$tForumThread = Database::get_course_table(TABLE_FORUM_THREAD);
46514652
$course_id = api_get_course_int_id();
46524653
$sql = "SELECT thread_title
4653-
FROM $t_forum_thread
4654-
WHERE c_id = $course_id AND iid = '".(int) $thread_id."' ";
4654+
FROM $tForumThread
4655+
WHERE iid = $threadId";
46554656
$result = Database::query($sql);
46564657
$row = Database::fetch_array($result);
46574658

@@ -4700,12 +4701,7 @@ function get_all_post_from_user(int $user_id, int $courseId): string
47004701
$post_counter = count($post_list);
47014702
if (is_array($post_list) && count($post_list) > 0) {
47024703
$hand_forums .= '<div id="social-thread">';
4703-
$hand_forums .= Display::return_icon(
4704-
'thread.png',
4705-
get_lang('Thread'),
4706-
'',
4707-
ICON_SIZE_MEDIUM
4708-
);
4704+
$hand_forums .= Display::getMdiIcon('format-quote-open', 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang('Thread'));
47094705
$hand_forums .= '&nbsp;'.Security::remove_XSS($thread->getThreadTitle(), STUDENT);
47104706
$hand_forums .= '</div>';
47114707

@@ -4724,7 +4720,7 @@ function get_all_post_from_user(int $user_id, int $courseId): string
47244720
$forum_results .= '<div id="social-forum">';
47254721
$forum_results .= '<div class="clear"></div><br />';
47264722
$forum_results .= '<div id="social-forum-title">'.
4727-
Display::return_icon('forum.gif', get_lang('Forum')).'&nbsp;'.Security::remove_XSS($forum->getForumTitle(), STUDENT).
4723+
Display::getMdiIcon('comment-quote', 'ch-tool-icon', '', ICON_SIZE_SMALL, get_lang('Forum')).'&nbsp;'.Security::remove_XSS($forum->getForumTitle(), STUDENT).
47284724
'<div style="float:right;margin-top:-35px">
47294725
<a href="../forum/viewforum.php?'.api_get_cidreq_params($courseId).'&forum='.$forum->getIid().' " >'.
47304726
get_lang('See forum').'
@@ -5061,16 +5057,16 @@ function getAttachedFiles(
50615057
// Check if $row is consistent
50625058
if ($attachment) {
50635059
// Set result as success and bring delete URL
5064-
$json['result'] = Display::return_icon('accept.png', get_lang('Uploaded.'));
5060+
$json['result'] = Display::getMdiIcon('check-circle', 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang('Uploaded.'));
50655061
$url = api_get_path(WEB_CODE_PATH).'forum/viewthread.php?'.api_get_cidreq().'&action=delete_attach&forum='.$forumId.'&thread='.$threadId.'&id_attach='.$row['iid'];
50665062
$json['delete'] = Display::url(
5067-
Display::return_icon('delete.png', get_lang('Delete'), [], ICON_SIZE_SMALL),
5063+
Display::getMdiIcon(ActionIcon::DELETE, 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang('Delete')),
50685064
$url,
50695065
['class' => 'deleteLink']
50705066
);
50715067
} else {
50725068
// If not, set an exclamation result
5073-
$json['result'] = Display::return_icon('exclamation.png', get_lang('Error'));
5069+
$json['result'] = Display::getMdiIcon('close-circle', 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang('Error'));
50745070
}
50755071
// Store array data into $_SESSION
50765072
$_SESSION['forum']['upload_file'][$courseId][$json['id']] = $json;

public/main/forum/forumqualify.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
use Chamilo\CoreBundle\Framework\Container;
66
use Chamilo\CourseBundle\Entity\CForum;
77
use Chamilo\CourseBundle\Entity\CForumThread;
8+
use Chamilo\CoreBundle\Component\Utils\ActionIcon;
9+
810

911
/**
1012
* @todo fix all this qualify files avoid including files, use classes POO jmontoya
@@ -339,7 +341,7 @@ function hidecontent(content){
339341
echo '<tr ><td height="50%">';
340342
$realname = $attachment_list['path'];
341343
$user_filename = $attachment_list['filename'];
342-
echo Display::return_icon('attachment.gif', get_lang('Attachment'));
344+
echo Display::getMdiIcon('paperclip', 'ch-tool-icon', '', ICON_SIZE_SMALL, get_lang('Attachment'));
343345
echo '<a href="download.php?file=';
344346
echo $realname;
345347
echo ' "> '.$user_filename.' </a>';

public/main/forum/index.php

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Chamilo\CourseBundle\Entity\CForumPost;
66
use ChamiloSession as Session;
7+
use Chamilo\CoreBundle\Component\Utils\ActionIcon;
78

89
/**
910
* These files are a complete rework of the forum. The database structure is
@@ -204,11 +205,12 @@ function hidecontent(content){
204205
$url = '../lp/lp_controller.php?'.api_get_cidreq()
205206
."&gradebook=&action=add_item&type=step&lp_id='.$lp_id.'#resource_tab-5";
206207
$actionLeft .= Display::url(
207-
Display::return_icon(
208-
'back.png',
209-
get_lang('Back to').' '.get_lang('Learning paths'),
208+
Display::getMdiIcon(
209+
ActionIcon::BACK,
210+
'ch-tool-icon',
210211
null,
211-
ICON_SIZE_MEDIUM
212+
ICON_SIZE_MEDIUM,
213+
get_lang('Back to').' '.get_lang('Learning paths')
212214
),
213215
$url
214216
);
@@ -217,23 +219,13 @@ function hidecontent(content){
217219
if (api_is_allowed_to_edit(false, true)) {
218220
if (is_array($forumCategories) && !empty($forumCategories)) {
219221
$actionLeft .= Display::url(
220-
Display::return_icon(
221-
'new_forum.png',
222-
get_lang('Add a forum'),
223-
null,
224-
ICON_SIZE_MEDIUM
225-
),
222+
Display::getMdiIcon('comment-quote', 'ch-tool-icon', null, ICON_SIZE_MEDIUM, get_lang('Add a forum')),
226223
api_get_self().'?'.api_get_cidreq().'&action=add_forum&lp_id='.$lp_id
227224
);
228225
}
229226

230227
$actionLeft .= Display::url(
231-
Display::return_icon(
232-
'new_folder.png',
233-
get_lang('Add a forumCategory'),
234-
null,
235-
ICON_SIZE_MEDIUM
236-
),
228+
Display::getMdiIcon('folder-multiple-plus', 'ch-tool-icon', null, ICON_SIZE_MEDIUM, get_lang('Add a forumCategory')),
237229
api_get_self().'?'.api_get_cidreq().'&action=add_category&lp_id='.$lp_id
238230
);
239231
}
@@ -346,12 +338,7 @@ function hidecontent(content){
346338
) {
347339
$tools .= '<a href="'.api_get_self().'?'.api_get_cidreq()
348340
.'&action=edit_category&content=forumcategory&id='.$categoryId
349-
.'">'.Display::return_icon(
350-
'edit.png',
351-
get_lang('Edit'),
352-
[],
353-
ICON_SIZE_SMALL
354-
)
341+
.'">'.Display::getMdiIcon(ActionIcon::EDIT, 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang('Edit'))
355342
.'</a>';
356343

357344
$tools .= '<a href="'.api_get_self().'?'.api_get_cidreq()
@@ -362,12 +349,7 @@ function hidecontent(content){
362349
ENT_QUOTES
363350
))
364351
."')) return false;\">"
365-
.Display::return_icon(
366-
'delete.png',
367-
get_lang('Delete'),
368-
[],
369-
ICON_SIZE_SMALL
370-
)
352+
.Display::getMdiIcon(ActionIcon::DELETE, 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang('Delete'))
371353
.'</a>';
372354
$tools .= returnVisibleInvisibleIcon(
373355
'forumcategory',
@@ -542,15 +524,15 @@ function hidecontent(content){
542524
if (api_is_allowed_to_edit(false, true)) {
543525
$toolActions .= '<a href="'.api_get_self().'?'.api_get_cidreq()
544526
.'&action=edit_forum&content=forum&id='.$forumId.'">'
545-
.Display::return_icon('edit.png', get_lang('Edit'), [], ICON_SIZE_SMALL)
527+
.Display::getMdiIcon(ActionIcon::EDIT, 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang('Edit'))
546528
.'</a>';
547529
$toolActions .= '<a href="'.api_get_self().'?'.api_get_cidreq()
548530
.'&action=delete_forum&content=forum&id='.$forumId
549531
."\" onclick=\"javascript:if(!confirm('".addslashes(
550532
api_htmlentities(get_lang('Delete forum ?'), ENT_QUOTES)
551533
)
552534
."')) return false;\">"
553-
.Display::return_icon('delete.png', get_lang('Delete'), [], ICON_SIZE_SMALL)
535+
.Display::getMdiIcon(ActionIcon::DELETE, 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang('Delete'))
554536
.'</a>';
555537

556538
$toolActions .= returnVisibleInvisibleIcon(

0 commit comments

Comments
 (0)