function wikiplugin_bigbluebutton($data, $params) { try { global $smarty, $prefs, $user; $bigbluebuttonlib = TikiLib::lib('bigbluebutton'); $meeting = $params['name']; // Meeting is more descriptive than name, but parameter name was already decided. $smarty->assign('bbb_meeting', $meeting); $smarty->assign('bbb_image', parse_url($prefs['bigbluebutton_server_location'], PHP_URL_SCHEME) . '://' . parse_url($prefs['bigbluebutton_server_location'], PHP_URL_HOST) . '/images/bbb_logo.png'); $perms = Perms::get('bigbluebutton', $meeting); $params = array_merge(array('prefix' => ''), $params); // This is incomplete, will only apply if the dynamic feature is enabled. To be completed. $params['configuration'] = array('presentation' => array('active' => false)); $smarty->assign('bbb_params', Tiki_Security::get()->encode($params)); if (!$bigbluebuttonlib->roomExists($meeting)) { if (!isset($_POST['bbb']) || $_POST['bbb'] != $meeting || !$perms->bigbluebutton_create) { $smarty->assign('bbb_recordings', $bigbluebuttonlib->getRecordings($meeting)); return $smarty->fetch('wiki-plugins/wikiplugin_bigbluebutton_create.tpl'); } } if ($perms->bigbluebutton_join) { $smarty->assign('bbb_attendees', $bigbluebuttonlib->getAttendees($meeting)); if ($perms->bigbluebutton_view_rec) { $smarty->assign('bbb_recordings', $bigbluebuttonlib->getRecordings($meeting)); } return $smarty->fetch('wiki-plugins/wikiplugin_bigbluebutton.tpl'); } elseif ($perms->bigbluebutton_view_rec) { # Case for anonymous users with the perm to view recordings but not to join meetings $smarty->assign('bbb_recordings', $bigbluebuttonlib->getRecordings($meeting)); return $smarty->fetch('wiki-plugins/wikiplugin_bigbluebutton_view_recordings.tpl'); } } catch (Exception $e) { return WikiParser_PluginOutput::internalError(tr('BigBlueButton misconfigured or unaccessible.')); } }
function wikiplugin_bigbluebutton($data, $params) { try { global $prefs, $user; $bigbluebuttonlib = TikiLib::lib('bigbluebutton'); $meeting = $params['name']; // Meeting is more descriptive than name, but parameter name was already decided. $smarty = TikiLib::lib('smarty'); $smarty->assign('bbb_meeting', $meeting); $perms = Perms::get('bigbluebutton', $meeting); $params = array_merge(array('prefix' => '', 'recording' => 0), $params); // This is incomplete, will only apply if the dynamic feature is enabled. To be completed. $params['configuration'] = array('presentation' => array('active' => false)); $smarty->assign('bbb_params', Tiki_Security::get()->encode($params)); if (!$bigbluebuttonlib->roomExists($meeting)) { if (!isset($_POST['bbb']) || $_POST['bbb'] != $meeting || !$perms->bigbluebutton_create) { if ($perms->bigbluebutton_view_rec && $params['showrecording'] != 'n') { $smarty->assign('bbb_recordings', $bigbluebuttonlib->getRecordings($meeting)); } else { $smarty->assign('bbb_recordings', null); } return $smarty->fetch('wiki-plugins/wikiplugin_bigbluebutton_create.tpl'); } } if ($perms->bigbluebutton_view_rec) { $smarty->assign('bbb_recordings', $bigbluebuttonlib->getRecordings($meeting)); } else { $smarty->assign('bbb_recordings', null); } if ($perms->bigbluebutton_join) { if ($params['showattendees'] != 'n') { $smarty->assign('bbb_attendees', $bigbluebuttonlib->getAttendees($meeting)); $smarty->assign('bbb_show_attendees', true); } else { $smarty->assign('bbb_show_attendees', false); } return $smarty->fetch('wiki-plugins/wikiplugin_bigbluebutton.tpl'); } // Won't display anything if recordings were not loaded return $smarty->fetch('wiki-plugins/wikiplugin_bigbluebutton_view_recordings.tpl'); } catch (Exception $e) { return WikiParser_PluginOutput::internalError(tr('BigBlueButton is misconfigured or inaccessible.')); } }
function testInternalError() { $output = WikiParser_PluginOutput::internalError(tra('Unknown conversion')); $this->assertContains('Unknown conversion', $output->toHtml()); }
function wikiplugin_bigbluebutton( $data, $params ) { try { global $smarty, $prefs, $user; $bigbluebuttonlib = TikiLib::lib('bigbluebutton'); $meeting = $params['name']; // Meeting is more descriptive than name, but parameter name was already decided. $smarty->assign('bbb_meeting', $meeting); $smarty->assign('bbb_image', parse_url($prefs['bigbluebutton_server_location'], PHP_URL_SCHEME) . '://' . parse_url($prefs['bigbluebutton_server_location'], PHP_URL_HOST) . '/images/bbb_logo.png'); $perms = Perms::get('bigbluebutton', $meeting); if ( ! $bigbluebuttonlib->roomExists($meeting) ) { if ( ! isset($_POST['bbb']) || $_POST['bbb'] != $meeting || ! $perms->bigbluebutton_create ) { $smarty->assign( 'bbb_recordings', $bigbluebuttonlib->getRecordings( $meeting ) ); return $smarty->fetch('wiki-plugins/wikiplugin_bigbluebutton_create.tpl'); } } $params = array_merge(array('prefix' => ''), $params); if ( $perms->bigbluebutton_join ) { if ( isset($_POST['bbb']) && $_POST['bbb'] == $meeting ) { if ( ! $user && isset($_POST['bbb_name']) && ! empty($_POST['bbb_name']) ) { $_SESSION['bbb_name'] = $params['prefix'] . $_POST['bbb_name']; } // Attempt to create room made before joining as the BBB server has no persistency. // Prior check ensures that the user has appropriate rights to create the room in the // first place or that the room was already officially created and this is only a // re-create if the BBB server restarted. // // This avoids the issue occuring when tiki cache thinks the room exist and it's gone // on the other hand. It does not solve the issue if the room is lost on the BBB server // and tiki cache gets flushed. To cover that one, create can be granted to everyone for // the specific object. $bigbluebuttonlib->createRoom($meeting, $params); $bigbluebuttonlib->joinMeeting($meeting); } $smarty->assign('bbb_attendees', $bigbluebuttonlib->getAttendees($meeting)); $smarty->assign('bbb_recordings', $bigbluebuttonlib->getRecordings($meeting)); return $smarty->fetch('wiki-plugins/wikiplugin_bigbluebutton.tpl'); } elseif ( $perms->bigbluebutton_view_rec ) { # Case for anonymous users with the perm to view recordings but not to join meetings $smarty->assign('bbb_recordings', $bigbluebuttonlib->getRecordings($meeting)); return $smarty->fetch('wiki-plugins/wikiplugin_bigbluebutton_view_recordings.tpl'); } } catch (Exception $e) { return WikiParser_PluginOutput::internalError(tr('BigBlueButton misconfigured or unaccessible.')); } }
function wikiplugin_addtocart($data, $params) { global $cartlib, $headerlib; require_once 'lib/payment/cartlib.php'; $headerlib->add_jsfile('lib/payment/cartlib.js'); if (!session_id()) { return WikiParser_PluginOutput::internalError(tra('A session must be active to use the cart.')); } if (!isset($params['code'], $params['description'], $params['price'])) { return WikiParser_PluginOutput::argumentError(array_diff(array('code', 'description', 'price'), array_keys($params))); } if (!isset($params['href'])) { $params['href'] = null; } if (!isset($params['label'])) { $params['label'] = tra('Add to cart'); } if (!isset($params['forceanon'])) { $params['forceanon'] = 'n'; } // once forceanon is set it will have to affect the whole shopping cart otherwise it will be inconsistent if ($params['forceanon'] == 'y') { $_SESSION['forceanon'] = 'y'; } if (!isset($params['ajaxaddtocart'])) { $params['ajaxaddtocart'] = 'y'; } foreach ($params as &$p) { $p = trim($p); // remove some line ends picked up in pretty tracker } $code = $params['code']; $product_class = $params['productclass']; $product_type = $params['producttype']; $product_bundle = $params['productbundle']; $bundle_class = $params['bundleclass']; $gift_certificate = $params['giftcertificate']; $eventcode = $params['eventcode']; $price = preg_replace('/[^\\d^\\.^,]/', '', $params['price']); $add_label = $params['label']; $ajax_add_to_cart = $params['ajaxaddtocart']; global $smarty; $smarty->assign('code', $code); $smarty->assign('productclass', $product_class); $smarty->assign('giftcertificate', $gift_certificate); $smarty->assign('price', $price); $smarty->assign('add_label', $add_label); global $cartuserlist, $userlib, $globalperms; if (!isset($cartuserlist)) { $cartuserlist = $userlib->get_users_light(); } $smarty->assign('cartuserlist', $cartuserlist); if ($params['onbehalf'] == 'y' && $globalperms->payment_admin) { $smarty->assign('onbehalf', 'y'); } if (!empty($params['exchangeorderitemid']) && !empty($params['exchangetoproductid'])) { $smarty->assign('exchangeorderitemid', $params['exchangeorderitemid']); $smarty->assign('exchangetoproductid', $params['exchangetoproductid']); $smarty->assign('hideamountfield', 'y'); } else { $smarty->assign('hideamountfield', 'n'); } if (is_numeric($product_class)) { $information_form = $cartlib->get_missing_user_information_form($product_class, 'required'); $missing_information = $cartlib->get_missing_user_information_fields($product_class, 'required'); $skip_information_form = $cartlib->skip_user_information_form_if_not_missing($product_class) && empty($missing_information); if ($information_form && !$skip_information_form) { $headerlib->add_jq_onready("\$('form.addProductToCartForm{$product_class}')\n\t\t\t\t\t.cartProductClassMissingForm({\n\t\t\t\t\t\tinformationForm: '{$information_form}'\n\t\t\t\t\t});"); } } if ($ajax_add_to_cart == 'y') { $headerlib->add_jq_onready("\$('form.addProduct').cartAjaxAdd();"); } if ($_SERVER['REQUEST_METHOD'] == 'POST') { global $jitPost, $access, $user; if (!empty($params['exchangeorderitemid']) && !empty($params['exchangetoproductid'])) { if ($jitPost->exchangeorderitemid->int() == $params['exchangeorderitemid'] && $jitPost->exchangetoproductid->int() == $params['exchangetoproductid']) { $correct_exchange = true; } else { $correct_exchange = false; } } else { $correct_exchange = true; } $quantity = $jitPost->quantity->int(); if ($jitPost->code->text() == $params['code'] && $quantity > 0 && $correct_exchange) { $behaviors = array(); if ($prefs['payment_cart_anonymous'] === 'y' && (!$user || $params['forceanon'] == 'y') && empty($_SESSION['shopperinfo'])) { $access->redirect($_SERVER['REQUEST_URI'], tr('Please enter your shopper information first')); } // There needs to be a shopperinfo plugin on the page if ($globalperms->payment_admin && !empty($_POST['buyonbehalf']) && $userlib->user_exists($_POST['buyonbehalf'])) { $onbehalf = $_POST['buyonbehalf']; } else { $onbehalf = ''; } $gift_certificate_error = tra("Invalid gift certificate: "); if ($_REQUEST['gift_certificate'] && isset($gift_certificate)) { if (!$cartlib->add_gift_certificate($_REQUEST['gift_certificate'])) { $smarty->assign('gift_certificate', $_REQUEST['gift_certificate']); $smarty->assign('gift_certificate_error', $gift_certificate_error); return $smarty->fetch('wiki-plugins/wikiplugin_addtocart.tpl'); //TODO: Notify user if gift certificate is invalid } } $product_info = array('description' => $params['description'], 'price' => $price, 'href' => $params['href'], 'behaviors' => $behaviors, 'eventcode' => $eventcode, 'onbehalf' => $onbehalf, 'producttype' => $product_type, 'productclass' => $product_class, 'productbundle' => $product_bundle, 'bundleclass' => $bundle_class); // Generate behavior for exchanges if (!empty($params['exchangeorderitemid']) && !empty($params['exchangetoproductid'])) { $product_info['behaviors'][] = array('event' => 'complete', 'behavior' => 'cart_exchange_product', 'arguments' => array($params["exchangeorderitemid"], $params["exchangetoproductid"])); $product_info['exchangeorderitemid'] = $params["exchangeorderitemid"]; $product_info['exchangetoproductid'] = $params["exchangetoproductid"]; if (!isset($params['exchangeorderamount']) || !$params['exchangeorderamount']) { $exchangeorderamount = 1; } else { $exchangeorderamount = $params["exchangeorderamount"]; } $product_info['exchangeorderamount'] = $exchangeorderamount; } // Generate behavior for gift certificate purchase if (strtolower($product_type) == 'gift certificate') { if ($onbehalf) { $giftcert_email = $userlib->get_user_email($onbehalf); } elseif (!$user && !empty($_SESSION['shopperinfo']['email'])) { $giftcert_email = $_SESSION['shopperinfo']['email']; } elseif ($user) { $giftcert_email = $userlib->get_user_email($user); } $product_info['behaviors'][] = array('event' => 'complete', 'behavior' => 'cart_gift_certificate_purchase', 'arguments' => array($code, $giftcert_email)); } // Now add product to cart $previous_cart_content = $cartlib->get_content(); $cartlib->add_product($params['code'], $quantity, $product_info); global $access, $tikilib, $tikiroot, $prefs; if ($params['autocheckout'] == 'y' && empty($previous_cart_content)) { $invoice = $cartlib->request_payment(); if ($invoice) { $paymenturl = 'tiki-payment.php?invoice=' . intval($invoice); $paymenturl = $tikilib->httpPrefix(true) . $tikiroot . $paymenturl; if (!$user || $params['forceanon'] == 'y' && !Perms::get('payment', $invoice)->manual_payment) { // token access needs to be an optional feature // and needs to depend on auth_token_access pref require_once 'lib/auth/tokens.php'; $tokenlib = AuthTokens::build($prefs); $tokenpaymenturl = $tokenlib->includeToken($paymenturl, array('Temporary Shopper', 'Anonymous')); } if ($globalperms->payment_admin || Perms::get('payment', $invoice)->manual_payment) { // if able to do manual payment it means it is admin and don't need token $access->redirect($paymenturl, tr('The order was recorded and is now awaiting payment. Reference number is %0.', $invoice)); } else { $access->redirect($tokenpaymenturl, tr('The order was recorded and is now awaiting payment. Reference number is %0.', $invoice)); } } else { if (!empty($params['forwardafterfree'])) { $access->redirect($params['forwardafterfree'], tr('Your free order of %0 (%1) has been processed. An email has been sent to you for your records.', $params['description'], $quantity)); } else { $access->redirect($_SERVER['REQUEST_URI'], tr('Your free order of %0 (%1) has been processed', $params['description'], $quantity)); } } die; } $access->redirect($_SERVER['REQUEST_URI'], tr('%0 (%1) was added to your cart', $params['description'], $quantity)); } } return $smarty->fetch('wiki-plugins/wikiplugin_addtocart.tpl'); }