Пример #1
0
 /**
  * Export a Base64 PDF Report
  * @param SugarBean report
  * @return file contents
  */
 protected function exportBase64(ServiceBase $api, SugarBean $report)
 {
     global $beanList, $beanFiles;
     global $sugar_config, $current_language;
     require_once 'modules/Reports/templates/templates_pdf.php';
     $contents = '';
     $report_filename = false;
     if ($report->id != null) {
         //Translate pdf to correct language
         $reporter = new Report(html_entity_decode($report->content), '', '');
         $reporter->layout_manager->setAttribute("no_sort", 1);
         $reporter->fromApi = true;
         //Translate pdf to correct language
         $mod_strings = return_module_language($current_language, 'Reports');
         //Generate actual pdf
         $report_filename = template_handle_pdf($reporter, false);
         sugar_cache_put($report->id . '-' . $GLOBALS['current_user']->id, $report_filename, $this->cacheLength * 60);
         $dl = new DownloadFile();
         $contents = $dl->getFileByFilename($report_filename);
     }
     if (empty($contents)) {
         throw new SugarApiException('File contents empty.');
     }
     // Reply is raw just pass back the base64 encoded contents
     return base64_encode($contents);
 }
    public function build_view(HTTPRequestCustom $request)
    {
        $now = new Date();
        $config = DownloadConfig::load();
        $authorized_categories = DownloadService::get_authorized_categories(Category::ROOT_CATEGORY);
        $mode = $request->get_getstring('sort', DownloadUrlBuilder::DEFAULT_SORT_MODE);
        $field = $request->get_getstring('field', DownloadUrlBuilder::DEFAULT_SORT_FIELD);
        $condition = 'WHERE id_category IN :authorized_categories
		' . (!DownloadAuthorizationsService::check_authorizations()->moderation() ? ' AND author_user_id = :user_id' : '') . '
		AND (approbation_type = 0 OR (approbation_type = 2 AND (start_date > :timestamp_now OR (end_date != 0 AND end_date < :timestamp_now))))';
        $parameters = array('user_id' => AppContext::get_current_user()->get_id(), 'authorized_categories' => $authorized_categories, 'timestamp_now' => $now->get_timestamp());
        $page = AppContext::get_request()->get_getint('page', 1);
        $pagination = $this->get_pagination($condition, $parameters, $field, $mode, $page);
        $sort_mode = $mode == 'asc' ? 'ASC' : 'DESC';
        switch ($field) {
            case 'name':
                $sort_field = DownloadFile::SORT_ALPHABETIC;
                break;
            case 'author':
                $sort_field = DownloadFile::SORT_AUTHOR;
                break;
            default:
                $sort_field = DownloadFile::SORT_DATE;
                break;
        }
        $result = PersistenceContext::get_querier()->select('SELECT download.*, member.*, com.number_comments, notes.average_notes, notes.number_notes, note.note
		FROM ' . DownloadSetup::$download_table . ' download
		LEFT JOIN ' . DB_TABLE_MEMBER . ' member ON member.user_id = download.author_user_id
		LEFT JOIN ' . DB_TABLE_COMMENTS_TOPIC . ' com ON com.id_in_module = download.id AND com.module_id = \'download\'
		LEFT JOIN ' . DB_TABLE_AVERAGE_NOTES . ' notes ON notes.id_in_module = download.id AND notes.module_name = \'download\'
		LEFT JOIN ' . DB_TABLE_NOTE . ' note ON note.id_in_module = download.id AND note.module_name = \'download\' AND note.user_id = :user_id
		' . $condition . '
		ORDER BY ' . $sort_field . ' ' . $sort_mode . '
		LIMIT :number_items_per_page OFFSET :display_from', array_merge($parameters, array('number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from())));
        $this->tpl->put_all(array('C_FILES' => $result->get_rows_count() > 0, 'C_MORE_THAN_ONE_FILE' => $result->get_rows_count() > 1, 'C_PENDING' => true, 'C_CATEGORY_DISPLAYED_SUMMARY' => $config->is_category_displayed_summary(), 'C_CATEGORY_DISPLAYED_TABLE' => $config->is_category_displayed_table(), 'C_COMMENTS_ENABLED' => $config->are_comments_enabled(), 'C_NOTATION_ENABLED' => $config->is_notation_enabled(), 'C_AUTHOR_DISPLAYED' => $config->is_author_displayed(), 'C_PAGINATION' => $pagination->has_several_pages(), 'PAGINATION' => $pagination->display(), 'TABLE_COLSPAN' => 4 + (int) $config->are_comments_enabled() + (int) $config->is_notation_enabled()));
        while ($row = $result->fetch()) {
            $downloadfile = new DownloadFile();
            $downloadfile->set_properties($row);
            $keywords = $downloadfile->get_keywords();
            $has_keywords = count($keywords) > 0;
            $this->tpl->assign_block_vars('downloadfiles', array_merge($downloadfile->get_array_tpl_vars(), array('C_KEYWORDS' => $has_keywords)));
            if ($has_keywords) {
                $this->build_keywords_view($keywords);
            }
        }
        $result->dispose();
        $this->build_sorting_form($field, $mode);
    }
 public function get_menu_content()
 {
     //Create file template
     $tpl = new FileTemplate('download/DownloadModuleMiniMenu.tpl');
     //Assign the lang file to the tpl
     $tpl->add_lang(LangLoader::get('common', 'download'));
     //Load module config
     $config = DownloadConfig::load();
     //Load module cache
     $download_cache = DownloadCache::load();
     //Load categories cache
     $categories_cache = DownloadService::get_categories_manager()->get_categories_cache();
     $downloadfiles = $download_cache->get_downloadfiles();
     $tpl->put_all(array('C_FILES' => !empty($downloadfiles), 'C_SORT_BY_DATE' => $config->is_sort_type_date(), 'C_SORT_BY_NOTATION' => $config->is_sort_type_notation(), 'C_SORT_BY_NUMBER_DOWNLOADS' => $config->is_sort_type_number_downloads()));
     $displayed_position = 1;
     foreach ($downloadfiles as $file) {
         $downloadfile = new DownloadFile();
         $downloadfile->set_properties($file);
         $tpl->assign_block_vars('downloadfiles', array_merge($downloadfile->get_array_tpl_vars(), array('DISPLAYED_POSITION' => $displayed_position)));
         $displayed_position++;
     }
     return $tpl->render();
 }
 private function contribution_actions(DownloadFile $downloadfile, $id)
 {
     if ($downloadfile->get_id() === null) {
         if ($this->is_contributor_member()) {
             $contribution = new Contribution();
             $contribution->set_id_in_module($id);
             $contribution->set_description(stripslashes($this->form->get_value('contribution_description')));
             $contribution->set_entitled($downloadfile->get_name());
             $contribution->set_fixing_url(DownloadUrlBuilder::edit($id)->relative());
             $contribution->set_poster_id(AppContext::get_current_user()->get_id());
             $contribution->set_module('download');
             $contribution->set_auth(Authorizations::capture_and_shift_bit_auth(DownloadService::get_categories_manager()->get_heritated_authorizations($downloadfile->get_id_category(), Category::MODERATION_AUTHORIZATIONS, Authorizations::AUTH_CHILD_PRIORITY), Category::MODERATION_AUTHORIZATIONS, Contribution::CONTRIBUTION_AUTH_BIT));
             ContributionService::save_contribution($contribution);
         }
     } else {
         $corresponding_contributions = ContributionService::find_by_criteria('download', $id);
         if (count($corresponding_contributions) > 0) {
             $downloadfile_contribution = $corresponding_contributions[0];
             $downloadfile_contribution->set_status(Event::EVENT_STATUS_PROCESSED);
             ContributionService::save_contribution($downloadfile_contribution);
         }
     }
     $downloadfile->set_id($id);
 }
Пример #5
0
 /**
  * Retrieves an User bean
  * pre-format name & full_name attribute with first/last
  * loads User's preferences
  * If the picture doesn't exist on the file system, it empties out the picture field
  *
  * @param string $id         ID of the User
  * @param bool $encode       Encode the result
  * @param bool $deleted      Include deleted users
  * @return User|null         Returns the user object unless once is not found, then it returns null
  */
 public function retrieve($id, $encode = true, $deleted = true)
 {
     $ret = parent::retrieve($id, $encode, $deleted);
     //CurrentUserApi needs a consistent timestamp/format of the data modified for hash purposes.
     $this->hashTS = $this->fetched_row['date_modified'];
     if ($ret) {
         if (isset($_SESSION)) {
             $this->loadPreferences();
         }
         // make sure that the picture actually exists
         SugarAutoLoader::requireWithCustom('include/download_file.php');
         $download_file = new DownloadFile();
         if (!empty($ret->picture) && !file_exists($download_file->getFilePathFromId($ret->picture))) {
             $ret->picture = '';
         }
     }
     return $ret;
 }
Пример #6
0
 /**
  * Resume the Download of a File
  *
  * @param urld - required -
  *          The download URL.
  * @param dir - required -
  *          The download folder (path+folderName).
  * @param password - optional -
  * 	  If a password has been set, the recipients are asked to enter the password before they can access the files. The minimum length of the password is 5 characters.
  * @param range - optional -
  * 	  Only the specified range of bytes is downloaded and appended to the existing file if a range has been set. If no range has been set the entire file is downloaded and saved inside the download directory (the value from $dir).
  * @return The status "fail" if the download has failed or the downloaded file name if the download has succeeded.
  * 	 */
 public function downloadaFileResume($urld, $dir, $password = '', $range = '')
 {
     $parameters = array();
     if ($password !== '') {
         $parameters['password'] = $password;
     }
     $a = new DownloadFile($this->_hostName, $this->_apiKey, $this->_userAgent);
     $response = $a->sendRequestWS($urld, $parameters, $this->_authToken);
     if ($response !== 'fail') {
         $s = strpos($response, "Location: ") + 10;
         $e = strpos($response, "Server:") - 2;
         $d = $e - $s;
         $url = substr($response, $s, $d);
         $response = $a->sendRequestResume($url, $this->_authToken, $range);
         if ($response !== 'fail') {
             $s = strpos($url, "&file=") + 6;
             $e = strlen($url);
             $d = $e - $s;
             $fname = substr($url, $s, $d);
             $f = $dir . $fname;
             if ($range[0] == '0' || ($range = '')) {
                 file_put_contents($f, $response);
             } else {
                 $fh = fopen($f, 'a');
                 fwrite($fh, $response);
                 fclose($fh);
             }
             return $fname;
         } else {
             return 'fail';
         }
     } else {
         return 'fail';
     }
 }
    private function build_view(HTTPRequestCustom $request)
    {
        $now = new Date();
        $authorized_categories = DownloadService::get_authorized_categories($this->get_category()->get_id());
        $mode = $request->get_getstring('sort', DownloadUrlBuilder::DEFAULT_SORT_MODE);
        $field = $request->get_getstring('field', DownloadUrlBuilder::DEFAULT_SORT_FIELD);
        $page = AppContext::get_request()->get_getint('page', 1);
        $subcategories_page = AppContext::get_request()->get_getint('subcategories_page', 1);
        $subcategories_number = count(DownloadService::get_categories_manager()->get_categories_cache()->get_childrens($this->get_category()->get_id()));
        $subcategories_pagination = $this->get_subcategories_pagination($subcategories_number, $this->config->get_categories_number_per_page(), $field, $mode, $page, $subcategories_page);
        //Children categories
        $result = PersistenceContext::get_querier()->select('SELECT @id_cat:= download_cats.id, download_cats.*,
		(SELECT COUNT(*) FROM ' . DownloadSetup::$download_table . '
			WHERE id_category IN (
				@id_cat,
				(SELECT GROUP_CONCAT(id SEPARATOR \',\') FROM ' . DownloadSetup::$download_cats_table . ' WHERE id_parent = @id_cat), 
				(SELECT GROUP_CONCAT(childs.id SEPARATOR \',\') FROM ' . DownloadSetup::$download_cats_table . ' parents
				INNER JOIN ' . DownloadSetup::$download_cats_table . ' childs ON parents.id = childs.id_parent
				WHERE parents.id_parent = @id_cat)
			)
			AND (approbation_type = 1 OR (approbation_type = 2 AND start_date < :timestamp_now AND (end_date > :timestamp_now OR end_date = 0)))
		) AS downloadfiles_number
		FROM ' . DownloadSetup::$download_cats_table . ' download_cats
		WHERE id_parent = :id_category
		AND id IN :authorized_categories
		ORDER BY id_parent, c_order
		LIMIT :number_items_per_page OFFSET :display_from', array('timestamp_now' => $now->get_timestamp(), 'id_category' => $this->category->get_id(), 'authorized_categories' => $authorized_categories, 'number_items_per_page' => $subcategories_pagination->get_number_items_per_page(), 'display_from' => $subcategories_pagination->get_display_from()));
        $nbr_cat_displayed = 0;
        while ($row = $result->fetch()) {
            $category_image = new Url($row['image']);
            $this->tpl->assign_block_vars('sub_categories_list', array('C_CATEGORY_IMAGE' => !empty($row['image']), 'C_MORE_THAN_ONE_DOWNLOADFILE' => $row['downloadfiles_number'] > 1, 'CATEGORY_NAME' => $row['name'], 'CATEGORY_IMAGE' => $category_image->rel(), 'DOWNLOADFILES_NUMBER' => $row['downloadfiles_number'], 'U_CATEGORY' => DownloadUrlBuilder::display_category($row['id'], $row['rewrited_name'])->rel()));
            $nbr_cat_displayed++;
        }
        $result->dispose();
        $nbr_column_cats = $nbr_cat_displayed > $this->config->get_columns_number_per_line() ? $this->config->get_columns_number_per_line() : $nbr_cat_displayed;
        $nbr_column_cats = !empty($nbr_column_cats) ? $nbr_column_cats : 1;
        $cats_columns_width = floor(100 / $nbr_column_cats);
        $condition = 'WHERE id_category = :id_category
		AND (approbation_type = 1 OR (approbation_type = 2 AND start_date < :timestamp_now AND (end_date > :timestamp_now OR end_date = 0)))';
        $parameters = array('id_category' => $this->get_category()->get_id(), 'timestamp_now' => $now->get_timestamp());
        $pagination = $this->get_pagination($condition, $parameters, $field, $mode, $page, $subcategories_page);
        $sort_mode = $mode == 'asc' ? 'ASC' : 'DESC';
        switch ($field) {
            case 'name':
                $sort_field = DownloadFile::SORT_ALPHABETIC;
                break;
            case 'download':
                $sort_field = DownloadFile::SORT_NUMBER_DOWNLOADS;
                break;
            case 'com':
                $sort_field = DownloadFile::SORT_NUMBER_COMMENTS;
                break;
            case 'note':
                $sort_field = DownloadFile::SORT_NOTATION;
                break;
            case 'author':
                $sort_field = DownloadFile::SORT_AUTHOR;
                break;
            case 'date':
                $sort_field = DownloadFile::SORT_DATE;
                break;
            default:
                $sort_field = DownloadFile::SORT_UPDATED_DATE;
                break;
        }
        $result = PersistenceContext::get_querier()->select('SELECT download.*, member.*, com.number_comments, notes.average_notes, notes.number_notes, note.note
		FROM ' . DownloadSetup::$download_table . ' download
		LEFT JOIN ' . DB_TABLE_MEMBER . ' member ON member.user_id = download.author_user_id
		LEFT JOIN ' . DB_TABLE_COMMENTS_TOPIC . ' com ON com.id_in_module = download.id AND com.module_id = \'download\'
		LEFT JOIN ' . DB_TABLE_AVERAGE_NOTES . ' notes ON notes.id_in_module = download.id AND notes.module_name = \'download\'
		LEFT JOIN ' . DB_TABLE_NOTE . ' note ON note.id_in_module = download.id AND note.module_name = \'download\' AND note.user_id = :user_id
		' . $condition . '
		ORDER BY ' . $sort_field . ' ' . $sort_mode . '
		LIMIT :number_items_per_page OFFSET :display_from', array_merge($parameters, array('user_id' => AppContext::get_current_user()->get_id(), 'number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from())));
        $category_description = FormatingHelper::second_parse($this->get_category()->get_description());
        $this->tpl->put_all(array('C_FILES' => $result->get_rows_count() > 0, 'C_MORE_THAN_ONE_FILE' => $result->get_rows_count() > 1, 'C_CATEGORY_DISPLAYED_SUMMARY' => $this->config->is_category_displayed_summary(), 'C_CATEGORY_DISPLAYED_TABLE' => $this->config->is_category_displayed_table(), 'C_CATEGORY_DESCRIPTION' => !empty($category_description), 'C_AUTHOR_DISPLAYED' => $this->config->is_author_displayed(), 'C_COMMENTS_ENABLED' => $this->config->are_comments_enabled(), 'C_NOTATION_ENABLED' => $this->config->is_notation_enabled(), 'C_MODERATION' => DownloadAuthorizationsService::check_authorizations($this->get_category()->get_id())->moderation(), 'C_PAGINATION' => $pagination->has_several_pages(), 'C_CATEGORY' => true, 'C_ROOT_CATEGORY' => $this->get_category()->get_id() == Category::ROOT_CATEGORY, 'C_HIDE_NO_ITEM_MESSAGE' => $this->get_category()->get_id() == Category::ROOT_CATEGORY && ($nbr_cat_displayed != 0 || !empty($category_description)), 'C_SUB_CATEGORIES' => $nbr_cat_displayed > 0, 'C_SUBCATEGORIES_PAGINATION' => $subcategories_pagination->has_several_pages(), 'SUBCATEGORIES_PAGINATION' => $subcategories_pagination->display(), 'CATS_COLUMNS_WIDTH' => $cats_columns_width, 'PAGINATION' => $pagination->display(), 'TABLE_COLSPAN' => 4 + (int) $this->config->are_comments_enabled() + (int) $this->config->is_notation_enabled(), 'ID_CAT' => $this->get_category()->get_id(), 'CATEGORY_NAME' => $this->get_category()->get_name(), 'CATEGORY_IMAGE' => $this->get_category()->get_image()->rel(), 'CATEGORY_DESCRIPTION' => $category_description, 'U_EDIT_CATEGORY' => $this->get_category()->get_id() == Category::ROOT_CATEGORY ? DownloadUrlBuilder::configuration()->rel() : DownloadUrlBuilder::edit_category($this->get_category()->get_id())->rel()));
        while ($row = $result->fetch()) {
            $downloadfile = new DownloadFile();
            $downloadfile->set_properties($row);
            $keywords = $downloadfile->get_keywords();
            $has_keywords = count($keywords) > 0;
            $this->tpl->assign_block_vars('downloadfiles', array_merge($downloadfile->get_array_tpl_vars(), array('C_KEYWORDS' => $has_keywords)));
            if ($has_keywords) {
                $this->build_keywords_view($keywords);
            }
        }
        $result->dispose();
        $this->build_sorting_form($field, $mode);
    }
    private function build_table()
    {
        $table_model = new SQLHTMLTableModel(DownloadSetup::$download_table, 'table', array(new HTMLTableColumn(LangLoader::get_message('form.name', 'common'), 'name'), new HTMLTableColumn(LangLoader::get_message('category', 'categories-common'), 'id_category'), new HTMLTableColumn(LangLoader::get_message('author', 'common'), 'display_name'), new HTMLTableColumn(LangLoader::get_message('form.date.creation', 'common'), 'creation_date'), new HTMLTableColumn(LangLoader::get_message('status', 'common'), 'approbation_type'), new HTMLTableColumn('')), new HTMLTableSortingRule('creation_date', HTMLTableSortingRule::DESC));
        $table = new HTMLTable($table_model);
        $table_model->set_caption($this->lang['download.management']);
        $results = array();
        $result = $table_model->get_sql_results('download
			LEFT JOIN ' . DB_TABLE_COMMENTS_TOPIC . ' com ON com.id_in_module = download.id AND com.module_id = \'download\'
			LEFT JOIN ' . DB_TABLE_AVERAGE_NOTES . ' notes ON notes.id_in_module = download.id AND notes.module_name = \'download\'
			LEFT JOIN ' . DB_TABLE_NOTE . ' note ON note.id_in_module = download.id AND note.module_name = \'download\' AND note.user_id = ' . AppContext::get_current_user()->get_id() . '
			LEFT JOIN ' . DB_TABLE_MEMBER . ' member ON member.user_id = download.author_user_id', array('*', 'download.id'));
        foreach ($result as $row) {
            $downloadfile = new DownloadFile();
            $downloadfile->set_properties($row);
            $category = $downloadfile->get_category();
            $user = $downloadfile->get_author_user();
            $edit_link = new LinkHTMLElement(DownloadUrlBuilder::edit($downloadfile->get_id()), '', array('title' => LangLoader::get_message('edit', 'common')), 'fa fa-edit');
            $delete_link = new LinkHTMLElement(DownloadUrlBuilder::delete($downloadfile->get_id()), '', array('title' => LangLoader::get_message('delete', 'common'), 'data-confirmation' => 'delete-element'), 'fa fa-delete');
            $user_group_color = User::get_group_color($user->get_groups(), $user->get_level(), true);
            $author = $user->get_id() !== User::VISITOR_LEVEL ? new LinkHTMLElement(UserUrlBuilder::profile($user->get_id()), $user->get_display_name(), !empty($user_group_color) ? array('style' => 'color: ' . $user_group_color) : array(), UserService::get_level_class($user->get_level())) : $user->get_display_name();
            $results[] = new HTMLTableRow(array(new HTMLTableRowCell(new LinkHTMLElement(DownloadUrlBuilder::display($category->get_id(), $category->get_rewrited_name(), $downloadfile->get_id(), $downloadfile->get_rewrited_name()), $downloadfile->get_name()), 'left'), new HTMLTableRowCell(new LinkHTMLElement(DownloadUrlBuilder::display_category($category->get_id(), $category->get_rewrited_name()), $category->get_name())), new HTMLTableRowCell($author), new HTMLTableRowCell($downloadfile->get_creation_date()->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE)), new HTMLTableRowCell($downloadfile->get_status()), new HTMLTableRowCell($edit_link->display() . $delete_link->display())));
        }
        $table->set_rows($table_model->get_number_of_matching_rows(), $results);
        $this->view->put('table', $table->display());
    }
Пример #9
0
 /**
  * Загрузка изображений
  * @param type $newNameFile -    1) новое имя изображения
  * @param type $nameIdInputFile -2) id name input
  * @param type $idFile -         3) id изображения, если загружено больше одного
  * @param type $access -         4) строка разрешенных расширений
  * @param type $fileSize -       5) допустимый размер файла
  * @param type $extension -      6) новое расширение
  * @param type $width -          7) ширина изображения
  * @param type $height -         8) высота изображения
  * @param type $parameterImage - 9) параметры ресайзa изображения 
  *              Может быть: exact - точно по заданным размерам; maxwidth - Ш-неизменна, Д-сохраняет соотношение; 
  *              maxheight - Д-неизменна, Ш-сохраняет соотношение; crop - обрезка; по умолчанию - default (авто) 
  */
 public function uploadFile($newNameFile, $nameIdInputFile, $idFile = null, $access = null, $fileSize = null, $extension = null, $width = null, $height = null, $parameterImage = null)
 {
     parent::uploadFile($newNameFile, $nameIdInputFile, $idFile, $access, $fileSize, $extension);
     // если файл существует
     if (file_exists($this->saveNameFile)) {
         // если допустимые размеры норм
         if ($this->checkImageSize($this->saveNameFile)) {
             // если задана только ширина, ресайз будет по ширине с сохранением пропорций
             if ($width !== null || $height !== null) {
                 if ($width !== null && $height === null) {
                     $this->width = $width;
                     $this->parameterImage = 'maxwidth';
                     // если задана только высота, ресайз будет по высотe с сохранением пропорций
                 } elseif ($height !== null && $width === null) {
                     $this->height = $height;
                     $this->parameterImage = 'maxheight';
                 } else {
                     // если задана и ширина и высота
                     if ($width !== null && $width != '' && $height !== null && $height != '') {
                         $this->width = $width;
                         $this->height = $height;
                         // и параметр ресайзa, ресайз будет по значению $parameterImage
                         if ($parameterImage !== null) {
                             $this->parameterImage = $parameterImage;
                         } else {
                             // ресайз будет по default
                             $this->parameterImage = 'default';
                         }
                     }
                 }
                 $this->resizeImages($this->saveNameFile, $this->width, $this->height, $this->parameterImage);
             }
         } else {
             // если максимальные или минимальные размеры не проходят, сообщаем об ошибке
             $this->errors[] = ' Файл не загружен';
             if (file_exists($this->saveNameFile)) {
                 unlink($this->saveNameFile);
             }
         }
     } else {
         $this->errors[] = ' Файл не найден';
     }
 }
Пример #10
0
    /**
     * @desc Return the properties of a downloadfile.
     * @param string $condition : Restriction to apply to the list
     * @param string[] $parameters : Parameters of the condition
     */
    public static function get_downloadfile($condition, array $parameters)
    {
        $row = self::$db_querier->select_single_row_query('SELECT download.*, member.*, notes.average_notes, notes.number_notes, note.note
		FROM ' . DownloadSetup::$download_table . ' download
		LEFT JOIN ' . DB_TABLE_MEMBER . ' member ON member.user_id = download.author_user_id
		LEFT JOIN ' . DB_TABLE_AVERAGE_NOTES . ' notes ON notes.id_in_module = download.id AND notes.module_name = \'download\'
		LEFT JOIN ' . DB_TABLE_NOTE . ' note ON note.id_in_module = download.id AND note.module_name = \'download\' AND note.user_id = ' . AppContext::get_current_user()->get_id() . '
		' . $condition, $parameters);
        $downloadfile = new DownloadFile();
        $downloadfile->set_properties($row);
        return $downloadfile;
    }
Пример #11
0
 public static function directTemp($file, $filename = null, $raiz = '/temp/', $force = true)
 {
     $down = new DownloadFile($file, $filename, $force);
     $down->downloadByTemp($raiz);
     //Melhor solução para arquivos grandes, jogar controle para apache
 }