-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata.php
More file actions
70 lines (48 loc) · 2.05 KB
/
data.php
File metadata and controls
70 lines (48 loc) · 2.05 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
<?php
namespace Cetera;
/************************************************************************************************
Список материалов
*************************************************************************************************/
try {
include('common_bo.php');
Material::clearLocks();
$od = ObjectDefinition::findByAlias('comments');
$math = $od->table;
$type = $od->id;
$where = '';
$fields = array('name');
if (!isset($_REQUEST['query'])) $_REQUEST['query'] = '';
$query = '%'.addslashes($_REQUEST['query']).'%';
$math_at_once = $_REQUEST['limit'];
$m_first = $_REQUEST['start'];
$order = $_REQUEST['dir'];
$sort = $_REQUEST['sort'];
$sql = "SELECT SQL_CALC_FOUND_ROWS
A.id, A.type, A.autor as autor_id, UNIX_TIMESTAMP(A.dat) as dat,
IF(C.name<>'' and C.name IS NOT NULL, C.name, C.login) as autor,
A.alias, D.user_id as locked, A.name, A.comment, A.material_id, A.material_type
FROM $math A LEFT JOIN users C ON (A.autor=C.id) LEFT JOIN `lock` D ON (A.id = D.material_id and D.type_id=$type AND D.dat >= NOW()-INTERVAL 10 SECOND)
WHERE (A.name like '$query' or A.alias like '$query' or C.name like '$query' or C.login like '$query')
$where
ORDER BY $sort $order
LIMIT $m_first,$math_at_once";
$r = $application->getConn()->fetchAll($sql);
$all_filter = $application->getConn()->fetchColumn('SELECT FOUND_ROWS()',[],0);
$i = 0;
$materials = array();
foreach ($r as $f) {
$f['icon'] = ($f['type'] & MATH_PUBLISHED)?1:0;
$materials[] = $f;
}
echo json_encode(array(
'success' => true,
'total' => $all_filter,
'rows' => $materials
));
} catch (Exception $e) {
echo json_encode(array(
'success' => false,
'message' => $e->getMessage(),
'rows' => false
));
}