Exemple #1
0
/**
 * @param $mod_reference
 * @param $module_params
 */
function module_mustread($mod_reference, $module_params)
{
    global $prefs;
    $smarty = TikiLib::lib('smarty');
    $object = current_object();
    $smarty->assign('mustread_module', ['object' => $object, 'field' => $module_params['objectField']]);
}
/**
 * @param $mod_reference
 * @param $module_params
 */
function module_category_transition($mod_reference, $module_params)
{
    $smarty = TikiLib::lib('smarty');
    $modlib = TikiLib::lib('mod');
    if ($object = current_object()) {
        $cat_type = $object['type'];
        $cat_objid = $object['object'];
        $smarty->assign('objType', $cat_type);
        $smarty->assign('objId', $cat_objid);
        require_once 'lib/transitionlib.php';
        $transitionlib = new TransitionLib('category');
        if (isset($_POST['transition'])) {
            $transitionlib->triggerTransition($_POST['transition'], $cat_objid, $cat_type);
            header('Location: ' . $_SERVER['REQUEST_URI']);
            exit;
        }
        $transitions = $transitionlib->getAvailableTransitions($cat_objid, $cat_type);
        $smarty->assign('mod_transitions', $transitions);
    } else {
        if ($modlib->is_admin_mode(true)) {
            // add a dummy transition to display on the module admin page
            $smarty->assign('mod_transitions', array(array('enabled' => true, 'transitionId' => 0, 'name' => tra('Example Transition'))));
        }
    }
}
function module_contributors($mod_reference, $module_params)
{
	global $smarty, $userlib, $wikilib, $tikilib, $headerlib;
	$currentObject = current_object();
	if ($currentObject['type'] == 'wiki page') {
		$objectperms = Perms::get(array('type' => 'wiki page', 'object' => $currentObject['object']));
		if ($objectperms->view) {
			$contributors = $wikilib->get_contributors($currentObject['object']);
			$contributors_details = array();
			$headerlib->add_css('div.contributors div br {clear: both;}'); // Avoid avatar conflicts with lines below
			foreach ($contributors as $contributor) {
				$details = array('login' => $contributor);
				$details['realName'] = $userlib->get_user_preference($contributor, 'realName');
				$country = $tikilib->get_user_preference($contributor, 'country');
				if (!is_null($country) && $country != 'Other') {
					$details['country'] = $country;
				}
				$email_isPublic = $tikilib->get_user_preference($contributor, 'email is public');
				if ($email_isPublic != 'n') {
					include_once ('lib/userprefs/scrambleEmail.php');
					$details['email'] = $userlib->get_user_email($contributor);
					$details['scrambledEmail'] = scrambleEmail($details['email'], $email_isPublic);
				}
				$details['homePage'] = $tikilib->get_user_preference($contributor, 'homePage');
				$details['avatar'] = $tikilib->get_user_avatar($contributor);
				$contributors_details[] = $details;
			}
			$smarty->assign_by_ref('contributors_details', $contributors_details);
			$hiddenContributors = count($contributors_details) - 5;
			if ($hiddenContributors > 0) {
				$smarty->assign('hiddenContributors', $hiddenContributors);
			}
		}		
	}
}
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');
}
/**
 * @param $mod_reference
 * @param $module_params
 */
function module_articles($mod_reference, $module_params)
{
    global $user;
    $tikilib = TikiLib::lib('tiki');
    $smarty = TikiLib::lib('smarty');
    $artlib = TikiLib::lib('art');
    $urlParams = array('topicId' => 'topic', 'topic' => 'topicName', 'categId' => 'categId', 'type' => 'type', 'langfilter' => 'lang', 'start' => null, 'sort' => null);
    if (isset($module_params['topicId']) && $module_params['topicId'] == 0 && ($object = current_object()) && $object['type'] == 'article') {
        $topicId = $smarty->getTemplateVars('topicId');
    }
    foreach ($urlParams as $p => $v) {
        if (isset(${$p})) {
            continue;
        }
        ${$p} = isset($module_params[$p]) ? $module_params[$p] : '';
    }
    if ($start == '') {
        $start = 0;
    }
    if ($sort == '') {
        $sort = 'publishDate_desc';
    }
    $min_rating = isset($_REQUEST['min_rating']) ? $_REQUEST['min_rating'] : 0;
    $max_rating = isset($_REQUEST['max_rating']) ? $_REQUEST['max_rating'] : 10;
    $smarty->assign('min_rating', $min_rating);
    $smarty->assign('max_rating', $max_rating);
    $ranking = $artlib->list_articles($start, $mod_reference['rows'], $sort, '', '', '', $user, $type, $topicId, 'y', $topic, $categId, '', '', $langfilter, $min_rating, $max_rating, '', 'y');
    $smarty->assign_by_ref('urlParams', $urlParams);
    $smarty->assign('modArticles', $ranking["data"]);
    $smarty->assign('more', isset($module_params['more']) ? $module_params['more'] : 'n');
    $smarty->assign('absurl', isset($module_params["absurl"]) ? $module_params["absurl"] : 'n');
    $smarty->assign('showcreated', isset($module_params['showcreated']) ? $module_params['showcreated'] : 'n');
    $smarty->assign('showpubl', isset($module_params['showpubl']) ? $module_params['showpubl'] : 'n');
    $smarty->assign('show_rating_selector', isset($module_params['show_rating_selector']) ? $module_params['show_rating_selector'] : 'n');
}
Exemple #6
0
function smarty_block_title($params, $content, $template, &$repeat)
{
    global $prefs, $tiki_p_view_templates, $tiki_p_edit_templates, $tiki_p_admin;
    if ($repeat || empty($content)) {
        return;
    }
    $template->loadPlugin('smarty_function_icon');
    $template->loadPlugin('smarty_modifier_sefurl');
    $template->loadPlugin('smarty_modifier_escape');
    if (!isset($params['help'])) {
        $params['help'] = '';
    }
    if (!isset($params['admpage'])) {
        $params['admpage'] = '';
    }
    if (!isset($params['actions'])) {
        $params['actions'] = '';
    }
    // Set the variable for the HTML title tag
    $template->smarty->assign('headtitle', $content);
    $class = '';
    $current = current_object();
    if (!isset($params['url'])) {
        $params['url'] = smarty_modifier_sefurl($current['object'], $current['type']);
    }
    $metadata = '';
    $coordinates = TikiLib::lib('geo')->get_coordinates($current['type'], $current['object']);
    if ($coordinates) {
        $class = ' geolocated primary';
        $metadata = " data-geo-lat=\"{$coordinates['lat']}\" data-geo-lon=\"{$coordinates['lon']}\"";
        if (isset($coordinates['zoom'])) {
            $metadata .= " data-geo-zoom=\"{$coordinates['zoom']}\"";
        }
    }
    $html = '<h1 class="pagetitle">';
    $html .= '<a class="' . $class . '"' . $metadata . ' href="' . $params['url'] . '">' . smarty_modifier_escape($content) . "</a>\n";
    if ($template->getTemplateVars('print_page') != 'y') {
        if ($prefs['feature_help'] == 'y' && $prefs['helpurl'] != '' && $params['help'] != '') {
            $html .= '<a href="';
            $html .= $prefs['helpurl'] . rawurlencode($params['help']) . '" class="tips btn btn-link" title="' . smarty_modifier_escape($content) . '|' . tra('Help page') . '" target="tikihelp">' . smarty_function_icon(array('name' => 'help'), $template) . "</a>\n";
        }
        if ($prefs['feature_edit_templates'] == 'y' && $tiki_p_edit_templates == 'y' && ($tpl = $template->getTemplateVars('mid'))) {
            $html .= '<a href="tiki-edit_templates.php?template=';
            $html .= $tpl . '" class="tips btn btn-link" title="' . tra('View or edit tpl') . '|' . htmlspecialchars($content) . '">' . smarty_function_icon(array('name' => 'edit'), $template) . "</a>\n";
        } elseif ($prefs['feature_view_tpl'] == 'y' && $tiki_p_view_templates == 'y' && ($tpl = $template->getTemplateVars('mid'))) {
            $html .= '<a href="tiki-edit_templates.php?template=';
            $html .= $tpl . '" class="tips btn btn-link" title="' . tra('View tpl') . '|' . htmlspecialchars($content) . '">' . smarty_function_icon(array('name' => 'view'), $template) . "</a>\n";
        }
        if ($tiki_p_admin == 'y' && $params['admpage'] != '') {
            $html .= '<a class="tips btn btn-link" href="tiki-admin.php?page=';
            $html .= $params['admpage'] . '" title="' . htmlspecialchars($content) . '|' . tra('Settings') . '">' . smarty_function_icon(array('name' => 'settings'), $template) . "</a>\n";
        }
        if ($params['actions'] != '') {
            $html .= $params['actions'];
        }
    }
    $html .= '</h1>';
    return $html;
}
function wikiplugin_addfreetag($data, $params)
{
	global $user;
	$object = current_object();

	if (isset($params['object']) && false !== strpos($params['object'], ':')) {
		list($object['type'], $object['object']) = explode(':', $params['object'], 2);
	}
	if ($object['type'] == 'wiki page' && !ctype_digit($object['object'])) {
		$identifier = 'wp_addfreetag_' . str_replace(array(':',' '), array('_',''), TikiLib::lib('tiki')->get_page_id_from_name($params['object']));
	} else {
		$identifier = 'wp_addfreetag_' . str_replace(array(':',' '), array('_',''), $params['object']);
	}

	if ($object['type'] == 'trackeritem') {
		$permobject = TikiLib::lib('trk')->get_tracker_for_item($object['object']);
		$permobjecttype = 'tracker';
	} else {
		$permobject = $object['object'];
		$permobjecttype = $object['type'];
	}
	if (! TikiLib::lib('tiki')->user_has_perm_on_object($user, $permobject, $permobjecttype, 'tiki_p_freetags_tag')) {
		return '';
	}
	if (!empty($_POST[$identifier])) {
		$_POST[$identifier] = '"' . str_replace('"', '', $_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');
				$taglist = '';	
				foreach ($currenttags['data'] as $tag) {
					if (strstr($tag['tag'], ' ')) {
						$taglist .= '"'.$tag['tag'] . '" ';
					} else {
						$taglist .= $tag['tag'] . ' ';
					}
				}
				// taglist will have slashes
				TikiLib::lib('trk')->modify_field($object['object'], $field, stripslashes($taglist));
			}
		} 
		require_once 'lib/search/refresh-functions.php';
		refresh_index($object['type'], $object['object']);
		$url = $_SERVER['REQUEST_URI'];
		header("Location: $url");
		die;
	}

	$smarty = TikiLib::lib('smarty');
	$smarty->assign('wp_addfreetag', $identifier); 
	return $smarty->fetch('wiki-plugins/wikiplugin_addfreetag.tpl');
}
/**
 * @param $mod_reference
 * @param $module_params
 */
function module_search_morelikethis($mod_reference, $module_params)
{
    global $prefs;
    $smarty = TikiLib::lib('smarty');
    $textfilters = array();
    $typefilters = array();
    if (!empty($module_params['textfilters'])) {
        $filters = explode(",", $module_params['textfilters']);
        $filters = array_map('trim', $filters);
        foreach ($filters as $f) {
            $exploded = explode("=", $f);
            if (!empty($exploded[1]) && !empty($exploded[0])) {
                $textfilters[$exploded[0]] = $exploded[1];
            }
        }
    }
    if (!empty($module_params['typefilters'])) {
        $typefilters = explode(",", $module_params['typefilters']);
        $typefilters = array_map('trim', $typefilters);
    }
    $object = array();
    if ($module_params['object'] && $module_params['type']) {
        $object['object'] = $module_params['object'];
        $object['type'] = $module_params['type'];
    } else {
        $object = current_object();
    }
    if (!empty($object)) {
        $unifiedsearchlib = TikiLib::lib('unifiedsearch');
        $query = $unifiedsearchlib->buildQuery(array());
        $query->filterSimilar($object['type'], $object['object']);
        $smarty->assign('simobject', $object);
        $query->setRange(0, $mod_reference['rows']);
        foreach ($textfilters as $k => $v) {
            $query->filterContent($v, $k);
        }
        if (!empty($typefilters)) {
            $query->filterType($typefilters);
        }
        if ($prefs['federated_enabled'] == 'y') {
            $fed = TikiLib::lib('federatedsearch');
            $fed->augmentSimilarQuery($query, $object['type'], $object['object']);
        }
        try {
            $morelikethis = $query->search($unifiedsearchlib->getIndex());
            $smarty->assign('modMoreLikeThis', $morelikethis);
            $smarty->assign('module_rows', $mod_reference["rows"]);
        } catch (Search_Elastic_NotFoundException $e) {
            // Target document not found - excluded from index, ignore module
        }
    }
    $smarty->assign('tpl_module_title', tra("Similar pages"));
}
function wikiplugin_addreference($data, $params)
{
    global $prefs;
    if ($prefs['wikiplugin_addreference'] == 'y') {
        $referenceslib = TikiLib::lib('references');
        if (!isset($GLOBALS['referencesData'])) {
            $GLOBALS['referencesData'] = array();
        }
        $data = trim($data);
        if (strstr($_SERVER['SCRIPT_NAME'], 'tiki-print.php')) {
            $page = urldecode($_REQUEST['page']);
            $page_id = TikiLib::lib('tiki')->get_page_id_from_name($page);
            $page_info = TikiLib::lib('tiki')->get_page_info($page);
        } else {
            $object = current_object();
            $page_id = TikiLib::lib('tiki')->get_page_id_from_name($object['object']);
            $page_info = TikiLib::lib('tiki')->get_page_info($object['object']);
        }
        extract($params, EXTR_SKIP);
        if (empty($params['biblio_code'])) {
            return;
        }
        $regex = "/{ADDREFERENCE\\(?\\ ?biblio_code=\"(.*)\"\\)?}.*({ADDREFERENCE})?/siU";
        preg_match_all($regex, $page_info['data'], $matches);
        $temp = array();
        $curr_matches = array();
        $temp = array_unique($matches[1]);
        $i = 0;
        foreach ($temp as $k => $v) {
            if (strlen(trim($v)) > 0) {
                $curr_matches[$i] = $v;
                $i++;
            }
        }
        unset($temp);
        $found_keys = array();
        foreach ($curr_matches as $key => $val) {
            if (strlen(trim($val)) > 0) {
                if ($val == $params['biblio_code']) {
                    if (!in_array($val, $found_keys)) {
                        $found_keys[] = $val;
                        $index = $key + 1;
                        $i++;
                    }
                }
            }
        }
        $GLOBALS['referencesData'] = $curr_matches;
        $url = $GLOBALS['base_uri'] . "#" . $params['biblio_code'];
        return $data . "<a href='" . $url . "' title='" . $params['biblio_code'] . "'><sup>" . $index . "</sup></a>";
    }
}
function smarty_block_title($params, $content, $template, &$repeat)
{
    global $prefs, $tiki_p_view_templates, $tiki_p_edit_templates, $tiki_p_admin;
    if ($repeat || empty($content)) {
        return;
    }
    $template->loadPlugin('smarty_function_icon');
    if (!isset($params['help'])) {
        $params['help'] = '';
    }
    if (!isset($params['admpage'])) {
        $params['admpage'] = '';
    }
    if (!isset($params['url'])) {
        $template->loadPlugin('smarty_function_query');
        $params['url'] = htmlspecialchars(smarty_function_query(array('_type' => 'absolute_path'), $template));
        $params['url'] = str_replace('&amp;amp;', '&', $params['url']);
    }
    // Set the variable for the HTML title tag
    $template->smarty->assign('headtitle', $content);
    $class = 'pagetitle';
    $current = current_object();
    $metadata = '';
    $coordinates = TikiLib::lib('geo')->get_coordinates($current['type'], $current['object']);
    if ($coordinates) {
        $class = ' geolocated primary';
        $metadata = " data-geo-lat=\"{$coordinates['lat']}\" data-geo-lon=\"{$coordinates['lon']}\"";
        if (isset($coordinates['zoom'])) {
            $metadata .= " data-geo-zoom=\"{$coordinates['zoom']}\"";
        }
    }
    $html = '<h1>';
    $html .= '<a class="' . $class . '"' . $metadata . ' href="' . $params['url'] . '">' . htmlspecialchars($content) . "</a>\n";
    if ($template->getTemplateVars('print_page') != 'y') {
        if ($prefs['feature_help'] == 'y' && $prefs['helpurl'] != '' && $params['help'] != '') {
            $html .= '<a href="' . $prefs['helpurl'] . rawurlencode($params['help']) . '" class="titletips" title="' . tra('Help page:') . ' ' . htmlspecialchars($content) . '" target="tikihelp">' . smarty_function_icon(array('_id' => 'help'), $template) . "</a>\n";
        }
        if ($prefs['feature_edit_templates'] == 'y' && $tiki_p_edit_templates == 'y' && ($tpl = $template->getTemplateVars('mid'))) {
            $html .= '<a href="tiki-edit_templates.php?template=' . $tpl . '" class="titletips" title="' . tra('View or edit tpl:') . ' ' . htmlspecialchars($content) . '">' . smarty_function_icon(array('_id' => 'shape_square_edit', 'alt' => tra('Edit Template')), $template) . "</a>\n";
        } elseif ($prefs['feature_view_tpl'] == 'y' && $tiki_p_view_templates == 'y' && ($tpl = $template->getTemplateVars('mid'))) {
            $html .= '<a href="tiki-edit_templates.php?template=' . $tpl . '" class="titletips" title="' . tra('View tpl:') . ' ' . htmlspecialchars($content) . '">' . smarty_function_icon(array('_id' => 'shape_square', 'alt' => tra('View Template')), $template) . "</a>\n";
        }
        if ($tiki_p_admin == 'y' && $params['admpage'] != '') {
            $html .= '<a class="titletips" href="tiki-admin.php?page=' . $params['admpage'] . '" title="' . tra('Admin page:') . ' ' . htmlspecialchars($content) . '">' . smarty_function_icon(array('_id' => 'wrench', 'alt' => tra('Admin Feature')), $template) . "</a>\n";
        }
    }
    $html .= '</h1>';
    return $html;
}
/**
 * @param $mod_reference
 * @param $module_params
 */
function module_freetags_morelikethis($mod_reference, $module_params)
{
    $smarty = TikiLib::lib('smarty');
    $freetaglib = TikiLib::lib('freetag');
    $out = null;
    if (isset($module_params['type'])) {
        $out = $module_params['type'];
    }
    if ($object = current_object()) {
        $morelikethis = $freetaglib->get_similar($object['type'], $object['object'], $mod_reference["rows"], $out);
        $smarty->assign('modMoreLikeThis', $morelikethis);
        $smarty->assign('module_rows', $mod_reference["rows"]);
    }
    $smarty->assign('tpl_module_title', tra("Similar pages"));
}
/**
 * @param $mod_reference
 * @param $module_params
 */
function module_freetags_morelikethis($mod_reference, $module_params)
{
    global $smarty;
    global $freetaglib;
    include_once 'lib/freetag/freetaglib.php';
    $out = null;
    if (isset($module_params['type'])) {
        $out = $module_params['type'];
    }
    if ($object = current_object()) {
        $morelikethis = $freetaglib->get_similar($object['type'], $object['object'], $mod_reference["rows"], $out);
        $smarty->assign('modMoreLikeThis', $morelikethis);
        $smarty->assign('module_rows', $mod_reference["rows"]);
    }
    $smarty->assign('tpl_module_title', tra("Similar pages"));
}
Exemple #13
0
 function HandleObjectCategories($objectCategoryIds)
 {
     global $prefs;
     $perspectivelib = TikiLib::lib('perspective');
     $current_object = current_object();
     if (!$current_object) {
         // only used on tiki objects
         return;
     }
     $descendants = $this->get_category_descendants($prefs['areas_root']);
     $objectPerspective = 0;
     if (!empty($objectCategoryIds)) {
         if (!isset($_SESSION['current_perspective'])) {
             unset($_SESSION['current_perspective']);
         }
         foreach ($objectCategoryIds as $categId) {
             // If category is inside $prefs['areas_root']
             if (in_array($categId, $descendants)) {
                 $area = $this->getAreaByCategId($categId);
                 if ($area) {
                     $objectPerspective = $area['perspectives'][0];
                     // use 1st persp
                     break;
                 }
             }
         }
         if ($objectPerspective && $objectPerspective != $_SESSION['current_perspective']) {
             $area = $this->getAreaByPerspId($_SESSION['current_perspective']);
             $objectArea = $this->getAreaByPerspId($objectPerspective);
             if ($area && !$area['share_common'] || $objectArea && $objectArea['exclusive']) {
                 $perspectivelib->set_perspective($objectPerspective, true);
                 ZendOpenId\OpenId::redirect(ZendOpenId\OpenId::selfUrl());
             }
         }
     }
     if ($objectPerspective < 1 && !empty($_SESSION['current_perspective'])) {
         // uncategorised objects
         $area = $this->getAreaByPerspId($_SESSION['current_perspective']);
         if ($area) {
             if (!$area['share_common']) {
                 $perspectivelib->set_perspective($objectPerspective, true);
                 ZendOpenId\OpenId::redirect(ZendOpenId\OpenId::selfUrl());
             }
         }
     }
 }
function _breadcrumb_getTitle($crumbs, $loc)
{
    global $prefs, $print_page, $info, $structure, $structure_path, $tikilib, $smarty;
    $len = count($crumbs);
    if ($prefs['feature_breadcrumbs'] == 'n' || $prefs['feature_sitetitle'] == 'title') {
        $smarty->loadPlugin('smarty_modifier_sefurl');
        $smarty->loadPlugin('smarty_modifier_escape');
        $class = "pagetitle";
        $metadata = '';
        $current = current_object();
        $escapedHref = smarty_modifier_escape(smarty_modifier_sefurl($current['object'], $current['type']));
        if ($coordinates = TikiLib::lib('geo')->get_coordinates($current['type'], $current['object'])) {
            $class = ' geolocated primary';
            $metadata = " data-geo-lat=\"{$coordinates['lat']}\" data-geo-lon=\"{$coordinates['lon']}\"";
            if (isset($coordinates['zoom'])) {
                $metadata .= " data-geo-zoom=\"{$coordinates['zoom']}\"";
            }
        }
        $ret = '<strong><a class="' . $class . '"' . $metadata . ' title="' . tra("refresh") . '" href="' . $escapedHref . '">';
    } else {
        $class = "crumblink";
        $ret = '<a class="' . $class . '" title="';
        if ($structure == 'y' && $info) {
            $cnt = count($structure_path);
        } else {
            $cnt = count($crumbs);
        }
        $ret .= tra("go back to this crumb");
        $ret .= '" accesskey="' . $cnt;
        include_once 'tiki-sefurl.php';
        $ret .= '" href="' . filter_out_sefurl($crumbs[$len - 1]->url) . '">';
    }
    if ($prefs['feature_breadcrumbs'] == 'n' && $loc == "admin") {
        $ret .= tra("Administration:") . " ";
    }
    if (!empty($prefs['wiki_pagename_strip'])) {
        include_once 'lib/smarty_tiki/modifier.pagename.php';
        $ret .= tra(smarty_modifier_pagename($crumbs[$len - 1]->title)) . '</a>';
    } else {
        $ret .= htmlentities(tra($crumbs[$len - 1]->title), ENT_QUOTES, 'UTF-8') . '</a>';
    }
    $ret .= help_doclink(array('crumb' => $crumbs[$len - 1]));
    if (isset($info['flag']) && $info['flag'] == 'L' && $print_page != 'y') {
        $ret .= ' <img src="img/icons/lock.png" height="16" width="16" alt="' . tra('locked') . '" title="' . tra('locked by') . ' ' . $info['user'] . '" />';
    }
    if ($prefs['feature_breadcrumbs'] == 'n' || $prefs['feature_sitetitle'] == 'title') {
        $ret .= '</strong>';
    }
    return $ret;
}
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');
}
function wikiplugin_freetagged($data, $params)
{
    global $freetaglib, $smarty, $tikilib, $headerlib;
    include_once 'lib/freetag/freetaglib.php';
    $defaults = array('tags' => '', 'type' => null, 'offset' => 0, 'maxRecords' => -1, 'sort_mode' => 'created_desc', 'find' => '', 'broaden' => 'n', 'h_level' => '3', 'titles_only' => 'n', 'max_image_size' => 0);
    $params = array_merge($defaults, $params);
    extract($params, EXTR_SKIP);
    if ($type == tra('all')) {
        $type = null;
    }
    $sort_mode = str_replace('created', 'o.`created`', $sort_mode);
    if (!$tags && ($object = current_object())) {
        $tagArray = array();
        $ta = $freetaglib->get_tags_on_object($object['object'], $object['type']);
        foreach ($ta['data'] as $tag) {
            $tagArray[] = $tag['tag'];
        }
        if (!$type) {
            $type = $object['type'];
        }
        $objects = $freetaglib->get_similar($object['type'], $object['object'], $maxRecords, $type);
    } else {
        $tagArray = $freetaglib->_parse_tag($tags);
        $objects = $freetaglib->get_objects_with_tag_combo($tagArray, $type, '', 0, $maxRecords, $sort_mode, $find, $broaden);
        $objects = $objects['data'];
    }
    foreach ($objects as &$obj) {
        if ($titles_only == 'n') {
            switch ($obj['type']) {
                case 'article':
                    global $artlib;
                    include_once 'lib/articles/artlib.php';
                    $info = $artlib->get_article($obj['itemId']);
                    $obj['date'] = $info['publishDate'];
                    $obj['description'] = $tikilib->parse_data($info['heading']);
                    if ($info['useImage'] == 'y') {
                        $obj['image'] = 'article_image.php?id=' . $obj['itemId'];
                    } else {
                        if (!empty($info['topicId'])) {
                            $obj['image'] = 'article_image.php?image_type=topic&amp;id=' . $info['topicId'];
                        }
                    }
                    if (isset($obj['image'])) {
                        if (!empty($info['image_x'])) {
                            $w = $info['image_x'];
                        } else {
                            $w = 0;
                        }
                        if (!empty($info['image_y'])) {
                            $h = $info['image_y'];
                        } else {
                            $h = 0;
                        }
                        if ($max_image_size > 0) {
                            if ($w > $h && $w > $max_image_size) {
                                $w = $max_image_size;
                                $h = floor($w * $h / $info['image_x']);
                            } else {
                                if ($h > $max) {
                                    $h = $max_image_size;
                                    $w = floor($h * $w / $info['image_y']);
                                }
                            }
                        }
                        $obj['img'] = '<img  src="' . $obj['image'] . ($w ? ' width="' . $w . '"' : '') . ($h ? ' height="' . $h . '"' : '') . '"/>';
                    }
                    break;
                case 'file':
                    global $filegallib;
                    include_once 'lib/filegals/filegallib.php';
                    $info = $filegallib->get_file($obj['itemId']);
                    $obj['description'] = $info['description'];
                    $obj['date'] = $info['lastModif'];
                    include_once 'lib/wiki-plugins/wikiplugin_img.php';
                    $imgparams = array('fileId' => $obj['itemId'], 'rel' => 'box[g]');
                    $imgparams['thumb'] = 'y';
                    if ($max_image_size > 0) {
                        $imgparams['max'] = $max_image_size;
                    }
                    $obj['img'] = wikiplugin_img('', $imgparams, 0);
                    $obj['img'] = str_replace('~np~', '', $obj['img']);
                    // don't nest ~np~
                    $obj['img'] = str_replace('~/np~', '', $obj['img']);
                    break;
                case 'wiki page':
                    $info = $tikilib->get_page_info($obj['name'], false);
                    $obj['description'] = $info['description'];
                    $obj['date'] = $info['lastModif'];
                    $obj['image'] = '';
                    break;
                default:
                    $obj['description'] = '';
                    $obj['image'] = '';
                    $obj['date'] = '';
            }
        } else {
            $obj['description'] = '';
            $obj['image'] = '';
            $obj['date'] = '';
        }
    }
    $smarty->assign_by_ref('objects', $objects);
    $smarty->assign('h_level', $h_level);
    $ret = $smarty->fetch('wiki-plugins/wikiplugin_freetagged.tpl');
    return '~np~' . $ret . '~/np~';
}
Exemple #17
0
        header("Location: {$url}");
        die;
    }
    if ($object = current_object()) {
        $tags = $freetaglib->get_tags_on_object($object['object'], $object['type']);
    } else {
        $tags = array();
    }
    $smarty->assign('freetags', $tags);
    if ($tiki_p_freetags_tag == 'y' && $prefs['freetags_multilingual'] == 'y') {
        $ft_lang = null;
        $ft_multi = false;
        if (!empty($tags['data'])) {
            foreach ($tags['data'] as $row) {
                $l = $row['lang'];
                if (!$l) {
                    continue;
                }
                if (!$ft_lang) {
                    $ft_lang = $l;
                } elseif ($ft_lang != $l) {
                    $ft_multi = true;
                    break;
                }
            }
        }
        if ($ft_multi && ($object = current_object())) {
            $smarty->assign('freetags_mixed_lang', 'tiki-freetag_translate.php?objType=' . urlencode($object['type']) . '&objId=' . urlencode($object['object']));
        }
    }
}
Exemple #18
0
function _breadcrumb_getTitle($crumbs, $loc)
{
    global $prefs, $print_page, $info, $structure, $structure_path;
    $smarty = TikiLib::lib('smarty');
    $tikilib = TikiLib::lib('tiki');
    $len = count($crumbs);
    if ($prefs['feature_breadcrumbs'] == 'n' || $prefs['feature_sitetitle'] == 'title') {
        $smarty->loadPlugin('smarty_modifier_sefurl');
        $smarty->loadPlugin('smarty_modifier_escape');
        $class = "";
        $metadata = '';
        $current = current_object();
        $escapedHref = smarty_modifier_escape(smarty_modifier_sefurl($current['object'], $current['type']));
        if ($coordinates = TikiLib::lib('geo')->get_coordinates($current['type'], $current['object'])) {
            $class = ' geolocated primary';
            $metadata = " data-geo-lat=\"{$coordinates['lat']}\" data-geo-lon=\"{$coordinates['lon']}\"";
            if (isset($coordinates['zoom'])) {
                $metadata .= " data-geo-zoom=\"{$coordinates['zoom']}\"";
            }
        }
        $ret = '<a class="' . $class . '"' . $metadata . ' title="' . tra("refresh") . '" href="' . $escapedHref . '">';
    } else {
        $class = "crumblink";
        $ret = '<a class="' . $class . '" title="';
        if ($structure == 'y' && $info) {
            $cnt = count($structure_path);
        } else {
            $cnt = count($crumbs);
        }
        $ret .= tra("go back to this crumb");
        $ret .= '" accesskey="' . $cnt;
        include_once 'tiki-sefurl.php';
        $ret .= '" href="' . filter_out_sefurl($crumbs[$len - 1]->url) . '">';
    }
    if ($prefs['feature_breadcrumbs'] == 'n' && $loc == "admin") {
        $ret .= tra("Administration:") . " ";
    }
    // Should show alias if in structure
    $cur_title = $crumbs[$len - 1]->title;
    if ($structure == 'y') {
        foreach ($structure_path as $crumb) {
            if ($crumb['pageName'] == $cur_title && $crumb['page_alias'] != '') {
                $cur_title = $crumb['page_alias'];
            }
        }
    }
    if (!empty($prefs['wiki_pagename_strip'])) {
        include_once 'lib/smarty_tiki/modifier.pagename.php';
        $ret .= tra(smarty_modifier_pagename($cur_title)) . '</a>';
    } else {
        $ret .= htmlentities(tra($cur_title), ENT_QUOTES, 'UTF-8') . '</a>';
    }
    $ret .= help_doclink(array('crumb' => $crumbs[$len - 1]));
    if (isset($info['flag']) && $info['flag'] == 'L' && $print_page != 'y') {
        $smarty->loadPlugin('smarty_function_icon');
        $ret .= smarty_function_icon(['name' => 'lock', 'iclass' => 'tips', 'ititle' => ':' . tra('Locked by') . $info['user']], $smarty);
    }
    return $ret;
}
function wikiplugin_freetagged($data, $params)
{
    $smarty = TikiLib::lib('smarty');
    $tikilib = TikiLib::lib('tiki');
    $headerlib = TikiLib::lib('header');
    $freetaglib = TikiLib::lib('freetag');
    $defaults = array('tags' => '', 'type' => null, 'offset' => 0, 'maxRecords' => -1, 'sort_mode' => 'created_desc', 'find' => '', 'broaden' => 'n', 'h_level' => '3', 'titles_only' => 'n', 'max_image_size' => 0, 'more' => 'n', 'moreurl' => 'tiki-browse_freetags.php', 'moretext' => 'more');
    $params = array_merge($defaults, $params);
    extract($params, EXTR_SKIP);
    if ($type == tra('all')) {
        $type = null;
    }
    $sort_mode = str_replace('created', 'o.`created`', $sort_mode);
    // We only display the "more" link if the number of displayed values is limited and there are more values than displayed
    // so we might need one more item just to know if there are more values than displayed
    if ($maxRecords > 0 && $more == 'y') {
        $maxReturned = $maxRecords + 1;
    } else {
        $maxReturned = $maxRecords;
    }
    if (!$tags && ($object = current_object())) {
        $tagArray = array();
        $ta = $freetaglib->get_tags_on_object($object['object'], $object['type']);
        foreach ($ta['data'] as $tag) {
            $tagArray[] = $tag['tag'];
        }
        if (!$type) {
            $type = $object['type'];
        }
        $objects = $freetaglib->get_similar($object['type'], $object['object'], $maxReturned, $type);
    } else {
        $tagArray = $freetaglib->_parse_tag($tags);
        $objects = $freetaglib->get_objects_with_tag_combo($tagArray, $type, '', 0, $maxReturned, $sort_mode, $find, $broaden);
        $objects = $objects['data'];
    }
    if ($more == 'y' && count($objects) == $maxReturned) {
        array_pop($objects);
        $smarty->assign('more', 'y');
    } else {
        $smarty->assign('more', 'n');
    }
    $moreurlparams = 'tag=' . $tags . '&old_type=' . urlencode($type) . '&sort_mode=' . urlencode($params['sort_mode']) . '&find=' . urlencode($find) . '&broaden=' . urlencode($broaden);
    if (strpos($moreurl, '?') === FALSE) {
        $moreurl = $moreurl . '?' . $moreurlparams;
    } else {
        $moreurl = $moreurl . '&' . $moreurlparams;
    }
    $smarty->assign_by_ref('moreurl', $moreurl);
    if (isset($moretext)) {
        $smarty->assign_by_ref('moretext', $moretext);
    } else {
        $smarty->assign('moretext', 'more');
    }
    foreach ($objects as &$obj) {
        if ($titles_only == 'n') {
            switch ($obj['type']) {
                case 'article':
                    $artlib = TikiLib::lib('art');
                    $info = $artlib->get_article($obj['itemId']);
                    $obj['date'] = $info['publishDate'];
                    $obj['description'] = $tikilib->parse_data($info['heading']);
                    if ($info['useImage'] == 'y') {
                        $obj['image'] = 'article_image.php?id=' . $obj['itemId'];
                    } else {
                        if (!empty($info['topicId'])) {
                            $obj['image'] = 'article_image.php?image_type=topic&amp;id=' . $info['topicId'];
                        }
                    }
                    if (isset($obj['image'])) {
                        if (!empty($info['image_x'])) {
                            $w = $info['image_x'];
                        } else {
                            $w = 0;
                        }
                        if (!empty($info['image_y'])) {
                            $h = $info['image_y'];
                        } else {
                            $h = 0;
                        }
                        if ($max_image_size > 0) {
                            if ($w > $h && $w > $max_image_size) {
                                $w = $max_image_size;
                                $h = floor($w * $h / $info['image_x']);
                            } else {
                                if ($h > $max) {
                                    $h = $max_image_size;
                                    $w = floor($h * $w / $info['image_y']);
                                }
                            }
                        }
                        $obj['img'] = '<img  src="' . $obj['image'] . ($w ? ' width="' . $w . '"' : '') . ($h ? ' height="' . $h . '"' : '') . '"/>';
                    }
                    break;
                case 'file':
                    $filegallib = TikiLib::lib('filegal');
                    $info = $filegallib->get_file($obj['itemId']);
                    $obj['description'] = $info['description'];
                    $obj['date'] = $info['lastModif'];
                    include_once 'lib/wiki-plugins/wikiplugin_img.php';
                    $imgparams = array('fileId' => $obj['itemId'], 'thumb' => 'box');
                    if ($max_image_size > 0) {
                        $imgparams['max'] = $max_image_size;
                    }
                    $obj['img'] = wikiplugin_img('', $imgparams, 0);
                    $obj['img'] = str_replace('~np~', '', $obj['img']);
                    // don't nest ~np~
                    $obj['img'] = str_replace('~/np~', '', $obj['img']);
                    break;
                case 'wiki page':
                    $info = $tikilib->get_page_info($obj['name'], false);
                    $obj['description'] = $info['description'];
                    $obj['date'] = $info['lastModif'];
                    $obj['image'] = '';
                    break;
                default:
                    $obj['description'] = '';
                    $obj['image'] = '';
                    $obj['date'] = '';
            }
        } else {
            $obj['description'] = '';
            $obj['image'] = '';
            $obj['date'] = '';
        }
    }
    $smarty->assign_by_ref('objects', $objects);
    $smarty->assign('h_level', $h_level);
    $ret = $smarty->fetch('wiki-plugins/wikiplugin_freetagged.tpl');
    return '~np~' . $ret . '~/np~';
}
Exemple #20
0
 /**
  * needs a proper description
  * @param null   $resource_name
  * @param null   $cache_id
  * @param null   $compile_id
  * @param null   $parent
  * @param string $content_type
  * @return Purified|void
  */
 function display($resource_name = null, $cache_id = null, $compile_id = null, $parent = null, $content_type = 'text/html; charset=utf-8')
 {
     global $prefs;
     $this->muteExpectedErrors();
     if (!empty($prefs['feature_htmlpurifier_output']) and $prefs['feature_htmlpurifier_output'] == 'y') {
         static $loaded = false;
         static $purifier = null;
         if (!$loaded) {
             require_once 'lib/htmlpurifier_tiki/HTMLPurifier.tiki.php';
             $config = getHTMLPurifierTikiConfig();
             $purifier = new HTMLPurifier($config);
             $loaded = true;
         }
     }
     /**
      * By default, display is used with text/html content in UTF-8 encoding
      * If you want to output other data from smarty,
      * - either use fetch() / fetchLang()
      * - or set $content_type to '' (empty string) or another content type.
      */
     if ($content_type != '' && !headers_sent()) {
         header('Content-Type: ' . $content_type);
     }
     if (function_exists('current_object') && ($obj = current_object())) {
         $attributes = TikiLib::lib('attribute')->get_attributes($obj['type'], $obj['object']);
         if (isset($attributes['tiki.object.layout'])) {
             $prefs['site_layout'] = $attributes['tiki.object.layout'];
         }
     }
     $this->refreshLanguage();
     TikiLib::events()->trigger('tiki.process.render', []);
     if (!empty($prefs['feature_htmlpurifier_output']) and $prefs['feature_htmlpurifier_output'] == 'y') {
         return $purifier->purify(parent::display($resource_name, $cache_id, $compile_id));
     } else {
         return parent::display($resource_name, $cache_id, $compile_id);
     }
 }
/**
 * @param $mod_reference
 * @param $module_params
 */
function module_change_category($mod_reference, $module_params)
{
    global $prefs;
    $smarty = TikiLib::lib('tiki');
    $smarty = TikiLib::lib('smarty');
    $modlib = TikiLib::lib('mod');
    $smarty->assign('showmodule', false);
    $object = current_object();
    if ($object || $modlib->is_admin_mode(true)) {
        $categlib = TikiLib::lib('categ');
        if (!empty($module_params['id'])) {
            $id = $module_params['id'];
            $cat_parent = $categlib->get_category_name($id);
        } else {
            $id = 0;
            $cat_parent = '';
        }
        if (!empty($module_params['shy']) && !$modlib->is_admin_mode(true)) {
            $shy = $module_params['shy'] === 'y';
        } else {
            $shy = false;
        }
        $detailed = isset($module_params['detail']) ? $module_params['detail'] : "n";
        $smarty->assign('detailed', $detailed);
        $add = isset($module_params['add']) ? $module_params['add'] : "y";
        $smarty->assign('add', $add);
        $multiple = isset($module_params['multiple']) ? $module_params['multiple'] : "y";
        $smarty->assign('multiple', $multiple);
        $cat_type = $object['type'];
        $cat_objid = $object['object'];
        $categories = $categlib->getCategories($id ? array('identifier' => $id, 'type' => 'descendants') : null);
        if (!empty($module_params['group']) && $module_params['group'] == 'y') {
            global $user;
            $userlib = TikiLib::lib('user');
            if (!$user) {
                return;
            }
            $userGroups = $userlib->get_user_groups_inclusion($user);
            foreach ($categories as $i => $cat) {
                if (isset($userGroups[$cat['name']])) {
                    continue;
                }
                $ok = false;
                foreach ($cat['tepath'] as $c) {
                    if (isset($userGroups[$c])) {
                        $ok = true;
                        break;
                    }
                }
                if (!$ok) {
                    unset($categories[$i]);
                }
            }
        }
        $managedCategories = array_keys($categories);
        if (isset($_REQUEST['remove']) && (!isset($module_params['del']) || $module_params['del'] != 'n')) {
            $originalCategories = $categlib->get_object_categories($cat_type, $cat_objid);
            // Check if the object is in the category to prevent infinite redirection.
            if (in_array($_REQUEST['remove'], $originalCategories) && in_array($_REQUEST['remove'], $managedCategories)) {
                $selectedCategories = array();
                $managedCategories = array_intersect(array((int) $_REQUEST['remove']), $managedCategories);
            }
        } elseif (isset($_REQUEST["modcatid"]) and $_REQUEST["modcatid"] == $id) {
            if (!isset($_REQUEST['modcatchange'])) {
                $selectedCategories = array();
            } elseif (is_array($_REQUEST['modcatchange'])) {
                $selectedCategories = $_REQUEST['modcatchange'];
            } else {
                $selectedCategories = array($_REQUEST['modcatchange']);
            }
            foreach ($selectedCategories as &$selectedCategory) {
                $selectedCategory = (int) $selectedCategory;
            }
            if ($detailed != 'n') {
                $managedCategories = array_intersect($selectedCategories, $managedCategories);
            }
        }
        if (isset($selectedCategories)) {
            $objectperms = Perms::get(array('type' => $cat_type, 'object' => $cat_objid));
            if ($objectperms->modify_object_categories) {
                $categlib->update_object_categories($selectedCategories, $cat_objid, $cat_type, null, null, null, $managedCategories);
            }
            header('Location: ' . $_SERVER['REQUEST_URI']);
            die;
        }
        $objectCategories = $categlib->get_object_categories($cat_type, $cat_objid);
        $isInAllManagedCategories = true;
        foreach ($categories as &$category) {
            if (in_array($category['categId'], $objectCategories)) {
                $category['incat'] = 'y';
                $shy = false;
            } else {
                $category['incat'] = 'n';
                $isInAllManagedCategories = false;
            }
        }
        if (count($categories) != 1) {
            unset($module_params['imgUrlNotIn']);
            unset($module_params['imgUrlIn']);
        }
        $smarty->assign('isInAllManagedCategories', $isInAllManagedCategories);
        $smarty->assign('showmodule', !$shy);
        $objectlib = TikiLib::lib('object');
        $title = $objectlib->get_title($cat_type, $cat_objid);
        if (empty($cat_parent)) {
            $smarty->assign('tpl_module_title', sprintf(tra('Categorize %s'), htmlspecialchars($title)));
        } else {
            $smarty->assign('tpl_module_title', sprintf(tra('Categorize %s in %s'), htmlspecialchars($title), htmlspecialchars($cat_parent)));
        }
        $smarty->assign('modcatlist', $categories);
        $smarty->assign('modcatid', $id);
    }
}
Exemple #22
0
function tiki_setup_events()
{
    global $prefs;
    $events = TikiLib::events();
    $events->reset();
    $defer = function ($lib, $function) {
        return Tiki_Event_Lib::defer($lib, $function);
    };
    if ($prefs['feature_wiki'] == 'y') {
        if ($prefs['quantify_changes'] == 'y' && $prefs['feature_multilingual'] == 'y') {
            $events->bind('tiki.wiki.save', $defer('quantify', 'wiki_update'));
        }
        $prefix = $prefs['feature_wiki_userpage_prefix'];
        if ($prefs['feature_wiki_userpage'] && !empty($prefix)) {
            $events->bind('tiki.wiki.save', function ($args) use($events, $prefix) {
                global $prefs;
                if ($prefix == substr($args['object'], 0, strlen($prefix))) {
                    $user = substr($args['object'], strlen($prefix));
                    $events->trigger('tiki.user.update', array('type' => 'user', 'object' => $user));
                }
            });
        }
    }
    if ($prefs['feature_trackers'] == 'y') {
        $events->bind('tiki.trackeritem.save', $defer('trk', 'send_replace_item_notifications'));
        $events->bind('tiki.trackeritem.save', $defer('trk', 'sync_item_geo'));
        if ($prefs['feature_categories'] == 'y') {
            $events->bind('tiki.trackeritem.save', $defer('trk', 'sync_categories'));
            $events->bind('tiki.trackeritem.save', $defer('trk', 'sync_item_auto_categories'));
        }
        if (!empty($prefs['user_trackersync_realname'])) {
            $events->bind('tiki.trackeritem.save', $defer('trk', 'sync_user_realname'));
        }
        if ($prefs['user_trackersync_geo'] == 'y') {
            $events->bind('tiki.trackeritem.save', $defer('trk', 'sync_user_geo'));
        }
        if ($prefs['groupTracker'] == 'y') {
            $events->bind('tiki.trackeritem.create', $defer('trk', 'group_tracker_create'));
        }
        $events->bind('tiki.trackeritem.create', $defer('trk', 'setup_wiki_fields'));
        $events->bind('tiki.trackeritem.update', $defer('trk', 'update_wiki_fields'));
        $events->bind('tiki.trackeritem.delete', $defer('trk', 'delete_wiki_fields'));
        if ($prefs['userTracker'] == 'y') {
            $events->bind('tiki.trackeritem.save', $defer('trk', 'update_user_account'));
        }
        if ($prefs['feature_freetags'] == 'y') {
            $events->bind('tiki.trackeritem.save', $defer('trk', 'sync_freetags'));
        }
        $events->bind('tiki.trackeritem.save', $defer('trk', 'update_create_missing_pages'));
        if ($prefs['trackerfield_computed'] == 'y') {
            $events->bind('tiki.trackeritem.rating', array('Tracker_Field_Computed', 'computeFields'));
            $events->bind('tiki.trackeritem.save', array('Tracker_Field_Computed', 'computeFields'));
        }
        if ($prefs['feature_multilingual'] == 'y') {
            $events->bind('tiki.trackeritem.save', array('Tracker_Field_Language', 'update_language'));
        }
        if ($prefs['trackerfield_icon'] == 'y') {
            $events->bind('tiki.trackeritem.save', array('Tracker_Field_Icon', 'updateIcon'));
        }
        // Certain non-read only fields that can be edited outside of using the tracker field do store a value in the
        // tiki_tracker_item_fields database, and therefore need updates of the tracker field value to be in sync, when
        // edited elsewhere. Completely read-only fields don't have this problem as they don't save anything anyway.
        //
        // A possible solution could have been to avoid storing the value in the database altogether and get the value
        // from the canonical source, but there is code that currently could dependd on it and also it might actually
        // be argued in favor of for performance reasons to have the value in the tiki_tracker_item_fields db as well.
        //
        // TODO: freetags field. There is already handling for the Freetags field in wikiplugin_addfreetag.php which
        // is the most likely place it would be edited outside of tracker field but an event would be cleaner.
        //
        if ($prefs['trackerfield_relation'] == 'y') {
            $events->bind('tiki.social.relation.add', array('Tracker_Field_Relation', 'syncRelationAdded'));
            $events->bind('tiki.social.relation.remove', array('Tracker_Field_Relation', 'syncRelationRemoved'));
        }
        if ($prefs['trackerfield_category'] == 'y') {
            $events->bind('tiki.object.categorized', array('Tracker_Field_Category', 'syncCategoryFields'));
        }
        $events->bind('tiki.trackeritem.save', $defer('trk', 'update_tracker_summary'));
        $events->bind('tiki.trackeritem.save', $defer('trk', 'invalidate_item_cache'));
        $events->bind('tiki.trackeritem.rating', $defer('trk', 'invalidate_item_cache'));
        if ($prefs['tracker_refresh_itemlink_detail'] == 'y') {
            $events->bind('tiki.trackeritem.update', $defer('trk', 'refresh_index_on_master_update'));
        }
        if ($prefs['tracker_wikirelation_synctitle'] == 'y') {
            $events->bind('tiki.trackeritem.save', $defer('trk', 'rename_linked_page'));
        }
    }
    if ($prefs['feature_search'] == 'y' && $prefs['unified_incremental_update'] == 'y') {
        $events->bindPriority(100, 'tiki.save', 'tiki_save_refresh_index');
        $events->bindPriority(100, 'tiki.user.save', 'tiki_save_refresh_index');
        $events->bindPriority(100, 'tiki.social.save', 'tiki_save_refresh_index');
        $events->bindPriority(100, 'tiki.rating', 'tiki_save_refresh_index');
    }
    if ($prefs['feature_file_galleries'] == 'y') {
        $events->bind('tiki.save', $defer('filegal', 'save_sync_file_backlinks'));
    }
    if ($prefs['dailyreports_enabled_for_new_users'] == 'y') {
        $events->bind('tiki.user.create', array(Reports_Factory::build('Reports_Users'), 'addUserToDailyReports'));
    }
    if ($prefs['scorm_enabled'] == 'y') {
        $events->bind('tiki.file.create', $defer('scorm', 'handle_file_creation'));
        $events->bind('tiki.file.update', $defer('scorm', 'handle_file_update'));
    }
    if ($prefs['feature_futurelinkprotocol'] == 'y') {
        if ($prefs['feature_wikilingo'] == 'y') {
            $events->bind("tiki.wiki.view", $defer('wlte', 'wikilingo_flp_view'));
            $events->bind("tiki.wiki.save", $defer('wlte', 'wikilingo_flp_save'));
        } else {
            $events->bind("tiki.wiki.view", $defer('wlte', 'tiki_wiki_view_pastlink'));
            $events->bind("tiki.wiki.save", $defer('wlte', 'tiki_wiki_save_pastlink'));
        }
    }
    if ($prefs['goal_enabled'] == 'y') {
        TikiLib::lib('goalevent')->bindEvents($events);
    }
    $events->bind('tiki.save', $defer('tiki', 'object_post_save'));
    if ($prefs['activity_basic_events'] == 'y') {
        TikiLib::lib('activity')->bindBasicEvents($events);
    }
    if ($prefs['activity_custom_events'] == 'y') {
        try {
            TikiLib::lib('activity')->bindCustomEvents($events);
        } catch (Exception $e) {
            TikiLib::lib('errorreport')->report($e->getMessage());
        }
    }
    if ($prefs['storedsearch_enabled'] == 'y' && $prefs['monitor_enabled'] == 'y') {
        $events->bind('tiki.query.hit', $defer('storedsearch', 'handleQueryNotification'));
    }
    if ($prefs['monitor_enabled'] == 'y') {
        TikiLib::lib('monitor')->bindEvents($events);
    }
    if ($prefs['mustread_enabled'] == 'y') {
        $events->bind('tiki.trackeritem.create', ['Services_MustRead_Controller', 'handleItemCreation']);
        $events->bind('tiki.user.create', ['Services_MustRead_Controller', 'handleUserCreation']);
    }
    if ($prefs['feature_score'] == 'y') {
        TikiLib::lib('score')->bindEvents($events);
    }
    // If the parameter is supplied by the web server, Tiki will expose the username as a response header
    if (!empty($_SERVER['TIKI_HEADER_REPORT_USER'])) {
        $events->bind('tiki.process.render', function () {
            global $user;
            if ($user) {
                header('X-Remote-User: '******'TIKI_HEADER_REPORT_OBJECT'])) {
        $events->bind('tiki.process.render', function () {
            if (function_exists('current_object') && ($object = current_object())) {
                header("X-Current-Object: {$object['type']}:{$object['object']}");
            }
        });
    }
    // Chain events
    $events->bind('tiki.object.categorized', 'tiki.save');
    $events->bind('tiki.user.login', 'tiki.view');
    $events->bind('tiki.user.view', 'tiki.view');
    $events->bind('tiki.user.avatar', 'tiki.save');
    $events->bind('tiki.wiki.update', 'tiki.wiki.save');
    $events->bind('tiki.wiki.create', 'tiki.wiki.save');
    $events->bind('tiki.wiki.save', 'tiki.save');
    $events->bind('tiki.wiki.view', 'tiki.view');
    $events->bind('tiki.wiki.attachfile', 'tiki.save');
    $events->bind('tiki.article.create', 'tiki.article.save');
    $events->bind('tiki.article.save', 'tiki.save');
    $events->bind('tiki.article.delete', 'tiki.save');
    $events->bind('tiki.article.view', 'tiki.view');
    $events->bind('tiki.blog.create', 'tiki.blog.save');
    $events->bind('tiki.blog.save', 'tiki.save');
    $events->bind('tiki.blog.delete', 'tiki.save');
    $events->bind('tiki.blog.view', 'tiki.view');
    $events->bind('tiki.blogpost.create', 'tiki.blogpost.save');
    $events->bind('tiki.blogpost.save', 'tiki.save');
    $events->bind('tiki.blogpost.delete', 'tiki.save');
    $events->bind('tiki.trackeritem.update', 'tiki.trackeritem.save');
    $events->bind('tiki.trackeritem.create', 'tiki.trackeritem.save');
    $events->bind('tiki.trackeritem.save', 'tiki.save');
    $events->bind('tiki.trackeritem.delete', 'tiki.save');
    $events->bind('tiki.trackeritem.rating', 'tiki.rating');
    $events->bind('tiki.trackeritem.view', 'tiki.view');
    $events->bind('tiki.trackerfield.update', 'tiki.trackerfield.save');
    $events->bind('tiki.trackerfield.create', 'tiki.trackerfield.save');
    $events->bind('tiki.trackerfield.delete', 'tiki.save');
    $events->bind('tiki.trackerfield.save', 'tiki.save');
    $events->bind('tiki.tracker.update', 'tiki.tracker.save');
    $events->bind('tiki.tracker.create', 'tiki.tracker.save');
    $events->bind('tiki.tracker.delete', 'tiki.save');
    $events->bind('tiki.tracker.save', 'tiki.save');
    $events->bind('tiki.category.update', 'tiki.category.save');
    $events->bind('tiki.category.create', 'tiki.category.save');
    $events->bind('tiki.category.delete', 'tiki.category.save');
    $events->bind('tiki.category.save', 'tiki.save');
    $events->bind('tiki.file.update', 'tiki.file.save');
    $events->bind('tiki.file.create', 'tiki.file.save');
    $events->bind('tiki.file.delete', 'tiki.file.save');
    $events->bind('tiki.file.save', 'tiki.save');
    $events->bind('tiki.file.download', 'tiki.view');
    $events->bind('tiki.filegallery.update', 'tiki.filegallery.save');
    $events->bind('tiki.filegallery.create', 'tiki.filegallery.save');
    $events->bind('tiki.filegallery.delete', 'tiki.filegallery.save');
    $events->bind('tiki.filegallery.save', 'tiki.save');
    $events->bind('tiki.image.create', 'tiki.image.save');
    $events->bind('tiki.image.delete', 'tiki.image.save');
    $events->bind('tiki.image.save', 'tiki.save');
    $events->bind('tiki.image.view', 'tiki.view');
    $events->bind('tiki.imagegallery.create', 'tiki.imagegallery.save');
    $events->bind('tiki.imagegallery.delete', 'tiki.imagegallery.save');
    $events->bind('tiki.imagegallery.save', 'tiki.save');
    $events->bind('tiki.imagegallery.view', 'tiki.view');
    $events->bind('tiki.forum.update', 'tiki.forum.save');
    $events->bind('tiki.forum.create', 'tiki.forum.save');
    $events->bind('tiki.forum.delete', 'tiki.forum.save');
    $events->bind('tiki.forum.save', 'tiki.save');
    $events->bind('tiki.forumpost.create', 'tiki.forumpost.save');
    $events->bind('tiki.forumpost.reply', 'tiki.forumpost.save');
    $events->bind('tiki.forumpost.update', 'tiki.forumpost.save');
    $events->bind('tiki.forumpost.save', 'tiki.save');
    $events->bind('tiki.forumpost.view', 'tiki.view');
    $events->bind('tiki.group.update', 'tiki.group.save');
    $events->bind('tiki.group.create', 'tiki.group.save');
    $events->bind('tiki.group.delete', 'tiki.save');
    $events->bind('tiki.group.save', 'tiki.save');
    $events->bind('tiki.comment.post', 'tiki.comment.save');
    $events->bind('tiki.comment.reply', 'tiki.comment.save');
    $events->bind('tiki.comment.update', 'tiki.comment.save');
    $events->bind('tiki.comment.save', 'tiki.save');
    $events->bind('tiki.user.groupjoin', 'tiki.user.update');
    $events->bind('tiki.user.groupleave', 'tiki.user.update');
    $events->bind('tiki.user.update', 'tiki.user.save');
    $events->bind('tiki.user.create', 'tiki.user.save');
    $events->bind('tiki.user.follow.add', 'tiki.user.network');
    $events->bind('tiki.user.follow.incoming', 'tiki.user.network');
    $events->bind('tiki.user.friend.add', 'tiki.user.network');
    $events->bind('tiki.user.message', 'tiki.user.network');
    $events->bind('tiki.social.like.add', 'tiki.social.save');
    $events->bind('tiki.social.like.remove', 'tiki.social.save');
    $events->bind('tiki.social.favorite.add', 'tiki.social.save');
    $events->bind('tiki.social.favorite.remove', 'tiki.social.save');
    $events->bind('tiki.social.relation.add', 'tiki.social.save');
    $events->bind('tiki.social.relation.remove', 'tiki.social.save');
    $events->bind('tiki.social.rating.add', 'tiki.social.save');
    $events->bind('tiki.social.rating.remove', 'tiki.social.save');
    $events->bind('tiki.query.critical', 'tiki.query.hit');
    $events->bind('tiki.query.high', 'tiki.query.hit');
    $events->bind('tiki.query.low', 'tiki.query.hit');
    $events->bind('tiki.mustread.addgroup', 'tiki.save');
    $events->bind('tiki.mustread.adduser', 'tiki.save');
    $events->bind('tiki.mustread.complete', 'tiki.save');
    $events->bind('tiki.mustread.completed', 'tiki.save');
    $events->bind('tiki.mustread.required', 'tiki.save');
    if (function_exists('fastcgi_finish_request')) {
        // If available, try to send everything to the user at this point
        $events->bindPriority(-10, 'tiki.process.shutdown', 'fastcgi_finish_request');
    }
    // if article indexing is on as part of the rss article generator bind the categorization of objects to ensure
    // that the trackeritem and article are always in sync category-wise
    if (isset($prefs['tracker_article_indexing']) && $prefs['tracker_article_indexing'] == 'y') {
        $events->bind('tiki.object.categorized', $defer('trk', 'sync_tracker_article_categories'));
    }
    //Check the Addons to see if there are any events to bind
    $api = new TikiAddons_Api_Events();
    $api->bindEvents($events);
}