Skip to content

Commit 77c6423

Browse files
authored
Merge pull request #142 from RRZE-Webteam/dev
Dev
2 parents e46938b + a9091b1 commit 77c6423

File tree

2 files changed

+34
-13
lines changed

2 files changed

+34
-13
lines changed

cms-workflow.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*
44
Plugin Name: CMS-Workflow
55
Plugin URI: https://github.com/RRZE-Webteam/cms-workflow
6-
Version: 2.0.3
6+
Version: 2.0.4
77
Description: Redaktioneller Workflow.
88
Author: RRZE-Webteam
99
Author URI: https://blogs.fau.de/webworking/

includes/Modules/Authors/Authors.php

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,13 @@ public function enqueue_admin_scripts()
186186
{
187187
wp_enqueue_script('jquery-listfilterizer');
188188
wp_enqueue_script(
189-
'workflow-authors',
190-
$this->module_url . 'authors.js',
191-
array('jquery',
192-
'jquery-listfilterizer'),
193-
plugin()->getVersion(),
189+
'workflow-authors',
190+
$this->module_url . 'authors.js',
191+
array(
192+
'jquery',
193+
'jquery-listfilterizer'
194+
),
195+
plugin()->getVersion(),
194196
true
195197
);
196198

@@ -205,9 +207,9 @@ public function enqueue_admin_styles()
205207
{
206208
wp_enqueue_style('jquery-listfilterizer');
207209
wp_enqueue_style(
208-
'workflow-authors',
209-
$this->module->module_url . 'authors.css',
210-
false,
210+
'workflow-authors',
211+
$this->module->module_url . 'authors.css',
212+
false,
211213
plugin()->getVersion(),
212214
);
213215
}
@@ -229,7 +231,7 @@ public function add_post_meta_box($post_type)
229231

230232
public function authors_meta_box($post)
231233
{
232-
?>
234+
?>
233235
<div id="workflow-post-authors-box">
234236
<p><?php _e('Wählen Sie die Autoren zum Dokument', 'cms-workflow'); ?></p>
235237
<div id="workflow-post-authors-inside">
@@ -416,7 +418,7 @@ private function add_post_users($post, $users, $append = true)
416418

417419
public function add_post_usergroups($post, $usergroups, $append = true)
418420
{
419-
421+
420422

421423
if (!$this->module_activated('user_groups')) {
422424
return;
@@ -604,6 +606,14 @@ public function filter_user_has_cap($allcaps, $caps, $args)
604606
$user_id = isset($args[1]) ? $args[1] : 0;
605607
$post_id = isset($args[2]) ? $args[2] : 0;
606608

609+
if (is_a($post_id, 'WP_Block_Editor_Context')) {
610+
$post_id = $post_id->post->ID;
611+
}
612+
613+
if (!is_int($post_id) || $post_id == 0) {
614+
return $allcaps;
615+
}
616+
607617
if ($revision_parent_id = wp_is_post_revision($post_id)) {
608618
$post_id = $revision_parent_id;
609619
}
@@ -616,7 +626,7 @@ public function filter_user_has_cap($allcaps, $caps, $args)
616626

617627
$post_type_obj = get_post_type_object($post_type);
618628

619-
if (!$post_type_obj) {
629+
if (is_null($post_type_obj)) {
620630
return $allcaps;
621631
}
622632

@@ -630,6 +640,13 @@ public function filter_user_has_cap($allcaps, $caps, $args)
630640
return $allcaps;
631641
}
632642

643+
$status = get_post_status($post_id);
644+
645+
if ($status == 'publish' && isset($allcaps["edit_published_{$post_type}s"]) && !isset($allcaps["publish_{$post_type}s"])) {
646+
$allcaps["publish_{$post_type}s"] = true;
647+
$current_user->allcaps["publish_{$post_type}s"] = true;
648+
}
649+
633650
if (isset($post_type_obj->cap->edit_others_posts) && !empty($current_user->allcaps[$post_type_obj->cap->edit_posts])) {
634651
$allcaps[$post_type_obj->cap->edit_others_posts] = true;
635652
}
@@ -638,6 +655,10 @@ public function filter_user_has_cap($allcaps, $caps, $args)
638655
$allcaps[$post_type_obj->cap->delete_others_posts] = true;
639656
}
640657

658+
// error_log($current_user->user_login);
659+
// error_log(print_r($allcaps, true));
660+
// error_log(print_r($current_user->allcaps, true));
661+
// error_log(print_r($post_type_obj->cap, true));
641662
return $allcaps;
642663
}
643664

@@ -980,7 +1001,7 @@ public static function get_authors($post_id, $return = null)
9801001

9811002
private function get_authors_usergroups($post_id, $return = 'all')
9821003
{
983-
1004+
9841005

9851006
if ($return == 'slugs') {
9861007
$fields = 'all';

0 commit comments

Comments
 (0)