eis-commits Mailing List for EIS Integration Server
Status: Pre-Alpha
Brought to you by:
baslijnse
You can subscribe to this list here.
| 2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(7) |
Jun
(8) |
Jul
|
Aug
(18) |
Sep
(18) |
Oct
(1) |
Nov
(4) |
Dec
(1) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2008 |
Jan
(1) |
Feb
(2) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2009 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <bas...@us...> - 2009-02-22 11:02:57
|
Revision: 228
http://eis.svn.sourceforge.net/eis/?rev=228&view=rev
Author: baslijnse
Date: 2009-02-22 11:02:50 +0000 (Sun, 22 Feb 2009)
Log Message:
-----------
Removed unneccary declare of in engine.lib.php of the 1.5.x branch. This caused the eis.sf.net website to break
Modified Paths:
--------------
branches/1.5.x/lib/engine/engine.lib.php
Modified: branches/1.5.x/lib/engine/engine.lib.php
===================================================================
--- branches/1.5.x/lib/engine/engine.lib.php 2008-02-24 14:42:21 UTC (rev 227)
+++ branches/1.5.x/lib/engine/engine.lib.php 2009-02-22 11:02:50 UTC (rev 228)
@@ -25,7 +25,6 @@
var $concrete_page = null;
//EGINE CONFIGURATION
- var $config;
var $datadirEnabled = false;
var $databaseEnabled = false;
var $sessionEnabled = false;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bas...@us...> - 2008-02-24 14:42:25
|
Revision: 227
http://eis.svn.sourceforge.net/eis/?rev=227&view=rev
Author: baslijnse
Date: 2008-02-24 06:42:21 -0800 (Sun, 24 Feb 2008)
Log Message:
-----------
various small bugfixes in the widget module
Modified Paths:
--------------
trunk/mod/eis_widget/services/MainService.php
Modified: trunk/mod/eis_widget/services/MainService.php
===================================================================
--- trunk/mod/eis_widget/services/MainService.php 2008-02-24 14:40:44 UTC (rev 226)
+++ trunk/mod/eis_widget/services/MainService.php 2008-02-24 14:42:21 UTC (rev 227)
@@ -85,7 +85,7 @@
* @return html rendering of the widget
*/
function displayString($value, $conf = null) {
- $html = nl2br(htmlentities($value));
+ $html = nl2br($value);
if(isset($conf['link']) && $conf['link'] != '')
$html = '<a href="'.$conf['link'].'">'.$html.'</a>';
@@ -134,7 +134,7 @@
if(isset($conf['format']) && $conf['format'] != '') {
$format = $conf['format'];
} else {
- $format = "H:i:s";
+ $format = "H:i";
}
return '<span class="widget-display-time">'.date($format, $timestamp).'</span>';
} else {
@@ -208,6 +208,21 @@
return '<span class="widget-display-currency">'.$sign.' '.$value.'</span>';
}
+ /**
+ * Displays a localized label
+ * @param $label the label to display
+ * @param $conf optional configuration of the widget
+ * @return html rendering of the widget
+ */
+ function displayLabel($label, $conf = null) {
+
+ $html = $this->e->getString($label);
+ if(isset($conf['link']) && $conf['link'] != '')
+ $html = '<a href="'.$conf['link'].'">'.$html.'</a>';
+
+ return '<span class="widget-display-label">'.$html.'</span>';
+ }
+
//BASIC SCALAR INPUT
/**
@@ -398,22 +413,43 @@
if($id == null) {
$id = 'input-'.$name;
}
- //If a value is given parse it into a timestamp
- if($value != null) {
- $date = strtotime($value);
- }
+ $vals = array();
switch($type) {
case 'date':
$fields = array('j','m','Y');
$format = "j-m-Y";
+ if(ereg("^([^-]*)-([^-]*)-(.*)$", $value, $matches)) {
+ $vals['j'] = $matches[3];
+ $vals['m'] = $matches[2];
+ $vals['Y'] = $matches[1];
+ } else {
+ $vals = array_combine($fields,array_fill(0,count($fields),""));
+ }
break;
case 'time':
$fields = array('H','i','s');
$format = "H:i:s";
+ if(ereg("^([^:]*):([^:]*):(.*)$", $value, $matches)) {
+ $vals['H'] = $matches[1];
+ $vals['i'] = $matches[2];
+ $vals['s'] = $matches[3];
+ } else {
+ $vals = array_combine($fields,array_fill(0,count($fields),""));
+ }
break;
case 'datetime':
$fields = array('j','m','Y','H','i','s');
$format = "j-m-Y H:i:s";
+ if(ereg("^([^-]*)-([^-]*)-([^ ]*) ([^:]*):([^:]*):(.*)$", $value, $matches)) {
+ $vals['j'] = $matches[3];
+ $vals['m'] = $matches[2];
+ $vals['Y'] = $matches[1];
+ $vals['H'] = $matches[4];
+ $vals['i'] = $matches[5];
+ $vals['s'] = $matches[6];
+ } else {
+ $vals = array_combine($fields,array_fill(0,count($fields),""));
+ }
break;
}
//Use custom format if configured
@@ -422,17 +458,16 @@
} else {
$html = $format;
}
- //Replace format markers by unique markers in format string
+ //Replace fields by unique markers
foreach($fields as $field) {
- $html = str_replace($field,'__'.$field.'__',$html);
+ $html = str_replace($field,'__'.$field.'__', $html);
}
//Replace unique markers by html
foreach($fields as $field) {
$inp = '<input type="text" id="'.$id.'-'.$field.'" ';
- if($value != null) {
- $inp .= 'value="'.date($field,$date).'" ';
- }
+ $inp .= 'value="'.$vals[$field].'" ';
+
if($field == 'Y') {
$inp .= 'size="4" maxlength="4" ';
} else {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bas...@us...> - 2008-02-24 14:40:49
|
Revision: 226
http://eis.svn.sourceforge.net/eis/?rev=226&view=rev
Author: baslijnse
Date: 2008-02-24 06:40:44 -0800 (Sun, 24 Feb 2008)
Log Message:
-----------
Added a 'prefix' and 'unprefix' method to the element base class for adding unique prefixes to formfields
Modified Paths:
--------------
trunk/lib/base/element.lib.php
Modified: trunk/lib/base/element.lib.php
===================================================================
--- trunk/lib/base/element.lib.php 2008-01-03 22:13:20 UTC (rev 225)
+++ trunk/lib/base/element.lib.php 2008-02-24 14:40:44 UTC (rev 226)
@@ -66,6 +66,35 @@
$this->e->session->save();
return is_array($post) ? $post : array();
}
+
+ /**
+ * Prefixes a form input name with the element's id to make it unique
+ */
+ function prefix($formname) {
+ return 'e-'.$this->getId().'-'.$formname;
+ }
+ /**
+ * Strips the prefix from a form input name if it has been prefixed with the 'prefix' method
+ */
+ function unprefix($formname) {
+ $id = 'e-'.$this->getId().'-';
+
+ if(strpos($formname,$id) === 0) {
+ return substr($formname, strlen($id));
+ } else {
+ return $formname;
+ }
+ }
+ /**
+ * Strips the prefix for an entire form
+ */
+ function unprefixForm($form) {
+ $new = array();
+ foreach($form as $k => $v) {
+ $new[$this->unprefix($k)] = $v;
+ }
+ return $new;
+ }
/**
*DEPRECATED
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bas...@us...> - 2008-01-03 22:13:23
|
Revision: 225
http://eis.svn.sourceforge.net/eis/?rev=225&view=rev
Author: baslijnse
Date: 2008-01-03 14:13:20 -0800 (Thu, 03 Jan 2008)
Log Message:
-----------
Fixed small bug in getPost/setPost methods of base element lib
Modified Paths:
--------------
trunk/lib/base/element.lib.php
Modified: trunk/lib/base/element.lib.php
===================================================================
--- trunk/lib/base/element.lib.php 2007-12-13 18:50:02 UTC (rev 224)
+++ trunk/lib/base/element.lib.php 2008-01-03 22:13:20 UTC (rev 225)
@@ -57,12 +57,12 @@
}
function setPost($post) {
- $this->e->session->set('post',$post,'page');
+ $this->e->session->set('post-'.$this->getId(),$post,'page');
$this->e->session->save();
}
function getPost() {
- $post = $this->e->session->get('post','page');
- $this->e->session->clear('post','page');
+ $post = $this->e->session->get('post-'.$this->getId(),'page');
+ $this->e->session->clear('post-'.$this->getId(),'page');
$this->e->session->save();
return is_array($post) ? $post : array();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bas...@us...> - 2007-12-13 18:50:13
|
Revision: 224
http://eis.svn.sourceforge.net/eis/?rev=224&view=rev
Author: baslijnse
Date: 2007-12-13 10:50:02 -0800 (Thu, 13 Dec 2007)
Log Message:
-----------
Added first rough version of the eis_file module
Modified Paths:
--------------
trunk/cfg/applications.xml
trunk/lib/engine/application.lib.php
trunk/lib/engine/engine.lib.php
trunk/lib/engine/request.lib.php
trunk/lib/engine/user.lib.php
Added Paths:
-----------
trunk/lib/base/fileservice.lib.php
trunk/mod/eis_file/
trunk/mod/eis_file/module.xml
trunk/mod/eis_file/services/
trunk/mod/eis_file/services/FileStoreService.php
Removed Paths:
-------------
trunk/mod/file/
Modified: trunk/cfg/applications.xml
===================================================================
--- trunk/cfg/applications.xml 2007-11-30 18:22:03 UTC (rev 223)
+++ trunk/cfg/applications.xml 2007-12-13 18:50:02 UTC (rev 224)
@@ -18,10 +18,4 @@
<application>examples</application>
<environment>minimal</environment>
</application>
- <application>
- <name>dsaasd</name>
- <module>eis_engine</module>
- <application>servermanager</application>
- <environment>minimal</environment>
- </application>
</applications>
Added: trunk/lib/base/fileservice.lib.php
===================================================================
--- trunk/lib/base/fileservice.lib.php (rev 0)
+++ trunk/lib/base/fileservice.lib.php 2007-12-13 18:50:02 UTC (rev 224)
@@ -0,0 +1,97 @@
+<?php
+ /**
+ * Base interface class for file storage services.
+ * If a module implements this interface, EIS can use it to store and retrieve files
+ */
+ class FileService extends Service {
+
+ /**
+ * Creates an empty file and returns an identifier
+ *
+ * @param path string the location of the file content
+ * @param name string the filename
+ * @param type string the mime type of the file
+ * @return The file identifier
+ */
+ function create($path, $name, $type) {
+ }
+ /**
+ * Deletes a file.
+ *
+ * @param id int The file identifier
+ */
+ function delete($id) {
+ }
+ /**
+ * Returns a path to the file.
+ *
+ * @param id int The file identifier
+ * @return A associative array with the file's attributes
+ */
+ function getPath($id) {
+ }
+ /**
+ * Returns an attribute record with metadata about the file.
+ * The record includes filename, filesize and mimetype
+ *
+ * @param id int The file identifier
+ * @return A associative array with the file's attributes
+ */
+ function getAttributes($id) {
+ }
+ /**
+ * Sets the full attribute record with metadata about the file.
+ *
+ * @param id int The file identifier
+ * @param attributes struct The attribute record
+ */
+ function setAttributes($id, $attributes) {
+ }
+ /**
+ * Returns the entire file content.
+ *
+ * @param id int The file identifier
+ * @return The file content
+ */
+ function getContent($id) {
+ }
+ /**
+ * Sets the entire file content.
+ *
+ * @param id int The file identifier
+ * @param content The file content
+ */
+ function setContent($id, $content) {
+ }
+ /**
+ * Returns the size of the file content counted in chunks.
+ *
+ * @param id int The file identifier
+ * @param chunksize int The size of a chunk in bytes
+ * @return The amount of chunks
+ */
+ function getContentChunkCount($id, $chunksize = null) {
+ }
+ /**
+ * Returns the i'th chunk of content from a file.
+ * Where i ranges from 0 to chunkcount -1.
+ *
+ * @param id int The file identifier
+ * @param i int The chunk index
+ * @param chunksize int The size of a chunk in bytes
+ * @return The chunk content
+ */
+ function getContentChunk($id, $i, $chunksize = null) {
+ }
+ /**
+ * Sets the i'th chunk of content in a file.
+ *
+ * @param id int The file identifier
+ * @param i int The chunk index
+ * @param content string The content to be put in the file
+ * @param chunksize int The size of a chunk in bytes
+ */
+ function setContentChunk($id, $i, $content, $chunksize = null) {
+ }
+ }
+?>
Modified: trunk/lib/engine/application.lib.php
===================================================================
--- trunk/lib/engine/application.lib.php 2007-11-30 18:22:03 UTC (rev 223)
+++ trunk/lib/engine/application.lib.php 2007-12-13 18:50:02 UTC (rev 224)
@@ -15,9 +15,8 @@
var $title = null;
- var $session_backend = null;
- var $authentication_backend = null;
- var $log_backend = null;
+ var $backends = array(); //Session, User, File, Image and Log
+ var $backend_defaults = array();
var $elements = array();
@@ -27,6 +26,13 @@
function Application(&$engine) {
$this->e =& $engine;
+
+ //Default backend services
+ $this->backend_defaults['session'] = array('module'=>'eis_session', 'service'=>'FileStoreService');
+ $this->backend_defaults['user'] = array('module'=>'eis_engine', 'service'=>'AuthService');
+ $this->backend_defaults['file'] = array('module'=>'eis_file', 'service'=>'FileStoreService');
+ $this->backend_defaults['image'] = array('module'=>'eis_image', 'service'=>'FileStoreService');
+ $this->backend_defaults['log'] = array('module'=>'eis_log', 'service'=>'FileLogService');
}
function load($application) {
@@ -66,9 +72,12 @@
$this->title = $struct->getValue($app,'title');
//Backends
- $this->session_backend = $struct->getValue($app,'session_backend');
- $this->authentication_backend = $struct->getValue($app,'authentication_backend');
- $this->log_backend = $struct->getValue($app,'log_backend');
+ foreach( array('session','user','file','image','log') as $backend) {
+ $service = $struct->getValue($app, $backend.'_backend');
+ if($service != null) {
+ $this->backends[$backend] = $service;
+ }
+ }
//Module configuration
$modules = $struct->getArray($app,'module');
@@ -238,6 +247,7 @@
} else {
$elem['depth'] = $this->elements[$id]['inherit_default'];
}
+
$subpage_pipelines[$subpage][] = $elem;
$catchall_pipeline[] = $elem;
}
@@ -307,9 +317,7 @@
$cache = "<?php\n";
$cache .= "\$this->modules =".var_export($this->modules, true).";\n";
$cache .= "\$this->title =".var_export($this->title, true).";\n";
- $cache .= "\$this->session_backend =".var_export($this->session_backend, true).";\n";
- $cache .= "\$this->authentication_backend =".var_export($this->authentication_backend, true).";\n";
- $cache .= "\$this->log_backend =".var_export($this->log_backend, true).";\n";
+ $cache .= "\$this->backends =".var_export($this->backends, true).";\n";
$cache .= "\$this->elements =".var_export($this->elements, true).";\n";
$cache .= "\$this->page_root =".var_export($this->page_root, true).";\n";
$cache .= "\$this->page_notfound =".var_export($this->page_notfound, true).";\n";
@@ -327,14 +335,27 @@
return $this->environment;
}
function getSessionBackend() {
- return $this->session_backend;
+ return $this->_getBackend('session');
}
- function getAuthenticationBackend() {
- return $this->authentication_backend;
+ function getUserBackend() {
+ return $this->_getBackend('user');
}
+ function getFileBackend() {
+ return $this->_getBackend('file');
+ }
+ function getImageBackend() {
+ return $this->_getBackend('image');
+ }
function getLogBackend() {
- return $this->log_backend;
+ return $this->_getBackend('log');
}
+ function _getBackend($type) {
+ if(isset($this->backends[$type])) {
+ return $this->backends[$type];
+ } else {
+ return $this->backend_defaults[$type];
+ }
+ }
function getRequiredModules() {
return array_keys($this->modules);
}
Modified: trunk/lib/engine/engine.lib.php
===================================================================
--- trunk/lib/engine/engine.lib.php 2007-11-30 18:22:03 UTC (rev 223)
+++ trunk/lib/engine/engine.lib.php 2007-12-13 18:50:02 UTC (rev 224)
@@ -249,8 +249,6 @@
fclose($f);
}
-
-
/**
*Load elementconfig
*@param module of the config to be loaded
@@ -290,8 +288,6 @@
return $instance;
}
-
-
/**
* Creates an element instance
*
@@ -407,7 +403,6 @@
$this->error(5000,$message);
}
}
-
/**
*Errorlist and the setting of errors
*@param code the code of the error
@@ -741,15 +736,14 @@
case 'static':
$this->serveStatic($args);
break;
+ case 'file':
+ $this->serveFile($args);
+ break;
case 'image':
$this->serveImage($args);
break;
- case 'file':
- $this->serveFile($args);
- break;
}
}
-
ob_end_flush();
}
@@ -904,35 +898,46 @@
$this->error(404);
}
}
+
/**
- * Serves an image stored by the image module
+ * Serves a file managed by EIS
*/
- function serveImage() {
+ function serveFile($args) {
- //Load and stream image data
- $sImage =& $this->getService('image');
+ $id = intval($args['file']);
- $request = explode('_',$this->request['image']);
- $image = $sImage->getImageById($request[0]);
+ //Load file service for the current application
+ $backend = $this->application->getFileBackend();
+ $service =& $this->getService($backend['module'], $backend['service']);
- $file = $sImage->getCachedByFilename($this->request['image']);
+ //Load file attributes
+ $attributes = $service->getAttributes($id);
- if(!$image || !$file ) {
+ if(!is_array($attributes)) {
$this->error(404);
+ return;
}
-
- //TODO: Check image clearance
- //Send headers
- header('Content-Type: '.$image['mime_type']);
- header('Content-Length: '.filesize($file));
- header('Last-Modified: '.date("r",filemtime($file)));
+ //Send headers
+ header('Content-Type: '.$attributes['type']);
+ header('Content-Length: '.$attributes['size']);
+ if($args['inline']) {
+ header('Content-Disposition: inline; filename='.$attributes['name']);
+ } else {
+ header('Content-Disposition: attachment; filename='.$attributes['name']);
+ }
- $this->_engineHeaders();
-
- //Stream data
- readfile($file);
+ //Stream content
+ $num = $service->getContentChunkCount($id);
+ for($i = 0; $i < $num; $i++) {
+ print $service->getContentChunk($id,$i);
+ }
}
+ /**
+ * Serves an image managed by EIS
+ */
+ function serveImage($args) {
+ }
/**
* Serves a web service request
@@ -1044,6 +1049,7 @@
}
/**< API METHODS */
+
function getBaseHost() {
return $this->baseHost;
}
@@ -1108,28 +1114,117 @@
function getStrings($module) {
return $this->locale->getStrings($module);
}
+ /**
+ * Get a reference to a service object.
+ *
+ * @param module string Module to which the service belongs
+ * @param service string The name of the module
+ */
+ function &getService($module, $service = 'MainService') {
+ if(!isset($this->services[$module][$service])) {
+ $this->services[$module][$service] = $this->_loadService($module,$service);
+ }
+
+ return $this->services[$module][$service];
+ }
+
+
+ //EIS Managed resource methods
+
+ /**
+ * Return the envionment's database connection
+ * @param shared boolean If shared is set to false a new connection is made.
+ */
function getDatabase($shared = true) {
return $this->environment->getDatabase($shared);
}
/**
- * Get the Datadir
+ * Return the path to the environments datadir
*
* @return returns the path to the dir on succes and null on failure
*/
function getDataDir() {
return $this->environment->getDataDir();
}
+ /**
+ * Create a new file in the EIS file storage
+ *
+ * @param path the path to the file on the filesystem
+ * @param name the filename which should be stored with the file
+ * @param the mimetype which should be stored with the file
+ * @return an integer, the id of the file
+ */
+ function createFileFromPath($path, $name, $type) {
+ $backend = $this->application->getFileBackend();
+ if(!is_array($backend)) {
+ return 0;
+ }
+ $service =& $this->getService($backend['module'],$backend['service']);
+
+ return $service->create($path, $name, $type);
+ }
/**
- * Get the page history
+ * Create a new file in the EIS file storage
+ * directly from an upload.
+ *
+ * @param name the name of the upload in the $_FILES array
+ * @return an integer, the id of the file
*/
- function getPageHistory() {
- return $this->session->getHistory();
+ function createFileFromUpload($name) {
+ if(is_array($_FILES[$name]) && is_uploaded_file($_FILES[$name]['tmp_name'])) {
+ return $this->createFileFromPath(
+ $_FILES[$name]['tmp_name'],
+ $_FILES[$name]['name'],
+ $_FILES[$name]['type'] );
+ } else {
+ return 0;
+ }
}
-
/**
- *makes an href for the user in a html link to a view of the current element
+ * Deletes a file stored in the EIS storage
+ *
+ * @param id the id of the file in the storage
+ */
+ function deleteFile($id) {
+ $backend = $this->application->getFileBackend();
+ if(!is_array($backend)) {
+ return;
+ }
+ $service =& $this->getService($backend['module'],$backend['service']);
+ $service->delete($id);
+ }
+ /**
+ * Returns the path to the file
+ *
+ * @param id the id of the file in the storage
+ * @return the path to the file
+ */
+ function getFile($id) {
+ $backend = $this->application->getFileBackend();
+ if(!is_array($backend)) {
+ return;
+ }
+ $service =& $this->getService($backend['module'],$backend['service']);
+ return $service->getPath($id);
+ }
+ /**
+ * Returns the attributes of file
+ *
+ * @param id the id of the file in the storage
+ * @return an attributes record containing filename, type and size
+ */
+ function getFileAttributes($id) {
+ $backend = $this->application->getFileBackend();
+ if(!is_array($backend)) {
+ return;
+ }
+ $service =& $this->getService($backend['module'],$backend['service']);
+ return $service->getAttributes($id);
+ }
+ /**
+ *Makes an href for the user in a html link to a view of the current element
*@param view the name of a view of the currentelement
*@param parameter an array of parameters for the href
*@see hrefPage hrefAction hrefDetach hrefImage hrefPreviousPage hrefParentPage
@@ -1234,7 +1329,7 @@
*/
function hrefPreviousPage($steps = 1) {
- $history = $this->getPageHistory();
+ $history = $this->session->getHistory();
if(!is_array($history) || ! count($history)) {
return $this->hrefParentPage();
}
@@ -1262,33 +1357,31 @@
return $link;
}
- /**
- *Make image link
- *@param id the imgae id
- *@param attributes attributes of the filename
- *@see hrefPage hrefAction hrefView hrefDetach hrefParentPage hrefPreviousPage
- *@result a string containing the link
+ /**
+ * Creates a link to an EIS managed file
+ * @param id int The id of the file
+ * @param inline bool sent the file content as inline content. Default is attachment.
*/
- function hrefImage($id, $attributes) {
- $sI =& $this->getService('image');
- $hash = $sI->genFilename($id, $attributes);
+ function hrefFile($id, $inline = false) {
+ $link = $this->getApplicationPath().'F/';
+ $link .= intval($id);
+ if ($inline) {
+ $link .= '/inline';
+ }
- $str = '?i='.$hash;
-
- return $str;
+ return $link;
}
-
- function hrefFile($id, $attachment = true) {
- }
/**
- *Set header to redirect to a specified url
- *@param path the path for the header to redirect to
+ * Creates a link to an EIS managed image
+ *@param id the imgae id
+ *@param options dictionary with image options
*/
- function redirect($path) {
- header('Location: '.$this->baseHost.$path);
- exit;
+ function hrefImage($id, $attributes = null) {
+ //TODO
}
+ // Content generation
+
function showMessage($string, $replacements = null) {
$msg['type'] = 'message';
$msg['string'] = $string;
@@ -1379,18 +1472,13 @@
function setContentType($mimetype) {
$this->contentType = $mimetype;
}
-
/**
- * Get a reference to a service object.
- *
+ *Set header to redirect to a specified url
+ *@param path the path for the header to redirect to
*/
- function &getService($module, $service = 'MainService') {
-
- if(!isset($this->services[$module][$service])) {
- $this->services[$module][$service] = $this->_loadService($module,$service);
- }
-
- return $this->services[$module][$service];
+ function redirect($path) {
+ header('Location: '.$this->baseHost.$path);
+ exit;
}
}
?>
Modified: trunk/lib/engine/request.lib.php
===================================================================
--- trunk/lib/engine/request.lib.php 2007-11-30 18:22:03 UTC (rev 223)
+++ trunk/lib/engine/request.lib.php 2007-12-13 18:50:02 UTC (rev 224)
@@ -93,9 +93,17 @@
}
break;
case 'F':
- if(count($this->path) == 2) {
+ $c = count($this->path);
+ if($c == 2 || $c == 3) {
$this->subtype = 'file';
$this->args['file'] = intval($this->path[1]);
+ $this->args['inline'] = false;
+
+ if($c == 3) {
+ if($this->path[2] == 'inline') {
+ $this->args['inline'] = true;
+ }
+ }
} else {
print "Invalid file resource request";
}
Modified: trunk/lib/engine/user.lib.php
===================================================================
--- trunk/lib/engine/user.lib.php 2007-11-30 18:22:03 UTC (rev 223)
+++ trunk/lib/engine/user.lib.php 2007-12-13 18:50:02 UTC (rev 224)
@@ -99,7 +99,7 @@
* @return the uid of the user (integer) or 0 when the login failed.
*/
function loginByCredentials($username, $password) {
- $backend = $this->e->application->getAuthenticationBackend();
+ $backend = $this->e->application->getUserBackend();
if(!is_array($backend)) {
return 0;
}
@@ -120,7 +120,7 @@
* @return the uid of the user (integer) or 0 when the login failed.
*/
function loginByMD5($username, $seed, $hash) {
- $backend = $this->e->application->getAuthenticationBackend();
+ $backend = $this->e->application->getUserBackend();
if(!is_array($backend)) {
return 0;
}
Added: trunk/mod/eis_file/module.xml
===================================================================
--- trunk/mod/eis_file/module.xml (rev 0)
+++ trunk/mod/eis_file/module.xml 2007-12-13 18:50:02 UTC (rev 224)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<module>
+ <name>eis_file</name>
+ <version>0.1.0</version>
+ <description>File management of an EIS server.</description>
+ <author>EIS Team</author>
+ <homepage>http://eis.sourceforge.net/</homepage>
+ <license>BSD License</license>
+</module>
Added: trunk/mod/eis_file/services/FileStoreService.php
===================================================================
--- trunk/mod/eis_file/services/FileStoreService.php (rev 0)
+++ trunk/mod/eis_file/services/FileStoreService.php 2007-12-13 18:50:02 UTC (rev 224)
@@ -0,0 +1,187 @@
+<?php
+ require_once("lib/base/fileservice.lib.php");
+
+ /**
+ * Base interface class for file storage services.
+ * If a module implements this interface, EIS can use it to store and retrieve files
+ */
+ class eis_file_FileStoreService extends FileService {
+
+ var $basedir = '/eis_file/';
+ var $chunksize = 1024;
+
+ var $handles = array();
+
+ /**
+ * Creates an empty file and returns an identifier
+ * @return The file identifier
+ */
+ function create($path, $name, $type) {
+ $id = $this->_nextId();
+
+ //Create the file dir
+ mkdir($this->_getFileDir($id));
+
+ //Create attributes file
+ $attr = array('name' => $name, 'type' => $type);
+ $attr = '<?php $attributes = '.var_export($attr,true).'; ?>';
+ file_put_contents($this->_getFileDir($id).'/attributes',$attr);
+
+ //Copy content
+ copy($path, $this->_getFileDir($id).'/content');
+
+ return $id;
+ }
+ /**
+ * Deletes a file.
+ *
+ * @param id int The file identifier
+ */
+ function delete($id) {
+ $dir = $this->_getFileDir($id);
+
+ unlink($dir.'/content');
+ unlink($dir.'/attributes');
+ rmdir($dir);
+ }
+
+ /**
+ * Returns a path to the file.
+ *
+ * @param id int The file identifier
+ * @return A associative array with the file's attributes
+ */
+ function getPath($id) {
+ return $this->_getFileDir($id).'/content';
+ }
+
+ /**
+ * Returns an attribute record with metadata about the file.
+ * The record includes filename, filesize and mimetype
+ *
+ * @param id int The file identifier
+ * @return A associative array with the file's attributes
+ */
+ function getAttributes($id) {
+ $attribute_file = $this->_getFileDir($id).'/attributes';
+
+ if(is_readable($attribute_file)) {
+ include($attribute_file);
+ if(isset($attributes)) {
+ //Add filesize
+ $attributes['size'] = $this->_getFileSize($id); return $attributes;
+ }
+ }
+ return null;
+ }
+ /**
+ * Sets the full attribute record with metadata about the file.
+ *
+ * @param id int The file identifier
+ * @param attributes struct The attribute record
+ */
+ function setAttributes($id, $attributes) {
+ }
+ /**
+ * Returns the entire file content.
+ *
+ * @param id int The file identifier
+ * @return The file content
+ */
+ function getContent($id) {
+ return file_get_contents($this->_getFileContentPath($id));
+ }
+ /**
+ * Sets the entire file content.
+ *
+ * @param id int The file identifier
+ * @param content The file content
+ */
+ function setContent($id, $content) {
+ file_put_contents($this->_getFileContentPath($id),$content);
+ }
+ /**
+ * Returns the size of the file content counted in chunks.
+ *
+ * @param id int The file identifier
+ * @param chunksize int The size of a chunk in bytes
+ * @return The amount of chunks
+ */
+ function getContentChunkCount($id, $chunksize = null) {
+ return ceil(floatval($this->_getFileSize($id)) / (($chunksize == null) ? $this->chunksize : $chunksize));
+ }
+ /**
+ * Returns the i'th chunk of content from a file.
+ * Where i ranges from 0 to chunkcount -1.
+ *
+ * @param id int The file identifier
+ * @param i int The chunk index
+ * @param chunksize int The size of a chunk in bytes
+ * @return The chunk content
+ */
+ function getContentChunk($id, $i, $chunksize = null) {
+ $size = ($chunksize == null) ? $this->chunksize : $chunksize;
+ $offset = $i * $size;
+
+ $f = $this->_openFile($id);
+ fseek($f, $offset, SEEK_SET);
+
+ return fread($f, $size);
+ }
+ /**
+ * Sets the i'th chunk of content in a file.
+ *
+ * @param id int The file identifier
+ * @param i int The chunk index
+ * @param content string The content to be put in the file
+ * @param chunksize int The size of a chunk in bytes
+ */
+ function setContentChunk($id, $i, $content, $chunksize = null) {
+ //TODO
+ }
+ function _nextId() {
+
+ $dir = $this->e->getDatadir().$this->basedir;
+
+ if(is_dir($dir)) {
+ $next = 1;
+ $d = opendir($dir);
+ while($entry = readdir($d)) {
+ if(intval($entry) >= $next) {
+ $next = intval($entry) + 1;
+ }
+ }
+ closedir($d);
+
+ return $next;
+ } else {
+ mkdir($dir);
+ return 1;
+ }
+ }
+
+ function _getFileDir($id) {
+ return $this->e->getDatadir().$this->basedir.intval($id);
+ }
+ function _getFileAttributePath($id) {
+ return $this->_getFileDir($id).'/attributes';
+ }
+ function _getFileContentPath($id) {
+ return $this->_getFileDir($id).'/content';
+ }
+ function _getFileSize($id) {
+ $path = $this->_getFileContentPath($id);
+ if(file_exists($path)) {
+ return filesize($path);
+ } else {
+ return 0;
+ }
+ }
+ function _openFile($id) {
+ if(!isset($this->handles[$id])) {
+ $this->handles[$id] = fopen($this->_getFileContentPath($id),'r');
+ }
+ return $this->handles[$id];
+ }
+ }
+?>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bas...@us...> - 2007-11-30 18:22:08
|
Revision: 223
http://eis.svn.sourceforge.net/eis/?rev=223&view=rev
Author: baslijnse
Date: 2007-11-30 10:22:03 -0800 (Fri, 30 Nov 2007)
Log Message:
-----------
Removed PHP4/5 config optimalization, because it sometimes causes segfaults
Modified Paths:
--------------
trunk/index.php
Modified: trunk/index.php
===================================================================
--- trunk/index.php 2007-11-08 21:37:40 UTC (rev 222)
+++ trunk/index.php 2007-11-30 18:22:03 UTC (rev 223)
@@ -16,8 +16,6 @@
//Turn off magic quotes
require("lib/utils/magicquotes.lib.php");
- //PHP5 Workaround
- ini_set('zend.ze1_compatibility_mode',1);
if(!defined('E_STRICT')) {
define('E_STRICT',2048);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luu...@us...> - 2007-11-08 21:37:41
|
Revision: 222
http://eis.svn.sourceforge.net/eis/?rev=222&view=rev
Author: luukvandenbroek
Date: 2007-11-08 13:37:40 -0800 (Thu, 08 Nov 2007)
Log Message:
-----------
added svn ignore property to cache and data dir
Property Changed:
----------------
trunk/cache/
trunk/data/
Property changes on: trunk/cache
___________________________________________________________________
Name: svn:ignore
+ *
Property changes on: trunk/data
___________________________________________________________________
Name: svn:ignore
+ *
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luu...@us...> - 2007-11-08 21:31:17
|
Revision: 221
http://eis.svn.sourceforge.net/eis/?rev=221&view=rev
Author: luukvandenbroek
Date: 2007-11-08 13:31:14 -0800 (Thu, 08 Nov 2007)
Log Message:
-----------
fixed bug and made small change to makeOptions element
Modified Paths:
--------------
trunk/cfg/applications.xml
trunk/mod/eis_engine/elements/EditApplication.php
trunk/mod/eis_widget/services/MainService.php
Modified: trunk/cfg/applications.xml
===================================================================
--- trunk/cfg/applications.xml 2007-11-08 20:18:14 UTC (rev 220)
+++ trunk/cfg/applications.xml 2007-11-08 21:31:14 UTC (rev 221)
@@ -18,4 +18,10 @@
<application>examples</application>
<environment>minimal</environment>
</application>
+ <application>
+ <name>dsaasd</name>
+ <module>eis_engine</module>
+ <application>servermanager</application>
+ <environment>minimal</environment>
+ </application>
</applications>
Modified: trunk/mod/eis_engine/elements/EditApplication.php
===================================================================
--- trunk/mod/eis_engine/elements/EditApplication.php 2007-11-08 20:18:14 UTC (rev 220)
+++ trunk/mod/eis_engine/elements/EditApplication.php 2007-11-08 21:31:14 UTC (rev 221)
@@ -33,7 +33,11 @@
$inputs[] = $sWidget->inputString('application',$app['application'],$options);
$labels[] = 'eis_engine.l.environment';
- $options = $sWidget->makeOptions($sModule->listEnvironments(),'eis_engine.l.select');
+ $options = array();
+ $environments = $sConfig->getEnvironments();
+ foreach($environments as $environment){
+ $options[] = array('label' => $environment['name'], 'value' => $environment['name']);
+ }
$inputs[] = $sWidget->inputString('environment',$app['environment'],$options);
$labels[] = 'eis_engine.l.default';
Modified: trunk/mod/eis_widget/services/MainService.php
===================================================================
--- trunk/mod/eis_widget/services/MainService.php 2007-11-08 20:18:14 UTC (rev 220)
+++ trunk/mod/eis_widget/services/MainService.php 2007-11-08 21:31:14 UTC (rev 221)
@@ -859,8 +859,12 @@
$options[] = array('label' => $this->e->getString($title), 'value' => '');
}
if(is_array($values)) {
- foreach($values as $value) {
- $options[] = array('label' => $value, 'value' => $value);
+ foreach($values as $k => $value) {
+ if(is_array($value)){
+ $options[] = array('label' => $k, 'value' => $k);
+ }else{
+ $options[] = array('label' => $value, 'value' => $value);
+ }
}
}
return $options;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luu...@us...> - 2007-11-08 20:18:24
|
Revision: 220
http://eis.svn.sourceforge.net/eis/?rev=220&view=rev
Author: luukvandenbroek
Date: 2007-11-08 12:18:14 -0800 (Thu, 08 Nov 2007)
Log Message:
-----------
added missing elements for server manager everything works except adding modules the element has not yet been made
Modified Paths:
--------------
trunk/cfg/applications.xml
trunk/cfg/webservices.xml
trunk/mod/eis_engine/applications/servermanager.xml
trunk/mod/eis_engine/elements/AddWebService.php
trunk/mod/eis_engine/elements/DeleteEnvironment.php
trunk/mod/eis_engine/elements/DeleteWebService.php
trunk/mod/eis_engine/elements/DisplayApplication.php
trunk/mod/eis_engine/elements/EditWebService.php
trunk/mod/eis_engine/locales/en_en/strings.xml
trunk/mod/eis_engine/services/ConfigService.php
Added Paths:
-----------
trunk/mod/eis_engine/elements/DeleteApplication.php
trunk/mod/eis_engine/elements/EditApplication.php
Modified: trunk/cfg/applications.xml
===================================================================
--- trunk/cfg/applications.xml 2007-10-13 12:06:47 UTC (rev 219)
+++ trunk/cfg/applications.xml 2007-11-08 20:18:14 UTC (rev 220)
@@ -18,10 +18,4 @@
<application>examples</application>
<environment>minimal</environment>
</application>
- <application>
- <name>test</name>
- <module>eis_engine</module>
- <application>welcome</application>
- <environment>minimal</environment>
- </application>
</applications>
Modified: trunk/cfg/webservices.xml
===================================================================
--- trunk/cfg/webservices.xml 2007-10-13 12:06:47 UTC (rev 219)
+++ trunk/cfg/webservices.xml 2007-11-08 20:18:14 UTC (rev 220)
@@ -3,7 +3,7 @@
<webservice>
<name>status</name>
<module>eis_engine</module>
- <service>StatusService</service>
+ <service>ConfigService</service>
<protocol>xml-rpc</protocol>
<environment>dev</environment>
</webservice>
Modified: trunk/mod/eis_engine/applications/servermanager.xml
===================================================================
--- trunk/mod/eis_engine/applications/servermanager.xml 2007-10-13 12:06:47 UTC (rev 219)
+++ trunk/mod/eis_engine/applications/servermanager.xml 2007-11-08 20:18:14 UTC (rev 220)
@@ -162,6 +162,30 @@
<element>DisplayApplication</element>
<area>MAIN</area>
</element>
+ <page>
+ <name>edit</name>
+ <meta><name>menu-entry</name><value>eis_engine.t.edit.application</value></meta>
+ <element>
+ <module>eis_layout</module>
+ <element>String</element>
+ <area>TITLE</area>
+ <config><name>string</name><value>eis_engine.t.edit.application</value></config>
+ </element>
+ <element>
+ <module>eis_engine</module>
+ <element>EditApplication</element>
+ <area>MAIN</area>
+ </element>
+ </page>
+ <page>
+ <name>delete</name>
+ <meta><name>menu-entry</name><value>eis_engine.t.delete.application</value></meta>
+ <element>
+ <module>eis_engine</module>
+ <element>DeleteApplication</element>
+ <area>MAIN</area>
+ </element>
+ </page>
</catchall>
</page>
<page>
Modified: trunk/mod/eis_engine/elements/AddWebService.php
===================================================================
--- trunk/mod/eis_engine/elements/AddWebService.php 2007-10-13 12:06:47 UTC (rev 219)
+++ trunk/mod/eis_engine/elements/AddWebService.php 2007-11-08 20:18:14 UTC (rev 220)
@@ -9,7 +9,7 @@
$labels = array();
$inputs = array();
- $fields = array('module','service','mountpoint','environment','default');
+ $fields = array('module','service','mountpoint','environment','protocol');
$posted = $this->e->session->get('form','page');
$vals = $sWidget->fillValues($fields,null,$posted,$args);
@@ -25,6 +25,13 @@
$labels[] = 'eis_engine.l.mountpoint';
$inputs[] = $sWidget->inputString('mountpoint', $vals['mountpoint']);
+ $labels[] = 'eis_engine.l.protocol';
+ #TODO find better way to get values for options array
+ $options = array();
+ $options[] = array('value' => 'xml-rpc', 'label' => 'xml-rpc');
+ $options[] = array('value' => 'xml-struct', 'label' => 'xml-struct');
+ $inputs[] = $sWidget->inputString('protocol',$vals['protocol'],$options);
+
$labels[] = 'eis_engine.l.environment';
$options = $sWidget->makeOptions($sConfig->listEnvironments(),'eis_engine.l.select');
$inputs[] = $sWidget->inputString('environment',$vals['environment'],$options);
@@ -48,5 +55,27 @@
print $sWidget->jsEncodeOptions($options);
}
+
+ function action_ok($form) {
+ $sConfig =& $this->e->getService('eis_engine','ConfigService');
+
+ $obj['name'] = $form['mountpoint'];
+ $obj['module'] = $form['module'];
+ $obj['service'] = $form['service'];
+ $obj['protocol'] = $form['protocol'];
+ $obj['environment'] = $form['environment'];
+
+ $sConfig->createWebService($obj);
+
+ if($sConfig->success()) {
+ $this->e->showMessage('eis_engine.m.webservice.added',array($obj['webservice'],$obj['name']));
+ $this->e->redirect($this->e->hrefParentPage());
+ } else {
+ $this->setPost($form);
+ $this->e->showServiceError($sConfig->getError());
+ $this->e->redirect($this->e->hrefCurrentPage());
+ }
+ }
+
}
?>
Added: trunk/mod/eis_engine/elements/DeleteApplication.php
===================================================================
--- trunk/mod/eis_engine/elements/DeleteApplication.php (rev 0)
+++ trunk/mod/eis_engine/elements/DeleteApplication.php 2007-11-08 20:18:14 UTC (rev 220)
@@ -0,0 +1,42 @@
+<?php
+ class eis_engine_DeleteApplication extends Element {
+
+ function view_default($args) {
+
+ $sConfig =& $this->e->getService('eis_engine','ConfigService');
+ $sWidget =& $this->e->getService('eis_widget');
+
+ $path = $this->getPath();
+ $name = $path[count($path) -2];
+ $app = $sConfig->getApplication($name);
+
+ if($app == null) {
+ $this->e->error(404);
+ }
+
+ $form = $sWidget->displayString($this->e->getString('eis_engine.q.delete.application', array($name)));
+ $form .= $sWidget->buttonSetOkCancel();
+ print $sWidget->form($form,$this->e->hrefAction('ok'));
+
+
+ }
+
+ function action_ok(){
+ $sConfig =& $this->e->getService('eis_engine','ConfigService');
+
+ $path = $this->getPath();
+ $name = $path[count($path) -2];
+
+ $sConfig->deleteApplication($name);
+
+ if($sConfig->success()) {
+ $this->e->showMessage('eis_engine.m.application.deleted',array($name));
+ $this->e->redirect($this->e->hrefParentPage(2));
+ } else {
+ $this->setPost($data);
+ $this->e->showServiceError($sConfig->getError());
+ $this->e->redirect($this->e->hrefCurrentPage());
+ }
+ }
+ }
+?>
Modified: trunk/mod/eis_engine/elements/DeleteEnvironment.php
===================================================================
--- trunk/mod/eis_engine/elements/DeleteEnvironment.php 2007-10-13 12:06:47 UTC (rev 219)
+++ trunk/mod/eis_engine/elements/DeleteEnvironment.php 2007-11-08 20:18:14 UTC (rev 220)
@@ -9,7 +9,7 @@
$path = $this->getPath();
$name = $path[count($path) -2];
$env = $sConfig->getEnvironment($name);
-
+ print_r($path);
if($env == null) {
$this->e->error(404);
}
@@ -31,7 +31,7 @@
if($sConfig->success()) {
$this->e->showMessage('eis_engine.m.environment.deleted',array($name));
- $this->e->redirect($this->e->hrefPreviousPage(2));
+ $this->e->redirect($this->e->hrefParentPage(2));
} else {
$this->setPost($data);
$this->e->showServiceError($sConfig->getError());
Modified: trunk/mod/eis_engine/elements/DeleteWebService.php
===================================================================
--- trunk/mod/eis_engine/elements/DeleteWebService.php 2007-10-13 12:06:47 UTC (rev 219)
+++ trunk/mod/eis_engine/elements/DeleteWebService.php 2007-11-08 20:18:14 UTC (rev 220)
@@ -1,7 +1,42 @@
<?php
- class eis_engine_DeleteWebService extends Element {
- function view_default($id) {
- print 'DeleteWebService';
+ class eis_engine_DeleteWebservice extends Element {
+
+ function view_default($args) {
+
+ $sConfig =& $this->e->getService('eis_engine','ConfigService');
+ $sWidget =& $this->e->getService('eis_widget');
+
+ $path = $this->getPath();
+ $name = $path[count($path) -2];
+ $ws = $sConfig->getWebService($name);
+
+ if($ws == null) {
+ $this->e->error(404);
+ }
+
+ $form = $sWidget->displayString($this->e->getString('eis_engine.q.delete.webservice', array($name)));
+ $form .= $sWidget->buttonSetOkCancel();
+ print $sWidget->form($form,$this->e->hrefAction('ok'));
+
+
}
+
+ function action_ok(){
+ $sConfig =& $this->e->getService('eis_engine','ConfigService');
+
+ $path = $this->getPath();
+ $name = $path[count($path) -2];
+
+ $sConfig->deleteWebService($name);
+
+ if($sConfig->success()) {
+ $this->e->showMessage('eis_engine.m.webservice.deleted',array($name));
+ $this->e->redirect($this->e->hrefParentPage(2));
+ } else {
+ $this->setPost($data);
+ $this->e->showServiceError($sConfig->getError());
+ $this->e->redirect($this->e->hrefCurrentPage());
+ }
+ }
}
?>
Modified: trunk/mod/eis_engine/elements/DisplayApplication.php
===================================================================
--- trunk/mod/eis_engine/elements/DisplayApplication.php 2007-10-13 12:06:47 UTC (rev 219)
+++ trunk/mod/eis_engine/elements/DisplayApplication.php 2007-11-08 20:18:14 UTC (rev 220)
@@ -31,7 +31,7 @@
$labels[] = 'eis_engine.l.name';
$inputs[] = $sWidget->displayString($app['name']);
- $labels[] = 'eis_engine.l.url';
+ $labels[] = 'eis_engine.l.mountpoint';
$inputs[] = $sWidget->displayURL($this->e->getBaseUrl().$app['name']);
$labels[] = 'eis_engine.l.module';
Added: trunk/mod/eis_engine/elements/EditApplication.php
===================================================================
--- trunk/mod/eis_engine/elements/EditApplication.php (rev 0)
+++ trunk/mod/eis_engine/elements/EditApplication.php 2007-11-08 20:18:14 UTC (rev 220)
@@ -0,0 +1,89 @@
+<?php
+ class eis_engine_EditApplication extends Element {
+ function view_default($args) {
+ $sConfig =& $this->e->getService('eis_engine','ConfigService');
+ $sModule =& $this->e->getService('eis_engine','ModuleService');
+ $sWidget =& $this->e->getService('eis_widget','MainService');
+
+ $path = $this->getPath();
+ $name = $path[count($path) -2];
+
+ $defaults = $sConfig->getApplication($name);
+ if($defaults == null) {
+ $this->e->error(404);
+ }
+
+
+ $fields = array('module','application','mountpoint','environment','default');
+ $posted = $this->e->session->get('form','page');
+ $app = $sWidget->fillValues($fields,$defaults,$posted,$args);
+
+ $labels = array();
+ $inputs = array();
+
+ $labels[] = 'eis_engine.l.name';
+ $inputs[] = $sWidget->displayString($defaults['name']);
+
+ $labels[] = 'eis_engine.l.module';
+ $options = $sWidget->makeOptions($sModule->listModules(),'eis_engine.l.select');
+ $inputs[] = $sWidget->inputString('module',$app['module'],$options);
+
+ $labels[] = 'eis_engine.l.application';
+ $options = $sWidget->makeOptions($sModule->listApplications($app['module']),'eis_engine.l.select');
+ $inputs[] = $sWidget->inputString('application',$app['application'],$options);
+
+ $labels[] = 'eis_engine.l.environment';
+ $options = $sWidget->makeOptions($sModule->listEnvironments(),'eis_engine.l.select');
+ $inputs[] = $sWidget->inputString('environment',$app['environment'],$options);
+
+ $labels[] = 'eis_engine.l.default';
+ $inputs[] = $sWidget->inputBoolean('default', $app['default']);
+
+ $form = $sWidget->formTable($labels, $inputs);
+ $form .= $sWidget->buttonSetOkCancel();
+
+ $form .= $sWidget->jsUpdateSelect('module','application',$this->e->hrefView('applicationOptions'));
+
+ print $sWidget->form($form,$this->e->hrefAction('ok'));
+ }
+
+ function view_applicationOptions($args) {
+
+ $sModule =& $this->e->getService('eis_engine','ModuleService');
+ $sWidget =& $this->e->getService('eis_widget','MainService');
+
+ $module = isset($args['module']) ? $args['module'] : null;
+
+ $apps = $sModule->listApplications($module);
+ $options = $sWidget->makeOptions($apps,'eis_engine.l.select');
+
+ print $sWidget->jsEncodeOptions($options);
+ }
+
+ function action_ok($data){
+ $sConfig =& $this->e->getService('eis_engine','ConfigService');
+
+ $path = $this->getPath();
+ $name = $path[count($path) -2];
+
+ $application = array();
+ $application['name'] = $name;
+
+ foreach($data as $k => $v){
+ $application[$k] = $v;
+ }
+
+ $sConfig->updateApplication($application);
+
+ if($sConfig->success()) {
+ $this->e->showMessage('eis_engine.m.application.updated',array($name));
+ $this->e->redirect($this->e->hrefParentPage());
+ } else {
+ $this->setPost($data);
+ $this->e->showServiceError($sConfig->getError());
+ $this->e->redirect($this->e->hrefCurrentPage());
+ }
+
+ }
+ }
+?>
Modified: trunk/mod/eis_engine/elements/EditWebService.php
===================================================================
--- trunk/mod/eis_engine/elements/EditWebService.php 2007-10-13 12:06:47 UTC (rev 219)
+++ trunk/mod/eis_engine/elements/EditWebService.php 2007-11-08 20:18:14 UTC (rev 220)
@@ -1,59 +1,92 @@
<?php
class eis_engine_EditWebService extends Element {
- function view_default($id) {
+ function view_default($args) {
+
$sConfig =& $this->e->getService('eis_engine','ConfigService');
+ $sModule =& $this->e->getService('eis_engine','ModuleService');
$sWidget =& $this->e->getService('eis_widget','MainService');
-
+
$path = $this->getPath();
- $name = $path[count($path) -2];
+ $name = $path[count($path) -2];
- $ws = $sConfig->getWebService($name);
+ $defaults = $sConfig->getWebService($name);
+ if($defaults == null) {
+ $this->e->error(404);
+ }
+
+ $fields = array('module','service','mountpoint','environment','protocol');
+ $posted = $this->e->session->get('form','page');
+ $ws = $sWidget->fillValues($fields,$defaults,$posted,$args);
- if($ws == null) {
- $this->e->error(404);
- }
-
- $form = $this->e->session->get('form','page');
-
$labels = array();
$inputs = array();
-
+
$labels[] = 'eis_engine.l.name';
- $inputs[] = $sWidget->displayString($ws['name']);
-
+ $inputs[] = $sWidget->displayString($defaults['name']);
+
$labels[] = 'eis_engine.l.module';
- $inputs[] = $sWidget->displayString($ws['module']);
+ $options = $sWidget->makeOptions($sModule->listModules(),'eis_engine.l.select');
+ $inputs[] = $sWidget->inputString('module',$ws['module'],$options);
$labels[] = 'eis_engine.l.service';
- $inputs[] = $sWidget->displayString($ws['service']);
+ $options = $sWidget->makeOptions($sModule->listServices($ws['module']),'eis_engine.l.select');
+ $inputs[] = $sWidget->inputString('service',$ws['service'],$options);
+ $labels[] = 'eis_engine.l.protocol';
+ #TODO find better way to get values for options array
$options = array();
- $environments = $sConfig->listEnvironments();
- foreach($environments as $dep) {
- $options[] = array('label' => $dep, 'value' => $dep);
- }
+ $options[] = array('value' => 'xml-rpc', 'label' => 'xml-rpc');
+ $options[] = array('value' => 'xml-struct', 'label' => 'xml-struct');
+ $inputs[] = $sWidget->inputString('protocol',$ws['protocol'],$options);
$labels[] = 'eis_engine.l.environment';
- $inputs[] = $sWidget->inputString('module',$ws['environment'], $options);
+ $options = $sWidget->makeOptions($sConfig->listEnvironments(),'eis_engine.l.select');
+ $inputs[] = $sWidget->inputString('environment',$ws['environment'],$options);
- $options = array();
- $options[] = array('label' => 'xml-rpc','value' => 'xml-rpc');
- $options[] = array('label' => 'xml-struct','value' => 'xml-struct');
-
- $labels[] = 'eis_engine.l.protocol';
- $inputs[] = $sWidget->inputString('module',$ws['protocol'], $options);
-
$form = $sWidget->formTable($labels, $inputs);
$form .= $sWidget->buttonSetOkCancel();
+ $form .= $sWidget->jsUpdateSelect('module','service',$this->e->hrefView('serviceOptions'));
+
print $sWidget->form($form,$this->e->hrefAction('ok'));
- //print $sWidget->form($form,'#');
}
+
+ function view_serviceOptions($args) {
+ $sModule =& $this->e->getService('eis_engine','ModuleService');
+ $sWidget =& $this->e->getService('eis_widget','MainService');
+
+ $module = isset($args['module']) ? $args['module'] : null;
+
+ $services = $sModule->listServices($module);
+ $options = $sWidget->makeOptions($services,'eis_engine.l.select');
+
+ print $sWidget->jsEncodeOptions($options);
+ }
+
function action_ok($form) {
- $this->e->session->set('form',$form,'page');
- $this->e->session->save();
+ $sConfig =& $this->e->getService('eis_engine','ConfigService');
- $this->e->redirect($this->e->hrefPreviousPage());
+ $path = $this->getPath();
+ $name = $path[count($path) -2];
+
+ $webservice = array();
+ $webservice['name'] = $name;
+
+ foreach($form as $k => $v){
+ $webservice[$k] = $v;
+ }
+
+ $sConfig->updateWebService($webservice);
+
+ if($sConfig->success()) {
+ $this->e->showMessage('eis_engine.m.webservice.updated',array($name));
+ $this->e->redirect($this->e->hrefParentPage());
+ } else {
+ $this->setPost($form);
+ $this->e->showServiceError($sConfig->getError());
+ $this->e->redirect($this->e->hrefCurrentPage());
+ }
}
+
}
?>
Modified: trunk/mod/eis_engine/locales/en_en/strings.xml
===================================================================
--- trunk/mod/eis_engine/locales/en_en/strings.xml 2007-10-13 12:06:47 UTC (rev 219)
+++ trunk/mod/eis_engine/locales/en_en/strings.xml 2007-11-08 20:18:14 UTC (rev 220)
@@ -94,6 +94,10 @@
<value><![CDATA[Add environment]]></value>
</string>
<string>
+ <name>t.edit.application</name>
+ <value><![CDATA[Edit application]]></value>
+ </string>
+ <string>
<name>t.edit.webservice</name>
<value><![CDATA[Edit web service]]></value>
</string>
@@ -102,6 +106,10 @@
<value><![CDATA[Edit environment]]></value>
</string>
<string>
+ <name>t.delete.application</name>
+ <value><![CDATA[Delete application]]></value>
+ </string>
+ <string>
<name>t.delete.webservice</name>
<value><![CDATA[Delete web service]]></value>
</string>
@@ -117,7 +125,6 @@
<name>l.title</name>
<value><![CDATA[Title]]></value>
</string>
-
<string>
<name>l.description</name>
<value><![CDATA[Description]]></value>
@@ -155,11 +162,6 @@
<value><![CDATA[Protocol]]></value>
</string>
<string>
- <name>l.title</name>
- <value><![CDATA[Title]]></value>
- </string>
-
- <string>
<name>l.admin</name>
<value><![CDATA[Administrator]]></value>
</string>
@@ -256,10 +258,17 @@
<value><![CDATA[Delete environment]]></value>
</string>
<string>
+ <name>q.delete.application</name>
+ <value><![CDATA[Do you really want to delete application '%s'?]]></value>
+ </string>
+ <string>
+ <name>q.delete.webservice</name>
+ <value><![CDATA[Do you really want to delete webservice '%s'?]]></value>
+ </string>
+ <string>
<name>q.delete.environment</name>
<value><![CDATA[Do you really want to delete environment '%s'?]]></value>
</string>
-
<string>
<name>e.illegalformat.name</name>
<value><![CDATA[A name can contain only letters, digits, dashes and underscores.]]></value>
@@ -281,6 +290,14 @@
<value><![CDATA[Please select an application]]></value>
</string>
<string>
+ <name>e.missing.service</name>
+ <value><![CDATA[Please select a service]]></value>
+ </string>
+ <string>
+ <name>e.missing.protocol</name>
+ <value><![CDATA[Please select a protocol]]></value>
+ </string>
+ <string>
<name>e.missing.mountpoint</name>
<value><![CDATA[Please enter a mountpoint]]></value>
</string>
@@ -305,6 +322,35 @@
<value><![CDATA[Successfully added application '%s' at '%s'.]]></value>
</string>
<string>
+ <name>m.application.updated</name>
+ <value><![CDATA[Successfully updated application '%s'.]]></value>
+ </string>
+ <string>
+ <name>m.application.deleted</name>
+ <value><![CDATA[Successfully deleted application '%s'.]]></value>
+ </string>
+ <string>
+ <name>m.webservice.added</name>
+ <value><![CDATA[Successfully added webservice '%s' at '%s'.]]></value>
+ </string>
+ <string>
+ <name>m.webservice.updated</name>
+ <value><![CDATA[Successfully updated webservice '%s'.]]></value>
+ </string>
+ <string>
+ <name>m.webservice.deleted</name>
+ <value><![CDATA[Successfully deleted webservice '%s'.]]></value>
+ </string>
+
+ <string>
+ <name>e.webservice.duplicate.mountpoint</name>
+ <value><![CDATA[Another webservice is already running at '%s'.]]></value>
+ </string>
+ <string>
+ <name>e.webservice.nonexistent.mountpoint</name>
+ <value><![CDATA[There is no webservice at '%s'.]]></value>
+ </string>
+ <string>
<name>e.environment.duplicate.name</name>
<value><![CDATA[Another environment is already known as '%s'.]]></value>
</string>
Modified: trunk/mod/eis_engine/services/ConfigService.php
===================================================================
--- trunk/mod/eis_engine/services/ConfigService.php 2007-10-13 12:06:47 UTC (rev 219)
+++ trunk/mod/eis_engine/services/ConfigService.php 2007-11-08 20:18:14 UTC (rev 220)
@@ -76,9 +76,28 @@
}
function updateApplication($obj) {
+ if(!$this->verifyApplication($obj)) {
+ return 0;
+ }
+ $applications = $this->_loadApplications();
+ foreach($applications as $k => $application) {
+ if($application['name'] == $obj['name']) {
+ $applications[$k] = $obj;
+ }
+ }
+
+ $this->_saveApplications($applications);
+
}
function deleteApplication($id) {
+ $applications = $this->_loadApplications();
+ foreach($applications as $k => $application) {
+ if($application['name'] == $id) {
+ unset($applications[$k]);
+ }
+ }
+ $this->_saveApplications($applications);
}
function getDefaultApplication() {
@@ -89,16 +108,25 @@
return $str->getValue($doc,'default');
}
- function getWebServices() {
+ function _loadWebServices() {
$str = new XmlStruct();
$doc = $str->decodeFile('cfg/webservices.xml');
$doc = $str->getValue($doc,'webservices');
return $str->getArray($doc,'webservice');
}
+ function _saveWebServices($webservices) {
+ $doc = array('webservices' => array('webservice' => $webservices));
+ $str = new XmlStruct();
+ $str->encodeFile($doc, 'cfg/webservices.xml');
+ }
+ function getWebServices() {
+ return $this->_loadWebServices();
+ }
+
function getWebService($id) {
- $services = $this->getWebServices();
+ $services = $this->_loadWebServices();
foreach($services as $service) {
if($service['name'] == $id) {
return $service;
@@ -108,12 +136,85 @@
}
function createWebService($obj) {
+ if(!$this->verifyWebService($obj,true)) {
+ return 0;
+ }
+
+ $webservices = $this->_loadWebServices();
+ $webservices[] = $obj;
+ $this->_saveWebServices($webservices);
}
+
function updateWebService($obj) {
+ if(!$this->verifyWebService($obj)) {
+ return 0;
+ }
+
+ $webservices = $this->_loadWebServices();
+ foreach($webservices as $k => $webservice) {
+ if($webservice['name'] == $obj['name']) {
+ $webservices[$k] = $obj;
+ }
+ }
+
+ $this->_saveWebServices($webservices);
+
}
+
function deleteWebService($id) {
+ $webservices = $this->_loadWebServices();
+ foreach($webservices as $k => $webservice) {
+ if($webservice['name'] == $id) {
+ unset($webservices[$k]);
+ }
+ }
+ $this->_saveWebServices($webservices);
}
+ function verifyWebService($obj, $new = false) {
+ if(!isset($obj['module']) || $obj['module'] == '') {
+ $this->setError(0,'eis_engine.e.missing.module');
+ return false;
+ }
+ if(!isset($obj['service']) || $obj['service'] == '') {
+ $this->setError(0,'eis_engine.e.missing.service');
+ return false;
+ }
+ if(!isset($obj['protocol']) || $obj['protocol'] == '') {
+ $this->setError(0,'eis_engine.e.missing.protocol');
+ return false;
+ }
+
+ if(!isset($obj['name']) || $obj['name'] == '') {
+ $this->setError(0,'eis_engine.e.missing.mountpoint');
+ return false;
+ } else {
+ //Check format of mountpoint
+ if(!ereg("^[a-zA-Z0-9_\-]+$",$obj['name'])) {
+ $this->setError(0,'eis_engine.e.illegalformat.mountpoint');
+ return false;
+ } else {
+ //Check if the application is already
+ if($this->getWebService($obj['name']) != null) {
+ if($new) {
+ $this->setError(0,'eis_engine.e.webservice.duplicate.mountpoint',array($obj['name']));
+ return false;
+ }
+ } else {
+ if(!$new) {
+ $this->setError(0,'eis_engine.e.webservice.nonexistent.mountpoint',array($obj['name']));
+ return false;
+ }
+ }
+ }
+ }
+ if(!isset($obj['environment']) || $obj['environment'] == '') {
+ $this->setError(0,'eis_engine.e.missing.environment');
+ return false;
+ }
+ return true;
+ }
+
function _loadEnvironments() {
$str = new XmlStruct();
$doc = $str->decodeFile('cfg/environments.xml');
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bas...@us...> - 2007-10-13 12:06:51
|
Revision: 219
http://eis.svn.sourceforge.net/eis/?rev=219&view=rev
Author: baslijnse
Date: 2007-10-13 05:06:47 -0700 (Sat, 13 Oct 2007)
Log Message:
-----------
removed deprecated module config fields
Modified Paths:
--------------
trunk/mod/eis_engine/module.xml
trunk/mod/eis_log/module.xml
trunk/mod/eis_session/module.xml
trunk/mod/eis_user/module.xml
Modified: trunk/mod/eis_engine/module.xml
===================================================================
--- trunk/mod/eis_engine/module.xml 2007-09-19 20:43:43 UTC (rev 218)
+++ trunk/mod/eis_engine/module.xml 2007-10-13 12:06:47 UTC (rev 219)
@@ -10,120 +10,4 @@
<name>admin_password</name>
<value>admin</value>
</config>
- <config>
- <name>redirect_404</name>
- <value></value>
- </config>
- <config>
- <name>redirect_403</name>
- <value></value>
- </config>
- <config>
- <name>admin</name>
- <value>nobody@localhost</value>
- </config>
- <config>
- <name>enable_datadir</name>
- <value>1</value>
- </config>
- <config>
- <name>enable_database</name>
- <value>1</value>
- </config>
- <config>
- <name>enable_session</name>
- <value>1</value>
- </config>
- <config>
- <name>enable_user</name>
- <value>1</value>
- </config>
- <config>
- <name>deployment_level</name>
- <value>dev</value>
- </config>
- <config>
- <name>deployment_dev_user</name>
- <value>dev</value>
- </config>
- <config>
- <name>deployment_dev_password</name>
- <value>dev</value>
- </config>
- <config>
- <name>deployment_dev_iprange</name>
- <value>127.0.0.1</value>
- </config>
- <config>
- <name>deployment_test_user</name>
- <value>test</value>
- </config>
- <config>
- <name>deployment_test_password</name>
- <value>test</value>
- </config>
- <config>
- <name>deployment_test_iprange</name>
- <value>127.0.0.1</value>
- </config>
- <config>
- <name>data_root</name>
- <value>data</value>
- </config>
- <config>
- <name>data_root_dev</name>
- <value></value>
- </config>
- <config>
- <name>data_root_test</name>
- <value></value>
- </config>
- <config>
- <name>mysql_user</name>
- <value></value>
- </config>
- <config>
- <name>mysql_host</name>
- <value></value>
- </config>
- <config>
- <name>mysql_db</name>
- <value></value>
- </config>
- <config>
- <name>mysql_pwd</name>
- <value></value>
- </config>
- <config>
- <name>mysql_dev_user</name>
- <value></value>
- </config>
- <config>
- <name>mysql_dev_host</name>
- <value></value>
- </config>
- <config>
- <name>mysql_dev_db</name>
- <value></value>
- </config>
- <config>
- <name>mysql_dev_pwd</name>
- <value></value>
- </config>
- <config>
- <name>mysql_test_user</name>
- <value></value>
- </config>
- <config>
- <name>mysql_test_host</name>
- <value></value>
- </config>
- <config>
- <name>mysql_test_db</name>
- <value></value>
- </config>
- <config>
- <name>mysql_test_pwd</name>
- <value></value>
- </config>
</module>
Modified: trunk/mod/eis_log/module.xml
===================================================================
--- trunk/mod/eis_log/module.xml 2007-09-19 20:43:43 UTC (rev 218)
+++ trunk/mod/eis_log/module.xml 2007-10-13 12:06:47 UTC (rev 219)
@@ -7,126 +7,6 @@
<homepage>http://eis.sourceforge.net/</homepage>
<license>BSD License</license>
<config>
- <name>admin_password</name>
- <value>admin</value>
- </config>
- <config>
- <name>redirect_404</name>
- <value></value>
- </config>
- <config>
- <name>redirect_403</name>
- <value></value>
- </config>
- <config>
- <name>admin</name>
- <value>nobody@localhost</value>
- </config>
- <config>
- <name>enable_datadir</name>
- <value>1</value>
- </config>
- <config>
- <name>enable_database</name>
- <value>1</value>
- </config>
- <config>
- <name>enable_session</name>
- <value>1</value>
- </config>
- <config>
- <name>enable_user</name>
- <value>1</value>
- </config>
- <config>
- <name>deployment_level</name>
- <value>dev</value>
- </config>
- <config>
- <name>deployment_dev_user</name>
- <value>dev</value>
- </config>
- <config>
- <name>deployment_dev_password</name>
- <value>dev</value>
- </config>
- <config>
- <name>deployment_dev_iprange</name>
- <value>127.0.0.1</value>
- </config>
- <config>
- <name>deployment_test_user</name>
- <value>test</value>
- </config>
- <config>
- <name>deployment_test_password</name>
- <value>test</value>
- </config>
- <config>
- <name>deployment_test_iprange</name>
- <value>127.0.0.1</value>
- </config>
- <config>
- <name>data_root</name>
- <value>data</value>
- </config>
- <config>
- <name>data_root_dev</name>
- <value></value>
- </config>
- <config>
- <name>data_root_test</name>
- <value></value>
- </config>
- <config>
- <name>mysql_user</name>
- <value></value>
- </config>
- <config>
- <name>mysql_host</name>
- <value></value>
- </config>
- <config>
- <name>mysql_db</name>
- <value></value>
- </config>
- <config>
- <name>mysql_pwd</name>
- <value></value>
- </config>
- <config>
- <name>mysql_dev_user</name>
- <value></value>
- </config>
- <config>
- <name>mysql_dev_host</name>
- <value></value>
- </config>
- <config>
- <name>mysql_dev_db</name>
- <value></value>
- </config>
- <config>
- <name>mysql_dev_pwd</name>
- <value></value>
- </config>
- <config>
- <name>mysql_test_user</name>
- <value></value>
- </config>
- <config>
- <name>mysql_test_host</name>
- <value></value>
- </config>
- <config>
- <name>mysql_test_db</name>
- <value></value>
- </config>
- <config>
- <name>mysql_test_pwd</name>
- <value></value>
- </config>
- <config>
<name>logfile_filename</name>
<value>message.log</value>
</config>
Modified: trunk/mod/eis_session/module.xml
===================================================================
--- trunk/mod/eis_session/module.xml 2007-09-19 20:43:43 UTC (rev 218)
+++ trunk/mod/eis_session/module.xml 2007-10-13 12:06:47 UTC (rev 219)
@@ -7,134 +7,6 @@
<homepage>http://eis.sourceforge.net/</homepage>
<license>BSD License</license>
<config>
- <name>admin_password</name>
- <value>admin</value>
- </config>
- <config>
- <name>redirect_404</name>
- <value></value>
- </config>
- <config>
- <name>redirect_403</name>
- <value></value>
- </config>
- <config>
- <name>admin</name>
- <value>nobody@localhost</value>
- </config>
- <config>
- <name>enable_datadir</name>
- <value>1</value>
- </config>
- <config>
- <name>enable_database</name>
- <value>1</value>
- </config>
- <config>
- <name>enable_session</name>
- <value>1</value>
- </config>
- <config>
- <name>enable_user</name>
- <value>1</value>
- </config>
- <config>
- <name>deployment_level</name>
- <value>dev</value>
- </config>
- <config>
- <name>deployment_dev_user</name>
- <value>dev</value>
- </config>
- <config>
- <name>deployment_dev_password</name>
- <value>dev</value>
- </config>
- <config>
- <name>deployment_dev_iprange</name>
- <value>127.0.0.1</value>
- </config>
- <config>
- <name>deployment_test_user</name>
- <value>test</value>
- </config>
- <config>
- <name>deployment_test_password</name>
- <value>test</value>
- </config>
- <config>
- <name>deployment_test_iprange</name>
- <value>127.0.0.1</value>
- </config>
- <config>
- <name>data_root</name>
- <value>data</value>
- </config>
- <config>
- <name>data_root_dev</name>
- <value></value>
- </config>
- <config>
- <name>data_root_test</name>
- <value></value>
- </config>
- <config>
- <name>mysql_user</name>
- <value></value>
- </config>
- <config>
- <name>mysql_host</name>
- <value></value>
- </config>
- <config>
- <name>mysql_db</name>
- <value></value>
- </config>
- <config>
- <name>mysql_pwd</name>
- <value></value>
- </config>
- <config>
- <name>mysql_dev_user</name>
- <value></value>
- </config>
- <config>
- <name>mysql_dev_host</name>
- <value></value>
- </config>
- <config>
- <name>mysql_dev_db</name>
- <value></value>
- </config>
- <config>
- <name>mysql_dev_pwd</name>
- <value></value>
- </config>
- <config>
- <name>mysql_test_user</name>
- <value></value>
- </config>
- <config>
- <name>mysql_test_host</name>
- <value></value>
- </config>
- <config>
- <name>mysql_test_db</name>
- <value></value>
- </config>
- <config>
- <name>mysql_test_pwd</name>
- <value></value>
- </config>
- <config>
- <name>logfile_filename</name>
- <value>message.log</value>
- </config>
- <config>
- <name>logfile_ansicolor</name>
- <value>1</value>
- </config>
- <config>
<name>ttl_authenticated</name>
<value>1800</value>
</config>
Modified: trunk/mod/eis_user/module.xml
===================================================================
--- trunk/mod/eis_user/module.xml 2007-09-19 20:43:43 UTC (rev 218)
+++ trunk/mod/eis_user/module.xml 2007-10-13 12:06:47 UTC (rev 219)
@@ -7,171 +7,7 @@
<homepage>http://eis.sourceforge.net/</homepage>
<license>BSD License</license>
<config>
- <name>admin_password</name>
- <value>admin</value>
- </config>
- <config>
- <name>redirect_404</name>
- <value></value>
- </config>
- <config>
- <name>redirect_403</name>
- <value></value>
- </config>
- <config>
- <name>admin</name>
- <value>nobody@localhost</value>
- </config>
- <config>
- <name>enable_datadir</name>
- <value>1</value>
- </config>
- <config>
- <name>enable_database</name>
- <value>1</value>
- </config>
- <config>
- <name>enable_session</name>
- <value>1</value>
- </config>
- <config>
- <name>enable_user</name>
- <value>1</value>
- </config>
- <config>
- <name>deployment_level</name>
- <value>dev</value>
- </config>
- <config>
- <name>deployment_dev_user</name>
- <value>dev</value>
- </config>
- <config>
- <name>deployment_dev_password</name>
- <value>dev</value>
- </config>
- <config>
- <name>deployment_dev_iprange</name>
- <value>127.0.0.1</value>
- </config>
- <config>
- <name>deployment_test_user</name>
- <value>test</value>
- </config>
- <config>
- <name>deployment_test_password</name>
- <value>test</value>
- </config>
- <config>
- <name>deployment_test_iprange</name>
- <value>127.0.0.1</value>
- </config>
- <config>
- <name>data_root</name>
- <value>data</value>
- </config>
- <config>
- <name>data_root_dev</name>
- <value></value>
- </config>
- <config>
- <name>data_root_test</name>
- <value></value>
- </config>
- <config>
- <name>mysql_user</name>
- <value></value>
- </config>
- <config>
- <name>mysql_host</name>
- <value></value>
- </config>
- <config>
- <name>mysql_db</name>
- <value></value>
- </config>
- <config>
- <name>mysql_pwd</name>
- <value></value>
- </config>
- <config>
- <name>mysql_dev_user</name>
- <value></value>
- </config>
- <config>
- <name>mysql_dev_host</name>
- <value></value>
- </config>
- <config>
- <name>mysql_dev_db</name>
- <value></value>
- </config>
- <config>
- <name>mysql_dev_pwd</name>
- <value></value>
- </config>
- <config>
- <name>mysql_test_user</name>
- <value></value>
- </config>
- <config>
- <name>mysql_test_host</name>
- <value></value>
- </config>
- <config>
- <name>mysql_test_db</name>
- <value></value>
- </config>
- <config>
- <name>mysql_test_pwd</name>
- <value></value>
- </config>
- <config>
- <name>logfile_filename</name>
- <value>message.log</value>
- </config>
- <config>
- <name>logfile_ansicolor</name>
- <value>1</value>
- </config>
- <config>
- <name>ttl_authenticated</name>
- <value>1800</value>
- </config>
- <config>
- <name>ttl_anonymous</name>
- <value>3600</value>
- </config>
- <config>
- <name>tmp_dir</name>
- <value>/tmp</value>
- </config>
- <config>
<name>password_type</name>
<value>md5</value>
</config>
- <config>
- <name>email_signup_from</name>
- <value>nobody@localhost</value>
- </config>
- <config>
- <name>email_signup_subject</name>
- <value>Activate your account now</value>
- </config>
- <config>
- <name>email_signup_body</name>
- <value>mod/user/mail/signup.txt</value>
- </config>
- <config>
- <name>pages_signup_activate</name>
- <value>/signup/activate</value>
- </config>
- <config>
- <name>user_activation_initial_groups</name>
- <value></value>
- </config>
- <config>
- <name>user_activation_autologin</name>
- <value>1</value>
- </config>
</module>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luu...@us...> - 2007-09-19 20:43:47
|
Revision: 218
http://eis.svn.sourceforge.net/eis/?rev=218&view=rev
Author: luukvandenbroek
Date: 2007-09-19 13:43:43 -0700 (Wed, 19 Sep 2007)
Log Message:
-----------
added empty cache dir
Added Paths:
-----------
trunk/cache/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tom...@us...> - 2007-09-18 20:51:26
|
Revision: 217
http://eis.svn.sourceforge.net/eis/?rev=217&view=rev
Author: tombroek
Date: 2007-09-18 13:51:23 -0700 (Tue, 18 Sep 2007)
Log Message:
-----------
Migrated the moduleconfig from config/module.php to the module.xml
The module.xml is automatically cached in the cache directory.
Modified Paths:
--------------
trunk/lib/engine/engine.lib.php
trunk/mod/eis_engine/module.xml
trunk/mod/eis_log/module.xml
trunk/mod/eis_session/module.xml
trunk/mod/eis_user/module.xml
Removed Paths:
-------------
trunk/mod/eis_engine/config/module.php
trunk/mod/eis_log/config/module.php
trunk/mod/eis_session/config/module.php
trunk/mod/eis_user/config/module.php
Modified: trunk/lib/engine/engine.lib.php
===================================================================
--- trunk/lib/engine/engine.lib.php 2007-09-17 09:17:04 UTC (rev 216)
+++ trunk/lib/engine/engine.lib.php 2007-09-18 20:51:23 UTC (rev 217)
@@ -31,6 +31,8 @@
var $user = null; /**< The user instance */
var $log = null; /**< The log instance */
+ var $cachedir = 'cache/';
+
/**
* Engine constructor, gathers basic info about the environment.
*/
@@ -146,10 +148,11 @@
//TODO: Get this from the module's definition
return 'default';
}
+
/**
- *Load moduleconfig
+ *Load moduleconfig. This function will load the moduleconfig from the cache or form the module.xml.
*@param modul of which the config has to be loaded
- *@result mosuleconfig is returned
+ *@result moduleconfig is returned
*/
function _loadModuleConfig($module, $reload = false) {
@@ -157,12 +160,12 @@
$config = array();
- //Load defaults
- $defaults = 'mod/'.$module.'/config/module.php';
- if(file_exists($defaults)) {
- include($defaults);
- if(is_array($cfg))
- $config = $cfg;
+ //Load moduleconfig
+ if($this->_cacheModuleConfigAvailable($module)) {
+ $config = $this->_loadModuleConfigFromCache($module);
+ } else {
+ $config = $this->_loadModuleConfigFromXml($module);
+ $this->_storeModuleConfigToCache($module, $config);
}
//Apply modifications
@@ -177,7 +180,78 @@
return $this->moduleConfig[$module];
}
+
/**
+ *Load moduleconfig from the module.xml of the module
+ *@param modul of which the config has to be loaded
+ *@result moduleconfig is returned
+ */
+ function _loadModuleConfigFromXml($module) {
+
+ $struct = new XmlStruct();
+
+ $moduleconfig = array();
+ //Libraries
+ $this->libraries = array();
+ $doc = $struct->decodeFile('mod/'.$module.'/module.xml');
+ $config = $struct->getArray($doc['module'],'config');
+
+ foreach($config as $entry) {
+ $moduleconfig[$entry['name']] = $entry['value'];
+ }
+
+ return $moduleconfig;
+
+
+ }
+
+ /**
+ *Checks if their is an valid cache version of the module config
+ *@param module of which the config has to be loaded
+ *@result moduleconfig is returned
+ */
+ function _cacheModuleConfigAvailable($module) {
+ if(is_readable($this->cachedir.'MODULECONFIG-'.$module.'.php')) {
+ $tcache = filemtime($this->cachedir.'MODULECONFIG-'.$module.'.php');
+ if(filemtime('mod/'.$module.'/module.xml') > $tcache) {
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
+ /**
+ *Load moduleconfig from the cache dir
+ *@param module of which the config has to be loaded
+ *@result moduleconfig is returned
+ */
+
+ function _loadModuleConfigFromCache($module) {
+ require($this->cachedir.'MODULECONFIG-'.$module.'.php');
+ return $config;
+ }
+
+ /**
+ *Store moduleconfig as a cached php file
+ *@param module of which the config has to be cached
+ *@param config wich contains the module config of $module
+ */
+ function _storeModuleConfigToCache($module, $config) {
+ if(!is_writable($this->cachedir))
+ return;
+
+ $cache = "<?php\n";
+ $cache .= "\$config =".var_export($config, true).";\n";
+ $cache .= "?>";
+
+ $f = fopen($this->cachedir.'MODULECONFIG-'.$module.'.php',"w");
+ fwrite($f, $cache);
+ fclose($f);
+ }
+
+
+
+ /**
*Load elementconfig
*@param module of the config to be loaded
*@param element of the config to be loaded
Deleted: trunk/mod/eis_engine/config/module.php
===================================================================
--- trunk/mod/eis_engine/config/module.php 2007-09-17 09:17:04 UTC (rev 216)
+++ trunk/mod/eis_engine/config/module.php 2007-09-18 20:51:23 UTC (rev 217)
@@ -1,47 +0,0 @@
-<?php
- $cfg['admin_password'] = 'admin';
-
- $cfg['redirect_404'] = null;
- $cfg['redirect_403'] = null;
-
- $cfg['admin'] = 'nobody@localhost';
-
- # Enable/disable options
- $cfg['enable_datadir'] = true;
- $cfg['enable_database'] = true;
- $cfg['enable_session'] = true;
- $cfg['enable_user'] = true;
-
- # Deployment and development settings
- $cfg['deployment_level'] = 'dev'; # Deployment level of this site: install|dev|test|live|unavailable
-
- $cfg['deployment_dev_user'] ='dev';
- $cfg['deployment_dev_password'] = 'dev';
- $cfg['deployment_dev_iprange'] = '127\.0\.0\.1';
-
- $cfg['deployment_test_user'] = 'test';
- $cfg['deployment_test_password'] = 'test';
- $cfg['deployment_test_iprange'] = '127\.0\.0\.1';
-
- # Data Dir Location
- $cfg['data_root'] = 'data';
-
- $cfg['data_root_dev'] = null;
- $cfg['data_root_test'] = null;
-
- #Mysql
- $cfg['mysql_user'] = null;
- $cfg['mysql_host'] = null;
- $cfg['mysql_db'] = null;
- $cfg['mysql_pwd'] = null;
-
- $cfg['mysql_dev_user'] = null;
- $cfg['mysql_dev_host'] = null;
- $cfg['mysql_dev_db'] = null;
- $cfg['mysql_dev_pwd'] = null;
-
- $cfg['mysql_test_user'] = null;
- $cfg['mysql_test_host'] = null;
- $cfg['mysql_test_db'] = null;
- $cfg['mysql_test_pwd'] = null;
-?>
Modified: trunk/mod/eis_engine/module.xml
===================================================================
--- trunk/mod/eis_engine/module.xml 2007-09-17 09:17:04 UTC (rev 216)
+++ trunk/mod/eis_engine/module.xml 2007-09-18 20:51:23 UTC (rev 217)
@@ -6,4 +6,124 @@
<author>EIS Team</author>
<homepage>http://eis.sourceforge.net/</homepage>
<license>BSD License</license>
+ <config>
+ <name>admin_password</name>
+ <value>admin</value>
+ </config>
+ <config>
+ <name>redirect_404</name>
+ <value></value>
+ </config>
+ <config>
+ <name>redirect_403</name>
+ <value></value>
+ </config>
+ <config>
+ <name>admin</name>
+ <value>nobody@localhost</value>
+ </config>
+ <config>
+ <name>enable_datadir</name>
+ <value>1</value>
+ </config>
+ <config>
+ <name>enable_database</name>
+ <value>1</value>
+ </config>
+ <config>
+ <name>enable_session</name>
+ <value>1</value>
+ </config>
+ <config>
+ <name>enable_user</name>
+ <value>1</value>
+ </config>
+ <config>
+ <name>deployment_level</name>
+ <value>dev</value>
+ </config>
+ <config>
+ <name>deployment_dev_user</name>
+ <value>dev</value>
+ </config>
+ <config>
+ <name>deployment_dev_password</name>
+ <value>dev</value>
+ </config>
+ <config>
+ <name>deployment_dev_iprange</name>
+ <value>127.0.0.1</value>
+ </config>
+ <config>
+ <name>deployment_test_user</name>
+ <value>test</value>
+ </config>
+ <config>
+ <name>deployment_test_password</name>
+ <value>test</value>
+ </config>
+ <config>
+ <name>deployment_test_iprange</name>
+ <value>127.0.0.1</value>
+ </config>
+ <config>
+ <name>data_root</name>
+ <value>data</value>
+ </config>
+ <config>
+ <name>data_root_dev</name>
+ <value></value>
+ </config>
+ <config>
+ <name>data_root_test</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_user</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_host</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_db</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_pwd</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_dev_user</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_dev_host</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_dev_db</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_dev_pwd</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_test_user</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_test_host</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_test_db</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_test_pwd</name>
+ <value></value>
+ </config>
</module>
Deleted: trunk/mod/eis_log/config/module.php
===================================================================
--- trunk/mod/eis_log/config/module.php 2007-09-17 09:17:04 UTC (rev 216)
+++ trunk/mod/eis_log/config/module.php 2007-09-18 20:51:23 UTC (rev 217)
@@ -1,4 +0,0 @@
-<?php
- $cfg['logfile_filename'] = 'message.log';
- $cfg['logfile_ansicolor'] = true;
-?>
Modified: trunk/mod/eis_log/module.xml
===================================================================
--- trunk/mod/eis_log/module.xml 2007-09-17 09:17:04 UTC (rev 216)
+++ trunk/mod/eis_log/module.xml 2007-09-18 20:51:23 UTC (rev 217)
@@ -6,4 +6,132 @@
<author>EIS Team</author>
<homepage>http://eis.sourceforge.net/</homepage>
<license>BSD License</license>
+ <config>
+ <name>admin_password</name>
+ <value>admin</value>
+ </config>
+ <config>
+ <name>redirect_404</name>
+ <value></value>
+ </config>
+ <config>
+ <name>redirect_403</name>
+ <value></value>
+ </config>
+ <config>
+ <name>admin</name>
+ <value>nobody@localhost</value>
+ </config>
+ <config>
+ <name>enable_datadir</name>
+ <value>1</value>
+ </config>
+ <config>
+ <name>enable_database</name>
+ <value>1</value>
+ </config>
+ <config>
+ <name>enable_session</name>
+ <value>1</value>
+ </config>
+ <config>
+ <name>enable_user</name>
+ <value>1</value>
+ </config>
+ <config>
+ <name>deployment_level</name>
+ <value>dev</value>
+ </config>
+ <config>
+ <name>deployment_dev_user</name>
+ <value>dev</value>
+ </config>
+ <config>
+ <name>deployment_dev_password</name>
+ <value>dev</value>
+ </config>
+ <config>
+ <name>deployment_dev_iprange</name>
+ <value>127.0.0.1</value>
+ </config>
+ <config>
+ <name>deployment_test_user</name>
+ <value>test</value>
+ </config>
+ <config>
+ <name>deployment_test_password</name>
+ <value>test</value>
+ </config>
+ <config>
+ <name>deployment_test_iprange</name>
+ <value>127.0.0.1</value>
+ </config>
+ <config>
+ <name>data_root</name>
+ <value>data</value>
+ </config>
+ <config>
+ <name>data_root_dev</name>
+ <value></value>
+ </config>
+ <config>
+ <name>data_root_test</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_user</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_host</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_db</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_pwd</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_dev_user</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_dev_host</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_dev_db</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_dev_pwd</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_test_user</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_test_host</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_test_db</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_test_pwd</name>
+ <value></value>
+ </config>
+ <config>
+ <name>logfile_filename</name>
+ <value>message.log</value>
+ </config>
+ <config>
+ <name>logfile_ansicolor</name>
+ <value>1</value>
+ </config>
</module>
Deleted: trunk/mod/eis_session/config/module.php
===================================================================
--- trunk/mod/eis_session/config/module.php 2007-09-17 09:17:04 UTC (rev 216)
+++ trunk/mod/eis_session/config/module.php 2007-09-18 20:51:23 UTC (rev 217)
@@ -1,6 +0,0 @@
-<?php
- $cfg['ttl_authenticated'] = "1800"; // Session time to live in minutes for authenticated sessions
- $cfg['ttl_anonymous'] = "3600"; //Session time to live for anomous sessions
-
- $cfg['tmp_dir'] = '/tmp';
-?>
Modified: trunk/mod/eis_session/module.xml
===================================================================
--- trunk/mod/eis_session/module.xml 2007-09-17 09:17:04 UTC (rev 216)
+++ trunk/mod/eis_session/module.xml 2007-09-18 20:51:23 UTC (rev 217)
@@ -1,9 +1,149 @@
<?xml version="1.0" encoding="utf-8" ?>
<module>
- <name>eis_engine</name>
+ <name>eis_session</name>
<version>0.1.0</version>
<description>Management of EIS sessions.</description>
<author>EIS Team</author>
<homepage>http://eis.sourceforge.net/</homepage>
<license>BSD License</license>
+ <config>
+ <name>admin_password</name>
+ <value>admin</value>
+ </config>
+ <config>
+ <name>redirect_404</name>
+ <value></value>
+ </config>
+ <config>
+ <name>redirect_403</name>
+ <value></value>
+ </config>
+ <config>
+ <name>admin</name>
+ <value>nobody@localhost</value>
+ </config>
+ <config>
+ <name>enable_datadir</name>
+ <value>1</value>
+ </config>
+ <config>
+ <name>enable_database</name>
+ <value>1</value>
+ </config>
+ <config>
+ <name>enable_session</name>
+ <value>1</value>
+ </config>
+ <config>
+ <name>enable_user</name>
+ <value>1</value>
+ </config>
+ <config>
+ <name>deployment_level</name>
+ <value>dev</value>
+ </config>
+ <config>
+ <name>deployment_dev_user</name>
+ <value>dev</value>
+ </config>
+ <config>
+ <name>deployment_dev_password</name>
+ <value>dev</value>
+ </config>
+ <config>
+ <name>deployment_dev_iprange</name>
+ <value>127.0.0.1</value>
+ </config>
+ <config>
+ <name>deployment_test_user</name>
+ <value>test</value>
+ </config>
+ <config>
+ <name>deployment_test_password</name>
+ <value>test</value>
+ </config>
+ <config>
+ <name>deployment_test_iprange</name>
+ <value>127.0.0.1</value>
+ </config>
+ <config>
+ <name>data_root</name>
+ <value>data</value>
+ </config>
+ <config>
+ <name>data_root_dev</name>
+ <value></value>
+ </config>
+ <config>
+ <name>data_root_test</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_user</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_host</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_db</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_pwd</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_dev_user</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_dev_host</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_dev_db</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_dev_pwd</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_test_user</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_test_host</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_test_db</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_test_pwd</name>
+ <value></value>
+ </config>
+ <config>
+ <name>logfile_filename</name>
+ <value>message.log</value>
+ </config>
+ <config>
+ <name>logfile_ansicolor</name>
+ <value>1</value>
+ </config>
+ <config>
+ <name>ttl_authenticated</name>
+ <value>1800</value>
+ </config>
+ <config>
+ <name>ttl_anonymous</name>
+ <value>3600</value>
+ </config>
+ <config>
+ <name>tmp_dir</name>
+ <value>/tmp</value>
+ </config>
</module>
Deleted: trunk/mod/eis_user/config/module.php
===================================================================
--- trunk/mod/eis_user/config/module.php 2007-09-17 09:17:04 UTC (rev 216)
+++ trunk/mod/eis_user/config/module.php 2007-09-18 20:51:23 UTC (rev 217)
@@ -1,12 +0,0 @@
-<?php
- $cfg['password_type'] = 'md5'; // plain | md5
-
- $cfg['email_signup_from'] = 'nobody@localhost';
- $cfg['email_signup_subject'] = 'Activate your account now';
- $cfg['email_signup_body'] = 'mod/user/mail/signup.txt';
-
- $cfg['pages_signup_activate'] = '/signup/activate';
-
- $cfg['user_activation_initial_groups'] = null;
- $cfg['user_activation_autologin'] = true;
-?>
Modified: trunk/mod/eis_user/module.xml
===================================================================
--- trunk/mod/eis_user/module.xml 2007-09-17 09:17:04 UTC (rev 216)
+++ trunk/mod/eis_user/module.xml 2007-09-18 20:51:23 UTC (rev 217)
@@ -6,4 +6,172 @@
<author>EIS Team</author>
<homepage>http://eis.sourceforge.net/</homepage>
<license>BSD License</license>
+ <config>
+ <name>admin_password</name>
+ <value>admin</value>
+ </config>
+ <config>
+ <name>redirect_404</name>
+ <value></value>
+ </config>
+ <config>
+ <name>redirect_403</name>
+ <value></value>
+ </config>
+ <config>
+ <name>admin</name>
+ <value>nobody@localhost</value>
+ </config>
+ <config>
+ <name>enable_datadir</name>
+ <value>1</value>
+ </config>
+ <config>
+ <name>enable_database</name>
+ <value>1</value>
+ </config>
+ <config>
+ <name>enable_session</name>
+ <value>1</value>
+ </config>
+ <config>
+ <name>enable_user</name>
+ <value>1</value>
+ </config>
+ <config>
+ <name>deployment_level</name>
+ <value>dev</value>
+ </config>
+ <config>
+ <name>deployment_dev_user</name>
+ <value>dev</value>
+ </config>
+ <config>
+ <name>deployment_dev_password</name>
+ <value>dev</value>
+ </config>
+ <config>
+ <name>deployment_dev_iprange</name>
+ <value>127.0.0.1</value>
+ </config>
+ <config>
+ <name>deployment_test_user</name>
+ <value>test</value>
+ </config>
+ <config>
+ <name>deployment_test_password</name>
+ <value>test</value>
+ </config>
+ <config>
+ <name>deployment_test_iprange</name>
+ <value>127.0.0.1</value>
+ </config>
+ <config>
+ <name>data_root</name>
+ <value>data</value>
+ </config>
+ <config>
+ <name>data_root_dev</name>
+ <value></value>
+ </config>
+ <config>
+ <name>data_root_test</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_user</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_host</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_db</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_pwd</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_dev_user</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_dev_host</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_dev_db</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_dev_pwd</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_test_user</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_test_host</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_test_db</name>
+ <value></value>
+ </config>
+ <config>
+ <name>mysql_test_pwd</name>
+ <value></value>
+ </config>
+ <config>
+ <name>logfile_filename</name>
+ <value>message.log</value>
+ </config>
+ <config>
+ <name>logfile_ansicolor</name>
+ <value>1</value>
+ </config>
+ <config>
+ <name>ttl_authenticated</name>
+ <value>1800</value>
+ </config>
+ <config>
+ <name>ttl_anonymous</name>
+ <value>3600</value>
+ </config>
+ <config>
+ <name>tmp_dir</name>
+ <value>/tmp</value>
+ </config>
+ <config>
+ <name>password_type</name>
+ <value>md5</value>
+ </config>
+ <config>
+ <name>email_signup_from</name>
+ <value>nobody@localhost</value>
+ </config>
+ <config>
+ <name>email_signup_subject</name>
+ <value>Activate your account now</value>
+ </config>
+ <config>
+ <name>email_signup_body</name>
+ <value>mod/user/mail/signup.txt</value>
+ </config>
+ <config>
+ <name>pages_signup_activate</name>
+ <value>/signup/activate</value>
+ </config>
+ <config>
+ <name>user_activation_initial_groups</name>
+ <value></value>
+ </config>
+ <config>
+ <name>user_activation_autologin</name>
+ <value>1</value>
+ </config>
</module>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bas...@us...> - 2007-09-17 09:17:10
|
Revision: 216
http://eis.svn.sourceforge.net/eis/?rev=216&view=rev
Author: baslijnse
Date: 2007-09-17 02:17:04 -0700 (Mon, 17 Sep 2007)
Log Message:
-----------
Removed backup module. It is no longer relevant
Removed Paths:
-------------
trunk/mod/backup/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bas...@us...> - 2007-09-17 09:16:34
|
Revision: 215
http://eis.svn.sourceforge.net/eis/?rev=215&view=rev
Author: baslijnse
Date: 2007-09-17 02:16:33 -0700 (Mon, 17 Sep 2007)
Log Message:
-----------
Removed devtools module. It is no longer relevant
Removed Paths:
-------------
trunk/mod/devtools/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bas...@us...> - 2007-09-17 09:14:47
|
Revision: 214
http://eis.svn.sourceforge.net/eis/?rev=214&view=rev
Author: baslijnse
Date: 2007-09-17 02:14:46 -0700 (Mon, 17 Sep 2007)
Log Message:
-----------
Added logservice base class
Added Paths:
-----------
trunk/lib/base/logservice.lib.php
Added: trunk/lib/base/logservice.lib.php
===================================================================
--- trunk/lib/base/logservice.lib.php (rev 0)
+++ trunk/lib/base/logservice.lib.php 2007-09-17 09:14:46 UTC (rev 214)
@@ -0,0 +1,17 @@
+<?php
+ class LogService extends Service {
+
+ /**
+ * Logs a message
+ *
+ * @param message The message to log
+ * @param type The type of message ('message','warning','error')
+ * @param time The timestamp at the logged moment
+ * @param ip The remote ip at the logged moment
+ * @param uid The user id at the logged moment
+ * @param sid The session id at the logged moment
+ */
+ function log($message, $type, $time, $ip, $uid, $sid ) {
+ }
+ }
+?>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bas...@us...> - 2007-09-17 09:14:14
|
Revision: 213
http://eis.svn.sourceforge.net/eis/?rev=213&view=rev
Author: baslijnse
Date: 2007-09-17 02:14:09 -0700 (Mon, 17 Sep 2007)
Log Message:
-----------
Added logging as pluggable service backend
Modified Paths:
--------------
trunk/cfg/environments.xml
trunk/lib/engine/application.lib.php
trunk/lib/engine/engine.lib.php
trunk/lib/engine/environment.lib.php
trunk/lib/engine/request.lib.php
trunk/lib/engine/session.lib.php
trunk/lib/engine/user.lib.php
trunk/mod/eis_engine/applications/servermanager.xml
Added Paths:
-----------
trunk/lib/engine/log.lib.php
trunk/mod/eis_log/
trunk/mod/eis_log/config/
trunk/mod/eis_log/config/module.php
trunk/mod/eis_log/module.xml
trunk/mod/eis_log/services/
trunk/mod/eis_log/services/FileLogService.php
Removed Paths:
-------------
trunk/lib/engine/logging.lib.php
trunk/mod/eis_user/elements/.UserSelectMembership.php.swp
trunk/mod/log/
Modified: trunk/cfg/environments.xml
===================================================================
--- trunk/cfg/environments.xml 2007-09-16 11:28:25 UTC (rev 212)
+++ trunk/cfg/environments.xml 2007-09-17 09:14:09 UTC (rev 213)
@@ -22,7 +22,7 @@
<mysql_user></mysql_user>
<mysql_password></mysql_password>
<mysql_database></mysql_database>
- <data_dir></data_dir>
+ <data_dir>data</data_dir>
</environment>
<environment>
<name>dev</name>
Modified: trunk/lib/engine/application.lib.php
===================================================================
--- trunk/lib/engine/application.lib.php 2007-09-16 11:28:25 UTC (rev 212)
+++ trunk/lib/engine/application.lib.php 2007-09-17 09:14:09 UTC (rev 213)
@@ -17,6 +17,7 @@
var $session_backend = null;
var $authentication_backend = null;
+ var $log_backend = null;
var $elements = array();
@@ -67,6 +68,7 @@
//Backends
$this->session_backend = $struct->getValue($app,'session_backend');
$this->authentication_backend = $struct->getValue($app,'authentication_backend');
+ $this->log_backend = $struct->getValue($app,'log_backend');
//Module configuration
$modules = $struct->getArray($app,'module');
@@ -307,6 +309,7 @@
$cache .= "\$this->title =".var_export($this->title, true).";\n";
$cache .= "\$this->session_backend =".var_export($this->session_backend, true).";\n";
$cache .= "\$this->authentication_backend =".var_export($this->authentication_backend, true).";\n";
+ $cache .= "\$this->log_backend =".var_export($this->log_backend, true).";\n";
$cache .= "\$this->elements =".var_export($this->elements, true).";\n";
$cache .= "\$this->page_root =".var_export($this->page_root, true).";\n";
$cache .= "\$this->page_notfound =".var_export($this->page_notfound, true).";\n";
@@ -329,6 +332,9 @@
function getAuthenticationBackend() {
return $this->authentication_backend;
}
+ function getLogBackend() {
+ return $this->log_backend;
+ }
function getRequiredModules() {
return array_keys($this->modules);
}
Modified: trunk/lib/engine/engine.lib.php
===================================================================
--- trunk/lib/engine/engine.lib.php 2007-09-16 11:28:25 UTC (rev 212)
+++ trunk/lib/engine/engine.lib.php 2007-09-17 09:14:09 UTC (rev 213)
@@ -29,6 +29,7 @@
var $session = null; /**< The session instance */
var $user = null; /**< The user instance */
+ var $log = null; /**< The log instance */
/**
* Engine constructor, gathers basic info about the environment.
@@ -120,21 +121,13 @@
}
/**
- *Initialize logging
+ *Initialize log
*/
- /*
- function _initLogging() {
-
- $config = $this->_loadModuleConfig('log');
-
- $this->log = new Logging();
-
- $this->log->setEngine($this);
- $this->log->setOutput($config['log_output']);
- if($this->config['enable_datadir'])
- $this->log->setLogFile($this->getDatadir('log').'/'.$config['log_file']);
+ function _initLog() {
+ require("lib/engine/log.lib.php");
+ require("lib/base/logservice.lib.php");
+ $this->log = new Log($this);
}
- */
/**
* Return's the main locale for a module. The main locale is
* the locale in which a module is maintained. Other locales are
@@ -632,6 +625,7 @@
}
}
+
//Initialize the locale
$this->_initLocale('en_en'); //TODO configurable locale
@@ -641,6 +635,9 @@
//Initialize the user
$this->_initUser();
+ //Initialize log
+ $this->_initLog();
+
//Catch errors
ini_set('display_errors',TRUE);
ini_set('error_reporting',E_ALL);
@@ -1044,11 +1041,10 @@
/**
* Get the Datadir
*
- * @param module the module for which the datadir is requested
- * @result returns the path to the dir on succes and null on failure
+ * @return returns the path to the dir on succes and null on failure
*/
- function getDataDir($module) {
- return $this->environment->getDataDir($module);
+ function getDataDir() {
+ return $this->environment->getDataDir();
}
/**
Modified: trunk/lib/engine/environment.lib.php
===================================================================
--- trunk/lib/engine/environment.lib.php 2007-09-16 11:28:25 UTC (rev 212)
+++ trunk/lib/engine/environment.lib.php 2007-09-17 09:14:09 UTC (rev 213)
@@ -100,28 +100,18 @@
return $this->admin;
}
- function getDataDir($module) {
+ function getDataDir() {
if($this->datadir == null)
- $this->e->error(1020,'Datadir error: No datadir configured ');
+ $this->e->error(1020,'No datadir configured ');
- $dir = $this->datadir.'/'.$module;
-
- //Try to return the path
- if(file_exists($dir)) {
- if(is_writable($dir) && is_readable($dir))
- return $dir;
+ //Check if it is accessable
+ if(file_exists($this->datadir)) {
+ if(is_writable($this->datadir) && is_readable($this->datadir))
+ return $this->datadir;
else
- $this->e->error(1020,'Datadir error: Datadir for module \''.$module.'\' not writeable/readable');
+ $this->e->error(1020,'Datadir not writeable/readable');
}
- //Try to create the dir for the module
- if(is_writable($this->datadir)) {
- mkdir($dir);
- return $dir;
- } else {
- $this->e->error(1020,'Datadir error: Datadir not writeable');
- }
-
return null;
}
Copied: trunk/lib/engine/log.lib.php (from rev 212, trunk/lib/engine/logging.lib.php)
===================================================================
--- trunk/lib/engine/log.lib.php (rev 0)
+++ trunk/lib/engine/log.lib.php 2007-09-17 09:14:09 UTC (rev 213)
@@ -0,0 +1,57 @@
+<?php
+ /**
+ *class that contains all loging functions
+ */
+ class Log {
+
+ var $e; /**< varaiable for the engine */
+
+ function Log(&$engine) {
+ $this->e =& $engine;
+ }
+
+ /**
+ *add message to the logfile
+ *@param the message to be added
+ */
+ function logMessage($msg) {
+ $this->_writeLog($msg, 'message');
+ }
+ /**
+ *add warning to the logfile
+ *@param the warning to be added
+ */
+ function logWarning($msg) {
+ $this->_writeLog($msg, 'warning');
+ }
+ /**
+ *add error to the logfile
+ *@param the error to be added
+ */
+ function logError($msg) {
+ $this->_writeLog($msg, 'error');
+ }
+
+ /**
+ *write something to the logfile
+ *@param message to written to logfile
+ *@param type the type of log message ('message','warning','error')
+ */
+ function _writeLog($msg, $type) {
+
+ $backend = $this->e->application->getLogBackend();
+ if(!is_array($backend)) {
+ return;
+ }
+
+ $service =& $this->e->getService($backend['module'],$backend['service']);
+
+ $time = time();
+ $ip = $this->e->request->getClientIp();
+ $uid = $this->e->user->getId();
+ $sid = $this->e->session->getId();
+
+ $service->log($msg, $type, $time, $ip, $uid, $sid);
+ }
+ }
+?>
Deleted: trunk/lib/engine/logging.lib.php
===================================================================
--- trunk/lib/engine/logging.lib.php 2007-09-16 11:28:25 UTC (rev 212)
+++ trunk/lib/engine/logging.lib.php 2007-09-17 09:14:09 UTC (rev 213)
@@ -1,149 +0,0 @@
-<?php
- /**
- *class that contains all loging functions
- */
- class Logging {
-
- var $engine; /**< varaiable for the engine */
-
- var $output = 1; /**< variable that determines where the output goes, 0 = none, 1 = file, 2 = database, 3 = both */
- var $logFile = ""; /**< determins the default log file */
- var $useAnsiColor = true; /**< determines the coloring of the logfiles true = Default colored logfiles */
-
- /**
- *assign engine variable to engine reference
- *@param engine reference
- */
- function setEngine(&$engine) {
- $this->engine =& $engine;
- }
- /**
- *assign variable for the logfile
- *@param variable to be assigned to the logFile
- */
- function setLogFile($file) {
- $this->logFile = $file;
- }
- /**
- *assign variable for the output
- *@param variable to be assigned to the output
- */
- function setOutput($output) {
- $this->output = $output;
- }
- /**
- *add message to the logfile
- *@param the message to be added
- *@param the module the message refers to
- */
- function addMessage($msg, $module = null) {
- $this->_writeLog($msg, 10, $module);
- }
- /**
- *add warning to the logfile
- *@param the warning to be added
- *@param the module the message refers to
- */
- function addWarning($msg, $module = null) {
- $this->_writeLog($msg, 20, $module);
- }
- /**
- *add error to the logfile
- *@param the error to be added
- *@param the module the message refers to
- */
- function addError($msg, $module = null) {
- $this->_writeLog($msg, 30, $module);
- }
- /**
- *write something to the logfile
- *@param message to written to logfile
- *@param integer representing the level of the message
- *@param the module the message refers to
- */
- function _writeLog($msg, $level, $module = null) {
-
- if(isset($this->engine->session)) {
- $sid = $this->engine->session->getId();
- $uid = $this->engine->session->getUid();
- $ip = $this->engine->session->getIp();
- } else {
- $sid = 0;
- $uid = 0;
- $ip = '0.0.0.0';
- }
-
- if (($this->output >> 0)%2)
- $this->_logFile($uid, $sid, $ip, $level, $module, $msg);
- if (($this->output >> 1)%2)
- $this->_logDatabase($uid, $sid, $ip, $level, $module, $msg);
- }
-
- /**
- *Log an message to the database
- *@param integer containing the id of the user
- *@param integer conatining the session id
- *@param integer unsure what it contains
- *@param integer representing the level of the message
- *@param the module the message refers to
- *@param the message
- */
- function _logDatabase($uid, $sid, $ip, $level, $module, $msg) {
-
- $sLog =& $this->engine->getService('log');
-
- $obj = array();
- $obj['module'] = $module;
- $obj['level'] = $level;
- $obj['user'] = $uid;
- $obj['session'] = $sid;
- $obj['ip'] = $ip;
- $obj['message'] = $msg;
-
- if(! $sLog->createLog($obj)) {
- //Fallback to log file
- $this->_logFile($uid, $sid, $ip, $level, $module, $msg);
- $this->_logFile($uid, $sid, $ip, 30, 'log', 'Unable to log to database');
- }
- }
-
- /**
- *write log to the database
- *@param integer containing the id of the user
- *@param integer conatining the session id
- *@param integer unsure what it contains
- *@param integer representing the level of the message
- *@param the module the message refers to
- *@param the message
- *@result returns 0 on succes and -1 on failure
- */
- function _logFile($uid, $sid, $ip, $level, $module, $msg) {
-
- if (! $this->logFile)
- return -1;
-
- if (! $file = fopen($this->logFile, 'a'))
- return -1;
-
- $message = date("Y-m-d H:i:s")." - $ip (M $module, L$level, U$uid, S$sid) - $msg\n";
-
- //Add ansi color codes
- if ($this->useAnsiColor) {
- if($level <= 10) //Messages
- $message = sprintf("\x1b[32m%s\x1b[0m",$message);
- else if($level <= 20) //Warnings
- $message = sprintf("\x1b[33m%s\x1b[0m",$message);
- else if($level <= 30) //Errors
- $message = sprintf("\x1b[31m%s\x1b[0m",$message);
- }
-
- if (! fputs($file, $message)) {
- fclose($file);
- return -1;
- }
-
- fclose($file);
- return 0;
- }
- }
-?>
Modified: trunk/lib/engine/request.lib.php
===================================================================
--- trunk/lib/engine/request.lib.php 2007-09-16 11:28:25 UTC (rev 212)
+++ trunk/lib/engine/request.lib.php 2007-09-17 09:14:09 UTC (rev 213)
@@ -157,6 +157,13 @@
return $this->webservice;
}
+ function getClientIp() {
+ return $this->clientIp;
+ }
+ function getClientAgent() {
+ return $this->clientAgent;
+ }
+
/**
* Return whether the default application was selected.
*/
Modified: trunk/lib/engine/session.lib.php
===================================================================
--- trunk/lib/engine/session.lib.php 2007-09-16 11:28:25 UTC (rev 212)
+++ trunk/lib/engine/session.lib.php 2007-09-17 09:14:09 UTC (rev 213)
@@ -31,6 +31,10 @@
function setId($id) {
$this->id = intval($id);
}
+ function getId() {
+ return $this->id;
+ }
+
function setIp($ip) {
$this->ip = $ip;
}
Modified: trunk/lib/engine/user.lib.php
===================================================================
--- trunk/lib/engine/user.lib.php 2007-09-16 11:28:25 UTC (rev 212)
+++ trunk/lib/engine/user.lib.php 2007-09-17 09:14:09 UTC (rev 213)
@@ -60,17 +60,20 @@
* @param user the user object returned by the authentication service
* @param error the error object returned by the authentication service
*/
- function _login($user, $error) {
+ function _login($username, $user, $error) {
if(is_array($user)) {
$this->_setUserProperties($user);
if($this->e->session !== null) {
$this->e->session->set('user',$user,'engine');
$this->e->session->setUid($user['id']);
$this->e->session->save();
+
+ $this->e->log->logMessage(sprintf('User \'%s\' logged in',$username));
return $user['id'];
}
return 0;
} else {
+ $this->e->log->logWarning(sprintf('Failed login attempt for username \'%s\'',$username));
$this->error = $error;
return 0;
}
@@ -105,7 +108,7 @@
$user = $service->authByCredentials($username, $password);
$error = $service->getError();
- return $this->_login($user,$error);
+ return $this->_login($username,$user,$error);
}
/**
* Log in a user based on their username and a hash of their password with a seed.
@@ -126,12 +129,15 @@
$user = $service->authByMD5($username, $seed, $hash);
$error = $service->getError();
- return $this->_login($user,$error);
+ return $this->_login($username,$user,$error);
}
/**
* Resets the user related properties and removes the user from the session
*/
function logout() {
+
+ $this->e->log->logMessage(sprintf('User \'%s\' logged out',$this->username));
+
$this->_resetUserProperties();
if($this->e->session !== null) {
$this->e->session->clear('user','engine');
Modified: trunk/mod/eis_engine/applications/servermanager.xml
===================================================================
--- trunk/mod/eis_engine/applications/servermanager.xml 2007-09-16 11:28:25 UTC (rev 212)
+++ trunk/mod/eis_engine/applications/servermanager.xml 2007-09-17 09:14:09 UTC (rev 213)
@@ -12,6 +12,11 @@
<service>FileStoreService</service>
</session_backend>
+ <log_backend>
+ <module>eis_log</module>
+ <service>FileLogService</service>
+ </log_backend>
+
<page_root>
<meta><name>menu-entry</name><value>eis_engine.l.home</value></meta>
<permission>eis_engine.administrator</permission>
Added: trunk/mod/eis_log/config/module.php
===================================================================
--- trunk/mod/eis_log/config/module.php (rev 0)
+++ trunk/mod/eis_log/config/module.php 2007-09-17 09:14:09 UTC (rev 213)
@@ -0,0 +1,4 @@
+<?php
+ $cfg['logfile_filename'] = 'message.log';
+ $cfg['logfile_ansicolor'] = true;
+?>
Added: trunk/mod/eis_log/module.xml
===================================================================
--- trunk/mod/eis_log/module.xml (rev 0)
+++ trunk/mod/eis_log/module.xml 2007-09-17 09:14:09 UTC (rev 213)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<module>
+ <name>eis_log</name>
+ <version>0.1.0</version>
+ <description>Management of EIS logs</description>
+ <author>EIS Team</author>
+ <homepage>http://eis.sourceforge.net/</homepage>
+ <license>BSD License</license>
+</module>
Added: trunk/mod/eis_log/services/FileLogService.php
===================================================================
--- trunk/mod/eis_log/services/FileLogService.php (rev 0)
+++ trunk/mod/eis_log/services/FileLogService.php 2007-09-17 09:14:09 UTC (rev 213)
@@ -0,0 +1,31 @@
+<?php
+ class eis_log_FileLogService extends LogService {
+
+ function log($message, $type, $time, $ip, $uid, $sid ) {
+
+ $logfile = $this->e->getDataDir().'/'.$this->mc['logfile_filename'];
+ $f = fopen($logfile,'a');
+
+ $message = sprintf("[%s] %s - %s (IP: %s, U: %s, S: %s)\n",
+ $type,
+ date("Y-m-d H:i:s",$time),
+ $message,
+ $ip,
+ $uid,
+ $sid);
+
+ //Add ansi color codes
+ if ($this->mc['logfile_ansicolor']) {
+ if($type == 'message')
+ $message = sprintf("\x1b[32m%s\x1b[0m",$message);
+ else if($type == 'warning')
+ $message = sprintf("\x1b[33m%s\x1b[0m",$message);
+ else if($type == 'error')
+ $message = sprintf("\x1b[31m%s\x1b[0m",$message);
+ }
+
+ fputs($f, $message);
+ fclose($f);
+ }
+ }
+?>
Deleted: trunk/mod/eis_user/elements/.UserSelectMembership.php.swp
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bas...@us...> - 2007-09-16 11:28:38
|
Revision: 212
http://eis.svn.sourceforge.net/eis/?rev=212&view=rev
Author: baslijnse
Date: 2007-09-16 04:28:25 -0700 (Sun, 16 Sep 2007)
Log Message:
-----------
Added 'setContentType' method for controlling output content type and added a getPathPart method for getting a single part of the path.
Modified Paths:
--------------
trunk/lib/engine/engine.lib.php
Modified: trunk/lib/engine/engine.lib.php
===================================================================
--- trunk/lib/engine/engine.lib.php 2007-09-15 00:40:07 UTC (rev 211)
+++ trunk/lib/engine/engine.lib.php 2007-09-16 11:28:25 UTC (rev 212)
@@ -10,6 +10,7 @@
var $currentModule = null; /**< Current rendered element's module */
var $currentElement = null; /**< Current rendered element */
var $moduleConfig = array(); /**< Variable containing array of moduleconfig elements*/
+ var $contentType = 'text/html; charset=UTF-8;'; /** < content type of output */
/**< ENGINE STATUS VARIABLES */
var $version = 'svn-trunk'; /**< Engine version */
@@ -735,7 +736,7 @@
}
//Show Headers
- header('Content-Type: text/html; charset=UTF-8;');
+ header('Content-Type: '.$this->contentType);
$this->_engineHeaders();
$this->_noCache();
@@ -1000,6 +1001,14 @@
function getPath() {
return $this->request->getPath();
}
+ function getPathPart($index) {
+ $path = $this->request->getPath();
+ if($index >= 0) {
+ return $path[$index];
+ } else {
+ return $path[count($path) + $index];
+ }
+ }
function getLocale() {
//TODO: Get this from session/browser/whatever
@@ -1293,6 +1302,15 @@
}
}
/**
+ * Set output mimetype
+ *
+ * @param mimetype the content mimetype
+ */
+ function setContentType($mimetype) {
+ $this->contentType = $mimetype;
+ }
+
+ /**
* Get a reference to a service object.
*
*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bas...@us...> - 2007-09-15 00:40:11
|
Revision: 211
http://eis.svn.sourceforge.net/eis/?rev=211&view=rev
Author: baslijnse
Date: 2007-09-14 17:40:07 -0700 (Fri, 14 Sep 2007)
Log Message:
-----------
added a pluggable session storage mechanism using services similiar to the authentication mechanism
Modified Paths:
--------------
trunk/lib/engine/engine.lib.php
trunk/lib/engine/session.lib.php
trunk/mod/eis_session/config/module.php
Added Paths:
-----------
trunk/lib/base/sessionservice.lib.php
trunk/mod/eis_session/services/
trunk/mod/eis_session/services/FileStoreService.php
Removed Paths:
-------------
trunk/mod/eis_session/info.txt
Added: trunk/lib/base/sessionservice.lib.php
===================================================================
--- trunk/lib/base/sessionservice.lib.php (rev 0)
+++ trunk/lib/base/sessionservice.lib.php 2007-09-15 00:40:07 UTC (rev 211)
@@ -0,0 +1,28 @@
+<?php
+ /**
+ * Base interface class for session services.
+ * If a module implements this interface, EIS can use it to store sessions
+ */
+ class SessionService extends Service {
+
+ /**
+ * Load a session datastructure.
+ *
+ * @return a dictionary containing:
+ * id (integer), key (string), uid, (integer), age (integer), data (structure)
+ */
+ function loadSession($id, $key, $ip) {
+ }
+ /**
+ * Store a session datastructure.
+ */
+ function storeSession($session) {
+ }
+ /**
+ * Purges old sessions from the data storage
+ */
+ function purgeSessions() {
+
+ }
+ }
+?>
Modified: trunk/lib/engine/engine.lib.php
===================================================================
--- trunk/lib/engine/engine.lib.php 2007-09-14 11:20:31 UTC (rev 210)
+++ trunk/lib/engine/engine.lib.php 2007-09-15 00:40:07 UTC (rev 211)
@@ -70,7 +70,6 @@
function _initApplication($application) {
require_once("lib/engine/application.lib.php");
require_once("lib/base/service.lib.php");
- require_once("lib/base/authservice.lib.php");
require_once("lib/base/element.lib.php");
$this->application = new Application($this);
$this->application->load($application);
@@ -105,6 +104,7 @@
*/
function _initSession() {
require("lib/engine/session.lib.php");
+ require("lib/base/sessionservice.lib.php");
$this->session = new Session($this);
$this->session->load();
}
@@ -113,6 +113,7 @@
*/
function _initUser() {
require("lib/engine/user.lib.php");
+ require("lib/base/authservice.lib.php");
$this->user = new User($this);
$this->user->load();
}
Modified: trunk/lib/engine/session.lib.php
===================================================================
--- trunk/lib/engine/session.lib.php 2007-09-14 11:20:31 UTC (rev 210)
+++ trunk/lib/engine/session.lib.php 2007-09-15 00:40:07 UTC (rev 211)
@@ -11,14 +11,9 @@
var $key; /**< Random session key */
var $uid; /**< User id */
- var $status; /**< Session status: new, renewed, expired */
+ var $status; /**< Session status: new, renewed, expired */
var $age; /**< Session age in seconds */
- var $ttlAnonymous = 3600; /**< Time to live for anonymous sessions */
- var $ttlAuthenticated = 3600; /**< Time to live for authenticated sessions */
-
- var $storage = 'file'; /**< Where to store the session data. file or database */
-
var $data = array();
function Session(&$engine) {
@@ -27,7 +22,7 @@
//Clean session
$this->id = 0;
$this->ip = $_SERVER['REMOTE_ADDR'];
- $this->key = "";
+ $this->key = $this->_genKey();
$this->uid = 0;
$this->status = 'new';
@@ -42,19 +37,8 @@
function setKey($key) {
$this->key = $key;
}
- function setTtlAnonymous($ttl) {
- $this->ttlAnonymous = intval($ttl);
- }
- function setTtlAuthenticated($ttl) {
- $this->ttlAuthenticated = intval($ttl);
- }
- function setStorage($storage) {
- if(in_array($storage,array('file','database'))) {
- $this->storage = $storage;
- }
- }
function setUid($uid) {
- //$this->uid = intval($uid);
+ $this->uid = intval($uid);
}
function getStatus() {
@@ -75,17 +59,24 @@
$id = intval($param[0]);
$key = $param[1];
- switch($this->storage) {
- case 'file':
- $this->_cleanFiles();
- $success = $this->_loadFromFile($id, $key);
- break;
- case 'database':
- $this->_cleanDatabase();
- $success = $this->_loadFromDatabase($id, $key);
- break;
+ $backend = $this->e->application->getSessionBackend();
+ if(!is_array($backend)) {
+ $this->status = 'new';
+ return;
}
- if($success) {
+
+ $service =& $this->e->getService($backend['module'],$backend['service']);
+ $session = $service->purgeSessions();
+ $session = $service->loadSession($id, $key,$_SERVER['REMOTE_ADDR']);
+
+ if(is_array($session)) {
+ $this->id = $session['id'];
+ $this->ip = $session['ip'];
+ $this->key = $session['key'];
+ $this->uid = $session['uid'];
+ $this->age = $session['age'];
+ $this->data = $session['data'];
+
$this->status = 'restored';
} else {
$this->status = 'expired';
@@ -97,18 +88,24 @@
}
function save () {
- switch($this->storage) {
- case 'file':
- $success = $this->_saveToFile();
- break;
- case 'database':
- $success = $this->_saveToDatabase();
- break;
+ $backend = $this->e->application->getSessionBackend();
+ if(!is_array($backend)) {
+ return;
}
- if ($success) {
- setcookie('eis-session', base64_encode($this->id.':'.$this->key),null,$this->e->getBasePath());
- }
- return $success;
+
+ $session['id'] = $this->id;
+ $session['ip'] = $this->ip;
+ $session['key'] = $this->key;
+ $session['uid'] = $this->uid;
+ $session['data'] = $this->data;
+
+ //Store session
+ $service =& $this->e->getService($backend['module'],$backend['service']);
+ $service->storeSession($session);
+
+ //Set cookie
+ $cookie = base64_encode($this->id.':'.$this->key);
+ setcookie('eis-session',$cookie,null,$this->e->getBasePath());
}
function set($key, $value, $cat = 'site') {
@@ -162,12 +159,6 @@
}
//Engine scope values
- function getPermissions() {
- return $this->get('permissions','engine');
- }
- function getPreferences() {
- return $this->get('preferences','engine');
- }
function getHistory() {
$history = $this->get('history','engine');
if(is_array($history)) {
@@ -188,102 +179,6 @@
$this->set('history',$history,'engine');
}
- function _loadFromFile($id, $key) {
-
- $pattern = '/tmp/eis-session-'.md5($id.$key).'-*';
- $files = glob($pattern);
-
- if(count($files) == 1 && is_readable($files[0])) {
-
- $filename = $files[0];
-
- //Get content
- $age = time() - filemtime($filename);
- $content = unserialize(implode('',file($filename)));
- if(is_array($content) && count($content) == 3) {
- list($ip, $uid, $data) = $content;
- } else {
- @unlink($filename);
- return false;
- }
- //Check ip
- if($ip != $_SERVER['REMOTE_ADDR']) {
- @unlink($filename);
- return false;
- }
- //Check age
- if(($uid == 0 && $age > $this->ttlAnonymous) ||
- ($uid > 0 && $age > $this->ttlAuthenticated) ) {
- @unlink($filename);
- return false;
- }
- //Touch file
- $f = fopen($filename,'a');
- fclose($f);
-
- //Restore data
- $this->id = $id;
- $this->key = $key;
- $this->uid = $uid;
- $this->age = $age;
- $this->data = $data;
-
- return true;
- } else {
- return false;
- }
- }
- function _loadFromDatabase($id, $key) {
- //TODO
- }
- function _saveToFile() {
- if($this->id == 0) {
- $this->id = 69;//TODO: Gen unique id
- $this->key = $this->_genKey();
- }
-
- $filename = '/tmp/eis-session-'.md5($this->id.$this->key).'-'.$this->uid;
- $content = array($this->ip,$this->uid,$this->data);
- $content = serialize($content);
-
- $f = fopen($filename,'w');
- fwrite($f,$content);
- fclose($f);
-
- return true;
- }
- function _saveToDatabase() {
- return true;
- }
- function _cleanFiles() {
- if(rand(0,20)) { //Cleanup once in 20 hits on average
- return;
- }
- $files = glob('/tmp/eis-session-*');
- if(!is_array($files)) {
- return;
- }
- foreach($files as $filename) {
- if(ereg('/tmp/eis-session-([0-9a-f]+)-([0-9]+)',$filename, $match)) {
- $uid = intval($match[2]);
- $age = time() - filemtime($filename);
- if($uid > 0) { //Authenticated
- if ($age <= $this->ttlAuthenticated) {
- continue;
- }
- } else { //Anonymous
- if ($age <= $this->ttlAnonymous) {
- continue;
- }
- }
- }
- //Remove file
- @unlink($filename);
- }
- }
- function _cleanDatabases() {
- //TODO
- }
function _genKey() {
$chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
$key = "";
Modified: trunk/mod/eis_session/config/module.php
===================================================================
--- trunk/mod/eis_session/config/module.php 2007-09-14 11:20:31 UTC (rev 210)
+++ trunk/mod/eis_session/config/module.php 2007-09-15 00:40:07 UTC (rev 211)
@@ -1,7 +1,6 @@
<?php
- # Session Settings
- $cfg['session_ttl_user'] = "600"; # Session time to live in minutes for authenticated sessions
- $cfg['session_ttl_anonymous'] = "1200"; # Session time to live for anomous sessions
+ $cfg['ttl_authenticated'] = "1800"; // Session time to live in minutes for authenticated sessions
+ $cfg['ttl_anonymous'] = "3600"; //Session time to live for anomous sessions
-
+ $cfg['tmp_dir'] = '/tmp';
?>
Deleted: trunk/mod/eis_session/info.txt
===================================================================
--- trunk/mod/eis_session/info.txt 2007-09-14 11:20:31 UTC (rev 210)
+++ trunk/mod/eis_session/info.txt 2007-09-15 00:40:07 UTC (rev 211)
@@ -1,15 +0,0 @@
-Module: user
-Version: 0.?
-Status: Testing
-Licencse: BSD
-Maintainer: bas...@en...
-Description:
-EIS uses sessions, which are basicly unrestricted datastructures, to keep
-state between stateless http requests. This module provides the basic
-infrastructure for sessions and some session related user interface
-components, such as statistics and information about currently active
-sessions.
-
-Known issues:
-The module's core session infrastructure is ready and in testing phase, but no
-interface elements as mentioned in the description have been made yet.
Added: trunk/mod/eis_session/services/FileStoreService.php
===================================================================
--- trunk/mod/eis_session/services/FileStoreService.php (rev 0)
+++ trunk/mod/eis_session/services/FileStoreService.php 2007-09-15 00:40:07 UTC (rev 211)
@@ -0,0 +1,92 @@
+<?php
+ class eis_session_FileStoreService extends SessionService {
+
+ function loadSession($id, $key, $ip) {
+
+ $pattern = $this->mc['tmp_dir'].'/eis-session-'.md5($id.$key);
+ $files = glob($pattern);
+
+ if(count($files) == 1 && is_readable($files[0])) {
+
+ $filename = $files[0];
+
+ $session = array();
+ $session['id'] = $id;
+ $session['key'] = $key;
+ $session['age'] = time() - filemtime($filename);
+
+ //Load content
+ $content = unserialize(implode('',file($filename)));
+
+ if(is_array($content) && count($content) == 3) {
+ $session['ip'] = $content[0];
+ $session['uid'] = $content[1];
+ $session['data'] = $content[2];
+ } else {
+ @unlink($filename);
+ return null;
+ }
+ //Check ip
+ if($session['ip'] != $ip) {
+ @unlink($filename);
+ return null;
+ }
+ //Check age
+ if(($session['uid'] == 0 && $session['age'] > $this->mc['ttl_anonymous']) ||
+ ($session['uid'] > 0 && $session['age'] > $this->mc['ttl_authenticated']) ) {
+ @unlink($filename);
+ return null;
+ }
+
+ //Touch file
+ $f = fopen($filename,'a');
+ fclose($f);
+
+ //Return session
+ return $session;
+ }
+
+ return null;
+ }
+
+ function storeSession($session) {
+
+ $filename = $this->mc['tmp_dir'].'/eis-session-'.md5($session['id'].$session['key']);
+ $content = serialize(array($session['ip'],$session['uid'],$session['data']));
+
+ $f = fopen($filename,'w');
+ fwrite($f,$content);
+ fclose($f);
+ }
+
+ function purgeSessions() {
+ if(rand(0,20)) { //Cleanup once in 20 hits on average
+ return;
+ }
+ $files = glob($this->mc['tmp_dir'].'/eis-session-*');
+ if(!is_array($files)) {
+ return;
+ }
+ foreach($files as $filename) {
+
+ $content = unserialize(implode('',file($filename)));
+
+ if(is_array($content) && count($content) == 3) {
+ $uid = intval($content[1]);
+ $age = time() - filemtime($filename);
+ if($uid > 0) { //Authenticated
+ if ($age <= $this->mc['ttl_authenticated']) {
+ continue;
+ }
+ } else { //Anonymous
+ if ($age <= $this->mc['ttl_anonymous']) {
+ continue;
+ }
+ }
+ }
+ //Remove file
+ @unlink($filename);
+ }
+ }
+ }
+?>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bas...@us...> - 2007-09-14 11:20:36
|
Revision: 210
http://eis.svn.sourceforge.net/eis/?rev=210&view=rev
Author: baslijnse
Date: 2007-09-14 04:20:31 -0700 (Fri, 14 Sep 2007)
Log Message:
-----------
Added autofocus of username input to Login element, cleaned up javascript functions in widgetService and renamed Logout element to LogoutLink because it reflects the type of element better.
Modified Paths:
--------------
trunk/mod/eis_engine/applications/servermanager.xml
trunk/mod/eis_user/elements/Login.php
trunk/mod/eis_widget/services/MainService.php
Added Paths:
-----------
trunk/mod/eis_user/elements/LogoutLink.php
Removed Paths:
-------------
trunk/mod/eis_user/elements/Logout.php
Modified: trunk/mod/eis_engine/applications/servermanager.xml
===================================================================
--- trunk/mod/eis_engine/applications/servermanager.xml 2007-09-14 09:14:46 UTC (rev 209)
+++ trunk/mod/eis_engine/applications/servermanager.xml 2007-09-14 11:20:31 UTC (rev 210)
@@ -9,7 +9,7 @@
<session_backend>
<module>eis_session</module>
- <service>FileStoreSessionService</service>
+ <service>FileStoreService</service>
</session_backend>
<page_root>
@@ -30,7 +30,7 @@
</element>
<element>
<module>eis_user</module>
- <element>Logout</element>
+ <element>LogoutLink</element>
<area>LOGOUT</area>
<config><name>logout_page</name><value>/login</value></config>
<inherit><depth>100</depth></inherit>
Modified: trunk/mod/eis_user/elements/Login.php
===================================================================
--- trunk/mod/eis_user/elements/Login.php 2007-09-14 09:14:46 UTC (rev 209)
+++ trunk/mod/eis_user/elements/Login.php 2007-09-14 11:20:31 UTC (rev 210)
@@ -56,6 +56,7 @@
print $sWidget->form($form, $this->e->hrefAction('login'), 'loginform');
print $sWidget->jsAttachHandler('loginform','onsubmit','hashPassword');
+ print $sWidget->jsInline('Form.focusFirstElement(\'loginform\');');
} else { //Use a custom template...
require_once("lib/utils/template.lib.php");
Deleted: trunk/mod/eis_user/elements/Logout.php
===================================================================
--- trunk/mod/eis_user/elements/Logout.php 2007-09-14 09:14:46 UTC (rev 209)
+++ trunk/mod/eis_user/elements/Logout.php 2007-09-14 11:20:31 UTC (rev 210)
@@ -1,20 +0,0 @@
-<?php
- class eis_user_Logout extends Element {
-
- function view_default() {
- print '<a href="'.$this->e->hrefAction('logout').'">'.$this->e->getString('eis_user.l.logout').'</a>';
- }
-
- function action_logout($data) {
-
- $this->e->user->logout();
-
- if($this->ec['redirect_logout'] != null) {
- $this->e->redirect($this->e->hrefPage($this->ec['redirect_logout']));
- } else {
- $this->e->redirect($this->e->hrefCurrentPage());
- }
- }
-
- }
-?>
Copied: trunk/mod/eis_user/elements/LogoutLink.php (from rev 208, trunk/mod/eis_user/elements/Logout.php)
===================================================================
--- trunk/mod/eis_user/elements/LogoutLink.php (rev 0)
+++ trunk/mod/eis_user/elements/LogoutLink.php 2007-09-14 11:20:31 UTC (rev 210)
@@ -0,0 +1,20 @@
+<?php
+ class eis_user_LogoutLink extends Element {
+
+ function view_default() {
+ print '<a href="'.$this->e->hrefAction('logout').'">'.$this->e->getString('eis_user.l.logout').'</a>';
+ }
+
+ function action_logout($data) {
+
+ $this->e->user->logout();
+
+ if($this->ec['redirect_logout'] != null) {
+ $this->e->redirect($this->e->hrefPage($this->ec['redirect_logout']));
+ } else {
+ $this->e->redirect($this->e->hrefCurrentPage());
+ }
+ }
+
+ }
+?>
Modified: trunk/mod/eis_widget/services/MainService.php
===================================================================
--- trunk/mod/eis_widget/services/MainService.php 2007-09-14 09:14:46 UTC (rev 209)
+++ trunk/mod/eis_widget/services/MainService.php 2007-09-14 11:20:31 UTC (rev 210)
@@ -867,8 +867,23 @@
}
//JAVASCRIPT GENERATION
-
/**
+ * Loads a separate javascript library
+ *
+ * @param file the file (static resource) that has to be loaded.
+ */
+ function jsLoadLib($file) {
+ $href = $this->e->hrefStatic($file);
+ return '<script type="text/javascript" src="'.$href.'"></script>';
+ }
+ /**
+ * Embeds a piece of inline javascript
+ * @param code the javascript code to include
+ */
+ function jsInline($code) {
+ return '<script type="text/javascript"> '.$code.' </script>';
+ }
+ /**
* Attaches a javascript event handler to html element
* For example jsAttachHandler('mybutton','onclick','doStuff') attaches the 'doStuff'
* Javascript function to the 'onclick' event of the element with id 'mybutton'.
@@ -878,11 +893,10 @@
* @param $handler the javascript function that serves as the event handler
*/
function jsAttachHandler($id, $event, $handler) {
- return '<script type="text/javascript"> $(\''.$id.'\').'.$event.' = '.$handler.'; </script>';
+ return $this->jsInline('$(\''.$id.'\').'.$event.' = '.$handler.';');
}
function jsUpdateSelect($src, $dest, $url) {
- $js = '<script type="text/javascript" >';
- $js .= '$(\'input-'.$src.'\').onchange = function () {';
+ $js = '$(\'input-'.$src.'\').onchange = function () {';
$js .= 'new Ajax.Request(\''.$url.'\',{';
$js .= 'method: \'get\', parameters: { '.$src.': $F(\'input-'.$src.'\') },';
$js .= 'onComplete: function(t) { ';
@@ -890,9 +904,8 @@
$js .= 'var dest = $(\'input-'.$dest.'\'); dest.options.length = 0; var len = 0; ';
$js .= 'opt.each(function(i){ dest.options[len] = new Option(i[1],i[0]); len++; }); ';
$js .= '}});}';
- $js .= '</script>';
- return $js;
+ return $this->jsInline($js);
}
function jsEncodeOptions($options) {
$html = array();
@@ -901,15 +914,6 @@
}
return "[".implode(",",$html)."]";
}
- /**
- * Loads a separate javascript library
- *
- * @param file the file (static resource) that has to be loaded.
- */
- function jsLoadLib($file) {
- $href = $this->e->hrefStatic($file);
- return '<script type="text/javascript" src="'.$href.'"></script>';
- }
/**
*Converts a php array into a javascript array.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bas...@us...> - 2007-09-14 09:14:49
|
Revision: 209
http://eis.svn.sourceforge.net/eis/?rev=209&view=rev
Author: baslijnse
Date: 2007-09-14 02:14:46 -0700 (Fri, 14 Sep 2007)
Log Message:
-----------
Fixed small typos
Modified Paths:
--------------
trunk/mod/eis_engine/locales/en_en/strings.xml
Modified: trunk/mod/eis_engine/locales/en_en/strings.xml
===================================================================
--- trunk/mod/eis_engine/locales/en_en/strings.xml 2007-09-14 09:08:02 UTC (rev 208)
+++ trunk/mod/eis_engine/locales/en_en/strings.xml 2007-09-14 09:14:46 UTC (rev 209)
@@ -257,7 +257,7 @@
</string>
<string>
<name>q.delete.environment</name>
- <value><![CDATA[Do U want to delete environment '%s'?]]></value>
+ <value><![CDATA[Do you really want to delete environment '%s'?]]></value>
</string>
<string>
@@ -322,6 +322,6 @@
</string>
<string>
<name>m.environment.deleted</name>
- <value><![CDATA[Successfully deletde environment '%s'.]]></value>
+ <value><![CDATA[Successfully deleted environment '%s'.]]></value>
</string>
</strings>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bas...@us...> - 2007-09-14 09:08:17
|
Revision: 208
http://eis.svn.sourceforge.net/eis/?rev=208&view=rev
Author: baslijnse
Date: 2007-09-14 02:08:02 -0700 (Fri, 14 Sep 2007)
Log Message:
-----------
Finished fully functional version of the authentication system. Also updated the Login element and added permissions and a login page to the server manager application.
Modified Paths:
--------------
trunk/lib/engine/application.lib.php
trunk/lib/engine/engine.lib.php
trunk/lib/engine/user.lib.php
trunk/mod/eis_engine/applications/servermanager.xml
trunk/mod/eis_engine/config/module.php
trunk/mod/eis_engine/locales/en_en/default/servermanager/css/main.css
trunk/mod/eis_engine/locales/en_en/default/servermanager/layout.html
trunk/mod/eis_engine/locales/en_en/strings.xml
trunk/mod/eis_engine/services/AuthService.php
trunk/mod/eis_user/config/elements.php
trunk/mod/eis_user/elements/Login.php
trunk/mod/eis_user/locales/en_en/strings.xml
trunk/mod/eis_widget/locales/en_en/default/css/widget.css
trunk/mod/eis_widget/services/MainService.php
Added Paths:
-----------
trunk/mod/eis_engine/locales/en_en/default/servermanager/css/login.css
trunk/mod/eis_engine/locales/en_en/default/servermanager/login.html
trunk/mod/eis_user/elements/Logout.php
trunk/mod/eis_user/locales/en_en/default/
trunk/mod/eis_user/locales/en_en/default/element-templates/
trunk/mod/eis_user/locales/en_en/default/element-templates/Login/
trunk/mod/eis_user/locales/en_en/default/element-templates/Login/basic.html
trunk/mod/eis_user/locales/en_en/default/element-templates/Login/tiny.html
trunk/mod/eis_user/locales/en_en/default/js/
trunk/mod/eis_user/locales/en_en/default/js/login.js
trunk/mod/eis_user/locales/en_en/default/js/md5.js
Removed Paths:
-------------
trunk/mod/eis_user/elements/Login_tpl/
trunk/mod/eis_user/maps/user/
Modified: trunk/lib/engine/application.lib.php
===================================================================
--- trunk/lib/engine/application.lib.php 2007-09-12 00:45:37 UTC (rev 207)
+++ trunk/lib/engine/application.lib.php 2007-09-14 09:08:02 UTC (rev 208)
@@ -340,18 +340,10 @@
}
}
function getPageNotFound() {
- if(isset($this->page_notfound['/'])) {
- return $this->page_notfound['/'];
- } else {
- return null;
- }
+ return $this->page_notfound;
}
function getPageNotAllowed() {
- if(isset($this->page_notallowed['/'])) {
- return $this->page_notallowed['/'];
- } else {
- return null;
- }
+ return $this->page_notallowed;
}
/**
* Gets the element instance information from the page map.
Modified: trunk/lib/engine/engine.lib.php
===================================================================
--- trunk/lib/engine/engine.lib.php 2007-09-12 00:45:37 UTC (rev 207)
+++ trunk/lib/engine/engine.lib.php 2007-09-14 09:08:02 UTC (rev 208)
@@ -698,12 +698,14 @@
}
//Check security clearance
- if($page['permission'] > 0 && ! $this->session->hasClearance($page['permission']) ) {
+ if($page['permission'] != null && !$this->user->hasPermission($page['permission'])) {
+
$page = $this->application->getPageNotAllowed();
if($page == null) {
$this->error(403);
}
+
}
//Check if this page should redirect
@@ -728,21 +730,7 @@
$mode = $instance->getMode();
//Add element to areas list
- if (!isset($this->areas[$area]))
- $this->areas[$area] = '';
-
- switch($mode) {
- default:
- case 'append':
- $this->areas[$area] = $this->areas[$area].$content;
- break;
- case 'prepend':
- $this->areas[$area] = $content.$this->areas[$area];
- break;
- case 'replace':
- $this->areas[$area] = $content;
- break;
- }
+ $this->addAreaContent($area, $content, $mode);
}
//Show Headers
@@ -1278,6 +1266,31 @@
else
return '';
}
+ /**
+ * Add content to an area
+ *
+ * @param area the area where the content needs to be added
+ * @param content the content to add to the area
+ * @param mode how should the content be added: 'prepend', 'replace' or 'append'
+ */
+ function addAreaContent($area, $content, $mode = 'append') {
+
+ if (!isset($this->areas[$area])) {
+ $this->areas[$area] = '';
+ }
+ switch($mode) {
+ default:
+ case 'append':
+ $this->areas[$area] = $this->areas[$area].$content;
+ break;
+ case 'prepend':
+ $this->areas[$area] = $content.$this->areas[$area];
+ break;
+ case 'replace':
+ $this->areas[$area] = $content;
+ break;
+ }
+ }
/**
* Get a reference to a service object.
*
Modified: trunk/lib/engine/user.lib.php
===================================================================
--- trunk/lib/engine/user.lib.php 2007-09-12 00:45:37 UTC (rev 207)
+++ trunk/lib/engine/user.lib.php 2007-09-14 09:08:02 UTC (rev 208)
@@ -32,6 +32,10 @@
$this->displayname = 'Anonymous';
$this->permissions = array();
$this->preferences = array();
+
+ //Add pseudo permissions
+ $this->permissions[] = 'public';
+ $this->permissions[] = 'unauthenticated';
}
/**
* Sets user related properties based on the user object
@@ -44,6 +48,10 @@
$this->displayname = $user['displayname'];
$this->permissions = $user['permissions'];
$this->preferences = $user['preferences'];
+
+ //Add pseudo permissions
+ $this->permissions[] = 'public';
+ $this->permissions[] = 'authenticated';
}
/**
* Checks if the authentication service returned a valid user
Modified: trunk/mod/eis_engine/applications/servermanager.xml
===================================================================
--- trunk/mod/eis_engine/applications/servermanager.xml 2007-09-12 00:45:37 UTC (rev 207)
+++ trunk/mod/eis_engine/applications/servermanager.xml 2007-09-14 09:08:02 UTC (rev 208)
@@ -14,6 +14,7 @@
<page_root>
<meta><name>menu-entry</name><value>eis_engine.l.home</value></meta>
+ <permission>eis_engine.administrator</permission>
<element>
<module>eis_engine</module>
<element>Version</element>
@@ -28,6 +29,13 @@
<inherit><depth>100</depth></inherit>
</element>
<element>
+ <module>eis_user</module>
+ <element>Logout</element>
+ <area>LOGOUT</area>
+ <config><name>logout_page</name><value>/login</value></config>
+ <inherit><depth>100</depth></inherit>
+ </element>
+ <element>
<module>eis_widget</module>
<element>Includes</element>
<area>HEAD</area>
@@ -72,8 +80,43 @@
<area>OUT</area>
<config><name>file</name><value>eis_engine/servermanager/layout.html</value></config>
<inherit><depth>100</depth></inherit>
+ <inherit><page>login</page><depth>0</depth></inherit>
</element>
<page>
+ <name>login</name>
+ <permission>public</permission>
+ <element>
+ <module>eis_widget</module>
+ <element>Includes</element>
+ <area>HEAD</area>
+ <inherit><depth>100</depth></inherit>
+ </element>
+ <element>
+ <module>eis_layout</module>
+ <element>String</element>
+ <area>TITLE</area>
+ <config><name>string</name><value>eis_engine.t.login</value></config>
+ </element>
+ <element>
+ <module>eis_layout</module>
+ <element>Message</element>
+ <area>MAIN</area>
+ <mode>prepend</mode>
+ </element>
+ <element>
+ <module>eis_user</module>
+ <element>Login</element>
+ <area>MAIN</area>
+ <config><name>redirect_login</name><value>/</value></config>
+ </element>
+ <element>
+ <module>eis_layout</module>
+ <element>Template</element>
+ <area>OUT</area>
+ <config><name>file</name><value>eis_engine/servermanager/login.html</value></config>
+ </element>
+ </page>
+ <page>
<name>applications</name>
<meta><name>menu-entry</name><value>eis_engine.t.select.application</value></meta>
<element>
@@ -266,4 +309,7 @@
</catchall>
</page>
</page_root>
+ <page_notallowed>
+ <redirect>/login</redirect>
+ <page_notallowed>
</application>
Modified: trunk/mod/eis_engine/config/module.php
===================================================================
--- trunk/mod/eis_engine/config/module.php 2007-09-12 00:45:37 UTC (rev 207)
+++ trunk/mod/eis_engine/config/module.php 2007-09-14 09:08:02 UTC (rev 208)
@@ -1,5 +1,5 @@
<?php
- $cfg['admin_password'] = 'eisroxx';
+ $cfg['admin_password'] = 'admin';
$cfg['redirect_404'] = null;
$cfg['redirect_403'] = null;
Added: trunk/mod/eis_engine/locales/en_en/default/servermanager/css/login.css
===================================================================
--- trunk/mod/eis_engine/locales/en_en/default/servermanager/css/login.css (rev 0)
+++ trunk/mod/eis_engine/locales/en_en/default/servermanager/css/login.css 2007-09-14 09:08:02 UTC (rev 208)
@@ -0,0 +1,49 @@
+body {
+ margin: 0px;
+ background-color: #fff;
+ font-family: Verdana, Helvetica, sans-serif;
+}
+body, td, th {
+ font-size: 12px;
+}
+a {
+ color: #9ccf51;
+ font-weight: bold;
+}
+img {
+ border: none;
+}
+table {
+ empty-cells: show;
+}
+#area-header {
+ text-align: center;
+ background-image: url('../img/header_bg.png');
+}
+#area-header img {
+ position: relative;
+ left: -30px;
+}
+#area-spacer {
+ color: #fff;
+ background-color: #9ccf51;
+ padding-left: 15px;
+ padding-top: 5px;
+}
+#area-main {
+ vertical-align: top;
+ padding-top: 10px;
+}
+#area-main-content {
+ position: relative;
+ left: 50%;
+ margin-left: -150px;
+ width: 300px;
+}
+div.error {
+ font-weight: bold;
+ color: #c30000;
+}
+div.message {
+ font-style: italic;
+}
Modified: trunk/mod/eis_engine/locales/en_en/default/servermanager/css/main.css
===================================================================
--- trunk/mod/eis_engine/locales/en_en/default/servermanager/css/main.css 2007-09-12 00:45:37 UTC (rev 207)
+++ trunk/mod/eis_engine/locales/en_en/default/servermanager/css/main.css 2007-09-14 09:08:02 UTC (rev 208)
@@ -63,6 +63,9 @@
#area-left-content, #area-main-content, #area-right-content {
margin: 10px;
}
+#area-left-content {
+ margin: 10px 10px 0px 10px;
+}
#area-left-content ul {
padding: 0px;
margin: 0px;
@@ -84,6 +87,14 @@
#area-left-content li.active a {
color: #fff;
}
+#area-left-logout {
+ margin: 0px 10px 0px 10px;
+ padding: 2px 0px 2px 10px;
+}
+#area-left-logout a {
+ text-decoration: none;
+ color: #000;
+}
#area-footer {
font-size: 10px;
text-align: center;
Modified: trunk/mod/eis_engine/locales/en_en/default/servermanager/layout.html
===================================================================
--- trunk/mod/eis_engine/locales/en_en/default/servermanager/layout.html 2007-09-12 00:45:37 UTC (rev 207)
+++ trunk/mod/eis_engine/locales/en_en/default/servermanager/layout.html 2007-09-14 09:08:02 UTC (rev 208)
@@ -16,6 +16,7 @@
<td width="200" id="area-left">
<div id="area-left-title"><h1>{AREA_MENUTITLE}</h1></div>
<div id="area-left-content">{AREA_LEFT}</div>
+ <div id="area-left-logout">{AREA_LOGOUT}</div>
</td>
<td id="area-main">
<div id="area-main-title"><h1>{AREA_TITLE}</h1></div>
Added: trunk/mod/eis_engine/locales/en_en/default/servermanager/login.html
===================================================================
--- trunk/mod/eis_engine/locales/en_en/default/servermanager/login.html (rev 0)
+++ trunk/mod/eis_engine/locales/en_en/default/servermanager/login.html 2007-09-14 09:08:02 UTC (rev 208)
@@ -0,0 +1,23 @@
+<html>
+<head>
+ <title>EIS :: {AREA_TITLE}</title>
+ <link rel="stylesheet" href="{URL_STATIC}eis_engine/servermanager/css/login.css" type="text/css" />
+ {AREA_HEAD}
+</head>
+<body>
+<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0" id="area-layout">
+ <tr>
+ <td height="100" id="area-top"></td>
+ </tr>
+ <tr>
+ <td height="70" id="area-header"><a href="{URL_HOME}"><img src="{URL_STATIC}eis_engine/servermanager/img/header_logo.png" /></a></td>
+ </tr>
+ <tr>
+ <td height="5" id="area-spacer"></td>
+ </tr>
+ <tr>
+ <td id="area-main"><div id="area-main-content">{AREA_MAIN}</div></td>
+ </tr>
+</table>
+</body>
+</html>
Modified: trunk/mod/eis_engine/locales/en_en/strings.xml
===================================================================
--- trunk/mod/eis_engine/locales/en_en/strings.xml 2007-09-12 00:45:37 UTC (rev 207)
+++ trunk/mod/eis_engine/locales/en_en/strings.xml 2007-09-14 09:08:02 UTC (rev 208)
@@ -17,7 +17,7 @@
Is this not the page you expected? The site is probably temporarily unavailable. Please try again on a later time.
</p>
<p>
-If you are the administrator of this site, you can now start <a href="eis-server/">setting up</a> EIS.
+If you are the administrator of this site, you can now start <a href="eis-server/">setting up</a> EIS. If you have just installed EIS, you can log in as 'admin' with password 'admin'.
</p>]]></value>
</string>
<string>
Modified: trunk/mod/eis_engine/services/AuthService.php
===================================================================
--- trunk/mod/eis_engine/services/AuthService.php 2007-09-12 00:45:37 UTC (rev 207)
+++ trunk/mod/eis_engine/services/AuthService.php 2007-09-14 09:08:02 UTC (rev 208)
@@ -8,6 +8,7 @@
if($username == 'admin' && $password == $this->mc['admin_password']) {
return $this->_getAdminUser();
} else {
+ $this->setError(0,'eis_user.e.login.incorrect');
return null;
}
}
@@ -18,6 +19,7 @@
if($username == 'admin' && md5(md5($this->mc['admin_password']).$seed) == $hash) {
return $this->_getAdminUser();
} else {
+ $this->setError(0,'eis_user.e.login.incorrect');
return null;
}
}
Modified: trunk/mod/eis_user/config/elements.php
===================================================================
--- trunk/mod/eis_user/config/elements.php 2007-09-12 00:45:37 UTC (rev 207)
+++ trunk/mod/eis_user/config/elements.php 2007-09-14 09:08:02 UTC (rev 208)
@@ -1,8 +1,10 @@
<?php
- $cfg['Login']['layout'] = null;
+ $cfg['Login']['template'] = null;
$cfg['Login']['redirect_login'] = null;
$cfg['Login']['redirect_logout'] = null;
+ $cfg['Logout']['redirect_logout'] = null;
+
$cfg['SelectUser']['type'] = 'person';
$cfg['SelectUser']['var'] = 'user.persons.current';
$cfg['SelectUser']['user_var'] = null;
Modified: trunk/mod/eis_user/elements/Login.php
===================================================================
--- trunk/mod/eis_user/elements/Login.php 2007-09-12 00:45:37 UTC (rev 207)
+++ trunk/mod/eis_user/elements/Login.php 2007-09-14 09:08:02 UTC (rev 208)
@@ -1,110 +1,122 @@
<?php
/**
- *@ingroup elements_user
- *@{
+ * Login element
*/
- /** Login element */
+ class eis_user_Login extends Element {
- class user_Login extends Element {
function view_default() {
- $sWidget =& $this->e->getService('widget');
+ $sWidget =& $this->e->getService('eis_widget');
//Get user id
- $uid = $this->e->session->getUid();
+ $uid = $this->e->user->getId();
if ($uid > 0) {
- print '<br />'.$this->e->language->getString('logged_in').': '.$this->e->user->getFullName();
- print '<br /><a href="'.$this->e->hrefAction('logout').'">'.$this->e->language->getString('do_logout').'</a><br /><br />';
+ print $this->e->getString('eis_user.l.logged_in',array($this->e->user->getDisplayName()));
+ print '<br /><br /><a href="'.$this->e->hrefAction('logout').'">';
+ print $this->e->getString('eis_user.l.logout').'</a><br /><br />';
} else {
+ //Load javascript libraries
+ $this->e->addAreaContent('HEAD',$sWidget->jsLoadLib('eis_user/js/md5.js'));
+ $this->e->addAreaContent('HEAD',$sWidget->jsLoadLib('eis_user/js/login.js'));
- //Display the form
- $t = new Template();
+ $fields = array('username','password');
+ $posted = $this->getPost();
+ $vals = $sWidget->fillValues($fields,null,$posted);
- $error =& $this->e->session->getReference('error');
+ $seed = $this->_genSeed();
+ $this->e->session->set('seed',$seed);
+ $this->e->session->save();
- if($this->elementConfig['layout'] != null) {
- $t->assign('FORM','form_' . $this->elementConfig['layout'] . '.tpl');
+ //Show form
+ if($this->ec['template'] == null) { //Use widgets...
- $t->addkey('_LOGIN_LABEL',ucfirst($this->e->language->getString('username')));
- $t->addkey('_PASSWORD_LABEL',ucfirst($this->e->language->getString('password')));
- $t->addkey('_SUBMIT_LABEL',ucfirst($this->e->language->getString('do_login')));
- if($error != null) {
- $t->addkey('_MSG',$this->e->language->getString($error));
- }
- } else {
- $t->assign('FORM','form.tpl');
+ $form = "";
- $rows[0][0] = ucfirst($this->e->language->getString('username'));
- $rows[0][1] = $sWidget->inputString('login','',null,'login_username');
+ $labels = array();
+ $values = array();
+
+ $labels[] = 'eis_user.l.username';
+ $values[] = $sWidget->inputString('username',$vals['username']);
- $rows[1][0] = ucfirst($this->e->language->getString('password'));
- $rows[1][1] = $sWidget->inputPassword('password','',null,'login_password');
+ $labels[] = 'eis_user.l.password';
+ $values[] = $sWidget->inputPassword('password',$vals['password']);
+
+ $button = $sWidget->buttonSubmit('eis_user.l.login');
- $t->addkey('_TABLE',$sWidget->formTable($rows));
- $t->addkey('_LOGIN',$sWidget->buttonSubmit('Inloggen'));
+ if($this->ec['template'] != null) { //Use a custom template
- if($error != null) {
- $errors[] = $this->e->language->getString($error);
- $t->addkey('_ERROR',$sWidget->errorList($errors));
+ } else { //Use standard form table
+ $form .= $sWidget->formTable($labels,$values);
+ $form .= $sWidget->buttonSet($button);
}
- }
- $t->assign('SCRIPT','script.tpl');
+ $form .= $sWidget->inputHidden('seed',$seed);
+ $form .= $sWidget->inputHidden('hash','');
- $t->addkey('_ACTION',$this->e->hrefAction('login'));
- $t->addkey('_JSMD5_URL',$this->e->hrefDetach('jsmd5'));
- $t->addkey('_KEY',$this->e->user->getLoginSeed());
- $t->addkey('_HASHED',($this->moduleConfig['password_type'] == 'md5') ? 1 : 0);
+ print $sWidget->form($form, $this->e->hrefAction('login'), 'loginform');
+ print $sWidget->jsAttachHandler('loginform','onsubmit','hashPassword');
- $error = null;
- $this->e->session->save();
+ } else { //Use a custom template...
+ require_once("lib/utils/template.lib.php");
+ $t = new Template();
+ $t->assign('MAIN',$this->e->getStatic($this->ec['template']));
- $t->parse('_SCRIPT','SCRIPT');
- $t->parse('OUT','FORM');
- $t->show('OUT');
- }
- }
+ //Labels
+ $t->addkey('_LABEL_USERNAME',$this->e->getString('eis_user.l.username'));
+ $t->addkey('_LABEL_PASSWORD',$this->e->getString('eis_user.l.password'));
+ $t->addkey('_LABEL_LOGIN',$this->e->getString('eis_user.l.login'));
- function view_jsmd5() {
- header('Content-Type: text/javascript');
+ //Inputs
+ $t->addkey('_VALUE_USERNAME',$vals['username']);
+ $t->addkey('_VALUE_SEED',$seed);
- $t = new Template();
- $t->assign('MAIN','jsmd5.tpl');
- $t->parse('OUT','MAIN');
- $t->show('OUT');
+ //Form action
+ $t->addkey('_ACTION',$this->e->hrefAction('login'));
+
+ $t->parse('OUT','MAIN');
+ $t->show('OUT');
+ }
+ }
}
- function action_login($data) {
+ function action_login($args) {
- // Fetch login parameters from action data
- $login = isset($data['login']) ? $data['login'] : null;
- $hash = isset($data['hash']) ? $data['hash'] : null;
+ $seed = $this->e->session->get('seed');
// Attempt login
- if($this->e->user->logIn($login, $hash)) {
- if($this->elementConfig['redirect_login'] != null) {
- $this->e->redirect($this->e->hrefPage($this->elementConfig['redirect_login']));
- exit;
+ if($this->e->user->loginByMD5($args['username'], $seed, $args['hash'])) {
+
+ if($this->ec['redirect_login'] != null) {
+ $this->e->redirect($this->e->hrefPage($this->ec['redirect_login']));
+ } else {
+ $this->e->redirect($this->e->hrefCurrentPage());
}
} else {
- //Store errormessage in session
- $error =& $this->e->session->getReference('error');
- $error = $this->e->user->getMessage();
- $this->e->session->save();
+ //Show error message
+ $this->setPost($args);
+ $this->e->showServiceError($this->e->user->getError());
+ $this->e->redirect($this->e->hrefCurrentPage());
}
}
function action_logout($data) {
- // Attempt logout
- if($this->e->user->logOut()) {
- if($this->elementConfig['redirect_logout'] != null) {
- $this->e->redirect($this->e->hrefPage($this->elementConfig['redirect_logout']));
- exit;
- }
+ $this->e->user->logout();
+
+ if($this->ec['redirect_logout'] != null) {
+ $this->e->redirect($this->e->hrefPage($this->ec['redirect_logout']));
+ } else {
+ $this->e->redirect($this->e->hrefCurrentPage());
}
}
+
+ function _genSeed() {
+ $seed = "";
+ for($i = 0; $i < 32; $i++) {
+ $seed .= chr(rand(97,122));
+ }
+ return $seed;
+ }
}
- /**@}*/
?>
Added: trunk/mod/eis_user/elements/Logout.php
===================================================================
--- trunk/mod/eis_user/elements/Logout.php (rev 0)
+++ trunk/mod/eis_user/elements/Logout.php 2007-09-14 09:08:02 UTC (rev 208)
@@ -0,0 +1,20 @@
+<?php
+ class eis_user_Logout extends Element {
+
+ function view_default() {
+ print '<a href="'.$this->e->hrefAction('logout').'">'.$this->e->getString('eis_user.l.logout').'</a>';
+ }
+
+ function action_logout($data) {
+
+ $this->e->user->logout();
+
+ if($this->ec['redirect_logout'] != null) {
+ $this->e->redirect($this->e->hrefPage($this->ec['redirect_logout']));
+ } else {
+ $this->e->redirect($this->e->hrefCurrentPage());
+ }
+ }
+
+ }
+?>
Added: trunk/mod/eis_user/locales/en_en/default/element-templates/Login/basic.html
===================================================================
--- trunk/mod/eis_user/locales/en_en/default/element-templates/Login/basic.html (rev 0)
+++ trunk/mod/eis_user/locales/en_en/default/element-templates/Login/basic.html 2007-09-14 09:08:02 UTC (rev 208)
@@ -0,0 +1,26 @@
+<table border="0" cellspacing="0" cellpadding="0">
+ <tr>
+ <td nowrap="1">
+ <form id="loginform" method="post" onsubmit="return hashPassword();" action="{_ACTION}">
+ <table border="0" cellspacing="0" cellpadding="0">
+ <tr>
+ <td>{_LABEL_USERNAME}: </td>
+ <td><input type="text" name="username" id="input-username" value="{_VALUE_USERNAME}"></td>
+ </tr>
+ <tr>
+ <td>{_LABEL_PASSWORD}: </td>
+ <td><input type="password" name="password" id="input-password"></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td align="right" nowrap="1">
+ <input type="submit" value="{_LABEL_LOGIN}" ></span>
+ </td>
+ </tr>
+ </table>
+ <input type="hidden" name="seed" id="input-seed" value="{_VALUE_SEED}" />
+ <input type="hidden" name="hash" id="input-hash" />
+ </form>
+ </td>
+ </tr>
+</table>
Property changes on: trunk/mod/eis_user/locales/en_en/default/element-templates/Login/basic.html
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/mod/eis_user/locales/en_en/default/element-templates/Login/tiny.html
===================================================================
--- trunk/mod/eis_user/locales/en_en/default/element-templates/Login/tiny.html (rev 0)
+++ trunk/mod/eis_user/locales/en_en/default/element-templates/Login/tiny.html 2007-09-14 09:08:02 UTC (rev 208)
@@ -0,0 +1,15 @@
+<script type="text/javascript" />
+function revealPassword() {
+ $('fake-password').style.display = 'none';
+ $('input-password').style.display = 'inline';
+ $('input-password').focus();
+}
+</script>
+<form id="loginform" method="post" onsubmit="return hashPassword();" action="{_ACTION}">
+<input type="text" name="username" value="{_LABEL_USERNAME}" onclick="this.value = '';" /><br />
+<input type="text" id="fake-password" value="{_LABEL_PASSWORD}" onfocus="revealPassword();" /><input type="password" name="password" id="input-password" style="display: none;" /><br />
+<input type="submit" value="{_LABEL_LOGIN}" />
+
+<input type="hidden" name="seed" id="input-seed" value="{_VALUE_SEED}"/>
+<input type="hidden" name="hash" id="input-hash" />
+</form>
Property changes on: trunk/mod/eis_user/locales/en_en/default/element-templates/Login/tiny.html
___________________________________________________________________
Name: svn:executable
+ *
Copied: trunk/mod/eis_user/locales/en_en/default/js/login.js (from rev 205, trunk/mod/eis_user/elements/Login_tpl/script.tpl)
===================================================================
--- trunk/mod/eis_user/locales/en_en/default/js/login.js (rev 0)
+++ trunk/mod/eis_user/locales/en_en/default/js/login.js 2007-09-14 09:08:02 UTC (rev 208)
@@ -0,0 +1,6 @@
+function hashPassword () {
+ $('input-hash').value = calcMD5(calcMD5($F('input-password')) + $F('input-seed'));
+ $('input-password').value = '';
+
+ return true;
+}
Copied: trunk/mod/eis_user/locales/en_en/default/js/md5.js (from rev 205, trunk/mod/eis_user/elements/Login_tpl/jsmd5.tpl)
===================================================================
--- trunk/mod/eis_user/locales/en_en/default/js/md5.js (rev 0)
+++ trunk/mod/eis_user/locales/en_en/default/js/md5.js 2007-09-14 09:08:02 UTC (rev 208)
@@ -0,0 +1,174 @@
+/*
+ * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
+ * Digest Algorithm, as defined in RFC 1321.
+ * Copyright (C) Paul Johnston 1999 - 2000.
+ * Updated by Greg Holt 2000 - 2001.
+ * See http://pajhome.org.uk/site/legal.html for details.
+ */
+
+/*
+ * Convert a 32-bit number to a hex string with ls-byte first
+ */
+var hex_chr = "0123456789abcdef";
+function rhex(num)
+{
+ str = "";
+ for(j = 0; j <= 3; j++)
+ str += hex_chr.charAt((num >> (j * 8 + 4)) & 0x0F) +
+ hex_chr.charAt((num >> (j * 8)) & 0x0F);
+ return str;
+}
+
+/*
+ * Convert a string to a sequence of 16-word blocks, stored as an array.
+ * Append padding bits and the length, as described in the MD5 standard.
+ */
+function str2blks_MD5(str)
+{
+ nblk = ((str.length + 8) >> 6) + 1;
+ blks = new Array(nblk * 16);
+ for(i = 0; i < nblk * 16; i++) blks[i] = 0;
+ for(i = 0; i < str.length; i++)
+ blks[i >> 2] |= str.charCodeAt(i) << ((i % 4) * 8);
+ blks[i >> 2] |= 0x80 << ((i % 4) * 8);
+ blks[nblk * 16 - 2] = str.length * 8;
+ return blks;
+}
+
+/*
+ * Add integers, wrapping at 2^32. This uses 16-bit operations internally
+ * to work around bugs in some JS interpreters.
+ */
+function add(x, y)
+{
+ var lsw = (x & 0xFFFF) + (y & 0xFFFF);
+ var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
+ return (msw << 16) | (lsw & 0xFFFF);
+}
+
+/*
+ * Bitwise rotate a 32-bit number to the left
+ */
+function rol(num, cnt)
+{
+ return (num << cnt) | (num >>> (32 - cnt));
+}
+
+/*
+ * These functions implement the basic operation for each round of the
+ * algorithm.
+ */
+function cmn(q, a, b, x, s, t)
+{
+ return add(rol(add(add(a, q), add(x, t)), s), b);
+}
+function ff(a, b, c, d, x, s, t)
+{
+ return cmn((b & c) | ((~b) & d), a, b, x, s, t);
+}
+function gg(a, b, c, d, x, s, t)
+{
+ return cmn((b & d) | (c & (~d)), a, b, x, s, t);
+}
+function hh(a, b, c, d, x, s, t)
+{
+ return cmn(b ^ c ^ d, a, b, x, s, t);
+}
+function ii(a, b, c, d, x, s, t)
+{
+ return cmn(c ^ (b | (~d)), a, b, x, s, t);
+}
+
+/*
+ * Take a string and return the hex representation of its MD5.
+ */
+function calcMD5(str)
+{
+ x = str2blks_MD5(str);
+ a = 1732584193;
+ b = -271733879;
+ c = -1732584194;
+ d = 271733878;
+
+ for(i = 0; i < x.length; i += 16)
+ {
+ olda = a;
+ oldb = b;
+ oldc = c;
+ oldd = d;
+
+ a = ff(a, b, c, d, x[i+ 0], 7 , -680876936);
+ d = ff(d, a, b, c, x[i+ 1], 12, -389564586);
+ c = ff(c, d, a, b, x[i+ 2], 17, 606105819);
+ b = ff(b, c, d, a, x[i+ 3], 22, -1044525330);
+ a = ff(a, b, c, d, x[i+ 4], 7 , -176418897);
+ d = ff(d, a, b, c, x[i+ 5], 12, 1200080426);
+ c = ff(c, d, a, b, x[i+ 6], 17, -1473231341);
+ b = ff(b, c, d, a, x[i+ 7], 22, -45705983);
+ a = ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
+ d = ff(d, a, b, c, x[i+ 9], 12, -1958414417);
+ c = ff(c, d, a, b, x[i+10], 17, -42063);
+ b = ff(b, c, d, a, x[i+11], 22, -1990404162);
+ a = ff(a, b, c, d, x[i+12], 7 , 1804603682);
+ d = ff(d, a, b, c, x[i+13], 12, -40341101);
+ c = ff(c, d, a, b, x[i+14], 17, -1502002290);
+ b = ff(b, c, d, a, x[i+15], 22, 1236535329);
+
+ a = gg(a, b, c, d, x[i+ 1], 5 , -165796510);
+ d = gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
+ c = gg(c, d, a, b, x[i+11], 14, 643717713);
+ b = gg(b, c, d, a, x[i+ 0], 20, -373897302);
+ a = gg(a, b, c, d, x[i+ 5], 5 , -701558691);
+ d = gg(d, a, b, c, x[i+10], 9 , 38016083);
+ c = gg(c, d, a, b, x[i+15], 14, -660478335);
+ b = gg(b, c, d, a, x[i+ 4], 20, -405537848);
+ a = gg(a, b, c, d, x[i+ 9], 5 , 568446438);
+ d = gg(d, a, b, c, x[i+14], 9 , -1019803690);
+ c = gg(c, d, a, b, x[i+ 3], 14, -187363961);
+ b = gg(b, c, d, a, x[i+ 8], 20, 1163531501);
+ a = gg(a, b, c, d, x[i+13], 5 , -1444681467);
+ d = gg(d, a, b, c, x[i+ 2], 9 , -51403784);
+ c = gg(c, d, a, b, x[i+ 7], 14, 1735328473);
+ b = gg(b, c, d, a, x[i+12], 20, -1926607734);
+
+ a = hh(a, b, c, d, x[i+ 5], 4 , -378558);
+ d = hh(d, a, b, c, x[i+ 8], 11, -2022574463);
+ c = hh(c, d, a, b, x[i+11], 16, 1839030562);
+ b = hh(b, c, d, a, x[i+14], 23, -35309556);
+ a = hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
+ d = hh(d, a, b, c, x[i+ 4], 11, 1272893353);
+ c = hh(c, d, a, b, x[i+ 7], 16, -155497632);
+ b = hh(b, c, d, a, x[i+10], 23, -1094730640);
+ a = hh(a, b, c, d, x[i+13], 4 , 681279174);
+ d = hh(d, a, b, c, x[i+ 0], 11, -358537222);
+ c = hh(c, d, a, b, x[i+ 3], 16, -722521979);
+ b = hh(b, c, d, a, x[i+ 6], 23, 76029189);
+ a = hh(a, b, c, d, x[i+ 9], 4 , -640364487);
+ d = hh(d, a, b, c, x[i+12], 11, -421815835);
+ c = hh(c, d, a, b, x[i+15], 16, 530742520);
+ b = hh(b, c, d, a, x[i+ 2], 23, -995338651);
+
+ a = ii(a, b, c, d, x[i+ 0], 6 , -198630844);
+ d = ii(d, a, b, c, x[i+ 7], 10, 1126891415);
+ c = ii(c, d, a, b, x[i+14], 15, -1416354905);
+ b = ii(b, c, d, a, x[i+ 5], 21, -57434055);
+ a = ii(a, b, c, d, x[i+12], 6 , 1700485571);
+ d = ii(d, a, b, c, x[i+ 3], 10, -1894986606);
+ c = ii(c, d, a, b, x[i+10], 15, -1051523);
+ b = ii(b, c, d, a, x[i+ 1], 21, -2054922799);
+ a = ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
+ d = ii(d, a, b, c, x[i+15], 10, -30611744);
+ c = ii(c, d, a, b, x[i+ 6], 15, -1560198380);
+ b = ii(b, c, d, a, x[i+13], 21, 1309151649);
+ a = ii(a, b, c, d, x[i+ 4], 6 , -145523070);
+ d = ii(d, a, b, c, x[i+11], 10, -1120210379);
+ c = ii(c, d, a, b, x[i+ 2], 15, 718787259);
+ b = ii(b, c, d, a, x[i+ 9], 21, -343485551);
+
+ a = add(a, olda);
+ b = add(b, oldb);
+ c = add(c, oldc);
+ d = add(d, oldd);
+ }
+ return rhex(a) + rhex(b) + rhex(c) + rhex(d);
+}
Modified: trunk/mod/eis_user/locales/en_en/strings.xml
===================================================================
--- trunk/mod/eis_user/locales/en_en/strings.xml 2007-09-12 00:45:37 UTC (rev 207)
+++ trunk/mod/eis_user/locales/en_en/strings.xml 2007-09-14 09:08:02 UTC (rev 208)
@@ -4,4 +4,24 @@
<name>l.logged_in</name>
<value><![CDATA[You are logged in as: %s]]></value>
</string>
+ <string>
+ <name>l.username</name>
+ <value><![CDATA[Username]]></value>
+ </string>
+ <string>
+ <name>l.password</name>
+ <value><![CDATA[Password]]></value>
+ </string>
+ <string>
+ <name>l.login</name>
+ <value><![CDATA[Log in]]></value>
+ </string>
+ <string>
+ <name>l.logout</name>
+ <value><![CDATA[Log out]]></value>
+ </string>
+ <string>
+ <name>e.login.incorrect</name>
+ <value><![CDATA[Incorrect username or password]]></value>
+ </string>
</strings>
Modified: trunk/mod/eis_widget/locales/en_en/default/css/widget.css
===================================================================
--- trunk/mod/eis_widget/locales/en_en/default/css/widget.css 2007-09-12 00:45:37 UTC (rev 207)
+++ trunk/mod/eis_widget/locales/en_en/default/css/widget.css 2007-09-14 09:08:02 UTC (rev 208)
@@ -26,7 +26,7 @@
border: solid 1px #999;
}
input.widget-input-password {
- width: 100%;
+ width: 200px;
border: solid 1px #999;
}
Modified: trunk/mod/eis_widget/services/MainService.php
===================================================================
--- trunk/mod/eis_widget/services/MainService.php 2007-09-12 00:45:37 UTC (rev 207)
+++ trunk/mod/eis_widget/services/MainService.php 2007-09-14 09:08:02 UTC (rev 208)
@@ -240,6 +240,9 @@
case 'password':
$html = $this->inputPassword($name, $value, $options, $id, $conf);
break;
+ case 'hidden':
+ $html = $this->inputHidden($name, $value, $options, $id, $conf);
+ break;
case 'currency':
$html = $this->inputCurrency($name, $value, $options, $id, $conf);
break;
@@ -467,9 +470,29 @@
$html .= 'id="'.$id.'" ';
$html .= 'class="widget-input-password" />';
- return $input;
+ return $html;
}
/**
+ * Input widget for a hidden value
+ * @param $name the identifying name of the input in a form
+ * @param $value the current value of the input
+ * @param $options an optional list of possible values for the input
+ * @param $id an optional html dom id to identify the widget with javascript or stylesheets
+ * @param $conf optional configuration of the widget
+ * @return html rendering of the widget
+ */
+ function inputHidden($name, $value, $options = null, $id = null, $conf = null) {
+ if($id == null) {
+ $id = 'input-'.$name;
+ }
+
+ $html = '<input type="hidden" name="'.$name.'" value="'.$value.'" ';
+ $html .= 'id="'.$id.'" ';
+ $html .= 'class="widget-input-hidden" />';
+
+ return $html;
+ }
+ /**
* Input widget for a url value
* @param $name the identifying name of the input in a form
* @param $value the current value of the input
@@ -481,7 +504,6 @@
function inputURL($name, $value, $options = null, $id = null, $conf = null) {
return $this->inputScalar('url', $name, $value, $options, $id, $conf);
}
-
/**
* Input widget for a currency value
* @param $name the identifying name of the input in a form
@@ -802,11 +824,15 @@
//UTILITY FUNCTIONS
- function form($body, $action, $conf = null) {
+ function form($body, $action, $id = null, $conf = null) {
$method = (isset($conf['method']) && $conf['method']) ? $conf['method'] : 'post';
- $html = '<form action="'.$action.'" method="'.$method.'" enctype="multipart/form-data" >';
+ $html = '<form action="'.$action.'" method="'.$method.'" enctype="multipart/form-data" ';
+ if($id != null) {
+ $html .= 'id="'.$id.'" ';
+ }
+ $html .= '>';
$html .= $body.'</form>';
return $html;
@@ -842,7 +868,19 @@
//JAVASCRIPT GENERATION
- function jsUpdateSelect($src,$dest,$url) {
+ /**
+ * Attaches a javascript event handler to html element
+ * For example jsAttachHandler('mybutton','onclick','doStuff') attaches the 'doStuff'
+ * Javascript function to the 'onclick' event of the element with id 'mybutton'.
+ *
+ * @param $id the DOM id of the html element
+ * @param $event the event that triggers the handler (e.g. onclick, onsubmit, onfocus)
+ * @param $handler the javascript function that serves as the event handler
+ */
+ function jsAttachHandler($id, $event, $handler) {
+ return '<script type="text/javascript"> $(\''.$id.'\').'.$event.' = '.$handler.'; </script>';
+ }
+ function jsUpdateSelect($src, $dest, $url) {
$js = '<script type="text/javascript" >';
$js .= '$(\'input-'.$src.'\').onchange = function () {';
$js .= 'new Ajax.Request(\''.$url.'\',{';
@@ -856,7 +894,6 @@
return $js;
}
-
function jsEncodeOptions($options) {
$html = array();
foreach($options as $option) {
@@ -864,6 +901,15 @@
}
return "[".implode(",",$html)."]";
}
+ /**
+ * Loads a separate javascript library
+ *
+ * @param file the file (static resource) that has to be loaded.
+ */
+ function jsLoadLib($file) {
+ $href = $this->e->hrefStatic($file);
+ return '<script type="text/javascript" src="'.$href.'"></script>';
+ }
/**
*Converts a php array into a javascript array.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luu...@us...> - 2007-09-12 00:45:40
|
Revision: 207
http://eis.svn.sourceforge.net/eis/?rev=207&view=rev
Author: luukvandenbroek
Date: 2007-09-11 17:45:37 -0700 (Tue, 11 Sep 2007)
Log Message:
-----------
fixed environment all elements are functional now redirect after deleting is not quite right yet as it can fetch wrong page depending on parent
Modified Paths:
--------------
trunk/cfg/applications.xml
trunk/cfg/environments.xml
trunk/mod/eis_engine/elements/AddEnvironment.php
trunk/mod/eis_engine/elements/DeleteEnvironment.php
trunk/mod/eis_engine/elements/DisplayEnvironment.php
trunk/mod/eis_engine/elements/EditEnvironment.php
trunk/mod/eis_engine/locales/en_en/strings.xml
trunk/mod/eis_engine/services/ConfigService.php
Modified: trunk/cfg/applications.xml
===================================================================
--- trunk/cfg/applications.xml 2007-09-11 16:56:12 UTC (rev 206)
+++ trunk/cfg/applications.xml 2007-09-12 00:45:37 UTC (rev 207)
@@ -18,4 +18,10 @@
<application>examples</application>
<environment>minimal</environment>
</application>
+ <application>
+ <name>test</name>
+ <module>eis_engine</module>
+ <application>welcome</application>
+ <environment>minimal</environment>
+ </application>
</applications>
Modified: trunk/cfg/environments.xml
===================================================================
--- trunk/cfg/environments.xml 2007-09-11 16:56:12 UTC (rev 206)
+++ trunk/cfg/environments.xml 2007-09-12 00:45:37 UTC (rev 207)
@@ -1,33 +1,37 @@
<?xml version="1.0" encoding="utf-8" ?>
<environments>
- <default>live</default>
<environment>
<name>install</name>
- <title>EIS Installation environment</title>
+ <title>EIS install environment</title>
<admin>root@localhost</admin>
-
<show_errors>off</show_errors>
<mail_errors>off</mail_errors>
+ <mysql_host></mysql_host>
+ <mysql_user></mysql_user>
+ <mysql_password></mysql_password>
+ <mysql_database></mysql_database>
+ <data_dir></data_dir>
</environment>
<environment>
<name>minimal</name>
- <title>EIS Minimal environment</title>
+ <title>EIS minimal environment</title>
<admin>root@localhost</admin>
-
<show_errors>on</show_errors>
<mail_errors>off</mail_errors>
+ <mysql_host></mysql_host>
+ <mysql_user></mysql_user>
+ <mysql_password></mysql_password>
+ <mysql_database></mysql_database>
+ <data_dir></data_dir>
</environment>
<environment>
<name>dev</name>
<title>EIS Development environment</title>
<admin>root@localhost</admin>
-
<http_user>dev</http_user>
<http_password>dev</http_password>
-
<show_errors>off</show_errors>
<mail_errors>off</mail_errors>
-
<mysql_host>localhost:8889</mysql_host>
<mysql_user>root</mysql_user>
<mysql_password></mysql_password>
@@ -38,13 +42,10 @@
<name>test</name>
<title>EIS Test environment</title>
<admin>root@localhost</admin>
-
<http_user>test</http_user>
<http_password>test</http_password>
-
<show_errors>off</show_errors>
<mail_errors>on</mail_errors>
-
<mysql_host>localhost</mysql_host>
<mysql_user>root</mysql_user>
<mysql_password></mysql_password>
@@ -55,10 +56,8 @@
<name>live</name>
<title>EIS Live environment</title>
<admin>root@localhost</admin>
-
<show_errors>off</show_errors>
<mail_errors>on</mail_errors>
-
<mysql_host>localhost</mysql_host>
<mysql_user>root</mysql_user>
<mysql_password></mysql_password>
Modified: trunk/mod/eis_engine/elements/AddEnvironment.php
===================================================================
--- trunk/mod/eis_engine/elements/AddEnvironment.php 2007-09-11 16:56:12 UTC (rev 206)
+++ trunk/mod/eis_engine/elements/AddEnvironment.php 2007-09-12 00:45:37 UTC (rev 207)
@@ -1,47 +1,56 @@
<?php
class eis_engine_AddEnvironment extends Element {
- function view_default($id) {
+ function view_default($args) {
$sConfig =& $this->e->getService('eis_engine','ConfigService');
$sWidget =& $this->e->getService('eis_widget','MainService');
$path = $this->getPath();
$name = $path[count($path) -2];
- $env = array();
+ $fields = array('name','title','admin','show_errors','mail_errors','mysql_host','mysql_user','mysql_password','mysql_database','data_dir');
+ $defaults = array('show_errors' => 'off', 'mail_errors' => 'on');
+ $posted = $this->e->session->get('form','page');
+
+
+ $env = $sWidget->fillValues($fields,$defaults,$posted,$args);
+
$labels = array();
$inputs = array();
$labels[] = 'eis_engine.l.name';
- $inputs[] = $sWidget->displayString($env['name']);
-
+ $inputs[] = $sWidget->inputString('name',$env['name']);
+
+ $labels[] = 'eis_engine.l.title';
+ $inputs[] = $sWidget->inputString('title',$env['title']);
+
$labels[] = 'eis_engine.l.admin';
- $inputs[] = $sWidget->inputString('module',$env['admin']);
+ $inputs[] = $sWidget->inputString('admin',$env['admin']);
$options = array();
$options[] = array('value' => 'on', 'label' => $this->e->getString('eis_engine.l.on'));
$options[] = array('value' => 'off', 'label' => $this->e->getString('eis_engine.l.off'));
$labels[] = 'eis_engine.l.show_errors';
- $inputs[] = $sWidget->inputString('module',isset($env['show_errors']) ? $env['show_errors']: 'off',$options);
+ $inputs[] = $sWidget->inputString('show_errors',$env['show_errors'],$options);
$labels[] = 'eis_engine.l.mail_errors';
- $inputs[] = $sWidget->inputString('module',isset($env['mail_errors']) ? $env['mail_errors']: 'on',$options);
+ $inputs[] = $sWidget->inputString('mail_errors',$env['mail_errors'],$options);
$labels[] = 'eis_engine.l.mysql_host';
- $inputs[] = $sWidget->inputString('module', isset($env['mysql_host']) ? $env['mysql_host']: '');
+ $inputs[] = $sWidget->inputString('mysql_host',$env['mysql_host']);
$labels[] = 'eis_engine.l.mysql_user';
- $inputs[] = $sWidget->inputString('module',isset($env['mysql_user']) ? $env['mysql_user']: '');
+ $inputs[] = $sWidget->inputString('mysql_user',$env['mysql_user']);
$labels[] = 'eis_engine.l.mysql_password';
- $inputs[] = $sWidget->inputString('module',isset($env['mysql_password']) ? $env['mysql_password']: '');
+ $inputs[] = $sWidget->inputString('mysql_password',$env['mysql_password']);
$labels[] = 'eis_engine.l.mysql_database';
- $inputs[] = $sWidget->inputString('module',isset($env['mysql_database']) ? $env['mysql_database']: '');
+ $inputs[] = $sWidget->inputString('mysql_database',$env['mysql_database']);
$labels[] = 'eis_engine.l.data_dir';
- $inputs[] = $sWidget->inputString('module',isset($env['data_dir']) ? $env['data_dir']: '');
+ $inputs[] = $sWidget->inputString('data_dir',$env['data_dir']);
$form = $sWidget->formTable($labels, $inputs);
@@ -51,20 +60,24 @@
}
function action_ok($data){
- print_r($data);
- exit;
$sConfig =& $this->e->getService('eis_engine','ConfigService');
$environment = array();
foreach($data as $k => $v){
$environment[$k] = $v;
}
+
+ $sConfig->createEnvironment($environment);
- if($sConfig->createEnvironment($environment)){
- $this->e->redirect->hrefPreviousPage();
- }else{
- return;
- }
+ if($sConfig->success()) {
+ $this->e->showMessage('eis_engine.m.environment.added',array($environment['name']));
+ $this->e->redirect($this->e->hrefParentPage());
+ } else {
+ $this->setPost($data);
+ $this->e->showServiceError($sConfig->getError());
+ $this->e->redirect($this->e->hrefCurrentPage());
+ }
+
}
}
?>
Modified: trunk/mod/eis_engine/elements/DeleteEnvironment.php
===================================================================
--- trunk/mod/eis_engine/elements/DeleteEnvironment.php 2007-09-11 16:56:12 UTC (rev 206)
+++ trunk/mod/eis_engine/elements/DeleteEnvironment.php 2007-09-12 00:45:37 UTC (rev 207)
@@ -7,15 +7,36 @@
$sWidget =& $this->e->getService('eis_widget');
$path = $this->getPath();
- $name = $path[count($path) -1];
-
+ $name = $path[count($path) -2];
$env = $sConfig->getEnvironment($name);
if($env == null) {
$this->e->error(404);
}
+
+ $form = $sWidget->displayString($this->e->getString('eis_engine.q.delete.environment', array($name)));
+ $form .= $sWidget->buttonSetOkCancel();
+ print $sWidget->form($form,$this->e->hrefAction('ok'));
+
+
+ }
+ function action_ok(){
+ $sConfig =& $this->e->getService('eis_engine','ConfigService');
+ $path = $this->getPath();
+ $name = $path[count($path) -2];
+
+ $sConfig->deleteEnvironment($name);
+
+ if($sConfig->success()) {
+ $this->e->showMessage('eis_engine.m.environment.deleted',array($name));
+ $this->e->redirect($this->e->hrefPreviousPage(2));
+ } else {
+ $this->setPost($data);
+ $this->e->showServiceError($sConfig->getError());
+ $this->e->redirect($this->e->hrefCurrentPage());
+ }
}
}
?>
Modified: trunk/mod/eis_engine/elements/DisplayEnvironment.php
===================================================================
--- trunk/mod/eis_engine/elements/DisplayEnvironment.php 2007-09-11 16:56:12 UTC (rev 206)
+++ trunk/mod/eis_engine/elements/DisplayEnvironment.php 2007-09-12 00:45:37 UTC (rev 207)
@@ -35,6 +35,9 @@
$labels[] = 'eis_engine.l.name';
$inputs[] = $sWidget->displayString($env['name']);
+ $labels[] = 'eis_engine.l.title';
+ $inputs[] = $sWidget->displayString($env['title']);
+
$labels[] = 'eis_engine.l.admin';
$inputs[] = $sWidget->displayString($env['admin']);
Modified: trunk/mod/eis_engine/elements/EditEnvironment.php
===================================================================
--- trunk/mod/eis_engine/elements/EditEnvironment.php 2007-09-11 16:56:12 UTC (rev 206)
+++ trunk/mod/eis_engine/elements/EditEnvironment.php 2007-09-12 00:45:37 UTC (rev 207)
@@ -1,51 +1,58 @@
<?php
class eis_engine_EditEnvironment extends Element {
- function view_default($id) {
+ function view_default($args) {
$sConfig =& $this->e->getService('eis_engine','ConfigService');
$sWidget =& $this->e->getService('eis_widget','MainService');
$path = $this->getPath();
$name = $path[count($path) -2];
+
+ $defaults = $sConfig->getEnvironment($name);
+ if($defaults == null) {
+ $this->e->error(404);
+ }
- $env = $sConfig->getEnvironment($name);
- if($env == null) {
- $this->e->error(404);
- }
+ $fields = array('name','title','admin','show_errors','mail_errors','mysql_host','mysql_user','mysql_password','mysql_database','data_dir');
+ $posted = $this->e->session->get('form','page');
+ $env = $sWidget->fillValues($fields,$defaults,$posted,$args);
$labels = array();
$inputs = array();
$labels[] = 'eis_engine.l.name';
- $inputs[] = $sWidget->displayString($env['name']);
+ $inputs[] = $sWidget->displayString($defaults['name']);
+ $labels[] = 'eis_engine.l.title';
+ $inputs[] = $sWidget->inputString('title',$env['title']);
+
$labels[] = 'eis_engine.l.admin';
- $inputs[] = $sWidget->inputString('module',$env['admin']);
+ $inputs[] = $sWidget->inputString('admin',$env['admin']);
$options = array();
$options[] = array('value' => 'on', 'label' => $this->e->getString('eis_engine.l.on'));
$options[] = array('value' => 'off', 'label' => $this->e->getString('eis_engine.l.off'));
$labels[] = 'eis_engine.l.show_errors';
- $inputs[] = $sWidget->inputString('module',isset($env['show_errors']) ? $env['show_errors']: 'off',$options);
+ $inputs[] = $sWidget->inputString('show_errors',$env['show_errors'],$options);
$labels[] = 'eis_engine.l.mail_errors';
- $inputs[] = $sWidget->inputString('module',isset($env['mail_errors']) ? $env['mail_errors']: 'on',$options);
+ $inputs[] = $sWidget->inputString('mail_errors',$env['mail_errors'],$options);
$labels[] = 'eis_engine.l.mysql_host';
- $inputs[] = $sWidget->inputString('module', isset($env['mysql_host']) ? $env['mysql_host']: '');
+ $inputs[] = $sWidget->inputString('mysql_host',$env['mysql_host']);
$labels[] = 'eis_engine.l.mysql_user';
- $inputs[] = $sWidget->inputString('module',isset($env['mysql_user']) ? $env['mysql_user']: '');
+ $inputs[] = $sWidget->inputString('mysql_user',$env['mysql_user']);
$labels[] = 'eis_engine.l.mysql_password';
- $inputs[] = $sWidget->inputString('module',isset($env['mysql_password']) ? $env['mysql_password']: '');
+ $inputs[] = $sWidget->inputString('mysql_password',$env['mysql_password']);
$labels[] = 'eis_engine.l.mysql_database';
- $inputs[] = $sWidget->inputString('module',isset($env['mysql_database']) ? $env['mysql_database']: '');
+ $inputs[] = $sWidget->inputString('mysql_database',$env['mysql_database']);
$labels[] = 'eis_engine.l.data_dir';
- $inputs[] = $sWidget->inputString('module',isset($env['data_dir']) ? $env['data_dir']: '');
+ $inputs[] = $sWidget->inputString('data_dir',$env['data_dir']);
$form = $sWidget->formTable($labels, $inputs);
@@ -55,20 +62,29 @@
}
function action_ok($data){
- print_r($data);
- exit;
$sConfig =& $this->e->getService('eis_engine','ConfigService');
+
+ $path = $this->getPath();
+ $name = $path[count($path) -2];
+
+ $environment = array();
+ $environment['name'] = $name;
- $environment = array();
foreach($data as $k => $v){
$environment[$k] = $v;
}
+
+ $sConfig->updateEnvironment($environment);
- if($sConfig->updateEnvironment($environment)){
- $this->e->redirect->hrefPreviousPage();
- }else{
- return;
- }
+ if($sConfig->success()) {
+ $this->e->showMessage('eis_engine.m.environment.updated',array($name));
+ $this->e->redirect($this->e->hrefParentPage());
+ } else {
+ $this->setPost($data);
+ $this->e->showServiceError($sConfig->getError());
+ $this->e->redirect($this->e->hrefCurrentPage());
+ }
+
}
}
?>
Modified: trunk/mod/eis_engine/locales/en_en/strings.xml
===================================================================
--- trunk/mod/eis_engine/locales/en_en/strings.xml 2007-09-11 16:56:12 UTC (rev 206)
+++ trunk/mod/eis_engine/locales/en_en/strings.xml 2007-09-12 00:45:37 UTC (rev 207)
@@ -114,6 +114,11 @@
<value><![CDATA[Name]]></value>
</string>
<string>
+ <name>l.title</name>
+ <value><![CDATA[Title]]></value>
+ </string>
+
+ <string>
<name>l.description</name>
<value><![CDATA[Description]]></value>
</string>
@@ -150,6 +155,11 @@
<value><![CDATA[Protocol]]></value>
</string>
<string>
+ <name>l.title</name>
+ <value><![CDATA[Title]]></value>
+ </string>
+
+ <string>
<name>l.admin</name>
<value><![CDATA[Administrator]]></value>
</string>
@@ -245,8 +255,24 @@
<name>l.delete.environment</name>
<value><![CDATA[Delete environment]]></value>
</string>
+ <string>
+ <name>q.delete.environment</name>
+ <value><![CDATA[Do U want to delete environment '%s'?]]></value>
+ </string>
<string>
+ <name>e.illegalformat.name</name>
+ <value><![CDATA[A name can contain only letters, digits, dashes and underscores.]]></value>
+ </string>
+ <string>
+ <name>e.missing.admin</name>
+ <value><![CDATA[Please enter an admin]]></value>
+ </string>
+ <string>
+ <name>e.missing.title</name>
+ <value><![CDATA[Please enter a title]]></value>
+ </string>
+ <string>
<name>e.missing.module</name>
<value><![CDATA[Please select a module]]></value>
</string>
@@ -278,4 +304,24 @@
<name>m.application.added</name>
<value><![CDATA[Successfully added application '%s' at '%s'.]]></value>
</string>
+ <string>
+ <name>e.environment.duplicate.name</name>
+ <value><![CDATA[Another environment is already known as '%s'.]]></value>
+ </string>
+ <string>
+ <name>e.environment.nonexistent.name</name>
+ <value><![CDATA[There is no environment known as '%s'.]]></value>
+ </string>
+ <string>
+ <name>m.environment.added</name>
+ <value><![CDATA[Successfully added environment '%s'.]]></value>
+ </string>
+ <string>
+ <name>m.environment.updated</name>
+ <value><![CDATA[Successfully updated environment '%s'.]]></value>
+ </string>
+ <string>
+ <name>m.environment.deleted</name>
+ <value><![CDATA[Successfully deletde environment '%s'.]]></value>
+ </string>
</strings>
Modified: trunk/mod/eis_engine/services/ConfigService.php
===================================================================
--- trunk/mod/eis_engine/services/ConfigService.php 2007-09-11 16:56:12 UTC (rev 206)
+++ trunk/mod/eis_engine/services/ConfigService.php 2007-09-12 00:45:37 UTC (rev 207)
@@ -114,22 +114,31 @@
function deleteWebService($id) {
}
- function getEnvironments() {
+ function _loadEnvironments() {
$str = new XmlStruct();
$doc = $str->decodeFile('cfg/environments.xml');
$doc = $str->getValue($doc,'environments');
return $str->getArray($doc,'environment');
+
}
+ function _saveEnvironments($environments) {
+ $doc = array('environments' => array('environment' => $environments));
+ $str = new XmlStruct();
+ $str->encodeFile($doc, 'cfg/environments.xml');
+ }
+ function getEnvironments() {
+ return $this->_loadEnvironments();
+ }
+
function getEnvironment($id) {
- $environments = $this->getEnvironments();
+ $environments = $this->_loadEnvironments();
foreach($environments as $environment) {
if($environment['name'] == $id) {
return $environment;
}
}
- exit;
return null;
}
@@ -141,5 +150,89 @@
}
return $names;
}
+
+ function createEnvironment($obj) {
+ if(!$this->verifyEnvironment($obj,true)) {
+ return 0;
+ }
+
+ $environments = $this->_loadEnvironments();
+ $environments[] = $obj;
+ $this->_saveEnvironments($environments);
+
+ }
+ function updateEnvironment($obj) {
+ if(!$this->verifyEnvironment($obj)) {
+ return 0;
+ }
+
+ $environments = $this->_loadEnvironments();
+ foreach($environments as $k => $environment) {
+ if($environment['name'] == $obj['name']) {
+ $environments[$k] = $obj;
+ }
+ }
+ $this->_saveEnvironments($environments);
+
+ }
+ function deleteEnvironment($id) {
+ $environments = $this->_loadEnvironments();
+ foreach($environments as $k => $environment) {
+ if($environment['name'] == $id) {
+ unset($environments[$k]);
+ }
+ }
+ $this->_saveEnvironments($environments);
+
+ }
+
+ function getDefaultEnvironment() {
+ $str = new XmlStruct();
+ $doc = $str->decodeFile('cfg/environments.xml');
+ $doc = $str->getValue($doc,'environments');
+
+ return $str->getValue($doc,'default');
+ }
+
+
+ function verifyEnvironment($obj,$new = false) {
+
+ if(!isset($obj['title']) || $obj['title'] == '') {
+ $this->setError(0,'eis_engine.e.missing.title');
+ return false;
+ }
+
+ if(!isset($obj['admin']) || $obj['admin'] == '') {
+ $this->setError(0,'eis_engine.e.missing.admin');
+ return false;
+ }
+
+ if(!isset($obj['name']) || $obj['name'] == '') {
+ $this->setError(0,'eis_engine.e.missing.name');
+ return false;
+ } else {
+ //Check format of mountpoint
+ if(!ereg("^[a-zA-Z0-9_]+$",$obj['name'])) {
+ $this->setError(0,'eis_engine.e.illegalformat.name');
+ return false;
+ } else {
+ //Check if the application is already
+ if($this->getEnvironment($obj['name']) != null) {
+ if($new) {
+ $this->setError(0,'eis_engine.e.environment.duplicate.name',array($obj['name']));
+ return false;
+ }
+ } else {
+ if(!$new) {
+ $this->setError(0,'eis_engine.e.environment.nonexistent.name',array($obj['name']));
+ return false;
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+
}
?>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bas...@us...> - 2007-09-11 16:56:22
|
Revision: 206
http://eis.svn.sourceforge.net/eis/?rev=206&view=rev
Author: baslijnse
Date: 2007-09-11 09:56:12 -0700 (Tue, 11 Sep 2007)
Log Message:
-----------
Updated the user library. It now supports authentication based on services as pluggable authentication backends. Also started with a cleanup of the user module. This needs to be finished as most elements will have to be rewritten.
Modified Paths:
--------------
trunk/cfg/applications.xml
trunk/cfg/environments.xml
trunk/lib/engine/application.lib.php
trunk/lib/engine/engine.lib.php
trunk/lib/engine/session.lib.php
trunk/lib/engine/user.lib.php
trunk/mod/eis_engine/applications/servermanager.xml
trunk/mod/eis_engine/config/module.php
trunk/mod/eis_user/elements/ShowLogin.php
Added Paths:
-----------
trunk/lib/base/authservice.lib.php
trunk/mod/eis_engine/services/AuthService.php
trunk/mod/eis_user/locales/
trunk/mod/eis_user/locales/en_en/
trunk/mod/eis_user/locales/en_en/strings.xml
Removed Paths:
-------------
trunk/mod/eis_user/Service.php
trunk/mod/eis_user/elements/ActivateUser.php
trunk/mod/eis_user/elements/ActivateUser_tpl/
trunk/mod/eis_user/elements/AddToGroup.php
trunk/mod/eis_user/elements/DeleteUser.php
trunk/mod/eis_user/elements/DeleteUser_tpl/
trunk/mod/eis_user/elements/DisplayUser.php
trunk/mod/eis_user/elements/DisplayUserImage.php
trunk/mod/eis_user/elements/DisplayUserTitle.php
trunk/mod/eis_user/elements/DisplayUser_tpl/
trunk/mod/eis_user/elements/EditUser.php
trunk/mod/eis_user/elements/RemoveFromGroup.php
trunk/mod/eis_user/elements/SelectUser.php
trunk/mod/eis_user/elements/SignupUser.php
trunk/mod/eis_user/elements/SignupUser_tpl/
trunk/mod/eis_user/info.txt
trunk/mod/eis_user/lang/
trunk/mod/eis_user/mail/
Modified: trunk/cfg/applications.xml
===================================================================
--- trunk/cfg/applications.xml 2007-09-11 12:18:06 UTC (rev 205)
+++ trunk/cfg/applications.xml 2007-09-11 16:56:12 UTC (rev 206)
@@ -4,18 +4,18 @@
<name>eis-welcome</name>
<module>eis_engine</module>
<application>welcome</application>
- <environment>install</environment>
+ <environment>minimal</environment>
</application>
<application>
<name>eis-server</name>
<module>eis_engine</module>
<application>servermanager</application>
- <environment>dev</environment>
+ <environment>minimal</environment>
</application>
<application>
<name>eis-examples</name>
<module>eis_examples</module>
<application>examples</application>
- <environment>dev</environment>
+ <environment>minimal</environment>
</application>
</applications>
Modified: trunk/cfg/environments.xml
===================================================================
--- trunk/cfg/environments.xml 2007-09-11 12:18:06 UTC (rev 205)
+++ trunk/cfg/environments.xml 2007-09-11 16:56:12 UTC (rev 206)
@@ -10,6 +10,14 @@
<mail_errors>off</mail_errors>
</environment>
<environment>
+ <name>minimal</name>
+ <title>EIS Minimal environment</title>
+ <admin>root@localhost</admin>
+
+ <show_errors>on</show_errors>
+ <mail_errors>off</mail_errors>
+ </environment>
+ <environment>
<name>dev</name>
<title>EIS Development environment</title>
<admin>root@localhost</admin>
Added: trunk/lib/base/authservice.lib.php
===================================================================
--- trunk/lib/base/authservice.lib.php (rev 0)
+++ trunk/lib/base/authservice.lib.php 2007-09-11 16:56:12 UTC (rev 206)
@@ -0,0 +1,30 @@
+<?php
+ /**
+ * Base interface class for authentication services.
+ * If a module implements this interface, EIS can use it to authenticate users
+ */
+ class AuthService extends Service {
+
+ /**
+ * Tries to authenticate a user by a login and password
+ *
+ * @param username the user's user name
+ * @param password the cleartext password
+ * @return a dictionary containing:
+ * id (integer), username, (string), displayname (string), permissions (array), preferences (dictionary)
+ */
+ function authByCredentials($username, $password) {
+ }
+ /**
+ * Tries to authenticate a user by a login and an md5 hash of the password and a seed.
+ * The hash is computed as md5(md5(password) . seed)
+ *
+ * @param username the user's user name
+ * @param seed the seed (random string) that the password is concatenated with
+ * @param hash the hash as computed by the client
+ * @return same dictionary as authByCredentials
+ */
+ function authByMD5($username, $seed, $hash) {
+ }
+ }
+?>
Modified: trunk/lib/engine/application.lib.php
===================================================================
--- trunk/lib/engine/application.lib.php 2007-09-11 12:18:06 UTC (rev 205)
+++ trunk/lib/engine/application.lib.php 2007-09-11 16:56:12 UTC (rev 206)
@@ -14,8 +14,10 @@
var $modules = null;
var $title = null;
- var $version = null;
+ var $session_backend = null;
+ var $authentication_backend = null;
+
var $elements = array();
var $page_root = array();
@@ -61,8 +63,11 @@
$app = $struct->getValue($doc,'application');
$this->title = $struct->getValue($app,'title');
- $this->version = $struct->getValue($app,'version');
+ //Backends
+ $this->session_backend = $struct->getValue($app,'session_backend');
+ $this->authentication_backend = $struct->getValue($app,'authentication_backend');
+
//Module configuration
$modules = $struct->getArray($app,'module');
foreach($modules as $module) {
@@ -300,7 +305,8 @@
$cache = "<?php\n";
$cache .= "\$this->modules =".var_export($this->modules, true).";\n";
$cache .= "\$this->title =".var_export($this->title, true).";\n";
- $cache .= "\$this->version =".var_export($this->version, true).";\n";
+ $cache .= "\$this->session_backend =".var_export($this->session_backend, true).";\n";
+ $cache .= "\$this->authentication_backend =".var_export($this->authentication_backend, true).";\n";
$cache .= "\$this->elements =".var_export($this->elements, true).";\n";
$cache .= "\$this->page_root =".var_export($this->page_root, true).";\n";
$cache .= "\$this->page_notfound =".var_export($this->page_notfound, true).";\n";
@@ -317,6 +323,12 @@
function getEnvironment() {
return $this->environment;
}
+ function getSessionBackend() {
+ return $this->session_backend;
+ }
+ function getAuthenticationBackend() {
+ return $this->authentication_backend;
+ }
function getRequiredModules() {
return array_keys($this->modules);
}
Modified: trunk/lib/engine/engine.lib.php
===================================================================
--- trunk/lib/engine/engine.lib.php 2007-09-11 12:18:06 UTC (rev 205)
+++ trunk/lib/engine/engine.lib.php 2007-09-11 16:56:12 UTC (rev 206)
@@ -1,8 +1,6 @@
<?php
- /** \todo Update all href* methods to the new url structure */
-
/**
- * The main engine class
+ * The EIS engine class
*/
class Engine {
@@ -11,10 +9,10 @@
var $services = array(); /**< Loaded services*/
var $currentModule = null; /**< Current rendered element's module */
var $currentElement = null; /**< Current rendered element */
- var $moduleConfig = array(); /**< variable containing array of moduleconfig elements*/
+ var $moduleConfig = array(); /**< Variable containing array of moduleconfig elements*/
/**< ENGINE STATUS VARIABLES */
- var $version = 'svn-trunk'; /**< engine version */
+ var $version = 'svn-trunk'; /**< Engine version */
var $baseHost = ''; /** < Host at which this server is located */
var $basePath = ''; /** < Path at which this server is located */
@@ -29,9 +27,10 @@
var $locale = null; /**< The locale instance */
var $session = null; /**< The session instance */
+ var $user = null; /**< The user instance */
/**
- * Creates the engine object and initializes.
+ * Engine constructor, gathers basic info about the environment.
*/
function Engine() {
@@ -45,70 +44,78 @@
$this->baseHost = $basehost;
$this->basePath = dirname($_SERVER['SCRIPT_NAME']).'/';
}
+
/** @name Private functions
* Private EIS functions
**/
/*@{*/
/**
- * Extracts all neccessary information from the request
+ * Extract all neccessary information from the request
*/
function _initRequest() {
require_once("lib/engine/request.lib.php");
$this->request = new Request($this);
}
/**
- * Initalizes the configuration of the EIS server.
+ * Initialize the configuration of the EIS server.
*/
function _initConfig() {
require_once("lib/engine/config.lib.php");
$this->config = new Config($this);
}
/**
- * Initilizes the engine for a request belonging to a web application
+ * Initialize the engine for a request belonging to a web application
*/
function _initApplication($application) {
require_once("lib/engine/application.lib.php");
+ require_once("lib/base/service.lib.php");
+ require_once("lib/base/authservice.lib.php");
require_once("lib/base/element.lib.php");
$this->application = new Application($this);
$this->application->load($application);
}
/**
- * Initializes the engine for a request belonging to a web service
+ * Initialize the engine for a request belonging to a web service
*/
function _initWebService($webservice) {
require_once("lib/engine/webservice.lib.php");
+ require_once("lib/base/service.lib.php");
$this->webservice = new WebService($this);
$this->webservice->load($webservice);
}
/**
- * Initializes the environment based on the
- * request type and config.
+ * Initialize the environment based on the request type and config.
*/
function _initEnvironment($environment) {
require_once("lib/engine/environment.lib.php");
$this->environment = new Environment($this);
$this->environment->load($environment);
}
-
/**
- * Initializes the locale
+ * Initialize locale
*/
function _initLocale($locale) {
require_once("lib/engine/locale.lib.php");
$this->locale = new Locale($this);
$this->locale->setLocale($locale);
}
-
/**
- *Initialize session
+ * Initialize session
*/
function _initSession() {
require("lib/engine/session.lib.php");
-
$this->session = new Session($this);
$this->session->load();
}
+ /**
+ * Initialize user
+ */
+ function _initUser() {
+ require("lib/engine/user.lib.php");
+ $this->user = new User($this);
+ $this->user->load();
+ }
/**
*Initialize logging
@@ -127,28 +134,6 @@
}
*/
/**
- *Initialize User
- */
- /*
- function _initUser() {
-
- $this->user = new User();
- $this->user->setEngine($this);
-
- //Full user support?
- if($this->databaseEnabled && $this->sessionEnabled) {
- $init = $this->user->init(true);
- $this->userEnabled = true;
- } else {
- $init = $this->user->init(false);
- }
-
- if (!$init)
- $this->error(1030, 'Unable tot initialize user: ' . $this->user->getError());
- }
- */
-
- /**
* Return's the main locale for a module. The main locale is
* the locale in which a module is maintained. Other locales are
* are translations of the main locale.
@@ -220,7 +205,6 @@
* Creates a service instance
*/
function _loadService($module, $service) {
- require_once("lib/base/service.lib.php");
$file = 'mod/'.$module.'/services/'.$service.'.php';
$class = $module.'_'.$service;
@@ -652,8 +636,8 @@
//Initialize the session
$this->_initSession();
- //Initialize user
- //Init user
+ //Initialize the user
+ $this->_initUser();
//Catch errors
ini_set('display_errors',TRUE);
@@ -1027,18 +1011,7 @@
function getPath() {
return $this->request->getPath();
}
- /**
- * Returns the id of the authenticated user or 0 if no user is authenticated
- */
- function getUserId() {
- //TODO
- }
- function getUserPermissions() {
- //TODO
- }
- function getUserPreferences() {
- //TODO
- }
+
function getLocale() {
//TODO: Get this from session/browser/whatever
return 'en_en';
Modified: trunk/lib/engine/session.lib.php
===================================================================
--- trunk/lib/engine/session.lib.php 2007-09-11 12:18:06 UTC (rev 205)
+++ trunk/lib/engine/session.lib.php 2007-09-11 16:56:12 UTC (rev 206)
@@ -14,7 +14,7 @@
var $status; /**< Session status: new, renewed, expired */
var $age; /**< Session age in seconds */
- var $ttlAnonymous = 30; /**< Time to live for anonymous sessions */
+ var $ttlAnonymous = 3600; /**< Time to live for anonymous sessions */
var $ttlAuthenticated = 3600; /**< Time to live for authenticated sessions */
var $storage = 'file'; /**< Where to store the session data. file or database */
@@ -53,6 +53,9 @@
$this->storage = $storage;
}
}
+ function setUid($uid) {
+ //$this->uid = intval($uid);
+ }
function getStatus() {
return $this->status;
Modified: trunk/lib/engine/user.lib.php
===================================================================
--- trunk/lib/engine/user.lib.php 2007-09-11 12:18:06 UTC (rev 205)
+++ trunk/lib/engine/user.lib.php 2007-09-11 16:56:12 UTC (rev 206)
@@ -1,259 +1,197 @@
<?php
/**
- *class which handles the user functions
+ * Class handling authentication and user permissions and preferences.
*/
class User {
- var $id; /**< id unknownk */
- var $engine; /**< engine variable */
+ var $e; /**< Reference to EIS engine */
- var $message; /**< message variable */
- var $errors = array(); /**< array of errors */
+ var $id; /**< User's id */
+ var $username; /**< User's user name */
+ var $displayname; /**< User's display name */
+ var $permissions; /**< User's permission */
+ var $preferences; /**< User's preferences */
- var $user = array(); /**< array of the user */
- var $clearances = array(0); /**< array of clearances for the user */
-
- var $login; /**< variable for the login */
- var $fullName; /**< variable for the fullname of a user */
- var $email; /**< variable for the user e-mail */
-
- var $seed;
-
- var $fullSupport;
-
+ var $error; /**< Error storage for authentication error */
/**
- *Set engine variable
- *@param engine engine reference
+ * Constructor
+ * @param engine A reference to the EIS engine
*/
- function setEngine(&$engine) {
- $this->engine =& $engine;
+ function User(&$engine) {
+ $this->e =& $engine;
+ $this->error = null;
+ $this->_resetUserProperties();
}
/**
- *Initialize user
+ * Resets all user related properties to default values.
*/
- function init($fullSupport = true) {
-
- $this->fullSupport = $fullSupport;
-
- if($fullSupport) {
- // Fetch user id from session
- $this->id = $this->engine->session->getUid();
- $this->seed =& $this->engine->session->getReference('login_seed','engine');
-
- if($this->id > 0) {
- $sUser = $this->engine->getService('user');
-
- //Load clearance
- $this->clearances = $sUser->getClearancesByUserId($this->id);
-
- //Load user
- $user = $sUser->getUserById($this->id);
- if($user != null) {
- $this->user = $user;
- $this->login = $user['login_username'];
- $this->fullName = $user['out_name'];
- $this->email = $user['out_email'];
- return true;
- }
- }
- }
-
- $this->id = 4;
- $this->login = "guest";
- $this->fullName = "Guest Account";
- $this->email = null;
- $this->clearances = array(0,4);
-
- return true;
+ function _resetUserProperties() {
+ $this->id = 0;
+ $this->username = '';
+ $this->displayname = 'Anonymous';
+ $this->permissions = array();
+ $this->preferences = array();
}
/**
- *Set message variable
- *@param msg message variable
+ * Sets user related properties based on the user object
+ *
+ * @param user the user object returned by the authentication service
*/
- function _setMessage($msg) {
- $this->message = $msg;
+ function _setUserProperties($user) {
+ $this->id = $user['id'];
+ $this->username = $user['username'];
+ $this->displayname = $user['displayname'];
+ $this->permissions = $user['permissions'];
+ $this->preferences = $user['preferences'];
}
/**
- *Get message from message variable
- *@result message
+ * Checks if the authentication service returned a valid user
+ * and stores it in the session when possible.
+ *
+ * @param user the user object returned by the authentication service
+ * @param error the error object returned by the authentication service
*/
- function getMessage() {
- return $this->message;
+ function _login($user, $error) {
+ if(is_array($user)) {
+ $this->_setUserProperties($user);
+ if($this->e->session !== null) {
+ $this->e->session->set('user',$user,'engine');
+ $this->e->session->setUid($user['id']);
+ $this->e->session->save();
+ return $user['id'];
+ }
+ return 0;
+ } else {
+ $this->error = $error;
+ return 0;
+ }
}
/**
- *Adds error to error array and warning to logfile
- *@param the errormessage to be added
+ * Checks if a user is logged in and loads details when this is the case.
*/
- function _addError($msg) {
- $this->errors[] = $msg;
- $this->engine->log->addWarning('USER-ERROR '.$msg,'user');
+ function load() {
+ //Check the session for a login
+ if($this->e->session !== null) {
+ $user = $this->e->session->get('user','engine');
+ if(is_array($user)) {
+ $this->_setUserProperties($user);
+ return;
+ }
+ }
}
/**
- *Get error from error array
- *@result array containing errors
+ * Login a user based on their username and password.
+ *
+ * @param username the user's username
+ * @param password the users's password
+ * @return the uid of the user (integer) or 0 when the login failed.
*/
- function getError() {
- return $this->errors;
+ function loginByCredentials($username, $password) {
+ $backend = $this->e->application->getAuthenticationBackend();
+ if(!is_array($backend)) {
+ return 0;
+ }
+ $service =& $this->e->getService($backend['module'],$backend['service']);
+
+ $user = $service->authByCredentials($username, $password);
+ $error = $service->getError();
+
+ return $this->_login($user,$error);
}
/**
- *Get Id from Id variable
- *@result variable containing an Id
+ * Log in a user based on their username and a hash of their password with a seed.
+ * The hash should be calculated as hash = md5(md5(password).seed)
+ *
+ * @param username the user's username
+ * @param seed the seed that was used for hashing the password
+ * @param hash the hash calculated from the password and seed
+ * @return the uid of the user (integer) or 0 when the login failed.
*/
- function getId() {
- return $this->id;
+ function loginByMD5($username, $seed, $hash) {
+ $backend = $this->e->application->getAuthenticationBackend();
+ if(!is_array($backend)) {
+ return 0;
+ }
+ $service =& $this->e->getService($backend['module'],$backend['service']);
+
+ $user = $service->authByMD5($username, $seed, $hash);
+ $error = $service->getError();
+
+ return $this->_login($user,$error);
}
/**
- *Get login variable
- *@result variable containing login
+ * Resets the user related properties and removes the user from the session
*/
- function getLogin() {
- return $this->login;
+ function logout() {
+ $this->_resetUserProperties();
+ if($this->e->session !== null) {
+ $this->e->session->clear('user','engine');
+ $this->e->session->setUid(0);
+ $this->e->session->save();
+ }
}
/**
- *Get Full name of user
- *@result full name of a user
+ * Get the error as returned by the authentication service
+ * @return an error datastructure as returned by services.
*/
- function getFullName() {
- return $this->fullName;
+ function getError() {
+ return $this->error;
}
/**
- *Get Clearances
- *@result variable containing clearances
+ * Get id variable
+ * @return user id
*/
- function getClearances() {
- return $this->clearances;
+ function getId() {
+ return $this->id;
}
/**
- *Determine if Clearance by zone
- *@param zone the zone for which clearance has to be retrieved
- *@result true or false
+ * Get username variable
+ * @return username
*/
- function hasClearance($zone) {
- return in_array($zone, $this->clearances);
+ function getUserName() {
+ return $this->username;
}
/**
- *Key generator
- *@result a random genrated key
+ * Get displayname variable
+ * @return displayname
*/
- function generateKey() {
- $chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
- $key = "";
-
- for ($i = 0; $i < 32; $i++) {
- $key = $key . substr($chars, rand(0, 62), 1);
- }
-
- return $key;
+ function getDisplayName() {
+ return $this->displayname;
}
/**
- *Get login seed
- *@result returns variable containing seed
- */
- function getLoginSeed() {
-
- $seed = $this->generateKey();
-
- //Store pre-hashed version of seed
- $this->seed = md5($seed);
- $this->engine->session->save();
-
- return $seed;
+ * Get permissions
+ * @return an array of permission identifiers
+ */
+ function getPermissions() {
+ return $this->permissions;
}
-
/**
- *Log in as User
- *@param username string containing user'susername
- *@param password string containing user's password
- *@param hashed bool is true or false
- *@result user Id on succes or 0 on failure
- */
- function logIn($username, $password, $hashed = true) {
-
- if(!$this->fullSupport)
- return 0;
-
- //Load service
- $sUser = $this->engine->getService('user');
-
- //Try login
- if($hashed)
- $uid = $sUser->getUidByLogin($username, $password, $this->seed);
- else
- $uid = $sUser->getUidByLogin($username, $password, null);
-
- //Chech user
- if($uid == 0) {
- $errors = $sUser->getErrors();
- foreach($errors as $error)
- $this->_addError($error);
-
- $this->_setMessage('auth_failed');
- return 0;
- }
-
- //Init with verified user id
- $this->engine->session->setUid($uid);
- $this->init();
-
- //Set session variable 'me' indicating the authenticated user
- //for use with user module elements.
- $me =& $this->engine->session->getReference('me','module','user');
- $me = $uid;
-
- //Set session variable 'user.me' for general use. Nu skool :)
- $this->engine->session->setValue('user.me',$uid);
-
- $this->engine->session->save();
-
- //Log login action
- $this->engine->log->addMessage('LOGIN '.$this->getFullName(),'user');
-
- return $uid;
+ * Check if a given permission is available
+ * @param permission the required permission
+ * @return true when the user has the permission, false otherwise
+ */
+ function hasPermission($permission) {
+ return in_array($permission, $this->permissions);
}
/**
- *Log in via user Id and not username and password
- *@param id variable containing integer of user Id
- *@result the user Id
+ * Get preferences
+ * @return a dictionary with preference values
*/
- function loginByUserId($id) {
-
- if(!$this->fullSupport)
- return 0;
-
- $this->engine->session->setUid($id);
- $this->init();
-
- $me =& $this->engine->session->getReference('me','module','user');
- $me = $id;
- $this->engine->session->save();
-
- return $id;
+ function getPreferences() {
+ return $this->preferences;
}
/**
- *Log out
- *result user id on succes or 0 on failure
+ * Get the value of a preference
+ * @param default a default value that is returned when the preference is not set for this user.
+ * @return the value of the preference.
*/
- function logOut() {
-
- if(!$this->fullSupport)
- return 0;
-
- //Log logout action
- $this->engine->log->addMessage('LOGOUT '.$this->getFullName(),'user');
-
- $this->engine->session->setUid(0);
- $this->engine->session->clear();
-
- if (! $this->engine->session->save()) {
- $this->_addError("Unable to reset user ID: could not save session");
- return 0;
+ function getPreference($preference, $default = null) {
+ if(isset($this->preferences[$preference])) {
+ return $this->preferences[$preference];
+ } else {
+ return $default;
}
-
- //Reinitialize user
- $this->init();
-
- return $this->id;
}
}
?>
Modified: trunk/mod/eis_engine/applications/servermanager.xml
===================================================================
--- trunk/mod/eis_engine/applications/servermanager.xml 2007-09-11 12:18:06 UTC (rev 205)
+++ trunk/mod/eis_engine/applications/servermanager.xml 2007-09-11 16:56:12 UTC (rev 206)
@@ -1,8 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<application>
<title>EIS Server Manager</title>
- <version>0.1</version>
+ <authentication_backend>
+ <module>eis_engine</module>
+ <service>AuthService</service>
+ </authentication_backend>
+
+ <session_backend>
+ <module>eis_session</module>
+ <service>FileStoreSessionService</service>
+ </session_backend>
+
<page_root>
<meta><name>menu-entry</name><value>eis_engine.l.home</value></meta>
<element>
Modified: trunk/mod/eis_engine/config/module.php
===================================================================
--- trunk/mod/eis_engine/config/module.php 2007-09-11 12:18:06 UTC (rev 205)
+++ trunk/mod/eis_engine/config/module.php 2007-09-11 16:56:12 UTC (rev 206)
@@ -1,4 +1,6 @@
<?php
+ $cfg['admin_password'] = 'eisroxx';
+
$cfg['redirect_404'] = null;
$cfg['redirect_403'] = null;
Added: trunk/mod/eis_engine/services/AuthService.php
===================================================================
--- trunk/mod/eis_engine/services/AuthService.php (rev 0)
+++ trunk/mod/eis_engine/services/AuthService.php 2007-09-11 16:56:12 UTC (rev 206)
@@ -0,0 +1,37 @@
+<?php
+ class eis_engine_AuthService extends AuthService {
+
+ /**
+ * Implementation of the authByCredentials interface of AuthService
+ */
+ function authByCredentials($username, $password) {
+ if($username == 'admin' && $password == $this->mc['admin_password']) {
+ return $this->_getAdminUser();
+ } else {
+ return null;
+ }
+ }
+ /**
+ * Implementation of the authByMD5 interface of AuthService
+ */
+ function authByMD5($username, $seed, $hash) {
+ if($username == 'admin' && md5(md5($this->mc['admin_password']).$seed) == $hash) {
+ return $this->_getAdminUser();
+ } else {
+ return null;
+ }
+ }
+ /**
+ * Returns a hardcoded record for the administrator user
+ */
+ function _getAdminUser() {
+ return array(
+ 'id' => 1,
+ 'username' => 'admin',
+ 'displayname' => 'Administrator',
+ 'permissions' => array('eis_engine.administrator'),
+ 'preferences' => array()
+ );
+ }
+ }
+?>
Deleted: trunk/mod/eis_user/Service.php
===================================================================
--- trunk/mod/eis_user/Service.php 2007-09-11 12:18:06 UTC (rev 205)
+++ trunk/mod/eis_user/Service.php 2007-09-11 16:56:12 UTC (rev 206)
@@ -1,901 +0,0 @@
-<?php
- /**
- * @defgroup elements_user Elements
- * @ingroup user
- */
-
- /** @defgroup user User
- * User module handles all functions and operations related to users
- * @{*/
-
- class Service_user extends Service {
-
- function getUidByLogin($username, $password, $seed = null ) {
-
- $sql = "SELECT id, login_active FROM user_users ";
- $sql .= "WHERE login_username = '".addslashes($username)."'";
-
- if($seed == null) {
- switch($this->moduleConfig['password_type']) {
- case 'plain':
- $sql .= " AND login_password = '".addslashes($password)."'";
- break;
- case 'md5':
- default:
- $sql .= " AND login_password = '".md5($password)."'";
- break;
- }
- } else {
- $sql .= " AND MD5(CONCAT('".addslashes($seed)."',login_password)) = '".addslashes($password)."'";
- }
-
- $sql .= " AND deleted = 0 ";
-
- $db = new Database();
- $db->setSql($sql);
- $db->query();
-
- $num = $db->getNumRows();
-
- if($num == 0) {
- $this->errors[] = 'error_login_notfound';
- return 0;
- }
- if($num > 1) {
- $this->errors[] = 'error_login_multiplefound';
- return 0;
- }
-
- $row = $db->fetchArray();
-
- if(!$row['login_active']) {
-
- $this->errors[] = 'error_login_inactive';
- return 0;
- } else {
- return $row['id'];
- }
- }
-
- // verifyObject
- function verifyUser($obj) {
-
- if(!isset($obj['type']) || $obj['type'] == null) {
- $this->errors = array('error_unknown_usertype');
- return false;
- }
-
- switch($obj['type']) {
- case 'person':
- return $this->verifyPerson($obj);
- case 'company':
- return $this->verifyCompany($obj);
- case 'group':
- return $this->verifyGroup($obj);
- default:
- $this->errors = array('error_illegal_usertype');
- return false;
- }
- }
-
- function verifyPerson($obj) {
-
- $errors = array();
-
- //Check name
- $name = false;
- if(isset($obj['name_first']) && $obj['name_first'] != '')
- $name = true;
- else if(isset($obj['name_last']) && $obj['name_last'] != '')
- $name = true;
-
- if(!$name)
- $errors[] = 'error_missing_name';
-
- //Check duplicate reference
- if(isset($obj['misc_reference']) && $obj['misc_reference'] != null) {
- $criteria = array();
- $criteria['matches']['!id'] = intval($obj['id']);
- $criteria['matches']['misc_reference'] = $obj['misc_reference'];
- if($this->getNumUsers($criteria))
- $errors[] = 'error_duplicate_reference';
- }
-
- //Check duplicate loginnames
- if(isset($obj['login_username']) && $obj['login_username'] != null) {
- $criteria = array();
- $criteria['matches']['!id'] = intval($obj['id']);
- $criteria['matches']['login_username'] = $obj['login_username'];
- if($this->getNumUsers($criteria))
- $errors[] = 'error_duplicate_username';
- }
-
- //Check if username and password are set for active accounts
- if(isset($obj['login_active']) && $obj['login_active']) {
- if(
- isset($obj['login_username']) &&
- $obj['login_username'] != '' &&
- isset($obj['login_password']) &&
- $obj['login_password']
- ) {} else {
- $errors[] = 'error_missing_accountinfo';
- }
- }
-
- if(isset($obj['in_password1']) || isset($obj['in_password2'])) {
- if($obj['in_password1'] != $obj['in_password2'])
- $errors[] = 'error_password_mismatch';
- }
-
- if(count($errors)) {
- $this->errors = $errors;
- return false;
- }
-
- return true;
- }
-
- function verifyCompany($obj) {
- if(!isset($obj['name_first']) || $obj['name_first'] == '') {
- $errors[] = 'error_missing_name';
- }
-
- //Check duplicate reference
- if(isset($obj['misc_reference']) && $obj['misc_reference'] != null) {
- $criteria = array();
- $criteria['matches']['!id'] = intval($obj['id']);
- $criteria['matches']['misc_reference'] = $obj['misc_reference'];
- if($this->getNumUsers($criteria))
- $errors[] = 'error_duplicate_reference';
- }
-
- if(count($errors)) {
- $this->errors = $errors;
- return false;
- }
-
- return true;
- }
-
- function verifyGroup($obj) {
- if(!isset($obj['name_first']) || $obj['name_first'] == '') {
- $errors[] = 'error_missing_name';
- }
-
- //Check duplicate reference
- if(isset($obj['misc_reference']) && $obj['misc_reference'] != null) {
- $criteria = array();
- $criteria['matches']['!id'] = intval($obj['id']);
- $criteria['matches']['misc_reference'] = $obj['misc_reference'];
- if($this->getNumUsers($criteria))
- $errors[] = 'error_duplicate_reference';
- }
-
- if(count($errors)) {
- $this->errors = $errors;
- return false;
- }
- return true;
- }
-
- // createObject
- function createPerson($obj) {
-
- $obj = $this->dynInPerson($obj);
-
- if(!$this->verifyPerson($obj))
- return 0;
-
- return $this->createObject('user_users',$obj);
- }
-
- function createCompany($obj) {
-
- $obj = $this->dynInCompany($obj);
-
- if(!$this->verifyCompany($obj))
- return 0;
-
- return $this->createObject('user_users',$obj);
- }
-
- function createGroup($obj) {
-
- $obj = $this->dynInGroup($obj);
-
- if(!$this->verifyGroup($obj))
- return 0;
-
- return $this->createObject('user_users',$obj);
- }
-
- // updateObject
-
- function updatePerson($obj) {
-
- if(!$this->verifyPerson($obj))
- return 0;
-
- $obj = $this->dynInPerson($obj);
-
- if(!$this->_onUpdatePerson($obj))
- return 0;
-
- return $this->updateObject('user_users',$obj);
- }
-
- function updateCompany($obj) {
-
- if(!$this->verifyCompany($obj))
- return 0;
-
- $obj = $this->dynInCompany($obj);
-
- if(!$this->_onUpdateCompany($obj))
- return 0;
-
- return $this->updateObject('user_users',$obj);
- }
-
- function updateGroup($obj) {
-
- if(!$this->verifyGroup($obj))
- return 0;
-
- $obj = $this->dynInGroup($obj);
-
- if(!$this->_onUpdateGroup($obj))
- return 0;
-
- return $this->updateObject('user_users',$obj);
- }
-
- // deleteObject
-
- function deletePerson($obj) {
-
- if(!$this->_onDeletePerson($obj))
- return 0;
-
- return $this->deleteObject('user_users', $obj);
- }
-
- function deleteCompany($obj) {
-
- if(!$this->_onDeleteCompany($obj))
- return 0;
-
- return $this->deleteObject('user_users', $obj);
- }
-
- function deleteGroup($obj) {
-
- if(!$this->_onDeletePerson($obj))
- return 0;
-
- return $this->deleteObject('user_users', $obj);
- }
-
- // getDefaultObject
- function getDefaultUser() {
- return $this->getDefaultObject('user_users');
- }
-
- // getObjectById
- function getUserById($id) {
-
- $obj = $this->getObjectById('user_users', $id);
-
- if($obj == null)
- return null;
-
- switch($obj['type']) {
- case 'person': return $this->dynOutPerson($obj); break;
- case 'company': return $this->dynOutCompany($obj); break;
- case 'group': return $this->dynOutGroup($obj); break;
- }
- }
-
- function getPersonById($id) {
-
- $obj = $this->getObjectById('user_users', $id);
-
- if($obj == null)
- return null;
-
- return $this->dynOutPerson($obj);
- }
-
- function getCompanyById($id) {
-
- $obj = $this->getObjectById('user_users', $id);
-
- if($obj == null)
- return null;
-
- return $this->dynOutCompany($obj);
- }
-
- function getGroupById($id) {
-
- $obj = $this->getObjectById('user_users', $id);
-
- if($obj == null)
- return null;
-
- return $this->dynOutGroup($obj);
- }
-
- // getObjects
- function getUsers($criteria = array()) {
-
- $objs = $this->getObjects('user_users', $criteria);
-
- foreach($objs as $i => $obj) {
- switch($obj['type']) {
- case 'person': $objs[$i] = $this->dynOutPerson($obj); break;
- case 'company': $objs[$i] = $this->dynOutCompany($obj); break;
- case 'group': $objs[$i] = $this->dynOutGroup($obj); break;
- }
- }
-
- return $objs;
- }
-
- function getPersons($criteria = array()) {
-
- $criteria['matches']['type'] = 'person';
-
- $objs = $this->getObjects('user_users', $criteria);
-
- foreach($objs as $i => $obj)
- $objs[$i] = $this->dynOutPerson($obj);
-
- return $objs;
- }
-
- function getCompanies($criteria = array()) {
-
- $criteria['matches']['type'] = 'company';
-
- $objs = $this->getObjects('user_users', $criteria);
-
- foreach($objs as $i => $obj)
- $objs[$i] = $this->dynOutCompany($obj);
-
- return $objs;
- }
-
- function getGroups($criteria = array()) {
-
- $criteria['matches']['type'] = 'group';
-
- $objs = $this->getObjects('user_users', $criteria);
-
- foreach($objs as $i => $obj)
- $objs[$i] = $this->dynOutGroup($obj);
-
- return $objs;
- }
-
- // getNumObjects
-
- function getNumUsers($criteria = array()) {
-
- return $this->getNumObjects('user_users',$criteria);
- }
-
- function getNumPersons($criteria = array()) {
-
- $criteria['matches']['type'] = 'person';
-
- return $this->getNumObjects('user_users',$criteria);
- }
-
- function getNumCompanies($criteria = array()) {
-
- $criteria['matches']['type'] = 'company';
-
- return $this->getNumObjects('user_users',$criteria);
- }
-
- function getNumGroups($criteria = array()) {
-
- $criteria['matches']['type'] = 'group';
-
- return $this->getNumObjects('user_users',$criteria);
- }
-
- // Special getObjects
-
- function getUsersByUsername($username) {
- $criteria['only_readable'] = false;
- $criteria['matches']['login_username'] = $username;
-
- return $this->getUsers($criteria);
- }
-
- function getUsersByReference($reference) {
- $criteria['matches']['misc_reference'] = $reference;
-
- return $this->getUsers($criteria);
- }
-
- function getUsersByGroupId($groupId, $criteria = array(), $inverse = false) {
-
- if($inverse) {
- //Getting the inverse list of users requires 2 queries.
- //It would be nice if it could be done with a join in one query.
- $ids = array();
- $users = $this->getUsersByGroupId($groupId,array('fields' => array('id')));
- foreach($users as $user)
- $ids[] = $user['id'];
-
- $criteria['matches']['!id'] = $ids;
- return $this->getUsers($criteria);
- }
-
- $sql = "SELECT u.* FROM user_memberships AS m LEFT JOIN user_users AS u ON (m.user = u.id)";
- $sql .= " WHERE m.group = ".intval($groupId)." AND m.deleted = 0";
-
- if($where = $this->makeCriteriaWhere($criteria,'u')) {
- $sql .= " AND ".$where;
- }
-
- $sql .= $this->makeCriteriaResultSpec($criteria);
-
- $db = new Database();
- $db->setSql($sql);
-
- $users = array();
- while($row = $db->fetchArray()) {
- switch($row['type']) {
- case 'person': $users[] = $this->dynOutPerson($row); break;
- case 'company': $users[] = $this->dynOutCompany($row); break;
- }
- }
-
- return $users;
- }
-
- function getGroupsByUserId($userId, $criteria = array(), $inverse = false) {
-
- if($inverse) {
- //Getting the inverse list of groups requires 2 queries.
- //It would be nice if it could be done with a join in one query.
- $ids = array();
- $groups = $this->getGroupsByUserId($userId,array('fields' => array('id')));
- foreach($groups as $group)
- $ids[] = $group['id'];
-
- $criteria['matches']['!id'] = $ids;
- return $this->getGroups($criteria);
- }
-
- $sql = "SELECT u.* FROM user_memberships AS m LEFT JOIN user_users AS u ON ";
- $sql .= "(m.group = u.id) ";
- $sql .= "WHERE m.user = ".intval($userId)." AND m.deleted = 0";
-
- if($where = $this->makeCriteriaWhere($criteria,'u')) {
- $sql .= " AND ".$where;
- }
-
- $sql .= $this->makeCriteriaResultSpec($criteria);
-
- $db = new Database();
- $db->setSql($sql);
-
- $groups = array();
- while($row = $db->fetchArray()) {
- $groups[] = $this->dynOutGroup($row);
- }
-
- return $groups;
- }
-
- //Special getNumObjects
-
- function getNumUsersByGroupId($groupId, $criteria = array(),$inverse = false) {
-
- $sql = "SELECT COUNT(*) FROM user_memberships AS m LEFT JOIN user_users AS u ON (m.user = u.id)";
- $sql .= " WHERE m.group = ".intval($groupId)." AND m.deleted = 0";
-
- if($where = $this->makeCriteriaWhere($criteria,'u')) {
- $sql .= " AND ".$where;
- }
-
- $db = new Database();
- $db->setSql($sql);
-
- $row = $db->fetchRow();
-
- return $row[0];
- }
-
- function getNumGroupsByUserId($userId, $criteria = array(), $inverse = false) {
-
- if($inverse) {
- $ids = array();
- $groups = $this->getGroupsByUserId($userId,array('fields' => array('id')));
- foreach($groups as $group)
- $ids[] = $group['id'];
-
- $criteria['matches']['!id'] = $ids;
-
- return $this->getNumGroups($criteria);
- }
-
- $criteria['matches']['type'] = 'group';
-
- $sql = "SELECT COUNT(*) FROM user_memberships AS m LEFT JOIN user_users AS u ON (m.user = u.id)";
- $sql .= " WHERE m.user = ".intval($userId)." AND m.deleted = 0";
-
- if($where = $this->makeCriteriaWhere($criteria,'u')) {
- $sql .= " AND ".$where;
- }
-
- $db = new Database();
- $db->setSql($sql);
-
- $row = $db->fetchRow();
-
- return $row[0];
- }
-
- // Dynamic input
-
- function dynInPerson($obj) {
-
- //Split in_name
- if(isset($obj['in_name'])) {
- if($obj['type'] == 'person') {
- $name = array();
- $parts = explode(' ',$obj['in_name']);
-
- foreach($parts as $part) {
- $part = trim($part);
- if($part != '')
- $name[] = $part;
- }
- if(count($name)) {
- $obj['name_first'] = array_shift($name);
- if(count($name)) {
- $obj['name_last'] = array_pop($name);
- }
- if(count($name)) {
- $obj['name_prefix'] = implode(' ',$name);
- }
- }
- } else {
- $obj['name_first'] = $obj['in_name'];
- }
- }
-
- //Password
- if(isset($obj['in_password1']) && isset($obj['in_password2'])) {
- if($this->moduleConfig['password_type'] == 'md5')
- $obj['login_password'] = md5($obj['in_password1']);
- else
- $obj['login_password'] = $obj['in_password1'];
- }
- return $obj;
- }
-
- function dynInCompany($obj) {
- return $obj;
- }
-
- function dynInGroup($obj) {
- return $obj;
- }
-
-
- function dynOutPerson($obj) {
- $obj['out_name'] = $this->_makeUserName($obj);
- $obj['out_address'] = $this->_makeUserAddress($obj);
- $obj['out_email'] = $this->_makeUserEmail($obj);
- $obj['out_phone'] = $this->_makeUserPhone($obj);
- return $obj;
- }
-
- function dynOutCompany($obj) {
- $obj['out_name'] = $this->_makeUserName($obj);
- $obj['out_address'] = $this->_makeUserAddress($obj);
- $obj['out_mail_address'] = $this->_makeUserMailAddress($obj);
- $obj['out_email'] = $this->_makeUserEmail($obj);
- $obj['out_phone'] = $this->_makeUserPhone($obj);
- return $obj;
- }
-
- function dynOutGroup($obj) {
- $obj['out_name'] = $this->_makeUserName($obj);
- return $obj;
- }
-
- // Signup / activation methods
-
- function signupUser($obj) {
-
- //Check Email, Username & Password
- $errors = array();
- if($obj['email1_address'] == '')
- $errors[] = 'error_missing_email';
- if($obj['login_username'] == '')
- $errors[] = 'error_missing_username';
- if($obj['login_password'] == '')
- $errors[] = 'error_missing_password';
-
- if(count($errors)) {
- $this->errors = $errors;
- return 0;
- }
-
- //Create user
- if(! $id = $this->createPerson($obj))
- return 0;
-
- //Send activation email
- $code = $this->getActivationCodeByUserId($id);
-
- $from = $this->moduleConfig['email_signup_from'];
- $subject = $this->moduleConfig['email_signup_subject'];
-
- $body = implode('',file($this->moduleConfig['email_signup_body']));
- $body = str_replace('{NAME}',$obj['in_name'],$body);
- $body = str_replace('{USERNAME}',$obj['login_username'],$body);
- $body = str_replace('{PASSWORD}',$obj['login_password'],$body);
- $body = str_replace('{CODE}',$code,$body);
-
- $activationlink = $this->e->request['baseUrl'];
- $activationlink .= $this->e->hrefPage($this->moduleConfig['pages_signup_activate']);
- $activationlink .= '&username='.urlencode($obj['login_username']).'&activationcode='.urlencode($code);
-
- $body = str_replace('{ACTIVATIONLINK}',$activationlink,$body);
-
- $m = new Email();
-
- $m->setFrom($from);
- $m->setSubject($subject);
- $m->setMsg($body);
-
- $m->addTo($obj['email1_address']);
-
- $m->send();
-
- return $id;
- }
-
- function getActivationCodeByUserId($id) {
-
- $code = substr(md5(rand(time(), time() -1000)),12,10);
-
- $obj = array();
- $obj['id'] = $id;
- $obj['login_activationcode'] = $code;
-
- $this->updateUser($obj);
-
- return $code;
- }
-
- function activateUserAccount($username, $activationcode) {
-
- $criteria['matches']['login_username'] = $username;
- $criteria['matches']['login_activationcode'] = $activationcode;
-
- $users = $this->getUsers($criteria);
-
- if(count($users) == 1) {
-
-
- $user = $users[0];
- $userId = $user['id'];
-
- $user['login_active'] = 1;
- $user['login_activationcode'] = null;
-
- if(!$this->updateUser($user)) {
- $this->errors = array('error_activation_failed');
- return 0;
- }
-
- //Automatic addition to groups
- if(is_array($this->moduleConfig['user_activation_initial_groups'])) {
- foreach($this->moduleConfig['user_activation_initial_groups'] as $groupId) {
- $this->addGroupMember($groupId,$userId);
- }
- }
-
- //Automatic login after activation
- if($this->moduleConfig['user_activation_autologin']) {
- $this->e->user->loginByUserId($userId);
- }
-
- } else {
- $this->errors = array('error_activation_failed');
- return 0;
- }
- }
-
-
- // Clearance method
-
- function getClearancesByUserId($id) {
-
- $clearances = array();
- $clearances[] = 0;
- $clearances[] = $id;
-
- $criteria['matches']['user'] = $id;
- $criteria['matches']['group_type'] = 'group';
-
- $objs = $this->getObjects('user_memberships',$criteria);
-
- foreach($objs as $obj)
- $clearances[] = $obj['group'];
-
- return $clearances;
- }
-
- // Group management methods
-
- function addGroupMember($groupId, $userId) {
- if($this->isGroupMember($groupId, $userId))
- return 0;
-
- //Get types
- $criteria['matches']['id'] = array($groupId, $userId);
- $criteria['index'] = 'id';
- $criteria['fields'] = array('type');
- $objs = $this->getUsers($criteria);
-
- if(count($objs) != 2)
- return 0;
-
- //Create membership
- $membership = array();
- $membership['user'] = $userId;
- $membership['user_type'] = $objs[$userId]['type'];
- $membership['group'] = $groupId;
- $membership['group_type'] = $objs[$groupId]['type'];
-
- if($this->createObject('user_memberships', $membership))
- return $userId;
- else
- return 0;
- }
-
- function removeGroupMember($groupId, $userId) {
-
- //Find membership
- $criteria['matches']['group'] = $groupId;
- $criteria['matches']['user'] = $userId;
-
- $objs = $this->getObjects('user_memberships',$criteria);
-
- //Remove membership
- if(count($objs)) {
- if($this->deleteObject('user_memberships',$objs[0]))
- return $groupId;
- else
- return 0;
- } else {
- return 0;
- }
- }
-
- function isGroupMember($groupId, $userId) {
-
- $criteria['matches']['group'] = $groupId;
- $criteria['matches']['user'] = $userId;
-
- $num = $this->getNumObjects('user_memberships',$criteria);
-
- if($num > 0)
- return true;
- else
- return false;
- }
-
- // Dynamic output
-
- /**@name Private User module function
- *@{**/
- function _makeUserName($obj) {
- $name = array();
- if(isset($obj['name_first']) && $obj['name_first'] != '') $name[] = $obj['name_first'];
- if(isset($obj['name_prefix']) && $obj['name_prefix'] != '') $name[] = $obj['name_prefix'];
- if(isset($obj['name_last']) && $obj['name_last'] != '') $name[] = $obj['name_last'];
-
- return implode(' ',$name);
- }
-
- function _makeUserAddress($obj) {
- if(isset($obj['addr_address']) && isset($obj['addr_address']) && isset($obj['addr_city'])) {
- $addr = $obj['addr_address']."\n";
- $addr .= $obj['addr_pcode'].' '.$obj['addr_city']."\n";
-
- return $addr;
- } else {
- return '';
- }
- }
- function _makeUserMailAddress($obj) {
- if(isset($obj['addr_mail_address']) && isset($obj['addr_mail_address']) && isset($obj['addr_mail_city'])) {
- $addr = $obj['addr_mail_address']."\n";
- $addr .= $obj['addr_mail_pcode'].' '.$obj['addr_mail_city']."\n";
-
- return $addr;
- } else {
- return '';
- }
- }
-
- function _makeUserEmail($obj) {
- if(isset($obj['email_work']) && $obj['email_work'] != '')
- return $obj['email_work'];
- if(isset($obj['email_home']) && $obj['email_home'] != '')
- return $obj['email_home'];
-
- return null;
- }
-
- function _makeUserPhone($obj) {
- if(isset($obj['phone_work']) && $obj['phone_work'] != '')
- return $obj['phone_work'];
- if(isset($obj['phone_mobile']) && $obj['phone_mobile'] != '')
- return $obj['phone_mobile'];
- if(isset($obj['phone_home']) && $obj['phone_home'] != '')
- return $obj['phone_home'];
-
- return null;
- }
-
- // Event handlers
-
- function _onCreatePerson($obj) {
- return 1;
- }
- function _onCreateCompany($obj) {
- return 1;
- }
- function _onCreateGroup($obj) {
- return 1;
- }
-
- function _onUpdatePerson($obj) {
- return 1;
- }
- function _onUpdateCompany($obj) {
- return 1;
- }
- function _onUpdateGroup($obj) {
- return 1;
- }
-
- function _onDeletePerson($obj) {
-
- //Delete memberships
- if(!$this->deleteObjectsByField('user_memberships','user',intval($obj['id'])))
- return 0;
-
- return 1;
- }
- function _onDeleteCompany($obj) {
- //Delete memberships
- if(!$this->deleteObjectsByField('user_memberships','user',intval($obj['id'])))
- return 0;
-
- return 1;
- }
- function _onDeleteGroup($obj) {
- //Delete memberships
- if(!$this->deleteObjectsByField('user_memberships','group',intval($obj['id'])))
- return 0;
-
- return 1;
- }
- /**@}*/
- }
- /** @} */
-?>
Deleted: trunk/mod/eis_user/elements/ActivateUser.php
===================================================================
--- trunk/mod/eis_user/elements/ActivateUser.php 2007-09-11 12:18:06 UTC (rev 205)
+++ trunk/mod/eis_user/elements/ActivateUser.php 2007-09-11 16:56:12 UTC (rev 206)
@@ -1,45 +0,0 @@
-<?php
- /**
- *@ingroup elements_user
- *@{
- */
- /** Element to activate a user account with an activation code*/
- class user_ActivateUser extends Element {
-
- function view_default() {
-
- $sWidget =& $this->e->getService('widget');
-
- $t = new Template();
- $t->assign('MAIN','main.tpl');
-
- $defaults = array('username'=>'','activationcode'=>'');
- $fields = $this->getFields($defaults);
-
- //Fill form
- $t->addkey('_ACTION',$this->e->hrefAction('activate'));
-
- $t->addkey('_USERNAME',$sWidget->inputString('username',$fields['username']));
- $t->addkey('_ACTIVATIONCODE',$sWidget->inputString('activationcode',$fields['activationcode']));
-
- $t->addkey('_ACTIVATE',$sWidget->buttonSubmit('Activate'));
-
- $t->parse('OUT','MAIN');
- $t->show('OUT');
- }
-
- function action_activate($data) {
-
- $sUser =& $this->e->getService('user');
-
- if($sUser->activateUserAccount($data['username'],$data['activationcode'])) {
- if($this->elementConfig['page_next'] != null)
- $this->e->redirect($this->e->hrefPage($this->elementConfig['page_next']));
- } else {
- $this->setFields($data);
- $this->setError($sUser->getErrors());
- }
- }
- }
- /**@}*/
-?>
Deleted: trunk/mod/eis_user/elements/AddToGroup.php
===================================================================
--- trunk/mod/eis_user/elements/AddToGroup.php 2007-09-11 12:18:06 UTC (rev 205)
+++ trunk/mod/eis_user/elements/AddToGroup.php 2007-09-11 16:56:12 UTC (rev 206)
@@ -1,111 +0,0 @@
-<?php
- /**
- *@ingroup elements_user
- *@{
- */
- /** Element to add a user to a group*/
- class user_AddToGroup extends Element {
-
- function view_default() {
-
- $type = $this->elementConfig['type'];
-
- $sUser =& $this->e->getService('user');
- $sWidget =& $this->e->getService('widget');
-
-
- $user_var = $this->elementConfig['user_var'];
- $user_id =& $this->e->session->getReference($user_var,'site');
- $group_var = $this->elementConfig['group_var'];
- $group_id =& $this->e->session->getReference($group_var,'site');
-
- $options = array();
-
- $criteria = array();
- $criteria['only_writable'] = true;
- $criteria['matches']['type'] = $type;
-
- //Load users/groups
- switch($type) {
- case 'person':
- $label = 'Persoon';
- $users = $sUser->getUsersByGroupId(intval($group_id), $criteria, true);
- $options[] = array('value' => 0, 'label' => 'Kies een persoon...');
- break;
- case 'company':
- $label = 'Bedrijf';
- $users = $sUser->getUsersByGroupId(intval($group_id), $criteria, true);
- $options[] = array('value' => 0, 'label' => 'Kies een bedrijf...');
- break;
- case 'group':
- $label = 'Groep';
- $users = $sUser->getGroupsByUserId(intval($user_id), $criteria, true);
- $options[] = array('value' => 0, 'label' => 'Kies een groep...');
- break;
- }
-
- //Prepare options
- foreach($users as $user) {
- $options[] = array('value' => $user['id'], 'label' => $user['out_name']);
- }
-
- $rows = array();
- $rows[0][0] = $label;
- $rows[0][1] = $sWidget->inputInteger('id', 0, $options);
-
- //Create form
- $action = $this->e->hrefAction('ok');
-
- $inputs = $sWidget->fieldset($sWidget->formTable($rows),'Toevoegen');
- $inputs .= $sWidget->buttonSetOkCancel(
- $this->e->hrefAction($action),
- $this->e->hrefAction('cancel'));
- $inputs = $sWidget->form($inputs, $this->e->hrefAction($action));
-
- print $inputs;
- }
-
- function action_ok($data) {
-
- $id = intval($data['id']);
-
- $sUser =& $this->e->getService('user');
-
- $user_var =& $this->e->session->getReference($this->elementConfig['user_var'],'site');
- $group_var =& $this->e->session->getReference($this->elementConfig['group_var'],'site');
-
- switch($this->elementConfig['type']) {
- case 'person':
- case 'company':
- $ret =$sUser->addGroupMember(intval($group_var),$id);
- break;
- case 'group':
- $ret =$sUser->addGroupMember($id,intval($user_var));
- break;
- }
-
- if($ret) {
- //Store added id
- if($this->elementConfig['type'] == 'group')
- $group_var = $id;
- else
- $user_var = $id;
-
- $this->e->session->save();
-
- if($this->elementConfig['page_ok'] != null)
- $this->e->redirect($this->e->hrefPage($this->elementConfig['page_ok']));
- else
- $this->e->redirect($this->e->hrefPreviousPage());
- }
- }
-
- function action_cancel($data) {
- if($this->elementConfig['page_cancel'] != null)
- $this->e->redirect($this->e->hrefPage($this->elementConfig['page_cancel']));
- else
- $this->e->redirect($this->e->hrefPreviousPage());
- }
- }
- /**@}*/
-?>
Deleted: trunk/mod/eis_user/elements/DeleteUser.php
===================================================================
--- trunk/mod/eis_user/elements/DeleteUser.php 2007-09-11 12:18:06 UTC (rev 205)
+++ trunk/mod/eis_user/elements/DeleteUser.php 2007-09-11 16:56:12 UTC (rev 206)
@@ -1,69 +0,0 @@
-<?php
- /**
- *@ingroup elements_user
- *@{
- */
- /** Element to delete a user */
- class user_DeleteUser extends Element {
-
- function view_default() {
-
- $sUser =& $this->e->getService('user');
- $sWidget =& $this->e->getService('widget');
-
- $id =& $this->e->session->getReference($this->elementConfig['var'],'site');
- $id = intval($id);
-
- $user = $sUser->getUserById($id);
-
- $question = 'Weet u zeker dat u "'.$user['out_name'].'" wilt verwijderen?';
-
- print $sWidget->fieldset($question,'Verwijderen');
- print $sWidget->buttonSetYesNo(
- $this->e->hrefAction('ok'),
- $this->e->hrefAction('cancel'),false);
- }
-
- function action_ok($data) {
-
- $sUser =& $this->e->getService('user');
-
- $id =& $this->e->session->getReference($this->elementConfig['var'],'site');
-
- $obj = $sUser->getUserById(intval($id));
-
- switch($obj['type']) {
- case 'person':
- $ret = $sUser->deletePerson($obj);
- break;
- case 'company':
- $ret = $sUser->deleteCompany($obj);
- break;
- case 'group':
- $ret = $sUser->deleteGroup($obj);
- break;
- }
-
- if($ret) {
- //Clear var
- $id = null;
- $this->e->session->save();
-
- if($this->elementConfig['page_ok'] != null)
- $this->e->redirect($this->e->hrefPage($this->elementConfig['page_ok']));
- else
- $this->e->redirect($this->e->hrefPreviousPage());
- } else {
- //TODO: ERROR
- }
- }
- function action_cancel($data) {
-
- if($this->elementConfig['page_cancel'] != null)
- $this->e->redirect($this->e->hrefPage($this->elemenConfig['page_cancel']));
- else
- $this->e->redirect($this->e->hrefPreviousPage());
- }
- }
- /**@}*/
-?>
Deleted: trunk/mod/eis_user/elements/DisplayUser.php
===================================================================
--- trunk/mod/eis_user/elements/DisplayUser.php 2007-09-11 12:18:06 UTC (rev 205)
+++ trunk/mod/eis_user/elements/DisplayUser.php 2007-09-11 16:56:12 UTC (rev 206)
@@ -1,192 +0,0 @@
-<?php
- /**
- *@ingroup elements_user
- *@{
- */
- /** Element to display a user*/
- class user_DisplayUser extends Element {
-
- function view_default() {
-
- $sUser = $this->e->getService('user');
- $sImage = $this->e->getService('image');
- $sWidget = $this->e->getService('widget');
-
- $id =& $this->e->session->getReference($this->elementConfig['var'],'site');
- $id = intval($id);
-
- $meid =& $this->e->session->getReference('me','module','user');
- $me = $sUser->getUserById($meid);
-
- $user = $sUser->getUserById($id);
-
- //Summary
- if($this->elementConfig['display_all'] || $this->elementConfig['display_person_summary']) {
- $rows = array();
- $rows[] = array('Naam',$sWidget->displayString($user['out_name']));
- $rows[] = array('Adres',$sWidget->displayString($user['out_address']));
- $rows[] = array('Telefoon',$sWidget->displayString($user['out_phone']));
- $rows[] = array('E-mail',$sWidget->displayString($user['out_email']));
- $rows[] = array('Gebruikersnaam',
- $sWidget->displayString($user['login_username']).
- ($user['login_active'] ? '' : ' (inactief)'));
-
- print $sWidget->fieldset($sWidget->formTable($rows),'Samenvatting');
- }
- //Personal info
- if($this->elementConfig['display_all'] || $this->elementConfig['display_person']) {
-
- $rows = array();
- //Name
- $rows[] = array('Titel',$sWidget->displayString($user['name_title']));
- $rows[] = array('Voornaam',$sWidget->displayString($user['name_first']));
- $rows[] = array('Initialen',$sWidget->displayString($user['name_initials']));
- $rows[] = array('Tussenvoegsel',$sWidget->displayString($user['name_prefix']));
- $rows[] = array('Achternaam',$sWidget->displayString($user['name_last']));
- $rows[] = array('Toevoeging',$sWidget->displayString($user['name_addition']));
-
- //Gender
- if($user['misc_gender'] == 'm')
- $rows[] = array('Geslacht',$sWidget->icon('male'));
- if($user['misc_gender'] == 'f')
- $rows[] = array('Geslacht',$sWidget->icon('female'));
-
- //Birthday
- $rows[] = array('Geboortedatum',$sWidget->displayDate($user['misc_birthday']));
-
- //Occupation
- $rows[] = array('Beroep',$sWidget->displayString($user['misc_occupation']));
-
- print $sWidget->fieldset($sWidget->formTable($rows),'Persoonsgegevens');
- }
- //Company information
- if($this->elementConfig['display_all'] || $this->elementConfig['display_company_summary']) {
- $rows = array();
- $rows[] = array('Naam',$sWidget->displayString($user['out_name']));
- $rows[] = array('Adres',$sWidget->displayString($user['out_address']));
- $rows[] = array('Telefoon',$user['phone_work']);
- $rows[] = array('E-mail',$user['email_work']);
- print $sWidget->fieldset($sWidget->formTable($rows),'Bedrijf');
- }
-
- //Company information
- if($this->elementConfig['display_all'] || $this->elementConfig['display_company']) {
- $rows = array();
- $rows[] = array('Naam',$sWidget->displayString($user['out_name']));
- $rows[] = array('Adres',$sWidget->displayString($user['out_address']));
- $rows[] = array('Telefoon',$user['phone_work']);
- $rows[] = array('Fax',$user['fax_work']);
- $rows[] = array('E-mail',$user['email_work']);
- $rows[] = array('Website',$user['website_work']);
- if($user['addr_mail_address']) {
- $rows[] = array('Post Adres',$sWidget->displayString($user['out_mail_address']));
- }
- print $sWidget->fieldset($sWidget->formTable($rows),'Bedrijf');
- }
-
- //Group information
- if($this->elementConfig['display_all'] || $this->elementConfig['display_group']) {
- $numMembers = $sUser->getNumUsersByGroupId($user['id']);
-
- $rows = array();
- $rows[] = array('Naam',$sWidget->displayString($user['out_name']));
- $rows[] = array('Aantal leden',$sWidget->displayInteger($numMembers));
-
- print $sWidget->fieldset($sWidget->formTable($rows),'Groep');
- }
- //Image
- if($this->elementConfig['display_all'] || $this->elementConfig['display_image']) ...
[truncated message content] |
|
From: <bas...@us...> - 2007-09-11 12:18:22
|
Revision: 205
http://eis.svn.sourceforge.net/eis/?rev=205&view=rev
Author: baslijnse
Date: 2007-09-11 05:18:06 -0700 (Tue, 11 Sep 2007)
Log Message:
-----------
added displayapplication element to server manager
Modified Paths:
--------------
trunk/mod/eis_engine/applications/servermanager.xml
trunk/mod/eis_engine/locales/en_en/strings.xml
Added Paths:
-----------
trunk/mod/eis_engine/elements/DisplayApplication.php
Modified: trunk/mod/eis_engine/applications/servermanager.xml
===================================================================
--- trunk/mod/eis_engine/applications/servermanager.xml 2007-09-10 09:10:29 UTC (rev 204)
+++ trunk/mod/eis_engine/applications/servermanager.xml 2007-09-11 12:18:06 UTC (rev 205)
@@ -61,7 +61,6 @@
<module>eis_layout</module>
<element>Template</element>
<area>OUT</area>
- <inherit><applications>10</applications></inherit>
<config><name>file</name><value>eis_engine/servermanager/layout.html</value></config>
<inherit><depth>100</depth></inherit>
</element>
@@ -94,6 +93,19 @@
<area>MAIN</area>
</element>
</page>
+ <catchall>
+ <element>
+ <module>eis_layout</module>
+ <element>String</element>
+ <area>TITLE</area>
+ <config><name>string</name><value>eis_engine.t.display.application</value></config>
+ </element>
+ <element>
+ <module>eis_engine</module>
+ <element>DisplayApplication</element>
+ <area>MAIN</area>
+ </element>
+ </catchall>
</page>
<page>
<name>webservices</name>
Added: trunk/mod/eis_engine/elements/DisplayApplication.php
===================================================================
--- trunk/mod/eis_engine/elements/DisplayApplication.php (rev 0)
+++ trunk/mod/eis_engine/elements/DisplayApplication.php 2007-09-11 12:18:06 UTC (rev 205)
@@ -0,0 +1,49 @@
+<?php
+ class eis_engine_DisplayApplication extends Element {
+
+ function view_default() {
+
+ $sConfig =& $this->e->getService('eis_engine','ConfigService');
+ $sWidget =& $this->e->getService('eis_widget');
+
+ $name = array_pop($this->getPath());
+ $app = $sConfig->getApplication($name);
+
+ if($app == null) {
+ $this->e->error(404);
+ }
+
+ //Toolbar
+ $edit = $sWidget->iconLink('eis_widget/img/icons/edit.png',
+ 'eis_engine.l.edit.application',
+ $this->e->hrefPage('edit'),
+ array('show_label'=>true));
+ $delete = $sWidget->iconLink('eis_widget/img/icons/delete.png',
+ 'eis_engine.l.delete.application',
+ $this->e->hrefPage('delete'),
+ array('show_label'=>true));
+
+ print $sWidget->toolBar($edit.$delete);
+
+ $labels = array();
+ $inputs = array();
+
+ $labels[] = 'eis_engine.l.name';
+ $inputs[] = $sWidget->displayString($app['name']);
+
+ $labels[] = 'eis_engine.l.url';
+ $inputs[] = $sWidget->displayURL($this->e->getBaseUrl().$app['name']);
+
+ $labels[] = 'eis_engine.l.module';
+ $inputs[] = $sWidget->displayString($app['module']);
+
+ $labels[] = 'eis_engine.l.application';
+ $inputs[] = $sWidget->displayString($app['application']);
+
+ $labels[] = 'eis_engine.l.environment';
+ $inputs[] = $sWidget->displayString($app['environment']);
+
+ print $sWidget->formTable($labels, $inputs);
+ }
+ }
+?>
Modified: trunk/mod/eis_engine/locales/en_en/strings.xml
===================================================================
--- trunk/mod/eis_engine/locales/en_en/strings.xml 2007-09-10 09:10:29 UTC (rev 204)
+++ trunk/mod/eis_engine/locales/en_en/strings.xml 2007-09-11 12:18:06 UTC (rev 205)
@@ -46,6 +46,10 @@
<value><![CDATA[Home]]></value>
</string>
<string>
+ <name>t.login</name>
+ <value><![CDATA[Log in]]></value>
+ </string>
+ <string>
<name>t.manager.home</name>
<value><![CDATA[EIS Server Manager]]></value>
</string>
@@ -66,6 +70,10 @@
<value><![CDATA[Environments]]></value>
</string>
<string>
+ <name>t.display.application</name>
+ <value><![CDATA[Application details]]></value>
+ </string>
+ <string>
<name>t.display.webservice</name>
<value><![CDATA[Web service details]]></value>
</string>
@@ -214,6 +222,10 @@
<value><![CDATA[Add environment]]></value>
</string>
<string>
+ <name>l.edit.application</name>
+ <value><![CDATA[Edit application]]></value>
+ </string>
+ <string>
<name>l.edit.webservice</name>
<value><![CDATA[Edit web service]]></value>
</string>
@@ -222,6 +234,10 @@
<value><![CDATA[Edit environment]]></value>
</string>
<string>
+ <name>l.delete.application</name>
+ <value><![CDATA[Delete application]]></value>
+ </string>
+ <string>
<name>l.delete.webservice</name>
<value><![CDATA[Delete web service]]></value>
</string>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bas...@us...> - 2007-09-10 09:10:36
|
Revision: 204
http://eis.svn.sourceforge.net/eis/?rev=204&view=rev
Author: baslijnse
Date: 2007-09-10 02:10:29 -0700 (Mon, 10 Sep 2007)
Log Message:
-----------
Finished service error mechanism. It is simple for now but can be extended later
Modified Paths:
--------------
trunk/lib/base/service.lib.php
trunk/lib/engine/engine.lib.php
trunk/mod/eis_engine/elements/AddApplication.php
trunk/mod/eis_engine/services/ConfigService.php
Modified: trunk/lib/base/service.lib.php
===================================================================
--- trunk/lib/base/service.lib.php 2007-09-05 10:01:41 UTC (rev 203)
+++ trunk/lib/base/service.lib.php 2007-09-10 09:10:29 UTC (rev 204)
@@ -4,12 +4,11 @@
*/
class Service {
- var $e; /**< variable for the engine */
- var $moduleConfig = array(); /**< array containing moduleconfig */
+ var $e; /**< variable for the engine */
+ var $error; /**< Last error*/
+ var $moduleConfig; /**< array containing moduleconfig */
+ var $mc;
- var $errors; /**< array containig errors */
- var $objects; /**< variable containing objects */
-
/**
*This function parameters are assigned to variable
*@param engine the engine reference for the service
@@ -18,34 +17,43 @@
function Service(&$engine, $moduleConfig) {
$this->e =& $engine;
- $this->errors = array();
+ $this->error = null;
$this->moduleConfig = $moduleConfig;
+
+ $this->mc =& $this->moduleConfig;
}
- /**
- *This function sets the error array of the service
- */
- function setErrors($errors) {
- if(is_array($errors)) {
- $this->errors = $errors;
- }
+ function setError($code = 0, $string = null, $replacements = null) {
+ $this->error = array(
+ 'code' => $code,
+ 'string' => $string,
+ 'replacements' => $replacements);
}
+ function clearError() {
+ $this->error = null;
+ }
+ function success() {
+ return !is_array($this->error);
+ }
+ function getError() {
+ return $this->error;
+ }
+
/**
- *This function retrieves the errors from the engine
- *Every service should handle errors the same, so therefore this base method
- *@result array containing errors
+ * This function retrieves an array with error strings from the engine
+ * This was the old way of error passing in services. It is now replaced by 'set/getError' and 'success' methods
+ * It is still available for backward compatibility
+ *
+ * @return array containing error strings
*/
function getErrors() {
- return $this->errors;
+ if(is_array($this->error)) {
+ return array($this->error['string']);
+ } else {
+ return array();
+ }
}
- function getFirstError() {
- return $this->errors[0];
- }
- function success() {
- return (count($this->errors) == 0);
- }
-
/**
*This function retrieves objects from a databasetable via a Mysql query
*@param table the name of the table from which the objects should be retrieved
Modified: trunk/lib/engine/engine.lib.php
===================================================================
--- trunk/lib/engine/engine.lib.php 2007-09-05 10:01:41 UTC (rev 203)
+++ trunk/lib/engine/engine.lib.php 2007-09-10 09:10:29 UTC (rev 204)
@@ -1173,8 +1173,8 @@
*Make a link to the current page
*@return href to current page
*/
- function hrefCurrentPage() {
- return $this->hrefPage($this->getPath());
+ function hrefCurrentPage($args = null) {
+ return $this->hrefPage($this->getPath(),$args);
}
/**
*Make a link to the parent page
@@ -1182,8 +1182,8 @@
*@see hrefPage hrefAction hrefView hrefDetach hrefImage hrefPreviousPage
*@result return parent page to hrefPage function
*/
- function hrefParentPage($steps = 1) {
- return $this->hrefPage(array_slice($this->getPath(), 0, -1 * $steps));
+ function hrefParentPage($steps = 1, $args = null) {
+ return $this->hrefPage(array_slice($this->getPath(), 0, -1 * $steps),$args);
}
/**
*Makes a link to the previous page
@@ -1275,6 +1275,10 @@
$this->session->save();
}
+ function showServiceError($error) {
+ $this->showError($error['string'],$error['replacements']);
+ }
+
function getMessage() {
$msg = $this->session->get('message','engine');
$this->session->clear('message','engine');
Modified: trunk/mod/eis_engine/elements/AddApplication.php
===================================================================
--- trunk/mod/eis_engine/elements/AddApplication.php 2007-09-05 10:01:41 UTC (rev 203)
+++ trunk/mod/eis_engine/elements/AddApplication.php 2007-09-10 09:10:29 UTC (rev 204)
@@ -67,7 +67,7 @@
$this->e->redirect($this->e->hrefParentPage());
} else {
$this->setPost($form);
- $this->e->showError($sConfig->getFirstError());
+ $this->e->showServiceError($sConfig->getError());
$this->e->redirect($this->e->hrefCurrentPage());
}
}
Modified: trunk/mod/eis_engine/services/ConfigService.php
===================================================================
--- trunk/mod/eis_engine/services/ConfigService.php 2007-09-05 10:01:41 UTC (rev 203)
+++ trunk/mod/eis_engine/services/ConfigService.php 2007-09-10 09:10:29 UTC (rev 204)
@@ -27,42 +27,47 @@
}
function verifyApplication($obj, $new = false) {
- $err = array();
if(!isset($obj['module']) || $obj['module'] == '') {
- $err[] = 'eis_engine.e.missing.module';
+ $this->setError(0,'eis_engine.e.missing.module');
+ return false;
}
if(!isset($obj['application']) || $obj['application'] == '') {
- $err[] = 'eis_engine.e.missing.application';
+ $this->setError(0,'eis_engine.e.missing.application');
+ return false;
}
if(!isset($obj['name']) || $obj['name'] == '') {
- $err[] = 'eis_engine.e.missing.mountpoint';
+ $this->setError(0,'eis_engine.e.missing.mountpoint');
+ return false;
} else {
//Check format of mountpoint
if(!ereg("^[a-zA-Z0-9_\-]+$",$obj['name'])) {
- $err[] = 'eis_engine.e.illegalformat.mountpoint';
+ $this->setError(0,'eis_engine.e.illegalformat.mountpoint');
+ return false;
} else {
//Check if the application is already
if($this->getApplication($obj['name']) != null) {
if($new) {
- $err[] = 'eis_engine.e.application.duplicate.mountpoint';
+ $this->setError(0,'eis_engine.e.application.duplicate.mountpoint',array($obj['name']));
+ return false;
}
} else {
if(!$new) {
- $err[] = 'eis_engine.e.application.nonexistent.mountpoint';
+ $this->setError(0,'eis_engine.e.application.nonexistent.mountpoint',array($obj['name']));
+ return false;
}
}
}
}
if(!isset($obj['environment']) || $obj['environment'] == '') {
- $err[] = 'eis_engine.e.missing.environment';
+ $this->setError(0,'eis_engine.e.missing.environment');
+ return false;
}
- return $err;
+ return true;
}
function createApplication($obj) {
- if($err = $this->verifyApplication($obj,true)) {
- $this->setErrors($err);
- return null;
+ if(!$this->verifyApplication($obj,true)) {
+ return 0;
}
$applications = $this->_loadApplications();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|