1 | <?php |
---|
2 | /*********************************************** |
---|
3 | * File : contentparameters.php |
---|
4 | * Project : Z-Push |
---|
5 | * Descr : Simple transportation class for |
---|
6 | * requested content parameter options |
---|
7 | * |
---|
8 | * Created : 11.04.2011 |
---|
9 | * |
---|
10 | * Copyright 2007 - 2012 Zarafa Deutschland GmbH |
---|
11 | * |
---|
12 | * This program is free software: you can redistribute it and/or modify |
---|
13 | * it under the terms of the GNU Affero General Public License, version 3, |
---|
14 | * as published by the Free Software Foundation with the following additional |
---|
15 | * term according to sec. 7: |
---|
16 | * |
---|
17 | * According to sec. 7 of the GNU Affero General Public License, version 3, |
---|
18 | * the terms of the AGPL are supplemented with the following terms: |
---|
19 | * |
---|
20 | * "Zarafa" is a registered trademark of Zarafa B.V. |
---|
21 | * "Z-Push" is a registered trademark of Zarafa Deutschland GmbH |
---|
22 | * The licensing of the Program under the AGPL does not imply a trademark license. |
---|
23 | * Therefore any rights, title and interest in our trademarks remain entirely with us. |
---|
24 | * |
---|
25 | * However, if you propagate an unmodified version of the Program you are |
---|
26 | * allowed to use the term "Z-Push" to indicate that you distribute the Program. |
---|
27 | * Furthermore you may use our trademarks where it is necessary to indicate |
---|
28 | * the intended purpose of a product or service provided you use it in accordance |
---|
29 | * with honest practices in industrial or commercial matters. |
---|
30 | * If you want to propagate modified versions of the Program under the name "Z-Push", |
---|
31 | * you may only do so if you have a written permission by Zarafa Deutschland GmbH |
---|
32 | * (to acquire a permission please contact Zarafa at trademark@zarafa.com). |
---|
33 | * |
---|
34 | * This program is distributed in the hope that it will be useful, |
---|
35 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
36 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
37 | * GNU Affero General Public License for more details. |
---|
38 | * |
---|
39 | * You should have received a copy of the GNU Affero General Public License |
---|
40 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
41 | * |
---|
42 | * Consult LICENSE file for details |
---|
43 | ************************************************/ |
---|
44 | |
---|
45 | |
---|
46 | class ContentParameters extends StateObject { |
---|
47 | protected $unsetdata = array( 'contentclass' => false, |
---|
48 | 'foldertype' => '', |
---|
49 | 'conflict' => false, |
---|
50 | 'deletesasmoves' => true, |
---|
51 | 'filtertype' => false, |
---|
52 | 'truncation' => false, |
---|
53 | 'rtftruncation' => false, |
---|
54 | 'mimesupport' => false, |
---|
55 | 'conversationmode' => false, |
---|
56 | ); |
---|
57 | |
---|
58 | private $synckeyChanged = false; |
---|
59 | |
---|
60 | /** |
---|
61 | * Expected magic getters and setters |
---|
62 | * |
---|
63 | * GetContentClass() + SetContentClass() |
---|
64 | * GetConflict() + SetConflict() |
---|
65 | * GetDeletesAsMoves() + SetDeletesAsMoves() |
---|
66 | * GetFilterType() + SetFilterType() |
---|
67 | * GetTruncation() + SetTruncation |
---|
68 | * GetRTFTruncation() + SetRTFTruncation() |
---|
69 | * GetMimeSupport () + SetMimeSupport() |
---|
70 | * GetMimeTruncation() + SetMimeTruncation() |
---|
71 | * GetConversationMode() + SetConversationMode() |
---|
72 | */ |
---|
73 | |
---|
74 | /** |
---|
75 | * Overwrite StateObject->__call so we are able to handle ContentParameters->BodyPreference() |
---|
76 | * |
---|
77 | * @access public |
---|
78 | * @return mixed |
---|
79 | */ |
---|
80 | public function __call($name, $arguments) { |
---|
81 | if ($name === "BodyPreference") |
---|
82 | return $this->BodyPreference($arguments[0]); |
---|
83 | |
---|
84 | return parent::__call($name, $arguments); |
---|
85 | } |
---|
86 | |
---|
87 | |
---|
88 | /** |
---|
89 | * Instantiates/returns the bodypreference object for a type |
---|
90 | * |
---|
91 | * @param int $type |
---|
92 | * |
---|
93 | * @access public |
---|
94 | * @return int/boolean returns false if value is not defined |
---|
95 | */ |
---|
96 | public function BodyPreference($type) { |
---|
97 | if (!isset($this->bodypref)) |
---|
98 | $this->bodypref = array(); |
---|
99 | |
---|
100 | if (isset($this->bodypref[$type])) |
---|
101 | return $this->bodypref[$type]; |
---|
102 | else { |
---|
103 | $asb = new BodyPreference(); |
---|
104 | $arr = (array)$this->bodypref; |
---|
105 | $arr[$type] = $asb; |
---|
106 | $this->bodypref = $arr; |
---|
107 | return $asb; |
---|
108 | } |
---|
109 | } |
---|
110 | |
---|
111 | /** |
---|
112 | * Returns available body preference objects |
---|
113 | * |
---|
114 | * @access public |
---|
115 | * @return array/boolean returns false if the client's body preference is not available |
---|
116 | */ |
---|
117 | public function GetBodyPreference() { |
---|
118 | if (!isset($this->bodypref) || !(is_array($this->bodypref) || empty($this->bodypref))) { |
---|
119 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("ContentParameters->GetBodyPreference(): bodypref is empty or not set")); |
---|
120 | return false; |
---|
121 | } |
---|
122 | return array_keys($this->bodypref); |
---|
123 | } |
---|
124 | |
---|
125 | /** |
---|
126 | * Called before the StateObject is serialized |
---|
127 | * |
---|
128 | * @access protected |
---|
129 | * @return boolean |
---|
130 | */ |
---|
131 | protected function preSerialize() { |
---|
132 | parent::preSerialize(); |
---|
133 | |
---|
134 | if ($this->changed === true && $this->synckeyChanged) |
---|
135 | $this->lastsynctime = time(); |
---|
136 | |
---|
137 | return true; |
---|
138 | } |
---|
139 | } |
---|
140 | |
---|
141 | ?> |
---|