-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathform.php
163 lines (113 loc) · 5.72 KB
/
form.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<?php # POL.VirtualPol.com — Copyright (c) 2008 Javier González González <gonzo@virtualpol.com> — MIT License
function polform($action, $pol_form, $submit='Enviar', $submit_disable=false) {
global $pol, $link;
$f .= '<div class="pol_form">
<form action="/accion/'.$action.'" method="post">
<input type="hidden" name="user_ID" value="' . $pol['user_ID'] . '" />
<ol>
';
if ($pol_form) {
foreach($pol_form as $v) {
if (!$v['size']) { $v['size'] = '30'; }
if (!$v['maxlenght']) { $v['maxlength'] = '255'; }
switch ($v['type']) {
case 'hidden':
$f .= '<input type="hidden" name="' . $v['name'] . '" value="' . $v['value'] . '" />' . "\n";
break;
case 'textrico':
$f .= '<li><b>' . $v['nombre'] . ':</b><br />';
//include('inc-functions-accion.php');
$f .= editor_enriquecido($v['name']) . '</li>' . "\n";
break;
case 'text':
$f .= '<li><b>' . $v['nombre'] . ':</b> ' . $v['desc'] . '<br /><input type="' . $v['type'] . '" name="' . $v['name'] . '" size="' . $v['size'] . '" maxlength="' . $v['maxlegth'] . '" /></li>' . "\n";
break;
case 'select_partidos':
$f .= '<li><b>'._('Partidos').':</b><br /><select name="partido"><option value="0">'._('Ninguno').'</option>';
$result = mysql_query_old("SELECT siglas, ID FROM partidos WHERE pais = '".PAIS."' AND estado = 'ok' ORDER BY siglas ASC", $link);
while($row = mysqli_fetch_array($result)){
if ($v['partido'] == strtolower($row['siglas'])) { $selected = ' selected="selected"'; } else { $selected = ''; }
$f .= '<option value="' . $row['ID'] . '"' . $selected . '>' . $row['siglas'] . '</option>';
}
$f .= '</select></li>' . "\n";
break;
case 'select_nivel':
$f .= '<li><b>'._('Nivel de acceso').':</b><br />';
$f .= '<select name="nivel"><option value="1"> 1 '._('Ciudadano').'</option>';
if ($pol['nivel'] > 1) {
$result = sql_old("SELECT nombre, nivel FROM cargos WHERE pais = '".PAIS."' AND asigna != '-1' AND nivel <= '".$pol['nivel']."' ORDER BY nivel ASC", $link);
while($row = r($result)){
if ($nivel_select == $row['nivel']) { $selected = ' selected="selected"'; } else { $selected = ''; }
$f .= '<option value="' . $row['nivel'] . '"' . $selected . '>' . $row['nivel'] . ' ' . $row['nombre'] . '</option>' . "\n";
}
}
$f .= '</select></li>' . "\n";
break;
case 'select_cat':
$f .= '<li><b>'._('Categoría').':</b><br />' . form_select_cat('docs') . '</li>' . "\n";
break;
case 'selectexpire':
$f .= '<li><b>'._('Duración').':</b>.<br />
<select name="expire">
<option value="60">60 '._('segundos').'</option>
<option value="120">2 '._('minutos').'</option>
<option value="300">5 '._('minutos').'</option>
<option value="600">10 '._('minutos').'</option>
<option value="900">15 '._('minutos').'</option>
<option value="1800">30 '._('minutos').'</option>
<option value="3600">60 '._('minutos').'</option>
<option value="18000">5 '._('horas').'</option>
<option value="86400">24 '._('horas').'</option>
<option value="259200">3 '._('días').'</option>
<option value="518400">6 '._('días').'</option>
<option value="777600">9 '._('días').'</option>
</select></li>' . "\n";
break;
}
}
}
if ($submit_disable == true) { $submit_disable = ' disabled="disabled"'; }
$f .= '<li><input type="submit" value="' . $submit . '"' . $submit_disable . ' /></li></ol></form></div>';
return $f;
}
switch ($_GET[1]) {
case 'crear-documento':
echo '<p>Formulario para crear un nuevo documento en '.PAIS.'.</p>';
$pol_form = array(
array('type'=>'select_cat'),
array('type'=>'hidden', 'name'=>'acceso_leer', 'value'=>'ciudadanos'),
array('type'=>'hidden', 'name'=>'acceso_escribir', 'value'=>'privado'),
array('type'=>'hidden', 'name'=>'acceso_cfg_leer', 'value'=>''),
array('type'=>'hidden', 'name'=>'acceso_cfg_escribir', 'value'=>strtolower($pol['nick'])),
array('type'=>'text', 'name'=>'title', 'size'=>'60', 'maxlegth'=>'200', 'nombre'=>'Título', 'desc'=>'Frase única a modo de titular del documento.'),
array('type'=>'hidden', 'name'=>'text', 'value'=>''),
);
echo polform($_GET[1], $pol_form, _('Crear documento'));
break;
case 'solicitar-ciudadania': redirect('/registrar'); break;
case 'afiliarse':
echo '<p>'._('Afiliación').' '._('partidos').':</p>';
$pol_form = array(
array('type'=>'select_partidos', 'partido'=>$_GET[2]),
);
if ($pol['config']['elecciones_estado'] == 'elecciones') { $submit_disable = true; } else { $submit_disable = false; }
echo polform($_GET[1], $pol_form, 'Afiliarse', $submit_disable);
break;
case 'crear-partido':
$partido = "";
$result = sql_old("SELECT ID, siglas, nombre FROM partidos WHERE pais = '".PAIS."' AND ID_presidente = '".$pol['user_ID']."'");
while($r = r($result)){ $partido = crear_link($r['siglas'], 'partido');}
if ($partido == ""){
echo '<h2>'._('Crear partido').':</h2>';
$pol_form = array(
array('type'=>'text', 'name'=>'siglas', 'value'=>'', 'size'=>'6', 'maxlegth'=>'10', 'nombre'=>'Siglas', 'desc'=>'Escribe entre 2 y 10 letras mayúsculas, guion permitido.'),
array('type'=>'text', 'name'=>'nombre', 'value'=>'', 'size'=>'', 'maxlegth'=>'40', 'nombre'=>'Nombre', 'desc'=>'Frase a modo de nombre que concuerda con las siglas anteriormente dadas.'),
array('type'=>'textrico', 'name'=>'descripcion', 'size'=>'10', 'nombre'=>'Introducción'),
);
echo polform($_GET[1], $pol_form, _('Crear partido'));
}
echo '<p><br/>'.('Ya eres presidente de un partido: ').$partido.'</p>';
echo '<a href="/partidos"><b>'._('Volver').'</b></a>';
break;
default: redirect('/');
}