next up previous contents
Next: 字串 Up: Openmeetings 優化 Previous: 模組函式   Contents

會議室編輯

  1. 原模組會議室設定程式,無法刪除錄影、會議室型態選擇不判斷是否只能錄影、錄影影片列表權限無法區分,必須修改的程式碼相當多。首先,先在開始定義函式新增 moodle 環境變數 $CFG,$DB,$USER
    [root@moodle moodle23]# diff -urN -wbBE mod_tmp/openmeetings/mod_form.php mod/openmeetings/mod_form.php
    --- mod_tmp/openmeetings/mod_form.php	2012-08-02 19:04:40.000000000 +0800
    +++ mod/openmeetings/mod_form.php	2014-02-25 09:17:39.130260495 +0800
    @@ -29,11 +29,13 @@
     
     class mod_openmeetings_mod_form extends moodleform_mod {
     
    	function definition() {
     
    -		global $openmeetings_gateway, $om_login;
    +		global $CFG,$DB,$USER,$openmeetings_gateway, $om_login;
     		$mform = $this->_form;
    +		$current=$this->current;
    
  2. 修改取得可用錄影影片列表,依據用戶權限取得該用戶所錄置的影片,並將此段程式碼移至會議室型態設定之前,以作為是否有可用錄影影片可用,有才可以選擇播放錄影。有管理 openmeetings 權限的用戶,則列出所有錄影影片。
    @@ -44,11 +46,78 @@
     
     		$mform->addElement('hidden', 'room_id', '0', array('size'=>'64'));
     
    +		
    +		/// Adding the "Available Recordings to Shows" field
    +		$recordingsbyroom = array();
    +		$recordings = array();
    +		if ($om_login) {
    +		
    +			$query = 'SELECT id,course,room_id FROM '.$CFG->prefix.'openmeetings';
    +			$course_room = $DB->get_records_sql($query);
    +			foreach ($course_room as $cr) {
    +					$resultDom = $openmeetings_gateway->openmeetings_getFlvRecordingByRoomId($cr->room_id); 
    +					$query = 'SELECT id,category,shortname FROM '.$CFG->prefix.'course WHERE id='.$cr->course;
    +					$course = $DB->get_records_sql($query);
    +					$query = 'SELECT id,path FROM '.$CFG->prefix.'course_categories where id='.$course[$cr->course]->category;
    +					$course_categories = $DB->get_records_sql($query);
    +					$cc=explode('/',$course_categories[$course[$cr->course]->category]->path);
    +					if (count($cc) > 2){
    +						$query = 'SELECT id,name FROM '.$CFG->prefix.'course_categories where id='.$cc[1];
    +						$course_categories = $DB->get_records_sql($query);
    +						$acysem = $course_categories[$cc[1]]->name.'/';
    +					} else { $acysem = ''; }
    +				$flvrecordings = $resultDom->getElementsByTagName('return');
    +					
    +				foreach ($flvrecordings as $flvrecording) {
    +					$flvRecordingIdNode = $flvrecording->getElementsByTagName('flvRecordingId');
    +					$flvRecordingNameNode = $flvrecording->getElementsByTagName('fileName');
    +					if ($flvRecordingIdNode->length > 0) {
    +						$recordingsbyroom[$flvRecordingIdNode->item(0)->nodeValue] = 
    +							$acysem.$course[$cr->course]->shortname.' '.
    +							substr_replace($flvRecordingNameNode->item(0)->nodeValue,'',0,9);
    +						//$recordings[$flvRecordingIdNode->item(0)->nodeValue] = $flvRecordingNameNode->item(0)->nodeValue;
    +					}
    +				}
    +			}
    +            
    +        	$context = get_context_instance(CONTEXT_SYSTEM);
    +
    +		    if (has_capability('mod/openmeetings:becomemoderator', $context)) {
    +				$resultDom = $openmeetings_gateway->openmeetings_getFlvRecordingByExternalRoomTypeByList(); 
    +			}
    +			else {
    +				$resultDom = $openmeetings_gateway->openmeetings_getFlvRecordingByExternalUserId();
    +			}
    +			$flvrecordings = $resultDom->getElementsByTagName('return');
    +				
    +			foreach ($flvrecordings as $flvrecording) {
    +				$flvRecordingIdNode = $flvrecording->getElementsByTagName('flvRecordingId');
    +				$flvRecordingNameNode = $flvrecording->getElementsByTagName('fileName');
    +				if ($flvRecordingIdNode->length > 0 && $recordingsbyroom[$flvRecordingIdNode->item(0)->nodeValue] !='') {
    +					$recordings[$flvRecordingIdNode->item(0)->nodeValue] = 
    +						$recordingsbyroom[$flvRecordingIdNode->item(0)->nodeValue]; 
    +				} else {
    +					$recordings[$flvRecordingIdNode->item(0)->nodeValue] = 
    +						substr_replace($flvRecordingNameNode->item(0)->nodeValue,'',0,9);
    +				}
    +			}
    +			//uksort($recordings); //dywang sort by date
    +			asort($recordings); 
    +				
    +		}
    
  3. 判斷目前的會議室是否還沒設定?用戶是否有可用的錄影影片?有錄影影片可用且會議室還未設定,就有四種型態可供設定。如果為已存在的會議室或無錄影可用,則只提供三種會議室型態供設定。其他則只能設定為播放錄影。
     		/// Adding the "Room Type" field
    +		$recordingcheck = array_filter($recordings);
    +		if ($current->id == '' and count($recordingcheck)>0 ) {
     		$mform->addElement('select', 'type', get_string('Room_Type', 'openmeetings'), array('1'=>get_string('Conference', 'openmeetings'), '3'=>get_string('Restricted', 'openmeetings'), '4'=>get_string('Interview', 'openmeetings'), '0'=>get_string('Recording', 'openmeetings')));
    +		} elseif ($current->type != 0 or count($recordingcheck) == 0){
    +			$mform->addElement('select', 'type', get_string('Room_Type', 'openmeetings'), array('1'=>get_string('Conference', 'openmeetings'), '3'=>get_string('Restricted', 'openmeetings'), '4'=>get_string('Interview', 'openmeetings')));
    +		} else {
    +			$mform->addElement('select', 'type', get_string('Room_Type', 'openmeetings'), array('0'=>get_string('Recording', 'openmeetings')));
    +		}
    
  4. 修改會議室人數選項,刪除 200 人以上選項。
     		/// Adding the "Number of Participants" field
    -		$mform->addElement('select', 'max_user', get_string('Max_User', 'openmeetings'), array('2'=>'2', '4'=>'4', '8'=>'8', '16'=>'16', '24'=>'24', '36'=>'36', '50'=>'50', '100'=>'100', '150'=>'150', '200'=>'200', '250'=>'250', '500'=>'500', '1000'=>'1000'));
    +		$mform->addElement('select', 'max_user', get_string('Max_User', 'openmeetings'), array('2'=>'2', '4'=>'4', '8'=>'8', '16'=>'16', '24'=>'24', '36'=>'36', '50'=>'50', '100'=>'100', '150'=>'150'));//dywang
    
  5. 修改會議室描述編輯區塊。
    @@ -87,7 +156,7 @@
     		$mform->addElement('select', 'language', get_string('Room_Language', 'openmeetings'), $language_array);
     		
     		/// Some description
    -		$mform->addElement('static', 'description', '', get_string('Moderation_Description', 'openmeetings'));
    +		$this->add_intro_editor(false, get_string('Comment', 'openmeetings')); //dywang
    
  6. 刪除原始取得錄影影片列表的程式。
    @@ -96,43 +165,27 @@
     		/// Adding the optional "intro" and "introformat" pair of fields
    -		$mform->addElement('htmleditor', 'intro', get_string('Comment', 'openmeetings'));
    -		$mform->setType('intro', PARAM_RAW);
    -		
    -		
    -		/// Adding the "Available Recordings to Shows" field
    -		$recordings = array();
    -			
    -		if ($om_login) {
    -		
    -			$resultDom = $openmeetings_gateway->openmeetings_getRecordingsByExternalRooms();
    -		
    -			$flvrecordings = $resultDom->getElementsByTagName('return');
    -				
    -			foreach ($flvrecordings as $flvrecording) {
    -				
    -				$flvRecordingIdNode = $flvrecording->getElementsByTagName('flvRecordingId');
    -				$flvRecordingNameNode = $flvrecording->getElementsByTagName('fileName');
    -				if ($flvRecordingIdNode->length > 0) {
    -					$recordings[$flvRecordingIdNode->item(0)->nodeValue] = $flvRecordingNameNode->item(0)->nodeValue;
    -				}
    -				
    -			}
     				
    -		
    -		
    -		}
    
  7. 增加移除錄影的按鈕。
     		
     		$mform->registerNoSubmitButton('avi');
     		$mform->registerNoSubmitButton('flv');
    +		$mform->registerNoSubmitButton('rm_rec');
     		$dgrp = array();
     		$dgrp[] =& $mform->createElement('static', 'description', '', get_string('recordings_label', 'openmeetings'));
     		$dgrp[] =& $mform->createElement('select', 'room_recording_id', get_string('recordings_show', 'openmeetings'), $recordings);
    +		$dgrp[] =& $mform->createElement('submit', 'rm_rec', get_string('rm_rec', 'openmeetings')); //dywang
     		$dgrp[] =& $mform->createElement('submit', 'avi', get_string('download_avi', 'openmeetings'));
     		$dgrp[] =& $mform->createElement('submit', 'flv', get_string('download_flv', 'openmeetings'));
     		$mform->addGroup($dgrp, 'dgrp', get_string('recordings_show', 'openmeetings'), array(' '), false);
    +		$mform->setType('rm_rec', PARAM_NOTAGS);
     		$mform->setType('avi', PARAM_NOTAGS);
     		$mform->setType('flv', PARAM_NOTAGS);
    
  8. 增加提交時,判斷是否是刪除錄影,如果是,則進行錄影刪除。
    @@ -158,7 +211,36 @@
     
     $mform = new mod_openmeetings_mod_form();
     
    -if ($mform->no_submit_button_pressed() && $om_login) {
    +if ($mform->no_submit_button_pressed() && $om_login) { //dywang
    +	if (isset($mform->get_submitted_data()->{'rm_rec'})) {
    +		$openmeetings_gateway->openmeetings_deleteFlvRecording($mform->get_submitted_data()->{'room_recording_id'});
    +		return;
    +	}
    +	else {
     	$type = isset($mform->get_submitted_data()->{'avi'}) ? "avi" :
     			(isset($mform->get_submitted_data()->{'flv'}) ? "flv" : "none");
     	$filename = 'flvRecording_' . $mform->get_submitted_data()->{'room_recording_id'} . '.' . $type;
                     . '&sid=' . $openmeetings_gateway->session_id);
     	exit(0);
     	}
    +}
    



2017-08-04