commit 0e0897e5df31750f61dfe13a8bc10fb6cff75b3d
parent 65d8921d55c2b1ac0b1975e36344bf3b1f0b07ab
Author: dankert <devnull@localhost>
Date: Sat, 22 Dec 2007 00:27:53 +0100
Felder mit Namen versehen. Beim Anlegen von Projekten Beispiel-Projekte ausw?hlen.
Diffstat:
1 file changed, 66 insertions(+), 10 deletions(-)
diff --git a/actionClasses/ProjectAction.class.php b/actionClasses/ProjectAction.class.php
@@ -20,6 +20,9 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// ---------------------------------------------------------------------------
// $Log$
+// Revision 1.17 2007-12-21 23:27:53 dankert
+// Felder mit Namen versehen. Beim Anlegen von Projekten Beispiel-Projekte ausw?hlen.
+//
// Revision 1.16 2007-11-17 20:55:41 dankert
// Fehlerhandling verbessert wenn Projektname nicht eingegeben.
//
@@ -121,27 +124,74 @@ class ProjectAction extends Action
function add()
{
+ $this->setTemplateVar( 'projects',Project::getAll() );
+
+ $examples = array();
+ $dir = opendir( 'examples/projects');
+ while( $file = readdir($dir) )
+ {
+ if ( substr($file,0,1) != '.' && ereg('.ini',$file) )
+ {
+ $examples[$file] = $file;
+ }
+ }
+
+ $this->setTemplateVar( 'examples',$examples );
}
-
+
+ /**
+ * Projekt hinzufuegen.
+ *
+ */
function addproject()
{
- // Projekt hinzufuegen
- if ( $this->getRequestVar('name') != '' )
+ if ( !$this->hasRequestVar('name') )
+ {
+ $this->addValidationError('name');
+ $this->callSubAction('add');
+ }
+ elseif ( !$this->hasRequestVar('type') )
{
- $this->project = new Project();
- $this->project->name = $this->getRequestVar('name');
- $this->project->add();
+ $this->addValidationError('type');
+ $this->callSubAction('add');
}
else
{
- $this->addValidationError('name');
- $this->callSubAction('add');
- return;
+ switch( $this->getRequestVar('type') )
+ {
+ case 'empty':
+ $this->project = new Project();
+ $this->project->name = $this->getRequestVar('name');
+ $this->project->add();
+ break;
+ case 'copy':
+ $db = db_connection();
+ $project = new Project($this->getRequestVar('projectid'));
+ $project->load();
+ $project->export($db->id);
+ break;
+ case 'example':
+ $this->project = new Project();
+ $this->project->name = $this->getRequestVar('name');
+ $this->project->add();
+
+ $example = parse_ini_file('examples/projects/'.$this->getRequestVar('example'),true);
+
+ break;
+ default:
+ Http::serverError('Unknown type while adding project '.$this->getRequestVar('type') );
+ }
+
+ $this->addNotice('project',$this->project->name,'ADDED');
}
}
+ /**
+ * Liste aller Projekte anzeigen.
+ *
+ */
function listing()
{
global $conf_php;
@@ -198,6 +248,7 @@ class ProjectAction extends Action
function remove()
{
+ $this->setTemplateVar( 'name',$this->project->name );
}
@@ -209,6 +260,7 @@ class ProjectAction extends Action
$this->project->delete();
$this->setTemplateVar('tree_refresh',true);
+ $this->addNotice('project',$this->project->name,'DELETED');
}
else
{
@@ -236,16 +288,20 @@ class ProjectAction extends Action
*/
function export()
{
+ $db = db_connection();
+ $this->setTemplateVar( 'dbid',$db->id );
+
global $conf;
$dbids = array();
foreach( $conf['database'] as $dbname=>$dbconf )
{
- if ( is_array($dbconf) )
+ if ( is_array($dbconf) && $dbconf['enabled'])
$dbids[$dbname] = $dbconf['comment'];
}
$this->setTemplateVar( 'dbids',$dbids );
+
if ( $this->hasRequestVar('ok') )
{
$this->project->export( $this->getRequestVar('dbid') );