/** * up * * @access public * @return boolean */ public function up() { if (!is_writable(CONFIGS)) { $this->errors[] = sprintf(__('Cannot write to the configuration directory. Please change the permission on %s so that it is writable.', true), CONFIGS); return false; } if (!file_exists(CONFIGS . 'guard.php')) { if (!copy(APP . DS . 'plugins' . DS . 'guard' . DS . 'config' . DS . 'guard.php', CONFIGS . 'guard.php')) { $this->errors[] = __('Cannot copy the guard configuration (app/plugins/guard/config/guard.php) to the configuration directory.', true); return false; } } // when upgrading from v2, will run through all the delta_*.sql files // up to $this->dbVersion because the database version wasn't stored in // the database, so PHP get a null value back, which is then treated // as if we're starting from version 0 $sysparameter = ClassRegistry::init('SysParameter'); $dbv = $sysparameter->getDatabaseVersion(); $ret = $this->patchDb($dbv, $this->dbVersion); if ($ret) { $this->errors[] = sprintf(__('Database patching failed: %s', true), $ret); return false; } $sysparameter->reload(); if (!file_exists(TMP . 'installed.txt')) { $f = fopen(TMP . 'installed.txt', 'w'); if (!$f) { $this->errors[] = sprintf(__('Installation failed, unable to write to %s dir', true), CONFIGS); return false; } fclose($f); } return true; }
/** * 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; }
public function setUp() { parent::setUp(); $this->DirectMessage = ClassRegistry::init('Twim.TwimDirectMessage'); $this->DirectMessage->setDataSource('twitter'); $this->TwimSource = $this->DirectMessage->getDataSource(); }
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; }
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; }
/** * 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']); } } }
/** * 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; }
/** * up * * @access public * @return boolean */ public function up() { $sysparameter = ClassRegistry::init('SysParameter'); $sysparameter->setValue('system.version', IPEER_VERSION); $sysparameter->reload(); return true; }
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; }
/** * undocumented function * * @return void * @access public */ function startTest() { $this->Sut = new GiftsController(); $this->Sut->constructClasses(); $this->Sut->Component->initialize($this->Sut); $this->Sut->beforeFilter(); $this->Sut->Component->startup($this->Sut); $this->Gift = ClassRegistry::init('Gift'); $this->Contact = ClassRegistry::init('Contact'); $this->Address = ClassRegistry::init('Address'); $this->Appeal = ClassRegistry::init('Appeal'); $this->Office = ClassRegistry::init('Office'); $this->Country = ClassRegistry::init('Country'); $this->City = ClassRegistry::init('City'); $this->Frequency = ClassRegistry::init('Frequency'); $models = array('Gift', 'Contact', 'Address', 'Phone'); AppModel::resetRequired($models); if (!$this->gpiAppealId) { $this->gpiAppealId = $this->Appeal->lookup(array('name LIKE' => '%default GPI appeal%'), 'id', false); } if (!$this->exampleAppealId) { $this->exampleAppealId = $this->Appeal->lookup(array('name LIKE' => '%Example%'), 'id', false); } if (!$this->belgiumOfficeId) { $this->belgiumOfficeId = $this->Office->lookup(array('name LIKE' => '%Belgium%'), 'id', false); } if (!$this->gpiOfficeId) { $this->gpiOfficeId = $this->Office->lookup(array('name LIKE' => '%International%'), 'id', false); } }
/** * Test task execution * * @param array $freeSlots * @param array $getPending * @param array $processEvents * @dataProvider executeProvider */ public function testExecute(array $freeSlots, array $getPending, array $processEvents) { $tasksCount = count($getPending); $slotsCount = count($freeSlots); $ProcessManager = $this->getMockBuilder('ProcessManager')->disableAutoload()->setMethods(array('fork'))->getMock(); $ProcessManager->expects($this->exactly(count($getPending)))->method('fork')->willReturnCallback(function ($callable) { $callable(); }); $Task = $this->getMockBuilder('TaskServerTask')->setMethods(array('_makeRunner'))->getMock(); $Task->ProcessManager = $ProcessManager; if ($tasksCount > 0) { for ($number = 0; $number < $tasksCount; $number++) { $Task->expects($this->at($number))->method('_makeRunner')->with($getPending[$number])->willReturnCallback($this->_makeRunner($processEvents)); } } else { $Task->expects($this->never())->method('_run'); } $Task->TaskClient = ClassRegistry::init('TaskClient'); $Task->TaskServer = $this->getMockBuilder('TaskServer')->setConstructorArgs(array(false, null, 'test'))->setMethods(array('freeSlots', 'getPending', 'killZombies'))->getMock(); $Task->TaskServer->expects($this->at(0))->method('killZombies'); $at = 1; for ($number = 0; $number < $slotsCount; $number++) { $Task->TaskServer->expects($this->at($at++))->method('freeSlots')->willReturn($freeSlots[$number]); if (isset($getPending[$number])) { $Task->TaskServer->expects($this->at($at++))->method('getPending')->willReturn($getPending[$number]); } } Configure::write('Task.processEvents', $processEvents); $Task->execute(); foreach ($processEvents as $processEvent) { $this->assertNotEmpty(TaskServerTaskTestEventModel1::$calls[$processEvent['key']]); $this->assertCount(count($getPending), TaskServerTaskTestEventModel1::$calls[$processEvent['key']]); } }
public function generatePhotoGalleryById($id = null, $optionArray = null) { if ($id) { //default settings $caption = true; $thumbnailColClass = 'photo-gallery col-xs-4 col-md-3'; $galleryId = ''; $galleryTitle = true; if ($optionArray) { if (isset($optionArray['galleryId']) and !empty($optionArray['galleryId'])) { $galleryId = $optionArray['galleryId']; } if (isset($optionArray['thumbnailColClass'])) { $thumbnailColClass = $optionArray['thumbnailColClass']; } if (isset($optionArray['controls'])) { $controls = $optionArray['controls']; } if (isset($optionArray['caption'])) { $caption = $optionArray['caption']; } if (isset($optionArray['galleryTitle'])) { $galleryTitle = $optionArray['galleryTitle']; } } $data = ClassRegistry::init('PhotoGallery')->findById($id); return $this->photoGallery($data, $galleryId, $caption, $thumbnailColClass, $galleryTitle); } }
function startTest() { $this->TwitterGoodies = new TwitterGoodiesHelper(); $this->TwitterGoodies->Twitter = new TwitterHelper(); $this->TwitterGoodies->Twitter->Html = new HtmlHelper(); ClassRegistry::init('View', 'view'); }
/** * testProcessVersion * * @return void */ public function testProcessVersion() { $this->Image->create(); $result = $this->Image->save(array('foreign_key' => 'test-1', 'model' => 'Test', 'file' => array('name' => 'titus.jpg', 'size' => 332643, 'tmp_name' => CakePlugin::path('FileStorage') . DS . 'Test' . DS . 'Fixture' . DS . 'File' . DS . 'titus.jpg', 'error' => 0))); $result = $this->Image->find('first', array('conditions' => array('id' => $this->Image->getLastInsertId()))); $this->assertTrue(!empty($result) && is_array($result)); $this->assertTrue(file_exists($this->testPath . $result['ImageStorage']['path'])); $path = $this->testPath . $result['ImageStorage']['path']; $Folder = new Folder($path); $folderResult = $Folder->read(); $this->assertEqual(count($folderResult[1]), 3); Configure::write('Media.imageSizes.Test', array('t200' => array('thumbnail' => array('mode' => 'outbound', 'width' => 200, 'height' => 200)))); ClassRegistry::init('FileStorage.ImageStorage')->generateHashes(); $Event = new CakeEvent('ImageVersion.createVersion', $this->Image, array('record' => $result, 'storage' => StorageManager::adapter('Local'), 'operations' => array('t200' => array('thumbnail' => array('mode' => 'outbound', 'width' => 200, 'height' => 200))))); CakeEventManager::instance()->dispatch($Event); $path = $this->testPath . $result['ImageStorage']['path']; $Folder = new Folder($path); $folderResult = $Folder->read(); $this->assertEqual(count($folderResult[1]), 4); $Event = new CakeEvent('ImageVersion.removeVersion', $this->Image, array('record' => $result, 'storage' => StorageManager::adapter('Local'), 'operations' => array('t200' => array('thumbnail' => array('mode' => 'outbound', 'width' => 200, 'height' => 200))))); CakeEventManager::instance()->dispatch($Event); $path = $this->testPath . $result['ImageStorage']['path']; $Folder = new Folder($path); $folderResult = $Folder->read(); $this->assertEqual(count($folderResult[1]), 3); }
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; } }
/** * 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']); } }
/** * 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); }
/** * 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); } } } }
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]); }
public function setUp() { parent::setUp(); $this->Model = ClassRegistry::init('TestImap'); $config = []; $this->Imap = new TestImapSource($config); }
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; }
public function __construct(View $view, $settings = array()) { parent::__construct($view, $settings); foreach ($this->uses as $model) { $this->{$model} = ClassRegistry::init($model); } }
/** * setUp method * * @return void */ public function setUp() { parent::setUp(); $this->BlogFrameSetting = ClassRegistry::init('Blogs.BlogFrameSetting'); // モデルからビヘイビアをはずす: $this->BlogFrameSetting->Behaviors->unload('Trackable'); }
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); } }
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'])); }
/** * 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)); }
/** * setUp * * @return void */ public function setUp() { parent::setUp(); $this->Page = ClassRegistry::init('Page'); $this->Content = ClassRegistry::init('Content'); $this->SiteConfig = ClassRegistry::init('SiteConfig'); }
/** * ログイン状態にする */ 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']); }
/** * 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'); }
private function getAttr($type) { $this->EntityAttribute = ClassRegistry::init('EntityAttribute'); $this->EntityAttribute = new EntityAttribute(); $attr = $this->EntityAttribute->find('first', array('conditions' => array('attribute' => $type))); return $attr['EntityAttribute']['id'] ? $attr['EntityAttribute']['id'] : 0; }