Make graphing a config option
Make graphing a config option

--- a/config/gitphp.conf.defaults.php
+++ b/config/gitphp.conf.defaults.php
@@ -248,6 +248,13 @@
  */
 $gitphp_conf['filemimetype'] = true;
 
+/*
+ * graphs
+ * Enable access to graphing and analytics features.
+ * Loading graph data can be resource intensive, especially
+ * on large projects.
+ */
+$gitphp_conf['graphs'] = false;
 
 
 

--- a/include/Config.class.php
+++ b/include/Config.class.php
@@ -162,6 +162,7 @@
 		$this->values['exportedonly'] = false;
 		$this->values['compressformat'] = GITPHP_COMPRESS_ZIP;
 		$this->values['locale'] = 'en_US';
+		$this->values['graphs'] = false;
 	}
 
 }

--- a/include/controller/ControllerBase.class.php
+++ b/include/controller/ControllerBase.class.php
@@ -470,6 +470,8 @@
 			$this->tpl->assign('currentlocale', 'en_US');
 		}
 		$this->tpl->assign('supportedlocales', GitPHP_Resource::SupportedLocales(true));
+		if ($this->config->GetValue('graphs'))
+			$this->tpl->assign('enablegraphs', true);
 
 		$scripturl = $_SERVER['SCRIPT_NAME'];
 		$fullscripturl = '';

--- a/include/controller/Controller_Graph.class.php
+++ b/include/controller/Controller_Graph.class.php
@@ -9,6 +9,18 @@
  */
 class GitPHP_Controller_Graph extends GitPHP_ControllerBase
 {
+	/**
+	 * Constructor
+	 */
+	public function __construct()
+	{
+		parent::__construct();
+
+		if (!$this->config->GetValue('graphs')) {
+			throw new Exception('Graphing has been disabled');
+		}
+	}
+
 	/**
 	 * Gets the template for this controller
 	 *

--- a/include/controller/Controller_GraphData.class.php
+++ b/include/controller/Controller_GraphData.class.php
@@ -15,6 +15,11 @@
 	public function __construct()
 	{
 		parent::__construct();
+
+		if (!$this->config->GetValue('graphs')) {
+			throw new Exception('Graphing has been disabled');
+		}
+
 		$this->preserveWhitespace = true;
 		$this->DisableLogging();
 	}

--- a/templates/nav.tpl
+++ b/templates/nav.tpl
@@ -44,10 +44,12 @@
    {else}
      <a href="{$scripturl}?p={$project->GetProject()|rawurlencode}&amp;a=tree{if $treecommit}&amp;hb={$treecommit->GetHash()}{/if}{if $tree}&amp;h={$tree->GetHash()}{/if}">{t}tree{/t}</a>
    {/if}
+   {if $enablegraphs}
    |
    {if $current=='graph' || !$commit}
      {t}graph{/t}
    {else}
      <a href="{$SCRIPTURL}?p={$project->GetProject()|rawurlencode}&amp;a=graph">{t}graph{/t}</a>
    {/if}
+   {/if}
 

comments