Ejemplo n.º 1
0
 function newStepFinal()
 {
     $session = JFactory::getSession();
     $config = JFactory::getConfig();
     $row = JTable::getInstance('RSForm_Forms', 'Table');
     $row->FormTitle = $session->get('com_rsform.wizard.FormTitle');
     if (empty($row->FormTitle)) {
         $row->FormTitle = JText::_('RSFP_FORM_DEFAULT_TITLE');
     }
     $row->FormName = JFilterOutput::stringURLSafe($row->FormTitle);
     $row->FormLayoutName = $session->get('com_rsform.wizard.FormLayout');
     if (empty($row->FormLayoutName)) {
         $row->FormLayoutName = 'inline';
     }
     $AdminEmail = $session->get('com_rsform.wizard.AdminEmail');
     if ($AdminEmail) {
         $row->AdminEmailTo = $session->get('com_rsform.wizard.AdminEmailTo');
         $row->AdminEmailFrom = $config->getValue('config.mailfrom');
         $row->AdminEmailFromName = $config->getValue('config.fromname');
         $row->AdminEmailSubject = JText::sprintf('RSFP_ADMIN_EMAIL_DEFAULT_SUBJECT', $row->FormTitle);
         $row->AdminEmailText = JText::_('RSFP_ADMIN_EMAIL_DEFAULT_MESSAGE');
     }
     $UserEmail = $session->get('com_rsform.wizard.UserEmail');
     if ($UserEmail) {
         $row->UserEmailFrom = $config->getValue('config.mailfrom');
         $row->UserEmailFromName = $config->getValue('config.fromname');
         $row->UserEmailSubject = JText::_('RSFP_USER_EMAIL_DEFAULT_SUBJECT');
         $row->UserEmailText = JText::_('RSFP_USER_EMAIL_DEFAULT_MESSAGE');
     }
     $action = $session->get('com_rsform.wizard.SubmissionAction');
     if ($action == 'thankyou') {
         $row->Thankyou = $session->get('com_rsform.wizard.Thankyou');
     } elseif ($action == 'redirect') {
         $row->ReturnUrl = $session->get('com_rsform.wizard.ReturnUrl');
     }
     $filter = JFilterInput::getInstance();
     $layout = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_rsform' . DS . 'layouts' . DS . $filter->clean($row->FormLayoutName, 'path') . '.php';
     if (file_exists($layout)) {
         $quickfields = array();
         $requiredfields = array();
         $this->_form = $row;
         $row->FormLayout = (include $layout);
     }
     if ($row->store()) {
         $predefinedForm = JRequest::getVar('predefinedForm');
         if ($predefinedForm) {
             $path = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_rsform' . DS . 'assets' . DS . 'forms' . DS . $filter->clean($predefinedForm);
             if (file_exists($path . DS . 'install.xml')) {
                 $GLOBALS['q_FormId'] = $row->FormId;
                 JRequest::setVar('formId', $row->FormId);
                 $options = array();
                 $options['cleanup'] = 0;
                 require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_rsform' . DS . 'helpers' . DS . 'restore.php';
                 $restore = new RSFormProRestore($options);
                 $restore->installDir = $path;
                 if ($restore->restore()) {
                     $model = $this->getModel('forms');
                     $quickfields = $model->getQuickFields();
                     if ($AdminEmail && !empty($quickfields)) {
                         foreach ($quickfields as $quickfield) {
                             $row->AdminEmailText .= "\n" . '<p>{' . $quickfield . ':caption}: {' . $quickfield . ':value}</p>';
                         }
                     }
                     if ($UserEmail) {
                         $row->UserEmailTo = '{Email:value}';
                         if (!empty($quickfields)) {
                             foreach ($quickfields as $quickfield) {
                                 $row->UserEmailText .= "\n" . '<p>{' . $quickfield . ':caption}: {' . $quickfield . ':value}</p>';
                             }
                         }
                     }
                     $row->store();
                 }
             }
         }
     }
     $session->clear('com_rsform.wizard.FormTitle');
     $session->clear('com_rsform.wizard.FormLayout');
     $session->clear('com_rsform.wizard.AdminEmail');
     $session->clear('com_rsform.wizard.AdminEmailTo');
     $session->clear('com_rsform.wizard.UserEmail');
     $session->clear('com_rsform.wizard.SubmissionAction');
     $session->clear('com_rsform.wizard.Thankyou');
     $session->clear('com_rsform.wizard.ReturnUrl');
     $this->setRedirect('index.php?option=com_rsform&task=forms.edit&formId=' . $row->FormId);
 }
Ejemplo n.º 2
0
 function restoreProcess()
 {
     require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_rsform' . DS . 'helpers' . DS . 'restore.php';
     jimport('joomla.filesystem.archive');
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.file');
     $lang = JFactory::getLanguage();
     $lang->load('com_installer');
     $link = 'index.php?option=com_rsform&task=backup.restore';
     if (!extension_loaded('zlib')) {
         JError::raiseWarning(500, JText::_('WARNINSTALLZLIB'));
         return $this->setRedirect($link);
     }
     $userfile = JRequest::getVar('userfile', null, 'files');
     if ($userfile['error']) {
         JError::raiseWarning(500, JText::_($userfile['error'] == 4 ? 'ERRORNOFILE' : 'WARNINSTALLUPLOADERROR'));
         return $this->setRedirect($link);
     }
     $baseDir = JPATH_SITE . DS . 'media';
     $moved = JFile::upload($userfile['tmp_name'], $baseDir . DS . $userfile['name']);
     if (!$moved) {
         JError::raiseWarning(500, JText::_('FAILED TO MOVE UPLOADED FILE TO'));
         return $this->setRedirect($link);
     }
     $options = array();
     $options['filename'] = $baseDir . DS . $userfile['name'];
     $options['overwrite'] = JRequest::getInt('overwrite');
     $restore = new RSFormProRestore($options);
     if (!$restore->process()) {
         JError::raiseWarning(500, JText::_('Unable to extract archive'));
         return $this->setRedirect($link);
     }
     if (!$restore->restore()) {
         return $this->setRedirect($link);
     }
     $this->setRedirect($link, JText::_('RSFP_RESTORE_OK'));
 }
Ejemplo n.º 3
0
 protected function restoreLegacy($userfile)
 {
     require_once JPATH_ADMINISTRATOR . '/components/com_rsform/helpers/restore/legacy.php';
     jimport('joomla.filesystem.archive');
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.file');
     $overwrite = $this->getOverwrite();
     if (!extension_loaded('zlib')) {
         throw new Exception('The installer cannot continue until Zlib is installed.');
     }
     if (!JFile::upload($userfile['tmp_name'], JPATH_SITE . '/media/' . $userfile['name'])) {
         throw new Exception('Failed to move uploaded file to <b>/media</b> directory.');
     }
     $options = array('filename' => JPATH_SITE . '/media/' . $userfile['name'], 'overwrite' => $overwrite);
     $restore = new RSFormProRestore($options);
     if (!$restore->process()) {
         throw new Exception('Unable to extract archive.');
     }
     if (!$restore->restore()) {
         throw new Exception($restore->getErrors());
     }
 }