PluginProbe
User Access Manager / 2.2.13
User Access Manager v2.2.13
2.3.20 2.3.19 2.3.18 2.3.17 2.3.16 2.3.15 2.3.14 2.3.13 trunk 0.6 0.6.1 0.6.2 0.7 0.7 Beta 0.7.0.1 0.8 0.8.0.1 0.8.0.2 0.9 0.9.1 0.9.1.1 0.9.1.2 0.9.1.3 0.9.1.4 1.0 All 136 releases
← All changes | src/Controller/Backend/PostObjectController.php +60 -10 2.3.172.2.13 View file →
@@ -1,5 +1,18 @@
1 1 <?php
2 +/**
3 + * PostObjectController.php
4 + *
5 + * The PostObjectController class file.
6 + *
7 + * PHP versions 5
8 + *
9 + * @author Alexander Schneider <alexanderschneider85@gmail.com>
10 + * @copyright 2008-2017 Alexander Schneider
11 + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2
12 + * @version SVN: $id$
13 + * @link http://wordpress.org/extend/plugins/user-access-manager/
14 + */
2 15
3 16 declare(strict_types=1);
4 17
5 18 namespace UserAccessManager\Controller\Backend;
@@ -7,10 +20,21 @@
7 20 use UserAccessManager\Object\ObjectHandler;
8 21 use UserAccessManager\UserGroup\UserGroupTypeException;
9 22 use WP_Post;
10 23
24 +/**
25 + * Class PostObjectController
26 + *
27 + * @package UserAccessManager\Controller\Backend
28 + */
11 29 class PostObjectController extends ObjectController
12 30 {
31 + /**
32 + * The function for the manage_posts_columns and
33 + * the manage_pages_columns filter.
34 + * @param array $defaults The table headers.
35 + * @return array
36 + */
13 37 public function addPostColumnsHeader(array $defaults): array
14 38 {
15 39 $defaults[self::COLUMN_NAME] = TXT_UAM_COLUMN_ACCESS;
16 40 return $defaults;
@@ -16,11 +40,14 @@
16 40 return $defaults;
17 41 }
18 42
19 43 /**
44 + * The function for the manage_users_custom_column action.
45 + * @param string $columnName The column name.
46 + * @param int|string $id The id.
20 47 * @throws UserGroupTypeException
21 48 */
22 - public function addPostColumn(string $columnName, int|string|null $id): void
49 + public function addPostColumn(string $columnName, $id)
23 50 {
24 51 if ($columnName === self::COLUMN_NAME) {
25 52 $post = $this->objectHandler->getPost($id);
26 53 echo $this->getGroupColumn($post->post_type, $post->ID);
@@ -27,11 +54,13 @@
27 54 }
28 55 }
29 56
30 57 /**
58 + * The function for the uam_post_access meta box.
59 + * @param mixed $post The post.
31 60 * @throws UserGroupTypeException
32 61 */
33 - public function editPostContent(mixed $post): void
62 + public function editPostContent($post)
34 63 {
35 64 if ($post instanceof WP_Post) {
36 65 $this->setObjectInformation($post->post_type, $post->ID);
37 66 }
@@ -38,20 +67,25 @@
38 67
39 68 echo $this->getIncludeContents('PostEditForm.php');
40 69 }
41 70
42 - public function addBulkAction(string $columnName): void
71 + /**
72 + * Adds the bulk edit form.
73 + * @param $columnName
74 + */
75 + public function addBulkAction($columnName)
43 76 {
44 77 if ($columnName === self::COLUMN_NAME) {
45 - $this->getObjectInformation()->setObjectId(null);
46 78 echo $this->getIncludeContents('BulkEditForm.php');
47 79 }
48 80 }
49 81
50 82 /**
83 + * The function for the save_post action.
84 + * @param mixed $postParam The post id or a array of a post.
51 85 * @throws UserGroupTypeException
52 86 */
53 - public function savePostData(mixed $postParam): void
87 + public function savePostData($postParam)
54 88 {
55 89 $postId = (is_array($postParam) === true) ? $postParam['ID'] : $postParam;
56 90 $post = $this->objectHandler->getPost($postId);
57 91 $postType = $post->post_type;
@@ -66,11 +100,13 @@
66 100 $this->saveObjectData($postType, $postId);
67 101 }
68 102
69 103 /**
104 + * The function for the add_attachment action.
105 + * @param int $postId
70 106 * @throws UserGroupTypeException
71 107 */
72 - public function addAttachment(int|string|null $postId): void
108 + public function addAttachment(int $postId)
73 109 {
74 110 $post = $this->objectHandler->getPost($postId);
75 111 $postType = $post->post_type;
76 112 $postId = $post->ID;
@@ -85,8 +121,13 @@
85 121 $this->saveObjectData($postType, $postId, $defaultGroups, true);
86 122 }
87 123
88 124 /**
125 + * The function for the attachment_fields_to_save filter.
126 + * We have to use this because the attachment actions work
127 + * not in the way we need.
128 + * @param array $attachment The attachment id.
129 + * @return array
89 130 * @throws UserGroupTypeException
90 131 */
91 132 public function saveAttachmentData(array $attachment): array
92 133 {
@@ -95,13 +136,14 @@
95 136 return $attachment;
96 137 }
97 138
98 139 /**
140 + * The function for the wp_ajax_save_attachment_compat filter.
99 141 * @throws UserGroupTypeException
100 142 */
101 - public function saveAjaxAttachmentData(): void
143 + public function saveAjaxAttachmentData()
102 144 {
103 - $attachmentId = (int) $this->getRequestParameter('id');
145 + $attachmentId = $this->getRequestParameter('id');
104 146 $userGroups = $this->getRequestParameter(self::DEFAULT_GROUPS_FORM_NAME);
105 147
106 148 $this->saveObjectData(
107 149 ObjectHandler::GENERAL_POST_OBJECT_TYPE,
@@ -109,9 +151,13 @@
109 151 $userGroups
110 152 );
111 153 }
112 154
113 - public function removePostData(int|string|null $postId): void
155 + /**
156 + * The function for the delete_post action.
157 + * @param int|string $postId The post id.
158 + */
159 + public function removePostData($postId)
114 160 {
115 161 $post = $this->objectHandler->getPost($postId);
116 162 $this->removeObjectData($post->post_type, $postId);
117 163 }
@@ -116,11 +162,15 @@
116 162 $this->removeObjectData($post->post_type, $postId);
117 163 }
118 164
119 165 /**
166 + * The function for the media_meta action.
167 + * @param array $formFields The meta.
168 + * @param WP_Post $post The post.
169 + * @return array
120 170 * @throws UserGroupTypeException
121 171 */
122 - public function showMediaFile(array $formFields, ?WP_Post $post = null): array
172 + public function showMediaFile(array $formFields, $post = null): array
123 173 {
124 174 if ($this->getRequestParameter('action') !== 'edit') {
125 175 $attachmentId = $this->getRequestParameter('attachment_id');
126 176