public function saveEstimate($issue_id, $months, $weeks, $days, $hours, $points) { $crit = $this->getCriteria(); $crit->addInsert(self::ESTIMATED_MONTHS, $months); $crit->addInsert(self::ESTIMATED_WEEKS, $weeks); $crit->addInsert(self::ESTIMATED_DAYS, $days); $crit->addInsert(self::ESTIMATED_HOURS, $hours); $crit->addInsert(self::ESTIMATED_POINTS, $points); $crit->addInsert(self::ISSUE_ID, $issue_id); $crit->addInsert(self::EDITED_AT, time()); $crit->addInsert(self::EDITED_BY, TBGContext::getUser()->getID()); $crit->addInsert(self::SCOPE, TBGContext::getScope()->getID()); $this->doInsert($crit); }
public function componentAccountSettings() { $i18n = TBGContext::getI18n(); $general_settings = array(); $issues_settings = array(); $general_settings['notify_add_friend'] = $i18n->__('Notify me when someone adds me as their friend'); $issues_settings[TBGMailing::NOTIFY_ISSUE_POSTED_UPDATED] = $i18n->__('Notify me when an issue I posted gets updated or created'); $issues_settings[TBGMailing::NOTIFY_ISSUE_ONCE] = $i18n->__('Only notify me once per issue until I open the issue'); $issues_settings[TBGMailing::NOTIFY_ISSUE_ASSIGNED_UPDATED] = $i18n->__("Notify me when an issue I'm assigned to gets updated or created"); $issues_settings[TBGMailing::NOTIFY_ISSUE_UPDATED_SELF] = $i18n->__('Notify me when I update or create an issue'); $issues_settings[TBGMailing::NOTIFY_ISSUE_TEAMASSIGNED_UPDATED] = $i18n->__("Notify me when an issue assigned to one of my teams is updated or created"); $issues_settings[TBGMailing::NOTIFY_ISSUE_RELATED_PROJECT_TEAMASSIGNED] = $i18n->__("Notify me when an issue assigned to one of my team projects is updated or created"); $issues_settings[TBGMailing::NOTIFY_ISSUE_PROJECT_ASSIGNED] = $i18n->__("Notify me when an issue assigned to one of my projects is updated or created"); $this->general_settings = $general_settings; $this->issues_settings = $issues_settings; $this->uid = TBGContext::getUser()->getID(); }
public static function getAvailableUserViews() { $searches = array(); $searches[self::DASHBOARD_VIEW_PREDEFINED_SEARCH] = array(TBGContext::PREDEFINED_SEARCH_MY_REPORTED_ISSUES => 'Issues reported by me', TBGContext::PREDEFINED_SEARCH_MY_ASSIGNED_OPEN_ISSUES => 'Open issues assigned to me', TBGContext::PREDEFINED_SEARCH_TEAM_ASSIGNED_OPEN_ISSUES => 'Open issues assigned to my teams', TBGContext::PREDEFINED_SEARCH_PROJECT_OPEN_ISSUES => 'Open issues', TBGContext::PREDEFINED_SEARCH_PROJECT_CLOSED_ISSUES => 'Closed issues', TBGContext::PREDEFINED_SEARCH_PROJECT_MOST_VOTED => 'Most voted issues'); $searches[self::DASHBOARD_VIEW_LOGGED_ACTION] = array(0 => 'What you\'ve done recently'); if (TBGContext::getUser()->canViewComments()) { $searches[self::DASHBOARD_VIEW_LAST_COMMENTS] = array(0 => 'Recent comments'); } $searches[self::DASHBOARD_VIEW_SAVED_SEARCH] = array(); $allsavedsearches = B2DB::getTable('TBGSavedSearchesTable')->getAllSavedSearchesByUserIDAndPossiblyProjectID(TBGContext::getUser()->getID()); foreach ($allsavedsearches as $savedsearches) { foreach ($savedsearches as $a_savedsearch) { $searches[self::DASHBOARD_VIEW_SAVED_SEARCH][$a_savedsearch->get(TBGSavedSearchesTable::ID)] = $a_savedsearch->get(TBGSavedSearchesTable::NAME); } } return $searches; }
public function saveFile($real_filename, $original_filename, $content_type, $description = null, $content = null) { $crit = $this->getCriteria(); $crit->addInsert(self::UID, TBGContext::getUser()->getID()); $crit->addInsert(self::REAL_FILENAME, $real_filename); $crit->addInsert(self::UPLOADED_AT, NOW); $crit->addInsert(self::ORIGINAL_FILENAME, $original_filename); $crit->addInsert(self::CONTENT_TYPE, $content_type); $crit->addInsert(self::SCOPE, TBGContext::getScope()->getID()); if ($description !== null) { $crit->addInsert(self::DESCRIPTION, $description); } if ($content !== null) { $crit->addInsert(self::CONTENT, $content); } $res = $this->doInsert($crit); return $res->getInsertID(); }
public function saveSearch($saved_search_name, $saved_search_description, $saved_search_public, $filters, $groupby, $grouporder, $ipp, $templatename, $template_parameter, $project_id, $saved_search_id = null) { $crit = $this->getCriteria(); if ($saved_search_id !== null) { $crit->addUpdate(self::NAME, $saved_search_name); $crit->addUpdate(self::DESCRIPTION, $saved_search_description); $crit->addUpdate(self::TEMPLATE_NAME, $templatename); $crit->addUpdate(self::TEMPLATE_PARAMETER, $template_parameter); $crit->addUpdate(self::GROUPBY, $groupby); $crit->addUpdate(self::GROUPORDER, $grouporder); $crit->addUpdate(self::ISSUES_PER_PAGE, $ipp); $crit->addUpdate(self::APPLIES_TO_PROJECT, $project_id); if (TBGContext::getUser()->canCreatePublicSearches()) { $crit->addUpdate(self::IS_PUBLIC, $saved_search_public); $crit->addUpdate(self::UID, (bool) $saved_search_public ? 0 : TBGContext::getUser()->getID()); } else { $crit->addUpdate(self::IS_PUBLIC, false); $crit->addWhere(self::UID, TBGContext::getUser()->getID()); } $crit->addUpdate(self::SCOPE, TBGContext::getScope()->getID()); $this->doUpdateById($crit, $saved_search_id); } else { $crit->addInsert(self::NAME, $saved_search_name); $crit->addInsert(self::DESCRIPTION, $saved_search_description); $crit->addInsert(self::TEMPLATE_NAME, $templatename); $crit->addInsert(self::TEMPLATE_PARAMETER, $template_parameter); $crit->addInsert(self::GROUPBY, $groupby); $crit->addInsert(self::GROUPORDER, $grouporder); $crit->addInsert(self::ISSUES_PER_PAGE, $ipp); $crit->addInsert(self::APPLIES_TO_PROJECT, $project_id); if (TBGContext::getUser()->canCreatePublicSearches()) { $crit->addInsert(self::IS_PUBLIC, $saved_search_public); $crit->addInsert(self::UID, (bool) $saved_search_public ? 0 : TBGContext::getUser()->getID()); } else { $crit->addInsert(self::IS_PUBLIC, false); $crit->addInsert(self::UID, TBGContext::getUser()->getID()); } $crit->addInsert(self::SCOPE, TBGContext::getScope()->getID()); $saved_search_id = $this->doInsert($crit)->getInsertID(); } Core::getTable('TBGSavedSearchFiltersTable')->deleteBySearchID($saved_search_id); Core::getTable('TBGSavedSearchFiltersTable')->saveFiltersForSavedSearch($saved_search_id, $filters); return $saved_search_id; }
public function addLink($target_type, $target_id = 0, $url = null, $description = null, $link_order = null, $scope = null) { $scope = $scope === null ? TBGContext::getScope()->getID() : $scope; if ($link_order === null) { $crit = $this->getCriteria(); $crit->addSelectionColumn(self::LINK_ORDER, 'max_order', B2DBCriteria::DB_MAX, '', '+1'); $crit->addWhere(self::TARGET_TYPE, $target_type); $crit->addWhere(self::TARGET_ID, $target_id); $crit->addWhere(self::SCOPE, $scope); $row = $this->doSelectOne($crit); $link_order = $row->get('max_order') ? $row->get('max_order') : 1; } $crit = $this->getCriteria(); $crit->addInsert(self::TARGET_TYPE, $target_type); $crit->addInsert(self::TARGET_ID, $target_id); $crit->addInsert(self::URL, $url); $crit->addInsert(self::DESCRIPTION, $description); $crit->addInsert(self::LINK_ORDER, $link_order); $crit->addInsert(self::UID, TBGContext::getUser() instanceof TBGUser ? TBGContext::getUser()->getID() : 0); $crit->addInsert(self::SCOPE, $scope); $res = $this->doInsert($crit); return $res->getInsertID(); }
public function runEditSavedSearch(TBGRequest $request) { if ($request->isPost()) { if ($request['delete_saved_search']) { try { if (!$this->search_object instanceof TBGSavedSearch || !$this->search_object->getB2DBID()) { throw new Exception('not a saved search'); } if ($this->search_object->getUserID() == TBGContext::getUser()->getID() || $this->search_object->isPublic() && TBGContext::getUser()->canCreatePublicSearches()) { $search->delete(); return $this->renderJSON(array('failed' => false, 'message' => TBGContext::getI18n()->__('The saved search was deleted successfully'))); } } catch (Exception $e) { return $this->renderJSON(array('failed' => true, 'message' => TBGContext::getI18n()->__('Cannot delete this saved search'))); } } elseif ($request['saved_search_name'] != '') { // $project_id = (TBGContext::isProjectContext()) ? TBGContext::getCurrentProject()->getID() : 0; // TBGSavedSearchesTable::getTable()->saveSearch($request['saved_search_name'], $request['saved_search_description'], $request['saved_search_public'], $this->filters, $this->groupby, $this->grouporder, $this->ipp, $this->templatename, $this->template_parameter, $project_id, $request['saved_search_id']); if (!$search instanceof TBGSavedSearch) { $search = new TBGSavedSearch(); } $search->setName($request['saved_search_name']); $search->setDescription($request['saved_search_description']); $search->setIsPublic((bool) $request['saved_search_public']); $search->save(); if ($request['saved_search_id']) { TBGContext::setMessage('search_message', TBGContext::getI18n()->__('The saved search was updated')); } else { TBGContext::setMessage('search_message', TBGContext::getI18n()->__('The saved search has been created')); } $params = array(); } else { TBGContext::setMessage('search_error', TBGContext::getI18n()->__('You have to specify a name for the saved search')); $params = array('fs' => $this->filters, 'groupby' => $this->groupby, 'grouporder' => $this->grouporder, 'templatename' => $this->templatename, 'saved_search' => $request['saved_search_id'], 'issues_per_page' => $this->ipp); } if (TBGContext::isProjectContext()) { $route = 'project_issues'; $params['project_key'] = TBGContext::getCurrentProject()->getKey(); } else { $route = 'search'; } $this->forward(TBGContext::getRouting()->generate($route, $params)); } }
/** * Returns a formatted string of the given timestamp * * @param integer $tstamp the timestamp to format * @param integer $format[optional] the format * @param integer $skiptimestamp */ function tbg_formatTime($tstamp, $format = 0) { // offset the timestamp properly if (TBGSettings::getGMToffset() > 0) { $tstamp += TBGSettings::getGMToffset() * 60 * 60; } elseif (TBGSettings::getGMToffset() < 0) { $tstamp -= TBGSettings::getGMToffset() * 60 * 60; } if (TBGSettings::getUserTimezone() > 0) { $tstamp += TBGSettings::getUserTimezone() * 60 * 60; } elseif (TBGSettings::getUserTimezone() < 0) { $tstamp -= TBGSettings::getUserTimezone() * 60 * 60; } switch ($format) { case 1: $tstring = strftime(TBGContext::getI18n()->getDateTimeFormat(1), $tstamp); break; case 2: $tstring = strftime(TBGContext::getI18n()->getDateTimeFormat(2), $tstamp); break; case 3: $tstring = strftime(TBGContext::getI18n()->getDateTimeFormat(3), $tstamp); break; case 4: $tstring = strftime(TBGContext::getI18n()->getDateTimeFormat(4), $tstamp); break; case 5: $tstring = strftime(TBGContext::getI18n()->getDateTimeFormat(5), $tstamp); break; case 6: $tstring = strftime(TBGContext::getI18n()->getDateTimeFormat(6), $tstamp); break; case 7: $tstring = strftime(TBGContext::getI18n()->getDateTimeFormat(7), $tstamp); break; case 8: $tstring = strftime(TBGContext::getI18n()->getDateTimeFormat(8), $tstamp); break; case 9: $tstring = strftime(TBGContext::getI18n()->getDateTimeFormat(9), $tstamp); break; case 10: $tstring = strftime(TBGContext::getI18n()->getDateTimeFormat(10), $tstamp); break; case 11: $tstring = strftime(TBGContext::getI18n()->getDateTimeFormat(9), $tstamp); break; case 12: $tstring = ''; if (date('dmY', $tstamp) == date('dmY')) { $tstring .= __('Today') . ', '; } elseif (date('dmY', $tstamp) == date('dmY', mktime(0, 0, 0, date('m'), date('d') - 1))) { $tstring .= __('Yesterday') . ', '; } elseif (date('dmY', $tstamp) == date('dmY', mktime(0, 0, 0, date('m'), date('d') + 1))) { $tstring .= __('Tomorrow') . ', '; } else { $tstring .= strftime(TBGContext::getI18n()->getDateTimeFormat(12) . ', ', $tstamp); } $tstring .= strftime(TBGContext::getI18n()->getDateTimeFormat(14), $tstamp); break; case 13: $tstring = ''; if (date('dmY', $tstamp) == date('dmY')) { //$tstring .= __('Today') . ', '; } elseif (date('dmY', $tstamp) == date('dmY', mktime(0, 0, 0, date('m'), date('d') - 1))) { $tstring .= __('Yesterday') . ', '; } elseif (date('dmY', $tstamp) == date('dmY', mktime(0, 0, 0, date('m'), date('d') + 1))) { $tstring .= __('Tomorrow') . ', '; } else { $tstring .= strftime(TBGContext::getI18n()->getDateTimeFormat(12) . ', ', $tstamp); } $tstring .= strftime(TBGContext::getI18n()->getDateTimeFormat(14), $tstamp); break; case 14: $tstring = ''; if (date('dmY', $tstamp) == date('dmY')) { $tstring .= __('Today'); } elseif (date('dmY', $tstamp) == date('dmY', mktime(0, 0, 0, date('m'), date('d') - 1))) { $tstring .= __('Yesterday'); } elseif (date('dmY', $tstamp) == date('dmY', mktime(0, 0, 0, date('m'), date('d') + 1))) { $tstring .= __('Tomorrow'); } else { $tstring .= strftime(TBGContext::getI18n()->getDateTimeFormat(12), $tstamp); } break; case 15: $tstring = strftime(TBGContext::getI18n()->getDateTimeFormat(11), $tstamp); break; case 16: $tstring = strftime(TBGContext::getI18n()->getDateTimeFormat(12), $tstamp); break; case 17: $tstring = strftime(TBGContext::getI18n()->getDateTimeFormat(13), $tstamp); break; case 18: $old = date_default_timezone_get(); date_default_timezone_set('UTC'); $tstring = strftime(TBGContext::getI18n()->getDateTimeFormat(16), $tstamp); date_default_timezone_set($old); break; case 19: $tstring = strftime(TBGContext::getI18n()->getDateTimeFormat(14), $tstamp); break; case 20: $tstring = ''; if (date('dmY', $tstamp) == date('dmY')) { $tstring .= __('Today') . ' (' . strftime('%H:%M', $tstamp) . ')'; } elseif (date('dmY', $tstamp) == date('dmY', mktime(0, 0, 0, date('m'), date('d') - 1))) { $tstring .= __('Yesterday') . ' (' . strftime('%H:%M', $tstamp) . ')'; } elseif (date('dmY', $tstamp) == date('dmY', mktime(0, 0, 0, date('m'), date('d') + 1))) { $tstring .= __('Tomorrow') . ' (' . strftime('%H:%M', $tstamp) . ')'; } else { $tstring .= strftime(TBGContext::getI18n()->getDateTimeFormat(15), $tstamp); } break; case 21: $tstring = TBGContext::isCLI() ? strftime('%a, %d %b %Y %H:%M:%S GMT', $tstamp) : strftime(TBGContext::getI18n()->getDateTimeFormat(17), $tstamp); if (TBGContext::getUser()->getTimezone() > 0) { $tstring .= '+'; } if (TBGContext::getUser()->getTimezone() < 0) { $tstring .= '-'; } if (TBGContext::getUser()->getTimezone() != 0) { $tstring .= TBGContext::getUser()->getTimezone(); } break; case 22: $tstring = strftime(TBGContext::getI18n()->getDateTimeFormat(15), $tstamp); break; case 23: $tstring = ''; if (date('dmY', $tstamp) == date('dmY')) { $tstring .= __('Today'); } elseif (date('dmY', $tstamp) == date('dmY', mktime(0, 0, 0, date('m'), date('d') - 1))) { $tstring .= __('Yesterday'); } elseif (date('dmY', $tstamp) == date('dmY', mktime(0, 0, 0, date('m'), date('d') + 1))) { $tstring .= __('Tomorrow'); } else { $tstring .= strftime(TBGContext::getI18n()->getDateTimeFormat(15), $tstamp); } break; default: return $tstamp; } return htmlentities($tstring); }
public function perform(TBGIssue $issue, $request = null) { switch ($this->_action_type) { case self::ACTION_ASSIGN_ISSUE_SELF: $issue->setAssignee(TBGContext::getUser()); break; case self::ACTION_SET_STATUS: if ($this->getTargetValue()) { $issue->setStatus(TBGContext::factory()->TBGStatus((int) $this->getTargetValue())); } else { $issue->setStatus($request['status_id']); } break; case self::ACTION_SET_MILESTONE: if ($this->getTargetValue()) { $issue->setMilestone(TBGContext::factory()->TBGMilestone((int) $this->getTargetValue())); } else { $issue->setMilestone($request['milestone_id']); } break; case self::ACTION_CLEAR_PRIORITY: $issue->setPriority(null); break; case self::ACTION_SET_PRIORITY: if ($this->getTargetValue()) { $issue->setPriority(TBGContext::factory()->TBGPriority((int) $this->getTargetValue())); } else { $issue->setPriority($request['priority_id']); } break; case self::ACTION_CLEAR_PERCENT: $issue->setPercentCompleted(0); break; case self::ACTION_SET_PERCENT: if ($this->getTargetValue()) { $issue->setPercentCompleted((int) $this->getTargetValue()); } else { $issue->setPercentCompleted((int) $request['percent_complete_id']); } break; case self::ACTION_CLEAR_DUPLICATE: $issue->setDuplicateOf(null); break; case self::ACTION_SET_DUPLICATE: $issue->setDuplicateOf($request['duplicate_issue_id']); break; case self::ACTION_CLEAR_RESOLUTION: $issue->setResolution(null); break; case self::ACTION_SET_RESOLUTION: if ($this->getTargetValue()) { $issue->setResolution(TBGContext::factory()->TBGResolution((int) $this->getTargetValue())); } else { $issue->setResolution($request['resolution_id']); } break; case self::ACTION_CLEAR_REPRODUCABILITY: $issue->setReproducability(null); break; case self::ACTION_SET_REPRODUCABILITY: if ($this->getTargetValue()) { $issue->setReproducability(TBGContext::factory()->TBGReproducability((int) $this->getTargetValue())); } else { $issue->setReproducability($request['reproducability_id']); } break; case self::ACTION_CLEAR_ASSIGNEE: $issue->clearAssignee(); break; case self::ACTION_ASSIGN_ISSUE: if ($this->getTargetValue()) { $target_details = explode('_', $this->_target_value); if ($target_details[0] == 'user') { $assignee = TBGUser::getB2DBTable()->selectById((int) $target_details[1]); } else { $assignee = TBGTeam::getB2DBTable()->selectById((int) $target_details[1]); } $issue->setAssignee($assignee); } else { $assignee = null; switch ($request['assignee_type']) { case 'user': $assignee = TBGUser::getB2DBTable()->selectById((int) $request['assignee_id']); break; case 'team': $assignee = TBGTeam::getB2DBTable()->selectById((int) $request['assignee_id']); break; } if ((bool) $request->getParameter('assignee_teamup', false) && $assignee instanceof TBGUser && $assignee->getID() != TBGContext::getUser()->getID()) { $team = new TBGTeam(); $team->setName($assignee->getBuddyname() . ' & ' . TBGContext::getUser()->getBuddyname()); $team->setOndemand(true); $team->save(); $team->addMember($assignee); $team->addMember(TBGContext::getUser()); $assignee = $team; } $issue->setAssignee($assignee); } break; case self::ACTION_USER_START_WORKING: $issue->clearUserWorkingOnIssue(); if ($issue->getAssignee() instanceof TBGTeam && $issue->getAssignee()->isOndemand()) { $members = $issue->getAssignee()->getMembers(); $issue->startWorkingOnIssue(array_shift($members)); } elseif ($issue->getAssignee() instanceof TBGUser) { $issue->startWorkingOnIssue($issue->getAssignee()); } break; case self::ACTION_USER_STOP_WORKING: if ($request->getParameter('did', 'nothing') == 'nothing') { $issue->clearUserWorkingOnIssue(); } elseif ($request->getParameter('did', 'nothing') == 'this') { $times = array(); if ($request['timespent_manual']) { $times = TBGIssue::convertFancyStringToTime($request['timespent_manual']); } elseif ($request['timespent_specified_type']) { $times = array('points' => 0, 'hours' => 0, 'days' => 0, 'weeks' => 0, 'months' => 0); $times[$request['timespent_specified_type']] = $request['timespent_specified_value']; } if (array_sum($times) > 0) { $times['hours'] *= 100; $spenttime = new TBGIssueSpentTime(); $spenttime->setIssue($issue); $spenttime->setUser(TBGContext::getUser()); $spenttime->setSpentPoints($times['points']); $spenttime->setSpentHours($times['hours']); $spenttime->setSpentDays($times['days']); $spenttime->setSpentWeeks($times['weeks']); $spenttime->setSpentMonths($times['months']); $spenttime->setActivityType($request['timespent_activitytype']); $spenttime->setComment($request['timespent_comment']); $spenttime->save(); } $issue->clearUserWorkingOnIssue(); } else { $issue->stopWorkingOnIssue(); } break; } }
/** * Whether or not the current user can access the component * * @return boolean */ public function hasAccess() { return $this->getProject()->canSeeAllComponents() || TBGContext::getUser()->hasPermission('canseecomponent', $this->getID()); }
/** * Handles an uploaded file, stores it to the correct folder, adds an entry * to the database and returns a TBGFile object * * @param string $thefile The request parameter the file was sent as * * @return TBGFile The TBGFile object */ public function handleUpload($key) { $apc_exists = self::CanGetUploadStatus(); if ($apc_exists && !array_key_exists($this->getParameter('APC_UPLOAD_PROGRESS'), $_SESSION['__upload_status'])) { $_SESSION['__upload_status'][$this->getParameter('APC_UPLOAD_PROGRESS')] = array('id' => $this->getParameter('APC_UPLOAD_PROGRESS'), 'finished' => false, 'percent' => 0, 'total' => 0, 'complete' => 0); } try { if ($this->getUploadedFile($key) !== null) { $thefile = $this->getUploadedFile($key); if (TBGSettings::isUploadsEnabled()) { TBGLogging::log('Uploads enabled'); if ($thefile['error'] == UPLOAD_ERR_OK) { TBGLogging::log('No upload errors'); if (filesize($thefile['tmp_name']) > TBGSettings::getUploadsMaxSize(true) && TBGSettings::getUploadsMaxSize() > 0) { throw new Exception(TBGContext::getI18n()->__('You cannot upload files bigger than %max_size% MB', array('%max_size%' => TBGSettings::getUploadsMaxSize()))); } TBGLogging::log('Upload filesize ok'); $extension = substr(basename($thefile['name']), strpos(basename($thefile['name']), '.')); if ($extension == '') { TBGLogging::log('OOps, could not determine upload filetype', 'main', TBGLogging::LEVEL_WARNING_RISK); //throw new Exception(TBGContext::getI18n()->__('Could not determine filetype')); } else { TBGLogging::log('Checking uploaded file extension'); $extension = substr($extension, 1); $upload_extensions = TBGSettings::getUploadsExtensionsList(); if (TBGSettings::getUploadsRestrictionMode() == 'blacklist') { TBGLogging::log('... using blacklist'); foreach ($upload_extensions as $an_ext) { if (strtolower(trim($extension)) == strtolower(trim($an_ext))) { TBGLogging::log('Upload extension not ok'); throw new Exception(TBGContext::getI18n()->__('This filetype is not allowed')); } } TBGLogging::log('Upload extension ok'); } else { TBGLogging::log('... using whitelist'); $is_ok = false; foreach ($upload_extensions as $an_ext) { if (strtolower(trim($extension)) == strtolower(trim($an_ext))) { TBGLogging::log('Upload extension ok'); $is_ok = true; break; } } if (!$is_ok) { TBGLogging::log('Upload extension not ok'); throw new Exception(TBGContext::getI18n()->__('This filetype is not allowed')); } } /*if (in_array(strtolower(trim($extension)), array('php', 'asp'))) { TBGLogging::log('Upload extension is php or asp'); throw new Exception(TBGContext::getI18n()->__('This filetype is not allowed')); }*/ } if (is_uploaded_file($thefile['tmp_name'])) { TBGLogging::log('Uploaded file is uploaded'); $files_dir = TBGSettings::getUploadsLocalpath(); $new_filename = TBGContext::getUser()->getID() . '_' . NOW . '_' . basename($thefile['name']); TBGLogging::log('Moving uploaded file to ' . $new_filename); if (!move_uploaded_file($thefile['tmp_name'], $files_dir . $new_filename)) { TBGLogging::log('Moving uploaded file failed!'); throw new Exception(TBGContext::getI18n()->__('An error occured when saving the file')); } else { TBGLogging::log('Upload complete and ok, storing upload status and returning filename ' . $new_filename); $content_type = TBGFile::getMimeType($files_dir . $new_filename); $file = new TBGFile(); $file->setRealFilename($new_filename); $file->setOriginalFilename(basename($thefile['name'])); $file->setContentType($content_type); $file->setDescription($this->getParameter($key . '_description')); if (TBGSettings::getUploadStorage() == 'database') { $file->setContent(file_get_contents($files_dir . $new_filename)); } $file->save(); //$file = TBGFile::createNew($new_filename, basename($thefile['name']), $content_type, $this->getParameter($key.'_description'), ((TBGSettings::getUploadStorage() == 'database') ? file_get_contents($files_dir.$new_filename) : null)); if ($apc_exists) { $_SESSION['__upload_status'][$this->getParameter('APC_UPLOAD_PROGRESS')] = array('id' => $this->getParameter('APC_UPLOAD_PROGRESS'), 'finished' => true, 'percent' => 100, 'total' => 0, 'complete' => 0, 'file_id' => $file->getID()); } return $file; } } else { TBGLogging::log('Uploaded file was not uploaded correctly'); throw new Exception(TBGContext::getI18n()->__('The file was not uploaded correctly')); } } else { TBGLogging::log('Upload error: ' . $thefile['error']); switch ($thefile['error']) { case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE: throw new Exception(TBGContext::getI18n()->__('You cannot upload files bigger than %max_size% MB', array('%max_size%' => TBGSettings::getUploadsMaxSize()))); break; case UPLOAD_ERR_PARTIAL: throw new Exception(TBGContext::getI18n()->__('The upload was interrupted, please try again')); break; case UPLOAD_ERR_NO_FILE: throw new Exception(TBGContext::getI18n()->__('No file was uploaded')); break; default: throw new Exception(TBGContext::getI18n()->__('An unhandled error occured') . ': ' . $thefile['error']); break; } } } else { TBGLogging::log('Uploads not enabled'); throw new Exception(TBGContext::getI18n()->__('Uploads are not enabled')); } TBGLogging::log('Uploaded file could not be uploaded'); throw new Exception(TBGContext::getI18n()->__('The file could not be uploaded')); } TBGLogging::log('Could not find uploaded file' . $key); throw new Exception(TBGContext::getI18n()->__('Could not find the uploaded file. Please make sure that it is not too big.')); } catch (Exception $e) { TBGLogging::log('Upload exception: ' . $e->getMessage()); if ($apc_exists) { $_SESSION['__upload_status'][$this->getParameter('APC_UPLOAD_PROGRESS')]['error'] = $e->getMessage(); $_SESSION['__upload_status'][$this->getParameter('APC_UPLOAD_PROGRESS')]['finished'] = true; $_SESSION['__upload_status'][$this->getParameter('APC_UPLOAD_PROGRESS')]['percent'] = 100; } throw $e; } }
public function isValid($input) { switch ($this->_rule) { case self::RULE_MAX_ASSIGNED_ISSUES: $num_issues = (int) $this->getRuleValue(); return $num_issues ? (bool) (count(TBGContext::getUser()->getUserAssignedIssues()) < $num_issues) : true; break; case self::RULE_STATUS_VALID: case self::RULE_PRIORITY_VALID: case self::RULE_RESOLUTION_VALID: case self::RULE_REPRODUCABILITY_VALID: $valid_items = explode(',', $this->getRuleValue()); $valid = false; foreach ($valid_items as $item) { if ($this->_rule == self::RULE_STATUS_VALID) { $fieldname = 'Status'; $fieldname_small = 'status'; } elseif ($this->_rule == self::RULE_RESOLUTION_VALID) { $fieldname = 'Resolution'; $fieldname_small = 'resolution'; } elseif ($this->_rule == self::RULE_REPRODUCABILITY_VALID) { $fieldname = 'Reproducability'; $fieldname_small = 'reproducability'; } elseif ($this->_rule == self::RULE_PRIORITY_VALID) { $fieldname = 'Priority'; $fieldname_small = 'priority'; } if ($input instanceof TBGIssue) { $type = "TBG{$fieldname}"; $getter = "get{$fieldname}"; if (TBGContext::factory()->{$type}((int) $item)->getID() == $issue->{$getter}()->getID()) { $valid = true; break; } } elseif ($input instanceof TBGRequest) { if ($input->getParameter("{$fieldname_small}_id") == $item) { $valid = true; break; } } } return $valid; break; } }
public function getAccessLevel($section, $module) { return TBGContext::getUser()->canSaveConfiguration($section, $module) ? TBGSettings::ACCESS_FULL : TBGSettings::ACCESS_READ; }
public function hasAccess() { return (bool) (TBGContext::getUser()->hasPageAccess('clientlist') || TBGContext::getUser()->isMemberOfClient($this)); }
public function getPredefinedBreadcrumbLinks($type, $project = null) { $i18n = TBGContext::getI18n(); $links = array(); switch ($type) { case 'main_links': $links[] = array('url' => TBGContext::getRouting()->generate('home'), 'title' => $i18n->__('Frontpage')); $links[] = array('url' => TBGContext::getRouting()->generate('dashboard'), 'title' => $i18n->__('Personal dashboard')); $links[] = array('title' => $i18n->__('Issues')); $links[] = array('title' => $i18n->__('Teams')); $links[] = array('title' => $i18n->__('Clients')); $links = TBGEvent::createNew('core', 'breadcrumb_main_links', null, array(), $links)->trigger()->getReturnList(); if (TBGContext::getUser()->canAccessConfigurationPage()) { $links[] = array('url' => make_url('configure'), 'title' => $i18n->__('Configure The Bug Genie')); } $links[] = array('url' => TBGContext::getRouting()->generate('about'), 'title' => $i18n->__('About %sitename%', array('%sitename%' => TBGSettings::getTBGname()))); $links[] = array('url' => TBGContext::getRouting()->generate('account'), 'title' => $i18n->__('Account details')); break; case 'project_summary': $links[] = array('url' => TBGContext::getRouting()->generate('project_dashboard', array('project_key' => $project->getKey())), 'title' => $i18n->__('Dashboard')); $links[] = array('url' => TBGContext::getRouting()->generate('project_scrum', array('project_key' => $project->getKey())), 'title' => $i18n->__('Sprint planning')); $links[] = array('url' => TBGContext::getRouting()->generate('project_roadmap', array('project_key' => $project->getKey())), 'title' => $i18n->__('Roadmap')); $links[] = array('url' => TBGContext::getRouting()->generate('project_team', array('project_key' => $project->getKey())), 'title' => $i18n->__('Team overview')); $links[] = array('url' => TBGContext::getRouting()->generate('project_statistics', array('project_key' => $project->getKey())), 'title' => $i18n->__('Statistics')); $links[] = array('url' => TBGContext::getRouting()->generate('project_timeline', array('project_key' => $project->getKey())), 'title' => $i18n->__('Timeline')); $links[] = array('url' => TBGContext::getRouting()->generate('project_reportissue', array('project_key' => $project->getKey())), 'title' => $i18n->__('Report an issue')); $links[] = array('url' => TBGContext::getRouting()->generate('project_issues', array('project_key' => $project->getKey())), 'title' => $i18n->__('Issues')); $links = TBGEvent::createNew('core', 'breadcrumb_project_links', null, array(), $links)->trigger()->getReturnList(); break; case 'client_list': foreach (TBGClient::getAll() as $client) { if ($client->hasAccess()) { $links[] = array('url' => TBGContext::getRouting()->generate('client_dashboard', array('client_id' => $client->getID())), 'title' => $client->getName()); } } break; case 'team_list': foreach (TBGTeam::getAll() as $team) { if ($team->hasAccess()) { $links[] = array('url' => TBGContext::getRouting()->generate('team_dashboard', array('team_id' => $team->getID())), 'title' => $team->getName()); } } break; } return $links; }
public function runUpdateIssueDetails(TBGRequest $request) { $this->error = false; try { $i18n = TBGContext::getI18n(); $issue = TBGIssue::getIssueFromLink($request->getParameter('issue_no')); if ($issue->getProject()->getID() != $this->selected_project->getID()) { throw new Exception($i18n->__('This issue is not valid for this project')); } if (!$issue instanceof TBGIssue) { die; } $workflow_transition = null; if ($passed_transition = $request->getParameter('workflow_transition')) { //echo "looking for transition "; $key = str_replace(' ', '', mb_strtolower($passed_transition)); //echo $key . "\n"; foreach ($issue->getAvailableWorkflowTransitions() as $transition) { //echo str_replace(' ', '', mb_strtolower($transition->getName())) . "?"; if (strpos(str_replace(' ', '', mb_strtolower($transition->getName())), $key) !== false) { $workflow_transition = $transition; //echo "found transition " . $transition->getID(); break; } //echo "no"; } if (!$workflow_transition instanceof TBGWorkflowTransition) { throw new Exception("This transition ({$key}) is not valid"); } } $fields = $request->getRawParameter('fields', array()); $return_values = array(); if ($workflow_transition instanceof TBGWorkflowTransition) { foreach ($fields as $field_key => $field_value) { $classname = "TBG" . ucfirst($field_key); $method = "set" . ucfirst($field_key); $choices = $classname::getAll(); $found = false; foreach ($choices as $choice_key => $choice) { if (strpos(str_replace(' ', '', strtolower($choice->getName())), str_replace(' ', '', strtolower($field_value))) !== false) { $request->setParameter($field_key . '_id', $choice->getId()); break; } } } $request->setParameter('comment_body', $request->getParameter('message')); $return_values['applied_transition'] = $workflow_transition->getName(); if ($workflow_transition->validateFromRequest($request)) { $retval = $workflow_transition->transitionIssueToOutgoingStepFromRequest($issue, $request); $return_values['transition_ok'] = $retval === false ? false : true; } else { $return_values['transition_ok'] = false; $return_values['message'] = "Please pass all information required for this transition"; } } elseif ($issue->isUpdateable()) { foreach ($fields as $field_key => $field_value) { try { if (in_array($field_key, array_merge(array('title', 'state'), TBGDatatype::getAvailableFields(true)))) { switch ($field_key) { case 'state': $issue->setState($field_value == 'open' ? TBGIssue::STATE_OPEN : TBGIssue::STATE_CLOSED); break; case 'title': if ($field_value != '') { $issue->setTitle($field_value); } else { throw new Exception($i18n->__('Invalid title')); } break; case 'description': case 'reproduction_steps': $method = "set" . ucfirst($field_key); $issue->{$method}($field_value); break; case 'status': case 'resolution': case 'reproducability': case 'priority': case 'severity': case 'category': $classname = "TBG" . ucfirst($field_key); $method = "set" . ucfirst($field_key); $choices = $classname::getAll(); $found = false; foreach ($choices as $choice_key => $choice) { if (str_replace(' ', '', strtolower($choice->getName())) == str_replace(' ', '', strtolower($field_value))) { $issue->{$method}($choice); $found = true; } } if (!$found) { throw new Exception('Could not find this value'); } break; case 'percent_complete': $issue->setPercentCompleted($field_value); break; case 'owner': case 'assignee': $set_method = "set" . ucfirst($field_key); $unset_method = "un{$set_method}"; switch (strtolower($field_value)) { case 'me': $issue->{$set_method}(TBGContext::getUser()); break; case 'none': $issue->{$unset_method}(); break; default: try { $user = TBGUser::findUser(strtolower($field_value)); if ($user instanceof TBGUser) { $issue->{$set_method}($user); } } catch (Exception $e) { throw new Exception('No such user found'); } break; } break; case 'estimated_time': case 'spent_time': $set_method = "set" . ucfirst(str_replace('_', '', $field_key)); $issue->{$set_method}($field_value); break; case 'milestone': $found = false; foreach ($this->selected_project->getAllMilestones() as $milestone) { if (str_replace(' ', '', strtolower($milestone->getName())) == str_replace(' ', '', strtolower($field_value))) { $issue->setMilestone($milestone->getID()); $found = true; } } if (!$found) { throw new Exception('Could not find this milestone'); } break; default: throw new Exception($i18n->__('Invalid field')); } } $return_values[$field_key] = array('success' => true); } catch (Exception $e) { $return_values[$field_key] = array('success' => false, 'error' => $e->getMessage()); } } } TBGEvent::listen('core', 'TBGIssue::save', function (TBGEvent $event) { $comment = $event->getParameter('comment'); $comment->setContent($request->getRawParameter('message') . "\n\n" . $comment->getContent()); $comment->setSystemComment(false); $comment->save(); }); if (!$workflow_transition instanceof TBGWorkflowTransition) { $issue->getWorkflowStep()->getWorkflow()->moveIssueToMatchingWorkflowStep($issue); } if (!array_key_exists('transition_ok', $return_values) || $return_values['transition_ok']) { $issue->save(); } $this->return_values = $return_values; } catch (Exception $e) { //$this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('failed' => true, 'error' => $e->getMessage())); } }
public function hasAccess() { return (bool) (TBGContext::getUser()->hasPageAccess('teamlist') || TBGContext::getUser()->isMemberOfTeam($this)); }
public function doSave($options = array(), $reason = null) { if (TBGArticlesTable::getTable()->doesNameConflictExist($this->_name, $this->_id, TBGContext::getScope()->getID())) { if (!array_key_exists('overwrite', $options) || !$options['overwrite']) { throw new Exception(TBGContext::getI18n()->__('Another article with this name already exists')); } } $user_id = TBGContext::getUser() instanceof TBGUser ? TBGContext::getUser()->getID() : 0; if (!isset($options['revert']) || !$options['revert']) { $revision = TBGArticleHistoryTable::getTable()->addArticleHistory($this->_name, $this->_old_content, $this->_content, $user_id, $reason); } else { $revision = null; } TBGArticleLinksTable::getTable()->deleteLinksByArticle($this->_name); TBGArticleCategoriesTable::getTable()->deleteCategoriesByArticle($this->_name); $this->save(); $this->_old_content = $this->_content; if (mb_substr($this->getContent(), 0, 10) == "#REDIRECT ") { $content = explode("\n", $this->getContent()); preg_match('/(\\[\\[([^\\]]*?)\\]\\])$/im', mb_substr(array_shift($content), 10), $matches); if (count($matches) == 3) { return; } } list($links, $categories) = $this->_retrieveLinksAndCategoriesFromContent($options); foreach ($links as $link => $occurrences) { TBGArticleLinksTable::getTable()->addArticleLink($this->_name, $link); } foreach ($categories as $category => $occurrences) { TBGArticleCategoriesTable::getTable()->addArticleCategory($this->_name, $category, $this->isCategory()); } $this->_history = null; TBGEvent::createNew('core', 'TBGWikiArticle::doSave', $this, compact('reason', 'revision', 'user_id'))->trigger(); return true; }
protected function _checkArticlePermissions($article_name, $permission_name) { $user = TBGContext::getUser(); switch ($this->getSetting('free_edit')) { case 1: $permissive = !$user->isGuest(); break; case 2: $permissive = true; break; case 0: default: $permissive = false; break; } if ($user->hasPermission($permission_name, $article_name, 'publish', true, $permissive)) { return true; } $namespaces = explode(':', $article_name); if (count($namespaces) > 1) { array_pop($namespaces); $composite_ns = ''; foreach ($namespaces as $namespace) { $composite_ns .= $composite_ns != '' ? ":{$namespace}" : $namespace; if ($user->hasPermission($permission_name, $composite_ns, 'publish', true, $permissive)) { return true; } } } return $user->hasPermission($permission_name, 0, 'publish', false, $permissive); }
/** * Whether this user is authenticated or just an authenticated guest * * @return boolean */ public function isAuthenticated() { return (bool) ($this->getID() == TBGContext::getUser()->getID()); }
/** * Perform a permission check based on a key, and whether or not to * check if the permission is explicitly set * * @param string $key The permission key to check for * @param boolean $exclusive Whether to make sure the permission is explicitly set * * @return boolean */ public function permissionCheck($key, $explicit = false) { $retval = TBGContext::getUser()->hasPermission($key, $this->getID(), 'core', true, null); if ($explicit) { $retval = $retval !== null ? $retval : TBGContext::getUser()->hasPermission($key, 0, 'core', true, null); } else { $retval = $retval !== null ? $retval : TBGContext::getUser()->hasPermission($key); } return $retval; }
/** * Transition an issue to the outgoing step, based on request data if available * * @param TBGIssue $issue * @param TBGRequest $request */ public function transitionIssueToOutgoingStepFromRequest(TBGIssue $issue, $request = null) { $request = $request !== null ? $request : $this->_request; $this->getOutgoingStep()->applyToIssue($issue); if (!empty($this->_validation_errors)) { return false; } foreach ($this->getActions() as $action) { $action->perform($issue, $request); } if ($request->hasParameter('comment_body') && trim($request['comment_body'] != '')) { $comment = new TBGComment(); $comment->setTitle(''); $comment->setContent($request->getParameter('comment_body', null, false)); $comment->setPostedBy(TBGContext::getUser()->getID()); $comment->setTargetID($issue->getID()); $comment->setTargetType(TBGComment::TYPE_ISSUE); $comment->setModuleName('core'); $comment->setIsPublic(true); $comment->setSystemComment(false); $comment->save(); $issue->setSaveComment($comment); } $issue->save(); }
/** * Performs the "find issues" action * * @param TBGRequest $request */ public function runFindIssues(TBGRequest $request) { $this->_getSearchDetailsFromRequest($request); if ($request->isMethod(TBGRequest::POST) && !$request->getParameter('quicksearch')) { if ($request->getParameter('delete_saved_search')) { try { $search = TBGSavedSearchesTable::getTable()->getByID($request->getParameter('saved_search_id')); if ($search->get(TBGSavedSearchesTable::UID) == TBGContext::getUser()->getID() || $search->get(TBGSavedSearchesTable::IS_PUBLIC) && TBGContext::getUser()->canCreatePublicSearches()) { TBGSavedSearchesTable::getTable()->doDeleteById($request->getParameter('saved_search_id')); return $this->renderJSON(array('failed' => false, 'message' => TBGContext::getI18n()->__('The saved search was deleted successfully'))); } } catch (Exception $e) { return $this->renderJSON(array('failed' => true, 'message' => TBGContext::getI18n()->__('Cannot delete this saved search'))); } } elseif ($request->getParameter('saved_search_name') != '') { $project_id = TBGContext::isProjectContext() ? TBGContext::getCurrentProject()->getID() : 0; TBGSavedSearchesTable::getTable()->saveSearch($request->getParameter('saved_search_name'), $request->getParameter('saved_search_description'), $request->getParameter('saved_search_public'), $this->filters, $this->groupby, $this->grouporder, $this->ipp, $this->templatename, $this->template_parameter, $project_id, $request->getParameter('saved_search_id')); if ($request->getParameter('saved_search_id')) { TBGContext::setMessage('search_message', TBGContext::getI18n()->__('The saved search was updated')); } else { TBGContext::setMessage('search_message', TBGContext::getI18n()->__('The saved search has been created')); } $params = array(); } else { TBGContext::setMessage('search_error', TBGContext::getI18n()->__('You have to specify a name for the saved search')); $params = array('filters' => $this->filters, 'groupby' => $this->groupby, 'grouporder' => $this->grouporder, 'templatename' => $this->templatename, 'saved_search' => $request->getParameter('saved_search_id'), 'issues_per_page' => $this->ipp); } if (TBGContext::isProjectContext()) { $route = 'project_issues'; $params['project_key'] = TBGContext::getCurrentProject()->getKey(); } else { $route = 'search'; } $this->forward(TBGContext::getRouting()->generate($route, $params)); } else { $this->doSearch($request); $this->issues = $this->foundissues; if ($request->getParameter('quicksearch') == true) { $this->redirect('quicksearch'); } } $this->search_error = TBGContext::getMessageAndClear('search_error'); $this->search_message = TBGContext::getMessageAndClear('search_message'); $this->appliedfilters = $this->filters; $this->templates = $this->getTemplates(); $this->savedsearches = B2DB::getTable('TBGSavedSearchesTable')->getAllSavedSearchesByUserIDAndPossiblyProjectID(TBGContext::getUser()->getID(), TBGContext::isProjectContext() ? TBGContext::getCurrentProject()->getID() : 0); }
/** * Add a build (AJAX call) * * @param TBGRequest $request The request object */ public function runProjectBuild(TBGRequest $request) { $i18n = TBGContext::getI18n(); if ($this->getUser()->canManageProjectReleases($this->selected_project)) { try { if (TBGContext::getUser()->canManageProjectReleases($this->selected_project)) { if (($b_name = $request['build_name']) && trim($b_name) != '') { $build = new TBGBuild($request['build_id']); $build->setName($b_name); $build->setVersion($request->getParameter('ver_mj', 0), $request->getParameter('ver_mn', 0), $request->getParameter('ver_rev', 0)); $build->setReleased((bool) $request['isreleased']); $build->setLocked((bool) $request['locked']); if ($request['milestone'] && ($milestone = TBGContext::factory()->TBGMilestone($request['milestone']))) { $build->setMilestone($milestone); } else { $build->clearMilestone(); } if ($request['edition'] && ($edition = TBGContext::factory()->TBGEdition($request['edition']))) { $build->setEdition($edition); } else { $build->clearEdition(); } $release_date = null; if ($request['has_release_date']) { $release_date = mktime($request['release_hour'], $request['release_minute'], 1, $request['release_month'], $request['release_day'], $request['release_year']); } $build->setReleaseDate($release_date); switch ($request->getParameter('download', 'leave_file')) { case '0': $build->clearFile(); $build->setFileURL(''); break; case 'upload_file': if ($build->hasFile()) { $build->getFile()->delete(); $build->clearFile(); } $file = TBGContext::getRequest()->handleUpload('upload_file'); $build->setFile($file); $build->setFileURL(''); break; case 'url': $build->clearFile(); $build->setFileURL($request['file_url']); break; } if ($request['edition_id']) { $build->setEdition($edition); } if (!$build->getID()) { $build->setProject($this->selected_project); } $build->save(); } else { throw new Exception($i18n->__('You need to specify a name for the release')); } } else { throw new Exception($i18n->__('You do not have access to this project')); } } catch (Exception $e) { TBGContext::setMessage('build_error', $e->getMessage()); } $this->forward(TBGContext::getRouting()->generate('project_release_center', array('project_key' => $this->selected_project->getKey()))); } return $this->forward403($i18n->__("You don't have access to add releases")); }
<td id="header_username" valign="middle"> <?php if ($tbg_user->isGuest()) { ?> <a href="javascript:void(0);" onclick="showFadedBackdrop('<?php echo make_url('get_partial_for_backdrop', array('key' => 'login')); ?> ')"><?php echo __('You are not logged in'); ?> </a> <?php } else { ?> <?php $name = TBGContext::getUser()->getRealname() == '' ? TBGContext::getUser()->getBuddyname() : TBGContext::getUser()->getRealname(); ?> <?php echo link_tag(make_url('dashboard'), tbg_decodeUTF8($name)); ?> <?php } ?> </td> <td class="header_userlinks"> <div class="dropdown_separator"> <?php echo javascript_link_tag(image_tag('tabmenu_dropdown.png', array('class' => 'menu_dropdown')), array('onmouseover' => "")); ?> </div> </td>
<?php echo image_tag('spinning_16.gif', array('id' => 'move_issue_indicator', 'style' => 'display: none; margin-right: 5px;')); ?> <?php echo __('%move_issue% or %cancel%', array('%move_issue%' => '', '%cancel%' => '')); ?> <a href="javascript:void(0)" onclick="$('move_issue').hide();"><?php echo __('cancel'); ?> </a> </div> </div> </form> </li> <?php if (TBGContext::getUser()->hasPermission('candeleteissues')) { ?> <li><a href="javascript:void(0)" onClick="$('delete_issue').toggle();"><?php echo image_tag('icon_delete.png', array('style' => 'float: left; margin-right: 5px;')) . __("Permanently delete this issue"); ?> </a></li> <?php } ?> </ul> <div class="rounded_box borderless red" style="display: none;" id="delete_issue"> <b><?php echo __('Permanently delete this issue'); ?> </b> <p><?php
public function view() { $crit = new B2DBCriteria(); $crit->addWhere(TBGArticleViewsTable::ARTICLE_ID, $this->getID()); $crit->addWhere(TBGArticleViewsTable::USER_ID, TBGContext::getUser()->getID()); if (B2DB::getTable('TBGArticleViewsTable')->doCount($crit) == 0) { $crit = new B2DBCriteria(); $crit->addInsert(TBGArticleViewsTable::ARTICLE_ID, $this->getID()); $crit->addInsert(TBGArticleViewsTable::USER_ID, TBGContext::getUser()->getID()); $crit->addInsert(TBGArticleViewsTable::SCOPE, TBGContext::getScope()->getID()); B2DB::getTable('TBGArticleViewsTable')->doInsert($crit); } }
public static function getToggle($toggle) { return (bool) self::get(self::TOGGLE_PREFIX . $toggle, 'core', TBGContext::getScope()->getID(), TBGContext::getUser()->getID()); }
public function perform(TBGIssue $issue, $request = null) { switch ($this->_action_type) { case self::ACTION_ASSIGN_ISSUE_SELF: $issue->setAssignee(TBGContext::getUser()); break; case self::ACTION_SET_STATUS: if ($this->getTargetValue()) { $issue->setStatus(TBGContext::factory()->TBGStatus((int) $this->getTargetValue())); } else { $issue->setStatus($request->getParameter('status_id')); } break; case self::ACTION_SET_MILESTONE: if ($this->getTargetValue()) { $issue->setMilestone(TBGContext::factory()->TBGMilestone((int) $this->getTargetValue())); } else { $issue->setMilestone($request->getParameter('milestone_id')); } break; case self::ACTION_CLEAR_PRIORITY: $issue->setPriority(null); break; case self::ACTION_SET_PRIORITY: if ($this->getTargetValue()) { $issue->setPriority(TBGContext::factory()->TBGPriority((int) $this->getTargetValue())); } else { $issue->setPriority($request->getParameter('priority_id')); } break; case self::ACTION_CLEAR_PERCENT: $issue->setPercentCompleted(0); break; case self::ACTION_SET_PERCENT: if ($this->getTargetValue()) { $issue->setPercentCompleted((int) $this->getTargetValue()); } else { $issue->setPercentCompleted((int) $request->getParameter('percent_complete_id')); } break; case self::ACTION_CLEAR_RESOLUTION: $issue->setResolution(null); break; case self::ACTION_SET_RESOLUTION: if ($this->getTargetValue()) { $issue->setResolution(TBGContext::factory()->TBGResolution((int) $this->getTargetValue())); } else { $issue->setResolution($request->getParameter('resolution_id')); } break; case self::ACTION_CLEAR_REPRODUCABILITY: $issue->setReproducability(null); break; case self::ACTION_SET_REPRODUCABILITY: if ($this->getTargetValue()) { $issue->setReproducability(TBGContext::factory()->TBGReproducability((int) $this->getTargetValue())); } else { $issue->setReproducability($request->getParameter('reproducability_id')); } break; case self::ACTION_CLEAR_ASSIGNEE: $issue->unsetAssignee(); break; case self::ACTION_ASSIGN_ISSUE: if ($this->getTargetValue()) { $issue->setAssignee(TBGContext::factory()->TBGUser((int) $this->getTargetValue())); } else { $assignee = null; switch ($request->getParameter('assignee_type')) { case TBGIdentifiableClass::TYPE_USER: $assignee = TBGContext::factory()->TBGUser($request->getParameter('assignee_id')); break; case TBGIdentifiableClass::TYPE_TEAM: $assignee = TBGContext::factory()->TBGTeam($request->getParameter('assignee_id')); break; } if ((bool) $request->getParameter('assignee_teamup', false)) { $team = new TBGTeam(); $team->setName($assignee->getBuddyname() . ' & ' . TBGContext::getUser()->getBuddyname()); $team->setOndemand(true); $team->save(); $team->addMember($assignee); $team->addMember(TBGContext::getUser()); $assignee = $team; } $issue->setAssignee($assignee); } break; case self::ACTION_USER_START_WORKING: $issue->clearUserWorkingOnIssue(); if ($issue->getAssignee() instanceof TBGTeam && $issue->getAssignee()->isOndemand()) { $members = $issue->getAssignee()->getMembers(); $issue->startWorkingOnIssue(array_shift($members)); } else { $issue->startWorkingOnIssue($issue->getAssignee()); } break; case self::ACTION_USER_STOP_WORKING: if ($request->getParameter('did', 'nothing') == 'nothing') { $issue->clearUserWorkingOnIssue(); } else { $issue->stopWorkingOnIssue(); } break; } }
/** * Whether or not the current user can access the build * * @return boolean */ public function hasAccess() { return $this->getProject() instanceof TBGProject && $this->getProject()->canSeeAllBuilds() || TBGContext::getUser()->hasPermission('canseebuild', $this->getID()); }