Hi, I am new to drupal.. I have implemented an auto-fill search functionality in my project. I is working fine when am logged in as admin but when i logged out I does not work and gives error 403 forbidded error or access denied. Here is my coding..
<?php
/**
* Implementation of hook_perm().
*/
function search_tours_perm() {
return array('Allow user to search tours','Allow user to search tours');
}
/**
* Implementation of hook_menu().
*/
function search_tours_menu() {
$items['search_tours/tours'] = array(
'page callback' => 'search_tours',
'access callback' => 'user_access',
'access arguments' => array('Allow user to search tours;'),
'access'=> TRUE,
'type' => MENU_CALLBACK,
);
return $items;
}
/*
* Implementation of hook_block
*/
drupal_add_js(drupal_get_path('module', 'search_tours') .'/js/search_tours.js');
drupal_add_css(drupal_get_path('module', 'search_tours') .'/css/search_tours.css');
function search_tours_block($op = 'list', $delta = 0, $edit = array()) {
// The $op parameter determines what piece of information is being requested.
switch ($op) {
case 'list':
// If $op is "list", we just need to return a list of block descriptions.
// This is used to provide a list of possible blocks to the administrator,
// end users will not see these descriptions.
$blocks[0] = array(
'info' => t('Auto Complete search tour '),
);
// A block can provide default settings. In this case we'll enable the
// block and make it visible only on the 'node/*' pages.
$blocks[1] = array(
'info' => t('Example: empty block'),
'status' => TRUE,
'weight' => 0,
'visibility' => 1,
'pages' => 'node/*',
);
return $blocks;
case 'configure':
// If $op is "configure", we need to provide the administrator with a
// configuration form. The $delta parameter tells us which block is being
// configured. In this example, we'll allow the administrator to customize
// the text of the first block.
$form = array();
if ($delta == 0) {
// All we need to provide is a text field, Drupal will take care of
// the other block configuration options and the save button.
$form['block_example_string'] = array(
'#type' => 'textfield',
'#title' => t('Block contents'),
'#size' => 60,
'#description' => t('This string will appear in the example block.'),
'#default_value' => variable_get('block_example_string', t('Some example content.')),
);
}
return $form;
case 'save':
// If $op is "save", we need to save settings from the configuration form.
// Since the first block is the only one that allows configuration, we
// need to check $delta to make sure we only save it.
if ($delta == 0) {
// Have Drupal save the string to the database.
variable_set('block_example_string', $edit['block_example_string']);
}
return;
case 'view': default:
// If $op is "view", then we need to generate the block for display
// purposes. The $delta parameter tells us which block is being requested.
switch ($delta) {
case 0:
// The subject is displayed at the top of the block. Note that it
// should be passed through t() for translation.
$block['subject'] = t(' ');
// The content of the block is typically generated by calling a custom
// function.
$block['content'] = search_tours_block_contents(1);
}
return $block;
}
}
function search_tours_block_contents($which_block) {
global $base_url;
$search_tours = '


';
return variable_get('block_search_tours',t($search_tours));
}
function search_tours() {
$value = $_POST['searchkey'];
$count_answers = db_result(db_query("select count(*) from node where title like ('" .$value . "%') and type = 'tour' "));
if($count_answers == '0')
{
$html = '
- No Result for '. $value.'
- field_tourname_nid.'">'.$row_search_tours->title.'
'.$row_search_tours->field_duration_value.' Days
- ';
}
else
{
$search_tours = "SELECT * FROM content_type_tour AS t1 INNER JOIN content_type_tourpricing AS t2 ON t1.nid = t2.field_tourname_nid inner join node as t3 on t1.nid = t3.nid where title like ('" .$value . "%')";
$result_search_tours = db_query($search_tours);
$html .= '
- ';
while ($row_search_tours = db_fetch_object( $result_search_tours)) {
$html .= '
';
}
$html .= '
';
}
return drupal_json(array('request' => 'valid', 'result'=>'false' , "html"=>$html ));
}
Comments
Hello:
I notice that you posted your issue some time back.
Please be aware that you posted your topic
in the 'Deprecated' (no longer used) section of the forums.
That is likely why you never got any replies.
If you still need help, "Post new Forum topic" on page...
'Post Installation' - http://drupal.org/forum/22
- Chris
Drupal 8 is great.
###