Submitted by masan on
Je suis entrain de créer un module mais dans la page admin aucun effet par rapport au module j'ai activé le module mais en vain.
voici mon code:
<?php
/<strong>
* @file
* submit, view, and manage to-do items and lists
*/
/</strong>
* Implementation of hook_help()
* Display help text for the questionnaire module
*/
function questionnaire_help() {
switch ($section) {
case 'admin/help#questionnaire':
$o .= '<p>' . t('Submit, view and manage questionnaire lists.') . '</p>';
return $o;
case 'admin/modules#description':
return t('Allows users to submit, view and manage to-do items and lists.');
case 'node/add#questionnaire':
return t('Add a task as a to-do item here. You can assign a due date and priority, as desired');
}
}
/<strong>
* Implementation of hook_perm().
* Define the permissions this module uses
*/
function questionnaire_perm() {
return array('create questionnaire items', 'manage own questionnaire items');
}
/</strong>
* Implementation of hook_access().
*/
function questionnaire_access($op, $node) {
global $user;
if ($op == 'create') {
return user_access('create questionnaire items');
}
if ($op == 'update' || $op == 'delete') {
if (user_access('manage own questionnaire items') && ($user->uid == $node->uid)) {
return TRUE;
}
}
}
/<strong>
* Implementation of hook_menu().
*/
function questionnaire_menu($may_cache) {
$items = array();
if ($may_cache) {
$items[] = array('path' => 'node/add/questionnaire', 'title' => t('questionnaire'),
'access' => user_access('create questionnaire items'));
}
return $items;
}
/</strong>
* Implementation of hook_node_info().
* Define the node type
*/
function todo_node_info() {
return array('todo' => array('name' => t('to-do'), 'base' => 'todo'));
}
/<strong>
* Implementation of hook_node_info().
* Define the node type
*/
function questionnaire_form(&$node) {
// summary / title
$form['title'] = array(
'#type' => 'textfield',
'#title' => t('Task'),
'#required' => TRUE,
'#default_value' => $node->title,
'#weight' => -5,
'#description' => t('Task summary')
);
// full description / body
$form['body_filter']['body'] = array(
'#type' => 'textarea',
'#title' => t('Task details'),
'#default_value' => $node->body,
'#rows' => 10,
'#required' => FALSE
);
$form['body_filter']['format'] = filter_form($node->format);
// due date
$form['duedate'] = array(
'#type' => 'textfield',
'#title' => t('Due date'),
'#required' => FALSE,
'#default_value' => $node->duedate,
'#weight' => 0,
'#description' => 'Format dd/mm/yyyy'
);
// priority
$priorities = _questionnaire_priorities();
$form['priority'] = array(
'#type' => 'select',
'#title' => t('Priority'),
'#required' => FALSE,
'#default_value' => $node->priority,
'#options' => $priorities,
'#weight' => 1
);
// current status
$statuses = _questionnaire_status();
$form['taskstatus'] = array(
'#type' => 'select',
'#title' => t('Current status'),
'#required' => TRUE,
'#default_value' => $node->taskstatus,
'#options' => $statuses,
'#weight' => 2
);
return $form;
}
/</strong>
* Return an array of priorities
* @return array of priorities
*/
function _questionnaire_priorities() {
return array('none', 'low', 'medium', 'high');
}
/**
* Return an array of task status
* @return array of statuses
*/
function _questionnaire_status() {
return array(
'unknown',
'not started',
'in progress',
'dependency blocked',
'complete'
);
}
?>
Merci d'avance!!