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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
|
# info about the structrure of the models
## user fields; insert / update sql queries
Insert user:
INSERT INTO user
( id,
prefix,
first_name,
last_name,
email,
father_name,
registration_number,
sector_id,
specialty,
belonging_school,
working_shcool,
position_type_id,
phone,
password,
expiration,
otp,
otp_expiration,
activation,
creation,
active) VALUES (:id,
:prefix,
:first_name,
:last_name,
:email,
:father_name,
:registration_number,
:sector_id,
:specialty,
:belonging_school,
:working_shcool,
:position_type_id,
:phone,
:password,
:expiration,
:otp,
:otp_expiration,
:activation,
:creation,
:active )
Update user
UPDATE user
SET prefix = :prefix,
first_name = :first_name,
last_name = :last_name,
email = :email,
father_name = :father_name,
registration_number = :registration_number,
sector_id = :sector_id,
specialty = :specialty,
belonging_school = :belonging_school,
working_shcool = :working_shcool,
position_type_id = :position_type_id,
phone = :phone,
password = :password,
expiration = :expiration,
otp = :otp,
otp_expiration = :otp_expiration,
activation = :activation,
creation = :creation,
active = :active,
## record_types
document forms -> json
request = {
user_id -> user: {
...
}
date: ...
body: ...
media: [ ... array of media-id(s) ]
}
penalty = {
user_id -> user: {
...
},
date:
time:
subject:
of_student:
place:
president:
members: [ list ]
reason:
apology:
decision:
}
## records
id
user_id
type
source_json
## record_media
record_id
media_id
USER menu
---
profile -> name, hello, last-login, do ...
profile/information
profile/requests (all)
profile/request/id (one)
Admin menu
---
admin -> requests (all), MODAL: protocol
admin/request/id -> request (one)
admin/iinvite
# callable/dynamic select options
<?php
class myclass {
static function say_hello()
{
echo "Hello!\n";
}
}
$classname = "myclass";
call_user_func(array($classname, 'say_hello'));
call_user_func($classname .'::say_hello');
$myobject = new myclass();
call_user_func(array($myobject, 'say_hello'));
?>
# APPlication
\ controllers
[ ] App
[*] Auth
\ extends
[ ] Cache_service
[*] App_manager
[*] App_user
[ ] SendMail_service
[*] Form_builder
\ models
[ ] Access_model
[ ] History_model
# DataBase Structure
SET NAMES utf8;
SET time_zone = '+00:00';
SET foreign_key_checks = 0;
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
SET NAMES utf8mb4;
DROP TABLE IF EXISTS `history`;
CREATE TABLE `history` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`type` smallint(6) NOT NULL,
`message` varchar(140) COLLATE utf8mb4_unicode_ci NOT NULL,
`note` text COLLATE utf8mb4_unicode_ci,
`ip` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`),
CONSTRAINT `history_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
DROP TABLE IF EXISTS `media`;
CREATE TABLE `media` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`title` varchar(256) COLLATE utf8mb4_unicode_ci NOT NULL,
`user_id` int(11) NOT NULL,
`path` varchar(512) COLLATE utf8mb4_unicode_ci NOT NULL,
`type` varchar(512) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'media-type',
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`),
CONSTRAINT `media_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
DROP TABLE IF EXISTS `petition`;
CREATE TABLE `petition` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`type_id` smallint(6) NOT NULL,
`form_structure` text COLLATE utf8mb4_unicode_ci NOT NULL,
`protocol` int(11) DEFAULT NULL,
`signature` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
`record_date` date DEFAULT NULL,
`creation_date` datetime DEFAULT CURRENT_TIMESTAMP,
`update_date` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `signature` (`signature`),
KEY `user_id` (`user_id`),
CONSTRAINT `petition_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
DROP TABLE IF EXISTS `petition_media`;
CREATE TABLE `petition_media` (
`petition_id` bigint(20) NOT NULL,
`media_id` bigint(20) NOT NULL,
KEY `petition_id` (`petition_id`),
KEY `media_id` (`media_id`),
CONSTRAINT `petition_media_ibfk_1` FOREIGN KEY (`petition_id`) REFERENCES `petition` (`id`),
CONSTRAINT `petition_media_ibfk_2` FOREIGN KEY (`media_id`) REFERENCES `media` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
DROP TABLE IF EXISTS `role`;
CREATE TABLE `role` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`alias` varchar(16) COLLATE utf8mb4_unicode_ci NOT NULL,
`label` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`prefix` varchar(16) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`first_name` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
`last_name` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
`email` varchar(48) COLLATE utf8mb4_unicode_ci NOT NULL,
`father_name` varchar(48) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`registration_number` bigint(20) DEFAULT NULL COMMENT 'AM',
`sector` varchar(48) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'sector_id + speciality',
`belonging_school` varchar(96) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`position` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'chief, permanent, deputy etc',
`phone` varchar(16) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`password` varchar(160) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`role_id` int(11) DEFAULT NULL,
`expiration` datetime DEFAULT NULL COMMENT 'account expiration datetime',
`otp` varchar(16) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'one time password for reset password',
`otp_expiration` datetime DEFAULT NULL,
`invitation` varchar(160) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'invitation code',
`creation_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'creation datetime',
`update_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`active` smallint(6) NOT NULL DEFAULT '0' COMMENT 'account status flag; 1=active 0=inactive',
PRIMARY KEY (`id`),
KEY `role_id` (`role_id`),
CONSTRAINT `user_ibfk_1` FOREIGN KEY (`role_id`) REFERENCES `role` (`id`) ON DELETE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|