-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathLMS.Helper.Browser.pas
More file actions
144 lines (113 loc) · 4.6 KB
/
LMS.Helper.Browser.pas
File metadata and controls
144 lines (113 loc) · 4.6 KB
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
unit LMS.Helper.Browser;
interface
uses
LMS._interface.LMS;
// Opens Moodle instace, category or course at the default system browser
procedure OpenInBrowser(const aURL: string); overload;
procedure OpenInBrowser(const aLMS: ILMS); overload;
procedure OpenInBrowser(const aCategory: ICategory); overload;
procedure OpenInBrowser(const aCourse: ICourse); overload;
procedure OpenInBrowser(const aUser: IUser); overload;
procedure OpenInBrowser(const aUser: IUser; const aCourse: ICourse); overload;
//
procedure OpenUsersInBrowser(const aLMS: ILMS); overload;
procedure OpenUsersInBrowser(const aCourse: ICourse); overload;
procedure OpenUploadUsersInBrowser(const aLMS: ILMS);
procedure OpenUserInCourseInBrowser(const aUser: IUser);
procedure OpenEditProfileInBrowser(const aUser: IUser; const aCourse: ICourse);
procedure OpenCreateUserInBrowser(const aLMS: ILMS);
procedure OpenInBrowserByLMS(const aLMS: ILMS; const aUser: IUser);
procedure OpenEditProfileByLMS(const aLMS: ILMS; const aUser: IUser);
// Edit course
procedure OpenEditCourseInBrowser(const aCourse: ICourse);
// Services
procedure OpenExternalServices(const aLMS: ILMS);
procedure OpenWebServiceDocumentation(const aLMS: ILMS);
procedure OpenShell(const path: string);
implementation
uses
sysutils,
Winapi.ShellAPI,
windows,
LMS.Helper.Consts;
procedure OpenInBrowser(const aURL: string); overload;
begin
ShellExecute(0, 'open', PChar(aURL), nil, nil, 0); // SW_SHOW);
end;
procedure OpenInBrowser(const aLMS: ILMS); overload;
begin
ShellExecute(0, 'open', PChar(aLMS.Host), nil, nil, 0); // SW_SHOW);
end;
procedure OpenInBrowser(const aCategory: ICategory); overload;
begin
ShellExecute(0, 'open', PChar(aCategory.LMS.Host + format(CATEGORY_VIEW, [aCategory.id])), nil, nil, 0); // SW_SHOW);
end;
procedure OpenInBrowser(const aCourse: ICourse); overload;
begin
ShellExecute(0, 'open', PChar(aCourse.LMS.Host + format(COURSE_VIEW, [aCourse.id])), nil, nil, 0); // SW_SHOW);
end;
procedure OpenUsersInBrowser(const aLMS: ILMS); overload;
begin
ShellExecute(0, 'open', PChar(aLMS.Host + ADMIN_USER), nil, nil, 0);
// SW_SHOW);
end;
procedure OpenUsersInBrowser(const aCourse: ICourse); overload;
begin
ShellExecute(0, 'open', PChar(aCourse.LMS.Host + format(USERS_VIEW, [aCourse.id])), nil, nil, 0); // SW_SHOW);
end;
procedure OpenInBrowser(const aUser: IUser); overload;
begin
ShellExecute(0, 'open', PChar(aUser.Course.LMS.Host + format(PROFILE_VIEW, [aUser.id])), nil, nil, 0); // SW_SHOW);
end;
procedure OpenInBrowser(const aUser: IUser; const aCourse: ICourse); overload;
begin
ShellExecute(0, 'open', PChar(aUser.Course.LMS.Host + format(PROFILE_VIEW_IN_COURSE, [aUser.id, aCourse.id])), nil, nil, 0);
// SW_SHOW);
end;
procedure OpenEditProfileInBrowser(const aUser: IUser; const aCourse: ICourse);
begin
ShellExecute(0, 'open', PChar(aUser.Course.LMS.Host + format(EDIT_PROFILE_IN_COURSE, [aUser.id, aCourse.id])), nil, nil, 0);
// SW_SHOW);
end;
procedure OpenEditCourseInBrowser(const aCourse: ICourse);
begin
ShellExecute(0, 'open', PChar(aCourse.LMS.Host + format(EDIT_COURSE, [aCourse.id])), nil, nil, 0); // SW_SHOW);
end;
procedure OpenExternalServices(const aLMS: ILMS);
begin
ShellExecute(0, 'open', PChar(aLMS.Host + ADMIN_SETTINGS_EXTERNALSERVICES), nil, nil, 0); // SW_SHOW);
end;
procedure OpenUserInCourseInBrowser(const aUser: IUser);
begin
ShellExecute(0, 'open', PChar(aUser.Course.LMS.Host + format(USERS_VIEW_FIRSTNAME_LASTNAME, [aUser.Course.id, UpperCase(aUser.First_Name[1]), UpperCase(aUser.Last_Name[1])])), nil, nil, 0);
// SW_SHOW);
// https://campusvirtual.unia.es/user/index.php?id=119&tifirst=J&tilast=A
end;
procedure OpenCreateUserInBrowser(const aLMS: ILMS);
begin
ShellExecute(0, 'open', PChar(aLMS.Host + USER_CREATE), nil, nil, 0);
end;
procedure OpenUploadUsersInBrowser(const aLMS: ILMS);
begin
ShellExecute(0, 'open', PChar(aLMS.Host + USERS_UPLOAD), nil, nil, 0);
end;
procedure OpenInBrowserByLMS(const aLMS: ILMS; const aUser: IUser);
begin
ShellExecute(0, 'open', PChar(aLMS.Host + format(PROFILE_VIEW, [aUser.id])), nil, nil, 0); // SW_SHOW);
end;
procedure OpenEditProfileByLMS(const aLMS: ILMS; const aUser: IUser);
begin
ShellExecute(0, 'open', PChar(aLMS.Host + format(EDIT_PROFILE, [aUser.id])), nil, nil, 0); // SW_SHOW);
end;
procedure OpenWebServiceDocumentation(const aLMS: ILMS);
begin
ShellExecute(0, 'open', PChar(aLMS.Host + ADMIN_WEBSERVICE_DOCUMENTATION), nil, nil, 0); // SW_SHOW);
end;
procedure OpenShell(const path: string);
var
thepath: PWideChar;
begin
thepath := PWideChar(path); //'/select,' + path);
ShellExecute(0, nil, 'explorer.exe', thepath, nil, SW_SHOWNORMAL)
end;
end.