PageRenderTime 47ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/common/libraries/plugin/phpexcel/PHPExcel/DocumentSecurity.php

https://bitbucket.org/chamilo/chamilo-dev/
PHP | 233 lines | 89 code | 18 blank | 126 comment | 5 complexity | da53bb1f420caac56f006a7ff9e8bbc6 MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause, LGPL-2.1, LGPL-3.0, GPL-3.0, MIT
  1. <?php
  2. /**
  3. * PHPExcel
  4. *
  5. * Copyright (c) 2006 - 2011 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 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
  24. * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  25. * @version 1.7.6, 2011-02-27
  26. */
  27. /**
  28. * PHPExcel_DocumentSecurity
  29. *
  30. * @category PHPExcel
  31. * @package PHPExcel
  32. * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
  33. */
  34. class PHPExcel_DocumentSecurity
  35. {
  36. /**
  37. * LockRevision
  38. *
  39. * @var boolean
  40. */
  41. private $_lockRevision;
  42. /**
  43. * LockStructure
  44. *
  45. * @var boolean
  46. */
  47. private $_lockStructure;
  48. /**
  49. * LockWindows
  50. *
  51. * @var boolean
  52. */
  53. private $_lockWindows;
  54. /**
  55. * RevisionsPassword
  56. *
  57. * @var string
  58. */
  59. private $_revisionsPassword;
  60. /**
  61. * WorkbookPassword
  62. *
  63. * @var string
  64. */
  65. private $_workbookPassword;
  66. /**
  67. * Create a new PHPExcel_DocumentSecurity
  68. */
  69. public function __construct()
  70. {
  71. // Initialise values
  72. $this->_lockRevision = false;
  73. $this->_lockStructure = false;
  74. $this->_lockWindows = false;
  75. $this->_revisionsPassword = '';
  76. $this->_workbookPassword = '';
  77. }
  78. /**
  79. * Is some sort of dcument security enabled?
  80. *
  81. * @return boolean
  82. */
  83. function isSecurityEnabled()
  84. {
  85. return $this->_lockRevision || $this->_lockStructure || $this->_lockWindows;
  86. }
  87. /**
  88. * Get LockRevision
  89. *
  90. * @return boolean
  91. */
  92. function getLockRevision()
  93. {
  94. return $this->_lockRevision;
  95. }
  96. /**
  97. * Set LockRevision
  98. *
  99. * @param boolean $pValue
  100. * @return PHPExcel_DocumentSecurity
  101. */
  102. function setLockRevision($pValue = false)
  103. {
  104. $this->_lockRevision = $pValue;
  105. return $this;
  106. }
  107. /**
  108. * Get LockStructure
  109. *
  110. * @return boolean
  111. */
  112. function getLockStructure()
  113. {
  114. return $this->_lockStructure;
  115. }
  116. /**
  117. * Set LockStructure
  118. *
  119. * @param boolean $pValue
  120. * @return PHPExcel_DocumentSecurity
  121. */
  122. function setLockStructure($pValue = false)
  123. {
  124. $this->_lockStructure = $pValue;
  125. return $this;
  126. }
  127. /**
  128. * Get LockWindows
  129. *
  130. * @return boolean
  131. */
  132. function getLockWindows()
  133. {
  134. return $this->_lockWindows;
  135. }
  136. /**
  137. * Set LockWindows
  138. *
  139. * @param boolean $pValue
  140. * @return PHPExcel_DocumentSecurity
  141. */
  142. function setLockWindows($pValue = false)
  143. {
  144. $this->_lockWindows = $pValue;
  145. return $this;
  146. }
  147. /**
  148. * Get RevisionsPassword (hashed)
  149. *
  150. * @return string
  151. */
  152. function getRevisionsPassword()
  153. {
  154. return $this->_revisionsPassword;
  155. }
  156. /**
  157. * Set RevisionsPassword
  158. *
  159. * @param string $pValue
  160. * @param boolean $pAlreadyHashed If the password has already been hashed, set this to true
  161. * @return PHPExcel_DocumentSecurity
  162. */
  163. function setRevisionsPassword($pValue = '', $pAlreadyHashed = false)
  164. {
  165. if (! $pAlreadyHashed)
  166. {
  167. $pValue = PHPExcel_Shared_PasswordHasher :: hashPassword($pValue);
  168. }
  169. $this->_revisionsPassword = $pValue;
  170. return $this;
  171. }
  172. /**
  173. * Get WorkbookPassword (hashed)
  174. *
  175. * @return string
  176. */
  177. function getWorkbookPassword()
  178. {
  179. return $this->_workbookPassword;
  180. }
  181. /**
  182. * Set WorkbookPassword
  183. *
  184. * @param string $pValue
  185. * @param boolean $pAlreadyHashed If the password has already been hashed, set this to true
  186. * @return PHPExcel_DocumentSecurity
  187. */
  188. function setWorkbookPassword($pValue = '', $pAlreadyHashed = false)
  189. {
  190. if (! $pAlreadyHashed)
  191. {
  192. $pValue = PHPExcel_Shared_PasswordHasher :: hashPassword($pValue);
  193. }
  194. $this->_workbookPassword = $pValue;
  195. return $this;
  196. }
  197. /**
  198. * Implement PHP __clone to create a deep clone, not just a shallow copy.
  199. */
  200. public function __clone()
  201. {
  202. $vars = get_object_vars($this);
  203. foreach ($vars as $key => $value)
  204. {
  205. if (is_object($value))
  206. {
  207. $this->$key = clone $value;
  208. }
  209. else
  210. {
  211. $this->$key = $value;
  212. }
  213. }
  214. }
  215. }