262e446b4e2783da78f3761d413ae315a4089e3b
Author: AD7six
Date: 2009-04-03 12:28:05 +0200
diff --git a/app_controller.php b/app_controller.php
index c9104c1..09ad7b5 100644
--- a/app_controller.php
+++ b/app_controller.php
@@ -41,7 +41,7 @@ class AppController extends Controller {
* @access public
*/
var $helpers = array(
- 'Tree', 'Menu' => array('autoI18n' => true, 'genericElement' => false),
+ 'Tree', 'Menu' => array('autoI18n' => true, 'genericElement' => false, 'showWarnings' => false),
'MiHtml', 'MiJavascript',
'Form', 'Time', 'Javascript', 'Cache');
/**
@@ -103,6 +103,7 @@ class AppController extends Controller {
'admin' => false, 'plugin' => 'users', 'controller' => 'users', 'action' => 'login');
$this->Auth->autoRedirect = false;
$this->Auth->allow('display');
+ $this->Auth->ajaxLogin = 'login';
$this->{$this->modelClass}->currentUserId = $this->Auth->user('id');
}
/**
@@ -293,7 +294,7 @@ class AppController extends Controller {
$this->redirect(array('action' => 'index'));
}
$this->__conditions = $this->{$this->modelClass}->searchConditions($term);
- $this->Session->setFlash(sprintf(__('All %1$s matching the term "%2$s"', true), Inflector::humanize($this->name), htmlspecialchars($term)));
+ $this->Session->setFlash(sprintf(__('All %1$s matching the term "%2$s"', true), Inflector::humanize($this->name), h($term)));
$this->admin_index();
$this->render('admin_index');
}
diff --git a/controllers/nodes_controller.php b/controllers/nodes_controller.php
index 622908c..abf6b24 100644
--- a/controllers/nodes_controller.php
+++ b/controllers/nodes_controller.php
@@ -654,12 +654,13 @@ class NodesController extends AppController {
* todo method
*
* List all sections that are not translated
+ * Give a short cache time so that if it's stale, it's not stale for long
*
* @return void
* @access public
*/
function todo() {
- $this->cacheAction = array('duration' => CACHE_DURATION, 'callbacks' => false);
+ $this->cacheAction = array('duration' => '+1 hour', 'callbacks' => false);
$this->paginate['limit'] = 20;
$conditions = array('Revision.status' => 'pending', 'Revision.lang' => $this->params['lang']);
$recursive = -1;
@@ -733,7 +734,6 @@ class NodesController extends AppController {
$this->cacheAction = array('duration' => CACHE_DURATION, 'callbacks' => false);
$languages = Configure::read('Languages.all');
$db =& ConnectionManager::getDataSource($this->Node->useDbConfig);
- $this->cacheAction = array('duration' => CACHE_DURATION, 'callbacks' => false);
$nodes = $this->Node->find('count', array('recursive' => -1));
$counts = $this->Node->Revision->find('all', array(
'conditions' => array('status' => 'current', 'lang' => $languages),
diff --git a/controllers/revisions_controller.php b/controllers/revisions_controller.php
index 02333ba..ae8020d 100755
--- a/controllers/revisions_controller.php
+++ b/controllers/revisions_controller.php
@@ -303,7 +303,6 @@ class RevisionsController extends AppController {
* @access public
*/
function admin_reset() {
- Configure::write('debug', 1);
$this->Revision->reset();
$this->redirect($this->Session->read('referer'), null, false);
}
diff --git a/models/comment.php b/models/comment.php
index 36b218a..93169dc 100644
--- a/models/comment.php
+++ b/models/comment.php
@@ -33,7 +33,7 @@ class Comment extends AppModel {
* @var string
* @access public
*/
- var $name= 'Comment';
+ var $name = 'Comment';
/**
* belongsTo variable
*
@@ -60,13 +60,15 @@ class Comment extends AppModel {
* @access public
*/
var $validate = array(
- 'title'=> array(
- 'required'=> VALID_NOT_EMPTY
- ),
- 'body'=>array(
- 'required'=> VALID_NOT_EMPTY
- )
- );
+ 'title' => array(
+ array('rule' => 'notEmpty', 'on' => 'create', 'required' => true),
+ array('rule' => 'notEmpty'),
+ ),
+ 'body'=>array(
+ array('rule' => 'notEmpty', 'on' => 'create', 'required' => true),
+ array('rule' => 'notEmpty'),
+ ),
+ );
/**
* beforeSave function
*
diff --git a/models/revision.php b/models/revision.php
index c71157b..437a45b 100644
--- a/models/revision.php
+++ b/models/revision.php
@@ -350,11 +350,13 @@ class Revision extends AppModel {
* @return void
*/
function reset() {
- $this->recursive = -1;
- $nodes = $this->find('list', array(
- 'fields' => array('node_id', 'node_id'),
- 'conditions' => array('node_id >' => 0)
- ));
+ $nodes = array_keys($this->Node->find('list', array(
+ 'conditions' => array('Node.id >' => 0),
+ 'order' => 'id',
+ 'recursive' => -1
+ )));
+ set_time_limit (min(count($nodes) / 10, 30));
+ $this->unbindModel(array('belongsTo' => array('Node')), false);
$order = 'Revision.id DESC';
$fields = array('id');
foreach ($nodes as $id) {
@@ -366,18 +368,26 @@ class Revision extends AppModel {
$conditions = array(
'node_id' => $id,
'lang' => $lang,
- 'status' => array('current', 'previous')
+ 'NOT' => array('status' => array('rejected'))
);
- if (!$this->find('count', compact('conditions'))) {
+ $count = $this->find('count', compact('conditions'));
+ if (!$count) {
continue;
}
$conditions['Revision.status'] = 'current';
- if ($this->find('count', compact('conditions'))) {
+ if ($this->find('count', compact('conditions')) === 1) {
continue;
}
$conditions['Revision.status'] = 'previous';
$last = $this->find('first', compact('conditions', 'order', 'fields'));
+ if ($last) {
+ unset($conditions['Revision.status']);
+ $last = $this->find('first', compact('conditions', 'order'));
+ }
$this->updateAll(array('status' => '"current"'), array('Revision.id' => $last['Revision']['id']));
+ $conditions['Revision.status'] = 'current';
+ $conditions['NOT'] = array('Revision.id' => $last['Revision']['id']);
+ $this->updateAll(array('Revision.status' => '"previous"'), $conditions);
}
}
}
