installScript() public method

Adds a script to the server.
public installScript ( string $scriptname, string $script, boolean $makeactive = false )
$scriptname string Name of the script.
$script string The script content.
$makeactive boolean Whether to make this the active script.
Beispiel #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);
     }
 }
Beispiel #2
0
 public function testRemoveScript()
 {
     $this->clear();
     $this->login();
     $scriptname = 'test script1';
     $before_scripts = $this->fixture->listScripts();
     $this->fixture->installScript($scriptname, $this->scripts[$scriptname]);
     $this->fixture->removeScript($scriptname);
     $after_scripts = $this->fixture->listScripts();
     $diff_scripts = array_values(array_diff($after_scripts, $before_scripts));
     $this->assertTrue(count($diff_scripts) == 0, 'Script still installed');
     $this->logout();
 }