@@ -174,30 +174,6 @@ public function run($ctype_name){
174174 }
175175 }
176176
177- // Комментарии
178- if ($ this ->ctype ['is_comments ' ] &&
179- $ this ->ctype ['is_approved ' ] &&
180- $ this ->ctype ['is_comments_on ' ] &&
181- $ this ->isControllerEnabled ('comments ' )){
182-
183- $ this ->item ['is_comments_on ' ] = true ;
184-
185- } else {
186- $ this ->item ['is_comments_on ' ] = false ;
187- }
188-
189- // Рейтинг. Если выключен, убираем ячейку из ответа
190- if (!$ this ->ctype ['is_rating ' ] && !$ this ->isControllerEnabled ('rating ' )){
191- unset($ this ->item ['rating ' ]);
192- }
193-
194- // Получаем теги
195- if ($ this ->ctype ['is_tags ' ]){
196- $ this ->item ['tags ' ] = cmsCore::getModel ('tags ' )->getTagsForTarget ($ this ->name , $ this ->ctype ['name ' ], $ this ->item ['id ' ]);
197- } else {
198- unset($ this ->item ['tags ' ]);
199- }
200-
201177 list ($ this ->ctype , $ this ->item , $ fields ) = cmsEventsManager::hook ('content_before_item ' , array ($ this ->ctype , $ this ->item , $ fields ));
202178 list ($ this ->ctype , $ this ->item , $ fields ) = cmsEventsManager::hook ("content_ {$ this ->ctype ['name ' ]}_before_item " , array ($ this ->ctype , $ this ->item , $ fields ));
203179 list ($ this ->ctype , $ this ->item , $ fields ) = cmsEventsManager::hook ('api_content_before_item ' , array ($ this ->ctype , $ this ->item , $ fields ));
@@ -209,8 +185,24 @@ public function run($ctype_name){
209185
210186 if (empty ($ this ->item [$ name ]) || $ field ['is_system ' ]) { continue ; }
211187
188+ // проверяем что группа пользователя имеет доступ к чтению этого поля
212189 if ($ field ['groups_read ' ] && !$ this ->cms_user ->isInGroups ($ field ['groups_read ' ])) {
190+ // если группа пользователя не имеет доступ к чтению этого поля,
191+ // проверяем на доступ к нему для авторов
192+ if (!empty ($ this ->item ['user_id ' ]) && !empty ($ field ['options ' ]['author_access ' ])){
193+
194+ if (!in_array ('is_read ' , $ field ['options ' ]['author_access ' ])){
195+ unset($ this ->item [$ name ]); continue ;
196+ }
197+
198+ if ($ this ->item ['user_id ' ] == $ this ->cms_user ->id ){
199+ unset($ this ->item [$ name ]); continue ;
200+ }
201+
202+ }
203+
213204 unset($ this ->item [$ name ]); continue ;
205+
214206 }
215207
216208 if (in_array ($ field ['type ' ], array ('images ' ,'image ' ))){
0 commit comments