<?php APP::uses('AppController', 'Controller'); App::uses('ExcelProcessor', 'Lib'); App::import('Vendor', 'Classes/PHPExcel.php'); App::import('Vendor', 'PHPExcel_IOFactory', array('file' => 'Classes/PHPExcel/IOFactory.php')); App::import('Vendor', 'PHPExcelReader', array('file' => 'Classes/PHPExcel/Reader/Excel2007.php')); App::import('Vendor', 'PHPExcelWriter', array('file' => 'Classes/PHPExcel/Writer/Excel2007.php')); class TeamleadersController extends AppController { public $uses = array("Role", "User", "Superadmin", "Manager", "Teamleader", "Telecaller", "Allocationmaster"); public $paginate = array('limit' => 25, 'conditions' => array('status' => '1'), 'order' => array('User.username' => 'asc')); public function beforeFilter() { parent::beforeFilter(); } public function isAuthorized($user) { if ($user['role'] === 'TeamLeader') { if ($this->action === 'index' || $this->action === 'add' || $this->action === 'edit' || $this->action === 'delete' || $this->action === 'upload_excel') { return true; } } else { return false; } } public function index() { $this->paginate = array('limit' => 20, 'conditions' => array('User.role' => 'TeamLeader'), 'order' => array('User.username' => 'asc')); $users = $this->paginate('User'); $this->set(compact('users'));
<?php /** * Model class for users database * Uses Containable behaviour. */ APP::uses('AuthComponent', 'Controller/Component'); class User extends AppModel { public $name = 'User'; public $cacheQueries = TRUE; //Cache for single request. public $actsAs = array('Containable'); //Associations with other models public $hasMany = array('Car' => array('className' => 'Car', 'foreignKey' => 'user_id', 'conditions' => array('Car.deleted' => 0), 'order' => '', 'limit' => '', 'offset' => '', 'dependent' => FALSE, 'exclusive' => FALSE, 'finderQuery' => '')); //Validation rules public $validate = array('given_name' => array('rule' => 'notEmpty', 'required' => FALSE, 'allowEmpty' => FALSE, 'on' => NULL, 'message' => 'Please provide a given name!'), 'surname_name' => array('rule' => 'notEmpty', 'required' => FALSE, 'allowEmpty' => FALSE, 'on' => NULL, 'message' => 'Please provide a surname!'), 'password' => array('provided' => array('rule' => 'notEmpty', 'required' => FALSE, 'allowEmpty' => FALSE, 'on' => NULL, 'message' => 'Please provide a password!'), 'matches' => array('rule' => array('fieldsMatch', 'password_confirmation'), 'required' => FALSE, 'allowEmpty' => FALSE, 'on' => NULL, 'message' => 'Passwords do not match!')), 'email' => array('validEmail' => array('rule' => 'email', 'required' => FALSE, 'allowEmpty' => FALSE, 'on' => NULL, 'message' => 'Please provide a valid email address!'), 'uniqueEmail' => array('rule' => 'isUnique', 'required' => FALSE, 'allowEmpty' => FALSE, 'on' => NULL, 'message' => 'This email exists already!'))); /** * Hash passwords * @see Model::beforeSave() */ public function beforeSave($options = array()) { if (!empty($this->data[$this->alias]['password'])) { $this->data[$this->alias]['password'] = AuthComponent::password($this->data[$this->alias]['password']); } return TRUE; } /** * Custom validation rule for matching fields. * @param array $check the value of the field to be checked. array('field' => 'value')
<?php App::uses('File', 'Utility'); APP::uses('Folder', 'Utility'); /** * Extensions Locales Controller * * PHP version 5 * * @category Controller * @package Croogo * @version 1.0 * @author Fahad Ibnay Heylaal <*****@*****.**> * @license http://www.opensource.org/licenses/mit-license.php The MIT License * @link http://www.croogo.org */ class ExtensionsLocalesController extends ExtensionsAppController { /** * Controller name * * @var string * @access public */ public $name = 'ExtensionsLocales'; /** * Models used by the Controller * * @var array * @access public */
<?php APP::uses("Market", "Model"); App::uses("TraitCountry", "Model"); App::uses('AuditableModel', 'Model'); class Phone extends AuditableModel { const ORDER = 0; const MAIN = 1; const SMS = 2; public $name = 'Phone'; public $validate = array('phone' => array('rule' => array('phone', '/^([0-9\\s\\-\\+\\(\\)]*)$/'), 'message' => 'Please supply a valid phone number.')); public function finalizeRules() { foreach (array("phone") as $field) { foreach ($this->validator()->getField($field)->getRules() as $rule) { $rule->required = TRUE; break; //I only need required on one of the rules } } } public function beforeValidate($options = array()) { // market touch point $trait = new TraitCountry(); $validator = $this->validator(); $format = $trait->getTrait($this->getMarketId(), 'phone_format'); //use Market Traits to validate city. if (!empty($format)) { $num = $trait->getTrait($this->getMarketId(), 'zip_qualifier');
<?php /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ APP::uses('AppModel', 'Model'); class Teamleader extends AppModel { public $actsAs = array('Containable'); // public $primaryKey = "user_id"; public $belongsTo = array('User' => array('className' => 'User', 'foreignKey' => 'id', 'conditions' => '', 'fields' => '', 'order' => ''), 'Manager' => array('className' => 'Manager', 'foreignKey' => 'manager_id', 'conditions' => '', 'fields' => '', 'order' => '')); public $hasMany = array('Telecaller' => array('className' => 'Telecaller', 'foreign_key' => 'teamleader_id', 'conditions' => '', 'fields' => '', 'order' => '')); }
/** * コンストラクタ */ public function __construct() { parent::__construct(); APP::uses("TmhkConverter", "TokushuMojiHenkanKun.Lib"); }
function UserService() { APP::uses("User", "UserManager.Model"); $this->User = new User(); }