当前位置: 首页>>代码示例>>PHP>>正文


PHP Common::getModel方法代码示例

本文整理汇总了PHP中Common::getModel方法的典型用法代码示例。如果您正苦于以下问题:PHP Common::getModel方法的具体用法?PHP Common::getModel怎么用?PHP Common::getModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Common的用法示例。


在下文中一共展示了Common::getModel方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: beforeRender

 /**
  * Before Render hook function
  * @see AppHelper::beforeRender
  */
 function beforeRender()
 {
     if (!isset($this->model)) {
         $this->model = Common::getModel('Action');
         // initialize model or get it back
     }
 }
开发者ID:stripthis,项目名称:BlackRabbit,代码行数:11,代码来源:actions.php

示例2: beforeFilter

 /**
  * Before filter function redefinition
  * @see Controller::beforeFilter
  */
 function beforeFilter()
 {
     parent::beforeFilter();
     $this->models = array_keys(Configure::read('App.favorites.models'), true);
     foreach ($this->models as $model) {
         $this->{$model} = Common::getModel($model);
         $this->Favorite->bindModel(array('belongsTo' => array($model => array('foreignKey' => 'foreign_id'))));
     }
 }
开发者ID:stripthis,项目名称:BlackRabbit,代码行数:13,代码来源:favorites_controller.php

示例3: get

 /**
  * Get the last n user log entries grouped by location
  * @param int $limit
  * @return array $results
  */
 static function get($limit = 5)
 {
     $_this = Common::getModel('UserLog');
     $results = $_this->find('all', array('fields' => array('resource', 'resource_id', 'get_data_url', 'get_data_named', 'action', 'user_id', 'MAX(UserLog.created) as created'), 'conditions' => array('user_id' => User::get('id'), 'resource_type' => 'controller'), 'group' => array('resource_type', 'action', 'get_data_url'), 'order' => 'created DESC', 'limit' => $limit));
     foreach ($results as $i => $value) {
         $results[$i]['UserLog']['created'] = $results[$i][0]['created'];
         unset($results[$i][0]);
     }
     //pr($results);
     return $results;
 }
开发者ID:stripthis,项目名称:BlackRabbit,代码行数:16,代码来源:user_log.php

示例4: link

 /**
  * Generate a link with the proper stared/unstared picture
  * @param $model
  * @param $uuid
  * @return string link
  */
 function link($uuid, $model, $isFavorited = null)
 {
     if (is_null($isFavorited)) {
         $isFavorited = Common::getModel('Favorite')->isFavorited($uuid, $model);
     }
     if (!$isFavorited) {
         $img = $this->Html->image($this->config['icons']['unfav'], array('alt' => __('unmark as favorite', true)));
         return $this->Html->link($img, array('controller' => 'favorites', 'action' => 'add', $uuid, $model), array('class' => 'star', 'escape' => false));
     } else {
         $img = $this->Html->image($this->config['icons']['fav'], array('alt' => __('mark as favorite', true)));
         return $this->Html->link($img, array('controller' => 'favorites', 'action' => 'delete', $uuid, $model), array('class' => 'star', 'escape' => false));
     }
 }
开发者ID:stripthis,项目名称:BlackRabbit,代码行数:19,代码来源:favorites.php

示例5: __bindArchivableModels

 /**
  * STATIC - Prepare static find
  * Bind models and define default find conditions
  * @param $_this instance of Favorites model
  * @param $conditions find conditions
  * @access private
  * @TODO move in archivable behavior?
  */
 static function __bindArchivableModels(&$_this, &$models, &$conditions, $archived)
 {
     $softDeleteModels = @array_keys(Configure::read('App.softdelete.models'), true);
     $softDeleteFields = Configure::read('App.softdelete.fields');
     $models = array_intersect($models, $softDeleteModels);
     $options = $hasManyOptions = array();
     //$conditions = array('Favorite.user_id' => User::get('id'));
     foreach ($models as $i => $model) {
         $options[$model] = array('foreignKey' => 'foreign_id');
         $Model = Common::getModel($model);
         $Model->bindModel(array('hasMany' => array('Favorite' => array('dependent' => true, 'foreignKey' => 'foreign_id'))), false);
         // dont retrieve archived records unless required
         foreach ($softDeleteFields as $field) {
             if (array_key_exists($field, $Model->_schema)) {
                 $alias = $Model->alias;
                 $value = $archived ? '1' : '0';
                 $conditions['conditions'][] = '(' . $alias . '.' . $field . '=' . $value . ' || ' . $alias . '.id IS NULL)';
             }
         }
     }
     $conditions['contain'] = $models;
     $_this->bindModel(array('belongsTo' => $options), false);
 }
开发者ID:stripthis,项目名称:BlackRabbit,代码行数:31,代码来源:favorite.php

示例6: setup

 /**
  * Initiate behavior for the model using settings.
  *
  * @param object $Model Model using the behaviour
  * @param array $settings Settings to override for model.
  * @access public
  */
 function setup(&$Model, $settings = array())
 {
     $this->__UserLog = Common::getModel('UserLog');
 }
开发者ID:stripthis,项目名称:BlackRabbit,代码行数:11,代码来源:loggable.php

示例7: initialize

 /**
  * Initialize
  * @param object $controller Controller using this component
  * @param array $settings
  * @return void
  * @access public
  */
 function initialize(&$controller, $settings = array())
 {
     $this->Controller =& $controller;
     $this->__UserLog = Common::getModel('UserLog');
     $this->Controller->UserLog =& $this->__UserLog;
 }
开发者ID:stripthis,项目名称:BlackRabbit,代码行数:13,代码来源:log.php

示例8: setActive

 /**
  * Set the user as current
  * @param array $user
  * @param bool $updateSession
  * @param bool $generateAuthCookie
  */
 static function setActive($user = null, $find = true)
 {
     $_this = Common::getModel('User');
     //@TODO only fetch if $user is incomplete compared to find conditions
     if ($find) {
         if ($user != 'guest' && isset($user['User']['id']) && Common::isUuid($user['User']['id'])) {
             $user = $_this->find('first', $_this->getFindOptions('userActivation', $user));
         }
         if ($user == 'guest' || is_null($user) || empty($user)) {
             $user = $_this->find('first', $_this->getFindOptions('guestActivation'));
         }
     }
     if (isset($user['User']['password'])) {
         unset($user['User']['password']);
         // just to make sure
     }
     Configure::write('User', $user);
     $Session = Common::getComponent('Session');
     $Session->write('User', $user);
     return $user;
 }
开发者ID:stripthis,项目名称:BlackRabbit,代码行数:27,代码来源:user.php

示例9: findUserId

 /**
  * undocumented function
  *
  * @param unknown $key 
  * @param unknown $auth_key_type_id 
  * @return void
  * @access public
  */
 static function findUserId($key, $auth_key_type_id = null)
 {
     $_this = Common::getModel('AuthKey');
     if (!empty($auth_key_type_id) && !ctype_digit($auth_key_type_id)) {
         $auth_key_type_id = $_this->AuthKeyType->lookup($auth_key_type_id, 'id', false);
     }
     if (!empty($auth_key_type_id) && !ctype_digit($auth_key_type_id)) {
         return false;
     }
     $conditions = compact('key');
     $recursive = -1;
     if (!empty($auth_key_type_id)) {
         $conditions['auth_key_type_id'] = $auth_key_type_id;
     }
     $authKey = $_this->find('first', compact('conditions', 'recursive'));
     if (empty($authKey)) {
         return false;
     }
     return $authKey['AuthKey']['user_id'];
 }
开发者ID:stripthis,项目名称:donate,代码行数:28,代码来源:auth_key.php

示例10: __validateInputAndGetUser

 /**
  * Validate auth related data and return a user if any
  * @param string $context such as login, reset password, ect.
  * @param array $data from the form
  * @return array $user
  * @access private
  */
 function __validateInputAndGetUser($context, $data)
 {
     $user = null;
     $this->User = Common::getModel('User');
     // validate the input data
     $this->User->data = $data;
     $rules = $this->User->getValidationRules($context);
     if (empty($rules) || $this->User->validates($rules)) {
         // build search conditions
         $options = User::getFindOptions($context, $data);
         // find a user or die trying
         $user = $this->User->find('first', $options);
     }
     return $user;
 }
开发者ID:stripthis,项目名称:BlackRabbit,代码行数:22,代码来源:auth.php


注:本文中的Common::getModel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。