/** * undocumented function * * @return void * @access public */ function admin_stats_erronous() { $conditions = $this->Session->read('transactions_filter_conditions'); $erronousCount = $this->Transaction->find('count', array('conditions' => am($conditions, array('Transaction.status' => 'error')))); $notErronousCount = $this->Transaction->find('count', array('conditions' => am($conditions, array('Transaction.status <>' => 'error')))); $this->set(compact('erronousCount', 'notErronousCount')); }
/** * Lists posts for a category * @param string $slug Category slug * @return \Cake\Network\Response|null|void * @throws RecordNotFoundException */ public function view($slug = null) { //The category can be passed as query string, from a widget if ($this->request->query('q')) { return $this->redirect([$this->request->query('q')]); } $page = $this->request->query('page') ? $this->request->query('page') : 1; //Sets the cache name $cache = sprintf('category_%s_limit_%s_page_%s', md5($slug), $this->paginate['limit'], $page); //Tries to get data from the cache list($posts, $paging) = array_values(Cache::readMany([$cache, sprintf('%s_paging', $cache)], $this->PostsCategories->cache)); //If the data are not available from the cache if (empty($posts) || empty($paging)) { $query = $this->PostsCategories->Posts->find('active')->select(['id', 'title', 'subtitle', 'slug', 'text', 'created'])->contain(['Categories' => function ($q) { return $q->select(['id', 'title', 'slug']); }, 'Tags' => function ($q) { return $q->order(['tag' => 'ASC']); }, 'Users' => function ($q) { return $q->select(['first_name', 'last_name']); }])->where(['Categories.slug' => $slug])->order([sprintf('%s.created', $this->PostsCategories->Posts->alias()) => 'DESC']); if ($query->isEmpty()) { throw new RecordNotFoundException(__d('me_cms', 'Record not found')); } $posts = $this->paginate($query)->toArray(); //Writes on cache Cache::writeMany([$cache => $posts, sprintf('%s_paging', $cache) => $this->request->param('paging')], $this->PostsCategories->cache); //Else, sets the paging parameter } else { $this->request->params['paging'] = $paging; } $this->set(am(['category' => $posts[0]->category], compact('posts'))); }
/** * ブログ記事一覧出力 * ページ編集画面等で利用する事ができる。 * 利用例: <?php $baser->blogPosts('news', 3) ?> * ビュー: app/webroot/themed/{テーマ名}/blog/{コンテンツテンプレート名}/posts.ctp * * @param int $contentsName * @param int $num * @param array $options * @param mixid $mobile '' / boolean * @return void * @access public */ function blogPosts($contentsName, $num = 5, $options = array()) { $_options = array('category' => null, 'tag' => null, 'year' => null, 'month' => null, 'day' => null, 'id' => null, 'keyword' => null, 'template' => null); $options = am($_options, $options); $BlogContent = ClassRegistry::init('Blog.BlogContent'); $id = $BlogContent->field('id', array('BlogContent.name' => $contentsName)); $url = array('plugin' => 'blog', 'controller' => 'blog', 'action' => 'posts'); $settings = Configure::read('AgentSettings'); foreach ($settings as $key => $setting) { if (isset($options[$key])) { $agentOn = $options[$key]; unset($options[$key]); } else { $agentOn = Configure::read('AgentPrefix.currentAgent') == $key; } if ($agentOn) { $url['prefix'] = $setting['prefix']; break; } } if (isset($options['templates'])) { $templates = $options['templates']; } else { $templates = 'posts'; } unset($options['templates']); echo $this->requestAction($url, array('return', 'pass' => array($id, $num, $templates), 'named' => $options)); }
function ajax_menu_add($pid = null, $edit = false) { $this->loadModel('Link'); if (!empty($this->data)) { Configure::write('debug', 0); $this->RequestHandler->setContent('json', 'text/x-json'); if ($this->data['Link']['path']) { $path = explode('/', $this->data['Link']['path']); $this->data['Link']['controller'] = $path[0]; $this->data['Link']['action'] = $path[1]; } if ($this->Link->save($this->data)) { $response['error'] = array("code" => 0); $response['redirect'] = array('action' => 'menu'); } else { $errorMessages = $this->validateErrors($this->Link); $response['error'] = array("code" => 1, "messages" => $errorMessages); $response['redirect'] = array('action' => 'menu'); } $this->set(compact("response")); $this->render('message'); } else { $reservedLinks = $this->Link->find('all', array('recursive' => -1)); $actions = $this->JvUtil->listActions($reservedLinks); $path = ""; if ($edit) { $this->data = $this->Link->read(null, $pid); $pid = $this->data['Link']['parent_id']; $path = $this->data['Link']['controller'] . "/" . $this->data['Link']['action']; $actions = am($actions, array($path => $path)); } $this->set(compact("pid", "actions", "edit", "path")); } }
function view($id = null) { if (!$id) { $this->Session->setFlash('Invalid Customer.'); $this->redirect('/customers/'); } $conditions = am(array('Customer.id' => $id), $this->generateConditions($this->Customer, null, null, null, 'findWithService')); if ($this->permissionsStatus['admin']) { $customer = $this->Customer->findWithService($conditions); } elseif ($this->permissionsStatus['owner']) { $customer = $this->Customer->findWithService($conditions); } else { $this->viewPath = 'errors'; $this->render('not_authorised'); return true; } if (!empty($customer)) { $this->set('customer', $customer); $this->pageTitle = "{$customer['Customer']['company_name']} | Customer"; } else { $this->viewPath = 'errors'; $this->render('not_found'); return true; } }
function beforeRender() { $user = $this->ZTAuth->user(); $group = $this->Group->findById($user['User']['group_id']); if (!empty($user)) { $this->set('logined', '1'); $this->set('group', $group['Group']['user_status']); $this->set('group_style', $group['Group']['status_style']); $this->set('username', $user['User']['username']); $this->set('avatar', $user['User']['avatar']); $this->set('uploaded', $user['User']['uploaded']); $this->set('downloaded', $user['User']['downloaded']); $this->User->save(array('id' => $user['User']['id'], 'last_access' => date("Y-m-d H:i:s"))); } else { $this->set('logined', '0'); } if ($this->name != 'CakeError') { $this->set('UserMenu', $this->Sideblock->fetchUserMenu()); $this->set('OnlineUsers', $this->Onlineblock->fetchOnlineBlock()); $this->set('Stats', $this->Sideblock->fetchStats()); $this->data = am($this->data, array('Menu' => $this->Menu->fetchData(&$this))); } else { $this->layout = '2col_layout'; } }
/** * undocumented function * * @return void * @access public */ function admin_index() { Assert::true(User::allowed($this->name, $this->action), '403'); $defaults = array('model' => null, 'user_id' => null, 'my_limit' => 20, 'custom_limit' => false, 'start_date_day' => '01', 'start_date_year' => date('Y'), 'start_date_month' => '01', 'end_date_day' => '31', 'end_date_year' => date('Y'), 'end_date_month' => '12'); $params = am($defaults, $this->params['url'], $this->params['named']); unset($params['ext']); unset($params['url']); if (is_numeric($params['custom_limit'])) { if ($params['custom_limit'] > 75) { $params['custom_limit'] = 75; } if ($params['custom_limit'] == 0) { $params['custom_limit'] = 50; } $params['my_limit'] = $params['custom_limit']; } $conditions = array(); if (!empty($params['model'])) { $conditions['Log.model'] = $params['model']; } if (!empty($params['user_id'])) { $conditions['Log.user_id'] = $params['user_id']; } $conditions = $this->Log->dateRange($conditions, $params, 'created'); $this->Session->write('logs_filter_conditions', $conditions); $userOptions = ClassRegistry::init('User')->find('list', array('conditions' => array('User.office_id' => $this->Session->read('Office.id')))); $this->paginate['Log'] = array('conditions' => $conditions, 'contain' => array('User', 'Gift', 'Transaction'), 'limit' => $params['my_limit'], 'order' => array('Log.continuous_id' => 'desc')); $logs = $this->paginate($this->Log); $this->set(compact('logs', 'params', 'userOptions')); }
/** * initialize * * @param &$controller * @param $settings * @return */ function initialize(&$controller, $settings = array()) { $this->settings = am($this->settings, $settings); $this->params = $controller->params; $this->emoji = HTML_Emoji::getInstance(); $this->emoji->setImageUrl(Router::url('/') . 'yak/img/'); if (!Configure::read('Yak.save')) { Configure::write('Yak.save', Configure::read('Session.save')); } if ($this->settings['enabled']) { $path = '../plugins/yak/config/session'; do { $config = CONFIGS . $path . '.php'; if (is_file($config)) { break; } $path = '../../plugins/yak/config/session'; $config = CONFIGS . $path . '.php'; if (is_file($config)) { break; } trigger_error(__("Can't find yak session file.", true), E_USER_ERROR); } while (false); Configure::write('Session.save', $path); } }
/** * */ function __resortLangs() { $langs = Configure::read('I18n.Langs'); $locale = Configure::read("I18n.Locale"); $ordered[$locale] = $langs[$locale]; Configure::write("I18n.Langs", am($ordered, array_diff($langs, $ordered))); }
/** * Envía un mensaje de notificación al view. * * @param string $message Mensaje de notificación que se envía. * @param string $type Tipo de mensaje (info,warning,success,error). * @param array $options Lista de opciones HTML * @access public * @return void */ function send($message, $type = null, $options = array()) { if (is_array($type)) { $options = $type; if (isset($options['type'])) { $type = $options['type']; unset($options['type']); } else { $type = null; } } if (empty($type)) { $type = 'info'; } $options['class'] = empty($options['class']) ? $type : $options['class'] . ' ' . $type; if ($this->RequestHandler->isAjax()) { $id = 'flashMessage'; $options = am($options, compact('message', 'type', 'id')); $notice = array(); foreach ($options as $key => $value) { $notice[] = "'{$key}':'{$value}'"; } header(sprintf('X-Notifier: {%s}', implode(',', $notice))); } else { $this->Session->setFlash($message, 'notifier', $options); } }
/** * Setup * * @param AppModel $model * @param array $settings */ public function setup(&$model, $settings = array()) { if (!isset($this->settings[$model->alias])) { $this->settings[$model->alias] = $this->defaults; } $this->settings[$model->alias] = am($this->settings[$model->alias], empty(is_array($settings)) ? $settings : array()); }
public function beforeFilter() { SlConfigure::setCollections(); if (isset($this->data[$this->modelClass]['id'])) { $this->id = $this->data[$this->modelClass]['id']; } elseif (isset($this->params['pass'][0])) { $this->id = $this->params['pass'][0]; } if (!empty($this->params['named']['ref'])) { SlSession::write('Routing.ref', base64_decode($this->params['named']['ref'])); } // Make AJAX errors and warnings readable if (class_exists('Debugger')) { if ($this->RequestHandler->isAjax()) { Debugger::output('base'); } } // update current language if (!empty($this->params['named']['lang'])) { $this->params['lang'] =& $this->params['named']['lang']; } if (!empty($this->params['lang'])) { Sl::setLocale($this->params['lang'], true); } $languages = SlConfigure::read('I18n.languages'); $currLang = SlConfigure::read('I18n.lang'); $languageLinks = array(); foreach ($languages as $lang => $language) { $languageLinks[$lang] = array('title' => $language, 'active' => $lang == $currLang, 'url' => am($this->passedArgs, array('action' => $this->action, 'lang' => $lang))); } SlConfigure::write('Navigation.languages', $languageLinks); }
/** * Create Login Button * * @param $elementId * @param $options * @deprecated * TODO: not testing */ public function connectButton($elementId = 'login', $options = array()) { $defaults = array('size' => 'large', 'createElement' => true, 'authComplete' => 'location.reload();', 'signOut' => '', 'callbackUrl' => null); extract(am($defaults, $options)); $out = ''; // -- create element if ($createElement) { $out = $this->Html->tag('span', '', array('id' => $elementId)); } // -- modifiy callback functions $authComplete = trim($authComplete); if (!preg_match('/^function/', $authComplete)) { $authComplete = "function (user) { {$authComplete} }"; } $signOut = trim($signOut); if (!preg_match('/^function/', $signOut)) { $signOut = "function () { {$signOut} }"; } // -- modify callback Url if (!empty($callbackUrl)) { $callbackUrl = "twttr.anywhere.config({ callbackURL: '{$this->url($callbackUrl, true)}' });"; } /// -- logout if (empty($logout)) { $logout = '<button type="button">Logout</button>'; } $out .= $this->Html->scriptBlock("\n twttr.anywhere(function (T) {\n\n {$callbackUrl}\n\n if (T.isConnected()) {\n \$('#{$elementId}').html('{$logout}');\n \$('#{$elementId}').children().click(function(){ twttr.anywhere.signOut(); location.reload(); return false; });\n } else {\n T('#{$elementId}').connectButton({\n size: '{$size}',\n authComplete: {$authComplete},\n signOut: {$signOut}\n });\n }\n });\n "); return $out; }
function __construct($options = array()) { parent::__construct($options); $defaultOptions = array('type' => 'max', 'size' => 4 * MB); $options = am($defaultOptions, $options); $this->options = $options; }
function getSellers($options = null) { $_options = array('conditions' => array('active' => 1), 'fields' => array('id', 'name'), 'contain' => array()); $options = am($_options, $options); $sellers = $this->find('all', $options); return $sellers; }
public function anti_spam_login() { global $log; $log->lwrite($_SERVER['HTTP_USER_AGENT']); $client_agent = $_SERVER['HTTP_USER_AGENT']; if (preg_match('/windows 2000/', $client_agent)) { header("Location:" . URL); exit; } $temp = explode('(', $client_agent); $Part = $temp[0]; $ext_info = $temp[1]; $ext_info = explode(')', $ext_info); $temp = explode(';', trim($ext_info[0])); $r_info = array(); if (!empty($ext_info[1])) { $r_info = trim($ext_info[1]); $r_info = explode(" ", $r_info); } $temp = array_filter($temp); $browser_info = am($Part, $temp, $r_info); $ext_len = count($browser_info); if ($ext_len < ANTI_LEVEL) { header("Location:" . URL); exit; } }
/** * レイアウトテンプレートを取得 * コンボボックスのソースとして利用 * * @return array レイアウトの一覧データ */ public function getTemplates() { $templatesPathes = array(); if ($this->BcBaser->siteConfig['theme']) { $templatesPathes[] = WWW_ROOT . 'theme' . DS . $this->BcBaser->siteConfig['theme'] . DS . 'Feed' . DS; } $templatesPathes[] = BASER_PLUGINS . 'Feed' . DS . 'View' . DS . 'Feed' . DS; $_templates = array(); foreach ($templatesPathes as $templatesPath) { $folder = new Folder($templatesPath); $files = $folder->read(true, true); $foler = null; if ($files[1]) { if ($_templates) { $_templates = am($_templates, $files[1]); } else { $_templates = $files[1]; } } } $templates = array(); foreach ($_templates as $template) { $ext = Configure::read('BcApp.templateExt'); if ($template != 'ajax' . $ext && $template != 'error' . $ext) { $template = basename($template, $ext); $templates[$template] = $template; } } return $templates; }
/** * initialize * * If debug is off the component will be disabled and not do any further time tracking * or load the toolbar helper. * * @return bool **/ function initialize(&$controller, $settings) { $this->settings = am($this->settings, $settings); if (!Configure::read('debug') && empty($this->settings['forceEnable'])) { $this->enabled = false; return false; } if ($this->settings['autoRun'] == false && !isset($controller->params['url']['debug'])) { $this->enabled = false; return false; } App::import('Vendor', 'DebugKit.DebugKitDebugger'); DebugKitDebugger::setMemoryPoint(__d('debug_kit', 'Component intitailization', true)); DebugKitDebugger::startTimer('componentInit', __d('debug_kit', 'Component initialization and startup', true)); $panels = $this->_defaultPanels; if (isset($settings['panels'])) { $panels = $this->_makePanelList($settings['panels']); unset($settings['panels']); } $this->cacheKey .= $controller->Session->read('Config.userAgent'); if (!isset($settings['history']) || isset($settings['history']) && $settings['history'] !== false) { $this->_createCacheConfig(); } $this->_loadPanels($panels, $settings); $this->_set($settings); $this->controller =& $controller; return false; }
/** * Verify that the current url is the right url to view the content * * Disabled if debug is > 1 * Doesn't do anything for admin methods, requestAction calls, ajax requests, or if data has been submitted. * Otherwise, check the url matches what the router says should be the url, check slugs and 301 redirect to the * correct url if the url doesn't match * * @return void * @access public */ function check() { if (isset($this->controller->params['requested']) || isset($this->controller->params['admin']) || $this->RequestHandler->isAjax() || $this->controller->data) { return; } $this->here = $here = '/' . trim($this->controller->params['url']['url'], '/'); $params =& $this->controller->params; $defaults = array('controller' => Inflector::underscore($this->controller->name), 'action' => $this->controller->action, 'admin' => !empty($this->controller->params['admin']), 'lang' => $params['lang'], 'theme' => $params['theme']); $url = am($defaults, $this->controller->passedArgs); if (isset($url[0]) && $params['url']['ext'] === 'html') { $id = Configure::read('Site.homeNode'); if (empty($url['admin']) && $url['controller'] === 'nodes' && $url['action'] === 'view' && $url[0] == $id) { $url = am($defaults, array('action' => 'index')); } } if (isset($url[0])) { $conditions = array(); $conditions['Node.id'] = $url[0]; $fields = array('Node.id', 'Revision.slug'); $recursive = 0; $result = $this->controller->Node->find('first', compact('conditions', 'fields', 'recursive')); if (!$result) { $this->controller->redirect($this->controller->Session->read('referer'), null, true); } $url[1] = $result['Revision']['slug']; } $normalized = Router::normalize($url); if ($normalized !== $here) { return $this->controller->redirect($normalized, 301); } }
/** * レイアウトテンプレートを取得 * コンボボックスのソースとして利用 * * @return array * @access public */ function getTemplates() { $templatesPathes = array(); if ($this->Baser->siteConfig['theme']) { $templatesPathes[] = WWW_ROOT . 'themed' . DS . $this->Baser->siteConfig['theme'] . DS . 'feed' . DS; } $templatesPathes[] = BASER_PLUGINS . 'feed' . DS . 'views' . DS . 'feed' . DS; $_templates = array(); foreach ($templatesPathes as $templatesPath) { $folder = new Folder($templatesPath); $files = $folder->read(true, true); $foler = null; if ($files[1]) { if ($_templates) { $_templates = am($_templates, $files[1]); } else { $_templates = $files[1]; } } } $templates = array(); foreach ($_templates as $template) { if ($template != 'ajax.ctp' && $template != 'error.ctp') { $template = basename($template, '.ctp'); $templates[$template] = $template; } } return $templates; }
/** * Initialize the Cache Engine * * Called automatically by the cache frontend * To reinitialize the settings call Cache::engine('EngineName', [optional] settings = array()); * * @param array $setting array of setting for the engine * @return boolean True if the engine has been successfully initialized, false if not * @access public */ function init($settings) { parent::init($settings); $defaults = array('PHP_AUTH_USER' => 'cake', 'PHP_AUTH_PW' => 'cake'); $this->settings = am($this->settings, $defaults, $settings); return function_exists('xcache_info'); }
function __updateCache(Model $model, $aggregate, $foreignKey, $foreignId) { $assocModel =& $model->{$aggregate['model']}; $calculations = array(); foreach ($aggregate as $function => $cacheField) { if (!in_array($function, $this->functions)) { continue; } $calculations[] = $function . '(' . $model->name . '.' . $aggregate['field'] . ') ' . $function . '_value'; } if (count($calculations) > 0) { $conditions = array($model->name . '.' . $foreignKey => $foreignId); if (array_key_exists('conditions', $aggregate)) { $conditions = am($conditions, $aggregate['conditions']); } else { $conditions = am($conditions, $model->belongsTo[$aggregate['model']]['conditions']); } $recursive = array_key_exists('recursive', $aggregate) ? $aggregate['recursive'] : null; $results = $model->find('first', array('fields' => $calculations, 'conditions' => $conditions, 'recursive' => $recursive, 'group' => $model->name . '.' . $foreignKey)); $newValues = array(); foreach ($aggregate as $function => $cacheField) { if (!in_array($function, $this->functions)) { continue; } $newValues[$cacheField] = $results[0][$function . '_value']; } $assocModel->id = $foreignId; $assocModel->save($newValues, false, array_keys($newValues)); } }
function tag($tag, $atributos = null, $opcoes = null, $conteudo = null) { //debug($opcoes); $opcoes_padrao = array('escape' => false, 'close_me' => false); $opcoes = am($opcoes_padrao, $opcoes); //debug($opcoes); extract($opcoes); unset($opcoes['escape']); // não faz sentido passar adiante $vazio = $conteudo != '0' ? empty($conteudo) : false; if ($close_me || $vazio) { $close_me = true; $opcoes['close_me'] = true; } else { $close_me = false; } $t = $this->stag($tag, $atributos, $opcoes); if (!$close_me) { if ($escape) { $conteudo = h($conteudo); } $t .= $conteudo . $this->etag($tag); } return $t; }
function find($type, $query = array()) { if (is_array($type)) { $query = $type; } else { $query['type'] = $type; } if (!is_array($query)) { $query = array('Title' => $query); } $map = array('info' => 'ResponseGroup', 'type' => 'SearchIndex'); foreach ($map as $old => $new) { $query[$new] = $query[$old]; unset($query[$old]); } foreach ($query as $key => $val) { if (preg_match('/^[a-z]/', $key)) { $query[Inflector::camelize($key)] = $val; unset($query[$key]); } } $query = am(array('Service' => 'AWSECommerceService', 'AWSAccessKeyId' => $this->config['key'], 'Operation' => 'ItemSearch', 'Version' => '2008-06-28'), $query); $r = $this->Http->get('http://ecs.amazonaws.com/onca/xml', $query); $r = Set::reverse(new Xml($r)); return $r; }
function afterSave($created) { App::import('Model', 'Myaro'); $this->Myaro = new Myaro(); $this->Myaro->recursive = 0; if ($created === true) { //If a new group has been created $aroData = array(); $aroData['Myaro']['model'] = 'group'; $aroData['Myaro']['foreign_key'] = $this->getLastInsertID(); $aroData['Myaro']['alias'] = '/' . $this->data['Group']['name']; $this->Myaro->save($aroData); } else { //If a group has been updated. $this->Myaro->updateAll(array('alias' => "'" . mysql_real_escape_string("/" . $this->data['Group']['name']) . "'"), array('model' => 'group', 'foreign_key' => $this->data['Group']['id'])); $this->data = am($this->data, $this->Myaro->find(array('foreign_key' => $this->data['Group']['id'], 'model' => 'group'))); $affectedUserAros = $this->Myaro->find('all', array('conditions' => array('parent_id' => $this->data['Myaro']['id'], 'model' => 'user'))); foreach ($affectedUserAros as $affectedUserAro) { //Update the user Aros that are children of the updated group $alias = split('/', $affectedUserAro['Myaro']['alias']); $alias = '/' . $this->data['Group']['name'] . '/' . $alias[2]; $this->Myaro->updateAll(array('alias' => "'" . mysql_real_escape_string($alias) . "'"), array('id' => $affectedUserAro['Myaro']['id'])); } } }
/** * ウィジェットエリアを表示する * * @param $no ウィジェットエリアNO * @param array $options オプション * `subDir` (boolean) エレメントのパスについてプレフィックスによるサブディレクトリを追加するかどうか * ※ その他のパラメータについては、View::element() を参照 */ public function show($no, $options = array()) { $options = array_merge(array('subDir' => true), $options); $WidgetArea = ClassRegistry::init('WidgetArea'); $widgetArea = $WidgetArea->find('first', array('conditions' => array('WidgetArea.id' => $no))); if (empty($widgetArea['WidgetArea']['widgets'])) { return; } $widgets = BcUtil::unserialize($widgetArea['WidgetArea']['widgets']); usort($widgets, array('BcWidgetAreaHelper', '_widgetSort')); foreach ($widgets as $key => $widget) { $key = key($widget); if ($widget[$key]['status']) { $params = array(); $plugin = ''; $params['widget'] = true; if (empty($_SESSION['Auth']['User']) && !isset($cache)) { $params['cache'] = '+1 month'; } $params = am($params, $widget[$key]); $params[$no . '_' . $widget[$key]['id']] = $no . '_' . $widget[$key]['id']; // 同じタイプのウィジェットでキャッシュを特定する為に必要 if (!empty($params['plugin'])) { $plugin = Inflector::camelize($params['plugin']) . '.'; unset($params['plugin']); } $this->_View->BcBaser->element($plugin . 'widgets/' . $widget[$key]['element'], $params, $options); } } }
public function initialize(&$Controller, $settings = array()) { $this->Controller = $Controller; $this->_settings = am($this->_settings, $settings); if (!$this->isActive()) { return; } // Control Debug $this->_settings['debug'] = (int) $this->_settings['debug']; Configure::write('debug', $this->_settings['debug']); $this->Controller->set('debug', $this->_settings['debug']); // Set credentials $this->credentials(true); // Prepare log $this->log(array('controller' => $this->Controller->name, 'action' => $this->Controller->action, 'model_id' => @$this->Controller->passedArgs[0] ? @$this->Controller->passedArgs[0] : 0, 'ratelimited' => 0, 'requested' => date('Y-m-d H:i:s'), 'ip' => $_SERVER['REMOTE_ADDR'], 'httpcode' => 200)); // Validate & Modify Post $this->postData = $this->_modelizePost($this->Controller->data); if ($this->postData === false) { return $this->abort('Invalid post data'); } // SSL if (!empty($this->_settings['auth']['requireSecure'])) { if (!isset($this->Controller->Security) || !is_object($this->Controller->Security)) { return $this->abort('You need to enable the Security component first'); } $this->Controller->Security->requireSecure($this->_settings['auth']['requireSecure']); } // Set content-headers $this->headers(); }
/** * Cambia las abreviaturas del configuracion allowed por los tipos correctos * @param array $config configuraciones del modelo * @return array $config configuraciones modificadas */ function normalizeAllowedConfig($config) { $abbreviations = Configure::read("Media.abbreviations"); $mime_types = Configure::read("Media.mime_types"); //log($config, 'debug'); #pr($config); $config['extensions'] = array(); foreach ($config['allowed'] as $key => $allowed) { if (isset($abbreviations[$allowed])) { foreach ($abbreviations[$allowed] as $extencion) { if (!in_array($mime_types[$extencion], $config['allowed'])) { $config['allowed'][] = $mime_types[$extencion]; } } $config['extensions'] = am($config['extensions'], $abbreviations[$allowed]); unset($config['allowed'][$key]); } else { if (isset($mime_types[$allowed])) { $config['allowed'][] = $mime_types[$allowed]; $config['extensions'][] = $allowed; } } } return $config; }
function add() { $this->Queries->retrieve_query(0, true); $this->set('query_new_record', true); $query = $this->Query->defaults(); $query['project'] = $this->_project; $query['user'] = $this->current_user; $query['is_public'] = $query['project'] && $this->User->is_allowed_to($this->current_user, ':manage_public_queries', $this->_project) || $this->current_user['admin'] ? true : false; $query['default_columns'] = true; if (!empty($this->data) && $this->RequestHandler->isPost() && $this->_get_param('confirm') && !$this->RequestHandler->isAjax()) { $this->data['Query']['project_id'] = $this->_project['Project']['id']; $this->data['Query']['user_id'] = $this->current_user['id']; foreach ($this->params['form']['fields'] as $field) { $this->Query->add_filter($field, $this->params['form']['operators'][$field], $this->params['form']['values'][$field]); } $this->Query->save($this->data); if (empty($this->Query->validationErrors)) { $this->Session->setFlash(__('Successful creation.', true), 'default', array('class' => 'flash flash_notice')); $this->redirect(array('controller' => 'issues', 'action' => 'index', 'project_id' => $this->_project['Project']['identifier'])); } } if (isset($this->data['Query'])) { $query = am($query, $this->data['Query']); } $this->data = am($this->data, array('Query' => $query)); if ($this->RequestHandler->isAjax()) { $this->layout = 'ajax'; } }
function initialize(&$controller, $settings = array()) { #$this->controller = $controller; $this->settings = am($this->settings, $settings); $this->Setting = ClassRegistry::init('Setting'); $this->Location = ClassRegistry::init("Location"); }