Skip to content

Commit

Permalink
Merge branch 'release/4.7.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlaefer committed Dec 13, 2014
2 parents ca2becc + ff25c48 commit 2baaaa3
Show file tree
Hide file tree
Showing 32 changed files with 147 additions and 138 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
tags

### CakePHP 3 ###
/bin
/logs
/tmp
/vendor
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ language: php
php:
- 5.4
- 5.5
- 5.6

env:
- DB=mysql
Expand Down
10 changes: 5 additions & 5 deletions app/Config/Schema/schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class AppSchema extends CakeSchema {
'user_id' => array('type' => 'integer', 'null' => true, 'default' => '0', 'unsigned' => false, 'key' => 'index'),
'name' => array('type' => 'string', 'null' => true, 'default' => null, 'collate' => 'utf8_unicode_ci', 'charset' => 'utf8'),
'subject' => array('type' => 'string', 'null' => true, 'default' => null, 'key' => 'index', 'collate' => 'utf8_unicode_ci', 'charset' => 'utf8'),
'category' => array('type' => 'integer', 'null' => false, 'default' => '0', 'unsigned' => false),
'category_id' => array('type' => 'integer', 'null' => false, 'default' => '0', 'unsigned' => false),
'text' => array('type' => 'text', 'null' => true, 'default' => null, 'collate' => 'utf8_unicode_ci', 'charset' => 'utf8'),
'email_notify' => array('type' => 'integer', 'null' => true, 'default' => '0', 'length' => 4, 'unsigned' => false),
'locked' => array('type' => 'integer', 'null' => true, 'default' => '0', 'length' => 4, 'unsigned' => false),
Expand All @@ -56,9 +56,9 @@ class AppSchema extends CakeSchema {
'tid' => array('column' => 'tid', 'unique' => 0),
'entries_userId' => array('column' => 'user_id', 'unique' => 0),
'last_answer' => array('column' => 'last_answer', 'unique' => 0),
'pft' => array('column' => array('pid', 'fixed', 'time', 'category'), 'unique' => 0),
'pfl' => array('column' => array('pid', 'fixed', 'last_answer', 'category'), 'unique' => 0),
'pid_category' => array('column' => array('pid', 'category'), 'unique' => 0),
'pft' => array('column' => array('pid', 'fixed', 'time', 'category_id'), 'unique' => 0),
'pfl' => array('column' => array('pid', 'fixed', 'last_answer', 'category_id'), 'unique' => 0),
'pid_category' => array('column' => array('pid', 'category_id'), 'unique' => 0),
'entries_userId_time' => array('column' => array('time', 'user_id'), 'unique' => 0),
'fulltext_search' => array('column' => array('subject', 'name', 'text'), 'type' => 'fulltext')
),
Expand Down Expand Up @@ -129,7 +129,7 @@ class AppSchema extends CakeSchema {

public $smilies = array(
'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false, 'key' => 'primary'),
'order' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => 4, 'unsigned' => false),
'sort' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => 4, 'unsigned' => false),
'icon' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => 100, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
'image' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => 100, 'collate' => 'utf8_unicode_ci', 'charset' => 'utf8'),
'title' => array('type' => 'string', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
Expand Down
8 changes: 0 additions & 8 deletions app/Config/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,6 @@
Configure::write('Saito.installed', FALSE);
endif;

/**
* Activates Saito's thread cache
*
* true: (default for debug 0 and 1) use cache
* false: (default for debug > 1) don't use cache
*/
Configure::write('Saito.Cache.Thread', true);

/**
* Add additional buttons to editor
* @td document in namespace
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.6.0');
Configure::write('Saito.v', '4.7.0');

Configure::write('Saito.saitoHomepage', 'http://saito.siezi.com');
16 changes: 8 additions & 8 deletions app/Controller/EntriesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ public function index() {

//= determine user sort order
$sortKey = 'Entry.';
if ($this->CurrentUser['user_sort_last_answer'] == false) {
$sortKey .= 'time';
} else {
if (!$this->CurrentUser->isLoggedIn() || $this->CurrentUser['user_sort_last_answer']) {
$sortKey .= 'last_answer';
} else {
$sortKey .= 'time';
}
$order = ['Entry.fixed' => 'DESC', $sortKey => 'DESC'];

Expand Down Expand Up @@ -71,7 +71,7 @@ public function feed() {
$order = 'last_answer DESC';
}

$conditions['category'] = $this->CurrentUser->Categories->getAllowed();
$conditions['category_id'] = $this->CurrentUser->Categories->getAllowed();

$entries = $this->Entry->find(
'feed',
Expand Down Expand Up @@ -544,7 +544,7 @@ public function preview() {
'pid' => $data['pid'],
'subject' => $data['subject'],
'text' => $data['text'],
'category' => $data['category'],
'category_id' => $data['category_id'],
'edited_by' => null,
'fixed' => false,
'solves' => 0,
Expand All @@ -556,7 +556,7 @@ public function preview() {
$this->Entry->prepare($newEntry);
$this->Entry->set($newEntry);

$this->Entry->validates(['fieldList' => ['subject', 'text', 'category']]);
$this->Entry->validates(['fieldList' => ['subject', 'text', 'category_id']]);
$errors = $this->Entry->validationErrors;

if (count($errors) === 0) :
Expand All @@ -568,7 +568,7 @@ public function preview() {
'first',
array(
'conditions' => array(
'id' => $newEntry['Entry']['category']
'id' => $newEntry['Entry']['category_id']
),
'contain' => false,
)
Expand Down Expand Up @@ -821,7 +821,7 @@ protected function _getInitialThreads(CurrentUserComponent $User, $order) {
$this->paginate = [
'conditions' => [
'pid' => 0,
'Entry.category' => $categories
'Entry.category_id' => $categories
],
'contain' => false,
'fields' => 'id, pid, tid, time, last_answer, fixed',
Expand Down
12 changes: 6 additions & 6 deletions app/Controller/SearchesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function simple() {
'fields' => $fields,
'conditions' => [
"MATCH (Entry.subject, Entry.text, Entry.name) AGAINST ('$q' IN BOOLEAN MODE)",
'Entry.category' => $this->CurrentUser->Categories->getAllowed()
'Entry.category_id' => $this->CurrentUser->Categories->getAllowed()
],
'order' => $order,
'paramType' => 'querystring'
Expand Down Expand Up @@ -148,12 +148,12 @@ public function advanced() {
'Y-m-d H:i:s',
mktime(0, 0, 0, $month, 1, $year));

if (isset($query['category']) && (int)$query['category'] !== 0) {
if (!isset($categories[(int)$query['category']])) {
if (isset($query['category_id']) && (int)$query['category_id'] !== 0) {
if (!isset($categories[(int)$query['category_id']])) {
throw new NotFoundException;
}
} else {
$settings['conditions']['Entry.category'] = $this->CurrentUser
$settings['conditions']['Entry.category_id'] = $this->CurrentUser
->Categories->getAllowed();
}
$this->Paginator->settings = $settings;
Expand All @@ -165,8 +165,8 @@ public function advanced() {
$this->Paginator->paginate(null, null, ['Entry.time']));
}

if (!isset($query['category'])) {
$this->request->data['Entry']['category'] = 0;
if (!isset($query['category_id'])) {
$this->request->data['Entry']['category_id'] = 0;
}

$this->set(compact('month', 'year'));
Expand Down
8 changes: 6 additions & 2 deletions app/Lib/Saito/Thread/Renderer/HtmlRendererAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ abstract class HtmlRendererAbstract {

protected $_EntryHelper;

protected $_defaults = ['ignore' => true, 'currentEntry' => null];
protected $_defaults = [
'currentEntry' => null,
'ignore' => true,
'rootWrap' => false
];

protected $_settings;

Expand All @@ -31,7 +35,7 @@ public function __construct(\EntryHHelper $EntryHelper, $options = []) {
public function render(\Saito\Posting\PostingInterface $node) {
$this->_lastAnswer = $node->getThread()->getLastAnswer();
$html = $this->_renderNode($node);
if ($node->isRoot()) {
if ($node->isRoot() || $this->_settings['rootWrap']) {
$html = $this->_wrapUl($html, 0, $node->get('id'));
}
return $html;
Expand Down
4 changes: 2 additions & 2 deletions app/Model/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Category extends AppSettingModel {
public $hasMany = [
'Entry' => [
'className' => 'Entry',
'foreignKey' => 'category'
'foreignKey' => 'category_id'
]
];

Expand Down Expand Up @@ -90,7 +90,7 @@ public function updateThreadCounter() {
'contain' => false,
'conditions' => [
'pid' => 0,
'Entry.category' => $this->id
'Entry.category_id' => $this->id
]
]
);
Expand Down
42 changes: 21 additions & 21 deletions app/Model/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ class Entry extends AppModel {
'subject' => ['type' => 'like'],
'text' => ['type' => 'like'],
'name' => ['type' => 'like'],
'category' => ['type' => 'value'],
'category_id' => ['type' => 'value'],
];

public $belongsTo = array(
'Category' => array(
'className' => 'Category',
'foreignKey' => 'category',
'foreignKey' => 'category_id',
),
'User' => array(
'className' => 'User',
Expand Down Expand Up @@ -85,7 +85,7 @@ class Entry extends AppModel {
'notEmpty' => ['rule' => 'notEmpty'],
'maxLength' => ['rule' => 'validateSubjectMaxLength']
],
'category' => [
'category_id' => [
'notEmpty' => ['rule' => 'notEmpty'],
'numeric' => ['rule' => 'numeric'],
'isAllowed' => ['rule' => 'validateCategoryIsAllowed']
Expand All @@ -112,7 +112,7 @@ class Entry extends AppModel {
'Entry.user_id',
'Entry.name',
'Entry.subject',
'Entry.category',
'Entry.category_id',
'Entry.text',
'Entry.locked',
'Entry.fixed',
Expand Down Expand Up @@ -158,7 +158,7 @@ class Entry extends AppModel {
'Entry.edited',
'Entry.edited_by',
'Entry.ip',
'Entry.category',
'Entry.category_id',

'User.id',
'User.signature',
Expand All @@ -172,14 +172,14 @@ class Entry extends AppModel {
*/
public $allowedInputFields = [
'create' => [
'category',
'category_id',
'pid',
'subject',
'text'
],
'update' => [
'id',
'category',
'category_id',
'subject',
'text'
]
Expand Down Expand Up @@ -208,7 +208,7 @@ public function getRecentEntries(CurrentUserComponent $User, array $options = []
$options += [
'user_id' => null,
'limit' => 10,
'category' => $User->Categories->getAllowed()
'category_id' => $User->Categories->getAllowed()
];

$_cacheKey = 'Entry.recentEntries-' . md5(serialize($options));
Expand All @@ -222,8 +222,8 @@ public function getRecentEntries(CurrentUserComponent $User, array $options = []
if ($options['user_id'] !== null) {
$conditions[]['Entry.user_id'] = $options['user_id'];
}
if ($options['category'] !== null):
$conditions[]['Entry.category'] = $options['category'];
if ($options['category_id'] !== null):
$conditions[]['Entry.category_id'] = $options['category_id'];
endif;

$result = $this->find(
Expand Down Expand Up @@ -345,7 +345,7 @@ public function createPosting($data) {
return false;
} else {
$_newPosting[$this->alias]['tid'] = $_newPostingId;
$this->Category->id = $data[$this->alias]['category'];
$this->Category->id = $data[$this->alias]['category_id'];
$this->Category->updateThreadCounter();
}
$this->_dispatchEvent(
Expand Down Expand Up @@ -417,7 +417,7 @@ public function update($data, $CurrentUser = null) {
// prevents normal user of changing category of complete thread when answering
// @todo this should be refactored together with the change category handling in beforeSave()
if ($this->isRoot($data) === false) {
unset($data[$this->alias]['category']);
unset($data[$this->alias]['category_id']);
}

$data[$this->alias]['edited'] = bDate();
Expand Down Expand Up @@ -698,7 +698,7 @@ public function deleteNode($id = null) {

if ($success):
if ($this->isRoot($entry)) {
$this->Category->id = $entry['Entry']['category'];
$this->Category->id = $entry['Entry']['category_id'];
$this->Category->updateThreadCounter();
$this->Esevent->deleteSubject($id, 'thread');
}
Expand Down Expand Up @@ -829,7 +829,7 @@ public function threadMerge($targetId) {
// appended source entries get category of target thread
$this->_threadChangeCategory(
$targetEntry[$this->alias]['tid'],
$targetEntry[$this->alias]['category']
$targetEntry[$this->alias]['category_id']
);

// update target thread last answer if source is newer
Expand Down Expand Up @@ -955,7 +955,7 @@ public function prepare(&$data, array $options = []) {
}

$data[$this->alias]['tid'] = $parent[$this->alias]['tid'];
$data[$this->alias]['category'] = $parent[$this->alias]['category'];
$data[$this->alias]['category_id'] = $parent[$this->alias]['category_id'];
}

//= markup preprocessing
Expand Down Expand Up @@ -1012,7 +1012,7 @@ public function paginateCount($conditions, $recursive, $extra) {
$categories = $this->Category->find(
'all',
[
'conditions' => array('id' => $conditions['Entry.category']),
'conditions' => array('id' => $conditions['Entry.category_id']),
'fields' => array('thread_count')
]
);
Expand All @@ -1032,16 +1032,16 @@ public function beforeSave($options = array()) {

//# change category of thread if category of root entry changed
$modified = !empty($this->id);
if (isset($this->data[$this->alias]['category']) && $modified) {
if (isset($this->data[$this->alias]['category_id']) && $modified) {
$oldEntry = $this->find('first',
['contain' => false, 'conditions' => ['Entry.id' => $this->id]]);

if ($oldEntry && (int)$oldEntry[$this->alias]['pid'] === 0) {
$categoryChanged = (int)$this->data[$this->alias]['category'] !== (int)$oldEntry[$this->alias]['category'];
$categoryChanged = (int)$this->data[$this->alias]['category_id'] !== (int)$oldEntry[$this->alias]['category_id'];
if ($categoryChanged) {
$success = $success && $this->_threadChangeCategory(
$oldEntry[$this->alias]['tid'],
$this->data[$this->alias]['category']
$this->data[$this->alias]['category_id']
);
}
}
Expand All @@ -1058,7 +1058,7 @@ public function beforeSave($options = array()) {
*/
public function validateCategoryIsAllowed($check) {
$availableCategories = $this->CurrentUser->Categories->getAllowed();
if (!isset($availableCategories[$check['category']])) {
if (!isset($availableCategories[$check['category_id']])) {
return false;
}
return true;
Expand Down Expand Up @@ -1123,7 +1123,7 @@ protected function _threadChangeCategory($tid = null, $newCategoryId = null) {
throw new NotFoundException;
}
$out = $this->updateAll(
['Entry.category' => $newCategoryId],
['Entry.category_id' => $newCategoryId],
['Entry.tid' => $tid]
);
return $out;
Expand Down
4 changes: 2 additions & 2 deletions app/Model/Smiley.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Smiley extends AppSettingModel {
public $name = 'Smiley';

public $validate = [
'order' => [
'sort' => [
'numeric' => [
'rule' => ['numeric']
]
Expand All @@ -34,7 +34,7 @@ public function load($force = false) {
}

$this->_smilies = [];
$smiliesRaw = $this->find('all', ['order' => 'Smiley.order ASC']);
$smiliesRaw = $this->find('all', ['order' => 'Smiley.sort ASC']);

foreach ($smiliesRaw as $smileyRaw) {
// 'image' defaults to 'icon'
Expand Down
Loading

0 comments on commit 2baaaa3

Please sign in to comment.