public function execute(HTTPRequestCustom $request)
 {
     $id = $request->get_getint('id', 0);
     if (!empty($id) && AppContext::get_current_user()->check_level(User::MEMBER_LEVEL)) {
         try {
             $this->downloadfile = DownloadService::get_downloadfile('WHERE download.id = :id', array('id' => $id));
         } catch (RowNotFoundException $e) {
             $error_controller = PHPBoostErrors::unexisting_page();
             DispatchManager::redirect($error_controller);
         }
     }
     if ($this->downloadfile !== null && $this->downloadfile->is_visible()) {
         if (!PersistenceContext::get_querier()->row_exists(PREFIX . 'events', 'WHERE id_in_module=:id_in_module AND module=\'download\' AND current_status = 0', array('id_in_module' => $this->downloadfile->get_id()))) {
             $contribution = new Contribution();
             $contribution->set_id_in_module($this->downloadfile->get_id());
             $contribution->set_entitled(StringVars::replace_vars(LangLoader::get_message('contribution.deadlink', 'common'), array('link_name' => $this->downloadfile->get_name())));
             $contribution->set_fixing_url(DownloadUrlBuilder::edit($this->downloadfile->get_id())->relative());
             $contribution->set_description(LangLoader::get_message('contribution.deadlink_explain', 'common'));
             $contribution->set_poster_id(AppContext::get_current_user()->get_id());
             $contribution->set_module('download');
             $contribution->set_type('alert');
             $contribution->set_auth(Authorizations::capture_and_shift_bit_auth(DownloadService::get_categories_manager()->get_heritated_authorizations($this->downloadfile->get_id_category(), Category::MODERATION_AUTHORIZATIONS, Authorizations::AUTH_CHILD_PRIORITY), Category::MODERATION_AUTHORIZATIONS, Contribution::CONTRIBUTION_AUTH_BIT));
             ContributionService::save_contribution($contribution);
         }
         DispatchManager::redirect(new UserContributionSuccessController());
     } else {
         $error_controller = PHPBoostErrors::unexisting_page();
         DispatchManager::redirect($error_controller);
     }
 }
 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);
 }
Exemplo n.º 3
0
 function Alert_topic($alert_post, $alert_title, $alert_contents)
 {
     global $LANG;
     try {
         $topic_infos = PersistenceContext::get_querier()->select_single_row(PREFIX . 'forum_topics', array("idcat", "title"), 'WHERE id=:id', array('id' => $alert_post));
     } catch (RowNotFoundException $e) {
         $error_controller = PHPBoostErrors::unexisting_element();
         DispatchManager::redirect($error_controller);
     }
     $result = PersistenceContext::get_querier()->insert(PREFIX . "forum_alerts", array('idcat' => $topic_infos['idcat'], 'idtopic' => $alert_post, 'title' => $alert_title, 'contents' => $alert_contents, 'user_id' => AppContext::get_current_user()->get_id(), 'status' => 0, 'idmodo' => 0, 'timestamp' => time()));
     $alert_id = $result->get_last_inserted_id();
     $contribution = new Contribution();
     //The id of the file in the module. It's useful when the module wants to search a contribution (we will need it in the file edition)
     $contribution->set_id_in_module($alert_id);
     //The entitled of the contribution
     $contribution->set_entitled(sprintf($LANG['contribution_alert_moderators_for_topics'], stripslashes($alert_title)));
     //The URL where a validator can treat the contribution (in the file edition panel)
     $contribution->set_fixing_url('/forum/moderation_forum.php?action=alert&id=' . $alert_id);
     //Description
     $contribution->set_description(stripslashes($alert_contents));
     //Who is the contributor?
     $contribution->set_poster_id(AppContext::get_current_user()->get_id());
     //The module
     $contribution->set_module('forum');
     //It's an alert, we will be able to manage other kinds of contributions in the module if we choose to use a type.
     $contribution->set_type('alert');
     //Assignation des autorisations d'écriture / Writing authorization assignation
     $contribution->set_auth(Authorizations::capture_and_shift_bit_auth(ForumService::get_categories_manager()->get_heritated_authorizations($topic_infos['idcat'], Category::MODERATION_AUTHORIZATIONS, Authorizations::AUTH_CHILD_PRIORITY), Category::MODERATION_AUTHORIZATIONS, Contribution::CONTRIBUTION_AUTH_BIT));
     //Sending the contribution to the kernel. It will place it in the contribution panel to be approved
     ContributionService::save_contribution($contribution);
 }
Exemplo n.º 4
0
                $media_contribution->set_status(Event::EVENT_STATUS_PROCESSED);
                ContributionService::save_contribution($media_contribution);
            }
        }
        // Feeds Regeneration
        Feed::clear_cache('media');
        AppContext::get_response()->redirect('media' . url('.php?id=' . $media['idedit']));
    } elseif (!$media['idedit'] && (($auth_write = MediaAuthorizationsService::check_authorizations($media['idcat'])->write()) || MediaAuthorizationsService::check_authorizations($media['idcat'])->contribution())) {
        $result = PersistenceContext::get_querier()->insert(PREFIX . "media", array('idcat' => $media['idcat'], 'iduser' => AppContext::get_current_user()->get_id(), 'timestamp' => time(), 'name' => $media['name'], 'contents' => FormatingHelper::strparse($media['contents']), 'url' => $media['url'], 'mime_type' => $media['mime_type'], 'infos' => MediaAuthorizationsService::check_authorizations($media['idcat'])->write() ? MEDIA_STATUS_APROBED : 0, 'width' => $media['width'], 'height' => $media['height']));
        $new_id_media = $result->get_last_inserted_id();
        // Feeds Regeneration
        Feed::clear_cache('media');
        if (!$auth_write) {
            $media_contribution = new Contribution();
            $media_contribution->set_id_in_module($new_id_media);
            $media_contribution->set_description(stripslashes($media['counterpart']));
            $media_contribution->set_entitled($media['name']);
            $media_contribution->set_fixing_url('/media/media_action.php?edit=' . $new_id_media);
            $media_contribution->set_poster_id(AppContext::get_current_user()->get_id());
            $media_contribution->set_module('media');
            $media_contribution->set_auth(Authorizations::capture_and_shift_bit_auth(MediaService::get_categories_manager()->get_heritated_authorizations($media['idcat'], Category::MODERATION_AUTHORIZATIONS, Authorizations::AUTH_CHILD_PRIORITY), Category::MODERATION_AUTHORIZATIONS, Contribution::CONTRIBUTION_AUTH_BIT));
            ContributionService::save_contribution($media_contribution);
            DispatchManager::redirect(new UserContributionSuccessController());
        } else {
            AppContext::get_response()->redirect('media' . url('.php?id=' . $new_id_media));
        }
    } else {
        $error_controller = PHPBoostErrors::user_not_authorized();
        DispatchManager::redirect($error_controller);
    }
} else {
Exemplo n.º 5
0
 function Alert_topic($alert_post, $alert_title, $alert_contents)
 {
     global $Sql, $User, $CAT_FORUM, $LANG;
     $topic_infos = $Sql->query_array(PREFIX . "forum_topics", "idcat", "title", "WHERE id = '" . $alert_post . "'", __LINE__, __FILE__);
     $Sql->query_inject("INSERT INTO " . PREFIX . "forum_alerts (idcat, idtopic, title, contents, user_id, status, idmodo, timestamp) VALUES ('" . $topic_infos['idcat'] . "', '" . $alert_post . "', '" . $alert_title . "', '" . $alert_contents . "', '" . $User->get_attribute('user_id') . "', 0, 0, '" . time() . "')", __LINE__, __FILE__);
     $alert_id = $Sql->insert_id("SELECT MAX(id) FROM " . PREFIX . "forum_alerts");
     import('events/contribution');
     import('events/contribution_service');
     $contribution = new Contribution();
     $contribution->set_id_in_module($alert_id);
     $contribution->set_entitled(sprintf($LANG['contribution_alert_moderators_for_topics'], stripslashes($alert_title)));
     $contribution->set_fixing_url('/forum/moderation_forum.php?action=alert&id=' . $alert_id);
     $contribution->set_description(stripslashes($alert_contents));
     $contribution->set_poster_id($User->get_attribute('user_id'));
     $contribution->set_module('forum');
     $contribution->set_type('alert');
     $contribution->set_auth(Authorizations::capture_and_shift_bit_auth($CAT_FORUM[$topic_infos['idcat']]['auth'], EDIT_CAT_FORUM, CONTRIBUTION_AUTH_BIT));
     ContributionService::save_contribution($contribution);
 }
Exemplo n.º 6
0
         case 1:
             list($start_timestamp, $end_timestamp) = array(0, 0);
             break;
         default:
             list($visible, $start_timestamp, $end_timestamp) = array(0, 0, 0);
     }
     import('util/url');
     $file_relative_url = new Url($file_url);
     $Sql->query_inject("INSERT INTO " . PREFIX . "download (title, idcat, url, size, count, force_download, contents, short_contents, image, timestamp, release_timestamp, start, end, visible, approved, users_note) " . "VALUES ('" . $file_title . "', '" . $file_cat_id . "', '" . $file_relative_url->relative() . "', '" . $file_size . "', '" . $file_hits . "', '" . ($file_download_method == 'force_download' ? DOWNLOAD_FORCE_DL : DOWNLOAD_REDIRECT) . "', '" . strparse($file_contents) . "', '" . strparse($file_short_contents) . "', '" . $file_image . "', '" . $file_creation_date->get_timestamp() . "', '" . ($ignore_release_date ? 0 : $file_release_date->get_timestamp()) . "', '" . $start_timestamp . "', '" . $end_timestamp . "', '" . $visible . "', '" . (int) $auth_write . "', '')", __LINE__, __FILE__);
     $new_id_file = $Sql->insert_id("SELECT MAX(id) FROM " . PREFIX . "download");
     if (!$auth_write) {
         import('events/contribution');
         import('events/contribution_service');
         $download_contribution = new Contribution();
         $download_contribution->set_id_in_module($new_id_file);
         $download_contribution->set_description(stripslashes($contribution_counterpart));
         $download_contribution->set_entitled(sprintf($DOWNLOAD_LANG['contribution_entitled'], $file_title));
         $download_contribution->set_fixing_url('/download/management.php?edit=' . $new_id_file);
         $download_contribution->set_poster_id($User->get_attribute('user_id'));
         $download_contribution->set_module('download');
         $download_contribution->set_auth(Authorizations::capture_and_shift_bit_auth(Authorizations::merge_auth($CONFIG_DOWNLOAD['global_auth'], $download_categories->compute_heritated_auth($file_cat_id, DOWNLOAD_WRITE_CAT_AUTH_BIT, AUTH_CHILD_PRIORITY), DOWNLOAD_WRITE_CAT_AUTH_BIT, AUTH_CHILD_PRIORITY), DOWNLOAD_WRITE_CAT_AUTH_BIT, CONTRIBUTION_AUTH_BIT));
         ContributionService::save_contribution($download_contribution);
         redirect(HOST . DIR . '/download/contribution.php');
     }
     $download_categories->Recount_sub_files();
     import('content/syndication/feed');
     Feed::clear_cache('download');
     redirect(HOST . DIR . '/download/' . url('download.php?id=' . $new_id_file, 'download-' . $new_id_file . '+' . url_encode_rewrite($file_title) . '.php'));
 } else {
     redirect(HOST . DIR . '/download/' . url('download.php'));
 }