PHP - Problema Drupal 7 (Insertando Modulo)

 
Vista:

Problema Drupal 7 (Insertando Modulo)

Publicado por Carlos (7 intervenciones) el 06/03/2012 16:17:55
Hola a Todos, Cuando Voy a la opcion "Mi Cuenta Corriente" de mi pagina web me dice que no tengo una cuenta corriente, y me da la opcion de registrar una llevandome a "Registrar Cuenta Corriente"

es ahi cuando me aparece el siguiente error:


Notice: Undefined index: step in actionForm() (line 21 of C:\Drupal\apps\drupal\htdocs\modules\php\php.module(74) : eval()'d code).


*** LOS CODIGOS SON LOS MISMOS QUE USO EN DRUPAL 5, AHORA ESTOY LLEVANDO TODO A DRUPAL 7


Los codifos son los siguientes:


MI CUENTA CORRIENTE

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
<?php
global $user;
 
function actionForm($form_values = NULL) {
  $form = array(
    '#redirect' => false,
    '#multistep' => true,
    '#prefix' => '<div id="customer-transactions">',
    '#suffix' => '</div>',
  );
  $format = 'Y-m-d H:i';
 
  $date_from_str= date("d-n-Y", strtotime("-3 months"));
  list($d, $m, $y) = split('[/.-]', $date_from_str);
 
  $form['date_from'] = array(
    '#type' => 'date',
    '#title' => t('Fecha emisión desde'),
    '#date_format' => $format,
    '#default_value' => array('year' => $y, 'month' => $m, 'day' => $d),
  );
  $form['date_to'] = array(
    '#type' => 'date',
    '#title' => t('Fecha emisión hasta'),
    '#date_format' => $format,
  );
  $form['service_id'] = array(
    '#type' => 'select',
    '#title' => t('Servicio'),
    '#default_value' => '--Todas--',
    '#options' => array(
      '' => t('--Todos los servicios--'),
      '1' => t('Energia'),
      '2' => t('Agua Potable'),
      '3' => t('Telefono'),
      '4' => t('Apross '),
      '5' => t('Internet'),
      '10' => t('Credito Hipotecario'),
      '25' => t('Premed'),
    ),
);
  $form['submit'] = array('#type' => 'submit', '#value' => t('Buscar'));
  $form['hidden'] = array('#type' => 'value', '#value' => 'is_it_here');
 
  if (isset($form_values)) {
    $form['msg'] = array('#value' => _get_data($form_values));
  }
  else {
    $form['msg'] = array('#value' => _get_data());
  }
  return $form;
}
 
function actionForm_validate($form_id, $form_values) {
/*
  if ($form_values['name'] == '') {
    form_set_error('', t('Debe ingresar un nombre para realizar la búsqueda'));
  }
*/
}
 
function get_correct_date($date_str, $default) {
	if (empty($date_str))
		$date_str = date("Y-m-d", strtotime($default));
	else {
		list($d, $m, $y) = split('[/.-]', $date_str);
		if ( checkdate($m, $d, $y) )
			$date_str = date("Y-m-d", mktime(0, 0, 0, $m, $d, $y));
		else
			$date_str = date("Y-m-d", strtotime($default));
	}
	return $date_str;
}
 
function _get_data($form_values = array()) {
  global $user;
 
  $date_from_str = isset($form_values['date_from'])? implode('-', $form_values['date_from']) : '';
  $date_to_str = isset($form_values['date_to'])? implode('-', $form_values['date_to']) : '';
 
  $date_from=urlencode(get_correct_date($date_from_str, "-3 months"));
  $date_to=urlencode(get_correct_date($date_to_str, "now"));
  $service_id=urlencode($form_values['service_id']);
  $customer_id = $user->customer_id;
 
  $base_api = 'http://200.43.54.146:88/coop-api/';
  $base_api_url = $base_api . 'customer_transactions/byCustomer/';
  $url=$base_api_url .  $customer_id . '/' . $date_from . '/' . $date_to . '/' . $service_id;
 
 
  $result = drupal_http_request($url);
  return $result->data;
}
 
if (!empty($user->customer_id))
  return drupal_get_form('actionForm');
else
  print l('No tiene una cuenta corriente asociada. Haga clic aqui para configurarla', 'reg-cc');
?>



REFISTRAR CUENTA CORRIENTE

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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
<?php
define('WIZARD_IDENTIFYCUSTOMER', 1);
define('WIZARD_ASKQUESTIONS', 2);
define('WIZARD_FINAL_STEP', 3);
global $user;
 
 
function actionForm($form_values = NULL) {
 
  $form = array(
    '#redirect' => false,
    '#multistep' => true,
    '#prefix' => '<div id="user-registration">',
    '#suffix' => '</div>',
  );
 
  if (!isset($form_values)) {
    $step = 1;
  }
  else {
    $step = $form_values['step'] + 1;
  }
 
  $form['step'] = array(
    '#type' => 'hidden',
    '#value' => $step,
  );
 
  $form['msg'] = array(
    '#value' => 'Paso: ' . $step . ' de ' . WIZARD_FINAL_STEP,
    '#prefix' => '<div id="form-step">',
    '#suffix' => '</div>',
  );
 
  switch ($step) {
    case WIZARD_IDENTIFYCUSTOMER:
      $form['title'] = array(
          '#value' => 'Necesitamos conocer su nro. de socio para relacionarlo con su cuenta corriente.',
         '#prefix' => '<div id="form-title">',
         '#suffix' => '</div>',
      );
 
      $form['customer_id'] = array(
        '#type' => 'textfield',
        '#title' => t('Numero de socio'),
        '#size' =>10,
        '#maxlength' => 12,
        '#required' => 1,
      );
      $msg = 'Aceptar';
      $form['submit'] = array( '#type' => 'submit', '#value' => $msg, );
 
    break;
    case WIZARD_ASKQUESTIONS:
      $form['title'] = array(
         '#value' => 'A fin de asegurar su identidad, le pedimos que responda las siguientes preguntas.',
         '#prefix' => '<div id="form-title">',
         '#suffix' => '</div>',
      );
 
      $customer_id  =urlencode($form_values['customer_id']);
      $lastInvoice = _getlastInvoice($customer_id);
 
      $doc = simplexml_load_string($lastInvoice);
      $path= $doc->xpath('//@BillingAccountID');
      $cpe = (string)$path[0];
      $path= $doc->xpath('//@BillNumber');
      $fact= (string)$path[0];
 
      $path= $doc->xpath('//@BillID');
      $cpe_a1 = substr($path[0], 0, 5);
      $fact_a1 = substr($path[0], -5, 5);
      $path= $doc->xpath('//@UtilityID');
      $cpe_a2 = substr($path[0], 0, 5);
      $fact_a2 = strrev(substr($path[0], -5, 5));
      $path= $doc->xpath('//@ServiceDesc');
      $serv = (string)$path[0];
      $path= $doc->xpath('//@DueDate');
      $dueDate= substr($path[0], 0, 10);
 
      $title_q1 = 'Código de pago electrónico del servicio ' . $serv;
      $title_q2 = 'Ultimos digitos del nro. de factura ' . trim($serv) . ', con vencimiento ' . $dueDate;
 
      $q1[0] = $cpe;
      $q1[1] = $cpe_a1;
      $q1[2] = $cpe_a2;
 
      $q2[0] = substr($fact, -5, 5);
      $q2[1] = $fact_a1;
      $q2[2] = $fact_a2;
 
      shuffle($q1);
      shuffle($q2);
 
      $form['cpe'] = array(
      '#type' => 'radios',
      '#options' => array ($q1[0]=> $q1[0], $q1[1] => $q1[1], $q1[2] => $q1[2]),
      '#title' => t($title_q1),
      '#default_value' => '',
      '#required' => 1,
      );
      $form['fact'] = array(
      '#type' => 'radios',
      '#options' => array ($q2[0]=> $q2[0], $q2[1] => $q2[1], $q2[2] => $q2[2]),
      '#title' => t($title_q2),
      '#default_value' => '',
      '#required' => 1,
      );
      $form['customer_id'] = array('#type' => 'hidden', '#value' => $customer_id , );
 
      $msg = 'Aceptar';
      $form['submit'] = array( '#type' => 'submit', '#value' => $msg, );
 
    break;
    case WIZARD_FINAL_STEP:
      $customer_id  =urlencode($form_values['customer_id']);
      $lastInvoice = _getlastInvoice($customer_id);
 
      $doc = simplexml_load_string($lastInvoice);
      $path= $doc->xpath('//@BillingAccountID');
      $cpe = (string)$path[0];
      $path= $doc->xpath('//@BillNumber');
      $fact= (string)$path[0];
      $fact = substr($fact, -5, 5);
 
      if ($cpe == $form_values['cpe'] && $fact == $form_values['fact']) {
        global $user;
        $extra_data = array('customer_id' => $customer_id);
        user_save($user, $extra_data);
//        user_multiple_role_edit($user->uid, 'add_role', 3);
 
        $notify = 'Completó con éxito la registración.';
        $msg = 'Ir a mi cuenta corriente';
        define('WIZARD_FINISH_REDIRECT', 'cc');
        $form['rd'] = array('#type' => 'hidden', '#value' => 'cc', );
      } else {
        $notify = 'No se pudo comprobar su identidad.';
        $msg = 'Finalizar';
        define('WIZARD_FINISH_REDIRECT', 'user');
        $form['rd'] = array('#type' => 'hidden', '#value' => 'user', );
      }
        $form['title'] = array(
           '#value' => $notify,
           '#prefix' => '<div id="form-title">',
           '#suffix' => '</div>',
        );
        $form['submit'] = array( '#type' => 'submit', '#value' => $msg, );
    break;
}
  ($step == WIZARD_FINAL_STEP)? $form['#redirect'] = NULL : $form['#redirect'] = FALSE;
 
return $form;
}
 
function actionForm_submit($form_id, $form_values) {
  return WIZARD_FINISH_REDIRECT;
}
 
function actionForm_validate($form_id, $form_values) {
  $step = $form_values['step'] ;
  switch ($step) {
    case WIZARD_IDENTIFYCUSTOMER:
      if (!ctype_digit($form_values['customer_id'])) {
        form_set_error('', t('Debe ingresar nro. de socio'));
      }
    break;
  }
 
  return;
}
 
function _getlastInvoice($customer_id) {
  global $user;
 
  $base_api = 'http://200.43.54.146:88/coop-api/';
  $base_api_url = $base_api . 'CustomerTransactions/lastInvoice/';
  $url=$base_api_url .  $customer_id;
 
  $result = drupal_http_request($url);
  return $result->data;
}
/*
$dest = drupal_get_destination();
if (!$user->uid) {
      drupal_goto('user/login',$dest);
}
*/
 
if (empty($user->customer_id))
  return drupal_get_form('actionForm');
else
  drupal_goto('cc');
 
?>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

Problema Drupal 7 (Insertando Modulo)

Publicado por Carlos (7 intervenciones) el 06/03/2012 16:18:46
PHP.MODULE


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
<?php
 
/**
 * @file
 * Additional filter for PHP input.
 */
 
/**
 * Implements hook_help().
 */
function php_help($path, $arg) {
  switch ($path) {
    case 'admin/help#php':
      $output = '';
      $output .= '<h3>' . t('About') . '</h3>';
      $output .= '<p>' . t('The PHP filter module adds a PHP filter to your site, for use with <a href="@filter">text formats</a>. This filter adds the ability to execute PHP code in any text field that uses a text format (such as the body of a content item or the text of a comment). <a href="@php-net">PHP</a> is a general-purpose scripting language widely-used for web development, and is the language with which Drupal has been developed. For more information, see the online handbook entry for the <a href="@php">PHP filter module</a>.', array('@filter' => url('admin/help/filter'), '@php-net' => 'http://www.php.net', '@php' => 'http://drupal.org/handbook/modules/php/')) . '</p>';
      $output .= '<h3>' . t('Uses') . '</h3>';
      $output .= '<dl>';
      $output .= '<dt>' . t('Enabling execution of PHP in text fields') . '</dt>';
      $output .= '<dd>' . t('The PHP filter module allows users with the proper permissions to include custom PHP code that will get executed when pages of your site are processed. While this is a powerful and flexible feature if used by a trusted user with PHP experience, it is a significant and dangerous security risk in the hands of a malicious or inexperienced user. Even a trusted user may accidentally compromise the site by entering malformed or incorrect PHP code. Only the most trusted users should be granted permission to use the PHP filter, and all PHP code added through the PHP filter should be carefully examined before use. <a href="@php-snippets">Example PHP snippets</a> can be found on Drupal.org.', array('@php-snippets' => url('http://drupal.org/handbook/customization/php-snippets'))) . '</dd>';
      $output .= '</dl>';
      return $output;
  }
}
 
/**
 * Implements hook_permission().
 */
function php_permission() {
  return array(
    'use PHP for settings' => array(
      'title' => t('Use PHP for settings'),
      'restrict access' => TRUE,
    ),
  );
}
 
/**
 * Evaluate a string of PHP code.
 *
 * This is a wrapper around PHP's eval(). It uses output buffering to capture both
 * returned and printed text. Unlike eval(), we require code to be surrounded by
 * <?php ?> tags; in other words, we evaluate the code as if it were a stand-alone
 * PHP file.
 *
 * Using this wrapper also ensures that the PHP code which is evaluated can not
 * overwrite any variables in the calling code, unlike a regular eval() call.
 *
 * @param $code
 *   The code to evaluate.
 * @return
 *   A string containing the printed output of the code, followed by the returned
 *   output of the code.
 *
 * @ingroup php_wrappers
 */
function php_eval($code) {
  global $theme_path, $theme_info, $conf;

  // Store current theme path.
  $old_theme_path = $theme_path;

  // Restore theme_path to the theme, as long as php_eval() executes,
  // so code evaluated will not see the caller module as the current theme.
  // If theme info is not initialized get the path from theme_default.
  if (!isset($theme_info)) {
    $theme_path = drupal_get_path('theme', $conf['theme_default']);
  }
  else {
    $theme_path = dirname($theme_info->filename);
  }

  ob_start();
  print eval('?>' . $code);
  $output = ob_get_contents();
  ob_end_clean();

  // Recover original theme path.
  $theme_path = $old_theme_path;

  return $output;
}

/**
 * Tips callback for php filter.
 */
function _php_filter_tips($filter, $format, $long = FALSE) {
  global $base_url;
  if ($long) {
    $output = '<h4>' . t('Using custom PHP code') . '</h4>';
    $output .= '<p>' . t('Custom PHP code may be embedded in some types of site content, including posts and blocks. While embedding PHP code inside a post or block is a powerful and flexible feature when used by a trusted user with PHP experience, it is a significant and dangerous security risk when used improperly. Even a small mistake when posting PHP code may accidentally compromise your site.') . '</p>';
    $output .= '<p>' . t('If you are unfamiliar with PHP, SQL, or Drupal, avoid using custom PHP code within posts. Experimenting with PHP may corrupt your database, render your site inoperable, or significantly compromise security.') . '</p>';
    $output .= '<p>' . t('Notes:') . '</p>';
    $output .= '<ul><li>' . t('Remember to double-check each line for syntax and logic errors <strong>before</strong> saving.') . '</li>';
    $output .= '<li>' . t('Statements must be correctly terminated with semicolons.') . '</li>';
    $output .= '<li>' . t('Global variables used within your PHP code retain their values after your script executes.') . '</li>';
    $output .= '<li>' . t('<code>register_globals</code> is <strong>turned off</strong>. If you need to use forms, understand and use the functions in <a href="@formapi">the Drupal Form API</a>.', array('@formapi' => url('http://api.drupal.org/api/group/form_api/7'))) . '</li>';
    $output .= '<li>' . t('Use a <code>print</code> or <code>return</code> statement in your code to output content.') . '</li>';
    $output .= '<li>' . t('Develop and test your PHP code using a separate test script and sample database before deploying on a production site.') . '</li>';
    $output .= '<li>' . t('Consider including your custom PHP code within a site-specific module or <code>template.php</code> file rather than embedding it directly into a post or block.') . '</li>';
    $output .= '<li>' . t('Be aware that the ability to embed PHP code within content is provided by the PHP Filter module. If this module is disabled or deleted, then blocks and posts with embedded PHP may display, rather than execute, the PHP code.') . '</li></ul>';
    $output .= '<p>' . t('A basic example: <em>Creating a "Welcome" block that greets visitors with a simple message.</em>') . '</p>';
    $output .= '<ul><li>' . t('<p>Add a custom block to your site, named "Welcome" . With its text format set to "PHP code" (or another format supporting PHP input), add the following in the Block body:</p>
<pre>
print t(\'Welcome visitor! Thank you for visiting.\');
</pre>') . '</li>';
    $output .= '<li>' . t('<p>To display the name of a registered user, use this instead:</p>
<pre>
global $user;
if ($user->uid) {
  print t(\'Welcome @name! Thank you for visiting.\', array(\'@name\' => format_username($user)));
}
else {
  print t(\'Welcome visitor! Thank you for visiting.\');
}
</pre>') . '</li></ul>';
    $output .= '<p>' . t('<a href="@drupal">Drupal.org</a> offers <a href="@php-snippets">some example PHP snippets</a>, or you can create your own with some PHP experience and knowledge of the Drupal system.', array('@drupal' => url('http://drupal.org'), '@php-snippets' => url('http://drupal.org/handbook/customization/php-snippets'))) . '</p>';
    return $output;
  }
  else {
    return t('You may post PHP code. You should include &lt;?php ?&gt; tags.');
  }
}

/**
 * Implements hook_filter_info().
 *
 * Provide PHP code filter. Use with care.
 */
function php_filter_info() {
  $filters['php_code'] = array(
    'title' => t('PHP evaluator'),
    'description' => t('Executes a piece of PHP code. The usage of this filter should be restricted to administrators only!'),
    'process callback' => 'php_eval',
    'tips callback' => '_php_filter_tips',
    'cache' => FALSE,
  );
  return $filters;
}
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar