Commit bf421a57f23899a7d2f4e14a3b0604233757e82b
1 parent
84f60ac0
KTC-248
"Disable commercial plugins on license expiry and display dashlet" Fixed. Changed delete user to deallocate the license. Changed isBaobabUser to isValid user on creating a session, so as not to lock the user out. Committed by: Megan Watson Reviewed by: Conrad Vermeulen git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7409 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
44 additions
and
42 deletions
lib/session/Session.inc
| ... | ... | @@ -45,10 +45,12 @@ class Session { |
| 45 | 45 | |
| 46 | 46 | session_start(); |
| 47 | 47 | |
| 48 | + | |
| 49 | + // Don't need to lock a user out the web interface if KT Tools exists and has no license. | |
| 48 | 50 | if (KTPluginUtil::pluginIsActive('ktdms.wintools')) { |
| 49 | 51 | if (!$oUser->isAnonymous()) { |
| 50 | 52 | require_once(KT_DIR . '/plugins/wintools/baobabkeyutil.inc.php'); |
| 51 | - $res = BaobabKeyUtil::isBaobabUser($oUser); | |
| 53 | + $res = BaobabKeyUtil::isValidUser($oUser); | |
| 52 | 54 | if (PEAR::isError($res)) { |
| 53 | 55 | return $res; |
| 54 | 56 | } | ... | ... |
lib/users/User.inc
| ... | ... | @@ -8,7 +8,7 @@ |
| 8 | 8 | * License Version 1.1.2 ("License"); You may not use this file except in |
| 9 | 9 | * compliance with the License. You may obtain a copy of the License at |
| 10 | 10 | * http://www.knowledgetree.com/KPL |
| 11 | - * | |
| 11 | + * | |
| 12 | 12 | * Software distributed under the License is distributed on an "AS IS" |
| 13 | 13 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. |
| 14 | 14 | * See the License for the specific language governing rights and |
| ... | ... | @@ -19,9 +19,9 @@ |
| 19 | 19 | * (ii) the KnowledgeTree copyright notice |
| 20 | 20 | * in the same form as they appear in the distribution. See the License for |
| 21 | 21 | * requirements. |
| 22 | - * | |
| 22 | + * | |
| 23 | 23 | * The Original Code is: KnowledgeTree Open Source |
| 24 | - * | |
| 24 | + * | |
| 25 | 25 | * The Initial Developer of the Original Code is The Jam Warehouse Software |
| 26 | 26 | * (Pty) Ltd, trading as KnowledgeTree. |
| 27 | 27 | * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright |
| ... | ... | @@ -29,13 +29,13 @@ |
| 29 | 29 | * All Rights Reserved. |
| 30 | 30 | * Contributor( s): ______________________________________ |
| 31 | 31 | */ |
| 32 | - | |
| 33 | -require_once(KT_LIB_DIR . '/database/dbutil.inc'); | |
| 34 | -require_once(KT_LIB_DIR . '/ktentity.inc'); | |
| 32 | + | |
| 33 | +require_once(KT_LIB_DIR . '/database/dbutil.inc'); | |
| 34 | +require_once(KT_LIB_DIR . '/ktentity.inc'); | |
| 35 | 35 | require_once(KT_LIB_DIR . "/util/sanitize.inc"); |
| 36 | 36 | |
| 37 | 37 | define('ADMIN_USER_ID', 1); |
| 38 | - | |
| 38 | + | |
| 39 | 39 | class User extends KTEntity { |
| 40 | 40 | /** user's login name */ |
| 41 | 41 | var $sUserName; |
| ... | ... | @@ -106,14 +106,14 @@ class User extends KTEntity { |
| 106 | 106 | function _table() { |
| 107 | 107 | return KTUtil::getTableName("users"); |
| 108 | 108 | } |
| 109 | - | |
| 109 | + | |
| 110 | 110 | // STATIC |
| 111 | 111 | function _ktentityOptions() { |
| 112 | 112 | return array( |
| 113 | 113 | 'orderby' => 'name', |
| 114 | 114 | ); |
| 115 | 115 | } |
| 116 | - | |
| 116 | + | |
| 117 | 117 | |
| 118 | 118 | function getUserName() { return sanitizeForSQLtoHTML($this->sUserName); } |
| 119 | 119 | function setUserName($sNewValue) { $this->sUserName = sanitizeForSQL($sNewValue); } |
| ... | ... | @@ -169,11 +169,11 @@ class User extends KTEntity { |
| 169 | 169 | return 'dashboard-state-' . $this->getId(); |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - function getDashboardState() { | |
| 172 | + function getDashboardState() { | |
| 173 | 173 | return KTUtil::getSystemSetting($this->_getDashboardStateKey()); |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - function setDashboardState($mValue) { | |
| 176 | + function setDashboardState($mValue) { | |
| 177 | 177 | KTUtil::setSystemSetting($this->_getDashboardStateKey(), $mValue); |
| 178 | 178 | } |
| 179 | 179 | |
| ... | ... | @@ -182,9 +182,9 @@ class User extends KTEntity { |
| 182 | 182 | require_once(KT_DIR . "/thirdparty/pear/JSON.php"); |
| 183 | 183 | |
| 184 | 184 | $dashletRegistry = & KTDashletRegistry::getSingleton(); |
| 185 | - | |
| 185 | + | |
| 186 | 186 | $aDashlets = $dashletRegistry->getDashlets($this); |
| 187 | - | |
| 187 | + | |
| 188 | 188 | $oJSON = new Services_JSON(); |
| 189 | 189 | |
| 190 | 190 | $state = $this->getDashboardState(); |
| ... | ... | @@ -193,18 +193,18 @@ class User extends KTEntity { |
| 193 | 193 | if (!isset($dashlets->left)) $dashlets->left = array(); |
| 194 | 194 | if (!isset($dashlets->right)) $dashlets->right = array(); |
| 195 | 195 | $mergedlist = kt_array_merge($dashlets->left,$dashlets->right); |
| 196 | - | |
| 197 | - | |
| 196 | + | |
| 197 | + | |
| 198 | 198 | $knownlist = array(); |
| 199 | 199 | foreach($mergedlist as $dashlet) |
| 200 | 200 | { |
| 201 | 201 | array_push($knownlist,$dashlet->id); |
| 202 | 202 | } |
| 203 | 203 | $update=false; |
| 204 | - | |
| 204 | + | |
| 205 | 205 | //if (!isset($dashlets->left)) $dashlets->left=array(); |
| 206 | 206 | //if (!isset($dashlets->right)) $dashlets->right=array(); |
| 207 | - | |
| 207 | + | |
| 208 | 208 | $column=1; |
| 209 | 209 | foreach($aDashlets as $dashlet) |
| 210 | 210 | { |
| ... | ... | @@ -215,7 +215,7 @@ class User extends KTEntity { |
| 215 | 215 | $obj = new stdClass(); |
| 216 | 216 | $obj->id=$class; |
| 217 | 217 | $obj->state=0; |
| 218 | - | |
| 218 | + | |
| 219 | 219 | if ($column == 0) |
| 220 | 220 | array_push($dashlets->left,$obj); |
| 221 | 221 | else |
| ... | ... | @@ -223,19 +223,19 @@ class User extends KTEntity { |
| 223 | 223 | $update=true; |
| 224 | 224 | } |
| 225 | 225 | } |
| 226 | - | |
| 226 | + | |
| 227 | 227 | if ($update) |
| 228 | 228 | { |
| 229 | 229 | $state = $oJSON->encode($dashlets); |
| 230 | 230 | $this->setDashboardState($state); |
| 231 | 231 | } |
| 232 | 232 | } |
| 233 | - | |
| 234 | - | |
| 233 | + | |
| 234 | + | |
| 235 | 235 | function &get($iId) { |
| 236 | 236 | return KTEntityUtil::get('User', $iId); |
| 237 | 237 | } |
| 238 | - | |
| 238 | + | |
| 239 | 239 | /** |
| 240 | 240 | * update the datastore, without overwriting the password. |
| 241 | 241 | * |
| ... | ... | @@ -244,25 +244,25 @@ class User extends KTEntity { |
| 244 | 244 | function doLimitedUpdate() { |
| 245 | 245 | $sQuery = 'UPDATE ' . $this->_table() . ' SET '; |
| 246 | 246 | $aParams = array(); |
| 247 | - | |
| 247 | + | |
| 248 | 248 | $blacklist = array( |
| 249 | 249 | "sPassword" => 1, |
| 250 | 250 | ); |
| 251 | - | |
| 251 | + | |
| 252 | 252 | $aParts = array(); // quick workaround to make the join less hurtful. |
| 253 | - | |
| 253 | + | |
| 254 | 254 | foreach ($this->_aFieldToSelect as $attr => $column) { |
| 255 | 255 | if (!array_key_exists($attr, $blacklist)) { |
| 256 | 256 | $val = $this->$attr; |
| 257 | 257 | $aParts[] = $column . ' = ?'; |
| 258 | - $aParams[] = $val; | |
| 259 | - } | |
| 258 | + $aParams[] = $val; | |
| 259 | + } | |
| 260 | 260 | } |
| 261 | 261 | $sQuery .= join(', ', $aParts); |
| 262 | - | |
| 262 | + | |
| 263 | 263 | $sQuery .= ' WHERE id = ? '; |
| 264 | 264 | $aParams[] = $this->getId(); |
| 265 | - | |
| 265 | + | |
| 266 | 266 | $res = DBUtil::runQuery(array($sQuery, $aParams)); |
| 267 | 267 | |
| 268 | 268 | $group = sprintf("%s/%s", get_class($this), 'id'); |
| ... | ... | @@ -272,8 +272,8 @@ class User extends KTEntity { |
| 272 | 272 | |
| 273 | 273 | return $res; |
| 274 | 274 | } |
| 275 | - | |
| 276 | - | |
| 275 | + | |
| 276 | + | |
| 277 | 277 | /** |
| 278 | 278 | * Static function |
| 279 | 279 | * Get a list of users |
| ... | ... | @@ -329,7 +329,7 @@ class User extends KTEntity { |
| 329 | 329 | |
| 330 | 330 | $this->iId = $id; |
| 331 | 331 | } |
| 332 | - | |
| 332 | + | |
| 333 | 333 | /** Static function |
| 334 | 334 | * Gets the user's default top level folder for the current user |
| 335 | 335 | */ |
| ... | ... | @@ -343,7 +343,7 @@ class User extends KTEntity { |
| 343 | 343 | $oUnit =& Unit::get($iUnitId); |
| 344 | 344 | return $oUnit->getFolderId(); |
| 345 | 345 | } |
| 346 | - | |
| 346 | + | |
| 347 | 347 | function &createFromArray($aOptions) { return KTEntityUtil::createFromArray('User', $aOptions); } |
| 348 | 348 | function &getByUserName($sUserName, $aOptions = null) { |
| 349 | 349 | return KTEntityUtil::getBy('User', 'username', $sUserName, $aOptions); |
| ... | ... | @@ -385,7 +385,7 @@ class User extends KTEntity { |
| 385 | 385 | $aParams = array(false); |
| 386 | 386 | return DBUtil::getOneResultKey(array($sQuery, $aParams), 'number'); |
| 387 | 387 | } |
| 388 | - | |
| 388 | + | |
| 389 | 389 | function isAnonymous() { return $this->iId == -2; } |
| 390 | 390 | |
| 391 | 391 | function disable() { |
| ... | ... | @@ -397,7 +397,7 @@ class User extends KTEntity { |
| 397 | 397 | } |
| 398 | 398 | return; |
| 399 | 399 | } |
| 400 | - | |
| 400 | + | |
| 401 | 401 | function enable() { |
| 402 | 402 | $this->setDisabled(0); |
| 403 | 403 | $this->update(); |
| ... | ... | @@ -406,7 +406,7 @@ class User extends KTEntity { |
| 406 | 406 | BaobabKeyUtil::allocateUser($this); |
| 407 | 407 | } |
| 408 | 408 | return; |
| 409 | - } | |
| 409 | + } | |
| 410 | 410 | |
| 411 | 411 | function create() { |
| 412 | 412 | if (KTPluginUtil::pluginIsActive('ktdms.wintools')) { |
| ... | ... | @@ -418,7 +418,7 @@ class User extends KTEntity { |
| 418 | 418 | } |
| 419 | 419 | return parent::create(); |
| 420 | 420 | } |
| 421 | - | |
| 421 | + | |
| 422 | 422 | function delete() |
| 423 | 423 | { |
| 424 | 424 | $this->setDisabled(2); |
| ... | ... | @@ -429,7 +429,7 @@ class User extends KTEntity { |
| 429 | 429 | $tempUserID = $this->iId; |
| 430 | 430 | $DeletedUsername = 'kt_deleted_'.$tempUsername.'_'.$tempUserID; |
| 431 | 431 | $this->setUsername($DeletedUsername); |
| 432 | - | |
| 432 | + | |
| 433 | 433 | //nullify all authentication_xxx fields |
| 434 | 434 | $this->setAuthenticationSourceId(null); |
| 435 | 435 | $this->setAuthenticationDetails(null); |
| ... | ... | @@ -440,13 +440,13 @@ class User extends KTEntity { |
| 440 | 440 | $this->setAuthenticationDetailsDate2(null); |
| 441 | 441 | $this->setAuthenticationDetailsBool1(null); |
| 442 | 442 | $this->setAuthenticationDetailsBool2(null); |
| 443 | - | |
| 443 | + | |
| 444 | 444 | $this->update(); |
| 445 | 445 | if (KTPluginUtil::pluginIsActive('ktdms.wintools')) { |
| 446 | 446 | require_once(KT_DIR . '/plugins/wintools/baobabkeyutil.inc.php'); |
| 447 | - BaobabKeyUtil::allocateUser($this); | |
| 447 | + BaobabKeyUtil::deallocateUser($this); | |
| 448 | 448 | } |
| 449 | 449 | return; |
| 450 | - | |
| 450 | + | |
| 451 | 451 | } |
| 452 | 452 | } | ... | ... |