summaryrefslogtreecommitdiff
path: root/app/helpers.php
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-10-04 23:31:03 -0400
committerFrédéric Guillot <fred@kanboard.net>2014-10-04 23:31:03 -0400
commit8e5673e3d289e4d28b4fc9f20721bda9f1c858c7 (patch)
treea5dc3eff7408e8709d20ea92b926c5424d70c5f9 /app/helpers.php
parentf531d57dc27b9d1568de0a10b19f69e8c2b2f156 (diff)
Improve settings page and move some config parameters to the database
Diffstat (limited to 'app/helpers.php')
-rw-r--r--app/helpers.php29
1 files changed, 25 insertions, 4 deletions
diff --git a/app/helpers.php b/app/helpers.php
index 5cb7b82e..1ab8586a 100644
--- a/app/helpers.php
+++ b/app/helpers.php
@@ -556,16 +556,37 @@ function form_numeric($name, $values = array(), array $errors = array(), array $
* @param string $controller Controller name
* @param string $action Action name
* @param array $params Url parameters
+ * @param boolean $csrf Add a CSRF token
* @param string $class CSS class attribute
* @return string
*/
-function a($label, $controller, $action, array $params = array(), $css = '')
+function a($label, $controller, $action, array $params = array(), $csrf = false, $class = '')
{
- $html = '<a href="?controller='.$controller.'&amp;action='.$action;
+ return '<a href="'.u($controller, $action, $params, $csrf).'" class="'.$class.'"/>'.$label.'</a>';
+}
+
+/**
+ * URL
+ *
+ * a('link', 'task', 'show', array('task_id' => $task_id))
+ *
+ * @param string $controller Controller name
+ * @param string $action Action name
+ * @param array $params Url parameters
+ * @param boolean $csrf Add a CSRF token
+ * @return string
+ */
+function u($controller, $action, array $params = array(), $csrf = false)
+{
+ $html = '?controller='.$controller.'&amp;action='.$action;
+
+ if ($csrf) {
+ $params['csrf_token'] = Security::getCSRFToken();
+ }
foreach ($params as $key => $value) {
$html .= '&amp;'.$key.'='.$value;
}
- return '" class="'.$class.'"/>'.$label.'</a>';
-}
+ return $html;
+} \ No newline at end of file