예제 #1
0
 /**
  * Test setConfigurations, validateConfigurations and getConfiguration
  */
 public function testSaveAndGetConfiguration()
 {
     $configuration = new Phprojekt_Configuration();
     $configuration->setModule('General');
     $this->assertEquals('', $configuration->getConfiguration('companyName'));
     $message = $configuration->validateConfigurations(array('companyName' => 'TEST'));
     $this->assertNull($message);
     $configuration->setConfigurations(array('companyName' => 'TEST'));
     $this->assertEquals('TEST', $configuration->getConfiguration('companyName'));
     $configuration->setConfigurations(array('companyName' => 'Invisible Root'));
 }
 /**
  * Saves the configuration for one module.
  *
  * OPTIONAL request parameters:
  * <pre>
  *  - string <b>moduleName</b>              Name of the module.
  *  - mixed  <b>all other module fields</b> All the fields values to save.
  * </pre>
  *
  * The return is a string in JSON format with:
  * <pre>
  *  - type    => 'success' or 'error'.
  *  - message => Success or error message.
  *  - id      => 0.
  * </pre>
  *
  * @throws Zend_Controller_Action_Exception On error in the action save or wrong id.
  *
  * @return void
  */
 public function jsonSaveAction()
 {
     $module = Cleaner::sanitize('alnum', $this->getRequest()->getParam('moduleName', null));
     $this->setCurrentProjectId();
     $configuration = new Phprojekt_Configuration();
     $configuration->setModule($module);
     $message = $configuration->validateConfigurations($this->getRequest()->getParams());
     if (!empty($message)) {
         $type = "error";
     } else {
         $message = Phprojekt::getInstance()->translate(self::EDIT_TRUE_TEXT);
         $configuration->setConfigurations($this->getRequest()->getParams());
         $type = "success";
     }
     $return = array('type' => $type, 'message' => $message, 'id' => 0);
     Phprojekt_Converter_Json::echoConvert($return);
 }