diff --git a/docs/VERSION.txt b/docs/VERSION.txt index 8c50098..9cec716 100644 --- a/docs/VERSION.txt +++ b/docs/VERSION.txt @@ -1 +1 @@ -3.1 +3.1.6 diff --git a/lib/authentication/authenticationsource.inc.php b/lib/authentication/authenticationsource.inc.php index 4010fce..e8c31fc 100644 --- a/lib/authentication/authenticationsource.inc.php +++ b/lib/authentication/authenticationsource.inc.php @@ -94,6 +94,14 @@ class KTAuthenticationSource extends KTEntity { } return KTAuthenticationSource::get($iAuthenticationSourceId); } + + function &getByAuthenticationProvider($sProvider) { + return KTEntityUtil::getBy('KTAuthenticationSource', 'authentication_provider', $sProvider); + } + + function &getSources() { + return KTEntityUtil::getList2('KTAuthenticationSource'); + } } ?> diff --git a/lib/authentication/authenticationutil.inc.php b/lib/authentication/authenticationutil.inc.php index 5d327fa..fe45747 100644 --- a/lib/authentication/authenticationutil.inc.php +++ b/lib/authentication/authenticationutil.inc.php @@ -68,4 +68,16 @@ class KTAuthenticationUtil { $oAuthenticator = KTAuthenticationUtil::getAuthenticatorForSource($iSourceId); return $oAuthenticator->synchroniseGroup($oGroup); } + + function autoSignup($sUsername, $aExtra) { + $aSources = KTAuthenticationSource::getSources(); + foreach ($aSources as $oSource) { + $oProvider = KTAuthenticationUtil::getAuthenticationProviderForSource($oSource); + $res = $oProvider->autoSignup($sUsername, $aExtra, $oSource); + if ($res) { + return $res; + } + } + return false; + } } diff --git a/lib/authentication/interceptor.inc.php b/lib/authentication/interceptor.inc.php new file mode 100644 index 0000000..feb37b0 --- /dev/null +++ b/lib/authentication/interceptor.inc.php @@ -0,0 +1,81 @@ +aInfo = $aInfo; + } + + function getName() { + return $this->sName; + } + + function getNamespace() { + return $this->sNamespace; + } + + /** + * Return a user object if the authentication succeeds + */ + function authenticated() { + return null; + } + + /** + * Get an opportunity to take over the request. + * Remember to exit if you take over. + */ + function takeOver() { + return null; + } + + function loginWidgets() { + return null; + } + + function alternateLogin() { + return null; + } +} + +class KTNoLocalUser extends PEAR_Error { + function KTNoLocalUser($aExtra = null) { + parent::PEAR_Error(_kt('No local user with that username')); + $this->aExtra = $aExtra; + } +} diff --git a/lib/authentication/interceptorinstances.inc.php b/lib/authentication/interceptorinstances.inc.php new file mode 100644 index 0000000..115e18b --- /dev/null +++ b/lib/authentication/interceptorinstances.inc.php @@ -0,0 +1,81 @@ + "id", + "sName" => "name", + "sInterceptorNamespace" => "interceptor_namespace", + "sConfig" => "config", + ); + + var $_bUsePearError = true; + + function getName() { return $this->sName; } + function getInterceptorNamespace() { return $this->sInterceptorNamespace; } + function getConfig() { return $this->sConfig; } + function setName($sName) { $this->sName = $sName; } + function setInterceptorNamespace($mValue) { $this->sInterceptorNamespace = $mValue; } + function setConfig($sConfig) { $this->sConfig = $sConfig; } + + function _table () { + return KTUtil::getTableName('interceptor_instances'); + } + + // STATIC + function &get($iId) { + return KTEntityUtil::get('KTInterceptorInstance', $iId); + } + + // STATIC + function &createFromArray($aOptions) { + return KTEntityUtil::createFromArray('KTInterceptorInstance', $aOptions); + } + + // STATIC + function &getList($sWhereClause = null) { + return KTEntityUtil::getList2('KTInterceptorInstance', $sWhereClause); + } + + // STATIC + function &getByInterceptorNamespace($sNamespace) { + return KTEntityUtil::getBy('KTInterceptorInstance', 'namespace', $sNamespace); + } + + function &getInterceptorInstances() { + return KTEntityUtil::getList2('KTInterceptorInstance', $sWhereClause); + } +} + +?> diff --git a/lib/authentication/interceptorregistry.inc.php b/lib/authentication/interceptorregistry.inc.php new file mode 100644 index 0000000..8eb105b --- /dev/null +++ b/lib/authentication/interceptorregistry.inc.php @@ -0,0 +1,127 @@ +_aInterceptorsInfo[$nsname] = array($class, $nsname, $path, $sPlugin); + } + + function getInterceptorInfo($nsname) { + return $this->_aInterceptorsInfo[$nsname]; + } + + function &getInterceptor($nsname, $config = null) { + $aInfo = $this->_aInterceptorsInfo[$nsname]; + $sClass = $aInfo[0]; + $sPath = $aInfo[2]; + if ($sPath) { + if (file_exists($sPath)) { + require_once($sPath); + } + } + if (!class_exists($sClass)) { + return PEAR::raiseError(sprintf(_kt("Can't find interceptor: %s"), $nsname)); + } + $oInterceptor =& new $sClass; + if ($config) { + $oInterceptor->configure($config); + } + return $oInterceptor; + } + + function &getInterceptorFromInstance($oInstance) { + return $this->getInterceptor($oInstance->getInterceptorNamespace(), $oInstance->getConfig()); + } + + function &getConfiguredInstances() { + $aInterceptorInstances = $this->_getInterceptorInstances(); + $aReturn = array(); + foreach ($aInterceptorInstances as $oInstance) { + $oInterceptor = $this->getInterceptorFromInstance($oInstance); + if (PEAR::isError($oInterceptor)) { + continue; + } + $aReturn[] = $oInterceptor; + } + return $aReturn; + } + + function checkInterceptorsForAuthenticated() { + $oRegistry =& KTInterceptorRegistry::getSingleton(); + $aInterceptors = $oRegistry->getConfiguredInstances(); + $aErrors = array(); + foreach ($aInterceptors as $oInterceptor) { + $oUser = $oInterceptor->authenticated(); + if (PEAR::isError($oUser)) { + $aErrors[] = $oUser; + continue; + } + if ($oUser) { + return $oUser; + } + } + if (count($aErrors)) { + return $aErrors; + } + return false; + } + + function _getInterceptorInstances() { + return KTInterceptorInstance::getInterceptorInstances(); + } + + function checkInterceptorsForTakeOver() { + $oRegistry =& KTInterceptorRegistry::getSingleton(); + $aInterceptors = $oRegistry->getConfiguredInstances(); + foreach ($aInterceptors as $oInterceptor) { + $oInterceptor->takeover(); + } + return false; + } +} + +?> diff --git a/lib/plugins/plugin.inc.php b/lib/plugins/plugin.inc.php index ddf827d..b748272 100644 --- a/lib/plugins/plugin.inc.php +++ b/lib/plugins/plugin.inc.php @@ -57,7 +57,7 @@ class KTPlugin { var $_aWidgets = array(); var $_aValidators = array(); var $_aCriteria = array(); - + var $_aInterceptors = array(); function KTPlugin($sFilename = null) { $this->sFilename = $sFilename; @@ -183,6 +183,10 @@ class KTPlugin { $this->_aCriteria[$sNamespace] = array($sClassName, $sNamespace, $sFilename, $aInitialize); } + function registerInterceptor($sClassname, $sNamespace, $sPath = null) { + $sPath = $this->_fixFilename($sPath); + $this->_aInterceptors[$sNamespace] = array($sClassname, $sNamespace, $sPath); + } function _fixFilename($sFilename) { if (empty($sFilename)) { @@ -245,6 +249,7 @@ class KTPlugin { require_once(KT_LIB_DIR . "/validation/validatorfactory.inc.php"); require_once(KT_LIB_DIR . "/browse/columnregistry.inc.php"); require_once(KT_LIB_DIR . "/browse/criteriaregistry.php"); + require_once(KT_LIB_DIR . "/authentication/interceptorregistry.inc.php"); $oPRegistry =& KTPortletRegistry::getSingleton(); $oTRegistry =& KTTriggerRegistry::getSingleton(); @@ -262,6 +267,7 @@ class KTPlugin { $oWidgetFactory =& KTWidgetFactory::getSingleton(); $oValidatorFactory =& KTValidatorFactory::getSingleton(); $oCriteriaRegistry =& KTCriteriaRegistry::getSingleton(); + $oInterceptorRegistry =& KTInterceptorRegistry::getSingleton(); foreach ($this->_aPortlets as $k => $v) { call_user_func_array(array(&$oPRegistry, 'registerPortlet'), $v); @@ -342,6 +348,10 @@ class KTPlugin { foreach ($this->_aValidators as $k => $v) { call_user_func_array(array(&$oValidatorFactory, 'registerValidator'), $v); } + + foreach ($this->_aInterceptors as $k => $v) { + call_user_func_array(array(&$oInterceptorRegistry, 'registerInterceptor'), $v); + } } function setup() { diff --git a/sql/mysql/install/data.sql b/sql/mysql/install/data.sql index 361aff3..4e069e5 100644 --- a/sql/mysql/install/data.sql +++ b/sql/mysql/install/data.sql @@ -3,7 +3,7 @@ -- http://www.phpmyadmin.net -- -- Host: localhost --- Generation Time: Jul 31, 2006 at 10:43 AM +-- Generation Time: Aug 22, 2006 at 10:19 AM -- Server version: 5.0.22 -- PHP Version: 4.4.2-1build1 @@ -391,6 +391,11 @@ INSERT INTO `help` VALUES (100, 'pageDisclaimer', 'pageDisclaimer.html'); -- +-- Dumping data for table `interceptor_instances` +-- + + +-- -- Dumping data for table `links` -- @@ -732,7 +737,7 @@ INSERT INTO `status_lookup` VALUES (5, 'Incomplete'); -- INSERT INTO `system_settings` VALUES (1, 'lastIndexUpdate', '0'); -INSERT INTO `system_settings` VALUES (2, 'knowledgeTreeVersion', '3.1'); +INSERT INTO `system_settings` VALUES (2, 'knowledgeTreeVersion', '3.1.6'); INSERT INTO `system_settings` VALUES (3, 'databaseVersion', '2.99.5'); -- @@ -885,6 +890,10 @@ INSERT INTO `upgrades` VALUES (110, 'sql*3.0.3.6*0*3.0.3.6/document-restore.sql' INSERT INTO `upgrades` VALUES (111, 'func*3.0.3.7*0*rebuildAllPermissions', 'Rebuild all permissions to ensure correct functioning of permission-definitions.', '2006-07-26 11:48:28', 1, 'upgrade*3.0.3.7*99*upgrade3.0.3.7'); INSERT INTO `upgrades` VALUES (112, 'upgrade*3.0.3.7*99*upgrade3.0.3.7', 'Upgrade from version 3.0.3.5 to 3.0.3.7', '2006-07-26 11:48:28', 1, 'upgrade*3.0.3.7*99*upgrade3.0.3.7'); INSERT INTO `upgrades` VALUES (113, 'upgrade*3.1*99*upgrade3.1', 'Upgrade from version 3.0.3.7 to 3.1', '2006-07-31 10:41:12', 1, 'upgrade*3.1*99*upgrade3.1'); +INSERT INTO `upgrades` VALUES (114, 'sql*3.1.1*0*3.1.1/parentless-documents.sql', 'Database upgrade to version 3.1.1: Parentless-documents', '2006-08-22 10:13:57', 1, 'upgrade*3.1.6*99*upgrade3.1.6'); +INSERT INTO `upgrades` VALUES (115, 'func*3.1.5*0*upgradeSavedSearches', 'Upgrade saved searches to use namespaces instead of integer ids', '2006-08-22 10:13:57', 1, 'upgrade*3.1.6*99*upgrade3.1.6'); +INSERT INTO `upgrades` VALUES (116, 'sql*3.1.6*0*3.1.6/interceptor_instances.sql', 'Database upgrade to version 3.1.6: Interceptor instances', '2006-08-22 10:13:57', 1, 'upgrade*3.1.6*99*upgrade3.1.6'); +INSERT INTO `upgrades` VALUES (117, 'upgrade*3.1.6*99*upgrade3.1.6', 'Upgrade from version 3.1 to 3.1.6', '2006-08-22 10:13:57', 1, 'upgrade*3.1.6*99*upgrade3.1.6'); -- -- Dumping data for table `user_history` @@ -1188,6 +1197,11 @@ INSERT INTO `zseq_help` VALUES (98); INSERT INTO `zseq_help_replacement` VALUES (1); -- +-- Dumping data for table `zseq_interceptor_instances` +-- + + +-- -- Dumping data for table `zseq_links` -- @@ -1335,7 +1349,7 @@ INSERT INTO `zseq_units_organisations_link` VALUES (1); -- Dumping data for table `zseq_upgrades` -- -INSERT INTO `zseq_upgrades` VALUES (113); +INSERT INTO `zseq_upgrades` VALUES (117); -- -- Dumping data for table `zseq_user_history` diff --git a/sql/mysql/install/structure.sql b/sql/mysql/install/structure.sql index f3f46a3..c6a9e11 100644 --- a/sql/mysql/install/structure.sql +++ b/sql/mysql/install/structure.sql @@ -3,7 +3,7 @@ -- http://www.phpmyadmin.net -- -- Host: localhost --- Generation Time: Jul 31, 2006 at 10:42 AM +-- Generation Time: Aug 22, 2006 at 10:18 AM -- Server version: 5.0.22 -- PHP Version: 4.4.2-1build1 @@ -483,7 +483,7 @@ CREATE TABLE `documents` ( `id` int(11) NOT NULL default '0', `creator_id` int(11) NOT NULL default '0', `modified` datetime NOT NULL default '0000-00-00 00:00:00', - `folder_id` int(11) default '0', + `folder_id` int(11) default NULL, `is_checked_out` tinyint(1) NOT NULL default '0', `parent_folder_ids` mediumtext, `full_path` mediumtext, @@ -785,6 +785,21 @@ CREATE TABLE `help_replacement` ( -- -------------------------------------------------------- -- +-- Table structure for table `interceptor_instances` +-- + +CREATE TABLE `interceptor_instances` ( + `id` int(11) NOT NULL, + `name` varchar(255) NOT NULL, + `interceptor_namespace` varchar(255) NOT NULL, + `config` text, + PRIMARY KEY (`id`), + KEY `interceptor_namespace` (`interceptor_namespace`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- -------------------------------------------------------- + +-- -- Table structure for table `links` -- @@ -1924,6 +1939,17 @@ CREATE TABLE `zseq_help_replacement` ( -- -------------------------------------------------------- -- +-- Table structure for table `zseq_interceptor_instances` +-- + +CREATE TABLE `zseq_interceptor_instances` ( + `id` int(10) unsigned NOT NULL auto_increment, + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; + +-- -------------------------------------------------------- + +-- -- Table structure for table `zseq_links` -- @@ -2194,7 +2220,7 @@ CREATE TABLE `zseq_units_organisations_link` ( CREATE TABLE `zseq_upgrades` ( `id` int(10) unsigned NOT NULL auto_increment, PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=114 ; +) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=118 ; -- --------------------------------------------------------