Example #1
1
 public function beforeFilter()
 {
     $this->loadModel('User');
     parent::beforeFilter();
     // Disable content cache for Chrome
     $this->response->disableCache();
     // Delete the default auth message.  Just show them the login page
     //  people will get the idea pretty quickly.
     $this->Session->delete('Message.auth');
     /*if ($this->RequestHandler->isMobile()) {
           $this->layout = 'mobile';
           $this->isMobile = true;
       } else {
           $this->layout = 'mobile';
           $this->isMobile = true;
       }*/
     if ($this->request->is('ajax')) {
         $this->layout = 'ajax';
     }
     $this->Auth->allow('index', 'view', 'display');
     // Let everyone know about the user
     $this->set('loggedIn', $this->Auth->loggedIn());
     $user = $this->Auth->user();
     $this->isAdmin = $this->User->isAdmin($user);
     $this->isEditor = $this->User->isEditor($user);
     $this->set('loggedInuserId', $this->Auth->user('id'));
     $this->set('isAdmin', $this->isAdmin);
     $this->set('isEditor', $this->isEditor);
     $this->set('allowAccountCreation', Configure::read('App.allowPublicAccountCreation'));
 }
Example #2
1
 /**
  * Displays a view
  *
  * @param mixed What page to display
  * @return void
  * @throws NotFoundException When the view file could not be found
  *	or MissingViewException in debug mode.
  */
 public function display()
 {
     $path = func_get_args();
     //debug($path);
     $count = count($path);
     //debug($count);
     if (!$count) {
         return $this->redirect('/');
     }
     $page = $subpage = $title_for_layout = null;
     //debug(Inflector::humanize($path[$count - 1]));
     if (!empty($path[0])) {
         $page = $path[0];
     }
     if (!empty($path[1])) {
         $subpage = $path[1];
     }
     if (!empty($path[$count - 1])) {
         $title_for_layout = Inflector::humanize($path[$count - 1]);
     }
     $this->set(compact('page', 'subpage', 'title_for_layout'));
     //debug($this->render(implode('/', $path)));
     //debug($page);
     //debug($subpage);
     //debug($title_for_layout);
     try {
         $this->render(implode('/', $path));
     } catch (MissingViewException $e) {
         if (Configure::read('debug')) {
             throw $e;
         }
         throw new NotFoundException();
     }
 }
 /**
  * Setup the config based on either the Configure::read() values
  * or the PaypalIpnConfig in config/paypal_ipn_config.php
  *
  * Will attempt to read configuration in the following order:
  *   Configure::read('PaypalIpn')
  *   App::import() of config/paypal_ipn_config.php
  *   App::import() of plugin's config/paypal_ipn_config.php
  */
 function __construct()
 {
     $this->config = Configure::read('PaypalIpn');
     if (empty($this->config)) {
         $importConfig = array('type' => 'File', 'name' => 'PaypalIpn.PaypalIpnConfig', 'file' => CONFIGS . 'paypal_ipn_config.php');
         if (!class_exists('PaypalIpnConfig')) {
             App::import($importConfig);
         }
         if (!class_exists('PaypalIpnConfig')) {
             // Import from paypal plugin configuration
             $importConfig['file'] = 'config' . DS . 'paypal_ipn_config.php';
             App::import($importConfig);
         }
         if (!class_exists('PaypalIpnConfig')) {
             trigger_error(__d('paypal_ipn', 'PaypalIpnConfig: The configuration could not be loaded.', true), E_USER_ERROR);
         }
         if (!PHP5) {
             $config =& new PaypalIpnConfig();
         } else {
             $config = new PaypalIpnConfig();
         }
         $vars = get_object_vars($config);
         foreach ($vars as $property => $configuration) {
             if (strpos($property, 'encryption_') === 0) {
                 $name = substr($property, 11);
                 $this->encryption[$name] = $configuration;
             } else {
                 $this->config[$property] = $configuration;
             }
         }
     }
     parent::__construct();
 }
Example #4
1
 public function __construct($id = false, $table = null, $ds = null)
 {
     if (!Configure::read('Backend.Acl.enabled')) {
         unset($this->actsAs['Acl']);
     }
     parent::__construct($id, $table, $ds);
 }
 function end()
 {
     $this->Transition->checkPrev(array('index', 'confirm'), '不正なページ遷移です。', array('action' => 'index'));
     $data = $this->Transition->data('index');
     $c =& $this->Contact;
     // $c->requireCaptcha(!$this->Ktai->is_ktai());
     $c->answerCaptcha = $this->Session->read('captcha');
     $c->set($data);
     if (!$c->validates()) {
         $this->Session->setFlash('送信内容に不備があります。');
         $this->redirect(array('action' => 'index'));
     }
     extract($data['Contact']);
     $this->toAddr = Configure::read('Site.contact_mail');
     $this->fromAddr = $email;
     if (!empty($company_name)) {
         $company_name .= ' : ';
     }
     if (DS != "\\") {
         if (!$this->_send($company_name . $name, 'contact_collect', compact('name', 'email', 'company_name', 'statement'))) {
             $this->Session->setFlash('送信に失敗しました。お手数ですが、時間を空けてから再度入力してください。');
             $this->redirect(array('action' => 'index'));
         } else {
             // 送信完了のメール?
         }
     }
     $this->Transition->clearData();
     $this->pageTitle = '送信完了';
 }
Example #6
1
 /**
  * Override startup of the Shell
  *
  * @return void
  */
 public function startup()
 {
     parent::startup();
     if (isset($this->params['connection'])) {
         $this->connection = $this->params['connection'];
     }
     $class = Configure::read('Acl.classname');
     list($plugin, $class) = pluginSplit($class, true);
     App::uses($class, $plugin . 'Controller/Component/Acl');
     if (!in_array($class, array('DbAcl', 'DB_ACL')) && !is_subclass_of($class, 'DbAcl')) {
         $out = "--------------------------------------------------\n";
         $out .= __d('cake_console', 'Error: Your current Cake configuration is set to an ACL implementation other than DB.') . "\n";
         $out .= __d('cake_console', 'Please change your core config to reflect your decision to use DbAcl before attempting to use this script') . "\n";
         $out .= "--------------------------------------------------\n";
         $out .= __d('cake_console', 'Current ACL Classname: %s', $class) . "\n";
         $out .= "--------------------------------------------------\n";
         $this->err($out);
         $this->_stop();
     }
     if ($this->command) {
         if (!config('database')) {
             $this->out(__d('cake_console', 'Your database configuration was not found. Take a moment to create one.'), true);
             $this->args = null;
             return $this->DbConfig->execute();
         }
         require_once APP . 'Config' . DS . 'database.php';
         if (!in_array($this->command, array('initdb'))) {
             $collection = new ComponentCollection();
             $this->Acl = new AclComponent($collection);
             $controller = new Controller();
             $this->Acl->startup($controller);
         }
     }
 }
 public function buildCss()
 {
     App::import('Vendor', 'AssetMinify.JSMinPlus');
     // Ouverture des fichiers de config
     $dir = new Folder(Configure::read('App.www_root') . 'css' . DS . 'minified');
     if ($dir->path !== null) {
         foreach ($dir->find('config_.*.ini') as $file) {
             preg_match('`^config_(.*)\\.ini$`', $file, $grep);
             $file = new File($dir->pwd() . DS . $file);
             $ini = parse_ini_file($file->path, true);
             $fileFull = new File($dir->path . DS . 'full_' . $grep[1] . '.css', true, 0644);
             $fileGz = new File($dir->path . DS . 'gz_' . $grep[1] . '.css', true, 0644);
             $contentFull = '';
             foreach ($ini as $data) {
                 // On a pas de version minifié
                 if (!($fileMin = $dir->find('file_' . md5($data['url'] . $data['md5']) . '.css'))) {
                     $fileMin = new File($dir->path . DS . 'file_' . md5($data['url'] . $data['md5']) . '.css', true, 0644);
                     $this->out("Compression de " . $data['file'] . ' ... ', 0);
                     $fileMin->write(MinifyUtils::compressCss(MinifyUtils::cssAbsoluteUrl($data['url'], file_get_contents($data['file']))));
                     $this->out('OK');
                 } else {
                     $fileMin = new File($dir->path . DS . 'file_' . md5($data['url'] . $data['md5']) . '.css');
                 }
                 $contentFull .= $fileMin->read() . PHP_EOL;
             }
             // version full
             $fileFull->write($contentFull);
             $fileFull->close();
             // compression
             $fileGz->write(gzencode($contentFull, 6));
         }
     }
 }
Example #8
0
 /**
  * Override startup of the Shell
  *
  * @access public
  */
 function startup()
 {
     $this->dataSource = 'default';
     if (isset($this->params['datasource'])) {
         $this->dataSource = $this->params['datasource'];
     }
     if (Configure::read('Acl.classname') != 'DB_ACL') {
         $out = "--------------------------------------------------\n";
         $out .= __("Error: Your current Cake configuration is set to", true) . "\n";
         $out .= __("an ACL implementation other than DB. Please change", true) . "\n";
         $out .= __("your core config to reflect your decision to use", true) . "\n";
         $out .= __("DB_ACL before attempting to use this script", true) . ".\n";
         $out .= "--------------------------------------------------\n";
         $out .= sprintf(__("Current ACL Classname: %s", true), Configure::read('Acl.classname')) . "\n";
         $out .= "--------------------------------------------------\n";
         $this->err($out);
         exit;
     }
     if ($this->command && !in_array($this->command, array('help'))) {
         if (!config('database')) {
             $this->out(__("Your database configuration was not found. Take a moment to create one.", true), true);
             $this->args = null;
             return $this->DbConfig->execute();
         }
         require_once CONFIGS . 'database.php';
         if (!in_array($this->command, array('initdb'))) {
             $this->Acl = new AclComponent();
             $controller = null;
             $this->Acl->startup($controller);
         }
     }
 }
 /**
  * Send email via Mailgun
  *
  * @param CakeEmail $email
  * @return array
  * @throws Exception
  */
 public function send(CakeEmail $email)
 {
     if (Configure::read('Mailgun.preventManyToRecipients') !== false && count($email->to()) > 1) {
         throw new Exception('More than one "to" recipient not allowed (set Mailgun.preventManyToRecipients = false to disable check)');
     }
     $mgClient = new Mailgun($this->_config['mg_api_key']);
     $headersList = array('from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'bcc', 'subject');
     $params = [];
     foreach ($email->getHeaders($headersList) as $header => $value) {
         if (isset($this->_paramMapping[$header]) && !empty($value)) {
             $key = $this->_paramMapping[$header];
             $params[$key] = $value;
         }
     }
     $params['text'] = $email->message(CakeEmail::MESSAGE_TEXT);
     $params['html'] = $email->message(CakeEmail::MESSAGE_HTML);
     $attachments = array();
     foreach ($email->attachments() as $name => $info) {
         $attachments['attachment'][] = '@' . $info['file'];
     }
     try {
         $result = $mgClient->sendMessage($this->_config['mg_domain'], $params, $attachments);
         if ($result->http_response_code != 200) {
             throw new Exception($result->http_response_body->message);
         }
     } catch (Exception $e) {
         throw $e;
     }
     return $result;
 }
 /**
  * Before migration callback
  *
  * @param string $direction, up or down direction of migration process
  * @return boolean Should process continue
  * @access public
  */
 public function before($direction)
 {
     if ($direction == 'down') {
         return Configure::read('debug') > 0;
     }
     return true;
 }
 public function _app_getUsers($data)
 {
     $conditions['sqrt(pow(69.1 * (UsersOnline.latitude - ' . $data['UsersOnline']['latitude'] . '), 2) + pow(53.0 * (UsersOnline.longitude - ' . $data['UsersOnline']['latitude'] . '), 2)) <'] = Configure::read('DistanceToGetUsers') / 1.609344;
     //Calculate if distance is lower than input. (Convertion miles to kilometres)
     $conditions['UsersOnline.user_id <>'] = $data['UsersOnline']['user_id'];
     $conditions['TIMEDIFF(ADDTIME(UsersOnline.modified, SEC_TO_TIME(UsersOnline.duration)), NOW()) >'] = 0;
     $conditions['UsersBanned.id'] = null;
     $joins = array(array('table' => 'allowed_profiles', 'alias' => 'AllowedProfile', 'type' => 'LEFT', 'conditions' => array('AllowedProfile.user_allowed_id = ' . $data['UsersOnline']['user_id'], 'AllowedProfile.user_profile_id = UsersOnline.user_id')), array('table' => 'users_banned', 'alias' => 'UsersBanned', 'type' => 'LEFT', 'conditions' => array('UsersBanned.user_to_id = ' . $data['UsersOnline']['user_id'], 'UsersBanned.user_from_id = UsersOnline.user_id')));
     $fields = array('User.id', 'User.auth_token', 'User.email', 'User.username', 'User.name', 'User.surname', 'User.headline', 'User.picture', 'User.show_name', 'User.show_headline', 'User.show_picture', 'User.show_skills', 'User.show_jobs', 'User.show_in_searches', 'UsersOnline.*', 'AllowedProfile.id');
     $users = $this->UsersOnline->find('all', array('fields' => $fields, 'joins' => $joins, 'conditions' => $conditions));
     foreach ($users as $key => $user) {
         if (empty($user['AllowedProfile']['id'])) {
             if (!$user['User']['show_name']) {
                 unset($user['User']['name']);
                 unset($user['User']['surname']);
             }
             if (!$user['User']['show_headline']) {
                 unset($user['User']['headline']);
             }
             if (!$user['User']['show_picture']) {
                 unset($user['User']['picture']);
             }
         }
         unset($user['AllowedProfile']);
         $users[$key] = $user;
     }
     return $users;
 }
Example #12
0
 public static function instance()
 {
     if (is_null(self::$instance)) {
         App::import('Vendor', 'Smarty', array('file' => 'autoload.php'));
         $smarty = new Smarty();
         $smarty->template_dir = APP . 'View' . DS;
         //plugins dir(s) must be set by array
         $smarty->plugins_dir = array(APP . 'View' . DS . 'SmartyPlugins', VENDORS . 'smarty' . DS . 'smarty' . DS . 'distribution' . DS . 'libs' . DS . 'plugins');
         $smarty->config_dir = APP . 'View' . DS . 'SmartyConfigs' . DS;
         $smarty->compile_dir = TMP . 'smarty' . DS . 'compile' . DS;
         $smarty->cache_dir = TMP . 'smarty' . DS . 'cache' . DS;
         $smarty->error_reporting = 'E_ALL & ~E_NOTICE';
         $smarty->default_modifiers = array('escape:"html"');
         $smarty->caching = true;
         $smarty->compile_check = true;
         $smarty->cache_lifetime = 3600;
         $smarty->cache_modified_check = false;
         $smarty->force_compile = Configure::read('debug') > 0 ? true : false;
         /*
          $smarty->autoload_filters = array(
          'pre' => array('hoge'),
          'output' => array('escape')
          );
          $smarty->left_delimiter = '{';
          $smarty->right_delimiter = '}';
          //for development
          $smarty->debugging = (Configure::read('debug') == 0) ? false : true;
         */
         self::$instance = $smarty;
     }
     return self::$instance;
 }
 public function testIgnoreRequests()
 {
     $ignored = Configure::read('NewRelic.ignoreRoutes');
     Configure::write('NewRelic.ignoreRoutes', array('/admin/:controller/:action/*', '/:controller/edit/*', '/new_relic_user_test/:action/5'));
     $testSucceed = array('/new_relic_test/index', '/new_relic_user_test/view/3');
     foreach ($testSucceed as $testUrl) {
         $filter = $this->_getNewRelicMock();
         $filter->expects($this->once())->method('hasNewRelic')->will($this->returnValue(true));
         $filter->expects($this->never())->method('ignoreTransaction');
         $response = $this->getMock('CakeResponse', array('_sendHeader'));
         $request = new CakeRequest($testUrl);
         $request->addParams(Router::parse($testUrl));
         $event = new CakeEvent('Dispatcher.beforeRequest', $this, compact('request', 'response'));
         $this->assertTrue($filter->beforeDispatch($event));
         $this->assertFalse($event->isStopped());
     }
     $testFail = array('/admin/new_relic_test/index', '/new_relic_user_test/edit', '/new_relic_user_test/edit/3', '/new_relic_user_test/view/5');
     foreach ($testFail as $testUrl) {
         $filter = $this->_getNewRelicMock();
         $filter->expects($this->once())->method('hasNewRelic')->will($this->returnValue(true));
         $filter->expects($this->once())->method('ignoreTransaction');
         $response = $this->getMock('CakeResponse', array('_sendHeader'));
         $request = new CakeRequest($testUrl);
         $request->addParams(Router::parse($testUrl));
         $event = new CakeEvent('Dispatcher.beforeRequest', $this, compact('request', 'response'));
         $this->assertTrue($filter->beforeDispatch($event));
         $this->assertFalse($event->isStopped());
     }
     Configure::write('NewRelic.ignoreRoutes', $ignored);
 }
Example #14
0
 function onEdit($record, $old_record)
 {
     $auth_model = Configure::read('security.auth_model');
     $username_field = $this->_controller->Auth->authenticate->userField;
     $email_field = $this->_controller->Auth->authenticate->emailField;
     // phpBB3 files need these
     global $phpbb_root_path, $phpEx;
     $phpbb_root_path = Configure::read('phpbb3.root_path');
     $phpEx = 'php';
     include $phpbb_root_path . 'config.php';
     $bb3_class = "{$table_prefix}users";
     $bb3_model = ClassRegistry::init($bb3_class);
     $bb3_user = $bb3_model->find('first', array('conditions' => array('username' => $old_record[$auth_model][$username_field])));
     // We only care about username and email address changes
     if (empty($bb3_user) || $bb3_user[$bb3_class]['username'] == $record[$auth_model][$username_field] && $bb3_user[$bb3_class]['user_email'] == $record[$auth_model][$email_field]) {
         return;
     }
     // Includ a couple of things needed for function definitions
     define('IN_PHPBB', true);
     include $phpbb_root_path . 'includes/functions.php';
     include $phpbb_root_path . 'includes/utf/utf_tools.php';
     $clean = utf8_clean_string($record[$auth_model][$username_field]);
     $hash = phpbb_email_hash($record[$auth_model][$email_field]);
     $bb3_model->updateAll(array('username' => "'{$record[$auth_model][$username_field]}'", 'username_clean' => "'{$clean}'", 'user_email' => "'{$record[$auth_model][$email_field]}'", 'user_email_hash' => "'{$hash}'"), array('user_id' => $bb3_user[$bb3_class]['user_id']));
 }
Example #15
0
 /**
  * @access public
  * @return void
  * 2009-07-30 ms
  */
 function testImages()
 {
     $is = $this->Gravatar->image(GARBIGE_TEST_EMAIL);
     echo $is;
     $this->assertTrue(!empty($is));
     $is = $this->Gravatar->image(Configure::read('Config.admin_email'));
     echo $is;
     $this->assertTrue(!empty($is));
     $is = $this->Gravatar->image(VALID_TEST_EMAIL);
     echo $is;
     $this->assertTrue(!empty($is));
     $is = $this->Gravatar->image(VALID_TEST_EMAIL, array('size' => '200'));
     echo $is;
     $this->assertTrue(!empty($is));
     $is = $this->Gravatar->image(VALID_TEST_EMAIL, array('size' => '20'));
     echo $is;
     $this->assertTrue(!empty($is));
     $is = $this->Gravatar->image(VALID_TEST_EMAIL, array('rating' => 'X'));
     # note the capit. x
     echo $is;
     $this->assertTrue(!empty($is));
     $is = $this->Gravatar->image(VALID_TEST_EMAIL, array('ext' => true));
     echo $is;
     $this->assertTrue(!empty($is));
     $is = $this->Gravatar->image(VALID_TEST_EMAIL, array('default' => 'none'));
     echo $is;
     $this->assertTrue(!empty($is));
     $is = $this->Gravatar->image(GARBIGE_TEST_EMAIL, array('default' => 'none'));
     echo $is;
     $this->assertTrue(!empty($is));
     $is = $this->Gravatar->image(GARBIGE_TEST_EMAIL, array('default' => 'http://2.gravatar.com/avatar/8379aabc84ecee06f48d8ca48e09eef4?d=identicon'));
     echo $is;
     $this->assertTrue(!empty($is));
 }
 function pick($layout_scheme)
 {
     App::import('Config', 'Typographer.' . $layout_scheme . '_config');
     $c_layout_scheme = Inflector::camelize($layout_scheme);
     //carrega os instrumentos e as configurações deste layout específico/
     $tools = Configure::read('Typographer.' . $c_layout_scheme . '.tools');
     $used_automatic_classes = Configure::read('Typographer.' . $c_layout_scheme . '.used_automatic_classes');
     foreach ($this->controller->helpers as $helper => $params) {
         if (is_array($params)) {
             if (isset($params['receive_tools'])) {
                 $this->controller->helpers[$helper]['tools'] = $tools;
                 unset($params['receive_tools']);
             }
             if (isset($params['receive_automatic_classes'])) {
                 $this->controller->helpers[$helper]['used_automatic_classes'] = $used_automatic_classes;
                 unset($params['used_automatic_classes']);
             }
         }
     }
     if (!isset($this->controller->view) || $this->controller->view == 'View') {
         $this->controller->view = 'Typographer.Type';
     }
     $this->controller->set('used_automatic_classes', $used_automatic_classes);
     $this->controller->set($tools);
     $this->controller->set('layout_scheme', $layout_scheme);
 }
 public function __construct(ComponentCollection $collection, $settings = array())
 {
     if (Configure::read('Sermepa')) {
         $settings = $settings + Configure::read('Sermepa');
     }
     parent::__construct($collection, $settings);
 }
Example #18
0
 /**
  * Before save callback
  *
  * @return bool Success
  */
 function beforeSave()
 {
     parent::beforeSave();
     // Construct the absolute page URL
     if (isset($this->data[$this->name]['slug'])) {
         $level = 0;
         $homePageId = intval(Configure::read('Wildflower.settings.home_page_id'));
         if (intval($this->id) === $homePageId && $homePageId !== 0) {
             // Home page has the URL of root
             $this->data[$this->name]['url'] = '/';
         } else {
             if (!isset($this->data[$this->name]['parent_id']) or !is_numeric($this->data[$this->name]['parent_id'])) {
                 // Page has no parent
                 $this->data[$this->name]['url'] = "/{$this->data[$this->name]['slug']}";
             } else {
                 $parentPage = $this->findById($this->data[$this->name]['parent_id'], array('url'));
                 $url = "/{$this->data[$this->name]['slug']}";
                 if ($parentPage[$this->name]['url'] !== '/') {
                     $url = $parentPage[$this->name]['url'] . $url;
                 }
                 $this->data[$this->name]['url'] = $url;
             }
         }
     }
     // Publish?
     if (isset($this->data[$this->name]['publish'])) {
         $this->data[$this->name]['draft'] = 0;
         unset($this->data[$this->name]['publish']);
     }
     return true;
 }
Example #19
0
 /**
  * タブメニューの情報を取得します。
  */
 private function getTabmenu($id)
 {
     $this->loadModel('Footer');
     $this->loadModel('BasicInfo');
     $this->loadModel('Shop');
     $basicInfo = $this->BasicInfo->getInfo($this->user_id, $this->Footer->getInfoName());
     $modified = '';
     $created = '';
     if (!empty($basicInfo)) {
         $modified = $basicInfo['BasicInfo']['modified'];
         $created = $basicInfo['BasicInfo']['created'];
     }
     $geocode = array('lat' => '', 'lng' => '');
     $shopInfo = json_decode($this->Shop->getData($this->user_id), true);
     if (array_key_exists('address', $shopInfo['profile'])) {
         $geocode = $this->geocode($shopInfo['profile']['address']);
     }
     $conf = Configure::read('DescriptionWithIconList');
     $tab = [];
     $tabInfo = json_decode($this->Footer->getData($id), true);
     foreach ($tabInfo as $key => $info) {
         if (empty($info['type'])) {
             continue;
         }
         $tab[] = array('type' => $info['type'], 'icon' => $conf[$info['icon']]['icon'], 'position' => (string) ($key + 1));
     }
     return $tab;
 }
 public function beforeRender()
 {
     $this->_setDate();
     $this->set('bodyClass', sprintf('%s %s', strtolower($this->name), strtolower($this->name) . '-' . strtolower($this->action)));
     $this->set(array('isAdmin' => $this->isPrefix('admin'), 'title_for_layout' => $this->titleForLayout, 'currentUser' => $this->currentUser, 'estadosBrasil' => Configure::read('estadosBrasil')));
     return parent::beforeRender();
 }
Example #21
0
 public function image($imagePath, $width = null, $height = null, $class = null, $typeImage = null, $isThumb = false, $crop = 2)
 {
     if (empty($imagePath)) {
         $imagePath = 'no_image.png';
     } else {
         if (!empty($typeImage)) {
             if ($typeImage == 'UserProfile') {
                 $imagePath = Configure::read('ImagePath.UserProfile') . $imagePath;
             } elseif ($typeImage == 'AdvisorProfile') {
                 $imagePath = Configure::read('ImagePath.AdvisorProfile') . $imagePath;
             } elseif ($typeImage == 'temp') {
                 $imagePath = Configure::read('ImagePath.temp') . $imagePath;
             } elseif ($typeImage == 'Job') {
                 $imagePath = Configure::read('ImagePath.Job') . $imagePath;
             } elseif ($typeImage == 'BusinessField') {
                 $imagePath = Configure::read('ImagePath.BusinessField') . $imagePath;
             }
         }
     }
     if ($isThumb) {
         if ($imagePath === 'no_image.png') {
             $imagePath = 'no_image.jpg';
         }
         $imagePath = Router::url('/', true) . IMAGES_URL . $imagePath;
         $imagePath = "/timthumb.php?src={$imagePath}&w={$width}&h={$height}&zc={$crop}";
     }
     return $this->Html->image($imagePath, array('width' => $width, 'height' => $height, 'class' => $class));
 }
 public function beforeRender()
 {
     parent::beforeRender();
     $this->set('section', $this->section);
     $this->set('CMS', Configure::read('Cms.Name'));
     $this->set('admin', $this->Auth->user());
 }
Example #23
0
 /**
  * testTranslationCaching method
  *
  * @return void
  */
 public function testTranslationCaching()
 {
     Configure::write('Config.language', 'cache_test_po');
     // reset internally stored entries
     I18n::clear();
     Cache::clear(false, '_cake_core_');
     $lang = Configure::read('Config.language');
     Cache::config('_cake_core_', Cache::config('default'));
     // make some calls to translate using different domains
     $this->assertEquals('Dom 1 Foo', I18n::translate('dom1.foo', false, 'dom1'));
     $this->assertEquals('Dom 1 Bar', I18n::translate('dom1.bar', false, 'dom1'));
     $domains = I18n::domains();
     $this->assertEquals('Dom 1 Foo', $domains['dom1']['cache_test_po']['LC_MESSAGES']['dom1.foo']);
     // reset internally stored entries
     I18n::clear();
     // now only dom1 should be in cache
     $cachedDom1 = Cache::read('dom1_' . $lang, '_cake_core_');
     $this->assertEquals('Dom 1 Foo', $cachedDom1['LC_MESSAGES']['dom1.foo']);
     $this->assertEquals('Dom 1 Bar', $cachedDom1['LC_MESSAGES']['dom1.bar']);
     // dom2 not in cache
     $this->assertFalse(Cache::read('dom2_' . $lang, '_cake_core_'));
     // translate a item of dom2 (adds dom2 to cache)
     $this->assertEquals('Dom 2 Foo', I18n::translate('dom2.foo', false, 'dom2'));
     // verify dom2 was cached through manual read from cache
     $cachedDom2 = Cache::read('dom2_' . $lang, '_cake_core_');
     $this->assertEquals('Dom 2 Foo', $cachedDom2['LC_MESSAGES']['dom2.foo']);
     $this->assertEquals('Dom 2 Bar', $cachedDom2['LC_MESSAGES']['dom2.bar']);
     // modify cache entry manually to verify that dom1 entries now will be read from cache
     $cachedDom1['LC_MESSAGES']['dom1.foo'] = 'FOO';
     Cache::write('dom1_' . $lang, $cachedDom1, '_cake_core_');
     $this->assertEquals('FOO', I18n::translate('dom1.foo', false, 'dom1'));
 }
Example #24
0
 /**
  * start Case - switch view paths
  *
  * @return void
  **/
 function startCase()
 {
     $this->_viewPaths = Configure::read('viewPaths');
     Configure::write('viewPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS, APP . 'plugins' . DS . 'debug_kit' . DS . 'views' . DS, ROOT . DS . LIBS . 'view' . DS));
     $this->_debug = Configure::read('debug');
     $this->firecake =& FireCake::getInstance();
 }
 public function upload()
 {
     $album_id = $_POST['album_id'];
     # Resize attributes configured in bootstrap.php
     $resize_attrs = $this->Picture->getResizeToSize();
     if ($_FILES) {
         $file = $_FILES['file'];
         try {
             # Check if the file have any errors
             $this->Util->checkFileErrors($file);
             # Get file extention
             $ext = pathinfo($file['name'], PATHINFO_EXTENSION);
             # Validate if the file extention is allowed
             $this->Util->validateExtensions($ext);
             # Generate a random filename
             $filename = $this->Util->getToken();
             $full_name = $filename . "." . $ext;
             # Image Path
             $path = $this->Picture->generateFilePath($album_id, $full_name);
             $main_id = $this->Picture->uploadFile($path, $album_id, $file['name'], $file['tmp_name'], $resize_attrs['width'], $resize_attrs['height'], $resize_attrs['action'], true);
             # Create extra pictures from the original one
             $this->Picture->createExtraImages(Configure::read('GalleryOptions.Pictures.styles'), $file['name'], $file['tmp_name'], $album_id, $main_id, $filename);
         } catch (ForbiddenException $e) {
             $response = $e->getMessage();
             return new CakeResponse(array('status' => 401, 'body' => json_encode($response)));
         }
     }
     $this->render(false, false);
 }
Example #26
0
 public function testHasManyWithMissingMediaAdapters()
 {
     $_backupConfig = Configure::read('Media');
     $_backupProcess = Media_Process::config();
     $_backupInfo = Media_Info::config();
     $s = array('convert' => 'image/png', 'zoomCrop' => array(100, 100));
     $m = array('convert' => 'image/png', 'fitCrop' => array(300, 300));
     $l = array('convert' => 'image/png', 'fit' => array(600, 440));
     Configure::write('Media.filter', array('audio' => compact('s', 'm'), 'document' => compact('s', 'm'), 'generic' => array(), 'image' => compact('s', 'm', 'l'), 'video' => compact('s', 'm')));
     Media_Process::config(array('image' => null));
     Media_Info::config(array('image' => null));
     $Model = $this->_model('hasMany');
     $file = $this->Data->getFile(array('image-jpg.jpg' => 'ta.jpg'));
     $data = array('Movie' => array('title' => 'Weekend', 'director' => 'Jean-Luc Godard'), 'Attachment' => array(array('file' => $file, 'model' => 'Movie')));
     $Model->create();
     $result = false;
     $expected = null;
     try {
         $result = $Model->saveAll($data, array('validate' => 'first'));
     } catch (Exception $exception) {
         $expected = $exception;
     }
     if ($expected === null) {
         $this->fail('Expected Model::saveAll to raise an error.');
     }
     $this->assertFalse($result);
     $this->assertTrue(file_exists($this->Data->settings['transfer'] . 'img' . DS . 'ta.jpg'));
     $result = $Model->find('first', array('conditions' => array('title' => 'Weekend')));
     $expected = array(0 => array('id' => '1', 'model' => 'Movie', 'foreign_key' => '4', 'dirname' => 'img', 'basename' => 'ta.jpg', 'checksum' => '073addc9c90e4d20a9a19d8a31e01b39', 'group' => null, 'alternative' => null, 'path' => 'img/ta.jpg'));
     $this->assertEqual($result['Attachment'], $expected);
     Media_Process::config($_backupProcess);
     Media_Info::config($_backupInfo);
     Configure::write('Media', $_backupConfig);
 }
Example #27
0
 /**
  * startCase method
  *
  * @access public
  * @return void
  */
 function startCase()
 {
     $this->_cacheDisable = Configure::read('Cache.disable');
     $this->_cacheConfig = Cache::config('default');
     Configure::write('Cache.disable', false);
     Cache::config('default', array('engine' => 'File', 'path' => CACHE));
 }
Example #28
0
 public function beforeFind($queryData)
 {
     $this->basePath = Configure::read('Filemanager.base_path');
     if (empty($this->basePath)) {
         $this->validationErrors[] = array('field' => 'basePath', 'message' => __('Base path does not exist'));
         return false;
     }
     $this->path = $this->basePath;
     if (isset($queryData['conditions']['path'])) {
         $this->path = $this->basePath . $queryData['conditions']['path'];
     }
     App::import('Folder');
     App::import('File');
     $Folder = new Folder($this->path);
     if (empty($Folder->path)) {
         $this->validationErrors[] = array('field' => 'path', 'message' => __('Path does not exist'));
         return false;
     }
     $this->fileList = $Folder->read();
     unset($this->fileList[1]);
     if (!empty($queryData['order'])) {
         $this->__order($queryData['order']);
     }
     return true;
 }
Example #29
0
 /**
  * configure Configure for testcase
  *
  * @return void
  **/
 function startCase()
 {
     $this->_aclDb = Configure::read('Acl.database');
     $this->_aclClass = Configure::read('Acl.classname');
     Configure::write('Acl.database', 'test_suite');
     Configure::write('Acl.classname', 'DbAcl');
 }
 /**
  * Initialization method. Triggered before the controller's `beforeFilfer`
  * method but after the model instantiation.
  *
  * @param Controller $controller
  * @param array $settings
  * @return null
  * @access public
  */
 public function initialize(Controller $controller)
 {
     // Handle loading our library firstly...
     App::build(array('Vendor' => array(APP . 'Vendor' . DS . 'vexxhost' . DS . 'cloud-flare-api')));
     App::import('Vendor', 'cloudflare_api', array('file' => 'vexxhost' . DS . 'cloud-flare-api' . DS . 'class_cloudflare.php'));
     $this->Cf = new cloudflare_api(Configure::read('CloudFlareApi.email'), Configure::read('CloudFlareApi.apiKey'));
 }