-
Notifications
You must be signed in to change notification settings - Fork 1
/
lyricrequest.php
125 lines (108 loc) · 2.82 KB
/
lyricrequest.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
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
<?php
//##copyright##
define('INTELLI_REALM', $cfg['name']);
$iaDb->setTable('lyrics');
$iaLyric = $iaCore->factoryModules(IA_CURRENT_PACKAGE, 'front', 'lyric');
$plans = [];
$errorFields = [];
if(isset($_GET['id'])) $id = (int)$_GET['id'];
else $id = false;
$lyric = $id ? $iaDb->row('*, \'lyrics\' as `item`', "`id`={$id}") : [];
// plans
$iaPlan = $iaCore->factory('front','plan');
$plans = $iaPlan->getPlans('lyrics');
$iaCore->assign('plans', $plans);
if (isset($_GET['id']))
{
if (empty($lyric))
{
iaView::errorPage(iaView::ERROR_NOT_FOUND);
}
elseif ($_SESSION['user']['id'] != $lyric['member_id'])
{
iaView::errorPage(iaView::ERROR_FORBIDDEN);
}
}
if ($id)
{
$sections = $iaCore->getAcoGroupsFields(false, 'lyrics', "`f`.`type` <> 'pictures'");
$iaCore->assign_by_ref('sections', $sections);
$pictures_sections = $iaCore->getAcoGroupsFields(false, 'lyrics', "`f`.`type`='pictures'", false);
$iaCore->assign_by_ref('pictures_sections', $pictures_sections);
}
else
{
$sections = $iaCore->getAcoGroupsFields(false, 'lyrics');
$iaCore->assign_by_ref('sections', $sections);
}
if (iaView::REQUEST_HTML == $iaView->getRequestType())
{
if (!empty($_POST))
{
$fields = $iaCore->getAcoFieldsList(false, 'lyrics', false, true);
if($fields)
{
$data = '';
iaCore::util();
list($data, $error, $messages, $errorFields) = iaUtil::updateItemPOSTFields($fields, $lyric);
}
if (!$error)
{
$iaCore->startHook("beforeEstateSubmit");
$dmsg = '';
if ($iaCore->get('lyrics_auto_approval') || $action == 'deleted')
{
$data['status'] = 'active';
}
else
{
$data['status'] = 'approval';
$dmsg = '_apporval';
}
if (empty($lyric))
{
$action = 'added';
$data['id'] = $iaLyric->add($data);
if($data['id'] == 0)
{
$error = true;
$messages[] = _t('mysql_error');
}
}
else
{
if(isset($_POST['delete_lyric']))
{
$iaDb->delete('`id` = '.$lyric['id']);
$action = 'deleted';
$data['id'] = 0;
}
else
{
$action = 'updated';
$data['id'] = $lyric['id'];
$iaDb->update($data);
}
}
if (!$error)
{
$url = IA_PACKAGE_URL . ( $data['id'] != 0 ? 'add/?id='.$data['id'] : 'accounts/' );
$messages[] = _t('lyric_'.$action.$dmsg);
iaCore::util();
iaUtil::redirect(_t('thanks'), $messages, $url, isset($_POST['ajax']));
}
}
if (isset($_POST['ajax']))
{
header('Content-type: text/xml');
echo '<?xml version="1.0" encoding="'.$iaCore->get('charset').'" ?>'
.'<root><error>' . $error . '</error><msg><![CDATA[<li>' . implode('</li><li>',$messages).']]></msg></root>';
exit;
}
}
$iaCore->assign('error_fields', $errorFields);
$iaCore->assign('item', $lyric);
$iaCore->set_cfg('body', 'request');
$iaCore->set_cfg('title', _t('page_title_'.INTELLI_REALM));
}
$iaDb->resetTable();