Exemplo n.º 1
0
 function _findFeed(&$Model, $state, $query, $results = array())
 {
     if ($state == 'before') {
         if (!isset($query['feed'])) {
             return $query;
         }
         $DboMysql = Connectionmanager::getDataSource($Model->useDbConfig);
         $sql = '';
         foreach ((array) $query['feed'] as $key => $feed) {
             $feed = array_merge($this->basicStatement, $feed);
             $sql .= ' UNION ';
             $currentModel = ClassRegistry::init($key);
             $setup = explode(' AND ', str_replace(array('=', '`'), array('AS', '\''), $DboMysql->conditions(array_flip($feed['setup']), false, false)));
             $sql .= $DboMysql->renderStatement('select', array('fields' => implode(', ', array_merge($DboMysql->fields($currentModel, null, (array) $feed['fields']), $setup)), 'table' => $DboMysql->fullTableName($currentModel), 'alias' => $currentModel->alias, 'joins' => '', 'conditions' => $DboMysql->conditions($feed['conditions']), 'group' => '', 'order' => $DboMysql->order($feed['order']), 'limit' => $DboMysql->limit($feed['limit'])));
         }
         $query = array_merge($this->basicStatement, $query);
         $setup = explode(' AND ', str_replace(array('=', '`'), array('AS', '\''), $DboMysql->conditions(array_flip($query['setup']), false, false)));
         $sql = $DboMysql->renderStatement('select', array('fields' => implode(', ', array_merge($DboMysql->fields($Model, null, (array) $query['fields']), $setup)), 'table' => $DboMysql->fullTableName($Model), 'alias' => $Model->alias, 'joins' => '', 'conditions' => $DboMysql->conditions($query['conditions']), 'group' => $sql, 'order' => $DboMysql->order($query['order']), 'limit' => $DboMysql->limit($query['limit'])));
         $_results = $Model->query($sql);
         foreach ($_results as $res) {
             $this->_results[]['Feed'] = $res[0];
         }
         return $query;
     } elseif ($state == 'after') {
         return $this->_results;
     }
     return false;
 }
 public function setUp()
 {
     parent::setUp();
     $this->DirectMessage = ClassRegistry::init('Twim.TwimDirectMessage');
     $this->DirectMessage->setDataSource('twitter');
     $this->TwimSource = $this->DirectMessage->getDataSource();
 }
Exemplo n.º 3
0
 /**
  * End a test
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     unset($this->Article);
     ClassRegistry::flush();
     DebugKitDebugger::clearTimers();
 }
 public function get_twitter_tweets_group_by_types($types, $order)
 {
     foreach ($types as &$t) {
         $t = array('id' => $t, 'search' => ClassRegistry::init('Dane.Dataobject')->find('all', array('conditions' => array('dataset' => 'twitter', 'twitter_accounts.typ_id' => $t, '!bez_retweetow' => '1', 'czas_utworzenia' => '2013-*'), 'order' => $order, 'limit' => 3)));
     }
     return $types;
 }
Exemplo n.º 5
0
 /**
  * Return roles_rooms_users
  *
  * @param array $conditions Conditions by Model::find
  * @return array
  */
 public function getRolesRoomsUsers($conditions = array())
 {
     $this->Room = ClassRegistry::init('Rooms.Room');
     $conditions = Hash::merge(array('Room.page_id_top NOT' => null), $conditions);
     $rolesRoomsUsers = $this->find('all', array('recursive' => -1, 'fields' => array($this->alias . '.*', $this->RolesRoom->alias . '.*', $this->Room->alias . '.*'), 'joins' => array(array('table' => $this->RolesRoom->table, 'alias' => $this->RolesRoom->alias, 'type' => 'INNER', 'conditions' => array($this->alias . '.roles_room_id' . ' = ' . $this->RolesRoom->alias . ' .id')), array('table' => $this->Room->table, 'alias' => $this->Room->alias, 'type' => 'INNER', 'conditions' => array($this->RolesRoom->alias . '.room_id' . ' = ' . $this->Room->alias . ' .id'))), 'conditions' => $conditions));
     return $rolesRoomsUsers;
 }
Exemplo n.º 6
0
 /**
  * Constructor
  *
  */
 public function __construct()
 {
     parent::__construct();
     $this->Permission = ClassRegistry::init(array('class' => 'Permission', 'alias' => 'Permission'));
     $this->Aro = $this->Permission->Aro;
     $this->Aco = $this->Permission->Aco;
 }
Exemplo n.º 7
0
 public function beforeSave($options = array())
 {
     $State = ClassRegistry::init('State');
     //$basketballTeam = new BasketballTeam();
     $state = $State->field('name', array('id' => $this->data['Insurance']['state_id']));
     $this->data['Insurance']['state'] = $state;
 }
Exemplo n.º 8
0
 function responsePreprocess()
 {
     $ipn = ClassRegistry::init("PaypalIpn.InstantPaymentNotification");
     if ($ipn->isValid($_POST)) {
         $notification = $ipn->buildAssociationsFromIPN($_POST);
         $ipn->saveAll($notification);
         if ($_POST["payment_status"] == "Completed") {
             if (isset($_POST['test_ipn'])) {
                 $this->payment['ShopPayment']['dev_mode'] = 1;
                 $data = array('id' => $this->payment['ShopPayment']['id'], 'dev_mode' => $this->payment['ShopPayment']['dev_mode']);
                 $this->ShopPayment->create();
                 $this->ShopPayment->save($data);
             }
             $this->PaymentFunct->setStatus($this->payment, "approved");
         } else {
             $this->log('Incomplete payment', LOG_DEBUG);
         }
         /*$conf = Configure::read('Shop.emailAdmin');
         		$this->Email->to = $conf['to'];
         		$this->Email->subject = "test module paypal";
         		$this->Email->sendAs = 'html';
         		$this->Email->template = 'shop_test';
         		$this->set('payment', $this->payment);
         		if(!$this->Email->send()){
         			Debugger::log('response email not sent');
         		}else{
         			Debugger::log('response email sent');
         		}*/
     } else {
         $this->log('Invalide Paypal IPN response', LOG_DEBUG);
         $this->log($_POST, LOG_DEBUG);
     }
 }
 /**
  * SetUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Configure::write('Config.language', 'deu');
     Configure::delete('Passwordable');
     Configure::write('Passwordable.auth', 'AuthTest');
     $this->User = ClassRegistry::init('Tools.ToolsUser');
     if (isset($this->User->validate['pwd'])) {
         unset($this->User->validate['pwd']);
     }
     if (isset($this->User->validate['pwd_repeat'])) {
         unset($this->User->validate['pwd_repeat']);
     }
     if (isset($this->User->validate['pwd_current'])) {
         unset($this->User->validate['pwd_current']);
     }
     if (isset($this->User->order)) {
         unset($this->User->order);
     }
     $this->User->create();
     $data = ['id' => '5', 'name' => 'admin', 'password' => Security::hash('somepwd', null, true), 'role_id' => '1'];
     $this->User->set($data);
     $result = $this->User->save();
     $this->assertTrue((bool) $result);
     Router::setRequestInfo(new CakeRequest(null, false));
 }
Exemplo n.º 10
0
 public function __construct(View $view, $settings = array())
 {
     parent::__construct($view, $settings);
     foreach ($this->uses as $model) {
         $this->{$model} = ClassRegistry::init($model);
     }
 }
 /**
  * Tear Down
  * 
  * @author	Everton Yoshitani <*****@*****.**>
  * @since	1.0
  * @return	void 
  */
 public function tearDown()
 {
     parent::tearDown();
     unset($this->ApiBehavior);
     unset($this->Thing);
     ClassRegistry::flush();
 }
Exemplo n.º 12
0
 public function setUp()
 {
     parent::setUp();
     $this->Model = ClassRegistry::init('TestImap');
     $config = [];
     $this->Imap = new TestImapSource($config);
 }
Exemplo n.º 13
0
 /**
  * Return readable fields
  *
  * @param Model $model Model using this behavior
  * @return void
  */
 private function __prepare(Model $model)
 {
     $this->UserAttribute = ClassRegistry::init('UserAttributes.UserAttribute');
     $this->UserAttributesRole = ClassRegistry::init('UserRoles.UserAttributesRole');
     if (!isset($this->__readableFields)) {
         $results = $this->UserAttributesRole->find('list', array('recursive' => -1, 'fields' => array('user_attribute_key', 'user_attribute_key'), 'conditions' => array('role_key' => AuthComponent::user('role_key'), 'other_readable' => true)));
         $this->__readableFields = array('id');
         foreach ($results as $key => $field) {
             //Fieldのチェック
             if ($model->hasField($field)) {
                 $this->__readableFields[$key] = $model->escapeField($field);
             }
             if ($model->UsersLanguage->hasField($field)) {
                 $this->__readableFields[$key] = $model->UsersLanguage->escapeField($field);
             }
             //Field(is_xxxx_public)のチェック
             $fieldKey = sprintf(UserAttribute::PUBLIC_FIELD_FORMAT, $field);
             if ($model->hasField($fieldKey)) {
                 $this->__readableFields[$fieldKey] = $model->escapeField($fieldKey);
             }
             //Field(xxxx_file_id)のチェック
             $fieldKey = sprintf(UserAttribute::FILE_FIELD_FORMAT, $field);
             if ($model->hasField($fieldKey)) {
                 $this->__readableFields[$fieldKey] = $model->escapeField($fieldKey);
             }
         }
     }
 }
 /**
  * Called after the Controller::beforeFilter() and before the controller action
  *
  * @param Controller $controller Controller with components to startup
  * @return void
  * @link http://book.cakephp.org/2.0/en/controllers/components.html#Component::startup
  */
 public function startup(Controller $controller)
 {
     //RequestActionの場合、スキップする
     if (!empty($controller->request->params['requested'])) {
         return;
     }
     $this->controller = $controller;
     //Modelの呼び出し
     $this->Plugin = ClassRegistry::init('PluginManager.Plugin');
     //Pluginデータ取得
     $this->plugins = $this->Plugin->getPlugins(Plugin::PLUGIN_TYPE_FOR_CONTROL_PANEL, $this->controller->viewVars['languageId']);
     //Layoutのセット
     $this->controller->layout = 'ControlPanel.default';
     //cancelUrlをセット
     $this->controller->set('cancelUrl', '/');
     $this->controller->set('isControlPanel', true);
     $this->controller->set('hasControlPanel', true);
     //ページHelperにセット
     $this->controller->set('pluginsMenu', $this->plugins);
     if (isset($this->settings['plugin'])) {
         $plugin = $this->settings['plugin'];
     } else {
         $plugin = $this->controller->params['plugin'];
     }
     $plugin = Hash::extract($this->plugins, '{n}.Plugin[key=' . $plugin . ']');
     if (isset($plugin[0]['name']) && !isset($this->controller->viewVars['title'])) {
         $this->controller->set('title', $plugin[0]['name']);
     }
 }
Exemplo n.º 15
0
 /**
  * tearDown method
  *
  * @return void
  */
 public function tearDown()
 {
     unset($this->Task);
     ClassRegistry::flush();
     App::build();
     parent::tearDown();
 }
Exemplo n.º 16
0
 public function endTest()
 {
     $this->unloadSettings();
     $this->Searches->Session->destroy();
     unset($this->Searches);
     ClassRegistry::flush();
 }
 public function setUp()
 {
     parent::setUp();
     Configure::delete('Localization');
     $this->Model = ClassRegistry::init('PaymentMethod');
     $this->Model->Behaviors->load('Tools.DecimalInput', ['fields' => ['rel_rate', 'set_rate'], 'output' => true]);
 }
Exemplo n.º 18
0
 /**
  * ログイン状態にする
  */
 protected function _login()
 {
     $User = ClassRegistry::init('User');
     $user = $User->find('first', array('conditions' => array('User.id' => 1), 'recursive' => -1));
     unset($user['User']['password']);
     $this->BcBaser->set('user', $user['User']);
 }
 public function afterSave($model, $created)
 {
     $allowed = true;
     if (empty($model->data)) {
         $model->data = $model->read();
     }
     if (!empty($this->settings[$model->alias]['scope'])) {
         foreach ($this->settings[$model->alias]['scope'] as $field => $value) {
             if ($model->data[$model->alias][$field] != $value) {
                 $allowed = false;
             }
         }
     }
     if (empty($model->data[$model->alias]['title'])) {
         $allowed = false;
     }
     if ($allowed) {
         $tweet = $model->data[$model->alias]['title'];
         if (!empty($this->settings[$model->alias]['append'])) {
             $tweet .= ' ';
             $tweet .= $this->settings[$model->alias]['append'];
         }
         $TwitterStatuses = ClassRegistry::init('Twitter.TwitterStatuses');
         if ($TwitterStatuses->update($tweet)) {
             Cache::clear();
         }
     }
     return true;
 }
Exemplo n.º 20
0
 function getBilanServiceWithLoop($id = 'all')
 {
     //  Méthode 2 : à l'aide d'une d'une boucle
     //ToDo
     $this->MatieresPerso =& ClassRegistry::init('MatieresPerso');
     $this->MatieresPerso->recursive = -1;
     if ($id == 'all' or $id == null) {
         $temp = $this->MatieresPerso->find('all');
         //$h = array('h_cours'=>0, 'h_td'=>0, 'h_tp'=>0);
         /*
         foreach ( $temp as $key => $matieresperso  ) {
         	$h['h_cours'] = $h['h_cours'] + $matieresperso['MatieresPerso']['h_cours'];
         	$h['h_td'] = $h['h_td'] + $matieresperso['MatieresPerso']['h_td'];
         	$h['h_tp'] = $h['h_tp'] + $matieresperso['MatieresPerso']['h_tp'];				
         }
         return $result;
         */
         //return $temp;
         // ToDo ToFix
         return "ToDo";
     } else {
         $temp = $this->MatieresPerso->find('all', array('conditions' => array('perso_id' => $id)));
         $h = array('h_cours' => 0, 'h_td' => 0, 'h_tp' => 0);
         foreach ($temp as $key => $matieresperso) {
             $h['h_cours'] = $h['h_cours'] + $matieresperso['MatieresPerso']['h_cours'];
             $h['h_td'] = $h['h_td'] + $matieresperso['MatieresPerso']['h_td'];
             $h['h_tp'] = $h['h_tp'] + $matieresperso['MatieresPerso']['h_tp'];
         }
         return $h;
     }
 }
Exemplo n.º 21
0
 /**
  * setUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->BlogFrameSetting = ClassRegistry::init('Blogs.BlogFrameSetting');
     // モデルからビヘイビアをはずす:
     $this->BlogFrameSetting->Behaviors->unload('Trackable');
 }
Exemplo n.º 22
0
 /**
  * 	
  * 	Generates nested unordered lists, with support for marking currently selected items
  * 	
  * 	$data = nested array of page results
  * 	
  * 	$settings = array with these keys:
  * 
  * 	currentPath = array of IDs of the currently active item and all its parents. 
  * 			each item when rendered is checked to see if it is in this array, and if so, 
  * 			gets 'class="selected" added to its <li> tag
  * 
  * 	initialDepth = how many levels should be expanded past the root. true means infinite, 
  * 			integer means number of levels to show. (currentPath items and their siblings 
  * 			are always shown - this is how to produce "open" branches.)
  * 	
  * 	depthLimit = not implemented yet - should stop us from opening the tree out too far - 
  * 			so that sub pages don't necessarily show up even if they are currently being viewed
  * 	
  * 	baseListId = ID of the root UL
  * 	
  * 	baseListClass = class to apply to the root UL
  * 	
  * 	TODO: allow custom HTML code for each item - so that edit/delete links could be output too. float:right with css?
  * 	
  * 	TODO: add a check for show_in_menu as treebehaviour->children() doesn't support find conditions
  * 	
  * 	
  */
 function generate($data, $settings = array())
 {
     $this->myview = ClassRegistry::getObject('view');
     $this->return = '';
     $this->__generate($data, $settings);
     return $this->return;
 }
Exemplo n.º 23
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']));
 }
Exemplo n.º 24
0
 /**
  * Find a user record using the standard options.
  *
  * The $conditions parameter can be a (string)username or an array containing conditions for Model::find('first'). If
  * the password field is not included in the conditions the password will be returned.
  *
  * @param Mixed $conditions The username/identifier, or an array of find conditions.
  * @param Mixed $password The password, only use if passing as $conditions = 'username'.
  * @return Mixed Either false on failure, or an array of user data.
  */
 protected function _findUser($conditions, $password = null)
 {
     $userModel = $this->settings['userModel'];
     list(, $model) = pluginSplit($userModel);
     $fields = $this->settings['fields'];
     if (!is_array($conditions)) {
         if (!$password) {
             return false;
         }
         $username = $conditions;
         $conditions = array($model . '.' . $fields['username'] => $username, $model . '.' . $fields['password'] => $this->_password($password));
     }
     if (!empty($this->settings['scope'])) {
         $conditions = array_merge($conditions, $this->settings['scope']);
     }
     $result = ClassRegistry::init($userModel)->find('first', array('conditions' => $conditions, 'recursive' => $this->settings['recursive'], 'contain' => $this->settings['contain']));
     if (empty($result) || empty($result[$model])) {
         return false;
     }
     $user = $result[$model];
     if (isset($conditions[$model . '.' . $fields['password']]) || isset($conditions[$fields['password']])) {
         unset($user[$fields['password']]);
     }
     unset($result[$model]);
     return array_merge($user, $result);
 }
 /**
  * setUp
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->Page = ClassRegistry::init('Page');
     $this->Content = ClassRegistry::init('Content');
     $this->SiteConfig = ClassRegistry::init('SiteConfig');
 }
Exemplo n.º 26
0
 /**
  * acl and auth
  *
  * @return void
  */
 public function auth()
 {
     //Configure AuthComponent
     $this->_controller->Auth->authenticate = array(AuthComponent::ALL => array('userModel' => 'User', 'fields' => array('username' => 'username', 'password' => 'password'), 'scope' => array('User.status' => 1)), 'Form');
     $actionPath = 'controllers';
     $this->_controller->Auth->authorize = array(AuthComponent::ALL => array('actionPath' => $actionPath), 'Actions');
     $this->_controller->Auth->loginAction = array('plugin' => null, 'controller' => 'users', 'action' => 'login');
     $this->_controller->Auth->logoutRedirect = array('plugin' => null, 'controller' => 'users', 'action' => 'login');
     $this->_controller->Auth->loginRedirect = array('plugin' => null, 'controller' => 'users', 'action' => 'index');
     if ($this->_controller->Auth->user() && $this->_controller->Auth->user('role_id') == 1) {
         // Role: Admin
         $this->_controller->Auth->allow();
     } else {
         if ($this->_controller->Auth->user()) {
             $roleId = $this->_controller->Auth->user('role_id');
         } else {
             $roleId = 3;
             // Role: Public
         }
         $allowedActions = ClassRegistry::init('Acl.AclPermission')->getAllowedActionsByRoleId($roleId);
         $linkAction = Inflector::camelize($this->_controller->request->params['controller']) . '/' . $this->_controller->request->params['action'];
         if (in_array($linkAction, $allowedActions)) {
             $this->_controller->Auth->allowedActions = array($this->_controller->request->params['action']);
         }
     }
 }
 /**
  * startTest
  *
  * @return void
  */
 public function startTest()
 {
     $this->cache_path = CACHE . 'models' . DS;
     Cache::config('default', array('prefix' => 'cake_', 'engine' => 'File', 'path' => $this->cache_path, 'duration' => '+1 hour'));
     $this->Article = ClassRegistry::init('Article');
     $this->User = ClassRegistry::init('User');
 }
 function tearDown()
 {
     Configure::write('Media', $this->_config);
     $this->TestData->flushFiles();
     $this->TmpFolder->delete();
     ClassRegistry::flush();
 }
Exemplo n.º 29
0
 public function tearDown()
 {
     parent::tearDown();
     $this->Data->cleanUp();
     ClassRegistry::flush();
     Configure::write('Media', $this->oldConfig);
 }
Exemplo n.º 30
0
 /**
  * up
  *
  * @access public
  * @return boolean
  */
 public function up()
 {
     $sysparameter = ClassRegistry::init('SysParameter');
     $sysparameter->setValue('system.version', IPEER_VERSION);
     $sysparameter->reload();
     return true;
 }