Cimy User Extra Fields - Version 1.4.0

Version Description

Download this release

Release Info

Developer Cimmo
Plugin Icon wp plugin Cimy User Extra Fields
Version 1.4.0
Comparing to
See all releases

Code changes from version 1.3.2 to 1.4.0

README_OFFICIAL.txt CHANGED
@@ -11,8 +11,13 @@ The plug-in adds two new menu voices in the admin for the administrator and two
11
 
12
  Two new menus are:
13
 
14
- * "Users-> A&U Extended" lets you show users lists with the new fields that are created
15
- * "Options-> Cimy User Extra Fields" lets administrators add as many new fields as are needed to the users' profile, giving the possibility to set some interesting rules.
 
 
 
 
 
16
 
17
  Rules are:
18
 
@@ -76,22 +81,22 @@ Bugs or suggestions can be mailed at: cimmino.marco@gmail.com
76
 
77
  REQUIREMENTS:
78
  PHP >= 5.0.0
79
- WORDPRESS >= 2.5.x
80
- WORDPRESS MU - NOT SUPPORTED
81
  MYSQL >= 4.0
82
 
83
  INSTALLATION:
84
- - just copy whole Cimy_User_Extra_Fields subdir into your plug-in directory and activate it
 
85
 
86
  UPDATE FROM A PREVIOUS VERSION:
87
- - always deactivate the plug-in and reactivate after the update
88
 
89
 
90
  FUNCTIONS USEFUL FOR YOUR THEMES OR TEMPLATES:
91
 
92
  [Function get_cimyFieldValue]
93
- NOTE 1: to use this function first you have to enable it via options page.
94
- NOTE 2: password fields values will not be returned for security reasons
95
 
96
  USAGE:
97
  $value = get_cimyFieldValue($user_id, $field_name, [$field_value]);
@@ -145,6 +150,7 @@ EXAMPLE:
145
  $values = get_cimyFieldValue(false, 'MY_FIELD');
146
 
147
  foreach ($values as $value) {
 
148
  echo $value['user_login'];
149
  echo cimy_uef_sanitize_content($value['VALUE']);
150
  }
@@ -162,6 +168,7 @@ EXAMPLE:
162
  $values = get_cimyFieldValue(false, 'COLOR', 'red');
163
 
164
  foreach ($values as $value) {
 
165
  echo $value['user_login'];
166
  }
167
 
@@ -182,6 +189,7 @@ EXAMPLE:
182
  $values = get_cimyFieldValue(false, 'WEBSITE', $field_value);
183
 
184
  foreach ($values as $value) {
 
185
  echo $value['user_login'];
186
  }
187
 
@@ -199,6 +207,7 @@ EXAMPLE:
199
  $old_name = "";
200
 
201
  foreach ($values as $value) {
 
202
  $new_name = $value['user_login'];
203
 
204
  if ($old_name != $new_name)
@@ -258,6 +267,7 @@ if (have_posts()) {
258
  }
259
  }
260
 
 
261
  PICTURE AND get_cimyFieldValue FUNCTION:
262
 
263
  If you want to display the image in an HTML page just use IMG object like this:
@@ -281,11 +291,42 @@ where $format is the date and time format, more tags details here:
281
  http://www.php.net/manual/en/function.strftime.php
282
 
283
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
284
  [Function get_cimyFields]
285
- This function returns an array containing all extra fields defined by the admin ordered by the order defined in the option page, if there are no fields an empty array is returned.
 
 
 
 
286
 
287
  USAGE:
288
- $allFields = get_cimyFields();
289
 
290
  EXAMPLE:
291
  $allFields = get_cimyFields();
@@ -336,6 +377,15 @@ KNOWN ISSUES:
336
  - if you add too many fields in the "A&U Extended" menu they will go out of frame
337
  - some rules are applied only during registration (apart editable and visibility rules and max length for text and password fields only)
338
  - registration date cannot be modified
 
 
 
 
 
 
 
 
 
339
 
340
 
341
  FAQ:
@@ -408,6 +458,53 @@ A lot of times I cannot reproduce the problem and I need more details, so if you
408
 
409
 
410
  CHANGELOG:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
411
  v1.3.2 - 11/01/2009
412
  - Added possibility to change/remove Extra Fields section title under user profile
413
  - Fixed bug where options were not correctly migrated for certain versions (introduced with v1.3.0 beta2)
11
 
12
  Two new menus are:
13
 
14
+ WordPress:
15
+ 1. "Users -> A&U Extended" - lets you show users lists with the new fields that are created
16
+ 2. "Settings -> Cimy User Extra Fields" - lets administrators add as many new fields as are needed to the users' profile, giving the possibility to set some interesting rules.
17
+
18
+ Wordpress MU:
19
+ 1. "Site Admin -> Users Extended" - lets you show users lists with the new fields that are created
20
+ 2. "Site Admin -> Cimy User Extra Fields" - lets administrators add as many new fields as are needed to the users' profile, giving the possibility to set some interesting rules.
21
 
22
  Rules are:
23
 
81
 
82
  REQUIREMENTS:
83
  PHP >= 5.0.0
84
+ WORDPRESS >= 2.6.x
85
+ WORDPRESS MU >= 2.6.x
86
  MYSQL >= 4.0
87
 
88
  INSTALLATION:
89
+ - WordPress: just copy whole cimy-user-extra-fields subdir into your plug-in directory and activate it
90
+ - WordPress MU: unpack the package under 'mu-plugins' directory, be sure that cimy_user_extra_fields.php is outside Cimy folder (move it if necessary), then go to "Site Admin -> Cimy User Extra Fields", press "Fix the problem" button and confirm
91
 
92
  UPDATE FROM A PREVIOUS VERSION:
93
+ - go to Cimy User Extra Fields admin options, press "Fix the problem" button and confirm
94
 
95
 
96
  FUNCTIONS USEFUL FOR YOUR THEMES OR TEMPLATES:
97
 
98
  [Function get_cimyFieldValue]
99
+ NOTE: password fields values will not be returned for security reasons
 
100
 
101
  USAGE:
102
  $value = get_cimyFieldValue($user_id, $field_name, [$field_value]);
150
  $values = get_cimyFieldValue(false, 'MY_FIELD');
151
 
152
  foreach ($values as $value) {
153
+ $user_id = $value['user_id'];
154
  echo $value['user_login'];
155
  echo cimy_uef_sanitize_content($value['VALUE']);
156
  }
168
  $values = get_cimyFieldValue(false, 'COLOR', 'red');
169
 
170
  foreach ($values as $value) {
171
+ $user_id = $value['user_id'];
172
  echo $value['user_login'];
173
  }
174
 
189
  $values = get_cimyFieldValue(false, 'WEBSITE', $field_value);
190
 
191
  foreach ($values as $value) {
192
+ $user_id = $value['user_id'];
193
  echo $value['user_login'];
194
  }
195
 
207
  $old_name = "";
208
 
209
  foreach ($values as $value) {
210
+ $user_id = $value['user_id'];
211
  $new_name = $value['user_login'];
212
 
213
  if ($old_name != $new_name)
267
  }
268
  }
269
 
270
+
271
  PICTURE AND get_cimyFieldValue FUNCTION:
272
 
273
  If you want to display the image in an HTML page just use IMG object like this:
291
  http://www.php.net/manual/en/function.strftime.php
292
 
293
 
294
+ [Function cimy_uef_sanitize_content]
295
+ This function protects your blog from users trying to add JavaScript or alter your blog doing HTML injection in extra fields. It is very important that you do not remove that function.
296
+ This function filters only some html tags and let other be used, the list of tags that are allowed is present under /wp-includes/kses.php search for $allowedtags array definition.
297
+
298
+ It can accepts two parameters:
299
+ $content: the content to be protected against HTML injections
300
+ $override_allowed_tags [array|null, default null]: if you want to override allowed tags you should pass a proper array where all your favourite tags are listed.
301
+
302
+ USAGE:
303
+ echo cimy_uef_sanitize_content([$content], [$override_allowed_tags]);
304
+
305
+ EXAMPLE:
306
+ global $allowedtags;
307
+
308
+ // copy the array to not modify the original one
309
+ $my_tags = $allowedtags;
310
+
311
+ // add img tag to allowed tags list
312
+ $my_tags["img"] = array(
313
+ "src" => array(),
314
+ "alt => array(),
315
+ );
316
+
317
+ // $content is what I want to show, see previous examples for more details
318
+ echo cimy_uef_sanitize_content($content, $my_tags);
319
+
320
+
321
  [Function get_cimyFields]
322
+ This function returns an array containing all extra fields defined by the admin ordered by the order defined in the admin page, if there are no fields an empty array is returned.
323
+
324
+ It can accepts two parameters:
325
+ $wp_fields [true|false, default false]: if true will return hidden WordPress fields enabled
326
+ $order_by_section [true|false, default false]: if true array returned will be ordered as first key by fieldset and as second key by order; this parameter can be applied only if the first one is set to false.
327
 
328
  USAGE:
329
+ $allFields = get_cimyFields([$wp_fields], [$order_by_section]);
330
 
331
  EXAMPLE:
332
  $allFields = get_cimyFields();
377
  - if you add too many fields in the "A&U Extended" menu they will go out of frame
378
  - some rules are applied only during registration (apart editable and visibility rules and max length for text and password fields only)
379
  - registration date cannot be modified
380
+ - using WordPress password to let user customize its password works, but has one issue:
381
+ - on WordPress email received will contain wrong password (generated by WordPress), this due to WordPress limitation
382
+ - on WordPress MU email received and activation page contain correct password, no issues!
383
+ - picture and avatar upload is disabled during registration under WordPress MU, will be possible once user is activated
384
+ - if you change order or remove fieldsets you may need to set all extra fields' fieldset assigment again
385
+ - dropdown issues:
386
+ - multiple choices dropdown are not supported
387
+ - custom value is not supported
388
+ - comma is not allowed as it is the delimiter
389
 
390
 
391
  FAQ:
458
 
459
 
460
  CHANGELOG:
461
+ v1.4.0 - 18/03/2009
462
+ - Added user_id in the array returned by get_cimyFieldValue function
463
+ - Added regular expression to equalTo rule for text, textarea, textarea-rich, password, dropdown (thanks to Shane Hartman for the patch)
464
+ - Fixed (again) textarea-rich under user registration page, hopefully now it works for everyone (thanx to Romain Bordessoul)
465
+ - Fixed some error messages weren't displayed under WordPress MU registration page (thanx to Nicolene Heunis for the patch)
466
+ - Readme file updated
467
+
468
+ v1.4.0 release candidate 1 - 24/02/2009
469
+ - Added picture/avatar directory check under options
470
+ - Added second parameter to cimy_uef_sanitize_content to let override allowed tags
471
+ - Fixed translation under WordPress MU (workaround)
472
+ - Fixed wrong password shown on WordPress MU activation page when using password personalization (thanx to Leo Kimble and Andrew Billits)
473
+ - Fixed dropdown not working if new lines were added to the list
474
+ - Renamed plug-in directory due to WordPress Plugin Directory rules
475
+ - Readme file updated
476
+
477
+ v1.4.0 beta3 - 08/02/2009
478
+ - Added possibility to set a custom fieldset per each extra fields
479
+ - Added fieldset to registration page
480
+ - Fixed data not saved into extra fields for some MYSQL configurations (thanx to Daniel Quinn)
481
+ - Fixed PHP error on comments when using avatar extra field (thanx to Serge Hardmeier)
482
+ - Fixed picture/avatar path were written even if upload failed
483
+ - Fixed password always overwritten in the WordPress MU welcome email
484
+ - Moved and renamed A&U Extended page under WordPress MU
485
+ - Disabled picture and avatar fields under WordPress MU registration page
486
+ - Removed deprecated "items per fieldset" option
487
+ - Readme file updated
488
+ - Updated Italian translation
489
+ - Updated German translation (Franz Josef)
490
+ - Code cleanup
491
+
492
+ v1.4.0 beta2 - 21/01/2009
493
+ - WordPress MU fixes:
494
+ - Fixed Extra Fields not saved under registration
495
+ - Fixed WordPress hidden fields not saved under registration
496
+ - Fixed PHP error when at least one WordPress hidden field is present under registration
497
+ - Fixed endless registration if there is at least one error due to rules in Extra Fields
498
+ - Fixed notification email is filtered in case password is chosen by the user
499
+
500
+ v1.4.0 beta1 - 19/01/2009
501
+ - Added WordPress MU 2.5.x & 2.6.x support
502
+ - Added a button to fix missing/pending update of tables/options
503
+ - Fixed PHP error when deleting an user on certain installations (thanx to jarred)
504
+ - Fixed PHP error when options are not present
505
+ - Fixed Extra Fields filter (introduced with v1.3.0 beta1)
506
+ - Readme file updated
507
+
508
  v1.3.2 - 11/01/2009
509
  - Added possibility to change/remove Extra Fields section title under user profile
510
  - Fixed bug where options were not correctly migrated for certain versions (introduced with v1.3.0 beta2)
cimy_uef_admin.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  function cimy_admin_define_extra_fields() {
4
- global $wpdb, $wpdb_fields_table, $wpdb_wp_fields_table, $rule_canbeempty, $rule_email, $rule_maxlen, $rule_maxlen_needed, $available_types, $max_length_name, $max_length_label, $max_length_desc, $max_length_value, $max_size_file, $rule_equalto, $rule_equalto_case_sensitive, $cimy_uef_domain, $is_mu, $cuef_plugin_path, $cimy_uef_file_types;
5
 
6
  if (!cimy_check_admin('manage_options'))
7
  return;
@@ -202,6 +202,7 @@ function cimy_admin_define_extra_fields() {
202
  $name = strtoupper($name);
203
  $oldname = strtoupper(stripslashes($_POST['oldname'.$field_order]));
204
  $type = $_POST['type'.$field_order];
 
205
 
206
  $minlen = $_POST['minlen'.$field_order];
207
  $exactlen = $_POST['exactlen'.$field_order];
@@ -247,6 +248,8 @@ function cimy_admin_define_extra_fields() {
247
  $store_rule['equal_to'] = stripslashes($_POST['equalto'.$field_order]);
248
 
249
  $equalto_casesens = $_POST['equalto_casesens'.$field_order];
 
 
250
  }
251
 
252
  $show_in_reg = $_POST['show_in_reg'.$field_order];
@@ -316,6 +319,11 @@ function cimy_admin_define_extra_fields() {
316
  $store_rule['equal_to_case_sensitive'] = true;
317
  else
318
  $store_rule['equal_to_case_sensitive'] = false;
 
 
 
 
 
319
  }
320
 
321
  if (($value != "") && (strtoupper($value) != "YES") && (strtoupper($value) != "NO")) {
@@ -326,6 +334,13 @@ function cimy_admin_define_extra_fields() {
326
  $errors['value'] = __("With radio type Value can only be", $cimy_uef_domain).": [Yes, No]";
327
  }
328
 
 
 
 
 
 
 
 
329
  // IF THERE ARE NO ERRORS THEN GO ON
330
  if (count($errors) == 0) {
331
  $exist = array();
@@ -368,6 +383,7 @@ function cimy_admin_define_extra_fields() {
368
  $data['store_rule'] = $store_rule;
369
  $data['field_order'] = $field_order;
370
  $data['num_fields'] = $num_fields;
 
371
 
372
  cimy_save_field($action, $fields_table, $data);
373
 
@@ -523,6 +539,11 @@ function cimy_admin_define_extra_fields() {
523
  else
524
  $selected_input["equal_to_case_sensitive"] = '';
525
 
 
 
 
 
 
526
  // CHECK EMAIL SYNTAX
527
  if ($store_rule['email'] == true)
528
  $selected_input["email"] = ' checked="checked"';
@@ -607,6 +628,10 @@ function cimy_admin_define_extra_fields() {
607
  ?>
608
  </select>
609
  </label>
 
 
 
 
610
  </td>
611
  <td style="vertical-align: middle;">
612
  <label><strong><?php _e("Label", $cimy_uef_domain); ?></strong><br /><textarea name="label" rows="2" cols="18"><?php echo $selected_input["label"]; ?></textarea></label><br /><br />
@@ -638,9 +663,12 @@ function cimy_admin_define_extra_fields() {
638
  </select>
639
  <br />
640
  <!-- EQUAL TO -->
641
- <input type="checkbox" name="equal" value="1"<?php echo $selected_input["equal"]; ?> /> <?php _e("Should be equal TO", $cimy_uef_domain); ?>: <input type="text" name="equalto" maxlength="50" value="<?php echo $selected_input["equal_to"]; ?>"/><br />
642
  <!-- CASE SENSITIVE -->
643
  &nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="equalto_casesens" value="1"<?php echo $selected_input["equal_to_case_sensitive"]; ?> /> <?php _e("Case sensitive", $cimy_uef_domain); ?><br />
 
 
 
644
 
645
  <!-- SHOW IN REGISTRATION -->
646
  <input type="checkbox" name="show_in_reg" value="1"<?php echo $selected_input["show_in_reg"]; ?> /> <?php _e("Show the field in the registration", $cimy_uef_domain); ?><br />
@@ -674,7 +702,7 @@ function cimy_admin_define_extra_fields() {
674
  }
675
 
676
  function cimy_admin_show_extra_fields($allFields, $submit_msgs, $wp_fields) {
677
- global $cimy_uef_domain, $rule_maxlen, $rule_email, $rule_canbeempty, $rule_equalto, $rule_equalto_case_sensitive, $available_types, $max_length_name, $max_length_label, $max_length_desc, $max_length_value, $max_size_file, $cimy_uef_file_types;
678
 
679
  if (!cimy_check_admin("manage_options"))
680
  return;
@@ -683,11 +711,13 @@ function cimy_admin_show_extra_fields($allFields, $submit_msgs, $wp_fields) {
683
  return;
684
 
685
  if ($wp_fields) {
 
686
  $disable_it = ' disabled="disabled"';
687
  $div_id = "wp_extrafields";
688
  $form_id = "form_wp_fields";
689
  }
690
  else {
 
691
  $div_id = "extrafields";
692
  $form_id = "form_extra_fields";
693
  $disable_it = '';
@@ -759,6 +789,7 @@ function cimy_admin_show_extra_fields($allFields, $submit_msgs, $wp_fields) {
759
  $label = attribute_escape($field['LABEL']);
760
  $type = $field['TYPE'];
761
  $rules = $field['RULES'];
 
762
 
763
  $text = "";
764
  $checkbox = "";
@@ -769,6 +800,7 @@ function cimy_admin_show_extra_fields($allFields, $submit_msgs, $wp_fields) {
769
  $dis_checkemail = "";
770
  $dis_equalto = "";
771
  $dis_equalto_casesens = "";
 
772
  $dis_value = "";
773
 
774
  // disable rules for certain fields
@@ -787,6 +819,9 @@ function cimy_admin_show_extra_fields($allFields, $submit_msgs, $wp_fields) {
787
  if (!in_array($type, $rule_equalto_case_sensitive))
788
  $dis_equalto_casesens = ' disabled="disabled"';
789
 
 
 
 
790
  // set selected type for every field
791
  $selected_type[$type] = ' selected="selected"';
792
 
@@ -861,11 +896,15 @@ function cimy_admin_show_extra_fields($allFields, $submit_msgs, $wp_fields) {
861
 
862
  if ($rules['equal_to_case_sensitive'])
863
  $equalto_casesens = ' checked="checked"';
 
 
 
864
  }
865
  else {
866
  $equal = "";
867
  $equalTo = "";
868
  $equalto_casesens = "";
 
869
  }
870
 
871
  $equalTo = attribute_escape($equalTo);
@@ -875,6 +914,13 @@ function cimy_admin_show_extra_fields($allFields, $submit_msgs, $wp_fields) {
875
  else
876
  $show_in_reg = "";
877
 
 
 
 
 
 
 
 
878
  if ($rules['show_in_profile'])
879
  $show_in_profile = ' checked="checked"';
880
  else
@@ -904,7 +950,7 @@ function cimy_admin_show_extra_fields($allFields, $submit_msgs, $wp_fields) {
904
  $style = ('class="alternate"' == $style) ? '' : 'class="alternate"';
905
  ?>
906
 
907
- <tr <?php echo $style; ?>>
908
  <td align="center" style="vertical-align: middle;">
909
  <input name="check<?php echo $order ?>" type="checkbox" value="1" /><br /><br />
910
  <label><strong><?php _e("Order", $cimy_uef_domain); ?></strong><br />
@@ -938,6 +984,13 @@ function cimy_admin_show_extra_fields($allFields, $submit_msgs, $wp_fields) {
938
  ?>
939
  </select>
940
  </label>
 
 
 
 
 
 
 
941
  </td>
942
  <td style="vertical-align: middle;">
943
  <label><strong><?php _e("Label", $cimy_uef_domain); ?></strong><br />
@@ -970,9 +1023,11 @@ function cimy_admin_show_extra_fields($allFields, $submit_msgs, $wp_fields) {
970
  <br />
971
 
972
  <!-- EQUAL TO -->
973
- <input type="checkbox" name="equal<?php echo $order ?>" value="1"<?php echo $equal.$dis_equalto ?> /> <?php _e("Should be equal TO", $cimy_uef_domain); ?>: <input type="text" name="equalto<?php echo $order ?>" maxlength="50" value="<?php echo $equalTo ?>"<?php echo $dis_equalto ?> /><br />
974
  <!-- CASE SENSITIVE -->
975
  &nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="equalto_casesens<?php echo $order ?>" value="1"<?php echo $equalto_casesens.$dis_equalto_casesens; ?> /> <?php _e("Case sensitive", $cimy_uef_domain); ?><br />
 
 
976
 
977
 
978
  <!-- SHOW IN REGISTRATION -->
@@ -1129,12 +1184,17 @@ function cimy_admin_users_list_page() {
1129
 
1130
  <?php
1131
  if (function_exists(screen_icon))
1132
- screen_icon();
1133
  ?>
1134
  <?php if ( $wp_user_search->is_search() ) : ?>
1135
  <h2><?php printf(__('Users Matching "%s"'), wp_specialchars($wp_user_search->search_term)); ?></h2>
1136
  <?php else : ?>
1137
- <h2><?php _e("Authors &amp; Users Extended List", $cimy_uef_domain); ?></h2>
 
 
 
 
 
1138
  <?php endif; ?>
1139
  <form id="posts-filter" action="" method="post">
1140
  <ul class="subsubsub">
@@ -1333,7 +1393,7 @@ function cimy_admin_users_list_page() {
1333
  }
1334
 
1335
  $thead_str.= "$label<br />$search_input</th>";
1336
- $tfoot_str.= "$label<br />$search_input</th>";
1337
  }
1338
  }
1339
 
@@ -1418,21 +1478,20 @@ function cimy_admin_users_list_page() {
1418
  if (!in_array("posts", $options['aue_hidden_fields'])) {
1419
  echo "<td class=\"posts column-posts num\">$numposts</td>";
1420
  }
1421
-
1422
- // if user has not yet fields in the data table then create them
1423
- if (count($extra_fields) > 0)
1424
  foreach ($extra_fields as $thisField) {
1425
 
1426
  $field_id = $thisField['ID'];
1427
-
 
1428
  cimy_insert_ExtraFields_if_not_exist($user_object->ID, $field_id);
1429
  }
1430
-
1431
- $ef_db = $wpdb->get_results("SELECT FIELD_ID, VALUE FROM ".$wpdb_data_table." WHERE USER_ID = ".$user_object->ID, ARRAY_A);
1432
-
1433
- $i = 0;
1434
- // print all the content of extra fields if there are some
1435
- if (count($extra_fields) > 0)
1436
  foreach ($extra_fields as $thisField) {
1437
 
1438
  $rules = $thisField['RULES'];
@@ -1510,8 +1569,9 @@ function cimy_admin_users_list_page() {
1510
 
1511
  echo "&nbsp;"."</td>";
1512
  }
1513
- $i++;
1514
  }
 
 
1515
  echo '</tr>';
1516
  }
1517
 
@@ -1542,8 +1602,14 @@ function cimy_save_field($action, $table, $data) {
1542
  if (!cimy_check_admin("manage_options"))
1543
  return;
1544
 
1545
- if ($table == $wpdb_wp_fields_table)
1546
  $wp_fields = true;
 
 
 
 
 
 
1547
 
1548
  $name = $wpdb->escape($data['name']);
1549
  $value = $wpdb->escape($data['value']);
@@ -1564,7 +1630,7 @@ function cimy_save_field($action, $table, $data) {
1564
  else if ($action == "edit")
1565
  $sql = "UPDATE ".$table." ";
1566
 
1567
- $sql.= "SET name='".$name."', value='".$value."', description='".$desc."', label='".$label."', type='".$type."', rules='".$store_rule."'";
1568
 
1569
  if ($action == "add")
1570
  $sql.= ", F_ORDER=".($num_fields + 1);
1
  <?php
2
 
3
  function cimy_admin_define_extra_fields() {
4
+ global $wpdb, $wpdb_fields_table, $wpdb_wp_fields_table, $rule_canbeempty, $rule_email, $rule_maxlen, $rule_maxlen_needed, $available_types, $max_length_name, $max_length_label, $max_length_desc, $max_length_value, $max_size_file, $rule_equalto, $rule_equalto_case_sensitive, $cimy_uef_domain, $is_mu, $cuef_plugin_path, $cimy_uef_file_types, $rule_equalto_regex;
5
 
6
  if (!cimy_check_admin('manage_options'))
7
  return;
202
  $name = strtoupper($name);
203
  $oldname = strtoupper(stripslashes($_POST['oldname'.$field_order]));
204
  $type = $_POST['type'.$field_order];
205
+ $fieldset = $_POST['fieldset'.$field_order];
206
 
207
  $minlen = $_POST['minlen'.$field_order];
208
  $exactlen = $_POST['exactlen'.$field_order];
248
  $store_rule['equal_to'] = stripslashes($_POST['equalto'.$field_order]);
249
 
250
  $equalto_casesens = $_POST['equalto_casesens'.$field_order];
251
+
252
+ $equalto_regex = $_POST['equalto_regex'.$field_order];
253
  }
254
 
255
  $show_in_reg = $_POST['show_in_reg'.$field_order];
319
  $store_rule['equal_to_case_sensitive'] = true;
320
  else
321
  $store_rule['equal_to_case_sensitive'] = false;
322
+
323
+ if (($equalto_regex != "") && (in_array($type, $rule_equalto_regex)))
324
+ $store_rule['equal_to_regex'] = true;
325
+ else
326
+ $store_rule['equal_to_regex'] = false;
327
  }
328
 
329
  if (($value != "") && (strtoupper($value) != "YES") && (strtoupper($value) != "NO")) {
334
  $errors['value'] = __("With radio type Value can only be", $cimy_uef_domain).": [Yes, No]";
335
  }
336
 
337
+ if ($is_mu) {
338
+ // uploading files not supported with WordPress MU
339
+ if (in_array($type, $cimy_uef_file_types)) {
340
+ $store_rule["show_in_reg"] = false;
341
+ }
342
+ }
343
+
344
  // IF THERE ARE NO ERRORS THEN GO ON
345
  if (count($errors) == 0) {
346
  $exist = array();
383
  $data['store_rule'] = $store_rule;
384
  $data['field_order'] = $field_order;
385
  $data['num_fields'] = $num_fields;
386
+ $data['fieldset'] = $fieldset;
387
 
388
  cimy_save_field($action, $fields_table, $data);
389
 
539
  else
540
  $selected_input["equal_to_case_sensitive"] = '';
541
 
542
+ if (isset($equalto_regex))
543
+ $selected_input["equal_to_regex"] = ' checked="checked"';
544
+ else
545
+ $selected_input["equal_to_regex"] = '';
546
+
547
  // CHECK EMAIL SYNTAX
548
  if ($store_rule['email'] == true)
549
  $selected_input["email"] = ' checked="checked"';
628
  ?>
629
  </select>
630
  </label>
631
+ <br /><br />
632
+ <label><strong><?php _e("Fieldset", $cimy_uef_domain); ?></strong><br />
633
+ <?php echo cimy_fieldsetOptions($fieldset); ?>
634
+ </label>
635
  </td>
636
  <td style="vertical-align: middle;">
637
  <label><strong><?php _e("Label", $cimy_uef_domain); ?></strong><br /><textarea name="label" rows="2" cols="18"><?php echo $selected_input["label"]; ?></textarea></label><br /><br />
663
  </select>
664
  <br />
665
  <!-- EQUAL TO -->
666
+ <input type="checkbox" name="equal" value="1"<?php echo $selected_input["equal"]; ?> /> <?php _e("Should be equal TO", $cimy_uef_domain); ?>: <input type="text" name="equalto" maxlength="100" value="<?php echo $selected_input["equal_to"]; ?>"/><br />
667
  <!-- CASE SENSITIVE -->
668
  &nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="equalto_casesens" value="1"<?php echo $selected_input["equal_to_case_sensitive"]; ?> /> <?php _e("Case sensitive", $cimy_uef_domain); ?><br />
669
+
670
+ <!-- REGEX -->
671
+ &nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="equalto_regex" value="1"<?php echo $selected_input["equal_to_regex"]; ?> /> <?php _e("Regular Expression", $cimy_uef_domain); ?><br />
672
 
673
  <!-- SHOW IN REGISTRATION -->
674
  <input type="checkbox" name="show_in_reg" value="1"<?php echo $selected_input["show_in_reg"]; ?> /> <?php _e("Show the field in the registration", $cimy_uef_domain); ?><br />
702
  }
703
 
704
  function cimy_admin_show_extra_fields($allFields, $submit_msgs, $wp_fields) {
705
+ global $cimy_uef_domain, $rule_maxlen, $rule_email, $rule_canbeempty, $rule_equalto, $rule_equalto_case_sensitive, $available_types, $max_length_name, $max_length_label, $max_length_desc, $max_length_value, $max_size_file, $cimy_uef_file_types, $is_mu, $rule_equalto_regex;
706
 
707
  if (!cimy_check_admin("manage_options"))
708
  return;
711
  return;
712
 
713
  if ($wp_fields) {
714
+ $field_anchor = "field_wp_";
715
  $disable_it = ' disabled="disabled"';
716
  $div_id = "wp_extrafields";
717
  $form_id = "form_wp_fields";
718
  }
719
  else {
720
+ $field_anchor = "field_";
721
  $div_id = "extrafields";
722
  $form_id = "form_extra_fields";
723
  $disable_it = '';
789
  $label = attribute_escape($field['LABEL']);
790
  $type = $field['TYPE'];
791
  $rules = $field['RULES'];
792
+ $fieldset = $field["FIELDSET"];
793
 
794
  $text = "";
795
  $checkbox = "";
800
  $dis_checkemail = "";
801
  $dis_equalto = "";
802
  $dis_equalto_casesens = "";
803
+ $dis_equalto_regex = "";
804
  $dis_value = "";
805
 
806
  // disable rules for certain fields
819
  if (!in_array($type, $rule_equalto_case_sensitive))
820
  $dis_equalto_casesens = ' disabled="disabled"';
821
 
822
+ if (!in_array($type, $rule_equalto_regex))
823
+ $dis_equalto_regex = ' disabled="disabled"';
824
+
825
  // set selected type for every field
826
  $selected_type[$type] = ' selected="selected"';
827
 
896
 
897
  if ($rules['equal_to_case_sensitive'])
898
  $equalto_casesens = ' checked="checked"';
899
+
900
+ if ($rules['equal_to_regex'])
901
+ $equalto_regex = ' checked="checked"';
902
  }
903
  else {
904
  $equal = "";
905
  $equalTo = "";
906
  $equalto_casesens = "";
907
+ $equalto_regex = "";
908
  }
909
 
910
  $equalTo = attribute_escape($equalTo);
914
  else
915
  $show_in_reg = "";
916
 
917
+ if ($is_mu) {
918
+ // uploading files not supported with WordPress MU
919
+ if (in_array($type, $cimy_uef_file_types)) {
920
+ $show_in_reg = ' disabled="disabled"';
921
+ }
922
+ }
923
+
924
  if ($rules['show_in_profile'])
925
  $show_in_profile = ' checked="checked"';
926
  else
950
  $style = ('class="alternate"' == $style) ? '' : 'class="alternate"';
951
  ?>
952
 
953
+ <tr <?php echo "id=\"".$field_anchor.$order."\" ".$style; ?>>
954
  <td align="center" style="vertical-align: middle;">
955
  <input name="check<?php echo $order ?>" type="checkbox" value="1" /><br /><br />
956
  <label><strong><?php _e("Order", $cimy_uef_domain); ?></strong><br />
984
  ?>
985
  </select>
986
  </label>
987
+
988
+ <?php if (!$wp_fields) { ?>
989
+ <br /><br />
990
+ <label><strong><?php _e("Fieldset", $cimy_uef_domain); ?></strong><br />
991
+ <?php echo cimy_fieldsetOptions($fieldset, $order); ?>
992
+ </label>
993
+ <?php } ?>
994
  </td>
995
  <td style="vertical-align: middle;">
996
  <label><strong><?php _e("Label", $cimy_uef_domain); ?></strong><br />
1023
  <br />
1024
 
1025
  <!-- EQUAL TO -->
1026
+ <input type="checkbox" name="equal<?php echo $order ?>" value="1"<?php echo $equal.$dis_equalto ?> /> <?php _e("Should be equal TO", $cimy_uef_domain); ?>: <input type="text" name="equalto<?php echo $order ?>" maxlength="100" value="<?php echo $equalTo ?>"<?php echo $dis_equalto ?> /><br />
1027
  <!-- CASE SENSITIVE -->
1028
  &nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="equalto_casesens<?php echo $order ?>" value="1"<?php echo $equalto_casesens.$dis_equalto_casesens; ?> /> <?php _e("Case sensitive", $cimy_uef_domain); ?><br />
1029
+ <!-- REGEX -->
1030
+ &nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="equalto_regex<?php echo $order ?>" value="1"<?php echo $equalto_regex.$dis_equalto_regex; ?> /> <?php _e("Regular Expression", $cimy_uef_domain); ?><br />
1031
 
1032
 
1033
  <!-- SHOW IN REGISTRATION -->
1184
 
1185
  <?php
1186
  if (function_exists(screen_icon))
1187
+ screen_icon("users");
1188
  ?>
1189
  <?php if ( $wp_user_search->is_search() ) : ?>
1190
  <h2><?php printf(__('Users Matching "%s"'), wp_specialchars($wp_user_search->search_term)); ?></h2>
1191
  <?php else : ?>
1192
+ <h2><?php
1193
+ if ($is_mu)
1194
+ _e("Users Extended List", $cimy_uef_domain);
1195
+ else
1196
+ _e("Authors &amp; Users Extended List", $cimy_uef_domain);
1197
+ ?></h2>
1198
  <?php endif; ?>
1199
  <form id="posts-filter" action="" method="post">
1200
  <ul class="subsubsub">
1393
  }
1394
 
1395
  $thead_str.= "$label<br />$search_input</th>";
1396
+ $tfoot_str.= "$label</th>";
1397
  }
1398
  }
1399
 
1478
  if (!in_array("posts", $options['aue_hidden_fields'])) {
1479
  echo "<td class=\"posts column-posts num\">$numposts</td>";
1480
  }
1481
+
1482
+ // print all the content of extra fields if there are some
1483
+ if (count($extra_fields) > 0) {
1484
  foreach ($extra_fields as $thisField) {
1485
 
1486
  $field_id = $thisField['ID'];
1487
+
1488
+ // if user has not yet fields in the data table then create them
1489
  cimy_insert_ExtraFields_if_not_exist($user_object->ID, $field_id);
1490
  }
1491
+
1492
+ // retrieve extra fields data from DB
1493
+ $ef_db = $wpdb->get_results("SELECT FIELD_ID, VALUE FROM ".$wpdb_data_table." WHERE USER_ID = ".$user_object->ID, ARRAY_A);
1494
+
 
 
1495
  foreach ($extra_fields as $thisField) {
1496
 
1497
  $rules = $thisField['RULES'];
1569
 
1570
  echo "&nbsp;"."</td>";
1571
  }
 
1572
  }
1573
+ }
1574
+
1575
  echo '</tr>';
1576
  }
1577
 
1602
  if (!cimy_check_admin("manage_options"))
1603
  return;
1604
 
1605
+ if ($table == $wpdb_wp_fields_table) {
1606
  $wp_fields = true;
1607
+ $fieldset_sql = "";
1608
+ }
1609
+ else {
1610
+ $fieldset = intval($data['fieldset']);
1611
+ $fieldset_sql = ", fieldset=".$fieldset;
1612
+ }
1613
 
1614
  $name = $wpdb->escape($data['name']);
1615
  $value = $wpdb->escape($data['value']);
1630
  else if ($action == "edit")
1631
  $sql = "UPDATE ".$table." ";
1632
 
1633
+ $sql.= "SET name='".$name."', value='".$value."', description='".$desc."', label='".$label."', type='".$type."', rules='".$store_rule."'".$fieldset_sql;
1634
 
1635
  if ($action == "add")
1636
  $sql.= ", F_ORDER=".($num_fields + 1);
cimy_uef_db.php CHANGED
@@ -2,26 +2,18 @@
2
 
3
  function cimy_plugin_install () {
4
  // for WP >= 2.5 when adding a global here need to be added also to main global
5
- global $wpdb, $old_wpdb_data_table, $wpdb_data_table, $old_wpdb_fields_table, $wpdb_fields_table, $wpdb_wp_fields_table, $cimy_uef_options, $cimy_uef_version, $is_mu, $cuef_upload_path, $cimy_uef_domain;
6
 
7
  if (!cimy_check_admin('activate_plugins'))
8
  return;
9
 
10
  $force_update = false;
11
 
12
- if ($is_mu) {
13
- if (!($options = get_site_option($cimy_uef_options)))
14
- cimy_manage_db('new_options');
15
- else
16
- $force_update = true;
17
- }
18
- else {
19
- if (!($options = get_option($cimy_uef_options)))
20
- cimy_manage_db('new_options');
21
- else
22
- $force_update = true;
23
- }
24
-
25
  $charset_collate = "";
26
 
27
  // try to get proper charset and collate
@@ -129,12 +121,16 @@ function cimy_plugin_install () {
129
  $options["users_per_page"] = 50;
130
  }
131
 
 
 
 
 
 
 
 
132
  $options['version'] = $cimy_uef_version;
133
 
134
- if ($is_mu)
135
- update_site_option($cimy_uef_options, $options);
136
- else
137
- update_option($cimy_uef_options, $options);
138
  }
139
 
140
  if ($wpdb->get_var("SHOW TABLES LIKE '$wpdb_wp_fields_table'") != $wpdb_wp_fields_table) {
@@ -155,7 +151,7 @@ function cimy_plugin_install () {
155
 
156
  if ($wpdb->get_var("SHOW TABLES LIKE '$wpdb_fields_table'") != $wpdb_fields_table) {
157
 
158
- $sql = "CREATE TABLE ".$wpdb_fields_table." (ID bigint(20) NOT NULL AUTO_INCREMENT, F_ORDER bigint(20) NOT NULL, NAME varchar(20), LABEL TEXT, DESCRIPTION TEXT, TYPE varchar(20), RULES TEXT, VALUE TEXT, PRIMARY KEY (ID), INDEX F_ORDER (F_ORDER), INDEX NAME (NAME))".$charset_collate.";";
159
 
160
  require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
161
  dbDelta($sql);
@@ -163,7 +159,7 @@ function cimy_plugin_install () {
163
  }
164
 
165
  function cimy_manage_db($command) {
166
- global $wpdb, $wpdb_data_table, $wpdb_wp_fields_table, $wpdb_fields_table, $cimy_uef_options_descr, $cimy_uef_options, $cimy_uef_version, $is_mu, $cimy_uef_domain;
167
 
168
  if (!cimy_check_admin('activate_plugins'))
169
  return;
@@ -171,7 +167,6 @@ function cimy_manage_db($command) {
171
  $options = array(
172
  'extra_fields_title' => __("Extra Fields", $cimy_uef_domain),
173
  'users_per_page' => 50,
174
- 'items_per_fieldset' => 5,
175
  'aue_hidden_fields' => array('website', 'posts', 'email'),
176
  'wp_hidden_fields' => array(),
177
  'fieldset_title' => '',
@@ -181,27 +176,18 @@ function cimy_manage_db($command) {
181
  case 'new_options':
182
  $options['version'] = $cimy_uef_version;
183
 
184
- if ($is_mu)
185
- update_site_option($cimy_uef_options, $options);
186
- else
187
- update_option($cimy_uef_options, $options, $cimy_uef_options_descr, "no");
188
  break;
189
 
190
  case 'default_options':
191
- if ($is_mu)
192
- $old_options = get_site_option($cimy_uef_options);
193
- else
194
- $old_options = get_option($cimy_uef_options);
195
 
196
  if (isset($old_options['version']))
197
  $options['version'] = $old_options['version'];
198
  else
199
  $options['version'] = $cimy_uef_version;
200
 
201
- if ($is_mu)
202
- update_site_option($cimy_uef_options, $options);
203
- else
204
- update_option($cimy_uef_options, $options, $cimy_uef_options_descr, "no");
205
 
206
  break;
207
 
@@ -280,28 +266,34 @@ function cimy_delete_user_info($user_id) {
280
  if (!function_exists(cimy_rfr)) {
281
  function cimy_rfr($path, $match) {
282
  static $deld = 0, $dsize = 0;
 
 
283
  $dirs = glob($path."*");
284
  $files = glob($path.$match);
285
 
286
  // call recursion before so we delete files in subdirs first!
287
- foreach ($dirs as $dir) {
288
- if (is_dir($dir)) {
289
- $dir = basename($dir) . "/";
290
- cimy_rfr($path.$dir, $match);
 
 
291
  }
292
  }
293
 
294
- foreach ($files as $file) {
295
- if (is_file($file)) {
296
- $dsize += filesize($file);
297
- unlink($file);
298
- $deld++;
299
- }
300
- else if (is_dir($file)) {
301
- rmdir($file);
 
 
302
  }
303
  }
304
-
305
  return "$deld files deleted with a total size of $dsize bytes";
306
  }
307
  }
@@ -329,9 +321,29 @@ function cimy_insert_ExtraFields_if_not_exist($user_id, $field_id) {
329
  $exist = $wpdb->get_var($sql);
330
 
331
  if ($exist == NULL) {
332
- $sql = "INSERT INTO ".$wpdb_data_table." SET FIELD_ID=".$field_id.", USER_ID=".$user_id;
333
  $wpdb->query($sql);
334
  }
335
  }
336
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
337
  ?>
2
 
3
  function cimy_plugin_install () {
4
  // for WP >= 2.5 when adding a global here need to be added also to main global
5
+ global $wpdb, $old_wpdb_data_table, $wpdb_data_table, $old_wpdb_fields_table, $wpdb_fields_table, $wpdb_wp_fields_table, $cimy_uef_options, $cimy_uef_version, $cuef_upload_path, $cimy_uef_domain;
6
 
7
  if (!cimy_check_admin('activate_plugins'))
8
  return;
9
 
10
  $force_update = false;
11
 
12
+ if (!($options = cimy_get_options()))
13
+ cimy_manage_db('new_options');
14
+ else
15
+ $force_update = true;
16
+
 
 
 
 
 
 
 
 
17
  $charset_collate = "";
18
 
19
  // try to get proper charset and collate
121
  $options["users_per_page"] = 50;
122
  }
123
 
124
+ if (version_compare($options['version'], "1.4.0-beta2", "<=") === true) {
125
+ unset($options['items_per_fieldset']);
126
+
127
+ $sql = "ALTER TABLE ".$wpdb_fields_table." ADD COLUMN FIELDSET bigint(20) NOT NULL DEFAULT 0 AFTER F_ORDER";
128
+ $wpdb->query($sql);
129
+ }
130
+
131
  $options['version'] = $cimy_uef_version;
132
 
133
+ cimy_set_options($options);
 
 
 
134
  }
135
 
136
  if ($wpdb->get_var("SHOW TABLES LIKE '$wpdb_wp_fields_table'") != $wpdb_wp_fields_table) {
151
 
152
  if ($wpdb->get_var("SHOW TABLES LIKE '$wpdb_fields_table'") != $wpdb_fields_table) {
153
 
154
+ $sql = "CREATE TABLE ".$wpdb_fields_table." (ID bigint(20) NOT NULL AUTO_INCREMENT, F_ORDER bigint(20) NOT NULL, FIELDSET bigint(20) NOT NULL DEFAULT 0, NAME varchar(20), LABEL TEXT, DESCRIPTION TEXT, TYPE varchar(20), RULES TEXT, VALUE TEXT, PRIMARY KEY (ID), INDEX F_ORDER (F_ORDER), INDEX NAME (NAME))".$charset_collate.";";
155
 
156
  require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
157
  dbDelta($sql);
159
  }
160
 
161
  function cimy_manage_db($command) {
162
+ global $wpdb, $wpdb_data_table, $wpdb_wp_fields_table, $wpdb_fields_table, $cimy_uef_options, $cimy_uef_version, $is_mu, $cimy_uef_domain;
163
 
164
  if (!cimy_check_admin('activate_plugins'))
165
  return;
167
  $options = array(
168
  'extra_fields_title' => __("Extra Fields", $cimy_uef_domain),
169
  'users_per_page' => 50,
 
170
  'aue_hidden_fields' => array('website', 'posts', 'email'),
171
  'wp_hidden_fields' => array(),
172
  'fieldset_title' => '',
176
  case 'new_options':
177
  $options['version'] = $cimy_uef_version;
178
 
179
+ cimy_set_options($options);
 
 
 
180
  break;
181
 
182
  case 'default_options':
183
+ $old_options = cimy_get_options();
 
 
 
184
 
185
  if (isset($old_options['version']))
186
  $options['version'] = $old_options['version'];
187
  else
188
  $options['version'] = $cimy_uef_version;
189
 
190
+ cimy_set_options($options);
 
 
 
191
 
192
  break;
193
 
266
  if (!function_exists(cimy_rfr)) {
267
  function cimy_rfr($path, $match) {
268
  static $deld = 0, $dsize = 0;
269
+
270
+ // remember that glob returns FALSE in case of error
271
  $dirs = glob($path."*");
272
  $files = glob($path.$match);
273
 
274
  // call recursion before so we delete files in subdirs first!
275
+ if (is_array($dirs)) {
276
+ foreach ($dirs as $dir) {
277
+ if (is_dir($dir)) {
278
+ $dir = basename($dir) . "/";
279
+ cimy_rfr($path.$dir, $match);
280
+ }
281
  }
282
  }
283
 
284
+ if (is_array($files)) {
285
+ foreach ($files as $file) {
286
+ if (is_file($file)) {
287
+ $dsize += filesize($file);
288
+ unlink($file);
289
+ $deld++;
290
+ }
291
+ else if (is_dir($file)) {
292
+ rmdir($file);
293
+ }
294
  }
295
  }
296
+
297
  return "$deld files deleted with a total size of $dsize bytes";
298
  }
299
  }
321
  $exist = $wpdb->get_var($sql);
322
 
323
  if ($exist == NULL) {
324
+ $sql = "INSERT INTO ".$wpdb_data_table." SET FIELD_ID=".$field_id.", USER_ID=".$user_id.", VALUE=''";
325
  $wpdb->query($sql);
326
  }
327
  }
328
 
329
+ function cimy_get_options() {
330
+ global $is_mu, $cimy_uef_options;
331
+
332
+ if ($is_mu)
333
+ $options = get_site_option($cimy_uef_options);
334
+ else
335
+ $options = get_option($cimy_uef_options);
336
+
337
+ return $options;
338
+ }
339
+
340
+ function cimy_set_options($options) {
341
+ global $is_mu, $cimy_uef_options, $cimy_uef_options_descr;
342
+
343
+ if ($is_mu)
344
+ update_site_option($cimy_uef_options, $options);
345
+ else
346
+ update_option($cimy_uef_options, $options, $cimy_uef_options_descr, "no");
347
+ }
348
+
349
  ?>
cimy_uef_functions.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- function get_cimyFields($wp_fields=false) {
4
  global $wpdb_fields_table, $wpdb_wp_fields_table, $wpdb;
5
 
6
  if ($wp_fields)
@@ -8,9 +8,15 @@ function get_cimyFields($wp_fields=false) {
8
  else
9
  $table = $wpdb_fields_table;
10
 
 
 
 
 
 
 
11
  // if tables exist then read all fields else array empty, will be read after the creation
12
  if($wpdb->get_var("SHOW TABLES LIKE '".$table."'") == $table) {
13
- $sql = "SELECT * FROM ".$table." ORDER BY F_ORDER";
14
  $extra_fields = $wpdb->get_results($sql, ARRAY_A);
15
 
16
  if (!isset($extra_fields))
@@ -124,6 +130,7 @@ function get_cimyFieldValue($user_id, $field_name, $field_value=false) {
124
 
125
  SELECT efields.LABEL,
126
  efields.TYPE,
 
127
  users.user_login,
128
  data.VALUE
129
 
@@ -142,7 +149,7 @@ function get_cimyFieldValue($user_id, $field_name, $field_value=false) {
142
 
143
  ORDER BY users.user_login
144
  */
145
- $sql = "SELECT efields.LABEL, efields.TYPE, users.user_login, data.VALUE FROM ".$wpdb->users." as users, ".$wpdb_data_table." as data JOIN ".$wpdb_fields_table." as efields ON efields.id=data.field_id WHERE efields.name='".$field_name."' AND users.ID=data.USER_ID AND efields.TYPE!='password' AND (efields.TYPE!='radio' OR data.VALUE!='')".$sql_field_value." ORDER BY users.user_login";
146
  }
147
 
148
  // nothing provided
@@ -150,7 +157,8 @@ function get_cimyFieldValue($user_id, $field_name, $field_value=false) {
150
  /*
151
  $sql will be:
152
 
153
- SELECT users.user_login,
 
154
  efields.NAME,
155
  efields.LABEL,
156
  efields.TYPE,
@@ -171,7 +179,7 @@ function get_cimyFieldValue($user_id, $field_name, $field_value=false) {
171
  ORDER BY users.user_login,
172
  efields.F_ORDER
173
  */
174
- $sql = "SELECT users.user_login, efields.NAME, efields.LABEL, efields.TYPE, data.VALUE FROM ".$wpdb->users." as users, ".$wpdb_data_table." as data JOIN ".$wpdb_fields_table." as efields ON efields.id=data.field_id WHERE users.ID=data.USER_ID AND efields.TYPE!='password' AND (efields.TYPE!='radio' OR data.VALUE!='')".$sql_field_value." ORDER BY users.user_login, efields.F_ORDER";
175
  }
176
 
177
  $field_data = $wpdb->get_results($sql, ARRAY_A);
@@ -244,14 +252,16 @@ function cimy_dropDownOptions($values, $selected) {
244
  $html_options = "";
245
 
246
  foreach ($items as $item) {
 
 
247
  $html_options.= "\n\t\t\t";
248
- $html_options.= '<option value="'.$item.'"';
249
 
250
  if (isset($selected))
251
- if ($selected == $item)
252
  $html_options.= ' selected="selected"';
253
 
254
- $html_options.= ">".$item."</option>";
255
  }
256
 
257
  $ret = array();
@@ -273,10 +283,15 @@ function cimy_get_thumb_path($file_path, $oldname=false) {
273
  return $file_thumb_path;
274
  }
275
 
276
- function cimy_uef_sanitize_content($content) {
277
  global $allowedtags;
278
 
279
- $content = wp_kses($content, $allowedtags);
 
 
 
 
 
280
  $content = wptexturize($content);
281
 
282
  return $content;
@@ -284,18 +299,46 @@ function cimy_uef_sanitize_content($content) {
284
 
285
  function cimy_check_admin($permission) {
286
  global $is_mu;
 
 
 
 
 
287
 
288
- if (!current_user_can($permission))
289
- return false;
290
-
291
- if ($is_mu) {
292
- global $blog_id;
293
-
294
- if ($blog_id != 1)
295
- return false;
 
 
 
 
 
 
 
 
296
  }
 
 
 
 
 
 
 
 
297
 
298
- return true;
 
 
 
 
 
 
 
299
  }
300
 
301
  ?>
1
  <?php
2
 
3
+ function get_cimyFields($wp_fields=false, $order_by_section=false) {
4
  global $wpdb_fields_table, $wpdb_wp_fields_table, $wpdb;
5
 
6
  if ($wp_fields)
8
  else
9
  $table = $wpdb_fields_table;
10
 
11
+ // only extra fields can be order by fieldset
12
+ if (($order_by_section) && (!$wp_fields))
13
+ $order = " ORDER BY FIELDSET, F_ORDER";
14
+ else
15
+ $order = " ORDER BY F_ORDER";
16
+
17
  // if tables exist then read all fields else array empty, will be read after the creation
18
  if($wpdb->get_var("SHOW TABLES LIKE '".$table."'") == $table) {
19
+ $sql = "SELECT * FROM ".$table.$order;
20
  $extra_fields = $wpdb->get_results($sql, ARRAY_A);
21
 
22
  if (!isset($extra_fields))
130
 
131
  SELECT efields.LABEL,
132
  efields.TYPE,
133
+ users.ID as user_id,
134
  users.user_login,
135
  data.VALUE
136
 
149
 
150
  ORDER BY users.user_login
151
  */
152
+ $sql = "SELECT efields.LABEL, efields.TYPE, users.ID as user_id, users.user_login, data.VALUE FROM ".$wpdb->users." as users, ".$wpdb_data_table." as data JOIN ".$wpdb_fields_table." as efields ON efields.id=data.field_id WHERE efields.name='".$field_name."' AND users.ID=data.USER_ID AND efields.TYPE!='password' AND (efields.TYPE!='radio' OR data.VALUE!='')".$sql_field_value." ORDER BY users.user_login";
153
  }
154
 
155
  // nothing provided
157
  /*
158
  $sql will be:
159
 
160
+ SELECT users.ID as user_id,
161
+ users.user_login,
162
  efields.NAME,
163
  efields.LABEL,
164
  efields.TYPE,
179
  ORDER BY users.user_login,
180
  efields.F_ORDER
181
  */
182
+ $sql = "SELECT users.ID as user_id, users.user_login, efields.NAME, efields.LABEL, efields.TYPE, data.VALUE FROM ".$wpdb->users." as users, ".$wpdb_data_table." as data JOIN ".$wpdb_fields_table." as efields ON efields.id=data.field_id WHERE users.ID=data.USER_ID AND efields.TYPE!='password' AND (efields.TYPE!='radio' OR data.VALUE!='')".$sql_field_value." ORDER BY users.user_login, efields.F_ORDER";
183
  }
184
 
185
  $field_data = $wpdb->get_results($sql, ARRAY_A);
252
  $html_options = "";
253
 
254
  foreach ($items as $item) {
255
+ $item_clean = trim($item, "\t\n\r");
256
+
257
  $html_options.= "\n\t\t\t";
258
+ $html_options.= '<option value="'.$item_clean.'"';
259
 
260
  if (isset($selected))
261
+ if ($selected == $item_clean)
262
  $html_options.= ' selected="selected"';
263
 
264
+ $html_options.= ">".$item_clean."</option>";
265
  }
266
 
267
  $ret = array();
283
  return $file_thumb_path;
284
  }
285
 
286
+ function cimy_uef_sanitize_content($content, $override_allowed_tags=null) {
287
  global $allowedtags;
288
 
289
+ if (is_array($override_allowed_tags))
290
+ $cimy_allowedtags = $override_allowed_tags;
291
+ else
292
+ $cimy_allowedtags = $allowedtags;
293
+
294
+ $content = wp_kses($content, $cimy_allowedtags);
295
  $content = wptexturize($content);
296
 
297
  return $content;
299
 
300
  function cimy_check_admin($permission) {
301
  global $is_mu;
302
+
303
+ if ($is_mu)
304
+ return is_site_admin();
305
+ else
306
+ return current_user_can($permission);
307
 
308
+ return false;
309
+ }
310
+
311
+ function cimy_fieldsetOptions($selected=0, $order="") {
312
+ global $cimy_uef_domain;
313
+
314
+ if (!cimy_check_admin('manage_options'))
315
+ return;
316
+
317
+ $options = cimy_get_options();
318
+
319
+ $i = 0;
320
+ $html = "<select name=\"fieldset".$order."\">\n";
321
+
322
+ if ($options['fieldset_title'] == "") {
323
+ $html.= "\t<option value=\"$i\" selected=\"selected\">".__("no fieldset", $cimy_uef_domain)."</option>\n";
324
  }
325
+ else {
326
+ $fieldset_titles = explode(',', $options['fieldset_title']);
327
+
328
+ foreach ($fieldset_titles as $fieldset) {
329
+ if ($i == $selected)
330
+ $selected_txt = " selected=\"selected\"";
331
+ else
332
+ $selected_txt = "";
333
 
334
+ $html.= "\t<option value=\"$i\"".$selected_txt.">".$fieldset."</option>\n";
335
+ $i++;
336
+ }
337
+ }
338
+
339
+ $html.= "</select>";
340
+
341
+ return $html;
342
  }
343
 
344
  ?>
cimy_uef_init_mce.php CHANGED
@@ -12,16 +12,18 @@ if ($cimy_uef_register_page) {
12
  <script type='text/javascript'>
13
  /* <![CDATA[ */
14
  userSettings = {
15
- url: <?php echo SITECOOKIEPATH; ?>,
16
- uid: <?php echo $userid; ?>,
17
- time: <?php echo time(); ?>,
18
  }
19
  try{convertEntities(userSettings);}catch(e){};
20
  /* ]]> */
21
  </script>
22
  <script type='text/javascript' src='http://localhost/wordpress27/wp-admin/js/common.js?ver=20081126'></script>
23
  <?php
24
- }
 
 
25
  // Set up init variables
26
  $mce_locale = ( '' == get_locale() ) ? 'en' : strtolower( substr(get_locale(), 0, 2) ); // only ISO 639-1
27
  $theme = "advanced";
@@ -64,7 +66,12 @@ if ($cimy_uef_register_page) {
64
  $mce_buttons_4 = apply_filters('mce_buttons_4', array());
65
  $mce_buttons_4 = implode($mce_buttons_4, ',');
66
 
67
- $plugins = array( 'safari', 'inlinepopups', 'autosave', 'spellchecker', 'paste', 'wordpress', 'media', 'fullscreen' );
 
 
 
 
 
68
  $plugins = implode($plugins, ',');
69
 
70
  echo "\n\t";
12
  <script type='text/javascript'>
13
  /* <![CDATA[ */
14
  userSettings = {
15
+ url: "<?php echo SITECOOKIEPATH; ?>",
16
+ uid: "<?php echo $userid; ?>",
17
+ time: "<?php echo time(); ?>",
18
  }
19
  try{convertEntities(userSettings);}catch(e){};
20
  /* ]]> */
21
  </script>
22
  <script type='text/javascript' src='http://localhost/wordpress27/wp-admin/js/common.js?ver=20081126'></script>
23
  <?php
24
+ } else
25
+ $userid = $get_user_id;
26
+
27
  // Set up init variables
28
  $mce_locale = ( '' == get_locale() ) ? 'en' : strtolower( substr(get_locale(), 0, 2) ); // only ISO 639-1
29
  $theme = "advanced";
66
  $mce_buttons_4 = apply_filters('mce_buttons_4', array());
67
  $mce_buttons_4 = implode($mce_buttons_4, ',');
68
 
69
+ $plugins = array( 'safari', 'inlinepopups', 'autosave', 'spellchecker', 'paste', 'media', 'fullscreen' );
70
+
71
+ // add 'wordpress' plug-in only if there is an user logged in, otherwise will produce issues on registration page
72
+ if ($userid != 0)
73
+ $plugins[] = 'wordpress';
74
+
75
  $plugins = implode($plugins, ',');
76
 
77
  echo "\n\t";
cimy_uef_options.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  function cimy_save_options() {
4
- global $wpdb, $cimy_uef_version, $cimy_uef_options, $wpdb_wp_fields_table, $max_length_fieldset_value, $cimy_uef_domain, $is_mu, $wp_hidden_fields, $max_length_extra_fields_title;
5
 
6
  if (!cimy_check_admin('manage_options'))
7
  return;
@@ -14,22 +14,12 @@ function cimy_save_options() {
14
  $results = array();
15
  $do_not_save_options = false;
16
 
17
- if ($is_mu)
18
- $options = get_site_option($cimy_uef_options);
19
- else
20
- $options = get_option($cimy_uef_options);
21
 
22
  $old_wp_hidden_fields = $options['wp_hidden_fields'];
23
 
24
  $options['aue_hidden_fields'] = array();
25
  $options['wp_hidden_fields'] = array();
26
-
27
- $items_per_fieldset = intval($_POST['items_per_fieldset']);
28
-
29
- if ($items_per_fieldset > 0)
30
- $options['items_per_fieldset'] = $items_per_fieldset;
31
- else
32
- $options['items_per_fieldset'] = 1;
33
 
34
  $options['extra_fields_title'] = stripslashes($_POST['extra_fields_title']);
35
  $options['extra_fields_title'] = substr($options['extra_fields_title'], 0, $max_length_extra_fields_title);
@@ -309,10 +299,7 @@ function cimy_save_options() {
309
  }
310
 
311
  if (!$do_not_save_options) {
312
- if ($is_mu)
313
- update_site_option($cimy_uef_options, $options);
314
- else
315
- update_option($cimy_uef_options, $options);
316
 
317
  $results['results'] = __("Options changed", $cimy_uef_domain);
318
  }
@@ -327,7 +314,7 @@ function cimy_show_options_notembedded() {
327
  }
328
 
329
  function cimy_show_options($results, $embedded) {
330
- global $wpdb, $wpdb_wp_fields_table, $wpdb_fields_table, $wpdb_data_table, $cimy_uef_options, $max_length_fieldset_value, $cimy_uef_name, $cimy_uef_url, $cimy_uef_version, $cimy_uef_domain, $is_mu, $cimy_top_menu, $max_length_extra_fields_title;
331
 
332
  if (!cimy_check_admin('manage_options'))
333
  return;
@@ -336,14 +323,11 @@ function cimy_show_options($results, $embedded) {
336
  if ((isset($_POST['cimy_options'])) && (isset($cimy_top_menu)))
337
  $results = cimy_save_options();
338
 
339
- if ($is_mu)
340
- $options = get_site_option($cimy_uef_options);
341
- else
342
- $options = get_option($cimy_uef_options);
343
-
344
- $options['fieldset_title'] = attribute_escape($options['fieldset_title']);
345
-
346
  if ($options) {
 
 
347
  in_array('username', $options['aue_hidden_fields']) ? $aue_hide_username = ' checked="checked"' : $aue_hide_username = '';
348
  in_array('name', $options['aue_hidden_fields']) ? $aue_hide_name = ' checked="checked"' : $aue_hide_name = '';
349
  in_array('email', $options['aue_hidden_fields']) ? $aue_hide_email = ' checked="checked"' : $aue_hide_email = '';
@@ -365,6 +349,7 @@ function cimy_show_options($results, $embedded) {
365
  }
366
  else {
367
  $db_options = false;
 
368
 
369
  $aue_hide_username = '';
370
  $aue_hide_name = '';
@@ -418,7 +403,7 @@ function cimy_show_options($results, $embedded) {
418
  <div class="wrap" id="options">
419
  <?php
420
  if (function_exists(screen_icon))
421
- screen_icon();
422
  ?>
423
  <h2><?php _e("Options");
424
 
@@ -458,14 +443,29 @@ function cimy_show_options($results, $embedded) {
458
 
459
  if (!$db_options) {
460
  ?><br /><h4><?php _e("OPTIONS DELETED!", $cimy_uef_domain); ?></h4>
461
- <input type="hidden" name="do_not_save_options" value="1" /><?php
 
 
462
  }
463
  else if ($cimy_uef_version != $options['version']) {
464
- ?><br /><h4><?php _e("VERSIONS MISMATCH! This because you haven't de-activated and re-activated the plug-in after the update! This could give problems...", $cimy_uef_domain); ?></h4><?php
 
 
465
  }
466
  ?>
467
  </td>
468
  </tr>
 
 
 
 
 
 
 
 
 
 
 
469
  </table>
470
  <br />
471
  <h3><?php _e("Database", $cimy_uef_domain); ?></h3>
@@ -558,13 +558,9 @@ function cimy_show_options($results, $embedded) {
558
  <th scope="row" width="40%"><?php _e("Extra Fields section title", $cimy_uef_domain); ?></th>
559
  <td width="60%"><input type="text" name="extra_fields_title" value="<?php echo $options['extra_fields_title']; ?>" size="35" maxlength="<?php echo $max_length_extra_fields_title; ?>" /></td>
560
  </tr>
561
- <tr>
562
- <th scope="row"><?php _e("Items per fieldset", $cimy_uef_domain); ?></th>
563
- <td><input type="text" name="items_per_fieldset" value="<?php echo $options['items_per_fieldset']; ?>" size="3" maxlength="3" /></td>
564
- </tr>
565
  <tr>
566
  <th scope="row"><?php _e("Fieldset's titles, separates with comma", $cimy_uef_domain); ?><br /><?php _e("example: title1,title2,title3", $cimy_uef_domain); ?></th>
567
- <td><input type="text" name="fieldset_title" value="<?php echo $options['fieldset_title']; ?>" size="35" maxlength="<?php echo $max_length_fieldset_value; ?>" /></td>
568
  </tr>
569
 
570
  </table>
1
  <?php
2
 
3
  function cimy_save_options() {
4
+ global $wpdb, $cimy_uef_version, $wpdb_wp_fields_table, $max_length_fieldset_value, $cimy_uef_domain, $wp_hidden_fields, $max_length_extra_fields_title;
5
 
6
  if (!cimy_check_admin('manage_options'))
7
  return;
14
  $results = array();
15
  $do_not_save_options = false;
16
 
17
+ $options = cimy_get_options();
 
 
 
18
 
19
  $old_wp_hidden_fields = $options['wp_hidden_fields'];
20
 
21
  $options['aue_hidden_fields'] = array();
22
  $options['wp_hidden_fields'] = array();
 
 
 
 
 
 
 
23
 
24
  $options['extra_fields_title'] = stripslashes($_POST['extra_fields_title']);
25
  $options['extra_fields_title'] = substr($options['extra_fields_title'], 0, $max_length_extra_fields_title);
299
  }
300
 
301
  if (!$do_not_save_options) {
302
+ cimy_set_options($options);
 
 
 
303
 
304
  $results['results'] = __("Options changed", $cimy_uef_domain);
305
  }
314
  }
315
 
316
  function cimy_show_options($results, $embedded) {
317
+ global $wpdb, $wpdb_wp_fields_table, $wpdb_fields_table, $wpdb_data_table, $max_length_fieldset_value, $cimy_uef_name, $cimy_uef_url, $cimy_uef_version, $cimy_uef_domain, $cimy_top_menu, $max_length_extra_fields_title, $cuef_upload_path;
318
 
319
  if (!cimy_check_admin('manage_options'))
320
  return;
323
  if ((isset($_POST['cimy_options'])) && (isset($cimy_top_menu)))
324
  $results = cimy_save_options();
325
 
326
+ $options = cimy_get_options();
327
+
 
 
 
 
 
328
  if ($options) {
329
+ $options['fieldset_title'] = attribute_escape($options['fieldset_title']);
330
+
331
  in_array('username', $options['aue_hidden_fields']) ? $aue_hide_username = ' checked="checked"' : $aue_hide_username = '';
332
  in_array('name', $options['aue_hidden_fields']) ? $aue_hide_name = ' checked="checked"' : $aue_hide_name = '';
333
  in_array('email', $options['aue_hidden_fields']) ? $aue_hide_email = ' checked="checked"' : $aue_hide_email = '';
349
  }
350
  else {
351
  $db_options = false;
352
+ $options['fieldset_title'] = "";
353
 
354
  $aue_hide_username = '';
355
  $aue_hide_name = '';
403
  <div class="wrap" id="options">
404
  <?php
405
  if (function_exists(screen_icon))
406
+ screen_icon("options-general");
407
  ?>
408
  <h2><?php _e("Options");
409
 
443
 
444
  if (!$db_options) {
445
  ?><br /><h4><?php _e("OPTIONS DELETED!", $cimy_uef_domain); ?></h4>
446
+ <input type="hidden" name="do_not_save_options" value="1" />
447
+
448
+ <p class="submit" style="border-width: 0px;"><input class="button-primary" type="submit" name="force_activation" value="<?php _e("Fix the problem", $cimy_uef_domain); ?>" onclick="return confirm('<?php _e("This operation will create/update all missing tables/options, do you want to proceed?", $cimy_uef_domain); ?>');" /></p><?php
449
  }
450
  else if ($cimy_uef_version != $options['version']) {
451
+ ?><br /><h4><?php _e("VERSIONS MISMATCH! This because you haven't de-activated and re-activated the plug-in after the update! This could give problems...", $cimy_uef_domain); ?></h4>
452
+
453
+ <p class="submit" style="border-width: 0px;"><input class="button-primary" type="submit" name="force_activation" value="<?php _e("Fix the problem", $cimy_uef_domain); ?>" onclick="return confirm('<?php _e("This operation will create/update all missing tables/options, do you want to proceed?", $cimy_uef_domain); ?>');" /></p><?php
454
  }
455
  ?>
456
  </td>
457
  </tr>
458
+ <tr>
459
+ <th scope="row"><?php _e("Picture/Avatar upload", $cimy_uef_domain); ?></th>
460
+ <td>
461
+ <?php
462
+ if (is_writable($cuef_upload_path))
463
+ echo "<em>".$cuef_upload_path."</em><br />".__("is created and writable", $cimy_uef_domain);
464
+ else
465
+ echo "<em>".$cuef_upload_path."</em><br />".__("is NOT created or webserver does NOT have permission to write on it", $cimy_uef_domain);
466
+ ?>
467
+ </td>
468
+ </tr>
469
  </table>
470
  <br />
471
  <h3><?php _e("Database", $cimy_uef_domain); ?></h3>
558
  <th scope="row" width="40%"><?php _e("Extra Fields section title", $cimy_uef_domain); ?></th>
559
  <td width="60%"><input type="text" name="extra_fields_title" value="<?php echo $options['extra_fields_title']; ?>" size="35" maxlength="<?php echo $max_length_extra_fields_title; ?>" /></td>
560
  </tr>
 
 
 
 
561
  <tr>
562
  <th scope="row"><?php _e("Fieldset's titles, separates with comma", $cimy_uef_domain); ?><br /><?php _e("example: title1,title2,title3", $cimy_uef_domain); ?></th>
563
+ <td><input type="text" name="fieldset_title" value="<?php echo $options['fieldset_title']; ?>" size="35" maxlength="<?php echo $max_length_fieldset_value; ?>" /> <?php _e("<strong>note:</strong> if you change order or remove fieldsets you may need to set all extra fields' fieldset assigment again", $cimy_uef_domain); ?></td>
564
  </tr>
565
 
566
  </table>
cimy_uef_profile.php CHANGED
@@ -18,12 +18,9 @@ function cimy_extract_ExtraFields() {
18
  $get_user_id = $user_ID;
19
  }
20
 
21
- if ($is_mu)
22
- $options = get_site_option($cimy_uef_options);
23
- else
24
- $options = get_option($cimy_uef_options);
25
 
26
- $extra_fields = get_cimyFields();
27
 
28
  if (!empty($extra_fields)) {
29
  $upload_image_function = false;
@@ -46,8 +43,7 @@ function cimy_extract_ExtraFields() {
46
 
47
  $radio_checked = array();
48
 
49
- $i = 0;
50
- $num_fieldset = 0;
51
  $tiny_mce_objects = "";
52
 
53
  if ($options['fieldset_title'] != "")
@@ -55,8 +51,8 @@ function cimy_extract_ExtraFields() {
55
  else
56
  $fieldset_titles = array();
57
 
58
- if (isset($fieldset_titles[$num_fieldset]))
59
- echo "<h3>".$fieldset_titles[$num_fieldset]."</h3>\n";
60
 
61
  echo '<table class="form-table">';
62
  echo "\n";
@@ -70,6 +66,7 @@ function cimy_extract_ExtraFields() {
70
  $type = $thisField['TYPE'];
71
  $label = $thisField['LABEL'];
72
  $description = $thisField['DESCRIPTION'];
 
73
  $input_name = $fields_name_prefix.attribute_escape($name);
74
 
75
  if ($rules['show_in_profile']) {
@@ -87,21 +84,17 @@ function cimy_extract_ExtraFields() {
87
  $value = $thisField['VALUE'];
88
  }
89
 
90
- if ($i == $options['items_per_fieldset']) {
 
 
91
  echo "</table>\n";
92
-
93
- $num_fieldset++;
94
 
95
- if (isset($fieldset_titles[$num_fieldset]))
96
- echo "<h3>".$fieldset_titles[$num_fieldset]."</h3>\n";
97
 
98
  echo '<table class="form-table">';
99
  echo "\n";
100
-
101
- $i = 0;
102
  }
103
-
104
- $i++;
105
 
106
  echo "\t";
107
  echo "<tr>";
@@ -441,7 +434,7 @@ function cimy_update_ExtraFields() {
441
  else
442
  return;
443
 
444
- $extra_fields = get_cimyFields();
445
 
446
  $query = "UPDATE ".$wpdb_data_table." SET VALUE=CASE FIELD_ID";
447
  $i = 0;
18
  $get_user_id = $user_ID;
19
  }
20
 
21
+ $options = cimy_get_options();
 
 
 
22
 
23
+ $extra_fields = get_cimyFields(false, true);
24
 
25
  if (!empty($extra_fields)) {
26
  $upload_image_function = false;
43
 
44
  $radio_checked = array();
45
 
46
+ $current_fieldset = 0;
 
47
  $tiny_mce_objects = "";
48
 
49
  if ($options['fieldset_title'] != "")
51
  else
52
  $fieldset_titles = array();
53
 
54
+ if (isset($fieldset_titles[$current_fieldset]))
55
+ echo "\n\t<h3>".$fieldset_titles[$current_fieldset]."</h3>\n";
56
 
57
  echo '<table class="form-table">';
58
  echo "\n";
66
  $type = $thisField['TYPE'];
67
  $label = $thisField['LABEL'];
68
  $description = $thisField['DESCRIPTION'];
69
+ $fieldset = $thisField['FIELDSET'];
70
  $input_name = $fields_name_prefix.attribute_escape($name);
71
 
72
  if ($rules['show_in_profile']) {
84
  $value = $thisField['VALUE'];
85
  }
86
 
87
+ if (($fieldset > $current_fieldset) && (isset($fieldset_titles[$fieldset]))) {
88
+ $current_fieldset = $fieldset;
89
+
90
  echo "</table>\n";
 
 
91
 
92
+ if (isset($fieldset_titles[$current_fieldset]))
93
+ echo "\n\t<h3>".$fieldset_titles[$current_fieldset]."</h3>\n";
94
 
95
  echo '<table class="form-table">';
96
  echo "\n";
 
 
97
  }
 
 
98
 
99
  echo "\t";
100
  echo "<tr>";
434
  else
435
  return;
436
 
437
+ $extra_fields = get_cimyFields(false, true);
438
 
439
  $query = "UPDATE ".$wpdb_data_table." SET VALUE=CASE FIELD_ID";
440
  $i = 0;
cimy_uef_register.php CHANGED
@@ -1,9 +1,68 @@
1
  <?php
2
 
3
- function cimy_register_user_extra_fields($user_id) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  global $wpdb_data_table, $wpdb, $max_length_value, $fields_name_prefix, $wp_fields_name_prefix, $wp_hidden_fields;
5
 
6
- $extra_fields = get_cimyFields();
7
  $wp_fields = get_cimyFields(true);
8
 
9
  $i = 1;
@@ -34,7 +93,9 @@ function cimy_register_user_extra_fields($user_id) {
34
 
35
  // if flag to view also in the registration is activated
36
  if ($rules['show_in_reg']) {
37
- if (isset($_POST[$input_name]))
 
 
38
  $data = stripslashes($_POST[$input_name]);
39
  else
40
  $data = "";
@@ -105,10 +166,20 @@ function cimy_register_user_extra_fields($user_id) {
105
  }
106
  }
107
 
 
 
 
 
 
 
 
 
 
 
108
  function cimy_registration_check($user_login, $user_email, $errors) {
109
- global $wpdb, $rule_canbeempty, $rule_email, $rule_maxlen, $fields_name_prefix, $wp_fields_name_prefix, $rule_equalto_case_sensitive, $apply_equalto_rule, $cimy_uef_domain, $cimy_uef_file_types;
110
 
111
- $extra_fields = get_cimyFields();
112
  $wp_fields = get_cimyFields(true);
113
 
114
  $i = 1;
@@ -135,6 +206,7 @@ function cimy_registration_check($user_login, $user_email, $errors) {
135
  $label = $thisField['LABEL'];
136
  $description = $thisField['DESCRIPTION'];
137
  $input_name = $prefix.$wpdb->escape($name);
 
138
 
139
  if (isset($_POST[$input_name]))
140
  $value = stripslashes($_POST[$input_name]);
@@ -170,26 +242,36 @@ function cimy_registration_check($user_login, $user_email, $errors) {
170
  if ((!$rules['can_be_empty']) || ($value != "")) {
171
  if (($rules['email']) && (in_array($type, $rule_email))) {
172
  if (!is_email($value))
173
- $errors->add('checkemail'.$name, '<strong>'.__("ERROR", $cimy_uef_domain).'</strong>: '.$label.' '.__('hasn&#8217;t a correct email syntax.', $cimy_uef_domain));
174
  }
175
 
176
  if ((!$rules['can_be_empty']) && (in_array($type, $rule_canbeempty))) {
177
  if ($value == '')
178
- $errors->add('empty'.$name, '<strong>'.__("ERROR", $cimy_uef_domain).'</strong>: '.$label.' '.__('couldn&#8217;t be empty.', $cimy_uef_domain));
179
  }
180
 
181
  if ((isset($rules['equal_to'])) && (in_array($type, $apply_equalto_rule))) {
182
 
183
  $equalTo = $rules['equal_to'];
184
-
185
- if ((!in_array($type, $rule_equalto_case_sensitive)) || (!$rules['equal_to_case_sensitive'])) {
 
 
 
 
 
186
 
187
  $value = strtoupper($value);
188
  $equalTo = strtoupper($equalTo);
189
  }
190
-
191
- if ($value != $equalTo) {
192
-
 
 
 
 
 
193
  if (($type == "radio") || ($type == "checkbox"))
194
  $equalTo == "YES" ? $equalTo = __("YES", $cimy_uef_domain) : __("NO", $cimy_uef_domain);
195
 
@@ -198,14 +280,14 @@ function cimy_registration_check($user_login, $user_email, $errors) {
198
  else
199
  $equalmsg = ' '.__("should be", $cimy_uef_domain).' '.$equalTo;
200
 
201
- $errors->add('equalto'.$name.$field_id, '<strong>'.__("ERROR", $cimy_uef_domain).'</strong>: '.$label.$equalmsg.'.');
202
  }
203
  }
204
 
205
  // CHECK IF IT IS A REAL PICTURE
206
  if (($type == "picture") || ($type == "avatar")) {
207
  if (stristr($file_type, "image/") === false) {
208
- $errors->add('filetype'.$name, '<strong>'.__("ERROR", $cimy_uef_domain).'</strong>: '.$label.' '.__('should be an image.', $cimy_uef_domain));
209
  }
210
  }
211
 
@@ -216,13 +298,13 @@ function cimy_registration_check($user_login, $user_email, $errors) {
216
  if (in_array($type, $cimy_uef_file_types)) {
217
  if ($file_size < $minlen) {
218
 
219
- $errors->add('minlength'.$name, '<strong>'.__("ERROR", $cimy_uef_domain).'</strong>: '.$label.' '.__('couldn&#8217;t have size less than', $cimy_uef_domain).' '.$minlen.' KB.');
220
  }
221
  }
222
  else {
223
  if (strlen($value) < $minlen) {
224
 
225
- $errors->add('minlength'.$name, '<strong>'.__("ERROR", $cimy_uef_domain).'</strong>: '.$label.' '.__('couldn&#8217;t have length less than', $cimy_uef_domain).' '.$minlen.'.');
226
  }
227
  }
228
  }
@@ -234,13 +316,13 @@ function cimy_registration_check($user_login, $user_email, $errors) {
234
  if (in_array($type, $cimy_uef_file_types)) {
235
  if ($file_size != $exactlen) {
236
 
237
- $errors->add('exactlength'.$name, '<strong>'.__("ERROR", $cimy_uef_domain).'</strong>: '.$label.' '.__('couldn&#8217;t have size different than', $cimy_uef_domain).' '.$exactlen.' KB.');
238
  }
239
  }
240
  else {
241
  if (strlen($value) != $exactlen) {
242
 
243
- $errors->add('exactlength'.$name, '<strong>'.__("ERROR", $cimy_uef_domain).'</strong>: '.$label.' '.__('couldn&#8217;t have length different than', $cimy_uef_domain).' '.$exactlen.'.');
244
  }
245
  }
246
  }
@@ -252,13 +334,13 @@ function cimy_registration_check($user_login, $user_email, $errors) {
252
  if (in_array($type, $cimy_uef_file_types)) {
253
  if ($file_size > $maxlen) {
254
 
255
- $errors->add('maxlength'.$name, '<strong>'.__("ERROR", $cimy_uef_domain).'</strong>: '.$label.' '.__('couldn&#8217;t have size more than', $cimy_uef_domain).' '.$maxlen.' KB.');
256
  }
257
  }
258
  else {
259
  if (strlen($value) > $maxlen) {
260
 
261
- $errors->add('maxlength'.$name, '<strong>'.__("ERROR", $cimy_uef_domain).'</strong>: '.$label.' '.__('couldn&#8217;t have length more than', $cimy_uef_domain).' '.$maxlen.'.');
262
  }
263
  }
264
  }
@@ -270,27 +352,34 @@ function cimy_registration_check($user_login, $user_email, $errors) {
270
  return $errors;
271
  }
272
 
273
- function cimy_registration_form() {
274
- global $wpdb, $start_cimy_uef_comment, $end_cimy_uef_comment, $rule_maxlen_needed, $fields_name_prefix, $wp_fields_name_prefix, $is_mu, $cuef_plugin_dir, $wp_version, $cimy_uef_file_types, $cimy_uef_textarea_types;
275
 
276
  // needed by cimy_uef_init_mce.php
277
  $cimy_uef_register_page = true;
278
- $extra_fields = get_cimyFields();
279
  $wp_fields = get_cimyFields(true);
280
 
281
- if (version_compare($wp_version, "2.6.9999", ">") === true) {
282
- $wp_27 = true;
283
- $input_class = "cimy_uef_input_27";
 
 
284
  }
285
  else {
286
- $wp_27 = false;
287
- $input_class = "cimy_uef_input";
 
 
288
  }
289
-
 
 
290
  $tabindex = 21;
291
 
292
  echo $start_cimy_uef_comment;
293
  echo "\t";
 
294
  echo '<input type="hidden" name="cimy_post" value="1" />';
295
  echo "\n";
296
  $radio_checked = array();
@@ -307,6 +396,15 @@ function cimy_registration_form() {
307
  else {
308
  $fields = $extra_fields;
309
  $prefix = $fields_name_prefix;
 
 
 
 
 
 
 
 
 
310
  }
311
 
312
  $i++;
@@ -321,12 +419,15 @@ function cimy_registration_form() {
321
  $type = $thisField['TYPE'];
322
  $label = $thisField['LABEL'];
323
  $description = $thisField['DESCRIPTION'];
 
324
  $input_name = $prefix.attribute_escape($name);
325
  $post_input_name = $prefix.$wpdb->escape($name);
326
  $maxlen = 0;
 
327
 
328
  if (isset($_POST[$post_input_name]))
329
  $value = stripslashes($_POST[$post_input_name]);
 
330
  else if (!isset($_POST["cimy_post"])) {
331
  $value = $thisField['VALUE'];
332
 
@@ -356,28 +457,19 @@ function cimy_registration_form() {
356
 
357
  // if flag to view also in the registration is activated
358
  if ($rules['show_in_reg']) {
359
-
360
- if ($is_mu) {
361
- echo "\t<tr>";
 
 
362
  }
363
-
364
  if (($description != "") && ($type != "registration-date")) {
365
- if ($is_mu) {
366
- echo '<td colspan="2">';
367
- echo "\n\t";
368
- }
369
-
370
  echo "\t";
371
  echo '<p id="'.$prefix.'p_desc_'.$field_id.'" class="desc"><br />'.$description.'</p>';
372
  echo "\n";
373
-
374
- if ($is_mu)
375
- echo "\t</td></tr>\n\t<tr>";
376
  }
377
-
378
- if ($is_mu)
379
- echo "<th>\n\t";
380
-
381
  echo "\t";
382
  echo '<p id="'.$prefix.'p_field_'.$field_id.'">';
383
  echo "\n\t";
@@ -386,7 +478,7 @@ function cimy_registration_form() {
386
  case "picture-url":
387
  case "password":
388
  case "text":
389
- $obj_label = '<label for="'.$prefix.$field_id.'">'.$label.'</label>';
390
  $obj_class = ' class="'.$input_class.'"';
391
  $obj_name = ' name="'.$input_name.'"';
392
 
@@ -407,7 +499,7 @@ function cimy_registration_form() {
407
  $label = $ret['label'];
408
  $html = $ret['html'];
409
 
410
- $obj_label = '<label for="'.$prefix.$field_id.'">'.$label.'</label>';
411
  $obj_class = ' class="'.$input_class.'"';
412
  $obj_name = ' name="'.$input_name.'"';
413
  $obj_type = '';
@@ -419,7 +511,7 @@ function cimy_registration_form() {
419
  break;
420
 
421
  case "textarea":
422
- $obj_label = '<label for="'.$prefix.$field_id.'">'.$label.'</label>';
423
  $obj_class = ' class="'.$input_class.'"';
424
  $obj_name = ' name="'.$input_name.'"';
425
  $obj_type = "";
@@ -436,7 +528,7 @@ function cimy_registration_form() {
436
  else
437
  $tiny_mce_objects .= ",".$fields_name_prefix.$field_id;
438
 
439
- $obj_label = '<label for="'.$prefix.$field_id.'">'.$label.'</label>';
440
  $obj_class = ' class="'.$input_class.'"';
441
  $obj_name = ' name="'.$input_name.'"';
442
  $obj_type = "";
@@ -448,7 +540,7 @@ function cimy_registration_form() {
448
  break;
449
 
450
  case "checkbox":
451
- $obj_label = '<label for="'.$prefix.$field_id.'"> '.$label.'</label><br />';
452
  $obj_class = ' class="cimy_uef_checkbox"';
453
  $obj_name = ' name="'.$input_name.'"';
454
  $obj_type = ' type="'.$type.'"';
@@ -460,7 +552,7 @@ function cimy_registration_form() {
460
  break;
461
 
462
  case "radio":
463
- $obj_label = '<label for="'.$prefix.$field_id.'"> '.$label.'</label>';
464
  $obj_class = ' class="cimy_uef_radio"';
465
  $obj_name = ' name="'.$input_name.'"';
466
  $obj_type = ' type="'.$type.'"';
@@ -484,13 +576,13 @@ function cimy_registration_form() {
484
  case "picture":
485
  // javascript will be added later
486
  $upload_image_function = true;
487
- $obj_label = '<label for="'.$prefix.$field_id.'">'.$label.' </label>';
488
  $obj_class = ' class="cimy_uef_picture"';
489
  $obj_name = ' name="'.$input_name.'"';
490
  $obj_type = ' type="file"';
491
  $obj_value = ' value="'.$value.'"';
492
  $obj_value2 = "";
493
- $obj_checked = ' onchange="uploadPic(\'registerform\', \''.$prefix.$field_id.'\', \''.__("Please upload an image with one of the following extensions", $cimy_uef_domain).'\');"';
494
  $obj_tag = "input";
495
  $obj_closing_tag = false;
496
  break;
@@ -508,10 +600,16 @@ function cimy_registration_form() {
508
  break;
509
  }
510
 
511
- $obj_id = ' id="'.$prefix.$field_id.'"';
512
- $obj_tabindex = ' tabindex="'.strval($tabindex).'"';
513
- $tabindex++;
514
-
 
 
 
 
 
 
515
  $obj_maxlen = "";
516
 
517
  if ((in_array($type, $rule_maxlen_needed)) && (!in_array($type, $cimy_uef_file_types))) {
@@ -535,24 +633,22 @@ function cimy_registration_form() {
535
  else
536
  $form_object.= " />";
537
 
538
- if ((($type != "radio") && ($type != "checkbox")) || ($is_mu))
539
  echo $obj_label;
540
-
541
  if ($is_mu) {
542
- echo "\n\t\t</p>";
543
- echo "\n\t</th>\n\t<td>\n\t\t";
 
544
  }
545
-
546
  // write to the html the form object built
547
  echo $form_object;
548
 
549
- if (!((($type != "radio") && ($type != "checkbox")) || ($is_mu)))
550
  echo $obj_label;
551
-
552
- if ($is_mu)
553
- echo "\n\t</td></tr>\n";
554
- else
555
- echo "\n\t</p>\n";
556
 
557
  if ((($type == "textarea-rich") || (in_array($type, $cimy_uef_file_types))) && ($wp_27))
558
  echo "\t<br />\n";
1
  <?php
2
 
3
+ function cimy_register_user_extra_hidden_fields_stage2() {
4
+ global $start_cimy_uef_comment, $end_cimy_uef_comment;
5
+
6
+ echo "\n".$start_cimy_uef_comment;
7
+
8
+ foreach ($_POST as $name=>$value) {
9
+ if (!(stristr($name, "cimy_uef_")) === FALSE) {
10
+ echo "\t\t<input type=\"hidden\" name=\"".$name."\" value=\"".attribute_escape($value)."\" />\n";
11
+ }
12
+ }
13
+
14
+ echo $end_cimy_uef_comment;
15
+ }
16
+
17
+ function cimy_register_user_extra_fields_signup_meta($meta) {
18
+ foreach ($_POST as $name=>$value) {
19
+ if (!(stristr($name, "cimy_uef_")) === FALSE) {
20
+ $meta[$name] = $value;
21
+ }
22
+ }
23
+
24
+ return $meta;
25
+ }
26
+
27
+ function cimy_register_user_extra_fields_mu_wrapper($blog_id, $user_id, $password, $signup, $meta) {
28
+ cimy_register_user_extra_fields($user_id, $password, $meta);
29
+ }
30
+
31
+ function cimy_register_mu_overwrite_password($password) {
32
+ global $wpdb;
33
+
34
+ if (!empty($_GET['key']))
35
+ $key = $_GET['key'];
36
+ else
37
+ $key = $_POST['key'];
38
+
39
+ if (!empty($key)) {
40
+ // seems useless since this code cannot be reached with a bad key anyway you never know
41
+ $key = $wpdb->escape($key);
42
+
43
+ $sql = "SELECT active, meta FROM ".$wpdb->signups." WHERE activation_key='".$key."'";
44
+ $data = $wpdb->get_results($sql);
45
+
46
+ // is there something?
47
+ if (isset($data[0])) {
48
+ // if not already active
49
+ if (!$data[0]->active) {
50
+ $meta = unserialize($data[0]->meta);
51
+
52
+ if (!empty($meta["cimy_uef_wp_PASSWORD"])) {
53
+ $password = $meta["cimy_uef_wp_PASSWORD"];
54
+ }
55
+ }
56
+ }
57
+ }
58
+
59
+ return $password;
60
+ }
61
+
62
+ function cimy_register_user_extra_fields($user_id, $password="", $meta=array()) {
63
  global $wpdb_data_table, $wpdb, $max_length_value, $fields_name_prefix, $wp_fields_name_prefix, $wp_hidden_fields;
64
 
65
+ $extra_fields = get_cimyFields(false, true);
66
  $wp_fields = get_cimyFields(true);
67
 
68
  $i = 1;
93
 
94
  // if flag to view also in the registration is activated
95
  if ($rules['show_in_reg']) {
96
+ if (isset($meta[$input_name]))
97
+ $data = stripslashes($meta[$input_name]);
98
+ else if (isset($_POST[$input_name]))
99
  $data = stripslashes($_POST[$input_name]);
100
  else
101
  $data = "";
166
  }
167
  }
168
 
169
+ function cimy_registration_check_mu_wrapper($data) {
170
+ $user_login = $data['user_name'];
171
+ $user_email = $data['user_email'];
172
+ $errors = $data['errors'];
173
+
174
+ $data['errors'] = cimy_registration_check($user_login, $user_email, $errors);
175
+
176
+ return $data;
177
+ }
178
+
179
  function cimy_registration_check($user_login, $user_email, $errors) {
180
+ global $wpdb, $rule_canbeempty, $rule_email, $rule_maxlen, $fields_name_prefix, $wp_fields_name_prefix, $rule_equalto_case_sensitive, $apply_equalto_rule, $cimy_uef_domain, $cimy_uef_file_types, $rule_equalto_regex;
181
 
182
+ $extra_fields = get_cimyFields(false, true);
183
  $wp_fields = get_cimyFields(true);
184
 
185
  $i = 1;
206
  $label = $thisField['LABEL'];
207
  $description = $thisField['DESCRIPTION'];
208
  $input_name = $prefix.$wpdb->escape($name);
209
+ $unique_id = $prefix.$field_id;
210
 
211
  if (isset($_POST[$input_name]))
212
  $value = stripslashes($_POST[$input_name]);
242
  if ((!$rules['can_be_empty']) || ($value != "")) {
243
  if (($rules['email']) && (in_array($type, $rule_email))) {
244
  if (!is_email($value))
245
+ $errors->add($unique_id, '<strong>'.__("ERROR", $cimy_uef_domain).'</strong>: '.$label.' '.__('hasn&#8217;t a correct email syntax.', $cimy_uef_domain));
246
  }
247
 
248
  if ((!$rules['can_be_empty']) && (in_array($type, $rule_canbeempty))) {
249
  if ($value == '')
250
+ $errors->add($unique_id, '<strong>'.__("ERROR", $cimy_uef_domain).'</strong>: '.$label.' '.__('couldn&#8217;t be empty.', $cimy_uef_domain));
251
  }
252
 
253
  if ((isset($rules['equal_to'])) && (in_array($type, $apply_equalto_rule))) {
254
 
255
  $equalTo = $rules['equal_to'];
256
+ // if the type is not allowed to be case sensitive
257
+ // OR if case sensitive is not checked
258
+ // AND
259
+ // if the type is not allowed to be a regex
260
+ // OR if regex rule is not set
261
+ // THEN switch to uppercase
262
+ if (((!in_array($type, $rule_equalto_case_sensitive)) || (!$rules['equal_to_case_sensitive'])) && ((!in_array($type, $rule_equalto_regex)) || (!$rules['equal_to_regex']))) {
263
 
264
  $value = strtoupper($value);
265
  $equalTo = strtoupper($equalTo);
266
  }
267
+
268
+ if ($rules['equal_to_regex']) {
269
+ if (!preg_match($equalTo, $value)) {
270
+ $equalmsg = " ".__("isn&#8217;t correct", $cimy_uef_domain);
271
+ $errors->add($unique_id, '<strong>'.__("ERROR", $cimy_uef_domain).'</strong>: '.$label.$equalmsg.'.');
272
+ }
273
+ }
274
+ else if ($value != $equalTo) {
275
  if (($type == "radio") || ($type == "checkbox"))
276
  $equalTo == "YES" ? $equalTo = __("YES", $cimy_uef_domain) : __("NO", $cimy_uef_domain);
277
 
280
  else
281
  $equalmsg = ' '.__("should be", $cimy_uef_domain).' '.$equalTo;
282
 
283
+ $errors->add($unique_id, '<strong>'.__("ERROR", $cimy_uef_domain).'</strong>: '.$label.$equalmsg.'.');
284
  }
285
  }
286
 
287
  // CHECK IF IT IS A REAL PICTURE
288
  if (($type == "picture") || ($type == "avatar")) {
289
  if (stristr($file_type, "image/") === false) {
290
+ $errors->add($unique_id, '<strong>'.__("ERROR", $cimy_uef_domain).'</strong>: '.$label.' '.__('should be an image.', $cimy_uef_domain));
291
  }
292
  }
293
 
298
  if (in_array($type, $cimy_uef_file_types)) {
299
  if ($file_size < $minlen) {
300
 
301
+ $errors->add($unique_id, '<strong>'.__("ERROR", $cimy_uef_domain).'</strong>: '.$label.' '.__('couldn&#8217;t have size less than', $cimy_uef_domain).' '.$minlen.' KB.');
302
  }
303
  }
304
  else {
305
  if (strlen($value) < $minlen) {
306
 
307
+ $errors->add($unique_id, '<strong>'.__("ERROR", $cimy_uef_domain).'</strong>: '.$label.' '.__('couldn&#8217;t have length less than', $cimy_uef_domain).' '.$minlen.'.');
308
  }
309
  }
310
  }
316
  if (in_array($type, $cimy_uef_file_types)) {
317
  if ($file_size != $exactlen) {
318
 
319
+ $errors->add($unique_id, '<strong>'.__("ERROR", $cimy_uef_domain).'</strong>: '.$label.' '.__('couldn&#8217;t have size different than', $cimy_uef_domain).' '.$exactlen.' KB.');
320
  }
321
  }
322
  else {
323
  if (strlen($value) != $exactlen) {
324
 
325
+ $errors->add($unique_id, '<strong>'.__("ERROR", $cimy_uef_domain).'</strong>: '.$label.' '.__('couldn&#8217;t have length different than', $cimy_uef_domain).' '.$exactlen.'.');
326
  }
327
  }
328
  }
334
  if (in_array($type, $cimy_uef_file_types)) {
335
  if ($file_size > $maxlen) {
336
 
337
+ $errors->add($unique_id, '<strong>'.__("ERROR", $cimy_uef_domain).'</strong>: '.$label.' '.__('couldn&#8217;t have size more than', $cimy_uef_domain).' '.$maxlen.' KB.');
338
  }
339
  }
340
  else {
341
  if (strlen($value) > $maxlen) {
342
 
343
+ $errors->add($unique_id, '<strong>'.__("ERROR", $cimy_uef_domain).'</strong>: '.$label.' '.__('couldn&#8217;t have length more than', $cimy_uef_domain).' '.$maxlen.'.');
344
  }
345
  }
346
  }
352
  return $errors;
353
  }
354
 
355
+ function cimy_registration_form($errors=null) {
356
+ global $wpdb, $start_cimy_uef_comment, $end_cimy_uef_comment, $rule_maxlen_needed, $fields_name_prefix, $wp_fields_name_prefix, $is_mu, $cuef_plugin_dir, $cimy_uef_file_types, $cimy_uef_textarea_types, $wp_27;
357
 
358
  // needed by cimy_uef_init_mce.php
359
  $cimy_uef_register_page = true;
360
+ $extra_fields = get_cimyFields(false, true);
361
  $wp_fields = get_cimyFields(true);
362
 
363
+ if ($wp_27) {
364
+ if ($is_mu)
365
+ $input_class = "cimy_uef_input_mu";
366
+ else
367
+ $input_class = "cimy_uef_input_27";
368
  }
369
  else {
370
+ if ($is_mu)
371
+ $input_class = "cimy_uef_input_mu";
372
+ else
373
+ $input_class = "cimy_uef_input";
374
  }
375
+
376
+ $options = cimy_get_options();
377
+
378
  $tabindex = 21;
379
 
380
  echo $start_cimy_uef_comment;
381
  echo "\t";
382
+ // needed to apply default values only first time and not in case of errors
383
  echo '<input type="hidden" name="cimy_post" value="1" />';
384
  echo "\n";
385
  $radio_checked = array();
396
  else {
397
  $fields = $extra_fields;
398
  $prefix = $fields_name_prefix;
399
+ $current_fieldset = 0;
400
+
401
+ if ($options['fieldset_title'] != "")
402
+ $fieldset_titles = explode(',', $options['fieldset_title']);
403
+ else
404
+ $fieldset_titles = array();
405
+
406
+ if (isset($fieldset_titles[$current_fieldset]))
407
+ echo "\n\t<h2>".$fieldset_titles[$current_fieldset]."</h2>\n";
408
  }
409
 
410
  $i++;
419
  $type = $thisField['TYPE'];
420
  $label = $thisField['LABEL'];
421
  $description = $thisField['DESCRIPTION'];
422
+ $fieldset = $thisField['FIELDSET'];
423
  $input_name = $prefix.attribute_escape($name);
424
  $post_input_name = $prefix.$wpdb->escape($name);
425
  $maxlen = 0;
426
+ $unique_id = $prefix.$field_id;
427
 
428
  if (isset($_POST[$post_input_name]))
429
  $value = stripslashes($_POST[$post_input_name]);
430
+ // if there is no value and not $_POST means is first visiting then put all default values
431
  else if (!isset($_POST["cimy_post"])) {
432
  $value = $thisField['VALUE'];
433
 
457
 
458
  // if flag to view also in the registration is activated
459
  if ($rules['show_in_reg']) {
460
+ if (($fieldset > $current_fieldset) && (isset($fieldset_titles[$fieldset])) && ($i != 1)) {
461
+ $current_fieldset = $fieldset;
462
+
463
+ if (isset($fieldset_titles[$current_fieldset]))
464
+ echo "\n\t<h2>".$fieldset_titles[$current_fieldset]."</h2>\n";
465
  }
466
+
467
  if (($description != "") && ($type != "registration-date")) {
 
 
 
 
 
468
  echo "\t";
469
  echo '<p id="'.$prefix.'p_desc_'.$field_id.'" class="desc"><br />'.$description.'</p>';
470
  echo "\n";
 
 
 
471
  }
472
+
 
 
 
473
  echo "\t";
474
  echo '<p id="'.$prefix.'p_field_'.$field_id.'">';
475
  echo "\n\t";
478
  case "picture-url":
479
  case "password":
480
  case "text":
481
+ $obj_label = '<label for="'.$unique_id.'">'.$label.'</label>';
482
  $obj_class = ' class="'.$input_class.'"';
483
  $obj_name = ' name="'.$input_name.'"';
484
 
499
  $label = $ret['label'];
500
  $html = $ret['html'];
501
 
502
+ $obj_label = '<label for="'.$unique_id.'">'.$label.'</label>';
503
  $obj_class = ' class="'.$input_class.'"';
504
  $obj_name = ' name="'.$input_name.'"';
505
  $obj_type = '';
511
  break;
512
 
513
  case "textarea":
514
+ $obj_label = '<label for="'.$unique_id.'">'.$label.'</label>';
515
  $obj_class = ' class="'.$input_class.'"';
516
  $obj_name = ' name="'.$input_name.'"';
517
  $obj_type = "";
528
  else
529
  $tiny_mce_objects .= ",".$fields_name_prefix.$field_id;
530
 
531
+ $obj_label = '<label for="'.$unique_id.'">'.$label.'</label>';
532
  $obj_class = ' class="'.$input_class.'"';
533
  $obj_name = ' name="'.$input_name.'"';
534
  $obj_type = "";
540
  break;
541
 
542
  case "checkbox":
543
+ $obj_label = '<label class="cimy_uef_label_checkbox" for="'.$unique_id.'"> '.$label.'</label><br />';
544
  $obj_class = ' class="cimy_uef_checkbox"';
545
  $obj_name = ' name="'.$input_name.'"';
546
  $obj_type = ' type="'.$type.'"';
552
  break;
553
 
554
  case "radio":
555
+ $obj_label = '<label class="cimy_uef_label_radio" for="'.$unique_id.'"> '.$label.'</label>';
556
  $obj_class = ' class="cimy_uef_radio"';
557
  $obj_name = ' name="'.$input_name.'"';
558
  $obj_type = ' type="'.$type.'"';
576
  case "picture":
577
  // javascript will be added later
578
  $upload_image_function = true;
579
+ $obj_label = '<label for="'.$unique_id.'">'.$label.' </label>';
580
  $obj_class = ' class="cimy_uef_picture"';
581
  $obj_name = ' name="'.$input_name.'"';
582
  $obj_type = ' type="file"';
583
  $obj_value = ' value="'.$value.'"';
584
  $obj_value2 = "";
585
+ $obj_checked = ' onchange="uploadPic(\'registerform\', \''.$unique_id.'\', \''.__("Please upload an image with one of the following extensions", $cimy_uef_domain).'\');"';
586
  $obj_tag = "input";
587
  $obj_closing_tag = false;
588
  break;
600
  break;
601
  }
602
 
603
+ $obj_id = ' id="'.$unique_id.'"';
604
+
605
+ // tabindex not used in MU, dropping...
606
+ if ($is_mu)
607
+ $obj_tabindex = "";
608
+ else {
609
+ $obj_tabindex = ' tabindex="'.strval($tabindex).'"';
610
+ $tabindex++;
611
+ }
612
+
613
  $obj_maxlen = "";
614
 
615
  if ((in_array($type, $rule_maxlen_needed)) && (!in_array($type, $cimy_uef_file_types))) {
633
  else
634
  $form_object.= " />";
635
 
636
+ if (($type != "radio") && ($type != "checkbox"))
637
  echo $obj_label;
638
+
639
  if ($is_mu) {
640
+ if ( $errmsg = $errors->get_error_message($unique_id) ) {
641
+ echo '<p class="error">'.$errmsg.'</p>';
642
+ }
643
  }
644
+
645
  // write to the html the form object built
646
  echo $form_object;
647
 
648
+ if (!(($type != "radio") && ($type != "checkbox")))
649
  echo $obj_label;
650
+
651
+ echo "\n\t</p>\n";
 
 
 
652
 
653
  if ((($type == "textarea-rich") || (in_array($type, $cimy_uef_file_types))) && ($wp_27))
654
  echo "\t<br />\n";
cimy_user_extra_fields.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Cimy User Extra Fields
4
  Plugin URI: http://www.marcocimmino.net/cimy-wordpress-plugins/cimy-user-extra-fields/
5
  Plugin Description: Add some useful fields to registration and user's info
6
- Version: 1.3.2
7
  Author: Marco Cimmino
8
  Author URI: mailto:cimmino.marco@gmail.com
9
  */
@@ -14,6 +14,7 @@ Cimy User Extra Fields - Allows adding mySQL Data fields to store/add more user
14
  Copyright (c) 2006-2009 Marco Cimmino
15
 
16
  Code for drop-down support is in part from Raymond Elferink raymond@raycom.com
 
17
 
18
  This program is free software; you can redistribute it and/or
19
  modify it under the terms of the GNU General Public License
@@ -35,9 +36,9 @@ The full copy of the GNU General Public License is available here: http://www.gn
35
  */
36
 
37
  // added for WordPress >=2.5 compatibility
38
- global $wpdb, $old_wpdb_data_table, $wpdb_data_table, $old_wpdb_fields_table, $wpdb_fields_table, $wpdb_wp_fields_table, $cimy_uef_options, $cimy_uef_version, $is_mu, $cuef_upload_path, $cimy_uef_domain;
39
 
40
- if (!stristr($wp_version, "mu") === FALSE) {
41
  $is_mu = true;
42
 
43
  $old_wpdb_data_table = $wpmuBaseTablePrefix."cimy_data";
@@ -58,6 +59,13 @@ else {
58
  $wpdb_wp_fields_table = $wpdb->prefix."cimy_uef_wp_fields";
59
  }
60
 
 
 
 
 
 
 
 
61
  $cimy_uef_options = "cimy_uef_options";
62
  $cimy_uef_options_descr = "Cimy User Extra Fields options are stored here and modified only by admin";
63
 
@@ -93,7 +101,10 @@ RULES (stored into an associative array and serialized):
93
  [all except avatar]
94
 
95
  - 'equal_to_case_sensitive': [true | false] => equal_to if selected can be case sensitive or not
96
- [only for text, textarea, password, dropdown]
 
 
 
97
 
98
  - 'show_in_reg': [true | false] => field is visible or not in the registration
99
  [all]
@@ -132,12 +143,20 @@ $cuef_upload_path = WP_CONTENT_DIR."/Cimy_User_Extra_Fields/";
132
  $cuef_upload_webpath = WP_CONTENT_URL."/Cimy_User_Extra_Fields/";
133
 
134
  if ($is_mu) {
135
- $cuef_plugin_dir = WP_CONTENT_DIR."/mu-plugins/".$cuef_plugin_path;
 
 
 
 
 
 
 
136
  $cuef_css_webpath = WP_CONTENT_URL."/mu-plugins/".$cuef_plugin_path."css/";
137
  $cuef_js_webpath = WP_CONTENT_URL."/mu-plugins/".$cuef_plugin_path."js/";
138
  }
139
  else {
140
  $cuef_plugin_dir = WP_CONTENT_DIR."/plugins/".$cuef_plugin_path;
 
141
  $cuef_css_webpath = WP_CONTENT_URL."/plugins/".$cuef_plugin_path."css/";
142
  $cuef_js_webpath = WP_CONTENT_URL."/plugins/".$cuef_plugin_path."js/";
143
  }
@@ -154,7 +173,7 @@ require_once($cuef_plugin_dir.'/cimy_uef_options.php');
154
  require_once($cuef_plugin_dir.'/cimy_uef_admin.php');
155
 
156
  $cimy_uef_name = "Cimy User Extra Fields";
157
- $cimy_uef_version = "1.3.2";
158
  $cimy_uef_url = "http://www.marcocimmino.net/cimy-wordpress-plugins/cimy-user-extra-fields/";
159
 
160
  $start_cimy_uef_comment = "<!--\n";
@@ -168,16 +187,21 @@ $end_cimy_uef_comment .= "\tEnd of code from ".$cimy_uef_name."\n";
168
  $end_cimy_uef_comment .= "-->\n";
169
 
170
  $cimy_uef_domain = 'cimy_uef';
171
- $cimy_uef_i18n_is_setup = 0;
172
  cimy_uef_i18n_setup();
173
 
 
 
 
 
 
174
  $wp_hidden_fields = array(
175
  'password' => array(
176
  'name' => "PASSWORD",
177
  'post_name' => "user_pass",
178
  'type' => "password",
179
  'label' => __("Password"),
180
- 'desc' => __('<strong>Note:</strong> this website let you personalize your password; after the registration you will receive an e-mail with another password, do not care about that!', $cimy_uef_domain),
181
  'value' => '',
182
  'store_rule' => array(
183
  'max_length' => 100,
@@ -328,10 +352,10 @@ $wp_hidden_fields = array(
328
  );
329
 
330
  // strong illegal charset
331
- $strong_illegal_chars = "/(\%27)|(\/)|(\\\)|(\[)|(\])|(\')|(\")|(\<)|(\>)|(\-\-)|(\%23)|(\#)/ix";
332
 
333
  // light illegal charset
334
- $light_illegal_chars = "/(\%27)|(\/)|(\\\)|(\[)|(\])|(\-\-)|(\%23)|(\#)/ix";
335
 
336
  // all available types
337
  $available_types = array("text", "textarea", "textarea-rich", "password", "checkbox", "radio", "dropdown", "picture", "picture-url", "registration-date", "avatar");
@@ -360,6 +384,9 @@ $rule_equalto = array("text", "textarea", "textarea-rich", "password", "checkbox
360
  // types that can have 'case (in)sensitive equal to' rule
361
  $rule_equalto_case_sensitive = array("text", "textarea", "textarea-rich", "password", "dropdown");
362
 
 
 
 
363
  // types that are file to be uploaded
364
  $cimy_uef_file_types = array("picture", "avatar");
365
 
@@ -379,15 +406,64 @@ $max_size_file = 20000;
379
  $fields_name_prefix = "cimy_uef_";
380
  $wp_fields_name_prefix = "cimy_uef_wp_";
381
 
382
- // add checks for extra fields in the registration form
383
- add_action('register_post', 'cimy_registration_check', 10, 3);