-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMultidatabaseContentEditAt.php
More file actions
115 lines (104 loc) · 3.05 KB
/
MultidatabaseContentEditAt.php
File metadata and controls
115 lines (104 loc) · 3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
/**
* MultidatabaseContentEditAt Model
* 汎用データベースコンテンツデータに関するモデル処理(添付ファイル)
*
* @author Noriko Arai <arai@nii.ac.jp>
* @author Tomoyuki OHNO (Ricksoft Co., Ltd.) <ohno.tomoyuki@ricksoft.jp>
* @link http://www.netcommons.org NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
* @copyright Copyright 2014, NetCommons Project
*/
App::uses('MultidatabasesAppModel', 'Multidatabases.Model');
App::uses('MultidatabaseModel', 'Multidatabase.Model');
App::uses('MultidatabaseMetadataModel', 'MultidatabaseMetadata.Model');
App::uses('MultidatabaseContentModel', 'MultidatabaseContent.Model');
App::uses('MultidatabaseContentFileModel', 'MultidatabaseContentFile.Model');
App::uses('MultidatabaseContentEditPrModel', 'MultidatabaseContentEditPr.Model');
/**
* MultidatabaseContentEditAt Model
*
* @author Tomoyuki OHNO (Ricksoft, Co., Ltd.) <ohno.tomoyuki@ricksoft.jp>
* @package NetCommons\Multidatabases\Model
*
*/
class MultidatabaseContentEditAt extends MultidatabasesAppModel {
/**
* Custom database table name
*
* @var string
*/
public $useTable = false;
/**
* 添付ファイル削除フラグを立てる
*
* @param array $data データ配列
* @param array $metadatas メタデータ配列
* @return array
*/
public function getAttachDelFlg($data, $metadatas) {
$this->loadModels([
'MultidatabaseContentEditPr' => 'Multidatabases.MultidatabaseContentEditPr',
]);
// 添付ファイル削除フラグを立てる
$result = [];
$tmp = $data;
foreach (array_keys($tmp['MultidatabaseContent']) as $key) {
if ($colNo = $this->MultidatabaseContentEditPr->prGetColNo($metadatas, $key)) {
if (
(
$metadatas[$colNo]['type'] == 'file' ||
$metadatas[$colNo]['type'] == 'image'
) &&
isset($tmp[$key . '_attach_del'])
) {
if (
isset($tmp[$key . '_attach_del']) &&
$tmp[$key . '_attach_del'] == 'on'
) {
$result[$key] = true;
} else {
$result[$key] = false;
}
//unset($data[$key . '_attach_del']);
}
}
}
return [
'attachDelFlg' => $result,
'data' => $data
];
}
/**
* 添付ファイルパスワードを取得する
*
* @param array $content コンテンツ配列
* @param array $metadatas メタデータ配列
* @return array
*/
public function getAttachPasswords($content, $metadatas) {
$this->loadModels([
'MultidatabaseContentEditPr' => 'Multidatabases.MultidatabaseContentEditPr',
]);
// 添付ファイルパスワードを取得する
$result = [];
$tmp = $content;
foreach (array_keys($tmp) as $key) {
if ($colNo = $this->MultidatabaseContentEditPr->prGetColNo($metadatas, $key)) {
if ($metadatas[$colNo]['type'] == 'file' &&
isset($tmp[$key . '_attach_pw'])
) {
$tmpPw = trim($tmp[$key . '_attach_pw']);
if (! empty($tmpPw)) {
$result['value' . $colNo] = $tmpPw;
}
unset($content[$key . '_attach_pw']);
}
}
}
return [
'attachPasswords' => $result,
'content' => $content
];
}
}