示例#1
0
 /**
  * @anonym
  * @service custom_separator write
  * @param Gpf_Rpc_Params $params
  * @return Gpf_Rpc_Form
  */
 public function save(Gpf_Rpc_Params $params) {
     $form = new Gpf_Rpc_Form($params);
     
     $key = trim($form->getFieldValue(self::ENCRYPT_KEY));
     $iv = trim($form->getFieldValue(self::ENCRYPT_IV));
     
     if (!in_array(strlen($key), array(16, 24, 32))) {
         $form->setFieldError(self::ENCRYPT_KEY, $this->_('Key must be 16, 24 or 32 characters long'));
     }
     if (strlen($iv) != 16) {
         $form->setFieldError(self::ENCRYPT_IV, $this->_('Initialization vector must be 16 characters long'));
     }
     
     if (!$form->isError()) {
         if ($key != Gpf_Settings::get(self::ENCRYPT_KEY) || $iv != Gpf_Settings::get(self::ENCRYPT_IV)) {
             Pap_Features_PayoutFieldsEncryption_Main::getHandlerInstance()->recodeAllValues($key, $iv);
         }
         Gpf_Settings::set(self::ENCRYPT_KEY, $key);
         Gpf_Settings::set(self::ENCRYPT_IV, $iv);
         $form->setInfoMessage($this->_('Encrypt codes saved'));
     }
     
     return $form;
 }
 public function onDeactivate() {
     Pap_Features_PayoutFieldsEncryption_Main::getHandlerInstance()->recodeAllValues('', '');
     $this->clearKeys();
 }