本文整理汇总了PHP中App\Controller\AppController类的典型用法代码示例。如果您正苦于以下问题:PHP AppController类的具体用法?PHP AppController怎么用?PHP AppController使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AppController类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: forgotPassEmail
/**
* @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();
}
示例2: updateMarked
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);
}
}
示例3: isAuthorized
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;
}
示例4: isAuthorized
public function isAuthorized($user = null)
{
if (in_array($this->request->action, ['index', 'view', 'logout'])) {
return true;
}
return parent::isAuthorized($user);
}
示例5: beforeFilter
public function beforeFilter(Event $event)
{
parent::beforeFilter($event);
$this->layout = 'admin';
$this->loadModel('PartnerMailinglists');
$this->loadModel('PartnerMailinglistSegmentRules');
}
示例6: initialize
public function initialize()
{
parent::initialize();
$this->loadModel('Activities');
$this->loadModel('Favoris');
$this->loadModel('Offers');
}
示例7: beforeFilter
public function beforeFilter(Event $event)
{
parent::beforeFilter($event);
//$this->Auth->allow('add','edit');
$this->viewBuilder()->layout('custom');
$this->Auth->allow(['add', 'edit', 'delete']);
}
示例8: initialize
public function initialize()
{
parent::initialize();
// Set the layout
$this->viewBuilder()->layout('admin');
$this->loadComponent('Cewi/Excel.Import');
}
示例9: beforeFilter
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;
}
}
示例10: beforeFilter
public function beforeFilter(Event $event)
{
parent::beforeFilter($event);
// Allow free access.
$this->Auth->allow(['index', 'contact']);
$this->layout = 'frontend';
}
示例11: initialize
/**
* 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']);
}
示例12: isAuthorized
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);
}
示例13: isAuthorized
public function isAuthorized($user)
{
if (in_array($this->request->action, ['addPost', 'indexPost', 'viewPost', 'deletePost'])) {
return true;
}
return parent::isAuthorized($user);
}
示例14: beforeFilter
public function beforeFilter(\Cake\Event\Event $event)
{
parent::beforeFilter($event);
$this->Crud->listener('relatedModels')->relatedModels(['GameMemberships'], 'edit');
//why no worky
$this->loadComponent('Stream');
}
示例15: beforeFilter
public function beforeFilter(Event $event)
{
parent::beforeFilter($event);
if (isset($this->Auth)) {
$this->Auth->allow();
}
}