Skip to content

Plugin: BBB: Update upstream PHP API library - refs #3244 #6553

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"a2lix/translation-form-bundle": "^3.0",
"api-platform/core": "^3.0",
"beberlei/doctrineextensions": "^1.3",
"bigbluebutton/bigbluebutton-api-php": "^2.0",
"chamilo/google-map-form-type-bundle": "1.7",
"chamilo/settings-bundle": "1.3.0",
"clue/graph": "^0.9.2",
Expand Down
146 changes: 143 additions & 3 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions public/main/inc/ajax/plugin.ajax.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php
/* For licensing terms, see /license.txt */

use Chamilo\CoreBundle\Entity\ResourceNode;
use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CourseBundle\Entity\CDocument;
use Michelf\MarkdownExtra;
use Chamilo\CoreBundle\Entity\Plugin;

Expand Down Expand Up @@ -112,7 +114,53 @@

echo json_encode(['success' => true, 'message' => "Plugin action '$action' applied to '$pluginTitle'."]);
break;
case 'list_documents':
$courseId = api_get_course_int_id();
$em = Database::getManager();
$repo = $em->getRepository(ResourceNode::class);

$qb = $em->createQueryBuilder()
->select('DISTINCT d')
->from(CDocument::class, 'd')
->innerJoin('d.resourceNode','rn')
->innerJoin('rn.resourceFiles','rf')
->where('d.filetype = :type')
->setParameter('type','file');

if ($courseId > 0) {
$qb->innerJoin('rn.resourceLinks','rl')
->andWhere('rl.course = :c')
->setParameter('c',$courseId);
}

$docs = $qb->getQuery()->getResult();
$out = [];

foreach ($docs as $doc) {
$files = $doc->getResourceNode()->getResourceFiles();
if ($files->isEmpty()) continue;

$file = $files->first();
$orig = $file->getOriginalName();
$ext = strtolower(pathinfo($orig, PATHINFO_EXTENSION));
if (! in_array($ext, ['pdf','ppt','pptx','odp'], true)) {
continue;
}

$path = '/var/upload/resource'.$repo->getFilename($file);
$base = str_replace('/public/', '', api_get_path(SYS_PATH));
$sysPath = $base . $path;

$out[] = [
'id' => $doc->getIid(),
'url' => $sysPath,
'filename' => $orig,
];
}

header('Content-Type: application/json');
echo json_encode($out);
exit;
default:
echo json_encode(['error' => 'Invalid action']);
}
9 changes: 8 additions & 1 deletion public/plugin/Bbb/lib/bbb.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public function __construct(
define('CONFIG_SERVER_BASE_URL', $this->url);
define('CONFIG_SERVER_PROTOCOL', $this->protocol);

$this->api = new BigBlueButtonBN();
$this->api = new BigBlueButtonBN(CONFIG_SERVER_URL_WITH_PROTOCOL, CONFIG_SECURITY_SALT);
$this->pluginEnabled = true;
$this->logoutUrl = $this->getListingUrl();
}
Expand Down Expand Up @@ -463,6 +463,7 @@ public function createMeeting($params)
'maxParticipants' => $max,
'record' => $record,
'duration' => $duration,
'documents' => $params['documents'],
];

$status = false;
Expand Down Expand Up @@ -636,9 +637,15 @@ public function joinMeeting($meetingName)
'username' => $this->userCompleteName,
'password' => $pass,
'userID' => api_get_user_id(),
'moderatorPw' => $this->getModMeetingPassword(),
'userID' => api_get_user_id(),
'webVoiceConf' => '',
];
$url = $this->api->getJoinMeetingURL($joinParams);
if (preg_match('#^https?://#i', $url)) {
return $url;
}

return $this->protocol . $url;
}

Expand Down
Loading
Loading