/**
  * @param form_persistentdocument_mail $document
  * @param Integer $parentNodeId Parent node ID where to save the document (optionnal => can be null !).
  * @throws form_ReplyToFieldAlreadyExistsException
  * @return void
  */
 protected function preSave($document, $parentNodeId = null)
 {
     if ($document->getMultiline()) {
         $document->setValidators('emails:true');
     } else {
         $document->setValidators('email:true');
     }
     if ($parentNodeId !== NULL) {
         $form = DocumentHelper::getDocumentInstance($parentNodeId);
     } else {
         $form = $this->getFormOf($document);
     }
     if ($form === null) {
         if (Framework::isWarnEnabled()) {
             Framework::warn(__METHOD__ . ' the mail field document (' . $document->__toString() . ')is not in a form');
         }
     } else {
         if ($document->getUseAsReply()) {
             $oldReplyField = form_BaseFormService::getInstance()->getReplyToField($form);
             if ($oldReplyField !== null && $oldReplyField !== $document) {
                 Framework::error(__METHOD__ . ' Old reply field :' . $oldReplyField->__toString());
                 throw new form_ReplyToFieldAlreadyExistsException(f_Locale::translate('&modules.form.bo.errors.Mail-field-for-replyto-exists'));
             }
         }
     }
     parent::preSave($document, $parentNodeId);
 }
Ejemplo n.º 2
0
 /**
  *
  *
  */
 public static function getModClassFile($class)
 {
     //
     global $config;
     //
     if (substr($class, 0, 7) != 'Module\\') {
         return;
     }
     //
     $offset = strpos($class, '\\', 8);
     //
     $realname = strtr(substr($class, $offset + 1), '\\', '/') . '.php';
     //
     $filename = strpos($realname, '/') ? lcfirst($realname) : $realname;
     //
     $currentModule = strtolower(substr($class, 7, $offset - 7));
     //
     if ($config->module) {
         foreach ($config->module as $module => $version) {
             //
             if ($currentModule != $module) {
                 continue;
             }
             //
             return __BASE__ . '/module/' . $module . '/' . intval($version) . '/' . $filename;
         }
     }
     //
     Framework::error('load module: ' . $currentModule, false);
 }