Initial revision
[mir.git] / source / mircoders / module / ModuleUsers.java
1 package mircoders.module;
2
3 import java.io.*;
4 import java.lang.*;
5 import java.util.*;
6 import java.sql.*;
7 import javax.servlet.*;
8 import javax.servlet.http.*;
9
10 import freemarker.template.*;
11
12 import webdb.servlet.*;
13 import webdb.module.*;
14 import webdb.entity.*;
15 import webdb.misc.*;
16 import webdb.storage.*;
17
18 import mir.entity.*;
19 import mir.storage.*;
20
21
22 /*
23  *  Users Module -
24  *
25  *
26  * @author RK
27  */
28
29 public class ModuleUsers extends AbstractModule
30 {
31         static Logfile theLog;
32
33         // Kontruktor
34
35         public ModuleUsers(StorageObject theStorage)
36         {
37
38                 if (theLog == null) theLog = Logfile.getInstance(Configuration.getProperty("Home") + Configuration.getProperty("Module.Users.Logfile"));
39                 if (theStorage == null) theLog.printWarning("StorageObject was null!");
40                 this.theStorage = theStorage;
41
42         }
43
44         /**
45          * login method
46          */
47
48         public EntityUsers getUserForLogin(String user, String password) throws ModuleException
49         {
50                 String whereString = "login='" +user + "' and password='"+ password + "' and is_admin='1'";
51                 EntityList userList = getByWhereClause(whereString, -1);
52                 if (userList != null && userList.getCount()==1)
53                         return (EntityUsers)userList.elementAt(0);
54                 else return null;
55         }
56
57
58
59         public EntityList getUsers(String whereClause, int offset, int limit)
60                 throws ModuleException
61         {
62                 try {
63                         return theStorage.selectByWhereClause(whereClause, null, offset, limit);
64                 }
65                 catch (StorageObjectException e){
66                         throw new ModuleException(e.toString());
67                 }
68         }
69
70         public SimpleList getUsersAsSimpleList() {
71                 //  String sql = "select id, name from Users order by name";
72                 return ((DatabaseUsers)theStorage).getPopupData();
73         }
74
75 }