/** * For now, this determines if there is a subclass of * ModelElement and makes the appropriate adjustments * based on the user's access to this element and its * related attributes. This is for the NonEditable render. * @return null. Modifies $elementInformation by reference. */ public static function resolveElementForNonEditableRender($model, &$elementInformation, $user) { assert('$model instanceof RedBeanModel || $model instanceof CModel'); assert('is_array($elementInformation)'); assert('$user instanceof User && $user->id > 0'); $elementclassname = $elementInformation['type'] . 'Element'; $attributeName = $elementInformation['attributeName']; if (is_subclass_of($elementclassname, 'ModelElement')) { $moduleId = $elementclassname::getModuleId(); $moduleClassName = get_class(Yii::app()->getModule($moduleId)); assert('is_string($moduleClassName)'); $userCanAccess = RightsUtil::canUserAccessModule($moduleClassName, $user); $userCanReadItem = ActionSecurityUtil::canUserPerformAction($elementclassname::getNonEditableActionType(), $model->{$attributeName}, $user); if ($userCanAccess && $userCanReadItem) { return; } elseif (!$userCanAccess && $userCanReadItem) { if ($model->{$attributeName}->id < 0) { $elementInformation['attributeName'] = null; $elementInformation['type'] = 'Null'; // Not Coding Standard } else { $elementInformation['noLink'] = true; } } else { $elementInformation['attributeName'] = null; $elementInformation['type'] = 'Null'; // Not Coding Standard } } elseif (is_subclass_of($elementclassname, 'ExplicitReadWriteModelPermissionsElement')) { if (ActionSecurityUtil::canUserPerformAction('Edit', $model, $user)) { return; } else { $elementInformation['type'] = 'Null'; // Not Coding Standard } } }
protected static function resolveAccountContentByUser(Account $account, User $user) { $userCanAccess = RightsUtil::canUserAccessModule('AccountsModule', $user); $userCanReadItem = ActionSecurityUtil::canUserPerformAction('Details', $account, $user); if ($userCanAccess && $userCanReadItem) { return ZurmoHtml::link(Yii::app()->format->text($account), Yii::app()->createUrl('accounts/default/details/', array('id' => $account->id))); } elseif (!$userCanAccess && $userCanReadItem) { return strval($account); } else { return; } }