Skip to content

Commit

Permalink
0.5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
benbalter authored and benbalter committed Jul 30, 2011
1 parent e525f1e commit 28a33e6
Show file tree
Hide file tree
Showing 6 changed files with 170 additions and 145 deletions.
159 changes: 83 additions & 76 deletions admin.php
Expand Up @@ -50,6 +50,9 @@ function __construct( &$instance = null) {

//media filters
add_action( 'posts_where', array( &$this, 'filter_from_media' ) );

//cleanup
add_action( 'delete_post', array( &$this, 'delete_attachments_with_document'), 10, 1 );

}

Expand Down Expand Up @@ -225,11 +228,11 @@ function document_metabox($post) {?>
<input type="hidden" id="content" name="content" value="<?php echo esc_attr( $post->post_content) ; ?>" />
<?php
if ( $lock_holder = $this->get_document_lock( $post ) ) { ?>
<div id="lock_override"> <?php printf( __('%s has prevented other users from making changes.', 'wp-document-revisions'), $lock_holder ); ?>
<?php if ( current_user_can( 'override_document_lock' ) ) { ?>
<?php _e('<br />If you believe this is in error you can <a href="#" id="override_link">override the lock</a>, but their changes will be lost.', 'wp-document-revisions'); ?>
<?php } ?>
</div>
<div id="lock_override"> <?php printf( __('%s has prevented other users from making changes.', 'wp-document-revisions'), $lock_holder ); ?>
<?php if ( current_user_can( 'override_document_lock' ) ) { ?>
<?php _e('<br />If you believe this is in error you can <a href="#" id="override_link">override the lock</a>, but their changes will be lost.', 'wp-document-revisions'); ?>
<?php } ?>
</div>
<?php } ?>
<div id="lock_override"><a href='media-upload.php?post_id=<?php echo $post->ID; ?>&TB_iframe=1&document=1' id='add_media' class='thickbox button' title='Upload Document' onclick='return false;' >Upload New Version</a></div>
<?php
Expand Down Expand Up @@ -367,59 +370,59 @@ function sanitize_upload_dir( $dir) {

}

/**
* Callback to create the upload location settings field
* @since 0.5
*/
function upload_location_cb() { ?>
<input name="document_upload_directory" type="text" id="document_upload_directory" value="<?php echo esc_attr( $this->document_upload_dir() ); ?>" class="regular-text code" />

/**
* Callback to create the upload location settings field
* @since 0.5
*/
function upload_location_cb() { ?>
<input name="document_upload_directory" type="text" id="document_upload_directory" value="<?php echo esc_attr( $this->document_upload_dir() ); ?>" class="regular-text code" />
<span class="description"><?php _e( 'Directory in which to store uploaded documents. The default is in your <code>wp_content/uploads</code> folder, but it may be moved to a folder outside of the <code>htdocs</code> or <code>public_html</code> folder for added security.', 'wp-document-revisions' ); ?></span>
<?php }
/**
* Callback to inject JavaScript in page after upload is complete
* @param int $id the ID of the attachment
* @since 0.5
*/
function post_upload_js( $id ) {
//can this be appended to the wp_document_revisions localization object?
//get the post object
$post = get_post( $id );
//get the extension from the post object to pass along to the client
$extension = $this->get_file_type( $post );
//begin output buffer so the javascript can be returned as a string, rather than output directly to the browser
ob_start();
?><script>
var attachmentID = <?php echo $id; ?>;
var extension = '<?php echo $extension; ?>';
jQuery(document).ready(function($) { $(this).trigger('documentUpload') });
</script><?php
//get contents of output buffer
$js = ob_get_contents();
//dump output buffer
ob_end_clean();
//return javascript
return $js;
}
/**
* Ugly, Ugly hack to sneak post-upload JS into the iframe
* If there was a hook there, I wouldn't have to do this
* @param string $meta dimensions / post meta
* @returns string meta + js to process post
* @since 0.5
*/
function media_meta_hack( $meta ) {
<?php }

/**
* Callback to inject JavaScript in page after upload is complete
* @param int $id the ID of the attachment
* @since 0.5
*/
function post_upload_js( $id ) {

//can this be appended to the wp_document_revisions localization object?
//get the post object
$post = get_post( $id );

//get the extension from the post object to pass along to the client
$extension = $this->get_file_type( $post );

//begin output buffer so the javascript can be returned as a string, rather than output directly to the browser
ob_start();

?><script>
var attachmentID = <?php echo $id; ?>;
var extension = '<?php echo $extension; ?>';
jQuery(document).ready(function($) { $(this).trigger('documentUpload') });
</script><?php

//get contents of output buffer
$js = ob_get_contents();

//dump output buffer
ob_end_clean();

//return javascript
return $js;
}

/**
* Ugly, Ugly hack to sneak post-upload JS into the iframe
* If there was a hook there, I wouldn't have to do this
* @param string $meta dimensions / post meta
* @returns string meta + js to process post
* @since 0.5
*/
function media_meta_hack( $meta ) {

if ( !$this->verify_post_type( ) )
return $meta;

Expand All @@ -429,10 +432,10 @@ function media_meta_hack( $meta ) {
$meta .= $this->post_upload_js( $latest->ID );

return $meta;
}
/**

}

/**
* Hook to follow file uploads to automate attaching the document to the post
* @param string $filter whatever we really should be filtering
* @returns string the same stuff they gave us, like we were never here
Expand All @@ -457,8 +460,8 @@ function post_upload_handler( $filter ) {
//should probably give this back...
return $filter;

}
}

/**
* Retrieves the most recent file attached to a post
* @param int $post_id the parent post
Expand Down Expand Up @@ -658,20 +661,9 @@ function workflow_state_save( $post_id ) {
//all's good, let's save
wp_set_post_terms( $post_id, array( $_POST['workflow_state'] ), 'workflow_state' );

}

/**
* Filters permalink displayed on edit screen in the event that there is no attachment yet uploaded
* @param string $html original HTML
* @param int $id Post ID
* @rerurns string modified HTML
* @since 0.5
*/
function sample_permalink_filter($html, $id ) {

return $html;
do_action( 'change_document_workflow_state', $post_id, $_POST['workflow_state'] );

}
}

/**
* Slightly modified document author metabox because the current one is ugly
Expand Down Expand Up @@ -760,6 +752,21 @@ function revision_filter( $id ) {
wp_delete_post( $id, true );

}

/**
* Deletes all attachments associated with a document or revision
* @since 1.0
* @param int $postID the id of the deleted post
*/
function delete_attachments_with_document( $postID ) {

if ( !$this->verify_post_type( $postID ) )
return;

if ( is_numeric( $post->post_content ) && get_post( $post->post_content ) )
wp_delete_attachment( $post->post_content, false );

}

}
?>
51 changes: 36 additions & 15 deletions readme.txt
Expand Up @@ -3,37 +3,58 @@ Contributors: benbalter
Donate link: http://ben.balter.com/
Tags: documents, uploads, attachments, document management, enterprise, version control, revisions, collaboration, journalism, government, files, revision log, document management
Requires at least: 3.2
Tested up to: 3.2
Tested up to: 3.3
Stable tag: trunk

WordPress Document Revisions – a workflow management and version control system for WordPress
WordPress Document Revisions – a document management and version control plugin that allows teams of any size to collaboratively edit files

== Description ==

WordPress Document Management – a workflow management and version control system for WordPress building on its existing core competencies. By treating documents as a custom post type, users can leverage the power of WordPress’s extensive attachment, revision, taxonomy, and URL rewriting functionalities. Document permalinks can be routed through the traditional rewrite structure such that the latest revision of a file always remains at a static, authenticated URL, and users can toggle the visibility of documents (both internally and externally) as they currently do with post statuses and permissions. Similarly, file locking can extend WordPress’s autosave functionality (as a ping), revision logs can extend WordPress’s existing revision relationship and can be outputted as a traditional RSS feed, etc.

[Read More in my original post "When all you have is a pair of bolt cutters..."](http://ben.balter.com/2011/04/04/when-all-you-have-is-a-pair-of-bolt-cutters/)

**Google Summer of Code 2011 project. Still under development. Not for production. This will break.**

Please feel free to download and kick the tires. Community feedback is greatly appreciated, but please note that this project is still under development, and is not quite ready for production environments.

**Features**
Read More in my original post ["When all you have is a pair of bolt cutters…](http://ben.balter.com/2011/04/04/when-all-you-have-is-a-pair-of-bolt-cutters/)

--------------------------------

[WP Document Revisions](http://wordpress.org/extend/plugins/wp-document-revisions/) is a [document management](http://en.wikipedia.org/wiki/Document_management_system) and [version control](http://en.wikipedia.org/wiki/Revision_control) plugin. Built for time-sensitive and mission-critical projects, teams can collaboratively edit files of any format -- text documents, spreadsheets, images, sheet music... anything -- all the while, seamlessly tracking the document's progress as it moves through your organization's existing workflow.

**Powerful Collaboration Tools ***With great power does not have to come great complexity. *Based on a simple philosophy of putting powerful but intuitive tools in the hands of managers and content creators, WP Document Revisions leverages many of the essential WordPress features that, for more than eight years, have been tested and proven across countless industries -- posts, attachments, revisions, taxonomies, authentication, and permalinks -- to make collaborating on the creation and publication of documents a natural endeavor. Think of it as an [open-source and more intuitive version](http://ben.balter.com/2011/04/04/when-all-you-have-is-a-pair-of-bolt-cutters/) of the popular Microsoft collaboration suite, [Sharepoint.](http://sharepoint.microsoft.com/en-us/Pages/default.aspx)

**Document History **At each step of the authoring process, WP Document Revisions gives you an instant snapshot of your team's progress and the document's history. It even gives you the option to revert back to a previous revision -- so don't fret if you make a mistake -- or receive updates on changes to the document right in your favorite feed reader.

**Access Control **Each document is given a persistent URL (e.g., yourcompany.com/documents/2011/08/TPS-Report.doc) which can be private (securely delivered only to members of your organization), password protected (available only to those you select), or public (published and hosted for the world to see). If you catch a typo and upload a new version, that URL will continue to point to the latest version, regardless of how many changes you make.

* Support for any file type (docs, spreadsheets, images, PDFs, etc.)
* Stores unlimited revisions with a revision log message for each
* Each file gets a permanent URL that always points to the latest version of the file
* Each revision gets its own unique url (e.g., my-document-revision-3.doc)
* Toggle documents between public, private, and password protected
**Enterprise Security** Worried about storing propriety or sensitive information? WP Document Revisions was built from the first line of code with government- and enterprise-grade security in mind. Each file is masked behind an anonymous 128-bit [MD5 hash](http://en.wikipedia.org/wiki/MD5) as soon as it touches the server, and requests for files are transparently routed through WordPress's time-tested URL rewriting, authentication, and permission systems (which can even [integrate with existing enterprise active directory](http://wordpress.org/extend/plugins/active-directory-integration/) or [LDAP servers](http://wordpress.org/extend/plugins/simple-ldap-login/)). Need more security? WP Document Revisions allows you to store documents in a folder above the `htdocs` or `public_html` [web root](http://httpd.apache.org/docs/2.0/mod/core.html#documentroot), further ensuring that only those you authorize have access to your work.

**Customization** WP Document Revisions recognizes that no two teams are identical, and as a result, molds to your firm's needs, not the other way around. Need to track additional information associated with a document? Departments, editors, issues, sections, even arbitrary key-value pairs -- whatever you can throw at it, it can handle. Development and customization costs are further minimized by its extensive plugin API, and the [WP Document Revisions Custom Taxonomy Generator](#) makes it easy for even the uninitiated to add custom fields and taxonomies to documents. Simply put, virtually every aspect of the plugin's functionality from workflow states to user-level permissions can be fully customized to your team's unique needs.

**The Vitals:**

* Support for any file type (docs, spreadsheets, images, PDFs -- anything!)
* Securely stores unlimited revisions of your business's essential files
* Provides a full file history in the form of a revision log, accessible via RSS
* Helps you track and organize documents as they move through your organization's existing workflow
* Each file gets a permanent, authenticated URL that always points to the latest version
* Each revision gets its own unique url (e.g.,TPS-Report-revision-3.doc) accessible only to those you deem
* Files are intuitively checked out and locked to prevent revisions from colliding
* Toggle documents between public, private, and password protected with a single mouse click
* Secure: filenames are hashed on upload and files are only accessible through WordPress's proven authentication system
* Can move document upload folder to location outside of web root to further secure files
* Helps you track and organize documents as they move through your organization's workflow
* RSS Feeds of revisions
* Can move document upload folder to location outside of web root to further ensure government- and enterprise-grade security
* Easily translated to your local language

Want to give it a try? Simply [download WP Document Revisions](http://wordpress.org/extend/plugins/wp-document-revisions/) from the WordPress Plugin Repository.

*WP Document Revisions was **developed by a [law student and a business student](http://ben.balter.com) **with a [grant from Google](http://code.google.com/soc/),** and in close coordination with and under the watchful eye of WordPress.org's lead developers.*** (Neither relationship should imply a formal endorsement.) **

**Known Issues**

* See the [development backlog](http://gsoc.trac.wordpress.org/query?status=accepted&status=assigned&status=new&status=reopened&component=Document+Revisions&col=id&col=summary&col=status&col=type&col=priority&col=milestone&col=component&order=priority) for a list of known issues

== Screenshots ==
1. A typical WP Document Revisions edit document screen.

== Installation ==

1. Download and Install
Expand Down
Binary file added screenshot-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 28a33e6

Please sign in to comment.