/** * Insert articles in comparision chart * @param int $articleId s_articles.id * @throws Enlight_Exception * @return bool true/false */ public function sAddComparison($articleId) { $articleId = (int) $articleId; if (!$articleId) { return null; } // Check if this article is already noted $checkForArticle = $this->db->fetchRow("SELECT id FROM s_order_comparisons WHERE sessionID=? AND articleID=?", [$this->session->offsetGet('sessionId'), $articleId]); // Check if max. numbers of articles for one comparison-session is reached $checkNumberArticles = $this->db->fetchRow("SELECT COUNT(id) AS countArticles FROM s_order_comparisons WHERE sessionID=?", [$this->session->offsetGet('sessionId')]); if ($checkNumberArticles["countArticles"] >= $this->config->offsetGet("sMAXCOMPARISONS")) { return "max_reached"; } if (!$checkForArticle["id"]) { $articleName = $this->db->fetchOne("SELECT s_articles.name AS articleName FROM s_articles WHERE id = ?", [$articleId]); if (!$articleName) { return false; } $sql = "\n INSERT INTO s_order_comparisons (sessionID, userID, articlename, articleID, datum)\n VALUES (?,?,?,?,now())\n "; $queryNewPrice = $this->db->executeUpdate($sql, [$this->session->offsetGet('sessionId'), empty($this->session["sUserId"]) ? 0 : $this->session["sUserId"], $articleName, $articleId]); if (!$queryNewPrice) { throw new Enlight_Exception("sArticles##sAddComparison##01: Error in SQL-query"); } } return true; }
/** * Set payment status by order id * * @param int $orderId * @param int $orderStatusId * @param bool $sendStatusMail * @param string|null $comment */ public function setOrderStatus($orderId, $orderStatusId, $sendStatusMail = false, $comment = null) { $previousStatusId = $this->getOrderStatus($orderId); if ($orderStatusId == $previousStatusId) { return; } $this->db->executeUpdate('UPDATE s_order SET status = :status WHERE id = :orderId;', array(':status' => $orderStatusId, ':orderId' => $orderId)); $sql = ' INSERT INTO s_order_history ( orderID, userID, previous_order_status_id, order_status_id, previous_payment_status_id, payment_status_id, comment, change_date ) SELECT id, NULL, :previousStatus, :currentStatus, cleared, cleared, :comment, NOW() FROM s_order WHERE id = :orderId '; $this->db->executeUpdate($sql, array(':previousStatus' => $previousStatusId, ':currentStatus' => $orderStatusId, ':comment' => $comment, ':orderId' => $orderId)); if ($sendStatusMail) { $mail = $this->createStatusMail($orderId, $orderStatusId); if ($mail) { $this->sendStatusMail($mail); } } }
/** * Save a new article comment / voting * Reads several values directly from _POST * @param int $article - s_articles.id * @throws Enlight_Exception * @return null */ public function sSaveComment($article) { $request = $this->frontController->Request(); $sVoteName = strip_tags($request->getPost('sVoteName')); $sVoteSummary = strip_tags($request->getPost('sVoteSummary')); $sVoteComment = strip_tags($request->getPost('sVoteComment')); $sVoteStars = doubleval($request->getPost('sVoteStars')); $sVoteMail = strip_tags($request->getPost('sVoteMail')); if ($sVoteStars < 1 || $sVoteStars > 10) { $sVoteStars = 0; } $sVoteStars = $sVoteStars / 2; if ($this->config['sVOTEUNLOCK']) { $active = 0; } else { $active = 1; } $sBADWORDS = "#sex|p**n|viagra|url\\=|src\\=|link\\=#i"; if (preg_match($sBADWORDS, $sVoteComment)) { return false; } if (!empty($this->session['sArticleCommentInserts'][$article])) { $sql = ' DELETE FROM s_articles_vote WHERE id=? '; $this->db->executeUpdate($sql, array($this->session['sArticleCommentInserts'][$article])); } $date = date("Y-m-d H:i:s"); $sql = ' INSERT INTO s_articles_vote (articleID, name, headline, comment, points, datum, active, email) VALUES (?, ?, ?, ?, ?, ?, ?, ?) '; $insertComment = $this->db->executeUpdate($sql, array($article, $sVoteName, $sVoteSummary, $sVoteComment, $sVoteStars, $date, $active, $sVoteMail)); if (empty($insertComment)) { throw new Enlight_Exception("sSaveComment #00: Could not save comment"); } $insertId = $this->db->lastInsertId(); if (!isset($this->session['sArticleCommentInserts'])) { $this->session['sArticleCommentInserts'] = new ArrayObject(); } $this->session['sArticleCommentInserts'][$article] = $insertId; }