Plugin Directory

Changeset 121224


Ignore:
Timestamp:
05/28/2009 07:21:15 PM (17 years ago)
Author:
redgecko
Message:

Add role equivalent groups edit GUI and add setting link in the plugin page.

Location:
simple-ldap-authentication/trunk
Files:
3 added
5 edited
1 copied

Legend:

Unmodified
Added
Removed
  • simple-ldap-authentication/trunk/languages/simple-ldap-authentication-ja.po

    r118102 r121224  
    33"Project-Id-Version: シンプル LDAP 認証 1.0.1\n"
    44"Report-Msgid-Bugs-To: http://wordpress.org/tag/simple-ldap-authentication\n"
    5 "POT-Creation-Date: 2009-05-15 18:40+0900\n"
    6 "PO-Revision-Date: 2009-05-15 18:43+0900\n"
     5"POT-Creation-Date: 2009-05-29 03:34+0900\n"
     6"PO-Revision-Date: 2009-05-29 03:36+0900\n"
    77"Last-Translator: Yoshimitsu Mori <[email protected]>\n"
    88"Language-Team: Japanese <[email protected]>\n"
     
    1111"Content-Transfer-Encoding: 8bit\n"
    1212
    13 #. #-#-#-#-#  simple-ldap-authentication.pot (Simple LDAP Authentication 1.0.1)  #-#-#-#-#
     13#. #-#-#-#-#  simple-ldap-authentication.pot (Simple LDAP Authentication 1.0.4)  #-#-#-#-#
    1414#. Plugin Name of an extension
    15 #: simple-ldap-authentication.php:78
     15#: simple-ldap-authentication.php:80
    1616msgid "Simple LDAP Authentication"
    1717msgstr "シンプル LDAP 認証"
    1818
    19 #: simple-ldap-authentication.php:143
     19#: simple-ldap-authentication.php:103
    2020msgid ""
    2121"<strong>ERROR</strong>: LDAP user ID search filter is inacuurate. The filter "
     
    2525"には '%user_id%' が含まれている必要があります。"
    2626
    27 #: simple-ldap-authentication.php:155
     27#: simple-ldap-authentication.php:115
    2828#, php-format
    2929msgid "<strong>ERROR</strong>: Cannot connect to '%s'."
    3030msgstr "<strong>エラー</strong>:'%s' に接続できません。"
    3131
    32 #: simple-ldap-authentication.php:165
     32#: simple-ldap-authentication.php:125
    3333msgid ""
    3434"<strong>ERROR</strong>: LDAP bind failed. Either the LDAPS connection failed "
     
    3838"たか、ログイン資格が間違っています。"
    3939
    40 #: simple-ldap-authentication.php:167
     40#: simple-ldap-authentication.php:127
    4141msgid "<strong>ERROR</strong>: LDAP bind failed. Check the login credentials."
    4242msgstr ""
     
    4444"てください。"
    4545
    46 #: simple-ldap-authentication.php:230
     46#: simple-ldap-authentication.php:190
    4747msgid ""
    4848"<strong>ERROR</strong>: This user exists in LDAP, but has not been granted "
     
    5252"セスは許可されていません。"
    5353
    54 #: simple-ldap-authentication.php:329
     54#: simple-ldap-authentication.php:372
    5555msgid "Simple LDAP Authentication Options"
    5656msgstr "シンプル LDAP 認証の設定"
    5757
    58 #: simple-ldap-authentication.php:337
     58#: simple-ldap-authentication.php:380
    5959msgid "LDAP Server"
    6060msgstr "LDAP サーバ"
    6161
    62 #: simple-ldap-authentication.php:340
     62#: simple-ldap-authentication.php:383
    6363msgid "LDAP Server (e.g. <code>ldap.example.net</code>)"
    6464msgstr "LDAP サーバを指定してください。(例:<code>ldap.example.net</code>)"
    6565
    66 #: simple-ldap-authentication.php:344
     66#: simple-ldap-authentication.php:387
    6767msgid "Use SSL connection with LDAP?"
    6868msgstr "SSL 接続を使いますか?"
    6969
    70 #: simple-ldap-authentication.php:347
     70#: simple-ldap-authentication.php:390
    7171msgid "If you use SSL connection or not, when LDAP connection."
    7272msgstr "LDAP での接続時に SSL で通信を行うかを設定します。"
    7373
    74 #: simple-ldap-authentication.php:351
     74#: simple-ldap-authentication.php:394
    7575msgid "Base DN"
    7676msgstr "ベース DN"
    7777
    78 #: simple-ldap-authentication.php:354
     78#: simple-ldap-authentication.php:397
    7979msgid "Base DN (e.g., <code>dc=example,dc=net</code>)"
    8080msgstr ""
     
    8282"code>)"
    8383
    84 #: simple-ldap-authentication.php:358
     84#: simple-ldap-authentication.php:401
    8585msgid "Bind DN"
    8686msgstr "特権のないデータベースユーザ (バインド DN)"
    8787
    88 #: simple-ldap-authentication.php:361
     88#: simple-ldap-authentication.php:404
    8989msgid "Bind DN (e.g., <code>cn=proxyuser,dc=example,dc=net</code>)"
    9090msgstr ""
     
    9292"(例:<code>cn=proxyuser,dc=example,dc=net</code>)"
    9393
    94 #: simple-ldap-authentication.php:365
     94#: simple-ldap-authentication.php:408
    9595msgid "Bind Password"
    9696msgstr "データベースログインアカウントのパスワード (バインド・パスワード)"
    9797
    98 #: simple-ldap-authentication.php:368
     98#: simple-ldap-authentication.php:411
    9999msgid "Password for database login account."
    100100msgstr ""
    101101"LDAP データベースにログインするのに使われるパスワードを入力してください。"
    102102
    103 #: simple-ldap-authentication.php:372
     103#: simple-ldap-authentication.php:415
    104104msgid "User ID Search Filter"
    105105msgstr "ユーザ ID を検索する際のフィルタ"
    106106
    107 #: simple-ldap-authentication.php:375
    108 msgid ""
    109 "LDAP filter for searching user ID (e.g., <code>(uid=%user_id%)</code>)<br/>\n"
     107#: simple-ldap-authentication.php:418
     108msgid ""
     109"LDAP filter for searching user ID (e.g., <code>(uid=%user_id%)</code>)<br />\n"
    110110"This setting must contain <code>%user_id%</code> string."
    111111msgstr ""
    112112"ユーザ ID を検索するための LDAP フィルタを指定してください。(例:<code>(uid="
    113 "%user_id%)</code>)<br/>\n"
     113"%user_id%)</code>)<br />\n"
    114114"この設定には、文字列 <code>%user_id%</code> が含まれている必要があります。"
    115115
    116 #: simple-ldap-authentication.php:380
     116#: simple-ldap-authentication.php:423
    117117msgid "Group Search Filter"
    118118msgstr "グループを検索する際のフィルタ"
    119119
    120 #: simple-ldap-authentication.php:383
    121 msgid ""
    122 "LDAP filter for searching group (e.g., <code>(cn=%group%)</code>)<br/>\n"
     120#: simple-ldap-authentication.php:426
     121msgid ""
     122"LDAP filter for searching group (e.g., <code>(cn=%group%)</code>)<br />\n"
    123123"This setting must contain <code>%group%</code> string."
    124124msgstr ""
    125125"グループを検索するための LDAP フィルタを指定してください。(例:<code>(cn=%"
    126 "group%)</code>)<br/>\n"
     126"group%)</code>)<br />\n"
    127127"この設定には、文字列 <code>%group%</code> が含まれている必要があります。"
    128128
    129 #: simple-ldap-authentication.php:388
     129#: simple-ldap-authentication.php:431
    130130msgid "Group Member Attribute"
    131131msgstr "グループメンバの属性"
    132132
    133 #: simple-ldap-authentication.php:391
     133#: simple-ldap-authentication.php:434
    134134msgid "LDAP attribute for group member (e.g., <code>memberuid</code>)"
    135135msgstr ""
     
    137137"<code>memberuid</code>)"
    138138
    139 #: simple-ldap-authentication.php:395
     139#: simple-ldap-authentication.php:438
    140140msgid ""
    141141"Automatically create accounts for any and all users can authenticate to the "
     
    143143msgstr "LDAP で認証された全てのユーザに対し自動的にアカウントを作成しますか?"
    144144
    145 #: simple-ldap-authentication.php:398
     145#: simple-ldap-authentication.php:441
    146146msgid ""
    147147"Should a new user be created automatically if not already in the WordPress "
     
    149149"Created users will obtain the role defined under &quot;New User Default "
    150150"Role&quot; on the <a href=\"options-general.php\">General Options</a> page.\n"
    151 "<br/>\n"
     151"<br />\n"
    152152"This setting is separate from the Role Equivalent Groups option, below.\n"
    153 "<br/>\n"
     153"<br />\n"
    154154"<strong>Users with role equivalent groups will be created even if this "
    155155"setting is turned off</strong> (because if you didn't want this to happen, "
     
    160160"作成されたユーザは、<a href=\"options-general.php\">一般設定</a>ページの "
    161161"&quot;新規ユーザーのデフォルト権限&quot; に沿った権限が与えられます。\n"
    162 "<br/>\n"
     162"<br />\n"
    163163"この設定は下にある自動グループ権限オプションとは独立して動作します。\n"
    164 "<br/>\n"
     164"<br />\n"
    165165"<strong>この設定がオフの場合でも、自動グループ権限に従ってユーザは作成されま"
    166166"す。</strong>(この動作を望ましくないと思うのであれば、くだんの設定を空にして"
    167167"おく必要があります。)"
    168168
    169 #: simple-ldap-authentication.php:407
     169#: simple-ldap-authentication.php:450
    170170msgid "Default email domain"
    171171msgstr "デフォルトの E-Mail ドメイン"
    172172
    173 #: simple-ldap-authentication.php:410
     173#: simple-ldap-authentication.php:453
    174174msgid ""
    175175"If the LDAP attribute 'mail' is blank, a user's email will be set to "
     
    179179"定値\"になります。"
    180180
    181 #: simple-ldap-authentication.php:414
     181#: simple-ldap-authentication.php:457
    182182msgid "Role Equivalent Groups"
    183183msgstr "自動グループ権限"
    184184
    185 #: simple-ldap-authentication.php:417
    186 msgid ""
    187 "List of LDAP groups which correspond to WordPress user roles.<br/>\n"
     185#: simple-ldap-authentication.php:460
     186msgid ""
     187"List of LDAP groups which correspond to WordPress user roles.<br />\n"
    188188"When a user is first created, his role will correspond to what is specified "
    189 "here.<br/>\n"
     189"here.<br />\n"
    190190"Format: <code>LDAP-Group=WordPress-Role;LDAP-Group=WordPress-Role;...</"
    191 "code><br/>\n"
     191"code><br />\n"
    192192"E.g., <code>Soc-Faculty=faculty</code> or <code>Faculty=faculty;"
    193 "Students=subscriber</code><br/>\n"
     193"Students=subscriber</code><br />\n"
    194194"A user will be created based on the first math, from left to right, so you "
    195 "should obviously put the more powerful groups first.<br/>\n"
     195"should obviously put the more powerful groups first.<br />\n"
    196196"NOTE: WordPress stores roles as lower case ( Faculty is stored as faculty )"
    197 "<br/>\n"
     197"<br />\n"
    198198"ALSO NOTE: LDAP groups are case-sensitive"
    199199msgstr ""
    200 "WordPress ユーザ権限に対応する LDAP グループをリストアップしてください。<br/"
     200"WordPress ユーザ権限に対応する LDAP グループをリストアップしてください。<br /"
    201201">\n"
    202202"ユーザが最初に作成される際、そのユーザの権限はここで指定される該当の物になり"
    203 "ます。<br/>\n"
     203"ます。<br />\n"
    204204"フォーマット:<code>LDAPグループ=WordPress権限;LDAPグループ=WordPress権限;..."
    205 "</code><br/>\n"
     205"</code><br />\n"
    206206"例:<code>Soc-Faculty=faculty</code> もしくは <code>Faculty=faculty;"
    207 "Students=subscriber</code><br/>\n"
     207"Students=subscriber</code><br />\n"
    208208"ユーザは左から右に向けて処理された最初の一致条件に基づき作成されるため、もっ"
    209 "とも権限の強いグループを先に書くべきです。<br/>\n"
     209"とも権限の強いグループを先に書くべきです。<br />\n"
    210210"注:WordPress は権限を小文字で保存します。(Faculty は faculty として保存され"
    211 "ます)<br/>\n"
     211"ます)<br />\n"
    212212"注:LDAP のグループは大文字小文字を区別します。"
     213
     214#: simple-ldap-authentication.php:476
     215msgid "Role Equivalent Groups Editor"
     216msgstr "自動グループ権限エディタ"
     217
     218#: simple-ldap-authentication.php:480
     219msgid "LDAP Group"
     220msgstr "LDAP グループ"
     221
     222#: simple-ldap-authentication.php:481
     223msgid "WordPress Role"
     224msgstr "WordPress 権限"
    213225
    214226#. Plugin URI of an extension
  • simple-ldap-authentication/trunk/languages/simple-ldap-authentication.pot

    r118102 r121224  
    77msgid ""
    88msgstr ""
    9 "Project-Id-Version: Simple LDAP Authentication 1.0.1\n"
     9"Project-Id-Version: Simple LDAP Authentication 1.0.4\n"
    1010"Report-Msgid-Bugs-To: http://wordpress.org/tag/simple-ldap-authentication\n"
    11 "POT-Creation-Date: 2009-05-15 18:40+0900\n"
     11"POT-Creation-Date: 2009-05-29 03:34+0900\n"
    1212"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    1313"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
     
    1717"Content-Transfer-Encoding: 8bit\n"
    1818
    19 #. #-#-#-#-#  simple-ldap-authentication.pot (Simple LDAP Authentication 1.0.1)  #-#-#-#-#
     19#. #-#-#-#-#  simple-ldap-authentication.pot (Simple LDAP Authentication 1.0.4)  #-#-#-#-#
    2020#. Plugin Name of an extension
    21 #: simple-ldap-authentication.php:78
     21#: simple-ldap-authentication.php:80
    2222msgid "Simple LDAP Authentication"
    2323msgstr ""
    2424
    25 #: simple-ldap-authentication.php:143
     25#: simple-ldap-authentication.php:103
    2626msgid ""
    2727"<strong>ERROR</strong>: LDAP user ID search filter is inacuurate. The filter "
     
    2929msgstr ""
    3030
    31 #: simple-ldap-authentication.php:155
     31#: simple-ldap-authentication.php:115
    3232#, php-format
    3333msgid "<strong>ERROR</strong>: Cannot connect to '%s'."
    3434msgstr ""
    3535
    36 #: simple-ldap-authentication.php:165
     36#: simple-ldap-authentication.php:125
    3737msgid ""
    3838"<strong>ERROR</strong>: LDAP bind failed. Either the LDAPS connection failed "
     
    4040msgstr ""
    4141
    42 #: simple-ldap-authentication.php:167
     42#: simple-ldap-authentication.php:127
    4343msgid "<strong>ERROR</strong>: LDAP bind failed. Check the login credentials."
    4444msgstr ""
    4545
    46 #: simple-ldap-authentication.php:230
     46#: simple-ldap-authentication.php:190
    4747msgid ""
    4848"<strong>ERROR</strong>: This user exists in LDAP, but has not been granted "
     
    5050msgstr ""
    5151
    52 #: simple-ldap-authentication.php:329
     52#: simple-ldap-authentication.php:372
    5353msgid "Simple LDAP Authentication Options"
    5454msgstr ""
    5555
    56 #: simple-ldap-authentication.php:337
     56#: simple-ldap-authentication.php:380
    5757msgid "LDAP Server"
    5858msgstr ""
    5959
    60 #: simple-ldap-authentication.php:340
     60#: simple-ldap-authentication.php:383
    6161msgid "LDAP Server (e.g. <code>ldap.example.net</code>)"
    6262msgstr ""
    6363
    64 #: simple-ldap-authentication.php:344
     64#: simple-ldap-authentication.php:387
    6565msgid "Use SSL connection with LDAP?"
    6666msgstr ""
    6767
    68 #: simple-ldap-authentication.php:347
     68#: simple-ldap-authentication.php:390
    6969msgid "If you use SSL connection or not, when LDAP connection."
    7070msgstr ""
    7171
    72 #: simple-ldap-authentication.php:351
     72#: simple-ldap-authentication.php:394
    7373msgid "Base DN"
    7474msgstr ""
    7575
    76 #: simple-ldap-authentication.php:354
     76#: simple-ldap-authentication.php:397
    7777msgid "Base DN (e.g., <code>dc=example,dc=net</code>)"
    7878msgstr ""
    7979
    80 #: simple-ldap-authentication.php:358
     80#: simple-ldap-authentication.php:401
    8181msgid "Bind DN"
    8282msgstr ""
    8383
    84 #: simple-ldap-authentication.php:361
     84#: simple-ldap-authentication.php:404
    8585msgid "Bind DN (e.g., <code>cn=proxyuser,dc=example,dc=net</code>)"
    8686msgstr ""
    8787
    88 #: simple-ldap-authentication.php:365
     88#: simple-ldap-authentication.php:408
    8989msgid "Bind Password"
    9090msgstr ""
    9191
    92 #: simple-ldap-authentication.php:368
     92#: simple-ldap-authentication.php:411
    9393msgid "Password for database login account."
    9494msgstr ""
    9595
    96 #: simple-ldap-authentication.php:372
     96#: simple-ldap-authentication.php:415
    9797msgid "User ID Search Filter"
    9898msgstr ""
    9999
    100 #: simple-ldap-authentication.php:375
    101 msgid ""
    102 "LDAP filter for searching user ID (e.g., <code>(uid=%user_id%)</code>)<br/>\n"
     100#: simple-ldap-authentication.php:418
     101msgid ""
     102"LDAP filter for searching user ID (e.g., <code>(uid=%user_id%)</code>)<br />\n"
    103103"This setting must contain <code>%user_id%</code> string."
    104104msgstr ""
    105105
    106 #: simple-ldap-authentication.php:380
     106#: simple-ldap-authentication.php:423
    107107msgid "Group Search Filter"
    108108msgstr ""
    109109
    110 #: simple-ldap-authentication.php:383
    111 msgid ""
    112 "LDAP filter for searching group (e.g., <code>(cn=%group%)</code>)<br/>\n"
     110#: simple-ldap-authentication.php:426
     111msgid ""
     112"LDAP filter for searching group (e.g., <code>(cn=%group%)</code>)<br />\n"
    113113"This setting must contain <code>%group%</code> string."
    114114msgstr ""
    115115
    116 #: simple-ldap-authentication.php:388
     116#: simple-ldap-authentication.php:431
    117117msgid "Group Member Attribute"
    118118msgstr ""
    119119
    120 #: simple-ldap-authentication.php:391
     120#: simple-ldap-authentication.php:434
    121121msgid "LDAP attribute for group member (e.g., <code>memberuid</code>)"
    122122msgstr ""
    123123
    124 #: simple-ldap-authentication.php:395
     124#: simple-ldap-authentication.php:438
    125125msgid ""
    126126"Automatically create accounts for any and all users can authenticate to the "
     
    128128msgstr ""
    129129
    130 #: simple-ldap-authentication.php:398
     130#: simple-ldap-authentication.php:441
    131131msgid ""
    132132"Should a new user be created automatically if not already in the WordPress "
     
    134134"Created users will obtain the role defined under &quot;New User Default "
    135135"Role&quot; on the <a href=\"options-general.php\">General Options</a> page.\n"
    136 "<br/>\n"
     136"<br />\n"
    137137"This setting is separate from the Role Equivalent Groups option, below.\n"
    138 "<br/>\n"
     138"<br />\n"
    139139"<strong>Users with role equivalent groups will be created even if this "
    140140"setting is turned off</strong> (because if you didn't want this to happen, "
     
    142142msgstr ""
    143143
    144 #: simple-ldap-authentication.php:407
     144#: simple-ldap-authentication.php:450
    145145msgid "Default email domain"
    146146msgstr ""
    147147
    148 #: simple-ldap-authentication.php:410
     148#: simple-ldap-authentication.php:453
    149149msgid ""
    150150"If the LDAP attribute 'mail' is blank, a user's email will be set to "
     
    152152msgstr ""
    153153
    154 #: simple-ldap-authentication.php:414
     154#: simple-ldap-authentication.php:457
    155155msgid "Role Equivalent Groups"
    156156msgstr ""
    157157
    158 #: simple-ldap-authentication.php:417
    159 msgid ""
    160 "List of LDAP groups which correspond to WordPress user roles.<br/>\n"
     158#: simple-ldap-authentication.php:460
     159msgid ""
     160"List of LDAP groups which correspond to WordPress user roles.<br />\n"
    161161"When a user is first created, his role will correspond to what is specified "
    162 "here.<br/>\n"
     162"here.<br />\n"
    163163"Format: <code>LDAP-Group=WordPress-Role;LDAP-Group=WordPress-Role;...</"
    164 "code><br/>\n"
     164"code><br />\n"
    165165"E.g., <code>Soc-Faculty=faculty</code> or <code>Faculty=faculty;"
    166 "Students=subscriber</code><br/>\n"
     166"Students=subscriber</code><br />\n"
    167167"A user will be created based on the first math, from left to right, so you "
    168 "should obviously put the more powerful groups first.<br/>\n"
     168"should obviously put the more powerful groups first.<br />\n"
    169169"NOTE: WordPress stores roles as lower case ( Faculty is stored as faculty )"
    170 "<br/>\n"
     170"<br />\n"
    171171"ALSO NOTE: LDAP groups are case-sensitive"
     172msgstr ""
     173
     174#: simple-ldap-authentication.php:476
     175msgid "Role Equivalent Groups Editor"
     176msgstr ""
     177
     178#: simple-ldap-authentication.php:480
     179msgid "LDAP Group"
     180msgstr ""
     181
     182#: simple-ldap-authentication.php:481
     183msgid "WordPress Role"
    172184msgstr ""
    173185
  • simple-ldap-authentication/trunk/readme.txt

    r119748 r121224  
    7777
    78781. The administration page under Settings -> Simple LDAP Authentication
    79 2. This plugin supports i18n. Japanese example.
     792. Role Equivalent Groups Editor in the option page.
     803. This plugin supports i18n. Japanese example.
  • simple-ldap-authentication/trunk/simple-ldap-authentication.php

    r119677 r121224  
    22/*
    33Plugin Name: Simple LDAP Authentication
    4 Version: 1.0.3
     4Version: 1.0.4
    55Plugin URI: http://redgecko.jp/wp/ldap_auth/
    66Description: Allows WordPress to authenticate users through LDAP
     
    4343            add_action('check_passwords', array(&$this, 'generate_password'), 10, 3);
    4444            add_filter('show_password_fields', array(&$this, 'disable_password_fields'));
     45            add_filter('plugin_action_links', array(&$this, 'add_link'), 10, 2);
    4546            $this->ldap_auth_domain = dirname(plugin_basename(__FILE__));
    4647        }
     
    7677                PLUGINDIR.'/'.dirname(plugin_basename(__FILE__)).'/languages',
    7778                dirname(plugin_basename(__FILE__)).'/languages');
    78             if ( function_exists('add_options_page') )
    79                     add_options_page(__('Simple LDAP Authentication', $this->ldap_auth_domain), __('Simple LDAP Authentication', $this->ldap_auth_domain), 9, __FILE__, array(&$this, '_display_options_page'));
    80         }
    81 
    82         function _user_in_group( $ldap, $username, $group ) {
    83             $base_dn = get_option('LDAP_authentication_base_dn');
    84             $group_filter = get_option('LDAP_authentication_group_filter');
    85             $group_attr = strtolower(get_option('LDAP_authentication_group_attribute'));
    86             $replace_count = 0;
    87             $group_filter = str_replace('%group%', $group, $group_filter, &$replace_count);
    88             if ( $replace_count == 0 ) {
    89                 if ( defined('WP_DEBUG') && ( true === WP_DEBUG ) )
    90                     trigger_error('LDAP group search filter is mistaked.');
    91                 return false;
    92             }
    93             if ( !defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) ) {
    94                 $result = @ldap_search($ldap, $base_dn, $group_filter, array($group_attr));
    95             } else {
    96                 trigger_error('Searching group in LDAP with \'' . $group_filter . '\' filter.');
    97                 $result = ldap_search($ldap, $base_dn, $group_filter, array($group_attr));
    98             }
    99             if ( $result === FALSE ) return false;
    100             $members = @ldap_get_entries($ldap, $result);
    101             $members = $members[0][$group_attr];
    102             return in_array($username, $members);
    103         }
    104 
    105         function _get_user_role_equiv( $ldap, $username ) {
    106             $role_equiv_groups = get_option('LDAP_authentication_role_equivalent_groups');
    107             $role_equiv_groups = explode(';', $role_equiv_groups);
    108             $user_role = '';
    109             foreach ( $role_equiv_groups as $whatever => $role_group ) {
    110                 if ( defined('WP_DEBUG') && ( true === WP_DEBUG ) )
    111                     trigger_error('Trying \''  . $role_group . '\' rule.');
    112                 $role_group = explode('=', $role_group);
    113                 if ( count($role_group) != 2 )
    114                     continue;
    115                 $ldap_group = $role_group[0];
    116                 $corresponding_role = $role_group[1];
    117                 if ( $this->_user_in_group($ldap, $username, $ldap_group) ) {
    118                     $user_role = $corresponding_role;
    119                     break;
    120                 }
    121             }
    122             if ( defined('WP_DEBUG') && ( true === WP_DEBUG ) )
    123                 trigger_error('User \'' . $username . '\' is assigned as \'' . $user_role . '\' role.');
    124             return $user_role;
     79            if ( function_exists('add_options_page') ) {
     80                $page = add_options_page(__('Simple LDAP Authentication', $this->ldap_auth_domain), __('Simple LDAP Authentication', $this->ldap_auth_domain), 9, __FILE__, array(&$this, '_display_options_page'));
     81                add_action("admin_print_styles-$page", array(&$this, 'add_admin_custom_css'));
     82                add_action("admin_print_scripts-$page", array(&$this, 'add_admin_script'));
     83            }
    12584        }
    12685
     
    271230        }
    272231
     232        /*
     233         * Add action link in the plugin page.
     234         */
     235        function add_link($links, $file) {
     236            static $this_plugin;
     237            if ( !$this_plugin ) $this_plugin = plugin_basename(__FILE__);
     238
     239            if ( $file === $this_plugin ) {
     240                $settings_link = '<a href="options-general.php?page=' . $this_plugin . '">' . _('Settings') . '</a>';
     241                array_unshift($links, $settings_link);
     242            }
     243
     244            return($links);
     245        }
     246
     247        /*
     248         * Add custom style sheet to the admin page
     249         */
     250        function add_admin_custom_css() {
     251            $style = WP_PLUGIN_URL . '/' . dirname(plugin_basename(__FILE__)) . '/extra-table.css';
     252            wp_register_style('ldap-auth-extra', $style, array('colors'));
     253            wp_enqueue_style('ldap-auth-extra');
     254        }
     255
     256        /*
     257         * Add custom script to the admin page
     258         */
     259        function add_admin_script() {
     260            $script = WP_PLUGIN_URL . '/' . dirname(plugin_basename(__FILE__)) . '/extra-table.js';
     261            wp_register_script('ldap-auth-extra', $script, array('jquery-ui-dialog'));
     262            wp_enqueue_script('ldap-auth-extra');
     263        }
    273264
    274265        /*************************************************************
    275266         * Functions
    276267         *************************************************************/
     268
     269        /*
     270         * Check the group includes the target user.
     271         */
     272        function _user_in_group( $ldap, $username, $group ) {
     273            $base_dn = get_option('LDAP_authentication_base_dn');
     274            $group_filter = get_option('LDAP_authentication_group_filter');
     275            $group_attr = strtolower(get_option('LDAP_authentication_group_attribute'));
     276            $replace_count = 0;
     277            $group_filter = str_replace('%group%', $group, $group_filter, &$replace_count);
     278            if ( $replace_count == 0 ) {
     279                if ( defined('WP_DEBUG') && ( true === WP_DEBUG ) )
     280                    trigger_error('LDAP group search filter is mistaked.');
     281                return false;
     282            }
     283            if ( !defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) ) {
     284                $result = @ldap_search($ldap, $base_dn, $group_filter, array($group_attr));
     285            } else {
     286                trigger_error('Searching group in LDAP with \'' . $group_filter . '\' filter.');
     287                $result = ldap_search($ldap, $base_dn, $group_filter, array($group_attr));
     288            }
     289            if ( $result === FALSE ) return false;
     290            $members = @ldap_get_entries($ldap, $result);
     291            $members = $members[0][$group_attr];
     292            return in_array($username, $members);
     293        }
     294
     295        /*
     296         * Get the user's group info from LDAP and return the WordPress role.
     297         */
     298        function _get_user_role_equiv( $ldap, $username ) {
     299            $role_equiv_groups = get_option('LDAP_authentication_role_equivalent_groups');
     300            $role_equiv_groups = explode(';', $role_equiv_groups);
     301            $user_role = '';
     302            foreach ( $role_equiv_groups as $whatever => $role_group ) {
     303                if ( defined('WP_DEBUG') && ( true === WP_DEBUG ) )
     304                    trigger_error('Trying \''  . $role_group . '\' rule.');
     305                $role_group = explode('=', $role_group);
     306                if ( count($role_group) != 2 )
     307                    continue;
     308                $ldap_group = $role_group[0];
     309                $corresponding_role = $role_group[1];
     310                if ( $this->_user_in_group($ldap, $username, $ldap_group) ) {
     311                    $user_role = $corresponding_role;
     312                    break;
     313                }
     314            }
     315            if ( defined('WP_DEBUG') && ( true === WP_DEBUG ) )
     316                trigger_error('User \'' . $username . '\' is assigned as \'' . $user_role . '\' role.');
     317            return $user_role;
     318        }
    277319
    278320        /*
     
    374416                <td>
    375417                    <input type="text" name="LDAP_authentication_uid_filter" id="LDAP_authentication_uid_filter" value="<?php echo $uid_filter; ?>" /><br />
    376                     <?php _e('LDAP filter for searching user ID (e.g., <code>(uid=%user_id%)</code>)<br/>
     418                    <?php _e('LDAP filter for searching user ID (e.g., <code>(uid=%user_id%)</code>)<br />
    377419This setting must contain <code>%user_id%</code> string.', $this->ldap_auth_domain); ?>
    378420                </td>
     
    382424                <td>
    383425                    <input type="text" name="LDAP_authentication_group_filter" id="LDAP_authentication_group_filter" value="<?php echo $group_filter; ?>" /><br />
    384                     <?php _e('LDAP filter for searching group (e.g., <code>(cn=%group%)</code>)<br/>
     426                    <?php _e('LDAP filter for searching group (e.g., <code>(cn=%group%)</code>)<br />
    385427This setting must contain <code>%group%</code> string.', $this->ldap_auth_domain); ?>
    386428                </td>
     
    399441                    <?php _e('Should a new user be created automatically if not already in the WordPress database?<br />
    400442Created users will obtain the role defined under &quot;New User Default Role&quot; on the <a href="options-general.php">General Options</a> page.
    401 <br/>
     443<br />
    402444This setting is separate from the Role Equivalent Groups option, below.
    403 <br/>
     445<br />
    404446<strong>Users with role equivalent groups will be created even if this setting is turned off</strong> (because if you didn\'t want this to happen, you would leave that option blank.)'); ?>
    405447                </td>
     
    408450                <th scope="row"><label for="LDAP_authentication_default_email_domain"><?php _e('Default email domain', $this->ldap_auth_domain); ?></label></th>
    409451                <td>
    410                     <input type="text" name="LDAP_authentication_default_email_domain" id="LDAP_authentication_default_email_domain" value="<?php echo $email_domain; ?>"><br />
     452                    <input type="text" name="LDAP_authentication_default_email_domain" id="LDAP_authentication_default_email_domain" value="<?php echo $email_domain; ?>" /><br />
    411453                    <?php _e('If the LDAP attribute \'mail\' is blank, a user\'s email will be set to username@whatever-this-says', $this->ldap_auth_domain); ?>
    412454                </td>
     
    416458                <td>
    417459                    <input type="text" name="LDAP_authentication_role_equivalent_groups" id="LDAP_authentication_role_equivalent_groups" value="<?php echo $role_equiv_groups; ?>" /><br />
    418                     <?php _e('List of LDAP groups which correspond to WordPress user roles.<br/>
    419 When a user is first created, his role will correspond to what is specified here.<br/>
    420 Format: <code>LDAP-Group=WordPress-Role;LDAP-Group=WordPress-Role;...</code><br/>
    421 E.g., <code>Soc-Faculty=faculty</code> or <code>Faculty=faculty;Students=subscriber</code><br/>
    422 A user will be created based on the first math, from left to right, so you should obviously put the more powerful groups first.<br/>
    423 NOTE: WordPress stores roles as lower case ( Faculty is stored as faculty )<br/>
     460                    <?php _e('List of LDAP groups which correspond to WordPress user roles.<br />
     461When a user is first created, his role will correspond to what is specified here.<br />
     462Format: <code>LDAP-Group=WordPress-Role;LDAP-Group=WordPress-Role;...</code><br />
     463E.g., <code>Soc-Faculty=faculty</code> or <code>Faculty=faculty;Students=subscriber</code><br />
     464A user will be created based on the first math, from left to right, so you should obviously put the more powerful groups first.<br />
     465NOTE: WordPress stores roles as lower case ( Faculty is stored as faculty )<br />
    424466ALSO NOTE: LDAP groups are case-sensitive', $this->ldap_auth_domain); ?>
    425467                </td>
    426468            </tr>
    427469        </table>
     470        <input type="hidden" name="default_role" id="default_role" value="<?php echo get_option('default_role'); ?>" />
    428471        <p class="submit">
    429472            <input type="submit" name="Submit" value="<?php _e('Save Changes'); ?>" />
     
    431474    </form>
    432475</div>
     476<div id="equivalent_dialog" title="<?php _e('Role Equivalent Groups Editor', $this->ldap_auth_domain); ?>" style="display: none" class="ui-widget">
     477    <table class="equivalent-table form-table">
     478        <thead>
     479            <tr align="center" class="ui-widget-header">
     480                <th scope="col"><?php _e('LDAP Group', $this->ldap_auth_domain); ?></th>
     481                <th scope="col"><?php _e('WordPress Role', $this->ldap_auth_domain); ?></th>
     482                <th scope="col"></th>
     483            </tr>
     484        </thead>
     485        <tbody>
     486            <tr valign="top" style="display: none">
     487                <td>
     488                    <input type="text" />
     489                </td>
     490                <td>
     491                    <select><?php wp_dropdown_roles(); ?></select>
     492                </td>
     493                <td>
     494                    <div class="submit">
     495                        <input type="button" value="+" />
     496                        <input type="button" value="-" />
     497                        <input type="button" value="&uarr;" />
     498                        <input type="button" value="&darr;" />
     499                    </div>
     500                </td>
     501            </tr>
     502        </tbody>
     503    </table>
     504</div>
    433505<?php
    434506        }
Note: See TracChangeset for help on using the changeset viewer.