public function updateMirroring(Project $project, array $repositories, $selected_mirror_ids) { $current_mirror_ids_per_repository = $this->mirror_data_mapper->getListOfMirrorIdsPerRepositoryForProject($project); foreach ($repositories as $repository) { if (!isset($selected_mirror_ids[$repository->getId()]) || !is_array($selected_mirror_ids[$repository->getId()])) { continue; } $mirror_ids = array(); foreach ($selected_mirror_ids[$repository->getId()] as $mirror_id => $should_be_mirrored) { if ($should_be_mirrored) { $mirror_ids[] = $mirror_id; } } if (!$this->areThereAnyChanges($repository, $mirror_ids, $current_mirror_ids_per_repository)) { continue; } if (!$this->updateRepositoryMirrors($repository, $mirror_ids)) { $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('plugin_git', 'mirroring_mirroring_error')); return; } } $more_than_one_repository = count($repositories) > 1; if ($more_than_one_repository && !$selected_mirror_ids) { $GLOBALS['Response']->addFeedback('warning', $GLOBALS['Language']->getText('plugin_git', 'mirroring_unmirroring_successful_plural')); } elseif ($more_than_one_repository && $selected_mirror_ids) { $GLOBALS['Response']->addFeedback('warning', $GLOBALS['Language']->getText('plugin_git', 'mirroring_mirroring_successful_plural')); } elseif (!$more_than_one_repository && !$selected_mirror_ids) { $GLOBALS['Response']->addFeedback('warning', $GLOBALS['Language']->getText('plugin_git', 'mirroring_unmirroring_successful')); } else { $GLOBALS['Response']->addFeedback('warning', $GLOBALS['Language']->getText('plugin_git', 'mirroring_mirroring_successful')); } }
protected function adminMassUpdateView() { $params = $this->getData(); $repositories = $params['repositories']; $mirrors = $this->getAdminMassUpdateMirrorPresenters(); $presenter = new GitPresenters_AdminMassUpdatePresenter($this->generateMassUpdateCSRF(), $this->groupId, $this->buildListOfMirroredRepositoriesPresenters($repositories, $mirrors, $this->mirror_data_mapper->getListOfMirrorIdsPerRepositoryForProject($this->project)), new GitPresenters_AdminMassUdpdateMirroringPresenter($mirrors)); $renderer = TemplateRendererFactory::build()->getRenderer(dirname(GIT_BASE_DIR) . '/templates'); echo $renderer->renderToString('admin', $presenter); }