~ubuntu-branches/ubuntu/lucid/phpmyadmin/lucid

« back to all changes in this revision

Viewing changes to libraries/PHPExcel/PHPExcel/DocumentSecurity.php

  • Committer: Bazaar Package Importer
  • Author(s): Michal Čihař
  • Date: 2010-03-08 15:25:00 UTC
  • mfrom: (1.2.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20100308152500-6e8hmuqc5co39de5
Tags: 4:3.3.0-1
* New upstream version.
* Rediff debian/patches.
* Fix permissions on mediawiki export extension.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/**
 
3
 * PHPExcel
 
4
 *
 
5
 * Copyright (c) 2006 - 2009 PHPExcel
 
6
 *
 
7
 * This library is free software; you can redistribute it and/or
 
8
 * modify it under the terms of the GNU Lesser General Public
 
9
 * License as published by the Free Software Foundation; either
 
10
 * version 2.1 of the License, or (at your option) any later version.
 
11
 * 
 
12
 * This library is distributed in the hope that it will be useful,
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
15
 * Lesser General Public License for more details.
 
16
 * 
 
17
 * You should have received a copy of the GNU Lesser General Public
 
18
 * License along with this library; if not, write to the Free Software
 
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
20
 *
 
21
 * @category   PHPExcel
 
22
 * @package    PHPExcel
 
23
 * @copyright  Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
 
24
 * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
 
25
 * @version    1.7.0, 2009-08-10
 
26
 */
 
27
 
 
28
 
 
29
/** PHPExcel root directory */
 
30
if (!defined('PHPEXCEL_ROOT')) {
 
31
        /**
 
32
         * @ignore
 
33
         */
 
34
        define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
 
35
}
 
36
 
 
37
/** PHPExcel_Shared_PasswordHasher */
 
38
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/PasswordHasher.php';
 
39
 
 
40
 
 
41
/**
 
42
 * PHPExcel_DocumentSecurity
 
43
 *
 
44
 * @category   PHPExcel
 
45
 * @package    PHPExcel
 
46
 * @copyright  Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
 
47
 */
 
48
class PHPExcel_DocumentSecurity
 
49
{
 
50
        /**
 
51
         * LockRevision
 
52
         *
 
53
         * @var boolean
 
54
         */
 
55
        private $_lockRevision;
 
56
        
 
57
        /**
 
58
         * LockStructure
 
59
         *
 
60
         * @var boolean
 
61
         */
 
62
        private $_lockStructure;
 
63
        
 
64
        /**
 
65
         * LockWindows
 
66
         *
 
67
         * @var boolean
 
68
         */
 
69
        private $_lockWindows;
 
70
        
 
71
        /**
 
72
         * RevisionsPassword
 
73
         *
 
74
         * @var string
 
75
         */
 
76
        private $_revisionsPassword;
 
77
        
 
78
        /**
 
79
         * WorkbookPassword
 
80
         *
 
81
         * @var string
 
82
         */
 
83
        private $_workbookPassword;
 
84
        
 
85
    /**
 
86
     * Create a new PHPExcel_DocumentSecurity
 
87
     */
 
88
    public function __construct()
 
89
    {
 
90
        // Initialise values
 
91
        $this->_lockRevision            = false;
 
92
        $this->_lockStructure           = false;
 
93
        $this->_lockWindows                     = false;
 
94
        $this->_revisionsPassword       = '';
 
95
        $this->_workbookPassword        = '';
 
96
    }
 
97
    
 
98
    /**
 
99
     * Is some sort of dcument security enabled?
 
100
     *
 
101
     * @return boolean
 
102
     */
 
103
    function isSecurityEnabled() {
 
104
        return  $this->_lockRevision ||
 
105
                        $this->_lockStructure ||
 
106
                        $this->_lockWindows;
 
107
    }
 
108
    
 
109
    /**
 
110
     * Get LockRevision
 
111
     *
 
112
     * @return boolean
 
113
     */
 
114
    function getLockRevision() {
 
115
        return $this->_lockRevision;
 
116
    }
 
117
    
 
118
    /**
 
119
     * Set LockRevision
 
120
     *
 
121
     * @param boolean $pValue
 
122
     * @return PHPExcel_DocumentSecurity
 
123
     */
 
124
    function setLockRevision($pValue = false) {
 
125
        $this->_lockRevision = $pValue;
 
126
        return $this;
 
127
    }
 
128
    
 
129
    /**
 
130
     * Get LockStructure
 
131
     *
 
132
     * @return boolean
 
133
     */
 
134
    function getLockStructure() {
 
135
        return $this->_lockStructure;
 
136
    }
 
137
    
 
138
    /**
 
139
     * Set LockStructure
 
140
     *
 
141
     * @param boolean $pValue
 
142
     * @return PHPExcel_DocumentSecurity
 
143
     */
 
144
    function setLockStructure($pValue = false) {
 
145
                $this->_lockStructure = $pValue;
 
146
                return $this;
 
147
    }
 
148
    
 
149
    /**
 
150
     * Get LockWindows
 
151
     *
 
152
     * @return boolean
 
153
     */
 
154
    function getLockWindows() {
 
155
        return $this->_lockWindows;
 
156
    }
 
157
    
 
158
    /**
 
159
     * Set LockWindows
 
160
     *
 
161
     * @param boolean $pValue
 
162
     * @return PHPExcel_DocumentSecurity
 
163
     */
 
164
    function setLockWindows($pValue = false) {
 
165
        $this->_lockWindows = $pValue;
 
166
        return $this;
 
167
    }
 
168
    
 
169
    /**
 
170
     * Get RevisionsPassword (hashed)
 
171
     *
 
172
     * @return string
 
173
     */
 
174
    function getRevisionsPassword() {
 
175
        return $this->_revisionsPassword;
 
176
    }
 
177
    
 
178
    /**
 
179
     * Set RevisionsPassword
 
180
     *
 
181
     * @param string    $pValue
 
182
     * @param boolean   $pAlreadyHashed If the password has already been hashed, set this to true
 
183
     * @return PHPExcel_DocumentSecurity
 
184
     */
 
185
    function setRevisionsPassword($pValue = '', $pAlreadyHashed = false) {
 
186
        if (!$pAlreadyHashed) {
 
187
                $pValue = PHPExcel_Shared_PasswordHasher::hashPassword($pValue);
 
188
        }
 
189
        $this->_revisionsPassword = $pValue;
 
190
        return $this;
 
191
    }
 
192
    
 
193
    /**
 
194
     * Get WorkbookPassword (hashed)
 
195
     *
 
196
     * @return string
 
197
     */
 
198
    function getWorkbookPassword() {
 
199
        return $this->_workbookPassword;
 
200
    }
 
201
 
 
202
    /**
 
203
     * Set WorkbookPassword
 
204
     *
 
205
     * @param string    $pValue
 
206
     * @param boolean   $pAlreadyHashed If the password has already been hashed, set this to true
 
207
     * @return PHPExcel_DocumentSecurity
 
208
     */
 
209
    function setWorkbookPassword($pValue = '', $pAlreadyHashed = false) {
 
210
        if (!$pAlreadyHashed) {
 
211
                $pValue = PHPExcel_Shared_PasswordHasher::hashPassword($pValue);
 
212
        }
 
213
                $this->_workbookPassword = $pValue;
 
214
                return $this;
 
215
    }
 
216
 
 
217
        /**
 
218
         * Implement PHP __clone to create a deep clone, not just a shallow copy.
 
219
         */
 
220
        public function __clone() {
 
221
                $vars = get_object_vars($this);
 
222
                foreach ($vars as $key => $value) {
 
223
                        if (is_object($value)) {
 
224
                                $this->$key = clone $value;
 
225
                        } else {
 
226
                                $this->$key = $value;
 
227
                        }
 
228
                }
 
229
        }
 
230
}