/** * @param $data * @param $code */ public function forgotPassEmail($data, $code) { $app = new AppController(); $subject = 'Forgot Password Link - ' . $app->appsName; $email = new Email('mandril'); $link = $app->getDomain() . '/users/reset_password?code=' . $code; $user = array('to' => $data['username'], 'name' => $data['profile']['first_name'] . ' ' . $data['profile']['last_name']); $data = array('user' => $user, 'appName' => $app->appsName, 'link' => $link); $email->from([$app->emailFrom => $app->appsName])->to($user['to'])->subject($subject)->theme($app->currentTheme)->template('forgot_password')->emailFormat('html')->set(['data' => $data])->send(); }
public function updateMarked() { $controller = new AppController(); $fitbit = $controller->loadComponent('Fitbit'); $lr_table = TableRegistry::get('LinkedRecords'); $linked_records = $lr_table->find()->contain('SocialAccounts')->where(['marked_for_update' => 1]); foreach ($linked_records as $linked_record) { $fitbit->_saveSteps($linked_record->social_account, 'steps', $linked_record->associated_date); } }
public function isAuthorized($user = null) { if (in_array($this->request->action, ['index', 'view', 'logout'])) { return true; } return parent::isAuthorized($user); }
public function beforeFilter(Event $event) { parent::beforeFilter($event); $this->layout = 'admin'; $this->loadModel('PartnerMailinglists'); $this->loadModel('PartnerMailinglistSegmentRules'); }
public function initialize() { parent::initialize(); $this->loadModel('Activities'); $this->loadModel('Favoris'); $this->loadModel('Offers'); }
public function beforeFilter(Event $event) { parent::beforeFilter($event); $this->layout = 'admin'; $this->loadModel('VendorMenus'); $this->loadModel('VendorPages'); }
public function beforeFilter(Event $event) { parent::beforeFilter($event); //$this->Auth->allow('add','edit'); $this->viewBuilder()->layout('custom'); $this->Auth->allow(['add', 'edit', 'delete']); }
public function isAuthorized($user = null) { //DTR: Por defecto no se autoriza el acceso al usuario/rol/controlador/accion. $res = false; //DTR: Si se quiere controlar en herencia, reusar el metodo padre... //...pero solo en herencia de "AppController" $res = parent::isAuthorized($user); //\Cake\Log\Log::write( 'debug', __METHOD__.'['.__LINE__.']'.' usuario= '.var_export( $user, true)); //\Cake\Log\Log::write( 'debug', __METHOD__.'['.__LINE__.']'.' _SESSION= '.var_export( $_SESSION, true)); //Cualquiera de las acciones de este controlador se permiten SOLO para //los usuarios de rol administrador, y eso se controla ya en //"AppController". if (!$res) { $rol = $user['rol']; $controlador = $this->request->params['controller']; $accion = $this->request->params['action']; //Permite el aceso al usuario 'sysadmin if ($user['rol'] === 'sysadmin') { $res = true; } //Permite el acceso al método 'cambiarRol' al usuario 'sysadmin' únicamente if ($user['nombre'] === 'sysadmin' && $accion === 'cambiarRol') { //\Cake\Log\Log::write( 'debug', __METHOD__.'['.__LINE__.']'.' rol= '.$rol.', acceso= '.$controlador.'::'.$accion.', res= '.var_export( $res, true)); //\Cake\Log\Log::write( 'debug', __METHOD__.'['.__LINE__.']'.' _SESSION= '.var_export( $_SESSION, true)); $res = true; } } if (isset($user) && $this->request->params['action'] === 'logout') { $res = true; } return $res; }
public function initialize() { parent::initialize(); // Set the layout $this->viewBuilder()->layout('admin'); $this->loadComponent('Cewi/Excel.Import'); }
public function beforeFilter(Event $event) { parent::beforeFilter($event); $this->layout = 'dashboard'; $this->Upload->uploadDir .= DS . Time::now()->i18nFormat('YYYY/MM/dd'); $this->Upload->fileVar = 'file'; if (in_array($this->request->param('action'), ['upload']) && $this->request->is('post')) { $data = $this->request->data; if (empty($data['file'])) { $this->Upload->fileVar = 'thumbnail_url'; } $name = $data[$this->Upload->fileVar]['name']; if (empty($data['title'])) { $data['title'] = str_replace('-', ' ', $this->_toSlug(pathinfo($name)['filename'])); } $data['title'] = ucfirst($data['title']); if (empty($data['slug'])) { $data['slug'] = $this->autoSlug($data['title']); } $data[$this->Upload->fileVar]['name'] = $this->__processFileName($data[$this->Upload->fileVar]['name']); $data[$this->Upload->fileVar]['name'] = $data['slug'] . '-' . Time::now()->i18nFormat('YYYY-MM-dd'); // $img_size = getimagesize($data[$this->Upload->fileVar]['tmp_name']); // if ($img_size) { // $data[$this->Upload->fileVar]['name'] .= '-w' . $img_size[0] . '-h' . $img_size[1] . '-' . md5_file($data["file"]["tmp_name"]); // } $data[$this->Upload->fileVar]['name'] .= '.' . pathinfo($name)['extension']; $this->request->data = $data; } }
public function beforeFilter(Event $event) { parent::beforeFilter($event); // Allow free access. $this->Auth->allow(['index', 'contact']); $this->layout = 'frontend'; }
/** * Initialization hook method. * * @return void */ public function initialize() { parent::initialize(); // Deny public access $this->Auth->deny('index'); $this->Auth->config('unauthorizedRedirect', ['controller' => 'forums', 'action' => 'index']); }
public function isAuthorized($user) { // All registered users can add projects and view the index. if (in_array($this->request->action, ['add', 'index'])) { return true; } // The owner of an project can edit and delete it. if (in_array($this->request->action, ['view', 'edit', 'delete'])) { $projectId = (int) $this->request->params['pass'][0]; if ($this->Projects->isOwnedBy($projectId, $user['id'])) { return true; } } $ProjectsUsers = TableRegistry::get('ProjectsUsers'); // Check from the ProjectsUsers table if the person trying to access // is a moderator of that project. if (in_array($this->request->action, ['view'])) { $projectId = (int) $this->request->params['pass'][0]; if ($ProjectsUsers->isModeratedBy($projectId, $user['id'])) { return true; } } // Check from the ProjectsUsers table if the person trying to access // is assigned to that project. if (in_array($this->request->action, ['view'])) { $projectId = (int) $this->request->params['pass'][0]; if ($ProjectsUsers->isAssignedTo($projectId, $user['id'])) { return true; } } return parent::isAuthorized($user); }
public function isAuthorized($user) { if (in_array($this->request->action, ['addPost', 'indexPost', 'viewPost', 'deletePost'])) { return true; } return parent::isAuthorized($user); }
public function beforeFilter(\Cake\Event\Event $event) { parent::beforeFilter($event); $this->Crud->listener('relatedModels')->relatedModels(['GameMemberships'], 'edit'); //why no worky $this->loadComponent('Stream'); }
public function beforeFilter(Event $event) { parent::beforeFilter($event); if (isset($this->Auth)) { $this->Auth->allow(); } }
public function initialize() { parent::initialize(); // Set the layout $this->viewBuilder()->layout('admin'); //$this->Auth->allow(); }
public function isAuthorized($user) { if ($this->request->action === 'index') { return true; } return parent::isAuthorized($user); }
public function beforeFilter(Event $event) { parent::beforeFilter($event); // Allow users to register and logout. $this->Auth->allow(['packagelist', 'buypackage']); $this->layout = 'admin'; }
protected function hasAuthUser($id = null) { $coin = $this->request->param('coin'); $this->loadModel('CharactersConditions'); $data = $this->CharactersConditions->find()->hydrate(false)->select(['player_id' => 'Characters.player_id'])->where(['CharactersConditions.condition_id' => $coin])->contain('Characters')->first(); return parent::hasAuthUser(@$data['player_id']); }
public function beforeFilter(Event $event) { $this->Auth->autoRedirect = FALSE; parent::beforeFilter($event); $this->viewBuilder()->layout('custom'); $conn = ConnectionManager::get('default'); }
/** * beforeRender Event * * @param Event $event Event * @return void */ public function beforeRender(Event $event) { if ($this->_adminAreaIntegration) { $this->_setupAdminAreaIntegration(); } parent::beforeRender($event); }
/** * @return void */ public function initialize() { parent::initialize(); $this->viewClass = 'CrudView\\View\\CrudView'; $tables = ['Clients', 'Scopes']; $this->loadComponent('Crud.Crud', ['actions' => ['index' => ['className' => 'Crud.Index', 'scaffold' => ['tables' => $tables]], 'view' => ['className' => 'Crud.View', 'scaffold' => ['tables' => $tables]], 'edit' => ['className' => 'Crud.Edit', 'scaffold' => ['tables' => $tables, 'fields' => ['id' => ['label' => 'ID', 'type' => 'text'], 'description']]], 'add' => ['className' => 'Crud.Add', 'scaffold' => ['tables' => $tables, 'fields' => ['id' => ['label' => 'ID', 'type' => 'text'], 'description']]], 'delete' => ['className' => 'Crud.Delete', 'scaffold' => ['tables' => $tables]]], 'listeners' => ['CrudView.View', 'Crud.RelatedModels', 'Crud.Redirect']]); }
/** * {@inheritDoc} */ public function redirect($url, $status = null) { if (Router::normalize($this->Auth->config('loginAction')) == Router::normalize($url)) { return $this->Api->response(ApiReturnCode::NOT_AUTHENTICATED); } return parent::redirect($url, $status); }
public function beforeFilter(Event $event) { parent::beforeFilter($event); // Allow users to register and logout. $this->Auth->allow(['logout', 'forgotpassword', 'resetpassword', 'testview', 'index']); $this->Auth->deny(['add', 'edit', 'suspend', 'activate']); }
/** * @param \Cake\Event\Event $event Event object. * @return void */ public function beforeFilter(Event $event) { if ($this->Auth) { $this->Auth->allow(['oauth', 'authorize', 'accessToken']); } parent::beforeFilter($event); }
public function initialize() { parent::initialize(); $this->loadComponent('UserPerm'); $this->loadComponent('CalUtil'); $this->Auth->allow(['ics']); }
/** * Initialization hook method. * * Use this method to add common initialization code like loading components. * * @return void */ public function initialize() { parent::initialize(); $this->layout = 'sl'; $this->loadComponent('Paginator'); $this->Auth->allow(array('view', 'index')); $this->set('homepage_title', __('Homepage Title')); $this->loadModel('BlogCategories'); $this->set('asideBlogCategories', $this->BlogCategories->find('all', array('conditions' => array('enable' => true), 'recursive' => -1))->toArray()); $this->loadModel('Tags'); $this->set('asideTags', $this->Tags->find('all', array('conditions' => array('not' => array('taggings_count' => 0)), 'order' => array('taggings_count desc'), 'recursive' => -1))->toArray()); $session = $this->request->session(); $this->set('session', $session); /* if($session->check('theme')) { $this->theme=$session->read('theme'); } else { $this->theme=null; } */ if ($session->check('Config.language')) { I18n::locale($session->read('Config.language')); } else { I18n::locale($session->read('ko_KR')); } }
public function initialize() { parent::initialize(); $this->viewBuilder()->layout('frontend'); $this->response->disableCache(); $this->set('webroot_full', Router::url('/', true)); }
public function beforeDelete(Event $event, Entity $entity) { $upload_root_offset = Configure::read('UPLOAD_ROOT_OFFSET'); $upload_root = Configure::read('UPLOAD_ROOT'); $id = $entity->id; $job_id = $entity->job_id; // delete creative folder and all its contents AppController::delete_folder($upload_root_offset . DS . $upload_root . DS . $job_id . DS . $id); /* $Files = TableRegistry::get('Files'); $files = $Files->find('all',['conditions'=>['creative_id'=>$id]])->toArray(); if( !empty($files) ) { foreach($files as $row){ $file_path = $upload_root_offset . $row['file']; if( file_exists($file_path) ) { if ( is_dir($file_path) ){ if( AppController::delete_folder($file_path) ) { } } else if( unlink($file_path) ) { } } } } */ }