3.3 model的扩展。
model的扩展文件命名与control类似,在ext/model/目录下面建立相应的以方法为名的文件,里面实现对应的查询功能。比如,我们 打算对misc的model新增一个方法,叫做foo,那么只需要在misc/ext/model/下面建立foo.php,代码如下:
public function foo()
{
return 'foo';
}
需要说明的是,这里面不不包含的起止符号,也不包含类的声明。就只是一个方法的声明。禅道框架在执行的时候,会自动将扩展目录下面的foo.php里面的代码,替换misc/model.php中的foo方法的代码。如果是新增的方法,则会追加到misc/model.php的代码中,最终生成一个合并之后的model类文件。
明白了, 那还是很好写的,明天试一下。
好的,我也这么想的,我准备就把mantis 那个ldap api OO一下, 我想了解一些这种library 级别的config 放在根目录下的config 里? 放一个ldap.php 就可以了? 但看了一下router.class.php 没看到自动load configRoot 下的任意文件的code. 不像扩展下的config 会自动load.
我看了一下load class 可以用$this->app->loadClass('ldap') 来实现, 如果在扩展里面写,$this->app 也是可以访问到的哦? 这里是用的eval 实现还是用的include 模拟宏实现的? 具体code 没找, 如果wwccss 大侠有时间解释一下吧,谢谢了。
做好了,放在我们公司的服务器上 http://www.thsmobile.com/download/ldap_exten.tgz
相对于根目录的结构如下, ldap.class.php 是从mantis 扣出来修改的, 可能license 有点问题是GPL的, 但我自己用,应该没有问题。 你们如果要加ldap发给其他用户,可能还得自己重写一下。
lib
└── ldap
└── ldap.class.php
module
└── user
└── ext
├── config
│ └── ldap.php
└── model
└── ldap.php
可以Config 的参数:
/**
* Specifies the LDAP or Active Directory server to connect to, and must be
* provided as an URI
* - Protocol is optional, can be one of ldap or ldaps, defaults to ldap
* - Port number is optional, and defaults to 389. If this doesn't work, try
* using one of the following standard port numbers: 636 (ldaps); for Active
* Directory Global Catalog forest-wide search, use 3268 (ldap) or 3269 (ldaps)
*
* Examples of valid URI:
*
* ldap.example.com
* ldap.example.com:3268
* ldap://ldap.example.com/
* ldaps://ldap.example.com:3269/
*
*/
$config->ldap->ldap_server = 'ldap://ldap.example.com:389/';
/**
* The LDAP Protocol Version, if 0, then the protocol version is not set. For Active Directory use version 3.
*/
$config->ldap->ldap_protocol_version = 3;
/**
* Determines whether the LDAP library automatically follows referrals returned by LDAP servers or not.
* This maps to LDAP_OPT_REFERRALS ldap library option. For Active Directory, this should be set to OFF.
*/
$config->ldap->ldap_follow_referrals = 1; //1 ON, 0 OFF
$config->ldap->ldap_root_dn = 'ou=www,dc=abc,dc=com';
$config->ldap->ldap_uid_field = 'sAMAccountName'; // Use 'sAMAccountName' for Active Directory
$config->ldap->ldap_bind_dn = 'CN=admin,OU=admin,DC=abc,DC=com';
$config->ldap->ldap_bind_passwd = 'abcdef';
/**
* Search filter for acitve person only, !(userAccountControl:1.2.840.113556.1.4.803:=2) means active user in AD
*/
$config->ldap->ldap_organization = '(objectCategory=person)(!(userAccountControl:1.2.840.113556.1.4.803:=2))';




精品资料包
1V1产品演示
免费试用增强功能
专属顾问答疑支持


