Skip to content

Commit

Permalink
Merge pull request #333 from moreonion/supporter-mgmt-permissions
Browse files Browse the repository at this point in the history
feat(manage): Show the manage supporters UI without editing permissions
  • Loading branch information
torotil authored Jun 17, 2024
2 parents 7c2db93 + 67e3fac commit dff234b
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 4 deletions.
2 changes: 1 addition & 1 deletion campaignion_manage/campaignion_manage.module
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function campaignion_manage_menu() {
$items['admin/supporters'] = array(
'title' => t('Manage Supporters'),
'type' => MENU_NORMAL_ITEM,
'access arguments' => array('manage redhen contacts'),
'access arguments' => array('access redhen contacts'),
'page callback' => 'campaignion_manage_supporters_page',
);
return $items;
Expand Down
8 changes: 8 additions & 0 deletions campaignion_manage/src/BulkOp/ContentPublish.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,12 @@ public function apply($nids, $values) {

return $messages;
}

/**
* Check if the currently active user has access to the operation.
*/
public function userHasAccess() {
return user_access('bypass node access') || user_access('administer nodes');
}

}
8 changes: 8 additions & 0 deletions campaignion_manage/src/BulkOp/ContentUnpublish.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,12 @@ public function apply($nids, $values) {

return $messages;
}

/**
* Check if the currently active user has access to the operation.
*/
public function userHasAccess() {
return user_access('bypass node access') || user_access('administer nodes');
}

}
14 changes: 11 additions & 3 deletions campaignion_manage/src/BulkOp/SupporterExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function batchFinish(&$data, &$results) {
* @param integer $level GZIP compression level (default: 9)
* @return string New filename (with .gz appended) if success, or FALSE if operation fails
*/
protected function compressFile($src_file_name, $dest_file_name = NULL, $level = 9){
protected function compressFile($src_file_name, $dest_file_name = NULL, $level = 9){
if ($dest_file_name == NULL) {
$dest_file_name = $src_file_name . '.gz';
}
Expand All @@ -114,13 +114,21 @@ protected function compressFile($src_file_name, $dest_file_name = NULL, $level =
fclose($fp_in);
}
else {
$result = FALSE;
$result = FALSE;
}
gzclose($fp_out);
gzclose($fp_out);
} else {
$result = FALSE;
}

return $result;
}

/**
* Check if the currently active user has access to the operation.
*/
public function userHasAccess() {
return user_access('administer redhen contacts') || user_access('manage redhen contacts') || user_access('access redhen contacts');
}

}
8 changes: 8 additions & 0 deletions campaignion_manage/src/BulkOp/SupporterNewsletter.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,12 @@ public function getBatch(&$data) {
}

public function batchFinish(&$data, &$results) {}

/**
* Check if the currently active user has access to the operation.
*/
public function userHasAccess() {
return user_access('administer redhen contacts') || user_access('manage redhen contacts');
}

}
8 changes: 8 additions & 0 deletions campaignion_manage/src/BulkOp/SupporterTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,12 @@ public function batchFinish(&$data, &$results) {
}
}
}

/**
* Check if the currently active user has access to the operation.
*/
public function userHasAccess() {
return user_access('administer redhen contacts') || user_access('manage redhen contacts');
}

}
3 changes: 3 additions & 0 deletions campaignion_manage/src/BulkOpForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ public function form(&$form, &$form_state) {
);

foreach ($this->ops as $name => $op) {
if (!$op->userHasAccess()) {
continue;
}
$form['bulk-wrapper']['operations']['#options'][$name] = $op->title();
$form['bulk-wrapper']['op-wrapper']['op'][$name] = array(
'#type' => 'fieldset',
Expand Down

0 comments on commit dff234b

Please sign in to comment.