public function do_execute() { $this->cliEcho("Importing articles ... \n", 'white', 'bold'); \thebuggenie\core\framework\Event::listen('publish', 'fixture_article_loaded', array($this, 'listenPublishFixtureArticleCreated')); $overwrite = (bool) ($this->getProvidedArgument('overwrite', 'no') == 'yes'); \thebuggenie\core\framework\Context::getModule('publish')->loadFixturesArticles(\thebuggenie\core\framework\Context::getScope()->getID(), $overwrite); }
public function do_execute() { $mailing = \thebuggenie\core\framework\Context::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 = MailQueueTable::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) { $processed_messages = array(); $failed_messages = 0; try { foreach ($messages as $message_id => $message) { $retval = $mailing->getMailer()->send($message); $processed_messages[] = $message_id; if (!$retval) { $failed_messages++; } } } catch (\Exception $e) { throw $e; } if (count($processed_messages)) { MailQueueTable::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"); } }
protected function _uninstallModule($module_name) { $this->cliEcho("Uninstall module\n", 'green', 'bold'); try { if (!$module_name || !file_exists(THEBUGGENIE_MODULES_PATH . $module_name . DS . ucfirst($module_name) . '.php')) { throw new \Exception("Please provide a valid module name"); } elseif (!\thebuggenie\core\framework\Context::isModuleLoaded($module_name)) { throw new \Exception("This module is not installed"); } else { $this->cliEcho("Removing {$module_name} ..."); \thebuggenie\core\framework\Context::getModule($module_name)->uninstall(); $this->cliEcho(' ok!', 'green', 'bold'); $this->cliEcho("\n"); } } catch (\Exception $e) { $this->cliEcho($e->getMessage() . "\n", 'red'); } }
public function runConfigureProjectSettings(framework\Request $request) { $this->forward403unless($request->isPost()); if ($this->access_level != framework\Settings::ACCESS_FULL) { $project_id = $request['project_id']; $fields = array('vcs_mode', 'match_keywords', 'access_method', 'access_passkey', 'commit_url', 'log_url', 'blob_url', 'diff_url', 'browser_url', 'vcs_workflow', 'browser_type'); foreach ($fields as $field) { framework\Context::getModule('vcs_integration')->saveSetting($field . '_' . $project_id, $request->getParameter($field)); } switch ($request['browser_type']) { case 'viewvc': $base_url = $request['browser_url']; $link_rev = '&view=rev&revision=%revno'; $link_file = '&view=log'; $link_diff = '&r1=%revno&r2=%oldrev'; $link_view = '&revision=%revno&view=markup'; break; case 'viewvc_repo': $base_url = $request['browser_url']; $link_rev = '/?view=rev&revision=%revno'; $link_file = '/%file?view=log'; $link_diff = '/%file?r1=%revno&r2=%oldrev'; $link_view = '/%file?revision=%revno&view=markup'; break; case 'websvn': $base_url = $request['browser_url']; $link_rev = '/revision.php?repname=' . $request['repository'] . '&isdir=1&rev=%revno'; $link_file = '/log.php?repname=' . $request['repository'] . '&path=/%file'; $link_diff = '/comp.php?repname=' . $request['repository'] . '&compare[]=/%file@%revno&compare[]=/%file@%oldrev'; $link_view = '/filedetails.php?repname=' . $request['repository'] . '&path=/%file&rev=%revno'; break; case 'websvn_mv': $base_url = $request['browser_url']; $link_rev = '/' . '?repname=' . $request['repository'] . '&op=log&isdir=1&rev=%revno'; $link_file = '/%file?repname=' . $request['repository']; $link_diff = '/%file?repname=' . $request['repository'] . '&compare[]=/%file@%revno&compare[]=/%file@%oldrev'; $link_view = '/%file?repname=' . $request['repository'] . '&rev=%revno'; break; case 'loggerhead': $base_url = $request['browser_url']; $link_rev = '/revision/%revno'; $link_file = '/changes'; $link_diff = '/revision/%revno?compare_revid=%oldrev'; $link_view = '/annotate/head:/%file'; break; case 'gitweb': $base_url = $request['browser_url']; $link_rev = ';a=commitdiff;h=%revno'; $link_file = ';a=history;f=%file;hb=HEAD'; $link_diff = ';a=blobdiff;f=%file;hb=%revno;hpb=%oldrev'; $link_view = ';a=blob;f=%file;hb=%revno'; break; case 'cgit': $base_url = $request['browser_url']; $link_rev = '/commit/?id=%revno'; $link_file = '/log'; $link_diff = '/diff/%file?id=%revno?id2=%oldrev'; $link_view = '/tree/%file?id=%revno'; break; case 'hgweb': $base_url = $request['browser_url']; $link_rev = '/rev/%revno'; $link_file = '/log/tip/%file'; $link_diff = '/diff/%revno/%file'; $link_view = '/file/%revno/%file'; break; case 'github': $base_url = $request['browser_url']; $link_rev = '/commit/%revno'; $link_file = '/commits/%branch/%file'; $link_diff = '/commit/%revno'; $link_view = '/blob/%revno/%file'; break; case 'gitlab': $base_url = $request['browser_url']; $link_rev = '/commit/%revno'; $link_file = '/commits/%branch/%file'; $link_diff = '/commit/%revno'; $link_view = '/blob/%revno/%file'; break; case 'bitbucket': $base_url = $request['browser_url']; $link_rev = '/commits/%revno'; $link_file = '/history/%file'; $link_diff = '/commits/%revno#chg-%file'; $link_view = '/src/%revno/%file'; break; case 'gitorious': $base_url = $request['browser_url']; $link_rev = '/commit/%revno'; $link_file = '/blobs/history/%branch/%file'; $link_diff = '/commit/%revno'; $link_view = '/blobs/%revno/%file'; break; case 'rhodecode': $base_url = $request['browser_url']; $link_rev = '/changeset/%revno'; $link_file = '/changelog/%revno/%file'; $link_diff = '/diff/%file?diff2=%revno&diff1=%oldrev&fulldiff=1&diff=diff'; $link_view = '/files/%revno/%file'; break; } if ($request['browser_type'] != 'other') { framework\Context::getModule('vcs_integration')->saveSetting('browser_url_' . $project_id, $base_url); framework\Context::getModule('vcs_integration')->saveSetting('log_url_' . $project_id, $link_file); framework\Context::getModule('vcs_integration')->saveSetting('blob_url_' . $project_id, $link_view); framework\Context::getModule('vcs_integration')->saveSetting('diff_url_' . $project_id, $link_diff); framework\Context::getModule('vcs_integration')->saveSetting('commit_url_' . $project_id, $link_rev); } return $this->renderJSON(array('failed' => false, 'message' => framework\Context::getI18n()->__('Settings saved'))); } else { $this->forward403(); } }
<?php $base_url = \thebuggenie\core\framework\Context::getModule('vcs_integration')->getSetting('browser_url_' . $projectId); if (mb_strstr($commit->getRevision(), ':')) { $revision = explode(':', $commit->getRevision()); $revision = $revision[1]; } else { $revision = $commit->getRevision(); } if (mb_strstr($commit->getPreviousRevision(), ':')) { $oldrevision = explode(':', $commit->getPreviousRevision()); $oldrevision = $oldrevision[1]; } else { $oldrevision = $commit->getPreviousRevision(); } $misc_data = explode('|', $commit->getMiscData()); $branchname = null; foreach ($misc_data as $data) { if (mb_strstr($data, 'branch')) { $branch = explode(':', $data); if (count($branch) == 2) { $branchname = $branch[1]; } } } $misc_data_array = $commit->getMiscDataArray(); $reposname = null; if (array_key_exists('gitlab_repos_ns', $misc_data_array)) { $reposname = $misc_data_array['gitlab_repos_ns']; } ?>
public function canRead() { return framework\Context::getModule('publish')->canUserReadArticle($this->getName()); }
<?php $article_name = isset($article_name) ? $article_name : ''; if (!\thebuggenie\core\framework\Context::isProjectContext() || \thebuggenie\core\framework\Context::isProjectContext() && mb_strtolower($article_name) != mb_strtolower(\thebuggenie\core\framework\Context::getCurrentProject()->getKey() . ':mainpage')) { if (\thebuggenie\core\framework\Context::isProjectContext()) { $tbg_response->addBreadcrumb(\thebuggenie\core\framework\Context::getModule('publish')->getMenuTitle(), make_url('publish_article', array('article_name' => \thebuggenie\core\framework\Context::getCurrentProject()->getKey() . ':MainPage'))); } else { $tbg_response->addBreadcrumb(\thebuggenie\core\framework\Context::getModule('publish')->getMenuTitle(), make_url('publish_article', array('article_name' => 'MainPage'))); } $items = explode(':', $article_name); $bcpath = array_shift($items); if (mb_strtolower($bcpath) == 'category') { $tbg_response->addBreadcrumb(__('Categories')); if (\thebuggenie\core\framework\Context::isProjectContext()) { $bcpath .= ":" . array_shift($items); } } elseif (!\thebuggenie\core\framework\Context::isProjectContext() && mb_strtolower($bcpath) != 'mainpage') { $tbg_response->addBreadcrumb($bcpath, make_url('publish_article', array('article_name' => $bcpath))); } foreach ($items as $bc_name) { $bcpath .= ":" . $bc_name; $tbg_response->addBreadcrumb($bc_name, make_url('publish_article', array('article_name' => $bcpath))); } } else { $tbg_response->addBreadcrumb(\thebuggenie\core\framework\Context::getModule('publish')->getMenuTitle(), make_url('publish_article', array('article_name' => \thebuggenie\core\framework\Context::getCurrentProject()->getKey() . ':MainPage'))); }
function get_spaced_name($camelcased) { return \thebuggenie\core\framework\Context::getModule('publish')->getSpacedName($camelcased); }
public function listen_viewissue_panel(framework\Event $event) { if (framework\Context::getModule('vcs_integration')->getSetting('vcs_mode_' . framework\Context::getCurrentProject()->getID()) == self::MODE_DISABLED) { return; } $links = IssueLink::getCommitsByIssue($event->getSubject()); include_component('vcs_integration/viewissue_commits', array('links' => $links, 'projectId' => $event->getSubject()->getProject()->getID())); }
?> </b> <span><?php echo $info['details']; ?> </span> </a> </li> <?php } ?> <?php foreach ($config_sections[\thebuggenie\core\framework\Settings::CONFIGURATION_SECTION_MODULES] as $section => $info) { ?> <?php if ($info['module'] != 'core' && !\thebuggenie\core\framework\Context::getModule($info['module'])->hasConfigSettings()) { continue; } ?> <li class="rounded_box"> <?php if (is_array($info['route'])) { ?> <?php $url = make_url($info['route'][0], $info['route'][1]); ?> <?php } else { ?> <?php $url = make_url($info['route']);
echo __('Author'); ?> </th> <th><?php echo __('Comment'); ?> </th> <?php if ($revision_count > 1) { ?> <th style="width: 60px;" colspan="2"><?php echo __('Compare'); ?> </th> <?php if (\thebuggenie\core\framework\Context::getModule('publish')->canUserEditArticle($article_name)) { ?> <th style="width: 150px;"><?php echo __('Actions'); ?> </th> <?php } ?> <?php } ?> </tr> </thead> <tbody> <?php
public static function unloadModule($module_key) { $module = framework\Context::getModule($module_key); $module->disable(); unset($module); framework\Context::unloadModule($module_key); }
/** * Get Gitlab url for merge request bz provided id * * @param integer $merge_request_id * @return string * * @throws \Exception */ public function getGitlabUrlForMergeRequestID($merge_request_id) { $base_url = \thebuggenie\core\framework\Context::getModule('vcs_integration')->getSetting('browser_url_' . $this->getProject()->getID()); $misc_data_array = $this->getMiscDataArray(); $reposname = null; if (array_key_exists('gitlab_repos_ns', $misc_data_array)) { $reposname = $misc_data_array['gitlab_repos_ns']; $base_url = rtrim($base_url, '/') . '/' . $reposname; } return $base_url . '/merge_requests/' . $merge_request_id; }
/** * Import all valid users * * @param \thebuggenie\core\framework\Request $request */ public function runImportUsers(framework\Request $request) { $validgroups = framework\Context::getModule('auth_ldap')->getSetting('groups'); $base_dn = framework\Context::getModule('auth_ldap')->getSetting('b_dn'); $dn_attr = framework\Context::getModule('auth_ldap')->getSetting('dn_attr'); $username_attr = framework\Context::getModule('auth_ldap')->getSetting('u_attr'); $fullname_attr = framework\Context::getModule('auth_ldap')->getSetting('f_attr'); $buddyname_attr = framework\Context::getModule('auth_ldap')->getSetting('b_attr'); $email_attr = framework\Context::getModule('auth_ldap')->getSetting('e_attr'); $groups_members_attr = framework\Context::getModule('auth_ldap')->getSetting('g_attr'); $user_class = framework\Context::getModule('auth_ldap')->getSetting('u_type'); $group_class = framework\Context::getModule('auth_ldap')->getSetting('g_type'); $users = array(); $importcount = 0; $updatecount = 0; try { /* * Connect and bind to the control user */ $connection = framework\Context::getModule('auth_ldap')->connect(); framework\Context::getModule('auth_ldap')->bind($connection, framework\Context::getModule('auth_ldap')->getSetting('control_user'), framework\Context::getModule('auth_ldap')->getSetting('control_pass')); /* * Get a list of all users of a certain objectClass */ $fields = array($fullname_attr, $buddyname_attr, $username_attr, $email_attr, 'cn', $dn_attr); $filter = '(objectClass=' . framework\Context::getModule('auth_ldap')->escape($user_class) . ')'; $results = ldap_search($connection, $base_dn, $filter, $fields); if (!$results) { framework\Logging::log('failed to search for users: ' . ldap_error($connection), 'ldap', framework\Logging::LEVEL_FATAL); throw new \Exception(framework\Context::geti18n()->__('Search failed: ') . ldap_error($connection)); } $data = ldap_get_entries($connection, $results); /* * For every user that exists, process it. */ for ($i = 0; $i != $data['count']; $i++) { $user_dn = $data[$i][strtolower($dn_attr)][0]; /* * 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 * 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', 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'))); }
<ul class="simple_list"> <?php if (count($role->getPermissions())) { ?> <?php foreach ($role->getPermissions() as $permission) { ?> <?php $permission_details = $permission->getModule() == 'core' ? \thebuggenie\core\framework\Context::getPermissionDetails($permission->getPermission()) : \thebuggenie\core\framework\Context::getModule($permission->getModule())->getPermissionDetails($permission->getPermission()); ?> <li> <?php echo image_tag('action_ok.png', array('style' => 'margin: 2px 5px -2px 0;')); echo array_key_exists('description', $permission_details) ? $permission_details['description'] : $permission; ?> </li> <?php } } else { ?> <li class="faded_out"><?php echo __('This role does not have any associated permissions'); ?> </li> <?php } ?> </ul>
/** * 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(); } } }
$action = 'U'; } echo '<td class="imgtd">' . image_tag('icon_action_' . $action . '.png', array(), false, 'vcs_integration') . '</td>'; $link_file = str_replace('%revno', $revision, \thebuggenie\core\framework\Context::getModule('vcs_integration')->getSetting('log_url_' . $projectId)); $link_file = str_replace('%oldrev', $oldrevision, $link_file); if ($branchname !== null) { $link_file = str_replace('%branch', $branchname, $link_file); } $link_file = $base_url . str_replace('%file', $file->getFile(), $link_file); $link_diff = str_replace('%revno', $revision, \thebuggenie\core\framework\Context::getModule('vcs_integration')->getSetting('diff_url_' . $projectId)); $link_diff = str_replace('%oldrev', $oldrevision, $link_diff); if ($branchname !== null) { $link_diff = str_replace('%branch', $branchname, $link_diff); } $link_diff = $base_url . str_replace('%file', $file->getFile(), $link_diff); $link_view = str_replace('%revno', $revision, \thebuggenie\core\framework\Context::getModule('vcs_integration')->getSetting('blob_url_' . $projectId)); $link_view = str_replace('%oldrev', $oldrevision, $link_view); if ($branchname !== null) { $link_view = str_replace('%branch', $branchname, $link_view); } $link_view = $base_url . str_replace('%file', $file->getFile(), $link_view); echo '<td><a href="' . $link_file . '" target="_new"><b>' . $file->getFile() . '</b></a></td>'; if ($action == "U" || $action == "M") { if (mb_substr($file->getFile(), -1) == '/' || mb_substr($file->getFile(), -1) == '\\') { echo '<td style="width: 75px;" class="faded_out">' . __('directory') . '</td>'; } else { echo '<td style="width: 75px;"><a href="' . $link_diff . '" target="_new"><b>' . __('Diff') . '</b></a></td>'; } } if ($action == "D") { echo '<td colspan="2" class="faded_out" style="width: 150px;">' . __('deleted') . '</td>';
<?php /* * Generate link for browser */ $link_repo = \thebuggenie\core\framework\Context::getModule('vcs_integration')->getSetting('browser_url_' . \thebuggenie\core\framework\Context::getCurrentProject()->getID()); if (\thebuggenie\core\framework\Context::getModule('vcs_integration')->getSetting('vcs_mode_' . \thebuggenie\core\framework\Context::getCurrentProject()->getID()) != \thebuggenie\modules\vcs_integration\Vcs_integration::MODE_DISABLED) { echo '<a href="' . $link_repo . '" target="_blank" class="button button-blue">' . image_tag('cfg_icon_vcs_integration.png', array(), false, 'vcs_integration') . __('Source code') . '</a>'; }
/** * Whether this user can access the specified module * * @param string $module The module key * * @return boolean */ public function hasModuleAccess($module) { return framework\Context::getModule($module)->hasAccess($this->getID()); }
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()); } } }
$('article-type-name').toggleClassName('selected'); }); }); } $('edit_article_form').on('keypress', function(event) { if (event.keyCode == 13 && event.target.tagName != 'TEXTAREA') { Event.stop(event); $('save_button').click(); } }); $('edit_article_form').on('submit', function(event) { var ok = true; <?php if (\thebuggenie\core\framework\Context::getModule('publish')->getSetting('require_change_reason') != 0) { ?> if ($('article_preview').value != 1 && $('change_reason').value.length == 0) { $('change_reason').focus(); TBG.Main.Helpers.Message.error('<?php echo __('Comment required'); ?> ', '<?php echo __('Please provide a comment describing the edit.'); ?> '); ok = false; } <?php } ?>
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 = framework\Context::getModule('auth_ldap')->getSetting('u_type'); $group_class = framework\Context::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: * framework\Logging::log('error goes here', 'ldap', framework\Logging::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=' . $this->escape($user_class) . ')(' . $username_attr . '=' . $this->escape($username) . '))'; $results = ldap_search($connection, $base_dn, $filter, $fields); if (!$results) { framework\Logging::log('failed to search for user: '******'ldap', framework\Logging::LEVEL_FATAL); throw new \Exception(framework\Context::geti18n()->__('Search failed: ') . ldap_error($connection)); } $data = ldap_get_entries($connection, $results); // User does not exist if ($data['count'] == 0) { framework\Logging::log('could not find user ' . $username . ', class ' . $user_class . ', attribute ' . $username_attr, 'ldap', framework\Logging::LEVEL_FATAL); throw new \Exception(framework\Context::geti18n()->__('User does not exist in the directory')); } // If we have more than 1 user, something is seriously messed up... if ($data['count'] > 1) { framework\Logging::log('too many users for ' . $username . ', class ' . $user_class . ', attribute ' . $username_attr, 'ldap', framework\Logging::LEVEL_FATAL); throw new \Exception(framework\Context::geti18n()->__('This user was found multiple times in the directory, please contact your administrator')); } /* * 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=' . $this->escape($group_class) . ')(cn=' . $this->escape($group) . '))'; $results2 = ldap_search($connection, $base_dn, $filter2, $fields2); if (!$results2) { framework\Logging::log('failed to search for user after binding: ' . 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])/', '', $data[0][strtolower($dn_attr)][0]); if (!is_numeric($member) && strtolower($member) == strtolower($user_dn)) { $allowed = true; } } } if ($allowed == false) { throw new \Exception(framework\Context::getI18n()->__('You are not a member of a group allowed to log in')); } } /* * 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[0])) { $realname = $username; } else { $realname = $data[0][strtolower($fullname_attr)][0]; } if (!array_key_exists(strtolower($buddyname_attr), $data[0])) { $buddyname = $username; } else { $buddyname = $data[0][strtolower($buddyname_attr)][0]; } if (!array_key_exists(strtolower($email_attr), $data[0])) { $email = ''; } else { $email = $data[0][strtolower($email_attr)][0]; } /* * If we are performing a non integrated authentication login, * now bind to the user and see if the credentials * are valid. We bind using the full DN of the user, so no need for DOMAIN\ stuff * on Windows, and more importantly it fixes other servers. * * If the bind fails (exception), we throw a nicer exception and don't continue. */ if ($mode == 1 && !$integrated_auth) { try { if (!is_array($data[0][strtolower($dn_attr)])) { $dn = $data[0][strtolower($dn_attr)]; } else { $dn = $data[0][strtolower($dn_attr)][0]; } $bind = $this->bind($connection, $this->escape($dn), $password); } catch (\Exception $e) { throw new \Exception(framework\Context::geti18n()->__('Your password was not accepted by the server')); } } elseif ($mode == 1) { if (!isset($_SERVER[$this->getSetting('integrated_auth_header')]) || $_SERVER[$this->getSetting('integrated_auth_header')] != $username) { throw new \Exception(framework\Context::geti18n()->__('HTTP authentication internal error.')); } } } catch (\Exception $e) { ldap_unbind($connection); throw $e; } try { /* * Get the user object. If the user exists, update the user's * data from the directory. */ $user = \thebuggenie\core\entities\User::getByUsername($username); if ($user instanceof \thebuggenie\core\entities\User) { $user->setBuddyname($buddyname); $user->setRealname($realname); $user->setPassword($user->getJoinedDate() . $username); // update password $user->setEmail($email); // update email address $user->save(); } else { /* * If not, and we are performing an initial login, create the user object * if we are validating a log in, kick the user out as the session is invalid. */ if ($mode == 1) { // create user $user = new \thebuggenie\core\entities\User(); $user->setUsername($username); $user->setRealname('temporary'); $user->setBuddyname($username); $user->setEmail('temporary'); $user->setEnabled(); $user->setActivated(); $user->setJoined(); $user->setPassword($user->getJoinedDate() . $username); $user->save(); } else { throw new \Exception('User does not exist in TBG'); } } } catch (\Exception $e) { ldap_unbind($connection); throw $e; } ldap_unbind($connection); /* * Set cookies and return user row for general operations. */ framework\Context::getResponse()->setCookie('tbg3_username', $username); framework\Context::getResponse()->setCookie('tbg3_password', \thebuggenie\core\entities\User::hashPassword($user->getJoinedDate() . $username, $user->getSalt())); return \thebuggenie\core\entities\tables\Users::getTable()->getByUsername($username); }
/** * Get an instance of this module * * @return \thebuggenie\modules\mailing\Mailing */ public static function getModule() { return framework\Context::getModule('mailing'); }
public function componentLeftmenu() { $this->show_article_options = (bool) ($this->article instanceof Article); $this->links_target_id = framework\Context::isProjectContext() ? framework\Context::getCurrentProject()->getID() : 0; $this->links = framework\Context::getModule('publish')->getMenuItems($this->links_target_id); }
?> <?php if ($show_actions) { ?> <div class="button-group"> <?php if ($article->getID() && $mode != 'view') { ?> <?php echo link_tag(make_url('publish_article', array('article_name' => $article->getName())), __('Show'), array('class' => 'button button-silver')); ?> <?php } ?> <?php if (isset($article) && $article->canEdit() || !isset($article) && (\thebuggenie\core\framework\Context::isProjectContext() && !\thebuggenie\core\framework\Context::getCurrentProject()->isArchived() || !\thebuggenie\core\framework\Context::isProjectContext() && \thebuggenie\core\framework\Context::getModule('publish')->canUserEditArticle($article_name))) { ?> <?php if ($mode == 'edit') { ?> <?php echo javascript_link_tag($article->getID() ? __('Edit') : __('Create new article'), array('class' => 'button button-silver button-pressed')); ?> <?php } else { ?> <?php echo link_tag(make_url('publish_article_edit', array('article_name' => $article_name)), $article->getID() ? __('Edit') : __('Create new article'), array('class' => 'button button-silver')); ?> <?php }
/** * Save project settings * * @Route(url="/configure/project/:project_id/mailing", name="configure_settings") * @Parameters(config_module="core", section=15) * @param \thebuggenie\core\framework\Request $request * @return type */ public function runConfigureProjectSettings(framework\Request $request) { $this->forward403unless($request->isPost()); if ($this->access_level != framework\Settings::ACCESS_FULL) { $project_id = $request['project_id']; if (trim($request['mailing_from_address']) != '') { if (filter_var(trim($request['mailing_from_address']), FILTER_VALIDATE_EMAIL) !== false) { framework\Context::getModule('mailing')->saveSetting(Mailing::SETTING_PROJECT_FROM_ADDRESS . $project_id, trim(mb_strtolower($request->getParameter('mailing_from_address')))); if (trim($request['mailing_from_name']) !== '') { framework\Context::getModule('mailing')->saveSetting(Mailing::SETTING_PROJECT_FROM_NAME . $project_id, trim($request->getParameter('mailing_from_name'))); } else { framework\Context::getModule('mailing')->deleteSetting(Mailing::SETTING_PROJECT_FROM_NAME . $project_id); } } else { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('message' => framework\Context::getI18n()->__('Please enter a valid email address'))); } } elseif (trim($request['mailing_from_address']) == '') { framework\Context::getModule('mailing')->deleteSetting(Mailing::SETTING_PROJECT_FROM_ADDRESS . $project_id); framework\Context::getModule('mailing')->deleteSetting(Mailing::SETTING_PROJECT_FROM_NAME . $project_id); } return $this->renderJSON(array('failed' => false, 'message' => framework\Context::getI18n()->__('Settings saved'))); } else { $this->forward403(); } }
?> <?php echo link_tag($wiki_url, __('Project wiki frontpage'), array('target' => 'blank')); ?> <?php } ?> <?php } ?> <div class="header"><?php echo __('Global content'); ?> </div> <?php echo link_tag($url, \thebuggenie\core\framework\Context::getModule('publish')->getMenuTitle(false)); ?> <?php $quicksearch_title = __('Find any article (press enter to search)'); ?> <div style="font-weight: normal; margin: 0 0 15px 5px;"> <form action="<?php echo make_url('publish_find_articles'); ?> " method="get" accept-charset="<?php echo \thebuggenie\core\framework\Context::getI18n()->getCharset(); ?> "> <input type="search" name="articlename" placeholder="<?php echo $quicksearch_title; ?>
if ($access_level != \thebuggenie\core\framework\Settings::ACCESS_FULL) { ?> <div class="rounded_box red" style="margin-top: 10px;"> <?php echo __('You do not have the relevant permissions to access email settings'); ?> </div> <?php } else { ?> <h4> <?php echo __('Incoming email accounts'); ?> </h4> <div id="mailing_incoming_accounts"> <?php foreach (\thebuggenie\core\framework\Context::getModule('mailing')->getIncomingEmailAccountsForProject(\thebuggenie\core\framework\Context::getCurrentProject()) as $account) { ?> <?php include_component('mailing/incomingemailaccount', array('account' => $account)); ?> <?php } ?> </div> <?php } ?> </div>