Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
ModulePermissionsViewUtil.php
1 <?php
2  /*********************************************************************************
3  * Zurmo is a customer relationship management program developed by
4  * Zurmo, Inc. Copyright (C) 2017 Zurmo Inc.
5  *
6  * Zurmo is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License version 3 as published by the
8  * Free Software Foundation with the addition of the following permission added
9  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10  * IN WHICH THE COPYRIGHT IS OWNED BY ZURMO, ZURMO DISCLAIMS THE WARRANTY
11  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12  *
13  * Zurmo is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Affero General Public License along with
19  * this program; if not, see http://www.gnu.org/licenses or write to the Free
20  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  * 02110-1301 USA.
22  *
23  * You can contact Zurmo, Inc. with a mailing address at 27 North Wacker Drive
24  * Suite 370 Chicago, IL 60606. or at email address contact@zurmo.com.
25  *
26  * The interactive user interfaces in original and modified versions
27  * of this program must display Appropriate Legal Notices, as required under
28  * Section 5 of the GNU Affero General Public License version 3.
29  *
30  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31  * these Appropriate Legal Notices must retain the display of the Zurmo
32  * logo and Zurmo copyright notice. If the display of the logo is not reasonably
33  * feasible for technical reasons, the Appropriate Legal Notices must display the words
34  * "Copyright Zurmo Inc. 2017. All rights reserved".
35  ********************************************************************************/
36 
41  {
46  protected static function makeMetadataFromData($data)
47  {
48  $elements = array();
49  $calledClassName = get_called_class();
50  $viewPermissions = $calledClassName::getPermissionsForView();
51  foreach ($data as $moduleClassName => $modulePermissions)
52  {
53  foreach ($viewPermissions as $permission)
54  {
55  $permissionsInformation = $modulePermissions[$permission];
56  $element = $calledClassName::getElementInformation(
57  $moduleClassName,
58  $permission,
59  $permissionsInformation);
60  $elements[$moduleClassName][] = $element;
61  }
62  }
63  $metadata = array(
64  'global' => array(
65  'panels' => array(
66  array(
67  'rows' => array(
68  ),
69  ),
70  ),
71  )
72  );
73  foreach ($elements as $moduleClassName => $moduleElements)
74  {
75  $rowTitle = $moduleClassName::getSecurableModuleDisplayName();
76  $metadata['global']['panels'][0]['rows'][] = $calledClassName::getRowByModuleElement(
77  $moduleElements,
78  $rowTitle);
79  }
80  return $metadata;
81  }
82 
83  protected static function getRowByModuleElement($moduleElements, $rowTitle)
84  {
85  assert('is_array($moduleElements)');
86  assert('$rowTitle == null | is_string($rowTitle)');
87  $row = array();
88  foreach ($moduleElements as $element)
89  {
90  if ($rowTitle != null)
91  {
92  $row['title'] = $rowTitle;
93  }
94  $row['cells'][] = array(
95  'elements' => array(
96  $element,
97  ),
98  );
99  }
100  return $row;
101  }
102 
108  public static function getPermissionsForView()
109  {
110  $permissions = array();
111  $calledClassName = get_called_class();
112  $permissionNames = $calledClassName::getPermissionNamesForView();
113  foreach ($permissionNames as $name)
114  {
115  $permissions[] = constant('Permission::' . $name);
116  }
117  return $permissions;
118  }
119 
125  public static function getPermissionNamesForView()
126  {
127  return array(
128  'READ',
129  'WRITE',
130  'DELETE',
131  );
132  }
133 
137  public static function getPermissionLabelsForView()
138  {
139  return array(
140  'READ' => Zurmo::t('ZurmoModule', 'Read'),
141  'WRITE' => Zurmo::t('ZurmoModule', 'Write'),
142  'DELETE' => Zurmo::t('Core', 'Delete'),
143  );
144  }
145  }
146 ?>
Generated on Thu Oct 22 2020 07:10:35
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.