Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
UsersModule.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 
38  {
39  const RIGHT_MANAGE_USERS = 'Manage Users';
40  const RIGHT_LOGIN_VIA_WEB = 'Login Via Web';
41  const RIGHT_LOGIN_VIA_MOBILE = 'Login Via Mobile';
42  const RIGHT_LOGIN_VIA_WEB_API = 'Login Via Web API';
43  const RIGHT_CREATE_USERS = 'Create Users';
44  const RIGHT_ACCESS_USERS = 'Access Users Tab';
45 
46  const POLICY_ENFORCE_STRONG_PASSWORDS = 'Enforce Strong Passwords';
47  const POLICY_MINIMUM_PASSWORD_LENGTH = 'Minimum Password Length';
48  const POLICY_MINIMUM_USERNAME_LENGTH = 'Minimum Username Length';
49  const POLICY_PASSWORD_EXPIRES = 'Password Expires';
50  const POLICY_PASSWORD_EXPIRY_DAYS = 'Password Expiry Days';
51 
52  const AUDIT_EVENT_USER_LOGGED_IN = 'User Logged In';
53  const AUDIT_EVENT_USER_LOGGED_OUT = 'User Logged Out';
54  const AUDIT_EVENT_USER_PASSWORD_CHANGED = 'User Password Changed';
55 
56  protected static $policyDefaults = array(
57  self::POLICY_ENFORCE_STRONG_PASSWORDS => null,
58  self::POLICY_MINIMUM_PASSWORD_LENGTH => 5,
59  self::POLICY_MINIMUM_USERNAME_LENGTH => 3,
60  self::POLICY_PASSWORD_EXPIRES => null,
61  self::POLICY_PASSWORD_EXPIRY_DAYS => null,
62  );
63 
64  public function canDisable()
65  {
66  return false;
67  }
68 
69  public function getDependencies()
70  {
71  return array(
72  'zurmo',
73  );
74  }
75 
76  public function getRootModelNames()
77  {
78  return array('User');
79  }
80 
81  public static function getTranslatedRightsLabels()
82  {
83  $labels = array();
84 
85  $labels[self::RIGHT_MANAGE_USERS] = Zurmo::t('UsersModule', 'Manage Users');
86  $labels[self::RIGHT_LOGIN_VIA_WEB] = Zurmo::t('UsersModule', 'Sign in Via Web');
87  $labels[self::RIGHT_LOGIN_VIA_MOBILE] = Zurmo::t('UsersModule', 'Sign in Via Mobile');
88  $labels[self::RIGHT_LOGIN_VIA_WEB_API] = Zurmo::t('UsersModule', 'Sign in Via Web API');
89  $labels[self::RIGHT_CREATE_USERS] = Zurmo::t('UsersModule', 'Create Users');
90  $labels[self::RIGHT_ACCESS_USERS] = Zurmo::t('UsersModule', 'Access Users Tab');
91  return $labels;
92  }
93 
94  public static function getTranslatedPolicyLabels()
95  {
96  $labels = array();
97  $labels[self::POLICY_ENFORCE_STRONG_PASSWORDS] = Zurmo::t('UsersModule', 'Enforce Strong Passwords');
98  $labels[self::POLICY_MINIMUM_PASSWORD_LENGTH] = Zurmo::t('UsersModule', 'Minimum Password Length');
99  $labels[self::POLICY_MINIMUM_USERNAME_LENGTH] = Zurmo::t('UsersModule', 'Minimum Username Length');
100  $labels[self::POLICY_PASSWORD_EXPIRES] = Zurmo::t('UsersModule', 'Password Expires');
101  $labels[self::POLICY_PASSWORD_EXPIRY_DAYS] = Zurmo::t('UsersModule', 'Password Expiry Days');
102  return $labels;
103  }
104 
105  public static function getStrongerPolicy($policyName, array $values)
106  {
107  assert('is_string($policyName) && $policyName != ""');
108  switch ($policyName)
109  {
110  case self::POLICY_ENFORCE_STRONG_PASSWORDS:
111  case self::POLICY_PASSWORD_EXPIRES:
112  assert('AssertUtil::all($values, "isPolicyYesNo", "UsersModule")');
113  return max($values);
114 
115  case self::POLICY_MINIMUM_PASSWORD_LENGTH:
116  case self::POLICY_MINIMUM_USERNAME_LENGTH:
117  assert('AssertUtil::all($values, "is_numeric")');
118  return max($values);
119 
120  case self::POLICY_PASSWORD_EXPIRY_DAYS:
121  assert('AssertUtil::all($values, "is_numeric")');
122  return min($values);
123 
124  default:
125  throw new NotSupportedException();
126  }
127  }
128 
129  public static function getPolicyRulesTypes()
130  {
131  $userPolicyRulesTypes = array(
132  'POLICY_ENFORCE_STRONG_PASSWORDS' => 'YesNo',
133  'POLICY_MINIMUM_PASSWORD_LENGTH' => 'Integer',
134  'POLICY_MINIMUM_USERNAME_LENGTH' => 'Integer',
135  'POLICY_PASSWORD_EXPIRES' => 'PasswordExpires',
136  'POLICY_PASSWORD_EXPIRY_DAYS' => 'PasswordExpiry',
137  );
138  return array_merge(parent::getPolicyNames(), $userPolicyRulesTypes);
139  }
140 
141  public static function getDefaultMetadata()
142  {
143  $metadata = array();
144  $metadata['global'] = array(
145  'adminTabMenuItems' => array(
146  array(
147  'label' => "eval:Zurmo::t('UsersModule', 'Users')",
148  'url' => array('/users/default'),
149  'right' => self::RIGHT_ACCESS_USERS,
150  ),
151  ),
152  'globalSearchAttributeNames' => array(
153  'fullName',
154  'anyEmail',
155  'username',
156  ),
157  'configureMenuItems' => array(
158  array(
159  'category' => ZurmoModule::ADMINISTRATION_CATEGORY_GENERAL,
160  'titleLabel' => "eval:Zurmo::t('UsersModule', 'Users')",
161  'descriptionLabel' => "eval:Zurmo::t('UsersModule', 'Manage Users')",
162  'route' => '/users/default',
163  'right' => self::RIGHT_ACCESS_USERS,
164  ),
165  ),
166  'headerMenuItems' => array(
167  array(
168  'label' => "eval:Zurmo::t('UsersModule', 'Users')",
169  'url' => array('/users/default'),
170  'right' => self::RIGHT_ACCESS_USERS,
171  'order' => 4,
172  'mobile' => false,
173  ),
174  ),
175  'userHeaderMenuItems' => array(
176  array(
177  'label' => "eval:Zurmo::t('UsersModule', 'My Profile')",
178  'url' => array('/users/default/profile'),
179  'order' => 10,
180  ),
181  array(
182  'label' => "eval:Zurmo::t('UsersModule', 'Sign out')",
183  'url' => array('/zurmo/default/logout'),
184  'order' => 40,
185  ),
186  ),
187  'designerMenuItems' => array(
188  'showFieldsLink' => false,
189  'showGeneralLink' => false,
190  'showLayoutsLink' => true,
191  'showMenusLink' => false,
192  ),
193  );
194  return $metadata;
195  }
196 
197  public static function getPrimaryModelName()
198  {
199  return 'User';
200  }
201 
202  public static function getAccessRight()
203  {
204  return self::RIGHT_ACCESS_USERS;
205  }
206 
207  public static function getCreateRight()
208  {
209  return self::RIGHT_CREATE_USERS;
210  }
211 
212  public static function stringifyAuditEvent(AuditEvent $auditEvent, $format = 'long')
213  {
214  assert('$format == "long" || $format == "short"');
215  $s = null;
216  switch ($auditEvent->eventName)
217  {
218  case self::AUDIT_EVENT_USER_PASSWORD_CHANGED:
219  if ($format == 'short')
220  {
221  return $auditEvent->eventName;
222  }
223  $s .= strval($auditEvent);
224  $username = unserialize($auditEvent->serializedData);
225  try
226  {
227  if ($auditEvent->modelClassName == 'User')
228  {
229  $user = User::getById((int)$auditEvent->modelId);
230  $s .= ", $user";
231  }
232  else
233  {
234  throw new NotSupporteException();
235  }
236  }
237  catch (NotFoundException $e)
238  {
239  $s .= ", $username";
240  }
241  break;
242  }
243  return $s;
244  }
245 
246  public static function getDemoDataMakerClassNames()
247  {
248  return array('UsersDemoDataMaker');
249  }
250 
256  public static function getGlobalSearchFormClassName()
257  {
258  return 'UsersSearchForm';
259  }
260 
261  public static function modelsAreNeverGloballySearched()
262  {
263  return true;
264  }
265 
266  protected static function getSingularModuleLabel($language)
267  {
268  return Zurmo::t('UsersModule', 'User', array(), null, $language);
269  }
270 
271  protected static function getPluralModuleLabel($language)
272  {
273  return Zurmo::t('UsersModule', 'Users', array(), null, $language);
274  }
275  }
276 ?>
static getGlobalSearchFormClassName()
static getById($id, $modelClassName=null)
Generated on Mon Sep 28 2020 07:10:34
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.