aboutsummaryrefslogtreecommitdiffstats
path: root/include/functions.inc.php
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--include/functions.inc.php46
1 files changed, 37 insertions, 9 deletions
diff --git a/include/functions.inc.php b/include/functions.inc.php
index d3fd3aee9..a9c48f33b 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -550,15 +550,8 @@ function get_query_string_diff($rejects = array())
{
if (!in_array($key, $rejects))
{
- if ($is_first)
- {
- $query_string.= '?';
- $is_first = false;
- }
- else
- {
- $query_string.= '&';
- }
+ $query_string.= $is_first ? '?' : '&';
+ $is_first = false;
$query_string.= $key.'='.$value;
}
}
@@ -695,4 +688,39 @@ function get_month_list($blockname, $selection)
'OPTION' => $lang['month'][$i]));
}
}
+
+/**
+ * fill the current user caddie with given elements, if not already in
+ * caddie
+ *
+ * @param array elements_id
+ */
+function fill_caddie($elements_id)
+{
+ global $user;
+
+ include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
+
+ $query = '
+SELECT element_id
+ FROM '.CADDIE_TABLE.'
+ WHERE user_id = '.$user['id'].'
+;';
+ $in_caddie = array_from_query($query, 'element_id');
+
+ $caddiables = array_diff($elements_id, $in_caddie);
+
+ $datas = array();
+
+ foreach ($caddiables as $caddiable)
+ {
+ array_push($datas, array('element_id' => $caddiable,
+ 'user_id' => $user['id']));
+ }
+
+ if (count($caddiables) > 0)
+ {
+ mass_inserts(CADDIE_TABLE, array('element_id','user_id'), $datas);
+ }
+}
?>