필자는 PHP에서 아주 기본적인 LDAP/AD 기능을 위해 작성한 독립형 클래스를 사용하고 있습니다. 나는 cakephp에서 작업하고있는 프로젝트에서이 클래스를 사용하고 싶습니다. CakePHP는 1.2 난 그냥 공급 업체로 클래스를 추가 할 수 있습니다 같은cakephp 1.3에서 독립 실행 형 클래스를 사용하려면 어떻게해야합니까?
그것은 그러나 그것은 공급 업체 CakePHP는 1.3 제거 지원처럼 보이는 보인다. 그러면이 클래스에서 몇 가지 함수를 호출하는 방법은 무엇입니까?
감사합니다 (I 클래스 자체를 동일하게 유지하고 불필요한 보인다, 플러그인으로 바꿀 수 없습니다하려고하고 싶습니다)! 아래
코드 :
**<?php
class UsersController extends AppController {
var $name = 'Users';
//commented out because it breaks the script
//App::import('Lib', 'ldap');
function index() {
$this->User->recursive = 0;
$this->set('users', $this->paginate());
}
function login() {
if (!empty($this->data)) {
if ($ldap->auth($this->data['User']['user'],$this->data['User']['password'])) {
$this->Session->setFlash(__('The user has been saved', true));
$this->Session->write('user', $this->data['User']['user']);
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('Login Failed', true));
}
}
}
function logout() {
$this->Session->delete('user');
$this->redirect($this->referer());
}
function view($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid user', true));
$this->redirect(array('action' => 'index'));
}
$this->set('user', $this->User->read(null, $id));
}
function add() {
if (!empty($this->data)) {
$this->User->create();
if ($this->User->save($this->data)) {
$this->Session->setFlash(__('The user has been saved', true));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The user could not be saved. Please, try again.', true));
}
}
$projects = $this->User->Project->find('list');
$this->set(compact('projects'));
}
function edit($id = null) {
if (!$id && empty($this->data)) {
$this->Session->setFlash(__('Invalid user', true));
$this->redirect(array('action' => 'index'));
}
if (!empty($this->data)) {
if ($this->User->save($this->data)) {
$this->Session->setFlash(__('The user has been saved', true));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The user could not be saved. Please, try again.', true));
}
}
if (empty($this->data)) {
$this->data = $this->User->read(null, $id);
}
$projects = $this->User->Project->find('list');
$this->set(compact('projects'));
}
function delete($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid id for user', true));
$this->redirect(array('action'=>'index'));
}
if ($this->User->delete($id)) {
$this->Session->setFlash(__('User deleted', true));
$this->redirect(array('action'=>'index'));
}
$this->Session->setFlash(__('User was not deleted', true));
$this->redirect(array('action' => 'index'));
}
}
?>**
나는 libs와 폴더에 내 ldap.php을 넣어 넣어이다 내가 어떤 페이지를 호출 할 때 내 users_controller.php에,하지만 난 얻을 "C에서 구문 오류, 예기치 못한 T_STRING, 기대 T_FUNCTION : 구문 분석 오류 \ XAMPP \ htdocs를 \ timetracker \ 컨트롤러 \ users_controller.php 6 행의" – lanrat
잘 @mrlanrat, 어딘가에 ** 구문 오류 **가 있습니다.이 오류는 Cake의 libs 나 공급 업체와 관련이 없습니다. – deceze
코드를 게시하면 도움을받을 수 있습니다! – Leo