Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
12.50% |
1 / 8 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| DeliveryFieldsService | |
12.50% |
1 / 8 |
|
50.00% |
1 / 2 |
14.72 | |
0.00% |
0 / 1 |
| getLabel | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
12 | |||
| getDeliveryExecutionPageTitle | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; under version 2 |
| 7 | * of the License (non-upgradable). |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | * |
| 18 | * Copyright (c) 2017 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | namespace oat\taoDelivery\model\fields; |
| 23 | |
| 24 | use core_kernel_classes_Resource; |
| 25 | use oat\generis\model\OntologyAwareTrait; |
| 26 | use oat\oatbox\service\ConfigurableService; |
| 27 | |
| 28 | /** |
| 29 | * Service to manage the custom fields of deliveries |
| 30 | * |
| 31 | * @access public |
| 32 | * @author Aleksej Tikhanovich, <aleksej@taotesting.com> |
| 33 | * @package taoDelivery |
| 34 | */ |
| 35 | class DeliveryFieldsService extends ConfigurableService |
| 36 | { |
| 37 | use OntologyAwareTrait; |
| 38 | |
| 39 | public const SERVICE_ID = 'taoDelivery/deliveryFields'; |
| 40 | |
| 41 | public const PROPERTY_CUSTOM_LABEL = 'http://www.tao.lu/Ontologies/TAODelivery.rdf#CustomLabel'; |
| 42 | |
| 43 | /** |
| 44 | * Getting custom label from Delivery |
| 45 | * |
| 46 | * @param \core_kernel_classes_Resource $delivery |
| 47 | * @param string $label |
| 48 | * @return string |
| 49 | */ |
| 50 | public function getLabel(\core_kernel_classes_Resource $delivery, $label = '') |
| 51 | { |
| 52 | $user = \common_session_SessionManager::getSession()->getUser(); |
| 53 | $customLabelRoles = $this->getOption(self::PROPERTY_CUSTOM_LABEL); |
| 54 | if (array_intersect($customLabelRoles, $user->getRoles())) { |
| 55 | $property = $this->getProperty(self::PROPERTY_CUSTOM_LABEL); |
| 56 | if ((string)$delivery->getOnePropertyValue($property)) { |
| 57 | $label = $delivery->getOnePropertyValue($property); |
| 58 | } |
| 59 | } |
| 60 | return (string) $label; |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * get Title of the Webpage on the Browser Tab when Run delivery Execution |
| 65 | * |
| 66 | * @param core_kernel_classes_Resource $delivery |
| 67 | * @return string |
| 68 | */ |
| 69 | public function getDeliveryExecutionPageTitle(core_kernel_classes_Resource $delivery) |
| 70 | { |
| 71 | return __('TAO: %s', $delivery->getLabel()); |
| 72 | } |
| 73 | } |