mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
Contribute
* added option to hide contribute tabs depending on subject (screenshots for sounds .. yeah, right)
This commit is contained in:
@@ -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: <wherever>), 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']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -11,6 +11,7 @@ class SoundList extends BaseType
|
||||
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';
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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])]];
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
<?php
|
||||
if (!empty($this->contribute));
|
||||
?>
|
||||
<div class="clear"></div>
|
||||
<div class="text">
|
||||
<h2><?php echo Lang::main('contribute'); ?></h2>
|
||||
@@ -12,9 +15,18 @@
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
var tabsContribute = new Tabs({parent: $WH.ge('tabs-contribute-generic')});
|
||||
tabsContribute.add(LANG.tab_addyourcomment, {id: 'add-your-comment'});
|
||||
tabsContribute.add(LANG.tab_submitascreenshot, {id: 'submit-a-screenshot'});
|
||||
if (g_user && g_user.roles & (U_GROUP_ADMIN | U_GROUP_BUREAU | U_GROUP_VIDEO))
|
||||
tabsContribute.add(LANG.tab_suggestavideo, {id: 'suggest-a-video'});
|
||||
<?php
|
||||
if ($this->contribute & CONTRIBUTE_CO):
|
||||
echo " tabsContribute.add(LANG.tab_addyourcomment, {id: 'add-your-comment'});\n";
|
||||
endif;
|
||||
if ($this->contribute & CONTRIBUTE_SS):
|
||||
echo " tabsContribute.add(LANG.tab_submitascreenshot, {id: 'submit-a-screenshot'});\n";
|
||||
endif;
|
||||
if ($this->contribute & CONTRIBUTE_VI):
|
||||
echo " if (g_user && g_user.roles & (U_GROUP_ADMIN | U_GROUP_BUREAU | U_GROUP_VIDEO))\n";
|
||||
echo " tabsContribute.add(LANG.tab_suggestavideo, {id: 'suggest-a-video'});\n";
|
||||
endif;
|
||||
?>
|
||||
tabsContribute.flush();
|
||||
</script>
|
||||
<? endif; ?>
|
||||
|
||||
@@ -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: <?=$tabVar; ?>, parent: 'lv-generic', data: lv_comments});
|
||||
new Listview({template: 'screenshot', id: 'screenshots', name: LANG.tab_screenshots, tabs: <?=$tabVar; ?>, 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: <?=$tabVar; ?>, parent: 'lv-generic', data: lv_videos});
|
||||
<?php
|
||||
if ($this->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):
|
||||
|
||||
Reference in New Issue
Block a user