summaryrefslogtreecommitdiffstats
path: root/vmail-controller.lua
blob: d087833007ce08b2f3cc951ca3481be391737631 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
module (..., package.seeall)

require("controllerfunctions")

default_action = "listmessages"

listfolders = function( self )
	return self.model.list_folders()
end

listusers = function( self )
	return self.model.list_users()
end

editusers = function( self )
	return self.model.list_users()
end

deleteuser = function( self )
	return controllerfunctions.handle_form(self, self.model.get_delete_user, self.model.set_delete_user, self.clientdata, "Delete", "Delete User", "User Deleted")
end

listmessages = function( self )
	return self.model.list_messages(self.clientdata.username)
end

listmymessages = function( self )
	return self.model.list_messages(self.sessiondata.userinfo.userid)
end

downloadmessage = function( self )
	self.conf.viewtype = "stream"
	return self.model.get_message(self.clientdata.message)
end

downloadmymessage = function( self )
	self.conf.viewtype = "stream"
	return self.model.get_message(self.clientdata.message, self.sessiondata.userinfo.userid)
end

deletemessage = function( self )
	return self:redirect_to_referrer(self.model.delete_message(self.clientdata.message))
end

deletemymessage = function( self )
	return self:redirect_to_referrer(self.model.delete_message(self.clientdata.message, self.sessiondata.userinfo.userid))
end

forwardmessage = function( self )
	return self:redirect_to_referrer(self.model.forward_message(self.clientdata.message, self.clientdata.newuser))
end

forwardmymessage = function( self )
	return self:redirect_to_referrer(self.model.forward_message(self.clientdata.message, self.clientdata.newuser, self.sessiondata.userinfo.userid))
end

emailmessage = function( self )
	return self:redirect_to_referrer(self.model.email_message(self.clientdata.message, self.clientdata.address))
end

emailmymessage = function( self )
	return self:redirect_to_referrer(self.model.email_message(self.clientdata.message, self.clientdata.address, self.sessiondata.userinfo.userid))
end

movemessage = function( self )
	return self:redirect_to_referrer(self.model.move_message(self.clientdata.message, self.clientdata.newfolder))
end

movemymessage = function( self )
	return self:redirect_to_referrer(self.model.move_message(self.clientdata.message, self.clientdata.newfolder, self.sessiondata.userinfo.userid))
end

callbackmessage = function( self )
	return self:redirect_to_referrer(self.model.callback_message(self.clientdata.message, self.clientdata.extension))
end

callbackmymessage = function( self )
	return self:redirect_to_referrer(self.model.callback_message(self.clientdata.message, self.clientdata.extension, self.sessiondata.userinfo.userid))
end

editusersettings = function( self )
	return controllerfunctions.handle_form(self, self.model.get_usersettings, self.model.update_usersettings, self.clientdata, "Save", "Edit Settings", "Settings Saved")
end

editmyusersettings = function( self )
	self.clientdata.username = nil
	if self.sessiondata.userinfo then
		self.clientdata.username = self.sessiondata.userinfo.userid
	end
	return controllerfunctions.handle_form(self, self.model.get_usersettings, self.model.update_usersettings, self.clientdata, "Save", "Edit Settings", "Settings Saved")
end

createuser = function( self )
	return controllerfunctions.handle_form(self, self.model.get_usersettings, self.model.create_usersettings, self.clientdata, "Create", "Create User", "User Created")
end

processdialplanxml = function( self )
	self.conf.viewtype = "xml"
	return self.model.process_dialplan_xml_request(self.clientdata)
end

processdirectoryxml = function( self )
	self.conf.viewtype = "xml"
	return self.model.process_directory_xml_request(self.clientdata)
end

editconfig = function( self )
	return controllerfunctions.handle_form(self, self.model.get_config, self.model.update_config, self.clientdata, "Save", "Update Config", "Config Saved")
end