Submitted by dagodev on
bonjour à tous,
j'aimerai faire un module qui va demander un mot de passe lorsqu'on veut joindre un groupe (OG), c'est à dire: lorsqu'on clique sur les liens "join" ou "joining this group", on demande d'abord un mot de passe.
J'aimerai donc ajouter cette forme lors de l'edit d'un groupe:
/**
* Implementation of hook_form().
*/
function protected_join_form($form_id, &$form) {
// check if this node type should be protected
$form['protected_join'] = array(
'#type' => 'fieldset',
'#description' => t( 'Here if you check the checkbox and provide a password, joining your group will be password protected.' ),
'#title' => t( 'Protect the group' ),
'#collapsible' => TRUE,
'#collapsed' => TRUE
);
$form['protected_join']['is_protected'] = array(
'#type' => 'checkbox',
'#title' => t( 'Node is protected' ),
'#description' => t( 'Check here if joining the group should be protected by a password.' )
);
$form['protected_join']['password'] = array(
'#type' => 'password_confirm',
'#description' => t( 'Enter the password here.' ),
'#size' => 20
);
}
Et lorsque l'utillisateur clique sur "join", j'aimerai afficher:
function protected_join_enterpassword( ) {
if (!isset( $_GET['destination'] )) {
// Illegal call
watchdog( 'protected_join', t( 'Illegal call to /protected-join' ), WATCHDOG_WARN );
drupal_access_denied();
}
$info = variable_get( 'protected_join_info', '' );
$form['protected_join'] = array(
'#value' => check_plain($info),
);
$form['protected_join_enterpassword'] = array(
'#type' => 'fieldset',
'#description' => t( 'The Group you are trying to join is password protected. Please enter password below to proceed.' ),
'#collapsible' => FALSE
);
$form['protected_join_enterpassword']['password'] = array(
'#type' => 'password',
'#title' => t( 'Node password' ),
'#size' => 20
);
$form['protected_join_enterpassword']['submit'] = array(
'#type' => 'submit',
'#value' => t( 'OK' )
);
return $form;
}
Mais je ne sais pas comment afficher cette forme une fois que le lien "join" est cliqué. Où dois-je mettre dans mon module que lorsque le lien join est cliqué, utilise telle fonction?
pouvez-vous m'aider s'il vous plaît?