public function associate() { $provider = $this->request->param('provider'); if (empty($provider)) { throw new NotFoundException('Invalid provider'); } $this->set(compact('provider')); if ($this->request->data('confirm_association')) { $this->User->recursive = -1; $originalUser = $this->User->findById($this->Auth->user('id')); $this->Session->write('Socialites.originalUser', $originalUser); switch ($provider) { case 'twitter': $eventName = 'Socialites.oauthAuthorize'; $event = Croogo::dispatchEvent($eventName, $this); return $this->redirect(); break; default: $config = Configure::read('Socialites.Providers.' . $provider); $fqcn = Configure::read('SocialitesProviderRegistry.' . $provider); $Provider = new $fqcn($config); return $this->redirect($Provider->getAuthorizationUrl()); break; } } else { if (!$this->Auth->user('id')) { $this->Session->setFlash(__d('socialites', 'You are not logged in'), 'flash'); return $this->redirect($this->referer()); } } }
public function admin_process() { $action = $this->request->data['Edition']['action']; $ids = array(); foreach ($this->request->data['Edition'] as $id => $value) { if ($id != 'action' && $value['id'] == 1) { $ids[] = $id; } } if (count($ids) == 0 || $action == null) { $this->Session->setFlash(__d('croogo', 'No items selected.'), 'default', array('class' => 'error')); $this->redirect(array('action' => 'index')); } $actionProcessed = $this->Edition->processAction($action, $ids); $eventName = 'Controller.Editions.after' . ucfirst($action); if ($actionProcessed) { switch ($action) { case 'delete': $messageFlash = __d('croogo', 'Edições excluidas!'); break; case 'publish': $messageFlash = __d('croogo', 'Edições publicadas!'); break; case 'unpublish': $messageFlash = __d('croogo', 'Edições despublicadas'); break; } $this->Session->setFlash($messageFlash, 'default', array('class' => 'success')); Croogo::dispatchEvent($eventName, $this, compact($ids)); } else { $this->Session->setFlash(__d('croogo', 'An error occurred.'), 'default', array('class' => 'error')); } $this->redirect(array('action' => 'index')); }
public function saveUrl($data) { $event = Croogo::dispatchEvent('Model.Node.beforeSaveNode', $this, compact('data')); $this->saveWithMeta($event->data['data']); $event = Croogo::dispatchEvent('Model.Node.afterSaveNode', $this, $event->data); return true; }
/** * Filter block shortcode in node body, eg [block:snippet] and replace it with * the block content * * @param CakeEvent $event * @return void */ public function filterBlockShortcode($event) { static $converter = null; if (!$converter) { $converter = new StringConverter(); } $View = $event->subject; $body = null; if (isset($event->data['content'])) { $body =& $event->data['content']; } elseif (isset($event->data['node'])) { $body =& $event->data['node'][key($event->data['node'])]['body']; } $parsed = $converter->parseString('block|b', $body, array('convertOptionsToArray' => true)); $regex = '/\\[(block|b):([A-Za-z0-9_\\-]*)(.*?)\\]/i'; foreach ($parsed as $blockAlias => $config) { $block = $View->Regions->block($blockAlias); preg_match_all($regex, $body, $matches); if (isset($matches[2][0])) { $replaceRegex = '/' . preg_quote($matches[0][0]) . '/'; $body = preg_replace($replaceRegex, $block, $body); } } Croogo::dispatchEvent('Helper.Layout.beforeFilter', $View, array('content' => &$body, 'options' => array())); }
/** * Test [vocabulary] shortcode */ public function testVocabularyShortcode() { $content = '[vocabulary:categories type="blog"]'; $this->View->viewVars['vocabularies_for_layout']['categories'] = array('Vocabulary' => array('id' => 1, 'title' => 'Categories', 'alias' => 'categories'), 'threaded' => array()); Croogo::dispatchEvent('Helper.Layout.beforeFilter', $this->View, array('content' => &$content)); $this->assertContains('vocabulary-1', $content); $this->assertContains('class="vocabulary"', $content); }
/** * Test [node] shortcode */ public function testNodeShortcode() { $content = '[node:recent_posts conditions="Node.type:blog" order="Node.id DESC" limit="5"]'; $this->View->viewVars['nodes_for_layout']['recent_posts'] = array(array('Node' => array('id' => 1, 'title' => 'Hello world', 'slug' => 'hello-world', 'type' => 'blog'))); Croogo::dispatchEvent('Helper.Layout.beforeFilter', $this->View, array('content' => &$content)); $this->assertContains('node-list-recent_posts', $content); $this->assertContains('class="node-list"', $content); }
/** * Test [menu] shortcode */ public function testMenuShortcode() { $content = '[menu:blogroll]'; $this->View->viewVars['menus_for_layout']['blogroll'] = array('Menu' => array('id' => 6, 'title' => 'Blogroll', 'alias' => 'blogroll'), 'threaded' => array()); Croogo::dispatchEvent('Helper.Layout.beforeFilter', $this->View, array('content' => &$content)); $this->assertContains('menu-6', $content); $this->assertContains('class="menu"', $content); }
public function beforeDelete($cascade = true) { if (!parent::beforeDelete($cascade)) { return false; } $Event = Croogo::dispatchEvent('FileStorage.beforeDelete', $this, array('cascade' => $cascade, 'adapter' => $this->field('adapter'))); if ($Event->isStopped()) { return false; } return true; }
/** * Gets valid statuses based on type * * @param string $type Status type if applicable * @return array Array of statuses */ public function status($statusType = 'publishing', $accessType = 'public') { $values = $this->_defaultStatus($statusType); $data = compact('statusType', 'accessType', 'values'); $event = Croogo::dispatchEvent('Croogo.Status.status', null, $data); if (array_key_exists('values', $event->data)) { return $event->data['values']; } else { return $values; } }
/** * testDispatchHelperEvents */ public function testDispatchHelperEvents() { $eventNames = array('Helper.Layout.afterFilter', 'Helper.Layout.beforeFilter'); App::uses('View', 'View'); $View = new View(); foreach ($eventNames as $name) { $event = Croogo::dispatchEvent($name, $View); $this->assertTrue($event->result, sprintf('Event: %s', $name)); $this->assertInstanceOf('View', $event->subject()); } }
/** * Test login succesfull event */ public function testLoginSuccessful() { $cookie = $this->autoLogin->readCookie('User'); $this->assertNull($cookie); $request = new CakeRequest(); $request->data = array('User' => array('username' => 'rchavik', 'password' => 'rchavik', 'remember' => true)); $this->controller->request = $request; $subject = $this->controller; $compare = $this->autoLogin->cookie($request); $_SERVER['REQUEST_METHOD'] = 'POST'; Croogo::dispatchEvent('Controller.Users.adminLoginSuccessful', $subject); $cookie = $this->autoLogin->readCookie('User'); $this->assertNotNull($cookie); $this->assertEquals($compare, $cookie); }
public function transform($markdownText) { $environment = Environment::createCommonMarkEnvironment(); $beforeParseEvent = Croogo::dispatchEvent('Helper.Markdown.beforeMarkdownParse', $this->_View, array('environment' => $environment, 'markdown' => $markdownText)); $markdownText = $beforeParseEvent->data['markdown']; $environment = $beforeParseEvent->data['environment']; $parser = new DocParser($environment); $htmlRenderer = new HtmlRenderer($environment); $documentAST = $parser->parse($markdownText); $beforeRenderEvent = Croogo::dispatchEvent('Helper.Markdown.beforeMarkdownRender', $this->_View, array('ast' => $documentAST)); $documentAST = $beforeRenderEvent->data['ast']; $rendered = $htmlRenderer->renderBlock($documentAST); $afterRenderEvent = Croogo::dispatchEvent('Helper.Markdown.afterMarkdownRender', $this->_View, array('rendered' => $rendered)); return $afterRenderEvent->data['rendered']; }
public function admin_restore_login() { $formerUser = $this->Session->read('Chameleon.User'); if (empty($formerUser)) { $this->Session->setFlash('Invalid request', 'flash', array('class' => 'error')); return $this->redirect('/'); } if ($this->Session->delete('Chameleon.User')) { Croogo::dispatchEvent('Controller.Users.adminLogoutSuccessful', $this); } Croogo::dispatchEvent('Controller.Chameleon.beforeAdminLogin', $this); if ($this->Auth->login($formerUser)) { Croogo::dispatchEvent('Controller.Users.adminLoginSuccessful', $this); return $this->redirect(Configure::read('Croogo.dashboardUrl')); } }
/** * Gets the dashboard markup * * @return string */ public function dashboards() { $registered = Configure::read('Dashboards'); $userId = AuthComponent::user('id'); if (empty($userId)) { return ''; } $columns = array(CroogoDashboard::LEFT => array(), CroogoDashboard::RIGHT => array(), CroogoDashboard::FULL => array()); if (empty($this->Role)) { $this->Role = ClassRegistry::init('Users.Role'); $this->Role->Behaviors->attach('Croogo.Aliasable'); } $currentRole = $this->Role->byId($this->Layout->getRoleId()); $cssSetting = $this->Layout->themeSetting('css'); if (!empty($this->_View->viewVars['boxes_for_dashboard'])) { $boxesForLayout = Hash::combine($this->_View->viewVars['boxes_for_dashboard'], '{n}.DashboardsDashboard.alias', '{n}.DashboardsDashboard'); $dashboards = array(); $registeredUnsaved = array_diff_key($registered, $boxesForLayout); foreach ($boxesForLayout as $alias => $userBox) { if (isset($registered[$alias]) && $userBox['status']) { $dashboards[$alias] = array_merge($registered[$alias], $userBox); } } $dashboards = Hash::merge($dashboards, $registeredUnsaved); $dashboards = Hash::sort($dashboards, '{s}.weight', 'ASC'); } else { $dashboards = Hash::sort($registered, '{s}.weight', 'ASC'); } foreach ($dashboards as $alias => $dashboard) { if ($currentRole != 'admin' && !in_array($currentRole, $dashboard['access'])) { continue; } $opt = array('alias' => $alias, 'dashboard' => $dashboard); Croogo::dispatchEvent('Croogo.beforeRenderDashboard', $this->_View, compact('alias', 'dashboard')); $dashboardBox = $this->_View->element('Extensions.admin/dashboard', $opt); Croogo::dispatchEvent('Croogo.afterRenderDashboard', $this->_View, compact('alias', 'dashboard', 'dashboardBox')); if ($dashboard['column'] === false) { $dashboard['column'] = count($columns[0]) <= count($columns[1]) ? CroogoDashboard::LEFT : CroogoDashboard::RIGHT; } $columns[$dashboard['column']][] = $dashboardBox; } $dashboardTag = $this->settings['dashboardTag']; $columnDivs = array(0 => $this->Html->tag($dashboardTag, implode('', $columns[CroogoDashboard::LEFT]), array('class' => $cssSetting['dashboardLeft'] . ' ' . $cssSetting['dashboardClass'], 'id' => 'column-0')), 1 => $this->Html->tag($dashboardTag, implode('', $columns[CroogoDashboard::RIGHT]), array('class' => $cssSetting['dashboardRight'] . ' ' . $cssSetting['dashboardClass'], 'id' => 'column-1'))); $fullDiv = $this->Html->tag($dashboardTag, implode('', $columns[CroogoDashboard::FULL]), array('class' => $cssSetting['dashboardFull'] . ' ' . $cssSetting['dashboardClass'], 'id' => 'column-2')); return $this->Html->tag('div', $fullDiv, array('class' => $cssSetting['row'])) . $this->Html->tag('div', implode('', $columnDivs), array('class' => $cssSetting['row'])); }
public function register() { if (!$this->request->is('post')) { return; } $customerUserId = $this->CustomerUser->Customer->createWithUser($this->request->data); if (!$customerUserId) { Croogo::dispatchEvent('Controller.Users.registrationFailure', $this); $this->Session->setFlash(__d('croogo', 'The User could not be saved. Please, try again.'), 'flash', array('class' => 'error')); return; } $customerUser = $this->CustomerUser->find('first', array('conditions' => array('CustomerUser.id' => $customerUserId), 'recursive' => -1)); $user = $this->CustomerUser->User->read(null, $customerUser['CustomerUser']['user_id']); Croogo::dispatchEvent('Controller.Users.registrationSuccessful', $this); $this->_sendEmail(array(Configure::read('Site.title'), $this->_getSenderEmail()), $user['User']['email'], __d('croogo', '[%s] Please activate your account', Configure::read('Site.title')), 'Users.register', 'user activation', $this->theme, array('user' => $user)); $this->Session->setFlash(__d('croogo', 'You have successfully registered an account. An email has been sent with further instructions.'), 'flash', array('class' => 'success')); $this->redirect(array('plugin' => 'users', 'controller' => 'users', 'action' => 'login')); return; }
public function resize($path, $width, $height, $options = array(), $htmlAttributes = array(), $return = false) { $filename = basename($path); $uploadsDir = dirname(basename($path)); if ($uploadsDir === '.') { $uploadsDir = ''; } $cacheDir = dirname($path); $options = Hash::merge(array('aspect' => true, 'adapter' => false, 'cacheDir' => $cacheDir, 'uploadsDir' => $uploadsDir), $options); $adapter = $options['adapter']; if ($adapter === 'LegacyLocalAttachment') { $options['cacheDir'] = 'resized'; $options['resizedInd'] = '.resized-'; $options['uploadsDir'] = 'uploads'; } $result = parent::resize($path, $width, $height, $options, $htmlAttributes, $return); $data = compact('result', 'path', 'width', 'height', 'aspect', 'htmlAttributes', 'adapter'); Croogo::dispatchEvent('Assets.AssetsImageHelper.resize', $this->_View, $data); return $result; }
/** * Show Block * * By default block is rendered using Blocks.block element. If `Block.element` is * set and exists, the render process will pass it through given element before wrapping * it inside the Blocks.block container. You disable the wrapping by setting * `enclosure=false` in the `params` field. * * @param string $blockAlias Block alias * @param array $options * @return string */ public function block($blockAlias, $options = array()) { $output = ''; if (!$blockAlias) { return $output; } $options = Hash::merge(array('elementOptions' => array()), $options); $elementOptions = $options['elementOptions']; $defaultElement = 'Blocks.block'; $blocks = Hash::combine($this->_View->viewVars['blocks_for_layout'], '{s}.{n}.Block.alias', '{s}.{n}'); if (!isset($blocks[$blockAlias])) { return $output; } $block = $blocks[$blockAlias]; $element = $block['Block']['element']; $exists = $this->_View->elementExists($element); $blockOutput = ''; Croogo::dispatchEvent('Helper.Regions.beforeSetBlock', $this->_View, array('content' => &$block['Block']['body'])); if ($exists) { $blockOutput = $this->_View->element($element, compact('block'), $elementOptions); } else { if (!empty($element)) { $this->log(sprintf('Missing element `%s` in block `%s` (%s)', $block['Block']['element'], $block['Block']['alias'], $block['Block']['id']), LOG_WARNING); } $blockOutput = $this->_View->element($defaultElement, compact('block'), array('ignoreMissing' => true) + $elementOptions); } Croogo::dispatchEvent('Helper.Regions.afterSetBlock', $this->_View, array('content' => &$blockOutput)); $enclosure = isset($block['Params']['enclosure']) ? $block['Params']['enclosure'] === "true" : true; if ($exists && $element != $defaultElement && $enclosure) { $block['Block']['body'] = $blockOutput; $block['Block']['element'] = null; $output .= $this->_View->element($defaultElement, compact('block'), $elementOptions); } else { $output .= $blockOutput; } return $output; }
/** * View * * @param string $alias * @return void * @access public * @throws NotFoundException */ public function view($alias = null) { if (!$alias) { $alias = 'contact'; } $contact = $this->Contact->find('first', array('conditions' => array('Contact.alias' => $alias, 'Contact.status' => 1), 'cache' => array('name' => $alias, 'config' => 'contacts_view'))); if (!isset($contact['Contact']['id'])) { throw new NotFoundException(); } $this->set('contact', $contact); $continue = true; if (!$contact['Contact']['message_status']) { $continue = false; } if (!empty($this->request->data) && $continue === true) { $this->request->data['Message']['contact_id'] = $contact['Contact']['id']; $this->request->data['Message']['title'] = htmlspecialchars($this->request->data['Message']['title']); $this->request->data['Message']['name'] = htmlspecialchars($this->request->data['Message']['name']); $this->request->data['Message']['body'] = htmlspecialchars($this->request->data['Message']['body']); Croogo::dispatchEvent('Controller.Contacts.beforeMessage', $this); $continue = $this->_spam_protection($continue, $contact); $continue = $this->_captcha($continue, $contact); $continue = $this->_validation($continue, $contact); $continue = $this->_send_email($continue, $contact); $this->set(compact('continue')); if ($continue === true) { Croogo::dispatchEvent('Controller.Contacts.afterMessage', $this); $this->Session->setFlash(__d('croogo', 'Your message has been received...'), 'flash', array('class' => 'success')); return $this->Croogo->redirect('/'); } } else { $this->Croogo->setReferer(); } $this->Croogo->viewFallback(array('view_' . $contact['Contact']['id'], 'view_' . $contact['Contact']['alias'])); $this->set('title_for_layout', $contact['Contact']['title']); }
/** * Logout * * @return void * @access public */ public function logout() { Croogo::dispatchEvent('Controller.Users.beforeLogout', $this); $this->Session->setFlash(__d('croogo', 'Log out successful.'), 'flash', array('class' => 'success')); $redirect = $this->Auth->logout(); Croogo::dispatchEvent('Controller.Users.afterLogout', $this); return $this->redirect($redirect); }
/** * Admin process * * @return void * @access public */ public function admin_process() { $action = $this->request->data['Node']['action']; $ids = array(); foreach ($this->request->data['Node'] as $id => $value) { if ($id != 'action' && $value['id'] == 1) { $ids[] = $id; } } if (count($ids) == 0 || $action == null) { $this->Session->setFlash(__('No items selected.'), 'default', array('class' => 'error')); $this->redirect(array('action' => 'index')); } if ($action == 'delete' && $this->Node->deleteAll(array('Node.id' => $ids), true, true)) { Croogo::dispatchEvent('Controller.Nodes.afterDelete', $this, compact($ids)); $this->Session->setFlash(__('Nodes deleted.'), 'default', array('class' => 'success')); } elseif ($action == 'publish' && $this->Node->updateAll(array('Node.status' => 1), array('Node.id' => $ids))) { Croogo::dispatchEvent('Controller.Nodes.afterPublish', $this, compact($ids)); $this->Session->setFlash(__('Nodes published'), 'default', array('class' => 'success')); } elseif ($action == 'unpublish' && $this->Node->updateAll(array('Node.status' => 0), array('Node.id' => $ids))) { Croogo::dispatchEvent('Controller.Nodes.afterUnpublish', $this, compact($ids)); $this->Session->setFlash(__('Nodes unpublished'), 'default', array('class' => 'success')); } elseif ($action == 'promote' && $this->Node->updateAll(array('Node.promote' => 1), array('Node.id' => $ids))) { Croogo::dispatchEvent('Controller.Nodes.afterPromote', $this, compact($ids)); $this->Session->setFlash(__('Nodes promoted'), 'default', array('class' => 'success')); } elseif ($action == 'unpromote' && $this->Node->updateAll(array('Node.promote' => 0), array('Node.id' => $ids))) { Croogo::dispatchEvent('Controller.Nodes.afterUnpromote', $this, compact($ids)); $this->Session->setFlash(__('Nodes unpromoted'), 'default', array('class' => 'success')); } else { $this->Session->setFlash(__('An error occurred.'), 'default', array('class' => 'error')); } $this->redirect(array('action' => 'index')); }
/** * Logout * * @return void * @access public */ public function logout() { Croogo::dispatchEvent('Controller.Users.beforeLogout', $this); $this->Session->setFlash(__('Log out successful.'), 'default', array('class' => 'success')); $this->redirect($this->Auth->logout()); Croogo::dispatchEvent('Controller.Users.afterLogout', $this); }
/** * Plugins */ $aclPlugin = Configure::read('Site.acl_plugin'); $pluginBootstraps = Configure::read('Hook.bootstraps'); $plugins = array_filter(explode(',', $pluginBootstraps)); if (!in_array($aclPlugin, $plugins)) { $plugins = Hash::merge((array) $aclPlugin, $plugins); } foreach ($plugins as $plugin) { $pluginName = Inflector::camelize($plugin); $pluginPath = APP . 'Plugin' . DS . $pluginName; if (!file_exists($pluginPath)) { $pluginFound = false; foreach (App::path('Plugin') as $path) { if (is_dir($path . $pluginName)) { $pluginFound = true; break; } } if (!$pluginFound) { CakeLog::error('Plugin not found during bootstrap: ' . $pluginName); continue; } } $option = array($pluginName => array('bootstrap' => true, 'routes' => true, 'ignoreMissing' => true)); CroogoPlugin::load($option); } CroogoEventManager::loadListeners(); Croogo::dispatchEvent('Croogo.bootstrapComplete');
protected function _loginUser($controller) { Croogo::dispatchEvent('Controller.Users.beforeLogin', $controller); $user = $controller->Session->read('Socialites.newUser.user'); if (!empty($user['User'])) { $user = $user['User']; } if (!empty($user) && $controller->Auth->login($user)) { Croogo::dispatchEvent('Controller.Users.loginSuccessful', $controller); return $controller->redirect($controller->Auth->redirectUrl()); } else { Croogo::dispatchEvent('Controller.Users.loginFailure', $controller); return $controller->redirect($controller->Auth->loginAction); } }
/** * Create/update a Node record * * @param $data array Node data * @param $typeAlias string Node type alias * @return mixed see Model::saveAll() */ public function saveNode($data, $typeAlias = self::DEFAULT_TYPE) { $result = false; $data = $this->formatData($data, $typeAlias); $event = Croogo::dispatchEvent('Model.Node.beforeSaveNode', $this, compact('data', 'typeAlias')); if (!$event->result) { return $event->result; } if (empty($event->data['data'][$this->alias]['path'])) { $event->data['data'][$this->alias]['path'] = $this->_getNodeRelativePath($event->data['data']); } $result = $this->saveAll($event->data['data']); Croogo::dispatchEvent('Model.Node.afterSaveNode', $this, $event->data); return $result; }
/** * Filter content * * Replaces bbcode-like element tags * * @param string $content content * @return string */ public function filter($content, $options = array()) { Croogo::dispatchEvent('Helper.Layout.beforeFilter', $this->_View, array('content' => &$content, 'options' => $options)); $content = $this->filterElements($content, $options); Croogo::dispatchEvent('Helper.Layout.afterFilter', $this->_View, array('content' => &$content, 'options' => $options)); return $content; }
public function admin_link_chooser() { Croogo::dispatchEvent('Controller.Links.setupLinkChooser', $this); $linkChoosers = Configure::read('Menus.linkChoosers'); $this->set(compact('linkChoosers')); }
/** * Set current Node * * @param array $node * @return void */ public function set($node) { $event = Croogo::dispatchEvent('Helper.Nodes.beforeSetNode', $this->_View, array('node' => $node)); $this->node = $event->data['node']; $this->Layout->hook('afterSetNode'); Croogo::dispatchEvent('Helper.Nodes.afterSetNode', $this->_View, array('node' => $this->node)); }
/** * Admin edit * * @param integer $id * @return void * @access public */ public function admin_edit($id = null) { if (!$id && empty($this->request->data)) { $this->Session->setFlash(__d('croogo', 'Invalid content'), 'flash', array('class' => 'error')); return $this->redirect(array('action' => 'index')); } $Node = $this->{$this->modelClass}; $Node->id = $id; $typeAlias = $Node->field('type'); $type = $Node->Taxonomy->Vocabulary->Type->findByAlias($typeAlias); if (!empty($this->request->data)) { if ($Node->saveNode($this->request->data, $typeAlias)) { Croogo::dispatchEvent('Controller.Nodes.afterEdit', $this, compact('data')); $this->Session->setFlash(__d('croogo', '%s has been saved', $type['Type']['title']), 'flash', array('class' => 'success')); $this->Croogo->redirect(array('action' => 'edit', $Node->id)); } else { $this->Session->setFlash(__d('croogo', '%s could not be saved. Please, try again.', $type['Type']['title']), 'flash', array('class' => 'error')); } } if (empty($this->request->data)) { $this->Croogo->setReferer(); $data = $Node->read(null, $id); if (empty($data)) { throw new NotFoundException('Invalid id: ' . $id); } $data['Role']['Role'] = $Node->decodeData($data[$Node->alias]['visibility_roles']); $this->request->data = $data; } $this->set('title_for_layout', __d('croogo', 'Edit %s: %s', $type['Type']['title'], $this->request->data[$Node->alias]['title'])); $this->_setCommonVariables($type); }
/** * beforeFilter * * @return void * @throws MissingComponentException */ public function beforeFilter() { parent::beforeFilter(); $aclFilterComponent = Configure::read('Site.acl_plugin') . 'Filter'; if (empty($this->{$aclFilterComponent})) { throw new MissingComponentException(array('class' => $aclFilterComponent)); } $this->{$aclFilterComponent}->auth(); $this->RequestHandler->setContent('json', array('text/x-json', 'application/json')); if (!$this->request->is('api')) { $this->Security->blackHoleCallback = 'securityError'; $this->Security->requirePost('admin_delete'); } if ($this->RequestHandler->isAjax()) { $this->layout = 'ajax'; } if (!isset($this->request->params['admin']) && Configure::read('Site.status') == 0 && $this->Auth->user('role_id') != 1) { if (!$this->request->is('whitelisted')) { $this->layout = 'maintenance'; $this->response->statusCode(503); $this->set('title_for_layout', __d('croogo', 'Site down for maintenance')); $this->render('../Elements/blank'); } } if (isset($this->request->params['locale'])) { Configure::write('Config.language', $this->request->params['locale']); } if (isset($this->request->params['admin'])) { Croogo::dispatchEvent('Croogo.beforeSetupAdminData', $this); } }
/** * Create/update a Node record * * @param $data array Node data * @param $typeAlias string Node type alias * @return mixed see Model::saveAll() * @see MetaBehavior::saveWithMeta() */ public function saveNode($data, $typeAlias = self::DEFAULT_TYPE) { $result = false; $data = $this->formatData($data, $typeAlias); $event = Croogo::dispatchEvent('Model.Node.beforeSaveNode', $this, compact('data')); $result = $this->saveWithMeta($event->data['data']); Croogo::dispatchEvent('Model.Node.afterSaveNode', $this, $event->data); return $result; }