1 <?php
2 3 4
5 class rex_api_content_copy extends rex_api_function
6 {
7 8 9 10 11
12 public function execute()
13 {
14 $article_id = rex_request('article_id', 'int');
15 $slice_revision = rex_request('slice_revision', 'int');
16 $clang_a = rex_request('clang_a', 'int');
17 $clang_b = rex_request('clang_b', 'int');
18
19 $user = rex::getUser();
20
21
22 if ($user->hasPerm('copyContent[]') &&
23 $user->getComplexPerm('clang')->hasPerm($clang_a) &&
24 $user->getComplexPerm('clang')->hasPerm($clang_b)
25 ) {
26 if (rex_content_service::copyContent($article_id, $article_id, $clang_a, $clang_b, $slice_revision)) {
27 $result = new rex_api_result(true, rex_i18n::msg('content_contentcopy'));
28 } else {
29 $result = new rex_api_result(true, rex_i18n::msg('content_errorcopy'));
30 }
31
32 return $result;
33 }
34
35 throw new rex_api_exception(rex_i18n::msg('no_rights_to_this_function'));
36 }
37
38 protected function requiresCsrfProtection()
39 {
40 return true;
41 }
42 }
43