Plugin() ; $this->_addHook('scm_plugin'); $this->_addHook('scm_page'); $this->_addHook('scm_admin_page'); $this->_addHook('scm_admin_update'); $this->_addHook('scm_stats'); $this->_addHook('scm_create_repo'); # Other common hooks that can be enabled per plugin: # scm_generate_snapshots # scm_gather_stats # scm_browser_page # scm_update_repolist } function CallHook($hookname, &$params) { global $HTML; switch ($hookname) { case 'scm_plugin': { $scm_plugins=& $params['scm_plugins']; $scm_plugins[]=$this->name; break; } case 'scm_page': { $this->printPage($params); break ; } case 'scm_browser_page': { $this->printBrowserPage($params); break ; } case 'scm_admin_page': { $this->printAdminPage($params); break ; } case 'scm_admin_update': { $this->adminUpdate($params); break ; } case 'scm_stats': { $this->printShortStats($params); break; } case 'scm_create_repo': { session_set_admin(); $this->createOrUpdateRepo($params); break; } case 'scm_update_repolist': { session_set_admin(); $this->updateRepositoryList($params); break; } case 'scm_generate_snapshots': { // Optional session_set_admin(); $this->generateSnapshots($params); break; } case 'scm_gather_stats': { // Optional session_set_admin(); $this->gatherStats($params); break; } case "widgets": { // Optional $this->widgets($params); break; } case "widget_instance": { // Optional $this->myPageBox($params); break; } case "activity": { //Optional $this->activity($params); break; } default: { // Forgot something } } } final function register() { global $scm_list; $scm_list[] = $this->name; } function browserDisplayable($project) { if ($project->usesSCM() && $project->usesPlugin($this->name)) { if ($project->enableAnonSCM() || forge_check_perm('scm', $project->getID(), 'read')) { return true; } } return false; } abstract function createOrUpdateRepo($params); function printShortStats($params) { $project = $this->checkParams($params); if (!$project) { return false ; } if ($project->usesPlugin($this->name)) { echo ' ('.$this->text.')' ; } } function getBlurb () { return '
' . _('Unimplemented SCM plugin.') . '
'; } function getInstructionsForAnon ($project) { return '' . _('Instructions for anonymous access for unimplemented SCM plugin.') . '
'; } function getInstructionsForRW ($project) { return '' . _('Instructions for read-write access for unimplemented SCM plugin.') . '
'; } function getSnapshotPara ($project) { return '' . _('Instructions for snapshot access for unimplemented SCM plugin.') . '
'; } function getBrowserLinkBlock($project) { global $HTML ; $b = $HTML->boxMiddle(_('Repository Browser')); $b .= ''; $b .= _('Browsing the SCM tree is not yet implemented for this SCM plugin.'); $b .= '
'; $b .= '[' ; $b .= util_make_link ("/scm/?group_id=".$project->getID(), _('Not implemented yet') ) ; $b .= ']
' ; return $b ; } function getBrowserBlock($project) { global $HTML ; $b = $HTML->boxMiddle(_('Repository Browser')); $b .= ''; $b .= _('Browsing the SCM tree is not yet implemented for this SCM plugin.'); $b .= '
'; return $b ; } function getStatsBlock($project) { global $HTML ; $b = $HTML->boxMiddle(_('Repository Statistics')); $b .= ''; $b .= _('Not implemented for this SCM plugin yet.') ; $b .= '
'; return $b ; } function printPage($params) { global $HTML; $project = $this->checkParams($params); if (!$project) { return false; } if ($project->usesPlugin($this->name)) { // Table for summary info print ''."\n"; print $this->getBlurb()."\n"; // Instructions for anonymous access if ($project->enableAnonSCM()) { print $this->getInstructionsForAnon($project); } // Instructions for developer access print $this->getInstructionsForRW($project); if ($this->browserDisplayable($project)) { echo $this->getBrowserLinkBlock($project); } // Snapshot if ($this->browserDisplayable($project)) { print $this->getSnapshotPara($project); } print ' | '."\n".''."\n"; // Browsing echo $HTML->boxTop(_('Repository History')); echo _('Data about current and past states of the repository'); if ($this->browserDisplayable($project)) { echo $this->getStatsBlock($project); } echo $HTML->boxBottom(); print ' |
c($group->enableAnonSCM()).' />'._('Enable Anonymous Read Access').'
'; } } function adminUpdate($params) { $project = $this->checkParams($params); if (!$project) { return false; } if ($project->usesPlugin($this->name) ) { if (isset($params['scm_enable_anonymous']) && $params['scm_enable_anonymous']) { $project->SetUsesAnonSCM(true); } else { $project->SetUsesAnonSCM(false); } } } function getBoxForProject($project) { $box = $project->getSCMBox(); if ($box == '') { $box = forge_get_config('default_server', $this->name); } if ($box == '') { $box = forge_get_config('web_host'); } return $box; } function checkParams ($params) { $group_id = $params['group_id'] ; $project = group_get_object($group_id); if (!$project || !is_object($project)) { return false; } elseif ($project->isError()) { return false; } return $project ; } function c($v) { if ($v) { return 'checked="checked"'; } else { return ''; } } } // Local Variables: // mode: php // c-file-style: "bsd" // End: ?>