Exemplo n.º 1
0
 /**
  * @protected entities\SavedSearch $search_object
  */
 public function componentPagination()
 {
     $this->currentpage = $this->search_object->getCurrentPage();
     $this->pagecount = $this->search_object->getNumberOfPages();
     $this->ipp = $this->search_object->getIssuesPerPage();
     $this->route = framework\Context::isProjectContext() ? framework\Context::getRouting()->generate('project_search_paginated', array('project_key' => framework\Context::getCurrentProject()->getKey())) : framework\Context::getRouting()->generate('search_paginated');
     $this->parameters = $this->search_object->getParametersAsString();
 }
Exemplo n.º 2
0
 /**
  * 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()));
 }
Exemplo n.º 3
0
 /**
  * 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')));
 }
Exemplo n.º 4
0
 /**
  * Pre-execute function
  *
  * @param framework\Request     $request
  * @param string        $action
  */
 public function preExecute(framework\Request $request, $action)
 {
     // forward 403 if you're not allowed here
     if ($request->isAjaxCall() == false) {
         $this->forward403unless(framework\Context::getUser()->canAccessConfigurationPage());
     }
     $this->access_level = $this->getAccessLevel(framework\Settings::CONFIGURATION_SECTION_IMPORT, 'core');
     if (!$request->isAjaxCall()) {
         $this->getResponse()->setPage('config');
         framework\Context::loadLibrary('ui');
         $this->getResponse()->addBreadcrumb(framework\Context::getI18n()->__('Configure %thebuggenie_name', array('%thebuggenie_name' => framework\Settings::getSiteHeaderName())), framework\Context::getRouting()->generate('configure'), $this->getResponse()->getPredefinedBreadcrumbLinks('configure'));
     }
 }
Exemplo n.º 5
0
 public function generateURL($route, $parameters = array())
 {
     $url = framework\Context::getRouting()->generate($route, $parameters);
     return $this->getMailingUrl() . $url;
 }
Exemplo n.º 6
0
 protected function _parse_internallink($matches)
 {
     $href = html_entity_decode($matches[4], ENT_QUOTES, 'UTF-8');
     if (isset($matches[6]) && $matches[6]) {
         $title = $matches[6];
     } else {
         $title = $href;
         if (isset($matches[7]) && $matches[7]) {
             $title .= $matches[7];
         }
     }
     $namespace = $matches[3];
     if (mb_strtolower($namespace) == 'category') {
         if (mb_substr($matches[2], 0, 1) != ':') {
             $this->addCategorizer($href);
             return '';
         }
     }
     if (mb_strtolower($namespace) == 'wikipedia') {
         if (framework\Context::isCLI()) {
             return $href;
         }
         $options = explode('|', $title);
         $title = (array_key_exists(5, $matches) && mb_strpos($matches[5], '|') !== false ? '' : $namespace . ':') . array_pop($options);
         return link_tag('http://en.wikipedia.org/wiki/' . $href, $title);
     }
     if (preg_match("/embed(\\s+url\\=)?/", mb_strtolower($namespace)) || preg_match("/embed((:)?|(\\s+url\\=)?)/", mb_strtolower($matches[0]))) {
         if (framework\Context::isCLI()) {
             return $href;
         }
         // if the name space is null more than likely the user is
         // using embed url= format without the http:// in front of the URL
         // and the href tag will contain "embed url=" and it must be removed
         if ($namespace == null) {
             $href = preg_replace("/embed(\\s+)url=/", "", $href);
         }
         // if the href is empty or set to 'embed' then stop processing
         // an empty embed tag was entered '[[embed]]'
         if ($href == 'embed' || $href == null) {
             return;
         }
         $options = explode('|', $title);
         // Default values
         $width = 500;
         $height = 400;
         $type = 'iframe';
         // if the link is a youtube link prepare it for embedding
         if (tbg_youtube_link($href)) {
             $href = tbg_youtube_prepare_link($href);
         }
         // check to see if any size options exist
         if (array_key_exists(0, $options)) {
             $settings = $options[0];
             // if width exists override default setting
             if (preg_match_all("/width=(\\d+)/", $settings, $width_matches)) {
                 if (!empty($width_matches)) {
                     $width = $width_matches[1][0];
                 }
             }
             // if height exists override default setting
             if (preg_match_all("/height=(\\d+)/", $settings, $height_matches)) {
                 if (!empty($height_matches)) {
                     $height = $height_matches[1][0];
                 }
             }
             // if type exists override default setting
             if (preg_match_all("/type=(iframe|object)/", $settings, $type_matches)) {
                 if (!empty($type_matches)) {
                     $type = $type_matches[1][0];
                 }
             }
         }
         if ($type == 'object') {
             $code = object_tag($href, $width, $height);
         } else {
             $code = iframe_tag($href, $width, $height);
         }
         return $code;
     }
     if (in_array(mb_strtolower($namespace), array('image', 'file'))) {
         $retval = $namespace . ':' . $href;
         if (!framework\Context::isCLI()) {
             $options = explode('|', $title);
             $filename = $href;
             $issuemode = (bool) (isset($this->options['issue']) && $this->options['issue'] instanceof \thebuggenie\core\entities\Issue);
             $articlemode = (bool) (isset($this->options['article']) && $this->options['article'] instanceof Article);
             $file = null;
             $file_link = $filename;
             $caption = $filename;
             if ($issuemode) {
                 $file = $this->options['issue']->getFileByFilename($filename);
             } elseif ($articlemode) {
                 $file = $this->options['article']->getFileByFilename($filename);
             }
             if ($file instanceof \thebuggenie\core\entities\File) {
                 $caption = !empty($options) ? array_pop($options) : htmlentities($file->getDescription(), ENT_COMPAT, framework\Context::getI18n()->getCharset());
                 $caption = $caption != '' ? $caption : htmlentities($file->getOriginalFilename(), ENT_COMPAT, framework\Context::getI18n()->getCharset());
                 $file_link = make_url('showfile', array('id' => $file->getID()));
             } else {
                 $caption = !empty($options) ? array_pop($options) : false;
             }
             if (($file instanceof \thebuggenie\core\entities\File && $file->isImage() || $articlemode) && (mb_strtolower($namespace) == 'image' || $issuemode) && \thebuggenie\core\framework\Settings::isCommentImagePreviewEnabled()) {
                 $divclasses = array('image_container');
                 $style_dimensions = '';
                 foreach ($options as $option) {
                     $optionlen = mb_strlen($option);
                     if (mb_substr($option, $optionlen - 2) == 'px') {
                         if (is_numeric($option[0])) {
                             $style_dimensions = ' width: ' . $option . ';';
                             break;
                         } else {
                             $style_dimensions = ' height: ' . mb_substr($option, 1) . ';';
                             break;
                         }
                     }
                 }
                 if (in_array('thumb', $options)) {
                     $divclasses[] = 'thumb';
                 }
                 if (in_array('left', $options)) {
                     $divclasses[] = 'icleft';
                 }
                 if (in_array('center', $options)) {
                     $divclasses[] = 'iccenter';
                 }
                 if (in_array('right', $options)) {
                     $divclasses[] = 'icright';
                 }
                 $retval = '<div class="' . join(' ', $divclasses) . '"';
                 if ($issuemode) {
                     $retval .= ' style="float: left; clear: left;"';
                 }
                 $retval .= '>';
                 $retval .= image_tag($file_link, array('alt' => $caption, 'title' => $caption, 'style' => $style_dimensions, 'class' => 'image'), true);
                 if ($caption != '') {
                     $retval .= '<br>' . $caption;
                 }
                 $retval .= link_tag($file_link, image_tag('icon_open_new.png', array('style' => 'margin-left: 5px;')), array('target' => 'new_window_' . rand(0, 10000), 'title' => __('Open image in new window')));
                 $retval .= '</div>';
             } else {
                 if (strpos($file_link, 'http') === 0) {
                     $retval = $this->_parse_image($file_link, $caption, $options);
                 } else {
                     if ($file_link == $filename) {
                         $retval = $caption . image_tag('icon_open_new.png', array('style' => 'margin-left: 5px;', 'title' => __('File no longer exists.')));
                     } else {
                         $retval = link_tag($file_link, $caption . image_tag('icon_open_new.png', array('style' => 'margin-left: 5px;')), array('target' => 'new_window_' . rand(0, 10000), 'title' => __('Open file in new window')));
                     }
                 }
             }
         }
         return $retval;
         //$file_id = \thebuggenie\core\entities\tables\Files::get
     }
     if ($namespace == 'TBG') {
         if (framework\Context::isCLI()) {
             return $href;
         }
         if (!framework\Context::getRouting()->hasRoute($href)) {
             return $href;
         }
         $options = explode('|', $title);
         $title = array_pop($options);
         try {
             return link_tag(make_url($href), $title);
             // $this->parse_image($href,$title,$options);
         } catch (\Exception $e) {
             return $href;
         }
     }
     if (mb_substr($href, 0, 1) == '/') {
         if (framework\Context::isCLI()) {
             return $href;
         }
         $options = explode('|', $title);
         $title = array_pop($options);
         return link_tag($href, $title);
         // $this->parse_image($href,$title,$options);
     }
     $title = preg_replace('/\\(.*?\\)/', '', $title);
     $title = preg_replace('/^.*?\\:/', '', $title);
     if (!$namespace || !array_key_exists($namespace, array('ftp', 'http', 'https', 'gopher', 'mailto', 'news', 'nntp', 'telnet', 'wais', 'file', 'prospero', 'aim', 'webcal'))) {
         if ($namespace) {
             $href = $namespace . ':' . $href;
         }
         $href = $this->_wiki_link($href);
         $title = isset($title) ? $title : $href;
         $this->addInternalLinkOccurrence($href);
         if (framework\Context::isCLI()) {
             return $href;
         }
         $href = framework\Context::getRouting()->generate('publish_article', array('article_name' => $href));
     } else {
         $href = $namespace . ':' . $this->_wiki_link($href);
     }
     if (framework\Context::isCLI()) {
         return $href;
     }
     return link_tag($href, $title);
 }
Exemplo n.º 7
0
 public function listen_project_links(framework\Event $event)
 {
     $event->addToReturnList(array('url' => framework\Context::getRouting()->generate('vcs_commitspage', array('project_key' => framework\Context::getCurrentProject()->getKey())), 'title' => framework\Context::getI18n()->__('Commits')));
 }
Exemplo n.º 8
0
 public function getRSSUrl()
 {
     switch ($this->getType()) {
         case self::VIEW_PREDEFINED_SEARCH:
         case self::VIEW_SAVED_SEARCH:
             return framework\Context::getRouting()->generate('search', $this->getSearchParameters(true));
             break;
         case self::VIEW_PROJECT_RECENT_ACTIVITIES:
             return framework\Context::getRouting()->generate('project_timeline', array('project_key' => $this->getProject()->getKey(), 'format' => 'rss'));
             break;
     }
 }
Exemplo n.º 9
0
            }
            ?>
                            <?php 
            if ($tbg_user->canAccessConfigurationPage()) {
                ?>
                                <?php 
                echo link_tag(make_url('configure'), image_tag('tab_config.png') . __('Configure %thebuggenie_name', array('%thebuggenie_name' => \thebuggenie\core\framework\Settings::getSiteHeaderName())));
                ?>
                            <?php 
            }
            ?>
                            <?php 
            \thebuggenie\core\framework\Event::createNew('core', 'user_dropdown_reg')->trigger();
            ?>
                            <?php 
            echo link_tag('http://www.thebuggenie.com/help/' . \thebuggenie\core\framework\Context::getRouting()->getCurrentRouteName(), image_tag('help.png') . __('Help for this page'), array('id' => 'global_help_link'));
            ?>
                            <a href="<?php 
            echo make_url('logout');
            ?>
" onclick="<?php 
            if (\thebuggenie\core\framework\Settings::isPersonaAvailable()) {
                ?>
if (navigator.id) { navigator.id.logout();return false; }<?php 
            }
            ?>
"><?php 
            echo image_tag('logout.png') . __('Logout');
            ?>
</a>
                            <div class="header"><?php 
Exemplo n.º 10
0
 /**
  * User dashboard project list buttons listener
  *
  * @Listener(module="core", identifier="main\Components::DashboardViewUserProjects::links")
  *
  * @param \thebuggenie\core\framework\Event $event
  */
 public function userDashboardProjectButtonLinks(framework\Event $event)
 {
     $routing = framework\Context::getRouting();
     $i18n = framework\Context::getI18n();
     $event->addToReturnList(array('url' => $routing->generate('agile_index', array('project_key' => '%project_key%')), 'text' => $i18n->__('Planning')));
 }
Exemplo n.º 11
0
 public function toJSON()
 {
     $return_values = array('id' => $this->getID(), 'issue_no' => $this->getFormattedIssueNo(), 'state' => $this->getState(), 'closed' => $this->isClosed(), 'created_at' => $this->getPosted(), 'created_at_iso' => date('c', $this->getPosted()), 'updated_at' => $this->getLastUpdatedTime(), 'updated_at_iso' => date('c', $this->getLastUpdatedTime()), 'title' => $this->getRawTitle(), 'href' => framework\Context::getRouting()->generate('viewissue', ['project_key' => $this->getProject()->getKey(), 'issue_no' => $this->getFormattedIssueNo()], false), 'posted_by' => $this->getPostedBy() instanceof \thebuggenie\core\entities\common\Identifiable ? $this->getPostedBy()->toJSON() : null, 'assignee' => $this->getAssignee() instanceof \thebuggenie\core\entities\common\Identifiable ? $this->getAssignee()->toJSON() : null, 'status' => $this->getStatus() instanceof \thebuggenie\core\entities\common\Identifiable ? $this->getStatus()->toJSON() : null);
     $fields = $this->getProject()->getVisibleFieldsArray($this->getIssueType());
     foreach ($fields as $field => $details) {
         $identifiable = true;
         switch ($field) {
             case 'shortname':
             case 'description':
             case 'votes':
                 $identifiable = false;
             case 'resolution':
             case 'priority':
             case 'severity':
             case 'category':
             case 'reproducability':
                 $method = 'get' . ucfirst($field);
                 $value = $this->{$method}();
                 break;
             case 'milestone':
                 $method = 'get' . ucfirst($field);
                 $value = $this->{$method}();
                 if (is_numeric($value) && $value == 0) {
                     $value = new Milestone();
                     $value->setID(0);
                 }
                 break;
             case 'owner':
                 $value = $this->getOwner();
                 break;
             case 'assignee':
                 $value = $this->getAssignee();
                 break;
             case 'percent_complete':
                 $value = $this->getPercentCompleted();
                 $identifiable = false;
                 break;
             case 'user_pain':
                 $value = $this->getUserPain();
                 $identifiable = false;
                 break;
             case 'reproduction_steps':
                 $value = $this->getReproductionSteps();
                 $identifiable = false;
                 break;
             case 'estimated_time':
                 $value = $this->getEstimatedTime();
                 $identifiable = false;
                 break;
             case 'spent_time':
                 $value = $this->getSpentTime();
                 $identifiable = false;
                 break;
             case 'build':
             case 'edition':
             case 'component':
                 break;
             default:
                 $value = $this->getCustomField($field);
                 $identifiable = false;
                 break;
         }
         if (isset($value)) {
             if ($identifiable) {
                 $return_values[$field] = $value instanceof \thebuggenie\core\entities\common\Identifiable ? $value->toJSON() : null;
             } else {
                 $return_values[$field] = $value;
             }
         }
     }
     $comments = array();
     foreach ($this->getComments() as $comment) {
         $comments[$comment->getCommentNumber()] = $comment->toJSON();
     }
     $return_values['comments'] = $comments;
     $return_values['visible_fields'] = $fields;
     return $return_values;
 }
Exemplo n.º 12
0
 public function runBulkUpdateIssues(framework\Request $request)
 {
     $issue_ids = $request['issue_ids'];
     $options = array('issue_ids' => array_values($issue_ids));
     framework\Context::loadLibrary('common');
     $options['last_updated'] = tbg_formatTime(time(), 20);
     if (!empty($issue_ids)) {
         $options['bulk_action'] = $request['bulk_action'];
         switch ($request['bulk_action']) {
             case 'assign_milestone':
                 $milestone = null;
                 if ($request['milestone'] == 'new') {
                     $milestone = new entities\Milestone();
                     $milestone->setProject(framework\Context::getCurrentProject());
                     $milestone->setName($request['milestone_name']);
                     $milestone->save();
                     $options['milestone_url'] = framework\Context::getRouting()->generate('agile_milestone', array('project_key' => $milestone->getProject()->getKey(), 'milestone_id' => $milestone->getID()));
                 } elseif ($request['milestone']) {
                     $milestone = new entities\Milestone($request['milestone']);
                 }
                 $milestone_id = $milestone instanceof entities\Milestone ? $milestone->getID() : null;
                 foreach (array_keys($issue_ids) as $issue_id) {
                     if (is_numeric($issue_id)) {
                         $issue = new entities\Issue($issue_id);
                         $issue->setMilestone($milestone_id);
                         $issue->save();
                     }
                 }
                 $options['milestone_id'] = $milestone_id;
                 $options['milestone_name'] = $milestone_id ? $milestone->getName() : '-';
                 break;
             case 'set_status':
                 if (is_numeric($request['status'])) {
                     $status = new entities\Status($request['status']);
                     foreach (array_keys($issue_ids) as $issue_id) {
                         if (is_numeric($issue_id)) {
                             $issue = new entities\Issue($issue_id);
                             $issue->setStatus($status->getID());
                             $issue->save();
                         }
                     }
                     $options['status'] = array('color' => $status->getColor(), 'name' => $status->getName(), 'id' => $status->getID());
                 }
                 break;
             case 'set_severity':
                 if (is_numeric($request['severity'])) {
                     $severity = $request['severity'] ? new entities\Severity($request['severity']) : null;
                     foreach (array_keys($issue_ids) as $issue_id) {
                         if (is_numeric($issue_id)) {
                             $issue = new entities\Issue($issue_id);
                             $severity_id = $severity instanceof entities\Severity ? $severity->getID() : 0;
                             $issue->setSeverity($severity_id);
                             $issue->save();
                         }
                     }
                     $options['severity'] = array('name' => $severity instanceof entities\Severity ? $severity->getName() : '-', 'id' => $severity instanceof entities\Severity ? $severity->getID() : 0);
                 }
                 break;
             case 'set_resolution':
                 if (is_numeric($request['resolution'])) {
                     $resolution = $request['resolution'] ? new entities\Resolution($request['resolution']) : null;
                     foreach (array_keys($issue_ids) as $issue_id) {
                         if (is_numeric($issue_id)) {
                             $issue = new entities\Issue($issue_id);
                             $resolution_id = $resolution instanceof entities\Resolution ? $resolution->getID() : 0;
                             $issue->setResolution($resolution_id);
                             $issue->save();
                         }
                     }
                     $options['resolution'] = array('name' => $resolution instanceof entities\Resolution ? $resolution->getName() : '-', 'id' => $resolution instanceof entities\Resolution ? $resolution->getID() : 0);
                 }
                 break;
             case 'set_priority':
                 if (is_numeric($request['priority'])) {
                     $priority = $request['priority'] ? new entities\Priority($request['priority']) : null;
                     foreach (array_keys($issue_ids) as $issue_id) {
                         if (is_numeric($issue_id)) {
                             $issue = new entities\Issue($issue_id);
                             $priority_id = $priority instanceof entities\Priority ? $priority->getID() : 0;
                             $issue->setPriority($priority_id);
                             $issue->save();
                         }
                     }
                     $options['priority'] = array('name' => $priority instanceof entities\Priority ? $priority->getName() : '-', 'id' => $priority instanceof entities\Priority ? $priority->getID() : 0);
                 }
                 break;
             case 'set_category':
                 if (is_numeric($request['category'])) {
                     $category = $request['category'] ? new entities\Category($request['category']) : null;
                     foreach (array_keys($issue_ids) as $issue_id) {
                         if (is_numeric($issue_id)) {
                             $issue = new entities\Issue($issue_id);
                             $category_id = $category instanceof entities\Category ? $category->getID() : 0;
                             $issue->setCategory($category_id);
                             $issue->save();
                         }
                     }
                     $options['category'] = array('name' => $category instanceof entities\Category ? $category->getName() : '-', 'id' => $category instanceof entities\Category ? $category->getID() : 0);
                 }
                 break;
         }
     }
     return $this->renderJSON($options);
 }
Exemplo n.º 13
0
 /**
  * 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')));
 }
Exemplo n.º 14
0
 public function hasTranslatedTemplate($template, $is_component = false)
 {
     if (mb_strpos($template, '/')) {
         $templateinfo = explode('/', $template);
         $module = $templateinfo[0];
         $templatefile = $is_component ? '_' . $templateinfo[1] . '.inc.php' : $templateinfo[1] . '.' . Context::getRequest()->getRequestedFormat() . '.php';
     } else {
         $module = Context::getRouting()->getCurrentRouteModule();
         $templatefile = $is_component ? '_' . $template . '.inc.php' : $template . '.' . Context::getRequest()->getRequestedFormat() . '.php';
     }
     if (file_exists(THEBUGGENIE_MODULES_PATH . $module . DS . 'i18n' . DS . $this->_language . DS . 'templates' . DS . $templatefile)) {
         return THEBUGGENIE_MODULES_PATH . $module . DS . 'i18n' . DS . $this->_language . DS . 'templates' . DS . $templatefile;
     } elseif (file_exists(THEBUGGENIE_PATH . 'i18n' . DS . $this->getCurrentLanguage() . DS . 'templates' . DS . $module . DS . $templatefile)) {
         return THEBUGGENIE_PATH . 'i18n' . DS . $this->getCurrentLanguage() . DS . 'templates' . DS . $module . DS . $templatefile;
     }
     return false;
 }
Exemplo n.º 15
0
 public function componentExtralinks()
 {
     switch (true) {
         case framework\Context::getRequest()->hasParameter('quicksearch'):
             $searchfor = framework\Context::getRequest()->getParameter('searchfor');
             $project_key = framework\Context::getCurrentProject() instanceof entities\Project ? framework\Context::getCurrentProject()->getKey() : 0;
             $this->csv_url = framework\Context::getRouting()->generate('project_issues', array('project_key' => $project_key, 'quicksearch' => 'true', 'format' => 'csv')) . '?searchfor=' . $searchfor;
             $this->rss_url = framework\Context::getRouting()->generate('project_issues', array('project_key' => $project_key, 'quicksearch' => 'true', 'format' => 'rss')) . '?searchfor=' . $searchfor;
             break;
         case framework\Context::getRequest()->hasParameter('predefined_search'):
             $searchno = framework\Context::getRequest()->getParameter('predefined_search');
             $project_key = framework\Context::getCurrentProject() instanceof entities\Project ? framework\Context::getCurrentProject()->getKey() : 0;
             $url = framework\Context::getCurrentProject() instanceof entities\Project ? 'project_issues' : 'search';
             $this->csv_url = framework\Context::getRouting()->generate($url, array('project_key' => $project_key, 'predefined_search' => $searchno, 'search' => '1', 'format' => 'csv'));
             $this->rss_url = framework\Context::getRouting()->generate($url, array('project_key' => $project_key, 'predefined_search' => $searchno, 'search' => '1', 'format' => 'rss'));
             break;
         default:
             preg_match('/((?<=\\/)issues).+$/i', framework\Context::getRequest()->getQueryString(), $get);
             if (!isset($get[0])) {
                 preg_match('/((?<=url=)issues).+$/i', framework\Context::getRequest()->getQueryString(), $get);
             }
             if (isset($get[0])) {
                 if (framework\Context::isProjectContext()) {
                     $this->csv_url = framework\Context::getRouting()->generate('project_issues', array('project_key' => framework\Context::getCurrentProject()->getKey(), 'format' => 'csv')) . '/' . $get[0];
                     $this->rss_url = framework\Context::getRouting()->generate('project_issues', array('project_key' => framework\Context::getCurrentProject()->getKey(), 'format' => 'rss')) . '?' . $get[0];
                 } else {
                     $this->csv_url = framework\Context::getRouting()->generate('search', array('format' => 'csv')) . '/' . $get[0];
                     $this->rss_url = framework\Context::getRouting()->generate('search', array('format' => 'rss')) . '?' . $get[0];
                 }
             }
             break;
     }
     $i18n = framework\Context::getI18n();
     $this->columns = array('title' => $i18n->__('Issue title'), 'issuetype' => $i18n->__('Issue type'), 'assigned_to' => $i18n->__('Assigned to'), 'status' => $i18n->__('Status'), 'resolution' => $i18n->__('Resolution'), 'category' => $i18n->__('Category'), 'severity' => $i18n->__('Severity'), 'percent_complete' => $i18n->__('% completed'), 'reproducability' => $i18n->__('Reproducability'), 'priority' => $i18n->__('Priority'), 'components' => $i18n->__('Component(s)'), 'milestone' => $i18n->__('Milestone'), 'estimated_time' => $i18n->__('Estimate'), 'spent_time' => $i18n->__('Time spent'), 'last_updated' => $i18n->__('Last updated time'), 'comments' => $i18n->__('Number of comments'));
 }
Exemplo n.º 16
0
 public function toJSON($detailed = true)
 {
     $jsonArray = array('id' => $this->getID(), 'key' => $this->getKey(), 'name' => $this->getName(), 'href' => framework\Context::getRouting()->generate('project_dashboard', array('project_key' => $this->getKey())), 'deleted' => $this->isDeleted(), 'archived' => $this->isArchived());
     if ($detailed) {
         $jsonArray['icon_large'] = $this->getLargeIconName();
         $jsonArray['icon_small'] = $this->getSmallIconName();
         $jsonArray['description'] = $this->getDescription();
         $jsonArray['url_documentation'] = $this->getDocumentationURL();
         $jsonArray['url_homepage'] = $this->getHomepage();
         $jsonArray['url_wiki'] = $this->getWikiURL();
         $jsonArray['prefix_used'] = $this->doesUsePrefix();
         $jsonArray['prefix'] = $this->getPrefix();
         $jsonArray['workflow_scheme'] = $this->hasWorkflowScheme() ? $this->getWorkflowScheme()->toJSON() : null;
         $jsonArray['issuetype_scheme'] = $this->getIssuetypeScheme()->toJSON();
         $jsonArray['builds_enabled'] = $this->isBuildsEnabled();
         $jsonArray['editions_enabled'] = $this->isEditionsEnabled();
         $jsonArray['components_enabled'] = $this->isComponentsEnabled();
         $jsonArray['allow_freelancing'] = $this->canChangeIssuesWithoutWorkingOnThem();
         $jsonArray['released'] = $this->isReleased();
         $jsonArray['release_date'] = $this->getReleaseDate();
         $jsonArray['frontpage_shown'] = $this->isShownInFrontpageSummary();
         $jsonArray['frontpage_summary_type'] = $this->getFrontpageSummaryType();
         $jsonArray['frontpage_milestones_visible'] = $this->isMilestonesVisibleInFrontpageSummary();
         $jsonArray['frontpage_issuetypes_visible'] = $this->isIssuetypesVisibleInFrontpageSummary();
         $jsonArray['frontpage_issuelist_visible'] = $this->isIssuelistVisibleInFrontpageSummary();
         $jsonArray['parent'] = $this->hasParent() ? $this->getParent()->toJSON() : null;
         $jsonArray['leader'] = $this->hasLeader() ? $this->getLeader()->toJSON() : null;
         $jsonArray['owner'] = $this->hasOwner() ? $this->getOwner()->toJSON() : null;
         $jsonArray['qa_responsible'] = $this->hasQaResponsible() ? $this->getQaResponsible()->toJSON() : null;
         $jsonArray['client'] = $this->hasClient() ? $this->getClient()->toJSON() : null;
         $jsonArray['issues_count'] = $this->countAllIssues();
         $jsonArray['issues_count_open'] = $this->countAllOpenIssues();
         $jsonArray['issues_count_closed'] = $this->countAllClosedIssues();
         $jsonArray['issues_percent_closed'] = $this->getClosedPercentageForAllIssues();
     }
     return $jsonArray;
 }
Exemplo n.º 17
0
 public function runProjectIcons(framework\Request $request)
 {
     if ($this->getUser()->canManageProject($this->selected_project) || $this->getUser()->canManageProjectReleases($this->selected_project)) {
         if ($request->isPost()) {
             if ($request['clear_icons']) {
                 $this->selected_project->clearSmallIcon();
                 $this->selected_project->clearLargeIcon();
             } else {
                 switch ($request['small_icon_action']) {
                     case 'upload_file':
                         $file = $request->handleUpload('small_icon');
                         $this->selected_project->setSmallIcon($file);
                         break;
                     case 'clear_file':
                         $this->selected_project->clearSmallIcon();
                         break;
                 }
                 switch ($request['large_icon_action']) {
                     case 'upload_file':
                         $file = $request->handleUpload('large_icon');
                         $this->selected_project->setLargeIcon($file);
                         break;
                     case 'clear_file':
                         $this->selected_project->clearLargeIcon();
                         break;
                 }
             }
             $this->selected_project->save();
         }
         $route = framework\Context::getRouting()->generate('project_settings', array('project_key' => $this->selected_project->getKey()));
         if ($request->isAjaxCall()) {
             return $this->renderJSON(array('forward' => $route));
         } else {
             $this->forward($route);
         }
     }
     return $this->forward403($this->getI18n()->__("You don't have access to perform this action"));
 }
Exemplo n.º 18
0
 public function runAddScope(framework\Request $request)
 {
     if ($request->isPost()) {
         $scope = framework\Context::getScope();
         $this->getUser()->addScope($scope, false);
         $this->getUser()->confirmScope($scope->getID());
         $route = framework\Settings::getLoginReturnRoute() != 'referer' ? framework\Settings::getLoginReturnRoute() : 'home';
         $this->forward(framework\Context::getRouting()->generate($route));
     }
 }
Exemplo n.º 19
0
 /**
  * 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();
         }
     }
 }
Exemplo n.º 20
0
/**
 * Generate a url based on a route
 * 
 * @param string    $name     The route key
 * @param array     $params    key => value pairs of route parameters
 * @param bool        $relative [optional] Whether to generate a full url or relative
 * 
 * @return string
 */
function make_url($name, $params = array(), $relative = true)
{
    return \thebuggenie\core\framework\Context::getRouting()->generate($name, $params, $relative);
}
Exemplo n.º 21
0
 public function getLargeIconName()
 {
     return $this->hasLargeIcon() ? framework\Context::getRouting()->generate('showfile', array('id' => $this->getLargeIcon()->getID())) : 'icon_project_large.png';
 }
Exemplo n.º 22
0
 public function runSiteIcons(framework\Request $request)
 {
     if ($this->getAccessLevel($request['section'], 'core') == framework\Settings::ACCESS_FULL) {
         if ($request->isPost()) {
             switch ($request['small_icon_action']) {
                 case 'upload_file':
                     $file = $request->handleUpload('small_icon');
                     framework\Settings::saveSetting(framework\Settings::SETTING_FAVICON_TYPE, framework\Settings::APPEARANCE_FAVICON_CUSTOM);
                     framework\Settings::saveSetting(framework\Settings::SETTING_FAVICON_ID, $file->getID());
                     break;
                 case 'clear_file':
                     framework\Settings::saveSetting(framework\Settings::SETTING_FAVICON_TYPE, framework\Settings::APPEARANCE_FAVICON_THEME);
                     break;
             }
             switch ($request['large_icon_action']) {
                 case 'upload_file':
                     $file = $request->handleUpload('large_icon');
                     framework\Settings::saveSetting(framework\Settings::SETTING_HEADER_ICON_TYPE, framework\Settings::APPEARANCE_HEADER_CUSTOM);
                     framework\Settings::saveSetting(framework\Settings::SETTING_HEADER_ICON_ID, $file->getID());
                     break;
                 case 'clear_file':
                     framework\Settings::saveSetting(framework\Settings::SETTING_HEADER_ICON_TYPE, framework\Settings::APPEARANCE_HEADER_THEME);
                     break;
             }
         }
         $route = framework\Context::getRouting()->generate('configure_settings');
         if ($request->isAjaxCall()) {
             return $this->renderJSON(array('forward' => $route));
         } else {
             $this->forward($route);
         }
     }
     return $this->forward403($this->getI18n()->__("You don't have access to perform this action"));
 }
Exemplo n.º 23
0
 /**
  * Returns the logged in user, or default user if not logged in
  *
  * @param \thebuggenie\core\framework\Request $request
  * @param \thebuggenie\core\framework\Action  $action
  *
  * @return \thebuggenie\core\entities\User
  */
 public static function loginCheck(framework\Request $request, framework\Action $action)
 {
     try {
         $authentication_method = $action->getAuthenticationMethodForAction(framework\Context::getRouting()->getCurrentRouteAction());
         $user = null;
         $external = false;
         switch ($authentication_method) {
             case framework\Action::AUTHENTICATION_METHOD_ELEVATED:
             case framework\Action::AUTHENTICATION_METHOD_CORE:
                 $username = $request['tbg3_username'];
                 $password = $request['tbg3_password'];
                 if ($authentication_method == framework\Action::AUTHENTICATION_METHOD_ELEVATED) {
                     $elevated_password = $request['tbg3_elevated_password'];
                 }
                 $raw = true;
                 // If no username and password specified, check if we have a session that exists already
                 if ($username === null && $password === null) {
                     if (framework\Context::getRequest()->hasCookie('tbg3_username') && framework\Context::getRequest()->hasCookie('tbg3_password')) {
                         $username = framework\Context::getRequest()->getCookie('tbg3_username');
                         $password = framework\Context::getRequest()->getCookie('tbg3_password');
                         $user = self::getB2DBTable()->getByUsername($username);
                         if ($authentication_method == framework\Action::AUTHENTICATION_METHOD_ELEVATED) {
                             $elevated_password = framework\Context::getRequest()->getCookie('tbg3_elevated_password');
                             if ($user instanceof User && !$user->hasPasswordHash($password)) {
                                 $user = null;
                             } else {
                                 if ($user instanceof User && !$user->hasPasswordHash($elevated_password)) {
                                     framework\Context::setUser($user);
                                     framework\Context::getRouting()->setCurrentRouteName('elevated_login_page');
                                     throw new framework\exceptions\ElevatedLoginException('reenter');
                                 }
                             }
                         } else {
                             if ($user instanceof User && !$user->hasPasswordHash($password)) {
                                 $user = null;
                             }
                         }
                         if (!$user instanceof User) {
                             framework\Context::logout();
                             throw new \Exception('No such login');
                         }
                     }
                 }
                 // If we have authentication details, validate them
                 if (framework\Settings::isUsingExternalAuthenticationBackend() && $username !== null && $password !== null) {
                     $external = true;
                     framework\Logging::log('Authenticating with backend: ' . framework\Settings::getAuthenticationBackend(), 'auth', framework\Logging::LEVEL_INFO);
                     try {
                         $mod = framework\Context::getModule(framework\Settings::getAuthenticationBackend());
                         if ($mod->getType() !== Module::MODULE_AUTH) {
                             framework\Logging::log('Auth module is not the right type', 'auth', framework\Logging::LEVEL_FATAL);
                         }
                         if (framework\Context::getRequest()->hasCookie('tbg3_username') && framework\Context::getRequest()->hasCookie('tbg3_password')) {
                             $user = $mod->verifyLogin($username, $password);
                         } else {
                             $user = $mod->doLogin($username, $password);
                         }
                         if (!$user instanceof User) {
                             // Invalid
                             framework\Context::logout();
                             throw new \Exception('No such login');
                             //framework\Context::getResponse()->headerRedirect(framework\Context::getRouting()->generate('login'));
                         }
                     } catch (\Exception $e) {
                         throw $e;
                     }
                 } elseif (framework\Settings::isUsingExternalAuthenticationBackend()) {
                     $external = true;
                     framework\Logging::log('Authenticating without credentials with backend: ' . framework\Settings::getAuthenticationBackend(), 'auth', framework\Logging::LEVEL_INFO);
                     try {
                         $mod = framework\Context::getModule(framework\Settings::getAuthenticationBackend());
                         if ($mod->getType() !== Module::MODULE_AUTH) {
                             framework\Logging::log('Auth module is not the right type', 'auth', framework\Logging::LEVEL_FATAL);
                         }
                         $user = $mod->doAutoLogin();
                         if ($user == false) {
                             // Invalid
                             framework\Context::logout();
                             throw new \Exception('No such login');
                             //framework\Context::getResponse()->headerRedirect(framework\Context::getRouting()->generate('login'));
                         } else {
                             if ($user == true) {
                                 $user = null;
                             }
                         }
                     } catch (\Exception $e) {
                         throw $e;
                     }
                 } elseif ($username !== null && $password !== null && !$user instanceof User) {
                     $external = false;
                     framework\Logging::log('Using internal authentication', 'auth', framework\Logging::LEVEL_INFO);
                     $user = self::getB2DBTable()->getByUsername($username);
                     if ($user instanceof User && !$user->hasPassword($password)) {
                         $user = null;
                     }
                     if (!$user instanceof User) {
                         framework\Context::logout();
                     }
                 }
                 break;
             case framework\Action::AUTHENTICATION_METHOD_DUMMY:
                 $user = self::getB2DBTable()->getByUserID(framework\Settings::getDefaultUserID());
                 break;
             case framework\Action::AUTHENTICATION_METHOD_CLI:
                 $user = self::getB2DBTable()->getByUsername(framework\Context::getCurrentCLIusername());
                 break;
             case framework\Action::AUTHENTICATION_METHOD_RSS_KEY:
                 $user = self::getB2DBTable()->getByRssKey($request['rsskey']);
                 break;
             case framework\Action::AUTHENTICATION_METHOD_APPLICATION_PASSWORD:
                 $user = self::getB2DBTable()->getByUsername($request['api_username']);
                 if (!$user->authenticateApplicationPassword($request['api_token'])) {
                     $user = null;
                 }
                 break;
         }
         if ($user === null && !framework\Settings::isLoginRequired()) {
             $user = self::getB2DBTable()->getByUserID(framework\Settings::getDefaultUserID());
         }
         if ($user instanceof User) {
             if (!$user->isActivated()) {
                 throw new \Exception('This account has not been activated yet');
             } elseif (!$user->isEnabled()) {
                 throw new \Exception('This account has been suspended');
             } elseif (!$user->isConfirmedMemberOfScope(framework\Context::getScope())) {
                 if (!framework\Settings::isRegistrationAllowed()) {
                     throw new \Exception('This account does not have access to this scope');
                 }
             }
             if ($external == false && $authentication_method == framework\Action::AUTHENTICATION_METHOD_CORE) {
                 $password = $user->getHashPassword();
                 if (!$request->hasCookie('tbg3_username') && !$user->isGuest()) {
                     if ($request->getParameter('tbg3_rememberme')) {
                         framework\Context::getResponse()->setCookie('tbg3_username', $user->getUsername());
                         framework\Context::getResponse()->setCookie('tbg3_password', $user->getPassword());
                     } else {
                         framework\Context::getResponse()->setSessionCookie('tbg3_username', $user->getUsername());
                         framework\Context::getResponse()->setSessionCookie('tbg3_password', $user->getPassword());
                     }
                 }
             }
         } elseif (framework\Settings::isLoginRequired()) {
             throw new \Exception('Login required');
         } else {
             throw new \Exception('No such login');
         }
     } catch (\Exception $e) {
         throw $e;
     }
     return $user;
 }
Exemplo n.º 24
0
<?php

if (function_exists('imagecreatetruecolor')) {
    // use of timestamped paramter in the captcha route for preventing image cache
    echo image_tag(\thebuggenie\core\framework\Context::getRouting()->generate('captcha', array(time())), array(), true, 'core', true);
} else {
    $chain = str_split($_SESSION['activation_number'], 1);
    foreach ($chain as $number) {
        echo image_tag('numbers/' . $number . '.png');
    }
}
?>
<li class="security_check">
    <label for="verification_no"><?php 
echo __('Enter the number you see above');
?>
</label>
    <input type="text" class="required" id="verification_no" name="verification_no" maxlength="6" value="" autocomplete="off" style="width: 100px;"><br><br>
</li>
Exemplo n.º 25
0
 public static function getFaviconURL()
 {
     return self::isUsingCustomFavicon() ? Context::getRouting()->generate('showfile', array('id' => self::getFaviconID())) : 'favicon.png';
 }
Exemplo n.º 26
0
 /**
  * Header wiki menu and search dropdown / list
  *
  * @Listener(module="core", identifier="templates/headermainmenu::projectmenulinks")
  *
  * @param \thebuggenie\core\framework\Event $event
  */
 public function listen_MenustripLinks(framework\Event $event)
 {
     $project_url = framework\Context::isProjectContext() ? framework\Context::getRouting()->generate('publish_article', array('article_name' => ucfirst(framework\Context::getCurrentProject()->getKey()) . ':MainPage')) : null;
     $wiki_url = framework\Context::isProjectContext() && framework\Context::getCurrentProject()->hasWikiURL() ? framework\Context::getCurrentProject()->getWikiURL() : null;
     $url = framework\Context::getRouting()->generate('publish');
     framework\ActionComponent::includeComponent('publish/menustriplinks', array('url' => $url, 'project_url' => $project_url, 'wiki_url' => $wiki_url, 'selected_tab' => $event->getParameter('selected_tab')));
 }
Exemplo n.º 27
0
              <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
          <![endif]-->
        <?php 
\thebuggenie\core\framework\Event::createNew('core', 'layout.php::header-ends')->trigger();
?>
    </head>
    <body id="body">
        <div id="main_container" class="page-<?php 
echo \thebuggenie\core\framework\Context::getRouting()->getCurrentRouteName();
?>
" data-url="<?php 
echo make_url('userdata');
?>
">
            <?php 
if (!in_array(\thebuggenie\core\framework\Context::getRouting()->getCurrentRouteName(), array('login_page', 'elevated_login_page', 'reset_password'))) {
    ?>
                <?php 
    \thebuggenie\core\framework\Logging::log('Rendering header');
    ?>
                <?php 
    require THEBUGGENIE_CORE_PATH . 'templates/headertop.inc.php';
    ?>
                <?php 
    \thebuggenie\core\framework\Logging::log('done (rendering header)');
    ?>
            <?php 
}
?>
            <div id="content_container">
                <?php 
Exemplo n.º 28
0
 public function componentLogin()
 {
     $this->selected_tab = isset($this->section) ? $this->section : 'login';
     $this->options = $this->getParameterHolder();
     if (framework\Context::hasMessage('login_referer')) {
         $this->referer = htmlentities(framework\Context::getMessage('login_referer'), ENT_COMPAT, framework\Context::getI18n()->getCharset());
     } elseif (array_key_exists('HTTP_REFERER', $_SERVER)) {
         $this->referer = htmlentities($_SERVER['HTTP_REFERER'], ENT_COMPAT, framework\Context::getI18n()->getCharset());
     } else {
         $this->referer = framework\Context::getRouting()->generate('dashboard');
     }
     try {
         $this->loginintro = null;
         $this->registrationintro = null;
         $this->loginintro = \thebuggenie\modules\publish\entities\tables\Articles::getTable()->getArticleByName('LoginIntro');
         $this->registrationintro = \thebuggenie\modules\publish\entities\tables\Articles::getTable()->getArticleByName('RegistrationIntro');
     } catch (\Exception $e) {
     }
     if (framework\Settings::isLoginRequired()) {
         framework\Context::getResponse()->deleteCookie('tbg3_username');
         framework\Context::getResponse()->deleteCookie('tbg3_password');
         $this->error = framework\Context::geti18n()->__('You need to log in to access this site');
     } elseif (!framework\Context::getUser()->isAuthenticated()) {
         $this->error = framework\Context::geti18n()->__('Please log in');
     } else {
         //$this->error = framework\Context::geti18n()->__('Please log in');
     }
 }
Exemplo n.º 29
0
 public function runUpgrade(framework\Request $request)
 {
     $version_info = explode(',', file_get_contents(THEBUGGENIE_PATH . 'installed'));
     $this->current_version = $version_info[0];
     $this->upgrade_available = $this->current_version != framework\Settings::getVersion(false);
     if ($this->upgrade_available) {
         $scope = new \thebuggenie\core\entities\Scope();
         $scope->setID(1);
         $scope->setEnabled();
         framework\Context::setScope($scope);
         if ($this->current_version == '3.2') {
             $this->statuses = \thebuggenie\core\entities\tables\ListTypes::getTable()->getStatusListForUpgrade();
             $this->adminusername = \thebuggenie\core\modules\installation\upgrade_32\TBGUsersTable::getTable()->getAdminUsername();
         }
     }
     $this->upgrade_complete = false;
     if ($this->upgrade_available && $request->isPost()) {
         $this->upgrade_complete = false;
         switch ($this->current_version) {
             case '3.2':
                 $this->_upgradeFrom3dot2($request);
                 break;
             default:
                 $this->upgrade_complete = true;
         }
         if ($this->upgrade_complete) {
             $existing_installed_content = file_get_contents(THEBUGGENIE_PATH . 'installed');
             file_put_contents(THEBUGGENIE_PATH . 'installed', framework\Settings::getVersion(false, false) . ', upgraded ' . date('d.m.Y H:i') . "\n" . $existing_installed_content);
             $this->current_version = framework\Settings::getVersion(false, false);
             $this->upgrade_available = false;
         }
     } elseif ($this->upgrade_available) {
         $this->permissions_ok = false;
         if (is_writable(THEBUGGENIE_PATH . 'installed') && is_writable(THEBUGGENIE_PATH . 'upgrade')) {
             $this->permissions_ok = true;
         }
     } elseif ($this->upgrade_complete) {
         $this->forward(framework\Context::getRouting()->generate('home'));
     }
 }
Exemplo n.º 30
0
<?php

if (\thebuggenie\core\framework\Context::getRouting()->getCurrentRouteName() != 'login_page') {
    ?>
    <a href="javascript:void(0);" onclick="TBG.Main.Login.showLogin('forgot_password_container');$('forgot_password_username').focus();"><?php 
    echo image_tag('icon_forgot.png') . __('Forgot password');
    ?>
</a>
<?php 
}