| 1 | <?php
|
|---|
| 2 | /**
|
|---|
| 3 | * name: Post Manager
|
|---|
| 4 | * description: Manage posts.
|
|---|
| 5 | * version: 0.4
|
|---|
| 6 | * folder: post_manager
|
|---|
| 7 | * class: PostManager
|
|---|
| 8 | * requires: submit 1.9
|
|---|
| 9 | * hooks: hotaru_header, install_plugin, admin_header_include, admin_plugin_settings, admin_sidebar_plugin_settings, user_manager_role, user_manager_details
|
|---|
| 10 | * author: Nick Ramsay
|
|---|
| 11 | * authorurl: http://hotarucms.org/member.php?1-Nick
|
|---|
| 12 | *
|
|---|
| 13 | * PHP version 5
|
|---|
| 14 | *
|
|---|
| 15 | * LICENSE: Hotaru CMS is free software: you can redistribute it and/or
|
|---|
| 16 | * modify it under the terms of the GNU General Public License as
|
|---|
| 17 | * published by the Free Software Foundation, either version 3 of
|
|---|
| 18 | * the License, or (at your option) any later version.
|
|---|
| 19 | *
|
|---|
| 20 | * Hotaru CMS is distributed in the hope that it will be useful, but WITHOUT
|
|---|
| 21 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|---|
| 22 | * FITNESS FOR A PARTICULAR PURPOSE.
|
|---|
| 23 | *
|
|---|
| 24 | * You should have received a copy of the GNU General Public License along
|
|---|
| 25 | * with Hotaru CMS. If not, see http://www.gnu.org/licenses/.
|
|---|
| 26 | *
|
|---|
| 27 | * @category Content Management System
|
|---|
| 28 | * @package HotaruCMS
|
|---|
| 29 | * @author Nick Ramsay <admin@hotarucms.org>
|
|---|
| 30 | * @copyright Copyright (c) 2009, Hotaru CMS
|
|---|
| 31 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
|
|---|
| 32 | * @link http://www.hotarucms.org/
|
|---|
| 33 | */
|
|---|
| 34 |
|
|---|
| 35 | class PostManager
|
|---|
| 36 | {
|
|---|
| 37 | // Most work is done in post_manager_settings.php
|
|---|
| 38 |
|
|---|
| 39 | /**
|
|---|
| 40 | * Adds an icon in User Manager about the user having pending or buried posts
|
|---|
| 41 | */
|
|---|
| 42 | public function user_manager_role($h)
|
|---|
| 43 | {
|
|---|
| 44 | list ($icons, $user_role, $user) = $h->vars['user_manager_role'];
|
|---|
| 45 |
|
|---|
| 46 | // Check to see if this user has any pending or buried posts:
|
|---|
| 47 | $sql = "SELECT post_id, post_status FROM " . TABLE_POSTS . " WHERE post_author = %d AND (post_status = %s OR post_status = %s) ORDER BY post_date DESC";
|
|---|
| 48 | $flags = $h->db->get_results($h->db->prepare($sql, $user->user_id, 'pending', 'buried'));
|
|---|
| 49 | $h->vars['post_manager_flags'] = $flags;
|
|---|
| 50 |
|
|---|
| 51 | if ($flags) {
|
|---|
| 52 | $unique_array = array();
|
|---|
| 53 | $title = $h->lang["post_man_flagged_reasons"];
|
|---|
| 54 | foreach ($flags as $flag) {
|
|---|
| 55 | if (!in_array($flag->post_status, $unique_array)) {
|
|---|
| 56 | $title .= $flag->post_status . ", ";
|
|---|
| 57 | array_push($unique_array, $flag->post_status);
|
|---|
| 58 | }
|
|---|
| 59 | }
|
|---|
| 60 | $title = rstrtrim($title, ", ");
|
|---|
| 61 | $icons .= " <img src = '" . BASEURL . "content/plugins/user_manager/images/flag_red.png' title='" . $title . "'>";
|
|---|
| 62 | $h->vars['user_manager_role'] = array($icons, $user_role, $user);
|
|---|
| 63 | }
|
|---|
| 64 | }
|
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 | /**
|
|---|
| 68 | * Adds a note in User Manager about the user having pending or buried posts
|
|---|
| 69 | */
|
|---|
| 70 | public function user_manager_details($h)
|
|---|
| 71 | {
|
|---|
| 72 | list ($output, $user) = $h->vars['user_manager_details'];
|
|---|
| 73 |
|
|---|
| 74 | // Check to see if this user has any pending or buried posts:
|
|---|
| 75 | $sql = "SELECT post_id, post_status FROM " . TABLE_POSTS . " WHERE post_author = %d AND (post_status = %s OR post_status = %s) ORDER BY post_date DESC";
|
|---|
| 76 |
|
|---|
| 77 | if (!isset($h->vars['post_manager_flags'])) {
|
|---|
| 78 | $flags = $h->db->get_results($h->db->prepare($sql, $user->user_id, 'pending', 'buried'));
|
|---|
| 79 | } else {
|
|---|
| 80 | $flags = $h->vars['post_manager_flags']; // retrieve from memory
|
|---|
| 81 | }
|
|---|
| 82 |
|
|---|
| 83 | if ($flags) {
|
|---|
| 84 | $output .= "<br /><b>" . $h->lang["post_man_flagged_reasons"] . "</b>";
|
|---|
| 85 | foreach ($flags as $flag) {
|
|---|
| 86 | $h->readPost($flag->post_id);
|
|---|
| 87 | $output .= "<a href='" . $h->url(array('page'=>$flag->post_id)) . "' title='" . $h->lang["post_man_flags_title"] . $h->post->title . "'>" . $flag->post_status . "</a>, ";
|
|---|
| 88 | }
|
|---|
| 89 | $output = rstrtrim($output, ", ");
|
|---|
| 90 | $h->vars['user_manager_details'] = array($output, $user);
|
|---|
| 91 | }
|
|---|
| 92 | }
|
|---|
| 93 | }
|
|---|
| 94 |
|
|---|
| 95 | ?> |
|---|