setActive() public method

Sets the active script.
public setActive ( string $scriptname )
$scriptname string The name of the script to be set as active.
コード例 #1
0
ファイル: Timsieved.php プロジェクト: horde/horde
 /**
  * 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);
     }
 }
コード例 #2
0
ファイル: ManageSieveTest.php プロジェクト: raz0rsdge/horde
 public function testSetActive()
 {
     $this->clear();
     $this->login();
     $scriptname = 'test script1';
     $this->fixture->installScript($scriptname, $this->scripts[$scriptname]);
     $this->fixture->setActive($scriptname);
     $active_script = $this->fixture->getActive();
     $this->assertEquals($scriptname, $active_script, 'Active script does not match');
     // Test for non-existant script.
     try {
         $this->fixture->setActive('non existant script');
         $this->fail('Exception expected');
     } catch (Exception $e) {
     }
     $this->logout();
 }