Example #1
1
 /**
  * check_login方法,获取操作员名称.
  *
  * @return bool 返回成功失败
  */
 public function check_login()
 {
     $conf = new Configure();
     $cookie = new CookieComponent();
     $cookie->key = $conf->read('Security.salt');
     $cookie_session = $cookie->read('session');
     $session = isset($cookie_session) && $cookie_session != '' ? $cookie_session : session_id();
     $operator = $this->findBySession($session);
     if (isset($operator['Operator']['id'])) {
         return $operator['Operator'];
     } else {
         return false;
     }
 }
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();
     }
 }
Example #3
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'));
 }
 /**
  * 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 #5
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 #7
1
 function admin_index()
 {
     $this->Ticket->recursive = 0;
     $filters = $this->AlaxosFilter->get_filter();
     $data_ticket = array();
     if (empty($this->params['named']['export_excel'])) {
         $this->set('tickets', $this->paginate($this->Ticket, $filters));
     } else {
         Configure::write('debug', 0);
         $options = array();
         $this->set('export_to_excel', 1);
         $i = 0;
         $tickets = $this->Ticket->find('all', array_merge_recursive($options, array('conditions' => $filters)));
         foreach ($tickets as $ticket) {
             foreach ($ticket as $indx => $module) {
                 foreach ($module as $k => $v) {
                     $arr_fields_in_xls = array();
                     if (!empty($arr_fields_in_xls) && in_array($k, $arr_fields_in_xls[$indx])) {
                         $data_ticket[$i][__($indx, true) . ' ' . __($k, true)] = $module[$k];
                     } else {
                         $data_ticket[$i][__($indx, true) . ' ' . __($k, true)] = $module[$k];
                     }
                 }
             }
             $i++;
         }
         $this->set('tickets', $data_ticket);
     }
 }
Example #8
0
 /**
  * initialize method
  *
  * Merge settings and set Config.language to a valid locale
  *
  * @return void
  * @access public
  */
 function initialize(&$Controller, $config = array())
 {
     App::import('Vendor', 'Mi.MiCache');
     $lang = MiCache::setting('Site.lang');
     if (!$lang) {
         if (!defined('DEFAULT_LANGUAGE')) {
             return;
         }
         $lang = DEFAULT_LANGUAGE;
     } elseif (!defined('DEFAULT_LANGUAGE')) {
         define('DEFAULT_LANGUAGE', $lang);
     }
     Configure::write('Config.language', $lang);
     App::import('Core', 'I18n');
     $I18n =& I18n::getInstance();
     $I18n->domain = 'default_' . $lang;
     $I18n->__lang = $lang;
     $I18n->l10n->get($lang);
     if (!empty($Controller->plugin)) {
         $config['plugins'][] = Inflector::underscore($Controller->plugin);
     }
     if (!empty($config['plugins'])) {
         $plugins = array_intersect(MiCache::mi('plugins'), $config['plugins']);
         $Inst = App::getInstance();
         foreach ($plugins as $path => $name) {
             $Inst->locales[] = $path . DS . 'locale' . DS;
         }
     }
 }
Example #9
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 #10
0
 /**
  * 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);
         }
     }
 }
Example #11
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);
         }
     }
 }
 /**
  * Configuration method.
  *
  * In addition to configuring the settings (see $__defaults above for settings explanation),
  * this function also loops through the installed plugins and 'registers' those that have a
  * PluginNameCallback class.
  *
  * @param object $controller    Controller object
  * @param array $settings       Component settings
  * @access public
  * @return void
  */
 public function initialize(&$controller, $settings = array())
 {
     $this->__controller =& $controller;
     $this->settings = array_merge($this->__defaults, $settings);
     if (empty($this->settings['priority'])) {
         $this->settings['priority'] = Configure::listobjects('plugin');
     } else {
         foreach (Configure::listobjects('plugin') as $plugin) {
             if (!in_array($plugin, $this->settings['priority'])) {
                 array_push($this->settings['priority'], $plugin);
             }
         }
     }
     foreach ($this->settings['priority'] as $plugin) {
         $file = Inflector::underscore($plugin) . '_callback';
         $className = $plugin . 'Callback';
         if (App::import('File', $className, true, array(APP . 'plugins' . DS . Inflector::underscore($plugin)), $file . '.php')) {
             if (class_exists($className)) {
                 $class = new $className();
                 ClassRegistry::addObject($className, $class);
                 $this->__registered[] = $className;
             }
         }
     }
     /**
      * Called before the controller's beforeFilter method.
      */
     $this->executeCallbacks('initialize');
 }
 function login()
 {
     Configure::write('debug', 0);
     if ($this->Auth->isAuthorized()) {
         $this->redirect('/fams/index');
     }
 }
 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 #15
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;
 }
 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 #17
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 setUp()
 {
     parent::setUp();
     Configure::write('Routing.prefixes', ['admin']);
     Router::reload();
     $this->Html = new HtmlExtHelper(new View(null));
 }
Example #19
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));
 }
Example #20
0
 public function beforeFilter()
 {
     parent::beforeFilter();
     Configure::write('debug', 0);
     $this->layout = 'ajax';
     $this->autoRender = false;
 }
 /**
  * index method
  *
  * @return void
  */
 public function download()
 {
     $this->set('employees', $this->Employee->find('all', array('fields' => array('id', 'first_name', 'last_name', 'address', 'city', 'home_phone', 'hire_date', 'gender', 'date_of_birth', 'status', 'employment_type', 'designation'))));
     $this->layout = null;
     $this->autoLayout = false;
     Configure::write('debug', '0');
 }
 public function download()
 {
     $this->set('vendormasters', $this->VendorMaster->find('all', array('fields' => array('id', 'vendor_type', 'name', 'address', 'phone_number', 'fax', 'setup_date', 'email', 'pc_name', 'pc_phone', 'pc_email', 'pc_fax', 'sc_name', 'sc_phone', 'sc_email', 'sc_fax', 'payment_term', 'tax', 'notes'))));
     $this->layout = null;
     $this->autoLayout = false;
     Configure::write('debug', '0');
 }
Example #23
0
 public function tearDown()
 {
     parent::tearDown();
     $this->Data->cleanUp();
     ClassRegistry::flush();
     Configure::write('Media', $this->oldConfig);
 }
 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));
         }
     }
 }
 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);
 }
 public function __construct(ComponentCollection $collection, $settings = array())
 {
     if (Configure::read('Sermepa')) {
         $settings = $settings + Configure::read('Sermepa');
     }
     parent::__construct($collection, $settings);
 }
Example #27
0
 function admin_index()
 {
     $this->City->recursive = 0;
     $filters = $this->AlaxosFilter->get_filter();
     $data_city = array();
     if (empty($this->params['named']['export_excel'])) {
         $this->set('cities', $this->paginate($this->City, $filters));
     } else {
         Configure::write('debug', 0);
         $options = array();
         $this->set('export_to_excel', 1);
         $i = 0;
         $cities = $this->City->find('all', array_merge_recursive($options, array('conditions' => $filters)));
         foreach ($cities as $city) {
             foreach ($city as $indx => $module) {
                 foreach ($module as $k => $v) {
                     $arr_fields_in_xls = array();
                     if (!empty($arr_fields_in_xls) && in_array($k, $arr_fields_in_xls[$indx])) {
                         $data_city[$i][__($indx, true) . ' ' . __($k, true)] = $module[$k];
                     } else {
                         $data_city[$i][__($indx, true) . ' ' . __($k, true)] = $module[$k];
                     }
                 }
             }
             $i++;
         }
         $this->set('cities', $data_city);
     }
     $districts = $this->City->District->find('list');
     $this->City->bindModel(array('belongsTo' => array('State' => array('className' => 'State', 'foreignKey' => '', 'conditions' => 'State.id = District.state_id', 'fields' => '', 'order' => ''))));
     $states = $this->City->State->find('list');
     $this->set(compact('districts', 'states'));
 }
 /**
  * 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;
 }
Example #29
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;
 }
Example #30
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));
 }