Ejemplo n.º 1
0
 public function updateSiteAccess($old_value)
 {
     if ($old_value == ForgeAccess::ANONYMOUS) {
         $this->dao->updateAllAnonymousToRegistered();
     }
     if ($old_value == ForgeAccess::RESTRICTED) {
         $this->dao->updateAllAuthenticatedToRegistered();
     }
 }
Ejemplo n.º 2
0
 /**
  * @return bool
  */
 public function isCompatibilityViewEnabled(Project $project)
 {
     $plugin_has_view_enabled = (bool) forge_get_config('enable_compatibility_view', 'mediawiki');
     $result = $this->dao->getCompatibilityViewUsage($project->getID());
     if (!$result) {
         return false;
     }
     return $plugin_has_view_enabled && (bool) $result['enable_compatibility_view'];
 }
 /**
  * This method will add missing permissions for a user
  *
  */
 private function addGroupsAccordingToMapping(MediawikiGroups $mediawiki_groups, PFUser $user, Group $project)
 {
     $mediawiki_groups->add('*');
     if ($user->isAnonymous()) {
         return;
     }
     if ($this->doesUserHaveSpecialAdminPermissions($user)) {
         $dar = $this->dao->getAllMediawikiGroups($project);
     } else {
         $dar = $this->dao->getMediawikiGroupsMappedForUGroups($user, $project);
     }
     foreach ($dar as $row) {
         $mediawiki_groups->add($row['real_name']);
     }
 }
Ejemplo n.º 4
0
 public function plugin_statistics_service_usage($params)
 {
     require_once 'MediawikiDao.class.php';
     $dao = new MediawikiDao();
     $project_manager = ProjectManager::instance();
     $start_date = $params['start_date'];
     $end_date = $params['end_date'];
     $number_of_page = array();
     $number_of_page_between_two_dates = array();
     $number_of_page_since_a_date = array();
     foreach ($project_manager->getProjectsByStatus(Project::STATUS_ACTIVE) as $project) {
         if ($project->usesService('plugin_mediawiki')) {
             $number_of_page[] = $dao->getMediawikiPagesNumberOfAProject($project);
             $number_of_page_between_two_dates[] = $dao->getModifiedMediawikiPagesNumberOfAProjectBetweenStartDateAndEndDate($project, $start_date, $end_date);
             $number_of_page_since_a_date[] = $dao->getCreatedPagesNumberSinceStartDate($project, $start_date);
         }
     }
     $params['csv_exporter']->buildDatas($number_of_page, "Mediawiki Pages");
     $params['csv_exporter']->buildDatas($number_of_page_between_two_dates, "Modified Mediawiki pages");
     $params['csv_exporter']->buildDatas($number_of_page_since_a_date, "Number of created Mediawiki pages since start date");
 }
Ejemplo n.º 5
0
 require_once "{$IP}/includes/Defines.php";
 require_once "{$IP}/includes/DefaultSettings.php";
 if ($wgCommandLineMode) {
     if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
         die("This script must be run from the command line\n");
     }
 }
 $wgSitename = $group->getPublicName() . " Wiki";
 $wgScriptPath = "/plugins/mediawiki/wiki/{$fusionforgeproject}";
 $wgEmergencyContact = forge_get_config('admin_email');
 $wgPasswordSender = forge_get_config('admin_email');
 $wgDBtype = "forge";
 $wgDBserver = forge_get_config('database_host');
 if (forge_get_config('mw_dbtype', 'mediawiki') == 'mysql') {
     // At the time writing schema in mysql is synonym for database
     $dao = new MediawikiDao();
     $wgDBname = $dao->getMediawikiDatabaseName($group, false);
     if (!$wgDBname) {
         exit_error(sprintf(_('Mediawiki for project %s cannot be found, please contact your system admininistrators.'), $fusionforgeproject . ':' . $project_dir));
     }
     $wgDBprefix = 'mw';
 } else {
     $wgDBname = forge_get_config('database_name');
 }
 $wgDBuser = forge_get_config('database_user');
 $wgDBpassword = forge_get_config('database_password');
 $wgDBadminuser = forge_get_config('database_user');
 $wgDBadminpassword = forge_get_config('database_password');
 $wgDBport = forge_get_config('database_port');
 $wgDBmwschema = str_replace('-', '_', "plugin_mediawiki_{$fusionforgeproject}");
 $wgDBts2schema = str_replace('-', '_', "plugin_mediawiki_{$fusionforgeproject}");
Ejemplo n.º 6
0
 public function saveOptions(Project $project, array $options)
 {
     $project_id = $project->getID();
     $enable_compatibility_view = (bool) isset($options['enable_compatibility_view']) ? $options['enable_compatibility_view'] : 0;
     return $this->dao->updateAdminOptions($project_id, $enable_compatibility_view);
 }
Ejemplo n.º 7
0
 if (!$res) {
     $err = "Error: Mediawiki Database Creation Failed: " . db_error();
     cron_debug($err);
     cron_entry(23, $err);
     db_rollback();
     exit;
 }
 $res = db_query_params("CREATE TEXT SEARCH CONFIGURATION {$schema}.default ( COPY = pg_catalog.english )", array());
 if (!$res) {
     $err = "Error: DB Query Failed: " . db_error();
     cron_debug($err);
     cron_entry(23, $err);
     db_rollback();
     exit;
 }
 $dao = new MediawikiDao();
 $update = $dao->addDatabase($schema, $this->project_id);
 if (!$update) {
     $err = 'Error: Mediawiki Database list update failed: (' . $schema . ':' . $this->project_id . ')' . mysql_error();
     cron_debug($err);
     cron_entry(23, $err);
     db_rollback();
     exit;
 }
 if (!db_commit()) {
     $err = "Error: DB Commit Failed: " . db_error();
     cron_debug($err);
     cron_entry(23, $err);
     exit;
 }
 cron_debug("  Creating project dir {$project_dir}.");
Ejemplo n.º 8
0
 private function mediawikiTests(Project $project)
 {
     $mediawiki_dao = new MediawikiDao();
     $mediawikilanguage_dao = new MediawikiLanguageDao();
     $res = $mediawiki_dao->getMediawikiPagesNumberOfAProject($project);
     $this->assertEqual(3, $res['result']);
     $res = $mediawikilanguage_dao->getUsedLanguageForProject($project->getGroupId());
     $this->assertEqual('fr_FR', $res['language']);
 }