Commit 8e1b8338 authored by changi67's avatar changi67
parent 95b44cb0
......@@ -53,12 +53,12 @@ function wikiplugin_addfreetag($data, $params)
}
if (!empty($_POST[$identifier])) {
$_POST[$identifier] = '"' . str_replace('"', '', $_POST[$identifier]) . '"';
TikiLib::lib('freetag')->tag_object( $user, $object['object'], $object['type'], $_POST[$identifier]);
TikiLib::lib('freetag')->tag_object($user, $object['object'], $object['type'], $_POST[$identifier]);
if ($object['type'] == 'trackeritem') {
// need to update tracker field as well
$definition = Tracker_Definition::get($permobject);
if ($field = $definition->getFreetagField()) {
$currenttags = TikiLib::lib('freetag')->get_tags_on_object( $object['object'], 'trackeritem' );
$currenttags = TikiLib::lib('freetag')->get_tags_on_object($object['object'], 'trackeritem');
$taglist = '';
foreach ($currenttags['data'] as $tag) {
if (strstr($tag['tag'], ' ')) {
......@@ -66,7 +66,7 @@ function wikiplugin_addfreetag($data, $params)
} else {
$taglist .= $tag['tag'] . ' ';
}
}
}
// taglist will have slashes
TikiLib::lib('trk')->modify_field($object['object'], $field, stripslashes($taglist));
}
......
......@@ -121,16 +121,16 @@ function wikiplugin_addrelation($data, $params)
if (isset($_POST[$id])) {
if ($_POST[$id] == 'y') {
$relationlib->add_relation( $qualifier, $source_object['type'], $source_object['object'], $target_object['type'], $target_object['object'] );
$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 );
$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 );
$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']) {
......@@ -147,4 +147,3 @@ function wikiplugin_addrelation($data, $params)
$smarty->assign('label_remove', $labelremove);
return $smarty->fetch('wiki-plugins/wikiplugin_addrelation.tpl');
}
......@@ -5,7 +5,8 @@
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$
function wikiplugin_addtocart_info() {
function wikiplugin_addtocart_info()
{
return array(
'name' => tra('Add to cart'),
'documentation' => tra('PluginAddToCart'),
......@@ -163,17 +164,18 @@ function wikiplugin_addtocart_info() {
);
}
function wikiplugin_addtocart( $data, $params ) {
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 ( ! 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['code'], $params['description'], $params['price'] ) ) {
return WikiParser_PluginOutput::argumentError(array_diff(array( 'code', 'description', 'price'), array_keys($params)));
}
if( ! isset( $params['href'] ) ) {
if ( ! isset( $params['href'] ) ) {
$params['href'] = null;
}
if (! isset($params['label'])) {
......@@ -189,7 +191,7 @@ function wikiplugin_addtocart( $data, $params ) {
if (! isset($params['ajaxaddtocart'])) {
$params['ajaxaddtocart'] = 'y';
}
foreach($params as &$p) {
foreach ($params as &$p) {
$p = trim($p); // remove some line ends picked up in pretty tracker
}
......@@ -200,13 +202,13 @@ function wikiplugin_addtocart( $data, $params ) {
$bundle_class = $params['bundleclass'];
$gift_certificate = $params['giftcertificate'];
$eventcode = $params['eventcode'];
$price = preg_replace( '/[^\d^\.^,]/', '', $params['price']);
$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('productclass', $product_class);
$smarty->assign('giftcertificate', $gift_certificate);
$smarty->assign('price', $price);
$smarty->assign('add_label', $add_label);
......@@ -230,26 +232,24 @@ function wikiplugin_addtocart( $data, $params ) {
}
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);
$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')
.cartProductClassMissingForm({
informationForm: '$information_form'
});
");
$headerlib->add_jq_onready(
"$('form.addProductToCartForm$product_class')
.cartProductClassMissingForm({
informationForm: '$information_form'
});"
);
}
}
if ( $ajax_add_to_cart == 'y' ) {
$headerlib->add_jq_onready("
$('form.addProduct').cartAjaxAdd();
");
$headerlib->add_jq_onready("$('form.addProduct').cartAjaxAdd();");
}
if( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
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'] ) {
......@@ -261,12 +261,12 @@ function wikiplugin_addtocart( $data, $params ) {
$correct_exchange = true;
}
$quantity = $jitPost->quantity->int();
if( $jitPost->code->text() == $params['code'] && $quantity > 0 && $correct_exchange ) {
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') );
$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'])) {
......@@ -277,7 +277,7 @@ function wikiplugin_addtocart( $data, $params ) {
$gift_certificate_error = tra("Invalid gift certificate: ");
if ( $_REQUEST['gift_certificate'] && isset($gift_certificate) ) {
if ( !$cartlib->add_gift_certificate( $_REQUEST['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
......@@ -322,37 +322,37 @@ function wikiplugin_addtocart( $data, $params ) {
}
// Now add product to cart
$previous_cart_content = $cartlib->get_content();
$cartlib->add_product( $params['code'], $quantity, $product_info );
$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 ( $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') );
$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) );
$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) );
$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 ) );
$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 ) );
$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 ) );
$access->redirect($_SERVER['REQUEST_URI'], tr('%0 (%1) was added to your cart', $params['description'], $quantity));
}
}
......
......@@ -5,7 +5,8 @@
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$
function wikiplugin_addtogooglecal_info() {
function wikiplugin_addtogooglecal_info()
{
return array(
'name' => tra('Add to Google Calendar'),
'documentation' => 'PluginAddToGoogleCal',
......@@ -43,7 +44,8 @@ function wikiplugin_addtogooglecal_info() {
);
}
function wikiplugin_addtogooglecal($data, $params) {
function wikiplugin_addtogooglecal($data, $params)
{
global $access, $calendarlib;
$access->check_feature('feature_calendar');
if (!is_object($calendarlib)) {
......@@ -52,7 +54,7 @@ function wikiplugin_addtogooglecal($data, $params) {
$cal_item_id = $params['calitemid'];
$cal_id = $calendarlib->get_calendarid($cal_item_id);
$calperms = Perms::get( array( 'type' => 'calendar', 'object' => $cal_id ) );
$calperms = Perms::get(array( 'type' => 'calendar', 'object' => $cal_id ));
if (!$calperms->view_events) {
return '';
}
......@@ -61,9 +63,9 @@ function wikiplugin_addtogooglecal($data, $params) {
return '';
}
$gcal_action = 'TEMPLATE';
$gcal_text = urlencode(str_replace(array("\n","\r"),array('',''), strip_tags($calitem['parsedName'])));
$gcal_details = urlencode(str_replace(array("\n","\r"),array('',''),$calitem['parsed']));
$gcal_location = urlencode(str_replace(array("\n","\r"),array('',''), strip_tags($calitem['locationName'])));
$gcal_text = urlencode(str_replace(array("\n","\r"), array('',''), strip_tags($calitem['parsedName'])));
$gcal_details = urlencode(str_replace(array("\n","\r"), array('',''), $calitem['parsed']));
$gcal_location = urlencode(str_replace(array("\n","\r"), array('',''), strip_tags($calitem['locationName'])));
$curtikidate = new TikiDate();
// Google requires date to be formatted in UTC
$old_tz = date_default_timezone_get();
......
......@@ -5,7 +5,8 @@
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$
function wikiplugin_adjustinventory_info() {
function wikiplugin_adjustinventory_info()
{
return array(
'name' => tra('Adjust Inventory'),
'documentation' => tra('PluginAdjustInventory'),
......@@ -40,7 +41,8 @@ function wikiplugin_adjustinventory_info() {
);
}
function wikiplugin_adjustinventory( $data, $params ) {
function wikiplugin_adjustinventory( $data, $params )
{
if (!isset($params['add'])) {
$params['add'] = 'y';
}
......@@ -53,16 +55,16 @@ function wikiplugin_adjustinventory( $data, $params ) {
$smarty->assign('subtract', $params['subtract']);
$form = $smarty->fetch('wiki-plugins/wikiplugin_adjustinventory.tpl');
if( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
global $jitPost, $access;
$add_quantity = $jitPost->add_quantity->int();
$subtract_quantity = $jitPost->subtract_quantity->int();
$quantity = $add_quantity - $subtract_quantity;
if( $jitPost->code->text() == $params['code'] && $quantity != 0 ) {
if ( $jitPost->code->text() == $params['code'] && $quantity != 0 ) {
global $cartlib; require_once 'lib/payment/cartlib.php';
$cartlib->change_inventory( $params['code'], $quantity );
$cartlib->change_inventory($params['code'], $quantity);
}
$access->redirect( $_SERVER['REQUEST_URI'], tr('Inventory was adjusted by %0', $quantity ) );
$access->redirect($_SERVER['REQUEST_URI'], tr('Inventory was adjusted by %0', $quantity));
}
return $form;
}
......
......@@ -5,11 +5,12 @@
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$
function wikiplugin_agentinfo_info() {
function wikiplugin_agentinfo_info()
{
return array(
'name' => tra( 'User Agent Info' ),
'name' => tra('User Agent Info'),
'documentation' => 'PluginAgentinfo',
'description' => tra( 'Show user\'s browser and server information' ),
'description' => tra('Show user\'s browser and server information'),
'prefs' => array('wikiplugin_agentinfo'),
'icon' => 'pics/icons/computer.png',
'params' => array(
......@@ -31,10 +32,11 @@ function wikiplugin_agentinfo_info() {
);
}
function wikiplugin_agentinfo($data, $params) {
function wikiplugin_agentinfo($data, $params)
{
global $tikilib;
extract ($params,EXTR_SKIP);
extract($params, EXTR_SKIP);
$asetup = '';
......
......@@ -5,7 +5,8 @@
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$
function wikiplugin_alink_info() {
function wikiplugin_alink_info()
{
return array(
'name' => tra('Anchor Link'),
'documentation' => 'PluginAlink',
......@@ -34,12 +35,12 @@ function wikiplugin_alink_info() {
function wikiplugin_alink($data, $params)
{
global $multilinguallib, $tikilib, $prefs;
global $multilinguallib, $tikilib, $prefs;
if( ! isset( $multilinguallib ) || !is_object($multilinguallib) ) {
if ( ! isset( $multilinguallib ) || !is_object($multilinguallib) ) {
include_once('lib/multilingual/multilinguallib.php');// must be done even in feature_multilingual not set
}
extract ($params, EXTR_SKIP);
extract($params, EXTR_SKIP);
if (!isset($aname)) {
return ("<b>missing parameter for aname</b><br />");
......@@ -49,10 +50,9 @@ function wikiplugin_alink($data, $params)
// and the same behavior as tikilib.php. This will change when the world arrives at XHTML 1.0 Strict.
$aname = preg_replace('/[^a-zA-Z0-9]+/', '_', $aname);
if( isset($pagename) && $pagename ) {
if ( isset($pagename) && $pagename ) {
// Stolen, with some modifications, from tikilib.php line 4717-4723
if( $desc = $tikilib->page_exists_desc($pagename) )
{
if ( $desc = $tikilib->page_exists_desc($pagename) ) {
// to choose the best page language
$bestLang = ($prefs['feature_multilingual'] == 'y' && $prefs['feature_best_language'] == 'y')? "&amp;bl" : "";
// $bestLang = $prefs['feature_best_language'] == 'y' ? "&amp;bl" : "";
......
......@@ -5,7 +5,8 @@
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$
function wikiplugin_aname_info() {
function wikiplugin_aname_info()
{
return array(
'name' => tra('Anchor Name'),
'documentation' => 'PluginAname',
......@@ -20,8 +21,8 @@ function wikiplugin_aname_info() {
function wikiplugin_aname($data, $params)
{
global $tikilib;
extract ($params, EXTR_SKIP);
global $tikilib;
extract($params, EXTR_SKIP);
// the following replace is necessary to maintain compliance with XHTML 1.0 Transitional
// and the same behavior as tikilib.php and ALINK. This will change when the world arrives at XHTML 1.0 Strict.
......
......@@ -5,7 +5,8 @@
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$
function wikiplugin_annotation_info() {
function wikiplugin_annotation_info()
{
return array(
'name' => tra('Image Annotation'),
'documentation' => 'PluginAnnotation',
......@@ -55,22 +56,21 @@ function wikiplugin_annotation_info() {
);
}
function wikiplugin_annotation($data, $params) {
function wikiplugin_annotation($data, $params)
{
static $first = true;
global $page, $tiki_p_edit, $headerlib;
$params = array_merge( array( 'align' => 'left' ), $params );
$params = array_merge(array( 'align' => 'left' ), $params);
$annotations = array();
foreach( explode( "\n", $data ) as $line )
{
foreach ( explode("\n", $data) as $line ) {
$line = trim($line);
if( empty( $line ) )
continue;
if( preg_match( "/^\(\s*(\d+)\s*,\s*(\d+)\s*\)\s*,\s*\(\s*(\d+)\s*,\s*(\d+)\s*\)(.*)\[(.*)\]$/", $line, $parts ) )
{
$parts = array_map( 'trim', $parts );
if ( preg_match("/^\(\s*(\d+)\s*,\s*(\d+)\s*\)\s*,\s*\(\s*(\d+)\s*,\s*(\d+)\s*\)(.*)\[(.*)\]$/", $line, $parts) ) {
$parts = array_map('trim', $parts);
list( $full, $x1, $y1, $x2, $y2, $label, $target ) = $parts;
$annotations[] = array(
......@@ -84,10 +84,9 @@ function wikiplugin_annotation($data, $params) {
}
}
$annotations = json_encode( $annotations );
$annotations = json_encode($annotations);
if( $first ) // {{{
{
if ( $first ) {
$first = false;
$script = <<<SCRIPT
var active = null;
......@@ -393,8 +392,8 @@ function serializeAnnotations( data, cid ) // {{{
SCRIPT;
$headerlib->add_js( $script );
} // }}}
$headerlib->add_js($script);
}
static $uid = 0;
$uid++;
......@@ -431,7 +430,7 @@ FORM;
JS;
global $headerlib;
$headerlib->add_js( $js );
$headerlib->add_js($js);
return <<<ANNOTATION
~np~
......
......@@ -69,20 +69,23 @@ function wikiplugin_appframe($data, $params)
$headerlib = TikiLib::lib('header');
if (isset($params['hideleft']) && $params['hideleft'] == 'y') {
$headerlib->add_js(<<<JS
$headerlib->add_js(
<<<JS
hideCol('col2','left', 'col1');
JS
);
}
if (isset($params['hideright']) && $params['hideright'] == 'y') {
$headerlib->add_js(<<<JS
$headerlib->add_js(
<<<JS
hideCol('col3','right', 'col1');
JS
);
}
$headerlib->add_js(<<<JS
$headerlib->add_js(
<<<JS
$(window).resize(function () {
var viewportHeight = $(window).height(), appframe = $('#appframe'), footerSize, centerHeader, surplus, target;
appframe.height(0);
......@@ -196,13 +199,9 @@ function wikiplugin_appframe_module($data, $params, $start)
$label = $info['name'];
}
$data = $modlib->execute_module(array(
'name' => $moduleName,
'params' => array_merge($params->none(), array(
'nobox' => 'y',
'notitle' => 'y',
)),
));
$data = $modlib->execute_module(
array('name' => $moduleName, 'params' => array_merge($params->none(), array('nobox' => 'y', 'notitle' => 'y')))
);
if (! $data) {
return null;
......
......@@ -5,7 +5,8 @@
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$
function wikiplugin_archivebuilder_info() {
function wikiplugin_archivebuilder_info()
{
return array(
'name' => tra('Archive Builder'),
'documentation' => 'PluginArchiveBuilder',
......@@ -24,14 +25,15 @@ function wikiplugin_archivebuilder_info() {
);
}
function wikiplugin_archivebuilder( $data, $params ) {
if( ! class_exists( 'ZipArchive' ) ) {
function wikiplugin_archivebuilder( $data, $params )
{
if ( ! class_exists('ZipArchive') ) {
return '^' . tra('Missing extension zip.') . '^';
}
$archive = md5( serialize( array( $data, $params ) ) );
$archive = md5(serialize(array( $data, $params )));
if( isset( $_POST[$archive] ) ) {
if ( isset( $_POST[$archive] ) ) {
$files = array();
$handlers = array(
......@@ -40,16 +42,16 @@ function wikiplugin_archivebuilder( $data, $params ) {
);
$archive = new ZipArchive;
$archive->open( $file = tempnam( 'temp/', 'archive' ) . '.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE );
$archive->open($file = tempnam('temp/', 'archive') . '.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE);
foreach( explode( "\n", $data ) as $line ) {
$parts = explode( ":", trim( $line ) );
$handler = array_shift( $parts );
foreach ( explode("\n", $data) as $line) {
$parts = explode(":", trim($line));
$handler = array_shift($parts);
if( isset( $handlers[$handler] ) ) {
$result = call_user_func_array( $handlers[$handler], $parts );
foreach( $result as $name => $content ) {
$archive->addFromString( $name, $content );
if ( isset( $handlers[$handler] ) ) {
$result = call_user_func_array($handlers[$handler], $parts);
foreach ( $result as $name => $content ) {
$archive->addFromString($name, $content);