Conditions | 6 |
Paths | 2 |
Total Lines | 167 |
Code Lines | 36 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
348 | public function getCourseMeetings() |
||
349 | { |
||
350 | $newMeetingsList = []; |
||
351 | $item = []; |
||
352 | $meetingsList = \Database::select( |
||
353 | '*', |
||
354 | $this->table, |
||
355 | ['where' => [ |
||
356 | 'c_id = ? ' => api_get_course_int_id(), |
||
357 | ' AND session_id = ? ' => api_get_session_id(), |
||
358 | ' AND status <> ? ' => 2, // status deleted |
||
359 | ], |
||
360 | ] |
||
361 | ); |
||
362 | $room = new Room(); |
||
363 | $room->SID = $this->sessionId; |
||
364 | if (!empty($meetingsList)) { |
||
365 | foreach ($meetingsList as $meetingDb) { |
||
366 | //$room->rooms_id = $meetingDb['room_id']; |
||
367 | error_log(__FILE__.'+'.__LINE__.' Meetings found: '.print_r($meetingDb, 1)); |
||
368 | $remoteMeeting = []; |
||
369 | $meetingDb['created_at'] = api_get_local_time($meetingDb['created_at']); |
||
370 | $meetingDb['closed_at'] = (!empty($meetingDb['closed_at']) ? api_get_local_time($meetingDb['closed_at']) : ''); |
||
371 | // Fixed value for now |
||
372 | $meetingDb['participantCount'] = 40; |
||
373 | $rec = $this->gateway->getFlvRecordingByRoomId($meetingDb['room_id']); |
||
374 | $links = []; |
||
375 | // Links to videos look like these: |
||
376 | // http://video2.openmeetings.com:5080/openmeetings/DownloadHandler?fileName=flvRecording_4.avi&moduleName=lzRecorderApp&parentPath=&room_id=&sid=dfc0cac396d384f59242aa66e5a9bbdd |
||
377 | $link = $this->url.'/DownloadHandler?fileName=%s&moduleName=lzRecorderApp&parentPath=&room_id=%s&sid=%s'; |
||
378 | if (!empty($rec)) { |
||
379 | $link1 = sprintf($link, $rec['fileHash'], $meetingDb['room_id'], $this->sessionId); |
||
380 | $link2 = sprintf($link, $rec['alternateDownload'], $meetingDb['room_id'], $this->sessionId); |
||
381 | $links[] = $rec['fileName'].' '. |
||
382 | \Display::url('[.flv]', $link1, ['target' => '_blank']).' '. |
||
383 | \Display::url('[.avi]', $link2, ['target' => '_blank']); |
||
384 | } |
||
385 | $item['show_links'] = implode('<br />', $links); |
||
386 | |||
387 | // The following code is currently commented because the web service |
||
388 | // says this is not allowed by the SOAP user. |
||
389 | /* |
||
390 | try { |
||
391 | // Get the conference room object from OpenMeetings server - requires SID and rooms_id to be defined |
||
392 | $objRoomId = $this->gateway->getRoomById($meetingDb['room_id']); |
||
393 | if (empty($objRoomId->return)) { |
||
394 | error_log(__FILE__.'+'.__LINE__.' Emptyyyyy '); |
||
395 | //\Database::delete($this->table, "id = {$meetingDb['id']}"); |
||
396 | // Don't delete expired rooms, just mark as closed |
||
397 | \Database::update($this->table, array('status' => 0, 'closed_at' => api_get_utc_datetime()), array('id = ? ' => $meetingDb['id'])); |
||
398 | continue; |
||
399 | } |
||
400 | //$objCurUs = $omServices->getRoomWithCurrentUsersById($objCurrentUsers); |
||
401 | } catch (SoapFault $e) { |
||
402 | error_log(__FILE__.'+'.__LINE__.' '.$e->faultstring); |
||
403 | exit; |
||
404 | } |
||
405 | //if( empty($objCurUs->returnMeetingID) ) continue; |
||
406 | |||
407 | $current_room = array( |
||
408 | 'roomtype' => $objRoomId->return->roomtype->roomtypes_id, |
||
409 | 'meetingName' => $objRoomId->return->name, |
||
410 | 'meetingId' => $objRoomId->return->meetingID, |
||
411 | 'createTime' => $objRoomId->return->rooms_id, |
||
412 | 'showMicrophoneStatus' => $objRoomId->return->showMicrophoneStatus, |
||
413 | 'attendeePw' => $objRoomId->return->attendeePW, |
||
414 | 'moderatorPw' => $objRoomId->return->moderators, |
||
415 | 'isClosed' => $objRoomId->return->isClosed, |
||
416 | 'allowRecording' => $objRoomId->return->allowRecording, |
||
417 | 'startTime' => $objRoomId->return->startTime, |
||
418 | 'endTime' => $objRoomId->return->updatetime, |
||
419 | 'participantCount' => count($objRoomId->return->currentusers), |
||
420 | 'maxUsers' => $objRoomId->return->numberOfPartizipants, |
||
421 | 'moderatorCount' => count($objRoomId->return->moderators) |
||
422 | ); |
||
423 | // Then interate through attendee results and return them as part of the array: |
||
424 | if (!empty($objRoomId->return->currentusers)) { |
||
425 | foreach ($objRoomId->return->currentusers as $a) |
||
426 | $current_room[] = array( |
||
427 | 'userId' => $a->username, |
||
428 | 'fullName' => $a->firstname . " " . $a->lastname, |
||
429 | 'isMod' => $a->isMod |
||
430 | ); |
||
431 | } |
||
432 | $remoteMeeting = $current_room; |
||
433 | */ |
||
434 | |||
435 | if (empty($remoteMeeting)) { |
||
436 | /* |
||
437 | error_log(__FILE__.'+'.__LINE__.' Empty remote Meeting for now'); |
||
438 | if ($meetingDb['status'] == 1 && $this->isTeacher()) { |
||
439 | $this->endMeeting($meetingDb['id']); |
||
440 | } |
||
441 | */ |
||
442 | } else { |
||
443 | $remoteMeeting['add_to_calendar_url'] = api_get_self().'?action=add_to_calendar&id='.$meetingDb['id'].'&start='.api_strtotime($meetingDb['startTime']); |
||
444 | } |
||
445 | $remoteMeeting['end_url'] = api_get_self().'?action=end&id='.$meetingDb['id']; |
||
446 | $remoteMeeting['delete_url'] = api_get_self().'?action=delete&id='.$meetingDb['id']; |
||
447 | |||
448 | //$record_array = array(); |
||
449 | |||
450 | // if ($meetingDb['record'] == 1) { |
||
451 | // $recordingParams = array( |
||
452 | // 'meetingId' => $meetingDb['id'], //-- OPTIONAL - comma separate if multiple ids |
||
453 | // ); |
||
454 | // |
||
455 | // $records = $this->api->getRecordingsWithXmlResponseArray($recordingParams); |
||
456 | // if (!empty($records)) { |
||
457 | // $count = 1; |
||
458 | // if (isset($records['message']) && !empty($records['message'])) { |
||
459 | // if ($records['messageKey'] == 'noRecordings') { |
||
460 | // $record_array[] = get_lang('NoRecording'); |
||
461 | // } else { |
||
462 | // //$record_array[] = $records['message']; |
||
463 | // } |
||
464 | // } else { |
||
465 | // foreach ($records as $record) { |
||
466 | // if (is_array($record) && isset($record['recordId'])) { |
||
467 | // $url = Display::url(get_lang('ViewRecord'), $record['playbackFormatUrl'], array('target' => '_blank')); |
||
468 | // if ($this->is_teacher()) { |
||
469 | // $url .= Display::url(Display::return_icon('link.gif',get_lang('CopyToLinkTool')), api_get_self().'?action=copy_record_to_link_tool&id='.$meetingDb['id'].'&record_id='.$record['recordId']); |
||
470 | // $url .= Display::url(Display::return_icon('agenda.png',get_lang('AddToCalendar')), api_get_self().'?action=add_to_calendar&id='.$meetingDb['id'].'&start='.api_strtotime($meetingDb['created_at']).'&url='.$record['playbackFormatUrl']); |
||
471 | // $url .= Display::url(Display::return_icon('delete.png',get_lang('Delete')), api_get_self().'?action=delete_record&id='.$record['recordId']); |
||
472 | // } |
||
473 | // //$url .= api_get_self().'?action=publish&id='.$record['recordID']; |
||
474 | // $count++; |
||
475 | // $record_array[] = $url; |
||
476 | // } else { |
||
477 | // |
||
478 | // } |
||
479 | // } |
||
480 | // } |
||
481 | // } |
||
482 | // //var_dump($record_array); |
||
483 | // $item['show_links'] = implode('<br />', $record_array); |
||
484 | // |
||
485 | // } |
||
486 | // |
||
487 | //$item['created_at'] = api_convert_and_format_date($meetingDb['created_at']); |
||
488 | // //created_at |
||
489 | // |
||
490 | // $item['publish_url'] = api_get_self().'?action=publish&id='.$meetingDb['id']; |
||
491 | // $item['unpublish_url'] = api_get_self().'?action=unpublish&id='.$meetingDb['id']; |
||
492 | // |
||
493 | //if ($meetingDb['status'] == 1) { |
||
494 | // $joinParams = array( |
||
495 | // 'meetingId' => $meetingDb['id'], //-- REQUIRED - A unique id for the meeting |
||
496 | // 'username' => $this->user_complete_name, //-- REQUIRED - The name that will display for the user in the meeting |
||
497 | // 'password' => $pass, //-- REQUIRED - The attendee or moderator password, depending on what's passed here |
||
498 | // 'createTime' => '', //-- OPTIONAL - string. Leave blank ('') unless you set this correctly. |
||
499 | // 'userID' => '', // -- OPTIONAL - string |
||
500 | // 'webVoiceConf' => '' // -- OPTIONAL - string |
||
501 | // ); |
||
502 | // $returnVal = $this->setUserObjectAndGenerateRoomHashByURLAndRecFlag( array('room_id' => $meetingDb['id']) ); |
||
503 | // $joinUrl = CONFIG_OPENMEETINGS_SERVER_URL . "?" . |
||
504 | // "secureHash=" . $returnVal; |
||
505 | // |
||
506 | // $item['go_url'] = $joinUrl; |
||
507 | //} |
||
508 | $item = array_merge($item, $meetingDb, $remoteMeeting); |
||
509 | //error_log(__FILE__.'+'.__LINE__.' Item: '.print_r($item,1)); |
||
510 | $newMeetingsList[] = $item; |
||
511 | } //end foreach $meetingsList |
||
512 | } |
||
513 | |||
514 | return $newMeetingsList; |
||
515 | } |
||
582 |
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.