diff --git a/includes/ajaxHandler/comment.class.php b/includes/ajaxHandler/comment.class.php index 3cf09e6d..35c22dd1 100644 --- a/includes/ajaxHandler/comment.class.php +++ b/includes/ajaxHandler/comment.class.php @@ -77,9 +77,13 @@ class AjaxComment extends AjaxHandler // i .. have problems believing, that everything uses nifty ajax while adding comments requires a brutal header(Loacation: ), yet, thats how it is protected function handleCommentAdd() { - if (!$this->_get['typeid'] || !$this->_get['type'] || !isset(Util::$typeStrings[$this->_get['type']])) + if (!$this->_get['typeid'] || !$this->_get['type'] || !isset(Util::$typeClasses[$this->_get['type']])) return; // whatever, we cant even send him back + // this type cannot be commented on + if (!(get_class_vars(Util::$typeClasses[$this->_get['type']])['contribute'] & CONTRIBUTE_CO)) + return; + // trim to max length if (!User::isInGroup(U_GROUP_MODERATOR) && mb_strlen($this->_post['commentbody']) > (self::COMMENT_LENGTH_MAX * (User::isPremium() ? 3 : 1))) $this->post['commentbody'] = mb_substr($this->_post['commentbody'], 0, (self::COMMENT_LENGTH_MAX * (User::isPremium() ? 3 : 1))); @@ -94,7 +98,7 @@ class AjaxComment extends AjaxHandler DB::Aowow()->query('INSERT INTO ?_comments_rates (commentId, userId, value) VALUES (?d, 0, 1)', $postIdx); // flag target with hasComment - if (Util::$typeClasses[$this->_get['type']] && ($tbl = get_class_vars(Util::$typeClasses[$this->_get['type']])['dataTable'])) + if ($tbl = get_class_vars(Util::$typeClasses[$this->_get['type']])['dataTable']) DB::Aowow()->query('UPDATE '.$tbl.' SET cuFlags = cuFlags | ?d WHERE id = ?d', CUSTOM_HAS_COMMENT, $this->_get['typeid']); } } diff --git a/includes/basetype.class.php b/includes/basetype.class.php index 84eebb30..614bd46e 100644 --- a/includes/basetype.class.php +++ b/includes/basetype.class.php @@ -17,6 +17,8 @@ abstract class BaseType protected $queryBase = ''; protected $queryOpts = []; + public static $contribute = CONTRIBUTE_ANY; + /* * condition as array [expression, value, operator] * expression: str - must match fieldname; diff --git a/includes/defines.php b/includes/defines.php index ef466fa2..4d9c0daa 100644 --- a/includes/defines.php +++ b/includes/defines.php @@ -208,6 +208,11 @@ define('CC_FLAG_APPROVED', 0x8); define('SOUND_TYPE_OGG', 1); define('SOUND_TYPE_MP3', 2); +define('CONTRIBUTE_CO', 0x1); +define('CONTRIBUTE_SS', 0x2); +define('CONTRIBUTE_VI', 0x4); +define('CONTRIBUTE_ANY', CONTRIBUTE_CO | CONTRIBUTE_SS | CONTRIBUTE_VI); + /* * Game */ diff --git a/includes/types/sound.class.php b/includes/types/sound.class.php index b71e466a..a7fa0440 100644 --- a/includes/types/sound.class.php +++ b/includes/types/sound.class.php @@ -8,11 +8,12 @@ class SoundList extends BaseType { use spawnHelper; - public static $type = TYPE_SOUND; - public static $brickFile = 'sound'; - public static $dataTable = '?_sounds'; + public static $type = TYPE_SOUND; + public static $brickFile = 'sound'; + public static $dataTable = '?_sounds'; + public static $contribute = CONTRIBUTE_CO; - protected $queryBase = 'SELECT *, s.id AS ARRAY_KEY FROM ?_sounds s'; + protected $queryBase = 'SELECT *, s.id AS ARRAY_KEY FROM ?_sounds s'; private $fileBuffer = []; private static $fileTypes = array( diff --git a/pages/genericPage.class.php b/pages/genericPage.class.php index 30c11ac0..bd974e6a 100644 --- a/pages/genericPage.class.php +++ b/pages/genericPage.class.php @@ -16,6 +16,8 @@ trait DetailPage protected $subject = null; // so it will not get cached + protected $contribute = CONTRIBUTE_ANY; + protected function generateCacheKey($withStaff = true) { $staff = intVal($withStaff && User::isInGroup(U_GROUP_EMPLOYEE)); @@ -287,6 +289,10 @@ class GenericPage if (method_exists($this, 'postCache')) // e.g. update dates for events and such $this->postCache(); + // determine contribute tabs + if (isset($this->subject)) + $this->contribute = $this->subject::$contribute; + if (!empty($this->hasComContent)) // get comments, screenshots, videos { $this->community = CommunityContent::getAll($this->type, $this->typeId, $jsGlobals); diff --git a/pages/screenshot.php b/pages/screenshot.php index 8ccdf668..2d074e74 100644 --- a/pages/screenshot.php +++ b/pages/screenshot.php @@ -47,6 +47,10 @@ class ScreenshotPage extends GenericPage if (empty(Util::$typeClasses[$m[1]])) $this->error(); + // this type cannot receive screenshots + if (!(get_class_vars(Util::$typeClasses[$m[1]])['contribute'] & CONTRIBUTE_SS)) + $this->error(); + $t = Util::$typeClasses[$m[1]]; $c = [['id', intVal($m[2])]]; diff --git a/pages/utility.php b/pages/utility.php index ee45285d..7f42c174 100644 --- a/pages/utility.php +++ b/pages/utility.php @@ -165,11 +165,14 @@ class UtilityPage extends GenericPage if (!User::isInGroup(U_GROUP_EMPLOYEE)) $cnd[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0]; - foreach (Util::$typeClasses as $classStr) + foreach (Util::$typeClasses as $type => $classStr) { if (!$classStr) continue; + if (!($classStr::$contribute & CONTRIBUTE_SS)) + continue; + $typeObj = new $classStr($cnd); if (!$typeObj->error) { diff --git a/template/bricks/contribute.tpl.php b/template/bricks/contribute.tpl.php index 4e4ddbca..fe10051b 100644 --- a/template/bricks/contribute.tpl.php +++ b/template/bricks/contribute.tpl.php @@ -1,3 +1,6 @@ +contribute)); +?>

@@ -12,9 +15,18 @@
+ diff --git a/template/bricks/lvTabs.tpl.php b/template/bricks/lvTabs.tpl.php index 380cf27d..c1049698 100644 --- a/template/bricks/lvTabs.tpl.php +++ b/template/bricks/lvTabs.tpl.php @@ -62,12 +62,16 @@ if (!empty($this->user)): echo ' us_addProfilesTab('.Util::toJSON($this->user['profileData']).");\n"; endif; elseif ($relTabs): -?> - new Listview({template: 'comment', id: 'comments', name: LANG.tab_comments, tabs: , parent: 'lv-generic', data: lv_comments}); - new Listview({template: 'screenshot', id: 'screenshots', name: LANG.tab_screenshots, tabs: , parent: 'lv-generic', data: lv_screenshots}); - if (lv_videos.length || (g_user && g_user.roles & (U_GROUP_ADMIN | U_GROUP_BUREAU | U_GROUP_VIDEO))) - new Listview({template: 'video', id: 'videos', name: LANG.tab_videos, tabs: , parent: 'lv-generic', data: lv_videos}); -contribute & CONTRIBUTE_CO): + echo " new Listview({template: 'comment', id: 'comments', name: LANG.tab_comments, tabs: ".$tabVar.", parent: 'lv-generic', data: lv_comments});\n"; + endif; + if ($this->contribute & CONTRIBUTE_SS): + echo " new Listview({template: 'screenshot', id: 'screenshots', name: LANG.tab_screenshots, tabs: ".$tabVar.", parent: 'lv-generic', data: lv_screenshots});\n"; + endif; + if ($this->contribute & CONTRIBUTE_VI): + echo " if (lv_videos.length || (g_user && g_user.roles & (U_GROUP_ADMIN | U_GROUP_BUREAU | U_GROUP_VIDEO)))\n"; + echo " new Listview({template: 'video', id: 'videos', name: LANG.tab_videos, tabs: ".$tabVar.", parent: 'lv-generic', data: lv_videos});\n"; + endif; endif; if ($isTabbed):