1<?php 2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project 3// 4// All Rights Reserved. See copyright.txt for details and a complete list of authors. 5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. 6// $Id$ 7 8//this script may only be included - so its better to die if called directly. 9if (strpos($_SERVER["SCRIPT_NAME"], basename(__FILE__)) !== false) { 10 header("location: index.php"); 11 exit; 12} 13 14function smarty_block_ifsearchexists($params, $content, $smarty, &$repeat) 15{ 16 if (empty($params['type']) || empty($params['id'])) { 17 return ''; 18 } 19 20 TikiLib::lib('access')->check_feature('feature_search'); 21 22 $query = new Search_Query; 23 $query->addObject($params['type'], $params['id']); 24 $index = TikiLib::lib('unifiedsearch')->getIndex(); 25 $result = $query->search($index); 26 27 if ($result->count() > 0) { 28 return $content; 29 } else { 30 return ''; 31 } 32} 33