本文整理汇总了PHP中thebuggenie\core\framework\Context::setMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP Context::setMessage方法的具体用法?PHP Context::setMessage怎么用?PHP Context::setMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类thebuggenie\core\framework\Context
的用法示例。
在下文中一共展示了Context::setMessage方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: runTestEmail
/**
* Send a test email
*
* @Route(url="/mailing/test")
* @param \thebuggenie\core\framework\Request $request
*/
public function runTestEmail(framework\Request $request)
{
if ($email_to = $request['test_email_to']) {
try {
if (framework\Context::getModule('mailing')->sendTestEmail($email_to)) {
framework\Context::setMessage('module_message', framework\Context::getI18n()->__('The email was successfully accepted for delivery'));
} else {
framework\Context::setMessage('module_error', framework\Context::getI18n()->__('The email was not sent'));
framework\Context::setMessage('module_error_details', framework\Logging::getMessagesForCategory('mailing', framework\Logging::LEVEL_NOTICE));
}
} catch (\Exception $e) {
framework\Context::setMessage('module_error', framework\Context::getI18n()->__('The email was not sent'));
framework\Context::setMessage('module_error_details', $e->getMessage());
}
} else {
framework\Context::setMessage('module_error', framework\Context::getI18n()->__('Please specify an email address'));
}
$this->forward(framework\Context::getRouting()->generate('configure_module', array('config_module' => 'mailing')));
}
示例2: transitionIssueToOutgoingStepWithoutRequest
/**
* Transition an issue to the outgoing step, based on request data if available
*
* @param \thebuggenie\core\entities\Issue $issue
*/
public function transitionIssueToOutgoingStepWithoutRequest(\thebuggenie\core\entities\Issue $issue)
{
// Pass new Request object so that functions like getParameter can be called.
$request = new \thebuggenie\core\framework\Request();
if (!$this->validateFromRequest($request)) {
framework\Context::setMessage('issue_error', 'transition_error');
framework\Context::setMessage('issue_workflow_errors', $this->getValidationErrors());
return false;
}
$this->getOutgoingStep()->applyToIssue($issue);
if (!empty($this->_validation_errors)) {
return false;
}
foreach ($this->getActions() as $action) {
$action->perform($issue, $request);
}
foreach ($this->getPostValidationRules() as $rule) {
if (!$rule->isValid($request)) {
$this->_validation_errors[$rule->getRule()] = true;
}
}
if (count($this->getValidationErrors())) {
framework\Context::setMessage('issue_error', 'transition_error');
framework\Context::setMessage('issue_workflow_errors', $this->getValidationErrors());
return false;
}
$issue->save();
return true;
}
示例3: runEditArticle
/**
* Show an article
*
* @param \thebuggenie\core\framework\Request $request
*/
public function runEditArticle(framework\Request $request)
{
if (!$this->article->canEdit()) {
framework\Context::setMessage('publish_article_error', framework\Context::getI18n()->__('You do not have permission to edit this article'));
$this->forward(framework\Context::getRouting()->generate('publish_article', array('article_name' => $this->article_name)));
}
$this->article_route = $this->article->getID() ? 'publish_article_edit' : 'publish_article_new';
$this->article_route_params = $this->article->getID() ? array('article_name' => $this->article_name) : array();
if ($request->isPost()) {
$this->preview = (bool) $request['preview'];
$this->change_reason = $request['change_reason'];
try {
$this->article->setArticleType($request['article_type']);
$this->article->setName($request['new_article_name']);
$this->article->setParentArticle(Articles::getTable()->getArticleByName($request['parent_article_name']));
$this->article->setManualName($request['manual_name']);
if ($this->article->getArticleType() == Article::TYPE_MANUAL && !$this->article->getName()) {
$article_name_prefix = $this->article->getParentArticle() instanceof Article ? $this->article->getParentArticle()->getName() . ':' : $request['parent_article_name'];
$this->article->setName(str_replace(' ', '', $article_name_prefix . $this->article->getManualName()));
}
$this->article->setContentSyntax($request['article_content_syntax']);
$this->article->setContent($request->getRawParameter('article_content'));
if (!$this->article->getName() || trim($this->article->getName()) == '' || !preg_match('/[\\w:]+/i', $this->article->getName())) {
throw new \Exception(framework\Context::getI18n()->__('You need to specify a valid article name'));
}
if ($request['article_type'] == Article::TYPE_MANUAL && (!$this->article->getManualName() || trim($this->article->getManualName()) == '' || !preg_match('/[\\w:]+/i', $this->article->getManualName()))) {
throw new \Exception(framework\Context::getI18n()->__('You need to specify a valid article name'));
}
if (!$this->preview && framework\Context::getModule('publish')->getSetting('require_change_reason') == 1 && (!$this->change_reason || trim($this->change_reason) == '')) {
throw new \Exception(framework\Context::getI18n()->__('You have to provide a reason for the changes'));
}
if ($this->article->getLastUpdatedDate() != $request['last_modified']) {
throw new \Exception(framework\Context::getI18n()->__('The file has been modified since you last opened it'));
}
if (($article = Article::getByName($request['new_new_article_name'])) && $article instanceof Article && $article->getID() != $request['article_id']) {
throw new \Exception(framework\Context::getI18n()->__('An article with that name already exists. Please choose a different article name'));
}
if (!$this->preview) {
$this->article->doSave(array(), $request['change_reason']);
framework\Context::setMessage('publish_article_message', framework\Context::getI18n()->__('The article was saved'));
$this->forward(framework\Context::getRouting()->generate('publish_article', array('article_name' => $this->article->getName())));
}
} catch (\Exception $e) {
$this->error = $e->getMessage();
}
}
}
示例4: runProjectBuild
/**
* Add a build (AJAX call)
*
* @param framework\Request $request The request object
*/
public function runProjectBuild(framework\Request $request)
{
$i18n = framework\Context::getI18n();
if ($this->getUser()->canManageProjectReleases($this->selected_project)) {
try {
if (framework\Context::getUser()->canManageProjectReleases($this->selected_project)) {
if (($b_name = $request['build_name']) && trim($b_name) != '') {
$build = new entities\Build($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 = entities\Milestone::getB2DBTable()->selectById($request['milestone']))) {
$build->setMilestone($milestone);
} else {
$build->clearMilestone();
}
if ($request['edition'] && ($edition = entities\Edition::getB2DBTable()->selectById($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 = framework\Context::getRequest()->handleUpload('upload_file');
$build->setFile($file);
$build->setFileURL('');
break;
case 'url':
$build->clearFile();
$build->setFileURL($request['file_url']);
break;
}
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) {
framework\Context::setMessage('build_error', $e->getMessage());
}
$this->forward(framework\Context::getRouting()->generate('project_release_center', array('project_key' => $this->selected_project->getKey())));
}
return $this->forward403($i18n->__("You don't have access to add releases"));
}
示例5: postConfigSettings
public function postConfigSettings(\thebuggenie\core\framework\Request $request)
{
if ($request->hasParameter('import_articles')) {
$cc = 0;
foreach ($request['import_article'] as $article_name => $import) {
$cc++;
Articles::getTable()->deleteArticleByName(urldecode($article_name));
$content = file_get_contents(THEBUGGENIE_MODULES_PATH . 'publish' . DS . 'fixtures' . DS . $article_name);
Article::createNew(urldecode($article_name), $content, null, array('overwrite' => true, 'noauthor' => true));
}
framework\Context::setMessage('module_message', framework\Context::getI18n()->__('%number_of_articles articles imported successfully', array('%number_of_articles' => $cc)));
} else {
$settings = array('allow_camelcase_links', 'menu_title', 'hide_wiki_links', 'free_edit', 'require_change_reason');
foreach ($settings as $setting) {
if ($request->hasParameter($setting)) {
$this->saveSetting($setting, $request->getParameter($setting));
}
}
}
}
示例6: runScope
public function runScope(framework\Request $request)
{
$this->scope = new entities\Scope($request['id']);
$modules = tables\Modules::getTable()->getModulesForScope($this->scope->getID());
$this->modules = $modules;
$this->scope_save_error = framework\Context::getMessageAndClear('scope_save_error');
if ($request->isPost()) {
try {
if ($request['scope_action'] == 'delete') {
if (!$this->scope->isDefault()) {
$this->scope->delete();
framework\Context::setMessage('scope_deleted', true);
$this->forward(make_url('configure_scopes'));
} else {
$this->scope_save_error = $this->getI18n()->__('You cannot delete the default scope');
}
} else {
if (!$request['name']) {
throw new \Exception($this->getI18n()->__('Please specify a scope name'));
}
$this->scope->setName($request['name']);
$this->scope->setDescription($request['description']);
$this->scope->setCustomWorkflowsEnabled((bool) $request['custom_workflows_enabled']);
$this->scope->setMaxWorkflowsLimit((int) $request['workflow_limit']);
$this->scope->setUploadsEnabled((bool) $request['file_uploads_enabled']);
$this->scope->setMaxUploadLimit((int) $request['upload_limit']);
$this->scope->setMaxProjects((int) $request['project_limit']);
$this->scope->setMaxUsers((int) $request['user_limit']);
$this->scope->setMaxTeams((int) $request['team_limit']);
$this->scope->save();
$enabled_modules = $request['module_enabled'];
$prev_scope = framework\Context::getScope();
foreach ($enabled_modules as $module => $enabled) {
if (!framework\Context::getModule($module)->isCore() && !$enabled && array_key_exists($module, $modules)) {
$module = tables\Modules::getTable()->getModuleForScope($module, $this->scope->getID());
$module->uninstall($this->scope->getID());
} elseif (!framework\Context::getModule($module)->isCore() && $enabled && !array_key_exists($module, $modules)) {
framework\Context::setScope($this->scope);
entities\Module::installModule($module);
framework\Context::setScope($prev_scope);
}
}
framework\Context::setMessage('scope_saved', true);
$this->forward(make_url('configure_scopes'));
}
} catch (\Exception $e) {
framework\Context::setMessage('scope_save_error', $e->getMessage());
}
}
}
示例7: runAccountPickUsername
public function runAccountPickUsername(framework\Request $request)
{
if (entities\User::isUsernameAvailable($request['selected_username'])) {
$user = $this->getUser();
$user->setUsername($request['selected_username']);
$user->setOpenIdLocked(false);
$user->setPassword(entities\User::createPassword());
$user->save();
$this->getResponse()->setCookie('tbg3_username', $user->getUsername());
$this->getResponse()->setCookie('tbg3_password', $user->getPassword());
framework\Context::setMessage('username_chosen', true);
$this->forward($this->getRouting()->generate('account'));
}
framework\Context::setMessage('error', $this->getI18n()->__('Could not pick the username "%username"', array('%username' => $request['selected_username'])));
$this->forward($this->getRouting()->generate('account'));
}
示例8: runEditSavedSearch
public function runEditSavedSearch(framework\Request $request)
{
if ($request->isPost()) {
if ($request['delete_saved_search']) {
try {
if (!$this->search_object instanceof entities\SavedSearch || !$this->search_object->getB2DBID()) {
throw new \Exception('not a saved search');
}
if ($this->search_object->getUserID() == framework\Context::getUser()->getID() || $this->search_object->isPublic() && framework\Context::getUser()->canCreatePublicSearches()) {
$this->search_object->delete();
return $this->renderJSON(array('failed' => false, 'message' => framework\Context::getI18n()->__('The saved search was deleted successfully')));
}
} catch (\Exception $e) {
return $this->renderJSON(array('failed' => true, 'message' => framework\Context::getI18n()->__('Cannot delete this saved search')));
}
} elseif ($request['saved_search_name'] != '') {
if (!$this->saved_search instanceof entities\SavedSearch) {
$this->saved_search = new entities\SavedSearch();
}
$this->saved_search->setName($request['saved_search_name']);
$this->saved_search->setDescription($request['saved_search_description']);
$this->saved_search->setIsPublic((bool) $request['saved_search_public']);
$this->saved_search->save();
if ($request['saved_search_id']) {
framework\Context::setMessage('search_message', framework\Context::getI18n()->__('The saved search was updated'));
} else {
framework\Context::setMessage('search_message', framework\Context::getI18n()->__('The saved search has been created'));
}
$params = array();
} else {
framework\Context::setMessage('search_error', framework\Context::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 (framework\Context::isProjectContext()) {
$route = 'project_issues';
$params['project_key'] = framework\Context::getCurrentProject()->getKey();
} else {
$route = 'search';
}
$this->forward(framework\Context::getRouting()->generate($route, $params));
}
}
示例9: runImportUsers
//.........这里部分代码省略.........
/*
* Find the group we are looking for, we search the entire directory
* We want to find 1 group, if we don't get 1, silently ignore this group.
*/
$fields2 = array($groups_members_attr);
$filter2 = '(&(cn=' . framework\Context::getModule('auth_ldap')->escape($group) . ')(objectClass=' . framework\Context::getModule('auth_ldap')->escape($group_class) . '))';
$results2 = ldap_search($connection, $base_dn, $filter2, $fields2);
if (!$results2) {
framework\Logging::log('failed to search for user: ' . ldap_error($connection), 'ldap', framework\Logging::LEVEL_FATAL);
throw new \Exception(framework\Context::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) {
$member = preg_replace('/(?<=,) +(?=[a-zA-Z])/', '', $member);
$user_dn = preg_replace('/(?<=,) +(?=[a-zA-Z])/', '', $user_dn);
if (!is_numeric($member) && strtolower($member) == strtolower($user_dn)) {
$allowed = true;
}
}
}
if ($allowed == false) {
continue;
}
}
$users[$i] = array();
/*
* Set user's properties.
* Realname is obtained from directory, if not found we set it to the username
* Email is obtained from directory, if not found we set it to blank
*/
if (!array_key_exists(strtolower($fullname_attr), $data[$i])) {
$users[$i]['realname'] = $data[$i]['cn'][0];
} else {
$users[$i]['realname'] = $data[$i][strtolower($fullname_attr)][0];
}
if (!array_key_exists(strtolower($buddyname_attr), $data[$i])) {
$users[$i]['buddyname'] = $data[$i]['cn'][0];
} else {
$users[$i]['buddyname'] = $data[$i][strtolower($buddyname_attr)][0];
}
if (!array_key_exists(strtolower($email_attr), $data[$i])) {
$users[$i]['email'] = '';
} else {
$users[$i]['email'] = $data[$i][strtolower($email_attr)][0];
}
$users[$i]['username'] = $data[$i][strtolower($username_attr)][0];
}
} catch (\Exception $e) {
framework\Context::setMessage('module_error', framework\Context::getI18n()->__('Import failed'));
framework\Context::setMessage('module_error_details', $e->getMessage());
$this->forward(framework\Context::getRouting()->generate('configure_module', array('config_module' => 'auth_ldap')));
}
/*
* For every user that was found, either create a new user object, or update
* the existing one. This will update the created and updated counts as appropriate.
*/
foreach ($users as $ldapuser) {
$username = $ldapuser['username'];
$email = $ldapuser['email'];
$realname = $ldapuser['realname'];
$buddyname = $ldapuser['buddyname'];
try {
$user = \thebuggenie\core\entities\User::getByUsername($username);
if ($user instanceof \thebuggenie\core\entities\User) {
$user->setRealname($realname);
$user->setEmail($email);
// update email address
$user->save();
$updatecount++;
} else {
// create user
$user = new \thebuggenie\core\entities\User();
$user->setUsername($username);
$user->setRealname($realname);
$user->setBuddyname($buddyname);
$user->setEmail($email);
$user->setEnabled();
$user->setActivated();
$user->setPassword($user->getJoinedDate() . $username);
$user->setJoined();
$user->save();
$importcount++;
}
} catch (\Exception $e) {
ldap_unbind($connection);
framework\Context::setMessage('module_error', framework\Context::getI18n()->__('Import failed'));
framework\Context::setMessage('module_error_details', $e->getMessage());
$this->forward(framework\Context::getRouting()->generate('configure_module', array('config_module' => 'auth_ldap')));
}
}
ldap_unbind($connection);
framework\Context::setMessage('module_message', framework\Context::getI18n()->__('Import successful! %imp users imported, %upd users updated from LDAP', array('%imp' => $importcount, '%upd' => $updatecount)));
$this->forward(framework\Context::getRouting()->generate('configure_module', array('config_module' => 'auth_ldap')));
}