Beispiel #1
0
 public function renderArticle($url)
 {
     if (!\App\Helper\Helper::isIndexBot()) {
         $this->articleManager->viewForArticleUrl($url, $this->getSession());
     }
     $this->template->serial = $this->articleDat->ref('underSerial');
     if ($this->template->serial) {
         $this->template->articleInSerial = $this->articleManager->getArticlesUnderSerial($this->template->serial->articleOrder);
     }
     $this->template->article = $this->articleDat;
 }
Beispiel #2
0
 public function addComment($values, $sub = false)
 {
     $data = ['byUser' => $this->userId, 'unregName' => isset($values->unregname) ? $values->unregname : null, 'date' => Helper::datTime(), 'text' => $this->fixComment($values->text), 'deleted' => 0];
     if ($sub !== false) {
         $data['forComment'] = $sub;
     } else {
         $data['forId'] = $this->forId;
         $data['forWhat'] = $this->forWhat;
     }
     return $this->commentDat($sub)->insert($data);
 }
Beispiel #3
0
 public function handleRate($points)
 {
     if (!$points || !is_numeric($points) || $points > $this->points || $points < $this->from) {
         throw new Nette\Application\BadRequestException();
     }
     if (\App\Helper\Helper::isIndexBot()) {
         return;
     }
     if ($this->ratingManager->addVote($points)) {
         $this->redrawAjax('Hodnocení přidáno');
     }
 }
Beispiel #4
0
 public function actionModerate($id = '')
 {
     $moderate = $this->user->isAllowed(self::RES, 'moderate');
     if (empty($id)) {
         throw new \Nette\Application\BadRequestException();
     }
     if (!$moderate) {
         $this->goHome();
     }
     $user = $this->userManager->getUserData($id);
     if (!$user) {
         $this->goHome('Neexistující uživatel');
     }
     $this->userMod = $user;
     $this->template->combinatedName = \App\Helper\Helper::combineUserName($user);
 }
Beispiel #5
0
 /**
  * Change mail is not succesful
  * @param \Nette\Security\IIdentity $user
  */
 public function changeMailFail(\Nette\Security\IIdentity $user)
 {
     $user->mail = $user->oldMail;
     $name = Helper::combineUserName($user, false);
     $checkCode = $this->genCheckCode('checkCode');
     (new SendMailManager())->sendNewMailCode($user->mail, $name, $checkCode, false);
     $this->updateUserDat($user->id, ['checkCode' => $checkCode, 'mail' => $user->oldMail]);
 }
Beispiel #6
0
 public function updateArticle($values)
 {
     $data = ['url' => $this->checkUnique($values->title, 'articleDat', $values->id), 'title' => $values->title, 'text' => $values->text, 'keyWords' => $values->keyWords, 'underSection' => $values->underSection === 0 ? null : $values->underSection, 'underSubSection' => $values->underSubSection === 0 ? null : $values->underSubSection, 'underSerial' => $values->underSerial === 0 ? null : $values->underSerial, 'lastChange' => Helper::datTime(), 'commentsAllow' => $values->commentsAllow, 'voteAllow' => $values->voteAllow, 'description' => $values->description];
     if (!empty($values->byUser) && empty($values->byUnregUser)) {
         $data['byUser'] = $values->byUser;
         $data['byUnregUser'] = null;
     }
     if (!empty($values->byUnregUser)) {
         $data['byUnregUser'] = $values->byUnregUser;
         $data['byUser'] = null;
     }
     if (isset($values->published)) {
         $data['published'] = $values->published;
     }
     if (isset($values->deleted)) {
         $data['deleted'] = $values->deleted;
     }
     if ($values->photo->isOK()) {
         $photo = $this->genName($values->photo, $values->title);
         $this->savePhoto($photo);
         $data['photo'] = $photo['name'];
     }
     $this->articleDat()->where('id', $values->id)->update($data);
     if ($values->underSerial && $values->underSerial != $values->oldSerial) {
         if ($values->oldSerial) {
             $oldAO = $this->serialDat()->where('id', $values->oldSerial)->fetch()->articleOrder;
             $this->serialDat()->where('id', $values->oldSerial)->update(['articleOrder' => $this->delArticleFromSerial($values->id, $oldAO)]);
         }
         $newAO = $this->serialDat()->where('id', $values->underSerial)->fetch()->articleOrder;
         $this->serialDat()->where('id', $values->underSerial)->update(['articleOrder' => $this->addArticleToSerial($values->id, $newAO)]);
     }
 }
Beispiel #7
0
 /**
  * Add to database
  * @param array $values
  * @param int $userId
  */
 public function addNews($values, $userId)
 {
     $this->newsDat()->insert(['byUser' => $userId, 'url' => $this->checkUnique($values->title), 'title' => $values->title, 'text' => $values->text, 'keyWords' => $values->keyWords ? $values->keyWords : '', 'date' => \App\Helper\Helper::datTime()]);
 }
Beispiel #8
0
 /**
  * Logout user
  */
 public function actionOut($request = '')
 {
     $this->notLoggedUser();
     $this->user->logout();
     $this->goHome(Helper::combineUserName($this->user->getIdentity()->data) . ' úspěšně odhlášen', 'Homepage:default', [], 'success', $request ? $request : false);
 }