示例#1
0
<?php

// Some sketchy crap for displaying pending glossary additions
include_once "../../includes/easyparliament/init.php";
include_once INCLUDESPATH . "easyparliament/editqueue.php";
include_once INCLUDESPATH . "easyparliament/glossary.php";
$this_page = "admin_glossary_pending";
$EDITQUEUE = new GLOSSEDITQUEUE();
$args = array('sort' => "regexp_replace");
$GLOSSARY = new GLOSSARY($args);
// This will build a list of pending requests for everything by default.
$EDITQUEUE->get_pending();
// If we're coming back here from a recent action we will have
// an http POST var of 'approve' or 'decline'.
// 'approve' can be an array or a single value depending on whether or not it was a form submission.
// 'decline' will always be a single value.
if (get_http_var('approve')) {
    $approve = get_http_var('approve');
    if (!is_array($approve)) {
        $approve = array($approve);
    }
    // Add all approved items
    $data = array('approvals' => $approve, 'epobject_type' => 2);
    $EDITQUEUE->approve($data);
} elseif (get_http_var('decline')) {
    $decline = array(get_http_var('decline'));
    // Dump all declined items
    $data = array('declines' => $decline, 'epobject_type' => 2);
    $EDITQUEUE->decline($data);
}
$PAGE->page_start();
示例#2
0
文件: glossary.php 项目: leowmjw/twfy
<?php

// Some sketchy crap for displaying pending glossary additions
include_once "../../includes/easyparliament/init.php";
include_once INCLUDESPATH . "easyparliament/editqueue.php";
include_once INCLUDESPATH . "easyparliament/glossary.php";
$this_page = "admin_glossary";
$EDITQUEUE = new GLOSSEDITQUEUE();
$args = array('sort' => "regexp_replace");
$GLOSSARY = new GLOSSARY($args);
// If we're coming back here from a recent action we will have
// an http POST var of 'approve' or 'decline'.
// 'approve' can be an array or a single value depending on whether or not it was a form submission.
// 'decline' will always be a single value.
if (get_http_var('approve')) {
    $approve = get_http_var('approve');
    if (!is_array($approve)) {
        $approve = array($approve);
    }
    // Add all approved items
    $data = array('approvals' => $approve, 'epobject_type' => 2);
    $EDITQUEUE->approve($data);
} elseif (get_http_var('decline')) {
    $decline = array(get_http_var('decline'));
    // Dump all declined items
    $data = array('declines' => $decline, 'epobject_type' => 2);
    $EDITQUEUE->decline($data);
} elseif (get_http_var('delete_confirm')) {
    $delete_id = get_http_var('delete_confirm');
    // Delete the existing glossary entry
    $GLOSSARY->delete($delete_id);
示例#3
0
文件: glossary.php 项目: leowmjw/twfy
 function create(&$data)
 {
     // Add a Glossary definition.
     // Sets visiblity to 0, and awaits moderator intervention.
     // For this we need to start up an epobject of type 2 and then an editqueue item
     // where editqueue.epobject_id_l = epobject.epobject_id
     $EDITQUEUE = new GLOSSEDITQUEUE();
     // Assuming that everything is ok, we will need:
     // For epobject:
     // 		title VARCHAR(255),
     // 		body TEXT,
     // 		type INTEGER,
     // 		created DATETIME,
     // 		modified DATETIME,
     // and for editqueue:
     //		edit_id INTEGER PRIMARY KEY NOT NULL,
     //		user_id INTEGER,
     //		edit_type INTEGER,
     //		epobject_id_l INTEGER,
     //		title VARCHAR(255),
     //		body TEXT,
     //		submitted DATETIME,
     //		editor_id INTEGER,
     //		approved BOOLEAN,
     //		decided DATETIME
     global $THEUSER;
     if (!$THEUSER->is_able_to('addterm')) {
         error("Sorry, you are not allowed to add Glossary terms.");
         return false;
     }
     if ($data['title'] == '') {
         error("Sorry, you can't define a term without a title");
         return false;
     }
     if ($data['body'] == '') {
         error("You haven't entered a definition!");
         return false;
     }
     if (is_numeric($THEUSER->user_id())) {
         // Flood check - make sure the user hasn't just posted a term recently.
         // To help prevent accidental duplicates, among other nasty things.
         $flood_time_limit = 20;
         // How many seconds until a user can post again?
         $q = $this->db->query("SELECT glossary_id\n\t\t\t\t\t\t\tFROM\teditqueue\n\t\t\t\t\t\t\tWHERE\tuser_id = '" . $THEUSER->user_id() . "'\n\t\t\t\t\t\t\tAND\t\tsubmitted + 0 > NOW() - {$flood_time_limit}");
         if ($q->rows() > 0) {
             error("Sorry, we limit people to posting one term per {$flood_time_limit} seconds to help prevent duplicate postings. Please go back and try again, thanks.");
             return false;
         }
     }
     // OK, let's get on with it...
     // Tidy up the HTML tags
     // (but we don't make URLs into links; only when displaying the comment).
     // We can display Glossary terms the same as the comments
     $data['title'] = filter_user_input($data['title'], 'comment_title');
     // In utility.php
     $data['body'] = filter_user_input($data['body'], 'comment');
     // In utility.php
     // Add the time and the edit type for the editqueue
     $data['posted'] = date('Y-m-d H:i:s', time());
     $data['edit_type'] = 2;
     // Add the item to the edit queue
     $success = $EDITQUEUE->add($data);
     if ($success) {
         return $success;
     } else {
         return false;
     }
 }