/** * @return form_BaseformService */ public static function getInstance() { if (self::$instance === null) { self::$instance = self::getServiceClassInstance(get_class()); } return self::$instance; }
/** * Entry point of the patch execution. */ public function execute() { // Update forms. $this->executeSQLQuery("create table m_form_doc_baseform select * from m_form_doc_form"); $this->executeSQLQuery("create table m_form_doc_baseform_i18n select * from m_form_doc_form_i18n"); $this->executeSQLQuery("RENAME TABLE `m_form_doc_form` TO `m_form_doc_form_todelete`;"); $this->executeSQLQuery("RENAME TABLE `m_form_doc_form_i18n` TO `m_form_doc_form_i18n_todelete`;"); $newPath = f_util_FileUtils::buildWebeditPath('modules/form/persistentdocument/mail.xml'); $newModel = generator_PersistentModel::loadModelFromString(f_util_FileUtils::read($newPath), 'form', 'mail'); $newProp = $newModel->getPropertyByName('acknowledgmentReceiver'); f_persistentdocument_PersistentProvider::getInstance()->addProperty('form', 'mail', $newProp); $newPath = f_util_FileUtils::buildWebeditPath('modules/form/persistentdocument/form.xml'); $newModel = generator_PersistentModel::loadModelFromString(f_util_FileUtils::read($newPath), 'form', 'form'); $newProp = $newModel->getPropertyByName('saveResponse'); f_persistentdocument_PersistentProvider::getInstance()->addProperty('form', 'baseform', $newProp); $newPath = f_util_FileUtils::buildWebeditPath('modules/form/persistentdocument/baseform.xml'); $newModel = generator_PersistentModel::loadModelFromString(f_util_FileUtils::read($newPath), 'form', 'baseform'); $newProp = $newModel->getPropertyByName('acknowledgment'); f_persistentdocument_PersistentProvider::getInstance()->addProperty('form', 'baseform', $newProp); $newProp = $newModel->getPropertyByName('acknowledgmentNotification'); f_persistentdocument_PersistentProvider::getInstance()->addProperty('form', 'baseform', $newProp); $this->execChangeCommand('compile-documents'); foreach (form_FormService::getInstance()->createQuery()->find() as $form) { $form->setSaveResponse(true); $form->save(); } // Update mail fields. $newPath = f_util_FileUtils::buildWebeditPath('modules/form/persistentdocument/mail.xml'); $newModel = generator_PersistentModel::loadModelFromString(f_util_FileUtils::read($newPath), 'form', 'mail'); $newProp = $newModel->getPropertyByName('initializeWithCurrentUserEmail'); f_persistentdocument_PersistentProvider::getInstance()->addProperty('form', 'mail', $newProp); // Update text fields. $newPath = f_util_FileUtils::buildWebeditPath('modules/form/persistentdocument/text.xml'); $newModel = generator_PersistentModel::loadModelFromString(f_util_FileUtils::read($newPath), 'form', 'text'); $newProp = $newModel->getPropertyByName('disableAutocorrect'); f_persistentdocument_PersistentProvider::getInstance()->addProperty('form', 'text', $newProp); $newProp = $newModel->getPropertyByName('disableAutocapitalize'); f_persistentdocument_PersistentProvider::getInstance()->addProperty('form', 'text', $newProp); $newProp = $newModel->getPropertyByName('disableAutocomplete'); f_persistentdocument_PersistentProvider::getInstance()->addProperty('form', 'text', $newProp); foreach (form_MailService::getInstance()->createQuery()->find() as $field) { $field->setDisableAutocorrect(true); $field->setDisableAutocapitalize(true); $field->save(); } // Republish all forms. $bfs = form_BaseformService::getInstance(); foreach ($bfs->createQuery()->find() as $form) { $bfs->publishIfPossible($form->getId()); } // Create recipientGroupFolder and move all groups in it. $folder = form_RecipientGroupFolderService::getInstance()->getFolder(); $folderId = $folder->getId(); $rgs = form_RecipientGroupService::getInstance(); foreach ($rgs->createQuery()->find() as $group) { $rgs->moveTo($group, $folderId); } $this->executeLocalXmlScript('newlist.xml'); $this->log('If all went OK, you can delete m_form_doc_form_todelete and m_form_doc_form_i18n_todelete tables!'); }
/** * @return form_persistentdocument_baseform */ public function getForm() { return form_BaseformService::getInstance()->getAncestorFormByDocument($this); }
/** * @param f_persistentdocument_PersistentDocument $document * @param string $forModuleName * @param array $allowedSections * @return array */ public function getResume($document, $forModuleName, $allowedSections = null) { $resume = parent::getResume($document, $forModuleName, $allowedSections); $openNotificationUri = join(',', array('notification', 'openDocument', 'modules_notification_notification', $document->getNotification()->getId(), 'properties')); $backUri = join(',', array('form', 'openDocument', 'modules_form_form', $document->getId(), 'resume')); $resume["properties"]["notification"] = array("uri" => $openNotificationUri, "label" => f_Locale::translateUI("&modules.uixul.bo.doceditor.open;"), "backuri" => $backUri); return $resume; }
/** * @return form_persistentdocument_baseform */ protected function initPersistentDocument() { return form_BaseformService::getInstance()->getNewDocumentInstance(); }
/** * Returns the parent form of the given $field. * @param form_persistentdocument_field $field The field to move. * @return form_persistentdocument_baseform * @throws Exception if no parent form is found. */ public function getFormOf($field) { $fbs = form_BaseformService::getInstance(); $form = $fbs->getAncestorFormByDocument($field); if ($form === null) { throw new Exception("Could not find parent form for field \"" . $field->__toString() . "\"."); } return $form; }