Cimy User Extra Fields - Version 2.3.3

Version Description

Download this release

Release Info

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

Code changes from version 2.3.2 to 2.3.3

README_OFFICIAL.txt CHANGED
@@ -619,6 +619,13 @@ A lot of times I cannot reproduce the problem and I need more details, so if you
619
 
620
 
621
  CHANGELOG:
 
 
 
 
 
 
 
622
  v2.3.2 - 14/12/2011
623
  - Fixed image upload was no more possible in some cases under WordPress MS (introduced with v2.3.0) (thanks to Alexander Temper)
624
  - Fixed a rare case of site crash under WordPress MS registration (thanks to Dan)
619
 
620
 
621
  CHANGELOG:
622
+ v2.3.3 - 29/12/2011
623
+ - Fixed image/file/avatar upload when Theme My Login is in use (introduced with v2.3.0) (thanks to Brandon Krakowsky)
624
+ - Fixed password meter and textarea-rich were not working after submitting a registration with some errors when form confirmation is turned on (introduced with v2.3.0)
625
+ - Fixed a lot of PHP warnings
626
+ - Code cleanup
627
+ - Added Belarusian translation (Alexander Ovsov)
628
+
629
  v2.3.2 - 14/12/2011
630
  - Fixed image upload was no more possible in some cases under WordPress MS (introduced with v2.3.0) (thanks to Alexander Temper)
631
  - Fixed a rare case of site crash under WordPress MS registration (thanks to Dan)
cimy_uef_admin.php CHANGED
@@ -220,17 +220,16 @@ function cimy_admin_define_extra_fields() {
220
  $label = substr(stripslashes($_POST['label'][$field_order]), 0, $max_length_label);
221
 
222
  $name = strtoupper($name);
223
- $oldname = strtoupper(stripslashes($_POST['oldname'][$field_order]));
224
  $type = $_POST['type'][$field_order];
225
- $fieldset = $_POST['fieldset'][$field_order];
 
 
 
226
 
227
- $minlen = $_POST['minlen'][$field_order];
228
- $exactlen = $_POST['exactlen'][$field_order];
229
- $maxlen = $_POST['maxlen'][$field_order];
230
-
231
  // min length available
232
  $minLen = 1;
233
-
234
  // max length or size for picture available
235
  if (in_array($type, $cimy_uef_file_types)) {
236
  $maxLen = $max_size_file;
@@ -254,45 +253,28 @@ function cimy_admin_define_extra_fields() {
254
 
255
  if (!empty($maxlen))
256
  $store_rule['max_length'] = intval($_POST['maxlength'][$field_order]);
257
-
258
- $empty = $_POST['empty'][$field_order];
259
- $empty == "1" ? $store_rule['can_be_empty'] = true : $store_rule['can_be_empty'] = false;
260
 
 
261
  $store_rule['edit'] = $_POST['edit'][$field_order];
262
-
263
- $email = $_POST['email'][$field_order];
264
- $email == "1" ? $store_rule['email'] = true : $store_rule['email'] = false;
265
- $equal = $_POST['equal'][$field_order];
266
-
267
- if (!empty($equal)) {
268
- $store_rule['equal_to'] = stripslashes($_POST['equalto'][$field_order]);
269
-
270
- $equalto_casesens = $_POST['equalto_casesens'][$field_order];
271
 
272
- $equalto_regex = $_POST['equalto_regex'][$field_order];
 
 
 
 
273
  }
274
 
275
  $store_rule["advanced_options"] = stripslashes($_POST['advanced_options'][$field_order]);
276
- $show_in_reg = $_POST['show_in_reg'][$field_order];
277
- $show_in_reg == "1" ? $store_rule['show_in_reg'] = true : $store_rule['show_in_reg'] = false;
278
-
279
- $show_in_profile = $_POST['show_in_profile'][$field_order];
280
- $show_in_profile == "1" ? $store_rule['show_in_profile'] = true : $store_rule['show_in_profile'] = false;
281
-
282
- $show_in_aeu = $_POST['show_in_aeu'][$field_order];
283
- $show_in_aeu == "1" ? $store_rule['show_in_aeu'] = true : $store_rule['show_in_aeu'] = false;
284
-
285
- $show_in_search = $_POST['show_in_search'][$field_order];
286
- $show_in_search == "1" ? $store_rule['show_in_search'] = true : $store_rule['show_in_search'] = false;
287
-
288
- $show_in_blog = $_POST['show_in_blog'][$field_order];
289
- $show_in_blog == "1" ? $store_rule['show_in_blog'] = true : $store_rule['show_in_blog'] = false;
290
 
291
  $show_level = $_POST['show_level'][$field_order];
292
  $store_rule['show_level'] = $show_level;
293
-
294
- $email_admin = $_POST['email_admin'][$field_order];
295
- $email_admin == "1" ? $store_rule['email_admin'] = true : $store_rule['email_admin'] = false;
296
 
297
  // START CHECKING FOR ERRORS
298
  if (empty($name))
@@ -351,7 +333,7 @@ function cimy_admin_define_extra_fields() {
351
  else
352
  $store_rule['equal_to_case_sensitive'] = false;
353
 
354
- if (($equalto_regex != "") && (in_array($type, $rule_equalto_regex)))
355
  $store_rule['equal_to_regex'] = true;
356
  else
357
  $store_rule['equal_to_regex'] = false;
@@ -445,13 +427,13 @@ function cimy_admin_define_extra_fields() {
445
  // print errors if there are some
446
  cimy_uef_print_messages($errors, $results);
447
 
448
- if ($store_rule['min_length'] == 0)
449
  unset($store_rule['min_length']);
450
 
451
- if ($store_rule['exact_length'] == 0)
452
  unset($store_rule['exact_length']);
453
 
454
- if ($store_rule['max_length'] == 0)
455
  unset($store_rule['max_length']);
456
 
457
  if (!isset($store_rule['show_level']))
@@ -470,12 +452,7 @@ function cimy_admin_define_extra_fields() {
470
  $selected_input["min_length"] = '';
471
  $selected_input["exact_length"] = '';
472
  $selected_input["max_length"] = '';
473
- $selected_input["equal"] = '';
474
  $selected_input["equal_to"] = '';
475
- $selected_input["equal_to_case_sensitive"] = '';
476
- $selected_input["equal_to_regex"] = '';
477
- $selected_input["email"] = '';
478
- $selected_input["email_admin"] = '';
479
  $selected_input["minlen"] = '';
480
  $selected_input["exactlen"] = '';
481
  $selected_input["maxlen"] = '';
@@ -511,37 +488,19 @@ function cimy_admin_define_extra_fields() {
511
  if (isset($store_rule['max_length']))
512
  $selected_input["max_length"] = $store_rule['max_length'];
513
 
514
- // EQUAL TO
515
- if (isset($equal))
516
- $selected_input["equal"] = ' checked="checked"';
517
-
518
  if (isset($store_rule['equal_to']))
519
  $selected_input["equal_to"] = $store_rule['equal_to'];
520
 
521
- if (isset($equalto_casesens))
522
- $selected_input["equal_to_case_sensitive"] = ' checked="checked"';
523
-
524
- if (isset($equalto_regex))
525
- $selected_input["equal_to_regex"] = ' checked="checked"';
526
-
527
- // CHECK EMAIL SYNTAX
528
- if ($store_rule['email'] == true)
529
- $selected_input["email"] = ' checked="checked"';
530
-
531
  // ADVANCED OPTIONS
532
  if (isset($store_rule['advanced_options']))
533
  $selected_input["advanced_options"] = $store_rule['advanced_options'];
534
-
535
- // EMAIL ADMIN
536
- if ($store_rule['email_admin'] == true)
537
- $selected_input["email_admin"] = ' checked="checked"';
538
  }
539
  // action is not "add"
540
  else {
541
  }
542
 
543
  // CAN BE EMPTY
544
- if (($store_rule['can_be_empty'] == true) || ($action != "add"))
545
  $selected_input["empty"] = ' checked="checked"';
546
  else
547
  $selected_input["empty"] = '';
@@ -632,7 +591,7 @@ function cimy_admin_define_extra_fields() {
632
  <input type="checkbox" name="maxlen[0]" value="1"<?php echo $selected_input["maxlen"]; ?> /> <?php echo $max_length_caption; ?> [1-<?php echo $maxLen; ?>]: &nbsp;&nbsp;<input type="text" name="maxlength[0]" value="<?php echo $selected_input["max_length"]; ?>" maxlength="5" size="5" /><br />
633
 
634
  <input type="checkbox" name="empty[0]" value="1"<?php echo $selected_input["empty"]; ?> /> <?php _e("Can be empty", $cimy_uef_domain); ?><br />
635
- <input type="checkbox" name="email[0]" value="1"<?php echo $selected_input["email"]; ?> /> <?php _e("Check for E-mail syntax", $cimy_uef_domain); ?><br />
636
 
637
  <select name="edit[0]">
638
  <option value="ok_edit"<?php selected('ok_edit', $store_rule['edit'], true); ?>><?php _e("Can be modified", $cimy_uef_domain); ?></option>
@@ -643,12 +602,12 @@ function cimy_admin_define_extra_fields() {
643
  </select>
644
  <br />
645
  <!-- EQUAL TO -->
646
- <input type="checkbox" name="equal[0]" value="1"<?php echo $selected_input["equal"]; ?> /> <?php _e("Should be equal TO", $cimy_uef_domain); ?>: <input type="text" name="equalto[0]" maxlength="500" value="<?php echo $selected_input["equal_to"]; ?>"/><br />
647
  <!-- CASE SENSITIVE -->
648
- &nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="equalto_casesens[0]" value="1"<?php echo $selected_input["equal_to_case_sensitive"]; ?> /> <?php _e("Case sensitive", $cimy_uef_domain); ?><br />
649
 
650
  <!-- REGEX -->
651
- &nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="equalto_regex[0]" value="1"<?php echo $selected_input["equal_to_regex"]; ?> /> <?php _e("Regular Expression", $cimy_uef_domain); ?><br />
652
 
653
  <!-- SHOW IN REGISTRATION -->
654
  <input type="checkbox" name="show_in_reg[0]" value="1"<?php echo $selected_input["show_in_reg"]; ?> /> <?php _e("Show the field in the registration", $cimy_uef_domain); ?><br />
@@ -679,7 +638,7 @@ function cimy_admin_define_extra_fields() {
679
  <br />
680
 
681
  <!-- EMAIL ADMIN -->
682
- <input type="checkbox" name="email_admin[0]" value="1"<?php echo $selected_input["email_admin"]; ?> /> <?php _e("Send an email to the admin if the user changes its value", $cimy_uef_domain); ?><br />
683
  <!-- ADVANCED OPTIONS -->
684
  <?php _e("Advanced options", $cimy_uef_domain); ?>: <input type="text" name="advanced_options[0]" maxlength="500" value="<?php echo $selected_input["advanced_options"]; ?>"/><br />
685
 
@@ -824,8 +783,8 @@ function cimy_admin_show_extra_fields($allFields, $submit_msgs, $wp_fields, $err
824
  $label = esc_attr($field['LABEL']);
825
  $type = $field['TYPE'];
826
  $rules = $field['RULES'];
827
- $fieldset = $field["FIELDSET"];
828
  if (!$wp_fields) {
 
829
  $javascripts_dep = cimy_uef_set_javascript_dependencies($javascripts_dep, $type, "show_in_reg", $rules["show_in_reg"]);
830
  $javascripts_dep = cimy_uef_set_javascript_dependencies($javascripts_dep, $type, "show_in_profile", $rules["show_in_profile"]);
831
  $javascripts_dep = cimy_uef_set_javascript_dependencies($javascripts_dep, $type, "show_in_aeu", $rules["show_in_aeu"]);
@@ -1034,8 +993,7 @@ function cimy_admin_show_extra_fields($allFields, $submit_msgs, $wp_fields, $err
1034
 
1035
  <?php
1036
  // this will help me to track down the javascript dependencies without looping through all fields too many times
1037
- if (!$wp_fields) {
1038
- $options = cimy_get_options();
1039
  $options['file_fields'] = $javascripts_dep['file_fields'];
1040
  $options['image_fields'] = $javascripts_dep['image_fields'];
1041
  $options['tinymce_fields'] = $javascripts_dep['tinymce_fields'];
@@ -1843,6 +1801,7 @@ function cimy_save_field($action, $table, $data) {
1843
  $fieldset_sql = "";
1844
  }
1845
  else {
 
1846
  $fieldset = intval($data['fieldset']);
1847
  $fieldset_sql = ", fieldset=".$fieldset;
1848
  }
220
  $label = substr(stripslashes($_POST['label'][$field_order]), 0, $max_length_label);
221
 
222
  $name = strtoupper($name);
223
+ $oldname = isset($_POST['oldname'][$field_order]) ? strtoupper(stripslashes($_POST['oldname'][$field_order])) : '';
224
  $type = $_POST['type'][$field_order];
225
+ $fieldset = isset($_POST['fieldset'][$field_order]) ? $_POST['fieldset'][$field_order] : '';
226
+ $minlen = isset($_POST['minlen'][$field_order]) ? $_POST['minlen'][$field_order] : '';
227
+ $exactlen = isset($_POST['exactlen'][$field_order]) ? $_POST['exactlen'][$field_order] : '';
228
+ $maxlen = isset($_POST['maxlen'][$field_order]) ? $_POST['maxlen'][$field_order] : '';
229
 
 
 
 
 
230
  // min length available
231
  $minLen = 1;
232
+
233
  // max length or size for picture available
234
  if (in_array($type, $cimy_uef_file_types)) {
235
  $maxLen = $max_size_file;
253
 
254
  if (!empty($maxlen))
255
  $store_rule['max_length'] = intval($_POST['maxlength'][$field_order]);
 
 
 
256
 
257
+ $store_rule['can_be_empty'] = empty($_POST['empty'][$field_order]) ? false : true;
258
  $store_rule['edit'] = $_POST['edit'][$field_order];
259
+ $store_rule['email'] = empty($_POST['email'][$field_order]) ? false : true;
 
 
 
 
 
 
 
 
260
 
261
+ $equal = empty($_POST['equal'][$field_order]) ? '' : $_POST['equal'][$field_order];
262
+ if (!empty($equal)) {
263
+ $store_rule['equal_to'] = empty($_POST['equalto'][$field_order]) ? '' : stripslashes($_POST['equalto'][$field_order]);
264
+ $equalto_casesens = empty($_POST['equalto_casesens'][$field_order]) ? '' : $_POST['equalto_casesens'][$field_order];
265
+ $equalto_regex = empty($_POST['equalto_regex'][$field_order]) ? '' : $_POST['equalto_regex'][$field_order];
266
  }
267
 
268
  $store_rule["advanced_options"] = stripslashes($_POST['advanced_options'][$field_order]);
269
+ $store_rule['show_in_reg'] = empty($_POST['show_in_reg'][$field_order]) ? false : true;
270
+ $store_rule['show_in_profile'] = empty($_POST['show_in_profile'][$field_order]) ? false : true;
271
+ $store_rule['show_in_aeu'] = empty($_POST['show_in_aeu'][$field_order]) ? false : true;
272
+ $store_rule['show_in_search'] = empty($_POST['show_in_search'][$field_order]) ? false : true;
273
+ $store_rule['show_in_blog'] = empty($_POST['show_in_blog'][$field_order]) ? false : true;
 
 
 
 
 
 
 
 
 
274
 
275
  $show_level = $_POST['show_level'][$field_order];
276
  $store_rule['show_level'] = $show_level;
277
+ $store_rule['email_admin'] = empty($_POST['email_admin'][$field_order]) ? false : true;
 
 
278
 
279
  // START CHECKING FOR ERRORS
280
  if (empty($name))
333
  else
334
  $store_rule['equal_to_case_sensitive'] = false;
335
 
336
+ if ((!empty($equalto_regex)) && (in_array($type, $rule_equalto_regex)))
337
  $store_rule['equal_to_regex'] = true;
338
  else
339
  $store_rule['equal_to_regex'] = false;
427
  // print errors if there are some
428
  cimy_uef_print_messages($errors, $results);
429
 
430
+ if (isset($store_rule['min_length']) && $store_rule['min_length'] == 0)
431
  unset($store_rule['min_length']);
432
 
433
+ if (isset($store_rule['exact_length']) && $store_rule['exact_length'] == 0)
434
  unset($store_rule['exact_length']);
435
 
436
+ if (isset($store_rule['max_length']) && $store_rule['max_length'] == 0)
437
  unset($store_rule['max_length']);
438
 
439
  if (!isset($store_rule['show_level']))
452
  $selected_input["min_length"] = '';
453
  $selected_input["exact_length"] = '';
454
  $selected_input["max_length"] = '';
 
455
  $selected_input["equal_to"] = '';
 
 
 
 
456
  $selected_input["minlen"] = '';
457
  $selected_input["exactlen"] = '';
458
  $selected_input["maxlen"] = '';
488
  if (isset($store_rule['max_length']))
489
  $selected_input["max_length"] = $store_rule['max_length'];
490
 
 
 
 
 
491
  if (isset($store_rule['equal_to']))
492
  $selected_input["equal_to"] = $store_rule['equal_to'];
493
 
 
 
 
 
 
 
 
 
 
 
494
  // ADVANCED OPTIONS
495
  if (isset($store_rule['advanced_options']))
496
  $selected_input["advanced_options"] = $store_rule['advanced_options'];
 
 
 
 
497
  }
498
  // action is not "add"
499
  else {
500
  }
501
 
502
  // CAN BE EMPTY
503
+ if ((!isset($store_rule['can_be_empty'])) || ($store_rule['can_be_empty'] == true) || ($action != "add"))
504
  $selected_input["empty"] = ' checked="checked"';
505
  else
506
  $selected_input["empty"] = '';
591
  <input type="checkbox" name="maxlen[0]" value="1"<?php echo $selected_input["maxlen"]; ?> /> <?php echo $max_length_caption; ?> [1-<?php echo $maxLen; ?>]: &nbsp;&nbsp;<input type="text" name="maxlength[0]" value="<?php echo $selected_input["max_length"]; ?>" maxlength="5" size="5" /><br />
592
 
593
  <input type="checkbox" name="empty[0]" value="1"<?php echo $selected_input["empty"]; ?> /> <?php _e("Can be empty", $cimy_uef_domain); ?><br />
594
+ <input type="checkbox" name="email[0]" value="1"<?php checked(true, $store_rule['email'], true); ?> /> <?php _e("Check for E-mail syntax", $cimy_uef_domain); ?><br />
595
 
596
  <select name="edit[0]">
597
  <option value="ok_edit"<?php selected('ok_edit', $store_rule['edit'], true); ?>><?php _e("Can be modified", $cimy_uef_domain); ?></option>
602
  </select>
603
  <br />
604
  <!-- EQUAL TO -->
605
+ <input type="checkbox" name="equal[0]" value="1"<?php checked(false, empty($equal), true); ?> /> <?php _e("Should be equal TO", $cimy_uef_domain); ?>: <input type="text" name="equalto[0]" maxlength="500" value="<?php echo $selected_input["equal_to"]; ?>"/><br />
606
  <!-- CASE SENSITIVE -->
607
+ &nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="equalto_casesens[0]" value="1"<?php checked(false, empty($equalto_casesens), true); ?> /> <?php _e("Case sensitive", $cimy_uef_domain); ?><br />
608
 
609
  <!-- REGEX -->
610
+ &nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="equalto_regex[0]" value="1"<?php checked(false, empty($equalto_regex), true); ?> /> <?php _e("Regular Expression", $cimy_uef_domain); ?><br />
611
 
612
  <!-- SHOW IN REGISTRATION -->
613
  <input type="checkbox" name="show_in_reg[0]" value="1"<?php echo $selected_input["show_in_reg"]; ?> /> <?php _e("Show the field in the registration", $cimy_uef_domain); ?><br />
638
  <br />
639
 
640
  <!-- EMAIL ADMIN -->
641
+ <input type="checkbox" name="email_admin[0]" value="1"<?php checked(true, $store_rule['email_admin'], true); ?> /> <?php _e("Send an email to the admin if the user changes its value", $cimy_uef_domain); ?><br />
642
  <!-- ADVANCED OPTIONS -->
643
  <?php _e("Advanced options", $cimy_uef_domain); ?>: <input type="text" name="advanced_options[0]" maxlength="500" value="<?php echo $selected_input["advanced_options"]; ?>"/><br />
644
 
783
  $label = esc_attr($field['LABEL']);
784
  $type = $field['TYPE'];
785
  $rules = $field['RULES'];
 
786
  if (!$wp_fields) {
787
+ $fieldset = $field["FIELDSET"];
788
  $javascripts_dep = cimy_uef_set_javascript_dependencies($javascripts_dep, $type, "show_in_reg", $rules["show_in_reg"]);
789
  $javascripts_dep = cimy_uef_set_javascript_dependencies($javascripts_dep, $type, "show_in_profile", $rules["show_in_profile"]);
790
  $javascripts_dep = cimy_uef_set_javascript_dependencies($javascripts_dep, $type, "show_in_aeu", $rules["show_in_aeu"]);
993
 
994
  <?php
995
  // this will help me to track down the javascript dependencies without looping through all fields too many times
996
+ if (!$wp_fields && $options = cimy_get_options()) {
 
997
  $options['file_fields'] = $javascripts_dep['file_fields'];
998
  $options['image_fields'] = $javascripts_dep['image_fields'];
999
  $options['tinymce_fields'] = $javascripts_dep['tinymce_fields'];
1801
  $fieldset_sql = "";
1802
  }
1803
  else {
1804
+ $wp_fields = false;
1805
  $fieldset = intval($data['fieldset']);
1806
  $fieldset_sql = ", fieldset=".$fieldset;
1807
  }
cimy_uef_db.php CHANGED
@@ -9,13 +9,14 @@ function cimy_plugin_install () {
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
20
  if ( $wpdb->supports_collation() ) {
21
  if ( ! empty($wpdb->charset) )
@@ -264,7 +265,6 @@ function cimy_plugin_install () {
264
  }
265
 
266
  if ($wpdb->get_var("SHOW TABLES LIKE '$wpdb_wp_fields_table'") != $wpdb_wp_fields_table) {
267
-
268
  $sql = "CREATE TABLE ".$wpdb_wp_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.";";
269
 
270
  require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
@@ -272,7 +272,6 @@ function cimy_plugin_install () {
272
  }
273
 
274
  if ($wpdb->get_var("SHOW TABLES LIKE '$wpdb_data_table'") != $wpdb_data_table) {
275
-
276
  $sql = "CREATE TABLE ".$wpdb_data_table." (ID bigint(20) NOT NULL AUTO_INCREMENT, USER_ID bigint(20) NOT NULL, FIELD_ID bigint(20) NOT NULL, VALUE TEXT NOT NULL, PRIMARY KEY (ID), INDEX USER_ID (USER_ID), INDEX FIELD_ID (FIELD_ID))".$charset_collate.";";
277
 
278
  require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
@@ -280,7 +279,6 @@ function cimy_plugin_install () {
280
  }
281
 
282
  if ($wpdb->get_var("SHOW TABLES LIKE '$wpdb_fields_table'") != $wpdb_fields_table) {
283
-
284
  $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.";";
285
 
286
  require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
@@ -339,11 +337,13 @@ function cimy_manage_db($command) {
339
  'aue_hidden_fields' => array('website', 'posts', 'email'),
340
  'wp_hidden_fields' => array(),
341
  'fieldset_title' => '',
 
342
  'captcha' => 'none',
343
  'welcome_email' => $welcome_email,
344
  'confirm_form' => false,
345
  'confirm_email' => false,
346
  'password_meter' => false,
 
347
  'redirect_to' => '',
348
  'file_fields' => array(
349
  'show_in_reg' => 0,
9
 
10
  $force_update = false;
11
 
12
+ if (!($options = cimy_get_options())) {
13
  cimy_manage_db('new_options');
14
+ $options = cimy_get_options();
15
+ }
16
  else
17
  $force_update = true;
18
 
19
  $charset_collate = "";
 
20
  // try to get proper charset and collate
21
  if ( $wpdb->supports_collation() ) {
22
  if ( ! empty($wpdb->charset) )
265
  }
266
 
267
  if ($wpdb->get_var("SHOW TABLES LIKE '$wpdb_wp_fields_table'") != $wpdb_wp_fields_table) {
 
268
  $sql = "CREATE TABLE ".$wpdb_wp_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.";";
269
 
270
  require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
272
  }
273
 
274
  if ($wpdb->get_var("SHOW TABLES LIKE '$wpdb_data_table'") != $wpdb_data_table) {
 
275
  $sql = "CREATE TABLE ".$wpdb_data_table." (ID bigint(20) NOT NULL AUTO_INCREMENT, USER_ID bigint(20) NOT NULL, FIELD_ID bigint(20) NOT NULL, VALUE TEXT NOT NULL, PRIMARY KEY (ID), INDEX USER_ID (USER_ID), INDEX FIELD_ID (FIELD_ID))".$charset_collate.";";
276
 
277
  require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
279
  }
280
 
281
  if ($wpdb->get_var("SHOW TABLES LIKE '$wpdb_fields_table'") != $wpdb_fields_table) {
 
282
  $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.";";
283
 
284
  require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
337
  'aue_hidden_fields' => array('website', 'posts', 'email'),
338
  'wp_hidden_fields' => array(),
339
  'fieldset_title' => '',
340
+ 'registration-logo' => '',
341
  'captcha' => 'none',
342
  'welcome_email' => $welcome_email,
343
  'confirm_form' => false,
344
  'confirm_email' => false,
345
  'password_meter' => false,
346
+ 'mail_include_fields' => false,
347
  'redirect_to' => '',
348
  'file_fields' => array(
349
  'show_in_reg' => 0,
cimy_uef_functions.php CHANGED
@@ -628,4 +628,271 @@ function cimy_uef_set_javascript_dependencies($javascripts_dep, $type, $rule_nam
628
  return $javascripts_dep;
629
  }
630
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
631
  ?>
628
  return $javascripts_dep;
629
  }
630
 
631
+ function cimy_uef_avatar_filter($avatar, $id_or_email, $size, $default, $alt="") {
632
+ global $wpdb, $wpdb_data_table, $wpdb_fields_table, $cuef_upload_path;
633
+
634
+ $sql = "SELECT ID,VALUE FROM $wpdb_fields_table WHERE TYPE='avatar' LIMIT 1";
635
+ $res = $wpdb->get_results($sql);
636
+
637
+ if (empty($res))
638
+ return $avatar;
639
+
640
+ $field_id = $res[0]->ID;
641
+ $overwrite_default = $res[0]->VALUE;
642
+
643
+ // if there is no avatar field all the rest is totally cpu time wasted, returning...
644
+ if (!isset($field_id))
645
+ return $avatar;
646
+
647
+ if (!empty($overwrite_default))
648
+ $overwrite_default = "<img alt='{$safe_alt}' src='{$overwrite_default}' class='avatar avatar-{$size} photo avatar-default' height='{$size}' width='{$size}' />";
649
+
650
+ $email = '';
651
+ $user_login = '';
652
+
653
+ // $id_or_email could be id, email or an object... fancy way to implement things!
654
+ // we may have the id
655
+ if ( is_numeric($id_or_email) ) {
656
+ $id = (int) $id_or_email;
657
+ $user = get_userdata($id);
658
+ if ( $user ) {
659
+ $email = $user->user_email;
660
+ $user_login = $user->user_login;
661
+ }
662
+ } elseif ( is_object($id_or_email) ) {
663
+ // we may have the object...
664
+ if ( isset($id_or_email->comment_type) && '' != $id_or_email->comment_type && 'comment' != $id_or_email->comment_type )
665
+ return false; // No avatar for pingbacks or trackbacks, maybe useless as same check is performed before this code is fired...
666
+
667
+ if ( !empty($id_or_email->user_id) ) {
668
+ $id = (int) $id_or_email->user_id;
669
+ $user = get_userdata($id);
670
+ if ( $user) {
671
+ $email = $user->user_email;
672
+ $user_login = $user->user_login;
673
+ }
674
+ } else {
675
+ // no user_id no custom avatar, nothing else to do
676
+ return $avatar;
677
+ }
678
+ } else {
679
+ // ...or we may have the email
680
+ $email = $id_or_email;
681
+
682
+ $sql = sprintf("SELECT ID, user_login FROM %s WHERE user_email='%s' LIMIT 1", $wpdb->users, $wpdb->escape($email));
683
+ $res = $wpdb->get_results($sql);
684
+
685
+ // something went wrong, aborting and returning normal avatar
686
+ if (!isset($res))
687
+ return $avatar;
688
+
689
+ $id = $res[0]->ID;
690
+ $user_login = $res[0]->user_login;
691
+ }
692
+
693
+ if (isset($id)) {
694
+ $sql = "SELECT data.VALUE FROM $wpdb_data_table as data JOIN $wpdb_fields_table as efields ON efields.id=data.field_id WHERE (efields.TYPE='avatar' AND data.USER_ID=$id) LIMIT 1";
695
+
696
+ $value = $wpdb->get_var($sql);
697
+
698
+ if ( false === $alt)
699
+ $safe_alt = '';
700
+ else
701
+ $safe_alt = esc_attr($alt);
702
+
703
+ // max $size allowed is 512
704
+ if (isset($value)) {
705
+ if ($value == "") {
706
+ // apply default only here or below, as we are sure to have an user that did not set anything
707
+ if ($overwrite_default != "")
708
+ return $overwrite_default;
709
+ else
710
+ return $avatar;
711
+ }
712
+
713
+ $thumb_value = cimy_get_thumb_path($value);
714
+ $file_thumb = $cuef_upload_path.$user_login."/avatar/".cimy_get_thumb_path(basename($value));
715
+
716
+ if (is_file($file_thumb))
717
+ $value = $thumb_value;
718
+
719
+ $avatar = "<img alt='{$safe_alt}' src='{$value}' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' />";
720
+ }
721
+ // apply default only here, as we are sure to have an user that did not set anything
722
+ else if ($overwrite_default != "")
723
+ return $overwrite_default;
724
+ }
725
+
726
+ return $avatar;
727
+ }
728
+
729
+ function cimy_manage_upload($input_name, $user_login, $rules, $old_file=false, $delete_file=false, $type="", $new_filename="") {
730
+ global $cuef_upload_path, $cuef_upload_webpath, $cuef_plugin_dir, $cimy_uef_plugins_dir;
731
+
732
+ $type_path = "";
733
+ if (($type == "file") || ($type == "avatar"))
734
+ $type_path.= $type."/";
735
+
736
+ $blog_path = $cuef_upload_path;
737
+
738
+ if (($cimy_uef_plugins_dir == "plugins") && (is_multisite())) {
739
+ global $blog_id;
740
+
741
+ $blog_path .= $blog_id."/";
742
+
743
+ // create blog subdir
744
+ if (!is_dir($blog_path)) {
745
+ if (defined("FS_CHMOD_DIR")) {
746
+ mkdir($blog_path, FS_CHMOD_DIR);
747
+ chmod($blog_path, FS_CHMOD_DIR);
748
+ }
749
+ else {
750
+ mkdir($blog_path, 0777);
751
+ chmod($blog_path, 0777);
752
+ }
753
+ }
754
+ }
755
+
756
+ if (!empty($user_login)) {
757
+ $user_path = $blog_path.$user_login."/";
758
+ $file_path = $blog_path.$user_login."/".$type_path;
759
+ }
760
+ else {
761
+ $user_path = $blog_path;
762
+ $file_path = $blog_path.$type_path;
763
+ }
764
+ if (!empty($new_filename))
765
+ $file_name = $new_filename;
766
+ else
767
+ $file_name = $_FILES[$input_name]['name'];
768
+
769
+ // protect from site traversing
770
+ $file_name = str_replace('../', '', $file_name);
771
+ $file_name = str_replace('/', '', $file_name);
772
+
773
+ // delete old file if requested
774
+ if ($delete_file) {
775
+ if (is_file($file_path.$old_file))
776
+ unlink($file_path.$old_file);
777
+
778
+ $old_thumb_file = cimy_get_thumb_path($old_file);
779
+
780
+ if (is_file($file_path.$old_thumb_file))
781
+ unlink($file_path.$old_thumb_file);
782
+ }
783
+
784
+ // if $user_login is not present
785
+ // or there is no file to upload
786
+ // or dest dir is not writable
787
+ // then everything else is useless
788
+ if ((($user_login == "") && ($type != "registration-logo")) || (!isset($_FILES[$input_name]['name'])) || (!is_writable($cuef_upload_path)))
789
+ return "";
790
+
791
+ // create user subdir
792
+ if (!is_dir($user_path)) {
793
+ if (defined("FS_CHMOD_DIR")) {
794
+ mkdir($user_path, FS_CHMOD_DIR);
795
+ chmod($user_path, FS_CHMOD_DIR);
796
+ }
797
+ else {
798
+ mkdir($user_path, 0777);
799
+ chmod($user_path, 0777);
800
+ }
801
+ }
802
+
803
+ // create avatar subdir if needed
804
+ if (($type != "registration-logo") && ($type != "picture") && (!is_dir($file_path))) {
805
+ if (defined("FS_CHMOD_DIR")) {
806
+ mkdir($file_path, FS_CHMOD_DIR);
807
+ chmod($file_path, FS_CHMOD_DIR);
808
+ }
809
+ else {
810
+ mkdir($file_path, 0777);
811
+ chmod($file_path, 0777);
812
+ }
813
+ }
814
+
815
+ // picture filesystem path
816
+ $file_full_path = $file_path.$file_name;
817
+
818
+ // picture url to write in the DB
819
+ $data = $cuef_upload_webpath;
820
+
821
+ if (($cimy_uef_plugins_dir == "plugins") && (is_multisite()))
822
+ $data.= $blog_id."/";
823
+
824
+ if (empty($user_login))
825
+ $data .= $type_path.$file_name;
826
+ else
827
+ $data .= $user_login."/".$type_path.$file_name;
828
+
829
+ // filesize in Byte transformed in KiloByte
830
+ $file_size = $_FILES[$input_name]['size'] / 1024;
831
+ $file_type = $_FILES[$input_name]['type'];
832
+ $file_tmp_name = $_FILES[$input_name]['tmp_name'];
833
+ $file_error = $_FILES[$input_name]['error'];
834
+
835
+ // CHECK IF IT IS A REAL PICTURE
836
+ if (($type != "file") && (stristr($file_type, "image/") === false))
837
+ $file_error = 1;
838
+
839
+ // MIN LENGTH
840
+ if (isset($rules['min_length']))
841
+ if ($file_size < (intval($rules['min_length'])))
842
+ $file_error = 1;
843
+
844
+ // EXACT LENGTH
845
+ if (isset($rules['exact_length']))
846
+ if ($file_size != (intval($rules['exact_length'])))
847
+ $file_error = 1;
848
+
849
+ // MAX LENGTH
850
+ if (isset($rules['max_length']))
851
+ if ($file_size > (intval($rules['max_length'])))
852
+ $file_error = 1;
853
+
854
+ // if there are no errors and filename is NOT empty
855
+ if (($file_error == 0) && (!empty($file_name))) {
856
+ if (move_uploaded_file($file_tmp_name, $file_full_path)) {
857
+ // change file permissions for broken servers
858
+ if (defined("FS_CHMOD_FILE"))
859
+ @chmod($file_full_path, FS_CHMOD_FILE);
860
+ else
861
+ @chmod($file_full_path, 0644);
862
+
863
+ // if there is an old file to delete
864
+ if ($old_file) {
865
+ // delete old file if the name is different, if equal NOPE because new file is already uploaded
866
+ if ($file_name != $old_file)
867
+ if (is_file($file_path.$old_file))
868
+ unlink($file_path.$old_file);
869
+
870
+ $old_thumb_file = cimy_get_thumb_path($old_file);
871
+
872
+ if (is_file($file_path.$old_thumb_file))
873
+ unlink($file_path.$old_thumb_file);
874
+ }
875
+
876
+ // should be stay AFTER DELETIONS
877
+ if ((isset($rules['equal_to'])) && ($type != "file")) {
878
+ if ($maxside = intval($rules['equal_to'])) {
879
+ if (!function_exists("image_resize"))
880
+ require_once(ABSPATH . 'wp-includes/media.php');
881
+
882
+ if (!function_exists("wp_load_image"))
883
+ require_once($cuef_plugin_dir.'/cimy_uef_missing_functions.php');
884
+
885
+ image_resize($file_full_path, $maxside, $maxside, false, "thumbnail");
886
+ }
887
+ }
888
+ }
889
+ else
890
+ $data = "";
891
+ }
892
+ else
893
+ $data = "";
894
+
895
+ return $data;
896
+ }
897
+
898
  ?>
cimy_uef_init.php ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function cimy_uef_i18n_setup() {
4
+ global $cimy_uef_domain, $cimy_uef_i18n_is_setup, $cuef_plugin_path, $cimy_uef_plugins_dir;
5
+
6
+ if ($cimy_uef_i18n_is_setup)
7
+ return;
8
+
9
+ // Stupid function, from relative path I need to go down because starts from WP_PLUGIN_DIR!
10
+ if (is_multisite())
11
+ load_plugin_textdomain($cimy_uef_domain, false, '../'.$cimy_uef_plugins_dir.'/'.$cuef_plugin_path.'langs');
12
+ else
13
+ load_plugin_textdomain($cimy_uef_domain, false, $cuef_plugin_path.'langs');
14
+ }
15
+
16
+ function cimy_admin_menu_custom() {
17
+ global $cimy_uef_name, $cimy_uef_domain, $cimy_top_menu, $cimy_uef_plugins_dir;
18
+
19
+ $aue_page = "";
20
+ if (isset($cimy_top_menu) && (!is_multisite())) {
21
+ add_submenu_page('cimy_series.php', $cimy_uef_name.": ".__("Options"), "UEF: ".__("Options"), 'manage_options', "user_extra_fields_options", 'cimy_show_options_notembedded');
22
+ add_submenu_page('cimy_series.php', $cimy_uef_name.": ".__("Fields", $cimy_uef_domain), "UEF: ".__("Fields", $cimy_uef_domain), 'manage_options', "user_extra_fields", 'cimy_admin_define_extra_fields');
23
+ $aue_page = add_submenu_page('profile.php', __('Users Extended', $cimy_uef_domain), __('Users Extended', $cimy_uef_domain), 'list_users', "users_extended", 'cimy_admin_users_list_page');
24
+ }
25
+ else {
26
+ if ((is_multisite()) && ($cimy_uef_plugins_dir == "mu-plugins")) {
27
+ // $aue_page = add_submenu_page('wpmu-admin.php', __("Users Extended", $cimy_uef_domain), __("Users Extended", $cimy_uef_domain), 'list_users', "users_extended", 'cimy_admin_users_list_page');
28
+ // add_submenu_page('wpmu-admin.php', $cimy_uef_name, $cimy_uef_name, 'manage_options', "user_extra_fields", 'cimy_admin_define_extra_fields');
29
+
30
+ // Since WP 3.1 we have network admin and everything seems changed
31
+ $aue_page = add_submenu_page('users.php', __("Users Extended", $cimy_uef_domain), __("Users Extended", $cimy_uef_domain), 'list_users', "users_extended", 'cimy_admin_users_list_page');
32
+ $admin = add_submenu_page('settings.php', $cimy_uef_name, $cimy_uef_name, 'manage_options', "user_extra_fields", 'cimy_admin_define_extra_fields');
33
+ }
34
+ else {
35
+ $admin = add_options_page($cimy_uef_name, $cimy_uef_name, 'manage_options', "user_extra_fields", 'cimy_admin_define_extra_fields');
36
+ $aue_page = add_submenu_page('profile.php', __('Users Extended', $cimy_uef_domain), __('Users Extended', $cimy_uef_domain), 'list_users', "users_extended", 'cimy_admin_users_list_page');
37
+ }
38
+ }
39
+ if (!empty($aue_page))
40
+ add_action('admin_print_scripts-'.$aue_page, 'cimy_uef_admin_ajax_edit');
41
+ if (!empty($admin))
42
+ add_action('admin_print_scripts-'.$admin, 'cimy_uef_admin_init_js');
43
+ }
44
+
45
+ function cimy_uef_admin_init() {
46
+ global $cuef_js_webpath;
47
+ wp_register_script("cimy_uef_invert_sel", $cuef_js_webpath."/invert_sel.js", array(), false);
48
+ wp_register_script("cimy_uef_ajax_new_value", $cuef_js_webpath."/ajax_new_value.js", array(), false);
49
+ }
50
+
51
+ function cimy_uef_admin_init_js() {
52
+ wp_enqueue_script("cimy_uef_invert_sel");
53
+ cimy_uef_init_upload_js();
54
+ }
55
+
56
+ function cimy_uef_init_upload_js() {
57
+ global $cuef_js_webpath;
58
+ wp_register_script("cimy_uef_upload_file", $cuef_js_webpath."/upload_file.js", array(), false);
59
+ wp_enqueue_script('cimy_uef_upload_file');
60
+ }
61
+
62
+ function cimy_uef_theme_my_login_fix() {
63
+ // Theme My Login spam with its css _all_ pages, we like it cleaner thanks!
64
+ if (!empty($GLOBALS['theme_my_login'])) {
65
+ if ($GLOBALS['theme_my_login']->is_login_page())
66
+ cimy_uef_register_css();
67
+ }
68
+ }
69
+
70
+ function cimy_uef_register_css() {
71
+ global $cuef_css_webpath;
72
+ wp_register_style("cimy_uef_register", $cuef_css_webpath."/cimy_uef_register.css", false, false);
73
+ wp_enqueue_style("cimy_uef_register");
74
+ cimy_uef_init_javascripts("show_in_reg");
75
+ // needed till they fix this bug: http://core.trac.wordpress.org/ticket/17916#comment:18
76
+ wp_print_styles();
77
+ }
78
+
79
+ function cimy_uef_admin_profile_init_js() {
80
+ cimy_uef_init_javascripts("show_in_profile");
81
+ }
82
+
83
+ function cimy_uef_init_javascripts($rule_name) {
84
+ global $cuef_plugin_dir, $cuef_css_webpath, $cuef_js_webpath;
85
+
86
+ $options = cimy_get_options();
87
+ if ($options['image_fields'][$rule_name] > 0) {
88
+ wp_enqueue_script('imgareaselect', "", array("jquery"));
89
+ wp_enqueue_style('imgareaselect');
90
+ wp_register_script('cimy_uef_img_selection', $cuef_js_webpath."/img_selection.js", array(), false);
91
+ wp_enqueue_script('cimy_uef_img_selection');
92
+ }
93
+
94
+ if ($options['file_fields'][$rule_name] > 0) {
95
+ cimy_uef_init_upload_js();
96
+ }
97
+
98
+ if ($rule_name == "show_in_profile") {
99
+ if ($options['tinymce_fields'][$rule_name] > 0 && function_exists("wp_editor")) {
100
+ wp_register_style("cimy_uef_tinymce", $cuef_css_webpath."/cimy_uef_tinymce.css", false, false);
101
+ wp_enqueue_style('cimy_uef_tinymce');
102
+ }
103
+ }
104
+ if ($rule_name == "show_in_reg") {
105
+ // This is needed for registration form on WordPress >= 3.3
106
+ if ($options['tinymce_fields'][$rule_name] > 0 && function_exists("wp_editor"))
107
+ wp_enqueue_script('utils');
108
+
109
+ if ($options['password_meter']) {
110
+ wp_register_script("cimy_uef_password_strength_meter", $cuef_js_webpath."/password_strength_meter.js", array("password-strength-meter"), false);
111
+ wp_enqueue_script('cimy_uef_password_strength_meter');
112
+ }
113
+
114
+ // damn WordPress bugs
115
+ if (is_multisite())
116
+ wp_print_scripts();
117
+ }
118
+ }
119
+
120
+ ?>
cimy_uef_options.php CHANGED
@@ -258,7 +258,7 @@ function cimy_show_options_notembedded() {
258
  }
259
 
260
  function cimy_show_options($results, $embedded) {
261
- global $wpdb, $wpdb_wp_fields_table, $wpdb_fields_table, $wpdb_data_table, $max_length_fieldset_value, $cimy_uef_name, $cimy_uef_url, $cimy_project_url, $cimy_uef_version, $cimy_uef_domain, $cimy_top_menu, $max_length_extra_fields_title, $cuef_upload_path, $cuef_plugin_dir;
262
 
263
  if (!cimy_check_admin('manage_options'))
264
  return;
@@ -271,15 +271,33 @@ function cimy_show_options($results, $embedded) {
271
  if (!empty($options['version']) && $cimy_uef_version != $options['version'])
272
  $options = cimy_plugin_install();
273
 
274
- wp_print_scripts("cimy_uef_upload_file");
275
- $warning_msg = $wpdb->escape(__("Please upload an image with one of the following extensions", $cimy_uef_domain));
276
 
277
  if ($options) {
278
- if ((!is_dir($cuef_upload_path)) && (is_writable(WP_CONTENT_DIR))) {
279
- if (defined("FS_CHMOD_DIR"))
280
- @mkdir($cuef_upload_path, FS_CHMOD_DIR);
281
- else
282
- @mkdir($cuef_upload_path, 0777);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
283
  }
284
 
285
  $options['fieldset_title'] = esc_attr($options['fieldset_title']);
@@ -326,7 +344,7 @@ function cimy_show_options($results, $embedded) {
326
  if ((isset($cimy_top_menu)) && ($embedded))
327
  return $ret;
328
 
329
- $update_db_label = $wpdb->escape(__("This operation will create/update all missing tables/options, do you want to proceed?", $cimy_uef_domain));
330
 
331
  ?>
332
 
258
  }
259
 
260
  function cimy_show_options($results, $embedded) {
261
+ global $wpdb, $wpdb_wp_fields_table, $wpdb_fields_table, $wpdb_data_table, $max_length_fieldset_value, $cimy_uef_name, $cimy_uef_url, $cimy_project_url, $cimy_uef_version, $cimy_uef_domain, $cimy_top_menu, $max_length_extra_fields_title, $cuef_upload_path, $cuef_plugin_dir, $cimy_uef_plugins_dir;
262
 
263
  if (!cimy_check_admin('manage_options'))
264
  return;
271
  if (!empty($options['version']) && $cimy_uef_version != $options['version'])
272
  $options = cimy_plugin_install();
273
 
274
+ $warning_msg = esc_js(__("Please upload an image with one of the following extensions", $cimy_uef_domain));
 
275
 
276
  if ($options) {
277
+ if (is_writable(WP_CONTENT_DIR)) {
278
+ if (!is_dir($cuef_upload_path)) {
279
+ if (defined("FS_CHMOD_DIR"))
280
+ @mkdir($cuef_upload_path, FS_CHMOD_DIR);
281
+ else
282
+ @mkdir($cuef_upload_path, 0777);
283
+ }
284
+
285
+ if (is_multisite()) {
286
+ if ($cimy_uef_plugins_dir == "plugins") {
287
+ if (!is_dir(WP_CONTENT_DIR.'/mu-plugins')) {
288
+ if (defined("FS_CHMOD_DIR"))
289
+ @mkdir(WP_CONTENT_DIR.'/mu-plugins', FS_CHMOD_DIR);
290
+ else
291
+ @mkdir(WP_CONTENT_DIR.'/mu-plugins', 0777);
292
+ }
293
+ if (!is_file(WP_CONTENT_DIR.'/mu-plugins/cimy_uef_mu_activation.php'))
294
+ copy($cuef_plugin_dir.'/cimy_uef_mu_activation.php', WP_CONTENT_DIR.'/mu-plugins/cimy_uef_mu_activation.php');
295
+ }
296
+ else if ($cimy_uef_plugins_dir == "mu-plugins") {
297
+ if (is_file(WP_CONTENT_DIR.'/mu-plugins/cimy_uef_mu_activation.php'))
298
+ unlink(WP_CONTENT_DIR.'/mu-plugins/cimy_uef_mu_activation.php');
299
+ }
300
+ }
301
  }
302
 
303
  $options['fieldset_title'] = esc_attr($options['fieldset_title']);
344
  if ((isset($cimy_top_menu)) && ($embedded))
345
  return $ret;
346
 
347
+ $update_db_label = esc_js(__("This operation will create/update all missing tables/options, do you want to proceed?", $cimy_uef_domain));
348
 
349
  ?>
350
 
cimy_uef_profile.php CHANGED
@@ -417,7 +417,7 @@ function cimy_extract_ExtraFields() {
417
  // echo "\n\t\t";
418
  }
419
 
420
- if ((($type == "picture") || ($type == "avatar")) && ((empty($rules["equal_to"])) || ($advanced_options["no-thumb"]))) {
421
  echo "<input type=\"hidden\" name=\"".$field_id_data."_x1\" id=\"".$field_id_data."_x1\" value=\"\" />";
422
  echo "<input type=\"hidden\" name=\"".$field_id_data."_y1\" id=\"".$field_id_data."_y1\" value=\"\" />";
423
  echo "<input type=\"hidden\" name=\"".$field_id_data."_x2\" id=\"".$field_id_data."_x2\" value=\"\" />";
417
  // echo "\n\t\t";
418
  }
419
 
420
+ if ((($type == "picture") || ($type == "avatar")) && ((empty($rules["equal_to"])) || (!empty($advanced_options["no-thumb"])))) {
421
  echo "<input type=\"hidden\" name=\"".$field_id_data."_x1\" id=\"".$field_id_data."_x1\" value=\"\" />";
422
  echo "<input type=\"hidden\" name=\"".$field_id_data."_y1\" id=\"".$field_id_data."_y1\" value=\"\" />";
423
  echo "<input type=\"hidden\" name=\"".$field_id_data."_x2\" id=\"".$field_id_data."_x2\" value=\"\" />";
cimy_uef_register.php CHANGED
@@ -45,7 +45,7 @@ function cimy_register_overwrite_password($password) {
45
  else {
46
  if (!empty($_GET['key']))
47
  $key = $_GET['key'];
48
- else
49
  $key = $_POST['key'];
50
 
51
  if (!empty($key)) {
@@ -83,7 +83,7 @@ function cimy_register_user_extra_fields($user_id, $password="", $meta=array())
83
  return;
84
 
85
  // avoid to save stuff if user is being added from: /wp-admin/user-new.php and shit WP 3.1 changed the value just to create new bugs :@
86
- if (($_POST["action"] == "adduser") || ($_POST["action"] == "createuser"))
87
  return;
88
 
89
  $my_user_level = $user_level;
@@ -307,7 +307,7 @@ function cimy_registration_check($user_login, $user_email, $errors) {
307
  $errors = cimy_check_user_on_signups($errors, $user_login, $user_email);
308
  }
309
  // avoid to save stuff if user is being added from: /wp-admin/user-new.php and shit WP 3.1 changed the value just to create new bugs :@
310
- if (($_POST["action"] == "adduser") || ($_POST["action"] == "createuser"))
311
  return $errors;
312
 
313
  $my_user_level = $user_level;
@@ -318,9 +318,11 @@ function cimy_registration_check($user_login, $user_email, $errors) {
318
 
319
  $extra_fields = get_cimyFields(false, true);
320
  $wp_fields = get_cimyFields(true);
321
-
 
 
322
  // if we are updating profile don't bother with WordPress fields' rules
323
- if ($_POST["from"] == "profile")
324
  $i = 2;
325
  else
326
  $i = 1;
@@ -359,7 +361,7 @@ function cimy_registration_check($user_login, $user_email, $errors) {
359
  // if show_level == anonymous then do NOT ovverride other show_xyz rules
360
  if ($rules['show_level'] == -1) {
361
  // if we are updating the profile check correct rule
362
- if ($_POST["from"] == "profile") {
363
  // if flag to show the field in the profile is NOT activated, skip it
364
  if (!$rules['show_in_profile'])
365
  continue;
@@ -374,7 +376,7 @@ function cimy_registration_check($user_login, $user_email, $errors) {
374
  if (((is_multisite()) || ($options["confirm_email"])) && (in_array($type, $cimy_uef_file_types)))
375
  continue;
376
 
377
- if ($_POST["from"] == "profile") {
378
  $old_value = $_POST[$input_name."_".$field_id."_prev_value"];
379
  // Hey, no need to check for rules if anyway I can't edit due to low permissions, neeeext!
380
  if (cimy_uef_is_field_disabled($type, $rules['edit'], $old_value))
@@ -389,27 +391,37 @@ function cimy_registration_check($user_login, $user_email, $errors) {
389
  }
390
  else
391
  $value = "";
392
-
393
  if ($type == "dropdown") {
394
  $ret = cimy_dropDownOptions($label, $value);
395
  $label = esc_html($ret['label']);
396
  $html = $ret['html'];
397
  }
398
 
399
- // confirmation page
400
- if ((!empty($_POST["register_confirmation"])) && ($_POST["register_confirmation"] == 2)) {
401
- $file_size = $_POST[$field_id_data."_size"];
402
- $file_type = $_POST[$field_id_data."_type"];
403
- $old_file = "";
404
- $del_old_file = "";
405
- }
406
- else if (in_array($type, $cimy_uef_file_types)) {
407
- // filesize in Byte transformed in KiloByte
408
- $file_size = $_FILES[$input_name]['size'] / 1024;
409
- $file_type = $_FILES[$input_name]['type'];
410
- $value = $_FILES[$input_name]['name'];
411
- $old_file = $_POST[$input_name."_".$field_id."_prev_value"];
412
- $del_old_file = $_POST[$input_name."_del"];
 
 
 
 
 
 
 
 
 
 
413
  }
414
 
415
  switch ($type) {
@@ -447,7 +459,6 @@ function cimy_registration_check($user_login, $user_email, $errors) {
447
  }
448
 
449
  if ((isset($rules['equal_to'])) && (in_array($type, $apply_equalto_rule))) {
450
-
451
  $equalTo = $rules['equal_to'];
452
  // if the type is not allowed to be case sensitive
453
  // OR if case sensitive is not checked
@@ -942,7 +953,7 @@ function cimy_registration_form($errors=null, $show_type=0) {
942
  $value = cimy_manage_upload($input_name, $temp_user_login, $rules, false, false, $type, (!empty($advanced_options["filename"])) ? $advanced_options["filename"] : "");
943
  $file_on_server = cimy_uef_get_dir_or_filename($temp_user_login, $value, false);
944
  $file_thumb = cimy_uef_get_dir_or_filename($temp_user_login, $value, true);
945
- if (($advanced_options["no-thumb"]) && (is_file($file_thumb)))
946
  rename($file_thumb, $file_on_server);
947
 
948
  // yea little trick
@@ -1218,4 +1229,58 @@ function cimy_confirmation_form() {
1218
  }
1219
  }
1220
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1221
  ?>
45
  else {
46
  if (!empty($_GET['key']))
47
  $key = $_GET['key'];
48
+ else if (!empty($_POST['key']))
49
  $key = $_POST['key'];
50
 
51
  if (!empty($key)) {
83
  return;
84
 
85
  // avoid to save stuff if user is being added from: /wp-admin/user-new.php and shit WP 3.1 changed the value just to create new bugs :@
86
+ if (!empty($_POST["action"]) && ($_POST["action"] == "adduser" || $_POST["action"] == "createuser"))
87
  return;
88
 
89
  $my_user_level = $user_level;
307
  $errors = cimy_check_user_on_signups($errors, $user_login, $user_email);
308
  }
309
  // avoid to save stuff if user is being added from: /wp-admin/user-new.php and shit WP 3.1 changed the value just to create new bugs :@
310
+ if (!empty($_POST["action"]) && ($_POST["action"] == "adduser" || $_POST["action"] == "createuser"))
311
  return $errors;
312
 
313
  $my_user_level = $user_level;
318
 
319
  $extra_fields = get_cimyFields(false, true);
320
  $wp_fields = get_cimyFields(true);
321
+ $from_profile = false;
322
+ if (!empty($_POST["profile"]) && $_POST["from"] == "profile")
323
+ $from_profile = true;
324
  // if we are updating profile don't bother with WordPress fields' rules
325
+ if ($from_profile)
326
  $i = 2;
327
  else
328
  $i = 1;
361
  // if show_level == anonymous then do NOT ovverride other show_xyz rules
362
  if ($rules['show_level'] == -1) {
363
  // if we are updating the profile check correct rule
364
+ if ($from_profile) {
365
  // if flag to show the field in the profile is NOT activated, skip it
366
  if (!$rules['show_in_profile'])
367
  continue;
376
  if (((is_multisite()) || ($options["confirm_email"])) && (in_array($type, $cimy_uef_file_types)))
377
  continue;
378
 
379
+ if ($from_profile) {
380
  $old_value = $_POST[$input_name."_".$field_id."_prev_value"];
381
  // Hey, no need to check for rules if anyway I can't edit due to low permissions, neeeext!
382
  if (cimy_uef_is_field_disabled($type, $rules['edit'], $old_value))
391
  }
392
  else
393
  $value = "";
394
+
395
  if ($type == "dropdown") {
396
  $ret = cimy_dropDownOptions($label, $value);
397
  $label = esc_html($ret['label']);
398
  $html = $ret['html'];
399
  }
400
 
401
+ // upload of a file, avatar or picture
402
+ if (in_array($type, $cimy_uef_file_types)) {
403
+ // confirmation page
404
+ if ((!empty($_POST["register_confirmation"])) && ($_POST["register_confirmation"] == 2)) {
405
+ $file_size = $_POST[$field_id_data."_size"];
406
+ $file_type = $_POST[$field_id_data."_type"];
407
+ $old_file = "";
408
+ $del_old_file = "";
409
+ }
410
+ else if (!empty($_FILES[$input_name])) {
411
+ // filesize in Byte transformed in KiloByte
412
+ $file_size = $_FILES[$input_name]['size'] / 1024;
413
+ $file_type = $_FILES[$input_name]['type'];
414
+ $value = $_FILES[$input_name]['name'];
415
+ $old_file = $from_profile ? $_POST[$input_name."_".$field_id."_prev_value"] : '';
416
+ $del_old_file = $from_profile ? $_POST[$input_name."_del"] : '';
417
+ }
418
+ else {
419
+ $file_size = 0;
420
+ $file_type = "";
421
+ $value = "";
422
+ $old_file = $from_profile ? $_POST[$input_name."_".$field_id."_prev_value"] : '';
423
+ $del_old_file = $from_profile ? $_POST[$input_name."_del"] : '';
424
+ }
425
  }
426
 
427
  switch ($type) {
459
  }
460
 
461
  if ((isset($rules['equal_to'])) && (in_array($type, $apply_equalto_rule))) {
 
462
  $equalTo = $rules['equal_to'];
463
  // if the type is not allowed to be case sensitive
464
  // OR if case sensitive is not checked
953
  $value = cimy_manage_upload($input_name, $temp_user_login, $rules, false, false, $type, (!empty($advanced_options["filename"])) ? $advanced_options["filename"] : "");
954
  $file_on_server = cimy_uef_get_dir_or_filename($temp_user_login, $value, false);
955
  $file_thumb = cimy_uef_get_dir_or_filename($temp_user_login, $value, true);
956
+ if ((!empty($advanced_options["no-thumb"])) && (is_file($file_thumb)))
957
  rename($file_thumb, $file_on_server);
958
 
959
  // yea little trick
1229
  }
1230
  }
1231
 
1232
+ function cimy_uef_registration_redirect($redirect_to) {
1233
+ if (empty($redirect_to)) {
1234
+ $options = cimy_get_options();
1235
+
1236
+ if ($options["redirect_to"] == "source")
1237
+ $redirect_to = esc_attr($_SERVER["HTTP_REFERER"]);
1238
+ }
1239
+
1240
+ return $redirect_to;
1241
+ }
1242
+
1243
+ function cimy_uef_redirect() {
1244
+ if (isset($_GET["cimy_key"]))
1245
+ cimy_uef_activate("");
1246
+
1247
+ if (!empty($_REQUEST["redirect_to"]))
1248
+ wp_safe_redirect($_REQUEST["redirect_to"]);
1249
+
1250
+ }
1251
+
1252
+ function cimy_change_signup_location($url) {
1253
+ global $blog_id, $current_site, $cimy_uef_plugins_dir;
1254
+
1255
+ if ($cimy_uef_plugins_dir == "plugins")
1256
+ $attribute = "?blog_id=".$blog_id;
1257
+ else
1258
+ $attribute = "";
1259
+
1260
+ return "http://" . $current_site->domain . $current_site->path . "wp-signup.php".$attribute;
1261
+ }
1262
+
1263
+ function cimy_change_login_registration_logo() {
1264
+ $options = cimy_get_options();
1265
+
1266
+ if (!empty($options["registration-logo"])) {
1267
+ global $cuef_upload_webpath;
1268
+ list($logo_width, $logo_height, $logo_type, $logo_attr) = getimagesize($options["registration-logo"]);
1269
+ ?>
1270
+ <style type="text/css">
1271
+ #login h1:first-child a:first-child {
1272
+ background: url(<?php echo esc_url($cuef_upload_webpath.basename($options["registration-logo"])); ?>) no-repeat top center;
1273
+ background-position: center top;
1274
+ width: <?php echo max(328, $logo_width); ?>px;
1275
+ height: <?php echo $logo_height; ?>px;
1276
+ text-indent: -9999px;
1277
+ overflow: hidden;
1278
+ padding-bottom: 15px;
1279
+ display: block;
1280
+ }
1281
+ </style>
1282
+ <?php
1283
+ }
1284
+ }
1285
+
1286
  ?>
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
  Description: Add some useful fields to registration and user's info
6
- Version: 2.3.2
7
  Author: Marco Cimmino
8
  Author URI: mailto:cimmino.marco@gmail.com
9
  License: GPL2
@@ -36,6 +36,7 @@ The full copy of the GNU General Public License is available here: http://www.gn
36
  // added for WordPress >=2.5 compatibility
37
  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, $cimy_uef_plugins_dir;
38
 
 
39
  function cimy_uef_set_tables() {
40
  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, $cimy_uef_plugins_dir;
41
  $prefix = $wpdb->prefix;
@@ -58,6 +59,7 @@ function cimy_uef_set_tables() {
58
  $wpdb_fields_table = $prefix."cimy_uef_fields";
59
  $wpdb_wp_fields_table = $prefix."cimy_uef_wp_fields";
60
  }
 
61
 
62
  cimy_uef_set_tables();
63
 
@@ -158,14 +160,7 @@ $cuef_css_webpath = plugins_url($cimy_uef_plugins_dirprefix."css", __FILE__);
158
  $cuef_js_webpath = plugins_url($cimy_uef_plugins_dirprefix."js", __FILE__);
159
  $cuef_securimage_webpath = plugins_url($cimy_uef_plugins_dirprefix."securimage", __FILE__);
160
 
161
- function cimy_uef_admin_init() {
162
- global $cuef_js_webpath;
163
- wp_register_script("cimy_uef_invert_sel", $cuef_js_webpath."/invert_sel.js", array(), false);
164
- wp_register_script("cimy_uef_ajax_new_value", $cuef_js_webpath."/ajax_new_value.js", array(), false);
165
- }
166
-
167
- add_action('admin_init', 'cimy_uef_admin_init');
168
-
169
  require_once($cuef_plugin_dir.'/cimy_uef_email_handler.php');
170
  require_once($cuef_plugin_dir.'/cimy_uef_db.php');
171
  require_once($cuef_plugin_dir.'/cimy_uef_register.php');
@@ -174,8 +169,10 @@ require_once($cuef_plugin_dir.'/cimy_uef_functions.php');
174
  require_once($cuef_plugin_dir.'/cimy_uef_options.php');
175
  require_once($cuef_plugin_dir.'/cimy_uef_admin.php');
176
 
 
 
177
  $cimy_uef_name = "Cimy User Extra Fields";
178
- $cimy_uef_version = "2.3.2";
179
  $cimy_uef_url = "http://www.marcocimmino.net/cimy-wordpress-plugins/cimy-user-extra-fields/";
180
  $cimy_project_url = "http://www.marcocimmino.net/cimy-wordpress-plugins/support-the-cimy-project-paypal/";
181
 
@@ -546,36 +543,8 @@ else {
546
  add_action('login_form_cimy_uef_redirect', 'cimy_uef_redirect');
547
  }
548
 
549
- function cimy_uef_registration_redirect($redirect_to) {
550
- if (empty($redirect_to)) {
551
- $options = cimy_get_options();
552
-
553
- if ($options["redirect_to"] == "source")
554
- $redirect_to = esc_attr($_SERVER["HTTP_REFERER"]);
555
- }
556
-
557
- return $redirect_to;
558
- }
559
-
560
- function cimy_uef_redirect() {
561
- if (isset($_GET["cimy_key"]))
562
- cimy_uef_activate("");
563
-
564
- if (!empty($_REQUEST["redirect_to"]))
565
- wp_safe_redirect($_REQUEST["redirect_to"]);
566
-
567
- }
568
-
569
- function cimy_change_signup_location($url) {
570
- global $blog_id, $current_site, $cimy_uef_plugins_dir;
571
-
572
- if ($cimy_uef_plugins_dir == "plugins")
573
- $attribute = "?blog_id=".$blog_id;
574
- else
575
- $attribute = "";
576
-
577
- return "http://" . $current_site->domain . $current_site->path . "wp-signup.php".$attribute;
578
- }
579
 
580
  // add javascripts to profile edit
581
  add_action('admin_print_scripts-user-edit.php', 'cimy_uef_admin_profile_init_js');
@@ -614,397 +583,4 @@ add_filter('get_avatar', 'cimy_uef_avatar_filter', 1, 5);
614
  // add code to handle new value from ajax code in A&U Extended
615
  add_action('wp_ajax_save-extra-field-new-value', 'cimy_uef_admin_ajax_save_ef_new_value');
616
 
617
- function cimy_uef_avatar_filter($avatar, $id_or_email, $size, $default, $alt="") {
618
- global $wpdb, $wpdb_data_table, $wpdb_fields_table, $cuef_upload_path;
619
-
620
- $sql = "SELECT ID,VALUE FROM $wpdb_fields_table WHERE TYPE='avatar' LIMIT 1";
621
- $res = $wpdb->get_results($sql);
622
-
623
- if (empty($res))
624
- return $avatar;
625
-
626
- $field_id = $res[0]->ID;
627
- $overwrite_default = $res[0]->VALUE;
628
-
629
- // if there is no avatar field all the rest is totally cpu time wasted, returning...
630
- if (!isset($field_id))
631
- return $avatar;
632
-
633
- if (!empty($overwrite_default))
634
- $overwrite_default = "<img alt='{$safe_alt}' src='{$overwrite_default}' class='avatar avatar-{$size} photo avatar-default' height='{$size}' width='{$size}' />";
635
-
636
- $email = '';
637
- $user_login = '';
638
-
639
- // $id_or_email could be id, email or an object... fancy way to implement things!
640
- // we may have the id
641
- if ( is_numeric($id_or_email) ) {
642
- $id = (int) $id_or_email;
643
- $user = get_userdata($id);
644
- if ( $user ) {
645
- $email = $user->user_email;
646
- $user_login = $user->user_login;
647
- }
648
- } elseif ( is_object($id_or_email) ) {
649
- // we may have the object...
650
- if ( isset($id_or_email->comment_type) && '' != $id_or_email->comment_type && 'comment' != $id_or_email->comment_type )
651
- return false; // No avatar for pingbacks or trackbacks, maybe useless as same check is performed before this code is fired...
652
-
653
- if ( !empty($id_or_email->user_id) ) {
654
- $id = (int) $id_or_email->user_id;
655
- $user = get_userdata($id);
656
- if ( $user) {
657
- $email = $user->user_email;
658
- $user_login = $user->user_login;
659
- }
660
- } else {
661
- // no user_id no custom avatar, nothing else to do
662
- return $avatar;
663
- }
664
- } else {
665
- // ...or we may have the email
666
- $email = $id_or_email;
667
-
668
- $sql = sprintf("SELECT ID, user_login FROM %s WHERE user_email='%s' LIMIT 1", $wpdb->users, $wpdb->escape($email));
669
- $res = $wpdb->get_results($sql);
670
-
671
- // something went wrong, aborting and returning normal avatar
672
- if (!isset($res))
673
- return $avatar;
674
-
675
- $id = $res[0]->ID;
676
- $user_login = $res[0]->user_login;
677
- }
678
-
679
- if (isset($id)) {
680
- $sql = "SELECT data.VALUE FROM $wpdb_data_table as data JOIN $wpdb_fields_table as efields ON efields.id=data.field_id WHERE (efields.TYPE='avatar' AND data.USER_ID=$id) LIMIT 1";
681
-
682
- $value = $wpdb->get_var($sql);
683
-
684
- if ( false === $alt)
685
- $safe_alt = '';
686
- else
687
- $safe_alt = esc_attr($alt);
688
-
689
- // max $size allowed is 512
690
- if (isset($value)) {
691
- if ($value == "") {
692
- // apply default only here or below, as we are sure to have an user that did not set anything
693
- if ($overwrite_default != "")
694
- return $overwrite_default;
695
- else
696
- return $avatar;
697
- }
698
-
699
- $thumb_value = cimy_get_thumb_path($value);
700
- $file_thumb = $cuef_upload_path.$user_login."/avatar/".cimy_get_thumb_path(basename($value));
701
-
702
- if (is_file($file_thumb))
703
- $value = $thumb_value;
704
-
705
- $avatar = "<img alt='{$safe_alt}' src='{$value}' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' />";
706
- }
707
- // apply default only here, as we are sure to have an user that did not set anything
708
- else if ($overwrite_default != "")
709
- return $overwrite_default;
710
- }
711
-
712
- return $avatar;
713
- }
714
-
715
- function cimy_uef_admin_init_js() {
716
- wp_enqueue_script("cimy_uef_invert_sel");
717
- cimy_uef_init_upload_js();
718
- }
719
-
720
- function cimy_uef_init_upload_js() {
721
- global $cuef_js_webpath;
722
- wp_register_script("cimy_uef_upload_file", $cuef_js_webpath."/upload_file.js", array(), false);
723
- wp_enqueue_script('cimy_uef_upload_file');
724
- }
725
-
726
- function cimy_uef_register_css() {
727
- global $cuef_css_webpath;
728
- wp_register_style("cimy_uef_register", $cuef_css_webpath."/cimy_uef_register.css", false, false);
729
- wp_enqueue_style("cimy_uef_register");
730
- cimy_uef_init_javascripts("show_in_reg");
731
- // needed till they fix this bug: http://core.trac.wordpress.org/ticket/17916#comment:18
732
- wp_print_styles();
733
- }
734
-
735
- function cimy_uef_admin_profile_init_js() {
736
- cimy_uef_init_javascripts("show_in_profile");
737
- }
738
-
739
- function cimy_uef_init_javascripts($rule_name) {
740
- global $cuef_plugin_dir, $cuef_css_webpath, $cuef_js_webpath;
741
-
742
- $options = cimy_get_options();
743
- if ($options['image_fields'][$rule_name] > 0) {
744
- wp_enqueue_script('imgareaselect', "", array("jquery"));
745
- wp_enqueue_style('imgareaselect');
746
- wp_register_script('cimy_uef_img_selection', $cuef_js_webpath."/img_selection.js", array(), false);
747
- wp_enqueue_script('cimy_uef_img_selection');
748
- }
749
-
750
- if ($options['file_fields'][$rule_name] > 0) {
751
- cimy_uef_init_upload_js();
752
- }
753
-
754
- if ($rule_name == "show_in_profile") {
755
- if ($options['tinymce_fields'][$rule_name] > 0 && function_exists("wp_editor")) {
756
- wp_register_style("cimy_uef_tinymce", $cuef_css_webpath."/cimy_uef_tinymce.css", false, false);
757
- wp_enqueue_style('cimy_uef_tinymce');
758
- }
759
- }
760
- if ($rule_name == "show_in_reg" && (empty($_POST['register_confirmation']) || $_POST['register_confirmation'] != "1")) {
761
- // This is needed for registration form on WordPress >= 3.3
762
- if ($options['tinymce_fields'][$rule_name] > 0 && function_exists("wp_editor"))
763
- wp_enqueue_script('utils');
764
-
765
- if ($options['password_meter']) {
766
- wp_register_script("cimy_uef_password_strength_meter", $cuef_js_webpath."/password_strength_meter.js", array("password-strength-meter"), false);
767
- wp_enqueue_script('cimy_uef_password_strength_meter');
768
- }
769
-
770
- // damn WordPress bugs
771
- if (is_multisite())
772
- wp_print_scripts();
773
- }
774
- }
775
-
776
- function cimy_change_login_registration_logo() {
777
- $options = cimy_get_options();
778
-
779
- if (!empty($options["registration-logo"])) {
780
- global $cuef_upload_webpath;
781
- list($logo_width, $logo_height, $logo_type, $logo_attr) = getimagesize($options["registration-logo"]);
782
- ?>
783
- <style type="text/css">
784
- #login h1:first-child a:first-child {
785
- background: url(<?php echo esc_url($cuef_upload_webpath.basename($options["registration-logo"])); ?>) no-repeat top center;
786
- background-position: center top;
787
- width: <?php echo max(328, $logo_width); ?>px;
788
- height: <?php echo $logo_height; ?>px;
789
- text-indent: -9999px;
790
- overflow: hidden;
791
- padding-bottom: 15px;
792
- display: block;
793
- }
794
- </style>
795
- <?php
796
- }
797
- }
798
-
799
- function cimy_uef_i18n_setup() {
800
- global $cimy_uef_domain, $cimy_uef_i18n_is_setup, $cuef_plugin_path, $cimy_uef_plugins_dir;
801
-
802
- if ($cimy_uef_i18n_is_setup)
803
- return;
804
-
805
- // Stupid function, from relative path I need to go down because starts from WP_PLUGIN_DIR!
806
- if (is_multisite())
807
- load_plugin_textdomain($cimy_uef_domain, false, '../'.$cimy_uef_plugins_dir.'/'.$cuef_plugin_path.'langs');
808
- else
809
- load_plugin_textdomain($cimy_uef_domain, false, $cuef_plugin_path.'langs');
810
- }
811
-
812
- function cimy_admin_menu_custom() {
813
- global $cimy_uef_name, $cimy_uef_domain, $cimy_top_menu, $cimy_uef_plugins_dir;
814
-
815
- $aue_page = "";
816
- if (isset($cimy_top_menu) && (!is_multisite())) {
817
- add_submenu_page('cimy_series.php', $cimy_uef_name.": ".__("Options"), "UEF: ".__("Options"), 'manage_options', "user_extra_fields_options", 'cimy_show_options_notembedded');
818
- add_submenu_page('cimy_series.php', $cimy_uef_name.": ".__("Fields", $cimy_uef_domain), "UEF: ".__("Fields", $cimy_uef_domain), 'manage_options', "user_extra_fields", 'cimy_admin_define_extra_fields');
819
- $aue_page = add_submenu_page('profile.php', __('Users Extended', $cimy_uef_domain), __('Users Extended', $cimy_uef_domain), 'list_users', "users_extended", 'cimy_admin_users_list_page');
820
- }
821
- else {
822
- if ((is_multisite()) && ($cimy_uef_plugins_dir == "mu-plugins")) {
823
- // $aue_page = add_submenu_page('wpmu-admin.php', __("Users Extended", $cimy_uef_domain), __("Users Extended", $cimy_uef_domain), 'list_users', "users_extended", 'cimy_admin_users_list_page');
824
- // add_submenu_page('wpmu-admin.php', $cimy_uef_name, $cimy_uef_name, 'manage_options', "user_extra_fields", 'cimy_admin_define_extra_fields');
825
-
826
- // Since WP 3.1 we have network admin and everything seems changed
827
- $aue_page = add_submenu_page('users.php', __("Users Extended", $cimy_uef_domain), __("Users Extended", $cimy_uef_domain), 'list_users', "users_extended", 'cimy_admin_users_list_page');
828
- $admin = add_submenu_page('settings.php', $cimy_uef_name, $cimy_uef_name, 'manage_options', "user_extra_fields", 'cimy_admin_define_extra_fields');
829
- }
830
- else {
831
- $admin = add_options_page($cimy_uef_name, $cimy_uef_name, 'manage_options', "user_extra_fields", 'cimy_admin_define_extra_fields');
832
- $aue_page = add_submenu_page('profile.php', __('Users Extended', $cimy_uef_domain), __('Users Extended', $cimy_uef_domain), 'list_users', "users_extended", 'cimy_admin_users_list_page');
833
- }
834
- }
835
- if (!empty($aue_page))
836
- add_action('admin_print_scripts-'.$aue_page, 'cimy_uef_admin_ajax_edit');
837
- if (!empty($admin))
838
- add_action('admin_print_scripts-'.$admin, 'cimy_uef_admin_init_js');
839
- }
840
-
841
- function cimy_manage_upload($input_name, $user_login, $rules, $old_file=false, $delete_file=false, $type="", $new_filename="") {
842
- global $cuef_upload_path, $cuef_upload_webpath, $cuef_plugin_dir, $cimy_uef_plugins_dir;
843
-
844
- $type_path = "";
845
- if (($type == "file") || ($type == "avatar"))
846
- $type_path.= $type."/";
847
-
848
- $blog_path = $cuef_upload_path;
849
-
850
- if (($cimy_uef_plugins_dir == "plugins") && (is_multisite())) {
851
- global $blog_id;
852
-
853
- $blog_path .= $blog_id."/";
854
-
855
- // create blog subdir
856
- if (!is_dir($blog_path)) {
857
- if (defined("FS_CHMOD_DIR")) {
858
- mkdir($blog_path, FS_CHMOD_DIR);
859
- chmod($blog_path, FS_CHMOD_DIR);
860
- }
861
- else {
862
- mkdir($blog_path, 0777);
863
- chmod($blog_path, 0777);
864
- }
865
- }
866
- }
867
-
868
- if (!empty($user_login)) {
869
- $user_path = $blog_path.$user_login."/";
870
- $file_path = $blog_path.$user_login."/".$type_path;
871
- }
872
- else {
873
- $user_path = $blog_path;
874
- $file_path = $blog_path.$type_path;
875
- }
876
- if (!empty($new_filename))
877
- $file_name = $new_filename;
878
- else
879
- $file_name = $_FILES[$input_name]['name'];
880
-
881
- // protect from site traversing
882
- $file_name = str_replace('../', '', $file_name);
883
- $file_name = str_replace('/', '', $file_name);
884
-
885
- // delete old file if requested
886
- if ($delete_file) {
887
- if (is_file($file_path.$old_file))
888
- unlink($file_path.$old_file);
889
-
890
- $old_thumb_file = cimy_get_thumb_path($old_file);
891
-
892
- if (is_file($file_path.$old_thumb_file))
893
- unlink($file_path.$old_thumb_file);
894
- }
895
-
896
- // if $user_login is not present
897
- // or there is no file to upload
898
- // or dest dir is not writable
899
- // then everything else is useless
900
- if ((($user_login == "") && ($type != "registration-logo")) || (!isset($_FILES[$input_name]['name'])) || (!is_writable($cuef_upload_path)))
901
- return "";
902
-
903
- // create user subdir
904
- if (!is_dir($user_path)) {
905
- if (defined("FS_CHMOD_DIR")) {
906
- mkdir($user_path, FS_CHMOD_DIR);
907
- chmod($user_path, FS_CHMOD_DIR);
908
- }
909
- else {
910
- mkdir($user_path, 0777);
911
- chmod($user_path, 0777);
912
- }
913
- }
914
-
915
- // create avatar subdir if needed
916
- if (($type != "registration-logo") && ($type != "picture") && (!is_dir($file_path))) {
917
- if (defined("FS_CHMOD_DIR")) {
918
- mkdir($file_path, FS_CHMOD_DIR);
919
- chmod($file_path, FS_CHMOD_DIR);
920
- }
921
- else {
922
- mkdir($file_path, 0777);
923
- chmod($file_path, 0777);
924
- }
925
- }
926
-
927
- // picture filesystem path
928
- $file_full_path = $file_path.$file_name;
929
-
930
- // picture url to write in the DB
931
- $data = $cuef_upload_webpath;
932
-
933
- if (($cimy_uef_plugins_dir == "plugins") && (is_multisite()))
934
- $data.= $blog_id."/";
935
-
936
- if (empty($user_login))
937
- $data .= $type_path.$file_name;
938
- else
939
- $data .= $user_login."/".$type_path.$file_name;
940
-
941
- // filesize in Byte transformed in KiloByte
942
- $file_size = $_FILES[$input_name]['size'] / 1024;
943
- $file_type = $_FILES[$input_name]['type'];
944
- $file_tmp_name = $_FILES[$input_name]['tmp_name'];
945
- $file_error = $_FILES[$input_name]['error'];
946
-
947
- // CHECK IF IT IS A REAL PICTURE
948
- if (($type != "file") && (stristr($file_type, "image/") === false))
949
- $file_error = 1;
950
-
951
- // MIN LENGTH
952
- if (isset($rules['min_length']))
953
- if ($file_size < (intval($rules['min_length'])))
954
- $file_error = 1;
955
-
956
- // EXACT LENGTH
957
- if (isset($rules['exact_length']))
958
- if ($file_size != (intval($rules['exact_length'])))
959
- $file_error = 1;
960
-
961
- // MAX LENGTH
962
- if (isset($rules['max_length']))
963
- if ($file_size > (intval($rules['max_length'])))
964
- $file_error = 1;
965
-
966
- // if there are no errors and filename is NOT empty
967
- if (($file_error == 0) && (!empty($file_name))) {
968
- if (move_uploaded_file($file_tmp_name, $file_full_path)) {
969
- // change file permissions for broken servers
970
- if (defined("FS_CHMOD_FILE"))
971
- @chmod($file_full_path, FS_CHMOD_FILE);
972
- else
973
- @chmod($file_full_path, 0644);
974
-
975
- // if there is an old file to delete
976
- if ($old_file) {
977
- // delete old file if the name is different, if equal NOPE because new file is already uploaded
978
- if ($file_name != $old_file)
979
- if (is_file($file_path.$old_file))
980
- unlink($file_path.$old_file);
981
-
982
- $old_thumb_file = cimy_get_thumb_path($old_file);
983
-
984
- if (is_file($file_path.$old_thumb_file))
985
- unlink($file_path.$old_thumb_file);
986
- }
987
-
988
- // should be stay AFTER DELETIONS
989
- if ((isset($rules['equal_to'])) && ($type != "file")) {
990
- if ($maxside = intval($rules['equal_to'])) {
991
- if (!function_exists("image_resize"))
992
- require_once(ABSPATH . 'wp-includes/media.php');
993
-
994
- if (!function_exists("wp_load_image"))
995
- require_once($cuef_plugin_dir.'/cimy_uef_missing_functions.php');
996
-
997
- image_resize($file_full_path, $maxside, $maxside, false, "thumbnail");
998
- }
999
- }
1000
- }
1001
- else
1002
- $data = "";
1003
- }
1004
- else
1005
- $data = "";
1006
-
1007
- return $data;
1008
- }
1009
-
1010
- ?>
3
  Plugin Name: Cimy User Extra Fields
4
  Plugin URI: http://www.marcocimmino.net/cimy-wordpress-plugins/cimy-user-extra-fields/
5
  Description: Add some useful fields to registration and user's info
6
+ Version: 2.3.3
7
  Author: Marco Cimmino
8
  Author URI: mailto:cimmino.marco@gmail.com
9
  License: GPL2
36
  // added for WordPress >=2.5 compatibility
37
  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, $cimy_uef_plugins_dir;
38
 
39
+ if (!function_exists('cimy_uef_set_tables')) :
40
  function cimy_uef_set_tables() {
41
  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, $cimy_uef_plugins_dir;
42
  $prefix = $wpdb->prefix;
59
  $wpdb_fields_table = $prefix."cimy_uef_fields";
60
  $wpdb_wp_fields_table = $prefix."cimy_uef_wp_fields";
61
  }
62
+ endif;
63
 
64
  cimy_uef_set_tables();
65
 
160
  $cuef_js_webpath = plugins_url($cimy_uef_plugins_dirprefix."js", __FILE__);
161
  $cuef_securimage_webpath = plugins_url($cimy_uef_plugins_dirprefix."securimage", __FILE__);
162
 
163
+ require_once($cuef_plugin_dir.'/cimy_uef_init.php');
 
 
 
 
 
 
 
164
  require_once($cuef_plugin_dir.'/cimy_uef_email_handler.php');
165
  require_once($cuef_plugin_dir.'/cimy_uef_db.php');
166
  require_once($cuef_plugin_dir.'/cimy_uef_register.php');
169
  require_once($cuef_plugin_dir.'/cimy_uef_options.php');
170
  require_once($cuef_plugin_dir.'/cimy_uef_admin.php');
171
 
172
+ add_action('admin_init', 'cimy_uef_admin_init');
173
+
174
  $cimy_uef_name = "Cimy User Extra Fields";
175
+ $cimy_uef_version = "2.3.3";
176
  $cimy_uef_url = "http://www.marcocimmino.net/cimy-wordpress-plugins/cimy-user-extra-fields/";
177
  $cimy_project_url = "http://www.marcocimmino.net/cimy-wordpress-plugins/support-the-cimy-project-paypal/";
178
 
543
  add_action('login_form_cimy_uef_redirect', 'cimy_uef_redirect');
544
  }
545
 
546
+ // with Theme My Login is more complicated, but we know how to workaround it
547
+ add_action('wp_enqueue_scripts', 'cimy_uef_theme_my_login_fix', 15);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
548
 
549
  // add javascripts to profile edit
550
  add_action('admin_print_scripts-user-edit.php', 'cimy_uef_admin_profile_init_js');
583
  // add code to handle new value from ajax code in A&U Extended
584
  add_action('wp_ajax_save-extra-field-new-value', 'cimy_uef_admin_ajax_save_ef_new_value');
585
 
586
+ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
langs/cimy_uef-be_BY.mo ADDED
Binary file
langs/cimy_uef-be_BY.po ADDED
@@ -0,0 +1,1207 @@