public function edit($advanced = null) { if ($this->request->is('put') || $this->request->is('post')) { if (!empty($this->request->data['Afip']['tipo_factura_id'])) { $tipoFactId = $this->request->data['Afip']['tipo_factura_id']; $TipoFact = Classregistry::init('Risto.TipoFactura')->find('first', array('conditions' => array('TipoFactura.id' => $tipoFactId), 'recursive' => -1)); $this->request->data['Restaurante']['tipofactura_name'] = $TipoFact['TipoFactura']['name']; $this->request->data['Printers']['default_tipo_factura_codename'] = $TipoFact['TipoFactura']['codename']; } if (TenantSettings::write($this->data)) { MtSites::loadConfigFiles(); $this->Session->setFlash(__('Se han guardado los cambios de configuración')); } else { $this->Session->setFlash(__('Error al guardar los cambios de configuración'), 'Risto.flash_error'); } } $this->request->data = TenantSettings::read(); if (empty($this->request->data['Geo']['currency_code']) && !empty($this->request->data['Config']['currency_code'])) { $this->request->data['Geo']['currency_code'] = $this->request->data['Config']['currency_code']; } $printers = Classregistry::init('Printers.Printer')->find('list'); $fiscal_printer = Classregistry::init('Printers.Printer')->read(null, Configure::read('Printers.fiscal_id')); $ivaResponsabilidades = Classregistry::init('Risto.IvaResponsabilidad')->find('list'); $tipoFacturas = Classregistry::init('Risto.TipoFactura')->find('list'); $mozos = Classregistry::init('Mesa.Mozo')->find('list', array('fields' => array('id', 'numero_y_nombre'))); $currencyCodes = $this->currencyCodes; $this->set(compact('printers', 'fiscal_printer', 'ivaResponsabilidades', 'tipoFacturas', 'mozos', 'currencyCodes')); if ($advanced) { $this->render('edit_' . $advanced); } }
/** * setUp method * * @return void */ public function setUp() { parent::setUp(); $this->Metable = new MetableBehavior(); $this->Article = Classregistry::init('MetaArticle'); $this->Meta = Classregistry::init('Meta'); }
/** * setUp method * * @return void */ public function setUp() { parent::setUp(); //$this->Themeable = new MetableBehavior(); $this->Article = Classregistry::init('Article'); $this->Template = Classregistry::init('Template'); }
/** * beforeFilter * * @return void */ public function beforeFilter() { parent::beforeFilter(); $this->Auth->allow(); //あとで適切なものに修正 $this->set('classUrl', 'upload'); $this->ThemeSettingsSite = Classregistry::init('ThemeSettings.ThemeSettingsSite'); $this->ThemeSettingsSiteValue = Classregistry::init('ThemeSettings.ThemeSettingsSiteValue'); }
/** * After migration callback * * @param string $direction Direction of migration process (up or down) * @return bool Should process continue */ public function after($direction) { if ($direction == 'up') { $shareModel = Classregistry::init('Share'); $shareModel->updateAll(array('Share.active' => 0), array('Share.active' => 1)); $userModel = Classregistry::init('User'); $userModel->updateAll(array('User.news_update' => 'User.modified'), array('User.is_deleted' => 0)); } return true; }
/** * setUp method * * @return void */ public function setUp() { parent::setUp(); $this->Usable = new UsableBehavior(); $this->Model = Classregistry::init('UsedArticle'); // not tied to an actual model file $this->Used = ClassRegistry::init('Users.Used'); // not tied to an actual model file $this->User = ClassRegistry::init('Users.User'); // not tied to an actual model file }
/** * beforeFilter * * @return void * @author Takako Miyagawa <*****@*****.**> **/ public function beforeFilter() { parent::beforeFilter(); $this->Auth->allow(); //権限 : あとで適切なものに修正 : システム管理社 $this->set('classUrl', 'site'); //このclassへ遷移させるURL $this->ThemeSettingsSite = Classregistry::init('ThemeSettings.ThemeSettingsSite'); $this->Security->requireAuth(array('confirm')); $this->ThemeList = $this->__getThemeList(); }
public function beforeFilter() { $this->set('title_for_layout','Massidea.org'); $this->Nodes = Classregistry::init('Node'); $this->Nodes->map = array('RelatedCompany' => 'RelatedCompanies'); /** * Setting content class * * content_class is used to define how the page is viewed. Default contentWithSidebar. * Should be overridden in controller if wished to use other class. */ $this->set('content_class','contentWithSidebar'); //End of automated class load for content }
function remove($id = null) { if (!$id) { return; } $user_id = $this->Session->read('User.id'); $sql = "delete from favorites where user_id = {$user_id} and tweet_id = {$id}"; Classregistry::init('Tweet'); $this->Tweets =& new TweetsController(); /*Loads the class*/ $this->Tweets->constructClasses(); /*Loads the model associations, components, etc. of the Pages controller*/ $this->Tweets->Tweet->query($sql); $this->redirect(array('controller' => 'tweets', 'action' => 'index')); }
public function lock($taskId = null, $userId = null) { $user = Classregistry::init('User'); if (!$taskId) { $taskId = $this->id; } if (!$userId) { $userId = $user->id = $user->getUserId(); } if (!$user->exists() || !$this->exists()) { $this->cakeError('internal'); } $this->read(array('locked', 'locked_by'), $taskId); $this->data['Task']['locked'] = date('Y-m-d H:i:s'); $this->data['Task']['locked_by'] = $userId; return $this->save(); }
function getProfile($slug, $bypassAcl = false) { $this->User = Classregistry::init('User'); $canView = false; $canRequest = false; if (!$slug) { $user = $this->controller->currentUser; } else { // get the user's info based on their slug $user = $this->User->getProfile($slug); } if (!$user) { $this->controller->redirect(array('controller' => 'users', 'action' => 'profile', $this->controller->currentUser['User']['slug'])); exit; } // check if the requested user is yourself if ($this->controller->currentUser['User']['id'] != $user['User']['id'] && !$bypassAcl) { // Do permission check if ($this->Aacl->checkPermissions($user['User']['id'], $this->controller->currentUser['User']['id'], 'profile')) { $canView = true; } else { $this->controller->Session->setFlash(__('not_allowed_profile', true), 'default', array('class' => 'warning')); } // are you friends with this person $isFriend = $this->User->GroupsUser->isFriend($this->controller->currentUser['User']['id'], $user['User']['id']); if (!$isFriend) { if (!$this->User->GroupsUser->requestSent($this->controller->currentUser['User']['id'], $user['User']['id'])) { $canRequest = true; } } } else { // These are defaults for viewing your own profile $canView = true; } //get gallery position data $galleryPosData = unserialize($user['Profile']['gallery_pos_data']); //pass the profile data to the view $this->controller->set(compact('canRequest', 'galleryPosData', 'user')); if ($canView) { return $user; } else { return false; } }
/** * Add a new faculty. * */ function add() { $this->set('title_for_layout', 'Add Faculty'); $this->RolesUser = Classregistry::init('RolesUser'); $superadmins = $this->RolesUser->find('all', array('conditions' => array('role_id' => 1))); $userfac = array(); if (!empty($this->data)) { $this->Faculty->create(); $this->data['Faculty']['name'] = trim($this->data['Faculty']['name']); if ($this->Faculty->save($this->data)) { $facultyId = $this->Faculty->getLastInsertID(); foreach ($superadmins as $sa) { $userfac[] = array('user_id' => $sa['RolesUser']['user_id'], 'faculty_id' => $facultyId); } $this->UserFaculty->saveAll($userfac); $this->Session->setFlash(__('Faculty added!', true), 'good'); $this->redirect(array('action' => 'index')); } else { $this->Session->setFlash(__('The faculty could not be saved. Please, try again.', true)); } } }
private function __sendEmails(&$Model, $userIds, $notificationTypeId) { $Notification = Classregistry::init('Notification'); $notificationType = $Notification->NotificationType->findById($notificationTypeId); App::import('Component', 'Mailer.Queue'); $Queue = new QueueComponent(); $Queue->initialize(); App::import('Component', 'Libs.Tools'); $Tools = new ToolsComponent(); $item = $Model->find('first', array('conditions' => array($Model->escapeField('id') => $Model->id), 'fields' => array('id', $Model->displayField))); $messageId = $Queue->createMessage(Configure::read('Kinspir.Email.Address.no-reply'), Configure::read('Kinspir.Email.Subject.notification'), Configure::read('Kinspir.Email.Template.notification')); $users = $Notification->User->find('all', array('conditions' => array('User.id' => $userIds), 'fields' => array('id', 'name', 'email'))); foreach ($users as $user) { $recipientId = $Queue->addRecipient($messageId, $user['User']['email']); $notification = $Tools->insertVars($notificationType['NotificationType']['text'], array(User::get('name'), $item[$Model->alias][$Model->displayField], null)); $Queue->addVariable($recipientId, 'user_name', $user['User']['name']); $Queue->addVariable($recipientId, 'notification_content', $notification); } if ($messageId) { return true; } return; }
/** * Get course data by departments * * @param array $departments array of departments * @param string $findType find type * * @return course data */ function getByDepartments($departments, $findType) { $this->CourseDepartment = Classregistry::init('CourseDepartment'); $courses = array(); foreach ($departments as $department) { $dp_id = $department['Department']['id']; $cd = $this->CourseDepartment->find('all', array('conditions' => array('department_id' => $dp_id))); foreach ($cd as $course) { array_push($courses, $course['CourseDepartment']['course_id']); } } $ret = $this->find($findType, array('conditions' => array('Course.id' => $courses))); return $ret; }
/** * getMyDepartmentsCourseList get the list of courses * * @param mixed $findType * * @access public * @return array list of courses */ function getMyDepartmentsCourseList($findType = 'list') { $this->UserFaculty = Classregistry::init('UserFaculty'); $this->Department = Classregistry::init('Department'); $this->Course = Classregistry::init('Course'); $uf = $this->UserFaculty->findAllByUserId($this->Auth->user('id')); $d = $this->Department->getByUserFaculties($uf); $ret = $this->Course->getByDepartments($d, $findType); return $ret; }
function setup(&$Model, $config = array()) { $this->SbmRanking = Classregistry::init('Sbmranking.SbmRanking'); $this->SbmPastRanking = Classregistry::init('Sbmranking.SbmPastRanking'); $this->config = Configure::read('sbmranking'); }
private function assignToNextReviewer($worksheetId, $reviewOrder) { Classregistry::init('Worksheet')->id = $worksheetId; if ($reviewOrder == '4') { //third review is also done Classregistry::init('Worksheet')->saveField('statusId', '6'); Classregistry::init('Worksheet')->saveField('assignedToId', null); return; } //blindly assignto 2nd reviewer...will get overwritten later appropriately Classregistry::init('Worksheet')->saveField('statusId', '4'); if ($reviewOrder == '3') { //check the status and assign to third reviewer $firstTwoReviews = $this->Review->find('list', array('fields' => array('reviewOrder', 'letterCode'), 'conditions' => array('worksheetId' => $worksheetId, 'invalidReview' => false))); if ($firstTwoReviews['1'] == $firstTwoReviews['2']) { Classregistry::init('Worksheet')->saveField('statusId', '6'); Classregistry::init('Worksheet')->saveField('assignedToId', null); //no need to assign to third reviewer // make the worksheet statusId as '6' return; } else { //worksheet pending third review Classregistry::init('Worksheet')->saveField('statusId', '5'); //assign to third reviewer } } $nextReview = $this->Review->find('first', array('conditions' => array('worksheetId' => $worksheetId, 'invalidReview' => false, 'statusCode' => '1', 'reviewOrder' => $reviewOrder))); if ($nextReview) { $this->Review->id = $nextReview['Review']['id']; $this->Review->saveField('assignedDate', date("Y-m-d H:i:s", time())); $this->Review->saveField('statusCode', '2'); // set worksheet status id to the next one //debug($nextReview);exit; Classregistry::init('Worksheet')->saveField('assignedToId', $nextReview['Review']['reviewerId']); } else { Classregistry::init('Worksheet')->saveField('assignedToId', null); } }
function testGetByDepartments() { $this->UserFaculty = Classregistry::init('UserFaculty'); $this->Course = ClassRegistry::init('Course'); $this->Department = ClassRegistry::init('Department'); $expected = array("1" => "MECH 328 - Mechanical Engineering Design Project", "2" => "APSC 201 - Technical Communication", "3" => "CPSC 101 - Connecting with Computer Science", "4" => "CPSC 404 - Advanced Software Engineering"); $empty = null; // super admin: user id 1, should see all courses $dep = array(array('Department' => array('id' => 1)), array('Department' => array('id' => 2)), array('Department' => array('id' => 3))); $course = $this->Course->getByDepartments($dep, 'list'); $this->assertEqual($course, $expected); // if no departments in array, should return nothing $course = $this->Course->getByDepartments(array(), 'all'); $this->assertEqual($course, $empty); }
public function afterDelete(&$Model) { $data = array('class' => $Model->name, 'foreign_id' => $Model->id); Classregistry::init('Feed')->deleteAll($data); return true; }
public function beforeRender(Controller $Controller) { parent::beforeRender($Controller); if ($Controller->layout == 'ajax') { return; } if (!empty($Controller->viewVars['error']) && $Controller->viewVars['error'] instanceof Exception) { $error = $Controller->viewVars['error']; unset($Controller->viewVars['error']); } $layout = array_values($Controller->viewVars); $theme = current(Set::extract('/Layout/theme_id', $layout)); $layout = current(Set::extract('/Layout/layout', $layout)); if (!empty($error)) { $Controller->viewVars['error'] = $error; $layout = 'error'; } if ($layout) { Configure::write('Themes.default_layout', $layout); } $event = $Controller->Event->trigger($Controller->plugin . '.setupThemeStart'); if (isset($event['setupThemeStart'][$Controller->plugin])) { if (is_string($event['setupThemeStart'][$Controller->plugin])) { $Controller->theme = $event['setupThemeStart'][$Controller->plugin]; return true; } else { if ($event['setupThemeStart'][$Controller->plugin] === false) { return false; } } } $Controller->layout = Configure::read('Themes.default_layout'); $theme = Cache::read('currentTheme'); if ($theme === false) { $theme = ClassRegistry::init('Themes.Theme')->getCurrentTheme(); } if (!empty($theme['Theme']['default_layout'])) { $Controller->layout = $theme['Theme']['default_layout']; } if (isset($Controller->request->params['admin']) && $Controller->request->params['admin']) { $Controller->layout = Configure::read('Themes.default_layout_admin'); } $event = $Controller->Event->trigger($Controller->plugin . '.setupThemeLayout', array('layout' => $Controller->layout, 'params' => $Controller->request->params)); if (isset($event['setupThemeLayout'][$Controller->plugin]) && is_string($event['setupThemeLayout'][$Controller->plugin])) { $Controller->layout = $event['setupThemeLayout'][$Controller->plugin]; } if (!isset($theme['Theme']['name'])) { $theme['Theme'] = array('name' => null); } else { $event = $Controller->Event->trigger($Controller->plugin . '.setupThemeSelector', array('theme' => $theme['Theme'], 'params' => $Controller->request->params)); if (isset($event['setupThemeSelector'][$Controller->plugin])) { if (is_array($event['setupThemeSelector'][$Controller->plugin])) { $theme['Theme'] = $event['setupThemeSelector'][$Controller->plugin]; if (!isset($theme['Theme']['name'])) { $this->cakeError('eventError', array('message' => 'The theme is invalid.', 'event' => $event)); } } } } $Controller->theme = $theme['Theme']['name']; Configure::write('Theme', $theme['Theme']); $event = $Controller->Event->trigger($Controller->plugin . '.setupThemeRoutes', array('params' => $Controller->request->params)); if (isset($event['setupThemeRoutes'][$Controller->plugin]) && !$event['setupThemeRoutes'][$Controller->plugin]) { return false; } if (empty($routes)) { $routes = Classregistry::init('Routes.Route')->getRoutes(); } $currentRoute = Router::currentRoute(Configure::read('CORE.current_route')); if (!empty($routes) && is_object($currentRoute)) { foreach ($routes as $route) { if ($route['Route']['url'] == $currentRoute->template) { if (!empty($route['Route']['theme'])) { $Controller->theme = $route['Route']['theme']; } if (!empty($route['Route']['layout'])) { $Controller->layout = $route['Route']['layout']; } } } } $event = $Controller->Event->trigger($Controller->plugin . '.setupThemeEnd', array('theme' => $Controller->theme, 'params' => $Controller->request->params)); if (isset($event['setupThemeEnd'][$Controller->plugin])) { if (is_string($event['setupThemeEnd'][$Controller->plugin])) { $Controller->theme = $event['setupThemeEnd'][$Controller->plugin]; } } return true; }
private function __getUserAros() { $aros = Classregistry::init('Aro')->find('all', array('conditions' => array('Aro.model' => 'User', 'Aro.foreign_key' => User::get('id')), 'fields' => array('Aro.id', 'Aro.model', 'Aro.foreign_key'))); $this->userAros = Set::extract('/Aro/id', $aros); }
<?php Cache::config('core', array('engine' => 'File', 'duration' => 3600, 'probability' => 100, 'prefix' => '', 'lock' => false, 'serialize' => true, 'path' => CACHE . 'core')); Router::parseExtensions('rss'); Router::parseExtensions('vcf'); Router::parseExtensions('json'); /** * redirect to the installer if there is nothing */ if (!file_exists(APP . 'config' . DS . 'database.php')) { Configure::write('Session.save', 'php'); Router::connect('/', array('plugin' => 'installer', 'controller' => 'install', 'action' => 'index')); } else { $routes = Cache::read('routes', 'core'); if (!$routes) { $routes = Classregistry::init('Management.Route')->getRoutes(); if (empty($routes)) { //something is broken // @todo -c Implement .some error message or something } } if (!empty($routes)) { foreach ($routes as $route) { if (false) { debugRoute($route); continue; } Router::connect($route['Route']['url'], $route['Route']['values'], $route['Route']['regex']); } } }
/** * testBeforeAndAfterCallbacks * * @return void */ public function testBeforeAndAfterCallbacks() { $listener = new CommentEventListener(); CakeEventManager::instance()->attach($listener); $this->Model = Classregistry::init('Article'); $options = array('userId' => '47ea303a-3b2c-4251-b313-4816c0a800fa', 'modelId' => '1', 'modelName' => 'Article', 'defaultTitle' => 'Specified default title', 'data' => array('Comment' => array('body' => "Comment Test successful Captn!", 'title' => 'Not the Default title')), 'permalink' => 'http://testing.something.com'); $this->Model->commentAdd(0, $options); $commentId = $this->Model->Comment->id; $comment = $this->Model->Comment->read(null, $commentId); $this->assertEqual($comment['Comment']['title'], 'Changed in beforeComment!'); $this->assertEqual($comment['Comment']['body'], 'Changed in afterComment!'); }
/** * Setup the theme for the site * * Gets the current theme set in db and sets if up */ function setupTheme() { $event = $this->Controller->Event->trigger($this->Controller->plugin . '.setupThemeStart'); if (isset($event['setupThemeStart'][$this->Controller->plugin])) { if (is_string($event['setupThemeStart'][$this->Controller->plugin])) { $this->Controller->theme = $event['setupThemeStart'][$this->Controller->plugin]; return true; } else { if ($event['setupThemeStart'][$this->Controller->plugin] === false) { return false; } } } $this->Controller->layout = 'front'; if (isset($this->Controller->params['admin']) && $this->Controller->params['admin']) { $this->Controller->layout = 'admin'; } $event = $this->Controller->Event->trigger($this->Controller->plugin . '.setupThemeLayout', array('layout' => $this->Controller->layout, 'params' => $this->Controller->params)); if (isset($event['setupThemeLayout'][$this->Controller->plugin])) { if (is_string($event['setupThemeLayout'][$this->Controller->plugin])) { $this->Controller->layout = $event['setupThemeLayout'][$this->Controller->plugin]; } } if (!($theme = Cache::read('currentTheme'))) { $theme = ClassRegistry::init('Management.Theme')->getCurrentTheme(); } if (!isset($theme['Theme']['name'])) { $theme['Theme'] = array(); } else { $event = $this->Controller->Event->trigger($this->Controller->plugin . '.setupThemeSelector', array('theme' => $theme['Theme'], 'params' => $this->Controller->params)); if (isset($event['setupThemeSelector'][$this->Controller->plugin])) { if (is_array($event['setupThemeSelector'][$this->Controller->plugin])) { $theme['Theme'] = $event['setupThemeSelector'][$this->Controller->plugin]; if (!isset($theme['Theme']['name'])) { $this->cakeError('eventError', array('message' => 'The theme is invalid.', 'event' => $event)); } } } } $this->Controller->theme = $theme['Theme']['name']; Configure::write('Theme', $theme['Theme']); $event = $this->Controller->Event->trigger($this->Controller->plugin . '.setupThemeRoutes', array('params' => $this->Controller->params)); if (isset($event['setupThemeRoutes'][$this->Controller->plugin]) && !$event['setupThemeRoutes'][$this->Controller->plugin]) { return false; } $routes = Cache::read('routes', 'core'); if (empty($routes)) { $routes = Classregistry::init('Management.Route')->getRoutes(); } $currentRoute = Router::currentRoute(); if (!empty($routes) && is_object($currentRoute)) { foreach ($routes as $route) { if ($route['Route']['url'] == $currentRoute->template && !empty($route['Route']['theme'])) { $this->Controller->theme = $route['Route']['theme']; } } } $event = $this->Controller->Event->trigger($this->Controller->plugin . '.setupThemeEnd', array('theme' => $this->Controller->theme, 'params' => $this->Controller->params)); if (isset($event['setupThemeEnd'][$this->Controller->plugin])) { if (is_string($event['setupThemeEnd'][$this->Controller->plugin])) { $this->Controller->theme = $event['setupThemeEnd'][$this->Controller->plugin]; } } }
public function testCustomSettings() { $User2 = Classregistry::init('User2'); $result = $User2->getAuditableSettings(); $expected = array('priority' => 1, 'auditSql' => false, 'skip' => array('modified'), 'fields' => array('created' => 'created_by', 'modified' => 'modified_by')); $this->assertEqual($expected, $result); $User3 = Classregistry::init('User3'); $result = $User3->getAuditableSettings(); $expected = array('priority' => 1, 'auditSql' => true, 'skip' => array('created', 'modified'), 'fields' => array('created' => 'created_by', 'modified' => 'modified_by')); $this->assertEqual($expected, $result); }
/** * testBeforeAndAfterCallbacks * * @return void */ public function testBeforeAndAfterCallbacks() { $this->Model = Classregistry::init('Article2'); $options = array('userId' => '47ea303a-3b2c-4251-b313-4816c0a800fa', 'modelId' => '1', 'modelName' => 'Article', 'defaultTitle' => 'Specified default title', 'data' => array('Comment' => array('body' => "Comment Test successful Captn!", 'title' => 'Not the Default title')), 'permalink' => 'http://testing.something.com'); $this->Model->commentAdd(0, $options); $this->assertEqual($this->Model->callbackData['beforeComment']['Comment']['title'], 'Changed in beforeComment!'); $this->assertEqual($this->Model->callbackData['afterComment']['Comment']['body'], 'Changed in afterComment!'); }
function __construct() { $this->Nodes = Classregistry::init('Node'); }
/** * Start test * * @return void * @access public */ public function startTest() { $this->Model = Classregistry::init('Article'); $this->Model->Comment->bindModel(array('belongsTo' => array('User'))); }
/** * Main execution method. Handles redirecting of invalid users, and processing * of login form data. * * @param object $controller A reference to the instantiating controller object * @return boolean * @access public */ function startup(&$controller) { $this->__checkCookie(); // see if user has the RememberMe cookie $isErrorOrTests = strtolower($controller->name) == 'cakeerror' || strtolower($controller->name) == 'tests' && Configure::read() > 0; if ($isErrorOrTests) { return true; } $methods = array_flip($controller->methods); $action = strtolower($controller->params['action']); $isMissingAction = $controller->scaffold === false && !isset($methods[$action]); if ($isMissingAction) { return true; } if (!$this->__setDefaults()) { return false; } $this->data = $controller->data = $this->hashPasswords($controller->data); $url = array(); if (!empty($controller->name) && !empty($controller->action)) { $url = array('controller' => strtolower($controller->name), 'action' => $controller->action); } $url = Router::normalize($url); $loginAction = Router::normalize($this->loginAction); $allowedActions = array_map('strtolower', $this->allowedActions); $isAllowed = $this->allowedActions == array('*') || in_array($action, $allowedActions); // row-level acl begin if ($this->user()) { $aros = Classregistry::init('Aro')->find('all', array('conditions' => array('Aro.model' => $this->userModel, 'Aro.foreign_key' => $this->user('id')), 'fields' => array('Aro.id', 'Aro.model', 'Aro.foreign_key'))); $this->userAros = Set::extract('/Aro/id', $aros); } // row-level acl end if ($loginAction != $url && $isAllowed) { return true; } if ($loginAction == $url) { $model =& $this->getModel(); if (empty($controller->data) || !isset($controller->data[$model->alias])) { if (!$this->Session->check('Auth.redirect') && !$this->loginRedirect && env('HTTP_REFERER')) { $this->Session->write('Auth.redirect', $controller->referer(null, true)); } return false; } $isValid = !empty($controller->data[$model->alias][$this->fields['username']]) && !empty($controller->data[$model->alias][$this->fields['password']]); if ($isValid) { $username = $controller->data[$model->alias][$this->fields['username']]; $password = $controller->data[$model->alias][$this->fields['password']]; $data = array($model->alias . '.' . $this->fields['username'] => $username, $model->alias . '.' . $this->fields['password'] => $password); if ($this->login($data)) { if ($this->autoRedirect) { $controller->redirect($this->redirect(), null, true); } return true; } } $this->Session->setFlash($this->loginError, $this->flashElement, array(), 'auth'); $controller->data[$model->alias][$this->fields['password']] = null; return false; } else { if (!$this->user()) { if (!$this->RequestHandler->isAjax()) { $this->Session->setFlash($this->authError, $this->flashElement, array(), 'auth'); if (!empty($controller->params['url']) && count($controller->params['url']) >= 2) { $query = $controller->params['url']; unset($query['url'], $query['ext']); $url .= Router::queryString($query, array()); } $this->Session->write('Auth.redirect', $url); $controller->redirect($loginAction); return false; } elseif (!empty($this->ajaxLogin)) { $controller->viewPath = 'elements'; echo $controller->render($this->ajaxLogin, $this->RequestHandler->ajaxLayout); $this->_stop(); return false; } else { $controller->redirect(null, 403); } } } if (!$this->authorize) { return true; } extract($this->__authType()); switch ($type) { case 'controller': $this->object =& $controller; break; case 'crud': case 'actions': if (isset($controller->Acl)) { $this->Acl =& $controller->Acl; } else { trigger_error(__('Could not find AclComponent. Please include Acl in Controller::$components.', true), E_USER_WARNING); } break; case 'acl': if (isset($controller->Acl)) { $this->Acl =& $controller->Acl; } else { trigger_error(__('Could not find AclComponent. Please include Acl in Controller::$components.', true), E_USER_WARNING); } case 'model': $object = null; if (!isset($object)) { $hasModel = isset($controller->{$controller->modelClass}) && is_object($controller->{$controller->modelClass}); $isUses = !empty($controller->uses) && isset($controller->{$controller->uses[0]}) && is_object($controller->{$controller->uses[0]}); if ($hasModel) { $object = $controller->modelClass; } elseif ($isUses) { $object = $controller->uses[0]; } } $type = array('model' => $object); if (isset($this->Acl)) { $type = array('acl' => $object); } break; } if ($this->isAuthorized($type)) { return true; } $this->Session->setFlash($this->authError, $this->flashElement, array(), 'auth'); $controller->redirect($controller->referer(), null, true); return false; }
/** * タグのオプション取得 * * @return array * @access public */ public function getTagOptions() { //ブログカテゴリモデル利用開始 $this->BlogTag = Classregistry::init('Blog.BlogTag'); //ブログカテゴリデータ取得 TODO: カテゴリ固定設定の場合の処理を追加する。 $blogTagDatas = $this->BlogTag->find('list', array('fields' => array('id', 'name'))); return $blogTagDatas; }