| 1 |
<?php
|
| 2 |
// $Id: $
|
| 3 |
|
| 4 |
/********************************************************************
|
| 5 |
* Drupal Hooks
|
| 6 |
********************************************************************/
|
| 7 |
|
| 8 |
/**
|
| 9 |
* Implementation of hook_perm().
|
| 10 |
*/
|
| 11 |
function skiresort_perm() {
|
| 12 |
return array('create ski resort', 'edit own business');
|
| 13 |
}
|
| 14 |
|
| 15 |
/**
|
| 16 |
* Implementation of hook_access().
|
| 17 |
*/
|
| 18 |
function skiresort_access($op, $node) {
|
| 19 |
global $user;
|
| 20 |
|
| 21 |
if ($op == 'create') {
|
| 22 |
return user_access('create ski resort');
|
| 23 |
}
|
| 24 |
|
| 25 |
if ($op == 'update' || $op == 'delete') {
|
| 26 |
if (user_access('edit own business') && ($user->uid == $node->uid)) {
|
| 27 |
return TRUE;
|
| 28 |
}
|
| 29 |
}
|
| 30 |
}
|
| 31 |
|
| 32 |
/**
|
| 33 |
* Implementation of hook_businessapi() from business_module.
|
| 34 |
*/
|
| 35 |
function skiresort_businessapi(&$node, $op, $a3 = null, $a4 = null) {
|
| 36 |
switch ($op) {
|
| 37 |
case 'type':
|
| 38 |
return array('ptype' => 'skiresort');
|
| 39 |
case 'wizard_select':
|
| 40 |
return array('skiresort' => t('Ski resort'));
|
| 41 |
case 'ammenities':
|
| 42 |
return array('skiresort' => t('Ski resort'));
|
| 43 |
case 'allowed_activities':
|
| 44 |
return array("lifticket" => "liftticket", "lessons" => "lessons", "skirental" => "skirental");
|
| 45 |
case 'form':
|
| 46 |
$form['ammenities'] = array(
|
| 47 |
'#type' => 'fieldset',
|
| 48 |
'#title' => t('Skiresort amenitites'),
|
| 49 |
'#tree' => true,
|
| 50 |
);
|
| 51 |
//generate
|
| 52 |
$result = db_query("SELECT a.description,a.aid,a.helptext FROM {business_ammenities} a JOIN {business_ammenities_ptype} p ON p.aid = a.aid WHERE p.ptype = '%s'",$node->ptype);
|
| 53 |
while($ammenity = db_fetch_object($result)){
|
| 54 |
$form['ammenities']['ammenity-'.$ammenity->aid] = array(
|
| 55 |
'#type' => 'checkbox',
|
| 56 |
'#title' => $ammenity->description,
|
| 57 |
'#return_value' => true,
|
| 58 |
'#default_value' => $node->ammenties[$ammenity->aid],
|
| 59 |
'#description' => $ammenity->helptext,
|
| 60 |
'#attributes' => NULL,
|
| 61 |
'#required' => FALSE,
|
| 62 |
);
|
| 63 |
}
|
| 64 |
return $form;
|
| 65 |
}
|
| 66 |
}
|
| 67 |
|
| 68 |
function theme_skiresort_view($node, $teaser = 0, $page = 0) {
|
| 69 |
$output .= '<div class="details">';
|
| 70 |
if($node->ammenties){
|
| 71 |
foreach($node->ammenties as $ammenity){
|
| 72 |
$facilities .= '<li>'.$ammenity.'</li>';
|
| 73 |
}
|
| 74 |
$output .= '<div class="special"><h4>'.t('Special features').'</h4><ul class="hotel">'.$facilities.'</ul></div>';
|
| 75 |
}
|
| 76 |
return $output. '</div>';
|
| 77 |
}
|