Commit 3eb78c2a authored by Shawn Kwang's avatar Shawn Kwang

Drupal: Changed flags machine names to 1, 2, 3.

Modified logic when flags are locked: now user sees link as 'Locked'.
Removed flag_access function.
parent 266b8636
......@@ -75,9 +75,23 @@ features[fieldgroup][] = "page-group_boinctranslate_opts"
features[filter_formats][] = "php_code"
features[filter_formats][] = "plain_text"
features[filter_formats][] = "rich_text"
features[flag][] = "abuse_comment"
features[flag][] = "abuse_node"
features[flag][] = "abuse_user"
features[flag][] = "abuse_comment_1"
features[flag][] = "abuse_comment_2"
features[flag][] = "abuse_comment_3"
features[flag][] = "abuse_comment_4"
features[flag][] = "abuse_comment_5"
features[flag][] = "abuse_comment_meta"
features[flag][] = "abuse_node_1"
features[flag][] = "abuse_node_2"
features[flag][] = "abuse_node_3"
features[flag][] = "abuse_node_4"
features[flag][] = "abuse_node_5"
features[flag][] = "abuse_node_meta"
features[flag][] = "abuse_user_1"
features[flag][] = "abuse_user_2"
features[flag][] = "abuse_user_3"
features[flag][] = "abuse_user_4"
features[flag][] = "abuse_user_meta"
features[flag][] = "subscriptions"
features[menu_custom][] = "menu-footer-links"
features[menu_links][] = "primary-links:<front>"
......
......@@ -51,25 +51,36 @@ function flag_abuse_reason_preprocess_flag(&$vars) {
drupal_add_css(drupal_get_path('module', 'flag_abuse_reason') . "/css/flag_abuse_reason.css");
global $user;
$metaflags = array('abuse_node_meta', 'abuse_comment_meta', 'abuse_user_meta');
// permmission check instead of a role
if (user_access('reset abuse flags', $user)) {
$metaflags = array('abuse_node_meta', 'abuse_comment_meta', 'abuse_user_meta');
// Is this one of our abuse flags?
if (in_array($vars['flag']->name, $metaflags)) {
// Is this one of our abuse flags?
if (in_array($vars['flag']->name, $metaflags)) {
// count the number of flags on this content
$count = db_result(db_query("SELECT COUNT(*) FROM {flag_content} WHERE content_id=%d AND fid=%d", $vars['content_id'], $vars['flag']->fid));
// count the number of flags on this content
$count = db_result(db_query("SELECT COUNT(*) FROM {flag_content} WHERE content_id=%d AND fid=%d", $vars['content_id'], $vars['flag']->fid));
// If the variable <flagname>-<contentid> is set, then Reset
// completely.
if (variable_get($vars['flag']->name.'-'.$vars['content_id'], FALSE)) {
// If the variable <flagname>-<contentid> is set, then Reset
// completely.
if (variable_get($vars['flag']->name.'-'.$vars['content_id'], FALSE)) {
if (user_access('reset abuse flags', $user)) {
$vars['action'] = 'none';
$vars['link_text'] = t('Reset Completely');
$vars['link_title'] = t('Reset everying, allows users to re-flag content.');
}
else {
// If there are flags on this content, clear the flags and
// lock the content.
$vars['action'] = 'none';
$vars['link_text'] = t('Locked');
$vars['link_title'] = t('Reporting locked by moderator.');
$vars['link'] = array();
$vars['link_href'] = '';
$vars['flag_classes'] = 'flag style-like-link';
}
}
else {
// If there are flags on this content, clear the flags and
// lock the content.
if (user_access('reset abuse flags', $user)) {
if ($count>0) {
$vars['action'] = 'reset';
$vars['link_text'] = t('Clear Reports and Lock');
......@@ -80,9 +91,11 @@ function flag_abuse_reason_preprocess_flag(&$vars) {
$vars['action'] = 'none';
$vars['link_text'] = t('No abuse reports');
$vars['link_title'] = t('This content has no abuse reports. Link does nothing.');
$vars['link'] = array();
$vars['link_href'] = '';
$vars['flag_classes'] = 'flag style-like-link';
}
}
}
}
}
......@@ -154,6 +167,7 @@ function flag_abuse_reason_flag($event, $flag, $content_id, $account) {
* Implementation of hook_flag_access().
*/
function flag_abuse_reason_flag_access($flag, $content_id, $action, $account) {
/* @todo - consider removing block
$metaflags = array('abuse_node_meta', 'abuse_comment_meta', 'abuse_user_meta');
if (in_array($flag->name, $metaflags)) {
// Check to see if this flag is locked.
......@@ -167,6 +181,7 @@ function flag_abuse_reason_flag_access($flag, $content_id, $action, $account) {
}
}
}
*/
}
/**
......
......@@ -8,15 +8,15 @@
* Define the flags for the flag_abuse_module. There are multiple
* flags for each content type: node, comment, and user. Each has a
* 'meta' flag which helps organize the 'subflags' for each type. Each
* subflag is labeled A, B, C, etc. There are five for node and
* subflag is labeled 1, 2, 3, etc. There are five for node and
* comment; four for user. More may be added here if necessary.
*
* In the admin flag interface, after adding the meta flags and flags
* A, B, C, etc. The admin may give the A, B, C, flags titles to make
* 1, 2, 3, etc. The admin may give the 1, 2, 3, flags titles to make
* them clear what each flag does. The machine readable name will
* still be use letters A, B, C, but the title, description, links,
* still be use number 1, 2, 3, but the title, description, links,
* etc should all be changed to be human readable as well as
* specific. E.g., abuse_node_a should be used for SPAM nodes.
* specific. Example: abuse_node_1 should be used for SPAM nodes.
*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * *
......@@ -70,15 +70,15 @@ function _flag_abuse_reason_abuse_node_flags(&$flags) {
'name' => 'name',
'global' => 'global',
),
'module' => 'flag_abuse',
'module' => 'flag_abuse_reason',
'api_version' => 2,
);
// Exported flag: "Node Abuse A".
// Exported flag: "Node Abuse 1".
$flags[] = array (
'content_type' => 'node',
'name' => 'abuse_node_a',
'title' => 'Node Abuse A',
'name' => 'abuse_node_1',
'title' => 'Node Abuse 1',
'global' => false,
'types' => array (
'0' => 'forum',
......@@ -121,15 +121,15 @@ function _flag_abuse_reason_abuse_node_flags(&$flags) {
'name' => 'name',
'global' => 'global',
),
'module' => 'flag_abuse',
'module' => 'flag_abuse_reason',
'api_version' => 2,
);
// Exported flag: "Node Abuse B".
// Exported flag: "Node Abuse 2".
$flags[] = array (
'content_type' => 'node',
'name' => 'abuse_node_b',
'title' => 'Node Abuse B',
'name' => 'abuse_node_2',
'title' => 'Node Abuse 2',
'global' => false,
'types' => array (
'0' => 'forum',
......@@ -172,15 +172,15 @@ function _flag_abuse_reason_abuse_node_flags(&$flags) {
'name' => 'name',
'global' => 'global',
),
'module' => 'flag_abuse',
'module' => 'flag_abuse_reason',
'api_version' => 2,
);
// Exported flag: "Node Abuse C".
// Exported flag: "Node Abuse 3".
$flags[] = array (
'content_type' => 'node',
'name' => 'abuse_node_c',
'title' => 'Node Abuse C',
'name' => 'abuse_node_3',
'title' => 'Node Abuse 3',
'global' => false,
'types' => array (
'0' => 'forum',
......@@ -223,15 +223,15 @@ function _flag_abuse_reason_abuse_node_flags(&$flags) {
'name' => 'name',
'global' => 'global',
),
'module' => 'flag_abuse',
'module' => 'flag_abuse_reason',
'api_version' => 2,
);
// Exported flag: "Node Abuse D".
// Exported flag: "Node Abuse 4".
$flags[] = array (
'content_type' => 'node',
'name' => 'abuse_node_d',
'title' => 'Node Abuse D',
'name' => 'abuse_node_4',
'title' => 'Node Abuse 4',
'global' => false,
'types' => array (
'0' => 'forum',
......@@ -274,15 +274,15 @@ function _flag_abuse_reason_abuse_node_flags(&$flags) {
'name' => 'name',
'global' => 'global',
),
'module' => 'flag_abuse',
'module' => 'flag_abuse_reason',
'api_version' => 2,
);
// Exported flag: "Node Abuse E".
// Exported flag: "Node Abuse 5".
$flags[] = array (
'content_type' => 'node',
'name' => 'abuse_node_e',
'title' => 'Node Abuse E',
'name' => 'abuse_node_5',
'title' => 'Node Abuse 5',
'global' => false,
'types' => array (
'0' => 'forum',
......@@ -325,7 +325,7 @@ function _flag_abuse_reason_abuse_node_flags(&$flags) {
'name' => 'name',
'global' => 'global',
),
'module' => 'flag_abuse',
'module' => 'flag_abuse_reason',
'api_version' => 2,
);
......@@ -382,15 +382,15 @@ function _flag_abuse_reason_abuse_comment_flags(&$flags) {
'name' => 'name',
'global' => 'global',
),
'module' => 'flag_abuse',
'module' => 'flag_abuse_reason',
'api_version' => 2,
);
// Exported flag: "Comment Abuse A".
// Exported flag: "Comment Abuse 1".
$flags[] = array (
'content_type' => 'comment',
'name' => 'abuse_comment_a',
'title' => 'Comment Abuse A',
'name' => 'abuse_comment_1',
'title' => 'Comment Abuse 1',
'global' => false,
'types' => array (
'0' => 'forum',
......@@ -430,15 +430,15 @@ function _flag_abuse_reason_abuse_comment_flags(&$flags) {
'name' => 'name',
'global' => 'global',
),
'module' => 'flag_abuse',
'module' => 'flag_abuse_reason',
'api_version' => 2,
);
// Exported flag: "Comment Abuse B".
// Exported flag: "Comment Abuse 2".
$flags[] = array (
'content_type' => 'comment',
'name' => 'abuse_comment_b',
'title' => 'Comment Abuse B',
'name' => 'abuse_comment_2',
'title' => 'Comment Abuse 2',
'global' => false,
'types' => array (
'0' => 'forum',
......@@ -478,15 +478,15 @@ function _flag_abuse_reason_abuse_comment_flags(&$flags) {
'name' => 'name',
'global' => 'global',
),
'module' => 'flag_abuse',
'module' => 'flag_abuse_reason',
'api_version' => 2,
);
// Exported flag: "Comment Abuse C".
// Exported flag: "Comment Abuse 3".
$flags[] = array (
'content_type' => 'comment',
'name' => 'abuse_comment_c',
'title' => 'Comment Abuse C',
'name' => 'abuse_comment_3',
'title' => 'Comment Abuse 3',
'global' => false,
'types' => array (
'0' => 'forum',
......@@ -526,15 +526,15 @@ function _flag_abuse_reason_abuse_comment_flags(&$flags) {
'name' => 'name',
'global' => 'global',
),
'module' => 'flag_abuse',
'module' => 'flag_abuse_reason',
'api_version' => 2,
);
// Exported flag: "Comment Abuse D".
// Exported flag: "Comment Abuse 4".
$flags[] = array (
'content_type' => 'comment',
'name' => 'abuse_comment_d',
'title' => 'Comment Abuse D',
'name' => 'abuse_comment_4',
'title' => 'Comment Abuse 4',
'global' => false,
'types' => array (
'0' => 'forum',
......@@ -574,15 +574,15 @@ function _flag_abuse_reason_abuse_comment_flags(&$flags) {
'name' => 'name',
'global' => 'global',
),
'module' => 'flag_abuse',
'module' => 'flag_abuse_reason',
'api_version' => 2,
);
// Exported flag: "Comment Abuse E".
// Exported flag: "Comment Abuse 5".
$flags[] = array (
'content_type' => 'comment',
'name' => 'abuse_comment_e',
'title' => 'Comment Abuse E',
'name' => 'abuse_comment_5',
'title' => 'Comment Abuse 5',
'global' => false,
'types' => array (
'0' => 'forum',
......@@ -622,7 +622,7 @@ function _flag_abuse_reason_abuse_comment_flags(&$flags) {
'name' => 'name',
'global' => 'global',
),
'module' => 'flag_abuse',
'module' => 'flag_abuse_reason',
'api_version' => 2,
);
......@@ -674,15 +674,15 @@ function _flag_abuse_reason_abuse_user_flags(&$flags) {
'name' => 'name',
'global' => 'global',
),
'module' => 'flag_abuse',
'module' => 'flag_abuse_reason',
'api_version' => 2,
);
// Exported flag: "User Abuse A".
// Exported flag: "User Abuse 1".
$flags[] = array (
'content_type' => 'user',
'name' => 'abuse_user_a',
'title' => 'User Abuse A',
'name' => 'abuse_user_1',
'title' => 'User Abuse 1',
'global' => false,
'types' => array (
),
......@@ -719,15 +719,15 @@ function _flag_abuse_reason_abuse_user_flags(&$flags) {
'name' => 'name',
'global' => 'global',
),
'module' => 'flag_abuse',
'module' => 'flag_abuse_reason',
'api_version' => 2,
);
// Exported flag: "User Abuse B".
// Exported flag: "User Abuse 2".
$flags[] = array (
'content_type' => 'user',
'name' => 'abuse_user_b',
'title' => 'User Abuse B',
'name' => 'abuse_user_2',
'title' => 'User Abuse 2',
'global' => false,
'types' => array (
),
......@@ -764,15 +764,15 @@ function _flag_abuse_reason_abuse_user_flags(&$flags) {
'name' => 'name',
'global' => 'global',
),
'module' => 'flag_abuse',
'module' => 'flag_abuse_reason',
'api_version' => 2,
);
// Exported flag: "User Abuse C".
// Exported flag: "User Abuse 3".
$flags[] = array (
'content_type' => 'user',
'name' => 'abuse_user_c',
'title' => 'User Abuse C',
'name' => 'abuse_user_3',
'title' => 'User Abuse 3',
'global' => false,
'types' => array (
),
......@@ -809,15 +809,15 @@ function _flag_abuse_reason_abuse_user_flags(&$flags) {
'name' => 'name',
'global' => 'global',
),
'module' => 'flag_abuse',
'module' => 'flag_abuse_reason',
'api_version' => 2,
);
// Exported flag: "User Abuse D".
// Exported flag: "User Abuse 4".
$flags[] = array (
'content_type' => 'user',
'name' => 'abuse_user_d',
'title' => 'User Abuse D',
'name' => 'abuse_user_4',
'title' => 'User Abuse 4',
'global' => false,
'types' => array (
),
......@@ -854,7 +854,7 @@ function _flag_abuse_reason_abuse_user_flags(&$flags) {
'name' => 'name',
'global' => 'global',
),
'module' => 'flag_abuse',
'module' => 'flag_abuse_reason',
'api_version' => 2,
);
......
......@@ -45,6 +45,14 @@ $(document).bind('flagGlobalBeforeLinkUpdate', function(event, data) {
ddelement.style.display = "none";
}
}
// User unflags by Cancel Report - refresh page
if ( window.getComputedStyle(ddelement).display === "none" &&
data.flagName == "abuse_node_meta" &&
data.flagStatus == "unflagged" ) {
window.location.reload();
}
break;
case 'comment':
......@@ -70,6 +78,14 @@ $(document).bind('flagGlobalBeforeLinkUpdate', function(event, data) {
ddelement.style.display = "none";
}
}
// User unflags by Cancel Report - refresh page
if ( window.getComputedStyle(ddelement).display === "none" &&
data.flagName == "abuse_comment_meta" &&
data.flagStatus == "unflagged" ) {
window.location.reload();
}
break;
case 'user':
......@@ -95,6 +111,14 @@ $(document).bind('flagGlobalBeforeLinkUpdate', function(event, data) {
ddelement.style.display = "none";
}
}
// User unflags by Cancel Report - refresh page
if ( window.getComputedStyle(ddelement).display === "none" &&
data.flagName == "abuse_user_meta" &&
data.flagStatus == "unflagged" ) {
window.location.reload();
}
break;
} //switch
......
......@@ -185,11 +185,11 @@
<?php endif; ?>
<div class="dropdown">
<div id="<?php print $ddname; ?>" class="dropdown-content">
<?php print flag_create_link('abuse_comment_a', $comment->cid); ?>
<?php print flag_create_link('abuse_comment_b', $comment->cid); ?>
<?php print flag_create_link('abuse_comment_c', $comment->cid); ?>
<?php print flag_create_link('abuse_comment_d', $comment->cid); ?>
<?php print flag_create_link('abuse_comment_e', $comment->cid); ?>
<?php print flag_create_link('abuse_comment_1', $comment->cid); ?>
<?php print flag_create_link('abuse_comment_2', $comment->cid); ?>
<?php print flag_create_link('abuse_comment_3', $comment->cid); ?>
<?php print flag_create_link('abuse_comment_4', $comment->cid); ?>
<?php print flag_create_link('abuse_comment_5', $comment->cid); ?>
</div>
</div>
<div class="content">
......
......@@ -217,11 +217,11 @@
<div class="dropdown">
<div id="<?php print $ddname; ?>" class="dropdown-content">
<?php print flag_create_link('abuse_node_a', $node->nid); ?>
<?php print flag_create_link('abuse_node_b', $node->nid); ?>
<?php print flag_create_link('abuse_node_c', $node->nid); ?>
<?php print flag_create_link('abuse_node_d', $node->nid); ?>
<?php print flag_create_link('abuse_node_e', $node->nid); ?>
<?php print flag_create_link('abuse_node_1', $node->nid); ?>
<?php print flag_create_link('abuse_node_2', $node->nid); ?>
<?php print flag_create_link('abuse_node_3', $node->nid); ?>
<?php print flag_create_link('abuse_node_4', $node->nid); ?>
<?php print flag_create_link('abuse_node_5', $node->nid); ?>
</div>
</div>
<div class="content">
......
......@@ -233,11 +233,11 @@
<div class="dropdown">
<div id="<?php print $ddname; ?>" class="dropdown-content">
<?php print flag_create_link('abuse_node_a', $node->nid); ?>
<?php print flag_create_link('abuse_node_b', $node->nid); ?>
<?php print flag_create_link('abuse_node_c', $node->nid); ?>
<?php print flag_create_link('abuse_node_d', $node->nid); ?>
<?php print flag_create_link('abuse_node_e', $node->nid); ?>
<?php print flag_create_link('abuse_node_1', $node->nid); ?>
<?php print flag_create_link('abuse_node_2', $node->nid); ?>
<?php print flag_create_link('abuse_node_3', $node->nid); ?>
<?php print flag_create_link('abuse_node_4', $node->nid); ?>
<?php print flag_create_link('abuse_node_5', $node->nid); ?>
</div>
</div>
<div class="content">
......
......@@ -236,10 +236,10 @@ if ($user->uid AND ($user->uid != $account->uid)) {
?>
<div class="dropdown">
<div id="<?php print $ddname; ?>" class="dropdown-content">
<?php print flag_create_link('abuse_user_a', $account->uid); ?>
<?php print flag_create_link('abuse_user_b', $account->uid); ?>
<?php print flag_create_link('abuse_user_c', $account->uid); ?>
<?php print flag_create_link('abuse_user_d', $account->uid); ?>
<?php print flag_create_link('abuse_user_e', $account->uid); ?>
<?php print flag_create_link('abuse_user_1', $account->uid); ?>
<?php print flag_create_link('abuse_user_2', $account->uid); ?>
<?php print flag_create_link('abuse_user_3', $account->uid); ?>
<?php print flag_create_link('abuse_user_4', $account->uid); ?>
<?php print flag_create_link('abuse_user_5', $account->uid); ?>
</div>
</div>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment