PHP Classes

noSQL Packages: Manage the approval of packages stored in files

Recommend this page to a friend!
  Info   View files Example   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 225 This week: 1All time: 8,209 This week: 560Up
Version License PHP version Categories
docnosql 0.1GNU General Publi...5.4PHP 5, Databases, Files and Folders, C...
Description 

Author

This class can manage the approval of packages stored in files.

It can add packages to a database made of CSV files with status information that determines if the package is submitted and is pending approval of a moderator, reviewed, approved, rejected or deleted.

The class can also update the package status and other information, retrieve the list of packages by status, retrieve the details of a package, and check if a given package id is valid.

The class can keep track of the history of changes to each package in a separate CSV file.

Innovation Award
PHP Programming Innovation award nominee
November 2015
Number 13
In user contributed content sites, it is often necessary have some kind of moderation to assure that all content complies with the site rules.

This package can manage a system of packages to be approved for publication in a user contributed content site. It uses a moderation process that allows for review and approval of submitted packages.

Manuel Lemos
Picture of Dave Smith
  Performance   Level  
Name: Dave Smith is available for providing paid consulting. Contact Dave Smith .
Classes: 51 packages by
Country: United States United States
Age: 58
All time rank: 618 in United States United States
Week rank: 20 Up3 in United States United States Up
Innovation award
Innovation award
Nominee: 32x

Winner: 7x

Recommendations

Open Source Approvals Management Engine
Need an "Open Source Approvals Management Engine"

Example

<?php
/*
example usage script
member of docStat class - document oriented noSQL approval system
version 0.1 beta 10/28/2015
*/
$includeDeleted = false;

include(
'docstat.class.php');
$docStat = new docStat('',$includeDeleted);
if( !empty(
$docStat->error) ){
   
    die(
$docStat->error);
   
}

$status = ( empty($_REQUEST['status']) ) ? 1 : $_REQUEST['status'];

$statusSelect = '<select name="status">';
foreach(
$docStat->statusText as $key=>$value ){
   
    if(
$key == 0 ){ continue; }
   
   
$selected = ( $status == $key ) ? ' selected' : '';
   
   
$statusSelect .= '<option value="'.$key.'"'.$selected.'>'.$value.'</option>';
   
}
$statusSelect .= '</select>';

if( !empty(
$_REQUEST['formPosted']) ){
   
   
$title = ( empty($_REQUEST['title']) ) ? '' : $_REQUEST['title'];
   
$userID = ( empty($_REQUEST['userID']) ) ? 0 : $_REQUEST['userID'];
   
$packageID = ( empty($_REQUEST['packageID']) ) ? null : $_REQUEST['packageID'];
   
$lastID = ( empty($_REQUEST['lastID']) ) ? 0 : $_REQUEST['lastID'];
   
$recordCount = ( empty($_REQUEST['recordCount']) ) ? 0 : $_REQUEST['recordCount'];
   
    if( empty(
$_REQUEST['action']) ){
       
       
$docStat->error = 'No action selected';
       
    }else{
       
        switch(
$_REQUEST['action'] ){
           
            case
'create':
               
$result = $docStat->createPackage($title,$userID,$status,$packageID);
                break;
               
            case
'read':
               
$result = $docStat->readPackage($packageID);
                break;
               
            case
'update':
               
$result = $docStat->updatePackage($packageID,$status,$userID,$title);
                break;
           
            case
'list':
               
$result = $docStat->packageList($status,$lastID,$recordCount);
                break;
           
            case
'readHistory':
               
$result = $docStat->readPackageHistory($packageID);
                break;
           
            case
'clearHistory':
               
$result = $docStat->clearPackageHistory($packageID,$userID);
                break;
           
        }
       
    }
   
}

?>
<!DOCTYPE html>
<html>
    <head>
        <title>docstat Usage Example</title>
    </head>
    <body>
        <h3>docstat Usage Example</h3>
        <h4>returned results are shown at bottom of the page</h4>
<?php
if( !empty($docStat->error) ){
?>
<hr>
        <h4 style="color: red;">Errors reported</h4>
        <div><?PHP echo $docStat->error;?></div>
<?php
}
?>
<hr>
        <h4>Package</h4>
        <form method="POST">
            <label for="title">Package Title:</label><br>
            (string)<br>
            <input type="text" name="title" value="<?PHP echo ( empty($_REQUEST['title']) ) ? '' : $_REQUEST['title'];?>"><br><br>
            <label for="status">Status:</label><br>
            (deleted files will <?PHP echo ( empty($includeDeleted) ) ? 'NOT' : '';?> be processed)<br>
            <?PHP echo $statusSelect;?><br><br>
            <label for="userID">User/Admin ID:</label><br>
            (numeric id - leave blank if not needed)<br>
            <input type="text" name="userID" value="<?PHP echo ( empty($_REQUEST['userID']) ) ? '' : $_REQUEST['userID'];?>"><br><br>
            <label for="packageID">Package ID:</label><br>
            (numeric id - new package will auto-increment last record if not supplied)<br>
            <input type="text" name="packageID" value="<?PHP echo ( empty($_REQUEST['packageID']) ) ? '' : $_REQUEST['packageID'];?>"><br><br>
            Action: (select one)<br>
            <input type="radio" name="action" value="create"> Create new package - object->createPackage(title[,userID=0][,status=1][,id=0])<br>
            <input type="radio" name="action" value="read"> Read package data - object->readPackage(id)<br>
            <input type="radio" name="action" value="update"> Update package - object->updatePackage(id,[,status=0][,userID=0][,title=''])<br>
            <input type="radio" name="action" value="delete" disabled="true"> Delete package - use update package with a deleted status - remove package folder to permanantly delete<br>
            <br><input type="hidden" name="formPosted" value="1"><input type="submit" name="formSubmit" value="Go">
        </form>
        <hr>
        <h4>Package List</h4>
        <form method="POST">
            <label for="status">Status:</label><br>
            (deleted files are <?PHP echo ( empty($includeDeleted) ) ? 'NOT' : '';?> included)<br>
            <?PHP echo $statusSelect;?><br><br>
            <label for="lastID">Last record ID:</label><br>
            (numeric id - indicates the last record accessed, useful for paging - leave blank to start at first record)<br>
            <input type="text" name="lastID" value="<?PHP echo ( empty($_REQUEST['lastID']) ) ? '' : $_REQUEST['lastID'];?>"><br><br>
            <label for="recordCount">Records to return:</label><br>
            (numeric id - number of records to return, useful for paging - leave blank to return all records)<br>
            <input type="text" name="recordCount" value="<?PHP echo ( empty($_REQUEST['recordCount']) ) ? '' : $_REQUEST['recordCount'];?>"><br><br>
            object->packageList([status=0][,lastID=0][,recordCount=0])
            <br><input type="hidden" name="action" value="list"><input type="hidden" name="formPosted" value="1"><input type="submit" name="formSubmit" value="Go">
        </form>
        <hr>
        <h4>History</h4>
        <form method="POST">
            <label for="packageID">Package ID:</label><br>
            (numeric id)<br>
            <input type="text" name="packageID" value="<?PHP echo ( empty($_REQUEST['packageID']) ) ? '' : $_REQUEST['packageID'];?>"><br><br>
            <label for="userID">User/Admin ID:</label><br>
            (numeric id - used to log who cleared history - leave blank if not needed)<br>
            <input type="text" name="userID" value="<?PHP echo ( empty($_REQUEST['userID']) ) ? '' : $_REQUEST['userID'];?>"><br><br>
            Action: (select one)<br>
            <input type="radio" name="action" value="readHistory"> Read history data - object->readPackageHistory(id)<br>
            <input type="radio" name="action" value="clearHistory"> Clear history data - object->clearPackageHistory(id[,userID])<br>
            <br><input type="hidden" name="formPosted" value="1"><input type="submit" name="formSubmit" value="Go">
        </form>
        <hr>
        <h4>Result</h4>
<?php
if( !empty($result) ){
?>
<div><?PHP var_dump($result);?></div>
<?php
}
?>
</body>
</html>


Details

Class: docStat Version: 0.1 beta 10/28/2015 Copyright 2015 Wagon Trader, All Rights Reserved Description: This class is a package approval system based on document oriented noSQL data. It supports creating, reading and updating package folders and tracks their approval status. Files: docstat.class.php - Main class example.php - Usage examples Installation: Upload files to a web accessible location on your server (eg. public_html). On Linux systems, set the permissions on your package folder to read and write (666) or (777) Configuration: Configure the following properties in docstat.class.php for your setup... $rootFolder - The folder which will contain the package data, defaults to package/ $allowDupTitles - Set to false to force unique package titles. $timeFormat - Set your prefered display format for timeStamps. Usage: Usage examples are provided in the example.php file. Changelog 0.1 beta Initial beta release

  Files folder image Files  
File Role Description
Files folder imagepackage (1 file)
Plain text file docstat.class.php Class Main Class
Accessible without login Plain text file example.php Example Example Usage
Accessible without login Plain text file license.txt Lic. License
Accessible without login Plain text file manual.txt Doc. Documentation

  Files folder image Files  /  package  
File Role Description
  Accessible without login Plain text file data.csv Data Site package data

 Version Control Unique User Downloads Download Rankings  
 0%
Total:225
This week:1
All time:8,209
This week:560Up