static function copy($option, $pkg, $ids)
 {
     global $database;
     JArrayHelper::toInteger($ids);
     require_once JPATH_SITE . '/administrator/components/com_breezingforms/admin/quickmode.class.php';
     require_once JPATH_SITE . '/administrator/components/com_breezingforms/libraries/Zend/Json/Decoder.php';
     require_once JPATH_SITE . '/administrator/components/com_breezingforms/libraries/Zend/Json/Encoder.php';
     $database = JFactory::getDBO();
     $total = count($ids);
     $row = new facileFormsForms($database);
     $elem = new facileFormsElements($database);
     if (count($ids)) {
         foreach ($ids as $id) {
             $row->load(intval($id));
             $row->id = NULL;
             $row->ordering = 999999;
             $row->title = 'Copy of ' . $row->title;
             $row->name = 'copy_' . $row->name;
             $row->store();
             $row->reorder('');
             $database->setQuery("select id from #__facileforms_elements where form={$id}");
             $eids = $database->loadObjectList();
             for ($i = 0; $i < count($eids); $i++) {
                 $eid = $eids[$i];
                 $elem->load(intval($eid->id));
                 $elem->id = NULL;
                 $elem->form = $row->id;
                 $elem->store();
             }
             // for
             // resetting easy and quickmode database ids
             JFactory::getDBO()->setQuery("Select template_areas, template_code_processed, template_code From #__facileforms_forms Where id = " . intval($row->{$id}));
             $row_ = JFactory::getDBO()->loadObject();
             if (trim($row_->template_code) != '') {
                 $areas = Zend_Json::decode($row_->template_areas);
                 $i = 0;
                 foreach ($areas as $area) {
                     $j = 0;
                     foreach ($area['elements'] as $element) {
                         $areas[$i]['elements'][$j]['dbId'] = 0;
                         $j++;
                     }
                     $i++;
                 }
                 $template_areas = Zend_Json::encode($areas);
                 $template_code = $row_->template_code;
                 if ($row_->template_code_processed == 'QuickMode') {
                     $dataObject = Zend_Json::decode(base64_decode($row_->template_code));
                     resetQuickModeDbId($dataObject);
                     $template_code = base64_encode(Zend_Json::encode($dataObject));
                 }
                 JFactory::getDBO()->setQuery("Update #__facileforms_forms Set template_code = " . JFactory::getDBO()->Quote($template_code) . ", template_areas = " . JFactory::getDBO()->Quote($template_areas) . " Where id = " . intval($id));
                 JFactory::getDBO()->query();
                 if ($row_ && $row_->template_code_processed == 'QuickMode') {
                     $quickMode = new QuickMode();
                     $quickMode->save($id, Zend_Json::decode(base64_decode($template_code)));
                 }
             }
             // reset end
         }
     }
     // foreach
     $msg = $total . ' ' . BFText::_('COM_BREEZINGFORMS_FORMS_SUCOPIED');
     JFactory::getApplication()->redirect("index.php?option={$option}&act=manageforms&pkg={$pkg}&mosmsg={$msg}");
 }
Beispiel #2
0
<?php

/**
* BreezingForms - A Joomla Forms Application
* @version 1.8
* @package BreezingForms
* @copyright (C) 2008-2012 by Markus Bopp
* @license Released under the terms of the GNU General Public License
**/
defined('_JEXEC') or die('Direct Access to this location is not allowed.');
require_once $ff_admpath . '/admin/quickmode.html.php';
require_once $ff_admpath . '/admin/quickmode.class.php';
require_once $ff_admpath . '/libraries/Zend/Json/Decoder.php';
require_once $ff_admpath . '/libraries/Zend/Json/Encoder.php';
$iconBase = '../administrator/components/com_breezingforms/libraries/jquery/themes/quickmode/i/';
$quickMode = new QuickMode();
$form = JRequest::getInt('form', 0);
switch ($task) {
    case 'doAjaxSave':
        $chunksLength = JRequest::getInt('chunksLength', 0);
        $form = JRequest::getInt('form', 0);
        $chunkIdx = JRequest::getInt('chunkIdx', 0);
        $rndAdd = JRequest::getVar('rndAdd', 0);
        $_dest = JPATH_SITE . '/media/breezingforms/ajax_cache/ajaxsave_' . $chunkIdx . '_' . $rndAdd . '.txt';
        $_chunk = JRequest::getVar('chunk', '');
        @JFile::write($_dest, $_chunk);
        @ob_end_clean();
        if ($chunkIdx == $chunksLength - 1) {
            $contents = '';
            for ($i = 0; $i < $chunksLength; $i++) {
                $contents .= @JFile::read(JPATH_SITE . '/media/breezingforms/ajax_cache/ajaxsave_' . $i . '_' . $rndAdd . '.txt');
 function import($filename)
 {
     global $errors, $errmode;
     // import crossreferences
     $this->xscripts = $this->xpieces = $this->oldscripts = $this->oldpieces = $this->scripts = $this->pieces = $this->forms = $this->elements = $this->menus = $this->warnings = array();
     $this->pubmenus = 0;
     if ($errmode == 'log') {
         $this->saveErrors = $errors;
         $errors = array();
     }
     // if
     $ok = parent::import($filename);
     if (!$ok) {
         // fail case
         $this->rollback();
         if ($errmode == 'log') {
             if (count($this->saveErrors)) {
                 $errors = array_merge($this->saveErrors, $errors);
             }
             $errors[] = BFText::_('COM_BREEZINGFORMS_INSTALLER') . ': ' . $this->error;
         }
         // if
     } else {
         // success case
         if ($this->pubmenus > 0) {
             updateComponentMenus();
         }
         $id = $this->getText(0, 'pkgid');
         if ($id != '') {
             relinkScripts($this->oldscripts);
             relinkPieces($this->oldpieces);
             savePackage($id, $this->getText(0, 'name'), $this->getText(0, 'title'), $this->getText(0, 'version'), $this->getText(0, 'creationDate'), $this->getText(0, 'author'), $this->getText(0, 'authorEmail'), $this->getText(0, 'authorUrl'), $this->getText(0, 'description'), $this->getText(0, 'copyright'));
         }
         // if
         require_once JPATH_SITE . '/administrator/components/com_breezingforms/admin/quickmode.class.php';
         require_once JPATH_SITE . '/administrator/components/com_breezingforms/libraries/Zend/Json/Decoder.php';
         require_once JPATH_SITE . '/administrator/components/com_breezingforms/libraries/Zend/Json/Encoder.php';
         foreach ($this->forms as $form_id) {
             JFactory::getDBO()->setQuery("Select template_areas, template_code_processed, template_code From #__facileforms_forms Where id = " . intval($form_id));
             $row = JFactory::getDBO()->loadObject();
             if (trim($row->template_code) != '') {
                 $areas = Zend_Json::decode(bf_b64dec($row->template_areas));
                 $i = 0;
                 foreach ($areas as $area) {
                     $j = 0;
                     foreach ($area['elements'] as $element) {
                         $areas[$i]['elements'][$j]['dbId'] = 0;
                         $j++;
                     }
                     $i++;
                 }
                 $template_areas = Zend_Json::encode($areas);
                 $template_code = $row->template_code;
                 if ($row->template_code_processed == 'QuickMode') {
                     $dataObject = Zend_Json::decode(bf_b64dec($row->template_code));
                     $this->resetQuickModeDbId($dataObject);
                     $template_code = bf_b64enc(Zend_Json::encode($dataObject));
                 }
                 JFactory::getDBO()->setQuery("Update #__facileforms_forms Set template_code = " . JFactory::getDBO()->Quote($template_code) . ", template_areas = " . JFactory::getDBO()->Quote($template_areas) . " Where id = " . intval($form_id));
                 JFactory::getDBO()->query();
                 if ($row && $row->template_code_processed == 'QuickMode') {
                     $quickMode = new QuickMode();
                     $quickMode->save($form_id, Zend_Json::decode(bf_b64dec($template_code)));
                 }
             }
         }
     }
     // if
     return $ok;
 }