Beispiel #1
0
 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;
 }
Beispiel #2
0
 public function __construct($userId)
 {
     parent::__construct();
     UHEADER_CLASS_Plugin::getInstance()->includeStatic();
     $this->userId = $userId;
     $this->service = UHEADER_BOL_Service::getInstance();
     $this->cover = $this->service->findCoverByUserId($this->userId, UHEADER_BOL_Cover::STATUS_ACTIVE);
     if ($this->cover === null) {
         $removedCover = $this->service->findCoverByUserId($this->userId, UHEADER_BOL_Cover::STATUS_REMOVED);
         if ($removedCover === null) {
             $template = $this->service->findDefaultTemplateForUser($userId);
             if ($template !== null) {
                 $this->cover = $template->createCover($this->userId);
                 $this->templateId = $template->id;
                 $this->defaultTemplateMode = true;
             }
         }
     } else {
         $this->hasCover = true;
     }
     $this->defaultTemplatesCount = $this->service->findTemplatesCountForUser($this->userId, true);
 }
Beispiel #3
0
 public function switchToDefaultTemplates($coverData)
 {
     $userId = (int) $coverData['userId'];
     $this->service->deleteAllUserCovers($userId);
     $template = $this->service->findDefaultTemplateForUser($userId);
     $data = array('position' => array('top' => 0, 'left' => 0));
     $src = null;
     $ratio = null;
     $templateId = null;
     if ($template !== null) {
         $data = $template->getSettings();
         $src = $template->getSrc();
         $ratio = $template->getRatio();
         $templateId = $template->id;
     }
     $message = OW::getLanguage()->text('uheader', 'cover_restore_success');
     return array('message' => $message, 'src' => $src, 'data' => $data, "defaultTemplateMode" => $templateId !== null, "templateId" => $templateId, 'ratio' => $ratio);
 }