コード例 #1
0
function wikiplugin_relations($data, $params)
{
    $object = current_object();
    if (isset($params['object']) && false !== strpos($params['object'], ':')) {
        list($object['type'], $object['object']) = explode(':', $params['object'], 2);
    }
    if (!isset($params['qualifiers'])) {
        return WikiParser_PluginOutput::argumentError(array('qualifiers'));
    }
    $singlelist = false;
    if (isset($params['singlelist']) && $params['singlelist']) {
        $singlelist = true;
    }
    $emptymsg = "No relations found.";
    if (isset($params['emptymsg']) && $params['emptymsg']) {
        $emptymsg = $params['emptymsg'];
    }
    $data = array();
    $relationlib = TikiLib::lib('relation');
    foreach ($params['qualifiers'] as $qualifier) {
        $name = $singlelist ? 'singlelist' : tra($qualifier);
        $found = $relationlib->get_relations_from($object['type'], $object['object'], $qualifier);
        foreach ($found as $relation) {
            $type = $relation['type'];
            $id = $relation['itemId'];
            $data[$name]["{$type}:{$id}"] = array('type' => $type, 'object' => $id);
        }
    }
    $smarty = TikiLib::lib('smarty');
    $smarty->assign('wp_relations', $data);
    $smarty->assign('wp_singlelist', $singlelist);
    $smarty->assign('wp_emptymsg', $emptymsg);
    return $smarty->fetch('wiki-plugins/wikiplugin_relations.tpl');
}
コード例 #2
0
ファイル: wikiplugin_poll.php プロジェクト: jkimdon/cohomeals
function wikiplugin_poll($data, $params)
{
    global $smarty, $polllib, $trklib, $tikilib, $dbTiki, $userlib, $tiki_p_admin, $prefs, $_REQUEST, $user;
    $default = array('showtitle' => 'y', 'showresult' => 'link', 'showtotal' => 'y');
    $params = array_merge($default, $params);
    extract($params, EXTR_SKIP);
    if (!isset($pollId)) {
        return WikiParser_PluginOutput::argumentError(array('pollId'));
    }
    global $polllib;
    include_once 'lib/polls/polllib.php';
    $poll_info = $polllib->get_poll($pollId);
    $options = $polllib->list_poll_options($pollId);
    $hasVoted = $tikilib->user_has_voted($user, 'poll' . $pollId);
    $ret = '';
    $smarty->assign_by_ref('showresult', $showresult);
    $smarty->assign_by_ref('showtotal', $showtotal);
    $smarty->assign_by_ref('hasVoted', $hasVoted);
    $smarty->assign_by_ref('showtitle', $showtitle);
    if (!$hasVoted || $prefs['feature_poll_revote'] == 'y') {
        $smarty->assign_by_ref('menu_info', $poll_info);
        $smarty->assign_by_ref('channels', $options);
        $smarty->assign_by_ref('poll_title', $data);
        $smarty->assign('ownurl', $tikilib->httpPrefix() . $_SERVER['REQUEST_URI']);
        ask_ticket('poll-form');
        $ret = $smarty->fetch('tiki-plugin_poll.tpl');
    }
    if ($showresult == 'voted' && $hasVoted || $showresult == 'always') {
        $total = $polllib->options_percent($poll_info, $options);
        $poll_info['options'] = $options;
        $smarty->assign_by_ref('poll_info', $poll_info);
        $ret .= $smarty->fetch('tiki-poll_results_bar.tpl');
    }
    return '~np~' . $ret . '~/np~';
}
コード例 #3
0
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.'));
    }
}
コード例 #4
0
ファイル: wikiplugin_rss.php プロジェクト: jkimdon/cohomeals
function wikiplugin_rss($data, $params)
{
    global $smarty;
    global $rsslib;
    require_once 'lib/rss/rsslib.php';
    $params = array_merge(array('max' => 10, 'date' => 0, 'desc' => 0, 'author' => 0, 'icon' => '', 'showtitle' => 1, 'ticker' => 0, 'desclen' => 0), $params);
    if (!isset($params['id'])) {
        return WikiParser_PluginOutput::argumentError(array('id'));
    }
    $params['id'] = (array) $params['id'];
    $items = $rsslib->get_feed_items($params['id'], $params['max']);
    $title = null;
    if (count($params['id']) == 1) {
        $module = $rsslib->get_rss_module(reset($params['id']));
        if ($module['sitetitle']) {
            $title = array('title' => $module['sitetitle'], 'link' => $module['siteurl']);
        }
    }
    if ($params['desc'] > 0 && $params['desclen'] > 0) {
        foreach ($items as &$item) {
            $item['description'] = limit_text($item['description'], $params['desclen']);
        }
    }
    global $smarty;
    $smarty->assign('rsstitle', $title);
    $smarty->assign('items', $items);
    $smarty->assign('showdate', $params['date'] > 0);
    $smarty->assign('showtitle', $params['showtitle'] > 0);
    $smarty->assign('showdesc', $params['desc'] > 0);
    $smarty->assign('showauthor', $params['author'] > 0);
    $smarty->assign('icon', $params['icon']);
    $smarty->assign('ticker', $params['ticker']);
    return $smarty->fetch('wiki-plugins/wikiplugin_rss.tpl');
}
コード例 #5
0
function wikiplugin_transclude( $data, $params )
{
	if ( ! isset( $params['page'] ) ) {
		return WikiParser_PluginOutput::argumentError(array( 'page' ));
	}
	
	$page = $params['page'];
	unset($params['page']);

	global $tikilib;

	if ( ! Perms::get('wiki page', $page)->view ) {
		return WikiParser_PluginOutput::error(tra('Permission Denied'), tra('Attempt to include a page that cannot be viewed.'));
	}

	if ( $info = $tikilib->get_page_info($page) ) {
		$parts = preg_split('/%%%text%%%/', $info['data']);
		$data = $tikilib->parse_data($data);
                $pass = $parts[0] . $data . $parts[1];
		return preg_replace_callback(
						'/%%%([A-z0-9]+)%%%/',
						array( new WikiPlugin_Transclude_Replacer($params), 'callback' ),
						$pass
		);
	} else {
		return WikiParser_PluginOutput::error(tr('Page not found'), tr('Page named "%0" does not exist at this time.', $page));
	}
}
コード例 #6
0
function wikiplugin_zoterolist($data, $params)
{
	if (! isset($params['tag'])) {
		return WikiParser_PluginOutput::argumentError(array('tag'));
	}

	$cachelib = TikiLib::lib('cache');
	$tikilib = TikiLib::lib('tiki');

	$cacheKey = 'zoterolist.' . $params['tag'];

	if ($cached = $cachelib->getSerialized($cacheKey, 'zotero')) {
		if (($cached['created'] + 3600) > $tikilib->now) {
			return WikiParser_PluginOutput::html($cached['data']);
		}
	}
	
	$zoterolib = TikiLib::lib('zotero');
	$html = $zoterolib->get_formatted_references($params['tag']);

	$cachelib->cacheItem($cacheKey, serialize(array('created' => $tikilib->now, 'data' => $html)), 'zotero');

	if ($html) {
		return WikiParser_PluginOutput::html($html);
	} else {
		return WikiParser_PluginOutput::error(tra('Error'), tra('No results obtained. The Zotero citation server may be down.'));
	}
}
コード例 #7
0
ファイル: wikiplugin_zotero.php プロジェクト: linuxwhy/tiki-1
function wikiplugin_zotero($data, $params)
{
    $zotero = TikiLib::lib('zotero');
    $cachelib = TikiLib::lib('cache');
    $tag = null;
    $key = null;
    $note = null;
    if (isset($params['key'])) {
        $key = $params['key'];
        $cacheKey = "key_{$key}";
    } elseif (isset($params['tag'])) {
        $tag = $params['tag'];
        $cacheKey = "tag_{$tag}";
    } else {
        return WikiParser_PluginOutput::argumentError(array('key', 'tag'));
    }
    if (isset($params['note'])) {
        $note = $params['note'];
    }
    if ($cached = $cachelib->getCached($cacheKey, 'zotero')) {
        $info = unserialize($cached);
    } else {
        if ($key) {
            $info = $zotero->get_entry($key);
        } else {
            $info = $zotero->get_first_entry($tag);
        }
        $cachelib->cacheItem($cacheKey, serialize($info), 'zotero');
    }
    $content = $info['content'];
    $content = str_replace('<div', '<span', $content);
    $content = str_replace('</div>', '</span>', $content);
    return "{FOOTNOTE()}~np~{$content} {$note}~/np~{FOOTNOTE}";
}
コード例 #8
0
function wikiplugin_trackercalendar($data, $params)
{
    static $id = 0;
    $headerlib = TikiLib::lib('header');
    $headerlib->add_cssfile('vendor_extra/fullcalendar-resourceviews/fullcalendar/fullcalendar.css');
    $headerlib->add_jsfile('vendor_extra/fullcalendar-resourceviews/fullcalendar/fullcalendar.min.js');
    $jit = new JitFilter($params);
    $definition = Tracker_Definition::get($jit->trackerId->int());
    $itemObject = Tracker_Item::newItem($jit->trackerId->int());
    if (!$definition) {
        return WikiParser_PluginOutput::userError(tr('Tracker not found.'));
    }
    $beginField = $definition->getFieldFromPermName($jit->begin->word());
    $endField = $definition->getFieldFromPermName($jit->end->word());
    if (!$beginField || !$endField) {
        return WikiParser_PluginOutput::userError(tr('Fields not found.'));
    }
    $views = array('month', 'agendaWeek', 'agendaDay');
    $resources = array();
    if ($resourceField = $jit->resource->word()) {
        $field = $definition->getFieldFromPermName($resourceField);
        $resources = wikiplugin_trackercalendar_get_resources($field);
        $views[] = 'resourceMonth';
        $views[] = 'resourceWeek';
        $views[] = 'resourceDay';
    }
    $smarty = TikiLib::lib('smarty');
    $smarty->assign('trackercalendar', array('id' => 'trackercalendar' . ++$id, 'trackerId' => $jit->trackerId->int(), 'begin' => $jit->begin->word(), 'end' => $jit->end->word(), 'resource' => $resourceField, 'resourceList' => $resources, 'coloring' => $jit->coloring->word(), 'beginFieldName' => 'ins_' . $beginField['fieldId'], 'endFieldName' => 'ins_' . $endField['fieldId'], 'firstDayofWeek' => 0, 'views' => implode(',', $views), 'viewyear' => (int) date('Y'), 'viewmonth' => (int) date('n'), 'viewday' => (int) date('j'), 'minHourOfDay' => 7, 'maxHourOfDay' => 20, 'addTitle' => tr('Insert'), 'canInsert' => $itemObject->canModify(), 'body' => $data));
    return $smarty->fetch('wiki-plugins/trackercalendar.tpl');
}
コード例 #9
0
function wikiplugin_modulelist($data, $params)
{
    // Pre-emptively load the modules, this normally would not happen until the final call to $smarty->display(...)
    // May have some side effects if not all of the information required to filter the modules is available at this time.
    include_once 'tiki-modules.php';
    $smarty = TikiLib::lib('smarty');
    $smarty->loadPlugin('smarty_function_modulelist');
    if (!isset($params['zone'])) {
        return WikiParser_PluginOutput::argumentError(array('zone'));
    }
    return smarty_function_modulelist(array('zone' => $params['zone'], 'id' => $params['zone'] . '_plugin_modules'), $smarty);
}
コード例 #10
0
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.'));
    }
}
コード例 #11
0
ファイル: wikiplugin_map.php プロジェクト: hurcane/tiki-azure
function wp_map_mapserver($params)
{
    global $prefs;
    if ($prefs['feature_maps'] != 'y') {
        return WikiParser_PluginOutput::disabled('map', array('feature_maps'));
    }
    extract($params, EXTR_SKIP);
    $mapdata = "";
    if (isset($mapfile)) {
        $mapdata = 'mapfile=' . $mapfile . '&';
    }
    $extdata = "";
    if (isset($extents)) {
        $dataext = explode("|", $extents);
        if (count($dataext) == 4) {
            $minx = floatval($dataext[0]);
            $maxx = floatval($dataext[1]);
            $miny = floatval($dataext[2]);
            $maxy = floatval($dataext[3]);
            $extdata = "minx=" . $minx . "&maxx=" . $maxx . "&miny=" . $miny . "&maxy=" . $maxy . "&zoom=1&";
        }
    }
    $sizedata = "";
    if (isset($size)) {
        $sizedata = "size=" . intval($size) . "&";
    }
    $widthdata = "";
    if (isset($width)) {
        $widthdata = 'width="' . intval($width) . '"';
    }
    $heightdata = "";
    if (isset($height)) {
        $heightdata = 'height="' . intval($height) . '"';
    }
    if (@$prefs['feature_maps'] != 'y') {
        $map = tra("Feature disabled");
    } else {
        $map = '<object border="0" hspace="0" vspace="0" type="text/html" data="tiki-map.php?' . $mapdata . $extdata . $sizedata . 'maponly=frame" ' . $widthdata . ' ' . $heightdata . '><a href="tiki-map.php?' . $mapdata . $extdata . $sizedata . '"><img src="tiki-map.php?' . $mapdata . $extdata . $sizedata . 'maponly=yes"/></a></object>';
    }
    return $map;
}
コード例 #12
0
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');
}
コード例 #13
0
 function testMissingArguments()
 {
     $output = WikiParser_PluginOutput::argumentError(array('id', 'test'));
     $this->assertContains('<li>id</li>', $output->toHtml());
 }
コード例 #14
0
function wikiplugin_trackeritemfield($data, $params)
{
    global $userTracker, $group, $user, $userlib, $tiki_p_admin_trackers, $prefs, $smarty, $tikilib;
    global $trklib;
    include_once 'lib/trackers/trackerlib.php';
    static $memoItemId = 0;
    static $memoTrackerId = 0;
    static $memoStatus = 0;
    static $memoUserTracker = false;
    static $memoItemObject = null;
    extract($params, EXTR_SKIP);
    if (empty($itemId) && !empty($_REQUEST['itemId'])) {
        if (!empty($trackerId)) {
            $info = $trklib->get_item_info($_REQUEST['itemId']);
            if (!empty($info) && $info['trackerId'] == $trackerId) {
                $itemId = $_REQUEST['itemId'];
            }
        } else {
            $itemId = $_REQUEST['itemId'];
        }
    }
    if (empty($itemId) && !empty($trackerId) && ($tracker_info = $trklib->get_tracker($trackerId))) {
        if ($t = $trklib->get_tracker_options($trackerId)) {
            $tracker_info = array_merge($tracker_info, $t);
        }
        $itemId = $trklib->get_user_item($trackerId, $tracker_info);
    }
    if (!empty($itemId) && $memoItemId == $itemId || empty($itemId) && !empty($memoItemId)) {
        $itemId = $memoItemId;
        if (empty($memoTrackerId)) {
            return tra('Incorrect param');
        }
        $trackerId = $memoTrackerId;
        $itemObject = $memoItemObject;
    } else {
        if (!empty($trackerId) && !empty($_REQUEST['view_user'])) {
            $itemId = $trklib->get_user_item($trackerId, $tracker_info, $_REQUEST['view_user']);
        }
        if (empty($trackerId) && empty($itemId) && (isset($userTracker) && $userTracker == 'y' || isset($prefs) && $prefs['userTracker'] == 'y') && !empty($group) && ($utid = $userlib->get_tracker_usergroup($user)) && $utid['usersTrackerId']) {
            $trackerId = $utid['usersTrackerId'];
            $itemId = $trklib->get_item_id($trackerId, $utid['usersFieldId'], $user);
        } else {
            if (empty($trackerId) && !empty($itemId)) {
                $item = $trklib->get_tracker_item($itemId);
                $trackerId = $item['trackerId'];
            }
        }
        if (empty($itemId) && empty($test) && empty($status)) {
            // need an item
            return tra('Incorrect param') . ': itemId';
        }
        if (!empty($status) && !$trklib->valid_status($status)) {
            return tra('Incorrect param') . ': status';
        }
        $info = $trklib->get_tracker_item($itemId);
        if (!empty($info) && empty($trackerId)) {
            $trackerId = $info['trackerId'];
        }
        $itemObject = Tracker_Item::fromInfo($info);
        if (!$itemObject->canView()) {
            return WikiParser_PluginOutput::error(tr('Permission denied'), tr('You are not allowed to view this item.'));
        }
        $memoStatus = $info['status'];
        $memoItemId = $itemId;
        $memoTrackerId = $info['trackerId'];
        $memoItemObject = $itemObject;
        if (isset($_REQUEST['itemId']) && $_REQUEST['itemId'] != $itemId) {
            global $logslib;
            include_once 'lib/logs/logslib.php';
            $logslib->add_action('Viewed', $itemId, 'trackeritem', $_SERVER['REQUEST_URI'] . '&trackeritemfield');
        }
    }
    if (!isset($data)) {
        $data = $dataelse = '';
    } elseif (!empty($data) && strpos($data, '{ELSE}')) {
        $dataelse = substr($data, strpos($data, '{ELSE}') + 6);
        $data = substr($data, 0, strpos($data, '{ELSE}'));
    } else {
        $dataelse = '';
    }
    if (!empty($status)) {
        if (!strstr($status, $memoStatus)) {
            return $dataelse;
        }
    }
    if (empty($itemId) && !empty($test)) {
        return $dataelse;
    } elseif (empty($itemId)) {
        return tra('Incorrect param') . ': itemId';
    } elseif (isset($fields)) {
        $all_fields = $trklib->list_tracker_fields($trackerId, 0, -1);
        $all_fields = $all_fields['data'];
        if (!empty($fields)) {
            foreach ($all_fields as $i => $fopt) {
                if (!in_array($fopt['fieldId'], $fields)) {
                    unset($all_fields[$i]);
                }
            }
            if (empty($all_fields)) {
                return tra('Incorrect param');
            }
        }
        $field_values = $trklib->get_item_fields($trackerId, $itemId, $all_fields, $itemUser);
        foreach ($field_values as $field_value) {
            if ($field_value['type'] == 'p' && $field_value['options_array'][0] == 'password' || $field_value['isHidden'] != 'n' && $field_value['isHidden'] != 'c') {
                continue;
            }
            if (!$itemObject->canViewField($field_value['fieldId'])) {
                continue;
            }
            if (empty($field_value['value'])) {
                return $dataelse;
            }
        }
    } elseif (!empty($fieldId)) {
        if (!($field = $trklib->get_tracker_field($fieldId))) {
            return tra('Incorrect param') . ': fieldId';
        }
        if (!$itemObject->canViewField($fieldId)) {
            return WikiParser_PluginOutput::error(tr('Permission denied'), tr('You are not allowed to view this field.'));
        }
        if (empty($test)) {
            $test = false;
        }
        if (($val = $trklib->get_item_value($trackerId, $itemId, $fieldId)) !== false) {
            if ($test) {
                if (!empty($value) && $val != $value) {
                    return $dataelse;
                }
                return $data;
            } else {
                $field['value'] = $val;
                $handler = $trklib->get_field_handler($field, $info);
                // gets the handler to blend back the value into the definitions array
                $out = $handler->renderOutput(array('showlinks' => 'n'));
                return $out;
            }
        } elseif ($test) {
            // testing the value of a field that does not exist yet
            return $dataelse;
        }
    }
    return $data;
}
コード例 #15
0
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.'));
	}
}
コード例 #16
0
ファイル: wikiplugin_addtocart.php プロジェクト: rjsmelo/tiki
function wikiplugin_addtocart($data, $params)
{
    global $cartuserlist, $globalperms;
    $smarty = TikiLib::lib('smarty');
    $userlib = TikiLib::lib('user');
    $headerlib = TikiLib::lib('header');
    $cartlib = TikiLib::lib('cart');
    if (!session_id()) {
        session_start();
    }
    if (!isset($params['code'], $params['description'], $params['price'])) {
        return WikiParser_PluginOutput::argumentError(array_diff(array('code', 'description', 'price'), array_keys($params)));
    }
    $plugininfo = wikiplugin_addtocart_info();
    $default = array();
    foreach ($plugininfo['params'] as $key => $param) {
        $default["{$key}"] = $param['default'];
    }
    $params = array_merge($default, $params);
    // 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';
    }
    foreach ($params as &$p) {
        $p = trim($p);
        // remove some line ends picked up in pretty tracker
    }
    $params['price'] = preg_replace('/[^\\d^\\.^,]/', '', $params['price']);
    $smarty->assign('params', $params);
    if ($params['onbehalf'] == 'y' && $globalperms->payment_admin) {
        $smarty->assign('onbehalf', 'y');
        // Do not load the user list unless it is needed, this light function is not as light as one would expect
        if (!isset($cartuserlist)) {
            $cartuserlist = $userlib->get_users_light();
        }
        $smarty->assign('cartuserlist', $cartuserlist);
    }
    if (!empty($params['exchangeorderitemid']) && !empty($params['exchangetoproductid'])) {
        $smarty->assign('hideamountfield', 'y');
    } else {
        $smarty->assign('hideamountfield', 'n');
    }
    if (is_numeric($params['productclass'])) {
        $information_form = $cartlib->get_missing_user_information_form($params['productclass'], 'required');
        $missing_information = $cartlib->get_missing_user_information_fields($params['productclass'], 'required');
        $skip_information_form = $cartlib->skip_user_information_form_if_not_missing($params['productclass']) && empty($missing_information);
        if ($information_form && !$skip_information_form) {
            $headerlib->add_jq_onready("\$('form.addProductToCartForm{$params['productclass']}')\n\t\t\t\t\t.cartProductClassMissingForm({\n\t\t\t\t\t\tinformationForm: '{$information_form}'\n\t\t\t\t\t});");
        }
    }
    if ($params['ajaxaddtocart'] == 'y') {
        $headerlib->add_jq_onready("\$('.wp_addtocart_form').cartAjaxAdd();");
        $smarty->assign('form_data', ' data-params=\'' . str_replace("'", "\\u0027", json_encode(array_filter($params))) . '\'');
    } else {
        $smarty->assign('form_data', '');
    }
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        global $jitPost, $user;
        $quantity = $jitPost->quantity->int();
        if ($jitPost->code->text() == $params['code'] && $quantity > 0) {
            $previous_cart_content = $cartlib->get_content();
            $addedOk = $cartlib->add_to_cart($params, $jitPost);
            global $tikiroot, $prefs;
            $access = TikiLib::lib('access');
            $tikilib = TikiLib::lib('tiki');
            if ($addedOk && $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');
}
コード例 #17
0
function wikiplugin_addrelation($data, $params)
{
	if (isset($params['source_object']) && false !== strpos($params['source_object'], ':')) {
		list($source_object['type'], $source_object['object']) = explode(':', $params['source_object'], 2);
	} else {
		$source_object = current_object();
	}
	if (isset($params['target_object']) && false !== strpos($params['target_object'], ':')) {
		list($target_object['type'], $target_object['object']) = explode(':', $params['target_object'], 2);
	} else {
		$target_object = current_object(); 
	}
	if ($source_object == $target_object) {
		return tra('Source and target object cannot be the same');
	}
	if (!isset($params['qualifier'])) {
		return WikiParser_PluginOutput::argumentError(array('qualifier'));
	} else {
		$qualifier = $params['qualifier'];
	}
	if (!empty($params['label_add'])) {
		$labeladd = $params['label_add'];	
	} else {
		$labeladd = tra('Add Relation');
	}
	if (!empty($params['label_remove'])) {
		$labelremove = $params['label_remove'];
	} else {
		$labelremove = tra('Remove Relation');
	}
	if (!empty($params['label_added'])) {
		$labeladded = $params['label_added'];
	} else {
		$labeladded = tra('Relation Added');
	}
	if (!empty($params['button_id'])) {
		$id = 'wp_addrelation_' . $params['button_id'];
	} else {
		$id = 'wp_addrelation_0';
	}
	$relationlib = TikiLib::lib('relation');

	if (isset($_POST[$id])) {
		if ($_POST[$id] == 'y') {
			$relationlib->add_relation($qualifier, $source_object['type'], $source_object['object'], $target_object['type'], $target_object['object']);	
		} elseif ($_POST[$id] == 'n') {
			$relation_id = $relationlib->add_relation($qualifier, $source_object['type'], $source_object['object'], $target_object['type'], $target_object['object']);
			$relationlib->remove_relation($relation_id);
		}
		require_once 'lib/search/refresh-functions.php';
		refresh_index($source_object['type'], $source_object['object']);
		refresh_index($target_object['type'], $target_object['object']);
	}
	$relationsfromsource = $relationlib->get_relations_from($source_object['type'], $source_object['object'], $qualifier);
	$relationexists = false;
	foreach ($relationsfromsource as $r) {
		if ($r['itemId'] == $target_object['object'] && $r['type'] == $target_object['type']) {
			$relationexists = true;
			break;
		}
	}

	$smarty = TikiLib::lib('smarty');
	$smarty->assign('wp_addrelation_id', $id);
	$smarty->assign('wp_addrelation_action', $relationexists ? 'n' : 'y');
	$smarty->assign('label_add', $labeladd);
	$smarty->assign('label_added', $labeladded);
	$smarty->assign('label_remove', $labelremove);
	return $smarty->fetch('wiki-plugins/wikiplugin_addrelation.tpl');
}
コード例 #18
0
function wikiplugin_trackercalendar($data, $params)
{
    static $id = 0;
    $headerlib = TikiLib::lib('header');
    $headerlib->add_cssfile('vendor_extra/fullcalendar-resourceviews/fullcalendar/fullcalendar.css');
    $headerlib->add_jsfile('vendor_extra/fullcalendar-resourceviews/fullcalendar/fullcalendar.min.js');
    $jit = new JitFilter($params);
    $definition = Tracker_Definition::get($jit->trackerId->int());
    $itemObject = Tracker_Item::newItem($jit->trackerId->int());
    if (!$definition) {
        return WikiParser_PluginOutput::userError(tr('Tracker not found.'));
    }
    $beginField = $definition->getFieldFromPermName($jit->begin->word());
    $endField = $definition->getFieldFromPermName($jit->end->word());
    if (!$beginField || !$endField) {
        return WikiParser_PluginOutput::userError(tr('Fields not found.'));
    }
    $views = array();
    if (!empty($params['amonth']) and $params['amonth'] != 'y') {
        $amonth = 'n';
    } else {
        $amonth = 'y';
        $views[] = 'month';
    }
    if (!empty($params['aweek']) and $params['aweek'] != 'y') {
        $aweek = 'n';
    } else {
        $aweek = 'y';
        $views[] = 'agendaWeek';
    }
    if (!empty($params['aday']) and $params['aday'] != 'y') {
        $aday = 'n';
    } else {
        $aday = 'y';
        $views[] = 'agendaDay';
    }
    $resources = array();
    if ($resourceField = $jit->resource->word()) {
        $field = $definition->getFieldFromPermName($resourceField);
        $resources = wikiplugin_trackercalendar_get_resources($field);
        if (!empty($params['rmonth']) and $params['rmonth'] != 'y') {
            $rmonth = 'n';
        } else {
            $rmonth = 'y';
            $views[] = 'resourceMonth';
        }
        if (!empty($params['rweek']) and $params['rweek'] != 'y') {
            $rweek = 'n';
        } else {
            $rweek = 'y';
            $views[] = 'resourceWeek';
        }
        if (!empty($params['rday']) and $params['rday'] != 'y') {
            $rday = 'n';
        } else {
            $rday = 'y';
            $views[] = 'resourceDay';
        }
    }
    // Define the default View (dView)
    if (!empty($params['dView'])) {
        $dView = $params['dView'];
    } else {
        $dView = 'month';
    }
    // Define the default date (dYear, dMonth, dDay)
    if (!empty($params['dYear'])) {
        $dYear = $params['dYear'];
    } else {
        $dYear = (int) date('Y');
    }
    if (!empty($params['dMonth']) and $params['dMonth'] > 0 and $params['dMonth'] < 13) {
        $dMonth = $params['dMonth'];
    } else {
        $dMonth = (int) date('n');
    }
    if (!empty($params['dDay']) and $params['dDay'] > 0 and $params['dDay'] < 32) {
        $dDay = $params['dDay'];
    } else {
        $dDay = (int) date('j');
    }
    global $prefs;
    if (!empty($params['fDayofWeek']) and $params['fDayofWeek'] > -1 and $params['fDayofWeek'] < 7) {
        $firstDayofWeek = $params['fDayofWeek'];
    } elseif ($prefs['calendar_firstDayofWeek'] !== 'user') {
        $firstDayofWeek = $prefs['calendar_firstDayofWeek'];
    } else {
        $firstDayofWeek = 0;
    }
    $params['addAllFields'] = empty($params['addAllFields']) ? 'y' : $params['addAllFields'];
    $params['useSessionStorage'] = empty($params['useSessionStorage']) ? 'y' : $params['useSessionStorage'];
    $params['weekends'] = empty($params['weekends']) ? 'y' : $params['weekends'];
    $smarty = TikiLib::lib('smarty');
    $smarty->assign('trackercalendar', array('id' => 'trackercalendar' . ++$id, 'trackerId' => $jit->trackerId->int(), 'begin' => $jit->begin->word(), 'end' => $jit->end->word(), 'resource' => $resourceField, 'resourceList' => $resources, 'coloring' => $jit->coloring->word(), 'beginFieldName' => 'ins_' . $beginField['fieldId'], 'endFieldName' => 'ins_' . $endField['fieldId'], 'firstDayofWeek' => $firstDayofWeek, 'views' => implode(',', $views), 'viewyear' => $dYear, 'viewmonth' => $dMonth, 'viewday' => $dDay, 'minHourOfDay' => 7, 'maxHourOfDay' => 24, 'addTitle' => tr('Insert'), 'canInsert' => $itemObject->canModify(), 'dView' => $dView, 'body' => $data, 'url' => $params['external'] === 'y' ? $params['url'] : '', 'trkitemid' => $params['external'] === 'y' ? $params['trkitemid'] : '', 'addAllFields' => $params['external'] === 'y' ? $params['addAllFields'] : '', 'useSessionStorage' => $params['external'] === 'y' ? $params['useSessionStorage'] : '', 'timeFormat' => $prefs['display_12hr_clock'] === 'y' ? 'h(:mm)TT' : 'HH:mm', 'weekends' => $params['weekends'] === 'y' ? 1 : 0));
    return $smarty->fetch('wiki-plugins/trackercalendar.tpl');
}
コード例 #19
0
ファイル: parserlib.php プロジェクト: railfuture/tiki-website
 private function convert_plugin_output($output, $from, $to, $parseOptions)
 {
     if (!$output instanceof WikiParser_PluginOutput) {
         if ($from === 'wiki') {
             $output = WikiParser_PluginOutput::wiki($output);
         } elseif ($from === 'html') {
             $output = WikiParser_PluginOutput::html($output);
         }
     }
     if ($to === 'html') {
         return $output->toHtml($parseOptions);
     } elseif ($to === 'wiki') {
         return $output->toWiki();
     }
 }
コード例 #20
0
ファイル: Wiki.php プロジェクト: rjsmelo/tiki
 function enabled(&$output)
 {
     if (!$this->info) {
         return true;
     }
     // Legacy plugins always execute
     global $prefs;
     $missing = array();
     if (isset($this->info['prefs'])) {
         foreach ($this->info['prefs'] as $pref) {
             if (isset($prefs[$pref]) && $prefs[$pref] != 'y') {
                 $missing[] = $pref;
             }
         }
     }
     if (count($missing) > 0) {
         $output = WikiParser_PluginOutput::disabled($this->name, $missing);
         return false;
     }
     return true;
 }