-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
helper contains a few more DokuWiki specifics around BBB action will handle the redirect to the room admin will be used to edit the room setups
- Loading branch information
1 parent
d0c80a3
commit 945c2be
Showing
5 changed files
with
219 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
/** | ||
* DokuWiki Plugin bigbluebutton (Action Component) | ||
* | ||
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html | ||
* @author Andreas Gohr <andi@splitbrain.org> | ||
*/ | ||
|
||
// must be run within Dokuwiki | ||
if (!defined('DOKU_INC')) die(); | ||
|
||
if (!defined('DOKU_LF')) define('DOKU_LF', "\n"); | ||
if (!defined('DOKU_TAB')) define('DOKU_TAB', "\t"); | ||
if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); | ||
|
||
require_once DOKU_PLUGIN.'action.php'; | ||
require_once DOKU_PLUGIN.'bigbluebutton/syntax.php'; | ||
|
||
class action_plugin_bigbluebutton extends DokuWiki_Action_Plugin { | ||
|
||
function register(&$controller) { | ||
|
||
$controller->register_hook('DOKUWIKI_STARTED', 'AFTER', $this, 'handle_dokuwiki_started'); | ||
|
||
} | ||
|
||
function handle_dokuwiki_started(&$event, $param) { | ||
if(!isset($_REQUEST['bigbluebutton'])) return; | ||
|
||
$helper = load_plugin('helper','bigbluebutton'); | ||
$room = $_REQUEST['bigbluebutton']; | ||
$setup = helper->loadRoomSetup($room); | ||
if(!count($setup)){ | ||
msg('No such room setup',-1); | ||
return; | ||
} | ||
|
||
$perm = $helper->checkPermission($room); | ||
if(!$perm){ | ||
msg('Sorry, you have no permission to join this room'); | ||
return; | ||
} | ||
|
||
$bbb = new BigBlueButton($this->getConf('apiurl'), | ||
$conf->getConf('salt')); | ||
|
||
$url = $bbb->joinRoomURL($room, 'FIXME', ($perm > 3), $setup); | ||
|
||
if($url) send_redirect($url); | ||
} | ||
|
||
} | ||
|
||
// vim:ts=4:sw=4:et:enc=utf-8: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
/** | ||
* DokuWiki Plugin bigbluebutton (Admin Component) | ||
* | ||
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html | ||
* @author Andreas Gohr <andi@splitbrain.org> | ||
*/ | ||
|
||
// must be run within Dokuwiki | ||
if (!defined('DOKU_INC')) die(); | ||
|
||
if (!defined('DOKU_LF')) define('DOKU_LF', "\n"); | ||
if (!defined('DOKU_TAB')) define('DOKU_TAB', "\t"); | ||
if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); | ||
|
||
require_once DOKU_PLUGIN.'admin.php'; | ||
|
||
class admin_plugin_bigbluebutton extends DokuWiki_Admin_Plugin { | ||
|
||
function getMenuSort() { return FIXME; } | ||
function forAdminOnly() { return false; } | ||
|
||
function handle() { | ||
} | ||
|
||
function html() { | ||
ptln('<h1>' . $this->getLang('menu') . '</h1>'); | ||
} | ||
} | ||
|
||
// vim:ts=4:sw=4:et:enc=utf-8: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
<?php | ||
/** | ||
* DokuWiki Plugin bigbluebutton (Helper Component) | ||
* | ||
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html | ||
* @author Andreas Gohr <andi@splitbrain.org> | ||
*/ | ||
|
||
// must be run within Dokuwiki | ||
if (!defined('DOKU_INC')) die(); | ||
if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); | ||
|
||
require_once DOKU_PLUGIN.'helper.php'; | ||
require_once DOKU_PLUGIN.'bigbluebutton/BigBlueButton.class.php'; | ||
|
||
|
||
class helper_plugin_bigbluebutton extends DokuWiki_Action_Plugin { | ||
|
||
private function getRoomSetupFile($room){ | ||
global $conf; | ||
return utf8_encodeFN(str_replace(':','',cleanID($room))); | ||
} | ||
|
||
public function loadRoomSetup($room){ | ||
$room = $this->getRoomSetupFile($room); | ||
$roomconf = confToHash($conf['metadir'].'_bigbluebutton/'.$room.'.bbbroom'); | ||
return $conf; | ||
} | ||
|
||
public function saveRoomSetup($room,$data){ | ||
$room = $this->getRoomSetupFile($room); | ||
$out = ''; | ||
foreach($data as $key => $val){ | ||
$out .= "$key\t$val\n"; | ||
} | ||
io_saveFile($room,$out); | ||
} | ||
|
||
/** | ||
* Check the permissions for the current users in the given room | ||
* | ||
* Possible return values: | ||
* | ||
* 0 - no permission to join | ||
* 1 - guest permission | ||
* 2 - normal attendee | ||
* 3 - moderator | ||
*/ | ||
public function checkPermission($room){ | ||
global $INFO; | ||
global $auth; | ||
|
||
$setup = $this->getRooomSetupFile($room); | ||
|
||
if( $INFO['userinfo']['user'] && | ||
$setup['moderators'] && | ||
$this->isMember($setup['moderators'], | ||
$INFO['userinfo']['user'], | ||
$INFO['userinfo']['grps'])){ | ||
return 3; | ||
} | ||
|
||
if($setup['attendees']){ | ||
if($this->isMember($setup['attendees'], | ||
$INFO['userinfo']['user'], | ||
$INFO['userinfo']['grps']){ | ||
return 2; | ||
}else{ | ||
return 0; | ||
} | ||
} | ||
|
||
return 1; | ||
} | ||
|
||
/** | ||
* Match a user and his groups against a comma separated list of | ||
* users and groups to determine membership status | ||
* | ||
* @fixme this should probably be moved to core | ||
* @param $memberlist string commaseparated list of allowed users and groups | ||
* @param $user string user to match against | ||
* @param $groups array groups the user is member of | ||
* @returns bool true for membership acknowledged | ||
*/ | ||
function isMember($memberlist,$user,array $groups){ | ||
// clean user and groups | ||
if($auth->isCaseSensitive()){ | ||
$user = utf8_strtolower($user); | ||
$groups = array_map('utf8_strtolower',$groups); | ||
} | ||
$user = $auth->userClean(); | ||
$groups = array_map(array($auth,'groupClean'),$groups); | ||
|
||
// extract the memberlist | ||
$members = explode(',',$memberlist); | ||
$members = array_map('trim',$members); | ||
$members = array_unique($members); | ||
$members = array_filter($members); | ||
|
||
// compare cleaned values | ||
foreach($members as $member){ | ||
if($auth->isCaseSensitive()) $member = utf8_strtolower($member); | ||
if($member[0] == '@'){ | ||
$member = $auth->groupClean(substr($member,1)); | ||
if(in_array($member, $groups)) return true; | ||
}else{ | ||
$member = $auth->userClean($member); | ||
if($member == $user) return true; | ||
} | ||
} | ||
|
||
// still here? not a member! | ||
return false; | ||
} | ||
|
||
} | ||
|
||
// vim:ts=4:sw=4:et:enc=utf-8: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters