Browse Source

朋友圈图片张数限制

author
wanghongjun 9 months ago
parent
commit
d355881b8a
  1. 20
      app/enterprise/controller/Posts.php
  2. 3
      app/lang/en_us.php
  3. 3
      app/lang/zh_cn.php

20
app/enterprise/controller/Posts.php

@ -48,7 +48,7 @@ class Posts extends BaseController
// 不可见 // 不可见
$where .= " or ( p.privacy = 4 and not exists ( $where .= " or ( p.privacy = 4 and not exists (
select 1 from {$prefix}posts_privacy_users peu select 1 from {$prefix}posts_privacy_users peu
where peu.posts_id = p.id and peu.user_id = p.user_id where peu.posts_id = p.id
and peu.type = 2 and peu.user_id = {$this->uid} and peu.type = 2 and peu.user_id = {$this->uid}
))"; ))";
} }
@ -211,6 +211,9 @@ class Posts extends BaseController
$type = '1'; $type = '1';
} }
if (!empty($imgArr)) { if (!empty($imgArr)) {
if (is_array($imgArr) && count($imgArr) > 9) {
return error(lang('posts.img_max_length'));
}
$type .= '2'; $type .= '2';
} elseif (!empty($video_file)) { } elseif (!empty($video_file)) {
$type .= '3'; $type .= '3';
@ -337,20 +340,7 @@ class Posts extends BaseController
$field = 'id as posts_id,content,type,location,address as location_address,privacy'; $field = 'id as posts_id,content,type,location,address as location_address,privacy';
$data = PostsModel::where($existsWhere)->field($field)->find(); $data = PostsModel::where($existsWhere)->field($field)->find();
if ($data) { if ($data) {
$fileWhere = [ $data['files'] = PostsFile::getPostsFile($data['posts_id']);
'posts_id' => $data['posts_id'],
'delete_time' => 0
];
$files = (new PostsFile())
->where($fileWhere)
->field('file_id,type')
->order('sort asc')
->select()
->toArray();
foreach ($files as $fileKey => $fileValue) {
$files[$fileKey]['src'] = File::where(['file_id' => $fileValue['file_id']])->value('src');
}
$data['files'] = $files;
$privacy_user =[]; $privacy_user =[];
if (in_array($data['privacy'], $this->privacyUserArr)) { if (in_array($data['privacy'], $this->privacyUserArr)) {
$PrivacyUsers = PostsPrivacyUsers::where(['posts_id' => $data['id']])->column('user_id'); $PrivacyUsers = PostsPrivacyUsers::where(['posts_id' => $data['id']])->column('user_id');

3
app/lang/en_us.php

@ -158,6 +158,7 @@ return [
'exists' => 'Save failed', 'exists' => 'Save failed',
'user_empty' => 'Restricting users to not be empty', 'user_empty' => 'Restricting users to not be empty',
'success_like' => 'Liked successfully', 'success_like' => 'Liked successfully',
'cancel_like' => 'Cancel likes' 'cancel_like' => 'Cancel likes',
'img_max_length' => 'Up to 9 images can be uploaded'
] ]
]; ];

3
app/lang/zh_cn.php

@ -157,6 +157,7 @@ return [
'exists' => '保存失败', 'exists' => '保存失败',
'user_empty' => '限制用户不能为空', 'user_empty' => '限制用户不能为空',
'success_like' => '点赞成功', 'success_like' => '点赞成功',
'cancel_like' => '取消点赞' 'cancel_like' => '取消点赞',
'img_max_length' => '图片最多上传9张'
] ]
]; ];
Loading…
Cancel
Save