2012-05-30 2 views
0

이것은 내 첫 번째 모듈입니다. 나는 일주일이 지난 지금부터 나의 모듈을 성공적으로 설치하려고 노력하고있다.드루팔 (Drupal 첫 번째 모듈 - 500 내부 서버 오류

나는 모든 라인을 통과했다. 스키마가 설치되고 시스템 테이블에 항목이 작성됩니다. 하지만 모듈을 활성화 한 후에도 시스템 테이블에서 항목을 삭제할 때까지 500 Internal Server Error가 표시됩니다.

제가 잘못하고있는 것을 안내해주십시오.

참고 : sisattribute 테이블이 이미 드루팔 데이터베이스에 작성됩니다

내 .install 파일

<?php 

/** 
* @file 
*/ 

function sisinstitute_install() { 
drupal_install_schema('sisinstitute'); 
variable_set('node_options_sisinstitute', array('status')); 

$attributes = array(); 

$attributes['Country'] = array(
    'US' => 'United States of America', 
    'AD' => 'Andorra', 
    'AE' => 'United Arab Emirates', 
    'AF' => 'Afghanistan', 
); 

$s = "INSERT INTO {sisattribute} (domain, akey, avalue, weight) VALUES ('%s', '%s', '%s', %d)"; 
$prevdomain = ''; 
$weight = 0; 
foreach ($attributes as $domain => $attribute) { 
if ($domain != $prevdomain) $weight=0; 
foreach ($attribute as $key => $value) { 
    db_query($s, $domain, $key, $value, $weight); 
    $weight++; 
} 
$prevdomain = $domain; 
} 
} 

function sisinstitute_disable() { 
drupal_set_message(t('Please note that they will now have reduced functionality, and will not be protected by previous access controls.'), 'warning'); 
} 

function sisinstitute_uninstall() { 
drupal_uninstall_schema('sisinstitute'); 

db_query($s = "DELETE FROM {sisattribute} WHERE domain IN ('Country')"); 
} 

function sisinstitute_schema() { 
    $schema['sisinstitute'] = array(
    'fields'  => array(
    'vid'   => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 
    'nid'   => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 
    'country'  => array('type' => 'varchar', 'length' => 100), 
    'www'   => array('type' => 'varchar', 'length' => 100), 
    'phone'  => array('type' => 'varchar', 'length' => 100), 
    'email'  => array('type' => 'varchar', 'length' => 50), 
    'provstate' => array('type' => 'varchar', 'length' => 50), 
    'zip'   => array('type' => 'varchar', 'length' => 10), 
    'city'  => array('type' => 'varchar', 'length' => 100), 
    'address'  => array('type' => 'varchar', 'length' => 100), 
    'orglanguage' => array('type' => 'varchar', 'length' => 100), 
    'isactive' => array('type' => 'int', 'default' => 1), 

), 
    'primary key' => array('vid'), 
    'indexes' => array(
    'nid'  => array('nid') 
), 
); 

    return $schema; 
    } 

그리고 내 .module 파일 :

<?php 
// $Id$ 

/** 
*@File 
*Module for Institution support in SIS package 
*/ 


/** 
*hook_help() 
*/ 


/** 
*hook_menu() 
*/ 




/** 
*hook_perm() 
*/ 
function sisinstitute_perm() { 
    return array('access institute', 'create institute', 'edit institute', 'delete institute', 'view belonged institute', 'view all institutes'); 

} 






/** 
*hook_access() 
*/ 
function sisinstitute_access($op, $node. $account=NULL) { 
if (empty($account)) { 
    global $user; 
    $account = $user; 
} 

if (is_numeric($node)) $node = node_load($node); 

if (!isset($account->sisinstitute_nid) && module_exists('sisstudent')) { 
    _sisstudent_load($account); 
} 

if (!isset($account->sisinstitute_nid) && module_exists('sisstaff')) { 
    _sisstaff_load($account); 
} 

switch($op) { 
    case 'create': return user_access('create institute', $account); 
    case 'update': return user_access('edit institute', $account); 
    case 'delete': return user_access('delete institute', $account); 
    case 'view' : { 
        if (user_access('view all institutes', $account)) 
        return TRUE; 
        elseif (user_access('view belonged institute', $account) && $account->sisinstitute_nid == $node->nid) 
        return TRUE; 
        else return FALSE; 
       } 
} 
} 




/** 
*hook_node_info() 
*/ 

function sisinstitute_node_info() { 
return array(
    'sisinstitute' => array(
    'name' => t('Institute'), 
    'module' => 'sisinstitute', 
    'description' => t("Institute for SIS"), 
    'title_label' => t("Name"), 
    'body_label' => t("Note"), 
) 
); 

} 



/** 
*hook_form() 
*/ 
function sisinstitute_form(&$node) { 
$type = node_get_types('type', $node); 

//$form['#attributes']['class'] = 'sismcomponent_node_form'; 

$form['title'] = array(
    '#type' => 'textfield', 
    '#title' => check_plain($type->title_label), 
    '#required' => TRUE, 
    '#default_value' => $node->title, 
    // '#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'title') : -18, 
); 


$form['isactive'] = array(
'#type' => 'checkbox', 
'#title' => t('Active'), 
'#default_value' => $node->isactive, 
); 

return $form; 
} 

답변

0

흠이있어 :-) (8 시간 후)

function sisinstitut e_access ($ op, $ node. $ 계정 = NULL) {

은 $ 노드 후 대신 쉼표 동안 약간의 문법 실수 : 모듈 개발을 시작하기에 축하했다

+0

OMG 있습니다. wsod 및 500 오류를 수정하는 방법은 http://drupal.org/node/158043을 참조하십시오. –