noalyss-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Noalyss-commit] [noalyss] 03/09: Widget : javascript variable uniq


From: dwm
Subject: [Noalyss-commit] [noalyss] 03/09: Widget : javascript variable uniq
Date: Mon, 19 Aug 2024 15:03:09 -0400 (EDT)

sparkyx pushed a commit to branch unstable
in repository noalyss.

commit 9d1f7bf29d2cdc76ff984fccb4bdb9f7d6546ef1
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Sun Aug 18 22:42:17 2024 +0200

    Widget : javascript variable uniq
---
 include/dashboard.inc.php |  3 +++
 include/widget/ajax.php   |  5 ++++-
 include/widget/widget.php | 10 +++++++---
 3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/include/dashboard.inc.php b/include/dashboard.inc.php
index 2a00531bc..90903bf23 100644
--- a/include/dashboard.inc.php
+++ b/include/dashboard.inc.php
@@ -11,3 +11,6 @@ echo \HtmlInput::button_action(_('Elements du tableau de 
bord'), "widget.manage(
 
 
 ?>
+<script>
+var widget=new Widget('<?=\Dossier::id()?>')
+</script>
diff --git a/include/widget/ajax.php b/include/widget/ajax.php
index b3dd83897..b6f095490 100644
--- a/include/widget/ajax.php
+++ b/include/widget/ajax.php
@@ -95,7 +95,10 @@ if ( $action == 'widget.save') {
     $query=$http->request("param","string","");
     try {
         parse_str($query, $aWigdet);
-        \Noalyss\Widget\Widget::save($aWigdet['contain_widget']);
+        if (isset ($aWigdet['contain_widget']))
+            \Noalyss\Widget\Widget::save($aWigdet['contain_widget']);
+        else
+            \Noalyss\Widget\Widget::save(array());
 
     } catch (\Exception $e) {
         echo "NOK";
diff --git a/include/widget/widget.php b/include/widget/widget.php
index d96d31e46..3ccb38c34 100644
--- a/include/widget/widget.php
+++ b/include/widget/widget.php
@@ -180,10 +180,11 @@ where use_login=$1 order by uw.uw_order
         $widget->close_div();
 
         $dossier_id=\Dossier::id();
+        $widgetjs=uniqid('widget');
         echo <<<EOF
 <script>
-var widget= new Widget('{$dossier_id}') 
-widget.display('{$box}',{$widget->get_user_widget_id()},'{$widget->get_widget_code()}')
+var {$widgetjs}= new Widget('{$dossier_id}') 
+{$widgetjs}.display('{$box}',{$widget->get_user_widget_id()},'{$widget->get_widget_code()}')
 </script>
 
 
@@ -218,8 +219,11 @@ EOF;
      * @exception DatabaseCore fails , cannot update
      */
     static function save($array) {
-        if (empty($array)) return;
         global $cn,$g_user;
+        if (empty($array)) {
+            $cn->exec_sql("delete from user_widget where use_login = 
$1",[$g_user->getLogin()]);
+            return;
+        }
         try {
             $cn->start();
             $order=10;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]