本文整理汇总了PHP中Assert::true方法的典型用法代码示例。如果您正苦于以下问题:PHP Assert::true方法的具体用法?PHP Assert::true怎么用?PHP Assert::true使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assert
的用法示例。
在下文中一共展示了Assert::true方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: admin_index
/**
* undocumented function
*
* @return void
* @access public
*/
function admin_index()
{
Assert::true(User::allowed($this->name, $this->action), '403');
$defaults = array('model' => null, 'user_id' => null, 'my_limit' => 20, 'custom_limit' => false, 'start_date_day' => '01', 'start_date_year' => date('Y'), 'start_date_month' => '01', 'end_date_day' => '31', 'end_date_year' => date('Y'), 'end_date_month' => '12');
$params = am($defaults, $this->params['url'], $this->params['named']);
unset($params['ext']);
unset($params['url']);
if (is_numeric($params['custom_limit'])) {
if ($params['custom_limit'] > 75) {
$params['custom_limit'] = 75;
}
if ($params['custom_limit'] == 0) {
$params['custom_limit'] = 50;
}
$params['my_limit'] = $params['custom_limit'];
}
$conditions = array();
if (!empty($params['model'])) {
$conditions['Log.model'] = $params['model'];
}
if (!empty($params['user_id'])) {
$conditions['Log.user_id'] = $params['user_id'];
}
$conditions = $this->Log->dateRange($conditions, $params, 'created');
$this->Session->write('logs_filter_conditions', $conditions);
$userOptions = ClassRegistry::init('User')->find('list', array('conditions' => array('User.office_id' => $this->Session->read('Office.id'))));
$this->paginate['Log'] = array('conditions' => $conditions, 'contain' => array('User', 'Gift', 'Transaction'), 'limit' => $params['my_limit'], 'order' => array('Log.continuous_id' => 'desc'));
$logs = $this->paginate($this->Log);
$this->set(compact('logs', 'params', 'userOptions'));
}
示例2: admin_delete
/**
* undocumented function
*
* @param string $id
* @return void
* @access public
*/
function admin_delete($id)
{
$filter = $this->Filter->find('first', array('conditions' => array('Filter.id' => $id), 'contain' => false, 'fields' => array('id', 'user_id')));
Assert::notEmpty($filter, '404');
Assert::true(AppModel::isOwn($filter, 'Filter'), '403');
$this->Filter->del($id);
$msg = __('Filter deleted.', true);
$this->Message->add($msg, 'ok', true, $this->referer());
}
示例3: admin_delete
/**
* undocumented function
*
* @param string $id
* @return void
* @access public
*/
function admin_delete($id = null)
{
Assert::true(false, '404');
$user = $this->User->find('first', $id);
$this->User->delete($id);
$this->Silverpop->UserOptOut($user);
$msg = __('Successfully deleted!', true);
$this->Message->add($msg, 'ok', true, array('action' => 'index'));
}
示例4: admin_go
/**
* undocumented function
*
* @return void
* @access public
*/
function admin_go()
{
Assert::false($this->isGet(), '404');
$validTypes = array('gifts', 'transactions', 'users', 'appeals');
$type = $this->data['Search']['resource'];
Assert::true(in_array($type, $validTypes), '404');
$url = array('controller' => $type, 'action' => 'index', 'all', '?' => 'keyword=' . $this->data['Search']['keyword']);
$this->redirect($url);
}
示例5: beforeFilter
/**
* undocumented function
*
* @return void
* @access public
*/
function beforeFilter()
{
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
Assert::false($this->name == 'App', '404');
Assert::true(!!$this->action, '404');
}
$this->Session = $this->AppSession;
ClassRegistry::addObject('Component.Session', $this->Session);
ClassRegistry::addObject('Component.RequestHandler', $this->RequestHandler);
ClassRegistry::addObject('Component.Cookie', $this->Cookie);
ClassRegistry::addObject('Component.Email', $this->Email);
ClassRegistry::addObject('Component.Pgp', $this->Pgp);
$this->_loadPermissions();
$this->_setLanguage();
$this->_loadPluginConfigs();
if ($this->isAdmin()) {
$this->layout = 'admin';
}
if (defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
return;
}
$this->RequestHandler->setContent('list', 'text/html');
if (empty($this->ignoreUserSession)) {
$rules = Configure::read('App.userPermissions.' . User::get('Role.name'));
Assert::notEmpty($rules, '500');
$canAccess = Common::requestAllowed($this->name, $this->action, $rules, true);
if (!$canAccess) {
Assert::true(User::is('guest'), '403');
if ($this->isOkForSessionRedirect()) {
$this->Session->write($this->loginRedirectSesskey, $this->here);
}
$this->Session->write('cant_access', true);
return $this->redirect('/admin/auth/login', '403', true);
}
if (!User::is('guest') && $this->name == 'auth' && $this->action == 'login') {
$url = '/admin/home';
if ($this->Session->check($this->loginRedirectSesskey)) {
$url = $this->Session->read($this->loginRedirectSesskey);
}
$this->redirect($url);
}
}
$here = $this->params['url']['url'];
if (!empty($here) && $here[0] != '/') {
$here = '/' . $here;
}
$this->setJson('here', $here);
$ajax = $isAjax = false;
if ($this->isAjax()) {
$this->layout = 'ajax';
$ajax = $isAjax = true;
}
$this->set(compact('ajax', 'isAjax', 'here'));
}
示例6: index
/**
* Post Index - Read rss feed from "Making waves" blog
*
* @return void
* @access public
*/
function index($cat = 'news')
{
switch ($cat) {
case 'news':
case 'twitter':
$posts = $this->Post->find('twitter');
$this->set(compact('posts'));
break;
default:
Assert::true(false, '404');
break;
}
}
示例7: admin_save
/**
* undocumented function
*
* @return void
* @access public
*/
function admin_save()
{
Assert::true($this->isPost(), '404');
$this->data = array('WidgetState' => $this->params['form']);
$userId = User::get('id');
$widgetState = $this->WidgetState->find('first', array('conditions' => array('user_id' => $userId)));
$this->data['WidgetState']['user_id'] = $userId;
if (empty($widgetState)) {
$this->WidgetState->create($this->data);
} else {
$this->data['WidgetState']['id'] = $widgetState['WidgetState']['id'];
$this->WidgetState->set($this->data);
}
$this->WidgetState->save();
$this->Message->add(false, 'ok');
}
示例8: view
/**
* undocumented function
*
* @return void
* @access public
*/
function view($key)
{
$userId = $this->params['named']['user_id'];
$authKeyTypeId = $this->params['named']['auth_key_type_id'];
Assert::true(Common::isUuid($userId), '403');
Assert::true(Common::isUuid($authKeyTypeId), '403');
Assert::true(AuthKey::verify($key, $userId, $authKeyTypeId), '403');
$authKeyType = $this->AuthKey->AuthKeyType->lookup(array('id' => $authKeyTypeId), 'name', false);
User::login($userId);
switch ($authKeyType) {
case 'Lost Password':
$this->Session->write('lost_password', true);
$msg = __('Please go ahead and change your password now.', true);
$this->Message->add($msg, 'ok', true, '/admin/users/edit_password/' . $userId);
}
}
示例9: delete
/**
* undocumented function
*
* @param string $id
* @return void
* @access public
*/
function delete($id = null)
{
$comment = $this->Comment->find('first', array('conditions' => array('Comment.id' => $id)));
Assert::true(Comment::isOwn($comment));
if (!$this->Comment->delete($id)) {
if ($this->isAjax()) {
$msg = __('There are problems with the form.', true);
return $this->Json->error($msg, array('profile' => true));
}
$dispatcher = new Dispatcher();
$dispatcher->dispatch($this->referer(), array('formerror' => true, 'formerror-msg' => __('There are problems with the form.', true)));
exit;
}
$msg = __('Successfully deleted!', true);
$this->Message->add($msg, 'ok', true, $this->referer());
}
示例10: isOwn
/**
* undocumented function
*
* @param string $comment
* @return void
* @access public
*/
static function isOwn($comment)
{
$isAuthor = $comment['Comment']['user_id'] == User::get('id');
$isOwned = false;
if (!$isAuthor) {
$models = $this->belongsTo;
foreach ($models as $model => $data) {
$row = $this->{$model}->find('first', array('conditions' => array($model . '.id' => $comment['Comment']['foreign_id'])));
if (!empty($row) && AppModel::isOwn($row, $model)) {
$isOwned = true;
break;
}
}
Assert::true($isOwned, '403');
}
return true;
}
示例11: _process
/**
* undocumented function
*
* @param string $model
* @param string $contain
* @return void
* @access public
*/
function _process($model, $contain = array())
{
Assert::true(User::allowed($this->name, $this->action), '403');
Assert::true($this->isPost() || $this->Session->read($this->sessKeyModel) == $model, '404');
if (isset($this->data[$model]) && !isset($this->data[$model]['process'])) {
$this->saveModel($model);
return $this->saveSelection($model);
}
$plural = low(Inflector::pluralize($model));
$conditions = $this->Session->read($plural . '_filter_conditions');
$selection = $this->loadSelection();
if (!empty($selection)) {
$conditions[$model . '.id'] = $selection;
}
// remove gift id from csv fields, although cake fetched it to do joins
$addedGiftId = false;
if (!in_array($model . '.id', (array) $this->data[$model]['fields'])) {
$addedGiftId = true;
$this->data[$model]['fields'][] = $model . '.id';
}
$items = $this->{$model}->find('all', array('conditions' => $conditions, 'contain' => $contain, 'fields' => am($this->data[$model]['fields'], array('Currency.iso_code'))));
// remove the gift id from fields list now if needed
if ($addedGiftId) {
$key = array_search($model . '.id', $this->data[$model]['fields']);
unset($this->data[$model]['fields'][$key]);
}
if ($this->data[$model]['softdelete']) {
$this->{$model}->softdelete($items);
}
$items = $this->filterFields($model, $items, $contain);
foreach ($items as $i => $item) {
$items[$i][$model]['amount'] .= ' ' . $items[$i]['Currency']['iso_code'];
unset($items[$i]['Currency']);
}
if (isset($this->data[$model]['download']) && $this->data[$model]['download']) {
$name = $plural . '_export_' . date('Y_m_d_H_i');
$path = '/admin/exports/' . $plural . '.' . $this->data[$model]['format'];
$this->ForceDownload->forceDownload($path, $name);
}
$Export = ClassRegistry::init('Export');
$Export->create(array('user_id' => User::get('id'), 'nb_exported' => count($items), 'model' => $model));
$Export->save();
$this->set(compact('items'));
$this->RequestHandler->renderAs($this, $this->data[$model]['format']);
}
示例12: Controller
/**
* undocumented
*
* @access public
*/
function &getComponent($component)
{
$componentKey = 'Component.' . $component;
if (ClassRegistry::isKeySet($componentKey)) {
$Component =& ClassRegistry::getObject($componentKey);
} else {
Assert::true(App::import('Component', $component));
$class = $component . 'Component';
$Component = new $class();
$Controller = new Controller();
if (method_exists($Component, 'initialize')) {
$Component->initialize($Controller, array());
}
if (method_exists($Component, 'startup')) {
$Component->startup($Controller);
}
}
Assert::isObject($Component);
return $Component;
}
示例13: admin_delete
/**
* delete action
*
* @param string $id the transaction id
* @return void
* @access public
*/
function admin_delete($id = null)
{
$transaction = $this->Transaction->find('first', array('conditions' => array('Transaction.id' => $id), 'contain' => array('Gift')));
Assert::notEmpty($transaction, '404');
Assert::true(User::allowed($this->name, $this->action, $transaction), '403');
$this->Transaction->set(array('id' => $id, 'archived' => '1'));
$this->Transaction->save();
$msg = __('The Transaction has been deleted.', true);
$this->Message->add($msg, 'ok', true, array('action' => 'admin_index'));
}
示例14: admin_view
/**
* undocumented function
*
* @param string $id
* @return void
* @access public
*/
function admin_view($id = null)
{
$gift = $this->Gift->find('first', array('conditions' => array('Gift.id' => $id), 'contain' => array('Contact.Address.Phone', 'Contact.Address.Country(id, name)', 'Contact.Address.State(id, name)', 'Contact.Address.City(id, name)', 'GiftType(humanized)', 'Office(id, name)', 'Appeal', 'Frequency', 'Currency(iso_code)')));
Assert::notEmpty($gift, '404');
Assert::true(User::allowed($this->name, $this->action, $gift), '403');
$this->paginate['Transaction'] = array('conditions' => array('Transaction.gift_id' => $id), 'contain' => array('Gateway(name)', 'Currency(iso_code)'), 'order' => array('Transaction.created' => 'asc'));
$transactions = $this->paginate('Transaction');
$this->Gift = ClassRegistry::init('Gift');
$commentMethod = $this->Gift->hasMany['Comment']['threaded'] ? 'threaded' : 'all';
$comments = $this->Gift->Comment->find($commentMethod, array('conditions' => array('Comment.foreign_id' => $id), 'contain' => array('User(login, id)')));
$this->set(compact('gift', 'comments', 'commentMethod', 'transactions'));
}
示例15: login
/**
* undocumented function
*
* @param unknown $user
* @param unknown $log
* @return void
* @access public
*/
static function login($user, $permantly = false)
{
Assert::true(User::setActive($user, true, $permantly));
return true;
}