summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LibertyContent.php44
-rwxr-xr-xLibertySystem.php48
-rw-r--r--admin/admin_liberty_inc.php4
-rw-r--r--admin/schema_inc.php8
-rw-r--r--admin/upgrade_inc.php4
-rw-r--r--bit_setup_inc.php12
-rw-r--r--templates/edit_content_status_inc.tpl6
7 files changed, 101 insertions, 25 deletions
diff --git a/LibertyContent.php b/LibertyContent.php
index 46cd468..ca6e927 100644
--- a/LibertyContent.php
+++ b/LibertyContent.php
@@ -3,7 +3,7 @@
* Management of Liberty content
*
* @package liberty
-* @version $Header: /cvsroot/bitweaver/_bit_liberty/LibertyContent.php,v 1.179 2007/03/06 15:54:14 squareing Exp $
+* @version $Header: /cvsroot/bitweaver/_bit_liberty/LibertyContent.php,v 1.180 2007/03/10 16:07:01 nickpalmer Exp $
* @author spider <spider@steelsun.com>
*/
@@ -153,13 +153,37 @@ class LibertyContent extends LibertyBase {
if( !@$this->verifyId( $this->mContentId ) ) {
// These should never be updated, only inserted
$pParamHash['content_store']['created'] = !empty( $pParamHash['created'] ) ? $pParamHash['created'] : $gBitSystem->getUTCTime();
+ // This may get overridden by owner set
$pParamHash['content_store']['user_id'] = $pParamHash['user_id'];
+ // Set a default status when creating
+ // This may get overwritten below
+ $pParamHash['content_store']['content_status_id'] = $gBitSystem->getConfig('liberty_default_status', BIT_CONTENT_DEFAULT_STATUS);
} else {
$pParamHash['content_id'] = $this->mContentId;
}
}
+
+ // Are we allowed to override owner?
+ if ($gBitSystem->isFeatureActive('liberty_allow_change_owner') && $gBitUser->hasPermission('p_liberty_edit_content_owner')) {
+ // If an owner is being set override user_id
+ if (!empty($pParamHash['owner_id']) && !empty($pParamHash['current_owner_id']) && $pParamHash['owner_id'] != $pParamHash['current_owner_id']) {
+ $pParamHash['content_store']['user_id'] = $pParamHash['owner_id'];
+ }
+ }
+
+ // Do we need to change the status
+ if ($gBitSystem->isFeatureActive('liberty_display_status') && ($gBitUser->hasPermission('p_liberty_edit_content_status') || $gBitUser->hasPermission('p_liberty_edit_all_status'))) {
+ $allStatus = $this->getContentStatus();
+ if (!empty($pParamHash['content_status_id'])) {
+ if (!in_array($pParamHash['content_status_is'], $allStatus)) {
+ $this->mError['content_status_id'] = "No such status ID or permission denied.";
+ }
+ else {
+ $pParamHash['content_store']['content_status_id'] = $pParamHash['content_status_id'];
+ }
+ }
+ }
- $pParamHash['content_store']['content_status_id'] = (@BitBase::verifyId( $pParamHash['content_status_id'] ) ? $pParamHash['content_status_id'] : $gBitSystem->getConfig( 'liberty_default_status', BIT_CONTENT_DEFAULT_STATUS ));
$pParamHash['field_changed'] = empty( $pParamHash['content_id'] )
|| (!empty($this->mInfo["data"]) && !empty($pParamHash["edit"]) && (md5($this->mInfo["data"]) != md5($pParamHash["edit"])))
|| (!empty($pParamHash["title"]) && !empty($this->mInfo["title"]) && (md5($this->mInfo["title"]) != md5($pParamHash["title"])))
@@ -2284,5 +2308,21 @@ class LibertyContent extends LibertyBase {
$this->mDb->query( "DELETE FROM `".BIT_DB_PREFIX."liberty_action_log` $where", $bindVars );
return TRUE;
}
+
+ /**
+ * getContentStatus
+ *
+ * @access public
+ * @return an array of content_status_id, content_status_names the current user can use on this content. Subclases may easily override with return LibertyContent::getContentStatus(-100, 0) for example to restrict to only hidden content types.
+ */
+ function getContentStatus($pUserMinimum=-100, $pUserMaximum=100) {
+ global $gBitUser;
+ if ($gBitUser->hasPermission('p_liberty_edit_all_status')) {
+ return( $this->mDb->getAssoc( "SELECT `content_status_id`,`content_status_name` FROM `".BIT_DB_PREFIX."liberty_content_status` ORDER BY `content_status_id`" ) );
+ }
+ else {
+ return( $this->mDb->getAssoc( "SELECT `content_status_id`, `content_status_name` FROM `".BIT_DB_PREFIX."liberty_content_status` WHERE `content_status_id` > ? AND `content_status_id` < ? ORDER BY `content_status_id`", array($pUserMinimum, $pUserMaximum)));
+ }
+ }
}
?>
diff --git a/LibertySystem.php b/LibertySystem.php
index 0a27669..6fe80b0 100755
--- a/LibertySystem.php
+++ b/LibertySystem.php
@@ -3,7 +3,7 @@
* System class for handling the liberty package
*
* @package liberty
-* @version $Header: /cvsroot/bitweaver/_bit_liberty/LibertySystem.php,v 1.63 2007/03/05 00:59:58 wjames5 Exp $
+* @version $Header: /cvsroot/bitweaver/_bit_liberty/LibertySystem.php,v 1.64 2007/03/10 16:07:01 nickpalmer Exp $
* @author spider <spider@steelsun.com>
*/
@@ -357,20 +357,6 @@ class LibertySystem extends LibertyBase {
$this->scanAllPlugins();
}
-
-
-
- // ****************************** Content Type Functions
- /**
- * getContentStatus
- *
- * @access public
- * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
- */
- function getContentStatus() {
- return( $this->mDb->getAssoc( "SELECT `content_status_id`,`content_status_name` FROM `".BIT_DB_PREFIX."liberty_content_status`" ) );
- }
-
/**
* Load all available content types into $this->mContentTypes
*
@@ -758,4 +744,36 @@ function liberty_plugins_div_style( $pParamHash ) {
return $ret;
}
+function liberty_content_load_sql() {
+ global $gBitSystem, $gBitUser;
+ $ret = array();
+ if ($gBitSystem->isFeatureActive('liberty_display_status') && !$gBitUser->hasPermission('p_liberty_edit_all_status')) {
+ $ret['where_sql'] = " AND lc.`content_status_id` < 100 AND ( (lc.`user_id` = '".$gBitUser->getUserId()."' AND lc.`content_status_id` > -100) OR lc.`content_status_id` > 0 )";
+ }
+ // Make sure owner comes out properly for all content
+ if ($gBitSystem->isFeatureActive('liberty_allow_change_owner') && $gBitUser->hasPermission('p_liberty_edit_content_owner')) {
+ $ret['select_sql'] = " , lc.`user_id` AS owner_id";
+ }
+ return $ret;
+}
+
+function liberty_content_list_sql() {
+ global $gBitSystem, $gBitUser;
+ $ret = array();
+ if ($gBitSystem->isFeatureActive('liberty_display_status') && !$gBitUser->hasPermission('p_liberty_edit_all_status')) {
+ $ret['where_sql'] = " AND lc.`content_status_id` < 100 AND ( (lc.`user_id` = '".$gBitUser->getUserId()."' AND lc.`content_status_id` > -100) OR lc.`content_status_id` > 0 )";
+ }
+ return $ret;
+}
+
+function liberty_content_preview(&$pObject) {
+ global $gBitSystem, $gBitUser;
+ if ($gBitSystem->isFeatureActive('liberty_display_status') && ($gBitUser->hasPermission('p_liberty_edit_content_status') || $gBitUser->hasPermission('p_libert_edit_all_status'))) {
+ $pObject->mInfo['content_status_id'] = $_REQUEST['content_status_id'];
+ }
+ if ($gBitSystem->isFeatureActive('liberty_allow_change_owner') && $gBitUser->hasPermission('p_liberty_edit_content_owner')) {
+ $pObject->mInfo['owner_id'] = $_REQUEST['owner_id'];
+ }
+}
+
?>
diff --git a/admin/admin_liberty_inc.php b/admin/admin_liberty_inc.php
index 304838b..2757e7c 100644
--- a/admin/admin_liberty_inc.php
+++ b/admin/admin_liberty_inc.php
@@ -4,6 +4,10 @@ $formLibertyFeatures = array(
'label' => 'Display content status',
'note' => 'Display a status selection menu when editing content (not fully developed, experimental feature).',
),
+ "liberty_allow_change_owner" => array(
+ 'label' => 'Allow Owner Change',
+ 'note' => 'Allow users with the proper permission to change the owner of content.',
+ ),
"liberty_cache_pages" => array(
'label' => 'External page cache',
'note' => 'Enabling this will download and cache external pages that are included.',
diff --git a/admin/schema_inc.php b/admin/schema_inc.php
index 181482e..4b9f7b6 100644
--- a/admin/schema_inc.php
+++ b/admin/schema_inc.php
@@ -239,9 +239,9 @@ $gBitInstaller->registerSchemaDefault( LIBERTY_PKG_NAME, array(
"INSERT INTO `".BIT_DB_PREFIX."liberty_content_status` (`content_status_id`,`content_status_name`) VALUES (-30, 'Password Protected')",
"INSERT INTO `".BIT_DB_PREFIX."liberty_content_status` (`content_status_id`,`content_status_name`) VALUES (-20, 'Group Protected')",
"INSERT INTO `".BIT_DB_PREFIX."liberty_content_status` (`content_status_id`,`content_status_name`) VALUES (-10, 'Hidden')",
- "INSERT INTO `".BIT_DB_PREFIX."liberty_content_status` (`content_status_id`,`content_status_name`) VALUES (10, 'Draft')",
+ "INSERT INTO `".BIT_DB_PREFIX."liberty_content_status` (`content_status_id`,`content_status_name`) VALUES (-5, 'Draft')",
+ "INSERT INTO `".BIT_DB_PREFIX."liberty_content_status` (`content_status_id`,`content_status_name`) VALUES (-1, 'Pending Approval')",
"INSERT INTO `".BIT_DB_PREFIX."liberty_content_status` (`content_status_id`,`content_status_name`) VALUES (50, 'Available')",
- "INSERT INTO `".BIT_DB_PREFIX."liberty_content_status` (`content_status_id`,`content_status_name`) VALUES (101, 'Pending Approval')",
"INSERT INTO `".BIT_DB_PREFIX."liberty_content_status` (`content_status_id`,`content_status_name`) VALUES (102, 'Commercial')",
"INSERT INTO `".BIT_DB_PREFIX."liberty_content_status` (`content_status_id`,`content_status_name`) VALUES (200, 'Recommended')",
"INSERT INTO `".BIT_DB_PREFIX."liberty_content_status` (`content_status_id`,`content_status_name`) VALUES (999, 'Copy Protected')",
@@ -262,6 +262,10 @@ $gBitInstaller->registerUserPermissions( LIBERTY_PKG_NAME, array(
array('p_liberty_detach_attachment', 'Can detach content attachments', 'registered', LIBERTY_PKG_NAME),
array('p_liberty_print', 'Can print content', 'basic', LIBERTY_PKG_NAME),
array('p_liberty_enter_html', 'Can enter HTML', 'registered', LIBERTY_PKG_NAME),
+ array('p_liberty_edit_content_status', 'Can edit the status of content', 'registered', LIBERTY_PKG_NAME),
+ array('p_liberty_edit_all_status', 'Can edit the status of content using all status', 'editors', LIBERTY_PKG_NAME),
+ array('p_liberty_view_all_status', 'Can view content with any status', 'editors', LIBERTY_PKG_NAME),
+ array('p_liberty_edit_content_owner', 'Can edit the owner of content', 'editors', LIBERTY_PKG_NAME),
) );
?>
diff --git a/admin/upgrade_inc.php b/admin/upgrade_inc.php
index 66e3afa..a7ad7aa 100644
--- a/admin/upgrade_inc.php
+++ b/admin/upgrade_inc.php
@@ -143,9 +143,9 @@ array( 'QUERY' =>
"INSERT INTO `".BIT_DB_PREFIX."liberty_content_status` (`content_status_id`,`content_status_name`) VALUES (-30, 'Password Protected')",
"INSERT INTO `".BIT_DB_PREFIX."liberty_content_status` (`content_status_id`,`content_status_name`) VALUES (-20, 'Group Protected')",
"INSERT INTO `".BIT_DB_PREFIX."liberty_content_status` (`content_status_id`,`content_status_name`) VALUES (-10, 'Hidden')",
- "INSERT INTO `".BIT_DB_PREFIX."liberty_content_status` (`content_status_id`,`content_status_name`) VALUES (10, 'Draft')",
+ "INSERT INTO `".BIT_DB_PREFIX."liberty_content_status` (`content_status_id`,`content_status_name`) VALUES (-5, 'Draft')",
+ "INSERT INTO `".BIT_DB_PREFIX."liberty_content_status` (`content_status_id`,`content_status_name`) VALUES (-1, 'Pending Approval')",
"INSERT INTO `".BIT_DB_PREFIX."liberty_content_status` (`content_status_id`,`content_status_name`) VALUES (50, 'Available')",
- "INSERT INTO `".BIT_DB_PREFIX."liberty_content_status` (`content_status_id`,`content_status_name`) VALUES (101, 'Pending Approval')",
"INSERT INTO `".BIT_DB_PREFIX."liberty_content_status` (`content_status_id`,`content_status_name`) VALUES (102, 'Commercial')",
"INSERT INTO `".BIT_DB_PREFIX."liberty_content_status` (`content_status_id`,`content_status_name`) VALUES (200, 'Recommended')",
"INSERT INTO `".BIT_DB_PREFIX."liberty_content_status` (`content_status_id`,`content_status_name`) VALUES (999, 'Copy Protected')",
diff --git a/bit_setup_inc.php b/bit_setup_inc.php
index 594b237..ad4694a 100644
--- a/bit_setup_inc.php
+++ b/bit_setup_inc.php
@@ -3,7 +3,7 @@
* base package include
*
* @author spider <spider@steelsun.com>
- * @version $Revision: 1.11 $
+ * @version $Revision: 1.12 $
* @package liberty
* @subpackage functions
*/
@@ -17,6 +17,16 @@ $gBitSystem->registerPackage( $registerHash );
require_once( LIBERTY_PKG_PATH.'LibertySystem.php' );
+$gLibertySystem->registerService( 'liberty', LIBERTY_PKG_NAME, array(
+ 'content_edit_mini_tpl' => 'bitpackage:liberty/edit_content_inc.tpl',
+ 'content_load_sql_function' => 'liberty_content_load_sql',
+ 'content_list_sql_function' => 'liberty_content_list_sql',
+ // 'content_store_function' => 'liberty_content_store',
+ // 'content_edit_function' => 'liberty_content_edit',
+ 'content_preview_function' => 'liberty_content_preview',
+ // 'content_expunge_function' => 'liberty_content_expunge',
+) );
+
// load only the active plugins unless this is the first run after an install
$current_default_format_guid = $gBitSystem->getConfig( 'default_format' );
$plugin_status = $gBitSystem->getConfig( 'liberty_plugin_status_'.$current_default_format_guid );
diff --git a/templates/edit_content_status_inc.tpl b/templates/edit_content_status_inc.tpl
index a747f4e..fdb2dc5 100644
--- a/templates/edit_content_status_inc.tpl
+++ b/templates/edit_content_status_inc.tpl
@@ -1,8 +1,8 @@
-{if $gBitSystem->isFeatureActive( 'liberty_display_status' )}
+{if $gBitSystem->isFeatureActive( 'liberty_display_status' ) && ($gBitUser->hasPermission('p_liberty_edit_content_status') || $gBitUser->hasPermission('p_liberty_edit_all_status'))}
<div class="row">
- {formlabel label="Status"}
+ {formlabel label="Status" for="content_status_id"}
{forminput}
- {html_options name="content_status_id" options=$gLibertySystem->getContentStatus() selected=$gContent->getField('content_status_id',$smarty.const.BIT_CONTENT_DEFAULT_STATUS)}
+ {html_options name="content_status_id" options=$gContent->getContentStatus() selected=$gContent->getField('content_status_id',$smarty.const.BIT_CONTENT_DEFAULT_STATUS)}
{/forminput}
</div>
{/if}