oMerge branch '1.10.x' of github.com:chamilo/chamilo-lms into 1.10.x

1.10.x
Yannick Warnier 11 years ago
commit 7d6fb212bc
  1. 27
      app/Resources/public/css/base.css
  2. 5
      composer.json
  3. 2
      main/admin/index.php
  4. 31
      main/admin/resource_sequence.php
  5. 61
      main/forum/forumfunction.inc.php
  6. 387
      main/forum/index.php
  7. 254
      main/forum/viewforumcategory.php
  8. BIN
      main/img/icons/128/alert.png
  9. BIN
      main/img/icons/128/forum_group.png
  10. BIN
      main/img/icons/128/notification_mail.png
  11. BIN
      main/img/icons/128/notification_mail_na.png
  12. BIN
      main/img/icons/16/post-item.png
  13. BIN
      main/img/icons/22/alert.png
  14. BIN
      main/img/icons/22/notification_mail.png
  15. BIN
      main/img/icons/22/notification_mail_na.png
  16. BIN
      main/img/icons/22/notification_mail_ok.png
  17. BIN
      main/img/icons/22/post-forum.png
  18. BIN
      main/img/icons/32/forum_blue.png
  19. BIN
      main/img/icons/32/forum_yellow.png
  20. BIN
      main/img/icons/32/notification_mail.png
  21. BIN
      main/img/icons/32/notification_mail_na.png
  22. BIN
      main/img/icons/48/forum_group.png
  23. BIN
      main/img/icons/64/notification_mail.png
  24. BIN
      main/img/icons/64/notification_mail_na.png
  25. 188
      main/inc/ajax/sequence.ajax.php
  26. 145
      main/inc/lib/SequenceManager.php
  27. 12
      main/inc/lib/formvalidator/FormValidator.class.php
  28. 139
      main/template/default/admin/resource_sequence.tpl
  29. 17
      src/Chamilo/CoreBundle/Entity/Manager/SequenceManager.php
  30. 18
      src/Chamilo/CoreBundle/Entity/Repository/SequenceRepository.php
  31. 114
      src/Chamilo/CoreBundle/Entity/SequenceResource.php

@ -6120,7 +6120,32 @@ div#chat-remote-video video {
height: auto;
width: 100%;
}
/* CSS Forum */
.forum {
border-color: #dddddd !important;
}
.forum .number-post{
background-color: #F7F7F9;
border: 1px solid #E1E1E1 ;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
padding: 10px;
text-align: center;
}
.forum .number-post p{
padding: 0;
margin: 0;
}
.forum .title{
margin: 0;
padding: 0;
font-size: 18px;
}
.forum .description{
font-size: 14px;
color: #666666;
}
/* CSS NEW TOP ******************************************************************************/
/* CSS Responsive */
@media (min-width: 1025px) and (max-width: 1200px) {

@ -76,7 +76,10 @@
"bower-asset/modernizr": "2.8.*",
"bower-asset/jqueryui-timepicker-addon": "@stable",
"bower-asset/imageMap-resizer": "0.5.3",
"bower-asset/simplewebrtc": "@stable"
"bower-asset/simplewebrtc": "@stable",
"clue/graph": "~0.9.0",
"graphp/graphviz": "~0.2.0",
"graphp/algorithms": "~0.8.0"
},
"require-dev": {
"behat/behat": "2.5.*@stable",

@ -345,7 +345,9 @@ if (api_is_platform_admin()) {
if (is_dir(api_get_path(SYS_TEST_PATH) . 'datafiller/')) {
$items[] = array('url' => 'filler.php', 'label' => get_lang('DataFiller'));
}
$items[] = array('url' => 'archive_cleanup.php', 'label' => get_lang('ArchiveDirCleanup'));
$items[] = array('url' => 'resource_sequence.php', 'label' => get_lang('ResourceSequencing'));
if (isset($_configuration['db_manager_enabled']) &&
$_configuration['db_manager_enabled'] == true &&

@ -0,0 +1,31 @@
<?php
/* For licensing terms, see /chamilo_license.txt */
$cidReset = true;
require_once '../inc/global.inc.php';
$tpl = new Template(get_lang('ResourceSequencing'));
$layout = $tpl->get_template('admin/resource_sequence.tpl');
$form = new FormValidator('');
$sessionList = SessionManager::get_sessions_list();
if (!empty($sessionList)) {
//$sessionList[] = ['name' => get_lang('PleaseSelect'), 'id' => 0];
$sessionList = array_column($sessionList, 'name', 'id');
}
$form->addHidden('sequence_type', 'session');
$form->addSelect(
'sessions',
get_lang('Sessions'),
$sessionList,
['id' => 'item', 'multiple' => 'multiple']
);
$form->addButtonNext(get_lang('UseAsReference'), 'use_as_reference');
$form->addButtonCreate(get_lang('SetAsRequirementForSelected'), 'set_requirement');
$form->addButtonSave(get_lang('Save'), 'save_resource');
$tpl->assign('left_block', $form->returnForm());
$tpl->display($layout);

@ -950,25 +950,37 @@ function check_if_last_post_of_thread($thread_id)
*/
function display_visible_invisible_icon($content, $id, $current_visibility_status, $additional_url_parameters = '')
{
echo return_visible_invisible_icon($content, $id, $current_visibility_status, $additional_url_parameters);
}
/**
* @param $content what is it that we want to make (in)visible: forum category, forum, thread, post
* @param $id the id of the content we want to make invisible
* @param $current_visibility_status what is the current status of the visibility (0 = invisible, 1 = visible)
* @return string HTML
*/
function return_visible_invisible_icon($content, $id, $current_visibility_status, $additional_url_parameters = '')
{
$html = '';
$id = Security::remove_XSS($id);
if ($current_visibility_status == '1') {
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&';
$html .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&';
if (is_array($additional_url_parameters)) {
foreach ($additional_url_parameters as $key => $value) {
echo $key.'='.$value.'&amp;';
$html .= $key . '=' . $value . '&amp;';
}
}
echo 'action=invisible&amp;content='.$content.'&amp;id='.$id.'">'.Display::return_icon('visible.png', get_lang('MakeInvisible'), array(), ICON_SIZE_SMALL).'</a>';
$html.='action=invisible&amp;content='.$content.'&amp;id='.$id.'">'.Display::return_icon('visible.png', get_lang('MakeInvisible'), array(), ICON_SIZE_SMALL).'</a>';
}
if ($current_visibility_status == '0') {
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;';
$html .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;';
if (is_array($additional_url_parameters)) {
foreach ($additional_url_parameters as $key => $value) {
echo $key.'='.$value.'&amp;';
$html .= $key . '=' . $value . '&amp;';
}
}
echo 'action=visible&amp;content='.$content.'&amp;id='.$id.'">'.Display::return_icon('invisible.png', get_lang('MakeVisible'), array(), ICON_SIZE_SMALL).'</a>';
$html .= 'action=visible&amp;content=' . $content . '&amp;id=' . $id . '">' . Display::return_icon('invisible.png', get_lang('MakeVisible'), array(), ICON_SIZE_SMALL) . '</a>';
}
return $html;
}
/**
@ -984,33 +996,39 @@ function display_visible_invisible_icon($content, $id, $current_visibility_statu
*/
function display_lock_unlock_icon($content, $id, $current_lock_status, $additional_url_parameters = '')
{
echo return_lock_unlock_icon($content, $id, $current_lock_status, $additional_url_parameters);
}
function return_lock_unlock_icon($content, $id, $current_lock_status, $additional_url_parameters = '')
{
$html = '';
$id = intval($id);
//check if the forum is blocked due
if ($content == 'thread') {
if (api_resource_is_locked_by_gradebook($id, LINK_FORUM_THREAD)) {
echo Display::return_icon('lock_na.png', get_lang('ResourceLockedByGradebook'), array(), ICON_SIZE_SMALL);
$html .= Display::return_icon('lock_na.png', get_lang('ResourceLockedByGradebook'), array(), ICON_SIZE_SMALL);
return;
return $html;
}
}
if ($current_lock_status == '1') {
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;';
$html .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&';
if (is_array($additional_url_parameters)) {
foreach ($additional_url_parameters as $key => $value) {
echo $key.'='.$value.'&amp;';
$html .= $key . '=' . $value . '&';
}
}
echo 'action=unlock&amp;content='.$content.'&amp;id='.$id.'">'.Display::return_icon('lock.png', get_lang('Unlock'), array(), ICON_SIZE_SMALL).'</a>';
$html.= 'action=unlock&content='.$content.'&id='.$id.'">'.Display::return_icon('lock.png', get_lang('Unlock'), array(), ICON_SIZE_SMALL).'</a>';
}
if ($current_lock_status == '0') {
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;';
$html .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&';
if (is_array($additional_url_parameters)) {
foreach ($additional_url_parameters as $key => $value) {
echo $key.'='.$value.'&amp;';
$html .= $key . '=' . $value . '&';
}
}
echo 'action=lock&amp;content='.$content.'&amp;id='.$id.'">'.Display::return_icon('unlock.png', get_lang('Lock'), array(), ICON_SIZE_SMALL).'</a>';
$html .= 'action=lock&content=' . $content . '&id=' . $id . '">' . Display::return_icon('unlock.png', get_lang('Lock'), array(), ICON_SIZE_SMALL) . '</a>';
}
return $html;
}
/**
@ -1027,6 +1045,10 @@ function display_lock_unlock_icon($content, $id, $current_lock_status, $addition
* @version february 2006, dokeos 1.8
*/
function display_up_down_icon($content, $id, $list)
{
echo return_up_down_icon($content, $id, $list);
}
function return_up_down_icon($content, $id, $list)
{
$id = strval(intval($id));
$total_items = count($list);
@ -1056,7 +1078,7 @@ function display_up_down_icon($content, $id, $list)
} else {
$return_value .= Display::return_icon('down_na.png', '-', array(), ICON_SIZE_SMALL);
}
echo $return_value;
return $return_value;
}
/**
@ -1272,7 +1294,14 @@ function class_visible_invisible($current_visibility_status)
return 'class="invisible"';
}
}
function return_visible_invisible($current_visibility_status)
{
$current_visibility_status = intval($current_visibility_status);
if ($current_visibility_status == 0) {
$status='invisible';
return $status;
}
}
/**
* Retrieve all the information off the forum categories (or one specific) for the current course.
* The categories are sorted according to their sorting order (cat_order

@ -263,91 +263,105 @@ if (is_array($forumCategories)) {
$forumCategory['cat_title'] = get_lang('WithoutCategory');
}
echo '<table class="forum_table">';
echo '<thead>';
echo '<tr><th class="forum_head" colspan="5">';
echo '<a href="viewforumcategory.php?'.api_get_cidreq(
).'&forumcategory='.intval(
$forumCategory['cat_id']
).'" '.class_visible_invisible($forumCategory['visibility']).'>'.
prepare4display($forumCategory['cat_title']).$session_displayed.
'</a>'.$session_img.'<br />';
if ($forumCategory['cat_comment'] != '' && trim(
$forumCategory['cat_comment']
) != '&nbsp;'
) {
echo '<span class="forum_description">'.prepare4display(
$forumCategory['cat_comment']
).'</span>';
}
echo '</th>';
echo '<th style="vertical-align: top;" align="center" >';
if (!empty($forumCategory['cat_id'])) {
if (api_is_allowed_to_edit(
false,
true
) && !($forumCategory['session_id'] == 0 && intval(
$sessionId
) != 0)
) {
echo '<a href="'.api_get_self().'?'.api_get_cidreq(
).'&action=edit&content=forumcategory&id='.intval(
$forumCategory['cat_id']
).'">'.Display::return_icon(
'edit.png',
get_lang('Edit'),
array(),
ICON_SIZE_SMALL
).'</a>';
echo '<a href="'.api_get_self().'?'.api_get_cidreq(
).'&action=delete&content=forumcategory&id='.intval(
$forumCategory['cat_id']
)."\" onclick=\"javascript:if(!confirm('".addslashes(
api_htmlentities(
$html = '';
$iconsEdit = '';
$idCategory = $forumCategory['cat_id'];
$urlCategory = 'viewforumcategory.php?'.api_get_cidreq().'&forumcategory='.intval($idCategory);
$titleCategory = Display::tag(
'a',
$forumCategory['cat_title'],
array(
'href' => $urlCategory,
'class' => return_visible_invisible($forumCategory['visibility'])
)
);
$descriptionCategory = $forumCategory['cat_comment'];
if (!empty($idCategory)){
if (api_is_allowed_to_edit(false, true) && !($forumCategory['session_id'] == 0 && intval($sessionId) != 0)){
$iconsEdit.= '<a href="'.api_get_self().'?'.api_get_cidreq()
.'&action=edit&content=forumcategory&id='.intval($idCategory).
'">'.Display::return_icon(
'edit.png',
get_lang('Edit'),
array(),
ICON_SIZE_SMALL
).'</a>';
$iconsEdit.='<a href="'.api_get_self().'?'.api_get_cidreq().
'&action=delete&content=forumcategory&id='. intval($idCategory).
"\" onclick=\"javascript:if(!confirm('". addslashes(api_htmlentities(
get_lang('DeleteForumCategory'),
ENT_QUOTES
)
)."')) return false;\">".Display::return_icon(
)).
"')) return false;\">".
Display::return_icon(
'delete.png',
get_lang('Delete'),
array(),
ICON_SIZE_SMALL
).'</a>';
display_visible_invisible_icon(
'forumcategory',
strval(intval($forumCategory['cat_id'])),
strval(intval($forumCategory['visibility']))
);
display_lock_unlock_icon(
'forumcategory',
strval(intval($forumCategory['cat_id'])),
strval(intval($forumCategory['locked']))
);
display_up_down_icon(
'forumcategory',
strval(intval($forumCategory['cat_id'])),
$forumCategories
);
).
'</a>';
$iconsEdit .= return_visible_invisible_icon(
'forumcategory',
strval(intval($idCategory)),
strval(intval($forumCategory['visibility']))
);
$iconsEdit .= return_lock_unlock_icon(
'forumcategory',
strval(intval($$idCategory)),
strval(intval($forumCategory['locked']))
);
$iconsEdit .= return_up_down_icon(
'forumcategory',
strval(intval($idCategory)),
$forumCategories
);
}
}
}
echo '</th>';
echo '</tr>';
echo '</thead>';
$html .= '<div class="category-forum">';
$html .= Display::tag(
'div',
$iconsEdit,
array(
'class' => 'pull-right'
)
);
$icoCategory = Display::return_icon(
'forum_blue.png',
get_lang(
$forumCategory['cat_title']
),
array(),
ICON_SIZE_MEDIUM
);
$html .= '<h3>' . $icoCategory . $titleCategory . '</h3>';
if ($descriptionCategory != '' && trim($descriptionCategory) != '&nbsp;') {
$html .= '<div class="forum-description">'.$descriptionCategory.'</div>';
}
$html .= '</div>';
echo $html;
echo '<div class="forum_display">';
if (!empty($forumsInCategory)) {
// Step 4: The interim headers (for the forum).
echo '<tr class="forum_header">';
/* echo '<tr class="forum_header">';
echo '<td></td>';
echo '<td>'.get_lang('Forum').'</td>';
echo '<td>'.get_lang('Topics').'</td>';
echo '<td>'.get_lang('Posts').'</td>';
echo '<td>'.get_lang('LastPosts').'</td>';
echo '<td>'.get_lang('Actions').'</td>';
echo '</tr>';
echo '</tr>'; */
// Step 5: We display all the forums in this category.
foreach ($forum_list as $forum) {
// Here we clean the whatnew_post_info array a little bit because to display the icon we
// test if $whatsnew_post_info[$forum['forum_id']] is empty or not.
@ -368,6 +382,7 @@ if (is_array($forumCategories)) {
// Note: This can be speed up if we transform the $forum_list
// to an array that uses the forum_category as the key.
if (isset($forum['forum_category']) &&
$forum['forum_category'] == $forumCategory['cat_id']
) {
@ -395,67 +410,53 @@ if (is_array($forumCategories)) {
if ($show_forum) {
$form_count++;
$mywhatsnew_post_info = isset($whatsnew_post_info[$forum['forum_id']]) ? $whatsnew_post_info[$forum['forum_id']] : null;
$mywhatsnew_post_info = isset($whatsnew_post_info[$forum['forum_id']]) ?
$whatsnew_post_info[$forum['forum_id']] : null;
$html = '<div class="panel panel-default forum">';
$html .= '<div class="panel-body">';
$forum_image = '';
$imgForum = '';
// Showing the image
if (!empty($forum['forum_image'])) {
$image_path = api_get_path(
WEB_COURSE_PATH
).api_get_course_path(
).'/upload/forum/images/'.$forum['forum_image'];
) . api_get_course_path() . '/upload/forum/images/' . $forum['forum_image'];
$image_size = api_getimagesize($image_path);
$img_attributes = '';
if (!empty($image_size)) {
if ($image_size['width'] > 100 || $image_size['height'] > 100) {
//limit display width and height to 100px
$img_attributes = ' style="width:100px" width="100px" height="100px"';
$td_width = 100;
} else {
$td_width = $image_size['width'];
}
$forum_image = "<img src=\"$image_path\" $img_attributes>";
//limit display width and height to 100px
$img_attributes = ' style="width:80px" height="80px"';
$imgForum = "<img src=\"$image_path\" $img_attributes>";
} else {
$forum_image = '';
$td_width = 20;
$imgForum = '';
}
echo '<td width="'.$td_width.'px">';
echo $forum_image;
$forum_image = $imgForum;
} else {
echo '<td width="20px">';
if ($forum['forum_of_group'] !== '0') {
if (is_array(
$mywhatsnew_post_info
) && !empty($mywhatsnew_post_info)
) {
echo Display::return_icon(
'forumgroupnew.gif'
);
} else {
echo Display::return_icon(
'forumgroup.gif',
get_lang('GroupForum')
);
}
if ($forum['forum_of_group'] == '0') {
$forum_image = Display::return_icon(
'forum_group.png',
get_lang('GroupForum'),
null,
ICON_SIZE_LARGE
);
} else {
if (is_array(
$mywhatsnew_post_info
) && !empty($mywhatsnew_post_info)
) {
echo Display::return_icon(
'forum.gif',
get_lang('Forum')
);
} else {
echo Display::return_icon('forum.gif');
}
$forum_image = Display::return_icon(
'forum.png',
get_lang('Forum'),
null,
ICON_SIZE_LARGE
);
}
}
echo '</td>';
// Validation when belongs to a session
$session_img = api_get_session_image(
$forum['session_id'],
@ -463,8 +464,10 @@ if (is_array($forumCategories)) {
);
if ($forum['forum_of_group'] != '0') {
$my_all_groups_forum_name = isset($all_groups[$forum['forum_of_group']]['name']) ? $all_groups[$forum['forum_of_group']]['name'] : null;
$my_all_groups_forum_id = isset($all_groups[$forum['forum_of_group']]['id']) ? $all_groups[$forum['forum_of_group']]['id'] : null;
$my_all_groups_forum_name = isset($all_groups[$forum['forum_of_group']]['name']) ?
$all_groups[$forum['forum_of_group']]['name'] : null;
$my_all_groups_forum_id = isset($all_groups[$forum['forum_of_group']]['id']) ?
$all_groups[$forum['forum_of_group']]['id'] : null;
$group_title = api_substr(
$my_all_groups_forum_name,
0,
@ -485,29 +488,84 @@ if (is_array($forumCategories)) {
}
$forum['forum_of_group'] == 0 ? $groupid = '' : $groupid = $forum['forum_of_group'];
echo '<td><a href="viewforum.php?'.api_get_cidreq(
).'&gidReq='.intval($groupid).'&forum='.intval(
$forum['forum_id']
).'" '.class_visible_invisible(
strval(intval($forum['visibility']))
).'>';
$number_threads = isset($forum['number_of_threads']) ? $forum['number_of_threads'] : 0;
$number_posts = isset($forum['number_of_posts']) ? $forum['number_of_posts'] : 0;
$html .= '<div class="row">';
$html .= '<div class="col-md-6">';
$html .= '<div class="col-md-3">';
$html .= '<div class="number-post">'.$forum_image .'<p>' . $number_posts . ' ' . get_lang('Posts') . '</p></div>';
$html .= '</div>';
$html .= '<div class="col-md-9">';
$iconForum = Display::return_icon(
'forum_yellow.png',
get_lang($forumCategory['cat_title']),
null,
ICON_SIZE_MEDIUM
);
$linkForum = '';
$linkForum .= Display::tag(
'a',
$forum['forum_title'],
array (
'href'=>'viewforum.php?' . api_get_cidreq().'&gidReq=' . intval($groupid).'&forum=' . intval(
$forum['forum_id']),
'class' => return_visible_invisible( strval( intval($forum['visibility']) ) ) )
);
// Forum title
echo prepare4display(
$forum['forum_title']
).$session_displayed.'</a>'.$forum_title_group_addition.'<br />';
$html .= '<h3 class="title">' . $iconForum . $linkForum . '</h3>';
echo '<span class="forum_description">'.prepare4display(
$forum['forum_comment']
).'</span>';
echo '</td>';
$html .= Display::tag(
'p',
strip_tags($forum['forum_comment']),
array(
'class'=>'description'
)
);
$html .= '</div>';
$html .= '</div>';
// The number of topics and posts.
$number_threads = isset($forum['number_of_threads']) ? $forum['number_of_threads'] : null;
$number_posts = isset($forum['number_of_posts']) ? $forum['number_of_posts'] : null;
if ($forum['forum_of_group'] !== '0') {
$iconEmpty='';
$newPost='';
if (is_array($mywhatsnew_post_info) && !empty($mywhatsnew_post_info)) {
$newPost = ' '.
Display::return_icon(
'alert.png',
get_lang('Forum'),
null,
ICON_SIZE_SMALL
);
} else {
$newPost = $iconEmpty;
}
} else {
if (is_array($mywhatsnew_post_info) && !empty($mywhatsnew_post_info)) {
$newPost = ' '.
Display::return_icon(
'alert.png',
get_lang('Forum'),
null,
ICON_SIZE_SMALL
);
} else {
$newPost = $iconEmpty;
}
}
echo '<td>'.$number_threads.'</td>';
echo '<td>'.$number_posts.'</td>';
$html .= '<div class="col-md-6">';
$html .= '<div class="row">';
$html .= '<div class="col-md-2">';
$html .= Display::return_icon(
'post-forum.png',
get_lang('Forum'),
null,
ICON_SIZE_SMALL
);
$html .= ' ' . $number_threads . '<br>'.$newPost.'</div>';
$html .= '<div class="col-md-6">';
// The last post in the forum.
if ($forum['last_poster_name'] != '') {
@ -526,23 +584,27 @@ if (is_array($forumCategories)) {
$userinfo['username']
);
}
echo '<td nowrap="nowrap">';
if (!empty($forum['last_post_id'])) {
echo api_convert_and_format_date(
$forum['last_post_date']
).'<br /> '.get_lang(
'By'
).' '.display_user_link(
$html .= Display::return_icon(
'post-item.png',
null,
null,
ICON_SIZE_TINY
).' '.
api_convert_and_format_date($forum['last_post_date']).
'<br /> ' . get_lang('By').' '.
display_user_link(
$poster_id,
$name,
'',
$username
);
}
echo '</td>';
$html .= '</div>';
$html .= '<div class="col-md-4">';
echo '<td class="td_actions">';
if (api_is_allowed_to_edit(
false,
true
@ -550,15 +612,15 @@ if (is_array($forumCategories)) {
$sessionId
) != 0)
) {
echo '<a href="'.api_get_self().'?'.api_get_cidreq(
).'&action=edit&content=forum&id='.$forum['forum_id'].'">'.
$html .= '<a href="'.api_get_self() . '?' . api_get_cidreq(
).'&action=edit&content=forum&id='.$forum['forum_id'] . '">'.
Display::return_icon(
'edit.png',
get_lang('Edit'),
array(),
ICON_SIZE_SMALL
).'</a>';
echo '<a href="'.api_get_self().'?'.api_get_cidreq(
) . '</a>';
$html .= '<a href="'.api_get_self().'?'.api_get_cidreq(
).'&action=delete&content=forum&id='.$forum['forum_id']."\" onclick=\"javascript:if(!confirm('".addslashes(
api_htmlentities(
get_lang('DeleteForum'),
@ -571,56 +633,71 @@ if (is_array($forumCategories)) {
array(),
ICON_SIZE_SMALL
).'</a>';
display_visible_invisible_icon(
$html .= return_visible_invisible_icon(
'forum',
$forum['forum_id'],
$forum['visibility']
);
display_lock_unlock_icon(
$html .= return_lock_unlock_icon(
'forum',
$forum['forum_id'],
$forum['locked']
);
display_up_down_icon(
$html .= return_up_down_icon(
'forum',
$forum['forum_id'],
$forumsInCategory
);
}
$iconnotify = 'send_mail.gif';
$session_forum_notification = isset($_SESSION['forum_notification']['forum']) ? $_SESSION['forum_notification']['forum'] : false;
$iconnotify = 'notification_mail_na.png';
$session_forum_notification = isset($_SESSION['forum_notification']['forum']) ?
$_SESSION['forum_notification']['forum'] : false;
if (is_array($session_forum_notification)) {
if (in_array(
$forum['forum_id'],
$session_forum_notification
)) {
$iconnotify = 'send_mail_checked.gif';
$iconnotify = 'notification_mail.png';
}
}
if (!api_is_anonymous(
) && api_is_allowed_to_session_edit(false, true)
) {
echo '<a href="'.api_get_self().'?'.api_get_cidreq(
$html .= '<a href="'.api_get_self().'?'.api_get_cidreq(
).'&action=notify&content=forum&id='.$forum['forum_id'].'">'.
Display::return_icon(
$iconnotify,
get_lang('NotifyMe')
).'</a>';
get_lang('NotifyMe'),
null,
ICON_SIZE_SMALL
) . '</a>';
}
echo '</td></tr>';
$html .= '</div>';
$html .= '</div>';
$html .= '</div>';
$html .= '</div>';
$html .= '</div>';
$html .= '</div>';
}
echo $html;
}
}
} else {
echo '<tr><td>'.get_lang(
echo '<div class="alert alert-warning">'.get_lang(
'NoForumInThisCategory'
).'</td>'.(api_is_allowed_to_edit(
).'</div>'.(api_is_allowed_to_edit(
false,
true
) ? '<td colspan="6"></td>' : '<td colspan="6"></td>').'</tr>';
) ? '<div>' : '</div>').'</div>';
}
echo '</table>';
echo '</div>';
}
}
Display:: display_footer();

@ -97,16 +97,18 @@ if (!api_is_allowed_to_edit(false,true) AND ($current_forum_category && $current
}
/* Action Links */
echo '<div class="actions">';
echo '<span style="float:right;">'.search_link().'</span>';
echo '<a href="index.php?gradebook='.$gradebook.'&'.api_get_cidreq().'">'.
$html = '';
$html .= '<div class="actions">';
$html .= '<a href="index.php?gradebook='.$gradebook.'&'.api_get_cidreq().'">'.
Display::return_icon('back.png', get_lang('BackToForumOverview'), '', ICON_SIZE_MEDIUM).'</a>';
if (api_is_allowed_to_edit(false,true)) {
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&forumcategory='.$current_forum_category['cat_id'].'&amp;action=add&amp;content=forum"> '.Display::return_icon('new_forum.png', get_lang('AddForum'),'',ICON_SIZE_MEDIUM).'</a>';
$html .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&forumcategory='.$current_forum_category['cat_id'].'&amp;action=add&amp;content=forum"> '.Display::return_icon('new_forum.png', get_lang('AddForum'),'',ICON_SIZE_MEDIUM).'</a>';
}
echo '</div>';
$html .= search_link();
$html .= '</div>';
/* ACTIONS */
echo $html;
$action_forums = isset($_GET['action']) ? $_GET['action'] : '';
if (api_is_allowed_to_edit(false, true)) {
@ -154,7 +156,12 @@ if ($action_forums != 'add') {
/* Display Forum Categories and the Forums in it */
echo '<table class="forum_table" width="100%">';
$html = '';
$html .= '<div class="category-forum">';
$my_session = isset($_SESSION['id_session']) ? $_SESSION['id_session'] : null;
if ((!isset($_SESSION['id_session']) || $_SESSION['id_session'] == 0) && !empty($forum_category['session_name'])) {
@ -163,25 +170,62 @@ if ($action_forums != 'add') {
$session_displayed = '';
}
$forum_categories_list = '';
echo '<thead>';
echo '<tr><th class="forum_head" '.(api_is_allowed_to_edit(null, true) ? 'colspan="5"' : 'colspan="6"').'>';
$forumId = $forum_category['cat_id'];
$forumTitle = $forum_category['cat_title'];
$linkForumCategory = 'viewforumcategory.php?'.api_get_cidreq().'&amp;forumcategory='.strval(intval($forumId));
$descriptionCategory = $forum_category['cat_comment'];
$icoCategory = Display::return_icon('forum_blue.png',
get_lang($forumCategory['cat_title']),
array('class'=>''),
ICON_SIZE_MEDIUM
);
echo '<a href="viewforumcategory.php?'.api_get_cidreq().'&amp;forumcategory='.strval(intval($forum_category['cat_id'])).'" '.class_visible_invisible(strval(intval($forum_category['visibility']))).'>'.prepare4display($forum_category['cat_title']).$session_displayed.'</a>'. $session_img .'<br />';
if (api_is_allowed_to_edit(false, true) && !($forum_category['session_id'] == 0 && intval($my_session) != 0)) {
echo '<span class="forum_description">'.prepare4display($forum_category['cat_comment']).'</span>';
$iconsEdit = '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;forumcategory='.Security::remove_XSS($_GET['forumcategory']).'&amp;action=edit&amp;content=forumcategory&amp;id='.$forumId.'">'.
Display::return_icon(
'edit.png',
get_lang('Edit'),
array(),
ICON_SIZE_SMALL
).'</a>';
$iconsEdit .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;forumcategory='.Security::remove_XSS($_GET['forumcategory']).'&amp;action=delete&amp;content=forumcategory&amp;amp;id='.$forumId."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('DeleteForumCategory'), ENT_QUOTES))."')) return false;\">".
Display::return_icon(
'delete.png',
get_lang('Delete'),
array(),
ICON_SIZE_SMALL
).'</a>';
$iconsEdit .= return_visible_invisible_icon('forumcategory', $forum_category['cat_id'], $forum_category['visibility'], array('forumcategory' => $_GET['forumcategory']));
$iconsEdit .= return_lock_unlock_icon('forumcategory', $forum_category['cat_id'], $forum_category['locked'], array('forumcategory' => $_GET['forumcategory']));
$iconsEdit .= return_up_down_icon('forumcategory', $forum_category['cat_id'], $forum_categories_list);
$html .= Display::tag('div',$iconsEdit,array('class'=>'pull-right'));
}
if (api_is_allowed_to_edit(false, true) && !($forum_category['session_id'] == 0 && intval($my_session) != 0)) {
echo '<th style="vertical-align: top;" align="center">';
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;forumcategory='.Security::remove_XSS($_GET['forumcategory']).'&amp;action=edit&amp;content=forumcategory&amp;id='.$forum_category['cat_id'].'">'.Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>';
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;forumcategory='.Security::remove_XSS($_GET['forumcategory']).'&amp;action=delete&amp;content=forumcategory&amp;amp;id='.$forum_category['cat_id']."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('DeleteForumCategory'), ENT_QUOTES))."')) return false;\">".Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL).'</a>';
display_visible_invisible_icon('forumcategory', $forum_category['cat_id'], $forum_category['visibility'], array('forumcategory' => $_GET['forumcategory']));
display_lock_unlock_icon('forumcategory', $forum_category['cat_id'], $forum_category['locked'], array('forumcategory' => $_GET['forumcategory']));
display_up_down_icon('forumcategory', $forum_category['cat_id'], $forum_categories_list);
echo '</th>';
$html .= Display::tag(
'h3',
$icoCategory.
Display::tag(
'a',
$forumTitle,
array(
'href'=>$linkForumCategory,
'class'=>return_visible_invisible(strval(intval($forum_category['visibility'])))
)
).$session_displayed.$session_img,
null
);
if ($descriptionCategory != '' && trim($descriptionCategory)!= '&nbsp;')
{
$html .= '<div class="forum-description">'.$descriptionCategory.'</div>';
}
echo '</tr>';
/* echo '<tr><th class="forum_head" '.(api_is_allowed_to_edit(null, true) ? 'colspan="5"' : 'colspan="6"').'>'; */
// Step 3: The interim headers (for the forum).
/*
echo '<tr class="forum_header">';
echo '<td colspan="2">'.get_lang('Forum').'</td>';
echo '<td>'.get_lang('ForumThreads').'</td>';
@ -190,7 +234,12 @@ if ($action_forums != 'add') {
echo '<td>'.get_lang('Actions').'</td>';
echo '</tr>';
echo '</thead>';
*/
$html .= '</div>';
echo $html;
echo '<div class="forum_display">';
// The forums in this category.
$forums_in_category = get_forums_in_category($forum_category['cat_id']);
@ -244,23 +293,29 @@ if ($action_forums != 'add') {
$form_count = isset($form_count) ? $form_count : 0;
if ($show_forum === true) {
$form_count++;
echo '<tr class="forum">';
echo '<td width="20">';
$html = '<div class="panel panel-default forum">';
$html .= '<div class="panel-body">';
$my_whatsnew_post_info = isset($whatsnew_post_info[$forum['forum_id']]) ? $whatsnew_post_info[$forum['forum_id']] : null;
if ($forum['forum_of_group'] !== '0') {
if (is_array($my_whatsnew_post_info) && !empty($my_whatsnew_post_info)) {
echo Display::return_icon('forumgroupnew.gif');
} else {
echo Display::return_icon('forumgroup.gif', get_lang('GroupForum'));
}
if ($forum['forum_of_group'] == '0') {
$forum_image = Display::return_icon(
'forum_group.png',
get_lang('GroupForum'),
null,
ICON_SIZE_LARGE
);
} else {
if (is_array($my_whatsnew_post_info) && !empty($my_whatsnew_post_info)) {
echo Display::return_icon('forum.gif', get_lang('Forum'));
} else {
echo Display::return_icon('forum.gif');
}
$forum_image = Display::return_icon(
'forum.png',
get_lang('Forum'),
null,
ICON_SIZE_LARGE
);
}
echo '</td>';
if ($forum['forum_of_group'] != '0') {
$my_all_groups_forum_name = isset($all_groups[$forum['forum_of_group']]['name']) ? $all_groups[$forum['forum_of_group']]['name'] : null;
@ -276,15 +331,92 @@ if ($action_forums != 'add') {
} else {
$session_displayed = '';
}
echo '<td><a href="viewforum.php?'.api_get_cidreq().'&amp;gidReq='.$forum['forum_of_group'].'&amp;forum='.$forum['forum_id'].'&amp;origin='.$origin.'&amp;search='.Security::remove_XSS(urlencode(isset($_GET['search']) ? $_GET['search'] : '')).'" '.class_visible_invisible($forum['visibility']).'>'.prepare4display($forum['forum_title']).$session_displayed.'</a>'.$forum_title_group_addition.'<br />'.prepare4display($forum['forum_comment']).'</td>';
//$number_forum_topics_and_posts=get_post_topics_of_forum($forum['forum_id']); // deprecated
// the number of topics and posts
$my_number_threads = isset($forum['number_of_threads']) ? $forum['number_of_threads'] : '';
$my_number_threads = isset($forum['number_of_threads']) ? $forum['number_of_threads'] : 0 ;
$my_number_posts = isset($forum['number_of_posts']) ? $forum['number_of_posts'] : 0 ;
$html .= '<div class="row">';
$html .= '<div class="col-md-6">';
$html .= '<div class="col-md-3">';
$html .= '<div class="number-post">'.$forum_image .'<p>' . $my_number_posts . ' ' . get_lang('Posts') . '</p></div>';
$html .= '</div>';
$html .= '<div class="col-md-9">';
$iconForum = Display::return_icon(
'forum_yellow.png',
get_lang($forumCategory['cat_title']),
null,
ICON_SIZE_MEDIUM
);
$linkForum = '';
$linkForum .= Display::tag(
'a',
$forum['forum_title'].$session_displayed,
array(
'href' => 'viewforum.php?'.api_get_cidreq().'&amp;gidReq='.$forum['forum_of_group'].'&amp;forum='.$forum['forum_id'].'&amp;origin='.$origin.'&amp;search='.Security::remove_XSS(urlencode(isset($_GET['search']) ? $_GET['search'] : '')),
'class' => return_visible_invisible($forum['visibility'])
)
);
$html .= Display::tag(
'h3',
$linkForum . ' ' . $forum_title_group_addition,
array(
'class' => 'title'
)
);
$html .= Display::tag(
'p',
strip_tags($forum['forum_comment']),
array(
'class' => 'description'
)
);
$html .= '</div>';
$html .= '</div>';
$html .= '<div class="col-md-6">';
// The number of topics and posts.
if ($forum['forum_of_group'] !== '0') {
$iconEmpty='';
$newPost='';
if (is_array($my_whatsnew_post_info) && !empty($my_whatsnew_post_info)) {
$newPost = ' '.
Display::return_icon(
'alert.png',
get_lang('Forum'),
null,
ICON_SIZE_SMALL
);
} else {
$newPost = $iconEmpty;
}
} else {
if (is_array($my_whatsnew_post_info) && !empty($my_whatsnew_post_info)) {
$newPost = ' '.
Display::return_icon(
'alert.png',
get_lang('Forum'),
null,
ICON_SIZE_SMALL
);
} else {
$newPost = $iconEmpty;
}
}
$html .= '<div class="row">';
$html .= '<div class="col-md-2">';
$html .= Display::return_icon(
'post-forum.png',
null,
null,
ICON_SIZE_SMALL
);
$html .= ' ' . $my_number_threads . '<br>'.$newPost.'</div>';
$my_number_posts = isset($forum['number_of_posts']) ? $forum['number_of_posts'] : '';
echo '<td>'.$my_number_threads.'</td>';
echo '<td>'.$my_number_posts.'</td>';
// the last post in the forum
if ($forum['last_poster_name'] != '') {
$name = $forum['last_poster_name'];
@ -293,38 +425,54 @@ if ($action_forums != 'add') {
$name = api_get_person_name($forum['last_poster_firstname'], $forum['last_poster_lastname']);
$poster_id = $forum['last_poster_id'];
}
echo '<td>';
$html .= '<div class="col-md-6">';
if (!empty($forum['last_post_id'])) {
echo $forum['last_post_date'].' '.get_lang('By').' '.display_user_link($poster_id, $name);
$html .= Display::return_icon(
'post-item.png',
null,
null,
ICON_SIZE_TINY
).' ';
$html .= api_convert_and_format_date(
$forum['last_post_date']
).' '.get_lang('By').' '.display_user_link($poster_id, $name);
}
echo '</td>';
echo '<td class="td_actions">';
$html .= '</div>';
$html .= '<div class="col-md-4">';
if (api_is_allowed_to_edit(false, true) && !($forum['session_id'] == 0 && intval(isset($_SESSION['id_session']) ? $_SESSION['id_session'] : null) != 0)) {
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;forumcategory='.Security::remove_XSS($_GET['forumcategory']).'&amp;action=edit&amp;content=forum&amp;id='.$forum['forum_id'].'">'.Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>';
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;forumcategory='.Security::remove_XSS($_GET['forumcategory']).'&amp;action=delete&amp;content=forum&amp;id='.$forum['forum_id']."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('DeleteForum'), ENT_QUOTES))."')) return false;\">".Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL).'</a>';
display_visible_invisible_icon('forum', $forum['forum_id'], $forum['visibility'], array('forumcategory' => $_GET['forumcategory']));
display_lock_unlock_icon('forum', $forum['forum_id'], $forum['locked'], array('forumcategory' => $_GET['forumcategory']));
display_up_down_icon('forum', $forum['forum_id'], $forums_in_category);
$html .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;forumcategory='.Security::remove_XSS($_GET['forumcategory']).'&amp;action=edit&amp;content=forum&amp;id='.$forum['forum_id'].'">'.Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>';
$html .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;forumcategory='.Security::remove_XSS($_GET['forumcategory']).'&amp;action=delete&amp;content=forum&amp;id='.$forum['forum_id']."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('DeleteForum'), ENT_QUOTES))."')) return false;\">".Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL).'</a>';
$html .= return_visible_invisible_icon('forum', $forum['forum_id'], $forum['visibility'], array('forumcategory' => $_GET['forumcategory']));
$html .= return_lock_unlock_icon('forum', $forum['forum_id'], $forum['locked'], array('forumcategory' => $_GET['forumcategory']));
$html .= return_up_down_icon('forum', $forum['forum_id'], $forums_in_category);
}
$iconnotify = 'send_mail.gif';
$iconnotify = 'notification_mail_na.png';
if (is_array(isset($_SESSION['forum_notification']['forum']) ? $_SESSION['forum_notification']['forum'] : null)) {
if (in_array($forum['forum_id'],$_SESSION['forum_notification']['forum'])) {
$iconnotify = 'send_mail_checked.gif';
$iconnotify = 'notification_mail.png';
}
}
if (!api_is_anonymous()) {
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;forumcategory='.Security::remove_XSS($_GET['forumcategory']).'&amp;action=notify&amp;content=forum&amp;id='.$forum['forum_id'].'">'.Display::return_icon($iconnotify, get_lang('NotifyMe')).'</a>';
$html .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;forumcategory='.Security::remove_XSS($_GET['forumcategory']).'&amp;action=notify&amp;content=forum&amp;id='.$forum['forum_id'].'">'.Display::return_icon($iconnotify, get_lang('NotifyMe')).'</a>';
}
echo '</td></tr>';
$html .= '</div>';
$html .= '</div>';
$html .= '</div>';
$html .= '</div>';
$html .= '</div></div>';
}
echo $html;
}
}
if (count($forum_list) == 0) {
echo '<tr><td>'.get_lang('NoForumInThisCategory').'</td></tr>';
echo '<div class="alert alert-warning">'.get_lang('NoForumInThisCategory').'</div>';
}
echo '</table>';
echo '</div>';
}
/* FOOTER */

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 494 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 702 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 976 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 848 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 976 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 927 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 875 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 831 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

@ -0,0 +1,188 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Responses to AJAX calls
*/
use Chamilo\CoreBundle\Entity\SequenceResource;
use Fhaculty\Graph\Graph;
use Fhaculty\Graph\Vertex;
use Graphp\GraphViz\GraphViz;
require_once '../global.inc.php';
api_protect_admin_script();
$action = isset($_REQUEST['a']) ? $_REQUEST['a'] : null;
$id = isset($_REQUEST['id']) ? $_REQUEST['id'] : null;
$type = isset($_REQUEST['type']) ? $_REQUEST['type'] : null;
$manager = Database::getManager();
$repository = $manager->getRepository('ChamiloCoreBundle:SequenceResource');
switch ($action) {
case 'get_icon':
$link = '';
switch ($type) {
case 'session':
$showDelete = isset($_REQUEST['show_delete']) ? $_REQUEST['show_delete'] : false;
$image = Display::return_icon('window_list.png');
$sessionInfo = api_get_session_info($id);
if (!empty($sessionInfo)) {
$linkDelete = '';
if ($showDelete) {
$linkDelete = Display::url(
get_lang('Delete'),
'#',
['class' => 'delete_vertex', 'data-id' => $id]
);
}
$link = '<div class="parent" data-id="'.$id.'">'.
$image.' '.$sessionInfo['name'].$linkDelete.
'</div>';
}
break;
}
echo $link;
break;
case 'delete_vertex':
$vertexId = isset($_REQUEST['vertex_id']) ? $_REQUEST['vertex_id'] : null;
/** @var SequenceResource $resource */
$resource = $repository->findOneByResourceId($id);
if (empty($resource)) {
exit;
}
$graph = $resource->getGraph();
if (!empty($graph)) {
/** @var Graph $graph */
$graph = unserialize($graph);
if ($graph->hasVertex($vertexId)) {
$vertex = $graph->getVertex($vertexId);
$vertex->destroy();
$resource->setGraph(serialize($graph));
$manager->persist($resource);
$manager->flush();
}
}
break;
case 'load_resource':
// children or parent
$loadResourceType = isset($_REQUEST['load_resource_type']) ? $_REQUEST['load_resource_type'] : null;
/** @var SequenceResource $resource */
$resource = $repository->findOneByResourceId($id);
if (empty($resource)) {
exit;
}
$graph = $resource->getGraph();
if (!empty($graph)) {
/** @var Graph $graph */
$graph = unserialize($graph);
$graphviz = new GraphViz();
//echo $graphviz->createImageHtml($graph);
/** @var Vertex $mainVertice */
if ($graph->hasVertex($id)) {
$mainVertice = $graph->getVertex($id);
if (!empty($mainVertice)) {
$list = [];
switch ($loadResourceType) {
case 'parent':
$verticeList = $mainVertice->getVerticesEdgeFrom();
break;
case 'children':
$verticeList = $mainVertice->getVerticesEdgeTo();
break;
}
foreach ($verticeList as $vertice) {
$list[] = $vertice->getId();
}
if (!empty($list)) {
echo implode(',', $list);
}
}
}
}
break;
case 'save_resource':
$parents = isset($_REQUEST['parents']) ? $_REQUEST['parents'] : null;
$parents = str_replace($id, '', $parents);
$parents = explode(',', $parents);
$parents = array_filter($parents);
$graph = new Graph();
switch ($type) {
case 'session':
$sessionInfo = api_get_session_info($id);
$name = $sessionInfo['name'];
$main = $graph->createVertex($id);
foreach ($parents as $parentId) {
$parent = $graph->createVertex($parentId);
// Check if parent Id exists in the DB
/** @var SequenceResource $resource */
$resource = $repository->findOneByResourceId($parentId);
if ($resource) {
$parentGraph = $resource->getGraph();
if (!empty($parentGraph)) {
/** @var Graph $parentGraph */
$parentGraph = unserialize($parentGraph);
try {
$vertex = $parentGraph->getVertex($parentId);
$parentMain = $parentGraph->createVertex($id);
$vertex->createEdgeTo($parentMain);
$resource->setGraph(serialize($parentGraph));
$manager->persist($resource);
$manager->flush();
/*
$graphviz = new GraphViz();
echo $graphviz->createImageHtml($parentGraph);*/
} catch (Exception $e) {
}
}
}
$parent->createEdgeTo($main);
}
$graphviz = new GraphViz();
//echo $graphviz->createImageHtml($graph);
/** @var SequenceResource $sequence */
$sequence = $repository->findOneByResourceId($id);
if (empty($sequence)) {
$sequence = new SequenceResource();
$sequence
->setGraph(serialize($graph))
->setType(SequenceResource::SESSION_TYPE)
->setResourceId($id);
} else {
$sequence->setGraph(serialize($graph));
}
$manager->persist($sequence);
$manager->flush();
break;
}
break;
}

@ -17,7 +17,7 @@ class SequenceManager
if (self::_debug) {
error_log('Entering '.__FUNCTION__.' in '.__FILE__);
}
$row_entity_id = intval(Database::escape_string($row_entity_id));
$row_entity_id = intval($row_entity_id);
if ($row_entity_id > 0) {
$seq_table = Database::get_main_table(TABLE_MAIN_SEQUENCE);
$sql = "SELECT sequence_row_entity_id FROM $seq_table
@ -88,7 +88,7 @@ class SequenceManager
if (self::_debug) {
error_log('Entering '.__FUNCTION__.' in '.__FILE__);
}
$entity_id = Database::escape_string($entity_id);
$entity_id = intval($entity_id);
if (is_numeric($entity_id)) {
$entity_id = intval($entity_id);
$ety_table = Database::get_main_table(TABLE_SEQUENCE_TYPE_ENTITY);
@ -156,12 +156,13 @@ class SequenceManager
if (self::_debug) {
error_log('Entering '.__FUNCTION__.' in '.__FILE__);
}
$rule_id = Database::escape_string($rule_id);
$rule_id = intval($rule_id);
if (is_numeric($rule_id)) {
$rule_id = intval($rule_id);
$con_table = Database::get_main_table(TABLE_SEQUENCE_CONDITION);
$rul_con_table = Database::get_main_table(TABLE_SEQUENCE_RULE_CONDITION);
$sql = "SELECT rc.sequence_condition_id FROM $rul_con_table rc WHERE rc.sequence_rule_id = $rule_id";
$sql = "SELECT rc.sequence_condition_id FROM $rul_con_table rc
WHERE rc.sequence_rule_id = $rule_id";
$sql = "SELECT * FROM $con_table co WHERE co.id IN ($sql)";
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
@ -186,7 +187,7 @@ class SequenceManager
if (self::_debug) {
error_log('Entering '.__FUNCTION__.' in '.__FILE__);
}
$rule_id = Database::escape_string($rule_id);
$rule_id = intval($rule_id);
if (is_numeric($rule_id)) {
$rule_id = intval($rule_id);
$met_table = Database::get_main_table(TABLE_SEQUENCE_METHOD);
@ -219,7 +220,7 @@ class SequenceManager
if (self::_debug) {
error_log('Entering '.__FUNCTION__.' in '.__FILE__);
}
$row_entity_id = intval(Database::escape_string($row_entity_id));
$row_entity_id = intval($row_entity_id);
if ($row_entity_id > 0) {
$val_table = Database::get_main_table(TABLE_SEQUENCE_VALUE);
$sql = "SELECT * FROM $val_table val
@ -246,7 +247,7 @@ class SequenceManager
if (self::_debug) {
error_log('Entering '.__FUNCTION__.' in '.__FILE__);
}
$condition_id = Database::escape_string($condition_id);
$condition_id = intval($condition_id);
if (is_numeric($condition_id)) {
$condition_id = intval($condition_id);
$var_table = Database::get_main_table(TABLE_SEQUENCE_VARIABLE);
@ -291,6 +292,7 @@ class SequenceManager
error_log('Entering '.__FUNCTION__.' in '.__FILE__);
}
$value = self::get_value_by_user_id($row_entity_id, $user_id, $session_id, $available);
$met_type = Database::escape_string($met_type);
if ($value !== false) {
if (empty($met_type)) {
$met_filter = " AND met.met_type NOT IN ('success', 'pre', 'update') ";
@ -370,7 +372,7 @@ class SequenceManager
if (self::_debug) {
error_log('Entering '.__FUNCTION__.' in '.__FILE__);
}
$user_id = (isset($user_id))? intval(Database::escape_string($user_id)) : api_get_user_id();
$user_id = (isset($user_id))? intval($user_id) : api_get_user_id();
if ($user_id > 0) {
$available = Database::escape_string($available);
$available = (is_numeric($available))? intval($available) : -1;
@ -402,10 +404,16 @@ class SequenceManager
}
$val_table = Database::get_main_table(TABLE_SEQUENCE_VALUE);
$sql = "SELECT * FROM $val_table
WHERE user_id = $user_id $available_filter $success_filter $row_entity_filter $session_filter";
WHERE
user_id = $user_id
$available_filter
$success_filter
$row_entity_filter
$session_filter
";
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
while($temp_value = Database::fetch_array($result,'ASSOC')){
while($temp_value = Database::fetch_array($result,'ASSOC')) {
$value[] = $temp_value;
}
@ -448,14 +456,15 @@ class SequenceManager
if (self::_debug) {
error_log('Entering '.__FUNCTION__.' in '.__FILE__);
}
$row_entity_id = intval(Database::escape_string($row_entity_id));
$row_entity_id = intval($row_entity_id);
if ($row_entity_id > 0) {
$row_entity_filter = "WHERE sequence_row_entity_id = $row_entity_id";
} else {
$row_entity_filter = '';
}
$val_table = Database::get_main_table(TABLE_SEQUENCE_VALUE);
$sql = "SELECT DISTINCT user_id, session_id FROM $val_table $row_entity_filter";
$sql = "SELECT DISTINCT user_id, session_id
FROM $val_table $row_entity_filter";
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
while ($temp_user = Database::fetch_array($result, 'ASSOC')) {
@ -482,9 +491,9 @@ class SequenceManager
if (self::_debug) {
error_log('Entering '.__FUNCTION__.' in '.__FILE__);
}
$user_id = intval(Database::escape_string($user_id));
$session_id = intval(Database::escape_string($session_id));
$row_entity_id = intval(Database::escape_string($row_entity_id));
$user_id = intval($user_id);
$session_id = intval($session_id);
$row_entity_id = intval($row_entity_id));
$seq_table = Database::get_main_table(TABLE_MAIN_SEQUENCE);
$val_table = Database::get_main_table(TABLE_SEQUENCE_VALUE);
$sql = "SELECT DISTINCT seq.sequence_row_entity_id, val.user_id
@ -533,7 +542,17 @@ class SequenceManager
if (self::_debug) {
error_log('Entering '.__FUNCTION__.' in '.__FILE__);
}
if (self::execute_formulas_by_user_id($row_entity_id, $user_id, $session_id, 'success', 1, null, null, null)) {
if (self::execute_formulas_by_user_id(
$row_entity_id,
$user_id,
$session_id,
'success',
1,
null,
null,
null
)
) {
$seq_table = Database::get_main_table(TABLE_MAIN_SEQUENCE);
$value = self::get_value_by_user_id($row_entity_id, $user_id, $session_id, 1, 1);
//$check_array = []; Update later
@ -547,7 +566,12 @@ class SequenceManager
$next[] = $temp_next['sequence_row_entity_id_next'];
}
foreach ($next as $nx) {
self::action_pre_init($nx, $user_id, $session_id, $available_end_date);
self::action_pre_init(
$nx,
$user_id,
$session_id,
$available_end_date
);
}
}
}
@ -563,9 +587,9 @@ class SequenceManager
if (self::_debug) {
error_log('Entering '.__FUNCTION__.' in '.__FILE__);
}
$row_id = intval(Database::escape_string($row_id));
$entity_id = intval(Database::escape_string($entity_id));
$c_id = intval(Database::escape_string($c_id));
$row_id = intval($row_id);
$entity_id = intval($entity_id);
$c_id = intval($c_id));
$row_entity_id_prev = self::get_row_entity_id_by_row_id($entity_id, $row_id, $c_id);
@ -601,9 +625,9 @@ class SequenceManager
if (self::_debug) {
error_log('Entering '.__FUNCTION__.' in '.__FILE__);
}
$row_id = intval(Database::escape_string($row_id));
$entity_id = intval(Database::escape_string($entity_id));
$c_id = intval(Database::escape_string($c_id));
$row_id = intval($row_id);
$entity_id = intval($entity_id);
$c_id = intval($c_id);
if ($row_id > 0 && $entity_id > 0 && $c_id > 0) {
$row_table = Database::get_main_table(TABLE_SEQUENCE_ROW_ENTITY);
$sql = "SELECT row.*
@ -611,7 +635,8 @@ class SequenceManager
WHERE
row.sequence_type_entity_id = $entity_id AND
row.row_id = $row_id AND
row.c_id = $c_id LIMIT 0, 1";
row.c_id = $c_id
LIMIT 0, 1";
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
@ -633,9 +658,9 @@ class SequenceManager
if (self::_debug) {
error_log('Entering '.__FUNCTION__.' in '.__FILE__);
}
$row_entity_id = intval(Database::escape_string($row_entity_id));
$user_id = intval(Database::escape_string($user_id));
$session_id = intval(Database::escape_string($session_id));
$row_entity_id = intval($row_entity_id);
$user_id = intval($user_id);
$session_id = intval($session_id);
if ($row_entity_id > 0 && $user_id > 0 && $session_id >= 0) {
$val_table = Database::get_main_table(TABLE_SEQUENCE_VALUE);
@ -666,9 +691,9 @@ class SequenceManager
break;
}
}
//Val row starts not available
// Val row starts not available
} else {
//Val row starts available
// Val row starts available
$available = 1;
}
return self::temp_hack_4_insert(1, $row_entity_id, $user_id, $available, $session_id);
@ -693,9 +718,9 @@ class SequenceManager
error_log('row_id: '.$row_id.'...................');
error_log('c_id: '.$c_id.'.......................');
}
$row_id = intval(Database::escape_string($row_id));
$entity_id = intval(Database::escape_string($entity_id));
$c_id = intval(Database::escape_string($c_id));
$row_id = intval($row_id);
$entity_id = intval($entity_id);
$c_id = intval($c_id);
$name = Database::escape_string($name);
if ($row_id > 0 && $entity_id > 0 && $c_id > 0) {
$row_table = Database::get_main_table(TABLE_SEQUENCE_ROW_ENTITY);
@ -817,7 +842,8 @@ class SequenceManager
$ety_table = Database::get_main_table(TABLE_SEQUENCE_TYPE_ENTITY);
$sql = "SELECT ety.ent_table
FROM $ety_table ety
WHERE ety.name = $entity_name LIMIT 0, 1";
WHERE ety.name = $entity_name
LIMIT 0, 1";
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
while ($temp_entity = Database::fetch_array($result, 'ASSOC')) {
@ -894,7 +920,7 @@ class SequenceManager
if (self::_debug) {
error_log('Entering '.__FUNCTION__.' in '.__FILE__);
}
$is_part = intval(Database::escape_string($is_part));
$is_part = intval($is_part);
$seq_table = Database::get_main_table(TABLE_MAIN_SEQUENCE);
$prev = self::get_row_entity_id_by_row_id($entity_id_prev, $row_id_prev, $c_id);
$next = self::get_row_entity_id_by_row_id($entity_id_next, $row_id_next, $c_id);
@ -922,10 +948,10 @@ class SequenceManager
if (self::_debug) {
error_log('Entering '.__FUNCTION__.' in '.__FILE__);
}
$user_id = intval(Database::escape_string($user_id));
$session_id = intval(Database::escape_string($session_id));
$total_items = intval(Database::escape_string($total_items));
$available = intval(Database::escape_string($available));
$user_id = intval($user_id));
$session_id = intval($session_id);
$total_items = intval($total_items);
$available = intval($available);
if ($available === -1) {
$pre_req = self::get_pre_req_id_by_row_entity_id($row_entity_id);
@ -960,7 +986,8 @@ class SequenceManager
}
$table = Database::get_main_table(TABLE_MAIN_SEQUENCE);
$row_entity_id_next = self::get_row_entity_id_by_row_id(1, $id, $c_id);
$sql = "DELETE FROM $table WHERE sequence_row_entity_id_next = $row_entity_id_next";
$sql = "DELETE FROM $table
WHERE sequence_row_entity_id_next = $row_entity_id_next";
Database::query($sql);
}
@ -1042,11 +1069,15 @@ class SequenceManager
}
}
public static function get_sessions_by_user_id ($user_id, $row_entity_id) {
public static function get_sessions_by_user_id($user_id, $row_entity_id)
{
if (self::_debug) {
error_log('Entering '.__FUNCTION__.' in '.__FILE__);
}
$val_table = Database::get_main_table(TABLE_SEQUENCE_VALUE);
$row_entity_id = intval($row_entity_id);
$sessions = [];
$sql = "SELECT session_id FROM $val_table
WHERE user_id = $user_id
@ -1058,7 +1089,8 @@ class SequenceManager
return $sessions;
}
public static function temp_hack_4_delete($entity_id, $row_id, $c_id) {
public static function temp_hack_4_delete($entity_id, $row_id, $c_id)
{
if (self::_debug) {
error_log('Entering '.__FUNCTION__.' in '.__FILE__);
}
@ -1073,7 +1105,8 @@ class SequenceManager
}
return false;
}
public static function temp_hack_3_delete($entity_id, $row_id, $c_id, $rule_id) {
public static function temp_hack_3_delete($entity_id, $row_id, $c_id, $rule_id)
{
if (self::_debug) {
error_log('Entering '.__FUNCTION__.' in '.__FILE__);
}
@ -1088,7 +1121,8 @@ class SequenceManager
}
if (is_array($seq_array)) {
foreach ($seq_array as $seq) {
$sql = "SELECT id FROM $seq_table WHERE sequence_row_entity_id_next = ".$seq['sequence_row_entity_id_next'];
$sql = "SELECT id FROM $seq_table
WHERE sequence_row_entity_id_next = ".$seq['sequence_row_entity_id_next'];
$result = Database::query($sql);
if (Database::num_rows($result) > 1){
$value = self::get_value_by_row_entity_id($seq['sequence_row_entity_id_next']);
@ -1110,9 +1144,10 @@ class SequenceManager
}
}
}
$sql = "DELETE FROM $seq_table WHERE
(sequence_row_entity_id = $row_entity_id AND sequence_row_entity_id_next = 0 ) OR
(sequence_row_entity_id_next = $row_entity_id)";
$sql = "DELETE FROM $seq_table
WHERE
(sequence_row_entity_id = $row_entity_id AND sequence_row_entity_id_next = 0 ) OR
(sequence_row_entity_id_next = $row_entity_id)";
Database::query($sql);
if (Database::affected_rows() > 0) {
return (!empty($seq_array))? $seq_array : true;
@ -1121,7 +1156,8 @@ class SequenceManager
return false;
}
public static function temp_hack_2_delete($entity_id, $row_id, $c_id) {
public static function temp_hack_2_delete($entity_id, $row_id, $c_id)
{
if (self::_debug) {
error_log('Entering '.__FUNCTION__.' in '.__FILE__);
}
@ -1136,7 +1172,9 @@ class SequenceManager
}
return false;
}
public static function temp_hack_5($entity_id, $row_id, $c_id, $rule_id) {
public static function temp_hack_5($entity_id, $row_id, $c_id, $rule_id)
{
if (self::_debug) {
error_log('Entering '.__FUNCTION__.' in '.__FILE__);
}
@ -1150,7 +1188,8 @@ class SequenceManager
return false;
}
public static function temp_hack_4_set_aval($row_entity_id, $user_id, $session_id, $available, $available_end_date = null) {
public static function temp_hack_4_set_aval($row_entity_id, $user_id, $session_id, $available, $available_end_date = null)
{
if (self::_debug) {
error_log('Entering '.__FUNCTION__.' in '.__FILE__);
}
@ -1184,7 +1223,7 @@ class SequenceManager
if (self::_debug) {
error_log('Entering '.__FUNCTION__.' in '.__FILE__);
}
$user_id = intval(Database::escape_string($user_id));
$user_id = intval($user_id);
if ($user_id > 0) {
$user_filter = "WHERE user_id = $user_id";
} else {
@ -1210,9 +1249,9 @@ class SequenceManager
if (self::_debug) {
error_log('Entering '.__FUNCTION__.' in '.__FILE__);
}
$row_entity_id = intval(Database::escape_string($row_entity_id));
$user_id = intval(Database::escape_string($user_id));
$session_id = intval(Database::escape_string($session_id));
$row_entity_id = intval($row_entity_id);
$user_id = intval($user_id);
$session_id = intval($session_id));
$val_table = Database::get_main_table(TABLE_SEQUENCE_VALUE);

@ -406,24 +406,28 @@ EOT;
/**
* Returns a button with the default (grey?) color and a magnifier icon
* @param string $label Text appearing on the button
* @param string $name Element name (for form treatment purposes)
*
* @return HTML_QuickForm_button
*/
public function addButtonSearch($label = null)
public function addButtonSearch($label = null, $name = 'submit')
{
if (empty($label)) {
$label = get_lang('Search');
}
return $this->addButton('submit', $label, 'search', 'default');
return $this->addButton($name, $label, 'search', 'default');
}
/**
* Returns a button with the primary color and a right-pointing arrow icon
* @param string $label Text appearing on the button
* @param string $name Element name (for form treatment purposes)
*
* @return HTML_QuickForm_button
*/
public function addButtonNext($label)
public function addButtonNext($label, $name = 'submit')
{
return $this->addButton('submit', $label, 'arrow-right', 'primary');
return $this->addButton($name, $label, 'arrow-right', 'primary');
}
/**

@ -0,0 +1,139 @@
{% extends template ~ "/layout/layout_1_col.tpl" %}
{% block content %}
<script>
var url = '{{ _p.web_ajax }}sequence.ajax.php';
var parentList = [];
var resourceId = 0;
$(document).ready(function() {
var type = $('input[name="sequence_type"]').val();
$('button[name="set_requirement"]').prop('disabled', true);
$('#parents').on('click', 'a', function() {
var vertexId = $(this).attr('data-id');
var parent = $(this).parent();
if (vertexId) {
$.ajax({
url: url + '?a=delete_vertex&id='+resourceId+'&vertex_id=' + vertexId + '&type=' + type,
success: function (data) {
parent.remove();
}
});
}
});
$('button[name="use_as_reference"]').click(function() {
$('button[name="set_requirement"]').prop('disabled', false);
var id = $("#item option:selected" ).val();
// Cleaning parent list.
parentList = [];
// Check if data exists and load parents
$.ajax({
url: url + '?a=load_resource&load_resource_type=parent&id=' + id + '&type='+type,
success: function (data) {
if (data) {
var listLoaded = data.split(',');
listLoaded.forEach(function(value) {
$.ajax({
url: url + '?a=get_icon&id='+ value+'&type='+type+'&show_delete=1',
success:function(data){
$('#parents').append(data);
parentList.push(id);
}
});
});
}
}
});
// Check if data exists and load children
$.ajax({
url: url + '?a=load_resource&load_resource_type=children&id=' + id + '&type='+type,
success: function (data) {
if (data) {
var listLoaded = data.split(',');
listLoaded.forEach(function(value) {
$.ajax({
url: url + '?a=get_icon&id='+ value+'&type='+type,
success:function(data){
$('#children').append(data);
}
});
});
}
}
});
// Cleaning
$('#parents').html('');
$('#children').html('');
$.ajax({
url: url + '?a=get_icon&id='+ id+'&type='+type,
success:function(data){
$('#resource').html(data);
parentList.push(id);
resourceId = id;
}
});
return false;
});
$('button[name="set_requirement"]').click(function() {
$("#item option:selected" ).each(function() {
var id = $(this).val();
if ($.inArray(id, parentList) == -1) {
$.ajax({
url: url + '?a=get_icon&id=' + id + '&type=' + type,
success: function (data) {
$('#parents').append(data);
parentList.push(id);
}
});
}
});
return false;
});
$('button[name="save_resource"]').click(function() {
if (resourceId != 0) {
var params = decodeURIComponent(parentList);
$.ajax({
url: url + '?a=save_resource&id=' + resourceId + '&parents=' + params+'&type='+type,
success: function (data) {
alert('saved');
}
});
}
return false;
});
});
</script>
<div class="row">
<div class="col-md-3">
{{ left_block }}
</div>
<div class="col-md-9">
<h3>
{{ 'ItemsTheReferenceDependsOn' | get_lang }}
</h3>
<div id="parents">
</div>
<h3>{{ 'Item' | get_lang }}</h3>
<div id="resource">
</div>
<h3>{{ 'Dependencies' | get_lang }}</h3>
<div id="children">
</div>
{{ right_block }}
</div>
</div>
{% endblock %}

@ -0,0 +1,17 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Entity\Manager;
use Sonata\CoreBundle\Model\BaseEntityManager;
/**
* Class SequenceManager
* CRUD for the course
*
* @package Chamilo\CoreBundle\Entity\Repository
*/
class SequenceManager extends BaseEntityManager
{
}

@ -0,0 +1,18 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Entity\Repository;
use Doctrine\ORM\EntityRepository;
/**
* Class SequenceRepository
* The functions inside this class must return an instance of QueryBuilder
*
* @package Chamilo\CoreBundle\Entity\Repository
*/
class SequenceRepository extends EntityRepository
{
}

@ -0,0 +1,114 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Class SequenceResource
* @ORM\Entity(repositoryClass="Chamilo\CoreBundle\Entity\Repository\SequenceRepository")
* @ORM\Table(name="sequence_resource")
* @ORM\Entity
*/
class SequenceResource
{
const COURSE_TYPE = 1;
const SESSION_TYPE = 2;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue()
*/
private $id;
/**
* @var integer
*
* @ORM\Column(name="type", type="integer")
*/
private $type;
/**
* @var integer
*
* @ORM\Column(name="resource_id", type="integer")
*/
private $resourceId;
/**
* @var string
*
* @ORM\Column(name="graph", type="text")
*/
private $graph;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* @param string $type
* @return SequenceResource
*/
public function setType($type)
{
$this->type = $type;
return $this;
}
/**
* @return string
*/
public function getGraph()
{
return $this->graph;
}
/**
* @param string $graph
* @return SequenceResource
*/
public function setGraph($graph)
{
$this->graph = $graph;
return $this;
}
/**
* @return int
*/
public function getResourceId()
{
return $this->resourceId;
}
/**
* @param int $resourceId
*/
public function setResourceId($resourceId)
{
$this->resourceId = $resourceId;
}
}
Loading…
Cancel
Save