本文整理汇总了PHP中TBGContext::getUser方法的典型用法代码示例。如果您正苦于以下问题:PHP TBGContext::getUser方法的具体用法?PHP TBGContext::getUser怎么用?PHP TBGContext::getUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TBGContext
的用法示例。
在下文中一共展示了TBGContext::getUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveEstimate
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);
}
示例2: componentAccountSettings
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();
}
示例3: getAvailableUserViews
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;
}
示例4: saveFile
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();
}
示例5: saveSearch
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;
}
示例6: addLink
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();
}
示例7: runEditSavedSearch
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));
}
}
示例8: tbg_formatTime
/**
* 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);
//.........这里部分代码省略.........
示例9: perform
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;
//.........这里部分代码省略.........
示例10: hasAccess
/**
* 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());
}
示例11: handleUpload
/**
* 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;
//.........这里部分代码省略.........
示例12: isValid
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;
}
}
示例13: getAccessLevel
public function getAccessLevel($section, $module)
{
return TBGContext::getUser()->canSaveConfiguration($section, $module) ? TBGSettings::ACCESS_FULL : TBGSettings::ACCESS_READ;
}
示例14: hasAccess
public function hasAccess()
{
return (bool) (TBGContext::getUser()->hasPageAccess('clientlist') || TBGContext::getUser()->isMemberOfClient($this));
}
示例15: getPredefinedBreadcrumbLinks
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;
}