예제 #1
0
 /**
  * Get folder preferences
  * @param $parameters
  * @return mixed
  */
 protected function _get_sources($parameters)
 {
     $result = $this->EE->db->get_where('assets_sources', $parameters)->result();
     foreach ($result as &$row) {
         $row->settings = json_encode(Assets_helper::apply_source_overrides($row->source_id, json_decode($row->settings)));
     }
     return $result;
 }
예제 #2
0
 /**
  * Get source
  *
  * @param StdCLass $data_object
  * @param bool $ignore_restrictions if set to TRUE, this source will not impose any filedir restrictions
  * @return Assets_base_source
  * @throws Exception
  */
 public function instantiate_source_type($data_object, $ignore_restrictions = FALSE)
 {
     $source_key = $data_object->source_type . '_' . (isset($data_object->source_id) ? $data_object->source_id : '') . '_' . (isset($data_object->filedir_id) ? $data_object->filedir_id : '') . (int) $ignore_restrictions;
     if (empty($this->cache['sources'][$source_key])) {
         require_once PATH_THIRD . 'assets/sources/' . $data_object->source_type . '/source.' . $data_object->source_type . '.php';
         require_once PATH_THIRD . 'assets/sources/' . $data_object->source_type . '/file.' . $data_object->source_type . '.php';
         $source_class = 'Assets_' . $data_object->source_type . '_source';
         if ($data_object->source_type == 'ee') {
             $settings = $this->EE->db->get_where('upload_prefs', array('id' => $data_object->filedir_id))->row();
             if (empty($settings)) {
                 throw new Exception(lang('unknown_source'));
             }
             $source_id = $data_object->filedir_id;
         } else {
             $settings = $this->EE->db->get_where('assets_sources', array('source_id' => $data_object->source_id, 'source_type' => $data_object->source_type))->row();
             if (empty($settings)) {
                 throw new Exception(lang('unknown_source'));
             }
             $source_id = $data_object->source_id;
             $settings = Assets_helper::apply_source_overrides($source_id, json_decode($settings->settings));
         }
         $this->cache['sources'][$source_key] = new $source_class($source_id, $settings, $ignore_restrictions);
     }
     if (empty($this->cache['sources'][$source_key])) {
         throw new Exception(lang('invalid_source_path'));
     }
     return $this->cache['sources'][$source_key];
 }