$list = new ae_CategoryList($filter); } else { if (isset($_GET['page'])) { $area = 'page'; $areaName = 'Pages'; if (ae_PageModel::isValidStatus($status)) { $filter['WHERE'] = 'pa_status = "' . $status . '"'; } else { $filter['WHERE'] = 'pa_status != "trash"'; } $list = new ae_PageList($filter); } else { if (isset($_GET['post'])) { $area = 'post'; $areaName = 'Posts'; if (ae_PostModel::isValidStatus($status)) { $filter['WHERE'] = 'po_status = "' . $status . '"'; } else { $filter['WHERE'] = 'po_status != "trash"'; } $list = new ae_PostList($filter); } else { if (isset($_GET['user'])) { $area = 'user'; $areaName = 'Users'; if (ae_UserModel::isValidStatus($status)) { $filter['WHERE'] = 'u_status = "' . $status . '"'; } $list = new ae_UserList($filter); } else { $area = 'comment';
public function testSetUserId() { $p = new ae_PostModel(); $p->setUserId(4); $this->assertTrue($p->getUserId() === 4); $this->setExpectedException('Exception'); $p->setUserId(-1); }
$modelName = 'ae_CommentModel'; $preDelete = ae_CommentModel::STATUS_TRASH; break; case 'media': $isValidStatus = $status == 'delete' ? TRUE : ae_MediaModel::isValidStatus($status); $mainArea = 'media'; $modelName = 'ae_MediaModel'; $preDelete = ae_MediaModel::STATUS_TRASH; break; case 'page': $isValidStatus = $status == 'delete' ? TRUE : ae_PageModel::isValidStatus($status); $modelName = 'ae_PageModel'; $preDelete = ae_PageModel::STATUS_TRASH; break; case 'post': $isValidStatus = $status == 'delete' ? TRUE : ae_PostModel::isValidStatus($status); $modelName = 'ae_PostModel'; $preDelete = ae_PostModel::STATUS_TRASH; break; case 'user': $isValidStatus = $status == 'delete' ? TRUE : ae_UserModel::isValidStatus($status); $modelName = 'ae_UserModel'; $preDelete = ae_UserModel::STATUS_SUSPENDED; break; default: $isValidStatus = FALSE; } $table = constant($modelName . '::TABLE'); $idField = constant($modelName . '::TABLE_ID_FIELD'); if (!$isValidStatus) { header('Location: ../admin.php?error=invalid_status');
$statuses = ae_CategoryModel::listStatuses(); } else { if ($area == 'cofilter') { $statuses = ae_CommentfilterModel::listStatuses(); } else { if ($area == 'comment') { $statuses = ae_CommentModel::listStatuses(); } else { if ($area == 'media') { $statuses = ae_MediaModel::listStatuses(); } else { if ($area == 'page') { $statuses = ae_PageModel::listStatuses(); } else { if ($area == 'post') { $statuses = ae_PostModel::listStatuses(); } else { if ($area == 'user') { $statuses = ae_UserModel::listStatuses(); } } } } } } } $select = ae_Forms::selectStatus('bulk-status-change', $statuses); if (isset($_GET['status']) && $_GET['status'] == 'trash') { $select = str_replace('trash', 'delete', $select); } else { if (isset($_GET['status']) && $_GET['status'] == 'inactive' && $area == 'cofilter') {
/** * Load the post model to the permalink. * @return {ae_PostModel} The loaded post model. */ public static function getPostModel() { if (!self::isPost()) { $msg = sprintf('[%s] Permalink does not represent a post.', get_class()); throw new Exception($msg); } $model = new ae_PostModel(); if (isset($_GET[PERMALINK_GET_POST]) && ae_Validate::id($_GET[PERMALINK_GET_POST])) { if (!$model->load($_GET[PERMALINK_GET_POST])) { return FALSE; } } else { $permalink = mb_substr(self::$url, 1); $permalink = preg_replace(';^' . PERMALINK_BASE_POST . ';i', '', $permalink); if (!$model->loadFromPermalink($permalink)) { return FALSE; } } return $model; }
if (isset($_GET['media']) && ae_Validate::id($_GET['media'])) { $editArea = 'Media'; $areaId = 'media'; $model = new ae_MediaModel(); $model->load($_GET['media']); } else { if (isset($_GET['page']) && ae_Validate::id($_GET['page'])) { $editArea = 'Page'; $areaId = 'page'; $model = new ae_PageModel(); $model->load($_GET['page']); } else { if (isset($_GET['post']) && ae_Validate::id($_GET['post'])) { $editArea = 'Post'; $areaId = 'post'; $model = new ae_PostModel(); $model->load($_GET['post']); $model->loadCategoryIds(); } else { if (isset($_GET['user']) && ae_Validate::id($_GET['user'])) { $editArea = 'User'; $areaId = 'user'; $model = new ae_UserModel(); $model->load($_GET['user']); } else { header('Location: admin.php?error=unknown_edit_area'); exit; } } } }
/** * Create the post. * @return {int} ID of the new post. */ function createPost() { if (!isset($_POST['post-title'], $_POST['post-permalink'], $_POST['post-content'], $_POST['post-tags'], $_POST['post-publish-month'], $_POST['post-publish-day'], $_POST['post-publish-year'], $_POST['post-publish-hour'], $_POST['post-publish-minute'], $_POST['submit'])) { header('Location: ../admin.php?error=missing_data_for_post'); exit; } $datetime = sprintf('%04d-%02d-%02d %02d:%02d:00', $_POST['post-publish-year'], $_POST['post-publish-month'], $_POST['post-publish-day'], $_POST['post-publish-hour'], $_POST['post-publish-minute']); $permalink = trim($_POST['post-permalink']); $status = $_POST['submit'] == 'draft' ? ae_PostModel::STATUS_DRAFT : ae_PostModel::STATUS_PUBLISHED; $post = new ae_PostModel(); if (isset($_POST['edit-id'])) { $post->setId($_POST['edit-id']); } $post->setTitle($_POST['post-title']); if ($permalink != '') { $post->setPermalink($permalink); } $post->setContent($_POST['post-content']); $post->setDatetime(isset($_POST['post-schedule']) ? $datetime : date('Y-m-d H:i:s')); $post->setCommentsStatus($_POST['post-comments-status']); $post->setStatus($status); $post->setTags($_POST['post-tags']); $post->setUserId(ae_Security::getCurrentUserId()); $post->save(); return $post->getId(); }