summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-05-21 15:01:53 +0100
committerLester Caine <lester@lsces.co.uk>2026-05-21 15:01:53 +0100
commit4077c49356aadbd2fe0498c1655966407c4165dd (patch)
treeefddbc57d9296f951ddef3be326c62a83181fb7b
parentf8a1163dd190ecd2db88513a2dbb6138d67573f9 (diff)
downloadprotector-4077c49356aadbd2fe0498c1655966407c4165dd.tar.gz
protector-4077c49356aadbd2fe0498c1655966407c4165dd.tar.bz2
protector-4077c49356aadbd2fe0498c1655966407c4165dd.zip
Fix storeProtection can't reset to System Default; tidy getProtectionList
- storeProtection: check isset(role_id) and valid content_id rather than verifyId(role_id) — role_id=-1 (System Default) now correctly DELETEs any existing role restriction instead of being skipped entirely - getProtectionList: remove garbled dead initialiser, use verifyId() guard Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
-rwxr-xr-xincludes/classes/LibertyProtector.php9
1 files changed, 4 insertions, 5 deletions
diff --git a/includes/classes/LibertyProtector.php b/includes/classes/LibertyProtector.php
index 823f375..249f76b 100755
--- a/includes/classes/LibertyProtector.php
+++ b/includes/classes/LibertyProtector.php
@@ -36,7 +36,7 @@ class LibertyProtector extends LibertyBase {
*/
public function storeProtection( &$pParamHash ) {
global $gBitSystem;
- if( \Bitweaver\BitBase::verifyId( $pParamHash['protector']['role_id'] ?? 0 ) ) {
+ if( isset( $pParamHash['protector']['role_id'] ) && \Bitweaver\BitBase::verifyId( $pParamHash['content_id'] ) ) {
$this->mDb->query( "DELETE FROM `".BIT_DB_PREFIX."liberty_content_role_map` WHERE `content_id`=?", [ $pParamHash['content_id'] ] );
if( $gBitSystem->isFeatureActive( 'protector_single_role' ) ) {
if( $pParamHash['protector']['role_id'] != -1 )
@@ -44,7 +44,7 @@ class LibertyProtector extends LibertyBase {
} else {
foreach( $pParamHash['protector']['role_id'] AS $roleId ) {
if( $roleId != -1 )
- $this->mDb->query( "INSERT INTO `".BIT_DB_PREFIX."liberty_content_role_map` ( `role_id`, `content_id` ) VALUES ( ?, ? )", [ $roleId, $pParamHash['content_id'] ] );
+ $this->mDb->query( "INSERT INTO `".BIT_DB_PREFIX."liberty_content_role_map` ( `role_id`, `content_id` ) VALUES ( ?, ? )", [ $roleId, $pParamHash['content_id'] ] );
}
}
}
@@ -69,9 +69,8 @@ class LibertyProtector extends LibertyBase {
* Ret -1 for anonymouse if alternatives are not stored
**/
public function getProtectionList( $ContentId = 0 ) {
- global $gBitSystem;
- $ret = [ '-1' <= $ContentId ];
- if( isset( $ContentId ) ) {
+ $ret = [];
+ if( \Bitweaver\BitBase::verifyId( $ContentId ) ) {
$ret = $this->mDb->GetAssoc( "SELECT `role_id`, `content_id` FROM `".BIT_DB_PREFIX."liberty_content_role_map` WHERE `content_id`=?", [ $ContentId ] );
}
return $ret;