/**
  * Manage redirect for specific buttons that posted.
  *
  * @param Event $event
  * @param array|string $url
  * @param Response $response
  * @return bool
  */
 public function beforeRedirect(Event $event, $url, Response $response)
 {
     if ($this->request->param('prefix') == 'admin') {
         if (isset($this->request->data['apply'])) {
             $response->location(Router::url($this->request->here(false), true));
         }
     }
     return true;
 }
 public function beforeFilter(Event $event)
 {
     $this->current_user = $this->Auth->user();
     //$this->set('logged_in', $this->logged_in);
     $this->set('current_user', $this->current_user);
     $menu_items = array('home' => array('text' => 'Home', 'link' => Router::url(['controller' => 'home', 'action' => 'index']), 'icon' => 'icon-home'), 'users' => array('text' => 'Users', 'link' => Router::url(['controller' => 'users', 'action' => 'index']), 'icon' => '', 'sub_menu' => array('index' => array('text' => 'List users', 'link' => Router::url(['controller' => 'users', 'action' => 'index']), 'icon' => ''), 'new' => array('text' => 'Add new users', 'link' => Router::url(['controller' => 'users', 'action' => 'add']), 'icon' => ''))), 'demos' => array('text' => 'Demos', 'link' => Router::url(['controller' => 'demos', 'action' => 'index']), 'icon' => ''), 'tests' => array('text' => 'Tests', 'link' => Router::url(['controller' => 'tests', 'action' => 'index']), 'icon' => ''), 'icon' => array('text' => 'Icon', 'link' => Router::url(['controller' => 'home', 'action' => 'icon']), 'icon' => ''));
     $this->set('menu_items', $menu_items);
     $menu_active = strtolower($this->request->params['controller']);
     $this->set('menu_active', $menu_active != '' ? $menu_active : 'index');
     $sub_menu_active = $this->request->params['action'];
     $this->set('sub_menu_active', $sub_menu_active != '' ? $sub_menu_active : 'index');
     $SessionExprieTime = $this->request->session()->read('Admin.SessionExprieTime');
     if (!empty($SessionExprieTime)) {
         if ($SessionExprieTime <= time()) {
             if ($SessionExprieTime <= time()) {
                 $controller = $this->request->params['controller'];
                 $action = $this->request->params['action'];
                 $avoid_action = array('validateSessionExprie', 'sessionLogout', 'login');
                 if ($controller != 'Users' || $controller == 'Users' && !in_array($action, $avoid_action)) {
                     $this->Auth->logout();
                 }
             }
         }
     }
     $this->set('SessionExprieIn', $this->createSessionExprie());
 }
 /**
  *
  *
  * FUNCTIONS PRIVATE
  *
  */
 private function _save($entity)
 {
     if ($this->request->is(['patch', 'post', 'put'])) {
         $entity = $this->Contentbuilders->patchEntity($entity, $this->request->data);
         // On ajoute les traductions
         $I18ns = TableRegistry::get('I18ns');
         $langs = $I18ns->find('list', ['keyField' => 'id', 'valueField' => 'locale'])->toArray();
         // On merge nos translations
         if (isset($entity->translations)) {
             $entity->_translations = array_merge($entity->_translations, $entity->translations);
             unset($entity->translations);
         }
         foreach ($entity->_translations as $lang => $data) {
             if (in_array($lang, $langs)) {
                 if ($entity->type_id !== Type::TYPE_HOMEPAGE && empty($data['slug']) && !empty($data['title'])) {
                     $data['slug'] = strtolower(Inflector::slug($data['title']));
                     // @ TODO : Il faudra penser a vérifier que le slug n'existe pas, sinon on rajoute -x
                 }
                 $entity->translation($lang)->set($data, ['guard' => false]);
             }
         }
         if ($this->Contentbuilders->save($entity)) {
             $this->set('response', [true, __("Object saved with success !"), Router::url(['controller' => 'Contentbuilders', 'action' => 'edit', $entity->id, '_ext' => 'html'])]);
             $this->set('_serialize', 'response');
         } else {
             $this->set('response', [false, __("Error occured while saving object !"), $entity->errors()]);
             $this->set('_serialize', 'response');
         }
     }
     $types = Contentbuilder::getPrettyType();
     $parents = $this->Contentbuilders->find('treeList', ['keyPath' => 'id', 'valuePath' => 'label', 'spacer' => ' --- ']);
     $this->set(compact('entity', 'types', 'parents'));
 }
Example #4
0
 /**
  * Custom finder for map the ntofications.
  *
  * @param \Cake\ORM\Query $query The query finder.
  * @param array $options The options passed in the query builder.
  *
  * @return \Cake\ORM\Query
  */
 public function findMap(Query $query, array $options)
 {
     return $query->formatResults(function ($notifications) use($options) {
         return $notifications->map(function ($notification) use($options) {
             $notification->data = unserialize($notification->data);
             switch ($notification->type) {
                 case 'conversation.reply':
                     $username = $notification->data['sender']->username;
                     $conversationTitle = Text::truncate($notification->data['conversation']->title, 50, ['ellipsis' => '...', 'exact' => false]);
                     //Check if the creator of the conversation is the current user.
                     if ($notification->data['conversation']->user_id === $options['session']->read('Auth.User.id')) {
                         $notification->text = __('<strong>{0}</strong> has replied in your conversation <strong>{1}</strong>.', h($username), h($conversationTitle));
                     } else {
                         $notification->text = __('<strong>{0}</strong> has replied in the conversation <strong>{1}</strong>.', h($username), h($conversationTitle));
                     }
                     $notification->link = Router::url(['controller' => 'conversations', 'action' => 'go', $notification->data['conversation']->last_message_id, 'prefix' => false]);
                     break;
                 case 'bot':
                     $notification->text = __('Welcome on <strong>{0}</strong>! You can now post your first comment in the blog.', \Cake\Core\Configure::read('Site.name'));
                     $notification->link = Router::url(['controller' => 'blog', 'action' => 'index', 'prefix' => false]);
                     $notification->icon = $notification->data['icon'];
                     break;
                 case 'badge':
                     $notification->text = __('You have unlock the badge "{0}".', $notification->data['badge']->name);
                     $notification->link = Router::url(['_name' => 'users-profile', 'id' => $notification->data['user']->id, 'slug' => $notification->data['user']->username, '#' => 'badges', 'prefix' => false]);
                     break;
             }
             return $notification;
         });
     });
 }
 /**
  * Return the webroot path to the image generated variant if this exist or to the controller if not.
  *
  * @param string $imagePath         Path to the original image file from webroot if absolute, or relative to img/
  * @param string|array $variantName Name of the variant configuration key or options array
  * @param array $options            options
  * @return string
  */
 public function variant($imagePath, $variantName, array $options = [])
 {
     if (!array_key_exists('plugin', $options) || $options['plugin'] !== false) {
         list($plugin, $imagePath) = $this->_View->pluginSplit($imagePath, false);
     }
     $url = false;
     $imagePath = $imagePath[0] === '/' ? substr($imagePath, 1) : $imagePath;
     if (!isset($plugin)) {
         $originalFile = WWW_ROOT . $imagePath;
         $variantFile = dirname($originalFile) . DS . $variantName . DS . basename($originalFile);
         if (is_file($variantFile)) {
             $url = str_replace(DS, '/', str_replace(WWW_ROOT, '/', $variantFile));
         }
     } else {
         $originalFile = WWW_ROOT . Inflector::underscore($plugin) . DS . $imagePath;
         $variantFile = dirname($originalFile) . DS . $variantName . DS . basename($originalFile);
         if (is_file($variantFile)) {
             $url = str_replace(DS, '/', str_replace(WWW_ROOT, '/', $variantFile));
         } else {
             $originalFile = Plugin::path($plugin) . 'webroot' . DS . $imagePath;
             $variantFile = dirname($originalFile) . DS . $variantName . DS . basename($originalFile);
             if (is_file($variantFile)) {
                 $url = str_replace(Plugin::path($plugin) . 'webroot' . DS, '/' . Inflector::underscore($plugin) . '/', $variantFile);
                 $url = str_replace(DS, '/', $url);
             }
         }
     }
     if ($url === false) {
         $url = ['controller' => 'Presenter', 'action' => 'variant', 'plugin' => 'ImagePresenter', 'prefix' => false, '?' => ['image' => isset($plugin) ? "{$plugin}.{$imagePath}" : $imagePath, 'variant' => $variantName]];
     }
     return Router::url($url);
 }
Example #6
0
 /**
  * Get index DataTable
  *
  * @param Query $query CakePHP query
  *
  * @return Table
  */
 protected function getIndexDataTable(Query $query)
 {
     $table = new Table('pages');
     $titleCol = new Column();
     $titleCol->setTitle('Title')->setData('Pages.title');
     $authorCol = new Column();
     $authorCol->setTitle('Author')->setData('Users.username')->setFormatter(function ($username, Page $page) {
         return $this->createView()->Html->link($username, ['author' => $page->getUserId()]);
     });
     $commentsCol = new Column();
     $commentsCol->setTitle('Comments')->setData('Pages.comment_count')->isSearchable(false);
     $dateCol = new Column();
     $dateCol->setTitle('Date')->setData('Pages.created_at')->isSearchable(false)->setFormatter(function (Time $cell) {
         return $cell->nice();
     });
     $action = new Column\Action();
     $action->setManager(function (Column\ActionBuilder $action, Page $page) {
         $action->addAction('view', __d('pages', 'View'), Router::url(['prefix' => false, 'controller' => 'Pages', 'action' => 'view', $page->getId()]), ['title' => __d('pages', 'View “%d”', $page->getTitle()), 'rel' => 'permalink']);
         $action->addAction('edit', __d('pages', 'Edit'), Router::url(['controller' => 'Pages', 'action' => 'edit', $page->getId()]), ['title' => __d('pages', 'Edit this item')]);
         $action->addAction('delete', __d('pages', 'Delete'), Router::url(['action' => 'delete', $page->getId()]), ['title' => __d('pages', 'Delete this item')]);
     })->setTitle('Action');
     $table->addColumn($titleCol)->addColumn($authorCol)->addColumn($commentsCol)->addColumn($dateCol)->addColumn($action);
     $table->setDataSource(new CakePHP($query, $this->request->here()));
     return $table;
 }
 public function initialize()
 {
     parent::initialize();
     $this->viewBuilder()->layout('frontend');
     $this->response->disableCache();
     $this->set('webroot_full', Router::url('/', true));
 }
 /**
  * Returns a URL based on provided parameters.
  *
  * ### Options:
  *
  * - `fullBase`: If true, the full base URL will be prepended to the result
  *
  * @param string|array|null $url Either a relative string url like `/products/view/23` or
  *    an array of URL parameters. Using an array for URLs will allow you to leverage
  *    the reverse routing features of CakePHP.
  * @param array $options Array of options
  * @return string Full translated URL with base path.
  */
 public function build($url = null, array $options = [])
 {
     $defaults = ['fullBase' => false];
     $options += $defaults;
     $url = Router::url($url, $options['fullBase']);
     return $url;
 }
Example #9
0
 public function beforeFilter(Event $event)
 {
     if ($this->request->is('ajax') && $this->request->params['action'] == 'delete_upload') {
         $this->eventManager()->off($this->Csrf);
     }
     $this->current_user = $this->Auth->user();
     //$this->set('logged_in', $this->logged_in);
     $this->set('current_user', $this->current_user);
     $this->set('menu_items', ['users' => ['text' => 'Users', 'link' => Router::url(['controller' => 'users', 'action' => 'index']), 'allow_access' => ['admin']], 'Members' => ['text' => 'Thành viên', 'link' => Router::url(['controller' => 'members', 'action' => 'index']), 'allow_access' => ['admin']], 'Introduces' => ['text' => 'Giới thiệu', 'link' => Router::url(['controller' => 'introduces', 'action' => 'index']), 'allow_access' => ['admin']], 'Posts' => ['text' => 'Thông báo', 'link' => Router::url(['controller' => 'posts', 'action' => 'index']), 'allow_access' => ['admin']], 'Contacts' => ['text' => 'Liên hệ', 'link' => Router::url(['controller' => 'contacts', 'action' => 'index']), 'allow_access' => ['admin']]]);
     $this->set('active_menu_item', $this->request->params['controller']);
     $SessionExprieTime = $this->request->session()->read('Admin.SessionExprieTime');
     if (!empty($SessionExprieTime)) {
         if ($SessionExprieTime <= time()) {
             if ($SessionExprieTime <= time()) {
                 $controller = $this->request->params['controller'];
                 $action = $this->request->params['action'];
                 $avoid_action = array('validateSessionExprie', 'sessionLogout', 'login');
                 if ($controller != 'Users' || $controller == 'Users' && !in_array($action, $avoid_action)) {
                     $this->Auth->logout();
                 }
             }
         }
     }
     $this->set('SessionExprieIn', $this->createSessionExprie());
 }
Example #10
0
 /**
  * Adds a comment in DB and redirects
  *
  * @return void
  */
 public function add()
 {
     $comment = $this->Comments->newEntity();
     // the body field should be empty as it's a honeypot for bots
     if ($this->request->is('post') && empty($this->request->data('body'))) {
         $data = $this->request->data;
         // Preparing data
         if (!empty($this->Auth->user('id'))) {
             $data['user_id'] = $this->Auth->user('id');
             $data['name'] = $this->Auth->user('username');
             $data['email'] = $this->Auth->user('email');
         } else {
             $data['user_id'] = null;
         }
         unset($data['body']);
         // Getting the route
         $route = Router::parse(str_replace(Router::url('/', true), '', $this->referer(true)));
         $data['fkid'] = $route['pass'][0];
         $data['model'] = $route['controller'];
         $comment = $this->Comments->patchEntity($comment, $data);
         if ($this->Comments->save($comment)) {
             if ($comment->allow_contact) {
                 $this->Flash->success(__d('elabs', 'Thank you for your comment. The author will contact you soon.'));
             } else {
                 $this->Flash->success(__d('elabs', 'Thank you for your comment.'));
             }
             $this->redirect($this->referer());
         } else {
             $this->Flash->error(__d('elabs', 'The comment could not be saved. Please try again.'));
         }
     }
     $this->redirect($this->referer());
 }
 /**
  * Get a new instance of FacebookRedirectLoginHelper with optional redirectUrl
  *
  * @param  string                               $redirectUrl destination to be redirect to after calling the login URL
  * @return Facebook\FacebookRedirectLoginHelper new instance
  */
 protected function _getFacebookRedirectLoginHelper($redirectUrl = null)
 {
     if ($redirectUrl == null) {
         $redirectUrl = Router::url(['controller' => 'Login', 'action' => 'facebook_login', 'plugin' => null], true);
     }
     return new FacebookRedirectLoginHelper($redirectUrl);
 }
 /**
  * Uploads a new file for the given FileField instance.
  *
  * @param string $name EAV attribute name
  * @throws \Cake\Network\Exception\NotFoundException When invalid slug is given,
  *  or when upload process could not be completed
  */
 public function upload($name)
 {
     $instance = $this->_getInstance($name);
     require_once Plugin::classPath('Field') . 'Lib/class.upload.php';
     $uploader = new \upload($this->request->data['Filedata']);
     if (!empty($instance->settings['extensions'])) {
         $exts = explode(',', $instance->settings['extensions']);
         $exts = array_map('trim', $exts);
         $exts = array_map('strtolower', $exts);
         if (!in_array(strtolower($uploader->file_src_name_ext), $exts)) {
             $this->_error(__d('field', 'Invalid file extension.'), 501);
         }
     }
     $response = '';
     $uploader->file_overwrite = false;
     $folder = normalizePath(WWW_ROOT . "/files/{$instance->settings['upload_folder']}/");
     $url = normalizePath("/files/{$instance->settings['upload_folder']}/", '/');
     $uploader->process($folder);
     if ($uploader->processed) {
         $response = json_encode(['file_url' => Router::url($url . $uploader->file_dst_name, true), 'file_size' => FileToolbox::bytesToSize($uploader->file_src_size), 'file_name' => $uploader->file_dst_name, 'mime_icon' => FileToolbox::fileIcon($uploader->file_src_mime)]);
     } else {
         $this->_error(__d('field', 'File upload error, details: {0}', $uploader->error), 502);
     }
     $this->viewBuilder()->layout('ajax');
     $this->title(__d('field', 'Upload File'));
     $this->set(compact('response'));
 }
 private function _parseItem($item, $options = array())
 {
     $template = $this->_defaultConfig['template'];
     if (isset($options['template'])) {
         $template['menuItem'] = $options['template'];
     }
     $active = false;
     $currentParams = $this->request->params;
     $url = $item['url'];
     if (is_array($url)) {
         if ($currentParams['plugin'] === @$url['plugin'] and $currentParams['controller'] === @$url['controller'] and $currentParams['action'] === @$url['action']) {
             $active = true;
         }
         $url = Router::url($url);
     }
     if ($active) {
         $itemResult = str_replace('{{url}}', $url, $template['menuItemActive']);
     } else {
         $itemResult = str_replace('{{url}}', $url, $template['menuItem']);
     }
     $itemResult = str_replace('{{text}}', $item['text'], $itemResult);
     if (isset($item['child'])) {
         $itemResult .= $this->_parseChildMenu($item['child']);
     }
     return $itemResult;
 }
Example #14
0
 public function setUri($uri)
 {
     if (is_array($uri)) {
         $uri = Router::url($uri);
     }
     return parent::setUri($uri);
 }
Example #15
0
 /**
  * Asserts that current url matches route.
  *
  * @param array|string $route Route's array or name.
  * @param array $params Extra route parameters (i.e. prefix, _method, etc.)
  */
 public function seeCurrentRouteIs($route, $params = [])
 {
     if (!is_array($route)) {
         $route = ['_name' => $route];
     }
     $this->seeCurrentUrlEquals(Router::url($route + $params));
 }
 public function testView()
 {
     $communitiesTable = TableRegistry::get('Communities');
     $community = $communitiesTable->find('all')->first();
     $this->get(Router::url(['controller' => 'Communities', 'action' => 'view', $community->id]));
     $this->assertResponseOk();
 }
Example #17
0
 protected function init()
 {
     require_once ROOT . DS . 'vendor' . DS . 'hybridauth' . DS . 'hybridauth' . DS . 'hybridauth' . DS . 'Hybrid' . DS . 'Auth.php';
     //D:\xampp\htdocs\libu\vendor\hybridauth\hybridauth\hybridauth\Hybrid
     $config = array("base_url" => Router::url("/social_endpoint", true), "debug_mode" => $this->debug_mode, "debug_file" => $this->debug_file, "providers" => array("Google" => array("enabled" => true, "keys" => array("id" => "384547532967-of8s1pp85dl90dafblfao29ll2qjeglr.apps.googleusercontent.com", "secret" => "tbJRI1QoEwJ5fa8ZfLjitnne")), "Facebook" => array("enabled" => true, "keys" => array("id" => "719642394849027", "secret" => "e6f3739977461ff0339d71ad50490f6d"), "trustForwarded" => false)));
     $this->hybridauth = new \Hybrid_Auth($config);
 }
 public function data_tables()
 {
     $current_developer = TableRegistry::get('Developers')->findById($this->request->session()->read('Developer.id'))->all()->first();
     $aColumns = ['report_id' => 'Reports.id', 'error_message' => 'Reports.error_message', 'error_name' => 'Reports.error_name', 'pma_version' => 'Reports.pma_version', 'exception_type' => 'Reports.exception_type', 'created_time' => 'Notifications.created'];
     $orderConditions = $this->OrderSearch->getOrder($aColumns);
     $searchConditions = $this->OrderSearch->getSearchConditions($aColumns);
     $aColumns['id'] = 'Notifications.id';
     $params = ['contain' => 'Reports', 'fields' => $aColumns, 'conditions' => ['AND' => [array('Notifications.developer_id ' => $current_developer['id']), $searchConditions]], 'order' => $orderConditions];
     //$current_developer = Sanitize::clean($current_developer);
     $pagedParams = $params;
     $pagedParams['limit'] = intval($this->request->query('iDisplayLength'));
     $pagedParams['offset'] = intval($this->request->query('iDisplayStart'));
     $rows = $this->Notifications->find('all', $pagedParams);
     //$rows = Sanitize::clean($rows);
     // Make the display rows array
     $dispRows = array();
     $tmp_row = array();
     foreach ($rows as $row) {
         $tmp_row[0] = '<input type="checkbox" name="notifs[]" value="' . $row['id'] . '"/>';
         $tmp_row[1] = '<a href="' . Router::url(array('controller' => 'reports', 'action' => 'view', $row['report_id'])) . '">' . $row['report_id'] . '</a>';
         $tmp_row[2] = $row['error_name'];
         $tmp_row[3] = $row['error_message'];
         $tmp_row[4] = $row['pma_version'];
         $tmp_row[5] = $row['exception_type'] ? 'php' : 'js';
         $tmp_row[6] = $row['created_time'];
         array_push($dispRows, $tmp_row);
     }
     $response = array('iTotalDisplayRecords' => count($dispRows), 'iTotalRecords' => $this->Notifications->find('all', $params)->count(), 'sEcho' => intval($this->request->query('sEcho')), 'aaData' => $dispRows);
     $this->autoRender = false;
     $this->response->body(json_encode($response));
     return $this->response;
 }
 /**
  * Edit an attachment.
  *
  * @return \Cake\Network\Response|void
  */
 public function edit()
 {
     $this->loadModel('BlogAttachments');
     $this->loadModel('BlogArticles');
     $attachment = $this->BlogAttachments->find()->where(['id' => $this->request->id])->first();
     //Check if the attachment is found.
     if (empty($attachment)) {
         $this->Flash->error(__d('admin', 'This attachment doesn\'t exist or has been deleted.'));
         return $this->redirect(['action' => 'index']);
     }
     if ($this->request->is(['put', 'post'])) {
         $this->BlogAttachments->patchEntity($attachment, $this->request->data());
         //Check if the article has already an attachment
         $article = $this->BlogArticles->find()->contain(['BlogAttachments'])->where(['BlogArticles.id' => $this->request->data['article_id']])->first();
         if (!is_null($article->blog_attachment) && $article->blog_attachment->id != $this->request->id) {
             $this->Flash->error(__d('admin', 'This article has already an attachment, you can edit it <a href="{0}" class="btn btn-sm btn-danger">here</a>.', Router::url(['_name' => 'attachments-edit', 'id' => $article->blog_attachment->id])));
             return $this->redirect(['action' => 'index']);
         }
         $attachment->user_id = $this->Auth->user('id');
         $attachment->accessible('url_file', true);
         if ($editedAttachment = $this->BlogAttachments->save($attachment)) {
             $file = new File(WWW_ROOT . $editedAttachment->url);
             $editedAttachment->name = $file->name;
             $editedAttachment->extension = '.' . $file->info()['extension'];
             $editedAttachment->size = $file->info()['filesize'];
             $this->BlogAttachments->save($editedAttachment);
             $this->Flash->success(__d('admin', 'Your attachment has been edited successfully !'));
             return $this->redirect(['action' => 'index']);
         }
     }
     $articles = $this->BlogAttachments->BlogArticles->find('list');
     $this->set(compact('attachment', 'articles'));
 }
Example #20
0
 public function reset_password()
 {
     // Se houver requisição POST
     if ($this->request->is(["post", "put"])) {
         // Pesquisa ator
         unset($this->request->data['role']);
         $where = $this->request->data;
         $atores_disponiveis = $this->getAtores($where);
         $tem_ator = false;
         foreach ($atores_disponiveis as $modelo => $atores) {
             $tem_ator = !empty($atores) ? true : $tem_ator;
         }
         // Se tiver ator
         if ($tem_ator) {
             $hash = base64_encode(serialize(['expiration_time' => new \DateTime('now'), 'username' => $this->request->data['username']]));
             // Enviar e-mail com URL com hash
             // Disparo de e-mail usando o template de trocar a senha
             $extra_data = ['user' => $this->request->data['username'], 'url' => Router::url(['controller' => 'authentication', 'action' => 'confirm_reset_password', '?' => ['token' => $hash]], true)];
             $user = (object) ['full_name' => $this->request->data['username'], 'username' => $this->request->data['username']];
             if ($this->dispararEmail(5, $user, $extra_data)) {
                 $this->Flash->success("E-mail com página para alterar senha enviado com sucesso.");
                 return $this->redirect(['action' => 'login']);
             }
         }
         // Se não tiver ator
         if (!$tem_ator) {
             $this->Flash->success("Não há atores com este e-mail.");
             return $this->redirect(['action' => 'login']);
         }
     } else {
         $this->Flash->success("Requisição inválida.");
         return $this->redirect(['action' => 'login']);
     }
 }
 public function sendMail()
 {
     $mailer = new Email();
     $mailer->transport('smtp');
     $email_to = '*****@*****.**';
     $replyToEmail = "*****@*****.**";
     $replyToEmailName = 'Info';
     $fromEmail = "*****@*****.**";
     $fromEmailName = "Xuan";
     $emailSubject = "Demo mail";
     //$view_link = Router::url('/', true);
     $params_name = 'XuanNguyen';
     $view_link = Router::url(['language' => $this->language, 'controller' => 'frontend', 'action' => 'view_email', 'confirmation', $params_name], true);
     $sentMailSatus = array();
     if (!empty($email_to)) {
         //emailFormat text, html or both.
         $mailer->template('content', 'template')->emailFormat('html')->subject($emailSubject)->viewVars(['data' => ['language' => $this->language, 'mail_template' => 'confirmation', 'email_vars' => ['view_link' => $view_link, 'name' => $params_name]]])->from([$fromEmail => $fromEmailName])->replyTo([$replyToEmail => $replyToEmailName])->to($email_to);
         if ($mailer->send()) {
             $sentMailSatus = 1;
         } else {
             $sentMailSatus = 0;
         }
     }
     pr($sentMailSatus);
     exit;
 }
    public function defineElfinderBrowser($return = false)
    {
        $url = Router::url('/cakephp-tinymce-elfinder/Elfinders/elfinder');
        $clientOptions = Configure::read('TinymceElfinder.client_options');
        $title = Configure::read('TinymceElfinder.title');
        $str = '
		<script type="text/javascript">
		function elFinderBrowser (field_name, url, type, win) {
			  tinymce.activeEditor.windowManager.open({
			    file: "' . $url . '",
			    title: "' . $title . '",
			    width: ' . ($clientOptions['width'] + 20) . ',  
			    height: ' . ($clientOptions['height'] + 50) . ',
			    resizable: "' . $clientOptions['resizable'] . '"
			  }, {
			    setUrl: function (url) {
			      win.document.getElementById(field_name).value = url;
			    }
			  });
			  return false;
			}
		</script>';
        if ($return) {
            return $str;
        } else {
            echo $str;
        }
    }
Example #23
0
 /**
  * send mail 
  * @param type $id
  * @param type $email
  * @param type $url
  * @param type $subject
  * @param type $body
  */
 public function send($id, $email, $url, $subject, $body)
 {
     $mail = new Email('default');
     $key = Configure::read('key.encrypt');
     $token = sha1($id . $key);
     $link = Router::url('/', true) . $url . '/' . $token;
     $mail->to($email)->subject($subject)->emailFormat("html")->send("<a href='" . $link . "'>" . $body . "<a>");
 }
 public function testResetPassword()
 {
     $userId = 1;
     $timestamp = time();
     $hash = Mailer::getPasswordResetHash($userId, $timestamp);
     $this->get(Router::url(['controller' => 'Users', 'action' => 'resetPassword', $userId, $timestamp, $hash]));
     $this->assertResponseOk();
 }
 /**
  * forgot password email
  *
  * @param  Event                  $cakeEvent The CakePHP event
  * @param  \App\Model\Entity\User $user      the user entity
  * @return void
  */
 public function onForgotPassword(Event $cakeEvent, \App\Model\Entity\User $user)
 {
     $hash = $this->Users->getHash($user);
     $token = $hash . strtotime('now');
     $restoreLink = Router::url(['plugin' => false, 'controller' => 'Login', 'action' => 'restorePassword', $user->id, $token], true);
     $data = ['locale' => 'de', 'recipient_user_id' => $user->id, 'transport' => 'email', 'config' => ['reset_password_link' => $restoreLink, 'user.salutation' => $user->salutation, 'user.fullname' => $user->full_name]];
     $notification = $this->NotificationQueue->createNotification('forgot_password', $data, true);
 }
Example #26
0
 /**
  * Generates the opauth callback url
  *
  * @return string Full translated URL with base path.
  */
 protected function _generateOpauthCompleteUrl()
 {
     $url = Configure::read('Opauth.complete_url');
     if (!is_array($url)) {
         $url = Router::parse($url);
     }
     $url['?'] = ['social' => $this->request->query('code')];
     return Router::url($url, true);
 }
Example #27
0
 /**
  * Adds Facebook tags
  * @return void
  * @uses MeCms\View\View\BaseView::_getTitleForLayout()
  * @uses MeTools\View\Helper\HtmlHelper::meta()
  */
 protected function _addFacebookTags()
 {
     $this->Html->meta(['content' => $this->_getTitleForLayout(), 'property' => 'og:title']);
     $this->Html->meta(['content' => Router::url(null, true), 'property' => 'og:url']);
     //Adds the app ID
     if (config('default.facebook_app_id')) {
         $this->Html->meta(['content' => config('default.facebook_app_id'), 'property' => 'fb:app_id']);
     }
 }
 public function login($provider = null)
 {
     if ($provider) {
         $config = ['path' => Router::url(['action' => 'login']) . '/', 'callback_url' => Router::url(['action' => 'callback']), 'security_salt' => Security::salt(), 'Strategy' => Configure::read('OpauthStrategy')];
         $opauth = new \Opauth($config, true);
     } else {
         throw new NotFoundException();
     }
 }
 /**
  * Redirect the client to the cookie authentication page. 
  * If a url is given, set Auth to return to that url after authentication.
  *
  * @param string $url The url to return the client to after authentication.
  */
 public function redirectToAuthenticationPage($url = null)
 {
     if ($url) {
         $this->Auth->redirectUrl($url);
     } else {
         $this->Auth->redirectUrl($this->request->here(false));
     }
     $this->controller->redirect(Router::url(['plugin' => 'Beskhue/CookieTokenAuth', 'controller' => 'CookieTokenAuth', '_base' => false]));
 }
Example #30
0
 /**
  * Parses url
  * @param string|array|null $url Url
  * @param array $options Options, for example `lastmod` or `priority`
  * @return array
  * @see Cake\Routing\Router::url()
  */
 protected static function parse($url, array $options = [])
 {
     if (!empty($options['lastmod'])) {
         $options['lastmod'] = $options['lastmod']->format('c');
     }
     if (empty($options['priority'])) {
         $options['priority'] = '0.5';
     }
     return am(['loc' => Router::url($url, true)], $options);
 }