$addedUgroups[] = $ugroupName;
                 }
             }
             //update group history
             group_add_history('membership_request_updated', implode(',', $oldUgroups) . ' :: ' . implode(',', $newUgroups), $group_id);
             $GLOBALS['Response']->addFeedback('info', $Language->getText('project_admin_index', 'member_request_delegation_ugroups_msg', implode(', ', $addedUgroups)));
         }
     } else {
         $GLOBALS['Response']->addFeedback('error', $Language->getText('project_admin_index', 'member_request_delegation_ugroups_error'));
     }
     break;
 case 'member_req_notif_message':
     $updatedMessage = true;
     // Validate the text
     $vMessage = new Valid_Text('text');
     $vMessage->required();
     $message = trim($request->get('text'));
     $dar = $pm->getMessageToRequesterForAccessProject($group_id);
     if ($dar && !$dar->isError() && $dar->rowCount() == 1) {
         $row = $dar->current();
         if (!strcmp($row['msg_to_requester'], $message)) {
             $updatedMessage = false;
         }
     }
     if ($request->valid($vMessage) & !empty($message) & $updatedMessage) {
         if ($pm->setMessageToRequesterForAccessProject($group_id, $message)) {
             $GLOBALS['Response']->addFeedback('info', $Language->getText('project_admin_index', 'member_request_delegation_msg_info'));
         }
     } else {
         $GLOBALS['Response']->addFeedback('error', $Language->getText('project_admin_index', 'member_request_delegation_msg_error'));
     }
 /**
  * Validate request values
  *
  * @param HTTPRequest $request request containing form values
  *
  * @return Array
  */
 function validateRequest($request)
 {
     $status = true;
     $invalid = array();
     $valid = new Valid_String('request_summary');
     $valid->required();
     $summary = trim($request->get('request_summary'));
     if ($request->valid($valid) && strlen($summary) < self::MAX_SUMMARY_LENGTH && $summary != '') {
         $params['summary'] = $summary;
     } else {
         $status = false;
         $invalid[] = $GLOBALS['Language']->getText('plugin_requesthelp', 'summary');
     }
     $valid = new Valid_Text('request_description');
     $valid->required();
     $description = trim($request->get('request_description'));
     $defaultDescription = $GLOBALS['Language']->getText('plugin_requesthelp', 'requesthelp_default_description');
     if ($request->valid($valid) && strlen($description) < self::MAX_DESCRIPTION_LENGTH && $description != '' && $description != $defaultDescription) {
         $params['description'] = $description;
     } else {
         $status = false;
         $invalid[] = 'Description';
     }
     $valid = new Valid_UInt('type');
     $valid->required();
     if ($request->valid($valid)) {
         $requestType = $request->get('type');
         $params['type'] = $requestType;
         switch ($requestType) {
             case RequestHelp::TYPE_SUPPORT:
                 $params['text_type'] = $this->_getPluginProperty('support_request');
                 break;
             case RequestHelp::TYPE_ENHANCEMENT:
                 $params['text_type'] = $this->_getPluginProperty('enhancement_request');
                 break;
             default:
                 $status = false;
                 $invalid[] = 'Type';
                 break;
         }
     } else {
         $status = false;
         $invalid[] = 'Type';
     }
     $valid = new Valid_UInt('severity');
     $valid->required();
     if ($request->valid($valid)) {
         $severity = $request->get('severity');
         $params['severity'] = $severity;
         switch ($severity) {
             case RequestHelp::SEVERITY_MINOR:
                 $params['text_severity'] = 'Minor';
                 break;
             case RequestHelp::SEVERITY_SERIOUS:
                 $params['text_severity'] = 'Serious';
                 break;
             case RequestHelp::SEVERITY_CRITICAL:
                 $params['text_severity'] = 'Critical';
                 break;
             default:
                 $status = false;
                 $invalid[] = $GLOBALS['Language']->getText('plugin_requesthelp', 'severity');
                 break;
         }
     } else {
         $status = false;
         $invalid[] = $GLOBALS['Language']->getText('plugin_requesthelp', 'severity');
     }
     $cc = array();
     $mails = array_map('trim', preg_split('/[,;]/', $request->get('cc')));
     $rule = new Rule_Email();
     $um = $this->_getUserManager();
     $invalidCc = array();
     foreach ($mails as $mail) {
         if ($rule->isValid($mail)) {
             $cc[] = $mail;
         } else {
             if (trim($mail) != '') {
                 $user = $um->findUser($mail);
                 if ($user) {
                     $mail = $user->getUserName();
                     if ($mail) {
                         $cc[] = $mail;
                     } else {
                         $invalidCc[] = $mail;
                     }
                 } else {
                     $invalidCc[] = $mail;
                 }
             }
         }
     }
     if (!empty($invalidCc)) {
         $c = $this->getController();
         $c->addWarn($GLOBALS['Language']->getText('plugin_requesthelp', 'requesthelp_invalid_cc', implode(", ", $invalidCc)));
     }
     $params['cc'] = implode(";", $cc);
     return array('status' => $status, 'params' => $params, 'invalid' => $invalid);
 }
Example #3
0
 public function _dispatchActionAndView($action, $repoId, $repositoryName, $user)
 {
     $pane = $this->request->get('pane');
     switch ($action) {
         #CREATE REF
         case 'create':
             $this->addView('create');
             break;
             #admin
         #admin
         case 'view':
             $this->addAction('getRepositoryDetails', array($this->groupId, $repoId));
             $this->addView('view');
             break;
             #ADD REF
         #ADD REF
         case 'add':
             $this->addAction('createReference', array($this->groupId, $repositoryName));
             $this->addView('index');
             break;
             #DELETE a repository
         #DELETE a repository
         case 'del':
             $this->addAction('deleteRepository', array($this->groupId, $repoId));
             $this->addView('index');
             break;
             #EDIT
         #EDIT
         case 'edit':
             $repository = $this->factory->getRepositoryById($repoId);
             if (empty($repository)) {
                 $this->addError($this->getText('actions_params_error'));
                 $this->redirect('/plugins/git/?action=index&group_id=' . $this->groupId);
                 return false;
             }
             if ($this->isAPermittedAction('clone') && $this->request->get('clone')) {
                 $valid = new Valid_UInt('parent_id');
                 $valid->required();
                 if ($this->request->valid($valid)) {
                     $parentId = (int) $this->request->get('parent_id');
                 }
                 $this->addAction('cloneRepository', array($this->groupId, $repositoryName, $parentId));
                 $this->addAction('getRepositoryDetails', array($this->groupId, $parentId));
                 $this->addView('view');
             } else {
                 if ($this->isAPermittedAction('save') && $this->request->get('save')) {
                     $repoDesc = null;
                     if ($this->request->exist('repo_desc')) {
                         $repoDesc = GitRepository::DEFAULT_DESCRIPTION;
                         $valid = new Valid_Text('repo_desc');
                         $valid->required();
                         if ($this->request->valid($valid)) {
                             $repoDesc = $this->request->get('repo_desc');
                         }
                     }
                     $repoAccess = null;
                     $valid = new Valid_String('repo_access');
                     $valid->required();
                     if ($this->request->valid($valid) || is_array($this->request->get('repo_access'))) {
                         $repoAccess = $this->request->get('repo_access');
                     }
                     $this->addAction('save', array($this->groupId, $repoId, $repoAccess, $repoDesc, $pane));
                     $this->addView('view');
                 } else {
                     $this->addError($this->getText('controller_access_denied'));
                     $this->redirect('/plugins/git/?group_id=' . $this->groupId);
                 }
             }
             break;
             #repo_management
         #repo_management
         case 'repo_management':
             $repository = $this->factory->getRepositoryById($repoId);
             if (empty($repository)) {
                 $this->addError($this->getText('actions_repo_not_found'));
                 $this->redirect('/plugins/git/?action=index&group_id=' . $this->groupId);
                 return false;
             }
             $this->addAction('repoManagement', array($repository));
             $this->addView('repoManagement');
             break;
         case 'mail':
             $this->processRepoManagementNotifications($pane, $repoId, $repositoryName, $user);
             break;
             #fork
         #fork
         case 'fork':
             $this->addAction('repoManagement', array($this->groupId, $repoId));
             $this->addView('forkRepositories');
             break;
             #confirm_private
         #confirm_private
         case 'confirm_private':
             if ($this->isAPermittedAction('confirm_deletion') && $this->request->get('confirm_deletion')) {
                 $repository = $this->factory->getRepositoryById($repoId);
                 $this->addAction('confirmDeletion', array($this->groupId, $repository));
                 $this->addView('confirm_deletion', array(0 => array('repo_id' => $repoId)));
             } else {
                 if ($this->isAPermittedAction('save') && $this->request->get('save')) {
                     $valid = new Valid_Text('repo_desc');
                     $valid->required();
                     if ($this->request->valid($valid)) {
                         $repoDesc = $this->request->get('repo_desc');
                     }
                     $valid = new Valid_String('repo_access');
                     $valid->required();
                     if ($this->request->valid($valid)) {
                         $repoAccess = $this->request->get('repo_access');
                     }
                     $this->addAction('confirmPrivate', array($this->groupId, $repoId, $repoAccess, $repoDesc));
                     $this->addView('confirmPrivate');
                 }
             }
             break;
             #SET TO PRIVATE
         #SET TO PRIVATE
         case 'set_private':
             $this->addAction('setPrivate', array($this->groupId, $repoId));
             $this->addView('view');
             break;
         case 'fork_repositories':
             $this->addAction('getProjectRepositoryList', array($this->groupId));
             $this->addView('forkRepositories');
             break;
         case 'admin-git-admins':
             if ($this->request->get('submit')) {
                 $valid = new Valid_Numeric(GitPresenters_AdminGitAdminsPresenter::GIT_ADMIN_SELECTBOX_NAME);
                 $project = $this->projectManager->getProject($this->groupId);
                 if ($this->request->validArray($valid)) {
                     $select_project_ids = $this->request->get(GitPresenters_AdminGitAdminsPresenter::GIT_ADMIN_SELECTBOX_NAME);
                     if ($select_project_ids) {
                         $this->addAction('updateGitAdminGroups', array($project, $user, $select_project_ids));
                     } else {
                         $this->addError($this->getText('no_data_retrieved'));
                     }
                 } else {
                     $this->addError($this->getText('not_valid_request'));
                 }
             }
             $this->addView('adminGitAdminsView', array($this->areMirrorsEnabledForProject()));
             break;
         case 'admin':
         case 'admin-gerrit-templates':
             $project = $this->projectManager->getProject($this->groupId);
             if ($this->request->get('save')) {
                 $template_content = $this->request->getValidated('git_admin_config_data', 'text');
                 if ($this->request->getValidated('git_admin_template_id', 'uint')) {
                     $template_id = $this->request->get('git_admin_template_id');
                     $this->addAction('updateTemplate', array($project, $user, $template_content, $template_id));
                 } else {
                     $template_name = $this->request->getValidated('git_admin_file_name', 'string');
                     $this->addAction('createTemplate', array($project, $user, $template_content, $template_name));
                 }
             }
             if ($this->request->get('delete')) {
                 if ($this->request->getValidated('git_admin_template_id', 'uint')) {
                     $template_id = $this->request->get('git_admin_template_id');
                     $this->addAction('deleteGerritTemplate', array($template_id, $project, $user));
                 }
             }
             if ($this->permissions_manager->userIsGitAdmin($user, $project)) {
                 $this->addAction('generateGerritRepositoryAndTemplateList', array($project, $user));
                 $this->addView('adminGerritTemplatesView', array($this->areMirrorsEnabledForProject()));
             } else {
                 $this->addError($this->getText('controller_access_denied'));
                 $this->redirect('/plugins/git/?action=index&group_id=' . $this->groupId);
                 return false;
             }
             break;
         case 'admin-mass-update':
             if ($this->request->get('save-mass-change') || $this->request->get('go-to-mass-change')) {
                 $this->checkSynchronizerToken('/plugins/git/?group_id=' . (int) $this->groupId . '&action=admin-mass-update');
                 $repositories = $this->getRepositoriesFromIds($this->request->get('repository_ids'));
                 if (!$repositories) {
                     $this->addError($this->getText('actions_repo_not_found'));
                     $this->redirect('/plugins/git/?action=index&group_id=' . $this->groupId);
                 }
             }
             if ($this->request->get('go-to-mass-change')) {
                 $this->addAction('setSelectedRepositories', array($repositories));
                 $this->addView('adminMassUpdateView');
                 return;
             }
             if ($this->request->get('save-mass-change')) {
                 $this->addAction('updateMirroring', array($this->request->getProject(), $repositories, $this->request->get('selected_mirror_ids')));
             }
             $this->addView('adminMassUpdateSelectRepositoriesView');
             break;
         case 'admin-default-settings':
             $this->addView('adminDefaultSettings', array($this->areMirrorsEnabledForProject()));
             break;
         case 'fetch_git_config':
             $project = $this->projectManager->getProject($this->groupId);
             $this->setDefaultPageRendering(false);
             $this->addAction('fetchGitConfig', array($repoId, $user, $project));
             break;
         case 'fetch_git_template':
             $project = $this->projectManager->getProject($this->groupId);
             $template_id = $this->request->getValidated('template_id', 'uint');
             $this->setDefaultPageRendering(false);
             $this->addAction('fetchGitTemplate', array($template_id, $user, $project));
             break;
         case 'fork_repositories_permissions':
             $scope = self::SCOPE_PERSONAL;
             $valid = new Valid_UInt('repos');
             $valid->required();
             if ($this->request->validArray($valid)) {
                 $repos = $this->request->get('repos');
             }
             $valid = new Valid_UInt('to_project');
             if ($this->request->valid($valid)) {
                 $toProject = $this->request->get('to_project');
             }
             $valid = new Valid_String('path');
             $valid->required();
             $path = '';
             if ($this->request->valid($valid)) {
                 $path = $this->request->get('path');
             }
             $valid = new Valid_String('choose_destination');
             $valid->required();
             if ($this->request->valid($valid)) {
                 $scope = $this->request->get('choose_destination');
             }
             if (!empty($repos)) {
                 $this->addAction('forkRepositoriesPermissions', array($repos, $toProject, $path, $scope));
                 $this->addView('forkRepositoriesPermissions');
             } else {
                 $this->addError($this->getText('actions_params_error'));
                 $this->addAction('getProjectRepositoryList', array($this->groupId));
                 $this->addView('forkRepositories');
             }
             break;
         case 'do_fork_repositories':
             try {
                 if ($this->request->get('choose_destination') == self::SCOPE_PERSONAL) {
                     if ($this->user->isMember($this->groupId)) {
                         $this->_doDispatchForkRepositories($this->request, $user);
                     } else {
                         $this->addError($this->getText('controller_access_denied'));
                     }
                 } else {
                     $this->_doDispatchForkCrossProject($this->request, $user);
                 }
             } catch (MalformedPathException $e) {
                 $this->addError($this->getText('fork_malformed_path'));
             }
             $this->addAction('getProjectRepositoryList', array($this->groupId));
             $this->addView('forkRepositories');
             break;
         case "view_last_git_pushes":
             $vGroupId = new Valid_GroupId();
             $vGroupId->required();
             if ($this->request->valid($vGroupId)) {
                 $groupId = $this->request->get('group_id');
             }
             $vWeeksNumber = new Valid_UInt('weeks_number');
             if ($this->request->valid($vWeeksNumber)) {
                 $weeksNumber = $this->request->get('weeks_number');
             }
             if (empty($weeksNumber) || $weeksNumber > Git_LastPushesGraph::MAX_WEEKSNUMBER) {
                 $weeksNumber = 12;
             }
             $imageRenderer = new Git_LastPushesGraph($groupId, $weeksNumber);
             $imageRenderer->display();
             break;
         case 'migrate_to_gerrit':
             if (ForgeConfig::get('sys_auth_type') !== ForgeConfig::AUTH_TYPE_LDAP) {
                 $this->redirect('/plugins/git/?group_id=' . $this->groupId);
                 break;
             }
             $repo = $this->factory->getRepositoryById($repoId);
             $remote_server_id = $this->request->getValidated('remote_server_id', 'uint');
             $gerrit_template_id = $this->getValidatedGerritTemplateId($repo);
             if (empty($repo) || empty($remote_server_id) || empty($gerrit_template_id)) {
                 $this->addError($this->getText('actions_params_error'));
                 $this->redirect('/plugins/git/?group_id=' . $this->groupId);
             } else {
                 try {
                     $project_exists = $this->gerritProjectAlreadyExists($remote_server_id, $repo);
                     if ($project_exists) {
                         $this->addError($this->getText('gerrit_project_exists'));
                     } else {
                         $this->addAction('migrateToGerrit', array($repo, $remote_server_id, $gerrit_template_id));
                     }
                 } catch (Git_Driver_Gerrit_Exception $e) {
                     $this->addError($this->getText('gerrit_server_down'));
                 }
                 $this->addAction('redirectToRepoManagementWithMigrationAccessRightInformation', array($this->groupId, $repoId, $pane));
             }
             break;
         case 'disconnect_gerrit':
             $repo = $this->factory->getRepositoryById($repoId);
             if (empty($repo)) {
                 $this->addError($this->getText('actions_params_error'));
                 $this->redirect('/plugins/git/?group_id=' . $this->groupId);
             } else {
                 $this->addAction('disconnectFromGerrit', array($repo));
                 $this->addAction('redirectToRepoManagement', array($this->groupId, $repoId, $pane));
             }
             break;
         case 'delete_gerrit_project':
             $repo = $this->factory->getRepositoryById($repoId);
             $server = $this->gerrit_server_factory->getServerById($repo->getRemoteServerId());
             $project_gerrit_name = $this->driver_factory->getDriver($server)->getGerritProjectName($repo);
             try {
                 $this->driver_factory->getDriver($server)->deleteProject($server, $project_gerrit_name);
             } catch (ProjectDeletionException $exception) {
                 $this->addError($this->getText('project_deletion_not_possible', array($project_gerrit_name, $exception->getMessage())));
             } catch (Git_Driver_Gerrit_Exception $e) {
                 $this->addError($this->getText('gerrit_server_down'));
             }
             $migrate_access_right = $this->request->existAndNonEmpty('migrate_access_right');
             $this->addAction('redirectToRepoManagementWithMigrationAccessRightInformation', array($this->groupId, $repoId, $pane));
             break;
         case 'update_mirroring':
             $repository = $this->factory->getRepositoryById($repoId);
             if (!$repository) {
                 $this->addError($this->getText('actions_repo_not_found'));
             }
             $selected_mirror_ids = $this->request->get('selected_mirror_ids');
             if (is_array($selected_mirror_ids)) {
                 $this->addAction('updateMirroring', array($this->request->getProject(), array($repository), $selected_mirror_ids));
             } else {
                 $this->addError($this->getText('actions_mirror_ids_not_valid'));
             }
             $this->addAction('redirectToRepoManagement', array($this->groupId, $repository->getId(), $pane));
             break;
         case 'update_default_mirroring':
             $project = $this->request->getProject();
             $selected_mirror_ids = $this->request->get('selected_mirror_ids');
             if (is_array($selected_mirror_ids)) {
                 $this->addAction('updateDefaultMirroring', array($project, $selected_mirror_ids));
             } else {
                 $this->addError($this->getText('actions_mirror_ids_not_valid'));
             }
             $this->addView('adminDefaultSettings', array($this->areMirrorsEnabledForProject()));
             break;
         case 'restore':
             $this->addAction('restoreRepository', array($repoId, $this->groupId));
             break;
             #LIST
         #LIST
         default:
             $user_id = null;
             $valid = new Valid_UInt('user');
             $valid->required();
             if ($this->request->valid($valid)) {
                 $user_id = $this->request->get('user');
                 $this->addData(array('user' => $user_id));
             }
             $this->addAction('getProjectRepositoryList', array($this->groupId, $user_id));
             $this->addView('index');
             break;
     }
 }
Example #4
0
$valid->required();
if ($request->valid($valid)) {
    $body = $request->get('body');
}
$csrf_token = new CSRFSynchronizerToken('sendmessage.php');
$purifier = Codendi_HTMLPurifier::instance();
if (isset($send_mail)) {
    if (!$subject || !$body || !$email) {
        /*
        force them to enter all vars
        */
        exit_missing_param();
    }
    $csrf_token->check();
    $valid = new Valid_Text('cc');
    $valid->required();
    if ($request->valid($valid)) {
        $cc = $request->get('cc');
    }
    $mailMgr = new MailManager();
    $mail = $mailMgr->getMailByType();
    if (isset($touser)) {
        //Return the user given its user_id
        $to = $um->getUserById($touser);
        if (!$to) {
            exit_error($Language->getText('include_exit', 'error'), $Language->getText('sendmessage', 'err_nouser'));
        }
        $mail->setToUser(array($to));
        $dest = $to->getRealName();
    } else {
        if (isset($toaddress)) {
Example #5
0
 public function _dispatchActionAndView($action, $repoId, $repositoryName, $user)
 {
     switch ($action) {
         #CREATE REF
         case 'create':
             $this->addView('create');
             break;
             #admin
         #admin
         case 'view':
             $this->addAction('getRepositoryDetails', array($this->groupId, $repoId));
             $this->addView('view');
             break;
             #ADD REF
         #ADD REF
         case 'add':
             $this->addAction('createReference', array($this->groupId, $repositoryName));
             $this->addView('index');
             break;
             #DELETE a repository
         #DELETE a repository
         case 'del':
             $this->addAction('deleteRepository', array($this->groupId, $repoId));
             $this->addView('index');
             break;
             #EDIT
         #EDIT
         case 'edit':
             if ($this->isAPermittedAction('clone') && $this->request->get('clone')) {
                 $valid = new Valid_UInt('parent_id');
                 $valid->required();
                 if ($this->request->valid($valid)) {
                     $parentId = (int) $this->request->get('parent_id');
                 }
                 $this->addAction('cloneRepository', array($this->groupId, $repositoryName, $parentId));
                 $this->addAction('getRepositoryDetails', array($this->groupId, $parentId));
                 $this->addView('view');
             } else {
                 if ($this->isAPermittedAction('confirm_deletion') && $this->request->get('confirm_deletion')) {
                     $this->addAction('confirmDeletion', array($this->groupId, $repoId));
                     $this->addView('confirm_deletion', array(0 => array('repo_id' => $repoId)));
                 } else {
                     if ($this->isAPermittedAction('save') && $this->request->get('save')) {
                         $valid = new Valid_Text('repo_desc');
                         $valid->required();
                         if ($this->request->valid($valid)) {
                             $repoDesc = $this->request->get('repo_desc');
                         }
                         $valid = new Valid_String('repo_access');
                         $valid->required();
                         if ($this->request->valid($valid) || is_array($this->request->get('repo_access'))) {
                             $repoAccess = $this->request->get('repo_access');
                         }
                         $this->addAction('save', array($this->groupId, $repoId, $repoAccess, $repoDesc));
                         $this->addView('view');
                     } else {
                         $this->addError($this->getText('controller_access_denied'));
                         $this->redirect('/plugins/git/?group_id=' . $this->groupId);
                     }
                 }
             }
             break;
             #repo_management
         #repo_management
         case 'repo_management':
             $this->addAction('repoManagement', array($this->groupId, $repoId));
             $this->addView('repoManagement');
             break;
             #mail prefix
         #mail prefix
         case 'mail_prefix':
             $valid = new Valid_String('mail_prefix');
             $valid->required();
             if ($this->request->valid($valid)) {
                 $mailPrefix = $this->request->get('mail_prefix');
             } else {
                 $mailPrefix = '';
             }
             $this->addAction('notificationUpdatePrefix', array($this->groupId, $repoId, $mailPrefix));
             $this->addView('repoManagement');
             break;
             #add mail
         #add mail
         case 'add_mail':
             $validMails = array();
             $mails = array_map('trim', preg_split('/[,;]/', $this->request->get('add_mail')));
             $rule = new Rule_Email();
             $um = UserManager::instance();
             foreach ($mails as $mail) {
                 if ($rule->isValid($mail)) {
                     $validMails[] = $mail;
                 } else {
                     $user = $um->findUser($mail);
                     if ($user) {
                         $mail = $user->getEmail();
                         if ($mail) {
                             $validMails[] = $mail;
                         } else {
                             $this->addError($this->getText('no_user_mail', array($mail)));
                         }
                     } else {
                         $this->addError($this->getText('no_user', array($mail)));
                     }
                 }
             }
             $this->addAction('notificationAddMail', array($this->groupId, $repoId, $validMails));
             $this->addView('repoManagement');
             break;
             #remove mail
         #remove mail
         case 'remove_mail':
             $mails = array();
             $valid = new Valid_Email('mail');
             $valid->required();
             if ($this->request->validArray($valid)) {
                 $mails = $this->request->get('mail');
             }
             if (count($mails) > 0) {
                 $this->addAction('notificationRemoveMail', array($this->groupId, $repoId, $mails));
                 $this->addView('repoManagement');
             } else {
                 $this->addAction('repoManagement', array($this->groupId, $repoId));
                 $this->addView('repoManagement');
             }
             break;
             #fork
         #fork
         case 'fork':
             $this->addAction('repoManagement', array($this->groupId, $repoId));
             $this->addView('forkRepositories');
             break;
             #confirm_private
         #confirm_private
         case 'confirm_private':
             if ($this->isAPermittedAction('confirm_deletion') && $this->request->get('confirm_deletion')) {
                 $this->addAction('confirmDeletion', array($this->groupId, $repoId));
                 $this->addView('confirm_deletion', array(0 => array('repo_id' => $repoId)));
             } else {
                 if ($this->isAPermittedAction('save') && $this->request->get('save')) {
                     $valid = new Valid_Text('repo_desc');
                     $valid->required();
                     if ($this->request->valid($valid)) {
                         $repoDesc = $this->request->get('repo_desc');
                     }
                     $valid = new Valid_String('repo_access');
                     $valid->required();
                     if ($this->request->valid($valid)) {
                         $repoAccess = $this->request->get('repo_access');
                     }
                     $this->addAction('confirmPrivate', array($this->groupId, $repoId, $repoAccess, $repoDesc));
                     $this->addView('confirmPrivate');
                 }
             }
             break;
             #SET TO PRIVATE
         #SET TO PRIVATE
         case 'set_private':
             $this->addAction('setPrivate', array($this->groupId, $repoId));
             $this->addView('view');
             break;
         case 'fork_repositories':
             $this->addAction('getProjectRepositoryList', array($this->groupId));
             $this->addView('forkRepositories');
             break;
         case 'do_fork_repositories':
             try {
                 if ($this->request->get('choose_destination') == 'personal') {
                     $this->_doDispatchForkRepositories($this->request, $user);
                 } else {
                     $this->_doDispatchForkCrossProject($this->request, $user);
                 }
             } catch (MalformedPathException $e) {
                 $this->addError($this->getText('fork_malformed_path'));
             }
             $this->addAction('getProjectRepositoryList', array($this->groupId));
             $this->addView('forkRepositories');
             break;
         case "view_last_git_pushes":
             $vGroupId = new Valid_GroupId();
             $vGroupId->required();
             if ($this->request->valid($vGroupId)) {
                 $groupId = $this->request->get('group_id');
             }
             $vWeeksNumber = new Valid_UInt('weeks_number');
             if ($this->request->valid($vWeeksNumber)) {
                 $weeksNumber = $this->request->get('weeks_number');
             }
             if (empty($weeksNumber) || $weeksNumber > Git_LastPushesGraph::MAX_WEEKSNUMBER) {
                 $weeksNumber = 12;
             }
             $imageRenderer = new Git_LastPushesGraph($groupId, $weeksNumber);
             $imageRenderer->display();
             break;
             #LIST
         #LIST
         default:
             $user_id = null;
             $valid = new Valid_UInt('user');
             $valid->required();
             if ($this->request->valid($valid)) {
                 $user_id = $this->request->get('user');
                 $this->addData(array('user' => $user_id));
             }
             $this->addAction('getProjectRepositoryList', array($this->groupId, $user_id));
             $this->addView('index');
             break;
     }
 }
Example #6
0
         if (user_isloggedin()) {
             if (!user_monitor_forum($forum_id, user_getid())) {
                 if (!forum_thread_add_monitor($forum_id, $request->get('thread_id'), user_getid())) {
                     $feedback .= $Language->getText('forum_forum_utils', 'insert_err');
                 }
             }
         }
     }
     // Note: there is a 'msg_id' send but not used here.
     $vFollowUp = new Valid_UInt('is_followup_to');
     $vFollowUp->required();
     $vSubject = new Valid_String('subject');
     $vSubject->required();
     $vSubject->setErrorMessage($GLOBALS['Language']->getText('forum_forum_utils', 'include_body_and_subject'));
     $vBody = new Valid_Text('body');
     $vBody->required();
     $vBody->setErrorMessage($GLOBALS['Language']->getText('forum_forum_utils', 'include_body_and_subject'));
     if ($request->valid($vThreadId) && $request->valid($vFollowUp) && $request->valid($vSubject) && $request->valid($vBody)) {
         post_message($request->get('thread_id'), $request->get('is_followup_to'), $request->get('subject'), $request->get('body'), $forum_id);
     }
 }
 /*
 	set up some defaults if they aren't provided
 */
 // Offset
 if ($request->valid(new Valid_UInt('offset'))) {
     $offset = $request->get('offset');
 } else {
     $offset = 0;
 }
 // Style
Example #7
0
 /**
  * Handle the HTTP request
  *
  * @param HTTPRequest $request HTTP request
  *
  * @return Void
  */
 public function handleRequest(HTTPRequest $request)
 {
     $validAction = new Valid_WhiteList('action', array('add', 'delete'));
     if ($request->valid($validAction)) {
         $action = $request->get('action');
         switch ($action) {
             case 'add':
                 $this->csrf->check();
                 $validProject = new Valid_String('project');
                 $validProject->required();
                 $project = null;
                 if ($request->valid($validProject)) {
                     $project = $request->get('project');
                 }
                 $validRequester = new Valid_String('requester');
                 $validRequester->required();
                 $requester = null;
                 if ($request->valid($validRequester)) {
                     $requester = $request->get('requester');
                 }
                 $validQuota = new Valid_UInt('quota');
                 $validQuota->required();
                 $quota = null;
                 if ($request->valid($validQuota)) {
                     $quota = $request->get('quota');
                 }
                 $validMotivation = new Valid_Text('motivation');
                 $validMotivation->required();
                 $motivation = null;
                 if ($request->valid($validMotivation)) {
                     $motivation = $request->get('motivation');
                 }
                 $this->projectQuotaManager->addQuota($project, $requester, $quota, $motivation);
                 break;
             case 'delete':
                 $this->csrf->check();
                 $list = $request->get('delete_quota');
                 $projects = array();
                 $validProjectId = new Valid_UInt();
                 foreach ($list as $projectId) {
                     if ($validProjectId->validate($projectId)) {
                         $project = $this->projectManager->getProject($projectId);
                         if ($project) {
                             $projects[$project->getId()] = $project->getPublicName();
                         }
                     }
                 }
                 $this->projectQuotaManager->deleteCustomQuota($projects);
                 break;
             default:
                 break;
         }
     } else {
         $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('plugin_statistics', 'invalid_action'));
     }
 }