function add() { $title = WebApp::post('title') === NULL ? '' : WebApp::post('title'); $p_from = WebApp::post('p_from') === '' ? NULL : getSQLDate(WebApp::post('p_from')); $p_to = WebApp::post('p_to') === '' ? NULL : getSQLDate(WebApp::post('p_to')); $article = WebApp::post('article') === NULL ? '' : WebApp::post('article'); $user = $this->parent->parent->user->getUserID(); $group = $this->parent->parent->user->getGroup(); $aid = removeSpecialChars($title); $article_add = $this->mySQL_w->prepare("INSERT INTO `news_articles` (`title`,`aid`,`user`,`group`,`article`,`date_p`,`publish_f`,`publish_u`) VALUES(?,?,?,?,?,NOW(),?,?)"); if ($article_add == false) { return new ActionResult($this, '/admin/news/article_add', 0, 'Failed to save article.<br />Error: <code>Query failed</code>', B_T_FAIL); } $article_add->bind_param('ssiisss', $title, $aid, $user, $group, $article, $p_from, $p_to); $article_add->execute(); $article_add->store_result(); if ($article_add->affected_rows == 1) { $this->parent->parent->logEvent($this::name_space, 'Added article ' . $title); return new ActionResult($this, '/admin/news/article_view', 1, 'Successfully saved article!', B_T_SUCCESS); } else { $this->parent->parent->logEvent($this::name_space, 'Failed to add article ' . $title); return new ActionResult($this, '/admin/news/article_add', 0, 'Failed to add article.<br />Error: <code>' . $this->mySQL_w->error . '</code>', B_T_FAIL); } }
function add_created_modified_dates() { if (isset($this->date_entered_only)) { $mysql_date_str = getSQLDate($this->date_entered_only); if (!empty($mysql_date_str)) { if (isset($this->time_entered_only)) { $this->date_entered = $mysql_date_str . " " . $this->time_entered_only; } else { $this->date_entered = $mysql_date_str . " 00:00:00"; } } } if (isset($this->date_modified_only)) { $mysql_date_str = getSQLDate($this->date_modified_only); if (!empty($mysql_date_str)) { if (isset($this->time_modified_only)) { $this->date_modified = $mysql_date_str . " " . $this->time_modified_only; } else { $this->date_modified = $mysql_date_str . " 00:00:00"; } } } if (!isset($this->date_modified) && isset($this->date_entered)) { $this->date_modified = $this->date_entered; } else { if (!isset($this->date_entered) && isset($this->date_modified)) { $this->date_entered = $this->date_modified; } } }
function getRedeemDates($params, $prefix) { $dateSQL = ""; if (Trim($params["FromDate"]) != "") { $NewFromDate = getSQLDate($params["FromDate"]) . ' 00:00:00'; $dateSQL .= " AND " . $prefix . "date >= '" . $NewFromDate . "' "; if (Trim($params["ToDate"]) != "") { $NewEndDate = getSQLDate($params["ToDate"]) . ' 23:59:59'; $dateSQL .= " AND " . $prefix . "date <= '" . $NewEndDate . "' "; } } return $dateSQL; }