本文整理汇总了PHP中TBGSettings::getDefaultUser方法的典型用法代码示例。如果您正苦于以下问题:PHP TBGSettings::getDefaultUser方法的具体用法?PHP TBGSettings::getDefaultUser怎么用?PHP TBGSettings::getDefaultUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TBGSettings
的用法示例。
在下文中一共展示了TBGSettings::getDefaultUser方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isDefaultUserGroup
public function isDefaultUserGroup()
{
return (bool) (TBGSettings::getDefaultUser()->getGroupID() == $this->getID());
}
示例2: processCommit
public static function processCommit(TBGProject $project, $commit_msg, $old_rev, $new_rev, $date = null, $changed, $author, $branch = null)
{
$output = '';
TBGContext::setCurrentProject($project);
if ($project->isArchived()) {
return;
}
try {
TBGContext::getI18n();
} catch (Exception $e) {
TBGContext::reinitializeI18n(null);
}
// Is VCS Integration enabled?
if (TBGSettings::get('vcs_mode_' . $project->getID(), 'vcs_integration') == TBGVCSIntegration::MODE_DISABLED) {
$output .= '[VCS ' . $project->getKey() . '] This project does not use VCS Integration' . "\n";
return $output;
}
// Parse the commit message, and obtain the issues and transitions for issues.
$parsed_commit = TBGIssue::getIssuesFromTextByRegex($commit_msg);
$issues = $parsed_commit["issues"];
$transitions = $parsed_commit["transitions"];
// If no issues exist, we may not be able to continue
// if (count($issues) == 0)
// {
// $output .= '[VCS '.$project->getKey().'] This project only accepts commits which affect issues' . "\n";
// return $output;
// }
// Build list of affected files
$file_lines = preg_split('/[\\n\\r]+/', $changed);
$files = array();
foreach ($file_lines as $aline) {
$action = mb_substr($aline, 0, 1);
if ($action == "A" || $action == "U" || $action == "D" || $action == "M") {
$theline = trim(mb_substr($aline, 1));
$files[] = array($action, $theline);
}
}
// Find author of commit, fallback is guest
/*
* Some VCSes use a different format of storing the committer's name. Systems like bzr, git and hg use the format
* Joe Bloggs <me@example.com>, instead of a classic username. Therefore a user will be found via 4 queries:
* a) First we extract the email if there is one, and find a user with that email
* b) If one is not found - or if no email was specified, then instead test against the real name (using the name part if there was an email)
* c) the username or full name is checked against the friendly name field
* d) and if we still havent found one, then we check against the username
* e) and if we STILL havent found one, we use the guest user
*/
if (preg_match("/(?<=<)(.*)(?=>)/", $author, $matches)) {
$email = $matches[0];
// a)
$user = TBGUsersTable::getTable()->getByEmail($email);
if (!$user instanceof TBGUser) {
// Not found by email
preg_match("/(?<=^)(.*)(?= <)/", $author, $matches);
$author = $matches[0];
}
}
// b)
if (!$user instanceof TBGUser) {
$user = TBGUsersTable::getTable()->getByRealname($author);
}
// c)
if (!$user instanceof TBGUser) {
$user = TBGUsersTable::getTable()->getByBuddyname($author);
}
// d)
if (!$user instanceof TBGUser) {
$user = TBGUsersTable::getTable()->getByUsername($author);
}
// e)
if (!$user instanceof TBGUser) {
$user = TBGSettings::getDefaultUser();
}
TBGContext::setUser($user);
TBGSettings::forceSettingsReload();
TBGContext::cacheAllPermissions();
$output .= '[VCS ' . $project->getKey() . '] Commit to be logged by user ' . $user->getName() . "\n";
if ($date == null) {
$date = NOW;
}
// Create the commit data
$commit = new TBGVCSIntegrationCommit();
$commit->setAuthor($user);
$commit->setDate($date);
$commit->setLog($commit_msg);
$commit->setPreviousRevision($old_rev);
$commit->setRevision($new_rev);
$commit->setProject($project);
if ($branch !== null) {
$data = 'branch:' . $branch;
$commit->setMiscData($data);
}
$commit->save();
$output .= '[VCS ' . $project->getKey() . '] Commit logged with revision ' . $commit->getRevision() . "\n";
// Iterate over affected issues and update them.
foreach ($issues as $issue) {
$inst = new TBGVCSIntegrationIssueLink();
$inst->setIssue($issue);
$inst->setCommit($commit);
$inst->save();
//.........这里部分代码省略.........