commit 06b9ce54c2034d7498f41516ce07612615e4ae19
parent b16fcc24efeb867801e7ca3ece3c5f5e77e1a487
Author: Jan Dankert <devnull@localhost>
Date: Fri, 26 Oct 2012 22:15:36 +0200
Falls so konfiguriert, dann, falls 1 Projekt vorhanden, dieses nach dem Login öffnen. Falls so konfiguriert, dann zuletzt geändertes Objekt anzeigen.
Diffstat:
8 files changed, 162 insertions(+), 43 deletions(-)
diff --git a/action/LoginAction.class.php b/action/LoginAction.class.php
@@ -841,8 +841,40 @@ class LoginAction extends Action
}
}
- $this->setStyle( $user->style );
- $this->setPerspective('start');
+ $this->setStyle( $user->style ); // Benutzer-Style setzen
+
+ // Entscheiden, welche Perspektive als erstes angezeigt werden soll.
+
+ $allProjects = Project::getAllProjects();
+
+ if ( $conf['login']['start']['start_single_project'] &&
+ count($allProjects) == 1 )
+ {
+ // Das einzige Projekt sofort starten.
+ $projectIds = array_keys($allProjects);
+ Session::setProject( new Project($projectIds[0]) );
+ $this->setPerspective('normal');
+ }
+ elseif ( $conf['login']['start']['start_lastchanged_object'] )
+ {
+ $user = Session::getUser();
+ $objectid = Value::getLastChangedObjectByUserId($user->userid);
+ if ( Object::available($objectid))
+ {
+ // Das Projekt des zuletzt geänderten Objekts ermitteln
+ // und dieses Projekt starten.
+ $o = new Object( $objectid );
+ $o->load();
+ Session::setProject( new Project($o->projectid) );
+ $this->setPerspective('normal');
+ }
+ }
+
+ else
+ {
+ // Erstmal die Startseite anzeigen.
+ $this->setPerspective('start');
+ }
}
}
diff --git a/action/StartAction.class.php b/action/StartAction.class.php
@@ -354,13 +354,11 @@ class StartAction extends Action
* Setzt die neue Projekt-Id und lädt die Workbench neu.
*
*/
- public function projectmenuPost() {
-
- //Session::setProject( $this->getRequestId() );
+ public function projectmenuPost()
+ {
$this->evaluateRequestVars( array('projectid'=>$this->getRequestId()) );
- Session::set('perspective','normal');
- $this->refresh();
+ $this->setPerspective('normal');
}
diff --git a/action/TreeAction.class.php b/action/TreeAction.class.php
@@ -83,29 +83,16 @@ class TreeAction extends Action
$project = Session::getProject();
$projectid = $project->projectid;
+ Logger::debug( "Initializing Tree for Project ".$projectid);
+
if ( $projectid == -1 )
{
$this->tree = new AdministrationTree();
-// Session::setProjectLanguage(null);
-// Session::setProjectModel(null);
-// Session::setProject(null);
}
else
{
-// $project = new Project($projectid);
-// $project->load();
-// Session::setProject($project);
-
$this->tree = new ProjectTree();
$this->tree->projectId = $projectid;
-
-// $language = new Language( Language::getDefaultId() );
-// $language->load();
-// Session::setProjectLanguage( $language );
-//
-// $model = new Model( Model::getDefaultId() );
-// $model->load();
-// Session::setProjectModel( $model );
}
Session::setTree( $this->tree );
@@ -225,7 +212,7 @@ class TreeAction extends Action
*/
public function showView()
{
- //if ( $this->hasRequestVar('projectid') )
+ return;
$this->load();
$project = Session::getProject();
@@ -241,7 +228,8 @@ class TreeAction extends Action
$var = array();
$var['zeilen'] = $this->outputElement( 0,0,array() );
-
+ $var['zeilen'] = array();
+
$this->setTemplateVars( $var );
}
@@ -262,6 +250,7 @@ class TreeAction extends Action
*/
public function loadEntryView()
{
+ exit;
$this->tree = Session::getTree();
$this->setTemplateVar( 'lines',$this->outputElement( 0,0,array() ) );
@@ -275,24 +264,33 @@ class TreeAction extends Action
*/
public function loadBranchView()
{
- $this->tree = Session::getTree();
-
- if ( !is_object($this->tree) ) {
- $this->setTemplateVar('notice','fuck, kein Baum');
- return;
- }
+ $project = Session::getProject();
+ $projectid = $project->projectid;
+
+ Logger::debug( "Initializing Tree for Project ".$projectid);
+
+ if ( $projectid == -1 )
+ {
+ $tree = new AdministrationTree();
+ }
+ else
+ {
+ $tree = new ProjectTree();
+ $tree->projectId = $projectid;
+ }
+
$type = $this->getRequestVar('type');
- $this->tree->tempElements = array();
+ $tree->tempElements = array();
if ( intval($this->getRequestVar('id')) != 0 )
- $this->tree->$type( $this->getRequestId() );
+ $tree->$type( $this->getRequestId() );
else
- $this->tree->$type();
+ $tree->$type();
$branch = array();
- foreach( $this->tree->tempElements as $element )
+ foreach( $tree->tempElements as $element )
{
$branch[] = get_object_vars($element);
}
diff --git a/action/WorkbenchAction.class.php b/action/WorkbenchAction.class.php
@@ -16,10 +16,23 @@ class WorkbenchAction extends Action
*/
function WorkbenchAction()
{
+ global $conf;
$this->perspective = Session::get('perspective');
+
+
+
+ }
+
+
+ /**
+ * Ersetzt den Inhalt mit einer anderen Datei
+ */
+ public function showView()
+ {
+ global $conf;
+ global $preselectobject;
if ( empty($this->perspective) )
{
- global $conf;
$guestConf = $conf['security']['guest'];
if ( $guestConf['enable'] )
@@ -29,16 +42,27 @@ class WorkbenchAction extends Action
Session::set('perspective',$this->perspective);
}
- }
-
- /**
- * Ersetzt den Inhalt mit einer anderen Datei
- */
- public function showView()
- {
+ // Zuletzt geändertes Objekt laden.
+ if ( $this->perspective == 'normal' &&
+ $conf['login']['start']['start_lastchanged_object'] ) {
+ $user = Session::getUser();
+ $project = Session::getProject();
+
+ $objectid = Value::getLastChangedObjectInProjectByUserId($project->projectid, $user->userid);
+ if ( Object::available($objectid))
+ {
+ $object = new Object($objectid);
+ $object->load();
+
+ Logger::debug('preselecting object '.$objectid);
+ $preselectobject = $object;
+ }
+ }
+
global $viewconfig;
$viewconfig = parse_ini_file('themes/default/layout/perspective/'.$this->perspective.'.ini.php',true);
+
require_once('themes/default/layout/perspective/header.php');
require_once('themes/default/layout/perspective/normal.php');
// Ausgabe fertig.
diff --git a/config/config-default.php b/config/config-default.php
@@ -361,6 +361,7 @@ $conf['login']['logo']['file']="./themes/default/images/logo.jpg" ;
$conf['login']['logo']['url']="http://www.openrat.de" ;
$conf['login']['start'] = array();
$conf['login']['start']['start_lastchanged_object']=true;
+$conf['login']['start']['start_single_project']=true;
$conf['log'] = array();
$conf['log']['file']= "";
$conf['log']['level']= "warn";
diff --git a/dispatcher.php b/dispatcher.php
@@ -218,9 +218,17 @@ switch( @$do->security )
$isAction = $_SERVER['REQUEST_METHOD'] == 'POST';
if ( $isAction )
+{
+ // POST-Request => ...Post() wird aufgerufen.
$subactionMethodName = $subaction.'Post';
+}
else
+{
+ // GET-Request => ...View() wird aufgerufen.
$subactionMethodName = $subaction.'View';
+ // Daten werden nur angezeigt, die Sitzung kann also schon geschlossen werden.
+ Session::close();
+}
Logger::debug("Executing $actionClassName::$subactionMethodName");
diff --git a/model/Value.class.php b/model/Value.class.php
@@ -1524,7 +1524,7 @@ SQL
*
* @return Integer Objekt-Id
*/
- function getLastChangedObjectByUserId( $userid )
+ public static function getLastChangedObjectByUserId( $userid )
{
$db = db_connection();
@@ -1545,6 +1545,33 @@ SQL
/**
+ * Es wird das Objekt ermittelt, welches der Benutzer zuletzt ge�ndert hat.
+ *
+ * @return Integer Objekt-Id
+ */
+ public static function getLastChangedObjectInProjectByUserId( $projectid, $userid )
+ {
+ $db = db_connection();
+
+ $sql = new Sql( <<<SQL
+SELECT {t_object}.id
+ FROM {t_value}
+ LEFT JOIN {t_page}
+ ON {t_page}.id={t_value}.pageid
+ LEFT JOIN {t_object}
+ ON {t_object}.id={t_page}.objectid
+ WHERE {t_value}.lastchange_userid={userid}
+ AND {t_object}.projectid = {projectid}
+ ORDER BY {t_value}.lastchange_date DESC
+SQL
+);
+ $sql->setInt ( 'userid' ,$userid );
+ $sql->setInt ( 'projectid' ,$projectid );
+ return $db->getOne( $sql );
+ }
+
+
+ /**
* Ermittelt einen tempor�ren Dateinamen f�r diesen Inhalt.
*/
function tmpfile()
diff --git a/themes/default/layout/perspective/header.php b/themes/default/layout/perspective/header.php
@@ -2,6 +2,8 @@
function view_header( $name )
{
+ global $preselectobject;
+
global $viewconfig;
global $conf;
$v = $viewconfig[$name];
@@ -20,6 +22,7 @@ function view_header( $name )
$viewlist = explode(',',$v['views']);
if ( empty($viewlist[0])) $viewlist = array();
+
// Tabreiter pro View erzeugen
foreach( $viewlist as $vn )
@@ -32,6 +35,19 @@ function view_header( $name )
?><img class="icon" src="<?php echo $icon_url ?>" /><div class="tabname"><?php echo $tmp_text ?></div><?php
?></li><?php
}
+
+ global $preselectobject;
+ if ( false && $name=='content' && is_object($preselectobject) )
+ {
+ $tmp_text = $preselectobject->name;
+ $liClass = 'action active';
+ $icon_url = OR_THEMES_EXT_DIR.'default/images/icon_'.$preselectobject->getType().'.png';
+
+ ?><li data-id="<?php echo $preselectobject->objectid ?>" data-method="edit" data-u="<?php echo $preselectobject->getType() ?>" class="<?php echo $liClass?>" title="<?php echo $preselectobject->description ?>"><?php
+ ?><img class="icon" src="<?php echo $icon_url ?>" /><div class="tabname"><?php echo $tmp_text ?></div><?php
+ ?></li><?php
+ }
+
if ( /* Deaktiviert */ false && @$conf['help']['enabled'] )
{
?><a class="help" data-url="<?php echo $conf['help']['url'] ?>" data-suffix="<?php echo @$conf['help']['suffix'] ?>" title="<?php echo langHtml('MENU_HELP_DESC') ?>"><img src="<?php echo $image_dir.'icon/help.png' ?>" /><?php echo @$conf['help']['only_question_mark']?'?':langHtml('MENU_HELP') ?></a><?php
@@ -42,6 +58,21 @@ function view_header( $name )
?>
</ul>
+
+<?php
+
+global $preselectobject;
+if ( $name=='content' && is_object($preselectobject) )
+{
+?>
+
+<script name="javascript" type="text/javascript">
+<!--
+openNewAction( '<?php echo $preselectobject->name; ?>','<?php echo $preselectobject->getType() ?>','<?php echo $preselectobject->objectid ?>',0 )
+//-->
+</script>
+
+<?php } ?>
<div class="icons">
<div class="icon">