Commit 767df718ecc6cdbee6838867a06fc8762277f384

Authored by conradverm
1 parent 937569ea

KTS-1687

"Double quote to single quote conversion"
Fixed.

KTS-1616
"Changing permissions error appears: Call to undefined function: getname()"
Fixed. Problem mainly due to db referential integrity issues.

Reviewed by: Jalalodien Abrahams

git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@6270 c91229c3-7414-0410-bfa2-8a42b809f60b
plugins/ktcore/folder/Permissions.php
... ... @@ -6,15 +6,15 @@ require_once(KT_LIB_DIR . '/permissions/permission.inc.php');
6 6 require_once(KT_LIB_DIR . '/permissions/permissionutil.inc.php');
7 7 require_once(KT_LIB_DIR . '/browse/browseutil.inc.php');
8 8  
9   -require_once(KT_LIB_DIR . "/foldermanagement/folderutil.inc.php");
  9 +require_once(KT_LIB_DIR . '/foldermanagement/folderutil.inc.php');
10 10  
11 11 require_once(KT_LIB_DIR . '/roles/Role.inc');
12 12  
13 13 class KTFolderPermissionsAction extends KTFolderAction {
14 14 var $sName = 'ktcore.actions.folder.permissions';
15 15  
16   - var $_sEditShowPermission = "ktcore.permissions.security";
17   - var $_sShowPermission = "ktcore.permissions.security";
  16 + var $_sEditShowPermission = 'ktcore.permissions.security';
  17 + var $_sShowPermission = 'ktcore.permissions.security';
18 18 var $_bAdminAlwaysAvailable = true;
19 19 var $bAutomaticTransaction = true;
20 20  
... ... @@ -23,8 +23,8 @@ class KTFolderPermissionsAction extends KTFolderAction {
23 23 }
24 24  
25 25 function do_main() {
26   - $this->oPage->setBreadcrumbDetails(_kt("Permissions"));
27   - $oTemplate = $this->oValidator->validateTemplate("ktcore/folder/view_permissions");
  26 + $this->oPage->setBreadcrumbDetails(_kt('Permissions'));
  27 + $oTemplate = $this->oValidator->validateTemplate('ktcore/folder/view_permissions');
28 28  
29 29 $oPO = KTPermissionObject::get($this->oFolder->getPermissionObjectID());
30 30 $aPermissions = KTPermission::getList();
... ... @@ -75,18 +75,21 @@ class KTFolderPermissionsAction extends KTFolderAction {
75 75 // this should be quite limited - direct role -> user assignment is typically rare.
76 76 foreach ($aActiveUsers as $id => $marker) {
77 77 $oUser = User::get($id);
  78 + if (is_null($oUser)) continue; // this is just a patch in case there is a db integrity issue.
78 79 $users[$oUser->getName()] = $oUser;
79 80 }
80 81 asort($users); // ascending, per convention.
81 82  
82 83 foreach ($aActiveGroups as $id => $marker) {
83 84 $oGroup = Group::get($id);
  85 + if (is_null($oGroup)) continue; // this is just a patch in case there is a db integrity issue.
84 86 $groups[$oGroup->getName()] = $oGroup;
85 87 }
86 88 asort($groups);
87 89  
88 90 foreach ($aActiveRoles as $id => $marker) {
89 91 $oRole = Role::get($id);
  92 + if (is_null($oRole)) continue; // this is just a patch in case there is a db integrity issue.
90 93 $roles[$oRole->getName()] = $oRole;
91 94 }
92 95 asort($roles);
... ... @@ -102,7 +105,7 @@ class KTFolderPermissionsAction extends KTFolderAction {
102 105 // from a folder.
103 106 if ($oInherited->getId() !== $this->oFolder->getId()) {
104 107 $iInheritedFolderId = $oInherited->getId();
105   - $sInherited = join(" » ", $oInherited->getPathArray());
  108 + $sInherited = join(' » ', $oInherited->getPathArray());
106 109 }
107 110 // only allow inheritance if not inherited, -and- folders is editable
108 111 $bInheritable = $bEdit && ($oInherited->getId() !== $this->oFolder->getId());
... ... @@ -114,9 +117,11 @@ class KTFolderPermissionsAction extends KTFolderAction {
114 117  
115 118 foreach ($aDynConditions as $oDynCondition) {
116 119 $g = Group::get($oDynCondition->getGroupId());
117   -
  120 + if (is_null($g)) continue; // db integrity catch
  121 +
118 122 if (PEAR::isError($g)) { continue; }
119   - $c = KTSavedSearch::get($oDynCondition->getConditionId());
  123 + $c = KTSavedSearch::get($oDynCondition->getConditionId());
  124 + if (is_null($c)) continue; // db integrity catch
120 125 if (PEAR::isError($c)) { continue; }
121 126  
122 127 $aInfo = array(
... ... @@ -133,18 +138,18 @@ class KTFolderPermissionsAction extends KTFolderAction {
133 138 }
134 139  
135 140 $aTemplateData = array(
136   - "context" => $this,
137   - "permissions" => $aPermissions,
138   - "groups" => $groups,
139   - "users" => $users,
140   - "roles" => $roles,
141   - "oFolder" => $this->oFolder,
142   - "aMapPermissionGroup" => $aMapPermissionGroup,
143   - "aMapPermissionRole" => $aMapPermissionRole,
144   - "aMapPermissionUser" => $aMapPermissionUser,
145   - "edit" => $bEdit,
  141 + 'context' => $this,
  142 + 'permissions' => $aPermissions,
  143 + 'groups' => $groups,
  144 + 'users' => $users,
  145 + 'roles' => $roles,
  146 + 'oFolder' => $this->oFolder,
  147 + 'aMapPermissionGroup' => $aMapPermissionGroup,
  148 + 'aMapPermissionRole' => $aMapPermissionRole,
  149 + 'aMapPermissionUser' => $aMapPermissionUser,
  150 + 'edit' => $bEdit,
146 151 'inheritable' => $bInheritable,
147   - "inherited" => $sInherited,
  152 + 'inherited' => $sInherited,
148 153 'foldername' => $this->oFolder->getName(),
149 154 'conditions' => $aConditions,
150 155 );
... ... @@ -152,8 +157,8 @@ class KTFolderPermissionsAction extends KTFolderAction {
152 157 }
153 158  
154 159 function do_resolved_users() {
155   - $this->oPage->setBreadcrumbDetails(_kt("Permissions"));
156   - $oTemplate = $this->oValidator->validateTemplate("ktcore/folder/resolved_permissions_user");
  160 + $this->oPage->setBreadcrumbDetails(_kt('Permissions'));
  161 + $oTemplate = $this->oValidator->validateTemplate('ktcore/folder/resolved_permissions_user');
157 162  
158 163 $oPL = KTPermissionLookup::get($this->oFolder->getPermissionLookupID());
159 164 $aPermissions = KTPermission::getList();
... ... @@ -187,6 +192,7 @@ class KTFolderPermissionsAction extends KTFolderAction {
187 192 // this should be quite limited - direct role -> user assignment is typically rare.
188 193 foreach ($aActiveUsers as $id => $marker) {
189 194 $oUser = User::get($id);
  195 + if (is_null($oUser)) continue;
190 196 $users[$oUser->getName()] = $oUser;
191 197 }
192 198 asort($users); // ascending, per convention.
... ... @@ -195,19 +201,19 @@ class KTFolderPermissionsAction extends KTFolderAction {
195 201 $sInherited = '';
196 202  
197 203 $aTemplateData = array(
198   - "context" => $this,
199   - "permissions" => $aPermissions,
200   - "groups" => $groups,
201   - "users" => $users,
202   - "roles" => $roles,
203   - "oFolder" => $this->oFolder,
204   - "aMapPermissionGroup" => $aMapPermissionGroup,
205   - "aMapPermissionRole" => $aMapPermissionRole,
206   - "aMapPermissionUser" => $aMapPermissionUser,
207   - "edit" => $bEdit,
208   - "inherited" => $sInherited,
  204 + 'context' => $this,
  205 + 'permissions' => $aPermissions,
  206 + 'groups' => $groups,
  207 + 'users' => $users,
  208 + 'roles' => $roles,
  209 + 'oFolder' => $this->oFolder,
  210 + 'aMapPermissionGroup' => $aMapPermissionGroup,
  211 + 'aMapPermissionRole' => $aMapPermissionRole,
  212 + 'aMapPermissionUser' => $aMapPermissionUser,
  213 + 'edit' => $bEdit,
  214 + 'inherited' => $sInherited,
209 215 'foldername' => $this->oFolder->getName(),
210   - "iFolderId" => $this->oFolder->getId(),
  216 + 'iFolderId' => $this->oFolder->getId(),
211 217 );
212 218 return $oTemplate->render($aTemplateData);
213 219 }
... ... @@ -226,7 +232,7 @@ class KTFolderPermissionsAction extends KTFolderAction {
226 232 function _copyPermissions() {
227 233 $oTransaction = KTFolderTransaction::createFromArray(array(
228 234 'folderid' => $this->oFolder->getId(),
229   - 'comment' => "Override permissions from parent",
  235 + 'comment' => 'Override permissions from parent',
230 236 'transactionNS' => 'ktcore.transactions.permissions_change',
231 237 'userid' => $_SESSION['userID'],
232 238 'ip' => Session::getClientIP(),
... ... @@ -242,7 +248,7 @@ class KTFolderPermissionsAction extends KTFolderAction {
242 248  
243 249  
244 250 function do_edit() {
245   - $this->oPage->setBreadcrumbDetails(_kt("Viewing Permissions"));
  251 + $this->oPage->setBreadcrumbDetails(_kt('Viewing Permissions'));
246 252  
247 253  
248 254 $oPO = KTPermissionObject::get($this->oFolder->getPermissionObjectId());
... ... @@ -257,7 +263,7 @@ class KTFolderPermissionsAction extends KTFolderAction {
257 263 if ($oInherited->getId() !== $this->oFolder->getId()) {
258 264 $override = KTUtil::arrayGet($_REQUEST, 'override', false);
259 265 if (empty($override)) {
260   - $this->errorRedirectToMain(_kt("This folder does not override its permissions"), sprintf("fFolderId=%d", $this->oFolder->getId()));
  266 + $this->errorRedirectToMain(_kt('This folder does not override its permissions'), sprintf('fFolderId=%d', $this->oFolder->getId()));
261 267 }
262 268 $this->startTransaction();
263 269 $this->_copyPermissions();
... ... @@ -280,7 +286,7 @@ class KTFolderPermissionsAction extends KTFolderAction {
280 286  
281 287 // templating
282 288 $oTemplating =& KTTemplating::getSingleton();
283   - $oTemplate = $oTemplating->loadTemplate("ktcore/folder/permissions");
  289 + $oTemplate = $oTemplating->loadTemplate('ktcore/folder/permissions');
284 290  
285 291 $bCanInherit = ($this->oFolder->getId() != 1);
286 292  
... ... @@ -288,11 +294,11 @@ class KTFolderPermissionsAction extends KTFolderAction {
288 294 $docperms = KTPermission::getDocumentRelevantList();
289 295  
290 296 $aTemplateData = array(
291   - "iFolderId" => $this->oFolder->getId(),
  297 + 'iFolderId' => $this->oFolder->getId(),
292 298 'roles' => Role::getList(),
293 299 'groups' => Group::getList(),
294   - "conditions" => KTSavedSearch::getConditions(),
295   - "dynamic_conditions" => $aDynamicConditions,
  300 + 'conditions' => KTSavedSearch::getConditions(),
  301 + 'dynamic_conditions' => $aDynamicConditions,
296 302 'context' => &$this,
297 303 'foldername' => $this->oFolder->getName(),
298 304 'jsonpermissions' => $sJSONPermissions,
... ... @@ -309,7 +315,7 @@ class KTFolderPermissionsAction extends KTFolderAction {
309 315 return array('error' => true,
310 316 'type' => 'kt.permission_denied',
311 317 'alert' => true,
312   - 'message' => _kt("You do not have permission to alter security settings."));
  318 + 'message' => _kt('You do not have permission to alter security settings.'));
313 319 }
314 320  
315 321 function &_getPermissionsMap() {
... ... @@ -368,7 +374,7 @@ class KTFolderPermissionsAction extends KTFolderAction {
368 374 $aEntityList = array();
369 375 }
370 376  
371   - $aGroups = Group::getList(sprintf('name like "%%%s%%"', $sFilter));
  377 + $aGroups = Group::getList(sprintf('name like \'%%%s%%\'', $sFilter));
372 378 foreach($aGroups as $oGroup) {
373 379 $aPerm = @array_keys($aPermissionsMap['group'][$oGroup->getId()]);
374 380 if(!is_array($aPerm)) {
... ... @@ -391,7 +397,7 @@ class KTFolderPermissionsAction extends KTFolderAction {
391 397 }
392 398 }
393 399  
394   - $aRoles = Role::getList(sprintf('name like "%%%s%%"', $sFilter));
  400 + $aRoles = Role::getList(sprintf('name like \'%%%s%%\'', $sFilter));
395 401 foreach($aRoles as $oRole) {
396 402 $aPerm = @array_keys($aPermissionsMap['role'][$oRole->getId()]);
397 403 if(!is_array($aPerm)) {
... ... @@ -425,7 +431,7 @@ class KTFolderPermissionsAction extends KTFolderAction {
425 431 if (!KTBrowseUtil::inAdminMode($this->oUser, $this->oFolder)) {
426 432 $this->oValidator->userHasPermissionOnItem($this->oUser, $this->_sEditShowPermission, $this->oFolder, $aOptions);
427 433 }
428   - require_once(KT_LIB_DIR . "/documentmanagement/observers.inc.php");
  434 + require_once(KT_LIB_DIR . '/documentmanagement/observers.inc.php');
429 435 $oPO = KTPermissionObject::get($this->oFolder->getPermissionObjectId());
430 436 $aFoo = $_REQUEST['foo'];
431 437  
... ... @@ -439,7 +445,7 @@ class KTFolderPermissionsAction extends KTFolderAction {
439 445  
440 446 $oTransaction = KTFolderTransaction::createFromArray(array(
441 447 'folderid' => $this->oFolder->getId(),
442   - 'comment' => "Updated permissions",
  448 + 'comment' => 'Updated permissions',
443 449 'transactionNS' => 'ktcore.transactions.permissions_change',
444 450 'userid' => $_SESSION['userID'],
445 451 'ip' => Session::getClientIP(),
... ... @@ -459,8 +465,8 @@ class KTFolderPermissionsAction extends KTFolderAction {
459 465  
460 466 $this->commitTransaction();
461 467  
462   - $this->addInfoMessage(_kt("Permissions on folder updated"));
463   - $po->redirect(KTUtil::addQueryString($_SERVER['PHP_SELF'], "action=edit&fFolderId=" . $this->oFolder->getId()));
  468 + $this->addInfoMessage(_kt('Permissions on folder updated'));
  469 + $po->redirect(KTUtil::addQueryString($_SERVER['PHP_SELF'], 'action=edit&fFolderId=' . $this->oFolder->getId()));
464 470 exit(0);
465 471 }
466 472  
... ... @@ -472,7 +478,7 @@ class KTFolderPermissionsAction extends KTFolderAction {
472 478 }
473 479 $oTransaction = KTFolderTransaction::createFromArray(array(
474 480 'folderid' => $this->oFolder->getId(),
475   - 'comment' => "Inherit permissions from parent",
  481 + 'comment' => 'Inherit permissions from parent',
476 482 'transactionNS' => 'ktcore.transactions.permissions_change',
477 483 'userid' => $_SESSION['userID'],
478 484 'ip' => Session::getClientIP(),
... ... @@ -504,7 +510,7 @@ class KTFolderPermissionsAction extends KTFolderAction {
504 510  
505 511 $oTransaction = KTFolderTransaction::createFromArray(array(
506 512 'folderid' => $this->oFolder->getId(),
507   - 'comment' => "Added dynamic permissions",
  513 + 'comment' => 'Added dynamic permissions',
508 514 'transactionNS' => 'ktcore.transactions.permissions_change',
509 515 'userid' => $_SESSION['userID'],
510 516 'ip' => Session::getClientIP(),
... ... @@ -524,7 +530,7 @@ class KTFolderPermissionsAction extends KTFolderAction {
524 530 $res = $oDynamicCondition->saveAssignment($aPermissionIds);
525 531 $this->oValidator->notError($res, $aOptions);
526 532 KTPermissionUtil::updatePermissionLookupForPO($oPO);
527   - $this->successRedirectTo('edit', _kt("Dynamic permission added"), "fFolderId=" . $this->oFolder->getId());
  533 + $this->successRedirectTo('edit', _kt('Dynamic permission added'), 'fFolderId=' . $this->oFolder->getId());
528 534 }
529 535  
530 536 function do_removeDynamicCondition() {
... ... @@ -541,7 +547,7 @@ class KTFolderPermissionsAction extends KTFolderAction {
541 547  
542 548 $oTransaction = KTFolderTransaction::createFromArray(array(
543 549 'folderid' => $this->oFolder->getId(),
544   - 'comment' => "Removed dynamic permissions",
  550 + 'comment' => 'Removed dynamic permissions',
545 551 'transactionNS' => 'ktcore.transactions.permissions_change',
546 552 'userid' => $_SESSION['userID'],
547 553 'ip' => Session::getClientIP(),
... ... @@ -554,7 +560,7 @@ class KTFolderPermissionsAction extends KTFolderAction {
554 560  
555 561 $oPO = KTPermissionObject::get($this->oFolder->getPermissionObjectId());
556 562 KTPermissionUtil::updatePermissionLookupForPO($oPO);
557   - $this->successRedirectTo('edit', _kt("Dynamic permission removed"), "fFolderId=" . $this->oFolder->getId());
  563 + $this->successRedirectTo('edit', _kt('Dynamic permission removed'), 'fFolderId=' . $this->oFolder->getId());
558 564 }
559 565 }
560 566  
... ...