PHPExcel
[ class tree: PHPExcel ] [ index: PHPExcel ] [ all elements ]

Source for file DocumentSecurity.php

Documentation is available at DocumentSecurity.php

  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. {
  49.     /**
  50.      * LockRevision
  51.      *
  52.      * @var boolean 
  53.      */
  54.     private $_lockRevision;
  55.     
  56.     /**
  57.      * LockStructure
  58.      *
  59.      * @var boolean 
  60.      */
  61.     private $_lockStructure;
  62.     
  63.     /**
  64.      * LockWindows
  65.      *
  66.      * @var boolean 
  67.      */
  68.     private $_lockWindows;
  69.     
  70.     /**
  71.      * RevisionsPassword
  72.      *
  73.      * @var string 
  74.      */
  75.     private $_revisionsPassword;
  76.     
  77.     /**
  78.      * WorkbookPassword
  79.      *
  80.      * @var string 
  81.      */
  82.     private $_workbookPassword;
  83.     
  84.     /**
  85.      * Create a new PHPExcel_DocumentSecurity
  86.      */
  87.     public function __construct()
  88.     {
  89.         // Initialise values
  90.         $this->_lockRevision        = false;
  91.         $this->_lockStructure        = false;
  92.         $this->_lockWindows            = false;
  93.         $this->_revisionsPassword    = '';
  94.         $this->_workbookPassword    = '';
  95.     }
  96.     
  97.     /**
  98.      * Is some sort of dcument security enabled?
  99.      *
  100.      * @return boolean 
  101.      */
  102.     function isSecurityEnabled({
  103.         return     $this->_lockRevision ||
  104.                 $this->_lockStructure ||
  105.                 $this->_lockWindows;
  106.     }
  107.     
  108.     /**
  109.      * Get LockRevision
  110.      *
  111.      * @return boolean 
  112.      */
  113.     function getLockRevision({
  114.         return $this->_lockRevision;
  115.     }
  116.     
  117.     /**
  118.      * Set LockRevision
  119.      *
  120.      * @param boolean $pValue 
  121.      * @return PHPExcel_DocumentSecurity 
  122.      */
  123.     function setLockRevision($pValue false{
  124.         $this->_lockRevision = $pValue;
  125.         return $this;
  126.     }
  127.     
  128.     /**
  129.      * Get LockStructure
  130.      *
  131.      * @return boolean 
  132.      */
  133.     function getLockStructure({
  134.         return $this->_lockStructure;
  135.     }
  136.     
  137.     /**
  138.      * Set LockStructure
  139.      *
  140.      * @param boolean $pValue 
  141.      * @return PHPExcel_DocumentSecurity 
  142.      */
  143.     function setLockStructure($pValue false{
  144.         $this->_lockStructure = $pValue;
  145.         return $this;
  146.     }
  147.     
  148.     /**
  149.      * Get LockWindows
  150.      *
  151.      * @return boolean 
  152.      */
  153.     function getLockWindows({
  154.         return $this->_lockWindows;
  155.     }
  156.     
  157.     /**
  158.      * Set LockWindows
  159.      *
  160.      * @param boolean $pValue 
  161.      * @return PHPExcel_DocumentSecurity 
  162.      */
  163.     function setLockWindows($pValue false{
  164.         $this->_lockWindows = $pValue;
  165.         return $this;
  166.     }
  167.     
  168.     /**
  169.      * Get RevisionsPassword (hashed)
  170.      *
  171.      * @return string 
  172.      */
  173.     function getRevisionsPassword({
  174.         return $this->_revisionsPassword;
  175.     }
  176.     
  177.     /**
  178.      * Set RevisionsPassword
  179.      *
  180.      * @param string     $pValue 
  181.      * @param boolean     $pAlreadyHashed If the password has already been hashed, set this to true
  182.      * @return PHPExcel_DocumentSecurity 
  183.      */
  184.     function setRevisionsPassword($pValue ''$pAlreadyHashed false{
  185.         if (!$pAlreadyHashed{
  186.             $pValue PHPExcel_Shared_PasswordHasher::hashPassword($pValue);
  187.         }
  188.         $this->_revisionsPassword = $pValue;
  189.         return $this;
  190.     }
  191.     
  192.     /**
  193.      * Get WorkbookPassword (hashed)
  194.      *
  195.      * @return string 
  196.      */
  197.     function getWorkbookPassword({
  198.         return $this->_workbookPassword;
  199.     }
  200.  
  201.     /**
  202.      * Set WorkbookPassword
  203.      *
  204.      * @param string     $pValue 
  205.      * @param boolean     $pAlreadyHashed If the password has already been hashed, set this to true
  206.      * @return PHPExcel_DocumentSecurity 
  207.      */
  208.     function setWorkbookPassword($pValue ''$pAlreadyHashed false{
  209.         if (!$pAlreadyHashed{
  210.             $pValue PHPExcel_Shared_PasswordHasher::hashPassword($pValue);
  211.         }
  212.         $this->_workbookPassword = $pValue;
  213.         return $this;
  214.     }
  215.  
  216.     /**
  217.      * Implement PHP __clone to create a deep clone, not just a shallow copy.
  218.      */
  219.     public function __clone({
  220.         $vars get_object_vars($this);
  221.         foreach ($vars as $key => $value{
  222.             if (is_object($value)) {
  223.                 $this->$key clone $value;
  224.             else {
  225.                 $this->$key $value;
  226.             }
  227.         }
  228.     }
  229. }

Documentation generated on Mon, 10 Aug 2009 08:03:13 +0200 by phpDocumentor 1.4.1