/** * Handle on prepare project overview event * * @param NamedList $tabs * @param User $logged_user * @param Project $project * @return null */ function source_handle_on_project_tabs(&$tabs, &$logged_user, &$project) { if ($logged_user->getProjectPermission('repository', $project) >= PROJECT_PERMISSION_ACCESS) { $tabs->add('source', array('text' => lang('Source'), 'url' => source_module_url($project))); } // if }
/** * Update a repository * * @param null * @return void */ function update() { if (!$this->active_repository->canEdit($this->logged_user)) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if $last_commit = $this->active_repository->getLastCommit(); $revision_to = !instance_of($last_commit, 'Commit') ? 1 : $last_commit->getRevision() + 1; $latest_revision = !instance_of($last_commit, 'Commit') ? 0 : $last_commit->getRevision(); $head_revision = $this->repository_engine->getHeadRevision($this->request->isAsyncCall()); $bulk_update = array_var($_GET, 'bulk') == '1'; $uptodate = intval($head_revision == $latest_revision); // simple mass update if ($this->request->isAsyncCall() == false && $bulk_update) { if (is_null($this->repository_engine->error)) { $logs = $this->repository_engine->getLogs($revision_to); // Loop through array of logs and prepare data for inserting into project_objects table if (is_foreachable($logs['data'])) { $this->active_repository->update($logs['data']); } // if if ($logs['total'] > 0) { $this->active_repository->sendToSubscribers($logs['total'], $this->repository_engine); $this->active_repository->createActivityLog($logs['total']); flash_success(lang('Update successfully performed with :total_commits new history entries added.'), array('total_commits' => $logs['total'])); } else { flash_success(lang('Repository is already up-to-date')); } // if } else { flash_error($this->repository_engine->error); } // if $this->redirectToReferer(source_module_url($this->active_project)); } elseif ($this->request->isAsyncCall()) { if (!is_null($this->repository_engine->error)) { die($this->repository_engine->error); } // if if (array_var($_GET, 'notify')) { $total_commits = $notify_subscribers; $this->active_repository->sendToSubscribers($total_commits, $this->repository_engine); $this->active_repository->createActivityLog($total_commits); die('success'); } // if $difference = $head_revision - $latest_revision; $more_logs = true; if ($difference > SOURCE_MODULE_LOGS_PER_REQUEST) { $revision_from = $revision_to + SOURCE_MODULE_LOGS_PER_REQUEST - 1; } else { $revision_from = $head_revision; $more_logs = false; } // if $log = $this->repository_engine->getLogs($revision_to, $revision_from); if (is_null($this->repository_engine->error)) { $this->active_repository->update($log['data']); die($more_logs || $log['total'] > 0 ? 'success' : 'finished'); } else { die($this->repository_engine->error); } // if } $this->smarty->assign(array('uptodate' => $uptodate, 'head_revision' => $head_revision, 'last_revision' => $latest_revision, 'repository_update_url' => str_replace('/', '\\/', $this->active_repository->getUpdateUrl()), 'indicator_ok' => ASSETS_URL . '/images/ok_indicator.gif')); }
/** * Execute SVN command * * @param string $command * @return boolean */ function execute($command) { $this->output = null; $authentication = '--username ' . $this->active_repository->getUsername() . ' --password ' . $this->active_repository->getPassword() . ' --non-interactive'; $executable_path = empty($this->executable_path) ? '' : with_slash($this->executable_path); $escaped = escapeshellcmd($executable_path . "svn " . $authentication . " " . $this->config_dir . " " . $this->trust_server_certificate . " {$command}") . " " . $this->stderr2stdout; //pre_var_dump($escaped); exec($escaped, $this->output); $error = $this->checkResponse($this->output); if (is_error($error)) { if (!$this->triggerred_by_handler) { flash_error($error->getMessage()); redirect_to_referer(source_module_url($this->active_project)); } else { $this->error = $error->getMessage(); } // if } // if return true; }