diff --git a/main/inc/lib/career.lib.php b/main/inc/lib/career.lib.php index 6ae8158423..e13a68847c 100644 --- a/main/inc/lib/career.lib.php +++ b/main/inc/lib/career.lib.php @@ -13,6 +13,7 @@ require_once 'fckeditor/fckeditor.php'; define ('CAREER_STATUS_ACTIVE', 1); define ('CAREER_STATUS_INACTIVE',0); + /** * @package chamilo.library */ @@ -162,7 +163,6 @@ class Career extends Model { return $cid; } - public function save($params) { $id = parent::save($params); if (!empty($id)) { @@ -174,6 +174,5 @@ class Career extends Model { public function delete($id) { parent::delete($id); event_system(LOG_CAREER_DELETE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id()); - } - -} + } +} \ No newline at end of file diff --git a/main/inc/lib/link.lib.php b/main/inc/lib/link.lib.php index f1364f1fd6..738686e1ba 100644 --- a/main/inc/lib/link.lib.php +++ b/main/inc/lib/link.lib.php @@ -20,6 +20,31 @@ /* FUNCTIONS */ + +class Link extends Model { + var $table; + var $is_course_model = true; + var $columns = array('id', 'c_id','url','title','description','category_id', 'display_order', 'on_homepage', 'target', 'session_id'); + var $required = array('url', 'title'); + + public function __construct() { + $this->table = Database::get_course_table(TABLE_LINK); + } + + public function save($params) { + $course_info = api_get_course_info(); + $params['session_id'] = api_get_session_id(); + $params['category_id'] = isset($params['category_id']) ? $params['category_id'] : 0; + + $id = parent::save($params); + if (!empty($id)) { + api_item_property_update($course_info, TOOL_LINK, $id, 'LinkAdded', api_get_user_id()); + } + return $id; + } +} + + /** * Used to add a link or a category * @param string $type, "link" or "category" diff --git a/main/link/link.php b/main/link/link.php index 4f47235451..ececd2a138 100644 --- a/main/link/link.php +++ b/main/link/link.php @@ -224,7 +224,7 @@ if (api_is_allowed_to_edit(null, true) && isset($_GET['action'])) { * URL
- +
'; echo '
@@ -232,7 +232,7 @@ if (api_is_allowed_to_edit(null, true) && isset($_GET['action'])) { '.get_lang('LinkName').'
- +
'; echo '
@@ -248,7 +248,7 @@ if (api_is_allowed_to_edit(null, true) && isset($_GET['action'])) { '.get_lang('Description').'
- +
'; diff --git a/plugin/bbb/bbb.lib.php b/plugin/bbb/bbb.lib.php index f264166498..ab929ea7cc 100644 --- a/plugin/bbb/bbb.lib.php +++ b/plugin/bbb/bbb.lib.php @@ -101,16 +101,30 @@ class bbb { if ($this->debug) error_log("meeting does not exist: $meeting_name "); return false; } + $meeting_is_running = BigBlueButtonBN::isMeetingRunning($meeting_data['id'], $this->url, $this->salt); + + + $meeting_info = BigBlueButtonBN::getMeetingInfoArray($meeting['id'], $pass, $this->url, $this->salt); + $meeting_info_exists = false; + + if ($meeting_info['returncode'] != 'FAILED') { + $meeting_info_exists = true; + } $url = false; if ($this->debug) error_log("meeting is running".$meeting_is_running); - if (isset($meeting_is_running)) { + + if (isset($meeting_is_running) && $meeting_info_exists) { $url = $this->protocol.BigBlueButtonBN::joinURL($meeting_data['id'], $this->user_complete_name, $pass, $this->salt, $this->url); } - if ($this->debug) error_log("url :".$url); + if ($this->debug) error_log("return url :".$url); return $url; } - + + /** + * Gets all the course meetings saved in the plugin_bbb_meeting table + * @return string + */ function get_course_meetings() { $pass = $this->get_user_metting_password(); $meeting_list = Database::select('*', $this->table, array('where' => array('c_id = ? ' => api_get_course_int_id()))); @@ -120,8 +134,7 @@ class bbb { $item_meeting = $meeting; $item_meeting['info'] = BigBlueButtonBN::getMeetingInfoArray($meeting['id'], $pass, $this->url, $this->salt); - if ($meeting['info']['returncode'] == 'FAILED') { - + if ($meeting['info']['returncode'] == 'FAILED') { } else { $item_meeting['end_url'] = api_get_self().'?action=end&id='.$meeting['id']; } @@ -129,19 +142,25 @@ class bbb { if ($meeting['record'] == 1) { $records = BigBlueButtonBN::getRecordingsArray($meeting['id'], $this->url, $this->salt); - - if (!empty($records)) { - foreach ($records as $record) { - //var_dump($record); + //var_dump($meeting['id']); + if (!empty($records)) { + foreach ($records as $record) { if (is_array($record) && isset($record['recordID']) && isset($record['playbacks'])) { - foreach ($record['playbacks'] as $item) { - $url = Display::url(get_lang('ViewRecord'), $item['url'], array('target' => '_blank')); + + //Fix the bbb timestamp + $record['startTime'] = substr($record['startTime'], 0, strlen($record['startTime']) -3); + $record['endTime'] = substr($record['endTime'], 0, strlen($record['endTime']) -3); + + foreach ($record['playbacks'] as $item) { + $url = Display::url(get_lang('ViewRecord'), $item['url'], array('target' => '_blank')).' - '.api_convert_and_format_date($record['startTime']).' - '.api_convert_and_format_date($record['endTime']); + //$url .= Display::url(get_lang('DeleteRecord'), api_get_self().'?action=delete_record&'.$record['recordID']); + $url .= Display::url(get_lang('CopyToLinkTool'), api_get_self().'?action=copy_record_to_link_tool&id='.$meeting['id'].'&record_id='.$record['recordID']); //$url .= api_get_self().'?action=publish&id='.$record['recordID']; $record_array[] = $url; } } } - } + } $item_meeting['show_links'] = implode('
', $record_array); } @@ -200,5 +219,34 @@ class bbb { } return 0; - } + } + + /** + * @todo + */ + function delete_record($id) { + } + + function copy_record_to_link_tool($id, $record_id) { + require_once api_get_path(LIBRARY_PATH).'link.lib.php'; + $records = BigBlueButtonBN::getRecordingsArray($id, $this->url, $this->salt); + if (!empty($records)) { + foreach ($records as $record) { + if ($record['recordID'] == $record_id) { + if (is_array($record) && isset($record['recordID']) && isset($record['playbacks'])) { + foreach ($record['playbacks'] as $item) { + $link = new Link(); + $params['url'] = $item['url']; + $params['title'] = 'bbb 1'; + $id = $link->save($params); + return $id; + } + } + + } + } + } + return false; + + } } \ No newline at end of file diff --git a/plugin/bbb/listing.php b/plugin/bbb/listing.php index 2a20c6f818..4b5b828d44 100644 --- a/plugin/bbb/listing.php +++ b/plugin/bbb/listing.php @@ -6,40 +6,49 @@ /** * Initialization */ + +$language_file = array('videoconf'); + require_once '../../main/inc/global.inc.php'; require_once 'bbb.lib.php'; require_once 'bbb_api.php'; -$course_code = api_get_course_id(); - - $bbb = new bbb(); $action = isset($_GET['action']) ? $_GET['action'] : null; switch ($action) { + case 'copy_record_to_link_tool': + $result = $bbb->copy_record_to_link_tool($_GET['id'], $_GET['record_id']); + if ($result) { + $message = Display::return_message(get_lang('Copied'), 'success'); + } else { + $message = Display::return_message(get_lang('Error'), 'error'); + } + break; + case 'delete_recording': + //$bbb->delete_record($_GET['id']); + break; case 'end': $bbb->end_meeting($_GET['id']); - break; - case 'save_to_documents': - $bbb->save_recording_to_document($_GET['id']); + $message = Display::return_message(get_lang('MeetingClosed'), 'success'); break; case 'publish': - $result = $bbb->publish_meeting($_GET['id']); + //$result = $bbb->publish_meeting($_GET['id']); break; case 'unpublish': - $result = $bbb->unpublish_meeting($_GET['id']); + //$result = $bbb->unpublish_meeting($_GET['id']); break; } $meetings = $bbb->get_course_meetings(); $users_online = $bbb->get_users_online_in_current_room(); - +$tool_name = get_lang('OrganisationSVideoconference'); $tpl = new Template($tool_name); $tpl->assign('meetings', $meetings); -$conference_url = api_get_path(WEB_PLUGIN_PATH).'bbb/start.php?'.api_get_cidreq(); +$conference_url = api_get_path(WEB_PLUGIN_PATH).'bbb/start.php?launch=1&'.api_get_cidreq(); $tpl->assign('conference_url', $conference_url); $tpl->assign('users_online', $users_online); diff --git a/plugin/bbb/listing.tpl b/plugin/bbb/listing.tpl index c90d440cf3..5358d655de 100644 --- a/plugin/bbb/listing.tpl +++ b/plugin/bbb/listing.tpl @@ -1,20 +1,25 @@
-
- +
- {{ 'EnterTheConference'|get_lang }} + {{ 'StartConference'|get_lang }} - {{ users_online }} user online + {{ users_online }} user(s) online
+
+ + + - + - + {% for meeting in meetings %} @@ -22,13 +27,20 @@
{{'id'|get_lang}}# {{'Meeting'|get_lang}} {{'Date'|get_lang}} {{'Actions'|get_lang}}
{{ meeting.id }}{{ meeting.created_at }} {% if meeting.record == 1 %} + + {# Record list #} {{ meeting.show_links }} + {% endif %} +
{% if meeting.status == 1 %} - Close + {{'MeetingOpened'|get_lang}} + {{'CloseMeeting'|get_lang}} + {% else %} + {{'MeetingClosed'|get_lang}} {% endif %} diff --git a/plugin/bbb/start.php b/plugin/bbb/start.php index 040852b606..35923fd0df 100644 --- a/plugin/bbb/start.php +++ b/plugin/bbb/start.php @@ -15,6 +15,14 @@ $course_code = api_get_course_id(); $meeting_params = array(); $meeting_params['meeting_name'] = api_get_course_id(); +$teacher = api_is_course_admin() || api_is_coach() || api_is_platform_admin(); + +//If I'm a teacher I'm going to the listing page +if ($teacher && !isset($_GET['launch'])) { + header('location: listing.php?'.api_get_cidreq()); + exit; +} + $bbb = new bbb(); if ($bbb) {