本文整理汇总了PHP中thebuggenie\core\entities\Project::getB2DBTable方法的典型用法代码示例。如果您正苦于以下问题:PHP Project::getB2DBTable方法的具体用法?PHP Project::getB2DBTable怎么用?PHP Project::getB2DBTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类thebuggenie\core\entities\Project
的用法示例。
在下文中一共展示了Project::getB2DBTable方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preExecute
/**
* The currently selected project in actions where there is one
*
* @access protected
* @property entities\Project $selected_project
*/
public function preExecute(framework\Request $request, $action)
{
try {
if ($project_key = $request['project_key']) {
$this->selected_project = entities\Project::getByKey($project_key);
} elseif ($project_id = (int) $request['project_id']) {
$this->selected_project = entities\Project::getB2DBTable()->selectByID($project_id);
}
if ($this->selected_project instanceof entities\Project) {
framework\Context::setCurrentProject($this->selected_project);
}
} catch (\Exception $e) {
}
}
示例2: preExecute
/**
* Pre-execute function
*
* @param framework\Request $request
* @param string $action
*/
public function preExecute(framework\Request $request, $action)
{
try {
if ($project_id = $request['project_id']) {
$this->selected_project = entities\Project::getB2DBTable()->selectById($project_id);
} elseif ($project_key = $request['project_key']) {
$this->selected_project = entities\Project::getByKey($project_key);
}
} catch (\Exception $e) {
}
if (!$this->selected_project instanceof entities\Project) {
return $this->return404(framework\Context::getI18n()->__('This project does not exist'));
}
framework\Context::setCurrentProject($this->selected_project);
$this->project_key = $this->selected_project->getKey();
}
示例3: componentArchivedProjects
public function componentArchivedProjects()
{
if (!isset($this->target)) {
$this->projects = entities\Project::getAllRootProjects(true);
$this->project_count = count($this->projects);
} elseif ($this->target == 'team') {
$this->team = entities\Team::getB2DBTable()->selectById($this->id);
$projects = array();
foreach (entities\Project::getAllByOwner($this->team) as $project) {
$projects[$project->getID()] = $project;
}
foreach (entities\Project::getAllByLeader($this->team) as $project) {
$projects[$project->getID()] = $project;
}
foreach (entities\Project::getAllByQaResponsible($this->team) as $project) {
$projects[$project->getID()] = $project;
}
foreach ($this->team->getAssociatedProjects() as $project_id => $project) {
$projects[$project_id] = $project;
}
$final_projects = array();
foreach ($projects as $project) {
if ($project->isArchived()) {
$final_projects[] = $project;
}
}
$this->projects = $final_projects;
} elseif ($this->target == 'client') {
$this->client = entities\Client::getB2DBTable()->selectById($this->id);
$projects = entities\Project::getAllByClientID($this->client->getID());
$final_projects = array();
foreach ($projects as $project) {
if (!$project->isArchived()) {
$final_projects[] = $project;
}
}
$this->projects = $final_projects;
} elseif ($this->target == 'project') {
$this->parent = entities\Project::getB2DBTable()->selectById($this->id);
$this->projects = $this->parent->getChildren(true);
}
$this->project_count = count($this->projects);
}
示例4: preExecute
/**
* The currently selected project in actions where there is one
*
* @access protected
* @property entities\Project $selected_project
*/
public function preExecute(framework\Request $request, $action)
{
try {
// Default to JSON if nothing is specified.
$newFormat = $request->getParameter('format', 'json');
$this->getResponse()->setTemplate(mb_strtolower($action) . '.' . $newFormat . '.php');
$this->getResponse()->setupResponseContentType($newFormat);
if ($project_key = $request['project_key']) {
$this->selected_project = entities\Project::getByKey($project_key);
} elseif ($project_id = (int) $request['project_id']) {
$this->selected_project = entities\Project::getB2DBTable()->selectByID($project_id);
}
if ($this->selected_project instanceof entities\Project) {
framework\Context::setCurrentProject($this->selected_project);
}
$this->render_detail = !isset($request['nodetail']);
} catch (\Exception $e) {
$this->getResponse()->setHttpStatus(500);
return $this->renderJSON(array('error' => 'An exception occurred: ' . $e));
}
}
示例5: runAddCommitGitorious
public function runAddCommitGitorious(framework\Request $request)
{
framework\Context::getResponse()->setContentType('text/plain');
framework\Context::getResponse()->renderHeaders();
$passkey = framework\Context::getRequest()->getParameter('passkey');
$project_id = framework\Context::getRequest()->getParameter('project_id');
$project = Project::getB2DBTable()->selectByID($project_id);
// Validate access
if (!$project) {
echo 'Error: The project with the ID ' . $project_id . ' does not exist';
exit;
}
if (framework\Settings::get('access_method_' . $project->getID(), 'vcs_integration') == Vcs_integration::ACCESS_DIRECT) {
echo 'Error: This project uses the CLI access method, and so access via HTTP has been disabled';
exit;
}
if (framework\Settings::get('access_passkey_' . $project->getID(), 'vcs_integration') != $passkey) {
echo 'Error: The passkey specified does not match the passkey specified for this project';
exit;
}
// Validate data
$data = html_entity_decode(framework\Context::getRequest()->getParameter('payload', null, false));
if (empty($data) || $data == null) {
die('Error: No payload was provided');
}
$entries = json_decode($data);
if ($entries == null) {
die('Error: The payload could not be decoded');
}
$entries = json_decode($data);
$previous = $entries->before;
// Branch is stored in the ref
$ref = $entries->ref;
$parts = explode('/', $ref);
if (count($parts) == 3) {
$branch = $parts[2];
} else {
$branch = null;
}
// Parse each commit individually
foreach (array_reverse($entries->commits) as $commit) {
$email = $commit->author->email;
$author = $commit->author->name;
$new_rev = $commit->id;
$old_rev = $previous;
$commit_msg = $commit->message;
$time = strtotime($commit->timestamp);
// Add commit
echo Vcs_integration::processCommit($project, $commit_msg, $old_rev, $previous, $time, "", $author, $branch);
$previous = $new_rev;
exit;
}
}
示例6: getAssociatedProjects
/**
* Get all the projects a team is associated with
*
* @return array
*/
public function getAssociatedProjects()
{
if ($this->_associated_projects === null) {
$this->_associated_projects = array();
$project_ids = tables\ProjectAssignedTeams::getTable()->getProjectsByTeamID($this->getID());
foreach ($project_ids as $project_id) {
$this->_associated_projects[$project_id] = \thebuggenie\core\entities\Project::getB2DBTable()->selectById($project_id);
}
}
return $this->_associated_projects;
}
示例7: runProjectWorkflowTable
public function runProjectWorkflowTable(framework\Request $request)
{
$this->selected_project = entities\Project::getB2DBTable()->selectById($request['project_id']);
if ($request->isPost()) {
try {
$workflow_scheme = entities\WorkflowScheme::getB2DBTable()->selectById($request['new_workflow']);
return $this->renderJSON(array('content' => $this->getComponentHTML('projectworkflow_table', array('project' => $this->selected_project, 'new_workflow' => $workflow_scheme))));
} catch (\Exception $e) {
$this->getResponse()->setHTTPStatus(400);
return $this->renderJSON(array('error' => framework\Context::geti18n()->__('This workflow scheme is not valid')));
}
}
}
示例8: hasPermission
/**
* Perform a permission check on this user
*
* @param string $permission_type The permission key
* @param integer $target_id [optional] a target id if applicable
* @param string $module_name [optional] the module for which the permission is valid
*
* @return boolean
*/
public function hasPermission($permission_type, $target_id = 0, $module_name = 'core', $check_global_role = true)
{
framework\Logging::log('Checking permission ' . $permission_type);
$group_id = (int) $this->getGroupID();
$has_associated_project = is_bool($check_global_role) ? $check_global_role : (is_numeric($target_id) && $target_id != 0 ? array_key_exists($target_id, $this->getAssociatedProjects()) : true);
$teams = $this->getTeams();
if ($target_id != 0 && Project::getB2DBTable()->selectById($target_id) instanceof \thebuggenie\core\entities\Project) {
$teams = array_intersect_key($teams, Project::getB2DBTable()->selectById($target_id)->getAssignedTeams());
}
$retval = framework\Context::checkPermission($permission_type, $this->getID(), $group_id, $teams, $target_id, $module_name, $has_associated_project);
if ($retval !== null) {
framework\Logging::log('...done (Checking permissions ' . $permission_type . ', target id ' . $target_id . ') - return was ' . ($retval ? 'true' : 'false'));
} else {
framework\Logging::log('...done (Checking permissions ' . $permission_type . ', target id ' . $target_id . ') - return was null');
}
return $retval;
}
示例9: getProject
/**
* Return the associated project if any
*
* @return Project
*/
public function getProject()
{
return $this->getItemdata() ? \thebuggenie\core\entities\Project::getB2DBTable()->selectById((int) $this->getItemdata()) : null;
}
示例10: _setArchived
/**
* Handle archive functiions
*
* @param bool $archived Status
* @param framework\Request $request The request object
*/
protected function _setArchived($archived, framework\Request $request)
{
$i18n = framework\Context::getI18n();
if ($this->access_level == framework\Settings::ACCESS_FULL) {
try {
$theProject = entities\Project::getB2DBTable()->selectByID($request['project_id']);
$theProject->setArchived($archived);
$theProject->save();
$projectbox = $this->getComponentHTML('projectbox', array('project' => $theProject, 'access_level' => $this->access_level));
return $this->renderJSON(array('message' => $i18n->__('Project successfully updated'), 'parent_id' => $theProject->getParentID(), 'box' => $projectbox));
} catch (\Exception $e) {
$this->getResponse()->setHttpStatus(400);
return $this->renderJSON(array('error' => $i18n->__('An error occured') . ': ' . $e->getMessage()));
}
}
$this->getResponse()->setHttpStatus(400);
return $this->renderJSON(array("error" => $i18n->__("You don't have access to archive projects")));
}
示例11: runGetBackdropPartial
/**
* Partial backdrop loader
*
* @Route(name="get_partial_for_backdrop", url="/get/partials/:key/*")
* @AnonymousRoute
*
* @param framework\Request $request
*
* @return bool
*/
public function runGetBackdropPartial(framework\Request $request)
{
if (!$request->isAjaxCall()) {
return $this->return404($this->getI18n()->__('You need to enable javascript for The Bug Genie to work properly'));
}
try {
$template_name = null;
if ($request->hasParameter('issue_id')) {
$issue = entities\Issue::getB2DBTable()->selectById($request['issue_id']);
$options = array('issue' => $issue);
} else {
$options = array();
}
switch ($request['key']) {
case 'usercard':
$template_name = 'main/usercard';
if ($user_id = $request['user_id']) {
$user = entities\User::getB2DBTable()->selectById($user_id);
$options['user'] = $user;
}
break;
case 'login':
$template_name = 'main/loginpopup';
$options = $request->getParameters();
$options['content'] = $this->getComponentHTML('login', array('section' => $request->getParameter('section', 'login')));
$options['mandatory'] = false;
break;
case 'uploader':
$template_name = 'main/uploader';
$options = $request->getParameters();
$options['uploader'] = $request['uploader'] == 'dynamic' ? 'dynamic' : 'standard';
break;
case 'attachlink':
$template_name = 'main/attachlink';
break;
case 'openid':
$template_name = 'main/openid';
break;
case 'notifications':
$template_name = 'main/notifications';
$options['first_notification_id'] = $request['first_notification_id'];
$options['last_notification_id'] = $request['last_notification_id'];
break;
case 'workflow_transition':
$transition = entities\WorkflowTransition::getB2DBTable()->selectById($request['transition_id']);
$template_name = $transition->getTemplate();
$options['transition'] = $transition;
if ($request->hasParameter('issue_ids')) {
$options['issues'] = array();
foreach ($request['issue_ids'] as $issue_id) {
$options['issues'][$issue_id] = new entities\Issue($issue_id);
}
} else {
$options['issue'] = new entities\Issue($request['issue_id']);
}
$options['show'] = true;
$options['interactive'] = true;
$options['project'] = $this->selected_project;
break;
case 'reportissue':
$this->_loadSelectedProjectAndIssueTypeFromRequestForReportIssueAction($request);
if ($this->selected_project instanceof entities\Project && !$this->selected_project->isLocked() && $this->getUser()->canReportIssues($this->selected_project)) {
$template_name = 'main/reportissuecontainer';
$options['selected_project'] = $this->selected_project;
$options['selected_issuetype'] = $this->selected_issuetype;
$options['locked_issuetype'] = $this->locked_issuetype;
$options['selected_milestone'] = $this->_getMilestoneFromRequest($request);
$options['parent_issue'] = $this->_getParentIssueFromRequest($request);
$options['board'] = $this->_getBoardFromRequest($request);
$options['selected_build'] = $this->_getBuildFromRequest($request);
$options['issuetypes'] = $this->issuetypes;
$options['errors'] = array();
} else {
throw new \Exception($this->getI18n()->__('You are not allowed to do this'));
}
break;
case 'move_issue':
$template_name = 'main/moveissue';
$options['multi'] = (bool) $request->getParameter('multi', false);
break;
case 'issue_permissions':
$template_name = 'main/issuepermissions';
break;
case 'issue_subscribers':
$template_name = 'main/issuesubscribers';
break;
case 'issue_spenttimes':
$template_name = 'main/issuespenttimes';
$options['initial_view'] = $request->getParameter('initial_view', 'list');
break;
//.........这里部分代码省略.........
示例12: runDoImportCSV
public function runDoImportCSV(framework\Request $request)
{
try {
if ($request['csv_data'] == '') {
throw new \Exception($this->getI18n()->__('No data supplied to import'));
}
$csv = str_replace("\r\n", "\n", $request['csv_data']);
$csv = html_entity_decode($csv);
$headerrow = null;
$data = array();
$errors = array();
// Parse CSV
$handle = fopen("php://memory", 'r+');
fputs($handle, $csv);
rewind($handle);
$i = 0;
while (($row = fgetcsv($handle, 1000)) !== false) {
if (!$headerrow) {
$headerrow = $row;
} else {
if (count($headerrow) == count($row)) {
$data[] = array_combine($headerrow, $row);
} else {
$errors[] = $this->getI18n()->__('Row %row does not have the same number of elements as the header row', array('%row' => $i));
}
}
$i++;
}
fclose($handle);
if (empty($data)) {
throw new \Exception($this->getI18n()->__('Insufficient data to import'));
}
// Verify required columns are present based on type
$requiredcols = array(self::CSV_TYPE_CLIENTS => array(self::CSV_CLIENT_NAME), self::CSV_TYPE_PROJECTS => array(self::CSV_PROJECT_NAME), self::CSV_TYPE_ISSUES => array(self::CSV_ISSUE_TITLE, self::CSV_ISSUE_PROJECT, self::CSV_ISSUE_ISSUE_TYPE));
if (!isset($requiredcols[$request['type']])) {
throw new \Exception('Sorry, this type is unimplemented');
}
foreach ($requiredcols[$request['type']] as $col) {
if (!in_array($col, $headerrow)) {
$errors[] = $this->getI18n()->__('Required column \'%col\' not found in header row', array('%col' => $col));
}
}
// Check if rows are long enough and fields are not empty
for ($i = 0; $i != count($data); $i++) {
$activerow = $data[$i];
// Check if fields are empty
foreach ($activerow as $col => $val) {
if (strlen($val) == 0) {
$errors[] = $this->getI18n()->__('Row %row column %col has no value', array('%col' => $col, '%row' => $i + 1));
}
}
}
if (count($errors) == 0) {
// Check if fields are valid
switch ($request['type']) {
case self::CSV_TYPE_PROJECTS:
for ($i = 0; $i != count($data); $i++) {
$activerow = $data[$i];
// Check if project exists
$key = str_replace(' ', '', $activerow[self::CSV_PROJECT_NAME]);
$key = mb_strtolower($key);
$tmp = entities\Project::getByKey($key);
if ($tmp !== null) {
$errors[] = $this->getI18n()->__('Row %row: A project with this name already exists', array('%row' => $i + 1));
}
// First off are booleans
$boolitems = array(self::CSV_PROJECT_SCRUM, self::CSV_PROJECT_ALLOW_REPORTING, self::CSV_PROJECT_AUTOASSIGN, self::CSV_PROJECT_FREELANCE, self::CSV_PROJECT_EN_BUILDS, self::CSV_PROJECT_EN_COMPS, self::CSV_PROJECT_EN_EDITIONS, self::CSV_PROJECT_SHOW_SUMMARY);
foreach ($boolitems as $boolitem) {
if (array_key_exists($boolitem, $activerow) && isset($activerow[$boolitem]) && $activerow[$boolitem] != 1 && $activerow[$boolitem] != 0) {
$errors[] = $this->getI18n()->__('Row %row column %col: invalid value (must be 1/0)', array('%col' => $boolitem, '%row' => $i + 1));
}
}
// Now identifiables
$identifiableitems = array(array(self::CSV_PROJECT_QA, self::CSV_PROJECT_QA_TYPE), array(self::CSV_PROJECT_LEAD, self::CSV_PROJECT_LEAD_TYPE), array(self::CSV_PROJECT_OWNER, self::CSV_PROJECT_OWNER_TYPE));
foreach ($identifiableitems as $identifiableitem) {
if (!array_key_exists($identifiableitem[1], $activerow) && array_key_exists($identifiableitem[0], $activerow) || array_key_exists($identifiableitem[1], $activerow) && !array_key_exists($identifiableitem[0], $activerow)) {
$errors[] = $this->getI18n()->__('Row %row: Both the type and item ID must be supplied for owner/lead/qa fields', array('%row' => $i + 1));
continue;
}
if (array_key_exists($identifiableitem[1], $activerow) && isset($activerow[$identifiableitem[1]]) !== null && $activerow[$identifiableitem[1]] != self::CSV_IDENTIFIER_TYPE_USER && $activerow[$identifiableitem[1]] != self::CSV_IDENTIFIER_TYPE_TEAM) {
$errors[] = $this->getI18n()->__('Row %row column %col: invalid value (must be 1 for a user or 2 for a team)', array('%col' => $identifiableitem[1], '%row' => $i + 1));
}
if (array_key_exists($identifiableitem[0], $activerow) && isset($activerow[$identifiableitem[0]]) && !is_numeric($activerow[$identifiableitem[0]])) {
$errors[] = $this->getI18n()->__('Row %row column %col: invalid value (must be a number)', array('%col' => $identifiableitem[0], '%row' => $i + 1));
} elseif (array_key_exists($identifiableitem[0], $activerow) && isset($activerow[$identifiableitem[0]]) && is_numeric($activerow[$identifiableitem[0]])) {
// check if they exist
switch ($activerow[$identifiableitem[1]]) {
case self::CSV_IDENTIFIER_TYPE_USER:
try {
entities\User::getB2DBTable()->selectByID($activerow[$identifiableitem[0]]);
} catch (\Exception $e) {
$errors[] = $this->getI18n()->__('Row %row column %col: user does not exist', array('%col' => $identifiableitem[0], '%row' => $i + 1));
}
break;
case self::CSV_IDENTIFIER_TYPE_TEAM:
try {
entities\Team::getB2DBTable()->selectById($activerow[$identifiableitem[0]]);
} catch (\Exception $e) {
$errors[] = $this->getI18n()->__('Row %row column %col: team does not exist', array('%col' => $identifiableitem[0], '%row' => $i + 1));
}
//.........这里部分代码省略.........