예제 #1
0
 public function verify()
 {
     parent::verify();
     // Each course has to have a course ID
     if (empty($this->data->courseId)) {
         throw new \Exception(Lang::txt('No course id'));
     }
 }
예제 #2
0
 public function verify()
 {
     parent::verify();
     // Check if the download file is set
     if (empty($this->data->meta['downloadFile']) || !$this->data->meta['downloadFile']) {
         throw new \Exception(Lang::txt('Download file must be set'));
     }
     // Check if the download file really exists
     $storefrontConfig = Component::params('com_storefront');
     $dir = $storefrontConfig->get('downloadFolder');
     $file = PATH_ROOT . $dir . DS . $this->data->meta['downloadFile'];
     if (!file_exists($file)) {
         throw new \Exception(Lang::txt('Download file doesn\'t exist'));
     }
 }
예제 #3
0
    /**
     * Delete an option and everything related to it
     *
     * @param	void
     * @return	void
     */
    public function delete()
    {
        // Delete the option record
        $sql = 'DELETE FROM `#__storefront_options` WHERE `oId` = ' . $this->db->quote($this->getId());
        $this->db->setQuery($sql);
        //print_r($this->db->replacePrefix($this->db->getQuery()));
        $this->db->query();
        // Find all SKUs that use this option before removing all references
        $sql = 'SELECT o.`sId` FROM `#__storefront_sku_options` o
				LEFT JOIN `#__storefront_skus` s ON o.`sId` = s.`sId`
				WHERE o.`oId` = ' . $this->db->quote($this->getId());
        $sql .= ' AND s.`sActive` = 1';
        $this->db->setQuery($sql);
        $sIds = $this->db->loadColumn();
        // Delete the SKU-option relation
        $sql = 'DELETE FROM `#__storefront_sku_options` WHERE `oId` = ' . $this->db->quote($this->getId());
        $this->db->setQuery($sql);
        //print_r($this->db->replacePrefix($this->db->getQuery()));
        $this->db->query();
        // Update dependencies, disable SKUs that became invalid
        $skusDisabled = false;
        foreach ($sIds as $sId) {
            $sku = new Sku($sId);
            if ($sku->getActiveStatus()) {
                try {
                    $sku->verify();
                } catch (\Exception $e) {
                    $sku->unpublish();
                    $skusDisabled = true;
                }
            }
        }
        if ($skusDisabled) {
            $this->addMessage('Some SKUs were unpublished because of the recent update. Check each SKU to fix the issues.');
        }
    }