Subversion-Projekte lars-tiefland.ci

Revision

Revision 1117 | Revision 2373 | 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: 2372 $
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
		";
2372 lars 41
		trigger_error($sql);
962 lars 42
		$res = $GLOBALS["db_red"]->query($sql);
999 lars 43
		$user = $res->row_array();
1002 lars 44
		list($user_local, $domain) = explode("@", $user["user"]);
45
		$user["domain"] = $domain;
46
		$user["local"] = $user_local;
1006 lars 47
		$user["datenquellen"] = unserialize($user["datenquellen"]);
962 lars 48
		return $user;
49
	}
1075 lars 50
 
51
	public function save($user)
52
	{
1077 lars 53
		if ($_SERVER['SERVER_NAME'] == "ci.starfleethq.de")
1075 lars 54
		{
55
			$GLOBALS['db_red_write'] = $GLOBALS['db_red'];
56
		}
57
		else
58
		{
59
			$GLOBALS['db_red_write'] = $this->load->database('db_red_write', TRUE);
60
		}
61
		$passwd = crypt($user['passwd']);
62
		if ($user["ID"])
63
		{
64
			$sql = "
65
				UPDATE
66
					Access
67
				SET
68
					name='".$user['name']."',
69
					user='".$user['user'].'@'.$GLOBALS["webs"]['domain']."',
1079 lars 70
			";
71
			if ($user["passwd"])
72
			{
73
				$sql .= "passwd='".$passwd."',";
74
			}
75
			$sql .= "
1075 lars 76
					ignoreRemoteHosts=".$user["ignoreRemoteHosts"].",
77
					email='".$user['email']."',
78
					telefon='".$user['telefon']."',
79
					fax='".$user['fax']."',
80
					dir='".$user['dir']."',
81
					beschreibung='".$user['beschreibung']."',
82
					mitarbeiter='".$user["Mitarbeiter"]."',
83
					app_user='".$user['app_user']."',
84
					letzte_aenderung_von='".$this->session->username."'
1082 lars 85
				WHERE
1075 lars 86
					id=".$user["ID"]."
87
			";
88
		}
89
		else
90
		{
91
			$sql = "
92
				INSERT INTO
93
					Access
94
				SET
95
					name='".$user['name']."',
96
					user='".$user['user'].'@'.$GLOBALS["webs"]['domain']."',
97
					passwd='".$passwd."',
98
					ignoreRemoteHosts=".$user["ignoreRemoteHosts"].",
99
					email='".$user['email']."',
100
					telefon='".$user['telefon']."',
101
					fax='".$user['fax']."',
102
					dir='".$user['dir']."',
103
					beschreibung='".$user['beschreibung']."',
104
					mitarbeiter='".$user["Mitarbeiter"]."',
105
					app_user='".$user['app_user']."',
106
					erstellt_am=NOW(),
107
					erstellt_von='".$this->session->username."'
108
			";
109
		}
110
		$GLOBALS['db_red_write']->query($sql);
111
	}
1110 lars 112
 
113
	public function del()
114
	{
115
		if ($_SERVER['SERVER_NAME'] == "ci.starfleethq.de")
116
		{
117
			$GLOBALS['db_red_write'] = $GLOBALS['db_red'];
118
		}
119
		else
120
		{
121
			$GLOBALS['db_red_write'] = $this->load->database('db_red_write', TRUE);
122
		}
123
		$sql="
124
			DELETE FROM
125
				Access
126
			WHERE
127
				ID = ".$this->input->post('id')."
128
		";
129
		$res = $GLOBALS["db_red_write"]->query($sql);
130
		if ($res)
131
		{
1115 lars 132
			$msg = "Benutzer wurde erfolgreich gelöscht!";
1110 lars 133
		}
134
		else
135
		{
136
			$msg = "Leider ist ein Fehler aufgetreten.<br>";
1115 lars 137
			$msg .= "Bitte versuchen Sie es später noch einmal!<br>";
1110 lars 138
			//$msg .= mysql_error();
139
		}
140
		return $msg;
141
	}
951 lars 142
}
143
 
144
?>