[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/phpexcel/PHPExcel/ -> DocumentSecurity.php (source)

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


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1