/** * 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')); }
/** * 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()); }
/** * 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')); }
/** * 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); }
/** * 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')); }
/** * 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; } }
/** * 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'); }
/** * 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); } }
/** * 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()); }
/** * 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; }
/** * 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']); }
/** * 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; }
/** * 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')); }
/** * 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')); }
/** * 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; }
namespace envtesting; /** * Test chek php.ini variables * * @author Roman Ozana <*****@*****.**> */ require_once dirname(__DIR__) . '/vendor/autoload.php'; $suite = new Suite('php.ini settings'); // check log_errors $suite->addTest('error_reporting', function () { Assert::true(Check::ini('log_errors', '1'), 'log_errors is OFF'); })->setType('INI'); // check display errors $suite->addTest('display_errors', function () { Assert::true(Check::ini('display_errors', '1'), 'display_errors is OFF'); })->setType('INI'); // check post_max_size $suite->addTest('post_max_size', function () { $size = Check::ini('post_max_size'); Assert::true($size > 256, 'post_max_size = ' . $size . ' is smaller then 256MB'); })->setType('INI'); echo '<pre>' . $suite->run() . '</pre>'; try { Assert::true(Check::ini('post_max_size') > 10000, 'post_max_size is smaller then 10000 MB'); Assert::true(Check::ini('log_errors', '1'), 'log_errors is OFF'); Assert::true(Check::ini('display_errors', '1'), 'log_errors is OFF'); } catch (\envtesting\Error $e) { echo '<pre>Error: ' . $e->getMessage() . '</pre>'; }
/** * undocumented function * * @return void * @access public */ function admin_manage_tree() { Assert::true(User::is('root'), '403'); $treeOffices = $this->Office->find('threaded', array('order' => array('name' => 'asc'), 'fields' => array('parent_id', 'id', 'name'))); $offices = $this->Office->find('all', array('order' => array('name' => 'asc'), 'fields' => array('parent_id', 'id', 'name'))); $this->set(compact('offices', 'treeOffices')); if ($this->isGet()) { return; } foreach ($this->data['options'] as $id => $parentId) { $this->Office->set(array('id' => $id, 'parent_id' => $parentId)); $this->Office->save(null, false); } $msg = __('Tree updated!', true); $this->Message->add($msg, 'ok', true, $this->here); }
/** * undocumented function * * @param string $segmentId * @param string $foreignId * @return void * @access public */ function admin_delete_item($segmentId, $foreignId) { $segment = $this->Segment->find('first', array('conditions' => array('id' => $segmentId), 'fields' => array('user_id'))); Assert::notEmpty($segment); Assert::true(AppModel::isOwn($segment, 'Segment'), '403'); $this->SegmentItem->deleteAll(array('segment_id' => $segmentId, 'foreign_id' => $foreignId)); $msg = 'The item was successfully removed from segment.'; $this->Message->add($msg, 'ok', true, $this->referer()); }
/** * undocumented function * * @param unknown $key * @return void * @access public */ static function expire($key) { $_this = Common::getModel('AuthKey'); return Assert::true($_this->deleteAll(compact('key')), false); }
/** * undocumented function * * @param string $id * @return void * @access public */ function admin_delete($id) { Assert::true(User::is('root'), '403'); $this->Bug->del($id); $msg = __('Bug successfully removed!', true); $this->Message->add($msg, 'ok', true, array('action' => 'index')); }
/** * Admin delete an template action * * @param string $id the template id * @return void * @access public */ function admin_delete($id = null, $undelete = false) { $template = $this->Template->find('first', array('conditions' => compact('id'))); Assert::notEmpty($template, '404'); Assert::true(User::allowed($this->name, $this->action, $template), '403'); $this->Template->del($id); $msg = __('The Template has been deleted.', true); $this->Message->add($msg, 'ok', true, array('action' => 'admin_index')); }