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);
 }
    $template->put_all(array('C_EDIT_CONTRIBUTION' => true, 'EDITOR' => $editor->display(), 'ENTITLED' => $contribution->get_entitled(), 'DESCRIPTION' => FormatingHelper::unparse($contribution->get_description()), 'CONTRIBUTION_ID' => $contribution->get_id(), 'EVENT_STATUS_UNREAD_SELECTED' => $contribution->get_status() == Event::EVENT_STATUS_UNREAD ? ' selected="selected"' : '', 'EVENT_STATUS_BEING_PROCESSED_SELECTED' => $contribution->get_status() == Event::EVENT_STATUS_BEING_PROCESSED ? ' selected="selected"' : '', 'EVENT_STATUS_PROCESSED_SELECTED' => $contribution->get_status() == Event::EVENT_STATUS_PROCESSED ? ' selected="selected"' : '', 'L_CONTRIBUTION_STATUS_UNREAD' => $LANG['contribution_status_unread'], 'L_CONTRIBUTION_STATUS_BEING_PROCESSED' => $LANG['contribution_status_being_processed'], 'L_CONTRIBUTION_STATUS_PROCESSED' => $LANG['contribution_status_processed'], 'L_CONTRIBUTION' => $LANG['contribution'], 'L_DESCRIPTION' => $LANG['contribution_description'], 'L_STATUS' => $LANG['contribution_status'], 'L_ENTITLED' => $LANG['contribution_entitled'], 'L_SUBMIT' => $LANG['submit'], 'L_PREVIEW' => $LANG['preview'], 'L_RESET' => $LANG['reset']));
} else {
    $template->put_all(array('C_CONTRIBUTION_LIST' => true));
    //Nombre de contributions
    $num_contributions = 1;
    define('CONTRIBUTIONS_PER_PAGE', 20);
    $page = AppContext::get_request()->get_getint('p', 1);
    //Gestion des critères de tri
    $criteria = retrieve(GET, 'criteria', 'current_status');
    $order = retrieve(GET, 'order', 'asc');
    if (!in_array($criteria, array('entitled', 'module', 'status', 'creation_date', 'fixing_date', 'poster_id', 'fixer_id'))) {
        $criteria = 'current_status';
    }
    $order = $order == 'desc' ? 'desc' : 'asc';
    //On liste les contributions
    foreach (ContributionService::get_all_contributions($criteria, $order) as $this_contribution) {
        //Obligé de faire une variable temp à cause de php4.
        $creation_date = $this_contribution->get_creation_date();
        $fixing_date = $this_contribution->get_fixing_date();
        //Affichage des contributions du membre
        if (AppContext::get_current_user()->check_auth($this_contribution->get_auth(), Contribution::CONTRIBUTION_AUTH_BIT) || AppContext::get_current_user()->get_id() == $this_contribution->get_poster_id()) {
            //On affiche seulement si on est dans le bon cadre d'affichage
            if ($num_contributions > CONTRIBUTIONS_PER_PAGE * ($page - 1) && $num_contributions <= CONTRIBUTIONS_PER_PAGE * $page) {
                $poster_group_color = User::get_group_color($this_contribution->get_poster_groups(), $this_contribution->get_poster_level());
                $fixer_group_color = User::get_group_color($this_contribution->get_fixer_groups(), $this_contribution->get_fixer_level());
                $template->assign_block_vars('contributions', array('C_POSTER_GROUP_COLOR' => !empty($poster_group_color), 'C_FIXER_GROUP_COLOR' => !empty($fixer_group_color), 'ENTITLED' => $this_contribution->get_entitled(), 'MODULE' => $this_contribution->get_module_name(), 'STATUS' => $this_contribution->get_status_name(), 'CREATION_DATE' => $creation_date->format(Date::FORMAT_DAY_MONTH_YEAR), 'FIXING_DATE' => $fixing_date->format(Date::FORMAT_DAY_MONTH_YEAR), 'POSTER' => $this_contribution->get_poster_login(), 'POSTER_LEVEL_CLASS' => UserService::get_level_class($this_contribution->get_poster_level()), 'POSTER_GROUP_COLOR' => $poster_group_color, 'FIXER' => $this_contribution->get_fixer_login(), 'FIXER_LEVEL_CLASS' => UserService::get_level_class($this_contribution->get_fixer_level()), 'FIXER_GROUP_COLOR' => $fixer_group_color, 'ACTIONS' => '', 'U_FIXER_PROFILE' => UserUrlBuilder::profile($this_contribution->get_fixer_id())->rel(), 'U_POSTER_PROFILE' => UserUrlBuilder::profile($this_contribution->get_poster_id())->rel(), 'U_CONSULT' => PATH_TO_ROOT . '/user/' . url('contribution_panel.php?id=' . $this_contribution->get_id()), 'C_FIXED' => $this_contribution->get_status() == Event::EVENT_STATUS_PROCESSED, 'C_PROCESSING' => $this_contribution->get_status() == Event::EVENT_STATUS_BEING_PROCESSED));
            }
            $num_contributions++;
        }
    }
    $pagination = new ModulePagination($page, $num_contributions, CONTRIBUTIONS_PER_PAGE);
Exemple #4
0
 function Del_alert_topic($id_alert)
 {
     PersistenceContext::get_querier()->delete(PREFIX . 'forum_alerts', 'WHERE id=:id', array('id' => $id_alert));
     //Si la contribution associée n'est pas réglée, on la règle
     $corresponding_contributions = ContributionService::find_by_criteria('forum', $id_alert, 'alert');
     if (count($corresponding_contributions) > 0) {
         $file_contribution = $corresponding_contributions[0];
         //We delete the contribution
         ContributionService::delete_contribution($file_contribution);
     }
     //Insertion de l'action dans l'historique.
     forum_history_collector(H_DEL_ALERT);
 }
 /**
  * {@inheritdoc}
  */
 public function synchronize()
 {
     $result = ContributionService::compute_number_contrib_for_each_profile();
     $this->set_values($result);
 }
 /**
  * @static
  * @desc Uninstalls a module.
  * @param int $module_id Module id (in the DB_TABLE_MODULES table)
  * @param bool $drop_files true if you want the module files to be dropped, otherwise false.
  * @return int One of the following error codes:
  * <ul>
  * 	<li>MODULE_FILES_COULD_NOT_BE_DROPPED: the module files couldn't be deleted (probably due to an authorization issue) but it has been uninstalled .</li>
  * 	<li>MODULE_UNINSTALLED: the module was successfully uninstalled.</li>
  * 	<li>NOT_INSTALLED_MODULE: the module to uninstall doesn't exist!</li>
  * </ul>
  */
 public static function uninstall_module($module_id, $drop_files = false)
 {
     if (!empty($module_id) && self::is_module_installed($module_id)) {
         $error = self::execute_module_uninstallation($module_id);
         if ($error === null) {
             ContributionService::delete_contribution_module($module_id);
             NotationService::delete_notes_module($module_id);
             CommentsService::delete_comments_module($module_id);
             PersistenceContext::get_querier()->delete(DB_TABLE_CONFIGS, "WHERE name = :name", array('name' => $module_id));
             //Régénération des feeds.
             Feed::clear_cache($module_id);
             try {
                 if (ServerEnvironmentConfig::load()->is_url_rewriting_enabled()) {
                     HtaccessFileCache::regenerate();
                 }
             } catch (IOException $ex) {
             }
             MenuService::delete_mini_module($module_id);
             MenuService::delete_module_feeds_menus($module_id);
             ModulesConfig::load()->remove_module_by_id($module_id);
             ModulesConfig::save();
             //Module home page ?
             $general_config = GeneralConfig::load();
             $module_home_page_selected = $general_config->get_module_home_page();
             if ($module_home_page_selected == $module_id) {
                 $general_config->set_module_home_page('');
                 $general_config->set_other_home_page('index.php');
             }
             //Suppression des fichiers du module
             if ($drop_files) {
                 $folder = new Folder(PATH_TO_ROOT . '/' . $module_id);
                 try {
                     $folder->delete();
                     self::update_class_list();
                     AppContext::init_extension_provider_service();
                 } catch (IOException $ex) {
                     return self::MODULE_FILES_COULD_NOT_BE_DROPPED;
                 }
             }
             AppContext::get_cache_service()->clear_cache();
             return self::MODULE_UNINSTALLED;
         }
         return $error;
     } else {
         return self::NOT_INSTALLED_MODULE;
     }
 }
Exemple #7
0
        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 {
    $error_controller = PHPBoostErrors::unexisting_page();
    DispatchManager::redirect($error_controller);
}
$tpl->display();
require_once '../kernel/footer.php';
 public static function __static()
 {
     self::$db_querier = PersistenceContext::get_querier();
 }
Exemple #9
0
 function Del_alert_topic($id_alert)
 {
     global $Sql;
     $Sql->query_inject("DELETE FROM " . PREFIX . "forum_alerts WHERE id = '" . $id_alert . "'", __LINE__, __FILE__);
     import('events/contribution');
     import('events/contribution_service');
     $corresponding_contributions = ContributionService::find_by_criteria('forum', $id_alert, 'alert');
     if (count($corresponding_contributions) > 0) {
         $file_contribution = $corresponding_contributions[0];
         ContributionService::delete_contribution($file_contribution);
     }
     forum_history_collector(H_DEL_ALERT);
 }
Exemple #10
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'));
     }
 } elseif ($preview) {
     $contribution_counterpart_source = strprotect(retrieve(POST, 'counterpart', '', TSTRING_AS_RECEIVED), HTML_PROTECT, ADDSLASHES_NONE);
     $begining_calendar = new MiniCalendar('begining_date');
     $begining_calendar->set_date($begining_date);
     $end_calendar = new MiniCalendar('end_date');
     $end_calendar->set_date($end_date);
Exemple #11
0
 function _get_member()
 {
     global $Sql;
     $config_member = 'global $CONFIG_USER, $CONTRIBUTION_PANEL_UNREAD, $ADMINISTRATOR_ALERTS;' . "\n";
     $CONFIG_USER = unserialize((string) $Sql->query("SELECT value FROM " . DB_TABLE_CONFIGS . " WHERE name = 'member'", __LINE__, __FILE__));
     foreach ($CONFIG_USER as $key => $value) {
         $config_member .= '$CONFIG_USER[\'' . $key . '\'] = ' . var_export($value, true) . ';' . "\n";
     }
     import('events/contribution_service');
     $config_member .= '$CONTRIBUTION_PANEL_UNREAD = ' . var_export(ContributionService::compute_number_contrib_for_each_profile(), true) . ';';
     import('events/administrator_alert_service');
     $config_member .= "\n" . '$ADMINISTRATOR_ALERTS = ' . var_export(AdministratorAlertService::compute_number_unread_alerts(), true) . ';';
     return $config_member;
 }