Example #1
0
 public function save()
 {
     if (!$this->getParameters()->icon) {
         $this->getParameters()->icon = 'folder';
     }
     return parent::save();
 }
Example #2
0
    public function save()
    {
        $this->storage_path = trim($this->storage_path);

        if ($this->isNew() && empty($this->storage_type)) {
            $this->storage_type = 'file';
        }

        if (!in_array($this->storage_type, array('file', 'remote')))
        {
            $this->setStatusMessage($this->getObject('translator')->translate('Storage type is not available'));
            $this->setStatus(KDatabase::STATUS_FAILED);

            return false;
        }

        if ($this->storage_type == 'remote')
        {
            $schemes = $this->getSchemes();
            $scheme  = parse_url($this->storage_path, PHP_URL_SCHEME);

            if (isset($schemes[$scheme]) && $schemes[$scheme] === false)
            {
                $this->setStatusMessage($this->getObject('translator')->translate('Storage type is not allowed'));
                $this->setStatus(KDatabase::STATUS_FAILED);

                return false;
            }
        }

        if (empty($this->docman_category_id))
        {
            if ($this->isNew())
            {
                $this->setStatusMessage($this->getObject('translator')->translate('Category cannot be empty'));
                $this->setStatus(KDatabase::STATUS_FAILED);

                return false;
            }
            else
            {
                unset($this->docman_category_id);
                unset($this->_modified['docman_category_id']);
            }
        }

        if (!$this->getParameters()->icon)
        {
            $icon = $this->getIcon($this->extension);

            if (empty($icon)) {
                $icon = 'default';
            }

            $this->getParameters()->icon = $icon;
        }

        return parent::save();
    }
Example #3
0
 public function save()
 {
     $result = false;
     if ($source = $this->getSource()) {
         $str = $source->thumbnail_string ? $source->thumbnail_string : $this->generateThumbnail();
         if ($str) {
             $this->setProperties(array('files_container_id' => $source->getContainer()->id, 'folder' => $source->folder, 'filename' => $source->name, 'thumbnail' => $str));
             $result = parent::save();
         }
     }
     return $result;
 }
Example #4
0
 public function save()
 {
     $conditions = $this->getConditions()->toArray();
     $conditions = $this->array_filter_recursive($conditions);
     array_walk_recursive($conditions, function (&$value) {
         if (is_numeric($value)) {
             $value = (int) $value;
         }
     });
     $this->getConditions()->merge($conditions);
     return parent::save();
 }
Example #5
0
 public function save()
 {
     @ini_set('memory_limit', '256M');
     $this->_setup();
     $result = true;
     if ($this->source) {
         $this->_saveUUID();
     }
     if ($this->type !== 'koowa-component') {
         if ($this->install_method === 'discover_install' && $this->dependency) {
             $result = $this->_installFromFilesystem();
         } elseif ($this->package) {
             $result = $this->_installFromPackage();
         }
     }
     if ($result) {
         if ($this->joomla_extension_id) {
             $this->_setCoreExtension(true);
             if ($this->isNew() && $this->type === 'plugin') {
                 $this->_setExtensionStatus(true);
             }
         }
         parent::save();
         if ($this->parent_id) {
             $this->_addDependency();
         }
         // Joomla does not add asset entries when doing discover_install on components
         if ($this->type === 'component' && $this->install_method === 'discover_install') {
             $this->_createAsset($this->name, 1);
         }
         if ($manifest = $this->getManifest()) {
             if ($manifest->dependencies) {
                 $this->_installDependencies($manifest->dependencies);
             }
             if ($manifest->deleted) {
                 $this->_deleteOldFiles($manifest->deleted);
             }
         }
         // Clear framework cache on each successful install for top level
         if (empty($this->parent_id)) {
             $this->clearCache();
         }
     }
     return $result;
 }
Example #6
0
 public function save()
 {
     // Activities are immutable.
     if (!$this->isNew()) {
         throw new RuntimeException('Activities cannot be modified.');
     }
     if (!$this->status) {
         // Attempt to provide a default status.
         switch ($this->verb) {
             case 'add':
                 $status = KDatabase::STATUS_CREATED;
                 break;
             case 'edit':
                 $status = KDatabase::STATUS_UPDATED;
                 break;
             case 'delete':
                 $status = KDatabase::STATUS_DELETED;
                 break;
             default:
                 $status = null;
         }
         if ($status) {
             $this->status = $status;
         }
     }
     foreach ($this->_required as $column) {
         if (empty($this->{$column})) {
             $this->setStatus(KDatabase::STATUS_FAILED);
             $this->setStatusMessage($this->getObject('translator')->translate('Missing required data'));
             return false;
         }
     }
     return parent::save();
 }