Horde\ManageSieve::hasSpace PHP Méthode

hasSpace() public méthode

Checks if the server has space to store the script by the server.
public hasSpace ( string $scriptname, integer $size ) : boolean
$scriptname string The name of the script to mark as active.
$size integer The size of the script.
Résultat boolean True if there is space.
    public function hasSpace($scriptname, $size)
    {
        $this->_checkAuthenticated();
        try {
            $this->_doCmd(sprintf('HAVESPACE %s %d', $this->_escape($scriptname), $size));
        } catch (Exception $e) {
            return false;
        }
        return true;
    }

Usage Example

Exemple #1
0
 /**
  * Sets a script running on the backend.
  *
  * @param array $script  The filter script information. Passed elements:
  *                       - 'name': (string) the script name.
  *                       - 'recipes': (array) the filter recipe objects.
  *                       - 'script': (string) the filter script.
  *
  * @throws Ingo_Exception
  */
 public function setScriptActive($script)
 {
     $this->_connect();
     try {
         if (!strlen($script['script'])) {
             $this->_sieve->setActive('');
             $this->_sieve->removeScript($script['name']);
             return;
         }
         if (!$this->_sieve->hasSpace($script['name'], strlen($script['script']))) {
             throw new Ingo_Exception(_("Not enough free space on the server."));
         }
         $this->_sieve->installScript($script['name'], $script['script'], true);
     } catch (ManageSieve\Exception $e) {
         throw new Ingo_Exception($e);
     }
 }