I have a separate class that I wrote in PHP for some basic LDAP / AD functions. and I would like to use this class in the project I'm working on in cakephp.
It looks like in cakephp 1.2 I could just add a class as a provider, but it seems like cakephp 1.3 has removed support for providers. So, how can I name a few functions from this class?
(I would like to try to save the class by itself, and not turn it into a plugin, as this seems unnecessary)
Thanks!
below:
**<?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')); } } ?>**
lanrat
source share