openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit f2270aa2c9436c0c67e1c873b8692861776e9100
parent 8826717b40823b262f44cb9792afaffae3c55382
Author: Jan Dankert <devnull@localhost>
Date:   Wed, 26 Sep 2012 21:57:33 +0200

Konsistenzprüfung für Projekte erweitert. Bei Fehler auch einen Fehler (ERROR) an die Oberfläche melden.

Diffstat:
action/ProjectAction.class.php | 6+++++-
model/Project.class.php | 35+++++++++++++++++++++++++++++++----
2 files changed, 36 insertions(+), 5 deletions(-)

diff --git a/action/ProjectAction.class.php b/action/ProjectAction.class.php @@ -167,11 +167,15 @@ class ProjectAction extends Action switch( $this->getRequestVar('type') ) { case 'check_files': + // Konsistenzprüfungen $this->project->checkLostFiles(); - $this->addNotice('project',$this->project->name,'DONE'); + $status = empty($this->project->log) ? OR_NOTICE_OK : OR_NOTICE_ERROR; + + $this->addNotice('project',$this->project->name,'DONE',$status,array(),$this->project->log); break; case 'check_limit': + // Alte Versionen löschen. $this->project->checkLimit(); $this->addNotice('project',$this->project->name,'DONE'); break; diff --git a/model/Project.class.php b/model/Project.class.php @@ -433,13 +433,17 @@ SQL } - - function checkLostFiles() + + /** + * Testet die Integrität der Datenbank. + */ + public function checkLostFiles() { $this->log = array(); $db = &Session::getDatabase(); - + + // Ordnerstruktur prüfen. $sql = new Sql( <<<EOF SELECT thistab.id FROM {t_object} AS thistab LEFT JOIN {t_object} AS parenttab @@ -469,6 +473,22 @@ EOF } } + + // Prüfe, ob die Verbindung Projekt->Template->Templatemodell->Projectmodell->Projekt konsistent ist. + $sql = new Sql( <<<EOF +SELECT DISTINCT projectid FROM {t_projectmodel} WHERE id IN (SELECT projectmodelid from {t_templatemodel} WHERE templateid in (SELECT id from {t_template} WHERE projectid={projectid})) +EOF +); + $sql->setInt('projectid',$this->projectid); + + $idList = $db->getCol($sql); + + if ( count( $idList ) > 1 ) + { + Logger::warn('Inconsistence found: Reference circle project<->template<->templatemodel<->projectmodel<->project is not consistent.'); + $this->log[] = 'Inconsistence found: Reference circle project<->template<->templatemodel<->projectmodel<->project is not consistent.'; + } + } @@ -484,6 +504,8 @@ EOF */ function export( $dbid_destination ) { + Logger::debug( 'Copying project '.$this->name.' to database '.$dbid_destination ); + global $conf; $zeit = date('Y-m-d\TH:i:sO'); @@ -563,7 +585,7 @@ EOF foreach( $ids as $tabelle=>$data ) { - + Logger::debug( 'Copying table '.$tabelle.' ...' ); $mapping[$tabelle] = array(); $idcolumn = $data['primary_key']; @@ -589,6 +611,7 @@ EOF foreach( $db_src->getCol($sql) as $srcid ) { + Logger::debug('Id '.$srcid.' of table '.$tabelle); $mapping[$tabelle][$srcid] = ++$nextid; $sql = new Sql( 'SELECT * FROM {t_'.$tabelle.'} WHERE id={id}'); @@ -601,6 +624,8 @@ EOF // Fremdschl�sselbeziehungen auf neue IDn korrigieren. foreach( $data['foreign_keys'] as $fkey_column=>$target_tabelle) { + Logger::debug($fkey_column.' '.$target_tabelle.' '.$row[$fkey_column]); + if ( intval($row[$fkey_column]) != 0 ) $row[$fkey_column] = $mapping[$target_tabelle][$row[$fkey_column]]; } @@ -666,6 +691,8 @@ EOF } } + Logger::debug( 'Finished copying project' ); + $db_dest->commit(); }