php thebuggenie-core-framework-Settings类(方法)实例源码

下面列出了php thebuggenie-core-framework-Settings 类(方法)源码代码实例,从而了解它的用法。

作者:founderi    项目:thebuggeni   
public function clearUserScopes($user_id)
 {
     $crit = $this->getCriteria();
     $crit->addWhere(self::SCOPE, \thebuggenie\core\framework\Settings::getDefaultScopeID(), Criteria::DB_NOT_EQUALS);
     $crit->addWhere(self::USER_ID, $user_id);
     $this->doDelete($crit);
 }

作者:AzerothShar    项目:thebuggeni   
public function runResolve(framework\Request $request)
 {
     $theme = isset($request['theme_name']) ? $request['theme_name'] : framework\Settings::getThemeName();
     if ($request->hasParameter('css')) {
         $this->getResponse()->setContentType('text/css');
         if (!$request->hasParameter('theme_name')) {
             $basepath = THEBUGGENIE_PATH . 'public' . DS . 'css';
             $asset = THEBUGGENIE_PATH . 'public' . DS . 'css' . DS . $request->getParameter('css');
         } else {
             $basepath = THEBUGGENIE_PATH . 'themes';
             $asset = THEBUGGENIE_PATH . 'themes' . DS . $theme . DS . 'css' . DS . $request->getParameter('css');
         }
     } elseif ($request->hasParameter('js')) {
         $this->getResponse()->setContentType('text/javascript');
         if ($request->hasParameter('theme_name')) {
             $basepath = THEBUGGENIE_PATH . 'themes';
             $asset = THEBUGGENIE_PATH . 'themes' . DS . $theme . DS . 'js' . DS . $request->getParameter('js');
         } elseif ($request->hasParameter('module_name') && framework\Context::isModuleLoaded($request['module_name'])) {
             $module_path = framework\Context::isInternalModule($request['module_name']) ? THEBUGGENIE_INTERNAL_MODULES_PATH : THEBUGGENIE_MODULES_PATH;
             $basepath = $module_path . $request['module_name'] . DS . 'public' . DS . 'js';
             $asset = $module_path . $request['module_name'] . DS . 'public' . DS . 'js' . DS . $request->getParameter('js');
         } else {
             $basepath = THEBUGGENIE_PATH . 'public' . DS . 'js';
             $asset = THEBUGGENIE_PATH . 'public' . DS . 'js' . DS . $request->getParameter('js');
         }
     } else {
         throw new \Exception('The expected theme Asset type is not supported.');
     }
     $fileAsset = new AssetCollection(array(new FileAsset($asset, array(), $basepath)));
     $fileAsset->load();
     // Do not decorate the asset with the theme's header/footer
     $this->getResponse()->setDecoration(framework\Response::DECORATE_NONE);
     return $this->renderText($fileAsset->dump());
 }

作者:founderi    项目:thebuggeni   
public function do_execute()
 {
     /* Prepare variables */
     try {
         $project_id = $this->getProvidedArgument('projectid');
         $project_row = \thebuggenie\core\entities\tables\Projects::getTable()->getById($project_id, false);
         \thebuggenie\core\framework\Context::setScope(new \thebuggenie\core\entities\Scope($project_row[\thebuggenie\core\entities\tables\Projects::SCOPE]));
         $project = new \thebuggenie\core\entities\Project($project_id, $project_row);
     } catch (\Exception $e) {
         $this->cliEcho("The project with the ID " . $this->getProvidedArgument('projectid') . " does not exist\n", 'red', 'bold');
         exit;
     }
     $author = $this->getProvidedArgument('author');
     $new_rev = $this->getProvidedArgument('revno');
     $commit_msg = $this->getProvidedArgument('log');
     $changed = $this->getProvidedArgument('changed');
     $old_rev = $this->getProvidedArgument('oldrev', null);
     $date = $this->getProvidedArgument('date', null);
     $branch = $this->getProvidedArgument('branch', null);
     if (\thebuggenie\core\framework\Settings::get('access_method_' . $project->getKey()) == Vcs_integration::ACCESS_HTTP) {
         $this->cliEcho("This project uses the HTTP access method, and so access via the CLI has been disabled\n", 'red', 'bold');
         exit;
     }
     if ($old_rev === null && !ctype_digit($new_rev)) {
         $this->cliEcho("Error: if only the new revision is specified, it must be a number so that old revision can be calculated from it (by substracting 1 from new revision number).");
     } else {
         if ($old_rev === null) {
             $old_rev = $new_rev - 1;
         }
     }
     $output = Vcs_integration::processCommit($project, $commit_msg, $old_rev, $new_rev, $date, $changed, $author, $branch);
     $this->cliEcho($output);
 }

作者:founderi    项目:thebuggeni   
public function loadFixtures(\thebuggenie\core\entities\Scope $scope)
 {
     foreach (IssueTypes::getTable()->getAllIDsByScopeID($scope->getID()) as $issuetype_id) {
         $crit = $this->getCriteria();
         $crit->addInsert(self::SCOPE, $scope->getID());
         $crit->addInsert(self::WORKFLOW_ID, \thebuggenie\core\framework\Settings::getCoreWorkflow()->getID());
         $crit->addInsert(self::WORKFLOW_SCHEME_ID, \thebuggenie\core\framework\Settings::getCoreWorkflowScheme()->getID());
         $crit->addInsert(self::ISSUETYPE_ID, $issuetype_id);
         $this->doInsert($crit);
     }
 }

作者:JonathanR    项目:thebuggeni   
/**
  * Logs the user out
  *
  * @param \thebuggenie\core\framework\Request $request
  *
  * @return bool
  */
 public function runLogout(framework\Request $request)
 {
     if ($this->getUser() instanceof entities\User) {
         framework\Logging::log('Setting user logout state');
         $this->getUser()->setOffline();
     }
     framework\Context::logout();
     if ($request->isAjaxCall()) {
         return $this->renderJSON(array('status' => 'logout ok', 'url' => framework\Context::getRouting()->generate(framework\Settings::getLogoutReturnRoute())));
     }
     $this->forward(framework\Context::getRouting()->generate(framework\Settings::getLogoutReturnRoute()));
 }

作者:founderi    项目:thebuggeni   
/**
  * @covers \thebuggenie\core\framework\Context::isInstallmode
  * @covers \thebuggenie\core\framework\Context::checkInstallMode
  */
 public function testInstallMode()
 {
     $installed_file = THEBUGGENIE_PATH . 'installed';
     if (file_exists($installed_file)) {
         unlink($installed_file);
     }
     \thebuggenie\core\framework\Context::checkInstallMode();
     $this->assertTrue(\thebuggenie\core\framework\Context::isInstallmode());
     file_put_contents($installed_file, \thebuggenie\core\framework\Settings::getMajorVer() . "." . \thebuggenie\core\framework\Settings::getMinorVer() . "." . \thebuggenie\core\framework\Settings::getRevision() . ", installed today");
     \thebuggenie\core\framework\Context::checkInstallMode();
     $this->assertFalse(\thebuggenie\core\framework\Context::isInstallmode());
 }

作者:nrense    项目:module-mobil   
protected function _install($scope)
 {
     if ($scope == framework\Settings::getDefaultScopeID()) {
         $mobile_css_path = THEBUGGENIE_PATH . THEBUGGENIE_PUBLIC_FOLDER_NAME . DS . 'css' . DS . 'mobile.css';
         if (!is_writable(pathinfo($mobile_css_path, PATHINFO_DIRNAME))) {
             throw new framework\exceptions\ConfigurationException("Cannot save the file {$mobile_css_path}", framework\exceptions\ConfigurationException::PERMISSION_DENIED);
         }
         if (file_exists($mobile_css_path)) {
             unlink($mobile_css_path);
         }
         symlink(THEBUGGENIE_MODULES_PATH . 'mobile' . DS . 'css' . DS . 'mobile.css', $mobile_css_path);
     }
 }

作者:pkdevbox    项目:thebuggeni   
public function do_execute()
 {
     $hostname = $this->getProvidedArgument('hostname');
     $this->cliEcho('Checking scope availability ...');
     if (tables\ScopeHostnames::getTable()->getScopeIDForHostname($hostname) === null) {
         $this->cliEcho("available!\n");
         $this->cliEcho("Creating scope ...");
         $scope = new entities\Scope();
         $scope->addHostname($hostname);
         $scope->setName($this->getProvidedArgument('shortname'));
         $uploads_enabled = $this->getProvidedArgument('enable_uploads', 'yes') == 'yes';
         $scope->setUploadsEnabled((bool) $uploads_enabled);
         $scope->setMaxUploadLimit($this->getProvidedArgument('upload_limit', 0));
         $scope->setMaxProjects($this->getProvidedArgument('projects', 0));
         $scope->setMaxUsers($this->getProvidedArgument('users', 0));
         $scope->setMaxTeams($this->getProvidedArgument('teams', 0));
         $scope->setMaxWorkflowsLimit($this->getProvidedArgument('workflows', 0));
         $scope->setEnabled();
         $this->cliEcho(".");
         $scope->save();
         $this->cliEcho(".done!\n");
         $admin_user = $this->getProvidedArgument('scope_admin');
         if ($admin_user) {
             $user = entities\User::getByUsername($admin_user);
             if ($user instanceof entities\User) {
                 $this->cliEcho("Adding user {$admin_user} to scope\n");
                 $admin_group_id = (int) framework\Settings::get(framework\Settings::SETTING_ADMIN_GROUP, 'core', $scope->getID());
                 tables\UserScopes::getTable()->addUserToScope($user->getID(), $scope->getID(), $admin_group_id, true);
             } else {
                 $this->cliEcho("Could not add user {$admin_user} to scope (username not found)\n");
             }
         }
         if ($this->getProvidedArgument('remove_admin', 'no') == 'yes') {
             $this->cliEcho("Removing administrator user from scope\n");
             tables\UserScopes::getTable()->removeUserFromScope(1, $scope->getID());
         }
         foreach (framework\Context::getModules() as $module) {
             $module_name = $module->getName();
             if ($module_name == 'publish') {
                 continue;
             }
             if ($this->getProvidedArgument("install_module_{$module_name}", "no") == 'yes') {
                 $this->cliEcho("Installing module {$module_name}\n");
                 entities\Module::installModule($module_name, $scope);
             }
         }
     } else {
         $this->cliEcho("not available\n", 'red');
     }
     $this->cliEcho("\n");
 }

作者:founderi    项目:thebuggeni   
public function do_execute()
 {
     $this->cliEcho("\n");
     $this->cliEcho("Revert authentication backend\n", 'white', 'bold');
     $this->cliEcho("This command is useful if you've managed to lock yourself.\n");
     $this->cliEcho("out due to an authentication backend change gone bad.\n\n");
     if (\thebuggenie\core\framework\Settings::getAuthenticationBackend() == 'tbg' || \thebuggenie\core\framework\Settings::getAuthenticationBackend() == null) {
         $this->cliEcho("You are currently using the default authentication backend.\n\n");
     } else {
         $this->cliEcho("Please type 'yes' if you want to revert to the default authentication backend: ");
         $this->cliEcho("\n");
         if ($this->getInput() == 'yes') {
             \thebuggenie\core\framework\Settings::saveSetting(\thebuggenie\core\framework\Settings::SETTING_AUTH_BACKEND, 'tbg');
             $this->cliEcho("Authentication backend reverted.\n\n");
         } else {
             $this->cliEcho("No changes made.\n\n");
         }
     }
 }

作者:founderi    项目:thebuggeni   
public function componentLeftmenu()
 {
     $config_sections = framework\Settings::getConfigSections(framework\Context::getI18n());
     $breadcrumblinks = array();
     foreach ($config_sections as $key => $sections) {
         foreach ($sections as $section) {
             if ($key == framework\Settings::CONFIGURATION_SECTION_MODULES) {
                 $url = is_array($section['route']) ? make_url($section['route'][0], $section['route'][1]) : make_url($section['route']);
                 $breadcrumblinks[] = array('url' => $url, 'title' => $section['description']);
             } else {
                 $breadcrumblinks[] = array('url' => make_url($section['route']), 'title' => $section['description']);
             }
         }
     }
     $this->breadcrumblinks = $breadcrumblinks;
     $this->config_sections = $config_sections;
     if ($this->selected_section == framework\Settings::CONFIGURATION_SECTION_MODULES) {
         if (framework\Context::getRouting()->getCurrentRouteName() == 'configure_modules') {
             $this->selected_subsection = 'core';
         } else {
             $this->selected_subsection = framework\Context::getRequest()->getParameter('config_module');
         }
     }
 }

作者:JonathanR    项目:thebuggeni   
public function setContentSyntax($syntax)
 {
     if (!is_numeric($syntax)) {
         $syntax = framework\Settings::getSyntaxValue($syntax);
     }
     $this->_content_syntax = $syntax;
 }

作者:pkdevbox    项目:thebuggeni   
?>
openid_providers.small/openid.ico.png'); }
    #regular-signin-button.persona-button span:after{ background-image: url('<?php 
echo $webroot . 'iconsets/' . \thebuggenie\core\framework\Settings::getIconsetName() . '/';
?>
footer_logo.png'); }
    #forgot_password_username { background-image: url('<?php 
echo $webroot . 'iconsets/' . \thebuggenie\core\framework\Settings::getIconsetName() . '/';
?>
user_mono.png'); }
    #planning_filter_title_input { background-image: url('<?php 
echo $webroot . 'iconsets/' . \thebuggenie\core\framework\Settings::getIconsetName() . '/';
?>
icon-mono-search.png'); }
    .login_popup .article h1 { background: url('<?php 
echo $webroot . 'iconsets/' . \thebuggenie\core\framework\Settings::getIconsetName() . '/';
?>
logo_48.png') 0 0 no-repeat; }

    table.results_normal th.sort_asc { background-image: url('<?php 
echo $webroot;
?>
iconsets/oxygen/sort_down.png') !important; padding-left: 25px !important; }
    table.results_normal th.sort_desc { background-image: url('<?php 
echo $webroot;
?>
iconsets/oxygen/sort_up.png') !important; padding-left: 25px !important; }

    .module .rating { background-image:url('<?php 
echo $webroot;
?>

作者:nrense    项目:thebuggeni   
} else {
    ?>
    <?php 
    if ($article->getArticleType() == \thebuggenie\modules\publish\entities\Article::TYPE_MANUAL) {
        echo get_spaced_name($article->getManualName());
    } else {
        $namespaces = explode(':', $article_name);
        if (count($namespaces) > 1 && $namespaces[0] == 'Category') {
            array_shift($namespaces);
            echo '<span class="faded_out blue">Category:</span>';
        }
        if (\thebuggenie\core\framework\Context::isProjectContext() && count($namespaces) > 1 && mb_strtolower($namespaces[0]) == \thebuggenie\core\framework\Context::getCurrentProject()->getKey()) {
            array_shift($namespaces);
            echo '<span>', \thebuggenie\core\framework\Context::getCurrentProject()->getName(), ':</span>';
        }
        echo \thebuggenie\core\framework\Settings::get('allow_camelcase_links', 'publish', \thebuggenie\core\framework\Context::getScope()->getID(), 0) ? get_spaced_name(implode(':', $namespaces)) : implode(':', $namespaces);
    }
    ?>
    <?php 
}
?>
    <?php 
if ($article->getID() && $mode) {
    switch ($mode) {
        /* case 'edit':
           ?><span class="faded_out"><?php echo __('%article_name ~ Edit', array('%article_name' => '')); ?></span><?php
           break; */
        case 'history':
            ?>
<span class="faded_out"><?php 
            echo __('%article_name ~ History', array('%article_name' => ''));

作者:nrense    项目:thebuggeni   
<?php

\thebuggenie\core\framework\Context::loadLibrary('publish/publish');
?>
<div class="article syntax_<?php 
echo \thebuggenie\core\framework\Settings::getSyntaxClass($article->getContentSyntax());
?>
">
    <?php 
if ($show_title) {
    ?>
        <?php 
    include_component('publish/header', array('article_name' => $article->getName(), 'article' => $article, 'show_actions' => $show_actions, 'mode' => $mode, 'embedded' => $embedded));
    ?>
    <?php 
}
?>
    <?php 
if ($show_details && $show_article) {
    ?>
        <div class="details">
            <?php 
    if (isset($redirected_from)) {
        ?>
                <div class="redirected_from">&rarr; <?php 
        echo __('Redirected from %article_name', array('%article_name' => link_tag(make_url('publish_article_edit', array('article_name' => $redirected_from)), get_spaced_name($redirected_from))));
        ?>
</div>
            <?php 
    }
    ?>

作者:founderi    项目:thebuggeni   
public function canUserSet(\thebuggenie\core\entities\User $user)
 {
     $retval = $user->hasPermission($this->getPermissionsKey(), $this->getID(), 'core');
     $retval = $retval === null ? $user->hasPermission($this->getPermissionsKey(), 0, 'core') : $retval;
     return $retval !== null ? $retval : \thebuggenie\core\framework\Settings::isPermissive();
 }

作者:RTechSof    项目:thebuggeni   
/**
  * Handles an uploaded file, stores it to the correct folder, adds an entry
  * to the database and returns a \thebuggenie\core\entities\File object
  *
  * @param string $key The request parameter the file was sent as
  *
  * @return \thebuggenie\core\entities\File The File 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 (Settings::isUploadsEnabled()) {
                 Logging::log('Uploads enabled');
                 if ($thefile['error'] == UPLOAD_ERR_OK) {
                     Logging::log('No upload errors');
                     if (filesize($thefile['tmp_name']) > Settings::getUploadsEffectiveMaxSize(true)) {
                         throw new \Exception(Context::getI18n()->__('You cannot upload files bigger than %max_size MB', array('%max_size' => Settings::getUploadsEffectiveMaxSize())));
                     }
                     Logging::log('Upload filesize ok');
                     $extension = mb_substr(basename($thefile['name']), mb_strrpos(basename($thefile['name']), '.'));
                     if ($extension == '') {
                         Logging::log('OOps, could not determine upload filetype', 'main', Logging::LEVEL_WARNING_RISK);
                         //throw new \Exception(Context::getI18n()->__('Could not determine filetype'));
                     } else {
                         Logging::log('Checking uploaded file extension');
                         $extension = mb_substr($extension, 1);
                         $upload_extensions = Settings::getUploadsExtensionsList();
                         if (Settings::getUploadsRestrictionMode() == 'blacklist') {
                             Logging::log('... using blacklist');
                             foreach ($upload_extensions as $an_ext) {
                                 if (mb_strtolower(trim($extension)) == mb_strtolower(trim($an_ext))) {
                                     Logging::log('Upload extension not ok');
                                     throw new \Exception(Context::getI18n()->__('This filetype is not allowed'));
                                 }
                             }
                             Logging::log('Upload extension ok');
                         } else {
                             Logging::log('... using whitelist');
                             $is_ok = false;
                             foreach ($upload_extensions as $an_ext) {
                                 if (mb_strtolower(trim($extension)) == mb_strtolower(trim($an_ext))) {
                                     Logging::log('Upload extension ok');
                                     $is_ok = true;
                                     break;
                                 }
                             }
                             if (!$is_ok) {
                                 Logging::log('Upload extension not ok');
                                 throw new \Exception(Context::getI18n()->__('This filetype is not allowed'));
                             }
                         }
                         /*if (in_array(mb_strtolower(trim($extension)), array('php', 'asp')))
                           {
                               Logging::log('Upload extension is php or asp');
                               throw new \Exception(Context::getI18n()->__('This filetype is not allowed'));
                           }*/
                     }
                     if (is_uploaded_file($thefile['tmp_name'])) {
                         Logging::log('Uploaded file is uploaded');
                         $new_filename = Context::getUser()->getID() . '_' . NOW . '_' . basename($thefile['name']);
                         if (Settings::getUploadStorage() == 'files') {
                             $files_dir = Settings::getUploadsLocalpath();
                             $filename = $files_dir . $new_filename;
                         } else {
                             $filename = $thefile['tmp_name'];
                         }
                         Logging::log('Moving uploaded file to ' . $filename);
                         if (Settings::getUploadStorage() == 'files' && !move_uploaded_file($thefile['tmp_name'], $filename)) {
                             Logging::log('Moving uploaded file failed!');
                             throw new \Exception(Context::getI18n()->__('An error occured when saving the file'));
                         } else {
                             Logging::log('Upload complete and ok, storing upload status and returning filename ' . $new_filename);
                             $content_type = File::getMimeType($filename);
                             $file = new File();
                             $file->setRealFilename($new_filename);
                             $file->setOriginalFilename(basename($thefile['name']));
                             $file->setContentType($content_type);
                             $file->setDescription($this->getParameter($key . '_description'));
                             $file->setUploadedBy(Context::getUser());
                             if (Settings::getUploadStorage() == 'database') {
                                 $file->setContent(file_get_contents($filename));
                             }
                             $file->save();
                             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 {
                         Logging::log('Uploaded file was not uploaded correctly');
                         throw new \Exception(Context::getI18n()->__('The file was not uploaded correctly'));
                     }
                 } else {
                     Logging::log('Upload error: ' . $thefile['error']);
//.........这里部分代码省略.........

作者:RTechSof    项目:thebuggeni   
public function processIncomingEmailAccount(IncomingEmailAccount $account)
 {
     $count = 0;
     if ($emails = $account->getUnprocessedEmails()) {
         try {
             $current_user = framework\Context::getUser();
             foreach ($emails as $email) {
                 $user = $this->getOrCreateUserFromEmailString($email->from);
                 if ($user instanceof User) {
                     if (framework\Context::getUser()->getID() != $user->getID()) {
                         framework\Context::switchUserContext($user);
                     }
                     $message = $account->getMessage($email);
                     $data = $message->getBodyPlain() ? $message->getBodyPlain() : strip_tags($message->getBodyHTML());
                     if ($data) {
                         if (mb_detect_encoding($data, 'UTF-8', true) === false) {
                             $data = utf8_encode($data);
                         }
                         $new_data = '';
                         foreach (explode("\n", $data) as $line) {
                             $line = trim($line);
                             if ($line) {
                                 $line = preg_replace('/^(_{2,}|-{2,})$/', "<hr>", $line);
                                 $new_data .= $line . "\n";
                             } else {
                                 $new_data .= "\n";
                             }
                         }
                         $data = nl2br($new_data, false);
                     }
                     // Parse the subject, and obtain the issues.
                     $parsed_commit = Issue::getIssuesFromTextByRegex(mb_decode_mimeheader($email->subject));
                     $issues = $parsed_commit["issues"];
                     // If any issues were found, add new comment to each issue.
                     if ($issues) {
                         foreach ($issues as $issue) {
                             $text = preg_replace('#(^\\w.+:\\n)?(^>.*(\\n|$))+#mi', "", $data);
                             $text = trim($text);
                             if (!$this->processIncomingEmailCommand($text, $issue) && $user->canPostComments()) {
                                 $comment = new Comment();
                                 $comment->setContent($text);
                                 $comment->setPostedBy($user);
                                 $comment->setTargetID($issue->getID());
                                 $comment->setTargetType(Comment::TYPE_ISSUE);
                                 $comment->save();
                             }
                         }
                     } else {
                         if ($user->canReportIssues($account->getProject())) {
                             $issue = new Issue();
                             $issue->setProject($account->getProject());
                             $issue->setTitle(mb_decode_mimeheader($email->subject));
                             $issue->setDescription($data);
                             $issue->setPostedBy($user);
                             $issue->setIssuetype($account->getIssuetype());
                             $issue->save();
                             // Append the new issue to the list of affected issues. This
                             // is necessary in order to process the attachments properly.
                             $issues[] = $issue;
                         }
                     }
                     // If there was at least a single affected issue, and mail
                     // contains attachments, add those attachments to related issues.
                     if ($issues && $message->hasAttachments()) {
                         foreach ($message->getAttachments() as $attachment_no => $attachment) {
                             echo 'saving attachment ' . $attachment_no;
                             $name = $attachment['filename'];
                             $new_filename = framework\Context::getUser()->getID() . '_' . NOW . '_' . basename($name);
                             if (framework\Settings::getUploadStorage() == 'files') {
                                 $files_dir = framework\Settings::getUploadsLocalpath();
                                 $filename = $files_dir . $new_filename;
                             } else {
                                 $filename = $name;
                             }
                             Logging::log('Creating issue attachment ' . $filename . ' from attachment ' . $attachment_no);
                             echo 'Creating issue attachment ' . $filename . ' from attachment ' . $attachment_no;
                             $content_type = $attachment['type'] . '/' . $attachment['subtype'];
                             $file = new File();
                             $file->setRealFilename($new_filename);
                             $file->setOriginalFilename(basename($name));
                             $file->setContentType($content_type);
                             $file->setDescription($name);
                             $file->setUploadedBy(framework\Context::getUser());
                             if (framework\Settings::getUploadStorage() == 'database') {
                                 $file->setContent($attachment['data']);
                             } else {
                                 Logging::log('Saving file ' . $new_filename . ' with content from attachment ' . $attachment_no);
                                 file_put_contents($new_filename, $attachment['data']);
                             }
                             $file->save();
                             // Attach file to each related issue.
                             foreach ($issues as $issue) {
                                 $issue->attachFile($file);
                             }
                         }
                     }
                     $count++;
                 }
             }
         } catch (\Exception $e) {
//.........这里部分代码省略.........

作者:underblaz    项目:thebuggenie-4.1.   
protected function _getOrGenerateRssKey()
 {
     static $key;
     $key = $key === null ? framework\Settings::getUserSetting($this->getID(), framework\Settings::USER_RSS_KEY) : $key;
     if ($key === null) {
         $key = $this->regenerateRssKey();
     }
     return $key;
 }

作者:founderi    项目:thebuggeni   
public function isDefaultUserGroup()
 {
     return (bool) (\thebuggenie\core\framework\Settings::getDefaultUser()->getGroupID() == $this->getID());
 }

作者:AzerothShar    项目:thebuggeni   
public static function processCommit(\thebuggenie\core\entities\Project $project, $commit_msg, $old_rev, $new_rev, $date = null, $changed, $author, $branch = null, \Closure $callback = null)
 {
     $output = '';
     framework\Context::setCurrentProject($project);
     if ($project->isArchived()) {
         return;
     }
     if (Commits::getTable()->isProjectCommitProcessed($new_rev, $project->getID())) {
         return;
     }
     try {
         framework\Context::getI18n();
     } catch (\Exception $e) {
         framework\Context::reinitializeI18n(null);
     }
     // Is VCS Integration enabled?
     if (framework\Settings::get('vcs_mode_' . $project->getID(), 'vcs_integration') == self::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 = \thebuggenie\core\entities\Issue::getIssuesFromTextByRegex($commit_msg);
     $issues = $parsed_commit["issues"];
     $transitions = $parsed_commit["transitions"];
     // 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
      */
     // a)
     $user = \thebuggenie\core\entities\tables\Users::getTable()->getByEmail($author);
     if (!$user instanceof \thebuggenie\core\entities\User && preg_match("/(?<=<)(.*)(?=>)/", $author, $matches)) {
         $email = $matches[0];
         // a2)
         $user = \thebuggenie\core\entities\tables\Users::getTable()->getByEmail($email);
         if (!$user instanceof \thebuggenie\core\entities\User) {
             // Not found by email
             preg_match("/(?<=^)(.*)(?= <)/", $author, $matches);
             $author = $matches[0];
         }
     }
     // b)
     if (!$user instanceof \thebuggenie\core\entities\User) {
         $user = \thebuggenie\core\entities\tables\Users::getTable()->getByRealname($author);
     }
     // c)
     if (!$user instanceof \thebuggenie\core\entities\User) {
         $user = \thebuggenie\core\entities\tables\Users::getTable()->getByBuddyname($author);
     }
     // d)
     if (!$user instanceof \thebuggenie\core\entities\User) {
         $user = \thebuggenie\core\entities\tables\Users::getTable()->getByUsername($author);
     }
     // e)
     if (!$user instanceof \thebuggenie\core\entities\User) {
         $user = framework\Settings::getDefaultUser();
     }
     framework\Context::setUser($user);
     framework\Settings::forceSettingsReload();
     framework\Context::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 Commit();
     $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);
     }
     if ($callback !== null) {
         $commit = $callback($commit);
     }
     $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 IssueLink();
         $inst->setIssue($issue);
//.........这里部分代码省略.........


问题


面经


文章

微信
公众号

扫码关注公众号