Skip to content

Commit

Permalink
more components
Browse files Browse the repository at this point in the history
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
splitbrain committed Nov 14, 2010
1 parent d0c80a3 commit 945c2be
Show file tree
Hide file tree
Showing 5 changed files with 219 additions and 9 deletions.
54 changes: 54 additions & 0 deletions action.php
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:
31 changes: 31 additions & 0 deletions admin.php
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:
3 changes: 2 additions & 1 deletion conf/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
* @author Andreas Gohr <andi@splitbrain.org>
*/

//$conf['fixme'] = 'FIXME';
$conf['apiurl'] = 'http://test-install.blindsidenetworks.com/bigbluebutton/api';
$conf['salt'] = '8cd8ef52e8e101574e400365b55e11a6';
119 changes: 119 additions & 0 deletions helper.php
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:
21 changes: 13 additions & 8 deletions syntax.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,31 +31,36 @@ function getSort() {


function connectTo($mode) {
$this->Lexer->addSpecialPattern('{{bigbluebutton}}',$mode,'plugin_bigbluebutton');
$this->Lexer->addSpecialPattern('{{bigbluebutton>[^}]+}}',$mode,'plugin_bigbluebutton');
}

function handle($match, $state, $pos, &$handler){
$data = array();

$data['room'] = trim(substr($match,16,-2));
return $data;
}

function render($mode, &$R, $data) {
if($mode != 'xhtml') return false;

#http://groups.google.com/group/bigbluebutton-dev/browse_thread/thread/de2a0098425403e1?pli=1
$bbb = new BigBlueButton('http://test-install.blindsidenetworks.com/bigbluebutton/api',
'8cd8ef52e8e101574e400365b55e11a6');
$helper = plugin_load('helper','bigbluebutton');

$R->doc .= 'here';
$roomconf = $helper->loadRoomSetup($data['room']);
if(!count($roomconf)){
$R->doc .= 'No such meeting room configured';
return true;
}

$room = 'dokuwiki5';
$R->doc .= '<a href="'.$bbb->joinRoomURL($room,'Andi',true).'">join.</a>';
#http://groups.google.com/group/bigbluebutton-dev/browse_thread/thread/de2a0098425403e1?pli=1
$bbb = new BigBlueButton($this->getConf('apiurl'),
$conf->getConf('salt'));

//FIXME add a form here
dbg($bbb->getAttendees($room));

return true;
}

}

// vim:ts=4:sw=4:et:enc=utf-8:

0 comments on commit 945c2be

Please sign in to comment.