Capability.php
9 years ago
LoginRedirect.php
9 years ago
Menu.php
9 years ago
Metabox.php
9 years ago
Post.php
9 years ago
Redirect.php
9 years ago
Teaser.php
9 years ago
Capability.php
57 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * ====================================================================== |
| 5 | * LICENSE: This file is subject to the terms and conditions defined in * |
| 6 | * file 'license.txt', which is part of this source code package. * |
| 7 | * ====================================================================== |
| 8 | */ |
| 9 | |
| 10 | /** |
| 11 | * Capability object |
| 12 | * |
| 13 | * @package AAM |
| 14 | * @author Vasyl Martyniuk <vasyl@vasyltech.com> |
| 15 | */ |
| 16 | class AAM_Core_Object_Capability extends AAM_Core_Object { |
| 17 | |
| 18 | /** |
| 19 | * Constructor |
| 20 | * |
| 21 | * @param AAM_Core_Subject $subject |
| 22 | * |
| 23 | * @return void |
| 24 | * |
| 25 | * @access public |
| 26 | */ |
| 27 | public function __construct(AAM_Core_Subject $subject) { |
| 28 | parent::__construct($subject); |
| 29 | |
| 30 | $this->setOption($this->getSubject()->getCapabilities()); |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * |
| 35 | * @param type $capability |
| 36 | * @param type $granted |
| 37 | */ |
| 38 | public function save($capability, $granted) { |
| 39 | if (intval($granted)) { |
| 40 | $result = $this->getSubject()->addCapability($capability); |
| 41 | } else { |
| 42 | $result = $this->getSubject()->removeCapability($capability); |
| 43 | } |
| 44 | |
| 45 | return $result; |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * |
| 50 | * @param type $capability |
| 51 | * @return type |
| 52 | */ |
| 53 | public function has($capability) { |
| 54 | return $this->getSubject()->hasCapability($capability); |
| 55 | } |
| 56 | |
| 57 | } |