/** * Returns class instance * * @return UHEADER_CLASS_PrivacyBridge */ public static function getInstance() { if (!isset(self::$classInstance)) { self::$classInstance = new self(); } return self::$classInstance; }
public function findCoverDtoByUserId($userId) { if (!$this->isActive()) { return null; } $permited = UHEADER_CLASS_PrivacyBridge::getInstance()->checkPrivacy($userId); if (!$permited) { return null; } return UHEADER_BOL_Service::getInstance()->findCoverByUserId($userId); }
public function getCover(OW_Event $event) { $params = $event->getParams(); $userId = $params["userId"]; $forWidth = empty($params["forWidth"]) ? null : $params["forWidth"]; $permited = UHEADER_CLASS_PrivacyBridge::getInstance()->checkPrivacy($userId); if (!$permited) { return null; } $cover = $this->service->findCoverByUserId($userId, UHEADER_BOL_Cover::STATUS_ACTIVE); if ($cover === null) { $cover = $this->service->findDefaultTemplateForUser($userId); } if ($cover === null) { return null; } $out = array("userId" => $userId, "src" => $cover->getSrc(), "data" => $cover->getSettings(), "canvas" => $cover->getCanvas($forWidth), "css" => $cover->getCss(), "cssString" => $cover->getCssString()); $event->setData($out); return $out; }
public function getPemissions() { $permissions = array("choose" => false, "stick" => false, 'add' => false, 'reposition' => false, 'restore' => false, 'delete' => false, 'view' => false, 'changeAvatar' => false, 'moderation' => false); $selfMode = $this->userId == OW::getUser()->getId(); $moderationMode = OW::getUser()->isAuthorized('uheader'); $choose = UHEADER_CLASS_PhotoBridge::getInstance()->isActive() || $this->service->findTemplatesCountForUser($this->userId) > 0; $permissions['changeAvatar'] = $selfMode; if ($selfMode || $moderationMode) { $permissions['delete'] = true; $permissions['view'] = true; $permissions["restore"] = true; } if ($selfMode && OW::getUser()->isAuthorized('uheader', 'add_cover')) { $permissions['reposition'] = true; $permissions['add'] = true; $permissions['choose'] = $choose; $permissions['stick'] = $this->defaultTemplatesCount > 1; } if (!$permissions['view'] && OW::getUser()->isAuthorized('uheader', 'view_cover')) { $permissions['view'] = UHEADER_CLASS_PrivacyBridge::getInstance()->checkPrivacy($this->userId); } if ($this->hasCover) { $permissions['controls'] = ($permissions['add'] || $permissions['reposition'] || $permissions['delete'] || $permissions['restore'] || $permissions['choose']) && $permissions['view']; } else { $permissions['controls'] = ($permissions['add'] || $permissions['choose'] || $permissions["stick"]) && $permissions['view']; } $permissions['moderation'] = !$selfMode && $moderationMode; return $permissions; }
<?php /** * Copyright (c) 2012, Sergey Kambalin * All rights reserved. * ATTENTION: This commercial software is intended for use with Oxwall Free Community Software http://www.oxwall.org/ * and is licensed under Oxwall Store Commercial License. * Full text of this license can be found at http://www.oxwall.org/store/oscl */ $plugin = OW::getPluginManager()->getPlugin('uheader'); //Routs $router = OW::getRouter(); $router->addRoute(new OW_Route('uheader-settings-page', 'admin/plugins/profile-cover', 'UHEADER_CTRL_Admin', 'index')); $router->addRoute(new OW_Route('uheader-settings-gallery', 'admin/plugins/profile-cover/gallery', 'UHEADER_CTRL_Templates', 'index')); $router->addRoute(new OW_Route('uheader-settings-gallery-item', 'admin/plugins/profile-cover/gallery/:tplId', 'UHEADER_CTRL_Templates', 'index')); // Bridges UHEADER_CLASS_PhotoBridge::getInstance()->init(); UHEADER_CLASS_NewsfeedBridge::getInstance()->init(); UHEADER_CLASS_PrivacyBridge::getInstance()->init(); UHEADER_CLASS_NotificationsBridge::getInstance()->init(); UHEADER_CLASS_CommentsBridge::getInstance()->init(); UHEADER_CLASS_CreditsBridge::getInstance()->init(); UHEADER_CLASS_UavatarsBridge::getInstance()->init(); UHEADER_CLASS_BaseBridge::getInstance()->init(); //Event handler UHEADER_CLASS_EventHandler::getInstance()->init();