WordPress:WPMU Cimy Extra Fields 插件

来自站长百科
跳转至: 导航、​ 搜索

These notes are from memory. Please correct them!

这些记录来自内存。请更改!

[1]

[2]

Note from Marco Cimmino the author of the plug-in:

来自插件作者Marco Cimmino的笔记:

These informations are from users not from me, so I thanx them but I should advise you that are UNOFFICIAL and UNSUPPORTED by me.

这些信息是来自用户而不是来自我的,因此,我感谢这些用户,但是我要提醒你,这些信息是不正式,也不由我支持。

Also note that these modifications are no more necessary with Cimy User Extra Fields 1.0.0 that partially support WordPress MU. If you want to see full MU support in this plug-in contact me and sponsor it.

同时注意部分由WordPress MU支持的Cimy User Extra Fields 1.0.0,更需要这些更改。 如果你希望得到这个插件的完全的MU支持,请联系我,我会提纲帮助。

Thanx
Marco Cimmino

Thanx
Marco Cimmino


Cimy User Extra Fields for WordPress[ ]

WordPress的Cimy User Extra Fields[ ]

WordPress is becoming more than ever a tool to open blog/websites and CMSs in an easier way. Users are increasing day by day; one of the limits however is the restricted and predefined fields that are available in the registered users profile: it is difficult for example to ask for the acceptance of “Terms and Conditions of Use” or “Permission to use personal data”.

WordPress is becoming more than ever a tool to open blog/websites and CMSs in an easier way. Users are increasing day by day; one of the limits however is the restricted and predefined fields that are available in the registered users profile: it is difficult for example to ask for the acceptance of “Terms and Conditions of Use” or “Permission to use personal data”.

WordPress越来越不仅仅是个以简单的方式打开博客/网站和CMSs的工具。用户一天天地增加;其中的一个限制是注册用户基本资料中的受限制的和预先确定的fields:例子很难要求接受“使用条款和条件” 或者“使用个人数据的权限”。

It’s also possible to set a password during registration combined to equalTO rule, only people who knows the password can register.

在注册过程中,设置与equalTO规则相结合的密码,只有知道密码的用户,才可以注册。

We have developed a WordPress plug-in to do this. 我们开发了WordPress插件来执行这个操作。



This plugin can work if you make two types of MU modification:

如果你创建两种类型的MU modification,这个插件可以运行:

1) wordPress:UnMuify the plugin shared tables 2) wordPress:Manually activate the WPMU mu-plugins

1) UnMuify the plugin shared tables

2) 动手激活WPMU mu-插件

For 1) at the start of the plugin's main file, there's a line that sets $cimy_data = $wpdb->prefix . 'cimy_data';

1)在插件的主要文件的开头,有一行设置了$cimy_data = $wpdb->prefix . 'cimy_data';

Now, WPMU muifys the prefix, replacing changing it from the default wp_ prefix to wp_x_ where x = 1...n; as this is usually needed to convert plugins that know about a single blog to one that can deal with many. You need to inhibit this. In the plugin file, at the top, replace the $wpdb->prefix with the change:

现在,WPMU muifys前缀,replacing changing it from the default wp_ prefix to wp_x_ where x = 1...n;通常这需要将了解单个博客的插件转换为了解多个博客的插件。你需要抑制这种情况。在插件文件中,在顶上方,将$wpdb->prefix替换为the change:

$cimy_data = 'wp_'. 'cimy_data'; $cimy_fields = 'wp_'. 'cimy_fields';

$cimy_data = 'wp_'. 'cimy_data'; $cimy_fields = 'wp_'. 'cimy_fields';

For 2) WPMU does not honour WP's contract to plugins to let them activate when they first start. This means that plugins never get the chance to initialize tables.

2)WPMU不让WP联系插件,使得插件刚开始,就激活。这意味着插件永远都不会初始化表格。

A crap (but effective) workaround is to manually install into plugins, activate, and move the plugin into Mu plugins. In order for this to work, you need to disable (remove) the copy on mu-plugins, activate this one, and then upload to mu-plugins.

A crap (但是有效) workaround是要动手安装到插件中,激活插件并且将插件转移到Mu插件。为了能够运行,你需要取消(移除)mu-plugins上的copy,激活这个插件,然后上传到mu-plugins。



Feel free to correct these instructions, and point to them liberally, but please don't add them to the forum. Because the forums are write-once, they have become morass of duplicated, often incorrect and incomplete.

随意地更改这些指示说明,随意地指向这些说明,但是请不要将这些说明添加到论坛上。因为论坛上发表的内容,会不断地被复制,通常内容不正确也不完整。

RCS file: cimy_user_extra_fields.php,v
retrieving revision 1.1
diff -C 5 -r1.1 cimy_user_extra_fields.php
*** cimy_user_extra_fields.php  2007/08/24 11:59:54     1.1
--- cimy_user_extra_fields.php  2007/08/24 19:01:42
***************
*** 35,46 ****
  */

  if (!function_exists(php_compat_mqgpc_unescape))
        include_once("magic_quotes_gpc_off_function.php");

! $wpdb_data_table = $wpdb->prefix."cimy_data";
! $wpdb_fields_table = $wpdb->prefix."cimy_fields";

  $cimy_uef_options = "cimy_uef_options";
  $cimy_uef_options_descr = "Cimy User Extra Fields options are stored here and modified only by admin";

  /*
--- 35,48 ----
  */

  if (!function_exists(php_compat_mqgpc_unescape))
        include_once("magic_quotes_gpc_off_function.php");

!       //$wpdb_data_table = $wpdb->prefix."cimy_data";
!       //$wpdb_fields_table = $wpdb->prefix."cimy_fields";
!       $wpdb_data_table = "wp_cimy_data";
!       $wpdb_fields_table = "wp_cimy_fields";

  $cimy_uef_options = "cimy_uef_options";
  $cimy_uef_options_descr = "Cimy User Extra Fields options are stored here and modified only by admin";

  /*
***************
*** 193,202 ****
--- 195,205 ----

  // add update engine for extra fields to user's registration
  add_action('user_register', 'cimy_register_user_extra_fields');

  // function that add the submenu under 'Users'
+
  add_action('admin_menu', 'cimy_admin_menu_custom');

  // delete user extra fields data when a user is deleted
  add_action('delete_user', 'cimy_delete_user_info');

***************
*** 257,267 ****
                $values = substr($values, $label_pos + 1);
        }
        else
                $label = "";

!       $items = explode(",",$values);
        $html_options = "";

        foreach ($items as $item) {
                $html_options.= "\n\t\t\t";
                $html_options.= '<option value="'.$item.'"';
--- 260,272 ----
                $values = substr($values, $label_pos + 1);
        }
        else
                $label = "";

!       // in case the user pastes from windows or mac, convert to \n
!       $items = str_replace(array("\r\n", "\n", "\r"), "\n", $items);
!       $items = explode("\n",$values);
        $html_options = "";

        foreach ($items as $item) {
                $html_options.= "\n\t\t\t";
                $html_options.= '<option value="'.$item.'"';
***************
*** 306,317 ****
  }

  function cimy_admin_menu_custom() {
        global $cimy_uef_name;

!       add_options_page($cimy_uef_name, $cimy_uef_name, 10, basename(__FILE__), 'cimy_admin_define_extra_fields');
!         add_submenu_page('profile.php', 'Authors & Users Extended', 'A&U Extended', 10, basename(__FILE__), 'cimy_admin_users_list_page');
  }

  function cimy_get_thumb_path($file_path) {
        $file_path_purename = substr($file_path, 0, strrpos($file_path, "."));
        $file_path_ext = substr($file_path, strlen($file_path_purename));
--- 311,324 ----
  }

  function cimy_admin_menu_custom() {
        global $cimy_uef_name;

!       if (is_site_admin()) {
!         add_options_page($cimy_uef_name, $cimy_uef_name, 10, basename(__FILE__), 'cimy_admin_define_extra_fields');
!         add_submenu_page('profile.php', 'Authors & Users Extended', 'A&U Extended', 10, basename(__FILE__), 'cimy_admin_users_list_page');
!       }
  }

  function cimy_get_thumb_path($file_path) {
        $file_path_purename = substr($file_path, 0, strrpos($file_path, "."));
        $file_path_ext = substr($file_path, strlen($file_path_purename));
***************
*** 2770,2780 ****

        if ($i > 0) {
                $query.=" ELSE FIELD_ID END WHERE FIELD_ID IN(".$field_ids.") AND USER_ID = ".$get_user_id;

                // $query WILL BE: UPDATE <table> SET VALUE=CASE FIELD_ID WHEN <field_id1> THEN <value1> [WHEN ... THEN ...] ELSE FIELD_ID END WHERE FIELD_ID IN(<field_id1>, [<field_id2>...]) AND USER_ID=<user_id>
!               $wpdb->query($query);
        }
  }

  function cimy_insert_ExtraFields_if_not_exist($user_id, $field_id) {
        global $wpdb, $wpdb_data_table;
--- 2777,2787 ----

        if ($i > 0) {
                $query.=" ELSE FIELD_ID END WHERE FIELD_ID IN(".$field_ids.") AND USER_ID = ".$get_user_id;

                // $query WILL BE: UPDATE <table> SET VALUE=CASE FIELD_ID WHEN <field_id1> THEN <value1> [WHEN ... THEN ...] ELSE FIELD_ID END WHERE FIELD_ID IN(<field_id1>, [<field_id2>...]) AND USER_ID=<user_id>
!               $ans = $wpdb->query($query);
        }
  }

  function cimy_insert_ExtraFields_if_not_exist($user_id, $field_id) {
        global $wpdb, $wpdb_data_table;
















RCS file: cimy_user_extra_fields.php,v
返回 1.1版本
diff -C 5 -r1.1 cimy_user_extra_fields.php
*** cimy_user_extra_fields.php  2007/08/24 11:59:54     1.1
--- cimy_user_extra_fields.php  2007/08/24 19:01:42
***************
*** 35,46 ****
  */

  if (!function_exists(php_compat_mqgpc_unescape))
        include_once("magic_quotes_gpc_off_function.php");

! $wpdb_data_table = $wpdb->prefix."cimy_data";
! $wpdb_fields_table = $wpdb->prefix."cimy_fields";

  $cimy_uef_options = "cimy_uef_options";
  $cimy_uef_options_descr = "Cimy User Extra Fields options are stored here and modified only by admin";

  /*
--- 35,48 ----
  */

  if (!function_exists(php_compat_mqgpc_unescape))
        include_once("magic_quotes_gpc_off_function.php");

!       //$wpdb_data_table = $wpdb->prefix."cimy_data";
!       //$wpdb_fields_table = $wpdb->prefix."cimy_fields";
!       $wpdb_data_table = "wp_cimy_data";
!       $wpdb_fields_table = "wp_cimy_fields";

  $cimy_uef_options = "cimy_uef_options";
  $cimy_uef_options_descr = "Cimy User Extra Fields 选项储存在这里而且只有管理员才能够更改";

  /*
***************
*** 193,202 ****
--- 195,205 ----

  // 为用户注册的额外fields添加更新引擎
  add_action('user_register', 'cimy_register_user_extra_fields');

  //将子菜单添加到 '用户'下面的函数
+
  add_action('admin_menu', 'cimy_admin_menu_custom');

  // 删除用户的时候,删除用户delete user extra fields 数据
  add_action('delete_user', 'cimy_delete_user_info');

***************
*** 257,267 ****
                $values = substr($values, $label_pos + 1);
        }
        else
                $label = "";

!       $items = explode(",",$values);
        $html_options = "";

        foreach ($items as $item) {
                $html_options.= "\n\t\t\t";
                $html_options.= '<option value="'.$item.'"';
--- 260,272 ----
                $values = substr($values, $label_pos + 1);
        }
        else
                $label = "";

!       // 用户从windows或者mac中粘贴,转换为 \n
!       $items = str_replace(array("\r\n", "\n", "\r"), "\n", $items);
!       $items = explode("\n",$values);
        $html_options = "";

        foreach ($items as $item) {
                $html_options.= "\n\t\t\t";
                $html_options.= '<option value="'.$item.'"';
***************
*** 306,317 ****
  }

  function cimy_admin_menu_custom() {
        global $cimy_uef_name;

!       add_options_page($cimy_uef_name, $cimy_uef_name, 10, basename(__FILE__), 'cimy_admin_define_extra_fields');
!         add_submenu_page('profile.php', 'Authors & Users Extended', 'A&U Extended', 10, basename(__FILE__), 'cimy_admin_users_list_page');
  }

  function cimy_get_thumb_path($file_path) {
        $file_path_purename = substr($file_path, 0, strrpos($file_path, "."));
        $file_path_ext = substr($file_path, strlen($file_path_purename));
--- 311,324 ----
  }

  function cimy_admin_menu_custom() {
        global $cimy_uef_name;

!       if (is_site_admin()) {
!         add_options_page($cimy_uef_name, $cimy_uef_name, 10, basename(__FILE__), 'cimy_admin_define_extra_fields');
!         add_submenu_page('profile.php', 'Authors & Users Extended', 'A&U Extended', 10, basename(__FILE__), 'cimy_admin_users_list_page');
!       }
  }

  function cimy_get_thumb_path($file_path) {
        $file_path_purename = substr($file_path, 0, strrpos($file_path, "."));
        $file_path_ext = substr($file_path, strlen($file_path_purename));
***************
*** 2770,2780 ****

        if ($i > 0) {
                $query.=" ELSE FIELD_ID END WHERE FIELD_ID IN(".$field_ids.") AND USER_ID = ".$get_user_id;

                // $query WILL BE: UPDATE <table> SET VALUE=CASE FIELD_ID WHEN <field_id1> THEN <value1> [WHEN ... THEN ...] ELSE FIELD_ID END WHERE FIELD_ID IN(<field_id1>, [<field_id2>...]) AND USER_ID=<user_id>
!               $wpdb->query($query);
        }
  }

  function cimy_insert_ExtraFields_if_not_exist($user_id, $field_id) {
        global $wpdb, $wpdb_data_table;
--- 2777,2787 ----

        if ($i > 0) {
                $query.=" ELSE FIELD_ID END WHERE FIELD_ID IN(".$field_ids.") AND USER_ID = ".$get_user_id;

                // $query WILL BE: UPDATE <table> SET VALUE=CASE FIELD_ID WHEN <field_id1> THEN <value1> [WHEN ... THEN ...] ELSE FIELD_ID END WHERE FIELD_ID IN(<field_id1>, [<field_id2>...]) AND USER_ID=<user_id>
!               $ans = $wpdb->query($query);
        }
  }

  function cimy_insert_ExtraFields_if_not_exist($user_id, $field_id) {
        global $wpdb, $wpdb_data_table;