本文整理汇总了PHP中TBGContext::getModule方法的典型用法代码示例。如果您正苦于以下问题:PHP TBGContext::getModule方法的具体用法?PHP TBGContext::getModule怎么用?PHP TBGContext::getModule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TBGContext
的用法示例。
在下文中一共展示了TBGContext::getModule方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: do_execute
public function do_execute()
{
$mailing = TBGContext::getModule('mailing');
if (!$mailing->isOutgoingNotificationsEnabled()) {
$this->cliEcho("Outgoing email notifications are disabled.\n", 'red', 'bold');
$this->cliEcho("\n");
return;
}
if (!$mailing->getMailingUrl()) {
$this->cliEcho("You must configure the mailing url via the web interface before you can use this feature.\n", 'red', 'bold');
$this->cliEcho("\n");
return;
}
$this->cliEcho("Processing mail queue ... \n", 'white', 'bold');
$limit = $this->getProvidedArgument('limit', null);
$messages = TBGMailQueueTable::getTable()->getQueuedMessages($limit);
$this->cliEcho("Email(s) to process: ");
$this->cliEcho(count($messages) . "\n", 'white', 'bold');
if ($this->getProvidedArgument('test', 'no') == 'no') {
if (count($messages) > 0) {
// $mailer = $mailing->getMailer();
$processed_messages = array();
$failed_messages = 0;
try {
foreach ($messages as $message_id => $message) {
$retval = $mailing->send($message);
$processed_messages[] = $message_id;
if (!$retval) {
$failed_messages++;
}
}
} catch (Exception $e) {
throw $e;
}
if (count($processed_messages)) {
TBGMailQueueTable::getTable()->deleteProcessedMessages($processed_messages);
$this->cliEcho("Emails successfully processed: ");
$this->cliEcho(count($messages) . "\n", 'green', 'bold');
if ($failed_messages > 0) {
$this->cliEcho("Emails processed with error(s): ");
$this->cliEcho($failed_messages . "\n", 'red', 'bold');
}
}
}
} else {
$this->cliEcho("Not processing queue...\n");
}
}
示例2: _uninstallModule
protected function _uninstallModule($module_name)
{
$this->cliEcho("Uninstall module\n", 'green', 'bold');
try {
if (!$module_name || !file_exists(THEBUGGENIE_MODULES_PATH . $module_name . DS . 'module')) {
throw new Exception("Please provide a valid module name");
} elseif (!TBGContext::isModuleLoaded($module_name)) {
throw new Exception("This module is not installed");
} else {
$this->cliEcho("Removing {$module_name} ...");
TBGContext::getModule($module_name)->uninstall();
$this->cliEcho(' ok!', 'green', 'bold');
$this->cliEcho("\n");
}
} catch (Exception $e) {
$this->cliEcho($e->getMessage() . "\n", 'red');
}
}
示例3: do_execute
public function do_execute()
{
/* Prepare variables */
$project = $this->getProvidedArgument('projectid');
$author = $this->getProvidedArgument('author');
$new_rev = $this->getProvidedArgument('revno');
$commit_msg = $this->getProvidedArgument('log');
$changed = $this->getProvidedArgument('changed');
$old_rev = $this->getProvidedArgument('oldrev', $new_rev - 1);
$date = $this->getProvidedArgument('date', null);
if (TBGContext::getModule('vcs_integration')->isUsingHTTPMethod()) {
$this->cliEcho("This access method has been disallowed\n", 'red', 'bold');
exit;
}
if (!is_numeric($new_rev) && is_numeric($old_rev) || is_numeric($new_rev) && !is_numeric($old_rev)) {
$this->cliEcho("If the old revision is specified, it must be the same format as the new revision (number or hash)\n", 'red', 'bold');
exit;
}
$output = TBGContext::getModule('vcs_integration')->addNewCommit($project, $commit_msg, $old_rev, $new_rev, $date, $changed, $author);
$this->cliEcho($output);
}
示例4: runDeleteArticle
/**
* Delete an article
*
* @param TBGRequest $request
*/
public function runDeleteArticle(TBGRequest $request)
{
try {
if (!$this->article instanceof TBGWikiArticle) {
throw new Exception($this->getI18n()->__('This article does not exist'));
}
if (!TBGContext::getModule('publish')->canUserDeleteArticle($this->article->getName())) {
throw new Exception($this->getI18n()->__('You do not have permission to delete this article'));
}
if (!$request['article_name']) {
throw new Exception($this->getI18n()->__('Please specify an article name'));
} else {
TBGWikiArticle::deleteByName($request['article_name']);
}
} catch (Exception $e) {
$this->getResponse()->setHttpStatus(400);
return $this->renderJSON(array('title' => $this->getI18n()->__('An error occured'), 'error' => $e->getMessage()));
}
return $this->renderJSON(array('message' => $this->getI18n()->__('The article was deleted')));
}
示例5: canEdit
public function canEdit()
{
return TBGContext::getModule('publish')->canUserEditArticle($this->getName());
}
示例6: runAddCommitGitorious
public function runAddCommitGitorious(TBGRequest $request)
{
if (!TBGContext::getModule('vcs_integration')->isUsingHTTPMethod()) {
echo 'Error: This access method has been disallowed';
exit;
}
$passkey = TBGContext::getRequest()->getParameter('passkey');
if ($passkey != TBGContext::getModule('vcs_integration')->getSetting('vcs_passkey')) {
echo 'Error: Invalid passkey';
exit;
}
$project = TBGContext::getRequest()->getParameter('project');
$data = TBGContext::getRequest()->getParameter('payload', null, false);
if (empty($data) || $data == null) {
die('Error: Invalid data');
}
if (!function_exists('json_decode')) {
die('Error: Gitorious support requires either PHP 5.2.0 or later, or the json PECL module version 1.2.0 or later for prior versions of PHP');
}
$entries = json_decode($data);
echo $project;
$previous = $entries->before;
// Parse each commit individually
foreach (array_reverse($entries->commits) as $commit) {
$email = $commit->author->email;
$author = $commit->author->name;
$new_rev = $commit->id;
$old_rev = $previous;
$commit_msg = $commit->message;
$time = strtotime($commit->timestamp);
//$f_issues = array_unique($f_issues[3]);
//$file_lines = preg_split('/[\n\r]+/', $changed);
//$files = array();
echo TBGContext::getModule('vcs_integration')->addNewCommit($project, $commit_msg, $old_rev, $previous, $time, "", $author);
$previous = $new_rev;
exit;
}
}
示例7: make_url
<?php
} else {
?>
<h4>
<div class="button button-green" style="float: right;" onclick="TBG.Main.Helpers.Backdrop.show('<?php
echo make_url('get_partial_for_backdrop', array('key' => 'mailing_editincomingemailaccount', 'project_id' => $project->getId()));
?>
');"><?php
echo __('Add new account');
?>
</div>
<?php
echo __('Incoming email accounts');
?>
</h4>
<div id="mailing_incoming_accounts">
<?php
foreach (TBGContext::getModule('mailing')->getIncomingEmailAccountsForProject(TBGContext::getCurrentProject()) as $account) {
?>
<?php
include_template('mailing/incomingemailaccount', array('account' => $account));
?>
<?php
}
?>
</div>
<?php
}
?>
</div>
示例8: hasModuleAccess
/**
* Whether this user can access the specified module
*
* @param string $module The module key
*
* @return boolean
*/
public function hasModuleAccess($module)
{
return TBGContext::getModule($module)->hasAccess($this->getID());
}
示例9: array
<?php
/*
* Generate link for browser
*/
$link_repo = TBGContext::getModule('vcs_integration')->getSetting('browser_url_' . TBGContext::getCurrentProject()->getID());
if (TBGContext::getModule('vcs_integration')->getSetting('vcs_mode_' . TBGContext::getCurrentProject()->getID()) != TBGVCSIntegration::MODE_DISABLED) {
echo link_tag(make_url('vcs_commitspage', array('project_key' => TBGContext::getCurrentProject()->getKey())), __('Commits'), $tbg_response->getPage() == 'vcs_commitspage' ? array('class' => 'selected') : array());
if (!$submenu && $tbg_response->getPage() == 'vcs_commitspage') {
?>
<ul class="simple_list">
<li><a href="<?php
echo $link_repo;
?>
" target="_blank"><?php
echo __('Browse source code');
?>
</a></li>
</ul>
<?php
}
}
示例10: runEditArticle
/**
* Show an article
*
* @param TBGRequest $request
*/
public function runEditArticle(TBGRequest $request)
{
$article_name = $this->article instanceof TBGWikiArticle ? $this->article->getName() : $request->getParameter('article_name');
if (!TBGContext::getModule('publish')->canUserEditArticle($article_name)) {
TBGContext::setMessage('publish_article_error', TBGContext::getI18n()->__('You do not have permission to edit this article'));
$this->forward(TBGContext::getRouting()->generate('publish_article', array('article_name' => $article_name)));
}
if ($request->isMethod(TBGRequest::POST)) {
if ($request->hasParameter('new_article_name') && $request->getParameter('new_article_name') != '') {
if ($request->hasParameter('change_reason') && trim($request->getParameter('change_reason')) != '') {
try {
if ($request->getParameter('article_id')) {
if (($article = PublishFactory::article($request->getParameter('article_id'))) && $article instanceof TBGWikiArticle) {
if ($article->getLastUpdatedDate() != $request->getParameter('last_modified')) {
$this->error = TBGContext::getI18n()->__('The file has been modified since you last opened it');
} else {
try {
$article->setName($request->getParameter('new_article_name'));
$article->setContent($request->getRawParameter('new_article_content'));
if ($request->getParameter('preview')) {
$this->article = $article;
} else {
$article->doSave(array(), $request->getParameter('change_reason'));
TBGContext::setMessage('publish_article_message', TBGContext::getI18n()->__('The article was saved'));
$this->forward(TBGContext::getRouting()->generate('publish_article', array('article_name' => $article->getName())));
}
} catch (Exception $e) {
$this->error = $e->getMessage();
}
}
}
}
} catch (Exception $e) {
}
if (($article = TBGWikiArticle::getByName($request->getParameter('new_article_name'))) && $article instanceof TBGWikiArticle && $article->getID() != $request->getParameter('article_id')) {
$this->error = TBGContext::getI18n()->__('An article with that name already exists. Please choose a different article name');
} elseif (!$article instanceof TBGWikiArticle) {
if ($request->getParameter('preview')) {
$article = new TBGWikiArticle();
$article->setContent($request->getRawParameter('new_article_content'));
$article->setName($request->getParameter('new_article_name'));
$this->article = $article;
} else {
$article_id = TBGWikiArticle::createNew($request->getParameter('new_article_name'), $request->getRawParameter('new_article_content', ''), true);
$this->forward(TBGContext::getRouting()->generate('publish_article', array('article_name' => $request->getParameter('new_article_name'))));
}
}
} else {
$this->error = TBGContext::getI18n()->__('You have to provide a reason for the changes');
}
} else {
$this->error = TBGContext::getI18n()->__('You need to specify the article name');
}
}
$this->preview = (bool) $request->getParameter('preview');
$this->article_title = null;
$this->article_content = null;
$this->article_intro = null;
$this->change_reason = null;
if ($this->article instanceof TBGWikiArticle) {
$this->article_title = $this->article->getTitle();
$this->article_content = $this->article->getContent();
if ($request->isMethod(TBGRequest::POST)) {
if ($request->hasParameter('new_article_name')) {
$this->article_title = $request->getParameter('new_article_name');
}
if ($request->hasParameter('new_article_content')) {
$this->article_content = $request->getRawParameter('new_article_content');
}
if ($request->hasParameter('change_reason')) {
$this->change_reason = $request->getParameter('change_reason');
}
}
} else {
if ($request->hasParameter('new_article_content')) {
$this->article_content = $request->getRawParameter('new_article_content');
}
TBGContext::loadLibrary('publish');
$this->article_title = str_replace(array(':', '_'), array(' ', ' '), get_spaced_name($this->article_name));
}
}
示例11: logout
/**
* Log out the current user (does not work when auth method is set to http)
*/
public static function logout()
{
if (TBGSettings::isUsingExternalAuthenticationBackend()) {
$mod = TBGContext::getModule(TBGSettings::getAuthenticationBackend());
$mod->logout();
}
TBGEvent::createNew('core', 'pre_logout')->trigger();
self::getResponse()->deleteCookie('tbg3_username');
self::getResponse()->deleteCookie('tbg3_password');
self::getResponse()->deleteCookie('tbg3_elevated_password');
self::getResponse()->deleteCookie('tbg3_persona_session');
self::getResponse()->deleteCookie('THEBUGGENIE');
session_regenerate_id(true);
TBGEvent::createNew('core', 'post_logout')->trigger();
}
示例12: doLogin
public function doLogin($username, $password, $mode = 1)
{
$validgroups = $this->getSetting('groups');
$base_dn = $this->getSetting('b_dn');
$dn_attr = $this->escape($this->getSetting('dn_attr'));
$username_attr = $this->escape($this->getSetting('u_attr'));
$fullname_attr = $this->escape($this->getSetting('f_attr'));
$buddyname_attr = $this->escape($this->getSetting('b_attr'));
$email_attr = $this->escape($this->getSetting('e_attr'));
$groups_members_attr = $this->escape($this->getSetting('g_attr'));
$user_class = TBGContext::getModule('auth_ldap')->getSetting('u_type');
$group_class = TBGContext::getModule('auth_ldap')->getSetting('g_type');
$email = null;
$integrated_auth = $this->getSetting('integrated_auth');
/*
* Do the LDAP check here.
*
* If a connection error or something, throw an exception and log
*
* If we can, set $mail and $realname to correct values from LDAP
* otherwise don't touch those variables.
*
* To log do:
* TBGLogging::log('error goes here', 'ldap', TBGLogging::LEVEL_FATAL);
*/
try {
/*
* First job is to connect to our control user (may be an anonymous bind)
* so we can find the user we want to log in as/validate.
*/
$connection = $this->connect();
$control_user = $this->getSetting('control_user');
$control_password = $this->getSetting('control_pass');
$this->bind($connection, $control_user, $control_password);
// Assume bind successful, otherwise we would have had an exception
/*
* Search for a user with the username specified. We search in the base_dn, so we can
* find users in multiple parts of the directory, and only return users of a specific
* class (default person).
*
* We want exactly 1 user to be returned. We get the user's full name, email, cn
* and dn.
*/
$fields = array($fullname_attr, $buddyname_attr, $email_attr, 'cn', $dn_attr);
$filter = '(&(objectClass=' . TBGLDAPAuthentication::getModule()->escape($user_class) . ')(' . $username_attr . '=' . $this->escape($username) . '))';
$results = ldap_search($connection, $base_dn, $filter, $fields);
if (!$results) {
TBGLogging::log('failed to search for user: ' . ldap_error($connection), 'ldap', TBGLogging::LEVEL_FATAL);
throw new Exception(TBGContext::geti18n()->__('Search failed: ') . ldap_error($connection));
}
$data = ldap_get_entries($connection, $results);
// User does not exist
if ($data['count'] == 0) {
TBGLogging::log('could not find user ' . $username . ', class ' . $user_class . ', attribute ' . $username_attr, 'ldap', TBGLogging::LEVEL_FATAL);
throw new Exception(TBGContext::geti18n()->__('User does not exist in the directory'));
}
// If we have more than 1 user, something is seriously messed up...
if ($data['count'] > 1) {
TBGLogging::log('too many users for ' . $username . ', class ' . $user_class . ', attribute ' . $username_attr, 'ldap', TBGLogging::LEVEL_FATAL);
throw new Exception(TBGContext::geti18n()->__('This user was found multiple times in the directory, please contact your admimistrator'));
}
/*
* If groups are specified, perform group restriction tests
*/
if ($validgroups != '') {
/*
* We will repeat this for every group, but groups are supplied as a comma-separated list
*/
if (strstr($validgroups, ',')) {
$groups = explode(',', $validgroups);
} else {
$groups = array();
$groups[] = $validgroups;
}
// Assumed we are initially banned
$allowed = false;
foreach ($groups as $group) {
// No need to carry on looking if we have access
if ($allowed == true) {
continue;
}
/*
* Find the group we are looking for, we search the entire directory as per users (See that stuff)
* We want to find 1 group, if we don't get 1, silently ignore this group.
*/
$fields2 = array($groups_members_attr);
$filter2 = '(&(objectClass=' . TBGLDAPAuthentication::getModule()->escape($group_class) . ')(cn=' . $this->escape($group) . '))';
$results2 = ldap_search($connection, $base_dn, $filter2, $fields2);
if (!$results2) {
TBGLogging::log('failed to search for user after binding: ' . ldap_error($connection), 'ldap', TBGLogging::LEVEL_FATAL);
throw new Exception(TBGContext::geti18n()->__('Search failed ') . ldap_error($connection));
}
$data2 = ldap_get_entries($connection, $results2);
if ($data2['count'] != 1) {
continue;
}
/*
* Look through the group's member list. If we are found, grant access.
*/
foreach ($data2[0][strtolower($groups_members_attr)] as $member) {
//.........这里部分代码省略.........
示例13: array
" <?php
if ($revision == $revision_count - 1) {
?>
checked <?php
}
?>
name="from_revision" id="to_revision_<?php
echo $revision;
?>
">
<?php
}
?>
</td>
<?php
if ($revision < $revision_count && TBGContext::getModule('publish')->canUserEditArticle($article_name)) {
?>
<td style="position: relative;">
<?php
echo javascript_link_tag(__('Restore this version'), array('onclick' => "\$('restore_article_revision_{$revision}').toggle();"));
?>
<div class="rounded_box white shadowed" style="width: 400px; position: absolute; right: 15px; display: none; z-index: 100;" id="restore_article_revision_<?php
echo $revision;
?>
">
<div class="header_div"><?php
echo __('Are you sure you want to restore this revision?');
?>
</div>
<div class="content" style="padding: 5px;">
<?php
示例14: getModule
/**
* Return an instance of this module
*
* @return TBGVCSIntegration
*/
public static function getModule()
{
return TBGContext::getModule('vcs_integration');
}
示例15: __construct
protected function __construct($subject, $template, $parameters = array(), $language = null, $message_plain = null, $message_html = null, $recipients = array(), $charset = 'utf-8')
{
/* Prepare two separators. $sep1 for the html/text message part. $sep2 for the attachment part. */
for ($len = 10, $sep1 = ""; mb_strlen($sep1) < $len; $sep1 .= chr(!mt_rand(0, 2) ? mt_rand(48, 57) : (!mt_rand(0, 1) ? mt_rand(65, 90) : mt_rand(97, 122)))) {
}
for ($len = 10, $sep2 = ""; mb_strlen($sep2) < $len; $sep2 .= chr(!mt_rand(0, 2) ? mt_rand(48, 57) : (!mt_rand(0, 1) ? mt_rand(65, 90) : mt_rand(97, 122)))) {
}
$this->sep1 = "_1_" . bin2hex($sep1);
$this->sep2 = "_2_" . bin2hex($sep2);
$this->subject = $subject;
if ($template !== null) {
$this->template = $template;
$this->template_parameters = $parameters;
if ($language !== null) {
$this->language = $language;
}
} elseif ($message_plain !== null) {
$this->message_plain = $message_plain;
$this->message_plain_replaced = $message_plain;
if ($this->message_html !== null) {
$this->message_html = $message_plain;
$this->message_html_replaced = $message_plain;
}
}
$recipients = (array) $recipients;
foreach ($recipients as $recipient) {
if (is_array($recipient)) {
if (array_key_exists('name', $recipient)) {
$this->addTo($recipient['address'], $recipient['name']);
} elseif (count($recipient) == 2) {
$this->addTo($recipient[1], $recipient[0]);
} else {
$this->addTo($recipient[0]);
}
} else {
$this->addTo($recipient);
}
}
$this->charset = $charset;
$this->headers['X-Mailer'] = "TBG";
$this->headers['Subject'] = $subject;
$this->headers['Date'] = date('r');
$this->headers['MIME-Version'] = "1.0";
$server_name = TBGContext::getModule('mailing')->getMailingUrl(true);
$this->headers['Message-ID'] = "<{$this->sep1}@{$server_name}>";
}