Subversion-Projekte lars-tiefland.ci

Revision

Revision 1116 | Revision 2372 | Zur aktuellen Revision | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
951 lars 1
<?php
2
 
3
/**
4
 *
5
 * @package WebanOS CI
6
 * @author Lars Tiefland <ltiefland@gmail.com>
7
 * @copyright 2016
8
 * @version $Rev: 1117 $
9
 */
10
 
11
class User_model extends CI_Model
12
{
13
	public function __construct()
14
	{
15
		parent::__construct();
16
	}
17
 
18
	public function user_list()
19
	{
20
		$sql = "SELECT
21
				*
22
			FROM
23
				Access
964 lars 24
			WHERE
1044 lars 25
				user LIKE '%@".__SHOP__."'
951 lars 26
		";
27
		$res = $GLOBALS['db_red']->query($sql);
28
		$users = $res->result_array();
29
		return $users;
30
	}
962 lars 31
 
32
	public function get_info($user_id)
33
	{
34
		$sql = "SELECT
35
				*
36
			FROM
37
				Access
38
			WHERE
39
				id=".$user_id."
40
		";
41
		$res = $GLOBALS["db_red"]->query($sql);
999 lars 42
		$user = $res->row_array();
1002 lars 43
		list($user_local, $domain) = explode("@", $user["user"]);
44
		$user["domain"] = $domain;
45
		$user["local"] = $user_local;
1006 lars 46
		$user["datenquellen"] = unserialize($user["datenquellen"]);
962 lars 47
		return $user;
48
	}
1075 lars 49
 
50
	public function save($user)
51
	{
1077 lars 52
		if ($_SERVER['SERVER_NAME'] == "ci.starfleethq.de")
1075 lars 53
		{
54
			$GLOBALS['db_red_write'] = $GLOBALS['db_red'];
55
		}
56
		else
57
		{
58
			$GLOBALS['db_red_write'] = $this->load->database('db_red_write', TRUE);
59
		}
60
		$passwd = crypt($user['passwd']);
61
		if ($user["ID"])
62
		{
63
			$sql = "
64
				UPDATE
65
					Access
66
				SET
67
					name='".$user['name']."',
68
					user='".$user['user'].'@'.$GLOBALS["webs"]['domain']."',
1079 lars 69
			";
70
			if ($user["passwd"])
71
			{
72
				$sql .= "passwd='".$passwd."',";
73
			}
74
			$sql .= "
1075 lars 75
					ignoreRemoteHosts=".$user["ignoreRemoteHosts"].",
76
					email='".$user['email']."',
77
					telefon='".$user['telefon']."',
78
					fax='".$user['fax']."',
79
					dir='".$user['dir']."',
80
					beschreibung='".$user['beschreibung']."',
81
					mitarbeiter='".$user["Mitarbeiter"]."',
82
					app_user='".$user['app_user']."',
83
					letzte_aenderung_von='".$this->session->username."'
1082 lars 84
				WHERE
1075 lars 85
					id=".$user["ID"]."
86
			";
87
		}
88
		else
89
		{
90
			$sql = "
91
				INSERT INTO
92
					Access
93
				SET
94
					name='".$user['name']."',
95
					user='".$user['user'].'@'.$GLOBALS["webs"]['domain']."',
96
					passwd='".$passwd."',
97
					ignoreRemoteHosts=".$user["ignoreRemoteHosts"].",
98
					email='".$user['email']."',
99
					telefon='".$user['telefon']."',
100
					fax='".$user['fax']."',
101
					dir='".$user['dir']."',
102
					beschreibung='".$user['beschreibung']."',
103
					mitarbeiter='".$user["Mitarbeiter"]."',
104
					app_user='".$user['app_user']."',
105
					erstellt_am=NOW(),
106
					erstellt_von='".$this->session->username."'
107
			";
108
		}
109
		$GLOBALS['db_red_write']->query($sql);
110
	}
1110 lars 111
 
112
	public function del()
113
	{
114
		if ($_SERVER['SERVER_NAME'] == "ci.starfleethq.de")
115
		{
116
			$GLOBALS['db_red_write'] = $GLOBALS['db_red'];
117
		}
118
		else
119
		{
120
			$GLOBALS['db_red_write'] = $this->load->database('db_red_write', TRUE);
121
		}
122
		$sql="
123
			DELETE FROM
124
				Access
125
			WHERE
126
				ID = ".$this->input->post('id')."
127
		";
128
		$res = $GLOBALS["db_red_write"]->query($sql);
129
		if ($res)
130
		{
1115 lars 131
			$msg = "Benutzer wurde erfolgreich gelöscht!";
1110 lars 132
		}
133
		else
134
		{
135
			$msg = "Leider ist ein Fehler aufgetreten.<br>";
1115 lars 136
			$msg .= "Bitte versuchen Sie es später noch einmal!<br>";
1110 lars 137
			//$msg .= mysql_error();
138
		}
139
		return $msg;
140
	}
951 lars 141
}
142
 
143
?>