Commit ae1ccccd75a9a7b67d8bd3b75dc5f5338bd73a32

Authored by Megan Watson
1 parent bb22bafd

Added new folderItem functions. Fixed up the Role and Permission Allocation func…

…tionality and unit tests.

Committed by: Megan Watson
Reviewed by: Kevin Cyster



git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@9741 c91229c3-7414-0410-bfa2-8a42b809f60b
ktapi/KTAPIAcl.inc.php
@@ -56,6 +56,7 @@ abstract class KTAPI_Dynamic @@ -56,6 +56,7 @@ abstract class KTAPI_Dynamic
56 /** 56 /**
57 * Generic getter method 57 * Generic getter method
58 * 58 *
  59 + * @author KnowledgeTree Team
59 * @access protected 60 * @access protected
60 * @param string $property 61 * @param string $property
61 * @return mixed 62 * @return mixed
@@ -70,15 +71,16 @@ abstract class KTAPI_Dynamic @@ -70,15 +71,16 @@ abstract class KTAPI_Dynamic
70 } 71 }
71 throw new Exception('Unknown method ' . get_class($this) . '.' . $method); 72 throw new Exception('Unknown method ' . get_class($this) . '.' . $method);
72 } 73 }
73 - 74 +
74 /** 75 /**
75 * Generic setter method 76 * Generic setter method
76 - * 77 + *
  78 + * @author KnowledgeTree Team
77 * @access protected 79 * @access protected
78 * @param string $property 80 * @param string $property
79 * @param mixed $value 81 * @param mixed $value
80 */ 82 */
81 - 83 +
82 protected 84 protected
83 function __set($property, $value) 85 function __set($property, $value)
84 { 86 {
@@ -137,7 +139,9 @@ class KTAPI_User extends KTAPI_Member @@ -137,7 +139,9 @@ class KTAPI_User extends KTAPI_Member
137 /** 139 /**
138 * Using the id, the user can be resolved. 140 * Using the id, the user can be resolved.
139 * 141 *
140 - * @static 142 + * @author KnowledgeTree Team
  143 + * @access public
  144 + * @static
141 * @param int $id 145 * @param int $id
142 * @return KTAPI_User Returns null if there is no match. 146 * @return KTAPI_User Returns null if there is no match.
143 */ 147 */
@@ -158,6 +162,8 @@ class KTAPI_User extends KTAPI_Member @@ -158,6 +162,8 @@ class KTAPI_User extends KTAPI_Member
158 /** 162 /**
159 * Using the full name, the user can be resolved. 163 * Using the full name, the user can be resolved.
160 * 164 *
  165 + * @author KnowledgeTree Team
  166 + * @access public
161 * @static 167 * @static
162 * @param string $name 168 * @param string $name
163 * @return KTAPI_User Returns null if there is no match. 169 * @return KTAPI_User Returns null if there is no match.
@@ -179,6 +185,8 @@ class KTAPI_User extends KTAPI_Member @@ -179,6 +185,8 @@ class KTAPI_User extends KTAPI_Member
179 /** 185 /**
180 * Using the username, the user is resolved. 186 * Using the username, the user is resolved.
181 * 187 *
  188 + * @author KnowledgeTree Team
  189 + * @access public
182 * @static 190 * @static
183 * @param string $username 191 * @param string $username
184 * @return KTAPI_User Returns null if there is no match. 192 * @return KTAPI_User Returns null if there is no match.
@@ -199,6 +207,8 @@ class KTAPI_User extends KTAPI_Member @@ -199,6 +207,8 @@ class KTAPI_User extends KTAPI_Member
199 /** 207 /**
200 * Using the email, the user is resolved. 208 * Using the email, the user is resolved.
201 * 209 *
  210 + * @author KnowledgeTree Team
  211 + * @access public
202 * @static 212 * @static
203 * @param string $email 213 * @param string $email
204 * @return KTAPI_User Returns null if there is no match. 214 * @return KTAPI_User Returns null if there is no match.
@@ -220,6 +230,8 @@ class KTAPI_User extends KTAPI_Member @@ -220,6 +230,8 @@ class KTAPI_User extends KTAPI_Member
220 /** 230 /**
221 * Returns a list of users matching the filter criteria. 231 * Returns a list of users matching the filter criteria.
222 * 232 *
  233 + * @author KnowledgeTree Team
  234 + * @access public
223 * @static 235 * @static
224 * @param string $filter 236 * @param string $filter
225 * @param array $options 237 * @param array $options
@@ -245,15 +257,19 @@ class KTAPI_User extends KTAPI_Member @@ -245,15 +257,19 @@ class KTAPI_User extends KTAPI_Member
245 } 257 }
246 258
247 /** 259 /**
248 - * Return username property. (readonly) 260 + * Return id property. (readonly)
249 * 261 *
250 - * @return string 262 + * @author KnowledgeTree Team
  263 + * @access public
  264 + * @return integer
251 */ 265 */
252 public function getId() { return $this->user->getId(); } 266 public function getId() { return $this->user->getId(); }
253 267
254 /** 268 /**
255 * Return username property. (readonly) 269 * Return username property. (readonly)
256 * 270 *
  271 + * @author KnowledgeTree Team
  272 + * @access public
257 * @return string 273 * @return string
258 */ 274 */
259 public function getUsername() { return $this->user->getUserName(); } 275 public function getUsername() { return $this->user->getUserName(); }
@@ -261,6 +277,8 @@ class KTAPI_User extends KTAPI_Member @@ -261,6 +277,8 @@ class KTAPI_User extends KTAPI_Member
261 /** 277 /**
262 * Return display name property. (readonly) 278 * Return display name property. (readonly)
263 * 279 *
  280 + * @author KnowledgeTree Team
  281 + * @access public
264 * @return string 282 * @return string
265 */ 283 */
266 public function getName() { return $this->user->getName(); } 284 public function getName() { return $this->user->getName(); }
@@ -268,6 +286,8 @@ class KTAPI_User extends KTAPI_Member @@ -268,6 +286,8 @@ class KTAPI_User extends KTAPI_Member
268 /** 286 /**
269 * Return email property. (readonly) 287 * Return email property. (readonly)
270 * 288 *
  289 + * @author KnowledgeTree Team
  290 + * @access public
271 * @return string 291 * @return string
272 */ 292 */
273 public function getEmail() { return $this->user->getEmail(); } 293 public function getEmail() { return $this->user->getEmail(); }
@@ -294,6 +314,7 @@ class KTAPI_Group extends KTAPI_Member @@ -294,6 +314,7 @@ class KTAPI_Group extends KTAPI_Member
294 /** 314 /**
295 * Constructor for KTAPI_Group. This is private, and can only be constructed by the static getByXXX() functions. 315 * Constructor for KTAPI_Group. This is private, and can only be constructed by the static getByXXX() functions.
296 * 316 *
  317 + * @author KnowledgeTree Team
297 * @access private 318 * @access private
298 * @param Group $group 319 * @param Group $group
299 */ 320 */
@@ -306,6 +327,8 @@ class KTAPI_Group extends KTAPI_Member @@ -306,6 +327,8 @@ class KTAPI_Group extends KTAPI_Member
306 /** 327 /**
307 * Using the id, the group can be resolved. 328 * Using the id, the group can be resolved.
308 * 329 *
  330 + * @author KnowledgeTree Team
  331 + * @access public
309 * @static 332 * @static
310 * @param int $id 333 * @param int $id
311 * @return KTAPI_Group Returns null if there is no match. 334 * @return KTAPI_Group Returns null if there is no match.
@@ -327,6 +350,8 @@ class KTAPI_Group extends KTAPI_Member @@ -327,6 +350,8 @@ class KTAPI_Group extends KTAPI_Member
327 /** 350 /**
328 * Using the name, the group can be resolved. 351 * Using the name, the group can be resolved.
329 * 352 *
  353 + * @author KnowledgeTree Team
  354 + * @access public
330 * @static 355 * @static
331 * @param string $name 356 * @param string $name
332 * @return KTAPI_Group Returns null if there is no match. 357 * @return KTAPI_Group Returns null if there is no match.
@@ -347,6 +372,8 @@ class KTAPI_Group extends KTAPI_Member @@ -347,6 +372,8 @@ class KTAPI_Group extends KTAPI_Member
347 /** 372 /**
348 * Returns a list of groups matching the filter criteria. 373 * Returns a list of groups matching the filter criteria.
349 * 374 *
  375 + * @author KnowledgeTree Team
  376 + * @access public
350 * @static 377 * @static
351 * @param string $filter 378 * @param string $filter
352 * @param array $options 379 * @param array $options
@@ -374,6 +401,8 @@ class KTAPI_Group extends KTAPI_Member @@ -374,6 +401,8 @@ class KTAPI_Group extends KTAPI_Member
374 /** 401 /**
375 * Return username property. (readonly) 402 * Return username property. (readonly)
376 * 403 *
  404 + * @author KnowledgeTree Team
  405 + * @access public
377 * @return string 406 * @return string
378 */ 407 */
379 public function getId() { return $this->group->getId(); } 408 public function getId() { return $this->group->getId(); }
@@ -381,6 +410,8 @@ class KTAPI_Group extends KTAPI_Member @@ -381,6 +410,8 @@ class KTAPI_Group extends KTAPI_Member
381 /** 410 /**
382 * Return display name property. (readonly) 411 * Return display name property. (readonly)
383 * 412 *
  413 + * @author KnowledgeTree Team
  414 + * @access public
384 * @return string 415 * @return string
385 */ 416 */
386 public function getName() { return $this->group->getName(); } 417 public function getName() { return $this->group->getName(); }
@@ -388,6 +419,8 @@ class KTAPI_Group extends KTAPI_Member @@ -388,6 +419,8 @@ class KTAPI_Group extends KTAPI_Member
388 /** 419 /**
389 * Indicates if the group members are system administrators. (readonly) 420 * Indicates if the group members are system administrators. (readonly)
390 * 421 *
  422 + * @author KnowledgeTree Team
  423 + * @access public
391 * @return boolean 424 * @return boolean
392 */ 425 */
393 public function getIsSystemAdministrator() { return $this->group->getSysAdmin(); } 426 public function getIsSystemAdministrator() { return $this->group->getSysAdmin(); }
@@ -414,6 +447,7 @@ class KTAPI_Role extends KTAPI_Member @@ -414,6 +447,7 @@ class KTAPI_Role extends KTAPI_Member
414 /** 447 /**
415 * Constructor for KTAPI_Group. This is private, and can only be constructed by the static getByXXX() functions. 448 * Constructor for KTAPI_Group. This is private, and can only be constructed by the static getByXXX() functions.
416 * 449 *
  450 + * @author KnowledgeTree Team
417 * @access private 451 * @access private
418 * @param Role $role 452 * @param Role $role
419 */ 453 */
@@ -426,6 +460,8 @@ class KTAPI_Role extends KTAPI_Member @@ -426,6 +460,8 @@ class KTAPI_Role extends KTAPI_Member
426 /** 460 /**
427 * Using the id, the role can be resolved. 461 * Using the id, the role can be resolved.
428 * 462 *
  463 + * @author KnowledgeTree Team
  464 + * @access public
429 * @static 465 * @static
430 * @param int $id 466 * @param int $id
431 * @return KTAPI_Role Returns null if there is no match. 467 * @return KTAPI_Role Returns null if there is no match.
@@ -445,6 +481,8 @@ class KTAPI_Role extends KTAPI_Member @@ -445,6 +481,8 @@ class KTAPI_Role extends KTAPI_Member
445 /** 481 /**
446 * Using the name, the role can be resolved. 482 * Using the name, the role can be resolved.
447 * 483 *
  484 + * @author KnowledgeTree Team
  485 + * @access public
448 * @static 486 * @static
449 * @param string $name 487 * @param string $name
450 * @return KTAPI_Role Returns null if there is no match. 488 * @return KTAPI_Role Returns null if there is no match.
@@ -467,6 +505,8 @@ class KTAPI_Role extends KTAPI_Member @@ -467,6 +505,8 @@ class KTAPI_Role extends KTAPI_Member
467 /** 505 /**
468 * Returns a list of roles matching the filter criteria. 506 * Returns a list of roles matching the filter criteria.
469 * 507 *
  508 + * @author KnowledgeTree Team
  509 + * @access public
470 * @static 510 * @static
471 * @param string $filter 511 * @param string $filter
472 * @param array $options 512 * @param array $options
@@ -494,6 +534,8 @@ class KTAPI_Role extends KTAPI_Member @@ -494,6 +534,8 @@ class KTAPI_Role extends KTAPI_Member
494 /** 534 /**
495 * Return id property. (readonly) 535 * Return id property. (readonly)
496 * 536 *
  537 + * @author KnowledgeTree Team
  538 + * @access public
497 * @return string 539 * @return string
498 */ 540 */
499 public function getId() { return $this->role->getId(); } 541 public function getId() { return $this->role->getId(); }
@@ -501,6 +543,8 @@ class KTAPI_Role extends KTAPI_Member @@ -501,6 +543,8 @@ class KTAPI_Role extends KTAPI_Member
501 /** 543 /**
502 * Return display name property. (readonly) 544 * Return display name property. (readonly)
503 * 545 *
  546 + * @author KnowledgeTree Team
  547 + * @access public
504 * @return string 548 * @return string
505 */ 549 */
506 public function getName() { return $this->role->getName(); } 550 public function getName() { return $this->role->getName(); }
@@ -529,6 +573,7 @@ class KTAPI_Permission extends KTAPI_Dynamic @@ -529,6 +573,7 @@ class KTAPI_Permission extends KTAPI_Dynamic
529 /** 573 /**
530 * Constructor for KTAPI_Permission. This is private, and can only be constructed by the static getByXXX() functions. 574 * Constructor for KTAPI_Permission. This is private, and can only be constructed by the static getByXXX() functions.
531 * 575 *
  576 + * @author KnowledgeTree Team
532 * @access private 577 * @access private
533 * @param KTPermission $permission 578 * @param KTPermission $permission
534 */ 579 */
@@ -541,6 +586,8 @@ class KTAPI_Permission extends KTAPI_Dynamic @@ -541,6 +586,8 @@ class KTAPI_Permission extends KTAPI_Dynamic
541 /** 586 /**
542 * Return a list of permissions. 587 * Return a list of permissions.
543 * 588 *
  589 + * @author KnowledgeTree Team
  590 + * @access public
544 * @static 591 * @static
545 * @param string $filter 592 * @param string $filter
546 * @param array $options 593 * @param array $options
@@ -567,6 +614,8 @@ class KTAPI_Permission extends KTAPI_Dynamic @@ -567,6 +614,8 @@ class KTAPI_Permission extends KTAPI_Dynamic
567 /** 614 /**
568 * Returns a KTAPI_Permission based on id. 615 * Returns a KTAPI_Permission based on id.
569 * 616 *
  617 + * @author KnowledgeTree Team
  618 + * @access public
570 * @static 619 * @static
571 * @param int $id 620 * @param int $id
572 * @return KTAPI_Permission Returns null if the namespace could not be resolved. 621 * @return KTAPI_Permission Returns null if the namespace could not be resolved.
@@ -587,6 +636,8 @@ class KTAPI_Permission extends KTAPI_Dynamic @@ -587,6 +636,8 @@ class KTAPI_Permission extends KTAPI_Dynamic
587 /** 636 /**
588 * Returns a KTAPI_Permission based on namespace. 637 * Returns a KTAPI_Permission based on namespace.
589 * 638 *
  639 + * @author KnowledgeTree Team
  640 + * @access public
590 * @static 641 * @static
591 * @param string $namespace 642 * @param string $namespace
592 * @return KTAPI_Permission Returns null if the namespace could not be resolved. 643 * @return KTAPI_Permission Returns null if the namespace could not be resolved.
@@ -607,6 +658,8 @@ class KTAPI_Permission extends KTAPI_Dynamic @@ -607,6 +658,8 @@ class KTAPI_Permission extends KTAPI_Dynamic
607 /** 658 /**
608 * Returns the permission id. 659 * Returns the permission id.
609 * 660 *
  661 + * @author KnowledgeTree Team
  662 + * @access public
610 * @return int 663 * @return int
611 */ 664 */
612 public 665 public
@@ -615,6 +668,8 @@ class KTAPI_Permission extends KTAPI_Dynamic @@ -615,6 +668,8 @@ class KTAPI_Permission extends KTAPI_Dynamic
615 /** 668 /**
616 * Returns the permission name. 669 * Returns the permission name.
617 * 670 *
  671 + * @author KnowledgeTree Team
  672 + * @access public
618 * @return string 673 * @return string
619 */ 674 */
620 public 675 public
@@ -623,6 +678,8 @@ class KTAPI_Permission extends KTAPI_Dynamic @@ -623,6 +678,8 @@ class KTAPI_Permission extends KTAPI_Dynamic
623 /** 678 /**
624 * Returns the permission namespace. 679 * Returns the permission namespace.
625 * 680 *
  681 + * @author KnowledgeTree Team
  682 + * @access public
626 * @return string 683 * @return string
627 */ 684 */
628 public 685 public
@@ -630,7 +687,7 @@ class KTAPI_Permission extends KTAPI_Dynamic @@ -630,7 +687,7 @@ class KTAPI_Permission extends KTAPI_Dynamic
630 } 687 }
631 688
632 /** 689 /**
633 - * AllocationBase. 690 + * Allocation Base class
634 * 691 *
635 * @author KnowledgeTree Team 692 * @author KnowledgeTree Team
636 * @package KTAPI 693 * @package KTAPI
@@ -672,6 +729,8 @@ abstract class KTAPI_AllocationBase extends KTAPI_Dynamic @@ -672,6 +729,8 @@ abstract class KTAPI_AllocationBase extends KTAPI_Dynamic
672 729
673 730
674 /** 731 /**
  732 + * Instance of the KTAPI object
  733 + *
675 * @access protected 734 * @access protected
676 * @var KTAPI 735 * @var KTAPI
677 */ 736 */
@@ -680,6 +739,7 @@ abstract class KTAPI_AllocationBase extends KTAPI_Dynamic @@ -680,6 +739,7 @@ abstract class KTAPI_AllocationBase extends KTAPI_Dynamic
680 /** 739 /**
681 * Constructor for KTAPI_Permission. This is protected, and can only be constructed by the static getAllocation() function. 740 * Constructor for KTAPI_Permission. This is protected, and can only be constructed by the static getAllocation() function.
682 * 741 *
  742 + * @author KnowledgeTree Team
683 * @access protected 743 * @access protected
684 * @param KTAPI_FolderItem $folderItem 744 * @param KTAPI_FolderItem $folderItem
685 */ 745 */
@@ -695,6 +755,7 @@ abstract class KTAPI_AllocationBase extends KTAPI_Dynamic @@ -695,6 +755,7 @@ abstract class KTAPI_AllocationBase extends KTAPI_Dynamic
695 /** 755 /**
696 * Helper method to identify the member type for the map. 756 * Helper method to identify the member type for the map.
697 * 757 *
  758 + * @author KnowledgeTree Team
698 * @access protected 759 * @access protected
699 * @param KTAPI_Member $member 760 * @param KTAPI_Member $member
700 * @return string 761 * @return string
@@ -707,7 +768,7 @@ abstract class KTAPI_AllocationBase extends KTAPI_Dynamic @@ -707,7 +768,7 @@ abstract class KTAPI_AllocationBase extends KTAPI_Dynamic
707 { 768 {
708 case 'KTAPI_User': $type = 'user'; break; 769 case 'KTAPI_User': $type = 'user'; break;
709 case 'KTAPI_Group': $type = 'group'; break; 770 case 'KTAPI_Group': $type = 'group'; break;
710 - case 'KTAPI_Route': $type = 'route'; break; 771 + case 'KTAPI_Role': $type = 'role'; break;
711 default: 772 default:
712 throw new Exception('Unknown type: ' . $type); 773 throw new Exception('Unknown type: ' . $type);
713 } 774 }
@@ -717,6 +778,7 @@ abstract class KTAPI_AllocationBase extends KTAPI_Dynamic @@ -717,6 +778,7 @@ abstract class KTAPI_AllocationBase extends KTAPI_Dynamic
717 /** 778 /**
718 * Log the transaction for the current user. 779 * Log the transaction for the current user.
719 * 780 *
  781 + * @author KnowledgeTree Team
720 * @access protected 782 * @access protected
721 * @param string $comment 783 * @param string $comment
722 * @param string $namespace 784 * @param string $namespace
@@ -761,6 +823,8 @@ abstract class KTAPI_AllocationBase extends KTAPI_Dynamic @@ -761,6 +823,8 @@ abstract class KTAPI_AllocationBase extends KTAPI_Dynamic
761 /** 823 /**
762 * Restore working copy, voiding the add(), remove() changes. 824 * Restore working copy, voiding the add(), remove() changes.
763 * 825 *
  826 + * @author KnowledgeTree Team
  827 + * @access public
764 */ 828 */
765 public 829 public
766 function restore() 830 function restore()
@@ -792,7 +856,9 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase @@ -792,7 +856,9 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase
792 /** 856 /**
793 * Returns the permission allocation for a specified folder item. 857 * Returns the permission allocation for a specified folder item.
794 * 858 *
795 - * @static 859 + * @author KnowledgeTree Team
  860 + * @access public
  861 + * @static
796 * @param KTAPI 862 * @param KTAPI
797 * @param KTAPI_FolderItem 863 * @param KTAPI_FolderItem
798 * @return KTAPI_PermissionAllocation 864 * @return KTAPI_PermissionAllocation
@@ -808,6 +874,8 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase @@ -808,6 +874,8 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase
808 /** 874 /**
809 * Force the current folder item to inherit permission from the parent. 875 * Force the current folder item to inherit permission from the parent.
810 * 876 *
  877 + * @author KnowledgeTree Team
  878 + * @access public
811 */ 879 */
812 public 880 public
813 function inheritAllocation() 881 function inheritAllocation()
@@ -822,6 +890,8 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase @@ -822,6 +890,8 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase
822 /** 890 /**
823 * Creates a copy of the current permissions. 891 * Creates a copy of the current permissions.
824 * 892 *
  893 + * @author KnowledgeTree Team
  894 + * @access public
825 */ 895 */
826 public 896 public
827 function overrideAllocation() 897 function overrideAllocation()
@@ -834,6 +904,8 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase @@ -834,6 +904,8 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase
834 /** 904 /**
835 * Gives permission to the specified member. 905 * Gives permission to the specified member.
836 * 906 *
  907 + * @author KnowledgeTree Team
  908 + * @access public
837 * @param KTAPI_Member $member A KTAPI_Role, KTAPI_Group or KTAPI_User. 909 * @param KTAPI_Member $member A KTAPI_Role, KTAPI_Group or KTAPI_User.
838 * @param KTAPI_Permission $permission 910 * @param KTAPI_Permission $permission
839 */ 911 */
@@ -847,6 +919,8 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase @@ -847,6 +919,8 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase
847 * Removes permission from the specified member. 919 * Removes permission from the specified member.
848 * NOTE: This only removes permission if it was already granted. 920 * NOTE: This only removes permission if it was already granted.
849 * 921 *
  922 + * @author KnowledgeTree Team
  923 + * @access public
850 * @param KTAPI_Member $member A KTAPI_Role, KTAPI_Group or KTAPI_User. 924 * @param KTAPI_Member $member A KTAPI_Role, KTAPI_Group or KTAPI_User.
851 * @param KTAPI_Permission $permission 925 * @param KTAPI_Permission $permission
852 */ 926 */
@@ -859,6 +933,7 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase @@ -859,6 +933,7 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase
859 /** 933 /**
860 * Helper method to update the permission map for the current folder item. 934 * Helper method to update the permission map for the current folder item.
861 * 935 *
  936 + * @author KnowledgeTree Team
862 * @access private 937 * @access private
863 * @param KTAPI_Member $member 938 * @param KTAPI_Member $member
864 * @param KTAPI_Permission $permission 939 * @param KTAPI_Permission $permission
@@ -881,6 +956,7 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase @@ -881,6 +956,7 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase
881 /** 956 /**
882 * Returns a list of members. 957 * Returns a list of members.
883 * 958 *
  959 + * @author KnowledgeTree Team
884 * @access private 960 * @access private
885 * @param string $type 961 * @param string $type
886 * @return array 962 * @return array
@@ -894,6 +970,8 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase @@ -894,6 +970,8 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase
894 /** 970 /**
895 * Return list of users for which there are allocations. 971 * Return list of users for which there are allocations.
896 * 972 *
  973 + * @author KnowledgeTree Team
  974 + * @access public
897 * @return array 975 * @return array
898 */ 976 */
899 public 977 public
@@ -905,6 +983,8 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase @@ -905,6 +983,8 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase
905 /** 983 /**
906 * Return list of groups for which there are allocations. 984 * Return list of groups for which there are allocations.
907 * 985 *
  986 + * @author KnowledgeTree Team
  987 + * @access public
908 * @return array 988 * @return array
909 */ 989 */
910 public 990 public
@@ -916,6 +996,8 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase @@ -916,6 +996,8 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase
916 /** 996 /**
917 * Return list of members for which there are allocations. 997 * Return list of members for which there are allocations.
918 * 998 *
  999 + * @author KnowledgeTree Team
  1000 + * @access public
919 * @return array 1001 * @return array
920 */ 1002 */
921 public 1003 public
@@ -927,6 +1009,8 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase @@ -927,6 +1009,8 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase
927 /** 1009 /**
928 * Returns the map of permissions for the specific member. 1010 * Returns the map of permissions for the specific member.
929 * 1011 *
  1012 + * @author KnowledgeTree Team
  1013 + * @access public
930 * @param KTAPI_Member $member 1014 * @param KTAPI_Member $member
931 * @return array 1015 * @return array
932 */ 1016 */
@@ -941,6 +1025,8 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase @@ -941,6 +1025,8 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase
941 /** 1025 /**
942 * Returns true if the permission is set for the specific member. 1026 * Returns true if the permission is set for the specific member.
943 * 1027 *
  1028 + * @author KnowledgeTree Team
  1029 + * @access public
944 * @param KTAPI_Member $member 1030 * @param KTAPI_Member $member
945 * @param KTAPI_Permission $permission 1031 * @param KTAPI_Permission $permission
946 * @return boolean 1032 * @return boolean
@@ -970,6 +1056,8 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase @@ -970,6 +1056,8 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase
970 /** 1056 /**
971 * Returns the properties defined in the system. 1057 * Returns the properties defined in the system.
972 * 1058 *
  1059 + * @author KnowledgeTree Team
  1060 + * @access public
973 * @return array 1061 * @return array
974 * 1062 *
975 */ 1063 */
@@ -982,6 +1070,8 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase @@ -982,6 +1070,8 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase
982 /** 1070 /**
983 * Returns an associative array with permissions mapped onto users, groups and roles. 1071 * Returns an associative array with permissions mapped onto users, groups and roles.
984 * 1072 *
  1073 + * @author KnowledgeTree Team
  1074 + * @access public
985 * @access protected 1075 * @access protected
986 */ 1076 */
987 protected 1077 protected
@@ -1097,13 +1187,13 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase @@ -1097,13 +1187,13 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase
1097 $inheritedId = $inherited->getId(); 1187 $inheritedId = $inherited->getId();
1098 $objectId = $object->getId(); 1188 $objectId = $object->getId();
1099 1189
1100 - $map['inherited'] = ($inheritedId === $objectId) && ($objectId != 1); 1190 + $map['inherited'] = ($inheritedId !== $objectId) && ($objectId != 1);
1101 1191
1102 - // only allow inheritance if not inherited, -and- folders is editable 1192 + // only allow inheritance of permissions from parent if not inherited, -and- folder is editable
1103 $map['inheritable'] = $editable && !$map['inherited'] && ($objectId != 1); 1193 $map['inheritable'] = $editable && !$map['inherited'] && ($objectId != 1);
1104 1194
1105 - // only allow edit if the folder is editable.  
1106 - $map['editable'] = $editable && $map['inherited']; 1195 + // only allow edit if the folder is editable and not inherited
  1196 + $map['editable'] = $editable && !$map['inherited'];
1107 1197
1108 $this->map = $map; 1198 $this->map = $map;
1109 $this->mapCopy = $map; 1199 $this->mapCopy = $map;
@@ -1113,6 +1203,8 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase @@ -1113,6 +1203,8 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase
1113 /** 1203 /**
1114 * Saves changes made by add() and remove(). 1204 * Saves changes made by add() and remove().
1115 * 1205 *
  1206 + * @author KnowledgeTree Team
  1207 + * @access public
1116 */ 1208 */
1117 public 1209 public
1118 function save() 1210 function save()
@@ -1124,7 +1216,7 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase @@ -1124,7 +1216,7 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase
1124 } 1216 }
1125 1217
1126 // if the current setup is inherited, then we must create a new copy to store the new associations. 1218 // if the current setup is inherited, then we must create a new copy to store the new associations.
1127 - if ($this->IsInherited) 1219 + if ($this->getIsInherited())
1128 { 1220 {
1129 $this->overrideAllocation(); 1221 $this->overrideAllocation();
1130 } 1222 }
@@ -1185,6 +1277,8 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase @@ -1185,6 +1277,8 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase
1185 /** 1277 /**
1186 * Indicates if any changes have been made. 1278 * Indicates if any changes have been made.
1187 * 1279 *
  1280 + * @author KnowledgeTree Team
  1281 + * @access public
1188 * @return boolean 1282 * @return boolean
1189 */ 1283 */
1190 public 1284 public
@@ -1193,6 +1287,8 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase @@ -1193,6 +1287,8 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase
1193 /** 1287 /**
1194 * Indicates if the current folder item is allowed to inherit permissions from the parent. 1288 * Indicates if the current folder item is allowed to inherit permissions from the parent.
1195 * 1289 *
  1290 + * @author KnowledgeTree Team
  1291 + * @access public
1196 * @return boolean 1292 * @return boolean
1197 */ 1293 */
1198 public 1294 public
@@ -1201,6 +1297,8 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase @@ -1201,6 +1297,8 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase
1201 /** 1297 /**
1202 * Indicates it the current folder item currently inherits the permissions from the parent. 1298 * Indicates it the current folder item currently inherits the permissions from the parent.
1203 * 1299 *
  1300 + * @author KnowledgeTree Team
  1301 + * @access public
1204 * @return boolean 1302 * @return boolean
1205 */ 1303 */
1206 public 1304 public
@@ -1209,6 +1307,8 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase @@ -1209,6 +1307,8 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase
1209 /** 1307 /**
1210 * Indicates if the permissions are editable but the current user. 1308 * Indicates if the permissions are editable but the current user.
1211 * 1309 *
  1310 + * @author KnowledgeTree Team
  1311 + * @access public
1212 * @return boolean 1312 * @return boolean
1213 */ 1313 */
1214 public 1314 public
@@ -1226,7 +1326,10 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase @@ -1226,7 +1326,10 @@ final class KTAPI_PermissionAllocation extends KTAPI_AllocationBase
1226 final class KTAPI_RoleAllocation extends KTAPI_AllocationBase 1326 final class KTAPI_RoleAllocation extends KTAPI_AllocationBase
1227 { 1327 {
1228 /** 1328 /**
1229 - * 1329 + * Resolve the folder item allocations
  1330 + *
  1331 + * @author KnowledgeTree Team
  1332 + * @access public
1230 * @access protected 1333 * @access protected
1231 */ 1334 */
1232 protected 1335 protected
@@ -1293,7 +1396,9 @@ final class KTAPI_RoleAllocation extends KTAPI_AllocationBase @@ -1293,7 +1396,9 @@ final class KTAPI_RoleAllocation extends KTAPI_AllocationBase
1293 /** 1396 /**
1294 * Returns a reference to the role alloction on a folder item. 1397 * Returns a reference to the role alloction on a folder item.
1295 * 1398 *
1296 - * @static 1399 + * @author KnowledgeTree Team
  1400 + * @access public
  1401 + * @static
1297 * @param KTAPI $ktapi 1402 * @param KTAPI $ktapi
1298 * @param KTAPI_FolderItem $folderItem 1403 * @param KTAPI_FolderItem $folderItem
1299 * @return KTAPI_RoleAllocation 1404 * @return KTAPI_RoleAllocation
@@ -1308,7 +1413,9 @@ final class KTAPI_RoleAllocation extends KTAPI_AllocationBase @@ -1308,7 +1413,9 @@ final class KTAPI_RoleAllocation extends KTAPI_AllocationBase
1308 /** 1413 /**
1309 * Return an array mapping the membership. 1414 * Return an array mapping the membership.
1310 * 1415 *
1311 - * @static 1416 + * @author KnowledgeTree Team
  1417 + * @access public
  1418 + * @static
1312 * @param string $filter 1419 * @param string $filter
1313 * @param array $options 1420 * @param array $options
1314 * @return array of KTAPIMember 1421 * @return array of KTAPIMember
@@ -1322,6 +1429,8 @@ final class KTAPI_RoleAllocation extends KTAPI_AllocationBase @@ -1322,6 +1429,8 @@ final class KTAPI_RoleAllocation extends KTAPI_AllocationBase
1322 /** 1429 /**
1323 * Link a member to a role on the current folder item. 1430 * Link a member to a role on the current folder item.
1324 * 1431 *
  1432 + * @author KnowledgeTree Team
  1433 + * @access public
1325 * @param KTAPI_Role $role Must be a KTAPIRole, or an array of roles. 1434 * @param KTAPI_Role $role Must be a KTAPIRole, or an array of roles.
1326 * @param KTAPI_Member $member A KTAPI_Group, KTAPI_User, array. 1435 * @param KTAPI_Member $member A KTAPI_Group, KTAPI_User, array.
1327 */ 1436 */
@@ -1356,6 +1465,8 @@ final class KTAPI_RoleAllocation extends KTAPI_AllocationBase @@ -1356,6 +1465,8 @@ final class KTAPI_RoleAllocation extends KTAPI_AllocationBase
1356 /** 1465 /**
1357 * Remove a member from a role on the current folder item. 1466 * Remove a member from a role on the current folder item.
1358 * 1467 *
  1468 + * @author KnowledgeTree Team
  1469 + * @access public
1359 * @param KTAPI_Role $role Must be a KTAPIRole, or an array of roles. 1470 * @param KTAPI_Role $role Must be a KTAPIRole, or an array of roles.
1360 * @param KTAPI_Member $member A KTAPI_Group or KTAPI_User. 1471 * @param KTAPI_Member $member A KTAPI_Group or KTAPI_User.
1361 */ 1472 */
@@ -1382,6 +1493,8 @@ final class KTAPI_RoleAllocation extends KTAPI_AllocationBase @@ -1382,6 +1493,8 @@ final class KTAPI_RoleAllocation extends KTAPI_AllocationBase
1382 /** 1493 /**
1383 * Check's if a role has a specific member 1494 * Check's if a role has a specific member
1384 * 1495 *
  1496 + * @author KnowledgeTree Team
  1497 + * @access public
1385 * @param KTAPI_Role $role 1498 * @param KTAPI_Role $role
1386 * @param KTAPI_Member $member 1499 * @param KTAPI_Member $member
1387 * @return boolean 1500 * @return boolean
@@ -1411,6 +1524,8 @@ final class KTAPI_RoleAllocation extends KTAPI_AllocationBase @@ -1411,6 +1524,8 @@ final class KTAPI_RoleAllocation extends KTAPI_AllocationBase
1411 /** 1524 /**
1412 * Removes all members associated with roles on the current folder item. 1525 * Removes all members associated with roles on the current folder item.
1413 * 1526 *
  1527 + * @author KnowledgeTree Team
  1528 + * @access public
1414 * @param KTAPI_Role $role Must be a KTAPI_Role, or an array of roles. 1529 * @param KTAPI_Role $role Must be a KTAPI_Role, or an array of roles.
1415 * @param KTAPI_Member $member A KTAPI_Group or KTAPI_User. 1530 * @param KTAPI_Member $member A KTAPI_Group or KTAPI_User.
1416 */ 1531 */
@@ -1436,8 +1551,10 @@ final class KTAPI_RoleAllocation extends KTAPI_AllocationBase @@ -1436,8 +1551,10 @@ final class KTAPI_RoleAllocation extends KTAPI_AllocationBase
1436 } 1551 }
1437 1552
1438 /** 1553 /**
1439 - * 1554 + * Override the role allocation for each role
1440 * 1555 *
  1556 + * @author KnowledgeTree Team
  1557 + * @access public
1441 */ 1558 */
1442 public 1559 public
1443 function overrideAllocation() 1560 function overrideAllocation()
@@ -1447,10 +1564,12 @@ final class KTAPI_RoleAllocation extends KTAPI_AllocationBase @@ -1447,10 +1564,12 @@ final class KTAPI_RoleAllocation extends KTAPI_AllocationBase
1447 $this->overrideRoleAllocation(KTAPI_Role::getById($roleId)); 1564 $this->overrideRoleAllocation(KTAPI_Role::getById($roleId));
1448 } 1565 }
1449 } 1566 }
1450 - 1567 +
1451 /** 1568 /**
1452 * Overrides a role allocation 1569 * Overrides a role allocation
1453 * 1570 *
  1571 + * @author KnowledgeTree Team
  1572 + * @access public
1454 * @param KTAPI_Role $role 1573 * @param KTAPI_Role $role
1455 */ 1574 */
1456 public 1575 public
@@ -1497,12 +1616,15 @@ final class KTAPI_RoleAllocation extends KTAPI_AllocationBase @@ -1497,12 +1616,15 @@ final class KTAPI_RoleAllocation extends KTAPI_AllocationBase
1497 1616
1498 // regenerate permissions 1617 // regenerate permissions
1499 1618
1500 - $this->renegeratePermissionsForRole($roleId); 1619 + $this->_regeneratePermissionsForRole($roleId);
  1620 + return $roleAllocation;
1501 } 1621 }
1502 1622
1503 /** 1623 /**
1504 * Force all roles to inherit role associations. 1624 * Force all roles to inherit role associations.
1505 * 1625 *
  1626 + * @author KnowledgeTree Team
  1627 + * @access public
1506 */ 1628 */
1507 public 1629 public
1508 function inheritAllocation() 1630 function inheritAllocation()
@@ -1520,6 +1642,13 @@ final class KTAPI_RoleAllocation extends KTAPI_AllocationBase @@ -1520,6 +1642,13 @@ final class KTAPI_RoleAllocation extends KTAPI_AllocationBase
1520 } 1642 }
1521 } 1643 }
1522 1644
  1645 + /**
  1646 + * Can the folder inherit allocations
  1647 + *
  1648 + * @author KnowledgeTree Team
  1649 + * @access public
  1650 + * @return unknown
  1651 + */
1523 public 1652 public
1524 function canInheritRoleAllocation() 1653 function canInheritRoleAllocation()
1525 { 1654 {
@@ -1532,6 +1661,8 @@ final class KTAPI_RoleAllocation extends KTAPI_AllocationBase @@ -1532,6 +1661,8 @@ final class KTAPI_RoleAllocation extends KTAPI_AllocationBase
1532 /** 1661 /**
1533 * Inherit the role associations from the parent. 1662 * Inherit the role associations from the parent.
1534 * 1663 *
  1664 + * @author KnowledgeTree Team
  1665 + * @access public
1535 * @param KTAPI_Role $role 1666 * @param KTAPI_Role $role
1536 * @param boolean $log 1667 * @param boolean $log
1537 */ 1668 */
@@ -1565,19 +1696,21 @@ final class KTAPI_RoleAllocation extends KTAPI_AllocationBase @@ -1565,19 +1696,21 @@ final class KTAPI_RoleAllocation extends KTAPI_AllocationBase
1565 return PEAR::raiseError(_kt('Could not inherit allocation from parent.')); 1696 return PEAR::raiseError(_kt('Could not inherit allocation from parent.'));
1566 } 1697 }
1567 1698
1568 - $this->_renegeratePermissionsForRole($roleId); 1699 + $this->_regeneratePermissionsForRole($roleId);
1569 } 1700 }
1570 1701
1571 /** 1702 /**
1572 * Regenerate permissions for a role. 1703 * Regenerate permissions for a role.
1573 * 1704 *
1574 - * Adapted from KTRoleAllocationPlugin::renegeratePermissionsForRole() 1705 + * Adapted from KTRoleAllocationPlugin::regeneratePermissionsForRole()
1575 * 1706 *
  1707 + * @author KnowledgeTree Team
  1708 + * @access public
1576 * @access private 1709 * @access private
1577 * @param int $iRoleId 1710 * @param int $iRoleId
1578 */ 1711 */
1579 private 1712 private
1580 - function _renegeratePermissionsForRole($iRoleId) 1713 + function _regeneratePermissionsForRole($iRoleId)
1581 { 1714 {
1582 $object = $this->folderItem->getObject(); 1715 $object = $this->folderItem->getObject();
1583 1716
@@ -1642,6 +1775,8 @@ final class KTAPI_RoleAllocation extends KTAPI_AllocationBase @@ -1642,6 +1775,8 @@ final class KTAPI_RoleAllocation extends KTAPI_AllocationBase
1642 /** 1775 /**
1643 * Save's the role allocation 1776 * Save's the role allocation
1644 * 1777 *
  1778 + * @author KnowledgeTree Team
  1779 + * @access public
1645 */ 1780 */
1646 public 1781 public
1647 function save() 1782 function save()
@@ -1692,4 +1827,4 @@ final class KTAPI_RoleAllocation extends KTAPI_AllocationBase @@ -1692,4 +1827,4 @@ final class KTAPI_RoleAllocation extends KTAPI_AllocationBase
1692 } 1827 }
1693 } 1828 }
1694 1829
1695 -?> 1830 -?>
  1831 +?>
1696 \ No newline at end of file 1832 \ No newline at end of file
ktapi/KTAPIDocument.inc.php
@@ -2257,6 +2257,30 @@ class KTAPI_Document extends KTAPI_FolderItem @@ -2257,6 +2257,30 @@ class KTAPI_Document extends KTAPI_FolderItem
2257 } 2257 }
2258 2258
2259 /** 2259 /**
  2260 + * Get the role allocation for the document
  2261 + *
  2262 + * @return KTAPI_RoleAllocation Instance of the role allocation object
  2263 + */
  2264 + public function getRoleAllocation()
  2265 + {
  2266 + $allocation = KTAPI_RoleAllocation::getAllocation($this->ktapi, $this);
  2267 +
  2268 + return $allocation;
  2269 + }
  2270 +
  2271 + /**
  2272 + * Get the permission allocation for the document
  2273 + *
  2274 + * @return KTAPI_PermissionAllocation Instance of the permission allocation object
  2275 + */
  2276 + public function getPermissionAllocation()
  2277 + {
  2278 + $allocation = KTAPI_PermissionAllocation::getAllocation($this->ktapi, $this);
  2279 +
  2280 + return $allocation;
  2281 + }
  2282 +
  2283 + /**
2260 * Checks if the user is subscribed to the document 2284 * Checks if the user is subscribed to the document
2261 * 2285 *
2262 * @author KnowledgeTree Team 2286 * @author KnowledgeTree Team
ktapi/KTAPIFolder.inc.php
@@ -32,7 +32,7 @@ @@ -32,7 +32,7 @@
32 * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices 32 * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
33 * must display the words "Powered by KnowledgeTree" and retain the original 33 * must display the words "Powered by KnowledgeTree" and retain the original
34 * copyright notice. 34 * copyright notice.
35 - * 35 + *
36 * @copyright 2008-2009, KnowledgeTree Inc. 36 * @copyright 2008-2009, KnowledgeTree Inc.
37 * @license GNU General Public License version 3 37 * @license GNU General Public License version 3
38 * @author KnowledgeTree Team 38 * @author KnowledgeTree Team
@@ -50,7 +50,7 @@ require_once(KT_DIR . '/ktwebservice/KTUploadManager.inc.php'); @@ -50,7 +50,7 @@ require_once(KT_DIR . '/ktwebservice/KTUploadManager.inc.php');
50 * @author KnowledgeTree Team 50 * @author KnowledgeTree Team
51 * @package KTAPI 51 * @package KTAPI
52 * @version Version 0.9 52 * @version Version 0.9
53 - * 53 + *
54 */ 54 */
55 class KTAPI_Folder extends KTAPI_FolderItem 55 class KTAPI_Folder extends KTAPI_FolderItem
56 { 56 {
@@ -112,7 +112,7 @@ class KTAPI_Folder extends KTAPI_FolderItem @@ -112,7 +112,7 @@ class KTAPI_Folder extends KTAPI_FolderItem
112 112
113 /** 113 /**
114 * Checks if the folder is a shortcut 114 * Checks if the folder is a shortcut
115 - * 115 + *
116 * @author KnowledgeTree Team 116 * @author KnowledgeTree Team
117 * @access public 117 * @access public
118 * @return boolean 118 * @return boolean
@@ -124,7 +124,7 @@ class KTAPI_Folder extends KTAPI_FolderItem @@ -124,7 +124,7 @@ class KTAPI_Folder extends KTAPI_FolderItem
124 124
125 /** 125 /**
126 * Retrieves the shortcuts linking to this folder 126 * Retrieves the shortcuts linking to this folder
127 - * 127 + *
128 * @author KnowledgeTree Team 128 * @author KnowledgeTree Team
129 * @access public 129 * @access public
130 * @return array 130 * @return array
@@ -194,7 +194,7 @@ class KTAPI_Folder extends KTAPI_FolderItem @@ -194,7 +194,7 @@ class KTAPI_Folder extends KTAPI_FolderItem
194 } 194 }
195 /** 195 /**
196 * This clears the global object cashe of the folder class. 196 * This clears the global object cashe of the folder class.
197 - * 197 + *
198 * @author KnowledgeTree Team 198 * @author KnowledgeTree Team
199 * @access public 199 * @access public
200 * 200 *
@@ -211,8 +211,8 @@ class KTAPI_Folder extends KTAPI_FolderItem @@ -211,8 +211,8 @@ class KTAPI_Folder extends KTAPI_FolderItem
211 } 211 }
212 212
213 /** 213 /**
214 - *  
215 - * 214 + *
  215 + *
216 * @author KnowledgeTree Team 216 * @author KnowledgeTree Team
217 * @access public 217 * @access public
218 * @return unknown 218 * @return unknown
@@ -247,7 +247,7 @@ class KTAPI_Folder extends KTAPI_FolderItem @@ -247,7 +247,7 @@ class KTAPI_Folder extends KTAPI_FolderItem
247 247
248 /** 248 /**
249 * This function will return a folder by it's name (not ID) 249 * This function will return a folder by it's name (not ID)
250 - * 250 + *
251 * @author KnowledgeTree Team 251 * @author KnowledgeTree Team
252 * @access public 252 * @access public
253 * @param KTAPI $ktapi 253 * @param KTAPI $ktapi
@@ -303,7 +303,7 @@ class KTAPI_Folder extends KTAPI_FolderItem @@ -303,7 +303,7 @@ class KTAPI_Folder extends KTAPI_FolderItem
303 303
304 /** 304 /**
305 * This will return the full path string of the current folder object 305 * This will return the full path string of the current folder object
306 - * 306 + *
307 * @author KnowledgeTree Team 307 * @author KnowledgeTree Team
308 * @access public 308 * @access public
309 * @return string 309 * @return string
@@ -318,7 +318,7 @@ class KTAPI_Folder extends KTAPI_FolderItem @@ -318,7 +318,7 @@ class KTAPI_Folder extends KTAPI_FolderItem
318 318
319 /** 319 /**
320 * This gets a document by filename or name. 320 * This gets a document by filename or name.
321 - * 321 + *
322 * @author KnowledgeTree Team 322 * @author KnowledgeTree Team
323 * @access private 323 * @access private
324 * @param string $documentname 324 * @param string $documentname
@@ -409,7 +409,7 @@ class KTAPI_Folder extends KTAPI_FolderItem @@ -409,7 +409,7 @@ class KTAPI_Folder extends KTAPI_FolderItem
409 409
410 /** 410 /**
411 * Gets a User class based on the user id 411 * Gets a User class based on the user id
412 - * 412 + *
413 * @author KnowledgeTree Team 413 * @author KnowledgeTree Team
414 * @param int $userid 414 * @param int $userid
415 * @return User 415 * @return User
@@ -431,7 +431,7 @@ class KTAPI_Folder extends KTAPI_FolderItem @@ -431,7 +431,7 @@ class KTAPI_Folder extends KTAPI_FolderItem
431 431
432 /** 432 /**
433 * Get's a permission string for a folder eg: 'RW' or 'RWA' 433 * Get's a permission string for a folder eg: 'RW' or 'RWA'
434 - * 434 + *
435 * @author KnowledgeTree Team 435 * @author KnowledgeTree Team
436 * @access public 436 * @access public
437 * @param Folder $folder 437 * @param Folder $folder
@@ -457,7 +457,7 @@ class KTAPI_Folder extends KTAPI_FolderItem @@ -457,7 +457,7 @@ class KTAPI_Folder extends KTAPI_FolderItem
457 457
458 /** 458 /**
459 * Get's a folder listing, recursing to the given depth 459 * Get's a folder listing, recursing to the given depth
460 - * 460 + *
461 * <code> 461 * <code>
462 * $root = $this->ktapi->get_root_folder(); 462 * $root = $this->ktapi->get_root_folder();
463 * $listing = $root->get_listing(); 463 * $listing = $root->get_listing();
@@ -468,7 +468,7 @@ class KTAPI_Folder extends KTAPI_FolderItem @@ -468,7 +468,7 @@ class KTAPI_Folder extends KTAPI_FolderItem
468 * } 468 * }
469 * } 469 * }
470 * </code> 470 * </code>
471 - * 471 + *
472 * @author KnowledgeTree Team 472 * @author KnowledgeTree Team
473 * @access public 473 * @access public
474 * @param int $depth 474 * @param int $depth
@@ -753,7 +753,7 @@ class KTAPI_Folder extends KTAPI_FolderItem @@ -753,7 +753,7 @@ class KTAPI_Folder extends KTAPI_FolderItem
753 753
754 /** 754 /**
755 * This adds a shortcut to an existing document to the current folder 755 * This adds a shortcut to an existing document to the current folder
756 - * 756 + *
757 * @author KnowledgeTree Team 757 * @author KnowledgeTree Team
758 * @access public 758 * @access public
759 * @param int $document_id The ID of the document to create a shortcut to 759 * @param int $document_id The ID of the document to create a shortcut to
@@ -787,7 +787,7 @@ class KTAPI_Folder extends KTAPI_FolderItem @@ -787,7 +787,7 @@ class KTAPI_Folder extends KTAPI_FolderItem
787 787
788 /** 788 /**
789 * This adds a shortcut pointing to an existing folder to the current folder 789 * This adds a shortcut pointing to an existing folder to the current folder
790 - * 790 + *
791 * @author KnowledgeTree Team 791 * @author KnowledgeTree Team
792 * @access public 792 * @access public
793 * @param int $folder_id The ID of the folder to create a shortcut to 793 * @param int $folder_id The ID of the folder to create a shortcut to
@@ -827,7 +827,7 @@ class KTAPI_Folder extends KTAPI_FolderItem @@ -827,7 +827,7 @@ class KTAPI_Folder extends KTAPI_FolderItem
827 * $folder = $kt->get_folder_by_name("My New folder"); 827 * $folder = $kt->get_folder_by_name("My New folder");
828 * $res = $folder->add_document("Test Document", "test.txt", "Default", $tmpfname); 828 * $res = $folder->add_document("Test Document", "test.txt", "Default", $tmpfname);
829 * </code> 829 * </code>
830 - * 830 + *
831 * @author KnowledgeTree Team 831 * @author KnowledgeTree Team
832 * @access public 832 * @access public
833 * @param string $title This is the title for the file in the repository. 833 * @param string $title This is the title for the file in the repository.
@@ -905,7 +905,7 @@ class KTAPI_Folder extends KTAPI_FolderItem @@ -905,7 +905,7 @@ class KTAPI_Folder extends KTAPI_FolderItem
905 * $root->add_folder("My New folder"); 905 * $root->add_folder("My New folder");
906 * ?> 906 * ?>
907 * </code> 907 * </code>
908 - * 908 + *
909 * @author KnowledgeTree Team 909 * @author KnowledgeTree Team
910 * @access public 910 * @access public
911 * @param string $foldername 911 * @param string $foldername
@@ -944,7 +944,7 @@ class KTAPI_Folder extends KTAPI_FolderItem @@ -944,7 +944,7 @@ class KTAPI_Folder extends KTAPI_FolderItem
944 * $folder = $kt->get_folder_by_name("My New folder"); 944 * $folder = $kt->get_folder_by_name("My New folder");
945 * $folder->delete("It was getting old!"); 945 * $folder->delete("It was getting old!");
946 * </code> 946 * </code>
947 - * 947 + *
948 * @author KnowledgeTree Team 948 * @author KnowledgeTree Team
949 * @access public 949 * @access public
950 * @param string $reason 950 * @param string $reason
@@ -975,7 +975,7 @@ class KTAPI_Folder extends KTAPI_FolderItem @@ -975,7 +975,7 @@ class KTAPI_Folder extends KTAPI_FolderItem
975 975
976 /** 976 /**
977 * This renames the folder 977 * This renames the folder
978 - * 978 + *
979 * @author KnowledgeTree Team 979 * @author KnowledgeTree Team
980 * @access public 980 * @access public
981 * @param string $newname 981 * @param string $newname
@@ -1043,7 +1043,7 @@ class KTAPI_Folder extends KTAPI_FolderItem @@ -1043,7 +1043,7 @@ class KTAPI_Folder extends KTAPI_FolderItem
1043 * $new_folder = $root->add_folder("New test folder"); 1043 * $new_folder = $root->add_folder("New test folder");
1044 * $res = $folder->copy($new_folder, "Test copy"); 1044 * $res = $folder->copy($new_folder, "Test copy");
1045 * </code> 1045 * </code>
1046 - * 1046 + *
1047 * @author KnowledgeTree Team 1047 * @author KnowledgeTree Team
1048 * @access public 1048 * @access public
1049 * @param KTAPI_Folder $ktapi_target_folder 1049 * @param KTAPI_Folder $ktapi_target_folder
@@ -1113,6 +1113,30 @@ class KTAPI_Folder extends KTAPI_FolderItem @@ -1113,6 +1113,30 @@ class KTAPI_Folder extends KTAPI_FolderItem
1113 } 1113 }
1114 1114
1115 /** 1115 /**
  1116 + * Get the role allocation for the folder
  1117 + *
  1118 + * @return KTAPI_RoleAllocation Instance of the role allocation object
  1119 + */
  1120 + public function getRoleAllocation()
  1121 + {
  1122 + $allocation = KTAPI_RoleAllocation::getAllocation($this->ktapi, $this);
  1123 +
  1124 + return $allocation;
  1125 + }
  1126 +
  1127 + /**
  1128 + * Get the permission allocation for the folder
  1129 + *
  1130 + * @return KTAPI_PermissionAllocation Instance of the permission allocation object
  1131 + */
  1132 + public function getPermissionAllocation()
  1133 + {
  1134 + $allocation = KTAPI_PermissionAllocation::getAllocation($this->ktapi, $this);
  1135 +
  1136 + return $allocation;
  1137 + }
  1138 +
  1139 + /**
1116 * Determines whether the currently logged on user is subscribed 1140 * Determines whether the currently logged on user is subscribed
1117 * 1141 *
1118 * @author KnowledgeTree Team 1142 * @author KnowledgeTree Team
@@ -1129,10 +1153,10 @@ class KTAPI_Folder extends KTAPI_FolderItem @@ -1129,10 +1153,10 @@ class KTAPI_Folder extends KTAPI_FolderItem
1129 } 1153 }
1130 1154
1131 /** 1155 /**
1132 - * 1156 + *
1133 * @author KnowledgeTree Team 1157 * @author KnowledgeTree Team
1134 * @access public 1158 * @access public
1135 - * 1159 + *
1136 */ 1160 */
1137 public function unsubscribe() 1161 public function unsubscribe()
1138 { 1162 {
@@ -1154,7 +1178,7 @@ class KTAPI_Folder extends KTAPI_FolderItem @@ -1154,7 +1178,7 @@ class KTAPI_Folder extends KTAPI_FolderItem
1154 * 1178 *
1155 * @author KnowledgeTree Team 1179 * @author KnowledgeTree Team
1156 * @access public 1180 * @access public
1157 - * 1181 + *
1158 */ 1182 */
1159 public function subscribe() 1183 public function subscribe()
1160 { 1184 {
ktapi/ktapi.inc.php
@@ -96,6 +96,10 @@ abstract class KTAPI_FolderItem @@ -96,6 +96,10 @@ abstract class KTAPI_FolderItem
96 96
97 public abstract function getObject(); 97 public abstract function getObject();
98 98
  99 + public abstract function getRoleAllocation();
  100 +
  101 + public abstract function getPermissionAllocation();
  102 +
99 public abstract function isSubscribed(); 103 public abstract function isSubscribed();
100 104
101 public abstract function unsubscribe(); 105 public abstract function unsubscribe();
tests/api/testAcl.php
1 <?php 1 <?php
2 -require_once (KTAPI_TEST_DIR . '/test.php'); 2 +require_once (KT_DIR . '/tests/test.php');
3 require_once (KT_DIR . '/ktapi/ktapi.inc.php'); 3 require_once (KT_DIR . '/ktapi/ktapi.inc.php');
4 4
5 class APIAclTestCase extends KTUnitTestCase { 5 class APIAclTestCase extends KTUnitTestCase {
@@ -123,8 +123,10 @@ class APIAclTestCase extends KTUnitTestCase { @@ -123,8 +123,10 @@ class APIAclTestCase extends KTUnitTestCase {
123 function testRoleAllocation() 123 function testRoleAllocation()
124 { 124 {
125 $root = $this->ktapi->get_root_folder(); 125 $root = $this->ktapi->get_root_folder();
126 - $folder = $this->ktapi->get_folder_by_name('/test123');  
127 - 126 + $folder = $this->ktapi->get_folder_by_name('test123');
  127 + if(!$folder instanceof KTAPI_Folder){
  128 + $folder = $root->add_folder('test123');
  129 + }
128 $allocation = KTAPI_RoleAllocation::getAllocation($this->ktapi, $folder); 130 $allocation = KTAPI_RoleAllocation::getAllocation($this->ktapi, $folder);
129 131
130 $role2 = KTAPI_Role::getByName('Reviewer'); 132 $role2 = KTAPI_Role::getByName('Reviewer');
@@ -133,27 +135,27 @@ class APIAclTestCase extends KTUnitTestCase { @@ -133,27 +135,27 @@ class APIAclTestCase extends KTUnitTestCase {
133 $user2 = KTAPI_User::getByUsername('anonymous'); 135 $user2 = KTAPI_User::getByUsername('anonymous');
134 $group = KTAPI_Group::getByName('System Administrators'); 136 $group = KTAPI_Group::getByName('System Administrators');
135 137
136 -// $this->assertFalse($allocation->doesRoleHaveMember($role, $user));  
137 -// $this->assertTrue($allocation->doesRoleHaveMember($role2, $user));  
138 -  
139 - 138 + $this->assertFalse($allocation->doesRoleHaveMember($role, $user));
  139 + $this->assertFalse($allocation->doesRoleHaveMember($role2, $user));
140 140
  141 + // Add Admin user to Reviewer role
141 $allocation->add($role2, $user); 142 $allocation->add($role2, $user);
  143 + // Add Admin user to Publisher role
142 $allocation->add($role, $user); 144 $allocation->add($role, $user);
  145 + // Add Sys admin group to Publisher role
143 $allocation->add($role, $group); 146 $allocation->add($role, $group);
  147 + // Add Anonymous to Publisher role - duplicate to test
  148 + $allocation->add($role, $user2);
  149 + $allocation->add($role, $user2);
144 $allocation->save(); 150 $allocation->save();
145 -/* $allocation->add($role, $user2);  
146 - $allocation->add($role, $user2); // yup. this is a dup. just to test.  
147 - $allocation->add($role, $group);  
148 151
149 $this->assertTrue($allocation->doesRoleHaveMember($role, $user)); 152 $this->assertTrue($allocation->doesRoleHaveMember($role, $user));
  153 + $this->assertTrue($allocation->doesRoleHaveMember($role, $group));
150 154
151 $allocation->remove($role, $user); 155 $allocation->remove($role, $user);
152 -  
153 $this->assertFalse($allocation->doesRoleHaveMember($role, $user)); 156 $this->assertFalse($allocation->doesRoleHaveMember($role, $user));
154 157
155 $allocation->remove($role, $user2); 158 $allocation->remove($role, $user2);
156 -  
157 $this->assertFalse($allocation->doesRoleHaveMember($role, $user2)); 159 $this->assertFalse($allocation->doesRoleHaveMember($role, $user2));
158 160
159 $allocation->save(); 161 $allocation->save();
@@ -162,8 +164,9 @@ class APIAclTestCase extends KTUnitTestCase { @@ -162,8 +164,9 @@ class APIAclTestCase extends KTUnitTestCase {
162 164
163 $allocation = KTAPI_RoleAllocation::getAllocation($this->ktapi, $root); 165 $allocation = KTAPI_RoleAllocation::getAllocation($this->ktapi, $root);
164 $this->assertFalse($allocation->doesRoleHaveMember($role, $user)); 166 $this->assertFalse($allocation->doesRoleHaveMember($role, $user));
165 - $this->assertFalse($allocation->doesRoleHaveMember($role, $user2));*/ 167 + $this->assertFalse($allocation->doesRoleHaveMember($role, $user2));
166 168
  169 + $folder->delete('Testing role allocation');
167 } 170 }
168 171
169 /** 172 /**
@@ -173,12 +176,16 @@ class APIAclTestCase extends KTUnitTestCase { @@ -173,12 +176,16 @@ class APIAclTestCase extends KTUnitTestCase {
173 function testPermissionAllocation() 176 function testPermissionAllocation()
174 { 177 {
175 $root = $this->ktapi->get_root_folder(); 178 $root = $this->ktapi->get_root_folder();
176 - $folder = $this->ktapi->get_folder_by_name('/test123'); 179 + $folder = $this->ktapi->get_folder_by_name('test123');
  180 + if(!$folder instanceof KTAPI_Folder){
  181 + $folder = $root->add_folder('test123');
  182 + }
177 183
178 - $allocation = KTAPI_PermissionAllocation::getAllocation($this->ktapi, $root); 184 + $allocation = KTAPI_PermissionAllocation::getAllocation($this->ktapi, $folder);
179 185
180 $group = KTAPI_Group::getByName('System Administrators'); 186 $group = KTAPI_Group::getByName('System Administrators');
181 $user = KTAPI_User::getByUsername('anonymous'); 187 $user = KTAPI_User::getByUsername('anonymous');
  188 + $role = KTAPI_Role::getByName('Publisher');
182 $read = KTAPI_Permission::getByNamespace('ktcore.permissions.read'); 189 $read = KTAPI_Permission::getByNamespace('ktcore.permissions.read');
183 $write = KTAPI_Permission::getByNamespace('ktcore.permissions.write'); 190 $write = KTAPI_Permission::getByNamespace('ktcore.permissions.write');
184 $addFolder = KTAPI_Permission::getByNamespace('ktcore.permissions.addFolder'); 191 $addFolder = KTAPI_Permission::getByNamespace('ktcore.permissions.addFolder');
@@ -188,21 +195,22 @@ class APIAclTestCase extends KTUnitTestCase { @@ -188,21 +195,22 @@ class APIAclTestCase extends KTUnitTestCase {
188 $allocation->add($user, $write); 195 $allocation->add($user, $write);
189 $allocation->add($user, $addFolder); 196 $allocation->add($user, $addFolder);
190 $allocation->add($user, $security); 197 $allocation->add($user, $security);
  198 + $allocation->add($role, $read);
  199 + $allocation->add($role, $write);
191 $allocation->remove($group, $write); 200 $allocation->remove($group, $write);
192 201
193 $allocation->save(); 202 $allocation->save();
194 203
  204 + // refresh object and check permission allocations
  205 + $folder2 = $this->ktapi->get_folder_by_name('test123');
195 206
196 - $root2 = $this->ktapi->get_root_folder();  
197 -  
198 - $allocation = KTAPI_PermissionAllocation::getAllocation($this->ktapi, $root2); 207 + $allocation = KTAPI_PermissionAllocation::getAllocation($this->ktapi, $folder2);
199 $this->assertTrue($allocation->isMemberPermissionSet($user, $read)); 208 $this->assertTrue($allocation->isMemberPermissionSet($user, $read));
200 $this->assertTrue($allocation->isMemberPermissionSet($user, $write)); 209 $this->assertTrue($allocation->isMemberPermissionSet($user, $write));
201 - 210 + $this->assertTrue($allocation->isMemberPermissionSet($role, $write));
202 $this->assertFalse($allocation->isMemberPermissionSet($group, $write)); 211 $this->assertFalse($allocation->isMemberPermissionSet($group, $write));
203 212
  213 + $folder->delete('Testing permission allocation');
204 } 214 }
205 -  
206 } 215 }
207 -?>  
208 - 216 +?>
209 \ No newline at end of file 217 \ No newline at end of file
tests/api/testDocument.php
@@ -271,6 +271,31 @@ class APIDocumentTestCase extends KTUnitTestCase { @@ -271,6 +271,31 @@ class APIDocumentTestCase extends KTUnitTestCase {
271 } 271 }
272 272
273 /** 273 /**
  274 + * Test role allocation and permission allocation
  275 + */
  276 + function testPermissions()
  277 + {
  278 + $randomFile = APIDocumentHelper::createRandomFile();
  279 + $this->assertTrue(is_file($randomFile));
  280 +
  281 + $document = $this->root->add_document('testtitle', 'testname', 'Default', $randomFile);
  282 + @unlink($randomFile);
  283 + $this->assertNotError($document);
  284 + if(PEAR::isError($document)) return;
  285 +
  286 + $permAllocation = $document->getPermissionAllocation();
  287 + $this->assertNotNull($permAllocation);
  288 + $this->assertEntity($permAllocation, KTAPI_PermissionAllocation);
  289 +
  290 + $roleAllocation = $document->getRoleAllocation();
  291 + $this->assertNotNull($roleAllocation);
  292 + $this->assertEntity($roleAllocation, KTAPI_RoleAllocation);
  293 +
  294 + $document->delete('Testing');
  295 + $document->expunge();
  296 + }
  297 +
  298 + /**
274 * Tests the adding of a duplicate document title 299 * Tests the adding of a duplicate document title
275 * 300 *
276 function testAddingDuplicateTitle() 301 function testAddingDuplicateTitle()
tests/api/testFolder.php
1 <?php 1 <?php
2 -require_once (dirname(__FILE__) . '/../test.php'); 2 +require_once (KT_DIR . '/tests/test.php');
3 require_once (KT_DIR . '/ktapi/ktapi.inc.php'); 3 require_once (KT_DIR . '/ktapi/ktapi.inc.php');
4 class APIFolderTestCase extends KTUnitTestCase { 4 class APIFolderTestCase extends KTUnitTestCase {
5 /** 5 /**
@@ -26,36 +26,36 @@ class APIFolderTestCase extends KTUnitTestCase { @@ -26,36 +26,36 @@ class APIFolderTestCase extends KTUnitTestCase {
26 $folder2->delete('because'); 26 $folder2->delete('because');
27 } 27 }
28 } 28 }
29 - 29 +
30 function testAddDocument() { 30 function testAddDocument() {
31 $tmpfname = tempnam("/tmp", "KTUNIT"); 31 $tmpfname = tempnam("/tmp", "KTUNIT");
32 $fp = fopen($tmpfname, "w"); 32 $fp = fopen($tmpfname, "w");
33 fwrite($fp, "Hello"); 33 fwrite($fp, "Hello");
34 fclose($fp); 34 fclose($fp);
35 - 35 +
36 $folder = $this->ktapi->get_root_folder(); 36 $folder = $this->ktapi->get_root_folder();
37 $res = $folder->add_document("Test Document", "test.txt", "Default", $tmpfname); 37 $res = $folder->add_document("Test Document", "test.txt", "Default", $tmpfname);
38 $this->assertEntity($res, 'KTAPI_Document'); 38 $this->assertEntity($res, 'KTAPI_Document');
39 -  
40 -  
41 - 39 +
  40 +
  41 +
42 $res = $res->delete("Test deletion"); 42 $res = $res->delete("Test deletion");
43 -  
44 -  
45 - 43 +
  44 +
  45 +
46 } 46 }
47 - 47 +
48 function testDeleteFolder() { 48 function testDeleteFolder() {
49 $folder = $this->ktapi->get_root_folder(); 49 $folder = $this->ktapi->get_root_folder();
50 $folder = $folder->add_folder('temp1'); 50 $folder = $folder->add_folder('temp1');
51 $this->assertEntity($folder, 'KTAPI_Folder'); 51 $this->assertEntity($folder, 'KTAPI_Folder');
52 $folder->delete('because'); 52 $folder->delete('because');
53 - 53 +
54 $folder = $this->ktapi->get_folder_by_name('temp1'); 54 $folder = $this->ktapi->get_folder_by_name('temp1');
55 $this->assertError($folder); 55 $this->assertError($folder);
56 } 56 }
57 -  
58 - 57 +
  58 +
59 /* function testRename() { 59 /* function testRename() {
60 $root = $this->ktapi->get_root_folder(); 60 $root = $this->ktapi->get_root_folder();
61 $this->assertEntity($root, 'KTAPI_Folder'); 61 $this->assertEntity($root, 'KTAPI_Folder');
@@ -77,26 +77,26 @@ class APIFolderTestCase extends KTUnitTestCase { @@ -77,26 +77,26 @@ class APIFolderTestCase extends KTUnitTestCase {
77 $root = $this->ktapi->get_root_folder(); 77 $root = $this->ktapi->get_root_folder();
78 $folder = $root->get_folder(); 78 $folder = $root->get_folder();
79 $this->assertEntity($folder, 'Folder'); 79 $this->assertEntity($folder, 'Folder');
80 - 80 +
81 $folder = $this->ktapi->get_folder_by_name("NONAMEFOLDER"); 81 $folder = $this->ktapi->get_folder_by_name("NONAMEFOLDER");
82 $this->assertError($folder); 82 $this->assertError($folder);
83 - 83 +
84 $junk = pack("H*", "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F"); 84 $junk = pack("H*", "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F");
85 $junk = $junk.$junk.$junk.$junk.$junk.$junk.$junk.$junk.$junk; 85 $junk = $junk.$junk.$junk.$junk.$junk.$junk.$junk.$junk.$junk;
86 $folder = $this->ktapi->get_folder_by_name($junk); 86 $folder = $this->ktapi->get_folder_by_name($junk);
87 $this->assertError($folder); 87 $this->assertError($folder);
88 - 88 +
89 } 89 }
90 - 90 +
91 function testListing() { 91 function testListing() {
92 $root = $this->ktapi->get_root_folder(); 92 $root = $this->ktapi->get_root_folder();
93 $listing = $root->get_listing(); 93 $listing = $root->get_listing();
94 $this->assertExpectedResults(true, is_array($listing)); 94 $this->assertExpectedResults(true, is_array($listing));
95 foreach($listing as $key => $val) { 95 foreach($listing as $key => $val) {
96 - 96 +
97 } 97 }
98 } 98 }
99 - 99 +
100 function testCreateFolders() { 100 function testCreateFolders() {
101 $root = $this->ktapi->get_root_folder(); 101 $root = $this->ktapi->get_root_folder();
102 $this->assertEntity($root, 'KTAPI_Folder'); 102 $this->assertEntity($root, 'KTAPI_Folder');
@@ -132,8 +132,8 @@ class APIFolderTestCase extends KTUnitTestCase { @@ -132,8 +132,8 @@ class APIFolderTestCase extends KTUnitTestCase {
132 $this->assertEntity($folder, 'PEAR_Error'); 132 $this->assertEntity($folder, 'PEAR_Error');
133 } 133 }
134 } 134 }
135 -  
136 - 135 +
  136 +
137 function testPermission() { 137 function testPermission() {
138 $root = $this->ktapi->get_root_folder(); 138 $root = $this->ktapi->get_root_folder();
139 $perm = $root->get_permissions(); 139 $perm = $root->get_permissions();
@@ -142,43 +142,63 @@ class APIFolderTestCase extends KTUnitTestCase { @@ -142,43 +142,63 @@ class APIFolderTestCase extends KTUnitTestCase {
142 142
143 function getSystemListing() { 143 function getSystemListing() {
144 // TODO .. can do anything as admin... 144 // TODO .. can do anything as admin...
145 - 145 +
146 } 146 }
147 function getAnonymousListing() { 147 function getAnonymousListing() {
148 // TODO 148 // TODO
149 // probably won't be able to do unless the api caters for setting up anonymous... 149 // probably won't be able to do unless the api caters for setting up anonymous...
150 - 150 +
151 } 151 }
152 function getUserListing() { 152 function getUserListing() {
153 // TODO 153 // TODO
154 - 154 +
155 } 155 }
156 function testCopy() { 156 function testCopy() {
157 $root = $this->ktapi->get_root_folder(); 157 $root = $this->ktapi->get_root_folder();
158 $folder = $root->add_folder("Test folder2"); 158 $folder = $root->add_folder("Test folder2");
159 $new_folder = $root->add_folder("New test folder2"); 159 $new_folder = $root->add_folder("New test folder2");
160 $res = $folder->copy($new_folder, "Unit test copy2"); 160 $res = $folder->copy($new_folder, "Unit test copy2");
161 - 161 +
162 $folder->delete("Clean up test"); 162 $folder->delete("Clean up test");
163 $new_folder->delete("Clean up test"); 163 $new_folder->delete("Clean up test");
164 - 164 +
165 $this->assertNull($res, "Error returned"); 165 $this->assertNull($res, "Error returned");
166 -  
167 - 166 +
  167 +
168 } 168 }
169 function testMove() { 169 function testMove() {
170 $root = $this->ktapi->get_root_folder(); 170 $root = $this->ktapi->get_root_folder();
171 $folder = $root->add_folder("Test folder2"); 171 $folder = $root->add_folder("Test folder2");
172 $new_folder = $root->add_folder("New test folder2"); 172 $new_folder = $root->add_folder("New test folder2");
173 $res = $folder->move($new_folder, "Unit test copy2"); 173 $res = $folder->move($new_folder, "Unit test copy2");
174 - 174 +
175 $folder->delete("Clean up test"); 175 $folder->delete("Clean up test");
176 $new_folder->delete("Clean up test"); 176 $new_folder->delete("Clean up test");
177 - 177 +
178 $this->assertNull($res, "Error returned"); 178 $this->assertNull($res, "Error returned");
179 -  
180 - 179 +
  180 +
181 } 181 }
182 182
  183 + /**
  184 + * Test role allocation and permission allocation
  185 + */
  186 + function testPermissions()
  187 + {
  188 + $root = $this->ktapi->get_root_folder();
  189 + $folder = $root->add_folder('testX');
  190 + $this->assertEntity($folder, 'KTAPI_Folder');
  191 + if(PEAR::isError($folder)) return;
  192 +
  193 + $permAllocation = $folder->getPermissionAllocation();
  194 + $this->assertNotNull($permAllocation);
  195 + $this->assertEntity($permAllocation, KTAPI_PermissionAllocation);
  196 +
  197 + $roleAllocation = $folder->getRoleAllocation();
  198 + $this->assertNotNull($roleAllocation);
  199 + $this->assertEntity($roleAllocation, KTAPI_RoleAllocation);
  200 +
  201 + $folder->delete('Testing');
  202 + }
183 } 203 }
184 ?> 204 ?>