/
index.php
56 lines (46 loc) · 1.11 KB
/
index.php
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
<?php
/*
Copyright 2014 - Mhd Sulhan
Authors:
- mhd.sulhan (m.shulhan@gmail.com)
*/
require_once "../../init.php";
$fields = [
"_profile_id"
, "id"
, "name"
, "extension"
, "size"
, "mime"
, "description"
, "path"
];
Jaring::$_mod["db_table"]["name"] = "_media";
Jaring::$_mod["db_table"]["read"] = $fields;
Jaring::$_mod["db_table"]["search"] = ["name", "extension", "mime", "description"];
Jaring::$_mod["db_table"]["order"] = ["id"];
Jaring::$_mod["db_table"]["create"] = $fields;
Jaring::$_mod["db_table"]["update"] = array_slice ($fields, 2);
//{{{ before delete request executed
function request_delete_before ($data)
{
foreach ($data as $d) {
// delete file
$q =" select path
from ". Jaring::$_mod["db_table"]["name"] ."
where id = ". $d["id"];
$rs = Jaring::db_execute ($q);
if (count ($rs) > 0) {
$f = APP_PATH . $rs[0]["path"];
if (file_exists ($f)) {
unlink ($f);
}
}
// delete link to media table.
$q = "delete from _media_table where _media_id = ". $d["id"];
Jaring::db_execute ($q, null, false);
}
return true;
}
//}}}
Jaring::request_handle ("action");