DrupalBin
Submit Code
About
Recent Posts
Fix for Allow HTML in <i> node titles</i> for Drupal 6.x
Template Pre-proccessing
Testing Ubercart donation product
dave's menu screenshot
Code
Modify user profile page theme
Modify user profile page
Fix for Fix for Code
Fix for Code
Code
more
User login
Log in using OpenID:
What is OpenID?
Username:
*
Password:
*
Log in using OpenID
Cancel OpenID login
Create new account
Request new password
Tags
CCK
drupal
fapi
jquery
menu
module
php
simpletest
test
theme
user
views
more tags
Home
›
Code
Fix for Code
View
Fix
Fixes are not saved to the database until you submit.
Summary:
Tags:
Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Show summary in full view
<?php // $Id: $ /** * @file * Client-side UI for management of games. */ /** * Implementation of hook_help(). * * no rellenado aun */ /** * Implementation of hook_perm(). */ function gestion_perm() { return array('alta de partida', 'my buddys activity'); } /** * Implementation of hook_menu(). */ function gestion_menu($may_cache) { $items = array(); if ($may_cache) { $items[] = array( 'path' => 'partida', 'title' => t('alta de partida'), 'access' => user_access('alta de partida'), 'type' => MENU_CALLBACK, 'callback' => 'drupal_get_form', 'callback arguments' => array('alta_form'), 'access' => user_access('alta de partida'), ); $items[] = array( 'path' => 'user/buddy', 'title' => t('my buddys activity'), 'callback' => 'my_buddy_activity', //'callback arguments' => array('user_edit'), 'type' => MENU_LOCAL_TASK, 'access' => user_access('my buddys activity'), ); } return $items; } /* * *Form alta partida * */ function alta_form(){ $form['jugadores'] = array( '#type' => 'fieldset', '#title' => t('alta datos jugadores'), '#collapsible' => TRUE, '#collapsed' => FALSE, ); $form['jugadores']['jugador1'] = array( '#type' => 'fieldset', '#title' => t('datos jugador 1'), '#collapsible' => TRUE, '#collapsed' => FALSE, '#attributes' => array('class' => 'jugador1'), ); $ejercito = array(); $query1 = ("select td.tid, td.name from {term_data} td ,{vocabulary} v WHERE td.vid=v.vid AND v.vid=%d"); $result1 = db_query($query1, 2); while($obj = db_fetch_object($result1)){ $ejercito[$obj->tid] = $obj->name; } $form['jugadores']['jugador1']['ejercito_jugador1'] = array( '#type' => 'select', '#title' => t('ejercito jugador 1'), '#options' => $ejercito, '#required' => TRUE, ); $jugador = array(); $query = ("select u.uid, u.name from {users} u ,{users_roles} ur WHERE u.uid=ur.uid AND ur.rid=%d"); $result = db_query($query, 3); while($ob = db_fetch_object($result)){ $jugador[$ob->uid] = $ob->name; } $form['jugadores']['jugador1']['jugador1'] = array( '#type' => 'select', '#title' => t('jugador 1'), '#options' => $jugador, '#required' => TRUE, ); $form['jugadores']['jugador2'] = array( '#type' => 'fieldset', '#title' => t('datos jugador 2'), '#collapsible' => TRUE, '#collapsed' => FALSE, '#attributes' => array('class' => 'jugador2'), ); $ejercito = array(); $query1 = ("select td.tid, td.name from {term_data} td ,{vocabulary} v WHERE td.vid=v.vid AND v.vid=%d"); $result1 = db_query($query1, 2); while($obj = db_fetch_object($result1)){ $ejercito[$obj->tid] = $obj->name; } $form['jugadores']['jugador2']['ejercito_jugador2'] = array( '#type' => 'select', '#title' => t('ejercito jugador 2'), '#options' => $ejercito, '#required' => TRUE, ); $jugador = array(); $query = ("select u.uid, u.name from {users} u ,{users_roles} ur WHERE u.uid=ur.uid AND ur.rid=%d"); $result = db_query($query, 3); while($ob = db_fetch_object($result)){ $jugador[$ob->uid] = $ob->name; } $form['jugadores']['jugador2']['jugador2'] = array( '#type' => 'select', '#title' => t('jugador 2'), '#options' => $jugador, '#required' => TRUE, ); $form['jugadores']['resultado'] = array( '#type' => 'fieldset', '#title' => t('resultado de la partida'), '#collapsible' => TRUE, '#collapsed' => FALSE, ); $form['jugadores']['resultado']['jugador1'] = array( '#type' => 'fieldset', '#title' => t('resultado jugador 1'), '#collapsible' => TRUE, '#collapsed' => FALSE, '#attributes' => array('class' => 'resultado1'), ); $form['jugadores']['resultado']['jugador1']['resultado1'] = array( '#type' => 'radios', '#title' => t('resultado'), '#options' => array('0' => 'derrota', '1'=> 'empate', '2'=> 'victoria'), '#attributes' => array('class' => 'jugador1', 'id' => 'resultado1'), '#required' => TRUE, ); $form['jugadores']['resultado']['jugador2'] = array( '#type' => 'fieldset', '#title' => t('resultado jugador 2'), '#collapsible' => TRUE, '#collapsed' => FALSE, '#attributes' => array('class' => 'resultado2'), ); $form['jugadores']['resultado']['jugador2']['resultado2'] = array( '#type' => 'radios', '#title' => t('resultado'), '#options' => array('0' => 'derrota', '1'=> 'empate', '2'=> 'victoria'), '#attributes' => array('class' => 'jugador2', 'id' => 'resultado2'), '#required' => TRUE, ); $form ['tipo'] = array( '#type' => 'fieldset', '#title' => t('Datos de partida'), '#collapsible' => TRUE, '#collapsed' => FALSE, '#attributes' => array('class' => 'tipo'), ); $form['tipo']['miaturas'] = array( '#type' => 'select', '#title' => t('miniaturas'), '#options' => array('0' => '6mm', '1'=> '15mm', '2'=> '20mm', '3'=> '28mm', '4'=>'32mm', '5'=>'54mm', '6' => 'naval', '7' =>'aviación', '8' => 'naves espaciales'), '#attributes' => array('class' => 'miniaturas', 'id' => 'miniaturas'), '#required' => TRUE, ); $form ['tipo']['puntos'] = array ( '#type' => 'select', '#title' => t('Puntos'), '#options' => array('0' => 'escaramuzas (hasta un 25% de los puntos estandar', '1' => 'infiltración (hasta un 50% de los puntos estandar', '2' => 'normal', '3' => 'Grande (el doble de una partida normal)', '4' => 'Gigante (3 veces los puntos normales)', '5' => 'Apocaliptica (4 o más veces los puntos estarndar)',), '#attributes' => array('class' => 'miniaturas', 'id' => 'miniaturas'), '#required' => TRUE, '#description' => t('hay que tener en cuenta que el la media de puntos de la campaña es x, por lo tanto verifica que tipo de partida se ha jugado'), ); $mision = array(); $query = ("select u.uid, u.name from {users} u ,{users_roles} ur WHERE u.uid=ur.uid AND ur.rid=%d"); $result = db_query($query, 3); while($ob = db_fetch_object($result)){ $mision[$ob->uid] = $ob->name; } $form['tipo']['mision'] = array( '#type' => 'select', '#title' => t('Indiqua que misión se ha jugado'), '#default_value' => t('Indiqua que misión se ha jugado'), '#options' => $mision, '#required' => TRUE, ); $teatro = array(); $query = ("select u.uid, u.name from {users} u ,{users_roles} ur WHERE u.uid=ur.uid AND ur.rid=%d"); $result = db_query($query, 3); while($ob = db_fetch_object($result)){ $teatro[$ob->uid] = $ob->name; } $form['tipo']['teatro'] = array( '#type' => 'select', '#title' => t('Indiqua la localización de la partida en la campaña'), '#options' => $teatro, '#required' => TRUE, ); $form['hidden'] = array( '#type' => 'value', '#value' => 'alta' ); $form['submit'] = array( '#type' => 'submit', '#value' => t('Guardar') ); return $form; //echo '<pre>'; //print_r ($form); //echo '</pre>'; } function test_page() { return drupal_get_form('alta_form'); } /* * *Validación de los campos del formulario. * */ function alta_form_validate($form_id, $form_values) { if ( $form_values['jugadores']['resultado']['jugador1'] ['resultado1']['options'] != '1'){ if ($form_values['jugadores']['resultado']['jugador1'] ['resultado1']['options'] == $form_values['jugadores']['resultado']['jugador2'] ['resultado2']['options']) { drupal_set_message('No se puede tener el mismo resultado uno tiene que perder para que el otro gane', 'error' ); } } } /* * *submit de la información. * */ function my_buddy_activity (){ $devolver = 'hello'; return $devolver; } ?>
Syntax highlighting mode:
ActionScript
ColdFusion
Diff
Drupal 5
Drupal 6
HTML
INI
Javascript
MySQL
PHP
Python
robots.txt
SQL
Text
Select the syntax highlighting mode to use.
See Also:
Order
Title:
URL:
-1
0
1
Title:
URL:
-1
0
1
Any links you'd like to have associated with the post (Drupal.org issue, Wikipedia article, etc).
File attachments
Changes made to the attachments are not permanent until you save this post. The first "listed" file will be included in RSS feeds.
Attach new file:
The maximum upload size is
1 MB
. Only files with the following extensions may be uploaded:
jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp
.