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(); } } }
public function actionEdit($id) { $contactWebForm = static::getModelAndCatchNotFoundAndDisplayError('ContactWebForm', intval($id)); ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($contactWebForm); $modelClassName = $this->getModule()->getPrimaryModelName(); $breadCrumbTitle = Zurmo::t('ContactWebFormsModule', 'Edit Web Form'); $breadCrumbLinks = array($breadCrumbTitle); $contactWebForm->defaultPermissionSetting = ContactWebFormAdapter::resolveAndGetDefaultPermissionSetting($contactWebForm); if ($contactWebForm->language === null) { $contactWebForm->language = Yii::app()->language; } if (isset($_POST[$modelClassName])) { unset($_POST[$modelClassName]['serializedData']); foreach ($_POST['ContactWebFormAttributeForm'] as $attributeName => $attributeData) { if (isset($attributeData['hiddenValue']) && !empty($attributeData['hiddenValue'])) { $_POST['ContactWebFormAttributeForm'][$attributeName]['hiddenValue'] = ContactWebFormsUtil::sanitizeHiddenAttributeValue($attributeName, $attributeData['hiddenValue']); } } $contactWebForm->serializedData = serialize($_POST['ContactWebFormAttributeForm']); if (isset($_POST[$modelClassName]['defaultPermissionGroupSetting'])) { $contactWebForm = ContactWebFormAdapter::setDefaultPermissionGroupSetting($contactWebForm, (int) $_POST[$modelClassName]['defaultPermissionSetting'], (int) $_POST[$modelClassName]['defaultPermissionGroupSetting']); unset($_POST[$modelClassName]['defaultPermissionGroupSetting']); } } $titleBarAndEditView = $this->makeEditAndDetailsView($this->attemptToSaveModelFromPost($contactWebForm), 'Edit'); $view = new ContactWebFormsPageView(ZurmoDefaultAdminViewUtil::makeViewWithBreadcrumbsForCurrentUser($this, $titleBarAndEditView, $breadCrumbLinks, 'ContactWebFormsBreadCrumbView')); echo $view->render(); }
/** * Based on the model's attribute value being a explicitReadWriteModelPermissions object, * resolves the selected type value. * @return string */ protected function resolveSelectedType() { return ContactWebFormAdapter::resolveAndGetDefaultPermissionSetting($this->model); }