/** * Renders the rich text editor. * @param string $name * @param string $value */ function Render($name, $value = '') { $baseUrl = $this->baseUrl; $grantResult = $this->guard->Grant(Action::UseIt(), $this); $disabled = (string) $grantResult != (string) GrantResult::Allowed(); $_SESSION['KCFINDER']['disabled'] = $disabled; $_SESSION['KCFINDER']['uploadURL'] = $this->uploadUrl; $_SESSION['KCFINDER']['uploadDir'] = $this->uploadDir; $oCKeditor = new \CKEditor(); $oCKeditor->basePath = IO\Path::Combine($baseUrl, 'ckeditor/'); $oCKeditor->config['skin'] = 'v2'; $oCKeditor->config['filebrowserBrowseUrl'] = IO\Path::Combine($baseUrl, 'kcfinder/browse.php?type=files'); $oCKeditor->config['filebrowserImageBrowseUrl'] = IO\Path::Combine($baseUrl, 'kcfinder/browse.php?type=images'); $oCKeditor->config['filebrowserFlashBrowseUrl'] = IO\Path::Combine($baseUrl, 'kcfinder/browse.php?type=flash'); $oCKeditor->config['filebrowserUploadUrl'] = IO\Path::Combine($baseUrl, 'kcfinder/upload.php?type=files'); $oCKeditor->config['filebrowserImageUploadUrl'] = IO\Path::Combine($baseUrl, 'kcfinder/upload.php?type=images'); $oCKeditor->config['filebrowserFlashUploadUrl'] = IO\Path::Combine($baseUrl, 'kcfinder/upload.php?type=flash'); foreach ($this->config as $key => $val) { $oCKeditor->config[$key] = $val; } ob_start(); echo '<div class="phine-cke">'; $oCKeditor->editor($name, $value); echo '</div>'; return ob_get_clean(); }
/** * Helper function checking if param $action is in $grantedActions * @param AccessBase\Action $action * @param array $grantedActions Array of actions that shall be granted * @return GrantResult Allowed if $action is in $grantedActions, NoAccess otherwise */ protected function GrantActions(Action $action, array $grantedActions) { foreach ($grantedActions as $grantedAction) { if ((string) $action == (string) $grantedAction) { return GrantResult::Allowed(); } } return GrantResult::NoAccess(); }
private function GrantOnUser(BackendAction $action, User $user) { $allowed = false; switch ($action) { case BackendAction::Delete(): case BackendAction::ChangeIsAdmin(): $allowed = $this->IsAdministrator() && !$this->GetUser()->Equals($user); break; case BackendAction::AssignGroups(): $allowed = $this->IsAdministrator() && !$user->GetIsAdmin(); break; case BackendAction::Edit(): case BackendAction::Read(): $allowed = $this->IsAdministrator() || $this->GetUser()->Equals($user); break; case BackendAction::Create(): $allowed = $this->IsAdministrator(); break; } return $allowed ? GrantResult::Allowed() : GrantResult::NoAccess(); }
/** * Checks access to an item by its properties and assigned groups * @param boolean $guestsOnly True if guests only see the item * @param boolean $publish True if item is generally published * @param Date $from The start date of publishing * @param Date $to The end date of publishing * @param Membergroup[] $groups Groups assigned to the item * @return GrantResult */ private function GrantByProperties($guestsOnly, $publish, Date $from = null, Date $to = null, array $groups = array()) { if (!PublishDateUtil::IsPublishedNow($publish, $from, $to)) { return GrantResult::NoAccess(); } if ($this->GetMember() && $guestsOnly) { return GrantResult::NoAccess(); } if (count($groups) == 0) { return GrantResult::Allowed(); } if (!$this->GetMember()) { return GrantResult::LoginRequired(); } $groupIDs = Membergroup::GetKeyList($groups); $memberGroupIDs = Membergroup::GetKeyList($this->Groups()); return count(array_intersect($groupIDs, $memberGroupIDs)) ? GrantResult::Allowed() : GrantResult::NoAccess(); }