Exemplo n.º 1
0
 /**
  * Creates the Admin Translations for the plugin
  *
  * @throws Exception
  */
 private function _createConfigTranslations()
 {
     $mapping = array('option_lable_basic_settings' => array('label' => '4004'), 'option_general_reason_one' => array('label' => '1623', 'description' => '1624'), 'option_general_reason_two' => array('label' => '1625', 'description' => '1624'), 'option_general_create_transactions' => array('label' => '4001', 'description' => '4002'), 'option_general_logging' => array('label' => '1630', 'description' => '1631'), 'option_general_remove_failed_transactions' => array('label' => '1654', 'description' => '1655'), 'option_lable_settings_sofortbanking' => array('label' => '4005'), 'option_sofortbanking_frontend_display' => array('label' => '1613', 'description' => '1614', 'store' => array(array(1, '1615'), array(2, '1616'))), 'option_sofortbanking_key' => array('label' => '1606', 'description' => '1607'), 'option_sofortbanking_customer_protection' => array('label' => '1617', 'description' => '1618'), 'option_sofortbanking_recommended_payment' => array('label' => '1619', 'description' => '1620'), 'option_lable_settings_sofortbanking_states' => array('label' => '1632'), 'option_sofortbanking_state_temporary' => array('label' => '1633', 'description' => '1634', 'store' => array(array(12, "Komplett bezahlt"), array(17, "Offen"), array(20, "Wiedergutschrift"), array(21, "Überprüfung notwendig"), array(35, "Vorgang wurde abgebrochen."))), 'option_sofortbanking_state_payment_confirmed' => array('label' => '1635', 'description' => '1636', 'store' => array(array(0, "1653"), array(12, "Komplett bezahlt"), array(17, "Offen"), array(20, "Wiedergutschrift"), array(21, "Überprüfung notwendig"), array(35, "Vorgang wurde abgebrochen."))), 'option_sofortbanking_state_payment_received' => array('label' => '1637', 'description' => '1638', 'store' => array(array(0, "1653"), array(12, "Komplett bezahlt"), array(17, "Offen"), array(20, "Wiedergutschrift"), array(21, "Überprüfung notwendig"), array(35, "Vorgang wurde abgebrochen."))), 'option_sofortbanking_state_payment_canceled' => array('label' => '1639', 'description' => '1640', 'store' => array(array(0, "1653"), array(12, "Komplett bezahlt"), array(17, "Offen"), array(20, "Wiedergutschrift"), array(21, "Überprüfung notwendig"), array(35, "Vorgang wurde abgebrochen."))), 'option_sofortbanking_state_investigation_needed' => array('label' => '1641', 'description' => '1642', 'store' => array(array(0, "1653"), array(12, "Komplett bezahlt"), array(17, "Offen"), array(20, "Wiedergutschrift"), array(21, "Überprüfung notwendig"), array(35, "Vorgang wurde abgebrochen."))), 'option_sofortbanking_state_refund_partial' => array('label' => '1643', 'description' => '1644', 'store' => array(array(0, "1653"), array(12, "Komplett bezahlt"), array(17, "Offen"), array(20, "Wiedergutschrift"), array(21, "Überprüfung notwendig"), array(35, "Vorgang wurde abgebrochen."))), 'option_sofortbanking_state_refund_full' => array('label' => '1645', 'description' => '1646', 'store' => array(array(0, "1653"), array(12, "Komplett bezahlt"), array(17, "Offen"), array(20, "Wiedergutschrift"), array(21, "Überprüfung notwendig"), array(35, "Vorgang wurde abgebrochen."))), 'option_lable_settings_ideal' => array('label' => '4006'), 'option_ideal_frontend_display' => array('label' => '1613', 'description' => '1614', 'store' => array(array(1, '1615'), array(2, '1616'))), 'option_ideal_key' => array('label' => '1606', 'description' => '1607'), 'option_ideal_project_password' => array('label' => '2605', 'description' => '2605'), 'option_ideal_notification_password' => array('label' => '2607', 'description' => '2608'), 'option_ideal_recommended_payment' => array('label' => '1619', 'description' => '1620'), 'option_lable_settings_ideal_states' => array('label' => '2632'), 'option_ideal_state_temporary' => array('label' => '2633', 'description' => '2634', 'store' => array(array(12, "Komplett bezahlt"), array(17, "Offen"), array(20, "Wiedergutschrift"), array(21, "Überprüfung notwendig"), array(35, "Vorgang wurde abgebrochen."))), 'option_ideal_state_payment_pending' => array('label' => '2635', 'description' => '2636', 'store' => array(array(0, "1653"), array(12, "Komplett bezahlt"), array(17, "Offen"), array(20, "Wiedergutschrift"), array(21, "Überprüfung notwendig"), array(35, "Vorgang wurde abgebrochen."))), 'option_ideal_state_payment_received' => array('label' => '2637', 'description' => '2638', 'store' => array(array(0, "1653"), array(12, "Komplett bezahlt"), array(17, "Offen"), array(20, "Wiedergutschrift"), array(21, "Überprüfung notwendig"), array(35, "Vorgang wurde abgebrochen."))), 'option_ideal_state_payment_canceled' => array('label' => '2639', 'description' => '2640', 'store' => array(array(0, "1653"), array(12, "Komplett bezahlt"), array(17, "Offen"), array(20, "Wiedergutschrift"), array(21, "Überprüfung notwendig"), array(35, "Vorgang wurde abgebrochen."))), 'option_ideal_state_storno' => array('label' => '2641', 'description' => '2642', 'store' => array(array(0, "1653"), array(12, "Komplett bezahlt"), array(17, "Offen"), array(20, "Wiedergutschrift"), array(21, "Überprüfung notwendig"), array(35, "Vorgang wurde abgebrochen."))), 'option_ideal_state_refund_partial' => array('label' => '2643', 'description' => '2644', 'store' => array(array(0, "1653"), array(12, "Komplett bezahlt"), array(17, "Offen"), array(20, "Wiedergutschrift"), array(21, "Überprüfung notwendig"), array(35, "Vorgang wurde abgebrochen."))), 'option_ideal_state_refund_full' => array('label' => '2645', 'description' => '2646', 'store' => array(array(0, "1653"), array(12, "Komplett bezahlt"), array(17, "Offen"), array(20, "Wiedergutschrift"), array(21, "Überprüfung notwendig"), array(35, "Vorgang wurde abgebrochen."))));
     //Build Translation array
     $translations = array();
     $translator = new Shopware_Plugins_Frontend_SofortPayment_Components_Services_Translator();
     //Build German Translations
     $translations['de_DE'] = array();
     $translator->setLanguage('de_DE');
     foreach ($mapping as $option => $values) {
         $translations['de_DE'][$option] = array();
         if (isset($values['label'])) {
             $translations['de_DE'][$option]['label'] = $translator->getSnippetByNumber($values['label']);
         }
         if (isset($values['text'])) {
             $translations['de_DE'][$option]['text'] = $translator->getSnippetByNumber($values['text']);
         }
         if (isset($values['description'])) {
             $translations['de_DE'][$option]['description'] = $translator->getSnippetByNumber($values['description']);
         }
         if (isset($values['store'])) {
             foreach ($values['store'] as $entries) {
                 if ($entries[1] !== "1653") {
                     $translations['de_DE'][$option]['store'][$entries[0]] = $entries[1];
                 } else {
                     $translations['de_DE'][$option]['store'][$entries[0]] = $translator->getSnippetByNumber($entries[1]);
                 }
             }
         }
     }
     //Build English Translations
     $translations['en_GB'] = array();
     $translator->setLanguage('en_GB');
     foreach ($mapping as $option => $values) {
         $translations['en_GB'][$option] = array();
         if (isset($values['label'])) {
             $translations['en_GB'][$option]['label'] = $translator->getSnippetByNumber($values['label']);
         }
         if (isset($values['text'])) {
             $translations['en_GB'][$option]['text'] = $translator->getSnippetByNumber($values['text']);
         }
         if (isset($values['description'])) {
             $translations['en_GB'][$option]['description'] = $translator->getSnippetByNumber($values['description']);
         }
         if (isset($values['store'])) {
             foreach ($values['store'] as $entries) {
                 if ($entries[1] !== "1653") {
                     $translations['en_GB'][$option]['store'][$entries[0]] = $entries[1];
                 } else {
                     $translations['en_GB'][$option]['store'][$entries[0]] = $translator->getSnippetByNumber($entries[1]);
                 }
             }
         }
     }
     $form = $this->_bootstrap->Form();
     $shopRepository = Shopware()->Models()->getRepository('\\Shopware\\Models\\Shop\\Locale');
     foreach ($translations as $locale => $snippets) {
         $localeModel = $shopRepository->findOneBy(array('locale' => $locale));
         foreach ($snippets as $element => $snippet) {
             if ($localeModel === null) {
                 continue;
             }
             $elementModel = $form->getElement($element);
             if ($elementModel === null) {
                 continue;
             }
             $translationModel = new \Shopware\Models\Config\ElementTranslation();
             if (isset($snippet['label'])) {
                 $translationModel->setLabel($snippet['label']);
             }
             if (isset($snippet['description'])) {
                 $translationModel->setDescription($snippet['description']);
             }
             /** @var $localeModel \Shopware\Models\Shop\Locale */
             $translationModel->setLocale($localeModel);
             $elementModel->addTranslation($translationModel);
         }
     }
 }
Exemplo n.º 2
0
    /**
     * Registers a plugin in the collection.
     *
     * @param   Shopware_Components_Plugin_Bootstrap $plugin
     * @return  bool
     */
    public function uninstallPlugin(Shopware_Components_Plugin_Bootstrap $plugin)
    {
        $result = $plugin->disable();
        $success = is_bool($result) ? $result : !empty($result['success']);
        if($success) {
            $result = $plugin->uninstall();
            $success = is_bool($result) ? $result : !empty($result['success']);
        }
        if ($success) {
            $id = $plugin->getId();
            $data = array(
                'installation_date' => NULL,
                'active' => 0
            );
            $this->Application()->Db()->update('s_core_plugins', $data, array('id=?' => $id));

            $sql = 'DELETE FROM `s_core_subscribes` WHERE `pluginID`=?';
            $this->Application()->Db()->query($sql, array($id));

            $sql = 'DELETE FROM `s_crontab` WHERE `pluginID`=?';
            $this->Application()->Db()->query($sql, array($id));

            /** @var $em Shopware\Components\Model\ModelManager */
            $em = $this->Application()->Models();

            if($plugin->hasForm()) {
                $form = $plugin->Form();
                if($form->getId()) {
                    $em->remove($form);
                } else {
                    $em->detach($form);
                }
                $em->flush();
            }

            $query = 'DELETE FROM Shopware\Models\Menu\Menu m WHERE m.pluginId = ?0';
            $query = $em->createQuery($query);
            $query->execute(array($id));

            $query = 'DELETE FROM Shopware\Models\Shop\Template t WHERE t.pluginId = ?0';
            $query = $em->createQuery($query);
            $query->execute(array($id));
        }
        return $result;
    }
Exemplo n.º 3
0
 /**
  * Helper function to remove a plugins form or only its translations (if removeData == false)
  *
  * @param Shopware_Components_Plugin_Bootstrap $bootstrap
  * @param bool $removeData
  * @throws Exception
  */
 private function removeForm(Shopware_Components_Plugin_Bootstrap $bootstrap, $removeData = true)
 {
     if (!$bootstrap->hasForm()) {
         return;
     }
     if ($removeData) {
         /** @var \Shopware\Components\Model\ModelManager $em */
         $em = $this->Application()->Models();
         $form = $bootstrap->Form();
         if ($form->getId()) {
             $em->remove($form);
         } else {
             $em->detach($form);
         }
         $em->flush();
         return;
     }
     $capabilities = $bootstrap->getCapabilities();
     if ($capabilities['secureUninstall']) {
         /** @var \Enlight_Components_Db_Adapter_Pdo_Mysql $db */
         $db = $this->Application()->Db();
         $id = $this->getPluginId($bootstrap->getName());
         // Remove element translations
         $sql = 'DELETE `s_core_config_element_translations`
                 FROM `s_core_config_element_translations`
                 INNER JOIN `s_core_config_elements`
                    ON `s_core_config_element_translations`.`element_id` = `s_core_config_elements`.`id`
                 INNER JOIN `s_core_config_forms`
                    ON `s_core_config_elements`.`form_id` = `s_core_config_forms`.`id`
                    AND `s_core_config_forms`.`plugin_id` = ?';
         $db->query($sql, array($id));
         // Remove form translations
         $sql = 'DELETE `s_core_config_form_translations`
                 FROM `s_core_config_form_translations`
                 INNER JOIN `s_core_config_forms`
                    ON `s_core_config_form_translations`.`form_id` = `s_core_config_forms`.`id`
                    AND `s_core_config_forms`.`plugin_id` = ?';
         $db->query($sql, array($id));
         return;
     }
     throw new \Exception('Plugin does not support secure uninstall.');
 }
Exemplo n.º 4
0
 /**
  * Registers a plugin in the collection.
  *
  * @param   Shopware_Components_Plugin_Bootstrap $bootstrap
  * @return  bool
  */
 public function uninstallPlugin(Shopware_Components_Plugin_Bootstrap $bootstrap)
 {
     /** @var \Shopware\Components\Model\ModelManager $em */
     $em = $this->Application()->Models();
     /** @var \Enlight_Components_Db_Adapter_Pdo_Mysql $db */
     $db = $this->Application()->Db();
     $id = $this->getPluginId($bootstrap->getName());
     $plugin = $em->find('Shopware\\Models\\Plugin\\Plugin', $id);
     $this->Application()->Events()->notify('Shopware_Plugin_PreUninstall', array('subject' => $this, 'plugin' => $bootstrap));
     $result = $bootstrap->disable();
     $success = is_bool($result) ? $result : !empty($result['success']);
     if ($success) {
         $result = $bootstrap->uninstall();
         $this->Application()->Events()->notify('Shopware_Plugin_PostUninstall', array('subject' => $this, 'plugin' => $bootstrap));
         $success = is_bool($result) ? $result : !empty($result['success']);
     }
     if ($success) {
         $plugin->setInstalled(null);
         $plugin->setActive(false);
         $em->flush($plugin);
         // Remove event subscribers
         $sql = 'DELETE FROM `s_core_subscribes` WHERE `pluginID`=?';
         $db->query($sql, array($id));
         // Remove crontab-entries
         $sql = 'DELETE FROM `s_crontab` WHERE `pluginID`=?';
         $db->query($sql, array($id));
         // Remove form
         if ($bootstrap->hasForm()) {
             $form = $bootstrap->Form();
             if ($form->getId()) {
                 $em->remove($form);
             } else {
                 $em->detach($form);
             }
             $em->flush();
         }
         // Remove menu-entry
         $query = 'DELETE FROM Shopware\\Models\\Menu\\Menu m WHERE m.pluginId = ?0';
         $query = $em->createQuery($query);
         $query->execute(array($id));
         // Remove templates
         $query = 'DELETE FROM Shopware\\Models\\Shop\\Template t WHERE t.pluginId = ?0';
         $query = $em->createQuery($query);
         $query->execute(array($id));
         // Remove emotion-components
         $sql = "DELETE s_emotion_element\n                    FROM s_emotion_element\n                    INNER JOIN s_library_component\n                        ON s_library_component.id = s_emotion_element.componentID\n                        AND s_library_component.pluginID = :pluginId";
         $db->query($sql, array(':pluginId' => $id));
         $sql = "DELETE s_library_component_field, s_library_component\n                    FROM s_library_component_field\n                    INNER JOIN s_library_component\n                        ON s_library_component.id = s_library_component_field.componentID\n                        AND s_library_component.pluginID = :pluginId";
         $db->query($sql, array(':pluginId' => $id));
         $this->removePluginWidgets($id);
     }
     return $result;
 }