Skip to content

Commit

Permalink
Merge branch 'release/4.6.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlaefer committed Nov 16, 2014
2 parents cb8081b + 630c1b6 commit ca2becc
Show file tree
Hide file tree
Showing 165 changed files with 2,211 additions and 2,438 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
.DS_Store
tags

### CakePHP 3 ###
/logs
/tmp
/vendor

# Saito
/app/Config/email.php
/app/Config/database.php
Expand Down
25 changes: 0 additions & 25 deletions app/Config/Schema/schema.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
<?php

App::uses('SchemaCakeMysqlFixTrait', 'Lib');

class AppSchema extends CakeSchema {

use SchemaCakeMysqlFixTrait;

public function before($event = array()) {
return true;
}

public function after($event = array()) {
if (isset($event['create']) && $event['create'] === 'ecaches') {
$this->cakeMysqlMediumBlobFix();
}
}

public $bookmarks = array(
'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false, 'key' => 'primary'),
'user_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false, 'key' => 'index'),
Expand Down Expand Up @@ -44,17 +30,6 @@ public function after($event = array()) {
'tableParameters' => array('charset' => 'utf8', 'collate' => 'utf8_unicode_ci', 'engine' => 'MyISAM')
);

public $ecaches = array(
'created' => array('type' => 'datetime', 'null' => false, 'default' => null),
'modified' => array('type' => 'datetime', 'null' => false, 'default' => null),
'key' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 128, 'key' => 'primary', 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
'value' => array('type' => 'binary', 'null' => false, 'default' => null),
'indexes' => array(
'PRIMARY' => array('column' => 'key', 'unique' => 1)
),
'tableParameters' => array('charset' => 'utf8', 'collate' => 'utf8_general_ci', 'engine' => 'MyISAM')
);

public $entries = array(
'created' => array('type' => 'datetime', 'null' => true, 'default' => null),
'modified' => array('type' => 'datetime', 'null' => true, 'default' => null),
Expand Down
1 change: 0 additions & 1 deletion app/Config/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@
'file' => 'saito-auth'
));

include APP . 'Lib' . DS . 'SaitoExceptions.php';
include 'version.php';

/**
Expand Down
4 changes: 4 additions & 0 deletions app/Config/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
*/
Router::connect('/admin',
['controller' => 'admins', 'action' => 'index', 'admin' => true]);
Router::connect(
'/admin/plugins',
['controller' => 'admins', 'action' => 'plugins', 'admin' => true]
);

/**
* Default search action
Expand Down
2 changes: 1 addition & 1 deletion app/Config/version.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
Configure::write('Saito.v', '4.5.0');
Configure::write('Saito.v', '4.6.0');

Configure::write('Saito.saitoHomepage', 'http://saito.siezi.com');
6 changes: 3 additions & 3 deletions app/Console/Command/DummyDataShell.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

App::uses('SaitoUser', 'Lib/SaitoUser');
use Saito\User\Auth;
use Saito\User\SaitoUser;

class DummyDataShell extends AppShell {

Expand Down Expand Up @@ -147,8 +148,7 @@ class SaitoUserDummy extends SaitoUser {

public function __construct($settings = null) {
parent::__construct($settings);
App::uses('CategoryAuth', 'Lib/SaitoUser');
$this->Categories = new CategoryAuth($this);
$this->Categories = new Auth\CategoryAuthorization($this);
}

public function getMaxAccession() {
Expand Down
20 changes: 13 additions & 7 deletions app/Controller/AdminsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,26 @@ public function admin_logs() {
// order here is output order in frontend
$_logsToRead = ['error', 'debug'];

$_logsToRead = glob(LOGS . '*.log');
if (!$_logsToRead) {
return;
}

// will contain ['error' => '<string>', 'debug' => '<string>']
$_logs = [];
foreach ($_logsToRead as $_log) {
$_path = LOGS . $_log . '.log';
foreach ($_logsToRead as $_path) {
$_content = '';
if (file_exists($_path)) {
$_size = filesize($_path);
$_content = file_get_contents($_path, false, null, $_size - 65536);
}
$_logs[$_log] = $_content;
$_size = filesize($_path);
$_content = file_get_contents($_path, false, null, $_size - 65536);
$name = basename($_path);
$_logs[$name] = $_content;
}
$this->set('logs', $_logs);
}

public function admin_plugins() {
}

public function admin_stats() {
$postingsPA = $this->_getYearStats('Entry', 'time');
$registrationsPA = $this->_getYearStats('User', 'registered');
Expand Down
23 changes: 16 additions & 7 deletions app/Controller/AppController.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<?php

App::uses('Properize', 'Lib');
use Saito\Exception\SaitoBlackholeException;

App::uses('Controller', 'Controller');
App::uses('CakeEmail', 'Network/Email');
App::import('Lib', 'Stopwatch.Stopwatch');

\App::uses('Saito\Logger\ForbiddenLogger', 'Lib');
\App::uses('Saito\Logger\ExceptionLogger', 'Lib');

if (Configure::read('debug') > 0) {
App::uses('FireCake', 'DebugKit.Lib');
}
Expand Down Expand Up @@ -105,9 +103,20 @@ public function __construct($request = null, $response = null) {
Stopwatch::start(
'---------------------- Controller ----------------------'
);

ClassRegistry::addObject('dic', \Saito\DicSetup::getNewDic());
parent::__construct($request, $response);
}

public function __get($name) {
switch ($name) {
case 'dic':
return ClassRegistry::getObject('dic');
default:
return parent::__get($name);
}
}

public function beforeFilter() {
Stopwatch::start('App->beforeFilter()');

Expand Down Expand Up @@ -151,7 +160,7 @@ public function beforeFilter() {
$this->_setConfigurationFromGetParams();

// must be set after all language chooser
Properize::setLanguage(Configure::read('Config.language'));
\Saito\String\Properize::setLanguage(Configure::read('Config.language'));

// allow sql explain for DebugKit toolbar
if ($this->request->plugin === 'debug_kit') {
Expand Down Expand Up @@ -298,10 +307,10 @@ protected function _setXFrameOptionsHeader() {
*
*
* @param $type
* @throws Saito\BlackHoledException
* @throws Saito\Exception\SaitoBlackholeException
*/
public function blackhole($type) {
throw new Saito\BlackHoledException($type,
throw new SaitoBlackholeException($type,
['CurrentUser' => $this->CurrentUser]);
}

Expand Down
14 changes: 10 additions & 4 deletions app/Controller/BookmarksController.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,18 @@ public function add() {
* @param null $id
* @throws NotFoundException
* @throws MethodNotAllowedException
* @throws Saito\ForbiddenException
*/
public function edit($id = null) {
$bookmark = $this->_getBookmark($id);

if (!$this->request->is('post') && !$this->request->is('put')) {
$posting = array(
'Entry' => $bookmark['Entry'],
'Category' => $bookmark['Entry']['Category'],
'User' => $bookmark['Entry']['User'],
);
$this->set('entry', $this->dic->newInstance('\Saito\Posting\Posting',
['rawData' => $posting]));
$this->request->data = $bookmark;
return;
}
Expand Down Expand Up @@ -103,10 +109,10 @@ public function beforeFilter() {

/**
* @param $id
* @return mixed
* @throws NotFoundException
* @throws MethodNotAllowedException
* @throws Saito\ForbiddenException
* @throws Saito\Exception\SaitoForbiddenException
* @return mixed
*/
protected function _getBookmark($id) {
if (!$this->CurrentUser->isLoggedIn()) {
Expand All @@ -121,7 +127,7 @@ protected function _getBookmark($id) {
$bookmark = $this->Bookmark->findById($id);

if ($bookmark['Bookmark']['user_id'] != $this->CurrentUser->getId()) {
throw new Saito\ForbiddenException("Attempt to edit bookmark $id.");
throw new Saito\Exception\SaitoForbiddenException("Attempt to edit bookmark $id.");
}
return $bookmark;
}
Expand Down
36 changes: 7 additions & 29 deletions app/Controller/Component/CacheSupportComponent.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
<?php

use Saito\Cache\CacheSupport;
use Saito\Cache\ItemCache;
use Saito\Cache\LineCacheSupportCachelet;
use Saito\Cache\SaitoCacheEngineAppCache;

App::uses('Component', 'Controller');
App::import('Lib/Cache', 'CacheSupport');
App::uses('CacheTree', 'Lib/Cache');
App::uses('CacheTreeCacheSupportCachelet', 'Lib/Cache');
App::uses('SaitoCacheEngineDbCache', 'Lib/Cache');
App::uses('SaitoCacheEngineAppCache', 'Lib/Cache');
App::uses('ItemCache', 'Lib/Cache');
App::uses('LineCacheSupportCachelet', 'Lib/Cache');

class CacheSupportComponent extends Component {

protected $_CacheSupport;

public $CacheTree;

/** * @var ItemCache */
public $LineCache;

public function initialize(Controller $Controller) {
Expand All @@ -23,7 +20,6 @@ public function initialize(Controller $Controller) {
$Controller->{$Controller->modelClass}->SharedObjects['CacheSupport'] = $this->_CacheSupport;
}
$this->_addConfigureCachelets();
$this->_initCacheTree($Controller);
$this->_initLineCache($Controller);
}

Expand All @@ -32,29 +28,11 @@ protected function _initLineCache() {
'Saito.LineCache',
new SaitoCacheEngineAppCache,
// duration: update relative time values in HTML at least every hour
['duration' => 3600, 'maxItems' => 500]
['duration' => 3600, 'maxItems' => 600]
);
$this->_CacheSupport->add(new LineCacheSupportCachelet($this->LineCache));
}

protected function _initCacheTree($Controller) {
$cacheConfig = Cache::settings();
if ($cacheConfig['engine'] === 'Apc') {
$CacheEngine = new SaitoCacheEngineAppCache;
} else {
$CacheEngine = new SaitoCacheEngineDbCache;
}

$this->CacheTree = new CacheTree(
'EntrySub',
$CacheEngine,
['maxItems' => 240]
);

$this->CacheTree->initialize($Controller->CurrentUser);
$this->_CacheSupport->add(new CacheTreeCacheSupportCachelet($this->CacheTree));
}

/**
* Adds additional cachelets from Configure `Saito.Cachelets`
*
Expand Down
Loading

0 comments on commit ca2becc

Please sign in to comment.