OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 83 | Rev 94 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 83 Rev 93
Line 27... Line 27...
27
import org.openconcerto.erp.core.humanresources.payroll.element.CaisseCotisationSQLElement;
27
import org.openconcerto.erp.core.humanresources.payroll.element.CaisseCotisationSQLElement;
28
import org.openconcerto.erp.element.objet.ClasseCompte;
28
import org.openconcerto.erp.element.objet.ClasseCompte;
29
import org.openconcerto.erp.modules.ModuleFrame;
29
import org.openconcerto.erp.modules.ModuleFrame;
30
import org.openconcerto.erp.modules.ModuleManager;
30
import org.openconcerto.erp.modules.ModuleManager;
31
import org.openconcerto.erp.panel.ComptaTipsFrame;
31
import org.openconcerto.erp.panel.ComptaTipsFrame;
-
 
32
import org.openconcerto.erp.rights.GroupUIComboRightEditor;
-
 
33
import org.openconcerto.erp.rights.MenuComboRightEditor;
32
import org.openconcerto.erp.utils.NXDatabaseAccessor;
34
import org.openconcerto.erp.utils.NXDatabaseAccessor;
33
import org.openconcerto.map.model.Ville;
35
import org.openconcerto.map.model.Ville;
34
import org.openconcerto.sql.Configuration;
36
import org.openconcerto.sql.Configuration;
35
import org.openconcerto.sql.element.SQLElement;
37
import org.openconcerto.sql.element.SQLElement;
36
import org.openconcerto.sql.model.SQLBackgroundTableCache;
38
import org.openconcerto.sql.model.SQLBackgroundTableCache;
Line 45... Line 47...
45
import org.openconcerto.sql.preferences.UserProps;
47
import org.openconcerto.sql.preferences.UserProps;
46
import org.openconcerto.sql.sqlobject.IComboSelectionItem;
48
import org.openconcerto.sql.sqlobject.IComboSelectionItem;
47
import org.openconcerto.sql.ui.ConnexionPanel;
49
import org.openconcerto.sql.ui.ConnexionPanel;
48
import org.openconcerto.sql.users.User;
50
import org.openconcerto.sql.users.User;
49
import org.openconcerto.sql.users.UserManager;
51
import org.openconcerto.sql.users.UserManager;
-
 
52
import org.openconcerto.sql.users.rights.SQLTableRightEditor;
50
import org.openconcerto.sql.users.rights.TableAllRights;
53
import org.openconcerto.sql.users.rights.TableAllRights;
51
import org.openconcerto.sql.users.rights.UserRightsManager;
54
import org.openconcerto.sql.users.rights.UserRightsManager;
52
import org.openconcerto.sql.users.rights.UserRightsManager.RightTuple;
55
import org.openconcerto.sql.users.rights.UserRightsManager.RightTuple;
53
import org.openconcerto.sql.utils.BackupPanel;
56
import org.openconcerto.sql.utils.BackupPanel;
54
import org.openconcerto.task.config.ComptaBasePropsConfiguration;
57
import org.openconcerto.task.config.ComptaBasePropsConfiguration;
Line 133... Line 136...
133
                        SQLPreferences.startMemCached(comptaPropsConfiguration.getRootSociete());
136
                        SQLPreferences.startMemCached(comptaPropsConfiguration.getRootSociete());
134
                    } catch (Exception e) {
137
                    } catch (Exception e) {
135
                        // don't die now, we might not need them
138
                        // don't die now, we might not need them
136
                        ExceptionHandler.handle("Impossible d'accéder aux préférences", e);
139
                        ExceptionHandler.handle("Impossible d'accéder aux préférences", e);
137
                    }
140
                    }
-
 
141
 
138
                    // needed by openEmergencyModuleManager()
142
                    // needed by openEmergencyModuleManager()
139
                    UserRightsManager.getInstance().addRightForAdmins(new RightTuple(ModuleManager.MODULE_DB_RIGHT, true));
143
                    UserRightsManager.getInstance().addRightForAdmins(new RightTuple(ModuleManager.MODULE_DB_RIGHT, true));
140
                    UserRightsManager.getInstance().addRightForAdmins(new RightTuple(BackupPanel.RIGHT_CODE, true));
144
                    UserRightsManager.getInstance().addRightForAdmins(new RightTuple(BackupPanel.RIGHT_CODE, true));
141
                    // finish filling the configuration before going any further, otherwise the
145
                    // finish filling the configuration before going any further, otherwise the
142
                    // SQLElementDirectory is not coherent
146
                    // SQLElementDirectory is not coherent
Line 153... Line 157...
153
                    final User user = UserManager.getInstance().getCurrentUser();
157
                    final User user = UserManager.getInstance().getCurrentUser();
154
                    // Si l'utilisateur n'est pas superUser ou si il n'a pas de droit d'accéder
158
                    // Si l'utilisateur n'est pas superUser ou si il n'a pas de droit d'accéder
155
                    // à toutes les société
159
                    // à toutes les société
156
                    final int userId = user.getId();
160
                    final int userId = user.getId();
157
                    if (!user.getRights().isSuperUser() && !user.getRights().haveRight("ACCES_ALL_SOCIETE")) {
161
                    if (!user.getRights().isSuperUser() && !user.getRights().haveRight("ACCES_ALL_SOCIETE")) {
158
                        final boolean emptyMeansAllow;
-
 
159
                        {
-
 
160
                            emptyMeansAllow = true;
-
 
161
                        }
-
 
162
 
162
 
163
                        final SQLTable tableAcces = comptaPropsConfiguration.getRoot().findTable("ACCES_SOCIETE");
163
                        final SQLTable tableAcces = comptaPropsConfiguration.getRoot().findTable("ACCES_SOCIETE");
164
                        SQLSelect sel = new SQLSelect();
164
                        SQLSelect sel = new SQLSelect();
165
                        sel.addSelectStar(tableAcces);
165
                        sel.addSelectStar(tableAcces);
166
                        sel.setWhere(new Where(tableAcces.getField("ID_USER_COMMON"), "=", userId));
166
                        sel.setWhere(new Where(tableAcces.getField("ID_USER_COMMON"), "=", userId));
167
                        if (!emptyMeansAllow) {
-
 
168
                            sel.andWhere(new Where(tableAcces.getField("ID_SOCIETE_COMMON"), "=", selectedSociete));
-
 
169
                        }
-
 
170
 
167
 
171
                        final List<SQLRow> accessRows = SQLRowListRSH.execute(sel);
168
                        final List<SQLRow> accessRows = SQLRowListRSH.execute(sel);
172
                        final boolean accessGranted;
169
                        final boolean accessGranted;
173
                        if (!emptyMeansAllow) {
-
 
174
                            accessGranted = accessRows.size() > 0;
-
 
175
                        } else {
-
 
176
                            if (accessRows.size() == 0) {
170
                        if (accessRows.size() == 0) {
177
                                accessGranted = true;
171
                            accessGranted = true;
178
                            } else {
172
                        } else {
179
                                boolean tmp = false;
173
                            boolean tmp = false;
180
                                for (final SQLRow r : accessRows) {
174
                            for (final SQLRow r : accessRows) {
Line 183... Line 177...
183
                                        break;
177
                                    break;
184
                                    }
178
                                }
185
                                }
179
                            }
186
                                accessGranted = tmp;
180
                            accessGranted = tmp;
187
                            }
181
                        }
188
                        }
-
 
189
 
182
 
190
                        if (!accessGranted) {
183
                        if (!accessGranted) {
191
                            JOptionPane.showMessageDialog(null, "Vous n'avez pas les droits suffisants, pour accéder à cette société!");
184
                            JOptionPane.showMessageDialog(null, "Vous n'avez pas les droits suffisants, pour accéder à cette société!");
192
                            return;
185
                            return;
193
                        }
186
                        }
194
                    }
187
                    }
195
 
188
 
196
                    SwingUtilities.invokeLater(new Runnable() {
189
                    SwingUtilities.invokeLater(new Runnable() {
197
                        @Override
190
                        @Override
198
                        public void run() {
191
                        public void run() {
-
 
192
                            MenuComboRightEditor.register();
-
 
193
                            GroupUIComboRightEditor.register();
-
 
194
                            SQLTableRightEditor.register();
199
                            // even for quick login, check the license before displaying the main
195
                            // even for quick login, check the license before displaying the main
200
                            // frame
196
                            // frame
201
 
197
 
202
                            MutableListComboPopupListener.setLockOverridable(user.getRights().isSuperUser());
198
                            MutableListComboPopupListener.setLockOverridable(user.getRights().isSuperUser());
203
 
199
 
Line 276... Line 272...
276
        c.fill = GridBagConstraints.BOTH;
272
        c.fill = GridBagConstraints.BOTH;
277
 
273
 
278
        this.connexionPanel = ConnexionPanel.create(r, image, !Gestion.isMinimalMode());
274
        this.connexionPanel = ConnexionPanel.create(r, image, !Gestion.isMinimalMode());
279
        if (this.connexionPanel == null)
275
        if (this.connexionPanel == null)
280
            return null;
276
            return null;
281
        this.connexionPanel.initLocalization(getClass().getName(),
277
        this.connexionPanel.initLocalization(getClass().getName(), Arrays.asList(Locale.FRANCE, Locale.CANADA_FRENCH, new Locale("fr", "CH"), new Locale("fr", "BE"), Locale.UK, Locale.CANADA,
282
                Arrays.asList(Locale.FRANCE, Locale.CANADA_FRENCH, new Locale("fr", "CH"), new Locale("fr", "BE"), Locale.UK, Locale.CANADA, Locale.US, Locale.GERMANY, new Locale("de", "CH")));
278
                Locale.US, Locale.GERMANY, new Locale("de", "CH"), new Locale("pl", "PL")));
283
 
279
 
284
        p.add(this.connexionPanel, c);
280
        p.add(this.connexionPanel, c);
285
        final PanelFrame panelFrame = new PanelFrame(p, "Connexion");
281
        final PanelFrame panelFrame = new PanelFrame(p, "Connexion");
286
        panelFrame.setLocationRelativeTo(null);
282
        panelFrame.setLocationRelativeTo(null);
287
        panelFrame.pack();
283
        panelFrame.pack();
Line 328... Line 324...
328
                tablesToCache.add(baseSociete.getTable("SAISIE_KM_ELEMENT"));
324
                tablesToCache.add(baseSociete.getTable("SAISIE_KM_ELEMENT"));
329
                tablesToCache.add(baseSociete.getTable("BON_DE_LIVRAISON_ELEMENT"));
325
                tablesToCache.add(baseSociete.getTable("BON_DE_LIVRAISON_ELEMENT"));
330
                tablesToCache.add(baseSociete.getTable("COMMANDE_CLIENT_ELEMENT"));
326
                tablesToCache.add(baseSociete.getTable("COMMANDE_CLIENT_ELEMENT"));
331
                tablesToCache.add(baseSociete.getTable("AVOIR_CLIENT_ELEMENT"));
327
                tablesToCache.add(baseSociete.getTable("AVOIR_CLIENT_ELEMENT"));
332
                tablesToCache.add(baseSociete.getTable("BON_RECEPTION_ELEMENT"));
328
                tablesToCache.add(baseSociete.getTable("BON_RECEPTION_ELEMENT"));
-
 
329
                tablesToCache.add(baseSociete.getTable("ASSOCIATION_ANALYTIQUE"));
333
                undefCache.preload(tablesToCache);
330
                undefCache.preload(tablesToCache);
334
            }
331
            }
335
 
332
 
336
        };
333
        };
337
        t.setName("Cache preload");
334
        t.setName("Cache preload");