public function getData()
 {
     $data = parent::getData();
     if ($this->model instanceof SecurableItem) {
         $element = new DerivedExplicitReadWriteModelPermissionsElement($this->model, null, null);
         $permissions = $element->resolveModelPermissionsArray();
         $data = CMap::mergeArray($permissions, $data);
     }
     return $data;
 }
 protected function renderRightSideFormLayoutForEdit($form)
 {
     assert('$form instanceof ZurmoActiveForm');
     $content = parent::renderRightSideFormLayoutForEdit($form);
     $content .= "<h3>" . Zurmo::t('ZurmoModule', 'Rights and Permissions') . '</h3><div id="owner-box">';
     $element = new UserElement($this->getModel(), 'owner', $form);
     $element->editableTemplate = '{label}{content}{error}';
     $content .= $element->render() . '</div>';
     $element = new DerivedExplicitReadWriteModelPermissionsElement($this->getModel(), 'null', $form);
     $element->editableTemplate = '{label}{content}{error}';
     $content .= $element->render();
     return $content;
 }
 public static function resolveUserDefaultPermissionsByUser(User $user, RedBeanModel $model = null)
 {
     $defaultPermissionSettings = UserConfigurationFormAdapter::resolveAndGetDefaultPermissionSetting($user);
     $nonEveryoneGroup = UserConfigurationFormAdapter::resolveAndGetValue($user, 'defaultPermissionGroupSetting', false);
     $type = DerivedExplicitReadWriteModelPermissionsElement::resolveUserPermissionConfigurationToPermissionType($defaultPermissionSettings);
     $explicitReadWriteModelPermissions = compact('type', 'nonEveryoneGroup');
     $permissions = compact('explicitReadWriteModelPermissions');
     if ($model === null || $model instanceof OwnedSecurableItem) {
         $owner = array('id' => $user->id);
         $permissions = compact('owner', 'explicitReadWriteModelPermissions');
     }
     return $permissions;
 }
 public static function setContactModelPermissionsByContactWebForm(SecurableItem $model, ContactWebForm $contactWebForm)
 {
     if ($model instanceof SecurableItem && count($model->permissions) === 0) {
         $defaultPermission = ContactWebFormAdapter::resolveAndGetDefaultPermissionSetting($contactWebForm);
         $nonEveryoneGroup = $contactWebForm->defaultPermissionGroupSetting;
         $type = DerivedExplicitReadWriteModelPermissionsElement::resolveUserPermissionConfigurationToPermissionType($defaultPermission);
         $postData = array('explicitReadWriteModelPermissions' => compact('type', 'nonEveryoneGroup'));
         $explicitReadWritePermissions = self::resolveAndMakeExplicitReadWriteModelPermissions($postData, $model);
         $updated = ExplicitReadWriteModelPermissionsUtil::resolveExplicitReadWriteModelPermissions($model, $explicitReadWritePermissions);
         if (!$updated) {
             throw new NotSupportedException();
         }
     }
 }
 /**
  * @param int $selectedType
  * @return mixed
  */
 public static function resolveUserPermissionConfigurationToPermissionType($selectedType)
 {
     return DerivedExplicitReadWriteModelPermissionsElement::resolveUserPermissionConfigurationToPermissionType($selectedType);
 }