Skip to content
Browse files

more components

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 945c2be52f1d238a0c534a28ccc69e626fc5fcac @splitbrain committed Nov 14, 2010
Showing with 219 additions and 9 deletions.
  1. +54 −0 action.php
  2. +31 −0 admin.php
  3. +2 −1 conf/default.php
  4. +119 −0 helper.php
  5. +13 −8 syntax.php
View
54 action.php
@@ -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:
View
31 admin.php
@@ -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:
View
3 conf/default.php
@@ -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';
View
119 helper.php
@@ -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:
View
21 syntax.php
@@ -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.
Something went wrong with that request. Please try again.