Compare commits

..

No commits in common. "master" and "bug-1390" have entirely different histories.

57 changed files with 3694 additions and 3699 deletions

7
.gitattributes vendored
View file

@ -1,7 +0,0 @@
* text=auto
*.php text
*.html text
*.phtml text
*.js text
*.css text

View file

@ -1,29 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<projectDescription> <projectDescription>
<name>ca-mgr (mawaunix)</name> <name>ca-mgr (mawaunix)</name>
<comment></comment> <comment></comment>
<projects> <projects>
</projects> </projects>
<buildSpec> <buildSpec>
<buildCommand> <buildCommand>
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name> <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand> <buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name> <name>org.eclipse.wst.validation.validationbuilder</name>
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand> <buildCommand>
<name>org.eclipse.dltk.core.scriptbuilder</name> <name>org.eclipse.dltk.core.scriptbuilder</name>
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
</buildSpec> </buildSpec>
<natures> <natures>
<nature>org.zend.php.framework.ZendFrameworkNature</nature> <nature>org.zend.php.framework.ZendFrameworkNature</nature>
<nature>org.eclipse.php.core.PHPNature</nature> <nature>org.eclipse.php.core.PHPNature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature> <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures> </natures>
</projectDescription> </projectDescription>

View file

@ -1,154 +1,154 @@
<?php <?php
require_once('plugins/plugin.charsetheader.php'); require_once('plugins/plugin.charsetheader.php');
require_once('plugins/plugin.forceauth.php'); require_once('plugins/plugin.forceauth.php');
require_once('plugins/plugin.loginlogout.php'); require_once('plugins/plugin.loginlogout.php');
require_once('plugins/plugin.buildmenu.php'); require_once('plugins/plugin.buildmenu.php');
require_once('config/Config.php'); require_once('config/Config.php');
require_once('log/Log.php'); require_once('log/Log.php');
require_once('l10n/L10n.php'); require_once('l10n/L10n.php');
require_once('i18n/I18n.php'); require_once('i18n/I18n.php');
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {
protected function _initAutoload() { protected function _initAutoload() {
$autoloader = new Zend_Application_Module_Autoloader(array( $autoloader = new Zend_Application_Module_Autoloader(array(
'namespace' => 'Default_', 'namespace' => 'Default_',
'basePath' => dirname(__FILE__) 'basePath' => dirname(__FILE__)
)); ));
return $autoloader; return $autoloader;
} }
protected function _initPlugins() { protected function _initPlugins() {
$this->bootstrap('session'); $this->bootstrap('session');
$fc = Zend_Controller_Front::getInstance(); $fc = Zend_Controller_Front::getInstance();
$charset_header = new CharsetHeader(); $charset_header = new CharsetHeader();
$fc->registerPlugin($charset_header); $fc->registerPlugin($charset_header);
$force_auth = new ForceAuth(); $force_auth = new ForceAuth();
$fc->registerPlugin($force_auth); $fc->registerPlugin($force_auth);
$buildmenu = new BuildMenu(); $buildmenu = new BuildMenu();
$fc->registerPlugin($buildmenu); $fc->registerPlugin($buildmenu);
$loginlogout = new LoginLogout(); $loginlogout = new LoginLogout();
$fc->registerPlugin($loginlogout); $fc->registerPlugin($loginlogout);
} }
protected function _initDoctype() { protected function _initDoctype() {
$this->bootstrap('view'); $this->bootstrap('view');
$this->bootstrap('log'); $this->bootstrap('log');
$this->bootstrap('I18n'); $this->bootstrap('I18n');
$this->bootstrap('session'); $this->bootstrap('session');
$view = $this->getResource('view'); $view = $this->getResource('view');
Zend_Registry::set('view', $view); Zend_Registry::set('view', $view);
$view->doctype('XHTML1_STRICT'); $view->doctype('XHTML1_STRICT');
$view->addHelperPath(APPLICATION_PATH . '/views/helpers/'); $view->addHelperPath(APPLICATION_PATH . '/views/helpers/');
$view->headTitle = I18n::_('CAcert Test Manager'); $view->headTitle = I18n::_('CAcert Test Manager');
} }
/** /**
* @todo expireSessionCookie() * @todo expireSessionCookie()
* @todo rememberMe(xx) * @todo rememberMe(xx)
* @todo forgetMe() * @todo forgetMe()
* @see Zend_Registry::get('session'); * @see Zend_Registry::get('session');
* @return Zend_Session_Namespace * @return Zend_Session_Namespace
*/ */
protected function _initSession() { protected function _initSession() {
$options = $this->getOption('ca_mgr'); $options = $this->getOption('ca_mgr');
$db = Zend_Db::factory($options['db']['session']['pdo'], $options['db']['session']); $db = Zend_Db::factory($options['db']['session']['pdo'], $options['db']['session']);
/** /**
* automatically clean up expired session entries from session cache * automatically clean up expired session entries from session cache
* use the modified and lifetime stamps to calculate expire time * use the modified and lifetime stamps to calculate expire time
*/ */
if ($options['db']['session']['autocleanup'] == '1') { if ($options['db']['session']['autocleanup'] == '1') {
$stmt = $db->query('delete from front_session where (modified + lifetime * 2) < unix_timestamp()'); $stmt = $db->query('delete from front_session where (modified + lifetime * 2) < unix_timestamp()');
# $stmt->execute(); # $stmt->execute();
} }
//you can either set the Zend_Db_Table default adapter //you can either set the Zend_Db_Table default adapter
//or you can pass the db connection straight to the save handler $config //or you can pass the db connection straight to the save handler $config
// @see lifetimeColumn / lifetime / overrideLifetime, lifetime defaults to php.ini: session.gc_maxlifetime // @see lifetimeColumn / lifetime / overrideLifetime, lifetime defaults to php.ini: session.gc_maxlifetime
Zend_Db_Table_Abstract::setDefaultAdapter($db); Zend_Db_Table_Abstract::setDefaultAdapter($db);
$config = array( $config = array(
'name' => 'front_session', 'name' => 'front_session',
'primary' => 'id', 'primary' => 'id',
'modifiedColumn' => 'modified', 'modifiedColumn' => 'modified',
'dataColumn' => 'data', 'dataColumn' => 'data',
'lifetimeColumn' => 'lifetime' 'lifetimeColumn' => 'lifetime'
); );
//create your Zend_Session_SaveHandler_DbTable and //create your Zend_Session_SaveHandler_DbTable and
//set the save handler for Zend_Session //set the save handler for Zend_Session
Zend_Session::setSaveHandler(new Zend_Session_SaveHandler_DbTable($config)); Zend_Session::setSaveHandler(new Zend_Session_SaveHandler_DbTable($config));
// Zend_Session::rememberMe(7200); // Zend_Session::rememberMe(7200);
//start your session! //start your session!
Zend_Session::start(); Zend_Session::start();
$session = new Zend_Session_Namespace(); $session = new Zend_Session_Namespace();
if (!isset($session->started)) if (!isset($session->started))
$session->started = time(); $session->started = time();
if (!isset($session->authdata)) if (!isset($session->authdata))
$session->authdata = array('authed' => false); $session->authdata = array('authed' => false);
Zend_Registry::set('session', $session); Zend_Registry::set('session', $session);
return $session; return $session;
} }
/** /**
* get the basic system config from database, store the config object in the bootstrap registry * get the basic system config from database, store the config object in the bootstrap registry
* @see Zend_Registry::get('config'); * @see Zend_Registry::get('config');
* @return Config * @return Config
*/ */
protected function _initConfig() { protected function _initConfig() {
$options = $this->getOption('ca_mgr'); $options = $this->getOption('ca_mgr');
$db = Zend_Db::factory($options['db']['config']['pdo'], $options['db']['config']); $db = Zend_Db::factory($options['db']['config']['pdo'], $options['db']['config']);
$config = Config::getInstance(SYSTEM_CONFIG, $db); $config = Config::getInstance(SYSTEM_CONFIG, $db);
Zend_Registry::set('config', $config); Zend_Registry::set('config', $config);
Zend_Registry::set('config_dbc', $db); Zend_Registry::set('config_dbc', $db);
return $config; return $config;
} }
/** /**
* make singleton system logger * make singleton system logger
* @see Zend_Registry::get('log'); * @see Zend_Registry::get('log');
* @return Log * @return Log
*/ */
public function _initLog() { public function _initLog() {
$this->bootstrap('Config'); $this->bootstrap('Config');
$op = $this->getOption('log'); $op = $this->getOption('log');
$log = Log::getInstance(SYSTEM_LOG, $op['application']); $log = Log::getInstance(SYSTEM_LOG, $op['application']);
Zend_Registry::set('log', $log); Zend_Registry::set('log', $log);
return $log; return $log;
} }
/** /**
* make singleton I18n (internationalization) object (translation) * make singleton I18n (internationalization) object (translation)
*/ */
public function _initI18n() { public function _initI18n() {
$this->bootstrap('Config'); $this->bootstrap('Config');
// need existing L10n object for initialization // need existing L10n object for initialization
$this->bootstrap('L10n'); $this->bootstrap('L10n');
$I18n = I18n::getInstance(L10n::getInstance()->getLanguage()); $I18n = I18n::getInstance(L10n::getInstance()->getLanguage());
} }
/** /**
* make singleton L10n (localization) object (set locale, convert date and * make singleton L10n (localization) object (set locale, convert date and
* number formats) * number formats)
*/ */
public function _initL10n() { public function _initL10n() {
$this->bootstrap('Config'); $this->bootstrap('Config');
$L10n = L10n::getInstance(); $L10n = L10n::getInstance();
} }
} }

View file

@ -1,57 +1,57 @@
[production] [production]
phpSettings.display_startup_errors = 1 phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1 phpSettings.display_errors = 1
includePaths.library = LIBRARY_PATH includePaths.library = LIBRARY_PATH
bootstrap.path = APPLICATION_PATH "/Bootstrap.php" bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap" bootstrap.class = "Bootstrap"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.noViewRenderer = 0 resources.frontController.noViewRenderer = 0
resources.frontController.noErrorHandler = 0 resources.frontController.noErrorHandler = 0
resources.frontController.useDefaultControllerAlways = 0 resources.frontController.useDefaultControllerAlways = 0
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts" resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"
resources.view[] = resources.view[] =
autoloadernamespaces.0 = "CAcert_" autoloadernamespaces.0 = "CAcert_"
; Database settings for Session DB ; Database settings for Session DB
ca_mgr.db.session.pdo = "Pdo_Mysql" ca_mgr.db.session.pdo = "Pdo_Mysql"
ca_mgr.db.session.autocleanup = 1 ca_mgr.db.session.autocleanup = 1
ca_mgr.db.session.host = "localhost" ca_mgr.db.session.host = "localhost"
ca_mgr.db.session.username = "ca_mgr" ca_mgr.db.session.username = "ca_mgr"
ca_mgr.db.session.password = "jsdfhsd47534hsdf7" ca_mgr.db.session.password = "jsdfhsd47534hsdf7"
ca_mgr.db.session.dbname = "ca_mgr" ca_mgr.db.session.dbname = "ca_mgr"
; Database settings for Auth DB (CACert User Table) ; Database settings for Auth DB (CACert User Table)
ca_mgr.db.auth.pdo = "Pdo_Mysql" ca_mgr.db.auth.pdo = "Pdo_Mysql"
ca_mgr.db.auth.host = "cacert1.it-sls.de" ca_mgr.db.auth.host = "cacert1.it-sls.de"
ca_mgr.db.auth.username = "ca_mgr" ca_mgr.db.auth.username = "ca_mgr"
ca_mgr.db.auth.password = "6348Jhfge(3457H5Kse" ca_mgr.db.auth.password = "6348Jhfge(3457H5Kse"
ca_mgr.db.auth.dbname = "cacert" ca_mgr.db.auth.dbname = "cacert"
ca_mgr.db.auth.tablename = "users" ca_mgr.db.auth.tablename = "users"
; Database settings for Auth DB (Manager User Table) ; Database settings for Auth DB (Manager User Table)
ca_mgr.db.auth2.pdo = "Pdo_Mysql" ca_mgr.db.auth2.pdo = "Pdo_Mysql"
ca_mgr.db.auth2.host = "localhost" ca_mgr.db.auth2.host = "localhost"
ca_mgr.db.auth2.username = "ca_mgr" ca_mgr.db.auth2.username = "ca_mgr"
ca_mgr.db.auth2.password = "jsdfhsd47534hsdf7" ca_mgr.db.auth2.password = "jsdfhsd47534hsdf7"
ca_mgr.db.auth2.dbname = "ca_mgr" ca_mgr.db.auth2.dbname = "ca_mgr"
ca_mgr.db.auth2.tablename = "system_user" ca_mgr.db.auth2.tablename = "system_user"
; Database settings for Config DB (access to system_config and dnssecme data tables) ; Database settings for Config DB (access to system_config and dnssecme data tables)
ca_mgr.db.config.pdo = "Pdo_Mysql" ca_mgr.db.config.pdo = "Pdo_Mysql"
ca_mgr.db.config.host = "localhost" ca_mgr.db.config.host = "localhost"
ca_mgr.db.config.username = "ca_mgr" ca_mgr.db.config.username = "ca_mgr"
ca_mgr.db.config.password = "jsdfhsd47534hsdf7" ca_mgr.db.config.password = "jsdfhsd47534hsdf7"
ca_mgr.db.config.dbname = "ca_mgr" ca_mgr.db.config.dbname = "ca_mgr"
; Application name for logger ; Application name for logger
log.application = "web" log.application = "web"
[staging : production] [staging : production]
[testing : production] [testing : production]
phpSettings.display_startup_errors = 1 phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1 phpSettings.display_errors = 1
[development : production] [development : production]
phpSettings.display_startup_errors = 1 phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1 phpSettings.display_errors = 1

View file

@ -1,57 +1,57 @@
[production] [production]
phpSettings.display_startup_errors = 1 phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1 phpSettings.display_errors = 1
includePaths.library = LIBRARY_PATH includePaths.library = LIBRARY_PATH
bootstrap.path = APPLICATION_PATH "/Bootstrap.php" bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap" bootstrap.class = "Bootstrap"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.noViewRenderer = 0 resources.frontController.noViewRenderer = 0
resources.frontController.noErrorHandler = 0 resources.frontController.noErrorHandler = 0
resources.frontController.useDefaultControllerAlways = 0 resources.frontController.useDefaultControllerAlways = 0
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts" resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"
resources.view[] = resources.view[] =
autoloadernamespaces.0 = "CAcert_" autoloadernamespaces.0 = "CAcert_"
; Database settings for Session DB ; Database settings for Session DB
ca_mgr.db.session.pdo = "Pdo_Mysql" ca_mgr.db.session.pdo = "Pdo_Mysql"
ca_mgr.db.session.autocleanup = 1 ca_mgr.db.session.autocleanup = 1
ca_mgr.db.session.host = "localhost" ca_mgr.db.session.host = "localhost"
ca_mgr.db.session.username = "front_session" ca_mgr.db.session.username = "front_session"
ca_mgr.db.session.password = "laskdsfzrwethv45" ca_mgr.db.session.password = "laskdsfzrwethv45"
ca_mgr.db.session.dbname = "ca_mgr" ca_mgr.db.session.dbname = "ca_mgr"
; Database settings for Auth DB (CACert User Table) ; Database settings for Auth DB (CACert User Table)
ca_mgr.db.auth.pdo = "Pdo_Mysql" ca_mgr.db.auth.pdo = "Pdo_Mysql"
ca_mgr.db.auth.host = "localhost" ca_mgr.db.auth.host = "localhost"
ca_mgr.db.auth.username = "ca_mgr" ca_mgr.db.auth.username = "ca_mgr"
ca_mgr.db.auth.password = "jsdfhsd47534hsdf7" ca_mgr.db.auth.password = "jsdfhsd47534hsdf7"
ca_mgr.db.auth.dbname = "cacert" ca_mgr.db.auth.dbname = "cacert"
ca_mgr.db.auth.tablename = "users" ca_mgr.db.auth.tablename = "users"
; Database settings for Auth DB (Manager User Table) ; Database settings for Auth DB (Manager User Table)
ca_mgr.db.auth2.pdo = "Pdo_Mysql" ca_mgr.db.auth2.pdo = "Pdo_Mysql"
ca_mgr.db.auth2.host = "localhost" ca_mgr.db.auth2.host = "localhost"
ca_mgr.db.auth2.username = "ca_mgr" ca_mgr.db.auth2.username = "ca_mgr"
ca_mgr.db.auth2.password = "jsdfhsd47534hsdf7" ca_mgr.db.auth2.password = "jsdfhsd47534hsdf7"
ca_mgr.db.auth2.dbname = "ca_mgr" ca_mgr.db.auth2.dbname = "ca_mgr"
ca_mgr.db.auth2.tablename = "system_user" ca_mgr.db.auth2.tablename = "system_user"
; Database settings for Config DB (access to system_config and dnssecme data tables) ; Database settings for Config DB (access to system_config and dnssecme data tables)
ca_mgr.db.config.pdo = "Pdo_Mysql" ca_mgr.db.config.pdo = "Pdo_Mysql"
ca_mgr.db.config.host = "localhost" ca_mgr.db.config.host = "localhost"
ca_mgr.db.config.username = "ca_mgr" ca_mgr.db.config.username = "ca_mgr"
ca_mgr.db.config.password = "jsdfhsd47534hsdf7" ca_mgr.db.config.password = "jsdfhsd47534hsdf7"
ca_mgr.db.config.dbname = "ca_mgr" ca_mgr.db.config.dbname = "ca_mgr"
; Application name for logger ; Application name for logger
log.application = "web" log.application = "web"
[staging : production] [staging : production]
[testing : production] [testing : production]
phpSettings.display_startup_errors = 1 phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1 phpSettings.display_errors = 1
[development : production] [development : production]
phpSettings.display_startup_errors = 1 phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1 phpSettings.display_errors = 1

View file

@ -1,34 +1,35 @@
<?php <?php
class ErrorController extends Zend_Controller_Action class ErrorController extends Zend_Controller_Action
{ {
public function errorAction() public function errorAction()
{ {
$errors = $this->_getParam('error_handler'); $errors = $this->_getParam('error_handler');
switch ($errors->type) { switch ($errors->type) {
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER: case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION: case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
// 404 error -- controller or action not found // 404 error -- controller or action not found
$this->getResponse()->setHttpResponseCode(404); $this->getResponse()->setHttpResponseCode(404);
$this->view->message = 'Page not found'; $this->view->message = 'Page not found';
break; break;
default: default:
// application error // application error
$this->getResponse()->setHttpResponseCode(500); $this->getResponse()->setHttpResponseCode(500);
$this->view->message = 'Application error'; $this->view->message = 'Application error';
break; break;
} }
$this->view->exception = $errors->exception; $this->view->exception = $errors->exception;
$this->view->request = $errors->request; $this->view->request = $errors->request;
Log::Log()->emerg($errors->exception); Log::Log()->emerg($errors->exception);
} }
public function permissiondeniedAction() { public function permissiondeniedAction() {
} }
} }

View file

@ -10,10 +10,10 @@ class IndexController extends Zend_Controller_Action
public function init() public function init()
{ {
/* Initialize action controller here */ /* Initialize action controller here */
/** /**
* get bootstrap, get resource from bootstrap * get bootstrap, get resource from bootstrap
* resources are created when an bootstrap _init method returns an object * resources are created when an bootstrap _init method returns an object
$bootstrap = $this->getInvokeArg('bootstrap'); $bootstrap = $this->getInvokeArg('bootstrap');
$view = $bootstrap->getResource('view'); $view = $bootstrap->getResource('view');
*/ */
} }

View file

@ -1,284 +1,284 @@
<?php <?php
/** /**
* @author markus * @author markus
* $Id: LoginController.php 75 2010-02-25 14:40:10Z markus $ * $Id: LoginController.php 75 2010-02-25 14:40:10Z markus $
*/ */
require_once('helpers/GetEnv.php'); require_once('helpers/GetEnv.php');
require_once('config/Config.php'); require_once('config/Config.php');
class LoginController extends Zend_Controller_Action class LoginController extends Zend_Controller_Action
{ {
public function init() { public function init() {
/* Initialize action controller here */ /* Initialize action controller here */
$config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV); $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV);
$db = Zend_Db::factory($config->ca_mgr->db->auth->pdo, $config->ca_mgr->db->auth); $db = Zend_Db::factory($config->ca_mgr->db->auth->pdo, $config->ca_mgr->db->auth);
Zend_Registry::set('auth_dbc', $db); Zend_Registry::set('auth_dbc', $db);
$db2 = Zend_Db::factory($config->ca_mgr->db->auth2->pdo, $config->ca_mgr->db->auth2); $db2 = Zend_Db::factory($config->ca_mgr->db->auth2->pdo, $config->ca_mgr->db->auth2);
Zend_Registry::set('auth2_dbc', $db2); Zend_Registry::set('auth2_dbc', $db2);
} }
public function indexAction() { public function indexAction() {
$this->view->form = $this->getForm(); $this->view->form = $this->getForm();
$this->render('index'); $this->render('index');
} }
public function loginAction() { public function loginAction() {
$form = $this->getForm(); $form = $this->getForm();
if ($form->isValid($_POST)) { if ($form->isValid($_POST)) {
$config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV); $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV);
$db = Zend_Registry::get('auth_dbc'); $db = Zend_Registry::get('auth_dbc');
$db2 = Zend_Registry::get('auth2_dbc'); $db2 = Zend_Registry::get('auth2_dbc');
$auth = new Zend_Auth_Adapter_DbTable($db); $auth = new Zend_Auth_Adapter_DbTable($db);
$auth->setTableName($config->ca_mgr->db->auth->tablename) $auth->setTableName($config->ca_mgr->db->auth->tablename)
->setIdentityColumn('email') ->setIdentityColumn('email')
->setCredentialColumn('password'); ->setCredentialColumn('password');
Log::Log()->info(__METHOD__ . ' authenticate ' . $this->getRequest()->getParam('login_name') . ' ' . sha1(utf8_decode($this->getRequest()->getParam('login_password')))); Log::Log()->info(__METHOD__ . ' authenticate ' . $this->getRequest()->getParam('login_name') . ' ' . sha1(utf8_decode($this->getRequest()->getParam('login_password'))));
$auth->setIdentity( $this->getRequest()->getParam('login_name')) $auth->setIdentity( $this->getRequest()->getParam('login_name'))
->setCredential( sha1(utf8_decode($this->getRequest()->getParam('login_password')))) ->setCredential( sha1(utf8_decode($this->getRequest()->getParam('login_password'))))
->setCredentialTreatment('?'); ->setCredentialTreatment('?');
$result = $auth->authenticate(); $result = $auth->authenticate();
$code = $result->getCode(); $code = $result->getCode();
switch ($code) { switch ($code) {
case Zend_Auth_Result::FAILURE: case Zend_Auth_Result::FAILURE:
Log::Log()->info(__METHOD__ . ' user failed (Zend_Auth_Result::FAILURE) to log in ' . $this->getRequest()->getParam('login_name')); Log::Log()->info(__METHOD__ . ' user failed (Zend_Auth_Result::FAILURE) to log in ' . $this->getRequest()->getParam('login_name'));
throw new Exception(__METHOD__ . ': unknown error'); throw new Exception(__METHOD__ . ': unknown error');
case Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND: case Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND:
Log::Log()->info(__METHOD__ . ' user failed (Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND) to log in ' . $this->getRequest()->getParam('login_name')); Log::Log()->info(__METHOD__ . ' user failed (Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND) to log in ' . $this->getRequest()->getParam('login_name'));
throw new Exception(__METHOD__ . ': ID unknown'); throw new Exception(__METHOD__ . ': ID unknown');
case Zend_Auth_Result::FAILURE_IDENTITY_AMBIGUOUS: case Zend_Auth_Result::FAILURE_IDENTITY_AMBIGUOUS:
Log::Log()->info(__METHOD__ . ' user failed (Zend_Auth_Result::FAILURE_IDENTITY_AMBIGUOUS) to log in ' . $this->getRequest()->getParam('login_name')); Log::Log()->info(__METHOD__ . ' user failed (Zend_Auth_Result::FAILURE_IDENTITY_AMBIGUOUS) to log in ' . $this->getRequest()->getParam('login_name'));
throw new Exception(__METHOD__ . ': ID not unique'); throw new Exception(__METHOD__ . ': ID not unique');
case Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID: case Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID:
Log::Log()->info(__METHOD__ . ' user failed (Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID) to log in ' . $this->getRequest()->getParam('login_name')); Log::Log()->info(__METHOD__ . ' user failed (Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID) to log in ' . $this->getRequest()->getParam('login_name'));
throw new Exception(__METHOD__ . ': ID unknown'); // to prevent brute force password attachs throw new Exception(__METHOD__ . ': ID unknown'); // to prevent brute force password attachs
case Zend_Auth_Result::FAILURE_UNCATEGORIZED: case Zend_Auth_Result::FAILURE_UNCATEGORIZED:
Log::Log()->info(__METHOD__ . ' user failed (Zend_Auth_Result::FAILURE_UNCATEGORIZED) to log in ' . $this->getRequest()->getParam('login_name')); Log::Log()->info(__METHOD__ . ' user failed (Zend_Auth_Result::FAILURE_UNCATEGORIZED) to log in ' . $this->getRequest()->getParam('login_name'));
throw new Exception(__METHOD__ . ': unknown error'); throw new Exception(__METHOD__ . ': unknown error');
} }
$this->getAuthDetailsIntoSession($auth, false); $this->getAuthDetailsIntoSession($auth, false);
Log::Log()->info(__METHOD__ . ' user logged in ' . $this->view->session->authdata['authed_username'] . Log::Log()->info(__METHOD__ . ' user logged in ' . $this->view->session->authdata['authed_username'] .
' (' . $this->getRequest()->getParam('login_name') . ')'); ' (' . $this->getRequest()->getParam('login_name') . ')');
#$this->_forward('index', 'index'); // only "soft" forward, we need to change the url in browser #$this->_forward('index', 'index'); // only "soft" forward, we need to change the url in browser
$this->_redirect($this->view->url(array('controller' => 'index', 'action' => 'index'), 'default', true)); $this->_redirect($this->view->url(array('controller' => 'index', 'action' => 'index'), 'default', true));
/* /*
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
$viewRenderer->setRender('loginresult'); $viewRenderer->setRender('loginresult');
$this->view->request = $this->getRequest(); $this->view->request = $this->getRequest();
*/ */
} }
else { else {
$this->view->form = $form; $this->view->form = $form;
return $this->render('index'); return $this->render('index');
} }
} }
public function crtAction() { public function crtAction() {
$ssl_client_s_dn = GetEnv::getEnvVar('SSL_CLIENT_S_DN'); $ssl_client_s_dn = GetEnv::getEnvVar('SSL_CLIENT_S_DN');
$ssl_client_i_dn = GetEnv::getEnvVar('SSL_CLIENT_I_DN'); $ssl_client_i_dn = GetEnv::getEnvVar('SSL_CLIENT_I_DN');
$config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV); $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV);
$db = Zend_Registry::get('auth_dbc'); $db = Zend_Registry::get('auth_dbc');
$db2 = Zend_Registry::get('auth2_dbc'); $db2 = Zend_Registry::get('auth2_dbc');
$auth = new Zend_Auth_Adapter_DbTable($db2); $auth = new Zend_Auth_Adapter_DbTable($db2);
$auth->setTableName($config->ca_mgr->db->auth2->tablename) $auth->setTableName($config->ca_mgr->db->auth2->tablename)
->setIdentityColumn('user_client_crt_s_dn_i_dn') ->setIdentityColumn('user_client_crt_s_dn_i_dn')
->setCredentialColumn('user_client_crt_s_dn_i_dn'); ->setCredentialColumn('user_client_crt_s_dn_i_dn');
$auth->setIdentity( $ssl_client_s_dn . '//' . $ssl_client_i_dn) $auth->setIdentity( $ssl_client_s_dn . '//' . $ssl_client_i_dn)
->setCredential($ssl_client_s_dn . '//' . $ssl_client_i_dn) ->setCredential($ssl_client_s_dn . '//' . $ssl_client_i_dn)
->setCredentialTreatment('?'); ->setCredentialTreatment('?');
$result = $auth->authenticate(); $result = $auth->authenticate();
$code = $result->getCode(); $code = $result->getCode();
switch ($code) { switch ($code) {
case Zend_Auth_Result::FAILURE: case Zend_Auth_Result::FAILURE:
Log::Log()->info(__METHOD__ . ' user failed (Zend_Auth_Result::FAILURE) to log in ' . $ssl_client_s_dn . '//' . $ssl_client_i_dn); Log::Log()->info(__METHOD__ . ' user failed (Zend_Auth_Result::FAILURE) to log in ' . $ssl_client_s_dn . '//' . $ssl_client_i_dn);
throw new Exception(__METHOD__ . ': unknown error'); throw new Exception(__METHOD__ . ': unknown error');
case Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND: case Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND:
Log::Log()->info(__METHOD__ . ' user failed (Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND) to log in ' . $ssl_client_s_dn . '//' . $ssl_client_i_dn); Log::Log()->info(__METHOD__ . ' user failed (Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND) to log in ' . $ssl_client_s_dn . '//' . $ssl_client_i_dn);
throw new Exception(__METHOD__ . ': ID unknown'); throw new Exception(__METHOD__ . ': ID unknown');
case Zend_Auth_Result::FAILURE_IDENTITY_AMBIGUOUS: case Zend_Auth_Result::FAILURE_IDENTITY_AMBIGUOUS:
Log::Log()->info(__METHOD__ . ' user failed (Zend_Auth_Result::FAILURE_IDENTITY_AMBIGUOUS) to log in ' . $ssl_client_s_dn . '//' . $ssl_client_i_dn); Log::Log()->info(__METHOD__ . ' user failed (Zend_Auth_Result::FAILURE_IDENTITY_AMBIGUOUS) to log in ' . $ssl_client_s_dn . '//' . $ssl_client_i_dn);
throw new Exception(__METHOD__ . ': ID not unique'); throw new Exception(__METHOD__ . ': ID not unique');
case Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID: case Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID:
Log::Log()->info(__METHOD__ . ' user failed (Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID) to log in ' . $ssl_client_s_dn . '//' . $ssl_client_i_dn); Log::Log()->info(__METHOD__ . ' user failed (Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID) to log in ' . $ssl_client_s_dn . '//' . $ssl_client_i_dn);
throw new Exception(__METHOD__ . ': ID unknown'); // to prevent brute force password attachs throw new Exception(__METHOD__ . ': ID unknown'); // to prevent brute force password attachs
case Zend_Auth_Result::FAILURE_UNCATEGORIZED: case Zend_Auth_Result::FAILURE_UNCATEGORIZED:
Log::Log()->info(__METHOD__ . ' user failed (Zend_Auth_Result::FAILURE_UNCATEGORIZED) to log in ' . $ssl_client_s_dn . '//' . $ssl_client_i_dn); Log::Log()->info(__METHOD__ . ' user failed (Zend_Auth_Result::FAILURE_UNCATEGORIZED) to log in ' . $ssl_client_s_dn . '//' . $ssl_client_i_dn);
throw new Exception(__METHOD__ . ': unknown error'); throw new Exception(__METHOD__ . ': unknown error');
} }
$this->getAuthDetailsIntoSession($auth, true); $this->getAuthDetailsIntoSession($auth, true);
/* /*
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
$viewRenderer->setRender('loginresult'); $viewRenderer->setRender('loginresult');
*/ */
Log::Log()->info(__METHOD__ . ' user logged in ' . $this->view->session->authdata['authed_username'] . Log::Log()->info(__METHOD__ . ' user logged in ' . $this->view->session->authdata['authed_username'] .
' (' . $ssl_client_s_dn . '//' . $ssl_client_i_dn . ')'); ' (' . $ssl_client_s_dn . '//' . $ssl_client_i_dn . ')');
#$this->_forward('index', 'index'); // only "soft" forward, we need to change the url in browser #$this->_forward('index', 'index'); // only "soft" forward, we need to change the url in browser
$this->_redirect($this->view->url(array('controller' => 'index', 'action' => 'index'), 'default', true)); $this->_redirect($this->view->url(array('controller' => 'index', 'action' => 'index'), 'default', true));
} }
/** /**
* get user data from Zend_Auth result and store data in session * get user data from Zend_Auth result and store data in session
* @param Zend_Auth_Result $auth * @param Zend_Auth_Result $auth
*/ */
protected function getAuthDetailsIntoSession($auth, $crt) { protected function getAuthDetailsIntoSession($auth, $crt) {
$session = Zend_Registry::get('session'); $session = Zend_Registry::get('session');
$db = Zend_Registry::get('auth_dbc'); $db = Zend_Registry::get('auth_dbc');
$db2 = Zend_Registry::get('auth2_dbc'); $db2 = Zend_Registry::get('auth2_dbc');
/** /**
* non existent in our case, look up a 2nd table (ca_mgr.system_user by login name (email)) and * non existent in our case, look up a 2nd table (ca_mgr.system_user by login name (email)) and
* get id from there, defaulting to User (1) when no db entry exists * get id from there, defaulting to User (1) when no db entry exists
*/ */
$auth_res = $auth->getResultRowObject(); $auth_res = $auth->getResultRowObject();
if (!isset($auth_res->system_role_id) || $auth_res->system_role_id == 0) { if (!isset($auth_res->system_role_id) || $auth_res->system_role_id == 0) {
$res = $db2->query('select * from system_user where login=?', array($auth_res->email)); $res = $db2->query('select * from system_user where login=?', array($auth_res->email));
if ($res->rowCount() > 0) { if ($res->rowCount() > 0) {
$res_ar = $res->fetch(); $res_ar = $res->fetch();
$system_roles_id = $res_ar['system_role_id']; $system_roles_id = $res_ar['system_role_id'];
} }
else { else {
// no extra user info in manager database, assume standard user // no extra user info in manager database, assume standard user
$system_roles_id = 1; $system_roles_id = 1;
} }
} }
else else
$system_roles_id = $auth_res->system_role_id; $system_roles_id = $auth_res->system_role_id;
$session->authdata['authed'] = true; $session->authdata['authed'] = true;
$session->authdata['authed_id'] = $auth_res->id; $session->authdata['authed_id'] = $auth_res->id;
if (!isset($auth_res->fname) || !isset($auth_res->lname)) { if (!isset($auth_res->fname) || !isset($auth_res->lname)) {
$res = $db->query('select * from users where email=?', array($auth_res->login)); $res = $db->query('select * from users where email=?', array($auth_res->login));
$res_ar = $res->fetch(); $res_ar = $res->fetch();
$session->authdata['authed_username'] = 'crt' . $res_ar['login']; $session->authdata['authed_username'] = 'crt' . $res_ar['login'];
$session->authdata['authed_fname'] = $res_ar['fname']; $session->authdata['authed_fname'] = $res_ar['fname'];
$session->authdata['authed_lname'] = $res_ar['lname']; $session->authdata['authed_lname'] = $res_ar['lname'];
} }
else { else {
$session->authdata['authed_username'] = $auth_res->email; $session->authdata['authed_username'] = $auth_res->email;
$session->authdata['authed_fname'] = $auth_res->fname; $session->authdata['authed_fname'] = $auth_res->fname;
$session->authdata['authed_lname'] = $auth_res->lname; $session->authdata['authed_lname'] = $auth_res->lname;
} }
$session->authdata['authed_by_crt'] = $crt; $session->authdata['authed_by_crt'] = $crt;
$session->authdata['authed_by_cli'] = true; $session->authdata['authed_by_cli'] = true;
$res = $db2->query('select * from system_role where id=?', array($system_roles_id)); $res = $db2->query('select * from system_role where id=?', array($system_roles_id));
$res_ar = $res->fetch(); $res_ar = $res->fetch();
$session->authdata['authed_role'] = $res_ar['role']; $session->authdata['authed_role'] = $res_ar['role'];
$acl = $this->makeAcl($db2); $acl = $this->makeAcl($db2);
$session->authdata['authed_permissions'] = $acl; $session->authdata['authed_permissions'] = $acl;
/* test cases /* test cases
Log::Log()->debug(($acl->isAllowed('User', 'Administration', 'view') == true)?'true':'false'); Log::Log()->debug(($acl->isAllowed('User', 'Administration', 'view') == true)?'true':'false');
Log::Log()->debug(($acl->isAllowed('User', 'Administration', 'edit') == true)?'true':'false'); Log::Log()->debug(($acl->isAllowed('User', 'Administration', 'edit') == true)?'true':'false');
Log::Log()->debug(($acl->isAllowed('User', 'Account', 'view') == true)?'true':'false'); Log::Log()->debug(($acl->isAllowed('User', 'Account', 'view') == true)?'true':'false');
Log::Log()->debug(($acl->isAllowed('User', 'Account', 'edit') == true)?'true':'false'); Log::Log()->debug(($acl->isAllowed('User', 'Account', 'edit') == true)?'true':'false');
Log::Log()->debug(($acl->isAllowed('Admin', 'Administration', 'view') == true)?'true':'false'); Log::Log()->debug(($acl->isAllowed('Admin', 'Administration', 'view') == true)?'true':'false');
Log::Log()->debug(($acl->isAllowed('Admin', 'Account', 'view') == true)?'true':'false'); Log::Log()->debug(($acl->isAllowed('Admin', 'Account', 'view') == true)?'true':'false');
*/ */
$this->view->session = $session; $this->view->session = $session;
} }
/** /**
* build login form and return to requesting method * build login form and return to requesting method
* @return Zend_Form * @return Zend_Form
*/ */
protected function getForm() { protected function getForm() {
$form = new Zend_Form(); $form = new Zend_Form();
$form->setAction('/login/login') $form->setAction('/login/login')
->setMethod('post'); ->setMethod('post');
#$form->setAttrib('id', 'loginform'); #$form->setAttrib('id', 'loginform');
$username = new Zend_Form_Element_Text('login_name'); $username = new Zend_Form_Element_Text('login_name');
$username->setRequired(true) $username->setRequired(true)
->setLabel(I18n::_('User Name')) ->setLabel(I18n::_('User Name'))
->addFilter(new Zend_Filter_StringTrim()) ->addFilter(new Zend_Filter_StringTrim())
->addFilter(new Zend_Filter_StripTags()); ->addFilter(new Zend_Filter_StripTags());
$password = new Zend_Form_Element_Password('login_password'); $password = new Zend_Form_Element_Password('login_password');
$password->setRequired(true) $password->setRequired(true)
->setLabel(I18n::_('Password')) ->setLabel(I18n::_('Password'))
->addFilter(new Zend_Filter_StringTrim()); ->addFilter(new Zend_Filter_StringTrim());
$submit = new Zend_Form_Element_Submit('submit'); $submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel(I18n::_('Login')); $submit->setLabel(I18n::_('Login'));
$form->addElement($username) $form->addElement($username)
->addElement($password) ->addElement($password)
->addElement($submit); ->addElement($submit);
return $form; return $form;
} }
/** /**
* get roles and resources from db, build Zend_Acl structure and add permissions * get roles and resources from db, build Zend_Acl structure and add permissions
* @param Zend_Db $db * @param Zend_Db $db
*/ */
protected function makeAcl($db) { protected function makeAcl($db) {
$acl = new Zend_Acl(); $acl = new Zend_Acl();
$res = $db->fetchAll('select * from system_role'); $res = $db->fetchAll('select * from system_role');
foreach ($res as $obj) { foreach ($res as $obj) {
if ($obj['inherit_role'] != '') { if ($obj['inherit_role'] != '') {
if ($acl->hasRole($obj['inherit_role'])) { if ($acl->hasRole($obj['inherit_role'])) {
$acl->addRole(new Zend_Acl_Role($obj['role']), $obj['inherit_role']); $acl->addRole(new Zend_Acl_Role($obj['role']), $obj['inherit_role']);
} }
else { else {
/** /**
* @todo very simply system to order roles, add role before inherited role * @todo very simply system to order roles, add role before inherited role
*/ */
$res[] = $obj; $res[] = $obj;
continue; continue;
} }
} }
else { else {
$acl->addRole(new Zend_Acl_Role($obj['role'])); $acl->addRole(new Zend_Acl_Role($obj['role']));
} }
} }
$res = $db->fetchAll('select * from system_resource'); $res = $db->fetchAll('select * from system_resource');
foreach ($res as $obj) { foreach ($res as $obj) {
$acl->addResource(new Zend_Acl_Resource($obj['resource'])); $acl->addResource(new Zend_Acl_Resource($obj['resource']));
} }
$res = $db->fetchAll('select r.role as role, rs.resource as resource, permission, privilege '. $res = $db->fetchAll('select r.role as role, rs.resource as resource, permission, privilege '.
'from system_role as r join system_role_has_system_resource as m on ' . 'from system_role as r join system_role_has_system_resource as m on ' .
'(r.id = m.system_role_id) join system_resource as rs on (m.system_resource_id = rs.id)'); '(r.id = m.system_role_id) join system_resource as rs on (m.system_resource_id = rs.id)');
foreach ($res as $obj) { foreach ($res as $obj) {
$privilege = explode(',', $obj['privilege']); $privilege = explode(',', $obj['privilege']);
if ($obj['permission'] == 'allow') { if ($obj['permission'] == 'allow') {
$acl->allow($obj['role'], $obj['resource'], $privilege); $acl->allow($obj['role'], $obj['resource'], $privilege);
} }
else { else {
$acl->deny($obj['role'], $obj['resource'], $privilege); $acl->deny($obj['role'], $obj['resource'], $privilege);
} }
} }
return $acl; return $acl;
} }
} }

View file

@ -1,27 +1,27 @@
<?php <?php
/** /**
* @author markus * @author markus
* $Id: LogoutController.php 12 2009-11-24 13:35:16Z markus $ * $Id: LogoutController.php 12 2009-11-24 13:35:16Z markus $
*/ */
require_once('helpers/GetEnv.php'); require_once('helpers/GetEnv.php');
require_once('config/Config.php'); require_once('config/Config.php');
class LogoutController extends Zend_Controller_Action class LogoutController extends Zend_Controller_Action
{ {
public function init() { public function init() {
/* Initialize action controller here */ /* Initialize action controller here */
} }
public function indexAction() { public function indexAction() {
$session = Zend_Registry::get('session'); $session = Zend_Registry::get('session');
Log::Log()->info(__METHOD__ . ' user logged out ' . $this->view->session->authdata['authed_username']); Log::Log()->info(__METHOD__ . ' user logged out ' . $this->view->session->authdata['authed_username']);
unset($session->authdata); unset($session->authdata);
$session->authdata['authed'] = false; $session->authdata['authed'] = false;
Zend_Session::destroy(); Zend_Session::destroy();
} }
} }

View file

@ -8,60 +8,60 @@ require_once(LIBRARY_PATH . '/imap/imapConnection.php');
class MailController extends Zend_Controller_Action class MailController extends Zend_Controller_Action
{ {
/** /**
* list of email addresses associated with that account * list of email addresses associated with that account
* @var array * @var array
*/ */
private $addresses = array(); private $addresses = array();
public function init() public function init()
{ {
/* Initialize action controller here */ /* Initialize action controller here */
$session = Zend_Registry::get('session'); $session = Zend_Registry::get('session');
$auth = $session->authdata['authed_permissions']; $auth = $session->authdata['authed_permissions'];
$action = $this->getRequest()->getActionName(); $action = $this->getRequest()->getActionName();
$this->view->leftNav('<a href="' . $this->view->leftNav('<a href="' .
$this->view->url(array('controller' => 'mail', 'action' => 'index'), 'default', true) . $this->view->url(array('controller' => 'mail', 'action' => 'index'), 'default', true) .
'"' . (($action == 'index')?' class="active"':'') . '>' . I18n::_('View own Mails') . '</a>', Zend_View_Helper_Placeholder_Container_Abstract::SET, 1); '"' . (($action == 'index')?' class="active"':'') . '>' . I18n::_('View own Mails') . '</a>', Zend_View_Helper_Placeholder_Container_Abstract::SET, 1);
if ($session->authdata['authed_role'] == 'Admin') { if ($session->authdata['authed_role'] == 'Admin') {
$this->view->leftNav('<a href="' . $this->view->leftNav('<a href="' .
$this->view->url(array('controller' => 'mail', 'action' => 'full'), 'default', true) . $this->view->url(array('controller' => 'mail', 'action' => 'full'), 'default', true) .
'"' . (($action == 'full')?' class="active"':'') . '>' . I18n::_('View all Mails') . '</a>', Zend_View_Helper_Placeholder_Container_Abstract::SET, 2); '"' . (($action == 'full')?' class="active"':'') . '>' . I18n::_('View all Mails') . '</a>', Zend_View_Helper_Placeholder_Container_Abstract::SET, 2);
} }
$config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV); $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV);
$db = Zend_Db::factory($config->ca_mgr->db->auth->pdo, $config->ca_mgr->db->auth); $db = Zend_Db::factory($config->ca_mgr->db->auth->pdo, $config->ca_mgr->db->auth);
$emails = new CAcert_User_Emails($db); $emails = new CAcert_User_Emails($db);
$this->addresses = $emails->getEmailAddressesByLogin($session->authdata['authed_username']); $this->addresses = $emails->getEmailAddressesByLogin($session->authdata['authed_username']);
} }
public function indexAction() public function indexAction()
{ {
$config = Zend_Registry::get('config'); $config = Zend_Registry::get('config');
$session = Zend_Registry::get('session'); $session = Zend_Registry::get('session');
$imap_config = $config->imap; $imap_config = $config->imap;
$imap = imapConnection::getInstance('cacert', $imap_config); $imap = imapConnection::getInstance('cacert', $imap_config);
$imap->imapSwitchMbox('INBOX'); $imap->imapSwitchMbox('INBOX');
$ck = $imap->imapCheck(); $ck = $imap->imapCheck();
$headers = array(); $headers = array();
for ($i=0; $i < $ck->Nmsgs; $i++) { for ($i=0; $i < $ck->Nmsgs; $i++) {
$header = $imap->imapHeader($i+1); $header = $imap->imapHeader($i+1);
// skip all emails that do not belong to the user // skip all emails that do not belong to the user
if (!in_array($header->toaddress, $this->addresses)) if (!in_array($header->toaddress, $this->addresses))
continue; continue;
$header->uid = $imap->imapUID($i+1); $header->uid = $imap->imapUID($i+1);
$header->detailslink = $this->view->url(array('controller' => 'mail', 'action' => 'read', 'uid' => $header->uid), 'default', true); $header->detailslink = $this->view->url(array('controller' => 'mail', 'action' => 'read', 'uid' => $header->uid), 'default', true);
$header->deletelink = $this->view->url(array('controller' => 'mail', 'action' => 'delete', 'uid' => $header->uid), 'default', true); $header->deletelink = $this->view->url(array('controller' => 'mail', 'action' => 'delete', 'uid' => $header->uid), 'default', true);
$headers[] = $header; $headers[] = $header;
} }
$this->view->headers = $headers; $this->view->headers = $headers;
@ -69,21 +69,21 @@ class MailController extends Zend_Controller_Action
public function fullAction() public function fullAction()
{ {
$config = Zend_Registry::get('config'); $config = Zend_Registry::get('config');
$imap_config = $config->imap; $imap_config = $config->imap;
$imap = imapConnection::getInstance('cacert', $imap_config); $imap = imapConnection::getInstance('cacert', $imap_config);
$imap->imapSwitchMbox('INBOX'); $imap->imapSwitchMbox('INBOX');
$ck = $imap->imapCheck(); $ck = $imap->imapCheck();
$headers = array(); $headers = array();
for ($i=0; $i < $ck->Nmsgs; $i++) { for ($i=0; $i < $ck->Nmsgs; $i++) {
$header = $imap->imapHeader($i+1); $header = $imap->imapHeader($i+1);
$header->uid = $imap->imapUID($i+1); $header->uid = $imap->imapUID($i+1);
$header->detailslink = $this->view->url(array('controller' => 'mail', 'action' => 'read', 'uid' => $header->uid), 'default', true); $header->detailslink = $this->view->url(array('controller' => 'mail', 'action' => 'read', 'uid' => $header->uid), 'default', true);
$header->deletelink = $this->view->url(array('controller' => 'mail', 'action' => 'delete', 'uid' => $header->uid), 'default', true); $header->deletelink = $this->view->url(array('controller' => 'mail', 'action' => 'delete', 'uid' => $header->uid), 'default', true);
$headers[] = $header; $headers[] = $header;
} }
$this->view->headers = $headers; $this->view->headers = $headers;
@ -91,50 +91,50 @@ class MailController extends Zend_Controller_Action
public function readAction() public function readAction()
{ {
$config = Zend_Registry::get('config'); $config = Zend_Registry::get('config');
$imap_config = $config->imap; $imap_config = $config->imap;
$imap = imapConnection::getInstance('cacert', $imap_config); $imap = imapConnection::getInstance('cacert', $imap_config);
$imap->imapSwitchMbox('INBOX'); $imap->imapSwitchMbox('INBOX');
$uid = $this->getRequest()->getParam('uid'); $uid = $this->getRequest()->getParam('uid');
$body = $imap->imapBodyByUID($uid); $body = $imap->imapBodyByUID($uid);
$this->view->mail_body = $body; $this->view->mail_body = $body;
} }
/** /**
* delete message with unique id * delete message with unique id
*/ */
public function deleteAction() public function deleteAction()
{ {
$config = Zend_Registry::get('config'); $config = Zend_Registry::get('config');
$uid = $this->getRequest()->getParam('uid', -1); $uid = $this->getRequest()->getParam('uid', -1);
$this->view->returnto = $_SERVER['HTTP_REFERER']; $this->view->returnto = $_SERVER['HTTP_REFERER'];
if ($uid == -1) { if ($uid == -1) {
$this->view->message = I18n::_('You did not select an email for deletion'); $this->view->message = I18n::_('You did not select an email for deletion');
} }
elseif ($this->view->returnto == '') { elseif ($this->view->returnto == '') {
$this->view->message = I18n::_('Please use the delete icons in the mail inventory to delete mails'); $this->view->message = I18n::_('Please use the delete icons in the mail inventory to delete mails');
} }
else { else {
$imap_config = $config->imap; $imap_config = $config->imap;
$imap = imapConnection::getInstance('cacert', $imap_config); $imap = imapConnection::getInstance('cacert', $imap_config);
$imap->imapSwitchMbox('INBOX'); $imap->imapSwitchMbox('INBOX');
$header = $imap->imapFetchOverview($uid); $header = $imap->imapFetchOverview($uid);
$session = Zend_Registry::get('session'); $session = Zend_Registry::get('session');
if ($session->authdata['authed_role'] != 'Admin' && !in_array($header->to, $this->addresses)) { if ($session->authdata['authed_role'] != 'Admin' && !in_array($header->to, $this->addresses)) {
$this->view->message = I18n::_('This message does not belong to you'); $this->view->message = I18n::_('This message does not belong to you');
} }
else { else {
$imap->imapDelete($uid); $imap->imapDelete($uid);
$imap->imapExpunge(); $imap->imapExpunge();
$this->view->message = I18n::_('Message deleted'); $this->view->message = I18n::_('Message deleted');
} }
} }
} }
} }

View file

@ -8,12 +8,12 @@ class ManageAccountController extends Zend_Controller_Action
const MAX_POINTS_PER_ASSURANCE = 35; const MAX_POINTS_PER_ASSURANCE = 35;
const MAX_POINTS_TOTAL = 150; const MAX_POINTS_TOTAL = 150;
const ADMIN_INCREASE_FRAGMENT_SIZE = 2; const ADMIN_INCREASE_FRAGMENT_SIZE = 2;
// Value used in the database to identify a admin increase // Value used in the database to identify a admin increase
const ADMIN_INCREASE_METHOD = 'Administrative Increase'; const ADMIN_INCREASE_METHOD = 'Administrative Increase';
protected $db; protected $db;
public function init() public function init()
{ {
$config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini',
@ -21,7 +21,7 @@ class ManageAccountController extends Zend_Controller_Action
$this->db = Zend_Db::factory($config->ca_mgr->db->auth->pdo, $this->db = Zend_Db::factory($config->ca_mgr->db->auth->pdo,
$config->ca_mgr->db->auth); $config->ca_mgr->db->auth);
// Build the left navigation // Build the left navigation
$actions = array(); $actions = array();
$actions['assurance'] = I18n::_('Automated Assurance'); $actions['assurance'] = I18n::_('Automated Assurance');
@ -35,16 +35,16 @@ class ManageAccountController extends Zend_Controller_Action
$link = '<a href="'.$this->view->url($url, 'default', true).'">'. $link = '<a href="'.$this->view->url($url, 'default', true).'">'.
$label . '</a>'; $label . '</a>';
$this->view->leftNav($link); $this->view->leftNav($link);
} }
} }
public function indexAction() public function indexAction()
{ {
// Just render the view // Just render the view
return; return;
} }
public function assuranceAction() public function assuranceAction()
{ {
// Validate form // Validate form
@ -53,13 +53,13 @@ class ManageAccountController extends Zend_Controller_Action
$this->view->assurance_form = $form; $this->view->assurance_form = $form;
return $this->render('assuranceform'); return $this->render('assuranceform');
} }
// Form is valid -> get values for processing // Form is valid -> get values for processing
$values = $form->getValues(); $values = $form->getValues();
// Get the current user // Get the current user
$user = Default_Model_User::findCurrentUser(); $user = Default_Model_User::findCurrentUser();
$this->view->assurancesDone = array(); $this->view->assurancesDone = array();
$quantity = $values['quantity']; $quantity = $values['quantity'];
do { do {
@ -71,56 +71,56 @@ class ManageAccountController extends Zend_Controller_Action
$points = $quantity; $points = $quantity;
$quantity = 0; $quantity = 0;
} }
// Get the assurer for this assurance // Get the assurer for this assurance
$issued = $user->findNewAssurer() $issued = $user->findNewAssurer()
->assure($user, $points, $values['location'], $values['date']); ->assure($user, $points, $values['location'], $values['date']);
$this->view->assurancesDone[] = $issued; $this->view->assurancesDone[] = $issued;
} while ($quantity > 0); } while ($quantity > 0);
return; return;
} }
public function batchAssuranceAction() { public function batchAssuranceAction() {
// Validate form // Validate form
$form = $this->getBatchAssuranceForm(); $form = $this->getBatchAssuranceForm();
if (!$this->getRequest()->isPost() || !$form->isValid($_POST)) { if (!$this->getRequest()->isPost() || !$form->isValid($_POST)) {
$this->view->batch_assurance_form = $form; $this->view->batch_assurance_form = $form;
return $this->render('batch-assurance-form'); return $this->render('batch-assurance-form');
} }
// Form is valid -> get values for processing // Form is valid -> get values for processing
$values = $form->getValues(); $values = $form->getValues();
$user = Default_Model_User::findCurrentUser(); $user = Default_Model_User::findCurrentUser();
$location = $values['location']; $location = $values['location'];
$date = $values['date']; $date = $values['date'];
$this->view->assurances = array(); $this->view->assurances = array();
for ($i = 0; $i < intval($values['quantity']); $i++) { for ($i = 0; $i < intval($values['quantity']); $i++) {
$assuree = $user->findNewAssuree(); $assuree = $user->findNewAssuree();
if ($values['percentage'] === 'percentage') { if ($values['percentage'] === 'percentage') {
$points = ($user->maxpoints() * intval($values['points'])) /100; $points = ($user->maxpoints() * intval($values['points'])) /100;
}elseif ($values['percentage'] === 'absolute') { }elseif ($values['percentage'] === 'absolute') {
$points = intval($values['points']); $points = intval($values['points']);
} }
$user->assure($assuree, $points, $location, $date); $user->assure($assuree, $points, $location, $date);
$this->view->assurances[] = array( $this->view->assurances[] = array(
'assuree'=>$assuree->getPrimEmail(), 'assuree'=>$assuree->getPrimEmail(),
'points'=>$points, 'points'=>$points,
'location'=>$location, 'location'=>$location,
'date'=>$date); 'date'=>$date);
} }
return; return;
} }
public function adminIncreaseAction() public function adminIncreaseAction()
{ {
// Validate form // Validate form
@ -129,16 +129,16 @@ class ManageAccountController extends Zend_Controller_Action
$this->view->admin_increase_form = $form; $this->view->admin_increase_form = $form;
return $this->render('admin-increase-form'); return $this->render('admin-increase-form');
} }
// Form is valid -> get values for processing // Form is valid -> get values for processing
$values = $form->getValues(); $values = $form->getValues();
// Get current user // Get current user
$user = Default_Model_User::findCurrentUser(); $user = Default_Model_User::findCurrentUser();
$this->view->adminIncreasesDone = array(); $this->view->adminIncreasesDone = array();
$points = $values['points']; $points = $values['points'];
// Only assign points within the limit if unlimited flag is not set // Only assign points within the limit if unlimited flag is not set
if ($values['unlimited'] != '1') { if ($values['unlimited'] != '1') {
if ($user->getPoints() >= self::MAX_POINTS_TOTAL) { if ($user->getPoints() >= self::MAX_POINTS_TOTAL) {
@ -148,14 +148,14 @@ class ManageAccountController extends Zend_Controller_Action
$points = self::MAX_POINTS_TOTAL - $user->getPoints(); $points = self::MAX_POINTS_TOTAL - $user->getPoints();
} }
} }
$user->adminIncrease($points, $values['location'], $values['date']); $user->adminIncrease($points, $values['location'], $values['date']);
$this->view->adminIncreasesDone[] = $points; $this->view->adminIncreasesDone[] = $points;
return; return;
} }
public function assurerChallengeAction() public function assurerChallengeAction()
{ {
// Validate form // Validate form
@ -164,27 +164,27 @@ class ManageAccountController extends Zend_Controller_Action
$this->view->assurer_challenge_form = $form; $this->view->assurer_challenge_form = $form;
return $this->render('assurer-challenge-form'); return $this->render('assurer-challenge-form');
} }
// Form is valid -> get values for processing // Form is valid -> get values for processing
$values = $form->getValues(); $values = $form->getValues();
// Get user data // Get user data
$user = Default_Model_User::findCurrentUser(); $user = Default_Model_User::findCurrentUser();
$user->assignChallenge(1, $values['variant']); $user->assignChallenge(1, $values['variant']);
} }
public function flagsAction() public function flagsAction()
{ {
$user = Default_Model_User::findCurrentUser(); $user = Default_Model_User::findCurrentUser();
// Validate form // Validate form
$form = $this->getFlagsForm($user); $form = $this->getFlagsForm($user);
$this->view->flags_form = $form; $this->view->flags_form = $form;
if (!$this->getRequest()->isPost() || !$form->isValid($_POST)) { if (!$this->getRequest()->isPost() || !$form->isValid($_POST)) {
return; return;
} }
$flags = $user->getFlags(); $flags = $user->getFlags();
foreach ($flags as $flag => $value) { foreach ($flags as $flag => $value) {
$element = $form->getElement($flag); $element = $form->getElement($flag);
@ -192,48 +192,48 @@ class ManageAccountController extends Zend_Controller_Action
$flags[$flag] = $element->isChecked(); $flags[$flag] = $element->isChecked();
} }
} }
$user->setFlags($flags); $user->setFlags($flags);
return; return;
} }
protected function getAssuranceForm() protected function getAssuranceForm()
{ {
$form = new Zend_Form(); $form = new Zend_Form();
$form->setAction('/manage-account/assurance')->setMethod('post'); $form->setAction('/manage-account/assurance')->setMethod('post');
$quantity = new Zend_Form_Element_Text('quantity'); $quantity = new Zend_Form_Element_Text('quantity');
$quantity->setRequired(true) $quantity->setRequired(true)
->setLabel(I18n::_('Number of Points')) ->setLabel(I18n::_('Number of Points'))
->addFilter(new Zend_Filter_Int()) ->addFilter(new Zend_Filter_Int())
->addValidator(new Zend_Validate_Between(0, 100)); ->addValidator(new Zend_Validate_Between(0, 100));
$form->addElement($quantity); $form->addElement($quantity);
$location = new Zend_Form_Element_Text('location'); $location = new Zend_Form_Element_Text('location');
$location->setRequired(true) $location->setRequired(true)
->setLabel(I18n::_('Location')) ->setLabel(I18n::_('Location'))
->setValue(I18n::_('CAcert Test Manager')) ->setValue(I18n::_('CAcert Test Manager'))
->addValidator(new Zend_Validate_StringLength(1,255)); ->addValidator(new Zend_Validate_StringLength(1,255));
$form->addElement($location); $form->addElement($location);
$date = new Zend_Form_Element_Text('date'); $date = new Zend_Form_Element_Text('date');
$date->setRequired(true) $date->setRequired(true)
->setLabel(I18n::_('Date of Assurance')) ->setLabel(I18n::_('Date of Assurance'))
->setValue(date('Y-m-d H:i:s')) ->setValue(date('Y-m-d H:i:s'))
->addValidator(new Zend_Validate_StringLength(1,255)); ->addValidator(new Zend_Validate_StringLength(1,255));
$form->addElement($date); $form->addElement($date);
$submit = new Zend_Form_Element_Submit('submit'); $submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel(I18n::_('Assure Me')); $submit->setLabel(I18n::_('Assure Me'));
$form->addElement($submit); $form->addElement($submit);
return $form; return $form;
} }
protected function getBatchAssuranceForm() { protected function getBatchAssuranceForm() {
$form = new Zend_Form(); $form = new Zend_Form();
$form->setAction('/manage-account/batch-assurance')->setMethod('post'); $form->setAction('/manage-account/batch-assurance')->setMethod('post');
$quantity = new Zend_Form_Element_Text('quantity'); $quantity = new Zend_Form_Element_Text('quantity');
$quantity->setRequired(true) $quantity->setRequired(true)
->setLabel(I18n::_('Number of Assurances')) ->setLabel(I18n::_('Number of Assurances'))
@ -241,17 +241,17 @@ class ManageAccountController extends Zend_Controller_Action
->addFilter(new Zend_Filter_Int()) ->addFilter(new Zend_Filter_Int())
->addValidator(new Zend_Validate_Between(0, 100)); ->addValidator(new Zend_Validate_Between(0, 100));
$form->addElement($quantity); $form->addElement($quantity);
$percentage = new Zend_Form_Element_Select('percentage'); $percentage = new Zend_Form_Element_Select('percentage');
$percentage->setRequired(true) $percentage->setRequired(true)
->setLabel(I18n::_('Are the points specified absolute?')) ->setLabel(I18n::_('Are the points specified absolute?'))
->setValue('percentage') ->setValue('percentage')
->setMultiOptions(array( ->setMultiOptions(array(
'percentage' => I18n::_('Percentage'), 'percentage' => I18n::_('Percentage'),
'absolute' => I18n::_('Absolute'), 'absolute' => I18n::_('Absolute'),
)); ));
$form->addElement($percentage); $form->addElement($percentage);
$points = new Zend_Form_Element_Text('points'); $points = new Zend_Form_Element_Text('points');
$points->setRequired(true) $points->setRequired(true)
->setLabel(I18n::_('Points per Assurance')) ->setLabel(I18n::_('Points per Assurance'))
@ -259,73 +259,73 @@ class ManageAccountController extends Zend_Controller_Action
->addFilter(new Zend_Filter_Int()) ->addFilter(new Zend_Filter_Int())
->addValidator(new Zend_Validate_Between(0, 100)); ->addValidator(new Zend_Validate_Between(0, 100));
$form->addElement($points); $form->addElement($points);
$location = new Zend_Form_Element_Text('location'); $location = new Zend_Form_Element_Text('location');
$location->setRequired(true) $location->setRequired(true)
->setLabel(I18n::_('Location')) ->setLabel(I18n::_('Location'))
->setValue(I18n::_('CAcert Test Manager Batch Assurance')) ->setValue(I18n::_('CAcert Test Manager Batch Assurance'))
->addValidator(new Zend_Validate_StringLength(1,255)); ->addValidator(new Zend_Validate_StringLength(1,255));
$form->addElement($location); $form->addElement($location);
$date = new Zend_Form_Element_Text('date'); $date = new Zend_Form_Element_Text('date');
$date->setRequired(true) $date->setRequired(true)
->setLabel(I18n::_('Date of Assurance')) ->setLabel(I18n::_('Date of Assurance'))
->setValue(date('Y-m-d H:i:s')) ->setValue(date('Y-m-d H:i:s'))
->addValidator(new Zend_Validate_StringLength(1,255)); ->addValidator(new Zend_Validate_StringLength(1,255));
$form->addElement($date); $form->addElement($date);
$submit = new Zend_Form_Element_Submit('submit'); $submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel(I18n::_('Make Batch Assurance')); $submit->setLabel(I18n::_('Make Batch Assurance'));
$form->addElement($submit); $form->addElement($submit);
return $form; return $form;
} }
protected function getAdminIncreaseForm() protected function getAdminIncreaseForm()
{ {
$form = new Zend_Form(); $form = new Zend_Form();
$form->setAction('/manage-account/admin-increase')->setMethod('post'); $form->setAction('/manage-account/admin-increase')->setMethod('post');
$points = new Zend_Form_Element_Text('points'); $points = new Zend_Form_Element_Text('points');
$points->setRequired(true) $points->setRequired(true)
->setLabel(I18n::_('Number of Points')) ->setLabel(I18n::_('Number of Points'))
->addFilter(new Zend_Filter_Int()) ->addFilter(new Zend_Filter_Int())
->addValidator(new Zend_Validate_GreaterThan(0)); ->addValidator(new Zend_Validate_GreaterThan(0));
$form->addElement($points); $form->addElement($points);
$unlimited = new Zend_Form_Element_Checkbox('unlimited'); $unlimited = new Zend_Form_Element_Checkbox('unlimited');
$unlimited->setLabel(I18n::_('Assign Points even if the Limit of 150 '. $unlimited->setLabel(I18n::_('Assign Points even if the Limit of 150 '.
'is exceeded')) 'is exceeded'))
->setChecked(false); ->setChecked(false);
$form->addElement($unlimited); $form->addElement($unlimited);
$location = new Zend_Form_Element_Text('location'); $location = new Zend_Form_Element_Text('location');
$location->setRequired(true) $location->setRequired(true)
->setLabel(I18n::_('Location')) ->setLabel(I18n::_('Location'))
->setValue(I18n::_('CAcert Test Manager')) ->setValue(I18n::_('CAcert Test Manager'))
->addValidator(new Zend_Validate_StringLength(1,255)); ->addValidator(new Zend_Validate_StringLength(1,255));
$form->addElement($location); $form->addElement($location);
$date = new Zend_Form_Element_Text('date'); $date = new Zend_Form_Element_Text('date');
$date->setRequired(true) $date->setRequired(true)
->setLabel(I18n::_('Date of Increase')) ->setLabel(I18n::_('Date of Increase'))
->setValue(date('Y-m-d H:i:s')) ->setValue(date('Y-m-d H:i:s'))
->addValidator(new Zend_Validate_StringLength(1,255)); ->addValidator(new Zend_Validate_StringLength(1,255));
$form->addElement($date); $form->addElement($date);
$submit = new Zend_Form_Element_Submit('submit'); $submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel(I18n::_('Give Me Points')); $submit->setLabel(I18n::_('Give Me Points'));
$form->addElement($submit); $form->addElement($submit);
return $form; return $form;
} }
protected function getAssurerChallengeForm() protected function getAssurerChallengeForm()
{ {
$form = new Zend_Form(); $form = new Zend_Form();
$form->setAction('/manage-account/assurer-challenge') $form->setAction('/manage-account/assurer-challenge')
->setMethod('post'); ->setMethod('post');
$variant = new Zend_Form_Element_Select('variant'); $variant = new Zend_Form_Element_Select('variant');
$variant->setLabel(I18n::_('Variant')); $variant->setLabel(I18n::_('Variant'));
$options = $options =
@ -333,22 +333,22 @@ class ManageAccountController extends Zend_Controller_Action
$variant->setMultiOptions($options) $variant->setMultiOptions($options)
->setRequired(true); ->setRequired(true);
$form->addElement($variant); $form->addElement($variant);
$submit = new Zend_Form_Element_Submit('submit'); $submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel(I18n::_('Challenge Me')); $submit->setLabel(I18n::_('Challenge Me'));
$form->addElement($submit); $form->addElement($submit);
return $form; return $form;
} }
protected function getFlagsForm(Default_Model_User $user) protected function getFlagsForm(Default_Model_User $user)
{ {
$form = new Zend_Form(); $form = new Zend_Form();
$form->setAction('/manage-account/flags') $form->setAction('/manage-account/flags')
->setMethod('post'); ->setMethod('post');
$flags = $user->getFlags(); $flags = $user->getFlags();
// Add a checkbox for each flag // Add a checkbox for each flag
$labels = array(); $labels = array();
$labels['admin'] = I18n::_('Support Engineer'); $labels['admin'] = I18n::_('Support Engineer');
@ -360,18 +360,18 @@ class ManageAccountController extends Zend_Controller_Action
$labels['tverify'] = I18n::_('TVerify'); $labels['tverify'] = I18n::_('TVerify');
$labels['locked'] = I18n::_('Lock Account'); $labels['locked'] = I18n::_('Lock Account');
$labels['assurer_blocked'] = I18n::_('Block Assurer'); $labels['assurer_blocked'] = I18n::_('Block Assurer');
foreach ($labels as $flag => $label) { foreach ($labels as $flag => $label) {
$checkbox = new Zend_Form_Element_Checkbox($flag); $checkbox = new Zend_Form_Element_Checkbox($flag);
$checkbox->setLabel($label) $checkbox->setLabel($label)
->setChecked($flags[$flag]); ->setChecked($flags[$flag]);
$form->addElement($checkbox); $form->addElement($checkbox);
} }
$submit = new Zend_Form_Element_Submit('submit'); $submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel(I18n::_('Save Flags')); $submit->setLabel(I18n::_('Save Flags'));
$form->addElement($submit); $form->addElement($submit);
return $form; return $form;
} }
} }

View file

@ -1,32 +1,32 @@
<?php <?php
// application/layouts/scripts/layout.phtml // application/layouts/scripts/layout.phtml
print $this->doctype(); ?> print $this->doctype(); ?>
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php print $this->headTitle; ?></title> <title><?php print $this->headTitle; ?></title>
<?php print $this->headLink()->prependStylesheet('/css/global.css'); ?> <?php print $this->headLink()->prependStylesheet('/css/global.css'); ?>
<?php print $this->headScript()->appendFile('/js/positionUserInfo.js'); // ->appendFile('/js/center.js'); ?> <?php print $this->headScript()->appendFile('/js/positionUserInfo.js'); // ->appendFile('/js/center.js'); ?>
</head> </head>
<body> <body>
<div id="center"> <div id="center">
<div id="header"> <div id="header">
<div id="header-logo"> <div id="header-logo">
<img src="/img/cacert4.png" border="0" alt="CACert Logo" width="100px" height="30px"> <img src="/img/cacert4.png" border="0" alt="CACert Logo" width="100px" height="30px">
</div> </div>
<div id="header-navigation"> <div id="header-navigation">
<?php print $this->topNav(); ?> <?php print $this->topNav(); ?>
</div> </div>
</div> </div>
<div id="left-navigation"> <div id="left-navigation">
<?php print $this->leftNav(); ?> <?php print $this->leftNav(); ?>
</div> </div>
<div id="content"> <div id="content">
<?php print $this->layout()->content; ?> <?php print $this->layout()->content; ?>
</div> </div>
</div> </div>
<? print $this->userInfo(); ?> <? print $this->userInfo(); ?>
</body> </body>
</html> </html>

View file

@ -5,20 +5,20 @@
class Default_Model_User { class Default_Model_User {
protected $db; protected $db;
protected $id; protected $id;
protected $points = null; protected $points = null;
protected function __construct(Zend_Db_Adapter_Abstract $db, $id) { protected function __construct(Zend_Db_Adapter_Abstract $db, $id) {
// Not allowed to create new users from within the manager // Not allowed to create new users from within the manager
$this->db = $db; $this->db = $db;
$this->id = $id; $this->id = $id;
} }
/** /**
* Get an user object for the given ID * Get an user object for the given ID
* *
* @param $id int * @param $id int
* @return Default_Model_User * @return Default_Model_User
*/ */
@ -29,7 +29,7 @@ class Default_Model_User {
APPLICATION_ENV); APPLICATION_ENV);
$db = Zend_Db::factory($config->ca_mgr->db->auth->pdo, $db = Zend_Db::factory($config->ca_mgr->db->auth->pdo,
$config->ca_mgr->db->auth); $config->ca_mgr->db->auth);
// Check if the ID is present on the test server // Check if the ID is present on the test server
$query = 'select `id` from `users` where `id` = :user'; $query = 'select `id` from `users` where `id` = :user';
$query_params['user'] = $id; $query_params['user'] = $id;
@ -39,13 +39,13 @@ class Default_Model_User {
__METHOD__ . ': user ID not found in the data base'); __METHOD__ . ': user ID not found in the data base');
} }
$row = $result->fetch(); $row = $result->fetch();
return new Default_Model_User($db, $row['id']); return new Default_Model_User($db, $row['id']);
} }
/** /**
* Get an user object for the currently logged in user * Get an user object for the currently logged in user
* *
* @return Default_Model_User * @return Default_Model_User
*/ */
public static function findCurrentUser() { public static function findCurrentUser() {
@ -54,130 +54,114 @@ class Default_Model_User {
throw new Exception( throw new Exception(
__METHOD__ . ': you need to log in to use this feature'); __METHOD__ . ': you need to log in to use this feature');
} }
return self::findById($session->authdata['authed_id']); return self::findById($session->authdata['authed_id']);
} }
/** /**
* Get the first assurer who didn't already assure the user * Get the first assurer who didn't already assure the user
* *
* @return Default_Model_User * @return Default_Model_User
*/ */
public function findNewAssurer() public function findNewAssurer()
{ {
$query = 'select min(`id`) as `assurer` from `users` ' . $query = 'select min(`id`) as `assurer` from `users` ' .
'where `email` like \'john.doe-___@example.com\' and ' . 'where `email` like \'john.doe-___@example.com\' and ' .
'`id` not in (select `from` from `notary` where `to` = :user)'; '`id` not in (select `from` from `notary` where `to` = :user)';
$query_params['user'] = $this->id; $query_params['user'] = $this->id;
$row = $this->db->query($query, $query_params)->fetch(); $row = $this->db->query($query, $query_params)->fetch();
if ($row['assurer'] === NULL) { if ($row['assurer'] === NULL) {
throw new Exception( throw new Exception(
__METHOD__ . ': no more assurers that haven\'t already '. __METHOD__ . ': no more assurers that haven\'t already '.
'assured this account'); 'assured this account');
} }
return new Default_Model_User($this->db, $row['assurer']); return new Default_Model_User($this->db, $row['assurer']);
} }
/** /**
* Get the first assuree who hasn't already been assured by this user * Get the first assuree who hasn't already been assured by this user
* *
* @return Default_Model_User * @return Default_Model_User
*/ */
public function findNewAssuree() { public function findNewAssuree() {
$query = 'select min(`id`) as `assuree` from `users` ' . $query = 'select min(`id`) as `assuree` from `users` ' .
'where `email` like \'john.doe-___@example.com\' and ' . 'where `email` like \'john.doe-___@example.com\' and ' .
'`id` not in (select `to` from `notary` where `from` = :user)'; '`id` not in (select `to` from `notary` where `from` = :user)';
$query_params['user'] = $this->id; $query_params['user'] = $this->id;
$row = $this->db->query($query, $query_params)->fetch(); $row = $this->db->query($query, $query_params)->fetch();
if ($row['assuree'] === NULL) { if ($row['assuree'] === NULL) {
throw new Exception( throw new Exception(
__METHOD__ . ': no more assurees that haven\'t already '. __METHOD__ . ': no more assurees that haven\'t already '.
'been assured by this account'); 'been assured by this account');
} }
return new Default_Model_User($this->db, $row['assuree']); return new Default_Model_User($this->db, $row['assuree']);
} }
/** /**
* Refresh the current value of points from the test server * Refresh the current value of points from the test server
* *
* Needed if operations outside this class are made, that might affect the * Needed if operations outside this class are made, that might affect the
* user's points * user's points
*/ */
public function refreshPoints() { public function refreshPoints() {
$query = "SELECT SUM(`points`) AS `total` FROM `notary` " . $query = 'select sum(`points`) as `total` from `notary` '.
"WHERE `to` = :user AND `method` != 'Administrative Increase' AND `from` != `to`"; 'where `to` = :user';
$query_params['user'] = $this->id; $query_params['user'] = $this->id;
$row = $this->db->query($query, $query_params)->fetch(); $row = $this->db->query($query, $query_params)->fetch();
if ($row['total'] === null) $row['total'] = 0; if ($row['total'] === null) $row['total'] = 0;
$this->points = $row['total']; $this->points = $row['total'];
if($this->points < 100) return;
$this->points = 100;
$query = "SELECT COUNT(`points`) AS `total` FROM `notary` " .
"WHERE `from` = :user AND `method` = 'Face to Face Meeting' AND `from` != `to`";
$query_params['user'] = $this->id;
$row = $this->db->query($query, $query_params)->fetch();
if ($row['total'] === null) $row['total'] = 0;
$this->points += ($row['total'] > 25) ? 50 : 2 * $row['total'];
} }
/** /**
* Get points of the user * Get points of the user
* *
* @return int * @return int
* The amount of points the user has * The amount of points the user has
*/ */
public function getPoints() public function getPoints()
{ {
if ($this->points === null) { if ($this->points === null) {
$this->refreshPoints(); $this->refreshPoints();
} }
return $this->points; return $this->points;
} }
/** /**
* Fix the assurer flag for the user * Fix the assurer flag for the user
*/ */
public function fixAssurerFlag() public function fixAssurerFlag()
{ {
// TODO: unset flag if requirements are not met // TODO: unset flag if requirements are not met
$query = 'UPDATE `users` SET `assurer` = 1 WHERE `users`.`id` = :user AND '. $query = 'UPDATE `users` SET `assurer` = 1 WHERE `users`.`id` = :user AND '.
'EXISTS(SELECT * FROM `cats_passed` AS `cp`, `cats_variant` AS `cv` '. 'EXISTS(SELECT * FROM `cats_passed` AS `cp`, `cats_variant` AS `cv` '.
'WHERE `cp`.`variant_id` = `cv`.`id` AND `cv`.`type_id` = 1 AND '. 'WHERE `cp`.`variant_id` = `cv`.`id` AND `cv`.`type_id` = 1 AND '.
'`cp`.`user_id` = :user) AND '. '`cp`.`user_id` = :user) AND '.
'(SELECT SUM(`points`) FROM `notary` WHERE `to` = :user AND '. '(SELECT SUM(`points`) FROM `notary` WHERE `to` = :user AND '.
'`expire` < now()) >= 100'; '`expire` < now()) >= 100';
$query_params['user'] = $this->id; $query_params['user'] = $this->id;
$this->db->query($query, $query_params); $this->db->query($query, $query_params);
$this->refreshPoints();
} }
/** /**
* @return boolean * @return boolean
*/ */
public function getAssurerStatus() { public function getAssurerStatus() {
$this->refreshPoints();
$query = 'SELECT 1 FROM `users` WHERE `users`.`id` = :user AND '. $query = 'SELECT 1 FROM `users` WHERE `users`.`id` = :user AND '.
'`assurer_blocked` = 0 AND '. '`assurer_blocked` = 0 AND '.
'EXISTS(SELECT * FROM `cats_passed` AS `cp`, `cats_variant` AS `cv` '. 'EXISTS(SELECT * FROM `cats_passed` AS `cp`, `cats_variant` AS `cv` '.
'WHERE `cp`.`variant_id` = `cv`.`id` AND `cv`.`type_id` = 1 AND '. 'WHERE `cp`.`variant_id` = `cv`.`id` AND `cv`.`type_id` = 1 AND '.
'`cp`.`user_id` = :user) AND '. '`cp`.`user_id` = :user) AND '.
'(SELECT SUM(`points`) FROM `notary` WHERE `to` = :user AND '. '(SELECT SUM(`points`) FROM `notary` WHERE `to` = :user AND '.
'`expire` < now()) >= 100'; '`expire` < now()) >= 100';
$query_params['user'] = $this->id; $query_params['user'] = $this->id;
@ -185,10 +169,10 @@ class Default_Model_User {
if ($result->rowCount() === 1) { if ($result->rowCount() === 1) {
return true; return true;
} }
return false; return false;
} }
/** /**
* @return Zend_Date * @return Zend_Date
*/ */
@ -196,10 +180,10 @@ class Default_Model_User {
$query = 'select `dob` from `users` where `id` = :user'; $query = 'select `dob` from `users` where `id` = :user';
$query_params['user'] = $this->id; $query_params['user'] = $this->id;
$row = $this->db->query($query, $query_params)->fetch(); $row = $this->db->query($query, $query_params)->fetch();
return new Zend_Date($row['dob'], Zend_Date::ISO_8601); return new Zend_Date($row['dob'], Zend_Date::ISO_8601);
} }
/** /**
* @return int * @return int
*/ */
@ -207,16 +191,16 @@ class Default_Model_User {
$now = new Zend_Date(); $now = new Zend_Date();
$dob = $this->getDob(); $dob = $this->getDob();
$age = $now->get(Zend_Date::YEAR) - $dob->get(Zend_Date::YEAR); $age = $now->get(Zend_Date::YEAR) - $dob->get(Zend_Date::YEAR);
// Did we have a happy birthday already this year? // Did we have a happy birthday already this year?
$dob->setYear($now); $dob->setYear($now);
if ($dob->compare($now) > 0) { if ($dob->compare($now) > 0) {
$age -= 1; $age -= 1;
} }
return $age; return $age;
} }
/** /**
* @return string * @return string
*/ */
@ -224,43 +208,44 @@ class Default_Model_User {
$query = 'select `email` from `users` where `id` = :user'; $query = 'select `email` from `users` where `id` = :user';
$query_params['user'] = $this->id; $query_params['user'] = $this->id;
$row = $this->db->query($query, $query_params)->fetch(); $row = $this->db->query($query, $query_params)->fetch();
return $row['email']; return $row['email'];
} }
/** /**
* Assure another user. Usual restrictions apply * Assure another user. Usual restrictions apply
* *
* @param $assuree Default_Model_User * @param $assuree Default_Model_User
* @param $points int * @param $points int
* @param $location string * @param $location string
* @param $date string * @param $date string
* @throws Exception * @throws Exception
* *
* @return int * @return int
* The amount of points that have been issued (might be less than * The amount of points that have been issued (might be less than
* $points) * $points)
*/ */
public function assure(Default_Model_User $assuree, $points, $location, $date) { public function assure(Default_Model_User $assuree, $points, $location,
$date) {
// Sanitize inputs // Sanitize inputs
$points = intval($points); $points = intval($points);
$location = stripslashes($location); $location = stripslashes($location);
$date = stripslashes($date); $date = stripslashes($date);
if (!$this->getAssurerStatus()) { if (!$this->getAssurerStatus()) {
throw new Exception( throw new Exception(
__METHOD__ . ': '.$this->id.' needs to be an assurer to do '. __METHOD__ . ': '.$this->id.' needs to be an assurer to do '.
'assurances'); 'assurances');
} }
if ($this->id === $assuree->id) { if ($this->id === $assuree->id) {
throw new Exception( throw new Exception(
__METHOD__ . ': '.$this->id.' is not allowed to assure '. __METHOD__ . ': '.$this->id.' is not allowed to assure '.
'himself'); 'himself');
} }
$query = 'select * from `notary` where `from`= :assurer and '. $query = 'select * from `notary` where `from`= :assurer and '.
'`to`= :assuree'; '`to`= :assuree';
$query_params['assurer'] = $this->id; $query_params['assurer'] = $this->id;
$query_params['assuree'] = $assuree->id; $query_params['assuree'] = $assuree->id;
$result = $this->db->query($query, $query_params); $result = $this->db->query($query, $query_params);
@ -269,11 +254,11 @@ class Default_Model_User {
__METHOD__ . ': '.$this->id.' is not allowed to assure '. __METHOD__ . ': '.$this->id.' is not allowed to assure '.
$assuree->id .' more than once'); $assuree->id .' more than once');
} }
// Respect the maximum points // Respect the maximum points
$max = $this->maxpoints(); $max = $this->maxpoints();
$points = min($points, $max); $points = min($points, $max);
$rounddown = $points; $rounddown = $points;
if ($max < 100) { if ($max < 100) {
if ($assuree->getPoints() + $points > 100) if ($assuree->getPoints() + $points > 100)
@ -283,10 +268,10 @@ class Default_Model_User {
$rounddown = $max - $assuree->getPoints(); $rounddown = $max - $assuree->getPoints();
} }
if ($rounddown < 0) $rounddown = 0; if ($rounddown < 0) $rounddown = 0;
$query = 'select * from `notary` where `from` = :assurer and '. $query = 'select * from `notary` where `from` = :assurer and '.
'`to` = :assuree and `awarded` = :points and '. '`to` = :assuree and `awarded` = :points and '.
'`location` = :location and `date` = :date'; '`location` = :location and `date` = :date';
$query_params['assurer'] = $this->id; $query_params['assurer'] = $this->id;
$query_params['assuree'] = $assuree->id; $query_params['assuree'] = $assuree->id;
$query_params['points'] = $points; $query_params['points'] = $points;
@ -298,7 +283,7 @@ class Default_Model_User {
__METHOD__ . ': '.$this->id.' is not allowed to do the same '. __METHOD__ . ': '.$this->id.' is not allowed to do the same '.
'assurance to '.$assuree->id.' more than once'); 'assurance to '.$assuree->id.' more than once');
} }
// Make sure it is empty // Make sure it is empty
$assurance = array(); $assurance = array();
$assurance['from'] = $this->id; $assurance['from'] = $this->id;
@ -308,16 +293,28 @@ class Default_Model_User {
$assurance['location'] = $location; $assurance['location'] = $location;
$assurance['date'] = $date; $assurance['date'] = $date;
$assurance['when'] = new Zend_Db_Expr('now()'); $assurance['when'] = new Zend_Db_Expr('now()');
$this->db->insert('notary', $assurance); $this->db->insert('notary', $assurance);
$assuree->points += $rounddown; $assuree->points += $rounddown;
$assuree->fixAssurerFlag(); $assuree->fixAssurerFlag();
if ($this->getPoints() < 150) {
$addpoints = 0;
if ($this->getPoints() < 149 && $this->getPoints() >= 100) {
$addpoints = 2;
} elseif ($this->getPoints() === 149) {
$addpoints = 1;
}
$this->adminIncrease($addpoints, $location, $date);
}
return $rounddown; return $rounddown;
} }
/** /**
* Do an administrative increase * Do an administrative increase
* *
* @param $points int * @param $points int
* @param $location string * @param $location string
* @param $date string * @param $date string
@ -327,7 +324,7 @@ class Default_Model_User {
$points = intval($points); $points = intval($points);
$location = stripslashes($location); $location = stripslashes($location);
$date = stripslashes($date); $date = stripslashes($date);
$increase = array(); $increase = array();
$increase['from'] = $this->id; $increase['from'] = $this->id;
$increase['to'] = $this->id; $increase['to'] = $this->id;
@ -337,23 +334,23 @@ class Default_Model_User {
$increase['date'] = $date; $increase['date'] = $date;
$increase['method'] = 'Administrative Increase'; $increase['method'] = 'Administrative Increase';
$increase['when'] = new Zend_Db_Expr('now()'); $increase['when'] = new Zend_Db_Expr('now()');
$this->db->insert('notary', $increase); $this->db->insert('notary', $increase);
$this->points += $points; $this->points += $points;
$this->fixAssurerFlag(); $this->fixAssurerFlag();
} }
/** /**
* Maximum number of points the user may issue * Maximum number of points the user may issue
* *
* @return int * @return int
*/ */
public function maxpoints() { public function maxpoints() {
if (!$this->getAssurerStatus()) return 0; if (!$this->getAssurerStatus()) return 0;
if ($this->getAge() < 18) return 10; if ($this->getAge() < 18) return 10;
$points = $this->getPoints(); $points = $this->getPoints();
if ($points >= 300) return 200; if ($points >= 300) return 200;
if ($points >= 200) return 150; if ($points >= 200) return 150;
@ -363,18 +360,18 @@ class Default_Model_User {
if ($points >= 120) return 20; if ($points >= 120) return 20;
if ($points >= 110) return 15; if ($points >= 110) return 15;
if ($points >= 100) return 10; if ($points >= 100) return 10;
// Should not get here // Should not get here
throw new Exception( throw new Exception(
__METHOD__ . ': '.$this->id.' We have reached unreachable code'); __METHOD__ . ': '.$this->id.' We have reached unreachable code');
} }
/** /**
* Get the challenge types that are available in the database * Get the challenge types that are available in the database
* *
* @param $db Zend_Db_Adapter_Abstract * @param $db Zend_Db_Adapter_Abstract
* The database connection to use * The database connection to use
* *
* @return array(int => string) * @return array(int => string)
*/ */
public static function getAvailableChallengeTypes( public static function getAvailableChallengeTypes(
@ -382,16 +379,16 @@ class Default_Model_User {
$query = 'select `id`, `type_text` from `cats_type`'; $query = 'select `id`, `type_text` from `cats_type`';
return $db->fetchPairs($query); return $db->fetchPairs($query);
} }
/** /**
* Get the challenge variants for this type that are available in the * Get the challenge variants for this type that are available in the
* database * database
* *
* @param $db Zend_Db_Adapter_Abstract * @param $db Zend_Db_Adapter_Abstract
* The database connection to use * The database connection to use
* @param $type int * @param $type int
* The type of challenge you want to get the variants of * The type of challenge you want to get the variants of
* *
* @return array(int => string) * @return array(int => string)
*/ */
public static function getAvailableChallengeVariants( public static function getAvailableChallengeVariants(
@ -401,15 +398,15 @@ class Default_Model_User {
$query_params['type'] = $type; $query_params['type'] = $type;
return $db->fetchPairs($query, $query_params); return $db->fetchPairs($query, $query_params);
} }
/** /**
* Assign the challenge to the user * Assign the challenge to the user
* *
* @param $type int * @param $type int
* The type of the challenge, has to be one of the keys returned by * The type of the challenge, has to be one of the keys returned by
* getAvailableChallengeTypes() * getAvailableChallengeTypes()
* @param $variant int * @param $variant int
* The variant of the challenge, has to be one of the keys returned by * The variant of the challenge, has to be one of the keys returned by
* getAvailableChallengeVariants() * getAvailableChallengeVariants()
* @param $date Zend_Date * @param $date Zend_Date
* The date the challenge was passed, defaults to current time * The date the challenge was passed, defaults to current time
@ -421,14 +418,14 @@ class Default_Model_User {
__METHOD__ . ': got wrong challenge type '.$type.' when '. __METHOD__ . ': got wrong challenge type '.$type.' when '.
'assigning challenge to user '.$this->id); 'assigning challenge to user '.$this->id);
} }
$variants = self::getAvailableChallengeVariants($this->db, $type); $variants = self::getAvailableChallengeVariants($this->db, $type);
if (!isset($variants[$variant])) { if (!isset($variants[$variant])) {
throw new Exception( throw new Exception(
__METHOD__ . ': got wrong challenge variant '.$variant.' when '. __METHOD__ . ': got wrong challenge variant '.$variant.' when '.
'assigning challenge to user '.$this->id); 'assigning challenge to user '.$this->id);
} }
$challenge = array(); $challenge = array();
$challenge['user_id'] = $this->id; $challenge['user_id'] = $this->id;
$challenge['variant_id'] = $variant; $challenge['variant_id'] = $variant;
@ -436,21 +433,21 @@ class Default_Model_User {
$challenge['pass_date'] = $date->toString('Y-m-d H:i:s'); $challenge['pass_date'] = $date->toString('Y-m-d H:i:s');
// otherwise default value of the database will be used // otherwise default value of the database will be used
} }
$this->db->insert('cats_passed', $challenge); $this->db->insert('cats_passed', $challenge);
$this->fixAssurerFlag(); $this->fixAssurerFlag();
} }
/** /**
* Get the flags that are set * Get the flags that are set
* *
* @return array (string => boolean) * @return array (string => boolean)
*/ */
public function getFlags() { public function getFlags() {
$flags = $this->db->select()->from('users', self::flags()) $flags = $this->db->select()->from('users', self::flags())
->where('`id` = ?', $this->id)->query()->fetch(); ->where('`id` = ?', $this->id)->query()->fetch();
foreach ($flags as $key => $value) { foreach ($flags as $key => $value) {
if ($value === '0') { if ($value === '0') {
$flags[$key] = false; $flags[$key] = false;
@ -458,20 +455,20 @@ class Default_Model_User {
$flags[$key] = true; $flags[$key] = true;
} }
} }
return $flags; return $flags;
} }
/** /**
* Set the flags - to know which flags exist you might want to call * Set the flags - to know which flags exist you might want to call
* getFlags() first * getFlags() first
* *
* @param $flags array (string => boolean) * @param $flags array (string => boolean)
* Currently unknown flags are silently ignored * Currently unknown flags are silently ignored
*/ */
public function setFlags(array $flags) { public function setFlags(array $flags) {
$newflags = array(); $newflags = array();
// filter values // filter values
foreach (self::flags() as $flag) { foreach (self::flags() as $flag) {
if (isset($flags[$flag])) { if (isset($flags[$flag])) {
@ -482,11 +479,11 @@ class Default_Model_User {
} }
} }
} }
$where = $this->db->quoteInto('`id` = ?', $this->id, Zend_Db::INT_TYPE); $where = $this->db->quoteInto('`id` = ?', $this->id, Zend_Db::INT_TYPE);
$this->db->update('users', $newflags, $where); $this->db->update('users', $newflags, $where);
} }
/** /**
* The flags from the `users` table that might be set * The flags from the `users` table that might be set
*/ */
@ -507,4 +504,4 @@ class Default_Model_User {
'assurer', 'assurer',
'assurer_blocked'); 'assurer_blocked');
} }
} }

View file

@ -1,96 +1,96 @@
<?php <?php
/** /**
* Zend Framework * Zend Framework
* *
* LICENSE * LICENSE
* *
* This source file is subject to the new BSD license that is bundled * This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt. * with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL: * It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd * http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to * If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email * obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately. * to license@zend.com so we can send you a copy immediately.
* *
* @category Zend * @category Zend
* @package Zend_View * @package Zend_View
* @subpackage Helper * @subpackage Helper
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id: LeftNav.php 8 2009-11-24 10:32:47Z markus $ * @version $Id: LeftNav.php 8 2009-11-24 10:32:47Z markus $
* @license http://framework.zend.com/license/new-bsd New BSD License * @license http://framework.zend.com/license/new-bsd New BSD License
*/ */
/** Zend_View_Helper_Placeholder_Container_Standalone */ /** Zend_View_Helper_Placeholder_Container_Standalone */
require_once 'Zend/View/Helper/Placeholder/Container/Standalone.php'; require_once 'Zend/View/Helper/Placeholder/Container/Standalone.php';
/** /**
* Helper for building an applications top navigation bar * Helper for building an applications top navigation bar
* *
* @uses Zend_View_Helper_Placeholder_Container_Standalone * @uses Zend_View_Helper_Placeholder_Container_Standalone
* @package Zend_View * @package Zend_View
* @subpackage Helper * @subpackage Helper
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License * @license http://framework.zend.com/license/new-bsd New BSD License
*/ */
class Zend_View_Helper_LeftNav extends Zend_View_Helper_Placeholder_Container_Standalone class Zend_View_Helper_LeftNav extends Zend_View_Helper_Placeholder_Container_Standalone
{ {
/** /**
* Registry key for placeholder * Registry key for placeholder
* @var string * @var string
*/ */
protected $_regKey = 'Zend_View_Helper_LeftNav'; protected $_regKey = 'Zend_View_Helper_LeftNav';
protected $items = array(); protected $items = array();
/** /**
* Retrieve placeholder for navigation element and optionally set state * Retrieve placeholder for navigation element and optionally set state
* *
* Single Link elements to be made with $this->url(array('controller'=>'<controller>'), 'default', true); * Single Link elements to be made with $this->url(array('controller'=>'<controller>'), 'default', true);
* *
* @param string $link * @param string $link
* @param string $setType * @param string $setType
* @param string $setPos * @param string $setPos
* @return Zend_View_Helper_LeftNav * @return Zend_View_Helper_LeftNav
*/ */
public function leftNav($link = null, $setType = Zend_View_Helper_Placeholder_Container_Abstract::APPEND, $setPos = 0) public function leftNav($link = null, $setType = Zend_View_Helper_Placeholder_Container_Abstract::APPEND, $setPos = 0)
{ {
$link = (string) $link; $link = (string) $link;
if ($link !== '') { if ($link !== '') {
if ($setType == Zend_View_Helper_Placeholder_Container_Abstract::SET) { if ($setType == Zend_View_Helper_Placeholder_Container_Abstract::SET) {
if ($setPos != 0) if ($setPos != 0)
$this->items[$setPos] = $link; $this->items[$setPos] = $link;
else else
$this->items[] = $link; $this->items[] = $link;
} elseif ($setType == Zend_View_Helper_Placeholder_Container_Abstract::PREPEND) { } elseif ($setType == Zend_View_Helper_Placeholder_Container_Abstract::PREPEND) {
$this->items = array_merge(array($link), $this->items); $this->items = array_merge(array($link), $this->items);
} else { } else {
$this->items[] = $link; $this->items[] = $link;
} }
} }
return $this; return $this;
} }
/** /**
* Turn helper into string * Turn helper into string
* *
* @param string|null $indent * @param string|null $indent
* @param string|null $locale * @param string|null $locale
* @return string * @return string
*/ */
public function toString($indent = null, $locale = null) public function toString($indent = null, $locale = null)
{ {
$output = ''; $output = '';
$indent = (null !== $indent) $indent = (null !== $indent)
? $this->getWhitespace($indent) ? $this->getWhitespace($indent)
: $this->getIndent(); : $this->getIndent();
$output .= $indent . "<ul>\n"; $output .= $indent . "<ul>\n";
foreach ($this->items as $item) { foreach ($this->items as $item) {
$output .= $indent . "<li>" . $item . "</li>\n"; $output .= $indent . "<li>" . $item . "</li>\n";
} }
$output .= $indent . "</ul>\n"; $output .= $indent . "</ul>\n";
return $output; return $output;
} }
} }

View file

@ -1,99 +1,99 @@
<?php <?php
/** /**
* Zend Framework * Zend Framework
* *
* LICENSE * LICENSE
* *
* This source file is subject to the new BSD license that is bundled * This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt. * with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL: * It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd * http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to * If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email * obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately. * to license@zend.com so we can send you a copy immediately.
* *
* @category Zend * @category Zend
* @package Zend_View * @package Zend_View
* @subpackage Helper * @subpackage Helper
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id: TopNav.php 20 2009-12-01 14:26:22Z markus $ * @version $Id: TopNav.php 20 2009-12-01 14:26:22Z markus $
* @license http://framework.zend.com/license/new-bsd New BSD License * @license http://framework.zend.com/license/new-bsd New BSD License
*/ */
/** Zend_View_Helper_Placeholder_Container_Standalone */ /** Zend_View_Helper_Placeholder_Container_Standalone */
require_once 'Zend/View/Helper/Placeholder/Container/Standalone.php'; require_once 'Zend/View/Helper/Placeholder/Container/Standalone.php';
/** /**
* Helper for building an applications top navigation bar * Helper for building an applications top navigation bar
* *
* @uses Zend_View_Helper_Placeholder_Container_Standalone * @uses Zend_View_Helper_Placeholder_Container_Standalone
* @package Zend_View * @package Zend_View
* @subpackage Helper * @subpackage Helper
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License * @license http://framework.zend.com/license/new-bsd New BSD License
*/ */
class Zend_View_Helper_TopNav extends Zend_View_Helper_Placeholder_Container_Standalone class Zend_View_Helper_TopNav extends Zend_View_Helper_Placeholder_Container_Standalone
{ {
/** /**
* Registry key for placeholder * Registry key for placeholder
* @var string * @var string
*/ */
protected $_regKey = 'Zend_View_Helper_TopNav'; protected $_regKey = 'Zend_View_Helper_TopNav';
protected $items = array(); protected $items = array();
/** /**
* Retrieve placeholder for navigation element and optionally set state * Retrieve placeholder for navigation element and optionally set state
* *
* Single Link elements to be made with $this->url(array('controller'=>'<controller>'), 'default', true); * Single Link elements to be made with $this->url(array('controller'=>'<controller>'), 'default', true);
* *
* @param string $link * @param string $link
* @param string $setType * @param string $setType
* @param string $setPos * @param string $setPos
* @return Zend_View_Helper_TopNav * @return Zend_View_Helper_TopNav
*/ */
public function topNav($link = null, $setType = Zend_View_Helper_Placeholder_Container_Abstract::APPEND, $setPos = 0) public function topNav($link = null, $setType = Zend_View_Helper_Placeholder_Container_Abstract::APPEND, $setPos = 0)
{ {
$link = (string) $link; $link = (string) $link;
if ($link !== '') { if ($link !== '') {
if ($setType == Zend_View_Helper_Placeholder_Container_Abstract::SET) { if ($setType == Zend_View_Helper_Placeholder_Container_Abstract::SET) {
if ($setPos != 0) if ($setPos != 0)
$this->items[$setPos] = $link; $this->items[$setPos] = $link;
else else
$this->items[] = $link; $this->items[] = $link;
} elseif ($setType == Zend_View_Helper_Placeholder_Container_Abstract::PREPEND) { } elseif ($setType == Zend_View_Helper_Placeholder_Container_Abstract::PREPEND) {
$this->items = array_merge(array($link), $this->items); $this->items = array_merge(array($link), $this->items);
} else { } else {
$this->items[] = $link; $this->items[] = $link;
} }
} }
return $this; return $this;
} }
/** /**
* Turn helper into string * Turn helper into string
* *
* @param string|null $indent * @param string|null $indent
* @param string|null $locale * @param string|null $locale
* @return string * @return string
*/ */
public function toString($indent = null, $locale = null) public function toString($indent = null, $locale = null)
{ {
$output = ''; $output = '';
$indent = (null !== $indent) $indent = (null !== $indent)
? $this->getWhitespace($indent) ? $this->getWhitespace($indent)
: $this->getIndent(); : $this->getIndent();
ksort($this->items); ksort($this->items);
$output .= $indent . "<ul>\n"; $output .= $indent . "<ul>\n";
foreach ($this->items as $item) { foreach ($this->items as $item) {
$output .= $indent . "<li>" . $item . "</li>\n"; $output .= $indent . "<li>" . $item . "</li>\n";
} }
$output .= $indent . "</ul>\n"; $output .= $indent . "</ul>\n";
return $output; return $output;
} }
} }

View file

@ -1,95 +1,95 @@
<?php <?php
/** /**
* Zend Framework * Zend Framework
* *
* LICENSE * LICENSE
* *
* This source file is subject to the new BSD license that is bundled * This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt. * with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL: * It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd * http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to * If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email * obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately. * to license@zend.com so we can send you a copy immediately.
* *
* @category Zend * @category Zend
* @package Zend_View * @package Zend_View
* @subpackage Helper * @subpackage Helper
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id: UserInfo.php 33 2009-12-10 15:08:38Z markus $ * @version $Id: UserInfo.php 33 2009-12-10 15:08:38Z markus $
* @license http://framework.zend.com/license/new-bsd New BSD License * @license http://framework.zend.com/license/new-bsd New BSD License
*/ */
/** Zend_View_Helper_Placeholder_Container_Standalone */ /** Zend_View_Helper_Placeholder_Container_Standalone */
require_once 'Zend/View/Helper/Placeholder/Container/Standalone.php'; require_once 'Zend/View/Helper/Placeholder/Container/Standalone.php';
/** /**
* Helper for displaying an user info div somewhere * Helper for displaying an user info div somewhere
* *
* @uses Zend_View_Helper_Placeholder_Container_Standalone * @uses Zend_View_Helper_Placeholder_Container_Standalone
* @package Zend_View * @package Zend_View
* @subpackage Helper * @subpackage Helper
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License * @license http://framework.zend.com/license/new-bsd New BSD License
*/ */
class Zend_View_Helper_UserInfo extends Zend_View_Helper_Placeholder_Container_Standalone class Zend_View_Helper_UserInfo extends Zend_View_Helper_Placeholder_Container_Standalone
{ {
/** /**
* Registry key for placeholder * Registry key for placeholder
* @var string * @var string
*/ */
protected $_regKey = 'Zend_View_Helper_UserInfo'; protected $_regKey = 'Zend_View_Helper_UserInfo';
private $items = array(); private $items = array();
/** /**
* Retrieve placeholder for navigation element and optionally set state * Retrieve placeholder for navigation element and optionally set state
* *
* Single Link elements to be made with $this->url(array('controller'=>'<controller>'), 'default', true); * Single Link elements to be made with $this->url(array('controller'=>'<controller>'), 'default', true);
* *
* @param array $data * @param array $data
* @return Zend_View_Helper_UserData * @return Zend_View_Helper_UserData
*/ */
public function UserInfo($ar = null, $setType = Zend_View_Helper_Placeholder_Container_Abstract::APPEND, $setPos = 0) public function UserInfo($ar = null, $setType = Zend_View_Helper_Placeholder_Container_Abstract::APPEND, $setPos = 0)
{ {
if ($ar !== null && is_array($ar)) { if ($ar !== null && is_array($ar)) {
$this->items = $ar; $this->items = $ar;
} }
return $this; return $this;
} }
/** /**
* Turn helper into string * Turn helper into string
* *
* @param string|null $indent * @param string|null $indent
* @param string|null $locale * @param string|null $locale
* @return string * @return string
*/ */
public function toString($indent = null, $locale = null) public function toString($indent = null, $locale = null)
{ {
$session = Zend_Registry::get('session'); $session = Zend_Registry::get('session');
$this->items = $session->authdata; $this->items = $session->authdata;
$output = ''; $output = '';
if ($session->authdata['authed'] !== true) if ($session->authdata['authed'] !== true)
return $output; return $output;
# $indent = (null !== $indent) # $indent = (null !== $indent)
# ? $this->getWhitespace($indent) # ? $this->getWhitespace($indent)
# : $this->getIndent(); # : $this->getIndent();
$indent = ''; $indent = '';
$output .= $indent . "<div id=\"userinfo\">\n"; $output .= $indent . "<div id=\"userinfo\">\n";
$output .= $indent . "\tUser: " . $this->items['authed_username'] . "<br>\n"; $output .= $indent . "\tUser: " . $this->items['authed_username'] . "<br>\n";
$output .= $indent . "\tName: " . htmlentities(strip_tags($this->items['authed_fname'] . ' ' . $this->items['authed_lname']), ENT_QUOTES, 'ISO-8859-1') . "<br>\n"; $output .= $indent . "\tName: " . $this->items['authed_fname'] . ' ' . $this->items['authed_lname'] . "<br>\n";
$output .= $indent . "\tRole: " . $this->items['authed_role'] . "<br>\n"; $output .= $indent . "\tRole: " . $this->items['authed_role'] . "<br>\n";
if ($this->items['authed_by_crt'] === true) if ($this->items['authed_by_crt'] === true)
$output .= $indent . "\tLoginmethod: CRT<br>\n"; $output .= $indent . "\tLoginmethod: CRT<br>\n";
else else
$output .= $indent . "\tLoginmethod: PASSWD<br>\n"; $output .= $indent . "\tLoginmethod: PASSWD<br>\n";
$output .= $indent . "</div>\n"; $output .= $indent . "</div>\n";
return $output; return $output;
} }
} }

View file

@ -1,7 +1,7 @@
<?php <?php
/** /**
* @author markus * @author markus
* $Id: index.phtml 25 2009-12-02 15:43:21Z markus $ * $Id: index.phtml 25 2009-12-02 15:43:21Z markus $
*/ */
?> ?>
<H1><?php print I18n::_('Dashboard'); ?></H1> <H1><?php print I18n::_('Dashboard'); ?></H1>

View file

@ -1,16 +1,16 @@
<?php <?php
/** /**
* @author markus * @author markus
* $Id: index.phtml 36 2009-12-15 15:49:57Z markus $ * $Id: index.phtml 36 2009-12-15 15:49:57Z markus $
*/ */
// $this->headScript()->appendFile('js/1st.js'); // $this->headScript()->appendFile('js/1st.js');
// $this->headScript()->appendFile('js/2nd.js'); // $this->headScript()->appendFile('js/2nd.js');
$this->headLink()->appendStylesheet('/css/login.css'); $this->headLink()->appendStylesheet('/css/login.css');
$this->headLink()->appendStylesheet('/css/form_dl.css'); $this->headLink()->appendStylesheet('/css/form_dl.css');
?> ?>
<H1><?php print I18n::_('Please log in'); ?></H1> <H1><?php print I18n::_('Please log in'); ?></H1>
<?php print $this->form;?> <?php print $this->form;?>
<a href='/login/crt'><?php print I18n::_('Client Cert Login'); ?></a> <a href='/login/crt'><?php print I18n::_('Client Cert Login'); ?></a>

View file

@ -1,12 +1,12 @@
<?php <?php
/** /**
* @author markus * @author markus
* $Id: index.phtml 25 2009-12-02 15:43:21Z markus $ * $Id: index.phtml 25 2009-12-02 15:43:21Z markus $
*/ */
$this->headLink()->appendStylesheet('/css/mail.css'); $this->headLink()->appendStylesheet('/css/mail.css');
$this->headScript()->appendFile('/js/mail_redirect.js'); $this->headScript()->appendFile('/js/mail_redirect.js');
?> ?>
<H1><?php print I18n::_('Delete Mail'); ?></H1> <H1><?php print I18n::_('Delete Mail'); ?></H1>
<?php <?php
print $this->message; print $this->message;
print '<input type="hidden" id="returnto" value="' . $this->returnto . '">'; print '<input type="hidden" id="returnto" value="' . $this->returnto . '">';

View file

@ -1,37 +1,37 @@
<?php <?php
/** /**
* @author markus * @author markus
* $Id: index.phtml 25 2009-12-02 15:43:21Z markus $ * $Id: index.phtml 25 2009-12-02 15:43:21Z markus $
*/ */
$this->headLink()->appendStylesheet('/css/mail.css'); $this->headLink()->appendStylesheet('/css/mail.css');
?> ?>
<H1><?php print I18n::_('View all Mail'); ?></H1> <H1><?php print I18n::_('View all Mail'); ?></H1>
<?php <?php
if (count($this->headers) == 0) { if (count($this->headers) == 0) {
print I18n::_('You currently have no mail.'); print I18n::_('You currently have no mail.');
} }
else { else {
?> ?>
<table> <table>
<tr> <tr>
<th class="col1"><?php print I18n::_('From');?></th> <th class="col1"><?php print I18n::_('From');?></th>
<th class="col2"><?php print I18n::_('To');?></th> <th class="col2"><?php print I18n::_('To');?></th>
<th class="col3"><?php print I18n::_('Subject');?></th> <th class="col3"><?php print I18n::_('Subject');?></th>
<th class="col4"><?php print I18n::_('Date');?></th> <th class="col4"><?php print I18n::_('Date');?></th>
<th class="col5"><?php print I18n::_('Size');?></th> <th class="col5"><?php print I18n::_('Size');?></th>
<th class="col6"><?php print I18n::_('Del');?></th> <th class="col6"><?php print I18n::_('Del');?></th>
</tr> </tr>
<?php <?php
foreach ($this->headers as $header) { foreach ($this->headers as $header) {
print " <tr>\n"; print " <tr>\n";
print " <td><a href=\"" . $header->detailslink . "\">" . $header->fromaddress . "</a></td>"; print " <td><a href=\"" . $header->detailslink . "\">" . $header->fromaddress . "</a></td>";
print " <td>" . $header->toaddress . "</td>"; print " <td>" . $header->toaddress . "</td>";
print " <td>" . htmlspecialchars(iconv_mime_decode($header->subject, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8'), ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8') . "</td>"; print " <td>" . $header->subject . "</td>";
print " <td>" . $header->date . "</td>"; print " <td>" . $header->date . "</td>";
print " <td>" . $header->Size . "</td>"; print " <td>" . $header->Size . "</td>";
print " <td><a class=\"delete\" href=\"" . $header->deletelink . "\"><img src=\"/img/delete_icon.jpg\"></a></td>"; print " <td><a class=\"delete\" href=\"" . $header->deletelink . "\"><img src=\"/img/delete_icon.jpg\"></a></td>";
print " </tr>\n"; print " </tr>\n";
} }
} }
?> ?>
</table> </table>

View file

@ -1,37 +1,37 @@
<?php <?php
/** /**
* @author markus * @author markus
* $Id: index.phtml 25 2009-12-02 15:43:21Z markus $ * $Id: index.phtml 25 2009-12-02 15:43:21Z markus $
*/ */
$this->headLink()->appendStylesheet('/css/mail.css'); $this->headLink()->appendStylesheet('/css/mail.css');
?> ?>
<H1><?php print I18n::_('View own Mail'); ?></H1> <H1><?php print I18n::_('View own Mail'); ?></H1>
<?php <?php
if (count($this->headers) == 0) { if (count($this->headers) == 0) {
print I18n::_('You currently have no mail.'); print I18n::_('You currently have no mail.');
} }
else { else {
?> ?>
<table> <table>
<tr> <tr>
<th class="col1"><?php print I18n::_('From');?></th> <th class="col1"><?php print I18n::_('From');?></th>
<th class="col2"><?php print I18n::_('To');?></th> <th class="col2"><?php print I18n::_('To');?></th>
<th class="col3"><?php print I18n::_('Subject');?></th> <th class="col3"><?php print I18n::_('Subject');?></th>
<th class="col4"><?php print I18n::_('Date');?></th> <th class="col4"><?php print I18n::_('Date');?></th>
<th class="col5"><?php print I18n::_('Size');?></th> <th class="col5"><?php print I18n::_('Size');?></th>
<th class="col6"><?php print I18n::_('Del');?></th> <th class="col6"><?php print I18n::_('Del');?></th>
</tr> </tr>
<?php <?php
foreach ($this->headers as $header) { foreach ($this->headers as $header) {
print " <tr>\n"; print " <tr>\n";
print " <td><a href=\"" . $header->detailslink . "\">" . $header->fromaddress . "</a></td>"; print " <td><a href=\"" . $header->detailslink . "\">" . $header->fromaddress . "</a></td>";
print " <td>" . $header->toaddress . "</td>"; print " <td>" . $header->toaddress . "</td>";
print " <td>" . htmlspecialchars(iconv_mime_decode($header->subject, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8'), ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8') . "</td>"; print " <td>" . $header->subject . "</td>";
print " <td>" . $header->date . "</td>"; print " <td>" . $header->date . "</td>";
print " <td>" . $header->Size . "</td>"; print " <td>" . $header->Size . "</td>";
print " <td><a class=\"delete\" href=\"" . $header->deletelink . "\"><img src=\"/img/delete_icon.jpg\"></a></td>"; print " <td><a class=\"delete\" href=\"" . $header->deletelink . "\"><img src=\"/img/delete_icon.jpg\"></a></td>";
print " </tr>\n"; print " </tr>\n";
} }
} }
?> ?>
</table> </table>

View file

@ -1,10 +1,10 @@
<?php <?php
/** /**
* @author markus * @author markus
* $Id: index.phtml 25 2009-12-02 15:43:21Z markus $ * $Id: index.phtml 25 2009-12-02 15:43:21Z markus $
*/ */
$this->headLink()->appendStylesheet('/css/mail.css'); $this->headLink()->appendStylesheet('/css/mail.css');
?> ?>
<H1><?php print I18n::_('Read Mail'); ?></H1> <H1><?php print I18n::_('Read Mail'); ?></H1>
<?php <?php
print nl2br(htmlspecialchars(quoted_printable_decode($this->mail_body), ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8')); print nl2br(htmlspecialchars(quoted_printable_decode($this->mail_body), ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'));

View file

@ -9,12 +9,12 @@
<p><?php print I18n::_('The following assurances were added to your account:')?></p> <p><?php print I18n::_('The following assurances were added to your account:')?></p>
<table> <table>
<thead> <thead>
<tr><th>#</th><th><?php print I18n::_('Number of points')?></th></tr> <tr><th>#</th><th><?php print I18n::_('Number of points')?></th></tr>
</thead> </thead>
<tbody> <tbody>
<?php foreach ($this->assurancesDone as $i => $points) { <?php foreach ($this->assurancesDone as $i => $points) {
printf('<tr><td> %1$d </td><td> %2$d </td></tr>', $i, $points); printf('<tr><td> %1$d </td><td> %2$d </td></tr>', $i, $points);
}?> }?>
</tbody> </tbody>
</table> </table>

View file

@ -7,22 +7,22 @@
<h1><?php print I18n::_('Do Multiple Assurances at Once') ?></h1> <h1><?php print I18n::_('Do Multiple Assurances at Once') ?></h1>
<p><?php print I18n::_('Assure multiple dummy accounts in one step. '. <p><?php print I18n::_('Assure multiple dummy accounts in one step. '.
'The assurances look just like normal assurances and can be used to gain '. 'The assurances look just like normal assurances and can be used to gain '.
'experience points without suffering from RSI (also known as mouse arm).') 'experience points without suffering from RSI (also known as mouse arm).')
?></p> ?></p>
<p><?php print I18n::_('The amount of points given per Assurance can be '. <p><?php print I18n::_('The amount of points given per Assurance can be '.
'specified in two ways:') ?></p> 'specified in two ways:') ?></p>
<dl> <dl>
<dt><?php print I18n::_('Percentage') ?></dt> <dt><?php print I18n::_('Percentage') ?></dt>
<dd><?php print I18n::_('n percent of the maximal possible points are '. <dd><?php print I18n::_('n percent of the maximal possible points are '.
'given per Assurance. If it\'s not an integer it is rounded down to '. 'given per Assurance. If it\'s not an integer it is rounded down to '.
'the next integer') ?></dd> 'the next integer') ?></dd>
<dt><?php print I18n::_('Absolute') ?></dt> <dt><?php print I18n::_('Absolute') ?></dt>
<dd><?php print I18n::_('Exactly n points are given. If n exceeds the '. <dd><?php print I18n::_('Exactly n points are given. If n exceeds the '.
'current maximum of points that may be given, it is set to the '. 'current maximum of points that may be given, it is set to the '.
'maximum until due to the gained experience points more points may be '. 'maximum until due to the gained experience points more points may be '.
'given') ?></dd> 'given') ?></dd>
</dl> </dl>
<?php print $this->batch_assurance_form ?> <?php print $this->batch_assurance_form ?>

View file

@ -9,20 +9,20 @@
<p><?php print I18n::_('The following assurances were executed:')?></p> <p><?php print I18n::_('The following assurances were executed:')?></p>
<table> <table>
<thead> <thead>
<tr> <tr>
<th>#</th> <th>#</th>
<th><?php print I18n::_('Assuree')?></th> <th><?php print I18n::_('Assuree')?></th>
<th><?php print I18n::_('Number of points')?></th> <th><?php print I18n::_('Number of points')?></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php foreach ($this->assurances as $i => $assurance) {?> <?php foreach ($this->assurances as $i => $assurance) {?>
<tr> <tr>
<td><?php print $i ?></td> <td><?php print $i ?></td>
<td><?php print $assurance['assuree'] ?></td> <td><?php print $assurance['assuree'] ?></td>
<td><?php print $assurance['points'] ?></td> <td><?php print $assurance['points'] ?></td>
</tr> </tr>
<?php }?> <?php }?>
</tbody> </tbody>
</table> </table>

View file

@ -1,60 +1,60 @@
<?php <?php
class CAcert_User_Emails { class CAcert_User_Emails {
private $db = null; private $db = null;
public function __construct($db) { public function __construct($db) {
$this->db = $db; $this->db = $db;
} }
/** /**
* get list of email addresses by login, needed to be able to filter emails * get list of email addresses by login, needed to be able to filter emails
* @param string $addr * @param string $addr
* @return array * @return array
*/ */
public function getEmailAddressesByLogin($addr) { public function getEmailAddressesByLogin($addr) {
$db = $this->db; $db = $this->db;
/** /**
* find out user id by email address * find out user id by email address
*/ */
$sql = 'select users.id from users where email=?'; $sql = 'select users.id from users where email=?';
$id = $db->fetchOne($sql, array($addr)); $id = $db->fetchOne($sql, array($addr));
/** /**
* get secondary email addresses * get secondary email addresses
*/ */
$sql = 'select email.email from email where memid=?'; $sql = 'select email.email from email where memid=?';
$res = $db->query($sql, array($id)); $res = $db->query($sql, array($id));
$emails = array(); $emails = array();
$num = $res->rowCount(); $num = $res->rowCount();
for ($i = 0; $i < $num; $i++) { for ($i = 0; $i < $num; $i++) {
$row = $res->fetch(PDO::FETCH_ASSOC); $row = $res->fetch(PDO::FETCH_ASSOC);
$emails[] = $row['email']; $emails[] = $row['email'];
} }
/** /**
* get additional addresses by domains * get additional addresses by domains
*/ */
$sql = 'select domains.domain from domains where memid=?'; $sql = 'select domains.domain from domains where memid=?';
$res = $db->query($sql, array($id)); $res = $db->query($sql, array($id));
$num = $res->rowCount(); $num = $res->rowCount();
$variants = array('root','hostmaster','postmaster','admin','webmaster'); $variants = array('root','hostmaster','postmaster','admin','webmaster');
for ($i = 0; $i < $num; $i++) { for ($i = 0; $i < $num; $i++) {
$row = $res->fetch(PDO::FETCH_ASSOC); $row = $res->fetch(PDO::FETCH_ASSOC);
foreach ($variants as $variant) { foreach ($variants as $variant) {
$emails[] = $variant . '@' . $row['domain']; $emails[] = $variant . '@' . $row['domain'];
} }
} }
// Log::Log()->debug(__METHOD__ . ' addresses ' . implode(',', $emails)); // Log::Log()->debug(__METHOD__ . ' addresses ' . implode(',', $emails));
return $emails; return $emails;
} }
} }

View file

@ -1,53 +1,53 @@
<?php <?php
require_once (FWACTIONS_PATH . '/FWAction.php'); require_once (FWACTIONS_PATH . '/FWAction.php');
class Index extends FWAction { class Index extends FWAction {
/** /**
* get a list of required permissions that are needed to access this action * get a list of required permissions that are needed to access this action
* @return array * @return array
*/ */
public static function getRequiredPermissions() { public static function getRequiredPermissions() {
return array(); return array();
} }
/** /**
* get a role that is required for accessing that action * get a role that is required for accessing that action
* @return string * @return string
*/ */
public static function getRequiredRole() { public static function getRequiredRole() {
return 'User'; return 'User';
} }
/** /**
* sort order for top navigation * sort order for top navigation
* @return integer * @return integer
*/ */
public static function getTopNavPrio() { public static function getTopNavPrio() {
return 1; return 1;
} }
/** /**
* controller to invoke * controller to invoke
* @return string * @return string
*/ */
public static function getController() { public static function getController() {
return 'index'; return 'index';
} }
/** /**
* action to invoke * action to invoke
* @return string * @return string
*/ */
public static function getAction() { public static function getAction() {
return 'index'; return 'index';
} }
/** /**
* get text for menu, caller is responsible for translating * get text for menu, caller is responsible for translating
* @return string * @return string
*/ */
public static function getMenuText() { public static function getMenuText() {
return 'Dashboard'; return 'Dashboard';
} }
} }

View file

@ -1,53 +1,53 @@
<?php <?php
require_once (FWACTIONS_PATH . '/FWAction.php'); require_once (FWACTIONS_PATH . '/FWAction.php');
class Login extends FWAction { class Login extends FWAction {
/** /**
* get a list of required permissions that are needed to access this action * get a list of required permissions that are needed to access this action
* @return array * @return array
*/ */
public static function getRequiredPermissions() { public static function getRequiredPermissions() {
return array(); return array();
} }
/** /**
* get a role that is required for accessing that action * get a role that is required for accessing that action
* @return string * @return string
*/ */
public static function getRequiredRole() { public static function getRequiredRole() {
return 'User'; return 'User';
} }
/** /**
* sort order for top navigation * sort order for top navigation
* @return integer * @return integer
*/ */
public static function getTopNavPrio() { public static function getTopNavPrio() {
return 1000; return 1000;
} }
/** /**
* controller to invoke * controller to invoke
* @return string * @return string
*/ */
public static function getController() { public static function getController() {
return 'login'; return 'login';
} }
/** /**
* action to invoke * action to invoke
* @return string * @return string
*/ */
public static function getAction() { public static function getAction() {
return 'index'; return 'index';
} }
/** /**
* get text for menu, caller is responsible for translating * get text for menu, caller is responsible for translating
* @return string * @return string
*/ */
public static function getMenuText() { public static function getMenuText() {
return 'Login'; return 'Login';
} }
} }

View file

@ -1,53 +1,53 @@
<?php <?php
require_once (FWACTIONS_PATH . '/FWAction.php'); require_once (FWACTIONS_PATH . '/FWAction.php');
class Mail extends FWAction { class Mail extends FWAction {
/** /**
* get a list of required permissions that are needed to access this action * get a list of required permissions that are needed to access this action
* @return array * @return array
*/ */
public static function getRequiredPermissions() { public static function getRequiredPermissions() {
return array(); return array();
} }
/** /**
* get a role that is required for accessing that action * get a role that is required for accessing that action
* @return string * @return string
*/ */
public static function getRequiredRole() { public static function getRequiredRole() {
return 'User'; return 'User';
} }
/** /**
* sort order for top navigation * sort order for top navigation
* @return integer * @return integer
*/ */
public static function getTopNavPrio() { public static function getTopNavPrio() {
return 100; return 100;
} }
/** /**
* controller to invoke * controller to invoke
* @return string * @return string
*/ */
public static function getController() { public static function getController() {
return 'mail'; return 'mail';
} }
/** /**
* action to invoke * action to invoke
* @return string * @return string
*/ */
public static function getAction() { public static function getAction() {
return 'index'; return 'index';
} }
/** /**
* get text for menu, caller is responsible for translating * get text for menu, caller is responsible for translating
* @return string * @return string
*/ */
public static function getMenuText() { public static function getMenuText() {
return 'Mail'; return 'Mail';
} }
} }

View file

@ -1,7 +1,7 @@
<?php <?php
/** /**
* @author markus * @author markus
*/ */
abstract class FWAction { abstract class FWAction {
} }

View file

@ -1,103 +1,104 @@
<?php <?php
require_once('config/Config_Db.php'); require_once('config/Config_Db.php');
class Config { class Config {
/** /**
* static pointer to instances * static pointer to instances
* @var array(Config) * @var array(Config)
*/ */
private static $instances = array(); private static $instances = array();
/** /**
* can handle several instances, distinct by instance name string * can handle several instances, distinct by instance name string
* @var string * @var string
*/ */
private $instanceName = ''; private $instanceName = '';
/** /**
* config object * config object
* @var Config_Db * @var Config_Db
*/ */
private $config = null; private $config = null;
/** /**
* make a new Config_Db * make a new Config_Db
* *
* by using the $where statement you can limit the data that is fetched from db, i.e. only get config for zone $id * by using the $where statement you can limit the data that is fetched from db, i.e. only get config for zone $id
* *
* @param string $instanceName * @param string $instanceName
* @param Zend_Db_Adapter $db * @param Zend_Db_Adapter $db
* @param string $where * @param string $where
*/ */
protected function __construct($instanceName = null, $db = null, $where = null) { protected function __construct($instanceName = null, $db = null, $where = null) {
if ($instanceName === null) if ($instanceName === null)
throw new Exception(__METHOD__ . ': expected an instance name, got none'); throw new Exception(__METHOD__ . ': expected an instance name, got none');
$config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV); $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV);
$this->instanceName = $instanceName; $this->instanceName = $instanceName;
if ($db === null) if ($db === null)
$db = Zend_Db::factory($config->dnssecme->db->config->pdo, $config->dnssecme->db->config); $db = Zend_Db::factory($config->dnssecme->db->config->pdo, $config->dnssecme->db->config);
$this->config = new Config_Db($db, $instanceName, $where, true); $this->config = new Config_Db($db, $instanceName, $where, true);
} }
/** /**
* get already existing instance, make new instance or throw an exception * get already existing instance, make new instance or throw an exception
* @param string $instanceName * @param string $instanceName
* @param Zend_Db_Adapter $db * @param Zend_Db_Adapter $db
* @param string $where * @param string $where
*/ */
public static function getInstance($instanceName, $db = null, $where = null) { public static function getInstance($instanceName, $db = null, $where = null) {
if ($instanceName === null) if ($instanceName === null)
throw new Exception(__METHOD__ . ': expected an instance name, got none'); throw new Exception(__METHOD__ . ': expected an instance name, got none');
// no caching if presumeably volatile data is requested // no caching if presumeably volatile data is requested
if ($db !== null && $where !== null) { if ($db !== null && $where !== null) {
return new Config($instanceName, $db, $where); return new Config($instanceName, $db, $where);
} }
if (!array_key_exists($instanceName, self::$instances)) { if (!array_key_exists($instanceName, self::$instances)) {
self::$instances[$instanceName] = new Config($instanceName, $db, $where); self::$instances[$instanceName] = new Config($instanceName, $db, $where);
} }
return self::$instances[$instanceName]; return self::$instances[$instanceName];
} }
/** /**
* magic method that dispatches all unrecognized method calls to the config object * magic method that dispatches all unrecognized method calls to the config object
* *
* @param string $param * @param string $param
*/ */
public function __get($param) { public function __get($param) {
return $this->config->$param; return $this->config->$param;
} }
/** /**
* magic method that handles isset inquiries to attributes * magic method that handles isset inquiries to attributes
* *
* @param string $param * @param string $param
*/ */
public function __isset($param) { public function __isset($param) {
return isset($this->config->$param); return isset($this->config->$param);
} }
/** /**
* magic method that dispatches all unrecognized method calls to the config object * magic method that dispatches all unrecognized method calls to the config object
* *
* @param string $param * @param string $param
* @param string $value * @param string $value
*/ */
public function __set($param, $value) { public function __set($param, $value) {
$this->config->$param = $value; $this->config->$param = $value;
} }
/** /**
* get the config object * get the config object
* @return Zend_Config_* * @return Zend_Config_*
*/ */
public function getConfig() { public function getConfig() {
return $this->config; return $this->config;
} }
} }
?>

View file

@ -1,339 +1,339 @@
<?php <?php
/** /**
* Add database driven configuration to the framework, source based on Zend_Config_Ini * Add database driven configuration to the framework, source based on Zend_Config_Ini
* *
* Zend Framework * Zend Framework
* *
* LICENSE * LICENSE
* *
* This source file is subject to the new BSD license that is bundled * This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt. * with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL: * It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd * http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to * If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email * obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately. * to license@zend.com so we can send you a copy immediately.
* *
* @category Zend * @category Zend
* @package Zend_Config * @package Zend_Config
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License * @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Config_Db.php 27 2009-12-03 13:00:29Z markus $ * @version $Id: Config_Db.php 27 2009-12-03 13:00:29Z markus $
*/ */
/** /**
* @see Zend_Config * @see Zend_Config
*/ */
require_once 'Zend/Config.php'; require_once 'Zend/Config.php';
/** /**
* @category Zend * @category Zend
* @package Zend_Config * @package Zend_Config
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License * @license http://framework.zend.com/license/new-bsd New BSD License
*/ */
class Config_Db extends Zend_Config class Config_Db extends Zend_Config
{ {
/** /**
* String that separates nesting levels of configuration data identifiers * String that separates nesting levels of configuration data identifiers
* *
* @var string * @var string
*/ */
protected $_nestSeparator = '.'; protected $_nestSeparator = '.';
/** /**
* String that separates the parent section name * String that separates the parent section name
* *
* @var string * @var string
*/ */
protected $_sectionSeparator = ':'; protected $_sectionSeparator = ':';
/** /**
* Wether to skip extends or not * Wether to skip extends or not
* *
* @var boolean * @var boolean
*/ */
protected $_skipExtends = false; protected $_skipExtends = false;
/** /**
* Loads the section $section from the config file $filename for * Loads the section $section from the config file $filename for
* access facilitated by nested object properties. * access facilitated by nested object properties.
* *
* If the section name contains a ":" then the section name to the right * If the section name contains a ":" then the section name to the right
* is loaded and included into the properties. Note that the keys in * is loaded and included into the properties. Note that the keys in
* this $section will override any keys of the same * this $section will override any keys of the same
* name in the sections that have been included via ":". * name in the sections that have been included via ":".
* *
* If the $section is null, then all sections in the ini file are loaded. * If the $section is null, then all sections in the ini file are loaded.
* *
* If any key includes a ".", then this will act as a separator to * If any key includes a ".", then this will act as a separator to
* create a sub-property. * create a sub-property.
* *
* example ini file: * example ini file:
* [all] * [all]
* db.connection = database * db.connection = database
* hostname = live * hostname = live
* *
* [staging : all] * [staging : all]
* hostname = staging * hostname = staging
* *
* after calling $data = new Zend_Config_Ini($file, 'staging'); then * after calling $data = new Zend_Config_Ini($file, 'staging'); then
* $data->hostname === "staging" * $data->hostname === "staging"
* $data->db->connection === "database" * $data->db->connection === "database"
* *
* The $options parameter may be provided as either a boolean or an array. * The $options parameter may be provided as either a boolean or an array.
* If provided as a boolean, this sets the $allowModifications option of * If provided as a boolean, this sets the $allowModifications option of
* Zend_Config. If provided as an array, there are two configuration * Zend_Config. If provided as an array, there are two configuration
* directives that may be set. For example: * directives that may be set. For example:
* *
* $options = array( * $options = array(
* 'allowModifications' => false, * 'allowModifications' => false,
* 'nestSeparator' => '->' * 'nestSeparator' => '->'
* ); * );
* *
* @param Zend_Db $dbc * @param Zend_Db $dbc
* @param string $db_table * @param string $db_table
* @param string|null $section * @param string|null $section
* @param boolean|array $options * @param boolean|array $options
* @throws Zend_Config_Exception * @throws Zend_Config_Exception
* @return void * @return void
*/ */
public function __construct($dbc, $db_table, $section = null, $options = false) public function __construct($dbc, $db_table, $section = null, $options = false)
{ {
if (empty($dbc)) { if (empty($dbc)) {
/** /**
* @see Zend_Config_Exception * @see Zend_Config_Exception
*/ */
require_once 'Zend/Config/Exception.php'; require_once 'Zend/Config/Exception.php';
throw new Zend_Config_Exception('Database connection is not set'); throw new Zend_Config_Exception('Database connection is not set');
} }
if (empty($db_table)) { if (empty($db_table)) {
/** /**
* @see Zend_Config_Exception * @see Zend_Config_Exception
*/ */
require_once 'Zend/Config/Exception.php'; require_once 'Zend/Config/Exception.php';
throw new Zend_Config_Exception('Database table is not set'); throw new Zend_Config_Exception('Database table is not set');
} }
$allowModifications = false; $allowModifications = false;
if (is_bool($options)) { if (is_bool($options)) {
$allowModifications = $options; $allowModifications = $options;
} elseif (is_array($options)) { } elseif (is_array($options)) {
if (isset($options['allowModifications'])) { if (isset($options['allowModifications'])) {
$allowModifications = (bool) $options['allowModifications']; $allowModifications = (bool) $options['allowModifications'];
} }
if (isset($options['nestSeparator'])) { if (isset($options['nestSeparator'])) {
$this->_nestSeparator = (string) $options['nestSeparator']; $this->_nestSeparator = (string) $options['nestSeparator'];
} }
if (isset($options['skipExtends'])) { if (isset($options['skipExtends'])) {
$this->_skipExtends = (bool) $options['skipExtends']; $this->_skipExtends = (bool) $options['skipExtends'];
} }
} }
$iniArray = $this->_loadIniFile($dbc, $db_table, $section); $iniArray = $this->_loadIniFile($dbc, $db_table, $section);
$section = null; $section = null;
if (null === $section) { if (null === $section) {
// Load entire file // Load entire file
$dataArray = array(); $dataArray = array();
foreach ($iniArray as $sectionName => $sectionData) { foreach ($iniArray as $sectionName => $sectionData) {
if(!is_array($sectionData)) { if(!is_array($sectionData)) {
$dataArray = array_merge_recursive($dataArray, $this->_processKey(array(), $sectionName, $sectionData)); $dataArray = array_merge_recursive($dataArray, $this->_processKey(array(), $sectionName, $sectionData));
} else { } else {
$dataArray[$sectionName] = $this->_processSection($iniArray, $sectionName); $dataArray[$sectionName] = $this->_processSection($iniArray, $sectionName);
} }
} }
parent::__construct($dataArray, $allowModifications); parent::__construct($dataArray, $allowModifications);
} else { } else {
// Load one or more sections // Load one or more sections
if (!is_array($section)) { if (!is_array($section)) {
$section = array($section); $section = array($section);
} }
$dataArray = array(); $dataArray = array();
foreach ($section as $sectionName) { foreach ($section as $sectionName) {
if (!isset($iniArray[$sectionName])) { if (!isset($iniArray[$sectionName])) {
/** /**
* @see Zend_Config_Exception * @see Zend_Config_Exception
*/ */
require_once 'Zend/Config/Exception.php'; require_once 'Zend/Config/Exception.php';
throw new Zend_Config_Exception("Section '$sectionName' cannot be found"); throw new Zend_Config_Exception("Section '$sectionName' cannot be found");
} }
$dataArray = array_merge($this->_processSection($iniArray, $sectionName), $dataArray); $dataArray = array_merge($this->_processSection($iniArray, $sectionName), $dataArray);
} }
parent::__construct($dataArray, $allowModifications); parent::__construct($dataArray, $allowModifications);
} }
$this->_loadedSection = $section; $this->_loadedSection = $section;
} }
/** /**
* Load data from database and preprocess the section separator (':' in the * Load data from database and preprocess the section separator (':' in the
* section name (that is used for section extension) so that the resultant * section name (that is used for section extension) so that the resultant
* array has the correct section names and the extension information is * array has the correct section names and the extension information is
* stored in a sub-key called ';extends'. We use ';extends' as this can * stored in a sub-key called ';extends'. We use ';extends' as this can
* never be a valid key name in an INI file that has been loaded using * never be a valid key name in an INI file that has been loaded using
* parse_ini_file(). * parse_ini_file().
* *
* @param Zend_Db $dbc * @param Zend_Db $dbc
* @param string $db_table * @param string $db_table
* @throws Zend_Config_Exception * @throws Zend_Config_Exception
* @return array * @return array
*/ */
protected function _loadIniFile($dbc, $db_table, $section = null) protected function _loadIniFile($dbc, $db_table, $section = null)
{ {
set_error_handler(array($this, '_loadFileErrorHandler')); set_error_handler(array($this, '_loadFileErrorHandler'));
$loaded = $this->_parse_ini_db($dbc, $db_table, $section); // Warnings and errors are suppressed $loaded = $this->_parse_ini_db($dbc, $db_table, $section); // Warnings and errors are suppressed
restore_error_handler(); restore_error_handler();
// Check if there was a error while loading file // Check if there was a error while loading file
if ($this->_loadFileErrorStr !== null) { if ($this->_loadFileErrorStr !== null) {
/** /**
* @see Zend_Config_Exception * @see Zend_Config_Exception
*/ */
require_once 'Zend/Config/Exception.php'; require_once 'Zend/Config/Exception.php';
throw new Zend_Config_Exception($this->_loadFileErrorStr); throw new Zend_Config_Exception($this->_loadFileErrorStr);
} }
$iniArray = array(); $iniArray = array();
foreach ($loaded as $key => $data) foreach ($loaded as $key => $data)
{ {
$pieces = explode($this->_sectionSeparator, $key); $pieces = explode($this->_sectionSeparator, $key);
$thisSection = trim($pieces[0]); $thisSection = trim($pieces[0]);
switch (count($pieces)) { switch (count($pieces)) {
case 1: case 1:
$iniArray[$thisSection] = $data; $iniArray[$thisSection] = $data;
break; break;
case 2: case 2:
$extendedSection = trim($pieces[1]); $extendedSection = trim($pieces[1]);
$iniArray[$thisSection] = array_merge(array(';extends'=>$extendedSection), $data); $iniArray[$thisSection] = array_merge(array(';extends'=>$extendedSection), $data);
break; break;
default: default:
/** /**
* @see Zend_Config_Exception * @see Zend_Config_Exception
*/ */
require_once 'Zend/Config/Exception.php'; require_once 'Zend/Config/Exception.php';
throw new Zend_Config_Exception("Section '$thisSection' may not extend multiple sections"); throw new Zend_Config_Exception("Section '$thisSection' may not extend multiple sections");
} }
} }
return $iniArray; return $iniArray;
} }
/** /**
* read config from (current db in $dbc).$db_table * read config from (current db in $dbc).$db_table
* *
* @param Zend_Db $dbc * @param Zend_Db $dbc
* @param string $db_table * @param string $db_table
* @param string $section * @param string $section
* @return array * @return array
*/ */
protected function _parse_ini_db($dbc, $db_table, $section) { protected function _parse_ini_db($dbc, $db_table, $section) {
$sql = 'select * from ' . $db_table; $sql = 'select * from ' . $db_table;
if ($section !== null) { if ($section !== null) {
$sql .= ' where ' . $section; $sql .= ' where ' . $section;
} }
$db_config = $dbc->query($sql); $db_config = $dbc->query($sql);
$config = array(); $config = array();
while (($row = $db_config->fetch()) !== false) { while (($row = $db_config->fetch()) !== false) {
$key = explode('.', $row['config_key']); $key = explode('.', $row['config_key']);
$depth = count($key); $depth = count($key);
$ci = &$config; $ci = &$config;
for ($cnt = 0; $cnt < $depth; $cnt++) { for ($cnt = 0; $cnt < $depth; $cnt++) {
if ($cnt == ($depth - 1)) if ($cnt == ($depth - 1))
$ci[$key[$cnt]] = $row['config_value']; $ci[$key[$cnt]] = $row['config_value'];
elseif (!isset($ci[$key[$cnt]])) elseif (!isset($ci[$key[$cnt]]))
$ci[$key[$cnt]] = array(); $ci[$key[$cnt]] = array();
$ci = &$ci[$key[$cnt]]; $ci = &$ci[$key[$cnt]];
} }
} }
return $config; return $config;
} }
/** /**
* Process each element in the section and handle the ";extends" inheritance * Process each element in the section and handle the ";extends" inheritance
* key. Passes control to _processKey() to handle the nest separator * key. Passes control to _processKey() to handle the nest separator
* sub-property syntax that may be used within the key name. * sub-property syntax that may be used within the key name.
* *
* @param array $iniArray * @param array $iniArray
* @param string $section * @param string $section
* @param array $config * @param array $config
* @throws Zend_Config_Exception * @throws Zend_Config_Exception
* @return array * @return array
*/ */
protected function _processSection($iniArray, $section, $config = array()) protected function _processSection($iniArray, $section, $config = array())
{ {
$thisSection = $iniArray[$section]; $thisSection = $iniArray[$section];
foreach ($thisSection as $key => $value) { foreach ($thisSection as $key => $value) {
if (strtolower($key) == ';extends') { if (strtolower($key) == ';extends') {
if (isset($iniArray[$value])) { if (isset($iniArray[$value])) {
$this->_assertValidExtend($section, $value); $this->_assertValidExtend($section, $value);
if (!$this->_skipExtends) { if (!$this->_skipExtends) {
$config = $this->_processSection($iniArray, $value, $config); $config = $this->_processSection($iniArray, $value, $config);
} }
} else { } else {
/** /**
* @see Zend_Config_Exception * @see Zend_Config_Exception
*/ */
require_once 'Zend/Config/Exception.php'; require_once 'Zend/Config/Exception.php';
throw new Zend_Config_Exception("Parent section '$section' cannot be found"); throw new Zend_Config_Exception("Parent section '$section' cannot be found");
} }
} else { } else {
$config = $this->_processKey($config, $key, $value); $config = $this->_processKey($config, $key, $value);
} }
} }
return $config; return $config;
} }
/** /**
* Assign the key's value to the property list. Handles the * Assign the key's value to the property list. Handles the
* nest separator for sub-properties. * nest separator for sub-properties.
* *
* @param array $config * @param array $config
* @param string $key * @param string $key
* @param string $value * @param string $value
* @throws Zend_Config_Exception * @throws Zend_Config_Exception
* @return array * @return array
*/ */
protected function _processKey($config, $key, $value) protected function _processKey($config, $key, $value)
{ {
if (strpos($key, $this->_nestSeparator) !== false) { if (strpos($key, $this->_nestSeparator) !== false) {
$pieces = explode($this->_nestSeparator, $key, 2); $pieces = explode($this->_nestSeparator, $key, 2);
if (strlen($pieces[0]) && strlen($pieces[1])) { if (strlen($pieces[0]) && strlen($pieces[1])) {
if (!isset($config[$pieces[0]])) { if (!isset($config[$pieces[0]])) {
if ($pieces[0] === '0' && !empty($config)) { if ($pieces[0] === '0' && !empty($config)) {
// convert the current values in $config into an array // convert the current values in $config into an array
$config = array($pieces[0] => $config); $config = array($pieces[0] => $config);
} else { } else {
$config[$pieces[0]] = array(); $config[$pieces[0]] = array();
} }
} elseif (!is_array($config[$pieces[0]])) { } elseif (!is_array($config[$pieces[0]])) {
/** /**
* @see Zend_Config_Exception * @see Zend_Config_Exception
*/ */
require_once 'Zend/Config/Exception.php'; require_once 'Zend/Config/Exception.php';
throw new Zend_Config_Exception("Cannot create sub-key for '{$pieces[0]}' as key already exists"); throw new Zend_Config_Exception("Cannot create sub-key for '{$pieces[0]}' as key already exists");
} }
$config[$pieces[0]] = $this->_processKey($config[$pieces[0]], $pieces[1], $value); $config[$pieces[0]] = $this->_processKey($config[$pieces[0]], $pieces[1], $value);
} else { } else {
/** /**
* @see Zend_Config_Exception * @see Zend_Config_Exception
*/ */
require_once 'Zend/Config/Exception.php'; require_once 'Zend/Config/Exception.php';
throw new Zend_Config_Exception("Invalid key '$key'"); throw new Zend_Config_Exception("Invalid key '$key'");
} }
} else { } else {
$config[$key] = $value; $config[$key] = $value;
} }
return $config; return $config;
} }
} }

View file

@ -1,217 +1,217 @@
<?php <?php
/** /**
* Zend Framework * Zend Framework
* *
* LICENSE * LICENSE
* *
* This source file is subject to the new BSD license that is bundled * This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt. * with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL: * It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd * http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to * If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email * obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately. * to license@zend.com so we can send you a copy immediately.
* *
* @category Zend * @category Zend
* @package Zend_Config * @package Zend_Config
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License * @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Config_Writer_Db.php 43 2009-12-21 14:12:34Z markus $ * @version $Id: Config_Writer_Db.php 43 2009-12-21 14:12:34Z markus $
*/ */
/** /**
* Usage: * Usage:
* require_once(LIBRARY_PATH . '/config/Config_Writer_Db.php'); * require_once(LIBRARY_PATH . '/config/Config_Writer_Db.php');
* $writer = new Config_Writer_Db(); * $writer = new Config_Writer_Db();
* $writer->setTableName('system_config'); * $writer->setTableName('system_config');
* $writer->write(Zend_Registry::get('config_dbc'), Zend_Registry::get('config')); * $writer->write(Zend_Registry::get('config_dbc'), Zend_Registry::get('config'));
* *
* $writer = new Config_Writer_Db(); * $writer = new Config_Writer_Db();
* $writer->setTableName('dnssec_org_param'); * $writer->setTableName('dnssec_org_param');
* $writer->write(Zend_Registry::get('config_dbc'), dnssec_org_conf, 'dnssec_org_id="2"'); * $writer->write(Zend_Registry::get('config_dbc'), dnssec_org_conf, 'dnssec_org_id="2"');
*/ */
/** /**
* @see Zend_Config_Writer * @see Zend_Config_Writer
*/ */
require_once 'Zend/Config/Writer.php'; require_once 'Zend/Config/Writer.php';
/** /**
* @category Zend * @category Zend
* @package Zend_Config * @package Zend_Config
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License * @license http://framework.zend.com/license/new-bsd New BSD License
*/ */
class Config_Writer_Db extends Zend_Config_Writer class Config_Writer_Db extends Zend_Config_Writer
{ {
/** /**
* String that separates nesting levels of configuration data identifiers * String that separates nesting levels of configuration data identifiers
* *
* @var string * @var string
*/ */
protected $_nestSeparator = '.'; protected $_nestSeparator = '.';
protected $_set = null; protected $_set = null;
protected $_tableName = null; protected $_tableName = null;
/** /**
* Set the nest separator * Set the nest separator
* *
* @param string $filename * @param string $filename
* @return Zend_Config_Writer_Ini * @return Zend_Config_Writer_Ini
*/ */
public function setNestSeparator($separator) public function setNestSeparator($separator)
{ {
$this->_nestSeparator = $separator; $this->_nestSeparator = $separator;
return $this; return $this;
} }
public function setTableName($name) public function setTableName($name)
{ {
$this->_tableName = $name; $this->_tableName = $name;
return $this; return $this;
} }
/** /**
* Defined by Zend_Config_Writer * Defined by Zend_Config_Writer
* *
* use set to limit impact when a shared config file is used (i.e. config per item using foreign keys) * use set to limit impact when a shared config file is used (i.e. config per item using foreign keys)
* *
* @param string $filename * @param string $filename
* @param Config_Db $config * @param Config_Db $config
* @param string $set * @param string $set
* @return void * @return void
*/ */
public function write($db = null, $config = null, $set = null) { public function write($db = null, $config = null, $set = null) {
$this->_set = $set; $this->_set = $set;
// this method is specialized for writing back Config objects (which hold config_db objects) // this method is specialized for writing back Config objects (which hold config_db objects)
if ($config !== null) { if ($config !== null) {
if ($config instanceof Config) if ($config instanceof Config)
$this->setConfig($config->getConfig()); $this->setConfig($config->getConfig());
else { else {
$this->setConfig($config); $this->setConfig($config);
} }
} }
if ($this->_config === null) { if ($this->_config === null) {
require_once 'Zend/Config/Exception.php'; require_once 'Zend/Config/Exception.php';
throw new Zend_Config_Exception('No config was set'); throw new Zend_Config_Exception('No config was set');
} }
if ($db === null) { if ($db === null) {
require_once 'Zend/Config/Exception.php'; require_once 'Zend/Config/Exception.php';
throw new Zend_Config_Exception('No db was set'); throw new Zend_Config_Exception('No db was set');
} }
$sql = array(); $sql = array();
$string = 'delete from ' . $this->_tableName; $string = 'delete from ' . $this->_tableName;
if ($this->_set !== null) { if ($this->_set !== null) {
$string .= ' where ' . $this->_set; $string .= ' where ' . $this->_set;
} }
$sql[] = $string; $sql[] = $string;
$iniString = ''; $iniString = '';
$extends = $this->_config->getExtends(); $extends = $this->_config->getExtends();
$sectionName = $this->_config->getSectionName(); $sectionName = $this->_config->getSectionName();
foreach ($this->_config as $key => $data) { foreach ($this->_config as $key => $data) {
$sql= array_merge($sql, $this->addEntry($sectionName, $key, $data)); $sql= array_merge($sql, $this->addEntry($sectionName, $key, $data));
} }
try { try {
$db->beginTransaction(); $db->beginTransaction();
foreach ($sql as $command) { foreach ($sql as $command) {
#Log::Log()->debug($command); #Log::Log()->debug($command);
$db->query($command); $db->query($command);
} }
$db->commit(); $db->commit();
} catch (Exception $e) { } catch (Exception $e) {
$db->rollBack(); $db->rollBack();
Log::Log()->err($e); Log::Log()->err($e);
throw $e; throw $e;
} }
} }
/** /**
* build key value pairs, key is created by recursively adding section names, delimited by "." * build key value pairs, key is created by recursively adding section names, delimited by "."
* @param string $prefix * @param string $prefix
* @param string $key * @param string $key
* @param mixed $data * @param mixed $data
*/ */
protected function addEntry($prefix, $key, $data) { protected function addEntry($prefix, $key, $data) {
$sql = array(); $sql = array();
if ($data instanceof Zend_Config) { if ($data instanceof Zend_Config) {
if ($prefix != '') if ($prefix != '')
$prefix .= '.'; $prefix .= '.';
$prefix .= $key; $prefix .= $key;
foreach ($data as $k => $v) { foreach ($data as $k => $v) {
$sql = array_merge($sql, $this->addEntry($prefix, $k, $v)); $sql = array_merge($sql, $this->addEntry($prefix, $k, $v));
} }
} }
else { else {
$string = 'insert into ' . $this->_tableName . ' set '; $string = 'insert into ' . $this->_tableName . ' set ';
$pkey = $prefix; $pkey = $prefix;
if ($pkey != '') if ($pkey != '')
$pkey .= '.'; $pkey .= '.';
$pkey .= $key; $pkey .= $key;
$string .= 'config_key=' . $this->_prepareValue($pkey) . ', '; $string .= 'config_key=' . $this->_prepareValue($pkey) . ', ';
$string .= 'config_value=' . $this->_prepareValue($data); $string .= 'config_value=' . $this->_prepareValue($data);
if ($this->_set !== null) if ($this->_set !== null)
$string .= ', ' . $this->_set; $string .= ', ' . $this->_set;
$sql[] = $string; $sql[] = $string;
} }
return $sql; return $sql;
} }
/** /**
* Add a branch to an INI string recursively * Add a branch to an INI string recursively
* *
* @param Zend_Config $config * @param Zend_Config $config
* @return void * @return void
*/ */
protected function _addBranch(Zend_Config $config, $parents = array()) protected function _addBranch(Zend_Config $config, $parents = array())
{ {
$iniString = ''; $iniString = '';
foreach ($config as $key => $value) { foreach ($config as $key => $value) {
$group = array_merge($parents, array($key)); $group = array_merge($parents, array($key));
if ($value instanceof Zend_Config) { if ($value instanceof Zend_Config) {
$iniString .= $this->_addBranch($value, $group); $iniString .= $this->_addBranch($value, $group);
} else { } else {
$iniString .= implode($this->_nestSeparator, $group) $iniString .= implode($this->_nestSeparator, $group)
. ' = ' . ' = '
. $this->_prepareValue($value) . $this->_prepareValue($value)
. "\n"; . "\n";
} }
} }
return $iniString; return $iniString;
} }
/** /**
* Prepare a value for INI * Prepare a value for INI
* *
* @param mixed $value * @param mixed $value
* @return string * @return string
*/ */
protected function _prepareValue($value) protected function _prepareValue($value)
{ {
if (is_integer($value) || is_float($value)) { if (is_integer($value) || is_float($value)) {
return $value; return $value;
} elseif (is_bool($value)) { } elseif (is_bool($value)) {
return ($value ? 'true' : 'false'); return ($value ? 'true' : 'false');
} else { } else {
return '"' . addslashes($value) . '"'; return '"' . addslashes($value) . '"';
} }
} }
} }

View file

@ -1,140 +1,140 @@
<?php <?php
/** /**
* class that provides methods to convert human readable time / interval length * class that provides methods to convert human readable time / interval length
* expressions into other formats * expressions into other formats
* *
* @author markus * @author markus
* $Id: HumanReadableTime.php 92 2010-03-10 11:43:15Z markus $ * $Id: HumanReadableTime.php 92 2010-03-10 11:43:15Z markus $
*/ */
require_once(LIBRARY_PATH . '/date/exception.HumanReadableTimeException.php'); require_once(LIBRARY_PATH . '/date/exception.HumanReadableTimeException.php');
class HumanReadableTime { class HumanReadableTime {
/** /**
* normalize an HRT string, convert from HRT to seconds and then convert back to * normalize an HRT string, convert from HRT to seconds and then convert back to
* HRT * HRT
* @param string $hrt * @param string $hrt
* @param string $maxunit * @param string $maxunit
* @return string * @return string
*/ */
public static function NormalizeHRT($hrt, $maxunit = 'w') { public static function NormalizeHRT($hrt, $maxunit = 'w') {
return self::Seconds2HR(self::HR2Seconds($hrt), $maxunit); return self::Seconds2HR(self::HR2Seconds($hrt), $maxunit);
} }
/** /**
* convert string / interger which contains an interval length to * convert string / interger which contains an interval length to
* human readable format (1w2d7h) * human readable format (1w2d7h)
* *
* if $maxunit is set, it defines the biggest unit in output (i.e. $maxunit = 'h' will * if $maxunit is set, it defines the biggest unit in output (i.e. $maxunit = 'h' will
* allow only hms) * allow only hms)
* *
* @param string|integer $seconds * @param string|integer $seconds
* @param string $maxunit * @param string $maxunit
* @return string * @return string
*/ */
public static function Seconds2HR($seconds, $maxunit = 'w') { public static function Seconds2HR($seconds, $maxunit = 'w') {
$maxunit = trim(strtolower($maxunit)); $maxunit = trim(strtolower($maxunit));
$allowed = array('w' => 0, 'd' => 0, 'h' => 0, 'm' => 0, 's' => 0); $allowed = array('w' => 0, 'd' => 0, 'h' => 0, 'm' => 0, 's' => 0);
if (!in_array($maxunit, array_keys($allowed), true)) if (!in_array($maxunit, array_keys($allowed), true))
throw new HumanReadableTimeException('illegal value for maxunit: "' . $maxunit . '"'); throw new HumanReadableTimeException('illegal value for maxunit: "' . $maxunit . '"');
foreach ($allowed as $key => $value) { foreach ($allowed as $key => $value) {
if ($maxunit == $key) if ($maxunit == $key)
break; break;
unset($allowed[$key]); unset($allowed[$key]);
} }
$seconds = intval($seconds); $seconds = intval($seconds);
$hrt = ''; $hrt = '';
foreach ($allowed as $key => $value) { foreach ($allowed as $key => $value) {
switch ($key) { switch ($key) {
case 'w': case 'w':
$tmp = intval($seconds / (7*86400)); $tmp = intval($seconds / (7*86400));
if ($tmp > 0) if ($tmp > 0)
$seconds %= (7*86400); $seconds %= (7*86400);
$allowed[$key] += $tmp; $allowed[$key] += $tmp;
break; break;
case 'd': case 'd':
$tmp = intval($seconds / (86400)); $tmp = intval($seconds / (86400));
if ($tmp > 0) if ($tmp > 0)
$seconds %= (86400); $seconds %= (86400);
$allowed[$key] += $tmp; $allowed[$key] += $tmp;
break; break;
case 'h': case 'h':
$tmp = intval($seconds / (3600)); $tmp = intval($seconds / (3600));
if ($tmp > 0) if ($tmp > 0)
$seconds %= (3600); $seconds %= (3600);
$allowed[$key] += $tmp; $allowed[$key] += $tmp;
break; break;
case 'm': case 'm':
$tmp = intval($seconds / (60)); $tmp = intval($seconds / (60));
if ($tmp > 0) if ($tmp > 0)
$seconds %= (60); $seconds %= (60);
$allowed[$key] += $tmp; $allowed[$key] += $tmp;
break; break;
case 's': case 's':
$allowed[$key] += $seconds; $allowed[$key] += $seconds;
break; break;
} }
} }
$hrt = ''; $hrt = '';
foreach ($allowed as $key => $value) { foreach ($allowed as $key => $value) {
if ($value > 0) if ($value > 0)
$hrt .= sprintf('%d%s', $value, $key); $hrt .= sprintf('%d%s', $value, $key);
} }
return $hrt; return $hrt;
} }
/** /**
* parse a string of 3h2m7s and return the number of seconds as integer * parse a string of 3h2m7s and return the number of seconds as integer
* add "s" to the end of the number if $addsecond is set to true * add "s" to the end of the number if $addsecond is set to true
* @param string $hr * @param string $hr
* @param boolean $addsecond * @param boolean $addsecond
* @return integer|string * @return integer|string
*/ */
public static function HR2Seconds($hr, $addsecond = false) { public static function HR2Seconds($hr, $addsecond = false) {
$hr = trim($hr); $hr = trim($hr);
if ($hr == '') { if ($hr == '') {
if ($addsecond === true) if ($addsecond === true)
return '0s'; return '0s';
else else
return 0; return 0;
} }
$hr = strtolower($hr); $hr = strtolower($hr);
$matches = array(); $matches = array();
if (preg_match_all('/([0-9]*)([wdhms])/', $hr, $matches, PREG_SET_ORDER) > 0) { if (preg_match_all('/([0-9]*)([wdhms])/', $hr, $matches, PREG_SET_ORDER) > 0) {
$interval = 0; $interval = 0;
for ($i = 0; $i < count($matches); $i++) { for ($i = 0; $i < count($matches); $i++) {
switch ($matches[$i][2]) { switch ($matches[$i][2]) {
case 'w': case 'w':
$interval += $matches[$i][1] * 7 * 86400; $interval += $matches[$i][1] * 7 * 86400;
break; break;
case 'd': case 'd':
$interval += $matches[$i][1] * 86400; $interval += $matches[$i][1] * 86400;
break; break;
case 'h': case 'h':
$interval += $matches[$i][1] * 3600; $interval += $matches[$i][1] * 3600;
break; break;
case 'm': case 'm':
$interval += $matches[$i][1] * 60; $interval += $matches[$i][1] * 60;
break; break;
case 's': case 's':
$interval += $matches[$i][1]; $interval += $matches[$i][1];
break; break;
} }
} }
if ($addsecond === true) if ($addsecond === true)
return sprintf('%ds', $interval); return sprintf('%ds', $interval);
else else
return $interval; return $interval;
} }
if ($addsecond === true) if ($addsecond === true)
return '0s'; return '0s';
else else
return 0; return 0;
} }
} }

View file

@ -1,36 +1,37 @@
<?php <?php
/** /**
* @package SLS * @package SLS
* @subpackage CONFIG.EXCEPTION * @subpackage CONFIG.EXCEPTION
*/ */
/** /**
* required files * required files
* @ignore * @ignore
*/ */
require_once(LIBRARY_PATH . '/exception/exception.Base.php'); require_once(LIBRARY_PATH . '/exception/exception.Base.php');
/** /**
* Exceptions thrown in the DNSSEC library classes * Exceptions thrown in the DNSSEC library classes
* *
* @package SLS * @package SLS
* @subpackage CONFIG.EXCEPTION * @subpackage CONFIG.EXCEPTION
* @author Markus Warg <mw@it-sls.de> * @author Markus Warg <mw@it-sls.de>
* @since 2009-02-25 13:05 * @since 2009-02-25 13:05
* @version $Id: exception.HumanReadableTimeException.php 91 2010-03-10 10:36:25Z markus $ * @version $Id: exception.HumanReadableTimeException.php 91 2010-03-10 10:36:25Z markus $
*/ */
class HumanReadableTimeException extends BaseException { class HumanReadableTimeException extends BaseException {
/** /**
* make new object * make new object
* *
* @access public * @access public
* @param string $message * @param string $message
* @param int $code * @param int $code
* @param string $extra * @param string $extra
*/ */
/* /*
public function __construct($message,$code = 0,$extra = '') { public function __construct($message,$code = 0,$extra = '') {
parent::__construct($message,$code, $extra); parent::__construct($message,$code, $extra);
} }
*/ */
} }
?>

View file

@ -1,15 +1,16 @@
<?php <?php
defined('LIBARARY_PATH') defined('LIBARARY_PATH')
|| define('LIBRARY_PATH', realpath(dirname(__FILE__) . '/..')); || define('LIBRARY_PATH', realpath(dirname(__FILE__) . '/..'));
require_once('HumanReadableTime.php'); require_once('HumanReadableTime.php');
$hrf = HumanReadableTime::HR2Seconds($argv[1], true); $hrf = HumanReadableTime::HR2Seconds($argv[1], true);
print 'Seconds: ' . $hrf . "\n"; print 'Seconds: ' . $hrf . "\n";
print 'Default: ' . HumanReadableTime::Seconds2HR($hrf) . "\n"; print 'Default: ' . HumanReadableTime::Seconds2HR($hrf) . "\n";
print 'Week: ' . HumanReadableTime::Seconds2HR($hrf, 'w') . "\n"; print 'Week: ' . HumanReadableTime::Seconds2HR($hrf, 'w') . "\n";
print 'Day: ' . HumanReadableTime::Seconds2HR($hrf, 'd') . "\n"; print 'Day: ' . HumanReadableTime::Seconds2HR($hrf, 'd') . "\n";
print 'Hour: ' . HumanReadableTime::Seconds2HR($hrf, 'h') . "\n"; print 'Hour: ' . HumanReadableTime::Seconds2HR($hrf, 'h') . "\n";
print 'Minute: ' . HumanReadableTime::Seconds2HR($hrf, 'm') . "\n"; print 'Minute: ' . HumanReadableTime::Seconds2HR($hrf, 'm') . "\n";
print 'Second: ' . HumanReadableTime::Seconds2HR($hrf, 's') . "\n"; print 'Second: ' . HumanReadableTime::Seconds2HR($hrf, 's') . "\n";

View file

@ -1,97 +1,98 @@
<?php <?php
/** /**
* @package SLS * @package SLS
* @subpackage EXCEPTION * @subpackage EXCEPTION
*/ */
/** /**
* extend PHPs standard exception by some details * extend PHPs standard exception by some details
* *
* @package SLS * @package SLS
* @subpackage EXCEPTION * @subpackage EXCEPTION
* @author Markus Warg <mw@it-sls.de> * @author Markus Warg <mw@it-sls.de>
* @since 2009-02-23 16:10 * @since 2009-02-23 16:10
* @version $Id: exception.Base.php 90 2010-03-09 09:48:27Z markus $ * @version $Id: exception.Base.php 90 2010-03-09 09:48:27Z markus $
*/ */
class BaseException extends Exception { class BaseException extends Exception {
/** /**
* additional data / string * additional data / string
* @var string * @var string
*/ */
protected $extra = ''; protected $extra = '';
/** /**
* location of thrower * location of thrower
* @var string * @var string
*/ */
protected $exception_location = ''; protected $exception_location = '';
/** /**
* make new object * make new object
* *
* @access public * @access public
* @param string $message * @param string $message
* @param int $code * @param int $code
*/ */
public function __construct($message, $code = 0, $extra = '') { public function __construct($message, $code = 0, $extra = '') {
$bt = debug_backtrace(); $bt = debug_backtrace();
$remove_exception = 0; $remove_exception = 0;
while( $remove_exception < count($bt) && isset($bt[$remove_exception]['class']) && eregi('exception', $bt[$remove_exception]['class']) ) { while( $remove_exception < count($bt) && isset($bt[$remove_exception]['class']) && eregi('exception', $bt[$remove_exception]['class']) ) {
$remove_exception++; $remove_exception++;
} }
if ($remove_exception > 0) if ($remove_exception > 0)
$remove_exception--; $remove_exception--;
if ($remove_exception < count($bt)) { if ($remove_exception < count($bt)) {
$this->exception_location = $bt[$remove_exception]['file'].':'.$bt[$remove_exception]['line']; $this->exception_location = $bt[$remove_exception]['file'].':'.$bt[$remove_exception]['line'];
} }
$this->extra = $extra; $this->extra = $extra;
parent::__construct($message,$code); parent::__construct($message,$code);
} }
/** /**
* Make a string out of this exception * Make a string out of this exception
* *
* @access public * @access public
* @return string * @return string
*/ */
public function __toString() { public function __toString() {
$out = __CLASS__ . '['.$this->code.']:'; $out = __CLASS__ . '['.$this->code.']:';
if ($this->exception_location != '') if ($this->exception_location != '')
$out.= $this->exception_location; $out.= $this->exception_location;
$out .= ':'; $out .= ':';
$out .= " {$this->message}"; $out .= " {$this->message}";
if (isset($this->extra) && strlen($this->extra) > 0) if (isset($this->extra) && strlen($this->extra) > 0)
$out .= " ({$this->extra})\n"; $out .= " ({$this->extra})\n";
return $out; return $out;
} }
/** /**
* get the extra info string * get the extra info string
* *
* @access public * @access public
* @return string * @return string
*/ */
public function getExtraInfo() { public function getExtraInfo() {
return $this->extra; return $this->extra;
} }
/** /**
* get the exception location string * get the exception location string
* *
* @access public * @access public
* @return string * @return string
*/ */
public function getExceptionLocation() { public function getExceptionLocation() {
return $this->exception_location; return $this->exception_location;
} }
} }
?>

View file

@ -1,28 +1,28 @@
<?php <?php
/** /**
* @author markus * @author markus
* $Id: defines.php 95 2010-03-19 14:14:39Z markus $ * $Id: defines.php 95 2010-03-19 14:14:39Z markus $
*/ */
// Define path to application directory // Define path to application directory
defined('APPLICATION_PATH') defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../application')); || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../application'));
defined('LIBARARY_PATH') defined('LIBARARY_PATH')
|| define('LIBRARY_PATH', realpath(dirname(__FILE__) . '/..')); || define('LIBRARY_PATH', realpath(dirname(__FILE__) . '/..'));
defined('FWACTIONS_PATH') defined('FWACTIONS_PATH')
|| define('FWACTIONS_PATH', LIBRARY_PATH . '/actions'); || define('FWACTIONS_PATH', LIBRARY_PATH . '/actions');
defined('LOCALE_PATH') defined('LOCALE_PATH')
|| define('LOCALE_PATH', realpath(dirname(__FILE__) . '/../../locale')); || define('LOCALE_PATH', realpath(dirname(__FILE__) . '/../../locale'));
// Define application environment // Define application environment
defined('APPLICATION_ENV') defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production')); || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
define('SYSTEM_CONFIG', 'system_config'); define('SYSTEM_CONFIG', 'system_config');
define('SYSTEM_LOG', 'log'); define('SYSTEM_LOG', 'log');
// Ensure library/ is on include_path // Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array( set_include_path(implode(PATH_SEPARATOR, array(
LIBRARY_PATH, LIBRARY_PATH,
get_include_path(), get_include_path(),
))); )));

View file

@ -1,95 +1,95 @@
<?php <?php
/** /**
* encapsulate Zend_Translate within an singleton class * encapsulate Zend_Translate within an singleton class
* @author markus * @author markus
* $Id: I18n.php 33 2009-12-10 15:08:38Z markus $ * $Id: I18n.php 33 2009-12-10 15:08:38Z markus $
*/ */
require_once('l10n/L10n.php'); require_once('l10n/L10n.php');
class I18n { class I18n {
/** /**
* static pointer to instance * static pointer to instance
* @var array(I18n) * @var array(I18n)
*/ */
private static $instance = null; private static $instance = null;
/** /**
* config object * config object
* @var Zend_Translate * @var Zend_Translate
*/ */
private $translate = null; private $translate = null;
/** /**
* make new translate * make new translate
*/ */
protected function __construct() { protected function __construct() {
$options = array( $options = array(
'log' => Log::Log(), 'log' => Log::Log(),
'logUntranslated' => false 'logUntranslated' => false
); );
$locale = L10n::getInstance(); $locale = L10n::getInstance();
$supported = $locale->getBrowser(); $supported = $locale->getBrowser();
arsort($supported, SORT_NUMERIC); arsort($supported, SORT_NUMERIC);
$file = ''; $file = '';
foreach ($supported as $loc => $val) { foreach ($supported as $loc => $val) {
if (file_exists(LOCALE_PATH . '/' . $loc . '/locale.php')) { if (file_exists(LOCALE_PATH . '/' . $loc . '/locale.php')) {
$file = LOCALE_PATH . '/' . $loc . '/locale.php'; $file = LOCALE_PATH . '/' . $loc . '/locale.php';
$locale->setLocale($loc); $locale->setLocale($loc);
break; break;
} }
} }
if ($file == '' && file_exists(LOCALE_PATH . '/en_US/locale.php')) { if ($file == '' && file_exists(LOCALE_PATH . '/en_US/locale.php')) {
$file = LOCALE_PATH . '/en_US/locale.php'; $file = LOCALE_PATH . '/en_US/locale.php';
$locale->setLocale('en_US'); $locale->setLocale('en_US');
} }
if ($file != '') { if ($file != '') {
$this->translate = new Zend_Translate(Zend_Translate::AN_ARRAY, $file, $locale->getLanguage(), $options); $this->translate = new Zend_Translate(Zend_Translate::AN_ARRAY, $file, $locale->getLanguage(), $options);
#Log::Log()->debug('locale ' . $locale->getLanguage() . '_' .$locale->getRegion() . ' loaded'); #Log::Log()->debug('locale ' . $locale->getLanguage() . '_' .$locale->getRegion() . ' loaded');
} }
else else
throw new Exception(__METHOD__ . ': no translation files available'); throw new Exception(__METHOD__ . ': no translation files available');
} }
/** /**
* get already existing instance, make new instance or throw an exception * get already existing instance, make new instance or throw an exception
* @return I18n * @return I18n
*/ */
public static function getInstance() { public static function getInstance() {
if (self::$instance === null) { if (self::$instance === null) {
self::$instance = new I18n(); self::$instance = new I18n();
} }
return self::$instance; return self::$instance;
} }
/** /**
* return the Zend_Translate object * return the Zend_Translate object
* @return Zend_Translate * @return Zend_Translate
*/ */
public static function getTranslate() { public static function getTranslate() {
return self::getInstance()->translate; return self::getInstance()->translate;
} }
/** /**
* map _ to translate * map _ to translate
* @param unknown_type $text * @param unknown_type $text
* @param unknown_type $locale * @param unknown_type $locale
*/ */
public function _($text, $locale = null) { public function _($text, $locale = null) {
return self::getInstance()->translate->_($text, $locale); return self::getInstance()->translate->_($text, $locale);
} }
/** /**
* magic __call dispatches all unknown methods to Zend_Translate * magic __call dispatches all unknown methods to Zend_Translate
* @param unknown_type $method * @param unknown_type $method
* @param unknown_type $arguments * @param unknown_type $arguments
*/ */
public function __call($method, $arguments) { public function __call($method, $arguments) {
return call_user_func_array(array($this->translate, $method), $arguments); return call_user_func_array(array($this->translate, $method), $arguments);
} }
} }

View file

@ -1,34 +1,34 @@
<?php <?php
/** /**
* @author markus * @author markus
* $Id: $ * $Id: $
*/ */
/** /**
* required files * required files
* @ignore * @ignore
*/ */
require_once(LIBRARY_PATH . '/exception/exception.Base.php'); require_once(LIBRARY_PATH . '/exception/exception.Base.php');
/** /**
* Exceptions thrown in the IMAP classes * Exceptions thrown in the IMAP classes
* *
* @package SLS * @package SLS
* @subpackage CONFIG.EXCEPTION * @subpackage CONFIG.EXCEPTION
* @author Markus Warg <mw@it-sls.de> * @author Markus Warg <mw@it-sls.de>
*/ */
class IMAPException extends BaseException { class IMAPException extends BaseException {
/** /**
* make new object * make new object
* *
* @access public * @access public
* @param string $message * @param string $message
* @param int $code * @param int $code
* @param string $extra * @param string $extra
*/ */
/* /*
public function __construct($message,$code = 0,$extra = '') { public function __construct($message,$code = 0,$extra = '') {
parent::__construct($message,$code, $extra); parent::__construct($message,$code, $extra);
} }
*/ */
} }

View file

@ -20,36 +20,36 @@ define('IMAP_RETRIES', 5);
*/ */
class imapConnection { class imapConnection {
/** /**
* Array mit den bereits vorhandenen Instanzen * Array mit den bereits vorhandenen Instanzen
* @var array * @var array
*/ */
private static $instances = array(); private static $instances = array();
/** /**
* Instanzname, die unterschiedlichen Entitäten werden über den Namen * Instanzname, die unterschiedlichen Entitäten werden über den Namen
* auseinandergehalten. * auseinandergehalten.
* @var string * @var string
*/ */
private $instanceName = ''; private $instanceName = '';
/** /**
* Configsection * Configsection
* @var Config * @var Config
*/ */
private $config = null; private $config = null;
/** /**
* IMAP Resource * IMAP Resource
* @var imap_stream * @var imap_stream
*/ */
private $imap = null; private $imap = null;
/** /**
* Servername, Port, Flags * Servername, Port, Flags
* @var string * @var string
*/ */
private $server = ''; private $server = '';
/** /**
* Name der zuletzt geöffneten Mailbox * Name der zuletzt geöffneten Mailbox
@ -57,222 +57,222 @@ class imapConnection {
*/ */
private $mbox = ''; private $mbox = '';
/** /**
* wird auf true gesetzt, wenn imapPing die Connection neu aufbaut * wird auf true gesetzt, wenn imapPing die Connection neu aufbaut
* @var boolean * @var boolean
*/ */
private $reopenedConnection = false; private $reopenedConnection = false;
/** /**
* liefert eine Liste der verfügbaren Folder * liefert eine Liste der verfügbaren Folder
* @param string $pattern * @param string $pattern
* @return array * @return array
*/ */
public function imapList($pattern = '*') { public function imapList($pattern = '*') {
if ($this->imap === null) { if ($this->imap === null) {
throw new IMAPException(__METHOD__ . ' not connected'); throw new IMAPException(__METHOD__ . ' not connected');
} }
$this->imapPing(true); $this->imapPing(true);
return imap_list($this->imap, $this->server, $pattern); return imap_list($this->imap, $this->server, $pattern);
} }
/** /**
* Checkt die Anzahl Messages in einer Mailbox * Checkt die Anzahl Messages in einer Mailbox
* return array * return array
*/ */
public function imapCheck() { public function imapCheck() {
if ($this->imap === null) { if ($this->imap === null) {
throw new IMAPException(__METHOD__ . ' not connected'); throw new IMAPException(__METHOD__ . ' not connected');
} }
$this->imapPing(true); $this->imapPing(true);
return imap_check($this->imap); return imap_check($this->imap);
} }
/** /**
* per imap_reopen die aktuelle Connection auf eine andere mbox umstellen * per imap_reopen die aktuelle Connection auf eine andere mbox umstellen
* @param string $mbox * @param string $mbox
* @return boolean * @return boolean
*/ */
public function imapSwitchMbox($mbox) { public function imapSwitchMbox($mbox) {
if ($this->imap === null) { if ($this->imap === null) {
throw new IMAPException(__METHOD__ . ' not connected'); throw new IMAPException(__METHOD__ . ' not connected');
} }
$this->imapPing(true); $this->imapPing(true);
if (imap_reopen($this->imap, $this->server.$mbox) === false) { if (imap_reopen($this->imap, $this->server.$mbox) === false) {
throw new IMAPException(__METHOD__ . ' reopen failed'); throw new IMAPException(__METHOD__ . ' reopen failed');
} }
$this->mbox = $mbox; $this->mbox = $mbox;
return true; return true;
} }
/** /**
* setzt ein Flag bei allen in $sequence aufgeführten Messages * setzt ein Flag bei allen in $sequence aufgeführten Messages
* @param string $sequence * @param string $sequence
* @param string $flag * @param string $flag
* @param integer $options * @param integer $options
* @return boolean * @return boolean
*/ */
public function imapSetflagFull($sequence, $flag, $options = 0) { public function imapSetflagFull($sequence, $flag, $options = 0) {
if ($this->imap === null) { if ($this->imap === null) {
throw new IMAPException(__METHOD__ . ' not connected'); throw new IMAPException(__METHOD__ . ' not connected');
} }
$this->imapPing(true); $this->imapPing(true);
return imap_setflag_full($this->imap, $sequence, $flag, $options); return imap_setflag_full($this->imap, $sequence, $flag, $options);
} }
/** /**
* liefert die Mailheader * liefert die Mailheader
* @return array * @return array
*/ */
public function imapHeaders() { public function imapHeaders() {
if ($this->imap === null) { if ($this->imap === null) {
throw new IMAPException(__METHOD__ . ' not connected'); throw new IMAPException(__METHOD__ . ' not connected');
} }
$this->imapPing(true); $this->imapPing(true);
return imap_headers($this->imap); return imap_headers($this->imap);
} }
/** /**
* liefert die Header zu genau einer Mail mit der gegebenen ID * liefert die Header zu genau einer Mail mit der gegebenen ID
* @param integer $number * @param integer $number
* @return array * @return array
*/ */
public function imapHeader($number) { public function imapHeader($number) {
if ($this->imap === null) { if ($this->imap === null) {
throw new IMAPException(__METHOD__ . ' not connected'); throw new IMAPException(__METHOD__ . ' not connected');
} }
$this->imapPing(true); $this->imapPing(true);
return imap_headerinfo($this->imap, $number); return imap_headerinfo($this->imap, $number);
} }
/** /**
* liefert die Header zu genau einer Mail mit der gegebenen UID * liefert die Header zu genau einer Mail mit der gegebenen UID
* @param integer $uid * @param integer $uid
* @return array * @return array
*/ */
public function imapFetchHeader($uid) { public function imapFetchHeader($uid) {
if ($this->imap === null) { if ($this->imap === null) {
throw new IMAPException(__METHOD__ . ' not connected'); throw new IMAPException(__METHOD__ . ' not connected');
} }
$ret = imap_fetchheader($this->imap, $uid, FT_UID); $ret = imap_fetchheader($this->imap, $uid, FT_UID);
return $ret; return $ret;
} }
/** /**
* liefert die Header zu genau einer Mail mit der gegebenen UID * liefert die Header zu genau einer Mail mit der gegebenen UID
* @param integer $uid * @param integer $uid
* @return array * @return array
*/ */
public function imapFetchOverview($uid) { public function imapFetchOverview($uid) {
if ($this->imap === null) { if ($this->imap === null) {
throw new IMAPException(__METHOD__ . ' not connected'); throw new IMAPException(__METHOD__ . ' not connected');
} }
$ret = imap_fetch_overview($this->imap, $uid, FT_UID); $ret = imap_fetch_overview($this->imap, $uid, FT_UID);
return $ret[0]; return $ret[0];
} }
/** /**
* liefert den Body zu genau einer Mail mit der gegebenen ID * liefert den Body zu genau einer Mail mit der gegebenen ID
* @param integer $number * @param integer $number
* @return string * @return string
*/ */
public function imapBody($number) { public function imapBody($number) {
if ($this->imap === null) { if ($this->imap === null) {
throw new IMAPException(__METHOD__ . ' not connected'); throw new IMAPException(__METHOD__ . ' not connected');
} }
$this->imapPing(true); $this->imapPing(true);
return imap_body($this->imap, $number); return imap_body($this->imap, $number);
} }
/** /**
* liefert den Body zu genau einer Mail mit der gegebenen UID * liefert den Body zu genau einer Mail mit der gegebenen UID
* @param integer $uid * @param integer $uid
* @return string * @return string
*/ */
public function imapBodyByUID($uid) { public function imapBodyByUID($uid) {
if ($this->imap === null) { if ($this->imap === null) {
throw new IMAPException(__METHOD__ . ' not connected'); throw new IMAPException(__METHOD__ . ' not connected');
} }
$this->imapPing(true); $this->imapPing(true);
return imap_body($this->imap, $uid, FT_UID ); return imap_body($this->imap, $uid, FT_UID );
} }
/** /**
* markiert die Nachricht mit der unique ID zum löschen * markiert die Nachricht mit der unique ID zum löschen
* @param integer $uid * @param integer $uid
* return boolean * return boolean
*/ */
public function imapDelete($uid) { public function imapDelete($uid) {
if ($this->imap === null) { if ($this->imap === null) {
throw new IMAPException(__METHOD__ . ' not connected'); throw new IMAPException(__METHOD__ . ' not connected');
} }
$this->imapPing(true); $this->imapPing(true);
$ret = imap_delete($this->imap, $uid, FT_UID); $ret = imap_delete($this->imap, $uid, FT_UID);
if ($ret !== true) { if ($ret !== true) {
print "imap delete returned false for ".$uid."\n"; print "imap delete returned false for ".$uid."\n";
} }
return $ret; return $ret;
} }
/** /**
* löscht alle zum löschen markierten Nachrichten * löscht alle zum löschen markierten Nachrichten
* @return boolean * @return boolean
*/ */
public function imapExpunge() { public function imapExpunge() {
if ($this->imap === null) { if ($this->imap === null) {
throw new IMAPException(__METHOD__ . ' not connected'); throw new IMAPException(__METHOD__ . ' not connected');
} }
$this->imapPing(true); $this->imapPing(true);
return imap_expunge($this->imap); return imap_expunge($this->imap);
} }
/** /**
* kopiert die Nachricht mit der gegebenen uid in die gegebene Mailbox *auf dem selben Server* * kopiert die Nachricht mit der gegebenen uid in die gegebene Mailbox *auf dem selben Server*
* @param integer $uid * @param integer $uid
* @param string $dest_mbox * @param string $dest_mbox
* @return boolean * @return boolean
*/ */
public function imapMailCopy($uid, $dest_mbox) { public function imapMailCopy($uid, $dest_mbox) {
if ($this->imap === null) { if ($this->imap === null) {
throw new IMAPException(__METHOD__ . ' not connected'); throw new IMAPException(__METHOD__ . ' not connected');
} }
$this->imapPing(true); $this->imapPing(true);
return imap_mail_copy($this->imap, $uid, $dest_mbox, CP_UID); return imap_mail_copy($this->imap, $uid, $dest_mbox, CP_UID);
} }
/** /**
* verschiebt die Nachricht mit der gegebenen uid in die gegebene Mailbox *auf dem selben Server* * verschiebt die Nachricht mit der gegebenen uid in die gegebene Mailbox *auf dem selben Server*
* @param integer $uid * @param integer $uid
* @param string $dest_mbox * @param string $dest_mbox
* @return boolean * @return boolean
*/ */
public function imapMailMove($uid, $dest_mbox) { public function imapMailMove($uid, $dest_mbox) {
if ($this->imap === null) { if ($this->imap === null) {
throw new IMAPException(__METHOD__ . ' not connected'); throw new IMAPException(__METHOD__ . ' not connected');
} }
$this->imapPing(true); $this->imapPing(true);
/* /*
* dont't add the server part, * dont't add the server part,
@ -280,136 +280,136 @@ class imapConnection {
* *
* $dest_mbox = $this->server.$dest_mbox; * $dest_mbox = $this->server.$dest_mbox;
*/ */
return imap_mail_move( $this->imap, $uid, $dest_mbox, CP_UID); return imap_mail_move( $this->imap, $uid, $dest_mbox, CP_UID);
} }
/** /**
* legt eine neue Mailbox *auf dem selben Server* an * legt eine neue Mailbox *auf dem selben Server* an
* @param string $mbox * @param string $mbox
* @return boolean * @return boolean
*/ */
public function imapCreateMailbox($mbox) { public function imapCreateMailbox($mbox) {
if ($this->imap === null) { if ($this->imap === null) {
throw new IMAPException(__METHOD__ . ' not connected'); throw new IMAPException(__METHOD__ . ' not connected');
} }
$this->imapPing(true); $this->imapPing(true);
return imap_createmailbox($this->imap, $this->server.$mbox); return imap_createmailbox($this->imap, $this->server.$mbox);
} }
/** /**
* fragt ab, ob eine mbox unterhalb von mbox_root existiert und liefert true zurück, falls ja * fragt ab, ob eine mbox unterhalb von mbox_root existiert und liefert true zurück, falls ja
* Funktion existiert nicht direkt als IMAP Kommando, aus einzelnen Kommando's zusammengebaut * Funktion existiert nicht direkt als IMAP Kommando, aus einzelnen Kommando's zusammengebaut
* *
* @param string $mbox_root * @param string $mbox_root
* @param string $mbox * @param string $mbox
* @return boolean * @return boolean
*/ */
public function imapMailboxExists($mbox_root, $mbox) { public function imapMailboxExists($mbox_root, $mbox) {
if ($this->imap === null) { if ($this->imap === null) {
throw new IMAPException(__METHOD__ . ' not connected'); throw new IMAPException(__METHOD__ . ' not connected');
} }
$this->imapPing(true); $this->imapPing(true);
$folderlist = $this->imapList($mbox_root); $folderlist = $this->imapList($mbox_root);
$foundFolder = false; $foundFolder = false;
foreach ($folderlist as $folder) { foreach ($folderlist as $folder) {
if (strpos($folder, $mbox) !== false) { if (strpos($folder, $mbox) !== false) {
return true; return true;
} }
} }
return false; return false;
} }
const AR_YYYY = 'Y'; const AR_YYYY = 'Y';
const AR_YYYYMM = 'Ym'; const AR_YYYYMM = 'Ym';
const AR_YYYYMMDD = 'Ymd'; const AR_YYYYMMDD = 'Ymd';
/** /**
* erzeugt eine Archivmailbox zur Mailbox $mbox, dabei wird das Archiv unterhalb von $mbox * erzeugt eine Archivmailbox zur Mailbox $mbox, dabei wird das Archiv unterhalb von $mbox
* auf dem selben Server angelegt, der Name der Mailbox enthält je nach $mode noch einen Datumsstamp * auf dem selben Server angelegt, der Name der Mailbox enthält je nach $mode noch einen Datumsstamp
* Wenn der Input ($mbox) bereits mehrere Ebenen enthält (NOC3.domain.incoming z.B.), dann * Wenn der Input ($mbox) bereits mehrere Ebenen enthält (NOC3.domain.incoming z.B.), dann
* wird automatisch nur der am weitesten rechts stehende Teil extrahiert und benutzt. * wird automatisch nur der am weitesten rechts stehende Teil extrahiert und benutzt.
* NOC3.domain.incoming => NOC3.domain.incoming.incoming-200705 * NOC3.domain.incoming => NOC3.domain.incoming.incoming-200705
* @param string $mbox * @param string $mbox
* @param string $mode * @param string $mode
* @param integer $timestamp * @param integer $timestamp
* @param string $delimiter * @param string $delimiter
* @return string * @return string
*/ */
public static function imapMakeArchiveName($mbox, $mode, $timestamp = null, $delimiter = '-') { public static function imapMakeArchiveName($mbox, $mode, $timestamp = null, $delimiter = '-') {
if ($timestamp === null) if ($timestamp === null)
$timestamp = time(); $timestamp = time();
$ar = explode('.', $mbox); $ar = explode('.', $mbox);
$sub_mbox = $ar[count($ar) - 1]; $sub_mbox = $ar[count($ar) - 1];
return $mbox.'.'.$sub_mbox.$delimiter.date($mode,$timestamp); return $mbox.'.'.$sub_mbox.$delimiter.date($mode,$timestamp);
} }
public static function imapMakePrefixedArchiveName($mbox, $mode, $prefix = '', $timestamp = null, $delimiter = '-') { public static function imapMakePrefixedArchiveName($mbox, $mode, $prefix = '', $timestamp = null, $delimiter = '-') {
if ($timestamp === null) if ($timestamp === null)
$timestamp = time(); $timestamp = time();
$ar = explode('.', $mbox); $ar = explode('.', $mbox);
$sub_mbox = $ar[count($ar) - 1]; $sub_mbox = $ar[count($ar) - 1];
return $mbox.'.'.$prefix.$delimiter.$sub_mbox.$delimiter.date($mode,$timestamp); return $mbox.'.'.$prefix.$delimiter.$sub_mbox.$delimiter.date($mode,$timestamp);
} }
/** /**
* liefert die unique ID der Nachricht mit der laufenden msg_number * liefert die unique ID der Nachricht mit der laufenden msg_number
* @param integer $msg_number * @param integer $msg_number
* @return integer * @return integer
*/ */
public function imapUID($msg_number) { public function imapUID($msg_number) {
if ($this->imap === null) { if ($this->imap === null) {
throw new IMAPException(__METHOD__ . ' not connected'); throw new IMAPException(__METHOD__ . ' not connected');
} }
$this->imapPing(true); $this->imapPing(true);
return imap_uid($this->imap, $msg_number); return imap_uid($this->imap, $msg_number);
} }
/** /**
* liefert die laufende msg_number der Nachricht, die die unique ID uid hat * liefert die laufende msg_number der Nachricht, die die unique ID uid hat
* @param integer $uid * @param integer $uid
* @return integer * @return integer
*/ */
public function imapMsgNo($uid) { public function imapMsgNo($uid) {
if ($this->imap === null) { if ($this->imap === null) {
throw new IMAPException(__METHOD__ . ' not connected'); throw new IMAPException(__METHOD__ . ' not connected');
} }
$this->imapPing(true); $this->imapPing(true);
return imap_msgno($this->imap, $uid); return imap_msgno($this->imap, $uid);
} }
/** /**
* prüft, ob die Connection noch aktiv ist, Exception falls keine Connection definiert ist, * prüft, ob die Connection noch aktiv ist, Exception falls keine Connection definiert ist,
* oder die Connection geschlossen wurde * oder die Connection geschlossen wurde
* wenn reconnect = true, dann wird bei einer geschlossenen Connection die Connection neu aufgebaut * wenn reconnect = true, dann wird bei einer geschlossenen Connection die Connection neu aufgebaut
* @param boolean $reconnect * @param boolean $reconnect
* @return boolean * @return boolean
*/ */
public function imapPing($reconnect = false) { public function imapPing($reconnect = false) {
if ($this->imap === null) { if ($this->imap === null) {
throw new IMAPException(__METHOD__ . ' not connected'); throw new IMAPException(__METHOD__ . ' not connected');
} }
$ret = imap_ping($this->imap); $ret = imap_ping($this->imap);
if ($ret === false) { if ($ret === false) {
if ($reconnect === true) { if ($reconnect === true) {
$this->imap = $this->imapOpen($this->server.$this->mbox, $this->imap = $this->imapOpen($this->server.$this->mbox,
$this->config->username, $this->config->username,
$this->config->password, $this->config->password,
OP_HALFOPEN); OP_HALFOPEN);
$ret = imap_ping($this->imap); $ret = imap_ping($this->imap);
@ -424,138 +424,138 @@ class imapConnection {
} }
} }
return true; return true;
} }
public function __destruct() { public function __destruct() {
if ($this->imap !== null) { if ($this->imap !== null) {
imap_close($this->imap); imap_close($this->imap);
$this->imap = null; $this->imap = null;
} }
} }
/** /**
* true, wenn imapPing die Connection neu aufgemacht hat * true, wenn imapPing die Connection neu aufgemacht hat
* Variable wird auf false gesetzt wenn $flush true ist * Variable wird auf false gesetzt wenn $flush true ist
* @param boolean $flush * @param boolean $flush
* @return boolean * @return boolean
*/ */
public function connectionReopened($flush = true) { public function connectionReopened($flush = true) {
$ret = $this->reopenedConnection; $ret = $this->reopenedConnection;
if ($flush === true) { if ($flush === true) {
$this->reopenedConnection = false; $this->reopenedConnection = false;
} }
return $ret; return $ret;
} }
/** /**
* interne IMAP Open Methode * interne IMAP Open Methode
* *
* @param string $servername * @param string $servername
* @param string $username * @param string $username
* @param string password * @param string password
* @param integer $flags * @param integer $flags
* @return resource * @return resource
*/ */
protected function imapOpen($server, $username, $password, $flags) { protected function imapOpen($server, $username, $password, $flags) {
return imap_open($server, $username, $password, $flags); return imap_open($server, $username, $password, $flags);
} }
/** /**
* privater Konstruktor, wird exklusiv von getInstance aufgerufen * privater Konstruktor, wird exklusiv von getInstance aufgerufen
* *
* @param $instanceName * @param $instanceName
* @param $config * @param $config
*/ */
protected function __construct($instanceName, $config) { protected function __construct($instanceName, $config) {
$this->instanceName = $instanceName; $this->instanceName = $instanceName;
$this->config = $config; $this->config = $config;
if (!isset($this->config->mailhost)) { if (!isset($this->config->mailhost)) {
throw new IMAPException(__METHOD__ . ' config attribute missing: "mailhost"'); throw new IMAPException(__METHOD__ . ' config attribute missing: "mailhost"');
} }
if (!isset($this->config->username)) { if (!isset($this->config->username)) {
throw new IMAPException(__METHOD__ . ' config attribute missing: "username"'); throw new IMAPException(__METHOD__ . ' config attribute missing: "username"');
} }
if (!isset($this->config->password)) { if (!isset($this->config->password)) {
throw new IMAPException(__METHOD__ . ' config attribute missing: "password"'); throw new IMAPException(__METHOD__ . ' config attribute missing: "password"');
} }
if (!isset($this->config->port)) { if (!isset($this->config->port)) {
throw new IMAPException(__METHOD__ . ' config attribute missing: "port"'); throw new IMAPException(__METHOD__ . ' config attribute missing: "port"');
} }
$this->server = '{'.$this->config->mailhost.':'.$this->config->port.'/imap'; $this->server = '{'.$this->config->mailhost.':'.$this->config->port.'/imap';
if( isset($this->config->use_tls) && if( isset($this->config->use_tls) &&
$this->config->use_tls != 0 ) { $this->config->use_tls != 0 ) {
$this->server .= '/tls'; $this->server .= '/tls';
} }
$this->server .= '/novalidate-cert}'; $this->server .= '/novalidate-cert}';
$mbox = ''; $mbox = '';
$this->mbox = $mbox; $this->mbox = $mbox;
$this->imap = null; $this->imap = null;
$this->imap = $this->imapOpen($this->server.$mbox, $this->imap = $this->imapOpen($this->server.$mbox,
$this->config->username, $this->config->username,
$this->config->password, $this->config->password,
OP_HALFOPEN); OP_HALFOPEN);
if ($this->imap === false) { if ($this->imap === false) {
$this->imap = null; $this->imap = null;
throw new IMAPException(__METHOD__ . ' not connected'); throw new IMAPException(__METHOD__ . ' not connected');
} }
$this->reopenedConnection = false; $this->reopenedConnection = false;
} }
/** /**
* sucht nach einer bereits vorhandenen Instanz, wird keine gefunden, * sucht nach einer bereits vorhandenen Instanz, wird keine gefunden,
* dann wird eine neue Instanz angelegt. * dann wird eine neue Instanz angelegt.
* Man kann die Config-Variable weglassen, wenn man sicher ist, dass * Man kann die Config-Variable weglassen, wenn man sicher ist, dass
* bereits eine Instanz mit dem gewünschten instanceName existiert, * bereits eine Instanz mit dem gewünschten instanceName existiert,
* existiert aber keiner, dann liefert getInstance eine Exception. * existiert aber keiner, dann liefert getInstance eine Exception.
* *
* @param $instance * @param $instance
* @param $config * @param $config
* @return imapConnection * @return imapConnection
*/ */
public static function getInstance($instanceName,$config = null) { public static function getInstance($instanceName,$config = null) {
if (!self::$instances) if (!self::$instances)
self::$instances = array(); self::$instances = array();
foreach (self::$instances as $instance) { foreach (self::$instances as $instance) {
if ($instance->getInstanceName() == $instanceName) if ($instance->getInstanceName() == $instanceName)
return $instance; return $instance;
} }
/* /*
if (!$config instanceof Config) { if (!$config instanceof Config) {
throw new IMAPException(__METHOD__ . ' no config'); throw new IMAPException(__METHOD__ . ' no config');
} }
*/ */
$object = new imapConnection($instanceName, $config); $object = new imapConnection($instanceName, $config);
self::$instances[] = $object; self::$instances[] = $object;
return $object; return $object;
} }
/** /**
* Liefert den Namen der aktuellen Instanz * Liefert den Namen der aktuellen Instanz
* @return string * @return string
*/ */
public function getInstanceName() { public function getInstanceName() {
return $this->instanceName; return $this->instanceName;
} }
} }

View file

@ -1,47 +1,47 @@
<?php <?php
/** /**
* encapsulate Zend_Locale within an singleton class * encapsulate Zend_Locale within an singleton class
* @author markus * @author markus
* $Id: L10n.php 13 2009-11-24 14:52:56Z markus $ * $Id: L10n.php 13 2009-11-24 14:52:56Z markus $
*/ */
class L10n { class L10n {
/** /**
* static pointer to instance * static pointer to instance
* @var L10n * @var L10n
*/ */
private static $instance = null; private static $instance = null;
/** /**
* config object * config object
* @var Zend_Locale * @var Zend_Locale
*/ */
private $locale = null; private $locale = null;
/** /**
* make new translate * make new translate
*/ */
protected function __construct() { protected function __construct() {
$this->locale = new Zend_Locale(); $this->locale = new Zend_Locale();
} }
/** /**
* get already existing instance, make new instance or throw an exception * get already existing instance, make new instance or throw an exception
* @return L10n * @return L10n
*/ */
public static function getInstance() { public static function getInstance() {
if (self::$instance === null) { if (self::$instance === null) {
self::$instance = new L10n(); self::$instance = new L10n();
} }
return self::$instance; return self::$instance;
} }
/** /**
* magic __call dispatches all unknown methods to Zend_Locale * magic __call dispatches all unknown methods to Zend_Locale
* @param unknown_type $method * @param unknown_type $method
* @param unknown_type $arguments * @param unknown_type $arguments
*/ */
public function __call($method, $arguments) { public function __call($method, $arguments) {
return call_user_func_array(array($this->locale, $method), $arguments); return call_user_func_array(array($this->locale, $method), $arguments);
} }
} }

View file

@ -1,105 +1,105 @@
<?php <?php
/** /**
* encapsulate Zend_Log with one or several log writers within an singleton class * encapsulate Zend_Log with one or several log writers within an singleton class
* @author markus * @author markus
* $Id: Log.php 77 2010-02-26 11:58:34Z markus $ * $Id: Log.php 77 2010-02-26 11:58:34Z markus $
*/ */
class Log { class Log {
/** /**
* static pointer to instances * static pointer to instances
* @var array(Config) * @var array(Config)
*/ */
private static $instances = array(); private static $instances = array();
/** /**
* can handle several instances, distinct by instance name string * can handle several instances, distinct by instance name string
* @var string * @var string
*/ */
private $instanceName = ''; private $instanceName = '';
/** /**
* config object * config object
* @var Zend_Log * @var Zend_Log
*/ */
private $log = null; private $log = null;
/** /**
* make new logger, configuration is taken from system_config, section $instanceName * make new logger, configuration is taken from system_config, section $instanceName
* @param string $instanceName * @param string $instanceName
* @param string $application * @param string $application
*/ */
protected function __construct($instanceName, $application = null) { protected function __construct($instanceName, $application = null) {
if ($instanceName === null) if ($instanceName === null)
throw new Exception(__METHOD__ . ': expected an instance name, got none'); throw new Exception(__METHOD__ . ': expected an instance name, got none');
$config = Config::getInstance(SYSTEM_CONFIG); $config = Config::getInstance(SYSTEM_CONFIG);
$log_config = $config->$instanceName; $log_config = $config->$instanceName;
$this->log = new Zend_Log(); $this->log = new Zend_Log();
if (isset($log_config->file) && intval($log_config->file->enabled) !== 0) { if (isset($log_config->file) && intval($log_config->file->enabled) !== 0) {
$file_logger = new Zend_Log_Writer_Stream($log_config->file->name); $file_logger = new Zend_Log_Writer_Stream($log_config->file->name);
/** /**
* *
$format = Zend_Log_Formatter_Simple::DEFAULT_FORMAT; $format = Zend_Log_Formatter_Simple::DEFAULT_FORMAT;
$formatter = new Zend_Log_Formatter_Simple($format); $formatter = new Zend_Log_Formatter_Simple($format);
$file_logger->setFormatter($formatter); $file_logger->setFormatter($formatter);
*/ */
if (isset($application) && $application != '') if (isset($application) && $application != '')
$this->log->setEventItem('application', $application); $this->log->setEventItem('application', $application);
$formatter = new Zend_Log_Formatter_Simple('%syslog_time% %application%[%pid%]: %priorityName%: %message%' . PHP_EOL); $formatter = new Zend_Log_Formatter_Simple('%syslog_time% %application%[%pid%]: %priorityName%: %message%' . PHP_EOL);
$file_logger->setFormatter($formatter); $file_logger->setFormatter($formatter);
$this->log->addWriter($file_logger); $this->log->addWriter($file_logger);
} }
if (isset($log_config->syslog) && intval($log_config->syslog->enabled) !== 0) { if (isset($log_config->syslog) && intval($log_config->syslog->enabled) !== 0) {
$param = array('facility' => $log_config->syslog->facility); $param = array('facility' => $log_config->syslog->facility);
if (isset($application) && $application != '') if (isset($application) && $application != '')
$param['application'] = $application; $param['application'] = $application;
$sys_logger = new Zend_Log_Writer_Syslog($param); $sys_logger = new Zend_Log_Writer_Syslog($param);
$formatter = new Zend_Log_Formatter_Simple('%priorityName%: %message%' . PHP_EOL); $formatter = new Zend_Log_Formatter_Simple('%priorityName%: %message%' . PHP_EOL);
$sys_logger->setFormatter($formatter); $sys_logger->setFormatter($formatter);
$this->log->addWriter($sys_logger); $this->log->addWriter($sys_logger);
} }
$filter = new Zend_Log_Filter_Priority(intval($log_config->priority)); $filter = new Zend_Log_Filter_Priority(intval($log_config->priority));
$this->log->addFilter($filter); $this->log->addFilter($filter);
} }
/** /**
* get already existing instance, make new instance or throw an exception * get already existing instance, make new instance or throw an exception
* @param string $instanceName * @param string $instanceName
* @param string $application * @param string $application
*/ */
public static function getInstance($instanceName = null, $application = null) { public static function getInstance($instanceName = null, $application = null) {
if ($instanceName === null) { if ($instanceName === null) {
if (count(self::$instances) == 0) if (count(self::$instances) == 0)
throw new Exception(__METHOD__ . ': expected an instance name, got none'); throw new Exception(__METHOD__ . ': expected an instance name, got none');
return self::$instances[0]; return self::$instances[0];
} }
if (!array_key_exists($instanceName, self::$instances)) { if (!array_key_exists($instanceName, self::$instances)) {
self::$instances[$instanceName] = new Log($instanceName, $application); self::$instances[$instanceName] = new Log($instanceName, $application);
} }
return self::$instances[$instanceName]; return self::$instances[$instanceName];
} }
/** /**
* return SYSTEM_LOG for convenience * return SYSTEM_LOG for convenience
* @return Zend_Log * @return Zend_Log
*/ */
public static function Log() { public static function Log() {
return self::$instances[SYSTEM_LOG]->getLog(); return self::$instances[SYSTEM_LOG]->getLog();
} }
/** /**
* get the Zend_Log object * get the Zend_Log object
* @return Zend_Log * @return Zend_Log
*/ */
public function getLog() { public function getLog() {
$this->log->setEventItem('pid', posix_getpid()); $this->log->setEventItem('pid', posix_getpid());
$this->log->setEventItem('syslog_time', date('Y-m-d H:i:s')); $this->log->setEventItem('syslog_time', date('Y-m-d H:i:s'));
return $this->log; return $this->log;
} }
} }

View file

@ -1,74 +1,74 @@
<?php <?php
/** /**
* this plugin tries to add modules to the top navigation depending on the user * this plugin tries to add modules to the top navigation depending on the user
* which is logged in and the required permissions needed (provided by the action modules) * which is logged in and the required permissions needed (provided by the action modules)
* *
* @author markus * @author markus
* $Id: plugin.buildmenu.php 95 2010-03-19 14:14:39Z markus $ * $Id: plugin.buildmenu.php 95 2010-03-19 14:14:39Z markus $
*/ */
class BuildMenu extends Zend_Controller_Plugin_Abstract { class BuildMenu extends Zend_Controller_Plugin_Abstract {
public function preDispatch(Zend_Controller_Request_Abstract $request) { public function preDispatch(Zend_Controller_Request_Abstract $request) {
$session = Zend_Registry::get('session'); $session = Zend_Registry::get('session');
if (!isset($session->authdata) || !isset($session->authdata['authed']) || $session->authdata['authed'] === false) if (!isset($session->authdata) || !isset($session->authdata['authed']) || $session->authdata['authed'] === false)
return; return;
$cur_ctrl = $request->getControllerName(); $cur_ctrl = $request->getControllerName();
$cur_action = $request->getActionName(); $cur_action = $request->getActionName();
$view = Zend_Registry::get('view'); $view = Zend_Registry::get('view');
if (is_dir(FWACTIONS_PATH)) { if (is_dir(FWACTIONS_PATH)) {
$dir = opendir(FWACTIONS_PATH); $dir = opendir(FWACTIONS_PATH);
while (($file = readdir($dir)) !== false) { while (($file = readdir($dir)) !== false) {
if ($file == '.' || $file == '..') if ($file == '.' || $file == '..')
continue; continue;
if (preg_match('/^Action([a-zA-Z0-9_]*)\.php/', $file, $match)) { if (preg_match('/^Action([a-zA-Z0-9_]*)\.php/', $file, $match)) {
$path = FWACTIONS_PATH . '/' . $file; $path = FWACTIONS_PATH . '/' . $file;
require_once($path); require_once($path);
$r = new ReflectionClass($match[1]); $r = new ReflectionClass($match[1]);
if ($r->isSubclassOf('FWAction')) { if ($r->isSubclassOf('FWAction')) {
/** /**
* match Actions permission with the permissions of the currently logged in user, * match Actions permission with the permissions of the currently logged in user,
* add to menu if user has access to that action * add to menu if user has access to that action
*/ */
$required = $r->getMethod('getRequiredPermissions')->invoke(null); $required = $r->getMethod('getRequiredPermissions')->invoke(null);
$menuprio = $r->getMethod('getTopNavPrio')->invoke(null); $menuprio = $r->getMethod('getTopNavPrio')->invoke(null);
$ctrl = $r->getMethod('getController')->invoke(null); $ctrl = $r->getMethod('getController')->invoke(null);
$action = $r->getMethod('getAction')->invoke(null); $action = $r->getMethod('getAction')->invoke(null);
$text = $r->getMethod('getMenutext')->invoke(null); $text = $r->getMethod('getMenutext')->invoke(null);
$role = $session->authdata['authed_role']; $role = $session->authdata['authed_role'];
if ($cur_ctrl == $ctrl) # && $cur_action == $action) if ($cur_ctrl == $ctrl) # && $cur_action == $action)
$aclass = ' class="active"'; $aclass = ' class="active"';
else else
$aclass = ''; $aclass = '';
$acl = $session->authdata['authed_permissions']; $acl = $session->authdata['authed_permissions'];
if (is_array($required) && count($required) == 0) { if (is_array($required) && count($required) == 0) {
$view->topNav('<a href="' . $view->topNav('<a href="' .
$view->url(array('controller' => $ctrl, 'action' => $action), 'default', true) . $view->url(array('controller' => $ctrl, 'action' => $action), 'default', true) .
'"' . $aclass . '>' . I18n::_($text) . '</a>', Zend_View_Helper_Placeholder_Container_Abstract::SET, $menuprio); '"' . $aclass . '>' . I18n::_($text) . '</a>', Zend_View_Helper_Placeholder_Container_Abstract::SET, $menuprio);
} }
else { else {
foreach ($required as $rperm) { foreach ($required as $rperm) {
if ($acl->has($rperm) && $acl->isAllowed($role, $rperm, 'view')) { if ($acl->has($rperm) && $acl->isAllowed($role, $rperm, 'view')) {
$view->topNav('<a href="' . $view->topNav('<a href="' .
$view->url(array('controller' => $ctrl, 'action' => $action), 'default', true) . $view->url(array('controller' => $ctrl, 'action' => $action), 'default', true) .
'"' . $aclass . '>' . I18n::_($text) . '</a>', Zend_View_Helper_Placeholder_Container_Abstract::SET, $menuprio); '"' . $aclass . '>' . I18n::_($text) . '</a>', Zend_View_Helper_Placeholder_Container_Abstract::SET, $menuprio);
break; // exit on first match break; // exit on first match
} }
} }
} }
} }
} }
} }
closedir($dir); closedir($dir);
} }
} }
} }

View file

@ -1,13 +1,13 @@
<?php <?php
/** /**
* @author markus * @author markus
* $Id: plugin.charsetheader.php 13 2009-11-24 14:52:56Z markus $ * $Id: plugin.charsetheader.php 13 2009-11-24 14:52:56Z markus $
*/ */
class CharsetHeader extends Zend_Controller_Plugin_Abstract { class CharsetHeader extends Zend_Controller_Plugin_Abstract {
public function preDispatch(Zend_Controller_Request_Abstract $request) { public function preDispatch(Zend_Controller_Request_Abstract $request) {
$response = $this->getResponse(); $response = $this->getResponse();
if ($response->canSendHeaders() === true) { if ($response->canSendHeaders() === true) {
$response->setHeader('Content-Type', 'text/html; charset=utf-8'); $response->setHeader('Content-Type', 'text/html; charset=utf-8');
} }
} }
} }

View file

@ -1,29 +1,29 @@
<?php <?php
/** /**
* @author markus * @author markus
* $Id: plugin.forceauth.php 40 2009-12-21 09:40:43Z markus $ * $Id: plugin.forceauth.php 40 2009-12-21 09:40:43Z markus $
*/ */
class ForceAuth extends Zend_Controller_Plugin_Abstract { class ForceAuth extends Zend_Controller_Plugin_Abstract {
public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request) { public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request) {
$session = Zend_Registry::get('session'); $session = Zend_Registry::get('session');
if (in_array($request->getControllerName(), array('login', 'error', 'js', 'img', 'css'))) if (in_array($request->getControllerName(), array('login', 'error', 'js', 'img', 'css')))
return; return;
if (!isset($session->authdata) || !isset($session->authdata['authed']) || $session->authdata['authed'] === false) { if (!isset($session->authdata) || !isset($session->authdata['authed']) || $session->authdata['authed'] === false) {
$fc = Zend_Controller_Front::getInstance(); $fc = Zend_Controller_Front::getInstance();
$response = $fc->getResponse(); $response = $fc->getResponse();
$response->canSendHeaders(true); $response->canSendHeaders(true);
$response->setHeader('Location', 'login', true); $response->setHeader('Location', 'login', true);
$response->setHeader('Status', '301', true); $response->setHeader('Status', '301', true);
Log::Log()->debug('redirected to login'); Log::Log()->debug('redirected to login');
$request->setModuleName('default') $request->setModuleName('default')
->setControllerName('login') ->setControllerName('login')
->setActionName('index') ->setActionName('index')
->setDispatched(false); ->setDispatched(false);
} }
} }
} }

View file

@ -1,31 +1,31 @@
<?php <?php
/** /**
* this plugin just monitors the authdata section in the current session and adds an login / logout link to the * this plugin just monitors the authdata section in the current session and adds an login / logout link to the
* top navigation bar depending on the value that was found * top navigation bar depending on the value that was found
* @author markus * @author markus
* $Id: plugin.loginlogout.php 95 2010-03-19 14:14:39Z markus $ * $Id: plugin.loginlogout.php 95 2010-03-19 14:14:39Z markus $
*/ */
class LoginLogout extends Zend_Controller_Plugin_Abstract { class LoginLogout extends Zend_Controller_Plugin_Abstract {
public function postDispatch(Zend_Controller_Request_Abstract $request) { public function postDispatch(Zend_Controller_Request_Abstract $request) {
$session = Zend_Registry::get('session'); $session = Zend_Registry::get('session');
if (!isset($session->authdata) || !isset($session->authdata['authed']) || $session->authdata['authed'] === false) { if (!isset($session->authdata) || !isset($session->authdata['authed']) || $session->authdata['authed'] === false) {
$controller = 'login'; $controller = 'login';
$text = 'Login'; $text = 'Login';
} }
else { else {
$controller = 'logout'; $controller = 'logout';
$text = 'Logout'; $text = 'Logout';
} }
$cur_ctrl = $request->getControllerName(); $cur_ctrl = $request->getControllerName();
if ($cur_ctrl == 'login') if ($cur_ctrl == 'login')
$aclass=' class="active"'; $aclass=' class="active"';
else else
$aclass=''; $aclass='';
$view = Zend_Registry::get('view'); $view = Zend_Registry::get('view');
$view->topNav('<a href="' . $view->topNav('<a href="' .
$view->url(array('controller' => $controller), 'default', true) . $view->url(array('controller' => $controller), 'default', true) .
'"' . $aclass . '>' . I18n::_($text) . '</a>', Zend_View_Helper_Placeholder_Container_Abstract::SET, 1000); '"' . $aclass . '>' . I18n::_($text) . '</a>', Zend_View_Helper_Placeholder_Container_Abstract::SET, 1000);
} }
} }

View file

@ -1,2 +1,2 @@
<?php <?php
return array(); return array();

View file

@ -1,23 +1,23 @@
@CHARSET "UTF-8"; @CHARSET "UTF-8";
#content dl.zend_form label.required { #content dl.zend_form label.required {
color: #000000; color: #000000;
font-weight: bold; font-weight: bold;
} }
#content dl.zend_form { #content dl.zend_form {
display: block; display: block;
} }
#content dl.zend_form dt { #content dl.zend_form dt {
display: block; display: block;
float: left; float: left;
width: 125px; width: 125px;
margin: 10px; margin: 10px;
} }
#content dl.zend_form dd { #content dl.zend_form dd {
display: block; display: block;
clear: right; clear: right;
padding: 10px; padding: 10px;
} }

View file

@ -1,24 +1,24 @@
@CHARSET "UTF-8"; @CHARSET "UTF-8";
#content dl.zend_form label.required { #content dl.zend_form label.required {
color: #000000; color: #000000;
font-weight: bold; font-weight: bold;
} }
#content dl.zend_form { #content dl.zend_form {
display: block; display: block;
font-size: 0.8em; font-size: 0.8em;
} }
#content dl.zend_form dt { #content dl.zend_form dt {
display: block; display: block;
float: left; float: left;
width: 350px; width: 350px;
margin: 10px; margin: 10px;
} }
#content dl.zend_form dd { #content dl.zend_form dd {
display: block; display: block;
clear: right; clear: right;
padding: 10px; padding: 10px;
} }

View file

@ -1,123 +1,123 @@
@CHARSET "UTF-8"; @CHARSET "UTF-8";
html { html {
font-family: sans-serif; font-family: sans-serif;
background-color: #cccccc; background-color: #cccccc;
color: #333333; color: #333333;
overflow: scroll; overflow: scroll;
} }
#center { #center {
position: absolute; position: absolute;
width: 1000px; width: 1000px;
left: 50%; left: 50%;
margin-left: -500px; margin-left: -500px;
} }
#header { #header {
background-color: #F5F7F7; background-color: #F5F7F7;
width: 99%; width: 99%;
height: 30px; height: 30px;
top: 0px; top: 0px;
left: 0px; left: 0px;
position: absolute; position: absolute;
padding: 3px; padding: 3px;
margin: 3px; margin: 3px;
} }
#header-logo { #header-logo {
float: left; float: left;
color: #FFFFFF; color: #FFFFFF;
} }
#header-navigation { #header-navigation {
float: right; float: right;
} }
#header-navigation ul { #header-navigation ul {
list-style-type: none; list-style-type: none;
padding: 0px; padding: 0px;
margin: 0px; margin: 0px;
font-size: 1.2em; font-size: 1.2em;
} }
#header-navigation ul li { #header-navigation ul li {
padding-left: 5px; padding-left: 5px;
margin-left: 5px; margin-left: 5px;
display: inline; display: inline;
} }
#header-navigation ul li a { #header-navigation ul li a {
text-decoration: none; text-decoration: none;
color: #000000; color: #000000;
} }
#header-navigation ul li a:hover { #header-navigation ul li a:hover {
color: #777777; color: #777777;
} }
#header-navigation ul li a.active { #header-navigation ul li a.active {
color: #505090; color: #505090;
} }
#left-navigation { #left-navigation {
background-color: #F5F7F7; background-color: #F5F7F7;
width: 180px; width: 180px;
height: 600px; height: 600px;
left: 0px; left: 0px;
top: 36px; top: 36px;
position: absolute; position: absolute;
padding: 3px; padding: 3px;
margin: 3px; margin: 3px;
} }
#left-navigation ul { #left-navigation ul {
list-style-type: none; list-style-type: none;
padding: 0px; padding: 0px;
margin: 0px; margin: 0px;
font-size: 1.2em; font-size: 1.2em;
} }
#left-navigation ul li { #left-navigation ul li {
padding-left: 5px; padding-left: 5px;
margin-left: 5px; margin-left: 5px;
display: block; display: block;
} }
#left-navigation ul li a { #left-navigation ul li a {
text-decoration: none; text-decoration: none;
color: #000000; color: #000000;
} }
#left-navigation ul li a:hover { #left-navigation ul li a:hover {
color: #777777; color: #777777;
} }
#left-navigation ul li a.active { #left-navigation ul li a.active {
color: #770000; color: #770000;
} }
#content { #content {
left: 186px; left: 186px;
top: 36px; top: 36px;
width: 800px; width: 800px;
position: absolute; position: absolute;
padding: 5px; padding: 5px;
margin: 3px; margin: 3px;
background-color: #FFFFFF; background-color: #FFFFFF;
} }
#userinfo { #userinfo {
right: 5px; right: 5px;
bottom: 5px; bottom: 5px;
position: absolute; position: absolute;
padding: 3px; padding: 3px;
margin: 3px; margin: 3px;
background-color: #DDDDAA; background-color: #DDDDAA;
font-size: 0.8em; font-size: 0.8em;
} }
#content .error { #content .error {
color: #F80808; color: #F80808;
font-weight: bold; font-weight: bold;
} }

View file

@ -1,11 +1,11 @@
@CHARSET "UTF-8"; @CHARSET "UTF-8";
#content a { #content a {
text-decoration: none; text-decoration: none;
color: #000000; color: #000000;
font-size: 1.2em; font-size: 1.2em;
} }
#content a:hover { #content a:hover {
color: #777777; color: #777777;
} }

View file

@ -1,49 +1,49 @@
@CHARSET "UTF-8"; @CHARSET "UTF-8";
#content table { #content table {
border: 1px solid black; border: 1px solid black;
border-collapse: collapse; border-collapse: collapse;
} }
#content th { #content th {
border: 1px solid black; border: 1px solid black;
padding: 3px; padding: 3px;
} }
#content td { #content td {
border: 1px solid black; border: 1px solid black;
padding: 3px; padding: 3px;
} }
#content .col1 { #content .col1 {
width: 170px; width: 170px;
} }
#content .col2 { #content .col2 {
width: 170px; width: 170px;
} }
#content .col3 { #content .col3 {
width: 165px; width: 165px;
} }
#content .col4 { #content .col4 {
width: 170px; width: 170px;
} }
#content .col5 { #content .col5 {
width: 50px; width: 50px;
} }
#content .col6 { #content .col6 {
width: 30px; width: 30px;
} }
#content a { #content a {
text-decoration: none; text-decoration: none;
color: #000000; color: #000000;
} }
#content a:hover { #content a:hover {
color: #777777; color: #777777;
} }
#content a.delete { #content a.delete {
background-color: #ffffff; background-color: #ffffff;
color: white; color: white;
} }

View file

@ -1,51 +1,51 @@
<?php <?php
/* /*
* @done Zend_Locale (http://framework.zend.com/manual/en/zend.locale.functions.html) * @done Zend_Locale (http://framework.zend.com/manual/en/zend.locale.functions.html)
* @done Zend_Translate (Buch 381ff, 383) http://framework.zend.com/manual/en/zend.translate.using.html * @done Zend_Translate (Buch 381ff, 383) http://framework.zend.com/manual/en/zend.translate.using.html
* @done Session Tabelle aufräumen (auto expire eingebaut, Housekeeper fehlt aber) * @done Session Tabelle aufräumen (auto expire eingebaut, Housekeeper fehlt aber)
* @todo Zend_Auth (LoginController - Reaktion auf falsche Eingaben fehlt noch) * @todo Zend_Auth (LoginController - Reaktion auf falsche Eingaben fehlt noch)
* @todo Zend_Filter_Input - Zeichensätze aus Userinput filtern * @todo Zend_Filter_Input - Zeichensätze aus Userinput filtern
* @todo Zend_Measure, Zend_Currency * @todo Zend_Measure, Zend_Currency
* @todo Zend_Date * @todo Zend_Date
* @todo Daemon / CLI Zend_Console_Getopt (Buch 203ff) * @todo Daemon / CLI Zend_Console_Getopt (Buch 203ff)
* @todo Zend_Mail (Buch 279ff) * @todo Zend_Mail (Buch 279ff)
* @todo Zend_Form(!), Zend_Validate, Zend_Filter * @todo Zend_Form(!), Zend_Validate, Zend_Filter
* @todo Zend_Log - Formatierung der Texte * @todo Zend_Log - Formatierung der Texte
* @todo Funktionsmodule - jedes Modul prüft die Rechte anhand der Session und Zend_Acl und fügt ggf. einen Link ins Menü ein (TOP / LEFT) * @todo Funktionsmodule - jedes Modul prüft die Rechte anhand der Session und Zend_Acl und fügt ggf. einen Link ins Menü ein (TOP / LEFT)
* @todo addMessages mit übersetzten Strings (LoginController -> getForm, ...) * @todo addMessages mit übersetzten Strings (LoginController -> getForm, ...)
* @todo favicon * @todo favicon
* @todo sinnvolle Defaults, wenn system_config leer ist (globale Config BIND) * @todo sinnvolle Defaults, wenn system_config leer ist (globale Config BIND)
* @todo sinnvolle Defaults, wenn system_config leer ist (Organisationsconfig BIND) * @todo sinnvolle Defaults, wenn system_config leer ist (Organisationsconfig BIND)
* @todo Links zum Löschen für Zonen / Organisationen, Rechtechecks in ActionController (foreign key constraints beachten!) * @todo Links zum Löschen für Zonen / Organisationen, Rechtechecks in ActionController (foreign key constraints beachten!)
* @todo ConfigBIND left Menu geht nicht aus, wenn man die selektierte Org deaktiviert (init vor Action) * @todo ConfigBIND left Menu geht nicht aus, wenn man die selektierte Org deaktiviert (init vor Action)
* @todo Textausgabe, wenn Attribute aus Defaults initialisiert und NICHT aus der DB geladen wurden * @todo Textausgabe, wenn Attribute aus Defaults initialisiert und NICHT aus der DB geladen wurden
*/ */
require_once('../library/global/defines.php'); require_once('../library/global/defines.php');
try { try {
/** Zend Autoloader */ /** Zend Autoloader */
require_once 'Zend/Loader/Autoloader.php'; require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance(); Zend_Loader_Autoloader::getInstance();
// Create application, bootstrap, and run // Create application, bootstrap, and run
$application = new Zend_Application( $application = new Zend_Application(
APPLICATION_ENV, APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini' APPLICATION_PATH . '/configs/application.ini'
); );
/** override settings from application.ini, if necessary /** override settings from application.ini, if necessary
$fc = Zend_Controller_Front::getInstance(); $fc = Zend_Controller_Front::getInstance();
$fc->setControllerDirectory(realpath(APPLICATION_PATH . '/controllers')); $fc->setControllerDirectory(realpath(APPLICATION_PATH . '/controllers'));
$fc->setParam('noViewRenderer', false); $fc->setParam('noViewRenderer', false);
$fc->throwExceptions(true); $fc->throwExceptions(true);
$fc->setParam('noErrorHandler', false); $fc->setParam('noErrorHandler', false);
*/ */
$application->bootstrap() $application->bootstrap()
->run(); ->run();
} catch (Exception $e) { } catch (Exception $e) {
print "Exception: " . $e->getMessage() . "\n"; print "Exception: " . $e->getMessage() . "\n";
print $e->getTraceAsString() . "\n"; print $e->getTraceAsString() . "\n";
Log::Log()->emerg($e); Log::Log()->emerg($e);
} }

View file

@ -1,10 +1,10 @@
function setCSS() { function setCSS() {
var x = window.innerWidth; var x = window.innerWidth;
x = x - 18; // maybe scroll bar x = x - 18; // maybe scroll bar
document.getElementById('center').style.width = x + "px"; document.getElementById('center').style.width = x + "px";
document.getElementById('center').style.marginLeft = "-" + x/2 + "px"; document.getElementById('center').style.marginLeft = "-" + x/2 + "px";
} }
window.onload = setCSS; window.onload = setCSS;
window.onresize = setCSS; window.onresize = setCSS;

View file

@ -1,8 +1,8 @@
var delay = 2000; var delay = 2000;
setTimeout('redirect()', delay); setTimeout('redirect()', delay);
function redirect() { function redirect() {
var returnto = document.getElementById('returnto'); var returnto = document.getElementById('returnto');
window.location = returnto.value; window.location = returnto.value;
} }

View file

@ -1,17 +1,17 @@
function setUserInfoPos() { function setUserInfoPos() {
var x = window.innerWidth; var x = window.innerWidth;
var ui; var ui;
x = x - 18; // maybe scroll bar x = x - 18; // maybe scroll bar
ui = document.getElementById('userinfo'); ui = document.getElementById('userinfo');
if (ui != null) { if (ui != null) {
ui.style.right = "3px"; ui.style.right = "3px";
// document.getElementById('userinfo').style.bottom = "3px"; // document.getElementById('userinfo').style.bottom = "3px";
ui.style.bottom = 3 - window.pageYOffset + "px"; ui.style.bottom = 3 - window.pageYOffset + "px";
} }
} }
window.onload = setUserInfoPos; window.onload = setUserInfoPos;
window.onresize = setUserInfoPos; window.onresize = setUserInfoPos;
window.onscroll = setUserInfoPos; window.onscroll = setUserInfoPos;