diff --git a/modules/projects/tpl/projects.tpl b/modules/projects/tpl/projects.tpl
index dd7ac99..a33190e 100644
--- a/modules/projects/tpl/projects.tpl
+++ b/modules/projects/tpl/projects.tpl
@@ -6,7 +6,7 @@
{PRJ_TEXT}
-
+
{PHP.L.Files}:
@@ -58,7 +58,7 @@
{PRJ_COUNTRY} {PRJ_REGION} {PRJ_CITY}
{PHP.L.Date}: {PRJ_DATE}
-
+
{PHP.L.Tags}:
, {PRJ_TAGS_ROW_TAG}
{PRJ_NO_TAGS}
diff --git a/modules/projects/tpl/projects.userdetails.tpl b/modules/projects/tpl/projects.userdetails.tpl
index e770e1b..bf51c8a 100644
--- a/modules/projects/tpl/projects.userdetails.tpl
+++ b/modules/projects/tpl/projects.userdetails.tpl
@@ -26,8 +26,8 @@
{PRJ_ROW_SHORTTITLE} {PRJ_ROW_LOCALSTATUS}
-
{PRJ_ROW_PAYTOP}
- {PRJ_ROW_PAYBOLD}
+ {PRJ_ROW_PAYTOP}
+ {PRJ_ROW_PAYBOLD}
[{PRJ_ROW_DATE}] {PRJ_ROW_COUNTRY} {PRJ_ROW_REGION} {PRJ_ROW_CITY} {PRJ_ROW_EDIT_URL}
{PRJ_ROW_SHORTTEXT}
diff --git a/modules/support/inc/support.functions.php b/modules/support/inc/support.functions.php
new file mode 100644
index 0000000..de6b89d
--- /dev/null
+++ b/modules/support/inc/support.functions.php
@@ -0,0 +1,23 @@
+registerTable('support_tickets');
+cot::$db->registerTable('support_messages');
+
+if(empty($cfg['plugin']['support']['email'])){
+ $cfg['plugin']['support']['email'] = $cfg['adminemail'];
+}
diff --git a/modules/support/inc/support.list.php b/modules/support/inc/support.list.php
new file mode 100644
index 0000000..badfc3a
--- /dev/null
+++ b/modules/support/inc/support.list.php
@@ -0,0 +1,139 @@
+query("SELECT COUNT(*) FROM $db_support_tickets
+ " . $where . "")->fetchColumn();
+
+$sqllist = $db->query("SELECT * FROM $db_support_tickets AS t
+ LEFT JOIN $db_users AS u ON u.user_id=t.ticket_userid
+ " . $where . "
+ " . $order . "
+ LIMIT $d, " . $cfg['maxrowsperpage']);
+
+$pagenav = cot_pagenav('support', '', $d, $totalitems, $cfg['maxrowsperpage']);
+
+$sqllist_rowset = $sqllist->fetchAll();
+
+$tickets_open = $db->query("SELECT COUNT(*) FROM $db_support_tickets WHERE ticket_userid=".$usr['id']." AND ticket_status='open'")->fetchColumn();
+
+$t->assign(array(
+ 'SUPPORT_TITLE' => cot_breadcrumbs($patharray, $cfg['homebreadcrumb'], true),
+ 'SUPPORT_COUNT_OPEN' => $tickets_open,
+ 'PAGENAV_PAGES' => $pagenav['main'],
+ 'PAGENAV_PREV' => $pagenav['prev'],
+ 'PAGENAV_NEXT' => $pagenav['next'],
+ 'PAGENAV_COUNT' => $totalitems,
+));
+
+/* === Hook === */
+$extp = cot_getextplugins('support.list.loop');
+/* ===== */
+
+$jj = 0;
+foreach ($sqllist_rowset as $ticket) {
+ $jj++;
+ $t->assign(cot_generate_usertags($ticket, 'TICKET_ROW_USER_'));
+
+ $lastpost = $db->query("SELECT * FROM $db_support_messages AS m
+ LEFT JOIN $db_users AS u ON u.user_id=m.msg_userid
+ WHERE msg_tid=".$ticket['ticket_id']." ORDER BY msg_date DESC LIMIT 1")->fetch();
+
+ if($lastpost){
+ $t->assign(cot_generate_usertags($lastpost, 'TICKET_ROW_LASTPOSTER_'));
+ }
+
+ $t->assign(array(
+ 'TICKET_ROW_ID' => $ticket['ticket_id'],
+ 'TICKET_ROW_TITLE' => $ticket['ticket_title'],
+ 'TICKET_ROW_STATUS' => $ticket['ticket_status'],
+ 'TICKET_ROW_COUNT' => $ticket['ticket_count'],
+ 'TICKET_ROW_DATE' => $ticket['ticket_date'],
+ 'TICKET_ROW_UPDATE' => $ticket['ticket_update'],
+ 'TICKET_ROW_URL' => cot_url('support', 'id='.$ticket['ticket_id']),
+ ));
+
+ /* === Hook - Part2 : Include === */
+ foreach ($extp as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+
+ $t->parse("MAIN.TICKET_ROW");
+}
+
+/* === Hook === */
+foreach (cot_getextplugins('support.list.tags') as $pl)
+{
+ include $pl;
+}
+/* ===== */
diff --git a/modules/support/inc/support.newticket.php b/modules/support/inc/support.newticket.php
new file mode 100644
index 0000000..f364529
--- /dev/null
+++ b/modules/support/inc/support.newticket.php
@@ -0,0 +1,167 @@
+query("SELECT COUNT(*) FROM $db_support_tickets WHERE ticket_userid=" . $usr['id'] . " AND ticket_status='open'")->fetchColumn();
+cot_block($tickets_open == 0 || !$cfg['support']['onlyoneticket']);
+
+$sys['parser'] = $cfg['support']['parser'];
+
+if ($a == 'add') {
+ cot_shield_protect();
+
+ list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = cot_auth('support', 'any');
+ cot_block($usr['auth_write']);
+
+ /* === Hook === */
+ foreach (cot_getextplugins('support.newticket.add.first') as $pl) {
+ include $pl;
+ }
+ /* ===== */
+
+ $rticket['ticket_title'] = cot_import('rtickettitle', 'P', 'TXT');
+ $rticket['ticket_name'] = cot_import('rticketname', 'P', 'TXT', 100, TRUE);
+ $rticket['ticket_email'] = cot_import('rticketemail', 'P', 'TXT', 64, TRUE);
+
+ if (empty($rticket['ticket_name'])) {
+ $rticket['ticket_name'] = $usr['profile']['user_name'];
+ }
+
+ if (empty($rticket['ticket_email'])) {
+ $rticket['ticket_email'] = $usr['profile']['user_email'];
+ }
+
+ $rticket['ticket_status'] = 'open';
+ $rticket['ticket_date'] = $sys['now'];
+ $rticket['ticket_update'] = $sys['now'];
+
+ $rmsg['msg_text'] = cot_import('rmsgtext', 'P', 'HTM');
+
+ $rmsg['msg_date'] = $sys['now'];
+
+ /* === Hook === */
+ foreach (cot_getextplugins('support.newticket.add.import') as $pl) {
+ include $pl;
+ }
+ /* ===== */
+
+ cot_check(empty($rticket['ticket_title']), $L['support_error_rtickettitle'], 'rtickettitle');
+ cot_check(strlen($rticket['ticket_title']) > 50, $L['support_error_rtickettitlelong'], 'rtickettitle');
+ cot_check(empty($rmsg['msg_text']), $L['support_error_rmsgtext'], 'rmsgtext');
+
+ if ($usr['id'] == 0) {
+ cot_check(empty($rticket['ticket_name']), $L['support_error_rticketname'], 'rticketname');
+ cot_check(!cot_check_email($rticket['ticket_email']), $L['support_error_rticketemail'], 'rticketemail');
+ }
+
+ /* === Hook === */
+ foreach (cot_getextplugins('support.newticket.add.validate') as $pl) {
+ include $pl;
+ }
+ /* ===== */
+
+ if (!cot_error_found()) {
+ if ($usr['id'] == 0) {
+ $userid = $db->query("SELECT user_id FROM $db_users WHERE user_email = ? LIMIT 1", array($rticket['ticket_email']))->fetchColumn();
+ } else {
+ $userid = $usr['id'];
+ }
+
+ $rticket['ticket_userid'] = $userid;
+ $rmsg['msg_userid'] = $userid;
+
+ $db->insert($db_support_tickets, $rticket);
+ $tid = $db->lastInsertId();
+
+ $rmsg['msg_tid'] = $tid;
+
+ $db->insert($db_support_messages, $rmsg);
+ $mid = $db->lastInsertId();
+
+ /* === Hook === */
+ foreach (cot_getextplugins('support.newticket.add.done') as $pl) {
+ include $pl;
+ }
+ /* ===== */
+
+ $supportemails = explode(',', $cfg['support']['email']);
+ foreach ($supportemails as $supportemail) {
+ $rsubject = sprintf($L['support_notify_newticket_title'], $tid);
+ $rbody = sprintf($L['support_notify_newticket_body'], htmlspecialchars($usr['name']), $cfg['mainurl'] . '/' . cot_url('support', 'id=' . $tid, '', true));
+ cot_mail($supportemail, $rsubject, $rbody);
+ }
+
+ if ($cot_plugins_active["notify"]) {
+ $admins = $db->query(" SELECT * FROM `{$db_users}` WHERE user_maingrp=5 OR user_maingrp=6 ")->fetchAll();
+ foreach ($admins as $admin) {
+ notify_send("support", "newticket", cot_url('support', 'id=' . $tid, '', true), "Support", $L['support'] . ": " . sprintf($L['support_notify_newticket_title'], $tid), $admin["user_id"], $usr['id']);
+ }
+ }
+
+ cot_redirect(cot_url('support', 'id=' . $tid, '', true));
+ }
+
+ cot_redirect(cot_url('support', 'm=newticket', '', true));
+}
+
+$out['subtitle'] = $L['support_addtitle'];
+$out['head'] .= $R['code_noindex'];
+
+$mskin = cot_tplfile(array('support', 'newticket'), 'module');
+
+/* === Hook === */
+foreach (cot_getextplugins('support.newticket.main') as $pl) {
+ include $pl;
+}
+/* ===== */
+
+$t = new XTemplate($mskin);
+
+$patharray[] = array(cot_url('support'), $L['support']);
+$patharray[] = array(cot_url('support', 'm=add'), $L['support_addtitle']);
+
+$t->assign(array(
+ 'TICKETADD_TITLE' => cot_breadcrumbs($patharray, $cfg['homebreadcrumb'], true),
+ 'TICKETADD_SUBTITLE' => $L['support_addtitle'],
+ 'TICKETADD_FORM_SEND' => cot_url('support', 'm=newticket&a=add'),
+ 'TICKETADD_FORM_OWNER' => cot_build_user($usr['id'], htmlspecialchars($usr['name'])),
+ 'TICKETADD_FORM_OWNERID' => $usr['id'],
+ 'TICKETADD_FORM_TITLE' => cot_inputbox(
+ 'text',
+ 'rtickettitle',
+ $rticket['ticket_title'] ?? '',
+ '' . $L['support_newticket_title'] . '"'
+ ),
+ 'TICKETADD_FORM_TEXT' => cot_textarea('rmsgtext', $rmsg['msg_text'] ?? '', 24, 120, '', 'input_textarea_editor'),
+ 'TICKETADD_FORM_NAME' => cot_inputbox('text', 'rticketname', $rticket['ticket_name'] ?? '', '' . $L['support_newticket_name'] . '"'),
+ 'TICKETADD_FORM_EMAIL' => cot_inputbox('text', 'rticketemail', $rticket['ticket_email'] ?? '', '' . $L['support_newticket_email'] . '"'),
+));
+
+if (cot_module_active('pfs')) {
+ require_once cot_incfile('pfs', 'module');
+
+ $pfs_src = 'ticketform';
+ $pfs_name = 'rmsgtext';
+ $pfs = cot_build_pfs($usr['id'], $pfs_src, $pfs_name, $L['Mypfs'], $sys['parser']);
+ $pfs .= (cot_auth('pfs', 'a', 'A')) ? ' ' . cot_build_pfs(0, $pfs_src, $pfs_name, $L['SFS'], $sys['parser']) : '';
+ $t->assign('TICKETADD_FORM_MYPFS', $pfs);
+}
+
+// Error and message handling
+cot_display_messages($t);
+
+/* === Hook === */
+foreach (cot_getextplugins('support.newticket.tags') as $pl) {
+ include $pl;
+}
+/* ===== */
diff --git a/modules/support/inc/support.ticket.php b/modules/support/inc/support.ticket.php
new file mode 100644
index 0000000..0bdf1a2
--- /dev/null
+++ b/modules/support/inc/support.ticket.php
@@ -0,0 +1,210 @@
+ 0) {
+ $query_string = (!$usr['isadmin']) ? " AND ticket_userid=" . $usr['id'] : "";
+
+ $sql = $db->query("SELECT * FROM $db_support_tickets AS t
+ LEFT JOIN $db_users AS u ON u.user_id=t.ticket_userid
+ WHERE ticket_id=" . $id . "" . $query_string . " LIMIT 1");
+}
+
+if (!$id || !$sql || $sql->rowCount() == 0) {
+ cot_block();
+}
+$ticket = $sql->fetch();
+
+$messages = $db->query("SELECT * FROM $db_support_messages AS m
+LEFT JOIN $db_users AS u ON u.user_id=m.msg_userid
+WHERE msg_tid=" . $id . " ORDER BY msg_date DESC")->fetchAll();
+
+if ($a == 'close') {
+ cot_check_xg();
+
+ $db->update($db_support_tickets, array('ticket_status' => 'closed', 'ticket_close' => $sys['now']), 'ticket_id=' . $id);
+
+ cot_redirect(cot_url('support', 'id=' . $id, '', true));
+}
+
+if ($a == 'addmsg') {
+ cot_shield_protect();
+
+ $rmsg['msg_text'] = cot_import('rmsgtext', 'P', 'HTM');
+
+ $rmsg['msg_tid'] = $id;
+ $rmsg['msg_userid'] = $usr['id'];
+ $rmsg['msg_date'] = $sys['now'];
+
+ /* === Hook === */
+ foreach (cot_getextplugins('support.ticket.addmsg.import') as $pl) {
+ include $pl;
+ }
+ /* ===== */
+
+ cot_check(empty($rmsg['msg_text']), $L['support_tickets_message_error_textempty'], 'rmsgtext');
+ cot_check($ticket['ticket_status'] == 'closed' && !$usr['isadmin'], $L['support_tickets_message_error_closed'], 'rmsgtext');
+
+ /* === Hook === */
+ foreach (cot_getextplugins('support.ticket.addmsg.validate') as $pl) {
+ include $pl;
+ }
+ /* ===== */
+
+ if (!cot_error_found()) {
+
+ $db->insert($db_support_messages, $rmsg);
+ $mid = $db->lastInsertId();
+
+ $rticket['ticket_update'] = $sys['now'];
+ $rticket['ticket_count'] = $ticket['ticket_count'] + 1;
+
+ $db->update($db_support_tickets, $rticket, 'ticket_id=' . $id);
+
+ if ($usr['id'] == $ticket['ticket_userid']) {
+ $supportemails = explode(',', $cfg['support']['email']);
+ foreach ($supportemails as $supportemail) {
+ $rsubject = sprintf($L['support_notify_newmsg_admin_title'], $id);
+ $rbody = sprintf($L['support_notify_newmsg_admin_body'], $id, $cfg['mainurl'] . '/' . cot_url('support', 'id=' . $id, '', true));
+ cot_mail($supportemail, $rsubject, $rbody);
+ }
+
+ if ($cot_plugins_active["notify"]) {
+ $admins = $db->query(" SELECT * FROM `{$db_users}` WHERE user_maingrp=5 OR user_maingrp=6 ")->fetchAll();
+ foreach ($admins as $admin) {
+ notify_send("support", "newticket", cot_url('support', 'id=' . $id, '', true), "Support", $L['support'] . ": " . sprintf($L['support_notify_newmsg_admin_title'], $id), $admin["user_id"], $usr['id']);
+ }
+ }
+ $rsubject = sprintf($L['support_notify_newmsg_user_title'], $id);
+ $rbody = sprintf($L['support_notify_newmsg_user_body'], $ticket['ticket_name'], $id, $cfg['mainurl'] . '/' . cot_url('support', 'id=' . $id, '', true));
+ cot_mail($ticket['ticket_email'], $rsubject, $rbody);
+ } else {
+ if ($cot_plugins_active["notify"]) {
+ notify_send("support", "newticket", cot_url('support', 'id=' . $id, '', true), "Support", $L['support'] . ": " . sprintf($L['support_notify_newmsg_admin_title'], $id), $ticket['ticket_userid'], $usr['id']);
+ }
+ }
+
+ /* === Hook === */
+ foreach (cot_getextplugins('support.ticket.addmsg.done') as $pl) {
+ include $pl;
+ }
+ /* ===== */
+ }
+ cot_redirect(cot_url('support', 'id=' . $id, '#msg' . $mid, true));
+}
+
+$out['subtitle'] = $support['support_title'];
+$out['head'] .= $R['code_noindex'];
+
+$mskin = cot_tplfile(array('support', 'ticket'), 'module');
+
+/* === Hook === */
+foreach (cot_getextplugins('support.ticket.main') as $pl) {
+ include $pl;
+}
+/* ===== */
+
+$t = new XTemplate($mskin);
+
+$patharray[] = array(cot_url('support'), $L['support']);
+$patharray[] = array(cot_url('support', 'id=' . $id), $ticket['ticket_title']);
+
+$t->assign(array(
+ 'SUPPORT_TITLE' => cot_breadcrumbs($patharray, $cfg['homebreadcrumb'], true),
+));
+
+$t->assign(cot_generate_usertags($ticket, 'TICKET_USER_'));
+
+$t->assign(array(
+ 'TICKET_ID' => $ticket['ticket_id'],
+ 'TICKET_STATUS' => $ticket['ticket_status'],
+ 'TICKET_TITLE' => $ticket['ticket_title'],
+ 'TICKET_DATE' => $ticket['ticket_date'],
+ 'TICKET_CLOSE_URL' => cot_url('support', 'a=close&id=' . $id . '&' . cot_xg(), '', true),
+));
+
+foreach ($messages as $msg) {
+ $t->assign(cot_generate_usertags($msg, 'MSG_ROW_USER_'));
+ $t->assign(array(
+ 'MSG_ROW_ID' => $msg['msg_id'],
+ 'MSG_ROW_TEXT' => cot_parse($msg['msg_text'], $cfg['support']['markup'], $cfg['support']['parser']),
+ 'MSG_ROW_DATE' => $msg['msg_date'],
+ ));
+ $lastposterid = $msg['user_id'];
+ $t->parse("MAIN.MSG_ROW");
+}
+
+$sys['parser'] = $cfg['support']['parser'];
+
+$t->assign(array(
+ 'MSG_FORM_SEND' => cot_url('support', 'id=' . $id . '&a=addmsg'),
+ 'MSG_FORM_TEXT' => cot_textarea('rmsgtext', $rmsg['msg_text'], 24, 120, '', 'input_textarea_editor'),
+));
+
+if (cot_module_active('pfs')) {
+ require_once cot_incfile('pfs', 'module');
+
+ $pfs_src = 'msgform';
+ $pfs_name = 'rmsgtext';
+ $pfs = cot_build_pfs($usr['id'], $pfs_src, $pfs_name, $L['Mypfs'], $sys['parser']);
+ $pfs .= (cot_auth('pfs', 'a', 'A')) ? ' ' . cot_build_pfs(0, $pfs_src, $pfs_name, $L['SFS'], $sys['parser']) : '';
+ $t->assign('MSG_FORM_MYPFS', $pfs);
+}
+
+if ($ticket['ticket_status'] == 'open') {
+ if ($cfg['support']['waitanswer'] && $lastposterid == $usr['id'] && !$usr['isadmin']) {
+ /* === Hook === */
+ foreach (cot_getextplugins('support.ticket.wait.tags') as $pl) {
+ include $pl;
+ }
+ /* ===== */
+
+ $t->parse("MAIN.MSGWAIT");
+ } else {
+ /* === Hook === */
+ foreach (cot_getextplugins('support.ticket.msgform') as $pl) {
+ include $pl;
+ }
+ /* ===== */
+
+ // Error and message handling
+ cot_display_messages($t);
+
+ $t->parse("MAIN.MSGFORM");
+ }
+} else {
+ /* === Hook === */
+ foreach (cot_getextplugins('support.ticket.closed.tags') as $pl) {
+ include $pl;
+ }
+ /* ===== */
+
+ $t->parse("MAIN.CLOSED");
+}
+
+/* === Hook === */
+foreach (cot_getextplugins('support.ticket.tags') as $pl) {
+ include $pl;
+}
+/* ===== */
diff --git a/modules/support/lang/support.en.lang.php b/modules/support/lang/support.en.lang.php
new file mode 100644
index 0000000..34011e9
--- /dev/null
+++ b/modules/support/lang/support.en.lang.php
@@ -0,0 +1,65 @@
+';
+$L['support_error_rtickettitlelong'] = 'Слишком длинный заголовок обращения';
+$L['support_error_rticketname'] = 'Пожалуйста, укажите ваше имя';
+$L['support_error_rticketemail'] = 'Пожалуйста, укажите ваш email';
+
+$L['support_error_rmsgtext'] = 'Не указан вопрос полностью';
+
+$L['support_tickets_message_error_textempty'] = 'Не указан текст сообщения';
+$L['support_tickets_message_error_closed'] = 'Данное обращение уже закрыто. Чтобы задать новый вопрос, пожалуйста, создайте новое обращение.';
diff --git a/modules/support/setup/support.install.sql b/modules/support/setup/support.install.sql
new file mode 100644
index 0000000..ece61c9
--- /dev/null
+++ b/modules/support/setup/support.install.sql
@@ -0,0 +1,27 @@
+/**
+ * support plugin DB installation
+ */
+
+CREATE TABLE IF NOT EXISTS `cot_support_tickets` (
+ `ticket_id` int(10) unsigned NOT NULL auto_increment,
+ `ticket_userid` int(11) NOT NULL,
+ `ticket_title` varchar(255) collate utf8_unicode_ci NOT NULL,
+ `ticket_date` int(11) NOT NULL,
+ `ticket_update` int(11) NOT NULL,
+ `ticket_close` int(11) NOT NULL,
+ `ticket_count` int(11) NOT NULL,
+ `ticket_name` varchar(255) collate utf8_unicode_ci NOT NULL,
+ `ticket_email` varchar(255) collate utf8_unicode_ci NOT NULL,
+ `ticket_status` varchar(20) collate utf8_unicode_ci NOT NULL,
+ PRIMARY KEY (`ticket_id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+
+CREATE TABLE IF NOT EXISTS `cot_support_messages` (
+ `msg_id` int(10) unsigned NOT NULL auto_increment,
+ `msg_tid` int(11) NOT NULL,
+ `msg_userid` int(11) NOT NULL,
+ `msg_text` MEDIUMTEXT collate utf8_unicode_ci NOT NULL,
+ `msg_date` int(11) NOT NULL,
+ PRIMARY KEY (`msg_id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
\ No newline at end of file
diff --git a/modules/support/setup/support.uninstall.sql b/modules/support/setup/support.uninstall.sql
new file mode 100644
index 0000000..6b8d676
--- /dev/null
+++ b/modules/support/setup/support.uninstall.sql
@@ -0,0 +1,6 @@
+/**
+ * Completely removes support data
+ */
+
+DROP TABLE IF EXISTS `cot_support_tickets`;
+DROP TABLE IF EXISTS `cot_support_messages`;
\ No newline at end of file
diff --git a/modules/support/support.php b/modules/support/support.php
new file mode 100644
index 0000000..154f578
--- /dev/null
+++ b/modules/support/support.php
@@ -0,0 +1,43 @@
+parse('MAIN');
+$t->out('MAIN');
+
+require_once $cfg['system_dir'] . '/footer.php';
diff --git a/modules/support/support.png b/modules/support/support.png
new file mode 100644
index 0000000..e672905
Binary files /dev/null and b/modules/support/support.png differ
diff --git a/modules/support/support.setup.php b/modules/support/support.setup.php
new file mode 100644
index 0000000..5ad8271
--- /dev/null
+++ b/modules/support/support.setup.php
@@ -0,0 +1,29 @@
+
+
+
{SUPPORT_TITLE}
+
+
{PHP.L.support_tickets}
+
+
{PHP.L.support_tickets_add_button}
+
+
+
+
+
+
+
+ ID
+ Заголовок обращения
+
+ Автор
+
+ Статус
+
+
+
+
+
+ #{TICKET_ROW_ID}
+
+
+ {TICKET_ROW_DATE|cot_date('d.m H:i:s', $this)}
+
+
+ {TICKET_ROW_USER_NAME}{PHP.L.Guest}
+
+
+
+
+
+ {PHP.L.support_tickets_new}
+ {TICKET_ROW_UPDATE|cot_build_timeago($this)}
+
+
+ {PHP.L.support_tickets_notanswered}
+ {PHP.L.support_tickets_lastpost_from}: {TICKET_ROW_LASTPOSTER_NAME}, {PHP.L.support_tickets_lastpost_when}: {TICKET_ROW_UPDATE|cot_build_timeago($this)}
+
+ {PHP.L.support_tickets_answer}
+ {PHP.L.support_tickets_lastpost_from}: {TICKET_ROW_LASTPOSTER_NAME}, {PHP.L.support_tickets_lastpost_when}: {TICKET_ROW_UPDATE|cot_build_timeago($this)}
+
+
+
+
+ {PHP.L.support_tickets_new}
+ {TICKET_ROW_UPDATE|cot_build_timeago($this)}
+
+
+ {PHP.L.support_tickets_waiting_answer}
+ {PHP.L.support_tickets_lastpost_from}: {TICKET_ROW_LASTPOSTER_NAME}, {PHP.L.support_tickets_lastpost_when}: {TICKET_ROW_UPDATE|cot_build_timeago($this)}
+
+ {PHP.L.support_tickets_answered}
+ {PHP.L.support_tickets_lastpost_from}: {TICKET_ROW_LASTPOSTER_NAME}, {PHP.L.support_tickets_lastpost_when}: {TICKET_ROW_UPDATE|cot_build_timeago($this)}
+
+
+
+
+ {PHP.L.support_tickets_closed}
+ {TICKET_ROW_UPDATE|cot_build_timeago($this)}
+
+
+
+
+
+
+
+
+
+
{PHP.L.None}
+
+
+
\ No newline at end of file
diff --git a/modules/support/tpl/support.newticket.tpl b/modules/support/tpl/support.newticket.tpl
new file mode 100644
index 0000000..752a4b9
--- /dev/null
+++ b/modules/support/tpl/support.newticket.tpl
@@ -0,0 +1,21 @@
+
+
+
{TICKETADD_TITLE}
+
{TICKETADD_SUBTITLE}
+{FILE "{PHP.cfg.themes_dir}/{PHP.cfg.defaulttheme}/warnings.tpl"}
+
+
+
+
\ No newline at end of file
diff --git a/modules/support/tpl/support.ticket.tpl b/modules/support/tpl/support.ticket.tpl
new file mode 100644
index 0000000..5bdc873
--- /dev/null
+++ b/modules/support/tpl/support.ticket.tpl
@@ -0,0 +1,50 @@
+
+
+
{SUPPORT_TITLE}
+
+
+
{PHP.L.support_tickets_close_button}
+
+
+
{TICKET_TITLE}
+
{PHP.L.support_tickets_number} #{TICKET_ID} | {TICKET_DATE|date('d.m.Y H:i:s', $this)}
+
+
+
{PHP.L.support_tickets_closed_alert}
+
+
+
+
+
+
{PHP.L.support_tickets_wait_alert}
+
+
+
+{FILE "{PHP.cfg.themes_dir}/{PHP.cfg.defaulttheme}/warnings.tpl"}
+
+
+
+
\ No newline at end of file
diff --git a/params.json b/params.json
deleted file mode 100644
index 7e2dddd..0000000
--- a/params.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "name": "Cot-freelance",
- "tagline": "Сборка фриланс-биржи на Cotonti Siena",
- "body": "Сборка фриланс-биржи на базе Cotonti Siena. С помощью данной сборки можно организовать любую биржу по поиску исполнителей на различные работы. Функционал биржи предоставляет гибкие возможности для эксплуатации и дальнейшей разработки.\r\n\r\nБиржа открывает перед разработчиками все возможности нового фреймворка Cotonti Siena, а это не много не мало такие фишки как возможность подключать различные способы оплаты без вмешательства в исходный код (на данный момент доступо подключение Robokassa, Interkassa и Webmoney), модульная архитектура, удобная система обновления, а также легкость освоения, так как у Siena имеется достаточно хорошая документация.\r\n\r\n### Возможности биржи:\r\n\r\nАккаунты пользователей со своими личными страницами (на личной странице выводится контактная информация, а также списки опубликованных проектов, работ в портфолио и в магазине); \r\nКаталог заказов (проектов), возможность публиковать заказы. Форма поиска заказов по регионам и ключевой фразе;\r\nКаталог фрилансеров и работодателей с сортировкой по специализациям;\r\nПлатежный модуль с внутренними счетами пользователей и возможностью пополнения и оплаты услуг;\r\nВозможность подключения к Интеркассе, Робокассе и Вебмани (отдельные плагины);\r\nПлатная услуга \"PRO-аккаунт\";\r\nПлатная услуга \"Платное место на главной\" (Пользователи оплатившие данную услугу выводятся на главной странице биржи);\r\nОтзывы и система рейтингов.\r\n \r\n\r\n### Роли пользователей (группы)\r\n\r\nВ традиционной фриланс-бирже участвует две стороны, это фрилансеры и заказчики. Но мы немного усовершенствовали систему и добавили возможность расширить число участников сервиса. Теперь можно создавать свои собственные роли на сайте и привязывать их к группам пользователей для которых можно настроить права доступа ко всем разделам сайта и определить для них свои возможности.\r\n\r\n### Проекты\r\n\r\nЛюбой пользователь может опубликовать свой проект на сайте. В проекте можно указать регион, город, цену, раздел в каталоге (направление деятельности), заголовок проекта и его описание. Также можно прикрепить различные файлы к описанию проекта.\r\nФрилансеры, которых заинтересовал опубликованный проект могут оставлять свои предложение на странице проекта.\r\nРаботодатель может выбрать исполнителем либо отказать по проекту любому Фрилансеру, который оставил предложение.\r\nРаботодатель или Фрилансер, оставивший предложение по проекту, могу вести переписку непосредственно на странице проекта.\r\n \r\n### Отзывы\r\n \r\nЛюбой пользователь сервиса может оставлять отзывы другим участникам. Отзыв может быть как положительным так и отрицательным, на выбор. Доступ к публикации Отзывов можно ограничить только в рамках проведенных проектов (настраивается). По-умолчанию пользователи могут оставлять отзывы другим пользователям. При необходимости систему отзывов можно настроить так, чтобы отзывы можно было оставлять только за исполненные заказы, то есть с привязкой к проекту.\r\n \r\n### Система рейтингов\r\n \r\nЧтобы выделить среди участников сервиса наиболее активных пользователей на сайте функционирует система начисления рейтинга. У кого больше рейтинг, тот пользователь более заметен на сайте.\r\n \r\nКак начисляются баллы (настройки по-умолчанию):\r\nЗа посещение сайта: +1 балл\r\nЗа размещение работы в портфолио: +5 баллов\r\nЗа статус исполнителя по проекту: +1 балл\r\nЗа получение отказа по проекту: -1 балл\r\nЗа получение положительного отзыва: +20 баллов\r\nЗа получение отрицательного отзыва: -20 баллов\r\nЗа покупку PRO-аккаунта: +20% к рейтингу\r\nЗа покупку платного места на главной: +20% к рейтингу.\r\nУказанные значения баллов можно изменить в админке сайта.\r\n \r\nТакже добавлена возможность вывода топ-пользователей в любом месте на сайте.\r\n \r\n### Система оплаты услуг сайта\r\n \r\nУ каждого пользователя есть свой личный счет на сайте. Пополнение счета осуществляется через системы приема платежей Робокасса, Интеркасса и Вебмани.\r\nС помощью личного счета пользователь может оплачивать платные услуги сайта. Данная система оплаты является универсальным механизмом, с помощью которого можно разрабатывать на сайте свои платные услуги.\r\n \r\n### Виды платных услуг:\r\n\r\nPRO-аккаунт (цена за месяц). PRO-аккаунт дает возможность выделиться среди других участников биржи специальным значком, а также приоритетное размещение в каталоге фрилансеров (работодателей);\r\nПлатное место на главной и в любом другом месте на сайте (цена за размещение). Рекламные блоки можно разместить в любом месте на сайте и установить для размерения в них разные цены. Размещение происходит путем смещения ранее оплативших и на срок 1 месяц.\r\nЦены также можно изменить в админке.\r\n\r\n### Магазин\r\n \r\nРаздел для размещения готовых к продаже товаров или услуг пользователя. Каждый товар содержит: заголовок, описание, изображение и цену. Также все товары/услуги распределены в каталоге по категориям для удобства поиска.\r\n \r\nВ админке предусмотрена возможность редактировать категории для всех разделов сайта:\r\n \r\nКатегории проектов\r\nТипы проектов (например: Обычные, Вакансии, и т.д.)\r\nКатегории фрилансеров\r\nКатегории в магазине\r\nКатегории информационных страниц сайта.\r\n",
- "note": "Don't delete this file! It's used internally to help with page regeneration."
-}
\ No newline at end of file
diff --git a/plugins/affiliate/affiliate.admin.php b/plugins/affiliate/affiliate.admin.php
new file mode 100644
index 0000000..9bc0424
--- /dev/null
+++ b/plugins/affiliate/affiliate.admin.php
@@ -0,0 +1,58 @@
+query("SELECT user_referal FROM $db_users WHERE user_referal!=0")->fetchAll();
+if(is_array($affiliates)){
+ foreach ($affiliates as $affiliate){
+ $affs[] = $affiliate['user_referal'];
+ }
+}
+
+if(is_array($affs)){
+ $sql = $db->query("SELECT * FROM $db_users WHERE user_maingrp>3 AND user_id IN (".implode(',', $affs).")");
+ while($urr = $sql->fetch()){
+ $t->assign(cot_generate_usertags($urr, 'REF_ROW_'));
+ $t->assign(array(
+ 'REF_ROW_TREE' => affiliate_referalstree($urr['user_id'], $urr['user_id'], 'admin', 0)
+ ));
+ $t->parse('MAIN.REF_ROW');
+ }
+}
+
+$summ = 0;
+
+$pays = $db->query("SELECT * FROM $db_payments AS p
+ LEFT JOIN $db_users AS u ON u.user_id=p.pay_userid
+ WHERE pay_status='done' AND pay_code LIKE 'affiliate:%'
+ ORDER BY pay_pdate DESC")->fetchAll();
+foreach ($pays as $pay)
+{
+ $summ += $pay['pay_summ'];
+
+ $paycode = explode(':', $pay['pay_code']);
+ $referalid = $paycode[1];
+ if(!empty($referalid)){
+ $t->assign(cot_generate_usertags($referalid, 'PAY_ROW_REFERAL_'));
+ }
+
+ $t->assign(cot_generate_usertags($pay, 'PAY_ROW_PARTNER_'));
+ $t->assign(cot_generate_paytags($pay, 'PAY_ROW_'));
+ $t->parse('MAIN.PAYMENTS.PAY_ROW');
+}
+
+$t->assign('PAYMENT_SUMM', $summ);
+
+$t->parse('MAIN.PAYMENTS');
+
+$t->parse("MAIN");
+$plugin_body .= $t->text("MAIN");
\ No newline at end of file
diff --git a/plugins/affiliate/affiliate.global.php b/plugins/affiliate/affiliate.global.php
new file mode 100644
index 0000000..c5d0d7d
--- /dev/null
+++ b/plugins/affiliate/affiliate.global.php
@@ -0,0 +1,19 @@
+ 0 && empty($_COOKIE['ref'])){
+ cot_setcookie('ref', $ref, $sys['now']+12*30*24*60*60, $cfg['cookiepath'], $cfg['cookiedomain'], $sys['secure'], true);
+}
\ No newline at end of file
diff --git a/plugins/affiliate/affiliate.payments.balance.billing.done.php b/plugins/affiliate/affiliate.payments.balance.billing.done.php
new file mode 100644
index 0000000..128459e
--- /dev/null
+++ b/plugins/affiliate/affiliate.payments.balance.billing.done.php
@@ -0,0 +1,29 @@
+ 0){
+ $levelpays = affiliate_cfg_levelpays();
+ for($level = 1; $level <= 10; $level++){
+ if($affs[$level] > 0){
+ $affid = $affs[$level];
+ $levelpercent = ($levelpays[$affid][$level] > 0) ? $levelpays[$affid][$level] : $levelpays[0][$level];
+ if($levelpercent > 0 && $pay['pay_summ'] > 0){
+ if(cot_payments_updateuserbalance($affid, $pay['pay_summ']*$levelpercent/100, 'affiliate:'.$pay['pay_userid'])){
+ if($affiliate = $db->query("SELECT * FROM $db_users WHERE user_id=".$affid)->fetch()){
+ cot_mail($affiliate['user_email'], $L['affiliate_mail_newpayment_subject'], sprintf($L['affiliate_mail_newpayment_body'], $pay['pay_summ']*$levelpercent/100));
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/plugins/affiliate/affiliate.paytags.main.php b/plugins/affiliate/affiliate.paytags.main.php
new file mode 100644
index 0000000..f317e33
--- /dev/null
+++ b/plugins/affiliate/affiliate.paytags.main.php
@@ -0,0 +1,13 @@
+assign('REFERALS_TREE', affiliate_referalstree($usr['id'], $usr['id']));
+
+$affs = affiliate_getaffiliates($usr['id']);
+
+$summ = 0;
+
+$pays = $db->query("SELECT * FROM $db_payments
+ WHERE pay_userid=" . $usr['id'] . " AND pay_status='done' AND pay_code LIKE 'affiliate%'
+ ORDER BY pay_pdate DESC")->fetchAll();
+foreach ($pays as $pay)
+{
+ $summ += $pay['pay_summ'];
+
+ $paycode = explode(':', $pay['pay_code']);
+ $referalid = $paycode[1];
+ if(!empty($referalid)){
+ $t->assign(cot_generate_usertags($referalid, 'PAY_ROW_REFERAL_'));
+ }
+
+ $t->assign(cot_generate_paytags($pay, 'PAY_ROW_'));
+ $t->parse('MAIN.PAYMENTS.PAY_ROW');
+}
+
+$t->assign('PAYMENT_SUMM', $summ);
+
+$t->parse('MAIN.PAYMENTS');
diff --git a/plugins/affiliate/affiliate.png b/plugins/affiliate/affiliate.png
new file mode 100644
index 0000000..713f9b5
Binary files /dev/null and b/plugins/affiliate/affiliate.png differ
diff --git a/plugins/affiliate/affiliate.setup.php b/plugins/affiliate/affiliate.setup.php
new file mode 100644
index 0000000..3ae47b0
--- /dev/null
+++ b/plugins/affiliate/affiliate.setup.php
@@ -0,0 +1,30 @@
+ 0) {
+ $partner = Cot::$db->query(
+ 'SELECT * FROM ' . Cot::$db->users . ' WHERE user_id = ' . $referal['user_referal']
+ )->fetch();
+
+ // Сообщаем партнеру о новом реферале
+ cot_mail(
+ $partner['user_email'],
+ Cot::$L['affiliate_mail_newreferal_subject'],
+ sprintf(Cot::$L['affiliate_mail_newreferal_body'], $partner['user_name'], $referal['user_name'])
+ );
+
+ // Начисляем баллы в рейтинг за нового реферала
+ if (cot_plugin_active('userpoints') && Cot::$cfg['plugin']['affiliate']['refpoints'] > 0) {
+ cot_setuserpoints(
+ Cot::$cfg['plugin']['affiliate']['refpoints'],
+ 'affiliate',
+ $referal['user_referal'],
+ $row['user_id']
+ );
+ }
+
+ // Начисляем на счет партнера вознаграждение за нового реферала
+ if(Cot::$cfg['plugin']['affiliate']['refpay'] > 0) {
+ $payinfo['pay_userid'] = $partner['user_id'];
+ $payinfo['pay_area'] = 'balance';
+ $payinfo['pay_code'] = 'affiliate:' . $row['user_id'];
+ $payinfo['pay_summ'] = Cot::$cfg['plugin']['affiliate']['refpay'];
+ $payinfo['pay_cdate'] = Cot::$sys['now'];
+ $payinfo['pay_pdate'] = Cot::$sys['now'];
+ $payinfo['pay_adate'] = Cot::$sys['now'];
+ $payinfo['pay_status'] = 'done';
+ $payinfo['pay_desc'] = Cot::$L['affiliate_refpay_desc'];
+
+ if (Cot::$db->insert(Cot::$db->payments, $payinfo)) {
+ cot_mail(
+ $partner['user_email'],
+ Cot::$L['affiliate_refpay_mail_subject'],
+ sprintf(Cot::$L['affiliate_refpay_mail_body'], $partner['user_name'])
+ );
+ cot_log("Payment for referal");
+ }
+ }
+}
\ No newline at end of file
diff --git a/plugins/affiliate/affiliate.users.details.main.php b/plugins/affiliate/affiliate.users.details.main.php
new file mode 100644
index 0000000..5cec07d
--- /dev/null
+++ b/plugins/affiliate/affiliate.users.details.main.php
@@ -0,0 +1,13 @@
+ 0 && $userid != $ref){
+ $db->update($db_users, array('user_referal' => $ref), "user_id=".$userid);
+ cot_setcookie('ref', '', time()-63072000, $cfg['cookiepath'], $cfg['cookiedomain'], $sys['secure'], true);
+}
\ No newline at end of file
diff --git a/plugins/affiliate/inc/affiliate.functions.php b/plugins/affiliate/inc/affiliate.functions.php
new file mode 100644
index 0000000..d63e5a2
--- /dev/null
+++ b/plugins/affiliate/inc/affiliate.functions.php
@@ -0,0 +1,108 @@
+ $value){
+ if($i == 0){
+ $userid = $value;
+ }else{
+ $levelpays[$userid][$level] = $value;
+ $level++;
+ }
+ }
+ }
+ }
+
+ return $levelpays;
+}
+
+/*
+ * Получаем дерево привлеченных рефералов
+ */
+function affiliate_getreferals($userid){
+ global $db, $db_users;
+
+ $referals = array();
+
+ $sql = $db->query("SELECT user_id FROM $db_users WHERE user_referal=".$userid);
+ while($referal = $sql->fetch()){
+ $referals[$referal['user_id']] = affiliate_getreferals($referal['user_id']);
+ }
+
+ return $referals;
+}
+
+
+/*
+ * Получаем цепочку аффилиатов
+ */
+function affiliate_getaffiliates($userid, $level = 1){
+ global $db, $db_users;
+
+ $affiliates = array();
+
+ $affiliate = $db->query("SELECT user_referal FROM $db_users WHERE user_referal!=0 AND user_id=".$userid)->fetchColumn();
+ if($affiliate){
+ $affiliates[$level] = $affiliate;
+ $nextaffs = affiliate_getaffiliates($affiliate, $level + 1);
+ if(is_array($nextaffs)){
+ $affiliates += $nextaffs;
+ }
+ }
+
+ return $affiliates;
+}
+
+
+/*
+ * Генерация реферального дерева
+ */
+function affiliate_referalstree($partnerid, $userid, $template = '', $level = 0){
+ global $cfg;
+
+ $level++;
+
+ $referals = affiliate_getreferals($userid);
+
+ if(!empty($referals)){
+ $levelpays = affiliate_cfg_levelpays($partnerid);
+
+ $t = new XTemplate(cot_tplfile(array('affiliate', 'level', $template), 'plug'));
+
+ foreach ($referals as $referalid => $subreferals){
+ $t->assign(cot_generate_usertags($referalid, 'REFERAL_ROW_USER_'));
+ $t->assign(array(
+ 'REFERAL_ROW_LEVEL' => $level,
+ 'REFERAL_ROW_PERCENT' => ($levelpays[$partnerid][$level] > 0) ? $levelpays[$partnerid][$level] : $levelpays[0][$level],
+ ));
+
+ if(count($subreferals) != 0 && ($level < $cfg['plugins']['affiliate']['maxlevelstoshow'] || $cfg['plugins']['affiliate']['maxlevelstoshow'] == 0)){
+ $t->assign('REFERAL_ROW_SUBREFERALS', affiliate_referalstree($partnerid, $referalid, $template, $level));
+ }else{
+ $t->assign('REFERAL_ROW_SUBREFERALS', '');
+ }
+ $t->parse('REFERALS.REFERAL_ROW');
+ }
+
+ $t->parse('REFERALS');
+
+ return $t->text('REFERALS');
+ }else{
+ return false;
+ }
+}
\ No newline at end of file
diff --git a/plugins/affiliate/lang/affiliate.en.lang.php b/plugins/affiliate/lang/affiliate.en.lang.php
new file mode 100644
index 0000000..286c771
--- /dev/null
+++ b/plugins/affiliate/lang/affiliate.en.lang.php
@@ -0,0 +1,30 @@
+fieldExists(Cot::$db->users, "user_referal")) {
+ Cot::$db->query('ALTER TABLE '. Cot::$db->users . ' ADD COLUMN user_referal INT NOT NULL DEFAULT 0');
+}
\ No newline at end of file
diff --git a/plugins/affiliate/setup/affiliate.uninstall.php b/plugins/affiliate/setup/affiliate.uninstall.php
new file mode 100644
index 0000000..97c5fca
--- /dev/null
+++ b/plugins/affiliate/setup/affiliate.uninstall.php
@@ -0,0 +1,10 @@
+fieldExists($db_users, "user_referal"))
+{
+ $db->query("ALTER TABLE `$db_users` DROP COLUMN `user_referal`");
+}
\ No newline at end of file
diff --git a/plugins/affiliate/setup/patch_1.0.3.1.inc b/plugins/affiliate/setup/patch_1.0.3.1.inc
new file mode 100644
index 0000000..9af25c8
--- /dev/null
+++ b/plugins/affiliate/setup/patch_1.0.3.1.inc
@@ -0,0 +1,10 @@
+update($db_config,
+ array(
+ 'config_value' => '0,'.$cfg['plugin']['affiliate']['levelpay'],
+ 'config_default' => '0,'.$cfg['plugin']['affiliate']['levelpay']
+ ),
+ "config_owner='plug' AND config_cat='affiliate' AND config_name='levelpay'");
\ No newline at end of file
diff --git a/plugins/affiliate/setup/patch_1.1.4.inc b/plugins/affiliate/setup/patch_1.1.4.inc
new file mode 100644
index 0000000..5e81702
--- /dev/null
+++ b/plugins/affiliate/setup/patch_1.1.4.inc
@@ -0,0 +1,8 @@
+query('ALTER TABLE '. Cot::$db->users . ' MODIFY user_referal INT UNSIGNED NOT NULL DEFAULT 0');
\ No newline at end of file
diff --git a/plugins/affiliate/tpl/affiliate.admin.tpl b/plugins/affiliate/tpl/affiliate.admin.tpl
new file mode 100644
index 0000000..f57db68
--- /dev/null
+++ b/plugins/affiliate/tpl/affiliate.admin.tpl
@@ -0,0 +1,44 @@
+
+
+
+
+
+ {REF_ROW_NAME}:
+ {REF_ROW_TREE}
+
+
+
+
+
+
+
+
{PHP.L.affiliate_payments_title}:
+
+
+
+
+ #
+ {PHP.L.Date}
+ {PHP.L.affiliate_referal}
+ {PHP.L.affiliate_partner}
+ {PHP.L.affiliate_partner_summ}
+
+
+
+
+
+ {PAY_ROW_ID}
+ {PAY_ROW_PDATE|cot_date('d.m.Y H:i', $this)}
+ {PAY_ROW_REFERAL_NAME}
+ {PAY_ROW_PARTNER_NAME}
+ {PAY_ROW_SUMM|number_format($this, '2', '.', ' ')} {PHP.cfg.payments.valuta}
+
+
+
+
+
+
{PHP.L.payments_allpayments}: {PAYMENT_SUMM|number_format($this, '2', '.', ' ')} {PHP.cfg.payments.valuta}
+
+
+
+
\ No newline at end of file
diff --git a/plugins/affiliate/tpl/affiliate.level.admin.tpl b/plugins/affiliate/tpl/affiliate.level.admin.tpl
new file mode 100644
index 0000000..cba5d4d
--- /dev/null
+++ b/plugins/affiliate/tpl/affiliate.level.admin.tpl
@@ -0,0 +1,12 @@
+
+
+
+
+
+ {REFERAL_ROW_USER_NAME} ({REFERAL_ROW_PERCENT}%)
+ {REFERAL_ROW_SUBREFERALS}
+
+
+
+
+
\ No newline at end of file
diff --git a/plugins/affiliate/tpl/affiliate.level.tpl b/plugins/affiliate/tpl/affiliate.level.tpl
new file mode 100644
index 0000000..cba5d4d
--- /dev/null
+++ b/plugins/affiliate/tpl/affiliate.level.tpl
@@ -0,0 +1,12 @@
+
+
+
+
+
+ {REFERAL_ROW_USER_NAME} ({REFERAL_ROW_PERCENT}%)
+ {REFERAL_ROW_SUBREFERALS}
+
+
+
+
+
\ No newline at end of file
diff --git a/plugins/affiliate/tpl/affiliate.tpl b/plugins/affiliate/tpl/affiliate.tpl
new file mode 100644
index 0000000..51648de
--- /dev/null
+++ b/plugins/affiliate/tpl/affiliate.tpl
@@ -0,0 +1,42 @@
+
+
+
{PHP.L.affiliate}
+
+
{PHP.L.affiliate_link_title}:
+
{PHP.cfg.mainurl}/?ref={PHP.usr.id}
+
+
+
{PHP.L.affiliate_tree_title}:
+ {REFERALS_TREE}
+
+
+
+
+
{PHP.L.affiliate_payments_title}:
+
+
+
+
+ #
+ {PHP.L.Date}
+ {PHP.L.affiliate_referal}
+ {PHP.L.payments_summ}
+
+
+
+
+
+ {PAY_ROW_ID}
+ {PAY_ROW_PDATE|cot_date('d.m.Y H:i', $this)}
+ {PAY_ROW_REFERAL_NAME}
+ {PAY_ROW_SUMM|number_format($this, '2', '.', ' ')} {PHP.cfg.payments.valuta}
+
+
+
+
+
+
{PHP.L.payments_allpayments}: {PAYMENT_SUMM|number_format($this, '2', '.', ' ')} {PHP.cfg.payments.valuta}
+
+
+
+
\ No newline at end of file
diff --git a/plugins/autoalias2lance/autoalias2lance.admin.php b/plugins/autoalias2lance/autoalias2lance.admin.php
index 4fdac7a..5899783 100644
--- a/plugins/autoalias2lance/autoalias2lance.admin.php
+++ b/plugins/autoalias2lance/autoalias2lance.admin.php
@@ -59,4 +59,4 @@
cot_display_messages($t);
$t->parse();
-$plugin_body = $t->text('MAIN');
+$pluginBody = $t->text('MAIN');
diff --git a/plugins/bstat/bstat.admin.home.php b/plugins/bstat/bstat.admin.home.php
new file mode 100644
index 0000000..b571a19
--- /dev/null
+++ b/plugins/bstat/bstat.admin.home.php
@@ -0,0 +1,113 @@
+query("SELECT pay_adate FROM $db_payments WHERE pay_status='done' AND pay_area='balance' ORDER BY pay_adate ASC")->fetchColumn();
+ }
+
+ $mindate = mktime( 0, 0, 0, cot_date('m', $mindate), cot_date('d', $mindate), cot_date('Y', $mindate) );
+
+ $maxdate = $sys['now'];
+ $maxdate = mktime( 23, 59, 59, cot_date('m', $maxdate), cot_date('d', $maxdate), cot_date('Y', $maxdate) );
+
+ $day = $mindate;
+ while($day <= $maxdate){
+ $nextday = $day + 24*60*60;
+ $paysumm[$day]['debet'] = $db->query("SELECT SUM(pay_summ) FROM $db_payments WHERE pay_status='done' AND pay_area='balance' AND pay_desc='Пополнение счета' AND pay_summ>0 AND pay_adate >= ".$day." AND pay_adate < ".$nextday)->fetchColumn();
+ $paysumm[$day]['credit'] = $db->query("SELECT SUM(pay_summ) FROM $db_payments WHERE pay_status='done' AND pay_area='balance' AND pay_summ<0 AND pay_adate >= ".$day." AND pay_adate < ".$nextday)->fetchColumn();
+ $day = $nextday;
+ }
+
+ if(is_array($paysumm)){
+ foreach($paysumm AS $day => $summ){
+ $tt->assign(array(
+ 'PAY_ROW_DEBET_SUMM' => (!empty($summ['debet'])) ? $summ['debet'] : 0,
+ 'PAY_ROW_CREDIT_SUMM' => (!empty($summ['credit'])) ? abs($summ['credit']) : 0,
+ 'PAY_ROW_DAY' => $day,
+ ));
+ $tt->parse('MAIN.PAY_ROW');
+ }
+ }
+}
+
+$sql = 'SELECT SUM(pay_summ) AS summ, pay_userid as userId FROM ' . Cot::$db->payments
+ . " WHERE pay_area = '" . PaymentDictionary::PAYMENT_SOURCE_BALANCE . "'"
+ . " AND pay_status = '" . PaymentDictionary::STATUS_DONE . "'"
+ . " GROUP BY pay_userid HAVING SUM(pay_summ) > 0 ORDER BY summ DESC LIMIT 300";
+
+$balances = Cot::$db->query($sql)->fetchAll();
+
+$users = [];
+if (!empty($balances)) {
+ $userIds = [];
+ foreach($balances AS $balance) {
+ if (!in_array($balance['userId'], $userIds)) {
+ $userIds[] = (int) $balance['userId'];
+ }
+ }
+ if ($userIds !== []) {
+ $tmp = UsersRepository::getInstance()->getByCondition(
+ ['user_id IN (' . implode(',', $userIds) . ')']
+ );
+ foreach ($tmp AS $user) {
+ $users[$user['user_id']] = $user;
+ }
+ }
+}
+
+$jj = 0;
+$summ = 0;
+
+if (!empty($balances)) {
+ foreach($balances AS $balance) {
+ $jj++;
+
+ $userData = (!empty($users[$balance['userId']])) ? $users[$balance['userId']] : [];
+
+ $tt->assign(cot_generate_usertags($userData, 'BAL_ROW_USER_'));
+
+ $tt->assign([
+ 'BAL_ROW_SUMM' => $balance['summ'],
+ "BAL_ROW_ODDEVEN" => cot_build_oddeven($jj)
+ ]);
+
+ $summ += $balance['summ'];
+
+ $tt->parse('MAIN.BAL_ROW');
+ }
+}
+
+// @todo Это неверно т.к. в выборке выше есть технический лимит
+$tt->assign('BAL_SUMM', $summ);
+
+$tt->parse('MAIN');
+$line = $tt->text('MAIN');
diff --git a/plugins/bstat/bstat.png b/plugins/bstat/bstat.png
new file mode 100644
index 0000000..5ba4f17
Binary files /dev/null and b/plugins/bstat/bstat.png differ
diff --git a/plugins/bstat/bstat.setup.php b/plugins/bstat/bstat.setup.php
new file mode 100644
index 0000000..c84e6cd
--- /dev/null
+++ b/plugins/bstat/bstat.setup.php
@@ -0,0 +1,24 @@
+
+
+
+
{PHP.L.bstat_graph_title}
+
+
+
+
+
+
+
+
{PHP.L.bstat_users_title}
+
+
+
+
+ {BAL_ROW_USER_FULL_NAME}
+ {BAL_ROW_SUMM} {PHP.cfg.payments.valuta}
+
+
+
+
+
+
+ {PHP.L.All}
+ {BAL_SUMM} {PHP.cfg.payments.valuta}
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/plugins/commentsfolio/commentsfolio.folio.edit.delete.done.php b/plugins/commentsfolio/commentsfolio.folio.edit.delete.done.php
new file mode 100644
index 0000000..b695771
--- /dev/null
+++ b/plugins/commentsfolio/commentsfolio.folio.edit.delete.done.php
@@ -0,0 +1,21 @@
+ $item['item_cat'], 'id' => $item['item_id']) : array('c' => $item['item_cat'], 'al' => $item['item_alias']);
+$t->assign(array(
+ 'LIST_ROW_COMMENTS' => cot_comments_link('folio', $page_urlp, 'folio', $item['item_id'], $c, $pag),
+ 'LIST_ROW_COMMENTS_COUNT' => cot_comments_count('folio', $item['item_id'], $pag)
+));
\ No newline at end of file
diff --git a/plugins/commentsfolio/commentsfolio.folio.list.query.php b/plugins/commentsfolio/commentsfolio.folio.list.query.php
new file mode 100644
index 0000000..e7315d3
--- /dev/null
+++ b/plugins/commentsfolio/commentsfolio.folio.list.query.php
@@ -0,0 +1,23 @@
+assign(array(
+ 'LIST_COMMENTS' => cot_comments_link('folio', 'c='.$c, 'folio', $c),
+ 'LIST_COMMENTS_COUNT' => cot_comments_count('folio', $c),
+ 'LIST_COMMENTS_DISPLAY' => cot_comments_display('folio', $c, $c)
+));
\ No newline at end of file
diff --git a/plugins/commentsfolio/commentsfolio.folio.tags.php b/plugins/commentsfolio/commentsfolio.folio.tags.php
new file mode 100644
index 0000000..4e96e29
--- /dev/null
+++ b/plugins/commentsfolio/commentsfolio.folio.tags.php
@@ -0,0 +1,27 @@
+assign(array(
+ 'PRD_COMMENTS' => cot_comments_link('folio', $pageurl_params, 'folio', $item['item_id'] , $item['item_cat'], $pag),
+ 'PRD_COMMENTS_DISPLAY' => cot_comments_display('folio', $item['item_id'] , $item['item_cat']),
+ 'PRD_COMMENTS_COUNT' => cot_comments_count('folio',$item['item_id'] , $pag),
+ 'PRD_COMMENTS_RSS' => cot_url('rss', 'm=comments&id=' . $item['item_id'])
+));
\ No newline at end of file
diff --git a/plugins/commentsfolio/commentsfolio.png b/plugins/commentsfolio/commentsfolio.png
new file mode 100644
index 0000000..c363f1e
Binary files /dev/null and b/plugins/commentsfolio/commentsfolio.png differ
diff --git a/plugins/commentsfolio/commentsfolio.setup.php b/plugins/commentsfolio/commentsfolio.setup.php
new file mode 100644
index 0000000..f2d986c
--- /dev/null
+++ b/plugins/commentsfolio/commentsfolio.setup.php
@@ -0,0 +1,18 @@
+ $item['item_cat'], 'id' => $item['item_id']) : array('c' => $item['item_cat'], 'al' => $item['item_alias']);
+$t->assign(array(
+ 'LIST_ROW_COMMENTS' => cot_comments_link('market', $page_urlp, 'market', $item['item_id'], $c, $pag),
+ 'LIST_ROW_COMMENTS_COUNT' => cot_comments_count('market', $item['item_id'], $pag)
+
+));
\ No newline at end of file
diff --git a/plugins/commentsmarket/commentsmarket.market.list.query.php b/plugins/commentsmarket/commentsmarket.market.list.query.php
new file mode 100644
index 0000000..4711025
--- /dev/null
+++ b/plugins/commentsmarket/commentsmarket.market.list.query.php
@@ -0,0 +1,24 @@
+assign(array(
+ 'LIST_COMMENTS' => cot_comments_link('market', 'c='.$c, 'market', $c),
+ 'LIST_COMMENTS_COUNT' => cot_comments_count('market', $c),
+ 'LIST_COMMENTS_DISPLAY' => cot_comments_display('market', $c, $c)
+));
\ No newline at end of file
diff --git a/plugins/commentsmarket/commentsmarket.market.tags.php b/plugins/commentsmarket/commentsmarket.market.tags.php
new file mode 100644
index 0000000..1d2bc22
--- /dev/null
+++ b/plugins/commentsmarket/commentsmarket.market.tags.php
@@ -0,0 +1,28 @@
+assign(array(
+ 'PRD_COMMENTS' => cot_comments_link('market', $pageurl_params, 'market', $item['item_id'] , $item['item_cat'], $pag),
+ 'PRD_COMMENTS_DISPLAY' => cot_comments_display('market', $item['item_id'] , $item['item_cat']),
+ 'PRD_COMMENTS_COUNT' => cot_comments_count('market',$item['item_id'] , $pag),
+ 'PRD_COMMENTS_RSS' => cot_url('rss', 'm=comments&id=' . $item['item_id'])
+));
\ No newline at end of file
diff --git a/plugins/commentsmarket/commentsmarket.setup.php b/plugins/commentsmarket/commentsmarket.setup.php
new file mode 100644
index 0000000..5334d1c
--- /dev/null
+++ b/plugins/commentsmarket/commentsmarket.setup.php
@@ -0,0 +1,18 @@
+$next_lvl_arr)
+{
+ foreach ($next_lvl_arr as $key => $value) {
+ $arr["FOOTER_COUNT_".$counter."_".$key] = $value;
+ }
+}
+$t1->assign($arr);
+$t1->parse('MAIN');
+$t->assign('FOOTER_COUNTER_TAG', $t1->text('MAIN'));
+}
\ No newline at end of file
diff --git a/plugins/countingusers/countingusers.header.php b/plugins/countingusers/countingusers.header.php
new file mode 100644
index 0000000..dd41cb3
--- /dev/null
+++ b/plugins/countingusers/countingusers.header.php
@@ -0,0 +1,37 @@
+$next_lvl_arr)
+{
+ foreach ($next_lvl_arr as $key => $value) {
+ $arr["HEADER_COUNT_".$counter."_".$key] = $value;
+ }
+}
+$t1->assign($arr);
+$t1->parse('MAIN');
+$t->assign('HEADER_COUNTER_TAG', $t1->text('MAIN'));
+}
\ No newline at end of file
diff --git a/plugins/countingusers/countingusers.index.php b/plugins/countingusers/countingusers.index.php
new file mode 100644
index 0000000..1a528f9
--- /dev/null
+++ b/plugins/countingusers/countingusers.index.php
@@ -0,0 +1,37 @@
+$next_lvl_arr)
+{
+ foreach ($next_lvl_arr as $key => $value) {
+ $arr["INDEX_COUNT_".$counter."_".$key] = $value;
+ }
+}
+$t1->assign($arr);
+$t1->parse('MAIN');
+$t->assign('INDEX_COUNTER_TAG', $t1->text('MAIN'));
+}
\ No newline at end of file
diff --git a/plugins/countingusers/countingusers.png b/plugins/countingusers/countingusers.png
new file mode 100644
index 0000000..a2bb9ed
Binary files /dev/null and b/plugins/countingusers/countingusers.png differ
diff --git a/plugins/countingusers/countingusers.setup.php b/plugins/countingusers/countingusers.setup.php
new file mode 100644
index 0000000..9f8641c
--- /dev/null
+++ b/plugins/countingusers/countingusers.setup.php
@@ -0,0 +1,34 @@
+db->get('counter_user', 'countingusers') : '' ;
+ if (is_null($result) || empty($result))
+ {
+ // кеш пуст, надо обновить
+ $result = get_data(); //получить данные
+ if($cache) {
+ if(is_numeric($cfg['plugin']['countingusers']['cache_db_ttl']))
+ $cache->db->store('counter_user', $result, 'countingusers', $cfg['plugin']['countingusers']['cache_db_ttl']);
+ }
+ }
+ return $result;
+ }
+ //получение данных с БД
+ function get_data(){
+ global $cfg;
+ //Если включен подсчет пользователей
+ if ($cfg['plugin']['countingusers']['count_usr'])
+ {
+ $count_usr = str_replace(' ', '', $cfg['plugin']['countingusers']['user_maingrp_count']);
+ $count_usr = explode(',', $count_usr);
+
+ foreach ($count_usr as $key => $value) {
+ if(is_numeric($value)){
+ $result["USR"][$value] = get_usrs_count($value);
+ }
+ }
+ if($cfg['plugin']['countingusers']['user_count_all']){
+ $result["USR"]["ALL"] = array_sum($result["USR"]);
+ }
+ }
+ //Если включен подсчет проектов
+ if ($cfg['plugin']['countingusers']['count_prj'] && cot_module_active('projects'))
+ {
+
+ $count_prj = str_replace(' ', '', $cfg['plugin']['countingusers']['projects_item_state']);
+
+ if($cfg['plugin']['countingusers']['projects_item_state'] == '0'){
+ $result["PRJ"][$cfg['plugin']['countingusers']['projects_item_state']] = get_prjs_count($cfg['plugin']['countingusers']['projects_item_state']);
+
+ }else {
+ $count_prj = explode(',', $count_prj);
+ foreach ($count_prj as $key => $value) {
+ if(is_numeric($value)){
+ $result["PRJ"][$value] =get_prjs_count($value);
+ }
+ }
+ }
+
+ if($cfg['plugin']['countingusers']['projects_from'] > 0){
+ global $db, $db_projects, $sys;
+ $openfrom = $sys['now'] - (int) $cfg['plugin']['countingusers']['projects_from'];
+ $result["PRJ"]["OPENFROM"] = $db->query("SELECT COUNT(*) FROM $db_projects WHERE item_state = 0 AND item_date > ".$openfrom)->fetchColumn();
+ }
+ }
+ //Если включен подсчет товаров
+ if ($cfg['plugin']['countingusers']['market_count'] && cot_module_active('market'))
+ {
+ $result["PRD"]["0"] = get_prds_count(0);
+ }
+ return $result;
+ }
+ function get_usrs_count($grp_id){
+ global $db, $db_users;
+ return $db->query("SELECT COUNT(*) FROM $db_users WHERE user_maingrp=".$grp_id."")->fetchColumn();
+ }
+ function get_prjs_count($prjs_status_id){
+ global $db, $db_projects;
+ return $db->query("SELECT COUNT(*) FROM $db_projects WHERE item_state=".$prjs_status_id)->fetchColumn();
+ }
+ function get_prds_count($prds_status_id){
+ global $db, $db_market;
+ return $db->query("SELECT COUNT(*) FROM $db_market WHERE item_state=".(int)$prds_status_id)->fetchColumn();
+ }
\ No newline at end of file
diff --git a/plugins/countingusers/lang/countingusers.en.lang.php b/plugins/countingusers/lang/countingusers.en.lang.php
new file mode 100644
index 0000000..d4fa787
--- /dev/null
+++ b/plugins/countingusers/lang/countingusers.en.lang.php
@@ -0,0 +1,17 @@
+ '0 '= Open
'1' = Stkrytye
'-1' = Removed ");
+$L['cfg_projects_from'] = array("Count the number of open projects in the past (s)", "0 - disable,");
+$L['cfg_market_count'] = array("Count the number of Products summary");
+$L['fr_users_title'] = 'Users';
+$L['fr_freelancers_title'] = 'Performers';
+$L['fr_employers_title'] = 'Rabotodaletey';
+$L['fr_traders_title'] = 'sales representatives';
+$L['fr_projects_title'] = 'Open Projects summary';
+$L['fr_projects_from_title'] = 'Open projects in recent years';
+$L['fr_market_title'] = 'Products';
\ No newline at end of file
diff --git a/plugins/countingusers/lang/countingusers.ru.lang.php b/plugins/countingusers/lang/countingusers.ru.lang.php
new file mode 100644
index 0000000..f3fc71a
--- /dev/null
+++ b/plugins/countingusers/lang/countingusers.ru.lang.php
@@ -0,0 +1,17 @@
+'0' = Открытые
'1' = Сткрытые
'-1' =Удалено");
+$L['cfg_projects_from'] = array("Считать количество отрытых проектов за последние (сек)", "0 - отключено");
+$L['cfg_market_count'] = array("Считать количество опубликованных товаров");
+$L['fr_users_title'] = 'Пользователей';
+$L['fr_freelancers_title'] = 'Исполнителей';
+$L['fr_employers_title'] = 'Работодалетей';
+$L['fr_traders_title'] = 'Торговых представителей';
+$L['fr_projects_title'] = 'Открытых проектов';
+$L['fr_projects_from_title'] = 'Открытых проектов за последнее время';
+$L['fr_market_title'] = 'Товаров';
\ No newline at end of file
diff --git a/plugins/countingusers/tpl/countingusers.footer.tpl b/plugins/countingusers/tpl/countingusers.footer.tpl
new file mode 100644
index 0000000..7e1d3d6
--- /dev/null
+++ b/plugins/countingusers/tpl/countingusers.footer.tpl
@@ -0,0 +1,46 @@
+
+
+
+
+ {PHP.L.fr_users_title}
+ {FOOTER_COUNT_USR_ALL}
+
+
+
+
+ {PHP.L.fr_freelancers_title}
+ {FOOTER_COUNT_USR_4}
+
+
+
+
+ {PHP.L.fr_employers_title}
+ {FOOTER_COUNT_USR_7}
+
+
+
+
+ {PHP.L.fr_traders_title}
+ {FOOTER_COUNT_USR_8}
+
+
+
+
+ {PHP.L.fr_projects_title}
+ {FOOTER_COUNT_PRJ_0}
+
+
+
+
+ {PHP.L.fr_projects_from_title}
+ {FOOTER_COUNT_PRJ_OPENFROM}
+
+
+
+
+ {PHP.L.fr_market_title}
+ {FOOTER_COUNT_PRD_0}
+
+
+
+
\ No newline at end of file
diff --git a/plugins/countingusers/tpl/countingusers.header.tpl b/plugins/countingusers/tpl/countingusers.header.tpl
new file mode 100644
index 0000000..5b1b9f8
--- /dev/null
+++ b/plugins/countingusers/tpl/countingusers.header.tpl
@@ -0,0 +1,46 @@
+
+
+
+
+ {PHP.L.fr_users_title}
+ {HEADER_COUNT_USR_ALL}
+
+
+
+
+ {PHP.L.fr_freelancers_title}
+ {HEADER_COUNT_USR_4}
+
+
+
+
+ {PHP.L.fr_employers_title}
+ {HEADER_COUNT_USR_7}
+
+
+
+
+ {PHP.L.fr_traders_title}
+ {HEADER_COUNT_USR_8}
+
+
+
+
+ {PHP.L.fr_projects_title}
+ {HEADER_COUNT_PRJ_0}
+
+
+
+
+ {PHP.L.fr_projects_from_title}
+ {HEADER_COUNT_PRJ_OPENFROM}
+
+
+
+
+ {PHP.L.fr_market_title}
+ {HEADER_COUNT_PRD_0}
+
+
+
+
\ No newline at end of file
diff --git a/plugins/countingusers/tpl/countingusers.index.tpl b/plugins/countingusers/tpl/countingusers.index.tpl
new file mode 100644
index 0000000..87338a7
--- /dev/null
+++ b/plugins/countingusers/tpl/countingusers.index.tpl
@@ -0,0 +1,46 @@
+
+
+
+
+ {PHP.L.fr_users_title}
+ {INDEX_COUNT_USR_ALL}
+
+
+
+
+ {PHP.L.fr_freelancers_title}
+ {INDEX_COUNT_USR_4}
+
+
+
+
+ {PHP.L.fr_employers_title}
+ {INDEX_COUNT_USR_7}
+
+
+
+
+ {PHP.L.fr_traders_title}
+ {INDEX_COUNT_USR_8}
+
+
+
+
+ {PHP.L.fr_projects_title}
+ {INDEX_COUNT_PRJ_0}
+
+
+
+
+ {PHP.L.fr_projects_from_title}
+ {INDEX_COUNT_PRJ_OPENFROM}
+
+
+
+
+ {PHP.L.fr_market_title}
+ {INDEX_COUNT_PRD_0}
+
+
+
+
\ No newline at end of file
diff --git a/plugins/detailcounts/detailcounts.png b/plugins/detailcounts/detailcounts.png
new file mode 100644
index 0000000..555072b
Binary files /dev/null and b/plugins/detailcounts/detailcounts.png differ
diff --git a/plugins/detailcounts/detailcounts.setup.php b/plugins/detailcounts/detailcounts.setup.php
new file mode 100644
index 0000000..8c7b72c
--- /dev/null
+++ b/plugins/detailcounts/detailcounts.setup.php
@@ -0,0 +1,23 @@
+query("UPDATE $db_users SET user_detailcounts= user_detailcounts + 1 WHERE user_id= $id");
+}
\ No newline at end of file
diff --git a/plugins/detailcounts/detailcounts.users.details.tags.php b/plugins/detailcounts/detailcounts.users.details.tags.php
new file mode 100644
index 0000000..2c8ef52
--- /dev/null
+++ b/plugins/detailcounts/detailcounts.users.details.tags.php
@@ -0,0 +1,12 @@
+assign(array(
+ 'USERS_DETAILS_DETAILCOUNTS_TITLE' => $L["detailcounts_title"],
+ 'USERS_DETAILS_DETAILCOUNTS' => $urr["user_detailcounts"]
+));
\ No newline at end of file
diff --git a/plugins/detailcounts/lang/detailcounts.en.lang.php b/plugins/detailcounts/lang/detailcounts.en.lang.php
new file mode 100644
index 0000000..8bad985
--- /dev/null
+++ b/plugins/detailcounts/lang/detailcounts.en.lang.php
@@ -0,0 +1,8 @@
+fieldExists($db_users, "user_detailcounts")) {
+ Cot::$db->query('ALTER TABLE ' . Cot::$db->users . ' ADD COLUMN user_detailcounts INT NOT NULL DEFAULT 0');
+}
\ No newline at end of file
diff --git a/plugins/detailcounts/setup/detailcounts.uninstall.php b/plugins/detailcounts/setup/detailcounts.uninstall.php
new file mode 100644
index 0000000..32e1e03
--- /dev/null
+++ b/plugins/detailcounts/setup/detailcounts.uninstall.php
@@ -0,0 +1,9 @@
+fieldExists(Cot::$db->users, 'user_detailcounts')) {
+ Cot::$db->query('ALTER TABLE ' . Cot::$db->users . ' DROP COLUMN user_detailcounts');
+}
\ No newline at end of file
diff --git a/plugins/detailcounts/setup/patch_1.0.2.inc b/plugins/detailcounts/setup/patch_1.0.2.inc
new file mode 100644
index 0000000..87dac4b
--- /dev/null
+++ b/plugins/detailcounts/setup/patch_1.0.2.inc
@@ -0,0 +1,8 @@
+query('ALTER TABLE ' . Cot::$db->users . ' MODIFY user_detailcounts INT NOT NULL DEFAULT 0');
\ No newline at end of file
diff --git a/plugins/filterforuser/filterforuser.admin.php b/plugins/filterforuser/filterforuser.admin.php
new file mode 100644
index 0000000..4fe5881
--- /dev/null
+++ b/plugins/filterforuser/filterforuser.admin.php
@@ -0,0 +1,84 @@
+query($queryToDB)->fetchColumn() > 0)
+ {
+ $db->update($db_filterforuser, array('fu_fieldstatus' => 1), "fu_fieldname = '$fu_opt'");
+ }
+ else
+ {
+ $db->insert($db_filterforuser, array('fu_fieldname' => $fu_opt, 'fu_fieldstatus' => 1));
+ }
+ cot_message(cot_rc('filterfor_add', $fu_opt));
+ cot_redirect(cot_url('admin', 'm=other&p=filterforuser', '', true));
+}elseif($a == 'delete'){ // вимикаємо використання поля в фільтрі
+ $fu_opt = trim(cot_import('fu_options', 'G', 'TXT'));
+ $queryToDB = "SELECT COUNT(*) FROM $db_filterforuser WHERE fu_fieldname = '$fu_opt'";
+ if ($db->query($queryToDB)->fetchColumn() == 1)
+ {
+ $db->delete($db_filterforuser, "fu_fieldname = ?", $fu_opt);
+ }
+ cot_message(cot_rc('filterfor_delete', $fu_opt));
+ cot_redirect(cot_url('admin', 'm=other&p=filterforuser', '', true));
+}
+
+$array_fu = array();
+$count = 0;
+$allowtype = array('select','checklistbox','radio');
+foreach($cot_extrafields[$db_users] as $exfld)
+{
+ if(in_array($exfld['field_type'], $allowtype, true)){
+ $array_fu[$count]['futype'] = $exfld['field_type'];
+ $array_fu[$count]['funame'] = strtolower($exfld['field_name']);
+ $array_fu[$count]['futext'] = isset($L['user_'.$exfld['field_name'].'_title']) ? $L['user_'.$exfld['field_name'].'_title'] : $exfld['field_description'];
+ $array_fu[$count]['fuenabled'] = ($exfld['field_enabled']) ? "Используется" : "Отключено" ;
+ $count++;
+ }
+}
+foreach ($array_fu as $val)
+{
+ if ($db->query("SELECT COUNT(*) FROM $db_filterforuser WHERE fu_fieldname = '$val[funame]'")->fetchColumn() == 1) {
+ $fu_url = cot_url('admin', 'm=other&p=filterforuser&a=delete&fu_options='.$val['funame']);
+ $fu_title = $L['filterfor_off'];
+ }else{
+ $fu_url = cot_url('admin', 'm=other&p=filterforuser&a=add&fu_options='.$val['funame']);
+ $fu_title = $L['filterfor_on'];
+ }
+ $t->assign(array(
+ 'FILTERFORUSER_ADD_OPTION' => $val['futext']." [".$val['funame']."] - ".$val['futype'],
+ 'FILTERFORUSER_ADD' => ($val['fuenabled'] == 'Отключено') ? '#' : $fu_url,
+ 'FILTERFORUSER_ADD_TITLE' => $fu_title
+ ));
+ $t->parse('MAIN.OPT_ROW');
+}
+
+cot_display_messages($t);
+$t->parse();
+$plugin_body = $t->text('MAIN');
\ No newline at end of file
diff --git a/plugins/filterforuser/filterforuser.png b/plugins/filterforuser/filterforuser.png
new file mode 100644
index 0000000..346332c
Binary files /dev/null and b/plugins/filterforuser/filterforuser.png differ
diff --git a/plugins/filterforuser/filterforuser.setup.php b/plugins/filterforuser/filterforuser.setup.php
new file mode 100644
index 0000000..7a112d2
--- /dev/null
+++ b/plugins/filterforuser/filterforuser.setup.php
@@ -0,0 +1,22 @@
+query("SELECT COUNT(*) FROM $db_filterforuser WHERE fu_fieldname = '$exfld[field_name]'")->fetchColumn() == 1) {
+ $uname = strtolower($exfld['field_name']);
+ $fieldtext = isset($L['user_'.$exfld['field_name'].'_title']) ? $L['user_'.$exfld['field_name'].'_title'] : $exfld['field_description'];
+ $cs = (cot_import('fu_'.$uname, 'G', 'TXT')) ? cot_import('fu_'.$uname, 'G', 'TXT') : '';
+ if (!is_array($exfld['field_variants']))
+ {
+ $titles = explode(',', $exfld['field_variants']);
+ }
+ foreach ($titles as $key => $value) {
+ $titles_select[$value] = $value;
+ }
+ $titles_select = ($cfg['plugin']['filterforuser']['fu_usetitle_for_first']) ? array(0 => $fieldtext) + $titles_select : array(0 => '---') + $titles_select ;
+
+ $t->assign('USERS_TOP_FILTER_FU_'.strtoupper($uname), cot_selectbox($cs, "fu_".strtolower($exfld['field_name']), array_keys($titles_select), array_values($titles_select), $add_empty = false, $attrs = '', $custom_rc = '', $htmlspecialchars_bypass = false));
+ $t->assign('USERS_TOP_FILTER_FU_'.strtoupper($uname).'_TITLE', $fieldtext);
+ unset($titles_select);
+ }
+ }
diff --git a/plugins/filterforuser/filterforuser.users.query.php b/plugins/filterforuser/filterforuser.users.query.php
new file mode 100644
index 0000000..73abcce
--- /dev/null
+++ b/plugins/filterforuser/filterforuser.users.query.php
@@ -0,0 +1,36 @@
+query("SELECT COUNT(*) FROM $db_filterforuser WHERE fu_fieldname = '$exfld[field_name]'")->fetchColumn() == 1) {
+ $uname = strtolower($exfld['field_name']);
+ $fieldtext = isset($L['user_'.$exfld['field_name'].'_title']) ? $L['user_'.$exfld['field_name'].'_title'] : $exfld['field_description'];
+ $extfl = trim(cot_import('fu_'.$uname, 'G', 'TXT'));
+ $extfl = ($extfl == '0') ? '' : $extfl;
+ if (!empty($extfl)) {
+ if ($exfld['field_type'] == 'checklistbox') {
+ $where[$exfld['field_name']] = "user_$exfld[field_name] LIKE '%".$extfl."%'";
+ }else{
+ $where[$exfld['field_name']] = "user_$exfld[field_name] = '".$extfl."'";
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/plugins/filterforuser/inc/filterforuser.functions.php b/plugins/filterforuser/inc/filterforuser.functions.php
new file mode 100644
index 0000000..2592d1e
--- /dev/null
+++ b/plugins/filterforuser/inc/filterforuser.functions.php
@@ -0,0 +1,26 @@
+{$fu_opt} добавлен';
+$L['filterfor_delete'] = 'Фильтр для поля
{$fu_opt} отключен';
+$L['filterfor_on'] = 'Использовать';
+$L['filterfor_off'] = 'Выключить';
+$L['allowtypes'] = 'Доступны типы полей: select,checklistbox,radio';
\ No newline at end of file
diff --git a/plugins/filterforuser/readme.md b/plugins/filterforuser/readme.md
new file mode 100644
index 0000000..766a4e3
--- /dev/null
+++ b/plugins/filterforuser/readme.md
@@ -0,0 +1,49 @@
+Addition filter
+==============
+Version 1.0
+
+UA
+==============
+
+Додатковий фільтр для модуля USERS по екстраполям
+
+###Можливості:
+
+1. Пошук користувачів по трьох типах полів - select,radio,checklistbox
+
+2. Різні оформлення для полів
+
+
+###Інструкція по установці
+
+1. Завантажити і розпакувати вміст архіву, скопіювати файли в папку plugins.
+2. Встановити через панель: (Управління сайтом / Розширення / Addition filter).
+3. В адмініструванні увімкнути поля по яких потрібно здійснювати пошук.
+4. В налаштунках можна вибрати параметр.
+5. Після інсталяції вивести в user.tpl {USERS_TOP_FILTER_FU_XXX}, {USERS_TOP_FILTER_FU_XXX_TITLE} для кожного поля
+
+
+RU
+==============
+
+Дополнительный фильтр для модуля USERS по екстраполям
+
+###Возможности:
+
+1. Поиск пользователей по трем типам полей - select,radio,checklistbox
+
+2. Разные оформления для полей в форме поиска
+
+###Инструкция по уcтановке
+
+1. Загрузить и распаковать файли в папку plugins.
+2. Установить через панель: (Управленние сайтом / Расширения / Addition filter).
+3. В администрировании включить поля по которым нужно производить поиск.
+4. В настройках выбрать нужный параметр.
+5. После установки добавить в user.tpl {USERS_TOP_FILTER_FU_XXX}, {USERS_TOP_FILTER_FU_XXX_TITLE} для каждого поля
+
+[](https://www.youtube.com/watch?v=WtCJQUBhgnw)
+
+Розробник - Ярослав Романенко ( yaroslav.romanenko@gmail.com )
+
+[](https://bitdeli.com/free "Bitdeli Badge")
diff --git a/plugins/filterforuser/setup/filterforuser.install.sql b/plugins/filterforuser/setup/filterforuser.install.sql
new file mode 100644
index 0000000..60def12
--- /dev/null
+++ b/plugins/filterforuser/setup/filterforuser.install.sql
@@ -0,0 +1,8 @@
+/* filterforuser schema */
+
+CREATE TABLE IF NOT EXISTS `cot_filterforuser` (
+ /*`fu_id` int(11) unsigned NOT NULL auto_increment,*/
+ `fu_fieldname` varchar(255) collate utf8_unicode_ci NOT NULL,
+ `fu_fieldstatus` varchar(255) collate utf8_unicode_ci default NULL,
+ PRIMARY KEY (`fu_fieldname`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
\ No newline at end of file
diff --git a/plugins/filterforuser/setup/filterforuser.uninstall.sql b/plugins/filterforuser/setup/filterforuser.uninstall.sql
new file mode 100644
index 0000000..e859c03
--- /dev/null
+++ b/plugins/filterforuser/setup/filterforuser.uninstall.sql
@@ -0,0 +1,5 @@
+/**
+ * Completely removes filterforuser data
+ */
+
+DROP TABLE IF EXISTS `cot_filterforuser`;
\ No newline at end of file
diff --git a/plugins/filterforuser/tpl/filterforuser.admin.tpl b/plugins/filterforuser/tpl/filterforuser.admin.tpl
new file mode 100644
index 0000000..b0fce77
--- /dev/null
+++ b/plugins/filterforuser/tpl/filterforuser.admin.tpl
@@ -0,0 +1,13 @@
+
+
{PHP.L.filterforuser}
+
{PHP.L.allowtypes}
+{FILE "{PHP.cfg.system_dir}/admin/tpl/warnings.tpl"}
+
+
\ No newline at end of file
diff --git a/plugins/filterforuser/tpl/filterforuser.tpl b/plugins/filterforuser/tpl/filterforuser.tpl
new file mode 100644
index 0000000..75a5da4
--- /dev/null
+++ b/plugins/filterforuser/tpl/filterforuser.tpl
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/plugins/flevents/flevents.global.php b/plugins/flevents/flevents.global.php
new file mode 100644
index 0000000..04fc425
--- /dev/null
+++ b/plugins/flevents/flevents.global.php
@@ -0,0 +1,61 @@
+quoteC('count')
+ . ' FROM cot_flevents WHERE ev_touid = :userId AND ev_status = ' . EventDictionary::STATUS_NEW
+ . ' GROUP BY ev_touid, ev_area, ev_type';
+
+$eventsData = Cot::$db->query($query, ['userId' => Cot::$usr['id']])->fetchAll();
+
+$result = [
+ 'offers' => ['all' => 0],
+ 'marketorders' => ['all' => 0],
+ 'orderservices' => ['all' => 0],
+ 'reviews' => ['all' => 0],
+ 'sbr' => ['all' => 0],
+];
+
+if (empty($eventsData)) {
+ Cot::$usr['flevents'] = $result;
+ return;
+}
+
+foreach ($eventsData as $event) {
+ if (!isset($result[$event['ev_area']])) {
+ $result[$event['ev_area']] = [];
+ }
+ if (!isset($result[$event['ev_area']]['all'])) {
+ $result[$event['ev_area']]['all'] = 0;
+ }
+ if (!isset($result[$event['ev_area']][$event['ev_type']])) {
+ $result[$event['ev_area']][$event['ev_type']] = 0;
+ }
+ $result[$event['ev_area']]['all'] += $event['count'];
+ $result[$event['ev_area']][$event['ev_type']] += $event['count'];
+}
diff --git a/plugins/flevents/flevents.header.tags.php b/plugins/flevents/flevents.header.tags.php
new file mode 100644
index 0000000..ec46f66
--- /dev/null
+++ b/plugins/flevents/flevents.header.tags.php
@@ -0,0 +1,23 @@
+hasTag('HEADER_FL_EVENTS')) {
+ $event = flevents_show('header', Cot::$cfg['plugin']['flevents']['header_count']);
+ $t->assign('HEADER_FL_EVENTS', $event);
+}
\ No newline at end of file
diff --git a/plugins/flevents/flevents.marketorders.check.php b/plugins/flevents/flevents.marketorders.check.php
new file mode 100644
index 0000000..c3aadfb
--- /dev/null
+++ b/plugins/flevents/flevents.marketorders.check.php
@@ -0,0 +1,25 @@
+ '2') {
+ $db->query("UPDATE $db_flevents SET ev_status='0' WHERE ev_area='marketorders' AND ev_touid='".$usr['id']."' AND ev_code='".$id."' AND ev_status='1'");
+}
\ No newline at end of file
diff --git a/plugins/flevents/flevents.marketorders.neworder.php b/plugins/flevents/flevents.marketorders.neworder.php
new file mode 100644
index 0000000..4d31586
--- /dev/null
+++ b/plugins/flevents/flevents.marketorders.neworder.php
@@ -0,0 +1,43 @@
+ 0) ? $customer['user_id'] : '0';
+
+$ev_data_sell['ev_area'] = 'marketorders';
+$ev_data_sell['ev_type'] = 'sell';
+$ev_data_sell['ev_code'] = $marketorder['order_id'];
+$ev_data_sell['ev_date'] = (int)$sys['now'];
+$ev_data_sell['ev_touid'] = (int)$seller['user_id'];
+$ev_data_sell['ev_fromuid'] = (int)$cst_id;
+$ev_data_sell['ev_status'] = '1';
+
+insert_not($ev_data_sell);
+
+if ($cst_id > 0) {
+ $ev_data['ev_area'] = 'marketorders';
+ $ev_data['ev_type'] = 'buy';
+ $ev_data['ev_code'] = $marketorder['order_id'];
+ $ev_data['ev_date'] = (int)$sys['now'];
+ $ev_data['ev_touid'] = (int)$customer['user_id'];
+ $ev_data['ev_fromuid'] = '0';
+ $ev_data['ev_status'] = '1';
+
+ insert_not($ev_data);
+}
\ No newline at end of file
diff --git a/plugins/flevents/flevents.marketorders.order.done.php b/plugins/flevents/flevents.marketorders.order.done.php
new file mode 100644
index 0000000..ebb55be
--- /dev/null
+++ b/plugins/flevents/flevents.marketorders.order.done.php
@@ -0,0 +1,29 @@
+ '2') {
+ $db->query("UPDATE $db_flevents SET ev_status='0' WHERE ev_area='orderservices' AND ev_touid='".$usr['id']."' AND ev_code='".$id."' AND ev_status='1'");
+}
\ No newline at end of file
diff --git a/plugins/flevents/flevents.orderservices.neworder.php b/plugins/flevents/flevents.orderservices.neworder.php
new file mode 100644
index 0000000..e1c3005
--- /dev/null
+++ b/plugins/flevents/flevents.orderservices.neworder.php
@@ -0,0 +1,35 @@
+ 0) ? $customer['user_id'] : '0';
+
+$ev_data_sell['ev_area'] = 'orderservices';
+$ev_data_sell['ev_type'] = 'sell';
+$ev_data_sell['ev_code'] = $orderservice['order_id'];
+$ev_data_sell['ev_date'] = (int)$sys['now'];
+$ev_data_sell['ev_touid'] = (int)$seller['user_id'];
+$ev_data_sell['ev_fromuid'] = (int)$cst_id;
+$ev_data_sell['ev_status'] = '1';
+
+insert_not($ev_data_sell);
+
+if ($cst_id > 0) {
+ $ev_data['ev_area'] = 'orderservices';
+ $ev_data['ev_type'] = 'buy';
+ $ev_data['ev_code'] = $orderservice['order_id'];
+ $ev_data['ev_date'] = (int)$sys['now'];
+ $ev_data['ev_touid'] = (int)$customer['user_id'];
+ $ev_data['ev_fromuid'] = '0';
+ $ev_data['ev_status'] = '1';
+
+ insert_not($ev_data);
+}
\ No newline at end of file
diff --git a/plugins/flevents/flevents.orderservices.order.done.php b/plugins/flevents/flevents.orderservices.order.done.php
new file mode 100644
index 0000000..f53be9c
--- /dev/null
+++ b/plugins/flevents/flevents.orderservices.order.done.php
@@ -0,0 +1,20 @@
+ 0 && $usr['auth_read']);
+
+if (Cot::$cfg['plugin']['flevents']['perPage'] > 0) {
+ [$pn, $d, $d_url] = cot_import_pagenav('d', Cot::$cfg['plugin']['flevents']['perPage']);
+}
+
+Cot::$out['subtitle'] = Cot::$L['Events_title'];
+Cot::$out['head'] .= Cot::$R['code_noindex'];
+
+require_once Cot::$cfg['system_dir'].'/header.php';
+
+$query_limit = (Cot::$cfg['plugin']['flevents']['perPage'] > 0) ? "LIMIT $d, ". Cot::$cfg['plugin']['flevents']['perPage'] : '';
+
+$totalItems = Cot::$db->query(
+ 'SELECT COUNT(*) FROM ' . Cot::$db->flevents . ' WHERE ev_touid = ? AND ev_status = ' . EventDictionary::STATUS_NEW,
+ $usr['id']
+)->fetchColumn();
+
+$pagenav = cot_pagenav('flevents', [], $d, $totalItems, $cfg['plugin']['flevents']['perPage']);
+
+$t = new XTemplate(cot_tplfile('flevents', 'plug'));
+
+$t->assign([
+ 'EVENTS_COUNT' => $totalItems,
+ 'EV_REVLINK' => cot_url('users', 'm=details&id=' . $usr['id'] . '&u=' . $usr['name'] . '&tab=reviews'),
+]);
+
+$t->assign(cot_generatePaginationTags($pagenav));
+
+$events = [];
+if ($totalItems > 0) {
+ $query = 'SELECT * FROM ' . Cot::$db->flevents . ' WHERE ev_touid = ? AND ev_status = '
+ . EventDictionary::STATUS_NEW . ' ORDER BY ev_date DESC ' . $query_limit;
+ $events = Cot::$db->query($query, $usr['id'])->fetchAll();
+}
+
+$userIds = [];
+foreach ($events as $event) {
+ $userId = (int) $event['ev_fromuid'];
+ if ($userId > 0) {
+ $userIds[] = $userId;
+ }
+}
+$users = [];
+if (!empty($userIds)) {
+ $userList = UsersRepository::getInstance()
+ ->getByCondition('user_id IN (' . implode(',', $userIds) . ')');
+ foreach ($userList as $user) {
+ $users[$user['user_id']] = $user;
+ }
+ unset($userList);
+}
+
+foreach ($events as $event) {
+ if ($event['ev_area'] == 'offers') {
+ $t->assign(cot_generate_projecttags($event['ev_code'], 'EV_ROW_PRJ_'));
+ } elseif ($event['ev_area'] == 'sbr') {
+ $t->assign(cot_generate_sbrtags($event['ev_code'], 'EV_ROW_SBR_'));
+ } elseif ($event['ev_area'] == 'marketorders') {
+ $t->assign(cot_generate_ordermarkettags($event['ev_code'], 'EV_ROW_ORDER_'));
+ } elseif ($event['ev_area'] == 'orderservices') {
+ $t->assign(cot_generate_ordertags($event['ev_code'], 'EV_ROW_ORDER_'));
+ }
+
+
+ $t->assign(
+ cot_generate_usertags(
+ $users[$event['ev_fromuid']] ?? ['user_id' => 0],
+ 'EV_ROW_USER_'
+ )
+ );
+
+ if ($event['ev_type'] == 'setperformer' || $event['ev_type'] == 'addoffer' || $event['ev_type'] == 'paid' || $event['ev_type'] == 'add1' || $event['ev_type'] == 'edit1' || $event['ev_type'] == 'buy') {
+ $style = "bg-success";
+ } elseif ($event['ev_type'] == 'refuselastperformer' || $event['ev_type'] == 'refuse' || $event['ev_type'] == 'emp_cancel' || $event['ev_type'] == 'add-1' || $event['ev_type'] == 'edit-1') {
+ $style = "bg-danger";
+ } elseif ($event['ev_type'] == 'addpost' || $event['ev_type'] == 'addpost_offer' || $event['ev_type'] == 'confirm' || $event['ev_type'] == 'del' || $event['ev_type'] == 'sell') {
+ $style = "bg-warning";
+ } elseif ($event['ev_type'] == 'new' || $event['ev_type'] == 'edit') {
+ $style = "bg-info";
+ } else {
+ $style = "";
+ }
+
+ $t->assign([
+ "EV_ROW_ID" => $event['ev_id'],
+ "EV_ROW_AREA" => $event['ev_area'],
+ "EV_ROW_TYPE" => $event['ev_type'],
+ "EV_ROW_TO" => $event['ev_touid'],
+ "EV_ROW_FROM" => $event['ev_fromuid'],
+ "EV_ROW_DATE" => cot_date('datetime_medium', $event['ev_date']),
+ "EV_ROW_DATE_STAMP" => $event['ev_date'],
+ "EV_ROW_STYLER" => $style,
+ ]);
+
+ $t->parse("MAIN.EV_ROWS");
+}
+
+$t->parse('MAIN');
+$t->out('MAIN');
+
+require_once $cfg['system_dir'] . '/footer.php';
\ No newline at end of file
diff --git a/plugins/flevents/flevents.png b/plugins/flevents/flevents.png
new file mode 100644
index 0000000..a3abdfb
Binary files /dev/null and b/plugins/flevents/flevents.png differ
diff --git a/plugins/flevents/flevents.prj.offers.add.done.php b/plugins/flevents/flevents.prj.offers.add.done.php
new file mode 100644
index 0000000..8617c77
--- /dev/null
+++ b/plugins/flevents/flevents.prj.offers.add.done.php
@@ -0,0 +1,28 @@
+query("UPDATE $db_flevents SET ev_status='0' WHERE ev_area='offers' AND ev_touid='".$usr['id']."' AND ev_code='".$id."' AND ev_status='1'");
\ No newline at end of file
diff --git a/plugins/flevents/flevents.prj.offers.refuse.php b/plugins/flevents/flevents.prj.offers.refuse.php
new file mode 100644
index 0000000..9462361
--- /dev/null
+++ b/plugins/flevents/flevents.prj.offers.refuse.php
@@ -0,0 +1,27 @@
+query("UPDATE $db_flevents SET ev_status='0' WHERE ev_area='reviews' AND ev_touid='".$id."' AND ev_status='1'");
+}
\ No newline at end of file
diff --git a/plugins/flevents/flevents.reviews.edit.delete.done.php b/plugins/flevents/flevents.reviews.edit.delete.done.php
new file mode 100644
index 0000000..92017bb
--- /dev/null
+++ b/plugins/flevents/flevents.reviews.edit.delete.done.php
@@ -0,0 +1,27 @@
+query("UPDATE $db_flevents SET ev_status='0' WHERE ev_area='sbr' AND ev_touid='".$usr['id']."' AND ev_code='".$id."' AND ev_status='1'");
\ No newline at end of file
diff --git a/plugins/flevents/flevents.sbr.confirm.done.php b/plugins/flevents/flevents.sbr.confirm.done.php
new file mode 100644
index 0000000..093d1a7
--- /dev/null
+++ b/plugins/flevents/flevents.sbr.confirm.done.php
@@ -0,0 +1,27 @@
+registerTable('flevents');
+
+function insert_not($noti_data)
+{
+ global $db, $db_flevents;
+ $db->insert($db_flevents, $noti_data);
+}
+
+function flevents_show($template = '', $count = null)
+{
+ global $db, $db_flevents, $usr;
+
+ if (Cot::$cfg['plugin']['flevents']['perPage'] > 0 && empty($count)) {
+ [$pn, $d, $d_url] = cot_import_pagenav('d', Cot::$cfg['plugin']['flevents']['perPage']);
+ }
+
+ $query_limit = (Cot::$cfg['plugin']['flevents']['perPage'] > 0 && empty($count))
+ ? "LIMIT $d, " . Cot::$cfg['plugin']['flevents']['perPage']
+ : "LIMIT " . $count;
+
+ $sql = Cot::$db->query(
+ 'SELECT * FROM ' . Cot::$db->flevents . ' WHERE ev_status = 1 AND ev_touid = ? ORDER BY ev_date DESC '
+ . $query_limit,
+ Cot::$usr['id']
+ );
+
+ $t = new XTemplate(cot_tplfile(['flevents', $template], 'plug'));
+
+ if (empty($count)) {
+ $totalitems = Cot::$db->query(
+ 'SELECT COUNT(*) FROM ' . Cot::$db->flevents . ' WHERE ev_status = 1 AND ev_touid = ?',
+ Cot::$usr['id']
+ )->fetchColumn();
+ $pagenav = cot_pagenav('flevents', [], $d, $totalitems, Cot::$cfg['plugin']['flevents']['perPage']);
+
+ $t->assign(cot_generatePaginationTags($pagenav));
+
+ } else {
+ $totalitems = Cot::$db->query(
+ 'SELECT COUNT(*) FROM ' . Cot::$db->flevents . ' WHERE ev_status = 1 AND ev_touid = ? ' . $query_limit,
+ Cot::$usr['id']
+ )->fetchColumn();
+ }
+
+ $t->assign([
+ "EVENTS_COUNT" => $totalitems,
+// "PAGENAV_PAGES" => $pagenav['main'],
+// "PAGENAV_PREV" => $pagenav['prev'],
+// "PAGENAV_NEXT" => $pagenav['next'],
+ "EV_REVLINK" => cot_url('users', 'm=details&id=' . $usr['id'] . '&u=' . $usr['name'] . '&tab=reviews'),
+ ]);
+
+ while ($flevents = $sql->fetch()) {
+ if ($flevents['ev_area'] == 'offers') {
+ $t->assign(cot_generate_projecttags($flevents['ev_code'], 'EV_ROW_PRJ_'));
+ } elseif ($flevents['ev_area'] == 'sbr') {
+ $t->assign(cot_generate_sbrtags($flevents['ev_code'], 'EV_ROW_SBR_'));
+ } elseif ($flevents['ev_area'] == 'marketorders') {
+ $t->assign(cot_generate_ordermarkettags($flevents['ev_code'], 'EV_ROW_ORDER_'));
+ } elseif ($flevents['ev_area'] == 'orderservices') {
+ $t->assign(cot_generate_ordertags($flevents['ev_code'], 'EV_ROW_ORDER_'));
+ }
+
+ $t->assign(cot_generate_usertags($flevents['ev_fromuid'], 'EV_ROW_USER_'));
+
+ if ($flevents['ev_type'] == 'setperformer' || $flevents['ev_type'] == 'addoffer' || $flevents['ev_type'] == 'paid' || $flevents['ev_type'] == 'add1' || $flevents['ev_type'] == 'edit1' || $flevents['ev_type'] == 'buy') {
+ $style = "bg-success";
+ } elseif ($flevents['ev_type'] == 'refuselastperformer' || $flevents['ev_type'] == 'refuse' || $flevents['ev_type'] == 'emp_cancel' || $flevents['ev_type'] == 'add-1' || $flevents['ev_type'] == 'edit-1') {
+ $style = "bg-danger";
+ } elseif ($flevents['ev_type'] == 'addpost' || $flevents['ev_type'] == 'addpost_offer' || $flevents['ev_type'] == 'confirm' || $flevents['ev_type'] == 'del' || $flevents['ev_type'] == 'sell') {
+ $style = "bg-warning";
+ } elseif ($flevents['ev_type'] == 'new' || $flevents['ev_type'] == 'edit') {
+ $style = "bg-info";
+ } else {
+ $style = "";
+ }
+
+ $t->assign([
+ "EV_ROW_ID" => $flevents['ev_id'],
+ "EV_ROW_AREA" => $flevents['ev_area'],
+ "EV_ROW_TYPE" => $flevents['ev_type'],
+ "EV_ROW_TO" => $flevents['ev_touid'],
+ "EV_ROW_FROM" => $flevents['ev_fromuid'],
+ "EV_ROW_DATE" => cot_date('datetime_medium', $flevents['ev_date']),
+ "EV_ROW_DATE_STAMP" => $flevents['ev_date'],
+ "EV_ROW_STYLER" => $style,
+ ]);
+
+ $t->parse("MAIN.EV_ROWS");
+ }
+
+
+ $t->parse('MAIN');
+ return $t->text("MAIN");
+}
+
+function cot_generate_ordertags(
+ $item_data,
+ $tag_prefix = '',
+ $textlength = 0,
+ $admin_rights = null,
+ $pagepath_home = false,
+ $emptytitle = ''
+) {
+ global $db, $cfg, $L, $Ls, $R, $db_services, $db_services_orders;
+
+ if (!is_array($item_data)) {
+ $sql = $db->query(
+ "SELECT * FROM $db_services_orders AS o
+ LEFT JOIN $db_services AS m ON m.item_id=o.order_pid
+ WHERE order_status!='new' AND order_id=" . (int)$item_data . " LIMIT 1"
+ );
+ $item_data = $sql->fetch();
+ }
+
+ if ($item_data['order_id'] > 0) {
+ $temp_array = [
+ "ID" => $item_data['order_id'],
+ "COUNT" => $item_data['order_count'],
+ "COST" => $item_data['order_cost'],
+ "TITLE" => $item_data['order_title'],
+ "COMMENT" => $item_data['order_text'],
+ "EMAIL" => $item_data['order_email'],
+ "PAID" => $item_data['order_paid'],
+ "DONE" => $item_data['order_done'],
+ "STATUS" => $item_data['order_status'],
+ "DOWNLOAD" => (in_array($item_data['order_status'], ['paid', 'done']
+ ) && !empty($item_data['item_file']) && file_exists(
+ $cfg['plugin']['orderservices']['filepath'] . '/' . $item_data['item_file']
+ )) ? cot_url('plug', 'r=orderservices&m=download&id=' . $item_data['order_id'] . '&key=' . $key) : '',
+ "LOCALSTATUS" => $L['orderservices_status_' . $item_data['order_status']],
+ "WARRANTYDATE" => $item_data['order_paid'] + $cfg['plugin']['orderservices']['warranty'] * 60 * 60 * 24,
+ ];
+ } else {
+ $temp_array = [
+ 'ORDER_ID' => (!empty($emptyid)) ? $emptyid : $L['Deleted'],
+ ];
+ }
+
+ $return_array = [];
+ foreach ($temp_array as $key => $val) {
+ $return_array[$tag_prefix . $key] = $val;
+ }
+
+ return $return_array;
+}
+
+function cot_generate_ordermarkettags(
+ $item_data,
+ $tag_prefix = '',
+ $textlength = 0,
+ $admin_rights = null,
+ $pagepath_home = false,
+ $emptytitle = ''
+) {
+ global $db, $cfg, $L, $Ls, $R, $db_market, $db_market_orders;
+
+ if (!is_array($item_data)) {
+ $sql = $db->query(
+ "SELECT * FROM $db_market_orders AS o
+ LEFT JOIN $db_market AS m ON m.item_id=o.order_pid
+ WHERE order_status!='new' AND order_id=" . (int)$item_data . " LIMIT 1"
+ );
+ $item_data = $sql->fetch();
+ }
+
+ if ($item_data['order_id'] > 0) {
+ $temp_array = [
+ "ID" => $item_data['order_id'],
+ "COUNT" => $item_data['order_count'],
+ "COST" => $item_data['order_cost'],
+ "TITLE" => $item_data['order_title'],
+ "COMMENT" => $item_data['order_text'],
+ "EMAIL" => $item_data['order_email'],
+ "PAID" => $item_data['order_paid'],
+ "DONE" => $item_data['order_done'],
+ "STATUS" => $item_data['order_status'],
+ "DOWNLOAD" => (in_array($item_data['order_status'], ['paid', 'done']
+ ) && !empty($item_data['item_file']) && file_exists(
+ $cfg['plugin']['marketorders']['filepath'] . '/' . $item_data['item_file']
+ )) ? cot_url('plug', 'r=marketorders&m=download&id=' . $item_data['order_id'] . '&key=' . $key) : '',
+ "LOCALSTATUS" => $L['marketorders_status_' . $item_data['order_status']],
+ "WARRANTYDATE" => $item_data['order_paid'] + $cfg['plugin']['marketorders']['warranty'] * 60 * 60 * 24,
+ ];
+ } else {
+ $temp_array = [
+ 'ORDER_ID' => (!empty($emptyid)) ? $emptyid : $L['Deleted'],
+ ];
+ }
+
+ $return_array = [];
+ foreach ($temp_array as $key => $val) {
+ $return_array[$tag_prefix . $key] = $val;
+ }
+
+ return $return_array;
+}
\ No newline at end of file
diff --git a/plugins/flevents/inc/index.html b/plugins/flevents/inc/index.html
new file mode 100644
index 0000000..eba420c
--- /dev/null
+++ b/plugins/flevents/inc/index.html
@@ -0,0 +1,2 @@
+
Forbidden
+
\ No newline at end of file
diff --git a/plugins/flevents/index.html b/plugins/flevents/index.html
new file mode 100644
index 0000000..eba420c
--- /dev/null
+++ b/plugins/flevents/index.html
@@ -0,0 +1,2 @@
+
Forbidden
+
\ No newline at end of file
diff --git a/plugins/flevents/lang/flevents.en.lang.php b/plugins/flevents/lang/flevents.en.lang.php
new file mode 100644
index 0000000..6b3cad6
--- /dev/null
+++ b/plugins/flevents/lang/flevents.en.lang.php
@@ -0,0 +1,59 @@
+Cot::$usr[\'flevents\'][\'xxx\'] или
{PHP.usr.flevents.xxx} в шаблонах';
+
+$L['Events_title'] = 'События';
+$L['Events_title_new'] = 'Новые события';
+$L['Events_addoffer'] = 'оставил предложение по проекту';
+$L['Events_setperformer'] = 'выбрал вас исполнителем по проекту';
+$L['Events_refuselastperformer'] = 'отказал вам по проекту';
+$L['Events_addpost'] = 'оставил новое сообщение к вашему предложению по проекту';
+$L['Events_addpost_offer'] = 'оставил новое сообщение к своему предложению по проекту';
+
+$L['Events_sbr_new'] = 'предлагает заключить сделку';
+$L['Events_sbr_edit'] = 'изменил условия по сделке';
+$L['Events_sbr_cancel'] = 'Заказчик отменил сделку';
+$L['Events_sbr_refuse'] = 'отказался от сделки';
+$L['Events_sbr_confirm'] = 'принял условия сделки';
+$L['Events_sbr_paid'] = 'Заказчик зарезервировал деньги под сделку';
+$L['Events_sbr_start'] = 'Можете приступать к работе.';
+$L['Events_sbr_addpost'] = 'оставил новое сообщение в сделке';
+
+$L['Events_sbr_need'] = 'Необходимо';
+$L['Events_sbr_reserve_money'] = 'зарезервировать деньги!';
+
+$L['Events_rev'] = 'отзыв';
+$L['Events_rev_add_pos'] = 'добавил вам положительный';
+$L['Events_rev_add_neg'] = 'добавил вам негативный';
+$L['Events_rev_edit'] = 'изменил';
+$L['Events_rev_del'] = 'удалил свой отзыв';
+
+$L['Events_market_buy'] = 'Вы совершили покупку в магазине';
+$L['Events_market_order'] = 'Заказ';
+$L['Events_market_sell_order'] = 'купил ваш товар';
+$L['Events_market_sell_guarant'] = 'По истечению гарантийного срока, средства поступят на Ваш счет.';
+$L['Events_market_order_paid'] = 'На Ваш счет поступила оплата по заказу';
+
+$L['Events_services_buy'] = 'Вы совершили оплату за услуги эксперта';
+$L['Events_services_order'] = 'Заказ';
+$L['Events_services_sell_order'] = 'совершил оплату за услугу';
+$L['Events_services_sell_guarant'] = 'По истечению гарантийного срока, средства поступят на Ваш счет.';
+$L['Events_services_order_paid'] = 'На Ваш счет поступила оплата по заказу';
+
+$L['Events_empty_new'] = 'У Вас нет новых событий!';
+$L['Events_empty'] = 'У Вас нет событий!';
+
+$Ls['Events_n'] = array('уведомление' , 'уведомления', 'уведомлений');
\ No newline at end of file
diff --git a/plugins/flevents/lang/flevents.ru.lang.php b/plugins/flevents/lang/flevents.ru.lang.php
new file mode 100644
index 0000000..6b3cad6
--- /dev/null
+++ b/plugins/flevents/lang/flevents.ru.lang.php
@@ -0,0 +1,59 @@
+Cot::$usr[\'flevents\'][\'xxx\'] или
{PHP.usr.flevents.xxx} в шаблонах';
+
+$L['Events_title'] = 'События';
+$L['Events_title_new'] = 'Новые события';
+$L['Events_addoffer'] = 'оставил предложение по проекту';
+$L['Events_setperformer'] = 'выбрал вас исполнителем по проекту';
+$L['Events_refuselastperformer'] = 'отказал вам по проекту';
+$L['Events_addpost'] = 'оставил новое сообщение к вашему предложению по проекту';
+$L['Events_addpost_offer'] = 'оставил новое сообщение к своему предложению по проекту';
+
+$L['Events_sbr_new'] = 'предлагает заключить сделку';
+$L['Events_sbr_edit'] = 'изменил условия по сделке';
+$L['Events_sbr_cancel'] = 'Заказчик отменил сделку';
+$L['Events_sbr_refuse'] = 'отказался от сделки';
+$L['Events_sbr_confirm'] = 'принял условия сделки';
+$L['Events_sbr_paid'] = 'Заказчик зарезервировал деньги под сделку';
+$L['Events_sbr_start'] = 'Можете приступать к работе.';
+$L['Events_sbr_addpost'] = 'оставил новое сообщение в сделке';
+
+$L['Events_sbr_need'] = 'Необходимо';
+$L['Events_sbr_reserve_money'] = 'зарезервировать деньги!';
+
+$L['Events_rev'] = 'отзыв';
+$L['Events_rev_add_pos'] = 'добавил вам положительный';
+$L['Events_rev_add_neg'] = 'добавил вам негативный';
+$L['Events_rev_edit'] = 'изменил';
+$L['Events_rev_del'] = 'удалил свой отзыв';
+
+$L['Events_market_buy'] = 'Вы совершили покупку в магазине';
+$L['Events_market_order'] = 'Заказ';
+$L['Events_market_sell_order'] = 'купил ваш товар';
+$L['Events_market_sell_guarant'] = 'По истечению гарантийного срока, средства поступят на Ваш счет.';
+$L['Events_market_order_paid'] = 'На Ваш счет поступила оплата по заказу';
+
+$L['Events_services_buy'] = 'Вы совершили оплату за услуги эксперта';
+$L['Events_services_order'] = 'Заказ';
+$L['Events_services_sell_order'] = 'совершил оплату за услугу';
+$L['Events_services_sell_guarant'] = 'По истечению гарантийного срока, средства поступят на Ваш счет.';
+$L['Events_services_order_paid'] = 'На Ваш счет поступила оплата по заказу';
+
+$L['Events_empty_new'] = 'У Вас нет новых событий!';
+$L['Events_empty'] = 'У Вас нет событий!';
+
+$Ls['Events_n'] = array('уведомление' , 'уведомления', 'уведомлений');
\ No newline at end of file
diff --git a/plugins/flevents/lang/index.html b/plugins/flevents/lang/index.html
new file mode 100644
index 0000000..eba420c
--- /dev/null
+++ b/plugins/flevents/lang/index.html
@@ -0,0 +1,2 @@
+
Forbidden
+
\ No newline at end of file
diff --git a/plugins/flevents/setup/flevents.install.sql b/plugins/flevents/setup/flevents.install.sql
new file mode 100644
index 0000000..33961b2
--- /dev/null
+++ b/plugins/flevents/setup/flevents.install.sql
@@ -0,0 +1,17 @@
+/**
+ * Events plugin DB installation
+ * @todo индексы, нормальные названия полей
+ */
+CREATE TABLE IF NOT EXISTS `cot_flevents` (
+ `ev_id` INT UNSIGNED NOT NULL auto_increment,
+ `ev_area` varchar(64) NOT NULL default '',
+ `ev_type` varchar(64) NOT NULL default '',
+ `ev_code` varchar(255) NOT NULL default '',
+ `ev_date` INT UNSIGNED NOT NULL,
+ `ev_touid` INT UNSIGNED NOT NULL,
+ `ev_fromuid` INT UNSIGNED NOT NULL DEFAULT 0,
+ `ev_status` TINYINT NOT NULL DEFAULT 1,
+ PRIMARY KEY (`ev_id`),
+ KEY `flevent_touid_idx` (`ev_touid`),
+ KEY `flevent_touid_status_idx` (`ev_touid`, `ev_status`)
+);
\ No newline at end of file
diff --git a/plugins/flevents/setup/flevents.uninstall.sql b/plugins/flevents/setup/flevents.uninstall.sql
new file mode 100644
index 0000000..50d7663
--- /dev/null
+++ b/plugins/flevents/setup/flevents.uninstall.sql
@@ -0,0 +1,5 @@
+/**
+ * Events removes projects data
+ */
+
+DROP TABLE IF EXISTS `cot_flevents`;
\ No newline at end of file
diff --git a/plugins/flevents/setup/index.html b/plugins/flevents/setup/index.html
new file mode 100644
index 0000000..eba420c
--- /dev/null
+++ b/plugins/flevents/setup/index.html
@@ -0,0 +1,2 @@
+
Forbidden
+
\ No newline at end of file
diff --git a/plugins/flevents/tpl/flevents.header.tpl b/plugins/flevents/tpl/flevents.header.tpl
new file mode 100644
index 0000000..0e8a450
--- /dev/null
+++ b/plugins/flevents/tpl/flevents.header.tpl
@@ -0,0 +1,85 @@
+
+
+
\ No newline at end of file
diff --git a/plugins/flevents/tpl/flevents.tpl b/plugins/flevents/tpl/flevents.tpl
new file mode 100644
index 0000000..567ce50
--- /dev/null
+++ b/plugins/flevents/tpl/flevents.tpl
@@ -0,0 +1,100 @@
+
+
+
{PHP.L.Events_title_new}
+
+
+
+
+
+
+
+
+
+
+
+
{PHP.L.Events_empty_new}
+
+
+
\ No newline at end of file
diff --git a/plugins/flevents/tpl/index.html b/plugins/flevents/tpl/index.html
new file mode 100644
index 0000000..eba420c
--- /dev/null
+++ b/plugins/flevents/tpl/index.html
@@ -0,0 +1,2 @@
+
Forbidden
+
\ No newline at end of file
diff --git a/plugins/ikassabilling/ikassabilling.ajax.php b/plugins/ikassabilling/ikassabilling.ajax.php
index 1df77e3..181d7c0 100644
--- a/plugins/ikassabilling/ikassabilling.ajax.php
+++ b/plugins/ikassabilling/ikassabilling.ajax.php
@@ -14,6 +14,11 @@
* @copyright Copyright (c) CMSWorks.ru
* @license BSD
*/
+
+use cot\modules\payments\dictionaries\PaymentDictionary;
+use cot\modules\payments\Repositories\PaymentRepository;
+use cot\modules\payments\Services\PaymentService;
+
defined('COT_CODE') or die('Wrong URL');
require_once cot_incfile('payments', 'module');
@@ -52,25 +57,26 @@
$signString = implode(':', $dataSet);
$sign = base64_encode(md5($signString, true));
-if(!empty($dataSet['ik_pm_no']))
-{
- $payinfo = cot_payments_payinfo($dataSet['ik_pm_no']);
+if(!empty($dataSet['ik_pm_no'])) {
+ $payinfo = PaymentRepository::getInstance()->getById($dataSet['ik_pm_no']);
}
-if ($ik_sign === $sign
+if (
+ $ik_sign === $sign
&& $dataSet['ik_inv_st'] == 'success'
&& $dataSet['ik_co_id'] == $cfg['plugin']['ikassabilling']['shop_id'])
{
- if(cot_payments_updatestatus($dataSet['ik_pm_no'], 'paid'))
- {
+ if (
+ PaymentService::getInstance()->setStatus(
+ $dataSet['ik_pm_no'],
+ PaymentDictionary::STATUS_PAID,
+ 'ikassa'
+ )
+ ) {
header ( 'HTTP/1.1 200' );
- }
- else
- {
+ } else {
header ( 'HTTP/1.1 302' );
}
-}
-else
-{
+} else {
header ( 'HTTP/1.1 302' );
}
diff --git a/plugins/ikassabilling/ikassabilling.php b/plugins/ikassabilling/ikassabilling.php
index b306943..d967666 100644
--- a/plugins/ikassabilling/ikassabilling.php
+++ b/plugins/ikassabilling/ikassabilling.php
@@ -14,6 +14,11 @@
* @copyright Copyright (c) CMSWorks.ru
* @license BSD
*/
+
+use cot\modules\payments\dictionaries\PaymentDictionary;
+use cot\modules\payments\Repositories\PaymentRepository;
+use cot\modules\payments\Services\PaymentService;
+
defined('COT_CODE') && defined('COT_PLUG') or die('Wrong URL');
require_once cot_incfile('ikassabilling', 'plug');
@@ -25,7 +30,7 @@
if (empty($m))
{
// Получаем информацию о заказе
- if (!empty($pid) && $pinfo = cot_payments_payinfo($pid))
+ if (!empty($pid) && $pinfo = PaymentRepository::getInstance()->getById($pid))
{
cot_block($usr['id'] == $pinfo['pay_userid']);
cot_block($pinfo['pay_status'] == 'new' || $pinfo['pay_status'] == 'process');
@@ -45,16 +50,13 @@
'IKASSA_FORM' => $ikassa_form,
));
$t->parse("MAIN.IKASSAFORM");
-
- cot_payments_updatestatus($pid, 'process'); // Изменяем статус "в процессе оплаты"
- }
- else
- {
+
+ // Изменяем статус "в процессе оплаты"
+ PaymentService::getInstance()->setStatus($pid, PaymentDictionary::STATUS_PROCESS, 'ikassa');
+ } else {
cot_die();
}
-}
-elseif ($m == 'success')
-{
+} elseif ($m == 'success') {
if($_SERVER['REQUEST_METHOD'] == 'POST' && $cfg['plugin']['ikassabilling']['enablepost'])
{
$status_data = $_POST;
@@ -67,45 +69,45 @@
if($status_data['ik_inv_st'] == 'success' && $status_data['ik_co_id'] == $cfg['plugin']['ikassabilling']['shop_id']) {
// проверка наличия номера платежки и ее статуса
- $pinfo = cot_payments_payinfo($status_data['ik_pm_no']);
+ $pinfo = PaymentRepository::getInstance()->getById($status_data['ik_pm_no']);
if ($pinfo['pay_status'] == 'done')
{
- $plugin_body = $L['ikassabilling_error_done'];
+ $pluginBody = $L['ikassabilling_error_done'];
$redirect = $pinfo['pay_redirect'];
}
elseif ($pinfo['pay_status'] == 'paid')
{
- $plugin_body = $L['ikassabilling_error_paid'];
+ $pluginBody = $L['ikassabilling_error_paid'];
}
elseif ($pinfo['pay_status'] == 'process')
{
- $plugin_body = $L['ikassabilling_error_wait'];
+ $pluginBody = $L['ikassabilling_error_wait'];
}
else
{
- $plugin_body = $L['roboxbilling_error_otkaz'];
+ $pluginBody = $L['roboxbilling_error_otkaz'];
}
}
elseif($status_data['ik_inv_st'] == 'waitAccept' || $status_data['ik_inv_st'] == 'process')
{
- $plugin_body = $L['ikassabilling_error_wait'];
+ $pluginBody = $L['ikassabilling_error_wait'];
}
elseif($status_data['ik_inv_st'] == 'canceled')
{
- $plugin_body = $L['ikassabilling_error_canceled'];
+ $pluginBody = $L['ikassabilling_error_canceled'];
}
elseif($status_data['ik_inv_st'] == 'fail')
{
- $plugin_body = $L['ikassabilling_error_fail'];
+ $pluginBody = $L['ikassabilling_error_fail'];
}
else
{
- $plugin_body = $L['ikassabilling_error_incorrect'];
+ $pluginBody = $L['ikassabilling_error_incorrect'];
}
$t->assign(array(
"IKASSA_TITLE" => $L['ikassabilling_error_title'],
- "IKASSA_ERROR" => $plugin_body
+ "IKASSA_ERROR" => $pluginBody
));
if($redirect){
diff --git a/plugins/locationselector/inc/locationselector.city.php b/plugins/locationselector/inc/locationselector.city.php
index f7ba11f..071598d 100644
--- a/plugins/locationselector/inc/locationselector.city.php
+++ b/plugins/locationselector/inc/locationselector.city.php
@@ -118,9 +118,9 @@
"REGION_NAME" => $region['region_name']
));
-$adminpath[] = array(cot_url('admin', 'm=other&p=locationselector&n=region&country=' . $region['region_country']),
+$adminPath[] = array(cot_url('admin', 'm=other&p=locationselector&n=region&country=' . $region['region_country']),
$cot_countries[$region['region_country']]);
-$adminpath[] = array(cot_url('admin', 'm=other&p=locationselector&n=city&id=' . $region['region_id']), $region['region_name']);
+$adminPath[] = array(cot_url('admin', 'm=other&p=locationselector&n=city&id=' . $region['region_id']), $region['region_name']);
$t->parse("MAIN");
-$plugin_body .= $t->text("MAIN");
-?>
+$pluginBody .= $t->text("MAIN");
+
diff --git a/plugins/locationselector/inc/locationselector.country.php b/plugins/locationselector/inc/locationselector.country.php
index 0dbe6da..9fbf9ea 100644
--- a/plugins/locationselector/inc/locationselector.country.php
+++ b/plugins/locationselector/inc/locationselector.country.php
@@ -57,6 +57,6 @@
$t->parse("MAIN.NOROWS");
}
$t->parse("MAIN");
-$plugin_body .= $t->text("MAIN");
+$pluginBody .= $t->text("MAIN");
?>
diff --git a/plugins/locationselector/inc/locationselector.functions.php b/plugins/locationselector/inc/locationselector.functions.php
index 5593324..504d52d 100644
--- a/plugins/locationselector/inc/locationselector.functions.php
+++ b/plugins/locationselector/inc/locationselector.functions.php
@@ -1,10 +1,8 @@
{$country} {$region} {$city} ' : $R['input_location'];
-if (!$cot_countries)
-{
+if (empty($cot_countries)) {
include_once cot_langfile('countries', 'core');
}
@@ -39,6 +36,7 @@ function cot_load_location()
$cot_lf_cities = array();
$cot_lf_regions = array();
$cot_lf_locations = array();
+ $countriesfilter = [];
if (!empty($cfg['plugin']['locationselector']['countriesfilter']) && $cfg['plugin']['locationselector']['countriesfilter'] != 'all')
{
$countriesfilter = str_replace(' ', '', $cfg['plugin']['locationselector']['countriesfilter']);
@@ -108,13 +106,15 @@ function cot_getcountries($countriesfilter = array())
function cot_getregions($country)
{
global $cot_lf_regions, $cot_lf_locations;
- $regions = array();
- $cot_lf_locations[$country] = (is_array($cot_lf_locations[$country])) ? $cot_lf_locations[$country] : array();
- foreach ($cot_lf_locations[$country] as $i => $reg)
- {
+
+ $regions = [];
+ $cot_lf_locations[$country] = (!empty($cot_lf_locations[$country]) && is_array($cot_lf_locations[$country])) ?
+ $cot_lf_locations[$country] : [];
+ foreach ($cot_lf_locations[$country] as $i => $reg) {
$regions[$i] = $cot_lf_regions[$i];
}
asort($regions);
+
return $regions;
}
@@ -165,18 +165,20 @@ function cot_getlocation($country = '', $region = 0, $city = 0)
$location['country'] = '';
$location['region'] = '';
$location['city'] = '';
- if(!empty($country))
- {
+ if (!empty($country) && isset($cot_countries[$country])) {
$location['country'] = $cot_countries[$country];
}
- if(!empty($country) && (int)$region > 0)
- {
- $location['region'] = $cot_lf_regions[$region];
+
+ $region = (int) $region;
+ if (!empty($country) && $region > 0 && isset($cot_lf_regions[$region])) {
+ $location['region'] = $cot_lf_regions[$region];
}
- if(!empty($country) && (int)$region > 0 && (int)$city > 0)
- {
- $location['city'] = $cot_lf_cities[$city];
+
+ $city = (int) $city;
+ if (!empty($country) && $region > 0 && $city > 0 && isset($cot_lf_cities[$city])) {
+ $location['city'] = $cot_lf_cities[$city];
}
+
return $location;
}
@@ -185,23 +187,26 @@ function cot_select_location($country = '', $region = 0, $city = 0, $userdefault
global $cfg, $L, $R, $usr;
$countriesfilter = array();
- if (!empty($cfg['plugin']['locationselector']['countriesfilter']) && $cfg['plugin']['locationselector']['countriesfilter'] != 'all')
- {
+ $disabled = '';
+
+ if (
+ !empty($cfg['plugin']['locationselector']['countriesfilter']) &&
+ $cfg['plugin']['locationselector']['countriesfilter'] != 'all'
+ ) {
$countriesfilter = str_replace(' ', '', $cfg['plugin']['locationselector']['countriesfilter']);
$countriesfilter = explode(',', $countriesfilter);
$disabled = (count($countriesfilter) == 1) ? 'disabled="disabled" ' : '';
$country = (count($countriesfilter) == 1) ? $countriesfilter[0] : $country;
}
- if ($userdefault && $usr['id'] > 0 && $country == '' && $region == 0 && $city == 0)
- {
+ if ($userdefault && $usr['id'] > 0 && $country == '' && $region == 0 && $city == 0) {
$country = $usr['profile']['user_country'];
$region = $usr['profile']['user_region'];
$city = $usr['profile']['user_city'];
}
$countries = cot_getcountries($countriesfilter);
- if($countries){
+ if ($countries) {
$countries = array(0 => $L['select_country']) + $countries;
$country_selectbox = cot_selectbox($country, 'country', array_keys($countries), array_values($countries),
false, $disabled . 'class="locselectcountry form-control" id="locselectcountry"');
@@ -252,6 +257,4 @@ function cot_import_location($source = 'P')
cot_load_location();
-//$cot_location - удалить
-
-?>
+//$cot_location - удалить
diff --git a/plugins/locationselector/inc/locationselector.region.php b/plugins/locationselector/inc/locationselector.region.php
index 38dfa7b..0d2a7fc 100644
--- a/plugins/locationselector/inc/locationselector.region.php
+++ b/plugins/locationselector/inc/locationselector.region.php
@@ -108,8 +108,8 @@
"COUNTRY_NAME" => $cot_countries[$country],
));
-$adminpath[] = array(cot_url('admin', 'm=other&p=locationselector&n=region&country=' . $country), $cot_countries[$country]);
+$adminPath[] = array(cot_url('admin', 'm=other&p=locationselector&n=region&country=' . $country), $cot_countries[$country]);
$t->parse("MAIN");
-$plugin_body .= $t->text("MAIN");
+$pluginBody .= $t->text("MAIN");
?>
diff --git a/plugins/locationselector/locationselector.edit.tags.php b/plugins/locationselector/locationselector.edit.tags.php
index b1e6c56..5058f18 100644
--- a/plugins/locationselector/locationselector.edit.tags.php
+++ b/plugins/locationselector/locationselector.edit.tags.php
@@ -33,5 +33,9 @@
}
$t->assign(array(
$prfx . 'LOCATION' => (function_exists('cot_select_location')) ?
- cot_select_location($ruser['user_country'], $ruser['user_region'], $ruser['user_city']) : '',
+ cot_select_location(
+ isset($ruser['user_country']) ? $ruser['user_country'] : '',
+ isset($ruser['user_region']) ? $ruser['user_region'] : 0,
+ isset($ruser['user_city']) ? $ruser['user_city'] : 0
+ ) : '',
));
diff --git a/plugins/locationselector/locationselector.market.add.tags.php b/plugins/locationselector/locationselector.market.add.tags.php
index d99ae13..4dd9804 100644
--- a/plugins/locationselector/locationselector.market.add.tags.php
+++ b/plugins/locationselector/locationselector.market.add.tags.php
@@ -17,16 +17,18 @@
defined('COT_CODE') or die('Wrong URL.');
// ==============================================
-if ((int) $id > 0)
-{
+if ((int) $id > 0) {
$t->assign(array(
"PRDEDIT_FORM_LOCATION" => cot_select_location($item['item_country'], $item['item_region'], $item['item_city'])
));
-}
-else
-{
+} else {
$t->assign(array(
- "PRDADD_FORM_LOCATION" => cot_select_location($ritem['item_country'], $ritem['item_region'], $ritem['item_city'], true)
+ "PRDADD_FORM_LOCATION" => cot_select_location(
+ !empty($ritem['item_country']) ? $ritem['item_country'] : '',
+ !empty($ritem['item_region']) ? $ritem[',item_region'] : 0,
+ !empty($ritem['item_city']) ? $ritem['item_city'] : 0,
+ true
+ )
));
}
diff --git a/plugins/locationselector/locationselector.market.query.php b/plugins/locationselector/locationselector.market.query.php
index 6b1583c..645604f 100644
--- a/plugins/locationselector/locationselector.market.query.php
+++ b/plugins/locationselector/locationselector.market.query.php
@@ -1,16 +1,15 @@
prep($location['country'])."'";
-if((int)$location['region'] > 0) $where['location'] = "item_region=" . (int)$location['region'];
-if((int)$location['city'] > 0) $where['location'] = "item_city=" . (int)$location['city'];
+if (!empty($location['country'])) {
+ $where['location'] = "item_country=" . cot::$db->quote($location['country']);
+}
+if ($location['region'] > 0) {
+ $where['location'] = "item_region=" . $location['region'];
+}
+if ($location['city'] > 0) {
+ $where['location'] = "item_city=" . $location['city'];
+}
$list_url_path['country'] = $location['country'];
diff --git a/plugins/locationselector/locationselector.market.tags.php b/plugins/locationselector/locationselector.market.tags.php
index 16a721f..faf00de 100644
--- a/plugins/locationselector/locationselector.market.tags.php
+++ b/plugins/locationselector/locationselector.market.tags.php
@@ -1,10 +1,10 @@
assign(array(
"SEARCH_LOCATION" => cot_select_location($location['country'], $location['region'], $location['city']),
));
-// ==============================================
diff --git a/plugins/locationselector/locationselector.projects.add.tags.php b/plugins/locationselector/locationselector.projects.add.tags.php
index e24f9f6..46204ad 100644
--- a/plugins/locationselector/locationselector.projects.add.tags.php
+++ b/plugins/locationselector/locationselector.projects.add.tags.php
@@ -1,33 +1,39 @@
0)
-{
- $t->assign(array(
- "PRJEDIT_FORM_LOCATION" => cot_select_location($item['item_country'], $item['item_region'], $item['item_city'])
- ));
-}
-else
-{
- $t->assign(array(
- "PRJADD_FORM_LOCATION" => cot_select_location($ritem['item_country'], $ritem['item_region'], $ritem['item_city'], true)
- ));
+if ((int) $id > 0) {
+ $t->assign([
+ "PRJEDIT_FORM_LOCATION" => cot_select_location(
+ $item['item_country'] ?? '',
+ $item['item_region'] ?? 0,
+ $item['item_city'] ?? 0,
+ ),
+ ]);
+} else {
+ $t->assign([
+ "PRJADD_FORM_LOCATION" => cot_select_location(
+ $ritem['item_country'] ?? '',
+ $ritem['item_region'] ?? 0,
+ $ritem['item_city'] ?? 0,
+ true
+ ),
+ ]);
}
-
-// ==============================================
\ No newline at end of file
diff --git a/plugins/locationselector/locationselector.projects.index.tags.php b/plugins/locationselector/locationselector.projects.index.tags.php
index 9674511..7d6e8c5 100644
--- a/plugins/locationselector/locationselector.projects.index.tags.php
+++ b/plugins/locationselector/locationselector.projects.index.tags.php
@@ -18,7 +18,11 @@
// ==============================================
$t_pr->assign(array(
- "SEARCH_LOCATION" => cot_select_location($location['country'], $location['region'], $location['city']),
+ "SEARCH_LOCATION" => cot_select_location(
+ !empty($location['country']) ? $location['country'] : '',
+ !empty($location['region']) ? $location['region'] : 0,
+ !empty($location['city']) ? $location['city'] : 0
+ ),
));
// ==============================================
diff --git a/plugins/locationselector/locationselector.projects.tags.php b/plugins/locationselector/locationselector.projects.tags.php
index 7cd11c5..f5200b2 100644
--- a/plugins/locationselector/locationselector.projects.tags.php
+++ b/plugins/locationselector/locationselector.projects.tags.php
@@ -1,21 +1,26 @@
assign(array(
- "SEARCH_LOCATION" => cot_select_location($location['country'], $location['region'], $location['city']),
-));
+$t->assign([
+ 'SEARCH_LOCATION' => cot_select_location(
+ $location['country'] ?? null,
+ $location['region'] ?? null,
+ $location['city'] ?? null
+ ),
+]);
diff --git a/plugins/locationselector/locationselector.rc.php b/plugins/locationselector/locationselector.rc.php
index de0b794..4473cf2 100644
--- a/plugins/locationselector/locationselector.rc.php
+++ b/plugins/locationselector/locationselector.rc.php
@@ -18,4 +18,4 @@
defined('COT_CODE') or die('Wrong URL.');
-cot_rc_add_file($cfg['plugins_dir'] . '/locationselector/js/locationselector.js');
+Resources::addFile(Cot::$cfg['plugins_dir'] . '/locationselector/js/locationselector.js');
diff --git a/plugins/locationselector/locationselector.setup.php b/plugins/locationselector/locationselector.setup.php
index e999fe9..8459180 100644
--- a/plugins/locationselector/locationselector.setup.php
+++ b/plugins/locationselector/locationselector.setup.php
@@ -4,8 +4,8 @@
* Code=locationselector
* Name=Location Selector
* Description=Редактор/Селектор стран, регионов, городов
- * Version=2.5.9
- * Date=2012.11.03
+ * Version=2.5.10
+ * Date=2022-09-08
* Author=CMSWorks Team
* Copyright=Copyright (c) CMSWorks.ru, littledev.ru
* Notes=
diff --git a/plugins/locationselector/locationselector.users.tags.php b/plugins/locationselector/locationselector.users.tags.php
index 04e9cb6..0db8935 100644
--- a/plugins/locationselector/locationselector.users.tags.php
+++ b/plugins/locationselector/locationselector.users.tags.php
@@ -16,9 +16,9 @@
*/
defined('COT_CODE') or die('Wrong URL.');
-// ==============================================
-$t->assign(array(
- 'SEARCH_ACTION_URL' => cot_url('users', "group=" . $group . "&cat=" . $c, '', true),
- 'SEARCH_LOCATION' => (function_exists('cot_select_location')) ?
- cot_select_location($location['country'], $location['region'], $location['city']) : ''
-));
+$t->assign([
+ //'SEARCH_ACTION_URL' => cot_url('users', "group=" . $group . "&cat=" . $c, '', true),
+ 'SEARCH_LOCATION' => (function_exists('cot_select_location') && is_array($location))
+ ? cot_select_location($location['country'], $location['region'], $location['city'])
+ : '',
+]);
diff --git a/plugins/locationselector/locationselector.userstags.php b/plugins/locationselector/locationselector.userstags.php
index 2592e04..083099c 100644
--- a/plugins/locationselector/locationselector.userstags.php
+++ b/plugins/locationselector/locationselector.userstags.php
@@ -9,20 +9,29 @@
* Location Selector for Cotonti
*
* @package locationselector
- * @version 2.0.0
* @author CMSWorks Team
* @copyright Copyright (c) CMSWorks.ru, littledev.ru
* @license BSD
*/
defined('COT_CODE') or die('Wrong URL.');
-if(is_array($user_data)){
- if (function_exists('cot_getlocation'))
- {
+if (is_array($user_data)) {
+ if (function_exists('cot_getlocation')) {
$location_info = cot_getlocation($user_data['user_country'], $user_data['user_region'], $user_data['user_city']);
$temp_array['COUNTRY'] = $location_info['country'];
$temp_array['REGION'] = $location_info['region'];
$temp_array['CITY'] = $location_info['city'];
}
- $temp_array['LOCATION_URL'] = cot_url('users', 'gm=' . $user_data['user_maingrp'] . '&country=' . $user_data['user_country'] . '®ion=' . $user_data['user_region'] . '&city=' . $user_data['user_location']);
+
+ $params = [
+ 'gm' => $user_data['user_maingrp'],
+ 'country' => $user_data['user_country'],
+ ];
+ if (!empty($user_data['user_region'])) {
+ $params['region'] = $user_data['user_region'];
+ }
+ if (!empty($user_data['user_location'])) {
+ $params['city'] = $user_data['user_location'];
+ }
+ $temp_array['LOCATION_URL'] = cot_url('users', $params);
}
\ No newline at end of file
diff --git a/plugins/logincheck/README.md b/plugins/logincheck/README.md
new file mode 100644
index 0000000..2692481
--- /dev/null
+++ b/plugins/logincheck/README.md
@@ -0,0 +1,10 @@
+# cot-logincheck
+Плагин проверки логина при регистрации для Cotonti Siena
+
+Простой плагин для проверки правильности введенного логина при регистрации пользователя. Плагин разрешает указывать в логине только латинские символы и цифры при регистрации пользователя. Также плагин умеет проверять логин на запрещенные имена.
+
+Как установить и настроить плагин:
+
+Распакуйте и скопируйте папку logincheck в директорию plugins/ вашего сайта на Cotonti;
+Зайдите в админ-панель сайта и перейдите в раздел "Расширения". Установите плагин Logincheck.
+В настройках плагина при необходимости можно указать список запрешенных логинов (через запятую).
diff --git a/plugins/logincheck/lang/logincheck.en.lang.php b/plugins/logincheck/lang/logincheck.en.lang.php
new file mode 100644
index 0000000..b71f6ab
--- /dev/null
+++ b/plugins/logincheck/lang/logincheck.en.lang.php
@@ -0,0 +1,8 @@
+ [
Документация по плагину, помощь, поддержка ]
+Version=1.4
+Date=2013-06-14
+Author=CMSWorks
+Copyright=Copyright (c) CMSWorks Team 2010-2013
+Notes=BSD License
+SQL=
+Auth_guests=R
+Lock_guests=W12345A
+Auth_members=RW
+Lock_members=12345
+[END_COT_EXT]
+
+[BEGIN_COT_EXT_CONFIG]
+invalidnames=01:textarea:::Invalid names
+[END_COT_EXT_CONFIG]
+==================== */
+
+defined('COT_CODE') or die('Wrong URL');
+
+?>
\ No newline at end of file
diff --git a/plugins/logincheck/logincheck.users.register.add.validate.php b/plugins/logincheck/logincheck.users.register.add.validate.php
new file mode 100644
index 0000000..46a2513
--- /dev/null
+++ b/plugins/logincheck/logincheck.users.register.add.validate.php
@@ -0,0 +1,20 @@
+ 0 AND {PRD_STATE} == 0 -->
+
+
+
+
{PHP.L.marketorders_title}
+
+
{PHP.L.marketorders_file_download}
+
+
{PRD_ORDER_LOCALSTATUS}
+
+
+
{PHP.L.marketorders_neworder_button}
+
+
+
+
+
+В шапку сайта можно добавить ссылки на покупки и продажи (этот код уже вставлен в базовую версию фриланс-биржи, здесь показан для примера):
+
+
+
{PHP.L.marketorders_mysales}
+
{PHP.L.marketorders_mypurchases}
+
+
+
+###Настройки для продажи файлов:
+
+Данная возможность еще находится в тестовом режиме. Загружать можно только один файл. Если нужно продавать несколько файлов, то очевидно их необходимо запаковать в один архив и загрузить на странице товара. Ссылка на скачивание товара будет доступна покупателю на странице оплаченного ЗАКАЗА в виде ссылки через скрипт.
+
+
+###Установите плагин или обновите его.
+
+По-умолчанию все файлы для продажи будут располагаться в директории datas/marketfiles и при установке или обновлении плагина будет создано экстраполе 'file' для загрузки файлов. Допустимые к загрузке типы файлов: zip и rar.
+В настройках плагина можно указать свой путь к этой директории. Эта директория может располагаться как в директории сайта, либо вы можете указать любую другую директорию (например можно указать директорию в любом месте вашего сервера, с абсолютным путем, чтобы доступа к ней из браузера не было, например /var/www/vhosts/.../files. Но чтобы это сделать, вам нужно узнать у хостера абсолютный путь к нужной вам директории). Если вы измените путь в настройках плагина, то не забудьте также изменить ее в настройках экстраполя 'file' для таблицы market через админку в разделе "Экстраполя". Убедитесь, что указанная директория реально существует и имеет права на запись. Если директория не существует, создайте ее вручную. В настройках созданного экстраполя можно также изменить список допустимого к загрузке файла, но будьте осторожны.
+
+Шаблоны добавления и редактирования товара должны содержать поля для загрузки архива, который будет предоставдяться покупателю после покупки.
+
+modules/market/tpl/market.add.tpl
+
+
+
+ {PHP.L.marketorders_file}:
+ {PRDADD_FORM_FILE}
+
+
+
+modules/market/tpl/market.edit.tpl
+
+
+
+ {PHP.L.marketorders_file}:
+ {PRDEDIT_FORM_FILE}
+
+
+
+
+
diff --git a/plugins/marketorders/inc/marketorders.addclaim.php b/plugins/marketorders/inc/marketorders.addclaim.php
new file mode 100644
index 0000000..55f9973
--- /dev/null
+++ b/plugins/marketorders/inc/marketorders.addclaim.php
@@ -0,0 +1,154 @@
+ 0)
+{
+ $sql = $db->query("SELECT * FROM $db_market_orders AS o
+ LEFT JOIN $db_market AS m ON m.item_id=o.order_pid
+ WHERE order_id=".$id." LIMIT 1");
+}
+
+if (!$id || !$sql || $sql->rowCount() == 0)
+{
+ cot_die_message(404, TRUE);
+}
+$marketorder = $sql->fetch();
+
+cot_block($marketorder['order_status'] == 'paid' && $marketorder['order_userid'] == $usr['id']);
+
+/* === Hook === */
+$extp = cot_getextplugins('marketorders.addclaim.first');
+foreach ($extp as $pl)
+{
+ include $pl;
+}
+/* ===== */
+
+if ($a == 'add')
+{
+ cot_shield_protect();
+
+ /* === Hook === */
+ foreach (cot_getextplugins('marketorders.addclaim.add.first') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+
+ $rorder['order_claimtext'] = cot_import('rclaimtext', 'P', 'TXT');
+
+ /* === Hook === */
+ foreach (cot_getextplugins('marketorders.addclaim.add.import') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+
+ cot_check(empty($rorder['order_claimtext']), 'marketorders_order_error_claimtext', 'rclaimtext');
+
+ /* === Hook === */
+ foreach (cot_getextplugins('marketorders.addclaim.add.error') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+
+ if (!cot_error_found())
+ {
+ $rorder['order_claim'] = $sys['now'];
+ $rorder['order_status'] = 'claim';
+
+ $db->update($db_market_orders, $rorder, 'order_id='.$id);
+
+ $seller = $db->query("SELECT * FROM $db_users WHERE user_id=".$marketorder['order_seller'])->fetch();
+ $customer = $db->query("SELECT * FROM $db_users WHERE user_id=".$marketorder['order_userid'])->fetch();
+
+ // Уведопляем продавца о том, что подана жалоба по этому заказу
+ $rsubject = cot_rc($L['marketorders_addclaim_mail_toseller_header'], array('order_id' => $marketorder['order_id'], 'product_title' => $marketorder['item_title']));
+ $rbody = cot_rc($L['marketorders_addclaim_mail_toseller_body'], array(
+ 'product_title' => $marketorder['item_title'],
+ 'order_id' => $marketorder['order_id'],
+ 'sitename' => $cfg['maintitle'],
+ 'link' => COT_ABSOLUTE_URL . cot_url('marketorders', "id=" . $marketorder['order_id'], '', true)
+ ));
+ cot_mail ($seller['user_email'], $rsubject, $rbody);
+
+ // Уведопляем админа о том, что подана жалоба по этому заказу
+ $rsubject = cot_rc($L['marketorders_addclaim_mail_toadmin_header'], array('order_id' => $marketorder['order_id'], 'product_title' => $marketorder['item_title']));
+ $rbody = cot_rc($L['marketorders_addclaim_mail_toadmin_body'], array(
+ 'product_title' => $marketorder['item_title'],
+ 'order_id' => $marketorder['order_id'],
+ 'sitename' => $cfg['maintitle'],
+ 'link' => COT_ABSOLUTE_URL . cot_url('marketorders', "id=" . $marketorder['order_id'], '', true)
+ ));
+
+ /* === Hook === */
+ foreach (cot_getextplugins('marketorders.addclaim.done') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+
+ cot_mail ($cfg['adminemail'], $rsubject, $rbody);
+
+ cot_redirect(cot_url('marketorders', 'm=order&id=' . $id, '', true));
+ exit;
+ }
+
+ cot_redirect(cot_url('marketorders', 'm=addclaim&id=' . $id, '', true));
+ exit;
+}
+
+$out['subtitle'] = $L['marketorders_neworder_title'];
+$out['head'] .= $R['code_noindex'];
+
+$mskin = cot_tplfile(array('marketorders', 'addclaim', $structure['market'][$item['item_cat']]['tpl']), 'plug');
+
+/* === Hook === */
+foreach (cot_getextplugins('marketorders.addclaim.main') as $pl)
+{
+ include $pl;
+}
+/* ===== */
+
+$t = new XTemplate($mskin);
+
+$catpatharray[] = array(cot_url('market'), $L['market']);
+$catpatharray[] = array('', $L['marketorders_addclaim_title']);
+
+$catpath = cot_breadcrumbs($catpatharray, $cfg['homebreadcrumb'], true);
+
+$t->assign(array(
+ "BREADCRUMBS" => $catpath,
+));
+
+// Error and message handling
+cot_display_messages($t);
+
+$t->assign(array(
+ "CLAIM_FORM_SEND" => cot_url('marketorders', 'm=addclaim&id='.$id.'&a=add'),
+ "CLAIM_FORM_TEXT" => cot_textarea('rclaimtext', '', 5, 60),
+));
+
+/* === Hook === */
+foreach (cot_getextplugins('marketorders.addclaim.tags') as $pl)
+{
+ include $pl;
+}
+/* ===== */
diff --git a/plugins/marketorders/inc/marketorders.functions.php b/plugins/marketorders/inc/marketorders.functions.php
new file mode 100644
index 0000000..33e6d49
--- /dev/null
+++ b/plugins/marketorders/inc/marketorders.functions.php
@@ -0,0 +1,64 @@
+registerTable('market_orders');
+
+function marketorders_file_download($filename, $mimetype='application/octet-stream') {
+ if (!file_exists($filename)) die('Файл не найден');
+
+ $from=$to=0; $cr=NULL;
+
+ if (isset($_SERVER['HTTP_RANGE'])) {
+ $range=substr($_SERVER['HTTP_RANGE'], strpos($_SERVER['HTTP_RANGE'], '=')+1);
+ $from=strtok($range, '-');
+ $to=strtok('/'); if ($to>0) $to++;
+ if ($to) $to-=$from;
+ header('HTTP/1.1 206 Partial Content');
+ $cr='Content-Range: bytes ' . $from . '-' . (($to)?(($to) . '/' . ($to+1)):filesize($filename));
+/* $cr='Content-Range: bytes ' . $from . '-' . (($to)?($to . '/' . $to+1):filesize($filename)); */
+ } else header('HTTP/1.1 200 Ok');
+
+ $etag=md5($filename);
+ $etag=substr($etag, 0, 8) . '-' . substr($etag, 8, 7) . '-' . substr($etag, 15, 8);
+ header('ETag: "' . $etag . '"');
+
+ header('Accept-Ranges: bytes');
+ header('Content-Length: ' . (filesize($filename)-$to+$from));
+ if ($cr) header($cr);
+
+ header('Connection: close');
+ header('Content-Type: ' . $mimetype);
+ header('Last-Modified: ' . gmdate('r', filemtime($filename)));
+ $f=fopen($filename, 'r');
+ header('Content-Disposition: attachment; filename="' . basename($filename) . '";');
+ if ($from) fseek($f, $from, SEEK_SET);
+ if (!isset($to) or empty($to)) {
+ $size=filesize($filename)-$from;
+ } else {
+ $size=$to;
+ }
+ $downloaded=0;
+ while(!feof($f) and !connection_status() and ($downloaded<$size)) {
+ echo fread($f, 512000);
+ $downloaded+=512000;
+ ob_flush();
+ flush();
+ }
+ fclose($f);
+}
diff --git a/plugins/marketorders/inc/marketorders.neworder.php b/plugins/marketorders/inc/marketorders.neworder.php
new file mode 100644
index 0000000..a545924
--- /dev/null
+++ b/plugins/marketorders/inc/marketorders.neworder.php
@@ -0,0 +1,174 @@
+ 0)
+{
+ $sql = $db->query("SELECT m.*, u.* FROM $db_market AS m LEFT JOIN $db_users AS u ON u.user_id=m.item_userid WHERE item_id=".$pid." LIMIT 1");
+}
+
+if (!$pid || !$sql || $sql->rowCount() == 0)
+{
+ cot_die_message(404, TRUE);
+}
+$item = $sql->fetch();
+
+cot_block(($item['item_cost'] > 0 || $cfg['plugin']['marketorders']['acceptzerocostorders']) && $item['item_state'] == 0);
+
+/* === Hook === */
+$extp = cot_getextplugins('marketorders.neworder.first');
+foreach ($extp as $pl)
+{
+ include $pl;
+}
+/* ===== */
+
+if ($a == 'add')
+{
+ cot_shield_protect();
+
+ /* === Hook === */
+ foreach (cot_getextplugins('marketorders.neworder.add.first') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+
+ $rorder['order_count'] = cot_import('rcount', 'P', 'INT');
+ $rorder['order_text'] = cot_import('rtext', 'P', 'TXT');
+ $email = cot_import('remail', 'P','TXT', 100, TRUE);
+
+ /* === Hook === */
+ foreach (cot_getextplugins('marketorders.neworder.add.import') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+
+ //cot_check(empty($rorder['order_count']), 'marketorders_neworder_error_count', 'rcount');
+ if (!cot_check_email($email) && $usr['id'] == 0) cot_error('aut_emailtooshort', 'remail');
+
+ if(!empty($email) && $usr['id'] == 0)
+ {
+ $rorder['order_userid'] = $db->query("SELECT user_id FROM $db_users WHERE user_email = ? LIMIT 1", array($email))->fetchColumn();
+ }
+ else
+ {
+ $rorder['order_userid'] = $usr['id'];
+ }
+
+ /* === Hook === */
+ foreach (cot_getextplugins('marketorders.neworder.add.error') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+
+ $rorder['order_count'] = ($rorder['order_count'] > 0) ? $rorder['order_count'] : 1;
+
+ if (!cot_error_found())
+ {
+ $rorder['order_pid'] = $pid;
+ $rorder['order_date'] = $sys['now'];
+ $rorder['order_status'] = 'new';
+ $rorder['order_title'] = $item['item_title'];
+ $rorder['order_seller'] = $item['item_userid'];
+ $rorder['order_cost'] = $item['item_cost']*$rorder['order_count'];
+ $rorder['order_email'] = $email;
+
+ if ($db->insert($db_market_orders, $rorder))
+ {
+ $orderid = $db->lastInsertId();
+
+ if(!empty($rorder['order_email']) && $usr['id'] == 0)
+ {
+ $key = sha1($rorder['order_email'].'&'.$orderid);
+ }
+
+ if($rorder['order_cost'] > 0) {
+ $options['code'] = $orderid;
+ $options['desc'] = $item['item_title'];
+
+ if ($db->fieldExists($db_payments, "pay_redirect"))
+ {
+ $options['redirect'] = $cfg['mainurl'].'/'.cot_url('marketorders', 'id='.$orderid.'&key='.$key, '', true);
+ }
+
+ /* === Hook === */
+ foreach (cot_getextplugins('marketorders.neworder.add.done') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+
+ cot_payments_create_order('marketorders', $rorder['order_cost'], $options);
+ } elseif($cfg['plugin']['marketorders']['acceptzerocostorders']) {
+ cot_redirect(cot_url('marketorders', 'id='.$orderid.'&key='.$key, '', true));
+ } else {
+ cot_redirect(cot_url('payments', 'm=error&msg=3', '', true));
+ }
+ }
+ }
+
+ cot_redirect(cot_url('marketorders', 'm=neworder&pid=' . $pid, '', true));
+ exit;
+}
+
+$out['subtitle'] = $L['marketorders_neworder_title'];
+$out['head'] .= $R['code_noindex'];
+
+$mskin = cot_tplfile(array('marketorders', 'neworder', $structure['market'][$item['item_cat']]['tpl']), 'plug');
+
+/* === Hook === */
+foreach (cot_getextplugins('marketorders.neworder.main') as $pl)
+{
+ include $pl;
+}
+/* ===== */
+
+$t = new XTemplate($mskin);
+
+$catpatharray[] = array(cot_url('market'), $L['market']);
+$catpatharray = array_merge($catpatharray, cot_structure_buildpath('market', $item['item_cat']));
+$catpatharray[] = array(cot_url('market', 'id='.$pid), $item['item_title']);
+$catpatharray[] = array('', $L['marketorders_neworder_title']);
+
+$catpath = cot_breadcrumbs($catpatharray, $cfg['homebreadcrumb'], true);
+
+$t->assign(array(
+ "BREADCRUMBS" => $catpath,
+));
+
+// Error and message handling
+cot_display_messages($t);
+
+$t->assign(cot_generate_markettags($item, 'NEWORDER_PRD_', $cfg['market']['shorttextlen'], $usr['isadmin'], $cfg['homebreadcrumb']));
+
+$t->assign(array(
+ "NEWORDER_FORM_SEND" => cot_url('marketorders', 'm=neworder&pid='.$pid.'&a=add'),
+ "NEWORDER_FORM_COUNT" => cot_inputbox('text', 'rcount', 1, 'size="10" id="count"'),
+ "NEWORDER_FORM_COMMENT" => cot_textarea('rtext', '', 5, 60),
+ "NEWORDER_FORM_EMAIL" => cot_inputbox('text', 'remail'),
+));
+
+/* === Hook === */
+foreach (cot_getextplugins('marketorders.neworder.tags') as $pl)
+{
+ include $pl;
+}
+/* ===== */
diff --git a/plugins/marketorders/inc/marketorders.order.php b/plugins/marketorders/inc/marketorders.order.php
new file mode 100644
index 0000000..ff11a15
--- /dev/null
+++ b/plugins/marketorders/inc/marketorders.order.php
@@ -0,0 +1,234 @@
+ 0)
+{
+ $sql = $db->query("SELECT * FROM $db_market_orders AS o
+ LEFT JOIN $db_market AS m ON m.item_id=o.order_pid
+ WHERE ".(!$cfg['plugin']['marketorders']['showneworderswithoutpayment'] ? "order_status!='new' AND" : "")." order_id=".$id." LIMIT 1");
+}
+
+if (!$id || !$sql || $sql->rowCount() == 0)
+{
+ cot_die_message(404, TRUE);
+}
+$marketorder = $sql->fetch();
+
+cot_block($usr['isadmin'] || $usr['id'] == $marketorder['order_userid'] || $usr['id'] == $marketorder['order_seller'] || !empty($key) && $usr['id'] == 0);
+
+if($usr['id'] == 0)
+{
+ $hash = sha1($marketorder['order_email'].'&'.$marketorder['order_id']);
+ cot_block($key == $hash);
+}
+
+/* === Hook === */
+$extp = cot_getextplugins('marketorders.order.first');
+foreach ($extp as $pl)
+{
+ include $pl;
+}
+/* ===== */
+
+$out['subtitle'] = $L['marketorders_title'];
+$out['head'] .= $R['code_noindex'];
+
+$mskin = cot_tplfile(array('marketorders', 'order', $structure['market'][$marketorder['item_cat']]['tpl']), 'plug');
+
+/* === Hook === */
+foreach (cot_getextplugins('marketorders.order.main') as $pl)
+{
+ include $pl;
+}
+/* ===== */
+
+$t = new XTemplate($mskin);
+
+$catpatharray[] = array(cot_url('market'), $L['market']);
+//$catpatharray = array_merge($catpatharray, cot_structure_buildpath('market', $item['item_cat']));
+//$catpatharray[] = array(cot_url('market', 'id='.$id), $marketorder['item_title']);
+$catpatharray[] = array('', $L['marketorders_title']);
+
+$catpath = cot_breadcrumbs($catpatharray, $cfg['homebreadcrumb'], true);
+
+$t->assign(array(
+ "BREADCRUMBS" => $catpath,
+));
+
+// Error and message handling
+cot_display_messages($t);
+
+$t->assign(cot_generate_markettags($marketorder['order_pid'], 'ORDER_PRD_', $cfg['market']['shorttextlen'], $usr['isadmin'], $cfg['homebreadcrumb']));
+$t->assign(cot_generate_usertags($marketorder['order_seller'], 'ORDER_SELLER_'));
+$t->assign(cot_generate_usertags($marketorder['order_userid'], 'ORDER_CUSTOMER_'));
+
+$t->assign(array(
+ "ORDER_ID" => $marketorder['order_id'],
+ "ORDER_COUNT" => $marketorder['order_count'],
+ "ORDER_COST" => $marketorder['order_cost'],
+ "ORDER_TITLE" => $marketorder['order_title'],
+ "ORDER_COMMENT" => $marketorder['order_text'],
+ "ORDER_EMAIL" => $marketorder['order_email'],
+ "ORDER_PAID" => $marketorder['order_paid'],
+ "ORDER_DONE" => $marketorder['order_done'],
+ "ORDER_STATUS" => $marketorder['order_status'],
+ "ORDER_DOWNLOAD" => (in_array($marketorder['order_status'], array('paid', 'done')) && !empty($marketorder['item_file']) && file_exists($cfg['plugin']['marketorders']['filepath'].'/'.$marketorder['item_file'])) ? cot_url('plug', 'r=marketorders&m=download&id='.$marketorder['order_id'].'&key='.$key) : '',
+ "ORDER_LOCALSTATUS" => $L['marketorders_status_'.$marketorder['order_status']],
+ "ORDER_WARRANTYDATE" => $marketorder['order_paid'] + $cfg['plugin']['marketorders']['warranty']*60*60*24,
+));
+
+if($marketorder['order_status'] == 'claim')
+{
+ $t->assign(array(
+ "CLAIM_DATE" => $marketorder['order_claim'],
+ "CLAIM_TEXT" => $marketorder['order_claimtext'],
+ ));
+
+ /* === Hook === */
+ foreach (cot_getextplugins('marketorders.order.claim') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+
+ if($usr['isadmin'])
+ {
+ // Отменяем заказ, возвращаем оплату покупателю
+ if($a == 'acceptclaim')
+ {
+ $rorder['order_cancel'] = $sys['now'];
+ $rorder['order_status'] = 'cancel';
+
+ if($db->update($db_market_orders, $rorder, 'order_id='.$id))
+ {
+ if($marketorder['order_userid'] > 0)
+ {
+ $payinfo['pay_userid'] = $marketorder['order_userid'];
+ $payinfo['pay_area'] = 'balance';
+ $payinfo['pay_code'] = 'market:'.$marketorder['order_id'];
+ $payinfo['pay_summ'] = $marketorder['order_cost'];
+ $payinfo['pay_cdate'] = $sys['now'];
+ $payinfo['pay_pdate'] = $sys['now'];
+ $payinfo['pay_adate'] = $sys['now'];
+ $payinfo['pay_status'] = 'done';
+ $payinfo['pay_desc'] = cot_rc($L['marketorders_claim_payments_customer_desc'],
+ array(
+ 'product_title' => $marketorder['item_title'],
+ 'order_id' => $marketorder['order_id']
+ )
+ );
+
+ $db->insert($db_payments, $payinfo);
+ }
+
+ $seller = $db->query("SELECT * FROM $db_users WHERE user_id=".$marketorder['order_seller'])->fetch();
+
+ if($marketorder['order_userid'] > 0)
+ {
+ $customer = $db->query("SELECT * FROM $db_users WHERE user_id=".$marketorder['order_userid'])->fetch();
+ }
+ else
+ {
+ $customer['user_name'] = $marketorder['order_email'];
+ $customer['user_email'] = $marketorder['order_email'];
+ }
+
+ // Уведопляем продавца об отмене заказа
+ $rsubject = cot_rc($L['marketorders_acceptclaim_mail_toseller_header'], array('order_id' => $marketorder['order_id'], 'product_title' => $marketorder['item_title']));
+ $rbody = cot_rc($L['marketorders_acceptclaim_mail_toseller_body'], array(
+ 'product_id' => $marketorder['item_id'],
+ 'product_title' => $marketorder['item_title'],
+ 'order_id' => $marketorder['order_id'],
+ 'sitename' => $cfg['maintitle'],
+ 'link' => COT_ABSOLUTE_URL . cot_url('marketorders', "id=" . $marketorder['order_id'], '', true)
+ ));
+ cot_mail ($seller['user_email'], $rsubject, $rbody);
+
+ // Уведопляем покупателя об отмене заказа
+ $rsubject = cot_rc($L['marketorders_acceptclaim_mail_tocustomer_header'], array('order_id' => $marketorder['order_id'], 'product_title' => $marketorder['item_title']));
+ $rbody = cot_rc($L['marketorders_acceptclaim_mail_tocustomer_body'], array(
+ 'product_id' => $marketorder['item_id'],
+ 'product_title' => $marketorder['item_title'],
+ 'order_id' => $marketorder['order_id'],
+ 'sitename' => $cfg['maintitle'],
+ 'link' => COT_ABSOLUTE_URL . cot_url('marketorders', "id=" . $marketorder['order_id'], '', true)
+ ));
+
+ /* === Hook === */
+ foreach (cot_getextplugins('marketorders.order.acceptclaim.done') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+
+ cot_mail ($customer['user_email'], $rsubject, $rbody);
+
+ cot_redirect(cot_url('marketorders', 'm=order&id=' . $id, '', true));
+ exit;
+ }
+
+ cot_redirect(cot_url('marketorders', 'm=order&id=' . $id, '', true));
+ exit;
+ }
+
+ // Отменяем жалобу
+ if($a == 'cancelclaim')
+ {
+ $rorder['order_claim'] = 0;
+ $rorder['order_status'] = 'paid';
+
+ if($db->update($db_market_orders, $rorder, 'order_id='.$id))
+ {
+ $customer = $db->query("SELECT * FROM $db_users WHERE user_id=".$marketorder['order_userid'])->fetch();
+
+ // Уведопляем покупателя об отклонении жалобы
+ $rsubject = cot_rc($L['marketorders_cancelclaim_mail_tocustomer_header'], array('order_id' => $marketorder['order_id'], 'product_title' => $marketorder['item_title']));
+ $rbody = cot_rc($L['marketorders_cancelclaim_mail_tocustomer_body'], array(
+ 'product_title' => $marketorder['item_title'],
+ 'order_id' => $marketorder['order_id'],
+ 'sitename' => $cfg['maintitle'],
+ 'link' => COT_ABSOLUTE_URL . cot_url('marketorders', "id=" . $marketorder['order_id'], '', true)
+ ));
+
+ /* === Hook === */
+ foreach (cot_getextplugins('marketorders.order.cancelclaim.done') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+
+ cot_mail ($customer['user_email'], $rsubject, $rbody);
+ }
+
+ cot_redirect(cot_url('marketorders', 'm=order&id=' . $id, '', true));
+ exit;
+ }
+
+ $t->parse('MAIN.CLAIM.ADMINCLAIM');
+ }
+ $t->parse('MAIN.CLAIM');
+}
+
+/* === Hook === */
+foreach (cot_getextplugins('marketorders.order.tags') as $pl)
+{
+ include $pl;
+}
+/* ===== */
diff --git a/plugins/marketorders/inc/marketorders.pay.php b/plugins/marketorders/inc/marketorders.pay.php
new file mode 100644
index 0000000..56b0dab
--- /dev/null
+++ b/plugins/marketorders/inc/marketorders.pay.php
@@ -0,0 +1,56 @@
+ 0)
+{
+ $sql = $db->query("SELECT * FROM $db_market_orders AS o
+ LEFT JOIN $db_market AS m ON m.item_id=o.order_pid
+ WHERE order_id=".$id." LIMIT 1");
+}
+
+if (!$id || !$sql || $sql->rowCount() == 0)
+{
+ cot_die_message(404, TRUE);
+}
+$marketorder = $sql->fetch();
+
+cot_block($marketorder['order_cost'] > 0 && $marketorder['order_status'] == 'new' && $marketorder['order_userid'] == $usr['id']);
+
+/* === Hook === */
+$extp = cot_getextplugins('marketorders.pay.first');
+foreach ($extp as $pl)
+{
+ include $pl;
+}
+/* ===== */
+
+$orderid = $marketorder['order_id'];
+
+if(!empty($marketorder['order_email']) && $usr['id'] == 0)
+{
+ $key = sha1($marketorder['order_email'].'&'.$orderid);
+}
+
+$options['code'] = $orderid;
+$options['desc'] = $item['item_title'];
+
+if ($db->fieldExists($db_payments, "pay_redirect"))
+{
+ $options['redirect'] = $cfg['mainurl'].'/'.cot_url('marketorders', 'id='.$orderid.'&key='.$key, '', true);
+}
+
+/* === Hook === */
+foreach (cot_getextplugins('marketorders.neworder.add.done') as $pl)
+{
+ include $pl;
+}
+/* ===== */
+
+cot_payments_create_order('marketorders', $marketorder['order_cost'], $options);
+exit;
diff --git a/plugins/marketorders/inc/marketorders.purchases.php b/plugins/marketorders/inc/marketorders.purchases.php
new file mode 100644
index 0000000..706de6c
--- /dev/null
+++ b/plugins/marketorders/inc/marketorders.purchases.php
@@ -0,0 +1,162 @@
+ 0 && $usr['auth_read']);
+
+if($cfg['plugin']['marketorders']['ordersperpage'] > 0)
+{
+ list($pn, $d, $d_url) = cot_import_pagenav('d', $cfg['plugin']['marketorders']['ordersperpage']);
+}
+
+/* === Hook === */
+$extp = cot_getextplugins('marketorders.purchases.first');
+foreach ($extp as $pl)
+{
+ include $pl;
+}
+/* ===== */
+
+$out['subtitle'] = $L['market_purchases_title'];
+$out['head'] .= $R['code_noindex'];
+
+$mskin = cot_tplfile(array('marketorders', 'purchases'), 'plug');
+
+/* === Hook === */
+foreach (cot_getextplugins('marketorders.purchases.main') as $pl)
+{
+ include $pl;
+}
+/* ===== */
+
+$t = new XTemplate($mskin);
+
+$where['userid'] = "o.order_userid=" . $usr['id'];
+
+switch($status)
+{
+
+ case 'paid':
+ $where['order_status'] = "o.order_status='paid'";
+ break;
+
+ case 'done':
+ $where['order_status'] = "o.order_status='done'";
+ break;
+
+ case 'claim':
+ $where['order_status'] = "o.order_status='claim'";
+ break;
+
+ case 'cancel':
+ $where['order_status'] = "o.order_status='cancel'";
+ break;
+
+ case 'new':
+ if($cfg['plugin']['marketorders']['showneworderswithoutpayment']) {
+ $where['order_status'] = "o.order_status='new'";
+ } else {
+ $where['order_status'] = "o.order_status!='new'";
+ }
+ break;
+
+ default:
+ if(!$cfg['plugin']['marketorders']['showneworderswithoutpayment']) {
+ $where['order_status'] = "o.order_status!='new'";
+ }
+ break;
+}
+
+$order['date'] = 'o.order_date DESC';
+
+/* === Hook === */
+foreach (cot_getextplugins('marketorders.purchases.query') as $pl)
+{
+ include $pl;
+}
+/* ===== */
+
+$where = ($where) ? 'WHERE ' . implode(' AND ', $where) : '';
+$order = ($order) ? 'ORDER BY ' . implode(', ', $order) : '';
+$query_limit = ($cfg['plugin']['marketorders']['ordersperpage'] > 0) ? "LIMIT $d, ".$cfg['plugin']['marketorders']['ordersperpage'] : '';
+
+$totalitems = $db->query("SELECT COUNT(*) FROM $db_market_orders AS o
+ LEFT JOIN $db_market AS m ON o.order_pid=m.item_id
+ " . $where . "")->fetchColumn();
+
+$sql = $db->query("SELECT * FROM $db_market_orders AS o
+ LEFT JOIN $db_market AS m ON o.order_pid=m.item_id
+ " . $where . "
+ " . $order . "
+ " . $query_limit . "");
+
+$pagenav = cot_pagenav('marketorders', 'm=purchases&status=' . $status, $d, $totalitems, $cfg['plugin']['marketorders']['ordersperpage']);
+
+$t->assign(array(
+ "PAGENAV_COUNT" => $totalitems,
+ "PAGENAV_PAGES" => $pagenav['main'],
+ "PAGENAV_PREV" => $pagenav['prev'],
+ "PAGENAV_NEXT" => $pagenav['next'],
+));
+
+$catpatharray[] = array(cot_url('market'), $L['market']);
+$catpatharray[] = array('', $L['marketorders_purchases_title']);
+
+$catpath = cot_breadcrumbs($catpatharray, $cfg['homebreadcrumb'], true);
+
+$t->assign(array(
+ "BREADCRUMBS" => $catpath,
+));
+
+/* === Hook === */
+$extp = cot_getextplugins('marketorders.purchases.loop');
+/* ===== */
+
+while ($marketorder = $sql->fetch())
+{
+ $t->assign(cot_generate_markettags($marketorder, 'ORDER_ROW_PRD_'));
+ $t->assign(cot_generate_usertags($marketorder['order_seller'], 'ORDER_ROW_SELLER_'));
+
+ $t->assign(array(
+ "ORDER_ROW_ID" => $marketorder['order_id'],
+ "ORDER_ROW_URL" => cot_url('marketorders','m=order&id='.$marketorder['order_id']),
+ "ORDER_ROW_COUNT" => $marketorder['order_count'],
+ "ORDER_ROW_COST" => $marketorder['order_cost'],
+ "ORDER_ROW_COMMENT" => $marketorder['order_text'],
+ "ORDER_ROW_EMAIL" => $marketorder['order_email'],
+ "ORDER_ROW_DATE" => $marketorder['order_date'],
+ "ORDER_ROW_PAID" => $marketorder['order_paid'],
+ "ORDER_ROW_STATUS" => $marketorder['order_status'],
+ "ORDER_ROW_WARRANTYDATE" => $marketorder['order_paid'] + $cfg['plugin']['marketorders']['warranty']*60*60*24,
+ ));
+
+ /* === Hook - Part2 : Include === */
+ foreach ($extp as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+
+ $t->parse("MAIN.ORDER_ROW");
+}
+
+/* === Hook === */
+foreach (cot_getextplugins('marketorders.purchases.tags') as $pl)
+{
+ include $pl;
+}
+/* ===== */
diff --git a/plugins/marketorders/inc/marketorders.sales.php b/plugins/marketorders/inc/marketorders.sales.php
new file mode 100644
index 0000000..708d29e
--- /dev/null
+++ b/plugins/marketorders/inc/marketorders.sales.php
@@ -0,0 +1,155 @@
+ 0 && $usr['auth_read']);
+
+if($cfg['plugin']['marketorders']['ordersperpage'] > 0)
+{
+ list($pn, $d, $d_url) = cot_import_pagenav('d', $cfg['plugin']['marketorders']['ordersperpage']);
+}
+
+/* === Hook === */
+$extp = cot_getextplugins('marketorders.sales.first');
+foreach ($extp as $pl)
+{
+ include $pl;
+}
+/* ===== */
+
+$out['subtitle'] = $L['market_sales_title'];
+$out['head'] .= $R['code_noindex'];
+
+$mskin = cot_tplfile(array('marketorders', 'sales'), 'plug');
+
+/* === Hook === */
+foreach (cot_getextplugins('marketorders.sales.main') as $pl)
+{
+ include $pl;
+}
+/* ===== */
+
+$t = new XTemplate($mskin);
+
+$where['userid'] = "order_seller=" . $usr['id'];
+
+switch($status)
+{
+
+ case 'paid':
+ $where['order_status'] = "o.order_status='paid'";
+ break;
+
+ case 'done':
+ $where['order_status'] = "o.order_status='done'";
+ break;
+
+ case 'claim':
+ $where['order_status'] = "o.order_status='claim'";
+ break;
+
+ case 'cancel':
+ $where['order_status'] = "o.order_status='cancel'";
+ break;
+
+ default:
+ $where['order_status'] = "o.order_status!='new'";
+ break;
+}
+
+$order['date'] = 'o.order_date DESC';
+
+/* === Hook === */
+foreach (cot_getextplugins('marketorders.sales.query') as $pl)
+{
+ include $pl;
+}
+/* ===== */
+
+$where = ($where) ? 'WHERE ' . implode(' AND ', $where) : '';
+$order = ($order) ? 'ORDER BY ' . implode(', ', $order) : '';
+$query_limit = ($cfg['plugin']['marketorders']['ordersperpage'] > 0) ? "LIMIT $d, ".$cfg['plugin']['marketorders']['ordersperpage'] : '';
+
+$totalitems = $db->query("SELECT COUNT(*) FROM $db_market_orders AS o
+ LEFT JOIN $db_market AS m ON o.order_pid=m.item_id
+ " . $where . "")->fetchColumn();
+
+$sql = $db->query("SELECT * FROM $db_market_orders AS o
+ LEFT JOIN $db_market AS m ON o.order_pid=m.item_id
+ " . $where . "
+ " . $order . "
+ " . $query_limit . "");
+
+$pagenav = cot_pagenav('marketorders', 'm=sales&status=' . $status, $d, $totalitems, $cfg['plugin']['marketorders']['ordersperpage']);
+
+$t->assign(array(
+ "PAGENAV_COUNT" => $totalitems,
+ "PAGENAV_PAGES" => $pagenav['main'],
+ "PAGENAV_PREV" => $pagenav['prev'],
+ "PAGENAV_NEXT" => $pagenav['next'],
+));
+
+$catpatharray[] = array(cot_url('market'), $L['market']);
+$catpatharray[] = array('', $L['marketorders_sales_title']);
+
+$catpath = cot_breadcrumbs($catpatharray, $cfg['homebreadcrumb'], true);
+
+$t->assign(array(
+ "BREADCRUMBS" => $catpath,
+));
+
+/* === Hook === */
+$extp = cot_getextplugins('marketorders.sales.loop');
+/* ===== */
+
+while ($marketorder = $sql->fetch())
+{
+ $t->assign(cot_generate_markettags($marketorder, 'ORDER_ROW_PRD_'));
+
+ if($marketorder['order_userid'] > 0)
+ {
+ $t->assign(cot_generate_usertags($marketorder['order_userid'], 'ORDER_ROW_CUSTOMER_'));
+ }
+
+ $t->assign(array(
+ "ORDER_ROW_ID" => $marketorder['order_id'],
+ "ORDER_ROW_URL" => cot_url('marketorders','m=order&id='.$marketorder['order_id']),
+ "ORDER_ROW_COUNT" => $marketorder['order_count'],
+ "ORDER_ROW_COST" => $marketorder['order_cost'],
+ "ORDER_ROW_COMMENT" => $marketorder['order_text'],
+ "ORDER_ROW_EMAIL" => $marketorder['order_email'],
+ "ORDER_ROW_DATE" => $marketorder['order_date'],
+ "ORDER_ROW_PAID" => $marketorder['order_paid'],
+ "ORDER_ROW_STATUS" => $marketorder['order_status'],
+ "ORDER_ROW_WARRANTYDATE" => $marketorder['order_paid'] + $cfg['plugin']['marketorders']['warranty']*60*60*24,
+ ));
+
+ /* === Hook - Part2 : Include === */
+ foreach ($extp as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+
+ $t->parse("MAIN.ORDER_ROW");
+}
+
+/* === Hook === */
+foreach (cot_getextplugins('marketorders.sales.tags') as $pl)
+{
+ include $pl;
+}
+/* ===== */
diff --git a/plugins/marketorders/lang/marketorders.en.lang.php b/plugins/marketorders/lang/marketorders.en.lang.php
new file mode 100644
index 0000000..abaf64c
--- /dev/null
+++ b/plugins/marketorders/lang/marketorders.en.lang.php
@@ -0,0 +1,118 @@
+query("SELECT COUNT(*) FROM $db_market_orders WHERE 1");
+$marketorderscount = $marketorderscount->fetchColumn();
+
+$marketordersclaims = $db->query("SELECT COUNT(*) FROM $db_market_orders WHERE order_status='claim'");
+$marketordersclaims = $marketordersclaims->fetchColumn();
+
+$marketordersdone = $db->query("SELECT COUNT(*) FROM $db_market_orders WHERE order_status='done'");
+$marketordersdone = $marketordersdone->fetchColumn();
+
+$tt->assign(array(
+ 'ADMIN_HOME_ORDERS_URL' => cot_url('admin', 'm=other&p=marketorders'),
+ 'ADMIN_HOME_ORDERS_COUNT' => $marketorderscount,
+ 'ADMIN_HOME_CLAIMS_URL' => cot_url('admin', 'm=other&p=marketorders&status=claim'),
+ 'ADMIN_HOME_CLAIMS_COUNT' => $marketordersclaims,
+ 'ADMIN_HOME_DONE_URL' => cot_url('admin', 'm=other&p=marketorders&status=done'),
+ 'ADMIN_HOME_DONE_COUNT' => $marketordersdone,
+));
+
+$tt->parse('MAIN');
+
+$line = $tt->text('MAIN');
diff --git a/plugins/marketorders/marketorders.admin.php b/plugins/marketorders/marketorders.admin.php
new file mode 100644
index 0000000..11eb200
--- /dev/null
+++ b/plugins/marketorders/marketorders.admin.php
@@ -0,0 +1,171 @@
+ 0)
+{
+ list($pn, $d, $d_url) = cot_import_pagenav('d', $cfg['plugin']['marketorders']['ordersperpage']);
+}
+
+/* === Hook === */
+$extp = cot_getextplugins('marketorders.admin.first');
+foreach ($extp as $pl)
+{
+ include $pl;
+}
+/* ===== */
+
+$out['subtitle'] = $L['market_sales_title'];
+$out['head'] .= $R['code_noindex'];
+
+$mskin = cot_tplfile(array('marketorders', 'admin'), 'plug');
+
+/* === Hook === */
+foreach (cot_getextplugins('marketorders.admin.main') as $pl)
+{
+ include $pl;
+}
+/* ===== */
+
+$t = new XTemplate($mskin);
+
+switch($status)
+{
+
+ case 'paid':
+ $where['order_status'] = "o.order_status='paid'";
+ break;
+
+ case 'done':
+ $where['order_status'] = "o.order_status='done'";
+ break;
+
+ case 'claim':
+ $where['order_status'] = "o.order_status='claim'";
+ break;
+
+ case 'cancel':
+ $where['order_status'] = "o.order_status='cancel'";
+ break;
+
+ case 'new':
+ if($cfg['plugin']['marketorders']['showneworderswithoutpayment']) {
+ $where['order_status'] = "o.order_status='new'";
+ } else {
+ $where['order_status'] = "o.order_status!='new'";
+ }
+ break;
+
+ default:
+ if(!$cfg['plugin']['marketorders']['showneworderswithoutpayment']) {
+ $where['order_status'] = "o.order_status!='new'";
+ }
+ break;
+}
+
+$order['date'] = 'o.order_date DESC';
+
+/* === Hook === */
+foreach (cot_getextplugins('marketorders.admin.query') as $pl)
+{
+ include $pl;
+}
+/* ===== */
+
+$where = ($where) ? 'WHERE ' . implode(' AND ', $where) : '';
+$order = ($order) ? 'ORDER BY ' . implode(', ', $order) : '';
+$query_limit = ($cfg['plugin']['marketorders']['ordersperpage'] > 0) ? "LIMIT $d, ".$cfg['plugin']['marketorders']['ordersperpage'] : '';
+
+$totalitems = $db->query("SELECT COUNT(*) FROM $db_market_orders AS o
+ LEFT JOIN $db_market AS m ON o.order_pid=m.item_id
+ " . $where . "")->fetchColumn();
+
+$sql = $db->query("SELECT * FROM $db_market_orders AS o
+ LEFT JOIN $db_market AS m ON o.order_pid=m.item_id
+ " . $where . "
+ " . $order . "
+ " . $query_limit . "");
+
+$pagenav = cot_pagenav('admin', 'm=other&p=marketorders&status=' . $status, $d, $totalitems, $cfg['plugin']['marketorders']['ordersperpage']);
+
+$t->assign(array(
+ "PAGENAV_COUNT" => $totalitems,
+ "PAGENAV_PAGES" => $pagenav['main'],
+ "PAGENAV_PREV" => $pagenav['prev'],
+ "PAGENAV_NEXT" => $pagenav['next'],
+));
+
+/* === Hook === */
+$extp = cot_getextplugins('marketorders.admin.loop');
+/* ===== */
+
+while ($marketorder = $sql->fetch())
+{
+ $t->assign(cot_generate_markettags($marketorder, 'ORDER_ROW_PRD_'));
+ $t->assign(cot_generate_usertags($marketorder['order_seller'], 'ORDER_ROW_SELLER_'));
+
+ if($marketorder['order_userid'] > 0)
+ {
+ $t->assign(cot_generate_usertags($marketorder['order_userid'], 'ORDER_ROW_CUSTOMER_'));
+ }
+
+ $t->assign(array(
+ "ORDER_ROW_ID" => $marketorder['order_id'],
+ "ORDER_ROW_URL" => cot_url('marketorders','m=order&id='.$marketorder['order_id']),
+ "ORDER_ROW_COUNT" => $marketorder['order_count'],
+ "ORDER_ROW_COST" => $marketorder['order_cost'],
+ "ORDER_ROW_COMMENT" => $marketorder['order_text'],
+ "ORDER_ROW_EMAIL" => $marketorder['order_email'],
+ "ORDER_ROW_DATE" => $marketorder['order_date'],
+ "ORDER_ROW_PAID" => $marketorder['order_paid'],
+ "ORDER_ROW_STATUS" => $marketorder['order_status'],
+ "ORDER_ROW_WARRANTYDATE" => $marketorder['order_paid'] + $cfg['market']['warranty']*60*60*24,
+ ));
+
+ /* === Hook - Part2 : Include === */
+ foreach ($extp as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+
+ $t->parse("MAIN.ORDER_ROW");
+}
+
+/* === Hook === */
+foreach (cot_getextplugins('marketorders.admin.tags') as $pl)
+{
+ include $pl;
+}
+/* ===== */
+
+$t->parse("MAIN");
+$plugin_body .= $t->text("MAIN");
diff --git a/plugins/marketorders/marketorders.ajax.php b/plugins/marketorders/marketorders.ajax.php
new file mode 100644
index 0000000..a8f2e8e
--- /dev/null
+++ b/plugins/marketorders/marketorders.ajax.php
@@ -0,0 +1,50 @@
+ 0)
+ {
+ $sql = $db->query("SELECT * FROM $db_market_orders AS o
+ LEFT JOIN $db_market AS m ON m.item_id=o.order_pid
+ WHERE order_id=".$id." LIMIT 1");
+ }
+
+ if (!$id || !$sql || $sql->rowCount() == 0)
+ {
+ cot_die_message(404, TRUE);
+ }
+ $marketorder = $sql->fetch();
+
+ cot_block($usr['isadmin'] || $usr['id'] == $marketorder['order_userid'] || $usr['id'] == $marketorder['order_seller'] || !empty($key) && $usr['id'] == 0);
+
+ if($usr['id'] == 0)
+ {
+ $hash = sha1($marketorder['order_email'].'&'.$marketorder['order_id']);
+ cot_block($key == $hash);
+ }
+
+ $file = $cfg['plugin']['marketorders']['filepath'].'/'.$marketorder['item_file'];
+
+ if(file_exists($file) && ($marketorder['order_status'] == 'paid' || $marketorder['order_status'] == 'done') || $usr['isadmin'] || $usr['id'] == $marketorder['order_seller']){
+ marketorders_file_download($file, $mimetype='application/octet-stream');
+ }else{
+ cot_block();
+ }
+}
diff --git a/plugins/marketorders/marketorders.global.php b/plugins/marketorders/marketorders.global.php
new file mode 100644
index 0000000..344b070
--- /dev/null
+++ b/plugins/marketorders/marketorders.global.php
@@ -0,0 +1,257 @@
+update($db_market_orders, array('order_paid' => (int)$sys['now'], 'order_status' => 'paid'), "order_id=".(int)$pay['pay_code']);
+
+ $marketorder = $db->query("SELECT * FROM $db_market_orders AS o
+ LEFT JOIN $db_market AS m ON m.item_id=o.order_pid
+ WHERE order_id=".$pay['pay_code'])->fetch();
+
+ $seller = $db->query("SELECT * FROM $db_users WHERE user_id=".$marketorder['order_seller'])->fetch();
+ if($marketorder['order_userid'] > 0)
+ {
+ $customer = $db->query("SELECT * FROM $db_users WHERE user_id=".$marketorder['order_userid'])->fetch();
+ }
+ else
+ {
+ $customer['user_name'] = $marketorder['order_email'];
+ $customer['user_email'] = $marketorder['order_email'];
+ }
+
+ $summ = $marketorder['order_cost'] - $marketorder['order_cost']*$cfg['plugin']['marketorders']['tax']/100;
+
+ // Уведопляем продавца о совершении покупки его товара
+ $rsubject = cot_rc($L['marketorders_paid_mail_toseller_header'], array('order_id' => $marketorder['order_id'], 'product_title' => $marketorder['item_title']));
+ $rbody = cot_rc($L['marketorders_paid_mail_toseller_body'], array(
+ 'user_name' => $customer['user_name'],
+ 'product_id' => $marketorder['item_id'],
+ 'product_title' => $marketorder['item_title'],
+ 'order_id' => $marketorder['order_id'],
+ 'summ' => $summ.' '.$cfg['payments']['valuta'],
+ 'tax' => $cfg['plugin']['marketorders']['tax'],
+ 'warranty' => $cfg['plugin']['marketorders']['warranty'],
+ 'sitename' => $cfg['maintitle'],
+ 'link' => COT_ABSOLUTE_URL . cot_url('marketorders', "id=" . $marketorder['order_id'], '', true)
+ ));
+ cot_mail ($seller['user_email'], $rsubject, $rbody);
+
+ // Уведопляем покупателя о совершении покупки
+ if(!empty($marketorder['order_email']))
+ {
+ $key = sha1($marketorder['order_email'].'&'.$marketorder['order_id']);
+ }
+
+ $rsubject = cot_rc($L['marketorders_paid_mail_tocustomer_header'], array('order_id' => $marketorder['order_id'], 'product_title' => $marketorder['item_title']));
+ $rbody = cot_rc($L['marketorders_paid_mail_tocustomer_body'], array(
+ 'user_name' => $customer['user_name'],
+ 'product_id' => $marketorder['item_id'],
+ 'product_title' => $marketorder['item_title'],
+ 'order_id' => $marketorder['order_id'],
+ 'cost' => $marketorder['order_cost'].' '.$cfg['payments']['valuta'],
+ 'tax' => $cfg['plugin']['marketorders']['tax'],
+ 'warranty' => $cfg['plugin']['marketorders']['warranty'],
+ 'sitename' => $cfg['maintitle'],
+ 'link' => COT_ABSOLUTE_URL . cot_url('marketorders', "id=" . $marketorder['order_id'] . '&key=' . $key, '', true)
+ ));
+ cot_mail ($customer['user_email'], $rsubject, $rbody);
+
+ /* === Hook === */
+ foreach (cot_getextplugins('marketorders.order.paid') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+ }
+ }
+}
+
+if($cfg['plugin']['marketorders']['acceptzerocostorders']) {
+ // Проверяем заказы с ценой 0 в маркете
+ $marketorders = $db->query("SELECT * FROM $db_market_orders AS o
+ LEFT JOIN $db_market AS m ON m.item_id=o.order_pid
+ WHERE order_status='new' AND order_cost<=0")->fetchAll();
+ foreach ($marketorders as $marketorder)
+ {
+ $db->update($db_market_orders, array('order_paid' => (int)$sys['now'], 'order_status' => 'paid'), "order_id=".(int)$marketorder['order_id']);
+
+ $seller = $db->query("SELECT * FROM $db_users WHERE user_id=".$marketorder['order_seller'])->fetch();
+ if($marketorder['order_userid'] > 0)
+ {
+ $customer = $db->query("SELECT * FROM $db_users WHERE user_id=".$marketorder['order_userid'])->fetch();
+ }
+ else
+ {
+ $customer['user_name'] = $marketorder['order_email'];
+ $customer['user_email'] = $marketorder['order_email'];
+ }
+
+ $summ = 0;
+
+ // Уведопляем продавца о совершении покупки его товара
+ $rsubject = cot_rc($L['marketorders_paid_mail_toseller_header'], array('order_id' => $marketorder['order_id'], 'product_title' => $marketorder['item_title']));
+ $rbody = cot_rc($L['marketorders_paid_mail_toseller_body'], array(
+ 'user_name' => $customer['user_name'],
+ 'product_id' => $marketorder['item_id'],
+ 'product_title' => $marketorder['item_title'],
+ 'order_id' => $marketorder['order_id'],
+ 'summ' => $summ.' '.$cfg['payments']['valuta'],
+ 'tax' => $cfg['plugin']['marketorders']['tax'],
+ 'warranty' => $cfg['plugin']['marketorders']['warranty'],
+ 'sitename' => $cfg['maintitle'],
+ 'link' => COT_ABSOLUTE_URL . cot_url('marketorders', "id=" . $marketorder['order_id'], '', true)
+ ));
+ cot_mail ($seller['user_email'], $rsubject, $rbody);
+
+ // Уведопляем покупателя о совершении покупки
+ if(!empty($marketorder['order_email']))
+ {
+ $key = sha1($marketorder['order_email'].'&'.$marketorder['order_id']);
+ }
+
+ $rsubject = cot_rc($L['marketorders_paid_mail_tocustomer_header'], array('order_id' => $marketorder['order_id'], 'product_title' => $marketorder['item_title']));
+ $rbody = cot_rc($L['marketorders_paid_mail_tocustomer_body'], array(
+ 'user_name' => $customer['user_name'],
+ 'product_id' => $marketorder['item_id'],
+ 'product_title' => $marketorder['item_title'],
+ 'order_id' => $marketorder['order_id'],
+ 'cost' => $marketorder['order_cost'].' '.$cfg['payments']['valuta'],
+ 'tax' => $cfg['plugin']['marketorders']['tax'],
+ 'warranty' => $cfg['plugin']['marketorders']['warranty'],
+ 'sitename' => $cfg['maintitle'],
+ 'link' => COT_ABSOLUTE_URL . cot_url('marketorders', "id=" . $marketorder['order_id'] . '&key=' . $key, '', true)
+ ));
+ cot_mail ($customer['user_email'], $rsubject, $rbody);
+
+ /* === Hook === */
+ foreach (cot_getextplugins('marketorders.order.paid') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+ }
+}
+
+// Выплаты продавцам по завершению гарантийного срока по оформленным заказам
+$warranty = $cfg['plugin']['marketorders']['warranty']*60*60*24;
+$marketorders = $db->query("SELECT * FROM $db_market_orders AS o
+ LEFT JOIN $db_market AS m ON m.item_id=o.order_pid
+ WHERE order_status='paid' AND order_paid+".$warranty."<".$sys['now'])->fetchAll();
+foreach ($marketorders as $marketorder)
+{
+ // Выплата продавцу на счет
+ $seller = $db->query("SELECT * FROM $db_users WHERE user_id=".$marketorder['order_seller'])->fetch();
+
+ if($marketorder['order_cost'] <= 0) {
+ $rorder = array();
+ $rorder['order_done'] = $sys['now'];
+ $rorder['order_status'] = 'done';
+
+ if($db->update($db_market_orders, $rorder, "order_id=".$marketorder['order_id']))
+ {
+
+ }
+
+ /* === Hook === */
+ foreach (cot_getextplugins('marketorders.order.done') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+
+ continue;
+ }
+
+ $summ = $marketorder['order_cost'] - $marketorder['order_cost']*$cfg['plugin']['marketorders']['tax']/100;
+
+ $payinfo['pay_userid'] = $marketorder['order_seller'];
+ $payinfo['pay_area'] = 'balance';
+ $payinfo['pay_code'] = 'marketorders:'.$marketorder['order_id'];
+ $payinfo['pay_summ'] = $summ;
+ $payinfo['pay_cdate'] = $sys['now'];
+ $payinfo['pay_pdate'] = $sys['now'];
+ $payinfo['pay_adate'] = $sys['now'];
+ $payinfo['pay_status'] = 'done';
+ $payinfo['pay_desc'] = cot_rc($L['marketorders_done_payments_desc'],
+ array(
+ 'product_title' => $marketorder['item_title'],
+ 'order_id' => $marketorder['order_id']
+ )
+ );
+
+ if($db->insert($db_payments, $payinfo))
+ {
+ // Уведомляем продавца о поступлении оплаты на его счет
+ $rsubject = cot_rc($L['marketorders_done_mail_toseller_header'], array('order_id' => $marketorder['order_id'], 'product_title' => $marketorder['item_title']));
+ $rbody = cot_rc($L['marketorders_done_mail_toseller_body'], array(
+ 'product_id' => $marketorder['item_id'],
+ 'product_title' => $marketorder['item_title'],
+ 'order_id' => $marketorder['order_id'],
+ 'summ' => $summ.' '.$cfg['payments']['valuta'],
+ 'tax' => $cfg['plugin']['marketorders']['tax'],
+ 'sitename' => $cfg['maintitle'],
+ 'link' => COT_ABSOLUTE_URL . cot_url('marketorders', "id=" . $marketorder['order_id'], '', true)
+ ));
+ cot_mail ($seller['user_email'], $rsubject, $rbody);
+
+ $rorder['order_done'] = $sys['now'];
+ $rorder['order_status'] = 'done';
+
+ if($db->update($db_market_orders, $rorder, "order_id=".$marketorder['order_id']))
+ {
+ if($cfg['plugin']['marketorders']['adminid'] > 0 && $cfg['plugin']['marketorders']['tax'] > 0)
+ {
+ $payinfo['pay_userid'] = $cfg['plugin']['marketorders']['adminid'];
+ $payinfo['pay_area'] = 'balance';
+ $payinfo['pay_code'] = 'marketorders:'.$marketorder['order_id'];
+ $payinfo['pay_summ'] = $marketorder['order_cost']*$cfg['plugin']['marketorders']['tax']/100;
+ $payinfo['pay_cdate'] = $sys['now'];
+ $payinfo['pay_pdate'] = $sys['now'];
+ $payinfo['pay_adate'] = $sys['now'];
+ $payinfo['pay_status'] = 'done';
+ $payinfo['pay_desc'] = cot_rc($L['marketorders_tax_payments_desc'],
+ array(
+ 'product_title' => $marketorder['item_title'],
+ 'order_id' => $marketorder['order_id']
+ )
+ );
+
+ $db->insert($db_payments, $payinfo);
+ }
+ }
+
+ /* === Hook === */
+ foreach (cot_getextplugins('marketorders.order.done') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+ }
+}
diff --git a/plugins/marketorders/marketorders.markettags.php b/plugins/marketorders/marketorders.markettags.php
new file mode 100644
index 0000000..1558ab5
--- /dev/null
+++ b/plugins/marketorders/marketorders.markettags.php
@@ -0,0 +1,46 @@
+query("SELECT * FROM $db_market_orders AS o
+ LEFT JOIN $db_market AS m ON m.item_id=o.order_pid
+ WHERE order_pid=".$item_data['item_id']." AND order_status!='new' AND order_userid=".$usr['id']." LIMIT 1")->fetch();
+
+if(!empty($key)){
+ $hash = sha1($marketorder['order_email'].'&'.$marketorder['order_id']);
+}
+if ($marketorder && ($usr['id'] > 0 || $usr['id'] == 0 && !empty($key) && $key == $hash)){
+ $temp_array['ORDER_ID'] = $marketorder['order_id'];
+ $temp_array['ORDER_URL'] = cot_url('marketorders', 'id='.$marketorder['order_id'].'&key='.$key);
+ $temp_array['ORDER_COUNT'] = $marketorder['order_count'];
+ $temp_array['ORDER_COST'] = $marketorder['order_cost'];
+ $temp_array['ORDER_TITLE'] = $marketorder['order_title'];
+ $temp_array['ORDER_COMMENT'] = $marketorder['order_text'];
+ $temp_array['ORDER_EMAIL'] = $marketorder['order_email'];
+ $temp_array['ORDER_PAID'] = $marketorder['order_paid'];
+ $temp_array['ORDER_DONE'] = $marketorder['order_done'];
+ $temp_array['ORDER_STATUS'] = $marketorder['order_status'];
+ $temp_array['ORDER_DOWNLOAD'] = (in_array($marketorder['order_status'], array('paid', 'done')) && !empty($marketorder['item_file']) && file_exists($cfg['plugin']['marketorders']['filepath'].'/'.$marketorder['item_file'])) ? cot_url('plug', 'r=marketorders&m=download&id='.$marketorder['order_id'].'&key='.$key) : '';
+ $temp_array['ORDER_LOCALSTATUS'] = $L['marketorders_status_'.$marketorder['order_status']];
+ $temp_array['ORDER_WARRANTYDATE'] = $marketorder['order_paid'] + $cfg['plugin']['marketorders']['warranty']*60*60*24;
+}
\ No newline at end of file
diff --git a/plugins/marketorders/marketorders.php b/plugins/marketorders/marketorders.php
new file mode 100644
index 0000000..b7574fa
--- /dev/null
+++ b/plugins/marketorders/marketorders.php
@@ -0,0 +1,41 @@
+
diff --git a/plugins/marketorders/marketorders.png b/plugins/marketorders/marketorders.png
new file mode 100644
index 0000000..b516376
Binary files /dev/null and b/plugins/marketorders/marketorders.png differ
diff --git a/plugins/marketorders/marketorders.setup.php b/plugins/marketorders/marketorders.setup.php
new file mode 100644
index 0000000..4240679
--- /dev/null
+++ b/plugins/marketorders/marketorders.setup.php
@@ -0,0 +1,41 @@
+
diff --git a/plugins/marketorders/setup/marketorders.install.php b/plugins/marketorders/setup/marketorders.install.php
new file mode 100644
index 0000000..f9193fa
--- /dev/null
+++ b/plugins/marketorders/setup/marketorders.install.php
@@ -0,0 +1,22 @@
+fieldExists($db_market_orders, "order_email"))
+{
+ $db->query("ALTER TABLE `$db_market_orders` ADD COLUMN `order_email` varchar(255) collate utf8_unicode_ci NOT NULL");
+}
diff --git a/plugins/marketorders/setup/patch_1.0.2.inc b/plugins/marketorders/setup/patch_1.0.2.inc
new file mode 100644
index 0000000..b740176
--- /dev/null
+++ b/plugins/marketorders/setup/patch_1.0.2.inc
@@ -0,0 +1,27 @@
+fieldExists($db_market_orders, "order_seller"))
+{
+ $db->query("ALTER TABLE `$db_market_orders` ADD COLUMN `order_seller` int(11) NOT NULL");
+}
+
+$marketorders = $db->query("SELECT * FROM $db_market_orders AS o
+ LEFT JOIN $db_market AS m ON m.item_id=o.order_pid
+ WHERE 1")->fetchAll();
+foreach ($marketorders as $marketorder)
+{
+ if($marketorder['item_userid'] > 0)
+ {
+ $db->update($db_market_orders, array('order_seller' => $marketorder['item_userid']), 'order_id='.$marketorder['order_id']);
+ }
+}
diff --git a/plugins/marketorders/setup/patch_1.0.3.inc b/plugins/marketorders/setup/patch_1.0.3.inc
new file mode 100644
index 0000000..ea85788
--- /dev/null
+++ b/plugins/marketorders/setup/patch_1.0.3.inc
@@ -0,0 +1,15 @@
+
+
+
{BREADCRUMBS}
+
{PHP.L.marketorders_addclaim_title}
+
+
+
\ No newline at end of file
diff --git a/plugins/marketorders/tpl/marketorders.admin.home.tpl b/plugins/marketorders/tpl/marketorders.admin.home.tpl
new file mode 100644
index 0000000..81f53a1
--- /dev/null
+++ b/plugins/marketorders/tpl/marketorders.admin.home.tpl
@@ -0,0 +1,10 @@
+
+
{PHP.L.marketorders}
+
+
\ No newline at end of file
diff --git a/plugins/marketorders/tpl/marketorders.admin.tpl b/plugins/marketorders/tpl/marketorders.admin.tpl
new file mode 100644
index 0000000..11138c2
--- /dev/null
+++ b/plugins/marketorders/tpl/marketorders.admin.tpl
@@ -0,0 +1,38 @@
+
+
+
{PHP.L.marketorders_sales_title}
+
+
+
+
+
+
+
+
+
+
+
+
{PHP.L.marketorders_empty}
+
+
+
diff --git a/plugins/marketorders/tpl/marketorders.neworder.tpl b/plugins/marketorders/tpl/marketorders.neworder.tpl
new file mode 100644
index 0000000..1d49941
--- /dev/null
+++ b/plugins/marketorders/tpl/marketorders.neworder.tpl
@@ -0,0 +1,54 @@
+
+
+
{BREADCRUMBS}
+
{PHP.L.marketorders_neworder_title}
+
+
+
\ No newline at end of file
diff --git a/plugins/marketorders/tpl/marketorders.order.tpl b/plugins/marketorders/tpl/marketorders.order.tpl
new file mode 100644
index 0000000..4df004d
--- /dev/null
+++ b/plugins/marketorders/tpl/marketorders.order.tpl
@@ -0,0 +1,69 @@
+
+
+
{BREADCRUMBS}
+
{ORDER_LOCALSTATUS}
+
{PHP.L.marketorders_title} № {ORDER_ID}
+
+
+
diff --git a/plugins/marketorders/tpl/marketorders.purchases.tpl b/plugins/marketorders/tpl/marketorders.purchases.tpl
new file mode 100644
index 0000000..d0f7741
--- /dev/null
+++ b/plugins/marketorders/tpl/marketorders.purchases.tpl
@@ -0,0 +1,43 @@
+
+
{BREADCRUMBS}
+
{PHP.L.marketorders_purchases_title}
+
+
+
+
+
+
+
+
+
+
+
+
{PHP.L.marketorders_empty}
+
+
+
diff --git a/plugins/marketorders/tpl/marketorders.sales.tpl b/plugins/marketorders/tpl/marketorders.sales.tpl
new file mode 100644
index 0000000..6f3df57
--- /dev/null
+++ b/plugins/marketorders/tpl/marketorders.sales.tpl
@@ -0,0 +1,35 @@
+
+
{BREADCRUMBS}
+
{PHP.L.marketorders_sales_title}
+
+
+
+
+
+
+
+
+
+
+
+
{PHP.L.marketorders_empty}
+
+
+
\ No newline at end of file
diff --git a/plugins/mavatars/inc/mavatars.functions.php b/plugins/mavatars/inc/mavatars.functions.php
index de7e9e6..28d30db 100644
--- a/plugins/mavatars/inc/mavatars.functions.php
+++ b/plugins/mavatars/inc/mavatars.functions.php
@@ -108,8 +108,7 @@ protected function load_config_table()
);
}
}
- if (!$mav_cfg['__default']['__default'])
- {
+ if (empty($mav_cfg['__default']['__default'])) {
$def_photodir = $this->fix_path($cfg['photos_dir']);
$mav_cfg['__default']['__default'] = array(
'filepath' => $def_photodir,
@@ -180,16 +179,12 @@ private function mavatars_query()
{
global $db_mavatars, $db, $usr, $sys;
- if($this->mode == 'edit')
- {
- if($usr['id'] == 0)
- {
+ $query_string = '';
+ if ($this->mode == 'edit') {
+ if ($usr['id'] == 0) {
$query_string = " AND mav_sessid='".cot_import('PHPSESSID', 'C', 'TXT')."'";
- }
- else
- {
- if(!$usr['isadmin'])
- {
+ } else {
+ if(!$usr['isadmin']) {
$query_string = " AND mav_userid=".$usr['id'];
}
}
@@ -212,6 +207,7 @@ private function mavatars_query()
return "SELECT * FROM $db_mavatars WHERE mav_extension ='".$db->prep($this->extension)."' AND
mav_code = '".$db->prep($this->code)."' $query_string ORDER BY mav_order ASC, mav_item ASC";
}
+
private function mavatars_queryid($id)
{
global $db_mavatars, $db;
diff --git a/plugins/mavatars/mavatars.admin.php b/plugins/mavatars/mavatars.admin.php
index c896ca6..5763884 100644
--- a/plugins/mavatars/mavatars.admin.php
+++ b/plugins/mavatars/mavatars.admin.php
@@ -1,16 +1,14 @@
\ No newline at end of file
+//}
diff --git a/plugins/mavatars/mavatars.setup.php b/plugins/mavatars/mavatars.setup.php
index bcf1cbb..3768d8a 100644
--- a/plugins/mavatars/mavatars.setup.php
+++ b/plugins/mavatars/mavatars.setup.php
@@ -1,5 +1,4 @@
update($db_config, array('config_value' => $mavatars_set), "config_cat='mavatars' AND config_name='set'");
\ No newline at end of file
+$mavatars_set = isset(cot::$cfg['plugin']['mavatars']['set']) ? cot::$cfg['plugin']['mavatars']['set'] : '';
+$mavatars_set = $mavatars_set .
+ "\r\nprojects||datas/projects|datas/projects|0||\r\nmarket||datas/market|datas/market|0||\r\nfolio||datas/folio|datas/folio|0||";
+
+cot::$db->update(cot::$db->config, array('config_value' => $mavatars_set), "config_cat='mavatars' AND config_name='set'");
\ No newline at end of file
diff --git a/plugins/nullbilling/images/index.html b/plugins/nullbilling/images/index.html
new file mode 100644
index 0000000..eba420c
--- /dev/null
+++ b/plugins/nullbilling/images/index.html
@@ -0,0 +1,2 @@
+
Forbidden
+
\ No newline at end of file
diff --git a/plugins/nullbilling/inc/index.html b/plugins/nullbilling/inc/index.html
new file mode 100644
index 0000000..eba420c
--- /dev/null
+++ b/plugins/nullbilling/inc/index.html
@@ -0,0 +1,2 @@
+
Forbidden
+
\ No newline at end of file
diff --git a/plugins/nullbilling/inc/nullbilling.functions.php b/plugins/nullbilling/inc/nullbilling.functions.php
index 680988e..9760ea2 100644
--- a/plugins/nullbilling/inc/nullbilling.functions.php
+++ b/plugins/nullbilling/inc/nullbilling.functions.php
@@ -1,18 +1,16 @@
\ No newline at end of file
diff --git a/plugins/nullbilling/index.html b/plugins/nullbilling/index.html
new file mode 100644
index 0000000..eba420c
--- /dev/null
+++ b/plugins/nullbilling/index.html
@@ -0,0 +1,2 @@
+
Forbidden
+
\ No newline at end of file
diff --git a/plugins/nullbilling/lang/index.html b/plugins/nullbilling/lang/index.html
new file mode 100644
index 0000000..eba420c
--- /dev/null
+++ b/plugins/nullbilling/lang/index.html
@@ -0,0 +1,2 @@
+
Forbidden
+
\ No newline at end of file
diff --git a/plugins/nullbilling/lang/nullbilling.en.lang.php b/plugins/nullbilling/lang/nullbilling.en.lang.php
index 5bae922..9edbcea 100644
--- a/plugins/nullbilling/lang/nullbilling.en.lang.php
+++ b/plugins/nullbilling/lang/nullbilling.en.lang.php
@@ -1,24 +1,15 @@
here.';
\ No newline at end of file
+$L['nullbilling_title'] = 'Test (fake) payment system';
diff --git a/plugins/nullbilling/lang/nullbilling.ru.lang.php b/plugins/nullbilling/lang/nullbilling.ru.lang.php
index ea4a51c..64a1f76 100644
--- a/plugins/nullbilling/lang/nullbilling.ru.lang.php
+++ b/plugins/nullbilling/lang/nullbilling.ru.lang.php
@@ -1,24 +1,15 @@
ссылке.';
\ No newline at end of file
+$L['nullbilling_title'] = 'Тестовая платежная система (пустышка)';
diff --git a/plugins/nullbilling/nullbilling.admin.extensions.details.php b/plugins/nullbilling/nullbilling.admin.extensions.details.php
new file mode 100644
index 0000000..9a752bb
--- /dev/null
+++ b/plugins/nullbilling/nullbilling.admin.extensions.details.php
@@ -0,0 +1,32 @@
+assign([
+ 'ADMIN_EXTENSIONS_JUMPTO_URL' => $standalone,
+ ]);
+}
diff --git a/plugins/nullbilling/nullbilling.admin.extensions.plug.list.loop.php b/plugins/nullbilling/nullbilling.admin.extensions.plug.list.loop.php
new file mode 100644
index 0000000..f669068
--- /dev/null
+++ b/plugins/nullbilling/nullbilling.admin.extensions.plug.list.loop.php
@@ -0,0 +1,31 @@
+assign([
+ 'ADMIN_EXTENSIONS_JUMPTO_URL' => null,
+ ]);
+}
diff --git a/plugins/nullbilling/nullbilling.payments.billing.register.php b/plugins/nullbilling/nullbilling.payments.billing.register.php
index 9af547c..7923a66 100644
--- a/plugins/nullbilling/nullbilling.payments.billing.register.php
+++ b/plugins/nullbilling/nullbilling.payments.billing.register.php
@@ -1,25 +1,27 @@
'nullbilling',
- 'title' => $L['nullbilling_title'],
- 'icon' => $cfg['plugins_dir'] . '/nullbilling/images/nullbill.png'
-);
\ No newline at end of file
+ 'title' => Cot::$L['nullbilling_title'],
+ 'icon' => Cot::$cfg['plugins_dir'] . '/nullbilling/images/nullbill.png',
+];
\ No newline at end of file
diff --git a/plugins/nullbilling/nullbilling.php b/plugins/nullbilling/nullbilling.php
index e3c24be..346f76a 100644
--- a/plugins/nullbilling/nullbilling.php
+++ b/plugins/nullbilling/nullbilling.php
@@ -1,10 +1,12 @@
assign(array(
- "BILLING_TITLE" => $L['nullbilling_error_title'],
- "BILLING_ERROR" => $L['nullbilling_error_done']
- ));
-
- if($redirect){
- $t->assign(array(
- "BILLING_REDIRECT_TEXT" => sprintf($L['nullbilling_redirect_text'], $redirect),
- "BILLING_REDIRECT_URL" => $redirect,
- ));
- }
-
- $t->parse("MAIN.ERROR");
+
+// Получаем информацию о заказе
+$payment = PaymentRepository::getInstance()->getById($pid);
+if ($payment === null) {
+ cot_die_message(404);
}
-elseif ($m == 'fail')
-{
- $t->assign(array(
- "BILLING_TITLE" => $L['nullbilling_error_title'],
- "BILLING_ERROR" => $L['nullbilling_error_fail']
- ));
- $t->parse("MAIN.ERROR");
+
+cot_block(Cot::$usr['id'] === $payment['pay_userid']);
+cot_block(in_array($payment['pay_status'], PaymentDictionary::ALLOW_PAYMENT_STATUSES, true));
+
+$paymentService = PaymentService::getInstance();
+
+// Изменяем статус "в процессе оплаты"
+$paymentService->setStatus($pid, PaymentDictionary::STATUS_PROCESS, 'nullbilling');
+
+// Изменяем статус "Оплачено"
+if ($paymentService->setStatus($pid, PaymentDictionary::STATUS_PAID, 'nullbilling')) {
+ cot_redirect($paymentService->getSuccessUrl($pid));
+} else {
+ cot_redirect($paymentService->getFailUrl($pid));
}
-?>
\ No newline at end of file
diff --git a/plugins/nullbilling/nullbilling.setup.php b/plugins/nullbilling/nullbilling.setup.php
index fb8c5b4..9a85086 100644
--- a/plugins/nullbilling/nullbilling.setup.php
+++ b/plugins/nullbilling/nullbilling.setup.php
@@ -1,35 +1,32 @@
\ No newline at end of file
diff --git a/plugins/nullbilling/tpl/nullbilling.tpl b/plugins/nullbilling/tpl/nullbilling.tpl
deleted file mode 100644
index e2134f3..0000000
--- a/plugins/nullbilling/tpl/nullbilling.tpl
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
{PHP.L.nullbilling_title}
-
-
-
{BILLING_TITLE}
- {BILLING_ERROR}
-
-
-
-
{BILLING_REDIRECT_TEXT}
-
-
-
-
-
-
\ No newline at end of file
diff --git a/plugins/orderform/lang/orderform.en.lang.php b/plugins/orderform/lang/orderform.en.lang.php
new file mode 100644
index 0000000..4b5ee43
--- /dev/null
+++ b/plugins/orderform/lang/orderform.en.lang.php
@@ -0,0 +1,64 @@
+query("SELECT item_title as title, item_id as id, u.* FROM $db_market AS m
+ LEFT JOIN $db_users AS u ON u.user_id=m.item_userid
+ WHERE item_id=".$code)->fetch();
+ break;
+ case 'products':
+ require_once cot_langfile('products', 'module');
+ $item = $db->query("SELECT prd_title as title, prd_id as id, u.* FROM $db_products AS p
+ LEFT JOIN $db_users AS u ON u.user_id=p.prd_ownerid
+ WHERE prd_id=".$code)->fetch();
+ break;
+}
+
+cot_block($item);
+
+if($a == 'send'){
+ $remail = cot_import('remail','P', 'TXT', 64, TRUE);
+ $rname = cot_import('rname', 'P', 'TXT');
+ $rphone = cot_import('rphone', 'P', 'TXT');
+ $rquantity = cot_import('rquantity', 'P', 'INT');
+ $rcomment = cot_import('rcomment', 'P', 'TXT');
+
+ cot_check($usr['id'] == 0 && !cot_check_email($remail), 'orderform_error_email', 'remail');
+ cot_check(empty($rname), 'orderform_error_name', 'rname');
+ cot_check(empty($rphone), 'orderform_error_phone', 'rphone');
+ cot_check(empty($rquantity), 'orderform_error_quantity', 'rquantity');
+// cot_check(empty($rcomment), 'orderform_error_comment', 'rcomment');
+
+ if(!cot_error_found()){
+
+ $remail = ($usr['id']) ? $usr['profile']['user_email'] : $remail;
+
+ $headers = ("From: \"" . $rname . "\" <" . $remail . ">\n");
+ $context = array(
+ 'sitetitle' => $cfg["maintitle"],
+ 'siteurl' => $cfg['mainurl'],
+ 'name' => $rname,
+ 'email' => $remail,
+ 'phone' => $rphone,
+ 'product_title' => $item['title'],
+ 'product_url' => $cfg['mainurl'].'/'.cot_url($area, 'id='.$item['id'], '', true),
+ 'quantity' => $rquantity,
+ 'comment' => $rcomment
+ );
+
+ // Отправка продавцу
+ $rsubject = $L['orderform_subject_seller'];
+ $rbody = cot_rc($L['orderform_body_seller'], $context);
+ cot_mail($item['user_email'], $rsubject, $rbody, $headers);
+
+ // Отправка покупателю
+ $rsubject = $L['orderform_subject_customer'];
+ $rbody = cot_rc($L['orderform_body_customer'], $context);
+ cot_mail($remail, $rsubject, $rbody);
+
+ // Отправка админу
+ $rsubject = $L['orderform_subject_admin'];
+ $rbody = cot_rc($L['orderform_body_admin'], $context);
+ cot_mail($cfg['adminemail'], $rsubject, $rbody);
+
+ cot_message('orderform_sent');
+ }
+
+ cot_redirect(cot_url('orderform', 'area='.$area.'&code='.$code, '', true));
+}
+
+$t = new XTemplate(cot_tplfile(array('orderform', $area), 'plug'));
+
+$t->assign(array(
+ 'ORDERFORM_ACTION' => cot_url('orderform', 'area='.$area.'&code='.$code.'&a=send'),
+ 'ORDERFORM_FORM_EMAIL' => cot_inputbox('text', 'remail', $remail, 'size="56" class="form-control"'),
+ 'ORDERFORM_FORM_NAME' => cot_inputbox('text', 'rname', $rname, 'size="56" class="form-control"'),
+ 'ORDERFORM_FORM_PHONE' => cot_inputbox('text', 'rphone', $rphone, 'size="56" class="form-control"'),
+ 'ORDERFORM_FORM_QUANTITY' => cot_inputbox('text', 'rquantity', $rquantity, 'size="56" class="form-control"'),
+ 'ORDERFORM_FORM_COMMENT' => cot_textarea('rcomment', $rcomment, 10, 60, 'id="formtext"', '', 'class="form-control"'),
+));
+
+switch ($area){
+ case 'market':
+ $t->assign(cot_generate_markettags($item['id'], 'PRD_', $cfg['market']['shorttextlen'], $usr['isadmin'], $cfg['homebreadcrumb']));
+ break;
+ case 'products':
+ $t->assign(cot_generate_prdtags($item['id'], 'PRD_', 0, $usr['isadmin'], $cfg['homebreadcrumb']));
+ break;
+}
+
+cot_display_messages($t);
\ No newline at end of file
diff --git a/plugins/orderform/orderform.png b/plugins/orderform/orderform.png
new file mode 100644
index 0000000..4e00955
Binary files /dev/null and b/plugins/orderform/orderform.png differ
diff --git a/plugins/orderform/orderform.setup.php b/plugins/orderform/orderform.setup.php
new file mode 100644
index 0000000..fd5af2b
--- /dev/null
+++ b/plugins/orderform/orderform.setup.php
@@ -0,0 +1,25 @@
+
\ No newline at end of file
diff --git a/plugins/orderform/tpl/orderform.tpl b/plugins/orderform/tpl/orderform.tpl
new file mode 100644
index 0000000..6258a20
--- /dev/null
+++ b/plugins/orderform/tpl/orderform.tpl
@@ -0,0 +1,47 @@
+
+
+
{PHP.L.orderform_title}
+
+{FILE "{PHP.cfg.themes_dir}/{PHP.cfg.defaulttheme}/warnings.tpl"}
+
+
+
\ No newline at end of file
diff --git a/plugins/paymarketbold/inc/paymarketbold.functions.php b/plugins/paymarketbold/inc/paymarketbold.functions.php
new file mode 100644
index 0000000..afdc170
--- /dev/null
+++ b/plugins/paymarketbold/inc/paymarketbold.functions.php
@@ -0,0 +1,17 @@
+
\ No newline at end of file
diff --git a/plugins/paymarketbold/lang/paymarketbold.en.lang.php b/plugins/paymarketbold/lang/paymarketbold.en.lang.php
new file mode 100644
index 0000000..32c6b17
--- /dev/null
+++ b/plugins/paymarketbold/lang/paymarketbold.en.lang.php
@@ -0,0 +1,27 @@
+Extend";
\ No newline at end of file
diff --git a/plugins/paymarketbold/lang/paymarketbold.ru.lang.php b/plugins/paymarketbold/lang/paymarketbold.ru.lang.php
new file mode 100644
index 0000000..b7a5cf5
--- /dev/null
+++ b/plugins/paymarketbold/lang/paymarketbold.ru.lang.php
@@ -0,0 +1,27 @@
+Продлить";
\ No newline at end of file
diff --git a/plugins/paymarketbold/paymarketbold.global.php b/plugins/paymarketbold/paymarketbold.global.php
new file mode 100644
index 0000000..7feae98
--- /dev/null
+++ b/plugins/paymarketbold/paymarketbold.global.php
@@ -0,0 +1,34 @@
+query("SELECT item_bold FROM $db_market WHERE item_id=" . $pay['pay_code'])->fetch();
+ $initialtime = ($adv['item_bold'] > $sys['now']) ? $adv['item_bold'] : $sys['now'];
+ $rboldexpire = $initialtime + $pay['pay_time'];
+
+ if (cot_payments_updatestatus($pay['pay_id'], 'done'))
+ {
+ $db->update($db_market, array('item_bold' => (int)$rboldexpire), "item_id=".(int)$pay['pay_code']);
+
+ /* === Hook === */
+ foreach (cot_getextplugins('paymarketbold.done') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+ }
+ }
+}
\ No newline at end of file
diff --git a/plugins/paymarketbold/paymarketbold.markettags.main.php b/plugins/paymarketbold/paymarketbold.markettags.main.php
new file mode 100644
index 0000000..0fb4938
--- /dev/null
+++ b/plugins/paymarketbold/paymarketbold.markettags.main.php
@@ -0,0 +1,28 @@
+ $sys['now'])
+{
+ $temp_array['PAYBOLD'] = sprintf($L['paymarketbold_buy_prodlit'], cot_date('d.m.Y H:i',$item_data['item_bold']), cot_url('plug', 'e=paymarketbold&id='.$item_data['item_id']));
+ $temp_array['BOLD'] = $item_data['item_bold'];
+ $temp_array['ISBOLD'] = 1;
+}
+else
+{
+ if($item_data['item_bold'] > 0)
+ {
+ $db->query("UPDATE $db_market SET item_bold=0 WHERE item_id=".$item_data['item_id']);
+ }
+
+ $temp_array['PAYBOLD'] = cot_rc_link(cot_url('plug', 'e=paymarketbold&id='.$item_data['item_id']), $L['paymarketbold_buy_title']);
+ $temp_array['BOLD'] = 0;
+ $temp_array['ISBOLD'] = 0;
+}
\ No newline at end of file
diff --git a/plugins/paymarketbold/paymarketbold.php b/plugins/paymarketbold/paymarketbold.php
new file mode 100644
index 0000000..75685f0
--- /dev/null
+++ b/plugins/paymarketbold/paymarketbold.php
@@ -0,0 +1,46 @@
+fieldExists($db_payments, "pay_redirect")){
+ $options['redirect'] = $cfg['mainurl'].'/'.cot_url('payments', 'm=balance', '', true);
+ }
+
+ cot_payments_create_order('market.bold', $summ, $options);
+ }
+}
+
+$t = new XTemplate(cot_tplfile('paymarketbold', 'plug'));
+
+cot_display_messages($t);
+
+$t->assign(array(
+ 'PAY_FORM_ACTION' => cot_url('plug', 'e=paymarketbold&a=buy&id='.$id),
+ 'PAY_FORM_PERIOD' => cot_selectbox('', 'days', range(1, 30), range(1, 30), false),
+));
\ No newline at end of file
diff --git a/plugins/paymarketbold/paymarketbold.png b/plugins/paymarketbold/paymarketbold.png
new file mode 100644
index 0000000..cdc4b55
Binary files /dev/null and b/plugins/paymarketbold/paymarketbold.png differ
diff --git a/plugins/paymarketbold/paymarketbold.setup.php b/plugins/paymarketbold/paymarketbold.setup.php
new file mode 100644
index 0000000..aa4236a
--- /dev/null
+++ b/plugins/paymarketbold/paymarketbold.setup.php
@@ -0,0 +1,34 @@
+
Не устанавливать без конкретной необходимости, может вызывать конфликты с добавлением товара [
Документация по плагину, помощь, поддержка ]
+ * Version=1.0.1
+ * Date=
+ * Author=CMSWorks Team
+ * Copyright=Copyright
+ * Notes=
+ * Auth_guests=R
+ * Lock_guests=12345A
+ * Auth_members=RW
+ * Lock_members=12345A
+ * Requires_modules=payments,market
+ * Requires_plugins=
+ * [END_COT_EXT]
+ *
+ * [BEGIN_COT_EXT_CONFIG]
+ * cost=01:string::100:Стоимость за день размещения
+ * [END_COT_EXT_CONFIG]
+ */
+
+/**
+ * paymarketbold Plugin
+ *
+ * @package paymarketbold
+ * @version 1.0.1
+ * @author CMSWorks Team
+ * @copyright Copyright (c)
+ * @license BSD
+ */
\ No newline at end of file
diff --git a/plugins/paymarketbold/setup/paymarketbold.install.php b/plugins/paymarketbold/setup/paymarketbold.install.php
new file mode 100644
index 0000000..f1fb2b7
--- /dev/null
+++ b/plugins/paymarketbold/setup/paymarketbold.install.php
@@ -0,0 +1,22 @@
+fieldExists($db_market, "item_bold"))
+{
+ $dbres = $db->query("ALTER TABLE `$db_market` ADD COLUMN `item_bold` int(10) NOT NULL");
+}
\ No newline at end of file
diff --git a/plugins/paymarketbold/setup/paymarketbold.uninstall.php b/plugins/paymarketbold/setup/paymarketbold.uninstall.php
new file mode 100644
index 0000000..afc0f48
--- /dev/null
+++ b/plugins/paymarketbold/setup/paymarketbold.uninstall.php
@@ -0,0 +1,22 @@
+fieldExists($db_market, "item_bold"))
+{
+ $db->query("ALTER TABLE `$db_market` DROP COLUMN `item_bold`");
+}
\ No newline at end of file
diff --git a/plugins/paymarketbold/tpl/paymarketbold.tpl b/plugins/paymarketbold/tpl/paymarketbold.tpl
new file mode 100644
index 0000000..f849fc0
--- /dev/null
+++ b/plugins/paymarketbold/tpl/paymarketbold.tpl
@@ -0,0 +1,25 @@
+
+
+
{PHP.L.paymarketbold_buy_title}
+
+{FILE "{PHP.cfg.themes_dir}/{PHP.cfg.defaulttheme}/warnings.tpl"}
+
+
+
\ No newline at end of file
diff --git a/plugins/paymarkettop/Thumbs.db b/plugins/paymarkettop/Thumbs.db
new file mode 100644
index 0000000..ac7f171
Binary files /dev/null and b/plugins/paymarkettop/Thumbs.db differ
diff --git a/plugins/paymarkettop/inc/paymarkettop.functions.php b/plugins/paymarkettop/inc/paymarkettop.functions.php
new file mode 100644
index 0000000..9ebec04
--- /dev/null
+++ b/plugins/paymarkettop/inc/paymarkettop.functions.php
@@ -0,0 +1,15 @@
+Extend";
\ No newline at end of file
diff --git a/plugins/paymarkettop/lang/paymarkettop.ru.lang.php b/plugins/paymarkettop/lang/paymarkettop.ru.lang.php
new file mode 100644
index 0000000..a5e89f9
--- /dev/null
+++ b/plugins/paymarkettop/lang/paymarkettop.ru.lang.php
@@ -0,0 +1,27 @@
+Продлить";
\ No newline at end of file
diff --git a/plugins/paymarkettop/paymarkettop.global.php b/plugins/paymarkettop/paymarkettop.global.php
new file mode 100644
index 0000000..9c743e7
--- /dev/null
+++ b/plugins/paymarkettop/paymarkettop.global.php
@@ -0,0 +1,34 @@
+query("SELECT item_top FROM $db_market WHERE item_id=" . $pay['pay_code'])->fetch();
+ $initialtime = ($adv['item_top'] > $sys['now']) ? $adv['item_top'] : $sys['now'];
+ $rtopexpire = $initialtime + $pay['pay_time'];
+
+ if (cot_payments_updatestatus($pay['pay_id'], 'done'))
+ {
+ $db->update($db_market, array('item_top' => (int)$rtopexpire), "item_id=".(int)$pay['pay_code']);
+
+ /* === Hook === */
+ foreach (cot_getextplugins('paymrttop.done') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+ }
+ }
+}
\ No newline at end of file
diff --git a/plugins/paymarkettop/paymarkettop.market.list.query.php b/plugins/paymarkettop/paymarkettop.market.list.query.php
new file mode 100644
index 0000000..338397c
--- /dev/null
+++ b/plugins/paymarkettop/paymarkettop.market.list.query.php
@@ -0,0 +1,14 @@
+ $sys['now'])
+{
+ $temp_array['PAYTOP'] = sprintf($L['paymarkettop_buy_prodlit'], cot_date('d.m.Y H:i',$item_data['item_top']), cot_url('plug', 'e=paymarkettop&id='.$item_data['item_id']));
+ $temp_array['TOP'] = $item_data['item_top'];
+ $temp_array['ISTOP'] = 1;
+}
+else
+{
+ if($item_data['item_top'] > 0)
+ {
+ $db->query("UPDATE $db_market SET item_top=0 WHERE item_id=".$item_data['item_id']);
+ }
+
+ $temp_array['PAYTOP'] = cot_rc_link(cot_url('plug', 'e=paymarkettop&id='.$item_data['item_id']), $L['paymarkettop_buy_title']);
+ $temp_array['TOP'] = 0;
+ $temp_array['ISTOP'] = 0;
+}
\ No newline at end of file
diff --git a/plugins/paymarkettop/paymarkettop.php b/plugins/paymarkettop/paymarkettop.php
new file mode 100644
index 0000000..be2a0f6
--- /dev/null
+++ b/plugins/paymarkettop/paymarkettop.php
@@ -0,0 +1,58 @@
+ $d) {
+ $minus = ($cfg['plugin']['paymarkettop']['cost'] / 100) * $d;
+ $t->assign('PAY_FORM_PERIOD_COST_'.$i, ($cfg['plugin']['paymarkettop']['cost'] - $minus) * $i);
+ $t->assign('PAY_FORM_PERIOD_OLD_COST_'.$i, ($cfg['plugin']['paymarkettop']['cost']) * $i);
+ $t->assign('PAY_FORM_PERIOD_DISCOUNT_'.$i, $d);
+}
+
+$t->assign(array(
+ 'PAY_FORM_ACTION' => cot_url('plug', 'e=paymarkettop&a=buy&id='.$id),
+ 'PAY_FORM_PERIOD' => cot_selectbox('', 'days', range(1, 30), range(1, 30), false),
+));
\ No newline at end of file
diff --git a/plugins/paymarkettop/paymarkettop.png b/plugins/paymarkettop/paymarkettop.png
new file mode 100644
index 0000000..081c6be
Binary files /dev/null and b/plugins/paymarkettop/paymarkettop.png differ
diff --git a/plugins/paymarkettop/paymarkettop.setup.php b/plugins/paymarkettop/paymarkettop.setup.php
new file mode 100644
index 0000000..0a07861
--- /dev/null
+++ b/plugins/paymarkettop/paymarkettop.setup.php
@@ -0,0 +1,35 @@
+
+ {PRD_ROW_PAYTOP}
+
+
+ market.list.tpl:
+ ?
+ 1
+ 2
+ 3
+
+
+ {PRD_ROW_PAYTOP}
+
+
+ market.tpl:
+ ?
+ 1
+ 2
+ 3
+
+
+ {PRD_PAYTOP}
+
+
+ .
+
+ -, .
+ market.list.tpl , , , :
+ ?
+ 1
+
+
+
+ css - .prdtop, :
+ ?
+ 1
+
+ .prdtop { background-color: #feefb3; }
\ No newline at end of file
diff --git a/plugins/paymarkettop/setup/paymarkettop.install.php b/plugins/paymarkettop/setup/paymarkettop.install.php
new file mode 100644
index 0000000..3924ebe
--- /dev/null
+++ b/plugins/paymarkettop/setup/paymarkettop.install.php
@@ -0,0 +1,22 @@
+fieldExists($db_market, "item_top"))
+{
+ $dbres = $db->query("ALTER TABLE `$db_market` ADD COLUMN `item_top` int(10) NOT NULL");
+}
\ No newline at end of file
diff --git a/plugins/paymarkettop/setup/paymarkettop.uninstall.php b/plugins/paymarkettop/setup/paymarkettop.uninstall.php
new file mode 100644
index 0000000..4458716
--- /dev/null
+++ b/plugins/paymarkettop/setup/paymarkettop.uninstall.php
@@ -0,0 +1,22 @@
+fieldExists($db_market, "item_top"))
+{
+ $db->query("ALTER TABLE `$db_market` DROP COLUMN `item_top`");
+}
\ No newline at end of file
diff --git a/plugins/paymarkettop/tpl/paymarkettop.tpl b/plugins/paymarkettop/tpl/paymarkettop.tpl
new file mode 100644
index 0000000..be694fc
--- /dev/null
+++ b/plugins/paymarkettop/tpl/paymarkettop.tpl
@@ -0,0 +1,25 @@
+
+
+
{PHP.L.paymarkettop_buy_title}
+
+{FILE "{PHP.cfg.themes_dir}/{PHP.cfg.defaulttheme}/warnings.tpl"}
+
+
+
\ No newline at end of file
diff --git a/plugins/payorders/README.md b/plugins/payorders/README.md
new file mode 100644
index 0000000..2f08674
--- /dev/null
+++ b/plugins/payorders/README.md
@@ -0,0 +1,18 @@
+Плагин для выставления произвольных счетов через модуль Payments для Cotonti
+
+Разработчик: Булат Юсупов support@cmsworks.ru
+
+Copyright CMSWorks Team 2015
+
+Плагин PayOrders позволяет выставлять произвольные счета пользователям через админ-панель сайта. Подойдет для сайтов, которые оказывают различные услуги своим посетителям. Также аналогичное решение используется на этом сайте.
+
+При создании счета администратор указывает логин получателя, наименование счета и сумму для оплаты. После того как счет создан, на почту пользователя высылается уведомление со ссылкой на оплату счета. После оплаты счета администратору высылается уведомление об успешной оплате.
+
+Порядок установки:
+
+Распакуйте исходники в папку plugins вашего сайта.
+Зайдите в панель администратора и установите данный плагин.
+В админке плагина выводится список созданных счетов, их статусы и форма для создания новых счетов.
+При необходимости вы можете разместить ссылку на выставленные счета пользователя в любом месте на сайте:
+
+\
Счета на оплату\
diff --git a/plugins/payorders/inc/payorders.functions.php b/plugins/payorders/inc/payorders.functions.php
new file mode 100644
index 0000000..71eeac6
--- /dev/null
+++ b/plugins/payorders/inc/payorders.functions.php
@@ -0,0 +1,16 @@
+query("SELECT * FROM $db_users WHERE user_name='".$username."'")->fetch();
+
+ cot_check(empty($desc), 'payorders_error_desc');
+ cot_check($summ <= 0, 'payorders_error_summ');
+ cot_check(empty($urr), 'payorders_error_userempty');
+
+ if(!cot_error_found()){
+
+ $payinfo['pay_userid'] = $urr['user_id'];
+ $payinfo['pay_desc'] = $desc;
+ $payinfo['pay_area'] = 'payorders';
+ $payinfo['pay_summ'] = $summ;
+ $payinfo['pay_cdate'] = $sys['now'];
+ $payinfo['pay_status'] = 'new';
+
+ $db->insert($db_payments, $payinfo);
+ $id = $db->lastInsertId();
+
+ $subject = $L['payorders_email_neworderinfo_subject'];
+ $body = sprintf($L['payorders_email_neworderinfo_body'], $urr['user_name'], $id, $desc, COT_ABSOLUTE_URL . cot_url('payorders', '', '', true));
+ cot_mail($urr['user_email'], $subject, $body);
+ }
+ cot_redirect(cot_url('admin', 'm=other&p=payorders', '', true));
+}
+
+if($a == 'delete'){
+ $db->delete($db_payments, "pay_id=?", array($id));
+ cot_redirect(cot_url('admin', 'm=other&p=payorders', '', true));
+}
+
+$payorders = $db->query("SELECT * FROM $db_payments AS p
+ LEFT JOIN $db_users AS u ON u.user_id=p.pay_userid
+ WHERE pay_area='payorders' ORDER BY pay_cdate DESC")->fetchAll();
+foreach ($payorders as $ord){
+ $t->assign(cot_generate_usertags($ord, 'ORD_ROW_USER_'));
+ $t->assign(array(
+ 'ORD_ROW_ID' => $ord['pay_id'],
+ 'ORD_ROW_DESC' => $ord['pay_desc'],
+ 'ORD_ROW_CDATE' => $ord['pay_cdate'],
+ 'ORD_ROW_PDATE' => $ord['pay_pdate'],
+ 'ORD_ROW_SUMM' => $ord['pay_summ'],
+ 'ORD_ROW_STATUS' => $ord['pay_status'],
+ ));
+ $t->parse('MAIN.ORD_ROW');
+}
+
+cot_display_messages($t);
+
+
+$t->assign(array(
+ 'ORD_FORM_ACTION_URL' => cot_url('admin', 'm=other&p=payorders&a=add'),
+ 'ORD_FORM_SUMM' => cot_inputbox('text', 'summ', $summ),
+ 'ORD_FORM_DESC' => cot_inputbox('text', 'desc', $desc),
+));
+
+$t->parse('MAIN');
+$adminMain = $t->text('MAIN');
\ No newline at end of file
diff --git a/plugins/payorders/payorders.global.php b/plugins/payorders/payorders.global.php
new file mode 100644
index 0000000..91e3d70
--- /dev/null
+++ b/plugins/payorders/payorders.global.php
@@ -0,0 +1,42 @@
+query("SELECT * FROM $db_users WHERE user_id=".$pay['pay_userid'])->fetch();
+
+ // отправляем пользователю детали операции на email
+ $usr['timezone'] = cot_timezone_offset($customer['user_timezone'], true);
+ $subject = $L['payorders_email_orderinfo_subject'];
+ $body = sprintf($L['payorders_email_orderinfo_body'], $customer['user_name'], $pay['pay_desc'], $pay['pay_summ'], $pay['pay_id'], cot_date('d.m.Y в H:i', $pay['pay_pdate']));
+ cot_mail($customer['user_email'], $subject, $body);
+
+ // отправляем админу детали операции на email
+ $subject = $L['payorders_email_orderinfo_admin_subject'];
+ $body = sprintf($L['payorders_email_orderinfo_admin_body'], $customer['user_name'], $pay['pay_desc'], $pay['pay_summ'], $pay['pay_id'], cot_date('d.m.Y в H:i', $pay['pay_pdate']));
+ cot_mail($cfg['adminemail'], $subject, $body);
+
+ /* === Hook === */
+ foreach (cot_getextplugins('payorders.done') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+ }
+ }
+}
\ No newline at end of file
diff --git a/plugins/payorders/payorders.php b/plugins/payorders/payorders.php
new file mode 100644
index 0000000..577aa93
--- /dev/null
+++ b/plugins/payorders/payorders.php
@@ -0,0 +1,21 @@
+query("SELECT * FROM $db_payments WHERE pay_area='payorders' AND pay_userid=".$usr['id'])->fetchAll();
+foreach($payorders as $ord)
+{
+ $t->assign(cot_generate_paytags($ord, 'ORD_ROW_'));
+ $t->parse('MAIN.ORD_ROW');
+}
\ No newline at end of file
diff --git a/plugins/payorders/payorders.png b/plugins/payorders/payorders.png
new file mode 100644
index 0000000..4ba1d85
Binary files /dev/null and b/plugins/payorders/payorders.png differ
diff --git a/plugins/payorders/payorders.setup.php b/plugins/payorders/payorders.setup.php
new file mode 100644
index 0000000..9505dc4
--- /dev/null
+++ b/plugins/payorders/payorders.setup.php
@@ -0,0 +1,24 @@
+
+
+
+
+
+ {ORD_ROW_ID}
+ {ORD_ROW_DESC}
+ {ORD_ROW_SUMM|number_format($this, '2', '.', ' ')} {PHP.L.valuta}
+ {ORD_ROW_USER_NAME}
+ {ORD_ROW_CDATE|cot_date('d.m.Y', $this)}
+ {ORD_ROW_PDATE|cot_date('d.m.Y', $this)}—
+ {ORD_ROW_STATUS}
+ {PHP.L.Delete}
+
+
+
+
+
{PHP.L.payorders_neworder_title}:
+{FILE "{PHP.cfg.themes_dir}/{PHP.cfg.defaulttheme}/warnings.tpl"}
+
+
+
\ No newline at end of file
diff --git a/plugins/payorders/tpl/payorders.tpl b/plugins/payorders/tpl/payorders.tpl
new file mode 100644
index 0000000..7dcc02d
--- /dev/null
+++ b/plugins/payorders/tpl/payorders.tpl
@@ -0,0 +1,36 @@
+
+
+
Счета на оплату
+
+
+
+
+ #
+ {PHP.L.payments_desc}
+ {PHP.L.payments_summ}
+ {PHP.L.payorders_date_create}
+ {PHP.L.payorders_date_paid}
+ {PHP.L.payorders_status}
+
+
+
+
+
+ {ORD_ROW_ID}
+ {ORD_ROW_DESC}
+ {ORD_ROW_SUMM|number_format($this, '2', '.', ' ')} {PHP.L.valuta}
+ {ORD_ROW_CDATE|cot_date('d.m.Y', $this)}
+ {ORD_ROW_PDATE|cot_date('d.m.Y', $this)}—
+
+
+ Оплачен
+
+ Оплатить
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/plugins/payprjbold/inc/index.html b/plugins/payprjbold/inc/index.html
new file mode 100644
index 0000000..eba420c
--- /dev/null
+++ b/plugins/payprjbold/inc/index.html
@@ -0,0 +1,2 @@
+
Forbidden
+
\ No newline at end of file
diff --git a/plugins/payprjbold/index.html b/plugins/payprjbold/index.html
new file mode 100644
index 0000000..eba420c
--- /dev/null
+++ b/plugins/payprjbold/index.html
@@ -0,0 +1,2 @@
+
Forbidden
+
\ No newline at end of file
diff --git a/plugins/payprjbold/lang/index.html b/plugins/payprjbold/lang/index.html
new file mode 100644
index 0000000..eba420c
--- /dev/null
+++ b/plugins/payprjbold/lang/index.html
@@ -0,0 +1,2 @@
+
Forbidden
+
\ No newline at end of file
diff --git a/plugins/payprjbold/payprjbold.global.php b/plugins/payprjbold/payprjbold.global.php
index fe84297..823416d 100644
--- a/plugins/payprjbold/payprjbold.global.php
+++ b/plugins/payprjbold/payprjbold.global.php
@@ -5,32 +5,34 @@
* Hooks=global
* [END_COT_EXT]
*/
+
+use cot\modules\payments\dictionaries\PaymentDictionary;
+use cot\modules\payments\Services\PaymentService;
+
defined('COT_CODE') or die('Wrong URL.');
require_once cot_incfile('payprjbold', 'plug');
require_once cot_incfile('projects', 'module');
require_once cot_incfile('payments', 'module');
-if ($pays = cot_payments_getallpays('prj.bold', 'paid'))
-{
- foreach ($pays as $pay)
- {
- $adv = $db->query("SELECT item_bold FROM $db_projects WHERE item_id=" . $pay['pay_code'])->fetch();
- $initialtime = ($adv['item_bold'] > $sys['now']) ? $adv['item_bold'] : $sys['now'];
+/**
+ * @todo правильнее обновлять статус используя хук 'payments.payment.success'
+ * @see \cot\modules\payments\Services\PaymentService::processSuccessPayment()
+ */
+if ($pays = cot_payments_getallpays('prj.bold', 'paid')) {
+ foreach ($pays as $pay) {
+ $adv = Cot::$db->query("SELECT item_bold FROM $db_projects WHERE item_id=" . $pay['pay_code'])->fetch();
+ $initialtime = ($adv['item_bold'] > Cot::$sys['now']) ? $adv['item_bold'] : Cot::$sys['now'];
$rboldexpire = $initialtime + $pay['pay_time'];
- if (cot_payments_updatestatus($pay['pay_id'], 'done'))
- {
- $db->update($db_projects, array('item_bold' => (int)$rboldexpire), "item_id=".(int)$pay['pay_code']);
+ if (PaymentService::getInstance()->setStatus($pay['pay_id'], PaymentDictionary::STATUS_DONE)) {
+ Cot::$db->update($db_projects, array('item_bold' => (int)$rboldexpire), "item_id=".(int)$pay['pay_code']);
/* === Hook === */
- foreach (cot_getextplugins('payprjbold.done') as $pl)
- {
+ foreach (cot_getextplugins('payprjbold.done') as $pl) {
include $pl;
}
/* ===== */
}
}
}
-
-?>
\ No newline at end of file
diff --git a/plugins/payprjbold/payprjbold.setup.php b/plugins/payprjbold/payprjbold.setup.php
index 862f590..c139f75 100644
--- a/plugins/payprjbold/payprjbold.setup.php
+++ b/plugins/payprjbold/payprjbold.setup.php
@@ -1,36 +1,34 @@
\ No newline at end of file
diff --git a/plugins/payprjbold/setup/index.html b/plugins/payprjbold/setup/index.html
new file mode 100644
index 0000000..eba420c
--- /dev/null
+++ b/plugins/payprjbold/setup/index.html
@@ -0,0 +1,2 @@
+
Forbidden
+
\ No newline at end of file
diff --git a/plugins/payprjbold/setup/patch_1.0.1.inc b/plugins/payprjbold/setup/patch_1.0.1.inc
new file mode 100644
index 0000000..880da95
--- /dev/null
+++ b/plugins/payprjbold/setup/patch_1.0.1.inc
@@ -0,0 +1,15 @@
+registerTable('projects');
+}
+
+Cot::$db->query('ALTER TABLE ' . Cot::$db->projects . ' MODIFY item_bold INT NOT NULL DEFAULT 0');
\ No newline at end of file
diff --git a/plugins/payprjbold/setup/payprjbold.install.php b/plugins/payprjbold/setup/payprjbold.install.php
index 8722f50..d487652 100644
--- a/plugins/payprjbold/setup/payprjbold.install.php
+++ b/plugins/payprjbold/setup/payprjbold.install.php
@@ -3,22 +3,24 @@
* Installation handler
*
* @package payprjbold
- * @version 1.0.0
- * @author CMSWorks Team
- * @copyright Copyright (c) CMSWorks.ru, littledev.ru
+ * @author CMSWorks Team, Cotonti team
+ * @copyright Copyright (c) CMSWorks.ru, littledev.ru, Cotonti team
* @license BSD
*/
+declare(strict_types=1);
+
defined('COT_CODE') or die('Wrong URL');
require_once cot_incfile('projects', 'module');
global $db_projects;
-// Add field if missing
-if (!$db->fieldExists($db_projects, "item_bold"))
-{
- $dbres = $db->query("ALTER TABLE `$db_projects` ADD COLUMN `item_bold` int(10) NOT NULL");
+if (empty($db_projects)) {
+ Cot::$db->registerTable('projects');
}
-?>
\ No newline at end of file
+// Add field if missing @todo миграцию
+if (!Cot::$db->fieldExists($db_projects, 'item_bold')) {
+ Cot::$db->query("ALTER TABLE $db_projects ADD COLUMN item_bold INT NOT NULL DEFAULT 0");
+}
diff --git a/plugins/payprjtop/payprjtop.global.php b/plugins/payprjtop/payprjtop.global.php
index f9ff350..2301b61 100644
--- a/plugins/payprjtop/payprjtop.global.php
+++ b/plugins/payprjtop/payprjtop.global.php
@@ -5,32 +5,35 @@
* Hooks=global
* [END_COT_EXT]
*/
+
+use cot\modules\payments\dictionaries\PaymentDictionary;
+use cot\modules\payments\Services\PaymentService;
+
defined('COT_CODE') or die('Wrong URL.');
require_once cot_incfile('payprjtop', 'plug');
require_once cot_incfile('projects', 'module');
require_once cot_incfile('payments', 'module');
-if ($pays = cot_payments_getallpays('prj.top', 'paid'))
-{
+/**
+ * @todo правильнее обновлять статус используя хук 'payments.payment.success'
+ * @see \cot\modules\payments\Services\PaymentService::processSuccessPayment()
+ */
+if ($pays = cot_payments_getallpays('prj.top', 'paid')) {
foreach ($pays as $pay)
{
- $adv = $db->query("SELECT item_top FROM $db_projects WHERE item_id=" . $pay['pay_code'])->fetch();
- $initialtime = ($adv['item_top'] > $sys['now']) ? $adv['item_top'] : $sys['now'];
+ $adv = Cot::$db->query("SELECT item_top FROM $db_projects WHERE item_id=" . $pay['pay_code'])->fetch();
+ $initialtime = ($adv['item_top'] > Cot::$sys['now']) ? $adv['item_top'] : Cot::$sys['now'];
$rtopexpire = $initialtime + $pay['pay_time'];
- if (cot_payments_updatestatus($pay['pay_id'], 'done'))
- {
- $db->update($db_projects, array('item_top' => (int)$rtopexpire), "item_id=".(int)$pay['pay_code']);
+ if (PaymentService::getInstance()->setStatus($pay['pay_id'], PaymentDictionary::STATUS_DONE)) {
+ Cot::$db->update($db_projects, array('item_top' => (int) $rtopexpire), "item_id=".(int)$pay['pay_code']);
/* === Hook === */
- foreach (cot_getextplugins('payprjtop.done') as $pl)
- {
+ foreach (cot_getextplugins('payprjtop.done') as $pl) {
include $pl;
}
/* ===== */
}
}
}
-
-?>
\ No newline at end of file
diff --git a/plugins/payprjtop/payprjtop.projects.userdetails.query.php b/plugins/payprjtop/payprjtop.projects.userdetails.query.php
index 0ec57ed..56aa246 100644
--- a/plugins/payprjtop/payprjtop.projects.userdetails.query.php
+++ b/plugins/payprjtop/payprjtop.projects.userdetails.query.php
@@ -9,6 +9,4 @@
require_once cot_incfile('payprjtop', 'plug');
-$orderby = 'item_top DESC, '.$orderby;
-
-?>
\ No newline at end of file
+$order = array_merge(['payprjtop' => 'item_top DESC'], $order ?? []);
diff --git a/plugins/payprjtop/payprjtop.projectstags.main.php b/plugins/payprjtop/payprjtop.projectstags.main.php
index 4a7675a..9e63ecb 100644
--- a/plugins/payprjtop/payprjtop.projectstags.main.php
+++ b/plugins/payprjtop/payprjtop.projectstags.main.php
@@ -26,5 +26,3 @@
$temp_array['TOP'] = 0;
$temp_array['ISTOP'] = 0;
}
-
-?>
\ No newline at end of file
diff --git a/plugins/payprjtop/payprjtop.setup.php b/plugins/payprjtop/payprjtop.setup.php
index ce6a2fd..7943fd7 100644
--- a/plugins/payprjtop/payprjtop.setup.php
+++ b/plugins/payprjtop/payprjtop.setup.php
@@ -5,10 +5,10 @@
* Name=Payprjtop
* Category=Payments
* Description=Услуга "Закрепить проект"
- * Version=1.0.1
+ * Version=1.0.2
* Date=
- * Author=CMSWorks Team
- * Copyright=Copyright (c) CMSWorks.ru, littledev.ru
+ * Author=CMSWorks Team, Cotonti team
+ * Copyright=Copyright (c) CMSWorks.ru, littledev.ru, Cotonti team
* Notes=
* Auth_guests=R
* Lock_guests=12345A
@@ -27,10 +27,7 @@
* PayPrjTop Plugin
*
* @package payprjtop
- * @version 1.0.1
- * @author CMSWorks Team
+ * @author CMSWorks Team
* @copyright Copyright (c) CMSWorks.ru, littledev.ru
* @license BSD
*/
-
-?>
\ No newline at end of file
diff --git a/plugins/payprjtop/setup/patch_1.0.2.inc b/plugins/payprjtop/setup/patch_1.0.2.inc
new file mode 100644
index 0000000..db688f1
--- /dev/null
+++ b/plugins/payprjtop/setup/patch_1.0.2.inc
@@ -0,0 +1,14 @@
+registerTable('projects');
+}
+
+Cot::$db->query('ALTER TABLE ' . Cot::$db->projects .' MODIFY item_top INT UNSIGNED NOT NULL DEFAULT 0');
\ No newline at end of file
diff --git a/plugins/payprjtop/setup/payprjtop.install.php b/plugins/payprjtop/setup/payprjtop.install.php
index 57e6a49..46fb65b 100644
--- a/plugins/payprjtop/setup/payprjtop.install.php
+++ b/plugins/payprjtop/setup/payprjtop.install.php
@@ -15,10 +15,11 @@
global $db_projects;
-// Add field if missing
-if (!$db->fieldExists($db_projects, "item_top"))
-{
- $dbres = $db->query("ALTER TABLE `$db_projects` ADD COLUMN `item_top` int(10) NOT NULL");
+if (empty($db_projects)) {
+ Cot::$db->registerTable('projects');
}
-?>
\ No newline at end of file
+// Add field if missing
+if (!Cot::$db->fieldExists(Cot::$db->projects, "item_top")) {
+ Cot::$db->query('ALTER TABLE ' . Cot::$db->projects .' ADD COLUMN item_top INT UNSIGNED NOT NULL DEFAULT 0');
+}
diff --git a/plugins/paypro/inc/paypro.functions.php b/plugins/paypro/inc/paypro.functions.php
index ec94108..c7df045 100644
--- a/plugins/paypro/inc/paypro.functions.php
+++ b/plugins/paypro/inc/paypro.functions.php
@@ -23,30 +23,25 @@ function cot_getuserpro($user = '')
{
global $db, $db_users, $sys, $usr;
- if(empty($user) && $usr['profile']['user_pro'] > 0)
- {
+ $upro = 0;
+
+ if (empty($user) && isset(cot::$usr['profile']) && cot::$usr['profile']['user_pro'] > 0) {
$upro = $usr['profile']['user_pro'];
$userid = $usr['id'];
- }
- elseif(!empty($user) && !is_array($user))
- {
+ } elseif (!empty($user) && !is_array($user)) {
$upro = $db->query("SELECT user_pro FROM $db_users WHERE user_id=".$user)->fetchColumn();
$userid = $user;
- }
- elseif(is_array($user))
- {
+ } elseif(is_array($user)) {
$upro = $user['user_pro'];
$userid = $user['user_id'];
}
- if($upro > $sys['now'])
- {
+ if($upro > $sys['now']) {
return $upro;
- }
- elseif($upro > 0)
- {
+ } elseif($upro > 0) {
$db->update($db_users, array('user_pro' => 0), "user_id=".$userid);
}
+
return false;
}
@@ -70,7 +65,10 @@ function cot_getcountoffersofuser($userid)
list($year, $month, $day) = explode('-', @date('Y-m-d', $sys['now_offset']));
$currentday = cot_mktime(0, 0, 0, $month, $day, $year);
- $sql = $db->query("SELECT COUNT(*) as count FROM $db_projects_offers WHERE offer_userid=" . $userid . " AND offer_date<" . $sys['now_offset'] . " AND offer_date>" . $currentday . "");
+ $sql = $db->query(
+ "SELECT COUNT(*) as count FROM $db_projects_offers "
+ . " WHERE offer_userid=" . $userid . " AND offer_date<" . Cot::$sys['now'] . " AND offer_date>" . $currentday
+ );
$count = $sql->fetchColumn();
return $count;
diff --git a/plugins/paypro/lang/paypro.en.lang.php b/plugins/paypro/lang/paypro.en.lang.php
index 9856575..e2a525a 100644
--- a/plugins/paypro/lang/paypro.en.lang.php
+++ b/plugins/paypro/lang/paypro.en.lang.php
@@ -3,7 +3,6 @@
* Paypro plugin
*
* @package payrpo
- * @version 1.0
* @author CMSWorks Team
* @copyright Copyright (c) CMSWorks.ru, littledev.ru
* @license BSD
@@ -14,7 +13,7 @@
/**
* Module Config
*/
-$L['cfg_cost'] = array('Cosr per month', '');
+$L['cfg_cost'] = array('Cost per month', '');
$L['cfg_offerslimit'] = array('Offers limit count for simple users', '');
$L['cfg_projectslimit'] = array('Projects limit count for simple users', '');
@@ -35,8 +34,16 @@
$L['paypro_header_expire_short'] = 'PRO to';
$L['paypro_header_extend'] = 'Extend';
-$L['paypro_warning_projectslimit_empty'] = 'You can no longer publish projects. Maximum number of projects for the publication is: '.$cfg['plugin']['paypro']['projectslimit'].' night. To remove this restriction, use PRO-service account.';
-$L['paypro_warning_offerslimit_empty'] = 'You can no longer post project proposals. The maximum number of responses to the projects is: '.$cfg['plugin']['paypro']['offerslimit'].' night. To remove this restriction, use PRO-service account.';
+$tmpProjectLimit = !empty(cot::$cfg['plugin']['paypro']['projectslimit']) ?
+ cot::$cfg['plugin']['paypro']['projectslimit'] : 0;
+$L['paypro_warning_projectslimit_empty'] = 'You can no longer publish projects. Maximum number of projects for the publication is: ' .
+ $tmpProjectLimit . ' night. To remove this restriction, use PRO-service account.';
+
+$tmpOffersLimit = !empty(cot::$cfg['plugin']['paypro']['offerslimit']) ?
+ cot::$cfg['plugin']['paypro']['offerslimit'] : 0;
+$L['paypro_warning_offerslimit_empty'] = 'You can no longer post project proposals. The maximum number of responses to the projects is: ' .
+ $tmpOffersLimit . ' night. To remove this restriction, use PRO-service account.';
+
$L['paypro_warning_onlyforpro'] = 'You can not leave suggestions for this project, as it is only available for users with PRO-account. To remove this restriction, use PRO-service account.';
$L['paypro_error_username'] = 'Login empty';
diff --git a/plugins/paypro/lang/paypro.ru.lang.php b/plugins/paypro/lang/paypro.ru.lang.php
index 72d33b2..f0c9e73 100644
--- a/plugins/paypro/lang/paypro.ru.lang.php
+++ b/plugins/paypro/lang/paypro.ru.lang.php
@@ -3,7 +3,6 @@
* Paypro plugin
*
* @package paypro
- * @version 1.0
* @author CMSWorks Team
* @copyright Copyright (c) CMSWorks.ru, littledev.ru
* @license BSD
@@ -35,8 +34,16 @@
$L['paypro_header_expire_short'] = 'PRO до';
$L['paypro_header_extend'] = 'Продлить услугу';
-$L['paypro_warning_projectslimit_empty'] = 'Вы больше не можете публиковать проекты. Максимальное число проектов для публикации составляет: '.$cfg['plugin']['paypro']['projectslimit'].' в сутки. Чтобы снять это ограничение, воспользуйтесь услугой PRO-аккаунт.';
-$L['paypro_warning_offerslimit_empty'] = 'Вы больше не можете оставлять предложения по проектам. Максимальное число откликов на проекты составляет: '.$cfg['plugin']['paypro']['offerslimit'].' в сутки. Чтобы снять это ограничение, воспользуйтесь услугой PRO-аккаунт.';
+$tmpProjectLimit = !empty(cot::$cfg['plugin']['paypro']['projectslimit']) ?
+ cot::$cfg['plugin']['paypro']['projectslimit'] : 0;
+$L['paypro_warning_projectslimit_empty'] = 'Вы больше не можете публиковать проекты. Максимальное число проектов для публикации составляет: ' .
+ $tmpProjectLimit . ' в сутки. Чтобы снять это ограничение, воспользуйтесь услугой PRO-аккаунт.';
+
+$tmpOffersLimit = !empty(cot::$cfg['plugin']['paypro']['offerslimit']) ?
+ cot::$cfg['plugin']['paypro']['offerslimit'] : 0;
+$L['paypro_warning_offerslimit_empty'] = 'Вы больше не можете оставлять предложения по проектам. Максимальное число откликов на проекты составляет: ' .
+ $tmpOffersLimit . ' в сутки. Чтобы снять это ограничение, воспользуйтесь услугой PRO-аккаунт.';
+
$L['paypro_warning_onlyforpro'] = 'Вы не можете оставлять предложения по данному проекту, так как он доступен только для пользователей с PRO-аккаунтом. Чтобы снять это ограничение, воспользуйтесь услугой PRO-аккаунт.';
$L['paypro_error_username'] = 'Не указан логин пользователя';
diff --git a/plugins/paypro/paypro.admin.php b/plugins/paypro/paypro.admin.php
index 1c8e04b..2582884 100644
--- a/plugins/paypro/paypro.admin.php
+++ b/plugins/paypro/paypro.admin.php
@@ -1,5 +1,4 @@
query("SELECT * FROM $db_users WHERE user_name='" . $username . "'")->fetch();
@@ -67,4 +66,4 @@
}
$t->parse('MAIN');
-$adminmain = $t->text('MAIN');
\ No newline at end of file
+$adminMain = $t->text('MAIN');
\ No newline at end of file
diff --git a/plugins/paypro/paypro.global.php b/plugins/paypro/paypro.global.php
index 0292b91..fc790fe 100644
--- a/plugins/paypro/paypro.global.php
+++ b/plugins/paypro/paypro.global.php
@@ -5,33 +5,35 @@
* Hooks=global
* [END_COT_EXT]
*/
+
+use cot\modules\payments\dictionaries\PaymentDictionary;
+use cot\modules\payments\Services\PaymentService;
+
defined('COT_CODE') or die('Wrong URL.');
require_once cot_incfile('paypro', 'plug');
require_once cot_incfile('payments', 'module');
-// Проверяем платежки на оплату услуги PRO. Если есть то включаем услугу или продлеваем ее.
-if ($propays = cot_payments_getallpays('pro', 'paid'))
-{
- foreach ($propays as $pay)
- {
+/**
+ * Проверяем платежки на оплату услуги PRO. Если есть то включаем услугу или продлеваем ее.
+ * @todo правильнее обновлять статус используя хук 'payments.payment.success'
+ * @see PaymentService::processSuccessPayment()
+ */
+if ($propays = cot_payments_getallpays('pro', 'paid')) {
+ foreach ($propays as $pay) {
$userid = (!empty($pay['pay_code'])) ? $pay['pay_code'] : $pay['pay_userid'];
$upro = cot_getuserpro($userid);
- $initialtime = ($upro > $sys['now']) ? $upro : $sys['now'];
+ $initialtime = ($upro > cot::$sys['now']) ? $upro : cot::$sys['now'];
$rproexpire = $initialtime + $pay['pay_time'];
- if (cot_payments_updatestatus($pay['pay_id'], 'done'))
- {
- $db->update($db_users, array('user_pro' => (int)$rproexpire), "user_id=".(int)$userid);
+ if (PaymentService::getInstance()->setStatus($pay['pay_id'], PaymentDictionary::STATUS_DONE)) {
+ cot::$db->update($db_users, array('user_pro' => (int) $rproexpire), "user_id=" . (int) $userid);
/* === Hook === */
- foreach (cot_getextplugins('paypro.done') as $pl)
- {
+ foreach (cot_getextplugins('paypro.done') as $pl) {
include $pl;
}
/* ===== */
}
}
}
-
-?>
\ No newline at end of file
diff --git a/plugins/paypro/paypro.setup.php b/plugins/paypro/paypro.setup.php
index 6d82bef..2db6ccf 100644
--- a/plugins/paypro/paypro.setup.php
+++ b/plugins/paypro/paypro.setup.php
@@ -5,8 +5,8 @@
* Name=PayPro
* Category=Payments
* Description=Услуга PRO
- * Version=1.2.3
- * Date=
+ * Version=1.2.4
+ * Date=2022-09-08
* Author=CMSWorks Team
* Copyright=Copyright (c) CMSWorks.ru, littledev.ru
* Notes=
@@ -29,10 +29,7 @@
* PayPro Plugin
*
* @package paypro
- * @version 1.2.3
* @author CMSWorks Team
* @copyright Copyright (c) CMSWorks.ru, littledev.ru
* @license BSD
*/
-
-?>
\ No newline at end of file
diff --git a/plugins/paypro/paypro.users.query.php b/plugins/paypro/paypro.users.query.php
index 399e966..4f15aee 100644
--- a/plugins/paypro/paypro.users.query.php
+++ b/plugins/paypro/paypro.users.query.php
@@ -1,5 +1,4 @@
0) as ispro';
$sqlorder = "ispro DESC";
-
-?>
\ No newline at end of file
diff --git a/plugins/paypro/setup/paypro.install.php b/plugins/paypro/setup/paypro.install.php
index fd59177..0fd9003 100644
--- a/plugins/paypro/setup/paypro.install.php
+++ b/plugins/paypro/setup/paypro.install.php
@@ -11,17 +11,15 @@
defined('COT_CODE') or die('Wrong URL');
-global $db_users, $db_projects;
+global $db_users, $db_projects, $R;
require_once cot_incfile('projects', 'module');
require_once cot_incfile('extrafields');
// Add field if missing
-if (!$db->fieldExists($db_users, "user_pro"))
-{
- $dbres = $db->query("ALTER TABLE `$db_users` ADD COLUMN `user_pro` int(10) DEFAULT '0'");
+if (!cot::$db->fieldExists($db_users, "user_pro")) {
+ // Todo may be tinyint?
+ $dbres = cot::$db->query("ALTER TABLE `$db_users` ADD COLUMN `user_pro` int NULL DEFAULT 0");
}
cot_extrafield_add($db_projects, 'forpro', 'checkbox', $R['input_checkbox'],'','','','', '','');
-
-?>
\ No newline at end of file
diff --git a/plugins/paytop/paytop.admin.config.php b/plugins/paytop/paytop.admin.config.php
index 07c7aea..9836d6c 100644
--- a/plugins/paytop/paytop.admin.config.php
+++ b/plugins/paytop/paytop.admin.config.php
@@ -18,7 +18,11 @@
defined('COT_CODE') or die('Wrong URL');
require_once cot_incfile('paytop', 'plug');
-$adminhelp = $L['paytop_help'];
+
+if (!isset($adminHelp)) {
+ $adminHelp = '';
+}
+$adminHelp .= isset(cot::$L['paytop_help']) ? cot::$L['paytop_help'] : '';
if ($p == 'paytop' && $row['config_name'] == 'paytopareas' && $cfg['jquery'])
{
diff --git a/plugins/paytop/paytop.admin.php b/plugins/paytop/paytop.admin.php
index a6f785d..1445e83 100644
--- a/plugins/paytop/paytop.admin.php
+++ b/plugins/paytop/paytop.admin.php
@@ -113,4 +113,4 @@
));
$t->parse('MAIN');
-$adminmain = $t->text('MAIN');
+$adminMain = $t->text('MAIN');
diff --git a/plugins/paytop/paytop.global.php b/plugins/paytop/paytop.global.php
index 0c2a2fd..3100514 100644
--- a/plugins/paytop/paytop.global.php
+++ b/plugins/paytop/paytop.global.php
@@ -5,40 +5,47 @@
* Hooks=global
* [END_COT_EXT]
*/
+
+use cot\modules\payments\dictionaries\PaymentDictionary;
+use cot\modules\payments\Services\PaymentService;
+
defined('COT_CODE') or die('Wrong URL.');
require_once cot_incfile('paytop', 'plug');
require_once cot_incfile('payments', 'module');
-// Проверяем платежки на оплату услуги TOP. Если есть то включаем услугу или продлеваем ее.
+/**
+ * Проверяем платежки на оплату услуги TOP. Если есть то включаем услугу или продлеваем ее.
+ * @todo правильнее обновлять статус используя хук 'payments.payment.success'
+ * @see PaymentService::processSuccessPayment()
+ */
$pt_cfg = cot_cfg_paytop();
-foreach($pt_cfg as $area => $opt)
-{
- if ($toppays = cot_payments_getallpays('paytop.'.$area, 'paid'))
- {
- foreach ($toppays as $pay)
- {
- if (cot_payments_userservice('paytop.'.$area, $pay['pay_userid'], $pay['pay_time']))
- {
- if (cot_payments_updatestatus($pay['pay_id'], 'done'))
- {
- $urr = $db->query("SELECT * FROM $db_users WHERE user_id=".$pay['pay_userid'])->fetch();
+foreach($pt_cfg as $area => $opt) {
+ if ($toppays = cot_payments_getallpays('paytop.'.$area, 'paid')) {
+ foreach ($toppays as $pay) {
+ if (cot_payments_userservice('paytop.'.$area, $pay['pay_userid'], $pay['pay_time'])) {
+ if (PaymentService::getInstance()->setStatus($pay['pay_id'], PaymentDictionary::STATUS_DONE)) {
+ $urr = Cot::$db->query("SELECT * FROM $db_users WHERE user_id=".$pay['pay_userid'])->fetch();
// Отправка уведомления админу
- $subject = $L['paytop_mail_admin_subject'];
- $body = sprintf($L['paytop_mail_admin_body'], $urr['user_name'], $opt['name'], $pay['pay_id'], cot_date('d.m.Y в H:i', $sys['now']));
- cot_mail($cfg['adminemail'], $subject, $body);
+ $subject = Cot::$L['paytop_mail_admin_subject'];
+ $body = sprintf(
+ Cot::$L['paytop_mail_admin_body'],
+ $urr['user_name'],
+ $opt['name'],
+ $pay['pay_id'],
+ cot_date('d.m.Y в H:i', Cot::$sys['now'])
+ );
+ cot_mail(Cot::$cfg['adminemail'], $subject, $body);
/* === Hook === */
- foreach (cot_getextplugins('paytop.done') as $pl)
- {
+ foreach (cot_getextplugins('paytop.done') as $pl) {
include $pl;
}
/* ===== */
/* === Hook === */
- foreach (cot_getextplugins('paytop.'.$area.'.done') as $pl)
- {
+ foreach (cot_getextplugins('paytop.'.$area.'.done') as $pl) {
include $pl;
}
/* ===== */
diff --git a/plugins/prjcount/inc/prjcount.functions.php b/plugins/prjcount/inc/prjcount.functions.php
new file mode 100644
index 0000000..6473e95
--- /dev/null
+++ b/plugins/prjcount/inc/prjcount.functions.php
@@ -0,0 +1,32 @@
+query("SELECT COUNT(item_id) FROM {$db_projects} WHERE item_state= 0 AND item_userid = {$usr} {$realized}")->fetchColumn();
+
+ if(!$count || $count < 0){
+ $count = 0;
+ }
+
+ return $count;
+}
+
+function cot_prj_offers_published_count($usr){
+ global $db, $db_projects_offers;
+
+ $count = $db->query("SELECT COUNT(offer_id) FROM {$db_projects_offers} WHERE offer_userid = {$usr}")->fetchColumn();
+
+ if(!$count || $count < 0){
+ $count = 0;
+ }
+
+ return $count;
+}
\ No newline at end of file
diff --git a/plugins/prjcount/lang/prjcount.en.lang.php b/plugins/prjcount/lang/prjcount.en.lang.php
new file mode 100644
index 0000000..5ea6fe6
--- /dev/null
+++ b/plugins/prjcount/lang/prjcount.en.lang.php
@@ -0,0 +1,13 @@
+assign(array(
+ 'HEADER_USER_PRJ_PUBLISHED' => cot_prj_published_count($usr['id']),
+ 'HEADER_USER_PRJ_OFFERS_PUBLISHED' => cot_prj_offers_published_count($usr['id']),
+ ));
\ No newline at end of file
diff --git a/plugins/prjcount/prjcount.png b/plugins/prjcount/prjcount.png
new file mode 100644
index 0000000..46e9441
Binary files /dev/null and b/plugins/prjcount/prjcount.png differ
diff --git a/plugins/prjcount/prjcount.setup.php b/plugins/prjcount/prjcount.setup.php
new file mode 100644
index 0000000..cefbb93
--- /dev/null
+++ b/plugins/prjcount/prjcount.setup.php
@@ -0,0 +1,25 @@
+ /dev/null 2>&1
+
+
+В шапке сайта необходимо добавить ссылку на страницу подписки:
+
+\
{PHP.L.prjsender}\
diff --git a/plugins/prjsender/lang/prjsender.en.lang.php b/plugins/prjsender/lang/prjsender.en.lang.php
new file mode 100644
index 0000000..c1ed243
--- /dev/null
+++ b/plugins/prjsender/lang/prjsender.en.lang.php
@@ -0,0 +1,11 @@
+ 0){
+ $limit = "LIMIT ".$cfg['plugin']['prjsender']['limittosend'];
+}
+
+$users_sql = $db->query("SELECT * FROM $db_users WHERE user_prjsendercats!='-1' AND user_maingrp=4 AND user_prjsenderdate<".$sys['now']);
+while($urr = $users_sql->fetch())
+{
+ if(!empty($urr['user_prjsendercats'])){
+ $prjcats = explode(',', $urr['user_prjsendercats']);
+ $cats_string = "AND item_cat IN ('".implode("','", $prjcats)."')";
+ }
+
+ $prjs = $db->query("SELECT * FROM $db_projects AS p
+ LEFT JOIN $db_users AS u ON u.user_id=p.item_userid
+ WHERE item_state=0 ".$cats_string." AND item_userid!=".$urr['user_id']." AND item_date>".$urr['user_prjsenderdate']." ".$limit)->fetchAll();
+
+ if(is_array($prjs) && count($prjs) > 0)
+ {
+ $t = new XTemplate(cot_tplfile(array('prjsender', 'mail'), 'plug'));
+
+ foreach($prjs as $item)
+ {
+ $t->assign(cot_generate_usertags($item, 'PRJ_ROW_OWNER_'));
+ $t->assign(cot_generate_projecttags($item, 'PRJ_ROW_'));
+
+ $t->parse("MAIN.PRJ_ROWS");
+ }
+
+ $t->parse('MAIN');
+
+ cot_mail($urr['user_email'], $L['prjsender_mail_title'], $t->text('MAIN'), '', false, null, true);
+
+ $db->update($db_users, array('user_prjsenderdate' => $sys['now']), "user_id=".$urr['user_id']);
+ }
+}
\ No newline at end of file
diff --git a/plugins/prjsender/prjsender.global.php b/plugins/prjsender/prjsender.global.php
new file mode 100644
index 0000000..52364da
--- /dev/null
+++ b/plugins/prjsender/prjsender.global.php
@@ -0,0 +1,10 @@
+update($db_users, array('user_prjsendercats' => $rcats, 'user_prjsenderdate' => $sys['now']), "user_id=".$usr['id']);
+
+ cot_redirect(cot_url('prjsender', '', '', true));
+}
+
+$out['subtitle'] = $L['prjsender'];
+
+$mskin = cot_tplfile(array('prjsender'), 'plug');
+
+/* === Hook === */
+foreach (cot_getextplugins('prjsender.main') as $pl)
+{
+ include $pl;
+}
+/* ===== */
+
+$t = new XTemplate($mskin);
+
+if(!empty($usr['profile']['user_prjsendercats']) && $usr['profile']['user_prjsendercats'] != '-1')
+{
+ $rcats = explode(',', $usr['profile']['user_prjsendercats']);
+}elseif($usr['profile']['user_prjsendercats'] == '-1'){
+ $rcats = array();
+}else{
+ $rcats = $prjcats;
+}
+
+
+$t->assign(array(
+ 'PRJSENDER_FORM_ACTION' => cot_url('prjsender', 'a=update'),
+ 'PRJSENDER_FORM_CATS' => cot_checklistbox($rcats, 'cats', $prjcats, $prjcats_titles, '', '', false),
+));
+
+/* === Hook === */
+foreach (cot_getextplugins('prjsender.tags') as $pl)
+{
+ include $pl;
+}
+/* ===== */
+
+?>
\ No newline at end of file
diff --git a/plugins/prjsender/prjsender.png b/plugins/prjsender/prjsender.png
new file mode 100644
index 0000000..12be49d
Binary files /dev/null and b/plugins/prjsender/prjsender.png differ
diff --git a/plugins/prjsender/prjsender.setup.php b/plugins/prjsender/prjsender.setup.php
new file mode 100644
index 0000000..73fb14e
--- /dev/null
+++ b/plugins/prjsender/prjsender.setup.php
@@ -0,0 +1,27 @@
+ 0) {
+
+ $allcats = cot_structure_children('projects', '', true);
+ $prjcats = array();
+ $prjcats_titles = array();
+ foreach($allcats as $cat)
+ {
+ $prjcats[] = $cat;
+ }
+
+ $rcats = cot_import('cats', 'P', 'ARR');
+
+ if(count($rcats) == count($prjcats)) {
+ $rcats = '';
+ }elseif(!empty($rcats)){
+ $rcats = implode(',', $rcats);
+ }else{
+ $rcats = '-1';
+ }
+
+ $db->update($db_users, array('user_prjsendercats' => $rcats, 'user_prjsenderdate' => $sys['now']), "user_id=".$userid);
+}
\ No newline at end of file
diff --git a/plugins/prjsender/prjsender.users.register.tags.php b/plugins/prjsender/prjsender.users.register.tags.php
new file mode 100644
index 0000000..b701036
--- /dev/null
+++ b/plugins/prjsender/prjsender.users.register.tags.php
@@ -0,0 +1,24 @@
+ 0) {
+ $t->assign(array(
+ 'USERS_REGISTER_PRJSENDER_CATS' => cot_checklistbox($rcats, 'cats', $prjcats, $prjcats_titles, '', '', false),
+ ));
+}
\ No newline at end of file
diff --git a/plugins/prjsender/setup/patch_1.0.3.inc b/plugins/prjsender/setup/patch_1.0.3.inc
new file mode 100644
index 0000000..5f0d868
--- /dev/null
+++ b/plugins/prjsender/setup/patch_1.0.3.inc
@@ -0,0 +1,11 @@
+query(
+ 'ALTER TABLE ' . Cot::$db->users . ' MODIFY user_prjsenderdate INT NOT NULL DEFAULT 0; '
+ . 'ALTER TABLE ' . Cot::$db->users . ' MODIFY user_prjsendercats MEDIUMTEXT NULL DEFAULT NULL;'
+);
\ No newline at end of file
diff --git a/plugins/prjsender/setup/prjsender.install.php b/plugins/prjsender/setup/prjsender.install.php
new file mode 100644
index 0000000..4534a50
--- /dev/null
+++ b/plugins/prjsender/setup/prjsender.install.php
@@ -0,0 +1,15 @@
+fieldExists($db_users, 'user_prjsenderdate')) {
+ Cot::$db->query('ALTER TABLE ' . Cot::$db->users . ' ADD COLUMN user_prjsenderdate INT NOT NULL DEFAULT 0');
+}
+
+if (!Cot::$db->fieldExists($db_users, 'user_prjsendercats')) {
+ Cot::$db->query(
+ 'ALTER TABLE ' . Cot::$db->users . ' ADD COLUMN user_prjsendercats MEDIUMTEXT NULL DEFAULT NULL'
+ );
+}
\ No newline at end of file
diff --git a/plugins/prjsender/tpl/prjsender.mail.tpl b/plugins/prjsender/tpl/prjsender.mail.tpl
new file mode 100644
index 0000000..8be3e4a
--- /dev/null
+++ b/plugins/prjsender/tpl/prjsender.mail.tpl
@@ -0,0 +1,10 @@
+
+
+
+
+
{PRJ_ROW_DATE}
+
{PRJ_ROW_TEXT}
+
+
+
+
\ No newline at end of file
diff --git a/plugins/prjsender/tpl/prjsender.tpl b/plugins/prjsender/tpl/prjsender.tpl
new file mode 100644
index 0000000..e5b5a62
--- /dev/null
+++ b/plugins/prjsender/tpl/prjsender.tpl
@@ -0,0 +1,14 @@
+
+
+
{PHP.L.prjsender}
+
{PHP.L.prjsender_title}
+
+
{PHP.L.prjsender_desc}
+
+
+
+
\ No newline at end of file
diff --git a/plugins/profitstats/lang/profitstats.en.lang.php b/plugins/profitstats/lang/profitstats.en.lang.php
new file mode 100644
index 0000000..db305c2
--- /dev/null
+++ b/plugins/profitstats/lang/profitstats.en.lang.php
@@ -0,0 +1,45 @@
+query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='pro' AND pay_status='done' AND pay_adate >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY))")->fetch();
+ $paytop_summ = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='paytop.top' AND pay_status='done' AND pay_adate >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY))")->fetch();
+ $paytopmarket_summ = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='paytop.market' AND pay_status='done' AND pay_adate >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY))")->fetch();
+ $paytopprojects_summ = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='paytop.projects' AND pay_status='done' AND pay_adate >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY))")->fetch();
+ $paytopusers_summ = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='paytop.users' AND pay_status='done' AND pay_adate >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY))")->fetch();
+ $paymarketbold_summ = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='market.bold' AND pay_status='done' AND pay_adate >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY))")->fetch();
+ $paymarkettop_summ = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='market.top' AND pay_status='done' AND pay_adate >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY))")->fetch();
+ $payprjbold_summ = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='prj.bold' AND pay_status='done' AND pay_adate >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY))")->fetch();
+ $payprjtop_summ = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='prj.top' AND pay_status='done' AND pay_adate >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY))")->fetch();
+ $sbr_summ = $db->query("SELECT SUM(sbr_cost) AS summ FROM $db_sbr WHERE sbr_status='done' AND sbr_done >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY))")->fetch();
+ $sbr_summ_tax = $db->query("SELECT SUM(sbr_tax) AS summ FROM $db_sbr WHERE sbr_status='done' AND sbr_done >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY))")->fetch();
+ $sbr_summ_tax_performer = $db->query("SELECT SUM(sbr_performer) AS summ FROM $db_sbr WHERE sbr_status='done' AND sbr_done >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY))")->fetch();
+ $out1 = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='payout' AND pay_status='done' AND pay_adate >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY))")->fetch();
+ $out2 = $db->query("SELECT SUM(out_summ) AS summ FROM $db_payments_outs WHERE out_status='done' AND out_date >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY))")->fetch();
+ $market_summ = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='marketorders' AND pay_status='done' AND pay_adate >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY))")->fetch();
+ $transfer_summ = $db->query("SELECT SUM(p2.pay_summ) AS summ FROM $db_payments p1 LEFT JOIN {$db_payments} p2 ON p2.pay_code=p1.pay_id WHERE p1.pay_area='transfer' AND p1.pay_status='done' AND p2.pay_userid=p1.pay_code AND p1.pay_adate >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY))")->fetch();
+ break;
+
+ case 'month':
+ $pro_summ = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='pro' AND pay_status='done' AND pay_adate >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH))")->fetch();
+ $paytop_summ = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='paytop.top' AND pay_status='done' AND pay_adate >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH))")->fetch();
+ $paytopmarket_summ = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='paytop.market' AND pay_status='done' AND pay_adate >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH))")->fetch();
+ $paytopprojects_summ = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='paytop.projects' AND pay_status='done' AND pay_adate >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH))")->fetch();
+ $paytopusers_summ = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='paytop.users' AND pay_status='done' AND pay_adate >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH))")->fetch();
+ $paymarketbold_summ = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='market.bold' AND pay_status='done' AND pay_adate >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH))")->fetch();
+ $paymarkettop_summ = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='market.top' AND pay_status='done' AND pay_adate >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH))")->fetch();
+ $payprjbold_summ = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='prj.bold' AND pay_status='done' AND pay_adate >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH))")->fetch();
+ $payprjtop_summ = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='prj.top' AND pay_status='done' AND pay_adate >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH))")->fetch();
+ $sbr_summ = $db->query("SELECT SUM(sbr_cost) AS summ FROM $db_sbr WHERE sbr_status='done' AND sbr_done >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH))")->fetch();
+ $sbr_summ_tax = $db->query("SELECT SUM(sbr_tax) AS summ FROM $db_sbr WHERE sbr_status='done' AND sbr_done >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH))")->fetch();
+ $sbr_summ_tax_performer = $db->query("SELECT SUM(sbr_performer) AS summ FROM $db_sbr WHERE sbr_status='done' AND sbr_done >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH))")->fetch();
+ $out1 = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='payout' AND pay_status='done' AND pay_adate >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH))")->fetch();
+ $out2 = $db->query("SELECT SUM(out_summ) AS summ FROM $db_payments_outs WHERE out_status='done' AND out_date >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH))")->fetch();
+ $market_summ = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='marketorders' AND pay_status='done' AND pay_adate >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH))")->fetch();
+ $transfer_summ = $db->query("SELECT SUM(p2.pay_summ) AS summ FROM $db_payments p1 LEFT JOIN {$db_payments} p2 ON p2.pay_code=p1.pay_id WHERE p1.pay_area='transfer' AND p1.pay_status='done' AND p2.pay_userid=p1.pay_code AND p1.pay_adate >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH))")->fetch();
+ break;
+
+ case 'year':
+ $pro_summ = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='pro' AND pay_status='done' AND pay_adate >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR))")->fetch();
+ $paytop_summ = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='paytop.top' AND pay_status='done' AND pay_adate >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR))")->fetch();
+ $paytopmarket_summ = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='paytop.market' AND pay_status='done' AND pay_adate >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR))")->fetch();
+ $paytopprojects_summ = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='paytop.projects' AND pay_status='done' AND pay_adate >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR))")->fetch();
+ $paytopusers_summ = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='paytop.users' AND pay_status='done' AND pay_adate >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR))")->fetch();
+ $paymarketbold_summ = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='market.bold' AND pay_status='done' AND pay_adate >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR))")->fetch();
+ $paymarkettop_summ = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='market.top' AND pay_status='done' AND pay_adate >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR))")->fetch();
+ $payprjbold_summ = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='prj.bold' AND pay_status='done' AND pay_adate >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR))")->fetch();
+ $payprjtop_summ = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='prj.top' AND pay_status='done' AND pay_adate >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR))")->fetch();
+ $sbr_summ = $db->query("SELECT SUM(sbr_cost) AS summ FROM $db_sbr WHERE sbr_status='done' AND sbr_done >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR))")->fetch();
+ $sbr_summ_tax = $db->query("SELECT SUM(sbr_tax) AS summ FROM $db_sbr WHERE sbr_status='done' AND sbr_done >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR))")->fetch();
+ $sbr_summ_tax_performer = $db->query("SELECT SUM(sbr_performer) AS summ FROM $db_sbr WHERE sbr_status='done' AND sbr_done >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR))")->fetch();
+ $out1 = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='payout' AND pay_status='done' AND pay_adate >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR))")->fetch();
+ $out2 = $db->query("SELECT SUM(out_summ) AS summ FROM $db_payments_outs WHERE out_status='done' AND out_date >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR))")->fetch();
+ $market_summ = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='marketorders' AND pay_status='done' AND pay_adate >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR))")->fetch();
+ $transfer_summ = $db->query("SELECT SUM(p2.pay_summ) AS summ FROM $db_payments p1 LEFT JOIN {$db_payments} p2 ON p2.pay_code=p1.pay_id WHERE p1.pay_area='transfer' AND p1.pay_status='done' AND p2.pay_userid=p1.pay_code AND p1.pay_adate >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR))")->fetch();
+ break;
+
+ default :
+ $pro_summ = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='pro' AND pay_status='done' ")->fetch();
+ $sbr_summ = $db->query("SELECT SUM(sbr_cost) AS summ FROM $db_sbr WHERE sbr_status='done'")->fetch();
+ $sbr_summ_tax_performer = $db->query("SELECT SUM(sbr_performer) AS summ FROM $db_sbr WHERE sbr_status='done'")->fetch();
+ $sbr_summ_tax = $db->query("SELECT SUM(sbr_tax) AS summ FROM $db_sbr WHERE sbr_status='done'")->fetch();
+ $out1 = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='payout' AND pay_status='done'")->fetch();
+ $out2 = $db->query("SELECT SUM(out_summ) AS summ FROM $db_payments_outs WHERE out_status='done'")->fetch();
+ $paytop_summ = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='paytop.top' AND pay_status='done' ")->fetch();
+ $paytopmarket_summ = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='paytop.market' AND pay_status='done' ")->fetch();
+ $paytopprojects_summ = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='paytop.projects' AND pay_status='done' ")->fetch();
+ $paytopusers_summ = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='paytop.users' AND pay_status='done' ")->fetch();
+ $paymarketbold_summ = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='market.bold' AND pay_status='done' ")->fetch();
+ $paymarkettop_summ = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='market.top' AND pay_status='done' ")->fetch();
+ $payprjbold_summ = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='prj.bold' AND pay_status='done' ")->fetch();
+ $payprjtop_summ = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='prj.top' AND pay_status='done' ")->fetch();
+ $market_summ = $db->query("SELECT SUM(pay_summ) AS summ FROM $db_payments WHERE pay_area='marketorders' AND pay_status='done' ")->fetch();
+ $transfer_summ = $db->query("SELECT SUM(p2.pay_summ) AS summ FROM $db_payments p1 LEFT JOIN {$db_payments} p2 ON p2.pay_code=p1.pay_id WHERE p1.pay_area='transfer' AND p1.pay_status='done' AND p2.pay_userid=p1.pay_code ")->fetch();
+}
+
+
+$payments_tax = ($cfg["payments"]["transfertax"]);
+$payments_summ_tax['summ'] = ($transfer_summ['summ'] * $payments_tax) / 100;
+
+$market_tax = $cfg["plugin"]["marketorders"]["tax"];
+$market_summ_tax['summ'] = ($market_summ['summ'] * $market_tax) / 100;
+
+$out_summ = $out1['summ'] - $out2['summ'];
+$total_amount = $sbr_summ_tax['summ'] +
+ $sbr_summ_tax_performer ['summ'] +
+ #$sbr_summ['summ'] +
+ $pro_summ['summ'] +
+ $market_summ_tax['summ'] +
+ $paytop_summ['summ'] +
+ $paytopmarket_summ['summ'] +
+ $paytopprojects_summ['summ'] +
+ $paytopusers_summ['summ'] +
+ $paymarketbold_summ['summ'] +
+ $paymarkettop_summ['summ'] +
+ $payprjbold_summ['summ'] +
+ $payprjtop_summ['summ'] +
+ $payments_summ_tax['summ'] +
+ $out_summ;
+
+$pft = new XTemplate(cot_tplfile('profitstats.admin.home.mainpanel', 'plug'));
+
+$pft->assign(array(
+ 'SBR_SUMM' => empty($sbr_summ['summ']) ? 0.00 : $sbr_summ['summ'],
+ 'SBR_TAX_SUMM' => empty($sbr_summ_tax['summ']) ? 0.00 : $sbr_summ_tax['summ'],
+ 'SBR_TAX_PERFORMER_SUMM' => empty($sbr_summ_tax_performer['summ']) ? 0.00 : $sbr_summ_tax_performer['summ'],
+ "PRO_SUMM" => empty($pro_summ['summ']) ? 0.00 : $pro_summ['summ'],
+ "MARKET_SUMM" => empty($market_summ_tax['summ']) ? 0.00 : $market_summ_tax['summ'],
+ "PAYTOP_SUMM" => empty($paytop_summ['summ']) ? 0.00 : $paytop_summ['summ'],
+ "PAYTOPMARKET_SUMM" => empty($paytopmarket_summ['summ']) ? 0.00 : $paytopmarket_summ['summ'],
+ "PAYTOPPROJECTS_SUMM" => empty($paytopprojects_summ['summ']) ? 0.00 : $paytopprojects_summ['summ'],
+ "PAYTOPUSERS_SUMM" => empty($paytopusers_summ['summ']) ? 0.00 : $paytopusers_summ['summ'],
+ "PAYMARKETBOLD_SUMM" => empty($paymarketbold_summ['summ']) ? 0.00 : $paymarketbold_summ['summ'],
+ "PAYMARKETTOP_SUMM" => empty($paymarkettop_summ['summ']) ? 0.00 : $paymarkettop_summ['summ'],
+ "PAYPRJBOLD_SUMM" => empty($payprjbold_summ['summ']) ? 0.00 : $payprjbold_summ['summ'],
+ "PAYPRJTOP_SUMM" => empty($payprjtop_summ['summ']) ? 0.00 : $payprjtop_summ['summ'],
+ "OUTS_TAX" => empty($out_summ) ? 0.00 : $out_summ,
+ "TRANSFER_TAX" => empty($payments_summ_tax['summ']) ? 0.00 : $payments_summ_tax['summ'],
+ "TOTAL_AMOUNT" => empty($total_amount) ? 0.00 : $total_amount
+));
+
+$pft->parse('MAIN');
+
+$line = $pft->text('MAIN');
diff --git a/plugins/profitstats/profitstats.png b/plugins/profitstats/profitstats.png
new file mode 100644
index 0000000..ada9b14
Binary files /dev/null and b/plugins/profitstats/profitstats.png differ
diff --git a/plugins/profitstats/profitstats.setup.php b/plugins/profitstats/profitstats.setup.php
new file mode 100644
index 0000000..805b3df
--- /dev/null
+++ b/plugins/profitstats/profitstats.setup.php
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+ {PHP.L.Profits_total_amount}: {TOTAL_AMOUNT|number_format($this, '0', '.', ' ')} {PHP.cfg.payments.valuta}
+
+
+ {PHP.L.Profits_stat}
+
+
+ {PHP.L.Profits_sbr}: {SBR_SUMM|number_format($this, '0', '.', ' ')} {PHP.cfg.payments.valuta}
+ {PHP.L.Profits_sbrtax}: {SBR_TAX_SUMM|number_format($this, '0', '.', ' ')} {PHP.cfg.payments.valuta}
+
+
+ {PHP.L.Profits_pro}: {PRO_SUMM|number_format($this, '0', '.', ' ')} {PHP.cfg.payments.valuta}
+
+
+
+
+ {PHP.L.Profits_paytop}: {PAYTOP_SUMM|number_format($this, '0', '.', ' ')} {PHP.cfg.payments.valuta}
+ {PHP.L.Profits_paytopprojects}: {PAYTOPPROJECTS_SUMM|number_format($this, '0', '.', ' ')} {PHP.cfg.payments.valuta}
+ {PHP.L.Profits_paytopusers}: {PAYTOPUSERS_SUMM|number_format($this, '0', '.', ' ')} {PHP.cfg.payments.valuta}
+
+
+
+
+ {PHP.L.Profits_paytopmarket}: {PAYTOPMARKET_SUMM|number_format($this, '0', '.', ' ')} {PHP.cfg.payments.valuta}
+
+
+ {PHP.L.Profits_paymarketbold}: {PAYMARKETBOLD_SUMM|number_format($this, '0', '.', ' ')} {PHP.cfg.payments.valuta}
+
+
+ {PHP.L.Profits_paymarkettop}: {PAYMARKETTOP_SUMM|number_format($this, '0', '.', ' ')} {PHP.cfg.payments.valuta}
+
+
+
+
+ {PHP.L.Profits_payprjbold}: {PAYPRJBOLD_SUMM|number_format($this, '0', '.', ' ')} {PHP.cfg.payments.valuta}
+
+
+ {PHP.L.Profits_payprjtop}: {PAYPRJTOP_SUMM|number_format($this, '0', '.', ' ')} {PHP.cfg.payments.valuta}
+
+
+ {PHP.L.Profits_market}: {MARKET_SUMM|number_format($this, '0', '.', ' ')} {PHP.cfg.payments.valuta}
+
+
+
+
+ {PHP.L.Profits_transfers}: {TRANSFER_TAX|number_format($this, '0', '.', ' ')} {PHP.cfg.payments.valuta}
+
+
+ {PHP.L.Profits_outstax}: {OUTS_TAX|number_format($this, '0', '.', ' ')} {PHP.cfg.payments.valuta}
+
+
+ {PHP.L.Profits_total_amount}: {TOTAL_AMOUNT|number_format($this, '0', '.', ' ')} {PHP.cfg.payments.valuta}
+
+
+
+
+
+
\ No newline at end of file
diff --git a/plugins/regpro/lang/regpro.en.lang.php b/plugins/regpro/lang/regpro.en.lang.php
new file mode 100644
index 0000000..345167c
--- /dev/null
+++ b/plugins/regpro/lang/regpro.en.lang.php
@@ -0,0 +1,8 @@
+ 0) {
+ require_once cot_langfile('regpro', 'plug');
+
+ if ($row['user_logcount'] == 1) {
+ $upro = cot_getuserpro($row['user_id']);
+ $initialtime = ($upro > Cot::$sys['now']) ? $upro : Cot::$sys['now'];
+ $rproexpire = $initialtime + Cot::$cfg['plugin']['regpro']['protime'] * 24 * 60 * 60;
+
+ if (
+ Cot::$db->update(Cot::$db->users, ['user_pro' => (int) $rproexpire], 'user_id = ' . $row['user_id'])
+ ) {
+ cot_mail(
+ $row['user_email'],
+ Cot::$L['regpro_mail_subject'],
+ sprintf(Cot::$L['regpro_mail_body'], $row['user_name'])
+ );
+ cot_log("Pro for register");
+
+ /* === Hook === */
+ foreach (cot_getextplugins('regpro.done') as $pl) {
+ include $pl;
+ }
+ /* ===== */
+ }
+ }
+}
diff --git a/plugins/regstat/README.md b/plugins/regstat/README.md
new file mode 100644
index 0000000..98d2019
--- /dev/null
+++ b/plugins/regstat/README.md
@@ -0,0 +1,18 @@
+cot-regstat
+=======
+Плагин для вывода статистики регистраций в админке Cotonti
+
+Разработчик: Булат Юсупов support@cmsworks.ru
+
+Copyright CMSWorks Team 2015
+
+Плагин Regstat позволяет вывести на главной странице админ-панели график регистраций пользователей. В настройках плагина вы можете выбрать период вывода статистики: за последнюю неделю (week), месяц (month), год (year) или за весь период работы вашего сайта (all).
+
+Для построения графиков используется Google Charts API
+
+Порядок установки:
+
+Распакуйте исходники в папку plugins вашего сайта.
+Зайдите в панель администратора и установите данный плагин.
+В настройках плагина установите период вывода статистики.
+На главной странице админки вы увидите график регистраций.
diff --git a/plugins/regstat/inc/regstat.functions.php b/plugins/regstat/inc/regstat.functions.php
new file mode 100644
index 0000000..1d73cd8
--- /dev/null
+++ b/plugins/regstat/inc/regstat.functions.php
@@ -0,0 +1,15 @@
+query("SELECT user_regdate FROM $db_users WHERE user_maingrp > 3 ORDER BY user_regdate ASC")->fetchColumn();
+}
+
+$mindate = mktime( 0, 0, 0, cot_date('m', $mindate), cot_date('d', $mindate), cot_date('Y', $mindate) );
+
+$maxdate = $sys['now'];
+$maxdate = mktime( 23, 59, 59, cot_date('m', $maxdate), cot_date('d', $maxdate), cot_date('Y', $maxdate) );
+
+$day = $mindate;
+while($day <= $maxdate){
+ $nextday = $day + 24*60*60;
+ $userscount[$day] = $db->query("SELECT COUNT(*) FROM $db_users WHERE user_maingrp > 3 AND user_regdate >= ".$day." AND user_regdate < ".$nextday)->fetchColumn();
+ $day = $nextday;
+}
+
+if(is_array($userscount)){
+ foreach($userscount AS $day => $count){
+ $tt->assign(array(
+ 'REG_ROW_COUNT' => $count,
+ 'REG_ROW_DAY' => $day,
+ ));
+ $tt->parse('MAIN.REG_ROW');
+ }
+}
+
+$tt->parse('MAIN');
+$line = $tt->text('MAIN');
diff --git a/plugins/regstat/regstat.png b/plugins/regstat/regstat.png
new file mode 100644
index 0000000..d6608b5
Binary files /dev/null and b/plugins/regstat/regstat.png differ
diff --git a/plugins/regstat/regstat.setup.php b/plugins/regstat/regstat.setup.php
new file mode 100644
index 0000000..162d2b0
--- /dev/null
+++ b/plugins/regstat/regstat.setup.php
@@ -0,0 +1,24 @@
+
+
+
Статистика регистраций пользователей
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/plugins/reviews/inc/reviews.functions.php b/plugins/reviews/inc/reviews.functions.php
index eb6e4fe..3aaa34a 100644
--- a/plugins/reviews/inc/reviews.functions.php
+++ b/plugins/reviews/inc/reviews.functions.php
@@ -1,10 +1,8 @@
prep($code) . "'" : '';
$sqlarea = " AND item_area='".$db->prep($area)."'";
}
@@ -84,7 +82,7 @@ function cot_reviews_list($userid, $area, $code='', $name='', $params='', $tail=
if(is_array($params))
{
$params2 = array();
- foreach ($array as $key => $value)
+ foreach ($params as $key => $value)
{
$params2[$key] = str_replace(array('$userid', '$area', '$code'), array('$userid', $area, $code), $value);
}
@@ -110,12 +108,12 @@ function cot_reviews_list($userid, $area, $code='', $name='', $params='', $tail=
'REVIEW_FORM_DELETE_URL' => cot_url('plug', 'r=reviews&a=delete&area='.$area.'&code='.$code.'&touser='.$userid.'&redirect='.$redirect.'&itemid=' . $item['item_id']),
));
- /* === Hook === */
- foreach (cot_getextplugins('reviews.edit.tags') as $pl)
- {
- include $pl;
- }
- /* ===== */
+ /* === Hook === */
+ foreach (cot_getextplugins('reviews.edit.tags') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
$t1->parse('MAIN.REVIEWS_ROWS.EDITFORM');
}
@@ -134,12 +132,11 @@ function cot_reviews_list($userid, $area, $code='', $name='', $params='', $tail=
'REVIEW_ROW_DELETE_URL' => ($usr['id'] == $item['item_userid'] || $usr['isadmin']) ? cot_url('plug', 'r=reviews&a=delete&area='.$area.'&code='.$code.'&itemid=' . $item['item_id'] . '&redirect='.$redirect) : '',
));
- /* === Hook === */
- foreach (cot_getextplugins('reviews.list.tags') as $pl)
- {
- include $pl;
- }
- /* ===== */
+ /* === Hook === */
+ foreach (cot_getextplugins('reviews.list.tags') as $pl) {
+ include $pl;
+ }
+ /* ===== */
if($item['item_area'] == 'projects' && !empty($item['item_code']))
{
@@ -153,14 +150,15 @@ function cot_reviews_list($userid, $area, $code='', $name='', $params='', $tail=
$t1->parse('MAIN.REVIEWS_ROWS');
}
- if($cfg['plugin']['reviews']['checkprojects'] && cot_module_active('projects') && $usr['id'] > 0 && $usr['auth_write'] && $usr['id'] != $userid)
+ if(cot_module_active('projects') && $cfg['plugin']['reviews']['checkprojects'] && $usr['id'] > 0 && $usr['auth_write'] && $usr['id'] != $userid)
{
require_once cot_incfile('projects', 'module');
global $db_projects_offers, $db_projects;
-
- $prj_reviews_sql = $db->query("SELECT item_code FROM $db_reviews WHERE item_area='projects' AND item_userid=".$usr['id']);
- while($row = $prj_reviews_sql->fetch())
- {
+
+ $prjreviews = [];
+
+ $prj_reviews_sql = $db->query("SELECT item_code FROM $db_reviews WHERE item_area='projects' AND item_userid=" . $usr['id']);
+ while($row = $prj_reviews_sql->fetch()) {
$prjreviews[] = $row['item_code'];
}
@@ -204,24 +202,34 @@ function cot_reviews_list($userid, $area, $code='', $name='', $params='', $tail=
$usr['auth_write'] = ($reviews_count > 0) ? false : $usr['auth_write'];
}
- if ($usr['auth_write'] && $usr['id'] != $userid)
- {
+ if (cot::$usr['auth_write'] && cot::$usr['id'] != $userid) {
cot_display_messages($t1);
$t1->assign(array(
'REVIEW_FORM_SEND' => cot_url('plug', 'r=reviews&a=add&area='.$area.'&touser='.$userid.'&redirect='.$redirect),
- 'REVIEW_FORM_TEXT' => cot_textarea('rtext', $ritem['item_text'], 5, 50),
- 'REVIEW_FORM_SCORE' => cot_radiobox($ritem['item_score'], 'rscore', $L['reviews_score_values'], $L['reviews_score_titles']),
- 'REVIEW_FORM_PROJECTS' => ($cfg['plugin']['reviews']['checkprojects'] && cot_module_active('projects') && $bothprj_count > 0) ? cot_selectbox($pid, 'code', $prj_ids, $prj_titles, false) : '',
+ // TODO Что за $ritem? Больше нигде не используется
+ 'REVIEW_FORM_TEXT' => cot_textarea(
+ 'rtext',
+ isset($ritem['item_text']) ? $ritem['item_text'] : '',
+ 5,
+ 50
+ ),
+ 'REVIEW_FORM_SCORE' => cot_radiobox(
+ isset($ritem['item_score']) ? $ritem['item_score'] : 0,
+ 'rscore',
+ cot::$L['reviews_score_values'],
+ cot::$L['reviews_score_titles']
+ ),
+ 'REVIEW_FORM_PROJECTS' => (cot_module_active('projects') && cot::$cfg['plugin']['reviews']['checkprojects'] && $bothprj_count > 0) ?
+ cot_selectbox(isset($pid) ? $pid : 0, 'code', $prj_ids, $prj_titles, false) : '',
'REVIEW_FORM_ACTION' => 'ADD',
));
- /* === Hook === */
- foreach (cot_getextplugins('reviews.add.tags') as $pl)
- {
- include $pl;
- }
- /* ===== */
+ /* === Hook === */
+ foreach (cot_getextplugins('reviews.add.tags') as $pl) {
+ include $pl;
+ }
+ /* ===== */
$t1->parse('MAIN.FORM');
}
diff --git a/plugins/reviews/reviews.index.php b/plugins/reviews/reviews.index.php
index 95a9d44..2af5334 100644
--- a/plugins/reviews/reviews.index.php
+++ b/plugins/reviews/reviews.index.php
@@ -1,5 +1,4 @@
0)
-{
- $scores = cot_getreview_scores($urr['user_id']);
+if (cot::$usr['id'] > 0) {
+ $scores = cot_getreview_scores(cot::$usr['id']);
$t->assign(array(
"USERINFO_REVIEWS_NEGATIVE_SUMM" => $scores['neg']['summ'],
"USERINFO_REVIEWS_POZITIVE_SUMM" => $scores['poz']['summ'],
- "USERINFO_RATING" => $usr['profile']['user_rating'],
+ "USERINFO_RATING" => !empty(cot::$usr['profile']['user_rating']) ? cot::$usr['profile']['user_rating'] : 0,
));
-}
-?>
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/plugins/reviews/reviews.setup.php b/plugins/reviews/reviews.setup.php
index d124bc5..acb8e2f 100644
--- a/plugins/reviews/reviews.setup.php
+++ b/plugins/reviews/reviews.setup.php
@@ -4,8 +4,8 @@
Code=reviews
Name=Reviews
Description=Отзывы о человеке
-Version=2.2.3
-Date=24.11.2012
+Version=2.2.4
+Date=2022-09-09
Author=CMSWorks Team
Copyright=Copyright © CMSWorks.ru, littledev.ru
Notes=
diff --git a/plugins/reviews/reviews.users.details.php b/plugins/reviews/reviews.users.details.php
index 55122de..5c43f99 100644
--- a/plugins/reviews/reviews.users.details.php
+++ b/plugins/reviews/reviews.users.details.php
@@ -20,15 +20,13 @@
$t->assign('REVIEWS', cot_reviews_list($urr['user_id'], 'users', '', 'users', "m=details&id=" . $urr['user_id'] . "&u=" . $urr['user_name'] . "&tab=reviews", '', $cfg['plugin']['reviews']['userall']));
-if (!$cfg['plugin']['reviews']['userall'])
-{
+$sqlarea = '';
+if (!cot::$cfg['plugin']['reviews']['userall']) {
$sqlarea = " AND item_area='users'";
}
-$user_reviews_count = $db->query("SELECT COUNT(*) FROM $db_reviews WHERE item_touserid=" . (int)$urr['user_id'] . " $sqlarea")->fetchColumn();
+$user_reviews_count = cot::$db->query("SELECT COUNT(*) FROM $db_reviews WHERE item_touserid=" . (int) $urr['user_id'] . " $sqlarea")->fetchColumn();
$t->assign(array(
'USERS_DETAILS_REVIEWS_COUNT' => $user_reviews_count,
"USERS_DETAILS_REVIEWS_URL" => cot_url('users', 'm=details&id=' . $urr['user_id'] . '&u=' . $urr['user_name'] . '&tab=reviews'),
-));
-
-?>
\ No newline at end of file
+));
\ No newline at end of file
diff --git a/plugins/roboxbilling/roboxbilling.ajax.php b/plugins/roboxbilling/roboxbilling.ajax.php
index 548647c..8a11f2d 100644
--- a/plugins/roboxbilling/roboxbilling.ajax.php
+++ b/plugins/roboxbilling/roboxbilling.ajax.php
@@ -16,12 +16,15 @@
* @license BSD
*/
+use cot\modules\payments\dictionaries\PaymentDictionary;
+use cot\modules\payments\Services\PaymentService;
+
defined('COT_CODE') or die('Wrong URL');
require_once cot_incfile('payments', 'module');
// регистрационная информация (пароль #2)
-$mrh_pass2 = $cfg['plugin']['roboxbilling']['mrh_pass2'];
+$mrh_pass2 = Cot::$cfg['plugin']['roboxbilling']['mrh_pass2'];
// чтение параметров
$out_summ = $_REQUEST["OutSum"];
@@ -34,21 +37,14 @@
$my_crc = strtoupper(md5("$out_summ:$inv_id:$mrh_pass2:Shp_item=$shp_item"));
// проверка корректности подписи
-if ($my_crc != $crc)
-{
+if ($my_crc != $crc) {
echo "bad sign\n";
exit();
}
-else
-{
- // Обновляем статус платежа на "оплачен"
- if (cot_payments_updatestatus($inv_id, 'paid'))
- {
- echo "OK$inv_id\n";
- }
- else
- {
- echo "Error of update order status!";
- }
+
+// Обновляем статус платежа на "оплачен"
+if (PaymentService::getInstance()->setStatus($inv_id, PaymentDictionary::STATUS_PAID, 'robox')) {
+ echo "OK$inv_id\n";
+} else {
+ echo "Error of update order status!";
}
-?>
\ No newline at end of file
diff --git a/plugins/roboxbilling/roboxbilling.input.php b/plugins/roboxbilling/roboxbilling.input.php
index 19718df..0451149 100644
--- a/plugins/roboxbilling/roboxbilling.input.php
+++ b/plugins/roboxbilling/roboxbilling.input.php
@@ -18,10 +18,14 @@
defined('COT_CODE') or die('Wrong URL.');
-if(($_GET['e'] == 'roboxbilling' || $_GET['r'] == 'roboxbilling') && $_SERVER['REQUEST_METHOD'] == 'POST' && $cfg['plugin']['roboxbilling']['enablepost'])
-{
+if(
+ (
+ (isset($_GET['e']) && $_GET['e'] == 'roboxbilling')
+ || (isset($_GET['r']) && $_GET['r'] == 'roboxbilling')
+ )
+ && $_SERVER['REQUEST_METHOD'] == 'POST'
+ && Cot::$cfg['plugin']['roboxbilling']['enablepost']
+) {
define('COT_NO_ANTIXSS', 1) ;
$cfg['referercheck'] = false;
}
-
-?>
\ No newline at end of file
diff --git a/plugins/roboxbilling/roboxbilling.php b/plugins/roboxbilling/roboxbilling.php
index 00cfa51..cec050c 100644
--- a/plugins/roboxbilling/roboxbilling.php
+++ b/plugins/roboxbilling/roboxbilling.php
@@ -14,6 +14,11 @@
* @copyright Copyright (c) CMSWorks.ru
* @license BSD
*/
+
+use cot\modules\payments\dictionaries\PaymentDictionary;
+use cot\modules\payments\Repositories\PaymentRepository;
+use cot\modules\payments\Services\PaymentService;
+
defined('COT_CODE') && defined('COT_PLUG') or die('Wrong URL');
require_once cot_incfile('roboxbilling', 'plug');
@@ -25,7 +30,7 @@
if (empty($m))
{
// Получаем информацию о заказе
- if (!empty($pid) && $pinfo = cot_payments_payinfo($pid))
+ if (!empty($pid) && $pinfo = PaymentRepository::getInstance()->getById($pid))
{
cot_block($usr['id'] == $pinfo['pay_userid']);
cot_block($pinfo['pay_status'] == 'new' || $pinfo['pay_status'] == 'process');
@@ -50,7 +55,8 @@
$post_opt = "MrchLogin=" . $mrh_login . "&OutSum=" . $out_summ . "&InvId=" . $inv_id . "&Desc=" . $inv_desc . "&SignatureValue=" . $crc . "&Shp_item=" . $shp_item . "&IncCurrLabel=" . $in_curr . "&Culture=" . $culture . $test_string;
- cot_payments_updatestatus($pid, 'process'); // Изменяем статус "в процессе оплаты"
+ // Изменяем статус "в процессе оплаты"
+ PaymentService::getInstance()->setStatus($pid, PaymentDictionary::STATUS_PROCESS, 'robox');
header('Location: ' . $url . '?' . $post_opt);
exit;
@@ -77,34 +83,34 @@
$my_crc = strtoupper(md5("$out_summ:$inv_id:$mrh_pass1:Shp_item=$shp_item"));
- $plugin_body = $L['roboxbilling_error_otkaz'];
+ $pluginBody = $L['roboxbilling_error_otkaz'];
// проверка корректности подписи
if ($my_crc != $crc)
{
- $plugin_body = $L['roboxbilling_error_incorrect'];
+ $pluginBody = $L['roboxbilling_error_incorrect'];
}
else
{
if(!empty($inv_id))
{
// проверка наличия номера платежки и ее статуса
- $pinfo = cot_payments_payinfo($inv_id);
+ $pinfo = PaymentRepository::getInstance()->getById($inv_id);
if ($pinfo['pay_status'] == 'done')
{
- $plugin_body = $L['roboxbilling_error_done'];
+ $pluginBody = $L['roboxbilling_error_done'];
$redirect = $pinfo['pay_redirect'];
}
elseif ($pinfo['pay_status'] == 'paid')
{
- $plugin_body = $L['roboxbilling_error_paid'];
+ $pluginBody = $L['roboxbilling_error_paid'];
}
}
}
$t->assign(array(
"ROBOX_TITLE" => $L['roboxbilling_error_title'],
- "ROBOX_ERROR" => $plugin_body
+ "ROBOX_ERROR" => $pluginBody
));
if($redirect){
@@ -123,4 +129,3 @@
));
$t->parse("MAIN.ERROR");
}
-?>
\ No newline at end of file
diff --git a/plugins/sbr/README.md b/plugins/sbr/README.md
new file mode 100644
index 0000000..c1bab95
--- /dev/null
+++ b/plugins/sbr/README.md
@@ -0,0 +1,63 @@
+cot-sbr
+=======
+
+Сделка без риска для фриланс-биржи на Cotonti
+
+Разработчик: Булат Юсупов support@cmsworks.ru, Cotonti team
+Оригинальный плагин: https://github.com/Cotonti-Extensions/freelance/tree/master/plugins/sbr
+
+Copyright 2016 CMSWorks Team, 2024-2025 Cotonti team
+
+Плагин позволяет организовать на сайте фриланс-биржи возможность пользователям оформлять между собой сделки с полным согласованием всех этапов работ. При этом бюджет сделки резервируется на счету сайта до начала всех работ и выплачивается Исполнителю после приемки результатов работ по каждому этапу сделки. При возникновении спорных вопросов, любая из сторон может обратиться в арбитражную комиссию (в администрацию сайта). Арбитражная комиссия, путем анализа внутренней переписки по сделке, принимает соответствующее решение об оплате выполненной работы Исполнителю, либо о возврате бюджета за этап сделки Заказчику. Также комиссия может принять решение о частичной выплате сторонам. Таким образом осуществляется защита всех сторон сделки.
+
+### Описание принципа работы:
+
+1. Создание сделки и согласование условий
+
+Оформление сделки начинается с выбора исполнителя. На странице проекта Заказчик выбирает наиболее подходящее предложение и переходит по кнопке "Предложить сделку". В открывшейся форме Заказчик должен заполнить всю необходимую информацию о будущем заказе и указать все этапы сделки. Каждый этап должен содержать заголовок, техническое задание (ТЗ). бюджет и сроки, необходимые для выполнения указанных работ. Общий бюджет сделки суммируется из бюджетов каждого из этапов. Таким образом формируется основной документ безопасной сделки. После того как вся информация заполнена, Заказчик отправляет ее на согласование выбранному Исполнителю. В случае, если Исполнитель не согласен с условиями сделки, то Заказчик может изменить текст и отправить сделку на повторное согласование. Если Исполнитель соглашается со всеми указанными условиями, то об этом уведомляется Заказчик. После этого Заказчик должен оплатить общий бюджет сделки, в том числе с учетом комиссии сервиса. Размер комиссии устанавливается администратором сайта и является платой за проведение на сайте данного вида услуг.
+
+Как только Заказчик оплатил сделку, Исполнитель может приступать к исполнению первого этапа.
+
+2. Исполнение этапов и завершение сделки
+
+Этап сделки должен быть выполнен в заранее согласованные строки. При этом стороны могут обмениваться сообщениями с помощью системы переписки на странице этапа сделки. Это позволяет уточнять различные вопросы и согласовывать промежуточные результаты выполняемых работ. После того как были выполнены все работы и обязательства по текущему этапу Заказчик принимает работу и тем самым закрывает данные этап сделки. Исполнителю на счет переводится оплата за данный этап.
+
+Завершение сделки осуществляется автоматически после приемки всех этапов.
+
+3. Арбитраж
+
+Если в ходе выполнения какого-либо из этапов возникли разногласия между сторонами сделки, можно обратиться в арбитраж для разрешения ситуации. Арбитражная комиссия принимает свое решение путем анализа сложившейся ситуации. Комиссия может принять решение о полной или частичной выплате (возврате) суммы за текущий этап сделки Заказчику или Исполнителю. Решение арбитражной комиссии нельзя отменить.
+
+
+### Сделки без привязки в проектам
+
+Если вы хотите использовать сделки вне проектов, то можно создать ссылку на создание сделки в любом шаблоне сайта таким образом:
+
+```
+
Предложить сделку
+```
+
+Либо, если нужно разместить кнопку на странице пользователя (users.details.tpl), то ссылка будет выглядеть так:
+
+```
+
Предложить сделку
+```
+
+
+### Установка:
+
+Распакуйте и скопируйте папку sbr в директорию plugins/ вашего сайта.
+Зайдите в админ-панель сайта и перейдите в раздел "Расширения". Установите плагин Sbr.
+В настройках плагина укажите размер комиссии сайта за оформление следки (в процентах) и другие настройки. Комиссия за оформление сделки взимается с Заказчика. Также при необходимости в настройках плагина можно указать размер комиссии с Исполнителя, которая взимается при выплате на счет Исполнителя по мере приемки каждого этапа сделки. Исполнитель получит оплату уже с учетом указанной комиссии.
+В шапку сайта можно добавить ссылку на сделки (этот код уже вставлен в базовую версию фриланс-биржи, здесь показан для примера):
+
+```
+
+
{PHP.L.sbr_mydeals}
+
+```
+
+Прикрепление файлов к этапам сделки и к переписке по сделке
+
+В настройках плагина можно указать директорию для хранения файлов, а также перечень расширений файлов, допустимых к загрузке. По-умолчанию, директория для загрузки файлов: datas/sbr. При установке плагина, создайте данную папку в соответствии с указанной директорией и установите на нее права 777.
+Работа с файлами на данный момент создана в режиме тестирования
diff --git a/plugins/sbr/inc/SbrFileService.php b/plugins/sbr/inc/SbrFileService.php
new file mode 100644
index 0000000..3fa186b
--- /dev/null
+++ b/plugins/sbr/inc/SbrFileService.php
@@ -0,0 +1,93 @@
+ 0) {
+ $fileSize = filesize($filePath);
+ if ($fileSize > $maxFileSize) {
+ return cot_rc(Cot::$L['sbr_error_fileToLarge'], ['size' => Cot::$cfg['plugin']['sbr']['maxUploadSize']]);
+ }
+ }
+
+ $allowedExtensions = explode(',', Cot::$cfg['plugin']['sbr']['extensions']);
+ if (!empty($allowedExtensions)) {
+ foreach ($allowedExtensions as $key => $ext) {
+ $ext = trim($ext);
+ if ($ext === '') {
+ unset($allowedExtensions[$key]);
+ continue;
+ }
+
+ $allowedExtensions[$key] = mb_strtolower($ext);
+ }
+ }
+
+ $fileExtension = $this->getFileExtension($fileName);
+ if ($fileExtension !== null) {
+ $fileExtension = mb_strtolower($fileExtension);
+ }
+
+ if (!empty($allowedExtensions)) {
+ if (
+ $fileExtension === null
+ || !in_array($fileExtension, $allowedExtensions)
+ ) {
+ return Cot::$L['sbr_error_invalidFileType'];
+ }
+ }
+
+ $pfsFileCheck = Cot::$cfg['pfs']['pfsfilecheck'] ?? null;
+ $pfsNoMimePass = Cot::$cfg['pfs']['pfsnomimepass'] ?? null;
+ Cot::$cfg['pfs']['pfsfilecheck'] = true;
+ Cot::$cfg['pfs']['pfsnomimepass'] = true;
+ $result = cot_file_check($filePath, $fileName, $fileExtension);
+ Cot::$cfg['pfs']['pfsfilecheck'] = $pfsFileCheck;
+ Cot::$cfg['pfs']['pfsnomimepass'] = $pfsNoMimePass;
+
+ if (!$result) {
+ return Cot::$L['sbr_error_invalidFileType'];
+ }
+
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/plugins/sbr/inc/sbr.add.php b/plugins/sbr/inc/sbr.add.php
new file mode 100644
index 0000000..d5f46e2
--- /dev/null
+++ b/plugins/sbr/inc/sbr.add.php
@@ -0,0 +1,364 @@
+ '',
+];
+
+/* === Hook === */
+foreach (cot_getextplugins('sbr.add.first') as $pl) {
+ include $pl;
+}
+/* ===== */
+
+cot_block($usr['auth_write'] && $uid != $usr['id']);
+
+if ($a == 'add')
+{
+ cot_shield_protect();
+
+ [$usr['auth_read'], $usr['auth_write'], $usr['isadmin']] = cot_auth('plug', 'sbr', 'RWA');
+ cot_block($usr['auth_write']);
+
+ /* === Hook === */
+ foreach (cot_getextplugins('sbr.add.add.first') as $pl) {
+ include $pl;
+ }
+ /* ===== */
+
+ $rsbrtitle = cot_import('rsbrtitle', 'P', 'TXT');
+ $rsbrsubmit = cot_import('rsbrsubmit', 'P', 'ALP');
+
+ $rstagetitle = cot_import('rstagetitle', 'P', 'ARR');
+ $rstagetext = cot_import('rstagetext', 'P', 'ARR');
+ $rstagecost = cot_import('rstagecost', 'P', 'ARR');
+ $rstagedays = cot_import('rstagedays', 'P', 'ARR');
+ $rStageExpire = cot_import('rstageexpire', 'P', 'ARR');
+
+ $rstagefiles = isset($_FILES['rstagefiles']) ? $_FILES['rstagefiles'] : null;
+
+ $stagescount = cot_import('stagescount', 'P', 'INT');
+
+ /* === Hook === */
+ foreach (cot_getextplugins('sbr.add.add.import') as $pl) {
+ include $pl;
+ }
+ /* ===== */
+
+ if (empty($uid)) {
+ $rsbrperformer = cot_import('rsbrperformer', 'P', 'TXT', 100, TRUE);
+ $rsbr['sbr_performer'] = $db->query("SELECT user_id FROM $db_users WHERE user_name = ? LIMIT 1", array($rsbrperformer))->fetchColumn();
+ if (empty($rsbr['sbr_performer'])) cot_error('sbr_error_rsbrperformer', 'rsbrperformer');
+ if ($rsbr['sbr_performer'] == $usr['id']) cot_error('sbr_error_rsbrperformernotyou', 'rsbrperformer');
+ } else {
+ $rsbr['sbr_performer'] = $uid;
+ }
+
+ cot_check(empty($rsbrtitle), Cot::$L['sbr_error_rsbrtitle'], 'rsbrtitle');
+
+ $rsbr['sbr_cost'] = 0;
+
+ for ($i = 1; $i <= $stagescount; $i++) {
+ if (Cot::$cfg['plugin']['sbr']['stages_on'] && $stagescount > 1) {
+ // Если у нас только 1 этап. Название этапа можно не указывать
+ cot_check(empty($rstagetitle[$i]), Cot::$L['sbr_error_rstagetitle'], 'rstagetitle[' . $i . ']');
+ }
+ cot_check(empty($rstagetext[$i]), Cot::$L['sbr_error_rstagetext'], 'rstagetext['.$i.']');
+ cot_check(empty($rstagecost[$i]), Cot::$L['sbr_error_rstagecost'], 'rstagecost['.$i.']');
+ cot_check(
+ (
+ !empty($rstagecost[$i])
+ && $rstagecost[$i] < $cfg['plugin']['sbr']['mincost']
+ && $cfg['plugin']['sbr']['mincost'] > 0
+ ),
+ Cot::$L['sbr_error_rstagecostmin'],
+ 'rstagecost['.$i.']'
+ );
+ cot_check(
+ (
+ !empty($rstagecost[$i])
+ && $rstagecost[$i] > $cfg['plugin']['sbr']['maxcost']
+ && $cfg['plugin']['sbr']['maxcost'] > 0
+ ),
+ Cot::$L['sbr_error_rstagecostmax'],
+ 'rstagecost['.$i.']'
+ );
+
+ if (!empty($rStageExpire[$i])) {
+ $rStageExpire[$i] = cot_import_date($rStageExpire[$i], true, false, 'D');
+ }
+ if (empty($rStageExpire[$i])) {
+ $rStageExpire[$i] = 0;
+ }
+ $rstagedays[$i] = (int) $rstagedays[$i];
+ cot_check(
+ empty($rstagedays[$i]) && empty($rStageExpire[$i]),
+ Cot::$L['sbr_error_rstagedays'],
+ 'rstagedays[' . $i . ']'
+ );
+ cot_check(
+ (
+ !empty($rstagedays[$i])
+ && $rstagedays[$i] > $cfg['plugin']['sbr']['maxdays']
+ && $cfg['plugin']['sbr']['maxdays'] > 0
+ ),
+ Cot::$L['sbr_error_rstagedaysmax'],
+ 'rstagedays['.$i.']'
+ );
+
+ cot_check(
+ ($rStageExpire[$i] > 0 && $rStageExpire[$i] < Cot::$sys['now']),
+ 'Дата окончания срока исполнения не может быть в прошлом',
+ 'rstageexpire[' . $i . ']'
+ );
+
+ /* === Hook === */
+ foreach (cot_getextplugins('sbr.add.add.stages.error') as $pl) {
+ include $pl;
+ }
+ /* ===== */
+
+ $rsbr['sbr_cost'] += (isset($rstagecost[$i]) ? (float) $rstagecost[$i] : 0);
+ }
+
+ $rsbr['sbr_tax'] = $rsbr['sbr_cost'] * ((float) Cot::$cfg['plugin']['sbr']['tax']) / 100;
+
+ $rsbr['sbr_title'] = $rsbrtitle;
+ $rsbr['sbr_pid'] = $pid;
+ $rsbr['sbr_employer'] = $usr['id'];
+
+ /* === Hook === */
+ foreach (cot_getextplugins('sbr.add.add.error') as $pl) {
+ include $pl;
+ }
+ /* ===== */
+
+ if (!cot_error_found()) {
+ $rsbr['sbr_status'] = 'new';
+ $rsbr['sbr_create'] = Cot::$sys['now'];
+
+ Cot::$db->insert(Cot::$db->sbr, $rsbr);
+ $id = Cot::$db->lastInsertId();
+
+ $fileService = SbrFileService::getInstance();
+
+ for ($i = 1; $i <= $stagescount; $i++) {
+ $rstage = [
+ 'stage_sid' => $id,
+ 'stage_num' => $i,
+ 'stage_title' => isset($rstagetitle[$i]) ? $rstagetitle[$i] : '',
+ 'stage_text' => $rstagetext[$i],
+ 'stage_cost' => $rstagecost[$i],
+ 'stage_days' => $rstagedays[$i],
+ 'stage_expire' => $rStageExpire[$i],
+ ];
+
+ Cot::$db->insert(Cot::$db->sbr_stages, $rstage);
+ $stageid = Cot::$db->lastInsertId();
+
+ $sbr_path = $cfg['plugin']['sbr']['filepath'] . '/' . $id . '/';
+ if (!file_exists($sbr_path)) {
+ mkdir($sbr_path, Cot::$cfg['dir_perms'], true);
+ }
+
+ for ($j = 0; $j < 10; $j++) {
+ if (!empty($rstagefiles['tmp_name'][$i][$j]) && $rstagefiles['size'][$i][$j] > 0 && $rstagefiles['error'][$i][$j] == 0) {
+ $u_tmp_name_file = $rstagefiles['tmp_name'][$i][$j];
+ $u_type_file = $rstagefiles['type'][$i][$j];
+ $u_name_file = $rstagefiles['name'][$i][$j];
+ $u_size_file = $rstagefiles['size'][$i][$j];
+
+ $u_name_file = str_replace("\'",'',$u_name_file );
+ $u_name_file = trim(str_replace("\"",'',$u_name_file ));
+ $dotpos = strrpos($u_name_file,".")+1;
+ $f_extension = substr($u_name_file, $dotpos, 5);
+
+ if (!empty($u_tmp_name_file)) {
+ $result = $fileService->validateUploadedFile($u_tmp_name_file, $u_name_file);
+ if ($result !== true) {
+ cot_error(
+ cot_rc(
+ Cot::$L['sbr_error_uploadFile'],
+ ['name' => $u_name_file, 'error' => $result]
+ )
+ );
+ continue;
+ }
+
+ $u_newname_file = $i . '_' . md5(uniqid(rand(),true)) . '.' . $f_extension;
+ $file = $sbr_path . $u_newname_file;
+
+ move_uploaded_file($u_tmp_name_file, $file);
+ @chmod($file, 0766);
+
+ $rfile['file_sid'] = $id;
+ $rfile['file_url'] = $file;
+ $rfile['file_title'] = $u_name_file;
+ $rfile['file_area'] = 'stage';
+ $rfile['file_code'] = $i;
+ $rfile['file_ext'] = $f_extension;
+ $rfile['file_size'] = floor($u_size_file / 1024);
+
+ $db->insert($db_sbr_files, $rfile);
+ }
+ }
+ }
+ }
+
+ $performer = $db->query("SELECT * FROM $db_users WHERE user_id=" . $rsbr['sbr_performer'])->fetch();
+ $rsubject = cot_rc($L['sbr_mail_toperformer_new_header'], array('sbr_title' => $rsbr['sbr_title']));
+ $rbody = cot_rc($L['sbr_mail_toperformer_new_body'], array(
+ 'performer_name' => $performer['user_name'],
+ 'employer_name' => $usr['profile']['user_name'],
+ 'sbr_title' => $rsbr['sbr_title'],
+ 'sbr_cost' => $rsbr['sbr_cost'].' '.$cfg['payments']['valuta'],
+ 'sitename' => $cfg['maintitle'],
+ 'link' => COT_ABSOLUTE_URL . cot_url('sbr', "id=" . $id, '', true)
+ ));
+ cot_mail ($performer['user_email'], $rsubject, $rbody);
+
+ cot_sbr_sendpost($id, $L['sbr_posts_performer_new'], $rsbr['sbr_performer'], 0, 'info');
+ cot_sbr_sendpost($id, $L['sbr_posts_employer_new'], $usr['id'], 0, 'info');
+
+ cot_redirect(cot_url('sbr', 'id=' . $id, '', true));
+ }
+}
+
+$out['subtitle'] = Cot::$L['sbr_addtitle'];
+$out['head'] .= Cot::$R['code_noindex'];
+
+$mskin = cot_tplfile(array('sbr', 'add'), 'plug');
+
+/* === Hook === */
+foreach (cot_getextplugins('sbr.add.main') as $pl) {
+ include $pl;
+}
+/* ===== */
+
+$t = new XTemplate($mskin);
+
+if(!empty($uid))
+{
+ $t->assign(cot_generate_usertags($uid, 'SBR_PERFORMER_'));
+}
+else
+{
+ $t->assign('SBRADD_FORM_PERFORMER', cot_inputbox('text', 'rsbrperformer', $rsbrperformer, 'placeholder="'.$L['sbr_performer_placeholder'].'"'));
+}
+
+if(!empty($pid))
+{
+ $t->assign(cot_generate_projecttags($pid, 'SBR_PROJECT_'));
+}
+
+$patharray[] = array(cot_url('sbr'), $L['sbr']);
+$patharray[] = array(cot_url('sbr', 'm=add&pid='.$pid.'&uip='.$uid), $L['sbr_addtitle']);
+
+$t->assign(array(
+ 'SBRADD_TITLE' => cot_breadcrumbs($patharray, $cfg['homebreadcrumb'], true),
+ 'SBRADD_SUBTITLE' => $L['sbr_addtitle'],
+ 'SBRADD_ADMINEMAIL' => "mailto:".$cfg['adminemail'],
+ 'SBRADD_FORM_SEND' => cot_url('sbr', 'm=add&pid='.$pid.'&uid='.$uid.'&a=add'),
+ 'SBRADD_FORM_OWNER' => cot_build_user($usr['id'], htmlspecialchars($usr['name'])),
+ 'SBRADD_FORM_OWNERID' => $usr['id'],
+ 'SBRADD_FORM_MAINTITLE' => cot_inputbox('text', 'rsbrtitle', $rsbr['sbr_title']),
+));
+
+for ($i = 1; $i <= $stagescount; $i++) {
+ $t->assign(array(
+ 'STAGEADD_FORM_NUM' => $i,
+ 'STAGEADD_FORM_TITLE' => cot_inputbox(
+ 'text',
+ 'rstagetitle['.$i.']',
+ isset($rstagetitle[$i]) ? $rstagetitle[$i] : ''
+ ),
+ 'STAGEADD_FORM_TEXT' => cot_textarea(
+ 'rstagetext['.$i.']',
+ isset($rstagetext[$i]) ? $rstagetext[$i] : '',
+ 10,
+ 120,
+ '',
+ 'input_textarea'
+ ),
+ 'STAGEADD_FORM_COST' => cot_inputbox(
+ 'text',
+ 'rstagecost['.$i.']',
+ isset($rstagecost[$i]) ? $rstagecost[$i] : '',
+ array('class' => 'stagecost', 'maxlength' => '100')
+ ),
+ 'STAGEADD_FORM_DAYS' => cot_inputbox(
+ 'text',
+ 'rstagedays['.$i.']',
+ !empty($rstagedays[$i]) ? $rstagedays[$i] : '',
+ ['maxlength' => '100']
+ ),
+ 'STAGEADD_FORM_EXPIRE' => cot_inputbox(
+ 'datetime-local',
+ 'rstageexpire['.$i.']',
+ !empty($rStageExpire[$i]) ?
+ cot_date('Y-m-d\TH:i:s', $rStageExpire[$i])
+ : cot_date('Y-m-d\TH:i:s'),
+ ['min' => cot_date('Y-m-d\TH:i:s')]
+ ),
+ ));
+
+ /* === Hook === */
+ foreach (cot_getextplugins('sbr.add.stages.tags') as $pl) {
+ include $pl;
+ }
+ /* ===== */
+
+ $t->parse('MAIN.STAGE_ROW');
+}
+
+// Extra fields
+foreach($cot_extrafields[$db_sbr] as $exfld)
+{
+ $uname = strtoupper($exfld['field_name']);
+ $exfld_val = cot_build_extrafields('rsbr'.$exfld['field_name'], $exfld, $rsbr['sbr_'.$exfld['field_name']]);
+ $exfld_title = isset($L['sbr_'.$exfld['field_name'].'_title']) ? $L['sbr_'.$exfld['field_name'].'_title'] : $exfld['field_description'];
+ $t->assign(array(
+ 'SBRADD_FORM_'.$uname => $exfld_val,
+ 'SBRADD_FORM_'.$uname.'_TITLE' => $exfld_title,
+ 'SBRADD_FORM_EXTRAFLD' => $exfld_val,
+ 'SBRADD_FORM_EXTRAFLD_TITLE' => $exfld_title
+ ));
+ $t->parse('MAIN.EXTRAFLD');
+}
+
+// Error and message handling
+cot_display_messages($t);
+
+/* === Hook === */
+foreach (cot_getextplugins('sbr.add.tags') as $pl)
+{
+ include $pl;
+}
+/* ===== */
diff --git a/plugins/sbr/inc/sbr.edit.php b/plugins/sbr/inc/sbr.edit.php
new file mode 100644
index 0000000..ebd337c
--- /dev/null
+++ b/plugins/sbr/inc/sbr.edit.php
@@ -0,0 +1,406 @@
+ 0) {
+ $query_string = (!$usr['isadmin']) ? " AND sbr_employer=".$usr['id']."" : "";
+ $sql = $db->query("SELECT * FROM $db_sbr WHERE sbr_id=" . $id . " " . $query_string . " LIMIT 1");
+}
+
+if (!$id || !$sql || $sql->rowCount() == 0) {
+ cot_die_message(404, TRUE);
+}
+$sbr = $sql->fetch();
+
+$cfg['msg_separate'] = true;
+
+[$usr['auth_read'], $usr['auth_write'], $usr['isadmin']] = cot_auth('plug', 'sbr');
+
+/* === Hook === */
+foreach (cot_getextplugins('sbr.edit.first') as $pl) {
+ include $pl;
+}
+/* ===== */
+
+if (!$usr['isadmin']) {
+ // Редактировать можно только новую сделку, которая еще полностью не оформлена
+ cot_block($usr['auth_write'] && ($sbr['sbr_status'] == 'new' || $sbr['sbr_status'] == 'confirm' || $sbr['sbr_status'] == 'refuse'));
+}
+
+if ($a == 'update' && $_SERVER['REQUEST_METHOD'] === 'POST') {
+ cot_shield_protect();
+
+ [$usr['auth_read'], $usr['auth_write'], $usr['isadmin']] = cot_auth('plug', 'sbr', 'RWA');
+ cot_block($usr['auth_write']);
+
+ /* === Hook === */
+ foreach (cot_getextplugins('sbr.edit.edit.first') as $pl) {
+ include $pl;
+ }
+ /* ===== */
+
+ $rsbrtitle = cot_import('rsbrtitle', 'P', 'TXT');
+ $rsbrsubmit = cot_import('rsbrsubmit', 'P', 'ALP');
+
+ $rstagetitle = cot_import('rstagetitle', 'P', 'ARR');
+ $rstagetext = cot_import('rstagetext', 'P', 'ARR');
+ $rstagecost = cot_import('rstagecost', 'P', 'ARR');
+ $rstagedays = cot_import('rstagedays', 'P', 'ARR');
+ $rStageExpire = cot_import('rstageexpire', 'P', 'ARR');
+
+ // Валидация стадий
+ cot_validate_stages($rstagetitle, $rstagetext, false);
+
+ $rstagefiles = $_FILES['rstagefiles'];
+ $rfilestoremove = cot_import('rfilestoremove', 'P', 'ARR');
+
+ $stagescount = cot_import('stagescount', 'P', 'INT');
+ if (empty($stagescount)) {
+ $stagescount = 1;
+ }
+
+ /* === Hook === */
+ foreach (cot_getextplugins('sbr.edit.edit.import') as $pl) {
+ include $pl;
+ }
+ /* ===== */
+
+ $rsbr['sbr_title'] = $rsbrtitle;
+ $rsbr['sbr_cost'] = 0;
+
+ cot_check(empty($rsbrtitle), $L['sbr_error_rsbrtitle'], 'rsbrtitle');
+
+ for ($i = 1; $i <= $stagescount; $i++) {
+ if (Cot::$cfg['plugin']['sbr']['stages_on'] && $stagescount > 1) {
+ // Если у нас только 1 этап. Название этапа можно не указывать
+ cot_check(empty($rstagetitle[$i]), $L['sbr_error_rstagetitle'], 'rstagetitle[' . $i . ']');
+ }
+ cot_check(empty($rstagetext[$i]), $L['sbr_error_rstagetext'], 'rstagetext['.$i.']');
+ cot_check(empty($rstagecost[$i]), $L['sbr_error_rstagecost'], 'rstagecost['.$i.']');
+ cot_check((!empty($rstagecost[$i]) && $rstagecost[$i] < $cfg['plugin']['sbr']['mincost'] && $cfg['plugin']['sbr']['mincost'] > 0), $L['sbr_error_rstagecostmin'], 'rstagecost['.$i.']');
+ cot_check((!empty($rstagecost[$i]) && $rstagecost[$i] > $cfg['plugin']['sbr']['maxcost'] && $cfg['plugin']['sbr']['maxcost'] > 0), $L['sbr_error_rstagecostmax'], 'rstagecost['.$i.']');
+
+ if (!empty($rStageExpire[$i])) {
+ $rStageExpire[$i] = cot_import_date($rStageExpire[$i], true, false, 'D');
+ }
+ if (empty($rStageExpire[$i])) {
+ $rStageExpire[$i] = 0;
+ }
+ $rstagedays[$i] = (int) $rstagedays[$i];
+ cot_check(
+ empty($rstagedays[$i]) && empty($rStageExpire[$i]),
+ Cot::$L['sbr_error_rstagedays'],
+ 'rstagedays[' . $i . ']'
+ );
+
+ cot_check(
+ (
+ !empty($rstagedays[$i])
+ && $rstagedays[$i] > $cfg['plugin']['sbr']['maxdays']
+ && $cfg['plugin']['sbr']['maxdays'] > 0
+ ),
+ $L['sbr_error_rstagedaysmax'],
+ 'rstagedays['.$i.']'
+ );
+
+ cot_check(
+ ($rStageExpire[$i] > 0 && $rStageExpire[$i] < Cot::$sys['now']),
+ 'Дата окончания срока исполнения не может быть в прошлом',
+ 'rstageexpire[' . $i . ']'
+ );
+
+ /* === Hook === */
+ foreach (cot_getextplugins('sbr.edit.edit.stages.error') as $pl) {
+ include $pl;
+ }
+ /* ===== */
+
+ $rsbr['sbr_cost'] += $rstagecost[$i];
+ }
+
+ $rsbr['sbr_tax'] = $rsbr['sbr_cost'] * ((float) Cot::$cfg['plugin']['sbr']['tax']) / 100;
+
+ /* === Hook === */
+ foreach (cot_getextplugins('sbr.edit.edit.error') as $pl) {
+ include $pl;
+ }
+ /* ===== */
+
+ if (!cot_error_found()) {
+ if ($rsbrsubmit == 'draft') {
+ $rsbr['sbr_status'] = 'draft';
+ } else {
+ $rsbr['sbr_status'] = 'new';
+ $rsbr['sbr_update'] = $sys['now'];
+ }
+
+ $db->update($db_sbr, $rsbr, "sbr_id = ?", $sbr['sbr_id']);
+ $db->delete($db_sbr_stages, "stage_num > :stage_num AND stage_sid = :stage_sid", array(
+ ":stage_num" => $stagescount,
+ ":stage_sid" => $sbr['sbr_id'],
+ ));
+
+ $stages = $db->query("SELECT * FROM $db_sbr_stages WHERE stage_sid=" . $sbr['sbr_id'] . " ORDER BY stage_num ASC")->fetchAll();
+ foreach($stages as $stage) {
+ $rstage['stage_title'] = $rstagetitle[$stage['stage_num']] ?? null;
+ $rstage['stage_text'] = $rstagetext[$stage['stage_num']] ?? null;
+ $rstage['stage_cost'] = $rstagecost[$stage['stage_num']] ?? null;
+ $rstage['stage_days'] = $rstagedays[$stage['stage_num']] ?? null;
+ $rstage['stage_expire'] = $rStageExpire[$stage['stage_num']] ?? null;
+
+ $db->update($db_sbr_stages, $rstage, "stage_num = :stage_num AND stage_sid = :stage_sid", array(
+ ":stage_num" => $stage['stage_num'],
+ ":stage_sid" => $sbr['sbr_id'],
+ ));
+ }
+
+ for ($i = $stage['stage_num'] + 1; $i <= $stagescount; $i++) {
+ $rstage['stage_sid'] = $id;
+ $rstage['stage_num'] = $i;
+ $rstage['stage_title'] = $rstagetitle[$i];
+ $rstage['stage_text'] = $rstagetext[$i];
+ $rstage['stage_cost'] = $rstagecost[$i];
+ $rstage['stage_days'] = $rstagedays[$i];
+
+ $db->insert($db_sbr_stages, $rstage);
+ $stageid = $db->lastInsertId();
+ }
+
+ if(is_array($rfilestoremove) && count($rfilestoremove) > 0)
+ {
+ $filestoremove = $db->query("SELECT * FROM $db_sbr_files WHERE file_sid=$id AND file_id IN (".implode(',', $rfilestoremove).")")->fetchAll();
+ foreach($filestoremove as $row)
+ {
+ unlink($row['file_url']);
+ }
+
+ $db->delete($db_sbr_files, "file_id IN (".implode(',', $rfilestoremove).")");
+ }
+
+ $sbr_path = $cfg['plugin']['sbr']['filepath'] . '/' . $id . '/';
+
+ $fileService = SbrFileService::getInstance();
+
+ for ($i = 1; $i <= $stagescount; $i++) {
+ for ($j = 0; $j < 10; $j++) {
+ if (!empty($rstagefiles['tmp_name'][$i][$j]) && $rstagefiles['size'][$i][$j] > 0 && $rstagefiles['error'][$i][$j] == 0) {
+ $u_tmp_name_file = $rstagefiles['tmp_name'][$i][$j];
+ $u_type_file = $rstagefiles['type'][$i][$j];
+ $u_name_file = $rstagefiles['name'][$i][$j];
+ $u_size_file = $rstagefiles['size'][$i][$j];
+
+ $u_name_file = str_replace("\'",'',$u_name_file );
+ $u_name_file = trim(str_replace("\"",'',$u_name_file ));
+ $dotpos = strrpos($u_name_file,".")+1;
+ $f_extension = substr($u_name_file, $dotpos, 5);
+
+ if (!empty($u_tmp_name_file)) {
+ $result = $fileService->validateUploadedFile($u_tmp_name_file, $u_name_file);
+ if ($result !== true) {
+ cot_error(
+ cot_rc(
+ Cot::$L['sbr_error_uploadFile'],
+ ['name' => $u_name_file, 'error' => $result]
+ )
+ );
+ continue;
+ }
+
+ $u_newname_file = $i."_".md5(uniqid(rand(),true)).".".$f_extension;
+ $file = $sbr_path . $u_newname_file;
+
+ move_uploaded_file($u_tmp_name_file, $file);
+ @chmod($file, 0766);
+
+ $rfile['file_sid'] = $id;
+ $rfile['file_url'] = $file;
+ $rfile['file_title'] = $u_name_file;
+ $rfile['file_area'] = 'stage';
+ $rfile['file_code'] = $i;
+ $rfile['file_ext'] = $f_extension;
+ $rfile['file_size'] = floor($u_size_file / 1024);
+
+ $db->insert($db_sbr_files, $rfile);
+ }
+ }
+ }
+ }
+
+ $performer = $db->query("SELECT * FROM $db_users WHERE user_id=" . $sbr['sbr_performer'])->fetch();
+ $rsubject = cot_rc($L['sbr_mail_toperformer_edited_header'], array('sbr_title' => $rsbr['sbr_title']));
+ $rbody = cot_rc($L['sbr_mail_toperformer_edited_body'], array(
+ 'performer_name' => $performer['user_name'],
+ 'employer_name' => $usr['profile']['user_name'],
+ 'sbr_title' => $rsbr['sbr_title'],
+ 'sbr_cost' => $rsbr['sbr_cost'].' '.$cfg['payments']['valuta'],
+ 'sitename' => $cfg['maintitle'],
+ 'link' => COT_ABSOLUTE_URL . cot_url('sbr', "id=" . $id, '', true)
+ ));
+ cot_mail ($performer['user_email'], $rsubject, $rbody);
+
+ cot_sbr_sendpost($id, $L['sbr_posts_performer_edited'], $performer['user_id'], 0, 'info');
+ cot_sbr_sendpost($id, $L['sbr_posts_employer_edited'], $usr['id'], 0, 'info');
+
+
+ cot_redirect(cot_url('sbr', 'id=' . $id, '', true));
+ }
+}
+
+$out['subtitle'] = $L['sbr_edittitle'];
+$out['head'] .= $R['code_noindex'];
+
+$mskin = cot_tplfile(array('sbr', 'edit'), 'plug');
+
+/* === Hook === */
+foreach (cot_getextplugins('sbr.edit.main') as $pl)
+{
+ include $pl;
+}
+/* ===== */
+
+$t = new XTemplate($mskin);
+
+$t->assign(cot_generate_sbrtags($sbr, 'SBR_'));
+
+$t->assign(cot_generate_usertags($sbr['sbr_performer'], 'SBR_PERFORMER_'));
+if(!empty($sbr['sbr_pid']))
+{
+ $t->assign(cot_generate_projecttags($sbr['sbr_pid'], 'SBR_PROJECT_'));
+}
+
+$patharray[] = array(cot_url('sbr'), $L['sbr']);
+$patharray[] = array(cot_url('sbr', 'm=edit&id='.$id), $L['sbr_edittitle']);
+
+$t->assign(array(
+ 'SBREDIT_TITLE' => cot_breadcrumbs($patharray, $cfg['homebreadcrumb'], true),
+ 'SBREDIT_SUBTITLE' => $L['sbr_edittitle'],
+ 'SBREDIT_ADMINEMAIL' => "mailto:".$cfg['adminemail'],
+ 'SBREDIT_FORM_SEND' => cot_url('sbr', 'm=edit&id='.$id.'&a=update'),
+ 'SBREDIT_FORM_OWNER' => cot_build_user($usr['id'], htmlspecialchars($usr['name'])),
+ 'SBREDIT_FORM_OWNERID' => $usr['id'],
+ 'SBREDIT_FORM_MAINTITLE' => cot_inputbox('text', 'rsbrtitle', $sbr['sbr_title']),
+));
+
+$stages = $db->query("SELECT * FROM $db_sbr_stages WHERE stage_sid=" . $sbr['sbr_id'] . " ORDER BY stage_num ASC")->fetchAll();
+if (empty($stagescount)) {
+ $stagescount = count($stages);
+}
+
+foreach($stages as $stage) {
+ $t->assign(array(
+ 'STAGEEDIT_FORM_NUM' => $stage['stage_num'],
+ 'STAGEEDIT_FORM_TITLE' => cot_inputbox('text', 'rstagetitle['.$stage['stage_num'].']', $stage['stage_title']),
+ 'STAGEEDIT_FORM_TEXT' => cot_textarea('rstagetext['.$stage['stage_num'].']', $stage['stage_text'], 10, 120, '', 'input_textarea'),
+ 'STAGEEDIT_FORM_COST' => cot_inputbox(
+ 'text',
+ 'rstagecost['.$stage['stage_num'].']',
+ $stage['stage_cost'],
+ array('class' => 'stagecost', 'maxlength' => '100')
+ ),
+ 'STAGEEDIT_FORM_DAYS' => cot_inputbox(
+ 'text',
+ 'rstagedays['.$stage['stage_num'].']',
+ !empty($stage['stage_days']) ? $stage['stage_days'] : '',
+ ['maxlength' => '100']
+ ),
+ 'STAGEEDIT_FORM_EXPIRE' => cot_inputbox(
+ 'datetime-local',
+ 'rstageexpire[' . $stage['stage_num'] . ']',
+ !empty($stage['stage_expire']) ?
+ cot_date('Y-m-d\TH:i:s', $stage['stage_expire'])
+ : cot_date('Y-m-d\TH:i:s', $sbr['sbr_create']),
+ ['min' => cot_date('Y-m-d\TH:i:s', $sbr['sbr_create'])]
+ ),
+ ));
+
+ $stagefiles = $db->query("SELECT * FROM $db_sbr_files WHERE file_sid=" . $sbr['sbr_id'] . " AND file_area='stage' AND file_code='".$stage['stage_num']."' ORDER BY file_id ASC")->fetchAll();
+ foreach($stagefiles as $file)
+ {
+ $t->assign(array(
+ 'FILE_ROW_ID' => $file['file_id'],
+ 'FILE_ROW_URL' => $file['file_url'],
+ 'FILE_ROW_TITLE' => $file['file_title'],
+ 'FILE_ROW_EXT' => $file['file_ext'],
+ 'FILE_ROW_SIZE' => $file['file_size'],
+ ));
+ $t->parse('MAIN.STAGE_ROW.FILE_ROW');
+ }
+
+ /* === Hook === */
+ foreach (cot_getextplugins('sbr.edit.stages.tags') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+
+ $t->parse('MAIN.STAGE_ROW');
+}
+
+for ($i = $stage['stage_num'] + 1; $i <= $stagescount; $i++)
+{
+ $t->assign(array(
+ 'STAGEEDIT_FORM_NUM' => $i,
+ 'STAGEEDIT_FORM_TITLE' => cot_inputbox('text', 'rstagetitle['.$i.']', $rstagetitle[$i]),
+ 'STAGEEDIT_FORM_TEXT' => cot_textarea('rstagetext['.$i.']', $rstagetext[$i], 10, 120, '', 'input_textarea'),
+ 'STAGEEDIT_FORM_COST' => cot_inputbox('text', 'rstagecost['.$i.']', $rstagecost[$i], array('class' => 'stagecost', 'size' => '10', 'maxlength' => '100')),
+ 'STAGEEDIT_FORM_DAYS' => cot_inputbox('text', 'rstagedays['.$i.']', $rstagedays[$i], array('size' => '10', 'maxlength' => '100')),
+ 'STAGEEDIT_FORM_EXPIRE' => cot_inputbox(
+ 'datetime-local',
+ 'rstageexpire['.$i.']',
+ !empty($rStageExpire[$i]) ?
+ cot_date('Y-m-d\TH:i:s', $rStageExpire[$i])
+ : cot_date('Y-m-d\TH:i:s'),
+ ['min' => cot_date('Y-m-d\TH:i:s')]
+ ),
+ ));
+
+ /* === Hook === */
+ foreach (cot_getextplugins('sbr.edit.stages.tags') as $pl) {
+ include $pl;
+ }
+ /* ===== */
+
+ $t->parse('MAIN.STAGE_ROW');
+}
+
+// Extra fields
+foreach($cot_extrafields[$db_sbr] as $exfld)
+{
+ $uname = strtoupper($exfld['field_name']);
+ $exfld_val = cot_build_extrafields('rsbr'.$exfld['field_name'], $exfld, $rsbr['sbr_'.$exfld['field_name']]);
+ $exfld_title = isset($L['sbr_'.$exfld['field_name'].'_title']) ? $L['sbr_'.$exfld['field_name'].'_title'] : $exfld['field_description'];
+ $t->assign(array(
+ 'SBREDIT_FORM_'.$uname => $exfld_val,
+ 'SBREDIT_FORM_'.$uname.'_TITLE' => $exfld_title,
+ 'SBREDIT_FORM_EXTRAFLD' => $exfld_val,
+ 'SBREDIT_FORM_EXTRAFLD_TITLE' => $exfld_title
+ ));
+ $t->parse('MAIN.EXTRAFLD');
+}
+
+// Error and message handling
+cot_display_messages($t);
+
+/* === Hook === */
+foreach (cot_getextplugins('sbr.edit.tags') as $pl)
+{
+ include $pl;
+}
+/* ===== */
diff --git a/plugins/sbr/inc/sbr.functions.php b/plugins/sbr/inc/sbr.functions.php
new file mode 100644
index 0000000..57fe323
--- /dev/null
+++ b/plugins/sbr/inc/sbr.functions.php
@@ -0,0 +1,319 @@
+registerTable('sbr');
+Cot::$db->registerTable('sbr_stages');
+Cot::$db->registerTable('sbr_posts');
+Cot::$db->registerTable('sbr_claims');
+Cot::$db->registerTable('sbr_files');
+
+cot_extrafields_register_table('sbr');
+
+function cot_generate_sbrtags($item_data, $tag_prefix = '', $admin_rights = null, $pagepath_home = false)
+{
+ global $db, $cot_extrafields, $cfg, $L, $Ls, $R, $db_sbr, $db_sbr_stages, $sys;
+
+ static $extp_first = null, $extp_main = null;
+
+ if (is_null($extp_first))
+ {
+ $extp_first = cot_getextplugins('sbrtags.first');
+ $extp_main = cot_getextplugins('sbrtags.main');
+ }
+
+ /* === Hook === */
+ foreach ($extp_first as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+ if (!is_array($item_data))
+ {
+ $sql = $db->query("SELECT * FROM $db_sbr WHERE sbr_id = '" . (int)$item_data . "' LIMIT 1");
+ $item_data = $sql->fetch();
+ }
+
+ if ($item_data['sbr_id'] > 0 && !empty($item_data['sbr_title']))
+ {
+ if (is_null($admin_rights))
+ {
+ $admin_rights = cot_auth('plug', 'sbr', 'A');
+ }
+
+ $patharray[] = array(cot_url('sbr'), $L['sbr']);
+ $patharray[] = array(cot_url('sbr', 'id='.$item_data['sbr_id']), $item_data['sbr_title']);
+
+ $itempath = cot_breadcrumbs($patharray, $pagepath_home, true);
+
+ $temp_array = array(
+ 'ID' => $item_data['sbr_id'],
+ 'STATUS' => $item_data['sbr_status'],
+ 'LOCALSTATUS' => $L['sbr_status_'.$item_data['sbr_status']],
+ 'LABELSTATUS' => $R['sbr_labels'][$item_data['sbr_status']],
+ 'URL' => cot_url('sbr', 'id='.$item_data['sbr_id']),
+ 'TITLE' => $itempath,
+ 'SHORTTITLE' => $item_data['sbr_title'],
+ 'CREATEDATE' => date('d.m.Y H:i', $item_data['sbr_create']),
+ 'CREATEDATE_STAMP' => $item_data['sbr_create'],
+ 'BEGINDATE' => date('d.m.Y H:i', $item_data['sbr_begin']),
+ 'BEGINDATE_STAMP' => $item_data['sbr_begin'],
+ 'DONEDATE' => date('d.m.Y H:i', $item_data['sbr_done']),
+ 'DONEDATE_STAMP' => $item_data['sbr_done'],
+ 'COST' => $item_data['sbr_cost'],
+ 'TAX' => $item_data['sbr_tax'],
+ 'TOTAL' => $item_data['sbr_cost'] + $item_data['sbr_tax'],
+ 'USER_IS_ADMIN' => (
+ $admin_rights
+ || (!empty($item_data['item_userid']) && cot::$usr['id'] == $item_data['item_userid'])
+ ),
+ );
+
+ if ($admin_rights || cot::$usr['id'] == $item_data['sbr_employer']) {
+ $temp_array['ADMIN_EDIT'] = cot_rc_link(cot_url('sbr', 'm=edit&id=' . $item_data['sbr_id']), $L['Edit']);
+ $temp_array['ADMIN_EDIT_URL'] = cot_url('sbr', 'm=edit&id=' . $item_data['sbr_id']);
+ }
+
+ // Extrafields
+ if (isset($cot_extrafields[$db_sbr])) {
+ foreach ($cot_extrafields[$db_sbr] as $exfld) {
+ $tag = mb_strtoupper($exfld['field_name']);
+ $temp_array[$tag . '_TITLE'] = isset($L['sbr_' . $exfld['field_name'] . '_title']) ? $L['sbr_' . $exfld['field_name'] . '_title'] : $exfld['field_description'];
+ $temp_array[$tag] = cot_build_extrafields_data('sbr', $exfld, $item_data['item_' . $exfld['field_name']]);
+ }
+ }
+
+ /* === Hook === */
+ foreach ($extp_main as $pl) {
+ include $pl;
+ }
+ /* ===== */
+ } else {
+ $temp_array = array(
+ 'TITLE' => (!empty($emptytitle)) ? $emptytitle : $L['Deleted'],
+ 'SHORTTITLE' => (!empty($emptytitle)) ? $emptytitle : $L['Deleted'],
+ );
+ }
+
+ $return_array = array();
+ foreach ($temp_array as $key => $val)
+ {
+ $return_array[$tag_prefix . $key] = $val;
+ }
+
+ return $return_array;
+}
+
+function cot_sbr_counters()
+{
+ global $db_sbr, $R;
+
+ $counters = ['all' => 0,];
+
+ $sbrstat = cot::$db->query("SELECT sbr_status as status, COUNT(*) as count FROM $db_sbr
+ WHERE (sbr_employer=" . cot::$usr['id'] . " OR sbr_performer=" . cot::$usr['id'] . ")
+ GROUP BY sbr_status")->fetchAll();
+
+ if (!empty($sbrstat)) {
+ foreach ($sbrstat as $stat) {
+ $counters[$stat['status']] = $stat['count'];
+ $counters['all'] += $stat['count'];
+ }
+ }
+
+ foreach (cot::$R['sbr_statuses'] as $status) {
+ $counters[$status] = !empty($counters[$status]) ? $counters[$status] : 0;
+ }
+
+ return $counters;
+}
+
+function cot_sbr_sendpost($id, $text, $to, $from = 0, $type = '', $mail = false, $rfiles = array())
+{
+ global $db, $db_sbr_posts, $db_sbr, $db_sbr_files, $db_users, $sys, $cfg, $L, $R;
+
+ $rpost['post_sid'] = $id;
+ $rpost['post_text'] = $text;
+ $rpost['post_date'] = $sys['now'];
+ $rpost['post_from'] = $from;
+ $rpost['post_to'] = $to;
+ $rpost['post_type'] = $type;
+
+ /* === Hook === */
+ foreach (cot_getextplugins('sbr.post.add.query') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+
+ if ($db->insert($db_sbr_posts, $rpost)) {
+ $postid = $db->lastInsertId();
+
+ $sbr_path = cot::$cfg['plugin']['sbr']['filepath'] . '/' . $id . '/';
+ if (!file_exists($sbr_path)) {
+ mkdir($sbr_path, cot::$cfg['dir_perms'], true);
+ }
+
+ $fileService = SbrFileService::getInstance();
+
+ for ($j = 0; $j < 10; $j++) {
+ if (isset($rfiles['tmp_name'][$j]) && $rfiles['size'][$j] > 0 && $rfiles['error'][$j] == 0) {
+ $u_tmp_name_file = $rfiles['tmp_name'][$j];
+ $u_type_file = $rfiles['type'][$j];
+ $u_name_file = $rfiles['name'][$j];
+ $u_size_file = $rfiles['size'][$j];
+
+ $u_name_file = str_replace("\'",'',$u_name_file );
+ $u_name_file = trim(str_replace("\"",'',$u_name_file ));
+ $dotpos = strrpos($u_name_file,".")+1;
+ $f_extension = substr($u_name_file, $dotpos, 5);
+
+ if (!empty($u_tmp_name_file)) {
+ $result = $fileService->validateUploadedFile($u_tmp_name_file, $u_name_file);
+ if ($result !== true) {
+ cot_error(
+ cot_rc(
+ Cot::$L['sbr_error_uploadFile'],
+ ['name' => $u_name_file, 'error' => $result]
+ )
+ );
+ continue;
+ }
+
+ $u_newname_file = $postid."_".md5(uniqid(rand(),true)).".".$f_extension;
+ $file = $sbr_path . $u_newname_file;
+
+ move_uploaded_file($u_tmp_name_file, $file);
+ @chmod($file, 0766);
+
+ $rfile['file_sid'] = $id;
+ $rfile['file_url'] = $file;
+ $rfile['file_title'] = $u_name_file;
+ $rfile['file_area'] = 'post';
+ $rfile['file_code'] = $postid;
+ $rfile['file_ext'] = $f_extension;
+ $rfile['file_size'] = floor($u_size_file / 1024);
+
+ $db->insert($db_sbr_files, $rfile);
+ }
+ }
+ }
+
+ // Отправка сообщения на почту!
+ if($mail)
+ {
+ $sbr = $db->query("SELECT * FROM $db_sbr WHERE sbr_id=" . $id)->fetch();
+
+ if(!empty($to))
+ {
+ $recipients[] = $db->query("SELECT * FROM $db_users WHERE user_id=" . $to)->fetch();
+ }
+ else
+ {
+ $recipients[] = $db->query("SELECT * FROM $db_users WHERE user_id=" . $sbr['sbr_performer'])->fetch();
+ $recipients[] = $db->query("SELECT * FROM $db_users WHERE user_id=" . $sbr['sbr_employer'])->fetch();
+ }
+
+ if(!empty($from))
+ {
+ $sender = $db->query("SELECT * FROM $db_users WHERE user_id=" . $from)->fetch();
+ }
+
+ foreach($recipients as $recipient)
+ {
+ if(!empty($from))
+ {
+ $rsubject = cot_rc($L['sbr_mail_posts_header'], array('sbr_id' => $id, 'sbr_title' => $sbr['sbr_title']));
+ $rbody = cot_rc($L['sbr_mail_posts_body'], array(
+ 'user_name' => $recipient['user_name'],
+ 'sender_name' => $sender['user_name'],
+ 'post_text' => $text,
+ 'sitename' => $cfg['maintitle'],
+ 'link' => COT_ABSOLUTE_URL . cot_url('sbr', "id=" . $id, '', true)
+ ));
+ }
+ else
+ {
+ $rsubject = cot_rc($L['sbr_mail_notification_header'], array('sbr_id' => $id, 'sbr_title' => $sbr['sbr_title']));
+ $rbody = cot_rc($L['sbr_mail_notification_body'], array(
+ 'user_name' => $recipient['user_name'],
+ 'post_text' => $text,
+ 'sitename' => $cfg['maintitle'],
+ 'link' => COT_ABSOLUTE_URL . cot_url('sbr', "id=" . $id, '', true)
+ ));
+ }
+ cot_mail ($recipient['user_email'], $rsubject, $rbody, '', false, null, true);
+ }
+ }
+
+ /* === Hook === */
+ foreach (cot_getextplugins('sbr.post.add.done') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+
+ return $db->lastInsertId();
+ }
+
+ return false;
+}
+
+/**
+ * Вычищаем ненужные символы из названий и текстов стадий
+ *
+ * @param array $rstagetitle Массив из title стадий
+ * @param array $rstagetext Массив из text стадий
+ * @param bool $purifier TRUE - вычистить внутренности скриптов, FALSE - заменить допустимыми символами
+ */
+function cot_validate_stages(&$rstagetitle, &$rstagetext, $purifier = false)
+{
+ // Если включен плагин htmlpurifier, то очищаем через него
+ if ($purifier === true) {
+ if (cot_plugin_active('htmlpurifier') && function_exists('htmlpurifier_filter')) {
+ if (!empty($rstagetitle)) {
+ foreach ($rstagetitle as $key => $value) {
+ $rstagetitle[$key] = htmlpurifier_filter($value, false);
+ }
+ }
+ if (!empty($rstagetext)) {
+ foreach ($rstagetext as $key => $value) {
+ $rstagetext[$key] = htmlpurifier_filter($value, false);
+ }
+ }
+ } else {
+ error_log('Попытка функции cot_validate_stages валидировать title и text с помощью неактивного плагина htmlpurifier');
+ return false;
+ }
+ }
+ // Иначе производим замену наподобии cot_import с фильтром 'TXT'
+ else {
+ if (!empty($rstagetitle)) {
+ foreach ($rstagetitle as $key => $value) {
+ $rstagetitle[$key] = str_replace('<', '<', trim($value));
+ }
+ }
+ if (!empty($rstagetext)) {
+ foreach ($rstagetext as $key => $value) {
+ $rstagetext[$key] = str_replace('<', '<', trim($value));
+ }
+ }
+ }
+}
diff --git a/plugins/sbr/inc/sbr.info.php b/plugins/sbr/inc/sbr.info.php
new file mode 100644
index 0000000..1f91e34
--- /dev/null
+++ b/plugins/sbr/inc/sbr.info.php
@@ -0,0 +1,89 @@
+ $sbr
+ * @var XTemplate $t
+ */
+
+defined('COT_CODE') or die('Wrong URL');
+
+$sqllist_rowset = cot::$db->query(
+ 'SELECT * FROM ' . cot::$db->sbr_stages . ' WHERE stage_sid = ? ORDER BY stage_num ASC',
+ $sbr['sbr_id']
+)->fetchAll();
+foreach ($sqllist_rowset as $stage) {
+ $expireDate = !empty($stage['stage_expire']) ?
+ $stage['stage_expire'] : $stage['stage_begin'] + $stage['stage_days'] * 24 * 60 * 60;
+
+ $t->assign(array(
+ 'STAGE_ROW_NUM' => $stage['stage_num'],
+ 'STAGE_ROW_ID' => $stage['stage_id'],
+ 'STAGE_ROW_TITLE' => $stage['stage_title'],
+ 'STAGE_ROW_TEXT' => $stage['stage_text'],
+ 'STAGE_ROW_COST' => $stage['stage_cost'],
+ 'STAGE_ROW_DAYS' => $stage['stage_days'],
+ 'STAGE_ROW_STATUS' => $stage['stage_status'],
+ 'STAGE_ROW_BEGIN' => $stage['stage_begin'],
+ 'STAGE_ROW_DONE' => $stage['stage_done'],
+ 'STAGE_ROW_EXPIRE' => $stage['stage_expire'],
+ 'STAGE_ROW_EXPIREDATE' => $expireDate,
+ 'STAGE_ROW_EXPIREDAYS' => cot_build_timegap(cot::$sys['now'], $expireDate),
+ 'STAGE_ROW_DONE_URL' => cot_url('sbr', 'id=' . $id . '&stageid=' . $stage['stage_id'] . '&a=done'),
+ ));
+
+ $stagefiles = $db->query("SELECT * FROM $db_sbr_files WHERE file_sid=" . $id . " AND file_area='stage' AND file_code='".$stage['stage_num']."' ORDER BY file_id ASC")->fetchAll();
+ if (count($stagefiles) > 0)
+ {
+ foreach($stagefiles as $file)
+ {
+ $t->assign(array(
+ 'FILE_ROW_ID' => $file['file_id'],
+ 'FILE_ROW_URL' => $file['file_url'],
+ 'FILE_ROW_TITLE' => $file['file_title'],
+ 'FILE_ROW_EXT' => $file['file_ext'],
+ 'FILE_ROW_SIZE' => $file['file_size'],
+ ));
+ $t->parse('MAIN.SBR.INFO.STAGE_ROW.FILES.FILE_ROW');
+ }
+ $t->parse('MAIN.SBR.INFO.STAGE_ROW.FILES');
+ }
+
+ if($stage['stage_status'] == 'arbitration')
+ {
+ require_once cot_incfile('arbitration', 'plug');
+
+ $arb = $db->query("SELECT * FROM $db_arbitration
+ WHERE arb_area='sbr' AND arb_code=".$stage['stage_id']."
+ AND (arb_defendantid=".$sbr['sbr_employer']." AND arb_claimantid=".$sbr['sbr_performer']." OR arb_defendantid=".$sbr['sbr_performer']." AND arb_claimantid=".$sbr['sbr_employer'].")")->fetch();
+
+ $t->assign(array(
+ "ARB_ID" => $arb['arb_id'],
+ "ARB_DATE" => $arb['arb_date'],
+ "ARB_TITLE" => $arb['arb_title'],
+ "ARB_TEXT" => $arb['arb_claimtext'],
+ ));
+ }
+
+ /* === Hook === */
+ foreach (cot_getextplugins('sbr.stages.tags') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+
+ $t->parse('MAIN.SBR.INFO.STAGE_ROW');
+}
+
+if(!empty($role) && ($sbr['sbr_status'] != 'cancel' || $sbr['sbr_status'] != 'arbitration'))
+{
+ $t->parse('MAIN.SBR.INFO.' . strtoupper($role));
+}
+
+$t->parse('MAIN.SBR.INFO');
\ No newline at end of file
diff --git a/plugins/sbr/inc/sbr.list.php b/plugins/sbr/inc/sbr.list.php
new file mode 100644
index 0000000..daee70b
--- /dev/null
+++ b/plugins/sbr/inc/sbr.list.php
@@ -0,0 +1,109 @@
+assign(array(
+ 'SBR_TITLE' => cot_breadcrumbs($patharray, $cfg['homebreadcrumb'], true),
+ 'SBR_COUNTERS' => cot_sbr_counters()
+));
+
+$where = array();
+$order = array();
+
+if(!empty($status))
+{
+ $where['status'] = "sbr_status='" . $db->prep($status) . "'";
+}
+
+$where['userid'] = "(sbr_employer=" . $usr['id'] . " OR sbr_performer=" . $usr['id'] . ")";
+
+$order['date'] = "sbr_create DESC";
+
+/* === Hook === */
+foreach (cot_getextplugins('sbr.list.query') as $pl)
+{
+ include $pl;
+}
+/* ===== */
+
+$where = ($where) ? 'WHERE ' . implode(' AND ', $where) : '';
+$order = ($order) ? 'ORDER BY ' . implode(', ', $order) : '';
+
+$totalitems = $db->query("SELECT COUNT(*) FROM $db_sbr
+ " . $where . "")->fetchColumn();
+
+$sqllist = $db->query("SELECT * FROM $db_sbr AS s
+ " . $where . "
+ " . $order . "
+ LIMIT $d, " . $cfg['plugin']['sbr']['maxrowsperpage']);
+
+$pagenav = cot_pagenav('sbr', '', $d, $totalitems, $cfg['plugin']['sbr']['maxrowsperpage']);
+
+$sqllist_rowset = $sqllist->fetchAll();
+
+/* === Hook === */
+$extp = cot_getextplugins('sbr.list.loop');
+/* ===== */
+
+$jj = 0;
+foreach ($sqllist_rowset as $sbr) {
+ $jj++;
+ $t->assign(cot_generate_usertags($sbr['sbr_employer'], 'SBR_ROW_EMPLOYER_'));
+ $t->assign(cot_generate_usertags($sbr['sbr_performer'], 'SBR_ROW_PERFORMER_'));
+ $t->assign(cot_generate_sbrtags($sbr, 'SBR_ROW_'));
+
+ /* === Hook - Part2 : Include === */
+ foreach ($extp as $pl) {
+ include $pl;
+ }
+ /* ===== */
+
+ $t->parse("MAIN.SBR_ROW");
+}
+
+/* === Hook === */
+foreach (cot_getextplugins('sbr.list.tags') as $pl) {
+ include $pl;
+}
+/* ===== */
diff --git a/plugins/sbr/inc/sbr.main.php b/plugins/sbr/inc/sbr.main.php
new file mode 100644
index 0000000..02a4e84
--- /dev/null
+++ b/plugins/sbr/inc/sbr.main.php
@@ -0,0 +1,853 @@
+query("SELECT * FROM $db_sbr WHERE sbr_id=" . $id . " " . $query_string . " LIMIT 1");
+if ($sql->rowCount() == 0) {
+ cot_die_message(404);
+}
+
+$sbr = $sql->fetch();
+
+// Действия только для Заказчика
+if ($usr['id'] == $sbr['sbr_employer']) {
+ $role = 'employer';
+
+ // Если сделка согласована, то можно оплатить.
+ if ($a == 'pay' && $sbr['sbr_status'] == 'confirm') {
+ /* === Hook === */
+ foreach (cot_getextplugins('sbr.pay.first') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+
+ $totalcost = $sbr['sbr_cost'] + $sbr['sbr_tax'];
+
+ $options['desc'] = cot_rc($L['sbr_paydesc'], array('sbr_title' => $sbr['sbr_title']));
+ $options['code'] = $id;
+
+ /* === Hook === */
+ foreach (cot_getextplugins('sbr.pay.main') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+
+ // Переход на оплату в Payments
+ cot_payments_create_order('sbr', $totalcost, $options);
+ }
+
+ // Если сделка согласована или на согласовании, то еще можно ее отменить. В иных случаях только через арбитраж
+ if($a == 'cancel' && ($sbr['sbr_status'] == 'new' || $sbr['sbr_status'] == 'refuse' || $sbr['sbr_status'] == 'confirm'))
+ {
+
+ /* === Hook === */
+ foreach (cot_getextplugins('sbr.cancel.first') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+
+ // Отправка уведомления Исполнителю
+
+ // Изменение статуса сделки
+ if($db->update($db_sbr, array('sbr_status' => 'cancel'), "sbr_id=" . $id))
+ {
+ cot_sbr_sendpost($id, $L['sbr_posts_performer_cancel'], $sbr['sbr_performer'], 0, 'warning', true);
+ cot_sbr_sendpost($id, $L['sbr_posts_employer_cancel'], $sbr['sbr_employer'], 0, 'warning', true);
+
+ /* === Hook === */
+ foreach (cot_getextplugins('sbr.cancel.done') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+ }
+
+ cot_redirect(cot_url('sbr', 'id=' . $id, '', true));
+ }
+
+ // Принятие этапа (Завершение этапа и оплата Исполнителю суммы за этап)
+ if (!empty($num) && $a == 'done' && $sbr['sbr_status'] == 'process') {
+ cot_shield_protect();
+
+ if (
+ $stage = $db->query(
+ "SELECT * FROM $db_sbr_stages WHERE stage_sid=" . $id . " AND stage_status='process' AND stage_num=" . $num
+ )->fetch()) {
+ $rtext = cot_import('rtext', 'P', 'TXT');
+
+ /* === Hook === */
+ foreach (cot_getextplugins('sbr.stage.done.first') as $pl) {
+ include $pl;
+ }
+ /* ===== */
+
+ $rstage['stage_done'] = Cot::$sys['now'];
+ $rstage['stage_status'] = 'done';
+
+ $feePerformer = !empty($cfg['plugin']['sbr']['tax_performer']) ? $cfg['plugin']['sbr']['tax_performer'] : '0';
+ $feePerformerAmount = bcmul($stage['stage_cost'], $feePerformer, 5);
+ $feePerformerAmount = bcdiv($feePerformerAmount, '100', 5);
+ $payPerformerAmount = '0';
+
+ $feeEmployer = !empty($cfg['plugin']['sbr']['tax']) ? $cfg['plugin']['sbr']['tax'] : '0';
+ $feeEmployerAmount = bcmul($stage['stage_cost'], $feeEmployer, 5);
+ $feeEmployerAmount = bcdiv($feeEmployerAmount, '100', 5);
+
+ $feeTotal = bcadd($feePerformer, $feeEmployer, 5);
+ $feeTotalAmount = bcmul($stage['stage_cost'], $feeTotal, 5);
+ $feeTotalAmount = bcdiv($feeTotalAmount, '100', 5);
+
+ if ($db->update($db_sbr_stages, $rstage, "stage_sid=" . $id . " AND stage_num=" . $num)) {
+ $payPerformerAmount = bcsub($stage['stage_cost'], $feePerformerAmount, 5);
+
+ // Выплата Исполнителю
+ $payinfo['pay_userid'] = $sbr['sbr_performer'];
+ $payinfo['pay_area'] = PaymentDictionary::PAYMENT_SOURCE_BALANCE;
+ $payinfo['pay_code'] = 'sbr:' . $id . ';stage:' . $stage['stage_num'];
+ $payinfo['pay_summ'] = $payPerformerAmount; // @todo Округлить до двух знаков после запятой?
+ $payinfo['pay_cdate'] = Cot::$sys['now'];
+ $payinfo['pay_pdate'] = Cot::$sys['now'];
+ $payinfo['pay_adate'] = Cot::$sys['now'];
+ $payinfo['pay_status'] = 'done';
+ $payinfo['pay_desc'] = cot_rc(Cot::$L['sbr_stage_done_payments_desc'],
+ array(
+ 'sbr_title' => $sbr['sbr_title'],
+ 'stage_title' => $stage['stage_title'],
+ 'stage_num' => $stage['stage_num']
+ )
+ );
+
+ if (Cot::$db->insert($db_payments, $payinfo)) {
+ if (Cot::$cfg['plugin']['sbr']['adminid'] > 0 && ((float) $feeTotal) > 0) {
+ $payinfo['pay_userid'] = Cot::$cfg['plugin']['sbr']['adminid'];
+ $payinfo['pay_area'] = PaymentDictionary::PAYMENT_SOURCE_BALANCE;
+ $payinfo['pay_code'] = 'sbr:' . $id . ';stage:' . $stage['stage_num'];
+ $payinfo['pay_summ'] = $feeTotalAmount;
+ $payinfo['pay_cdate'] = Cot::$sys['now'];
+ $payinfo['pay_pdate'] = Cot::$sys['now'];
+ $payinfo['pay_adate'] = Cot::$sys['now'];
+ $payinfo['pay_status'] = 'done';
+ $payinfo['pay_desc'] = cot_rc(Cot::$L['sbr_stage_tax_payments_desc'],
+ array(
+ 'sbr_title' => $sbr['sbr_title'],
+ 'stage_title' => $stage['stage_title'],
+ 'stage_num' => $stage['stage_num']
+ )
+ );
+
+ $db->insert($db_payments, $payinfo);
+ }
+
+ if (!empty($rtext)) {
+ cot_sbr_sendpost($id, $rtext, $sbr['sbr_performer'], $usr['id']);
+ }
+
+ cot_sbr_sendpost(
+ $id,
+ cot_rc($L['sbr_posts_performer_stage_done'],
+ array(
+ 'stage_num' => $stage['stage_num'],
+ 'stage_title' => $stage['stage_title'],
+ 'stage_cost' => $stage['stage_cost'],
+ 'valuta' => $cfg['payments']['valuta'],
+ )
+ ),
+ $sbr['sbr_performer'],
+ 0,
+ 'success',
+ true
+ );
+
+ cot_sbr_sendpost(
+ $id,
+ cot_rc($L['sbr_posts_employer_stage_done'],
+ array(
+ 'stage_num' => $stage['stage_num'],
+ 'stage_title' => $stage['stage_title'],
+ 'stage_cost' => $stage['stage_cost'],
+ 'valuta' => $cfg['payments']['valuta'],
+ )
+ ),
+ $sbr['sbr_employer'],
+ 0,
+ 'success',
+ true
+ );
+
+ // Запуск следующего этапа на исполнение, если он существует
+ $nextstagenum = $num + 1;
+ if($nstageid = $db->query("SELECT stage_id FROM $db_sbr_stages WHERE stage_sid=" . $id . " AND stage_num=" . $nextstagenum)->fetchColumn())
+ {
+ $nstage['stage_begin'] = $sys['now'];
+ $nstage['stage_status'] = 'process';
+ $db->update($db_sbr_stages, $nstage, "stage_id=" . $nstageid);
+ }
+
+ // Если нет этапов на исполнении, то завершить сделку полностью
+ $notstartedstages = (bool) $db->query("SELECT COUNT(*) FROM $db_sbr_stages WHERE stage_sid=" . $id . " AND stage_status='process'")->fetchColumn();
+ if (!$notstartedstages) {
+ $rsbr['sbr_done'] = $sys['now'];
+ $rsbr['sbr_status'] = 'done';
+ $db->update($db_sbr, $rsbr, "sbr_id=" . $id);
+
+ cot_sbr_sendpost($id, $L['sbr_posts_performer_done'], $sbr['sbr_performer'], 0, 'success', true);
+ cot_sbr_sendpost($id, $L['sbr_posts_employer_done'], $sbr['sbr_employer'], 0, 'success', true);
+ }
+
+ /* === Hook === */
+ foreach (cot_getextplugins('sbr.stage.done.done') as $pl) {
+ include $pl;
+ }
+ /* ===== */
+ }
+ }
+ }
+
+ $urlParams = ['id' => $id,];
+ $stagesCount = cot::$db->query(
+ 'SELECT COUNT(*) FROM ' . Cot::$db->sbr_stages . ' WHERE stage_sid = :id',
+ ['id' => $id,]
+ )->fetchColumn();
+ if (cot::$cfg['plugin']['sbr']['stages_on'] && $stagesCount > 1) {
+ $urlParams['num'] = $num;
+ }
+
+ cot_redirect(cot_url('sbr', $urlParams, '', true));
+ }
+
+// Действия только для Исполнителя
+} elseif (cot::$usr['id'] == $sbr['sbr_performer']) {
+ $role = 'performer';
+
+ // Если сделка на согласовании, то можно подтвердить участие
+ if ($a == 'confirm' && $sbr['sbr_status'] == 'new') {
+ /* === Hook === */
+ foreach (cot_getextplugins('sbr.confirm.first') as $pl) {
+ include $pl;
+ }
+ /* ===== */
+
+ // Отправка уведомления Заказчику
+
+ // Изменение статуса сделки
+ if($db->update($db_sbr, array('sbr_status' => 'confirm'), "sbr_id=" . $id))
+ {
+
+ cot_sbr_sendpost($id, $L['sbr_posts_performer_confirm'], $sbr['sbr_performer'], 0, 'info', true);
+ cot_sbr_sendpost($id, $L['sbr_posts_employer_confirm'], $sbr['sbr_employer'], 0, 'info', true);
+
+ /* === Hook === */
+ foreach (cot_getextplugins('sbr.confirm.done') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+ }
+
+ cot_redirect(cot_url('sbr', 'id=' . $id, '', true));
+ }
+
+ // Если сделка согласована или на согласовании, то еще можно отказаться. В иных случаях отказаться можно только через арбитраж.
+ if($a == 'refuse' && ($sbr['sbr_status'] == 'new' || $sbr['sbr_status'] == 'confirm'))
+ {
+ /* === Hook === */
+ foreach (cot_getextplugins('sbr.refuse.first') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+
+ // Отправка уведомления Заказчику
+
+ // Изменение статуса сделки
+ if($db->update($db_sbr, array('sbr_status' => 'refuse'), "sbr_id=" . $id))
+ {
+ cot_sbr_sendpost($id, $L['sbr_posts_performer_refuse'], $sbr['sbr_performer'], 0, 'warning', true);
+ cot_sbr_sendpost($id, $L['sbr_posts_employer_refuse'], $sbr['sbr_employer'], 0, 'warning', true);
+
+ /* === Hook === */
+ foreach (cot_getextplugins('sbr.refuse.done') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+ }
+
+ cot_redirect(cot_url('sbr', 'id=' . $id, '', true));
+ }
+}
+
+// Обращение в арбитраж
+if (!empty($num) && $a == 'claim' && $sbr['sbr_status'] == 'process') {
+ cot_shield_protect();
+
+ $urlParams = ['id' => $id,];
+ $stagesCount = cot::$db->query(
+ 'SELECT COUNT(*) FROM ' . cot::$db->sbr_stages . ' WHERE stage_sid = :id',
+ ['id' => $id,]
+ )->fetchColumn();
+ if (cot::$cfg['plugin']['sbr']['stages_on'] && $stagesCount > 1) {
+ $urlParams['num'] = $num;
+ }
+
+ if($stage = $db->query("SELECT * FROM $db_sbr_stages WHERE stage_sid=" . $id . " AND stage_status='process' AND stage_num=" . $num)->fetch())
+ {
+
+ $rtext = cot_import('rtext', 'P', 'TXT');
+
+ /* === Hook === */
+ foreach (cot_getextplugins('sbr.stage.claim.import') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+
+ cot_check(empty($rtext), 'sbr_claim_add_error_text', 'rtext');
+
+ if(!cot_error_found())
+ {
+ $rclaim['claim_text'] = $rtext;
+ $rclaim['claim_from'] = $usr['id'];
+ $rclaim['claim_date'] = $sys['now'];
+ $rclaim['claim_sid'] = $id;
+ $rclaim['claim_stage'] = $num;
+ $rclaim['claim_status'] = 'new';
+
+ if($db->insert($db_sbr_claims, $rclaim))
+ {
+ $rstage['stage_claim'] = $sys['now'];
+ $rstage['stage_status'] = 'claim';
+
+ if($db->update($db_sbr_stages, $rstage, "stage_sid=" . $id . " AND stage_num=" . $num))
+ {
+ cot_sbr_sendpost(
+ $id,
+ cot_rc(
+ $L['sbr_posts_stage_claim'], array(
+ 'from_name' => $usr['name'],
+ 'claim_text' => $rclaim['claim_text'],
+ )
+ ),
+ $sbr['sbr_performer'],
+ 0,
+ 'error',
+ true
+ );
+ cot_sbr_sendpost(
+ $id,
+ cot_rc(
+ $L['sbr_posts_stage_claim'], array(
+ 'from_name' => $usr['name'],
+ 'claim_text' => $rclaim['claim_text'],
+ )
+ ),
+ $sbr['sbr_employer'],
+ 0,
+ 'error',
+ true
+ );
+
+ $db->update($db_sbr, array('sbr_claim' => $sys['now'], 'sbr_status' => 'claim'), "sbr_id=" . $id);
+ }
+ }
+ cot_redirect(cot_url('sbr', $urlParams, '', true));
+ }
+ }
+
+ $urlParams['action'] = 'claim';
+ cot_redirect(cot_url('sbr', $urlParams, '', true));
+}
+
+// Принятие решения арбитражной комиссией
+if (!empty($num) && $a == 'decision' && $sbr['sbr_status'] == 'claim' && $usr['isadmin']) {
+ cot_shield_protect();
+
+ $urlParams = ['id' => $id,];
+ $stagesCount = cot::$db->query(
+ 'SELECT COUNT(*) FROM ' . cot::$db->sbr_stages . ' WHERE stage_sid = :id',
+ ['id' => $id,]
+ )->fetchColumn();
+
+ if (cot::$cfg['plugin']['sbr']['stages_on'] && $stagesCount > 1) {
+ $urlParams['num'] = $num;
+ }
+
+ if (
+ $stage = $db->query(
+ "SELECT * FROM $db_sbr_stages WHERE stage_sid=" . $id . " AND stage_status='claim' AND stage_num=" . $num
+ )->fetch()
+ ) {
+ $rtext = cot_import('rdecisiontext', 'P', 'TXT');
+ $payPerformer = cot_import('payperformer', 'P', 'NUM');
+ $payEmployer = cot_import('payemployer', 'P', 'NUM');
+
+ /* === Hook === */
+ foreach (cot_getextplugins('sbr.stage.decision.import') as $pl) {
+ include $pl;
+ }
+ /* ===== */
+
+ cot_check(empty($rtext), 'sbr_claim_decision_error_text', 'rdecisiontext');
+ cot_check(($payPerformer + $payEmployer != $stage['stage_cost']), 'sbr_claim_decision_error_pay', 'payemployer');
+
+ if (!cot_error_found()) {
+ $rclaim['claim_done'] = $sys['now'];
+ $rclaim['claim_status'] = 'new';
+
+ Cot::$db->beginTransaction();
+ try {
+ if ($db->update($db_sbr_claims, $rclaim, "claim_sid=" . $id . " AND claim_stage=" . $num)) {
+ $rstage['stage_done'] = $sys['now'];
+ $rstage['stage_status'] = 'done';
+
+ $feePerformer = !empty($cfg['plugin']['sbr']['tax_performer']) ? $cfg['plugin']['sbr']['tax_performer'] : '0';
+ $feePerformerAmount = bcmul($payPerformer, $feePerformer, 5);
+ $feePerformerAmount = bcdiv($feePerformerAmount, '100', 5);
+ $payPerformerAmount = '0';
+
+ $feeEmployer = !empty($cfg['plugin']['sbr']['tax']) ? $cfg['plugin']['sbr']['tax'] : '0';
+
+ // Комиссия считается только на сумму, выплаченную исполнителю
+ $feeTotal = bcadd($feePerformer, $feeEmployer, 5);
+ $feeTotalAmount = bcmul($payPerformer, $feeTotal, 5);
+ $feeTotalAmount = bcdiv($feeTotalAmount, '100', 5);
+
+ if ($db->update($db_sbr_stages, $rstage, "stage_sid=" . $id . " AND stage_num=" . $num)) {
+ $payPerformerAmount = bcsub($payPerformer, $feePerformerAmount, 5);
+
+ // Выплата Исполнителю
+ if ($payPerformer > 0) {
+ $payinfo['pay_userid'] = $sbr['sbr_performer'];
+ $payinfo['pay_area'] = PaymentDictionary::PAYMENT_SOURCE_BALANCE;
+ $payinfo['pay_code'] = 'sbr:' . $id . ';stage:' . $num;
+ $payinfo['pay_summ'] = $payPerformerAmount;
+ $payinfo['pay_cdate'] = $sys['now'];
+ $payinfo['pay_pdate'] = $sys['now'];
+ $payinfo['pay_adate'] = $sys['now'];
+ $payinfo['pay_status'] = PaymentDictionary::STATUS_DONE;
+ $payinfo['pay_desc'] = cot_rc(
+ Cot::$L['sbr_claim_payments_performer_desc'],
+ [
+ 'sbr_title' => $sbr['sbr_title'],
+ 'stage_title' => $stage['stage_title'],
+ 'stage_num' => $stage['stage_num']
+ ]
+ );
+
+ if (Cot::$db->insert($db_payments, $payinfo)) {
+ if (Cot::$cfg['plugin']['sbr']['adminid'] > 0 && ((float) $feeTotal) > 0) {
+ $payinfo['pay_userid'] = Cot::$cfg['plugin']['sbr']['adminid'];
+ $payinfo['pay_area'] = PaymentDictionary::PAYMENT_SOURCE_BALANCE;
+ $payinfo['pay_code'] = 'sbr:' . $id . ';stage:' . $num;
+ $payinfo['pay_summ'] = $feeTotalAmount;
+ $payinfo['pay_cdate'] = Cot::$sys['now'];
+ $payinfo['pay_pdate'] = Cot::$sys['now'];
+ $payinfo['pay_adate'] = Cot::$sys['now'];
+ $payinfo['pay_status'] = PaymentDictionary::STATUS_DONE;
+ $payinfo['pay_desc'] = cot_rc(
+ Cot::$L['sbr_claim_payments_admin_desc'],
+ [
+ 'sbr_title' => $sbr['sbr_title'],
+ 'stage_title' => $stage['stage_title'],
+ 'stage_num' => $stage['stage_num']
+ ]
+ );
+
+ $db->insert($db_payments, $payinfo);
+ }
+ }
+ }
+
+ // Выплата Заказчику
+ if ($payEmployer > 0) {
+ $payinfo['pay_userid'] = $sbr['sbr_employer'];
+ $payinfo['pay_area'] = PaymentDictionary::PAYMENT_SOURCE_BALANCE;
+ $payinfo['pay_code'] = 'sbr:' . $id . ';stage:' . $num;
+ $payinfo['pay_summ'] = $payEmployer; // @todo удержать комиссию?
+ $payinfo['pay_cdate'] = Cot::$sys['now'];
+ $payinfo['pay_pdate'] = Cot::$sys['now'];
+ $payinfo['pay_adate'] = Cot::$sys['now'];
+ $payinfo['pay_status'] = PaymentDictionary::STATUS_DONE;
+ $payinfo['pay_desc'] = cot_rc(
+ Cot::$L['sbr_claim_payments_employer_desc'],
+ [
+ 'sbr_title' => $sbr['sbr_title'],
+ 'stage_title' => $stage['stage_title'],
+ 'stage_num' => $stage['stage_num'],
+ ]
+ );
+
+ Cot::$db->insert($db_payments, $payinfo);
+ }
+
+ cot_sbr_sendpost(
+ $id,
+ cot_rc(
+ $L['sbr_posts_performer_stage_claim_decision_payment'],
+ [
+ 'sbr_title' => $sbr['sbr_title'],
+ 'stage_title' => $stage['stage_title'],
+ 'stage_num' => $stage['stage_num'],
+ 'payperformer' => (!empty($payPerformer)) ? $payPerformer : 0,
+ 'payemployer' => (!empty($payEmployer)) ? $payEmployer : 0,
+ 'decision' => $rtext,
+ 'valuta' => $cfg['payments']['valuta'],
+ ]
+ ),
+ $sbr['sbr_performer'],
+ 0,
+ 'warning',
+ true
+ );
+ cot_sbr_sendpost(
+ $id,
+ cot_rc(
+ $L['sbr_posts_employer_stage_claim_decision_payment'],
+ [
+ 'sbr_title' => $sbr['sbr_title'],
+ 'stage_title' => $stage['stage_title'],
+ 'stage_num' => $stage['stage_num'],
+ 'payperformer' => (!empty($payPerformer)) ? $payPerformer : 0,
+ 'payemployer' => (!empty($payEmployer)) ? $payEmployer : 0,
+ 'decision' => $rtext,
+ 'valuta' => $cfg['payments']['valuta'],
+ ]
+ ),
+ $sbr['sbr_employer'],
+ 0,
+ 'warning',
+ true
+ );
+
+ // Запуск следующего этапа на исполнение, если он существует
+ $nextstagenum = $num + 1;
+ if ($nstageid = $db->query(
+ "SELECT stage_id FROM $db_sbr_stages WHERE stage_sid=" . $id . " AND stage_num=" . $nextstagenum
+ )->fetchColumn()) {
+ $nstage['stage_begin'] = $sys['now'];
+ $nstage['stage_status'] = 'process';
+ $db->update($db_sbr_stages, $nstage, "stage_id=" . $nstageid);
+ }
+
+ // Если нет этапов на исполнении, то завершить сделку полностью
+ $notstartedstages = (bool)$db->query(
+ "SELECT COUNT(*) FROM $db_sbr_stages WHERE stage_sid=" . $id . " AND stage_status='process'"
+ )->fetchColumn();
+ if (!$notstartedstages) {
+ $rsbr['sbr_done'] = $sys['now'];
+ $rsbr['sbr_status'] = 'done';
+ $db->update($db_sbr, $rsbr, "sbr_id=" . $id);
+
+ cot_sbr_sendpost(
+ $id,
+ $L['sbr_posts_performer_done'],
+ $sbr['sbr_performer'],
+ 0,
+ 'success',
+ true
+ );
+ cot_sbr_sendpost(
+ $id,
+ $L['sbr_posts_employer_done'],
+ $sbr['sbr_employer'],
+ 0,
+ 'success',
+ true
+ );
+ } else {
+ $db->update(
+ $db_sbr,
+ ['sbr_claim' => $sys['now'], 'sbr_status' => 'process'],
+ "sbr_id=" . $id
+ );
+ }
+
+ /* === Hook === */
+ foreach (cot_getextplugins('sbr.stage.done.done') as $pl) {
+ include $pl;
+ }
+ /* ===== */
+ }
+ }
+ Cot::$db->commit();
+ } catch (Throwable $e) {
+ Cot::$db->rollback();
+ throw $e;
+ }
+
+ cot_redirect(cot_url('sbr', $urlParams, '', true));
+ }
+ }
+
+ $urlParams['action'] = 'decision';
+ cot_redirect(cot_url('sbr', $urlParams, '', true));
+}
+
+$to = null;
+if ($a == 'addpost') {
+ cot_shield_protect();
+
+ $rposttext = cot_import('rposttext', 'P', 'HTM');
+ $to = cot_import('to', 'P', 'ALP');
+
+ /* === Hook === */
+ foreach (cot_getextplugins('sbr.post.add.import') as $pl) {
+ include $pl;
+ }
+ /* ===== */
+
+ if (empty($_FILES)) {
+ cot_check(empty($rposttext), $L['sbr_posts_error_textempty'], 'rposttext');
+ }
+
+ if (!cot_error_found()) {
+ $post_type = '';
+ if (cot::$usr['isadmin']) {
+ if ($to != 'all') {
+ $recipient = ($to == 'employer') ? $sbr['sbr_employer'] : $sbr['sbr_performer'];
+ } else {
+ $recipient = 0;
+ $post_type = 'info';
+ }
+ } else {
+ $recipient = ($role == 'employer') ? $sbr['sbr_performer'] : $sbr['sbr_employer'];
+ }
+
+ $postid = cot_sbr_sendpost($id, $rposttext, $recipient, $usr['id'], $post_type, true, $_FILES['rpostfiles']);
+ }
+
+ $urlParams = ['id' => $id,];
+ $stagesCount = cot::$db->query(
+ 'SELECT COUNT(*) FROM ' . cot::$db->sbr_stages . ' WHERE stage_sid = :id',
+ ['id' => $id,]
+ )->fetchColumn();
+ if (cot::$cfg['plugin']['sbr']['stages_on'] && $stagesCount > 1) {
+ $urlParams['num'] = $num;
+ }
+
+ cot_redirect(cot_url('sbr', $urlParams, '#addpost', true));
+}
+
+$out['subtitle'] = $sbr['sbr_title'];
+$out['head'] .= $R['code_noindex'];
+
+$mskin = cot_tplfile(array('sbr', $role), 'plug');
+
+/* === Hook === */
+foreach (cot_getextplugins('sbr.main') as $pl)
+{
+ include $pl;
+}
+/* ===== */
+
+$t = new XTemplate($mskin);
+
+$t->assign(cot_generate_projecttags($sbr['sbr_pid'], 'SBR_PROJECT_'));
+$t->assign(cot_generate_usertags($sbr['sbr_employer'], 'SBR_EMPLOYER_'));
+$t->assign(cot_generate_usertags($sbr['sbr_performer'], 'SBR_PERFORMER_'));
+$t->assign(cot_generate_sbrtags($sbr, 'SBR_', $usr['isadmin'], $cfg['homebreadcrumb']));
+
+$sqllist_rowset = $db->query("SELECT * FROM $db_sbr_stages WHERE stage_sid=" . $id . " ORDER BY stage_num ASC")->fetchAll();
+$stagesCount = 0;
+if (!empty($sqllist_rowset)) {
+ foreach ($sqllist_rowset as $stage) {
+ $stagesCount++;
+ $t->assign(array(
+ 'STAGENAV_ROW_ID' => $stage['stage_id'],
+ 'STAGENAV_ROW_NUM' => $stage['stage_num'],
+ 'STAGENAV_ROW_TITLE' => $stage['stage_title'],
+ 'STAGENAV_ROW_TEXT' => $stage['stage_text'],
+ 'STAGENAV_ROW_STATUS' => $stage['stage_status'],
+ 'STAGENAV_ROW_URL' => cot_url('sbr', 'id=' . $id . '&num=' . $stage['stage_num']),
+ ));
+ $t->parse('MAIN.STAGENAV_ROW');
+ }
+}
+if (empty($action)) {
+ if (!empty($num)) {
+ require_once cot_incfile('sbr', 'plug', 'stage');
+ } else {
+ require_once cot_incfile('sbr', 'plug', 'info');
+ // Информацию о последнем (или единственном этапе) сделки выводим и на основной странице сделки
+ if (!empty($stage['stage_num'])) {
+ $num = $stage['stage_num'];
+ require_once cot_incfile('sbr', 'plug', 'stage');
+ $num = 0;
+ }
+ }
+
+ if (!empty($role)) {
+ $query_string = " AND (post_to=0 OR post_to=" . $usr['id'] . " OR post_from=" . $usr['id'] . ")";
+ }
+ /* === Hook === */
+ foreach (cot_getextplugins('sbr.posts.query') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+ $posts = $db->query("SELECT * FROM $db_sbr_posts
+ WHERE post_sid=" . $id . " ".$query_string ."
+ ORDER BY post_date ASC")->fetchAll();
+
+ /* === Hook === */
+ $extp = cot_getextplugins('sbr.posts.loop');
+ /* ===== */
+
+ foreach ($posts as $post)
+ {
+ if($post['post_from'] > 0)
+ {
+ $t->assign(cot_generate_usertags($post['post_from'], 'POST_ROW_FROM_'));
+ }
+ else
+ {
+ $t->assign('POST_ROW_FROM_NAME', '');
+ }
+
+ if($post['post_to'] > 0)
+ {
+ $t->assign(cot_generate_usertags($post['post_to'], 'POST_ROW_TO_'));
+ }
+ else
+ {
+ $t->assign('POST_ROW_TO_NAME', '');
+ }
+
+ $t->assign(array(
+ 'POST_ROW_FROM_ID' => $post['post_from'],
+ 'POST_ROW_ID' => $post['post_id'],
+ 'POST_ROW_TEXT' => $post['post_text'],
+ 'POST_ROW_TYPE' => $post['post_type'],
+ 'POST_ROW_DATE' => date('d.m.Y H:i:s', $post['post_date']),
+ ));
+ /* === Hook - Part2 : Include === */
+ foreach ($extp as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+
+ $postfiles = $db->query("SELECT * FROM $db_sbr_files WHERE file_sid=" . $id . " AND file_area='post' AND file_code='".$post['post_id']."' ORDER BY file_id ASC")->fetchAll();
+ if(count($postfiles) > 0)
+ {
+ foreach($postfiles as $file)
+ {
+ $t->assign(array(
+ 'FILE_ROW_ID' => $file['file_id'],
+ 'FILE_ROW_URL' => $file['file_url'],
+ 'FILE_ROW_TITLE' => $file['file_title'],
+ 'FILE_ROW_EXT' => $file['file_ext'],
+ 'FILE_ROW_SIZE' => $file['file_size'],
+ ));
+ $t->parse('MAIN.SBR.POSTS.POST_ROW.FILES.FILE_ROW');
+ }
+ $t->parse('MAIN.SBR.POSTS.POST_ROW.FILES');
+ }
+ $t->parse('MAIN.SBR.POSTS.POST_ROW');
+ }
+
+ $t->assign([
+ 'POST_FORM_ACTION' => cot_url('sbr', 'id=' . $id . '&num=' . $num . '&a=addpost'),
+ 'POST_FORM_TO' => cot_selectbox($to, 'to', $R['sbr_posts_to_values'], $R['sbr_posts_to_titles']),
+ 'STAGES_COUNT' => $stagesCount,
+ ]);
+
+ // cot_display_messages($t, 'MAIN.SBR.POSTS.POSTFORM');
+
+ $t->parse('MAIN.SBR.POSTS.POSTFORM');
+
+ $t->parse('MAIN.SBR.POSTS');
+
+ /* === Hook === */
+ foreach (cot_getextplugins('sbr.tags') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+
+ cot_display_messages($t, 'MAIN.SBR');
+
+ $t->parse('MAIN.SBR');
+}
+
+$urlParams = ['id' => $id, 'num' => $num,];
+if ($action == 'done') {
+ // Действие доступно только для заказчика
+ cot_block($role == 'employer');
+
+ $urlParams['a'] = 'done';
+ $t->assign([
+ 'STAGEDONE_FORM_ACTION' => cot_url('sbr', $urlParams),
+ 'STAGEDONE_FORM_TEXT' => cot_textarea('rtext', (isset($rtext) ? $rtext : ''), 5, 80),
+ ]);
+
+ cot_display_messages($t, 'MAIN.STAGEDONE');
+
+ $t->parse('MAIN.STAGEDONE');
+}
+
+if ($action == 'claim') {
+ $stage = $db->query("SELECT * FROM $db_sbr_stages WHERE stage_sid=" . $id . " AND stage_num=" . $num)->fetch();
+
+ cot_block(!empty($role) && $sbr['sbr_status'] == 'process' && $stage['stage_status'] == 'process');
+
+ $urlParams['a'] = 'claim';
+ $t->assign([
+ 'CLAIM_FORM_ACTION' => cot_url('sbr', $urlParams),
+ 'CLAIM_FORM_TEXT' => cot_textarea('rtext', $rtext, 5, 80),
+ ]);
+
+ cot_display_messages($t, 'MAIN.CLAIM');
+
+ $t->parse('MAIN.CLAIM');
+}
+
+if ($action == 'decision') {
+ cot_block($usr['isadmin'] && $sbr['sbr_status'] == 'claim');
+
+ $urlParams['a'] = 'decision';
+ $t->assign(array(
+ 'DECISION_FORM_ACTION' => cot_url('sbr', $urlParams),
+ 'DECISION_FORM_TEXT' => cot_textarea('rdecisiontext', $rtext ?? '', 5, 80),
+ 'DECISION_FORM_PAYPERFORMER' => cot_inputbox('text', 'payperformer', $payPerformer ?? 0),
+ 'DECISION_FORM_PAYEMPLOYER' => cot_inputbox('text', 'payemployer', $payEmployer ?? 0),
+ ));
+
+ cot_display_messages($t, 'MAIN.DECISION');
+
+ $t->parse('MAIN.DECISION');
+}
\ No newline at end of file
diff --git a/plugins/sbr/inc/sbr.resources.php b/plugins/sbr/inc/sbr.resources.php
new file mode 100644
index 0000000..346e3df
--- /dev/null
+++ b/plugins/sbr/inc/sbr.resources.php
@@ -0,0 +1,34 @@
+ 'default',
+ 'refuse' => 'inverse',
+ 'new' => 'warning',
+ 'confirm' => 'warning',
+ 'process' => 'info',
+ 'done' => 'success',
+ 'claim' => 'important'
+);
+
+$R['sbr_posts_to_values'] = array('all', 'performer', 'employer');
+$R['sbr_posts_to_titles'] = array($L['sbr_posts_to_all'], $L['sbr_posts_to_performer'], $L['sbr_posts_to_employer']);
\ No newline at end of file
diff --git a/plugins/sbr/inc/sbr.stage.php b/plugins/sbr/inc/sbr.stage.php
new file mode 100644
index 0000000..af4f538
--- /dev/null
+++ b/plugins/sbr/inc/sbr.stage.php
@@ -0,0 +1,79 @@
+query(
+ 'SELECT * FROM ' . cot::$db->sbr_stages . ' WHERE stage_sid = ? AND stage_num = ? LIMIT 1',
+ [$id, $num]
+ );
+ $stage = $sql->fetch();
+}
+
+if (!empty($stage)) {
+ $expireDate = !empty($stage['stage_expire']) ?
+ $stage['stage_expire'] : $stage['stage_begin'] + $stage['stage_days'] * 24 * 60 * 60;
+
+ $t->assign(array(
+ 'STAGE_NUM' => $stage['stage_num'],
+ 'STAGE_ID' => $stage['stage_id'],
+ 'STAGE_TITLE' => $stage['stage_title'],
+ 'STAGE_TEXT' => $stage['stage_text'],
+ 'STAGE_COST' => $stage['stage_cost'],
+ 'STAGE_DAYS' => $stage['stage_days'],
+ 'STAGE_STATUS' => $stage['stage_status'],
+ 'STAGE_BEGIN' => $stage['stage_begin'],
+ 'STAGE_DONE' => $stage['stage_done'],
+ 'STAGE_EXPIRE' => $stage['stage_expire'],
+ 'STAGE_EXPIREDATE' => $expireDate,
+ 'STAGE_EXPIREDAYS' => cot_build_timegap(cot::$sys['now'], $expireDate),
+ 'STAGE_DONE_URL' => cot_url('sbr', 'id=' . $id . '&num=' . $stage['stage_num'] . '&action=done'),
+ 'STAGE_CLAIM_URL' => cot_url('sbr', 'id=' . $id . '&num=' . $stage['stage_num'] . '&action=claim'),
+ 'STAGE_DECISION_URL' => cot_url('sbr', 'id=' . $id . '&num=' . $stage['stage_num'] . '&action=decision'),
+ ));
+
+ $stagefiles = $db->query("SELECT * FROM $db_sbr_files WHERE file_sid=" . $id . " AND file_area='stage' AND file_code='" . $stage['stage_num'] . "' ORDER BY file_id ASC")->fetchAll();
+ if (count($stagefiles) > 0) {
+ foreach ($stagefiles as $file) {
+ $t->assign(array(
+ 'FILE_ROW_ID' => $file['file_id'],
+ 'FILE_ROW_URL' => $file['file_url'],
+ 'FILE_ROW_TITLE' => $file['file_title'],
+ 'FILE_ROW_EXT' => $file['file_ext'],
+ 'FILE_ROW_SIZE' => $file['file_size'],
+ ));
+ $t->parse('MAIN.SBR.STAGE.FILES.FILE_ROW');
+ }
+ $t->parse('MAIN.SBR.STAGE.FILES');
+ }
+}
+/* === Hook === */
+foreach (cot_getextplugins('sbr.stage.tags') as $pl) {
+ include $pl;
+}
+/* ===== */
+
+$t->parse('MAIN.SBR.STAGE');
diff --git a/plugins/sbr/lang/sbr.en.lang.php b/plugins/sbr/lang/sbr.en.lang.php
new file mode 100644
index 0000000..9cc3243
--- /dev/null
+++ b/plugins/sbr/lang/sbr.en.lang.php
@@ -0,0 +1,193 @@
+
Бюджет и сроки ';
+$L['sbr_nav_stagenum'] = 'Этап №';
+
+$L['sbr_employer'] = 'Заказчик';
+$L['sbr_performer'] = 'Исполнитель';
+$L['sbr_performer_placeholder'] = 'Введите логин исполнителя';
+$L['sbr_sbrTitle'] = 'Deal name';
+$L['sbr_stagetitle'] = 'Название';
+$L['sbr_stagetext'] = 'Техническое задание';
+$L['sbr_stagecost'] = 'Бюджет';
+$L['sbr_stagedays'] = 'Сроки';
+$L['sbr_stagefiles'] = 'Файлы';
+$L['sbr_stagestart'] = 'Старт этапа';
+$L['sbr_stagedone'] = 'Приемка этапа';
+$L['sbr_stageexpiredays'] = 'Осталось';
+$L['sbr_stageexpired'] = 'Срок исполнения истек!';
+$L['sbr_stagemenu'] = 'Решение по этапу';
+$L['sbr_mincost'] = 'минимальный бюджет';
+$L['sbr_maxdays'] = 'отсчет времени начнется с момента резервирования денег, максимальное время этапа';
+
+$L['sbr_sendtoconfirm'] = 'Отправить на согласование';
+
+$L['sbr_info'] = 'Общая информация';
+$L['sbr_stage'] = 'Этап';
+$L['sbr_history'] = 'История сделки';
+$L['sbr_calc_title'] = 'Расчет суммы сделки с учетом комиссии';
+$L['sbr_calc_summ'] = 'Сумма сделки';
+$L['sbr_calc_tax'] = 'Комиссия сервиса';
+$L['sbr_calc_total'] = 'Итого к оплате';
+
+$L['sbr_addstagelink'] = 'Добавить этап';
+
+$L['sbr_status_title'] = 'Статус сделки';
+
+$L['sbr_deals_all'] = 'Все сделки';
+$L['sbr_deals_cancel'] = 'Отмененные';
+$L['sbr_deals_refuse'] = 'Не согласованные';
+$L['sbr_deals_new'] = 'На согласовании';
+$L['sbr_deals_confirm'] = 'Оплатить';
+$L['sbr_deals_process'] = 'В работе';
+$L['sbr_deals_done'] = 'Завершенные';
+$L['sbr_deals_claim'] = 'Арбитраж';
+
+$L['sbr_status_cancel'] = 'Отмененная сделка';
+$L['sbr_status_refuse'] = 'Не согласованная';
+$L['sbr_status_new'] = 'На согласовании';
+$L['sbr_status_confirm'] = 'Ожидает оплаты';
+$L['sbr_status_process'] = 'В работе';
+$L['sbr_status_done'] = 'Завершенная сделка';
+$L['sbr_status_claim'] = 'Арбитраж';
+
+$L['sbr_error_fileToLarge'] = 'The file is too large. You can upload files no larger than {$size} MB.';
+$L['sbr_error_invalidFileType'] = 'Invalid file type';
+$L['sbr_error_rsbrperformer'] = 'Пользователь с указанным логином не найден';
+$L['sbr_error_rsbrperformernotyou'] = 'Вы не можете быть одновременно Исполнителем и Заказчиком';
+$L['sbr_error_rsbrtitle'] = 'Не указано название сделки';
+$L['sbr_error_rstagetitle'] = 'Не указано название';
+$L['sbr_error_rstagetext'] = 'Не заполнено техническое задание';
+$L['sbr_error_rstagecost'] = 'Не указан бюджет';
+$L['sbr_error_rstagecostmin'] = 'Бюджет слишком маленький';
+$L['sbr_error_rstagecostmax'] = 'Бюджет слишком большой';
+$L['sbr_error_rstagedays'] = 'Не указаны сроки';
+$L['sbr_error_rstagedaysmax'] = 'Сроки слишком большие';
+$L['sbr_error_uploadFile'] = 'File upload error: {$name}
{$error}';
+
+$L['sbr_action_confirm'] = 'Согласиться';
+$L['sbr_action_refuse'] = 'Отказаться';
+$L['sbr_action_cancel'] = 'Отменить сделку';
+$L['sbr_action_edit'] = 'Изменить';
+$L['sbr_action_pay'] = 'Оплатить сделку';
+$L['sbr_action_claim'] = 'Обратиться в арбитраж';
+$L['sbr_action_stagedone'] = 'Принять работу по этапу';
+
+$L['sbr_paydesc'] = 'Оплата сделки "{$sbr_title}"';
+
+$L['sbr_mail_toperformer_new_header'] = 'Согласование сделки "{$sbr_title}"';
+$L['sbr_mail_toperformer_new_body'] = 'Здравствуйте, {$performer_name}. '."\n\n".'
+ Заказчик {$employer_name}, предлагает вам заключить безопастную сделку "{$sbr_title}" с общим бюджетом {$sbr_cost}.
+ Более подробно ознакомиться с условиями сделки можно по ссылке: {$link}';
+
+$L['sbr_mail_toperformer_edited_header'] = 'Изменения в условиях сделки "{$sbr_title}"';
+$L['sbr_mail_toperformer_edited_body'] = 'Здравствуйте, {$performer_name}. '."\n\n".'
+ Заказчик {$employer_name}, изменил условия безопасной сделки "{$sbr_title}" и предлагает вам ознакомиться с ними.
+ Более подробно ознакомиться с условиями сделки можно по ссылке: {$link}';
+
+$L['sbr_mail_posts_header'] = 'Новое сообщение по сделке № {$sbr_id} ({$sbr_title})';
+$L['sbr_mail_posts_body'] = 'Здравствуйте, {$user_name}.
{$sender_name} отправил вам сообщение:
{$post_text}
Подробности смотрите по ссылке: {$link}';
+
+$L['sbr_mail_notification_header'] = 'Уведомнение по сделке № {$sbr_id} ({$sbr_title})';
+$L['sbr_mail_notification_body'] = 'Здравствуйте, {$user_name}.
{$post_text}
Подробности смотрите по ссылке: {$link}';
+
+$L['sbr_posts_performer_new'] = 'Пожалуйста, ознакомьтесь с условиями сделки и подтвердите свое участие. После этого Заказчик произведет оплату сделки и вы сможете приступить к работе.';
+$L['sbr_posts_employer_new'] = 'Сделка отправлена на согласование исполнителю. Как только исполнитель подтвердит свое участие, вы получите уведомление и сможете произвести оплату.';
+
+$L['sbr_posts_performer_edited'] = 'Пожалуйста, ознакомьтесь с новыми условиями сделки и подтвердите свое участие. После этого Заказчик произведет оплату сделки и вы сможете приступить к работе.';
+$L['sbr_posts_employer_edited'] = 'Сделка с изменеными условиями отправлена на согласование исполнителю. Как только исполнитель подтвердит свое участие, вы получите уведомление и сможете произвести оплату.';
+
+$L['sbr_posts_performer_refuse'] = 'Вы отказались от сделки. Заказчик может пересмотреть условия сделки и повторить процедуру согласования.';
+$L['sbr_posts_employer_refuse'] = 'Исполнитель отказался от сделки. Вы можете пересмотреть условия сделки и повторить процедуру согласования.';
+
+$L['sbr_posts_performer_confirm'] = 'Ожидается оплата сделки Заказчиком.';
+$L['sbr_posts_employer_confirm'] = 'Исполнитель подтвердил свое согласие с условиями сделки. Теперь вы можете произвести оплату, чтобы Исполнитель смог приступить к работе.';
+
+$L['sbr_posts_performer_paid'] = 'Сделка оформлена. Можете приступать к работе. Сумма сделки зарезервирована на счету сервиса и будет выплачиваться вам по мере приемки Заказчиком этапов сделки.';
+$L['sbr_posts_employer_paid'] = 'Сделка оформлена. Сумма сделки зарезервирована на счету сервиса и будет выплачиваться Исполнителю по мере вашей приемки этапов сделки.';
+
+$L['sbr_posts_performer_stage_done'] = 'Заказчик принял работу по этапу №{$stage_num} ({$stage_title}). На ваш счет поступила оплата в размере: {$stage_cost} {$valuta}';
+$L['sbr_posts_employer_stage_done'] = 'Вы приняли работы по этапу №{$stage_num} ({$stage_title}). На счет Исполнителя поступила оплата в размере: {$stage_cost} {$valuta}';
+
+$L['sbr_posts_stage_claim'] = '
Подана жалоба в арбитраж! Текст жалобы: {$from_name}: {$claim_text}
Сделка будет рассмотрена арбитражной комиссией. Как только комиссия примет решение, вы получите уведомление по email.';
+
+$L['sbr_posts_performer_stage_claim_decision_payment'] = '
Решение арбитражной комиссии По результатам рассмотрения жалобы по этапу №{$stage_num} ({$stage_title}) арбитражной комиссией было принято следующее решение:
{$decision}
Оплата Исполнителю: {$payperformer} {$valuta}
Возврат Заказчику: {$payemployer} {$valuta}';
+$L['sbr_posts_employer_stage_claim_decision_payment'] = '
Решение арбитражной комиссии По результатам рассмотрения жалобы по этапу №{$stage_num} ({$stage_title}) арбитражной комиссией было принято следующее решение:
{$decision}
Оплата Исполнителю: {$payperformer} {$valuta}
Возврат Заказчику: {$payemployer} {$valuta}';
+
+$L['sbr_posts_performer_cancel'] = 'Сделка отменена Заказчиком.';
+$L['sbr_posts_employer_cancel'] = 'Сделка отменена вами.';
+
+$L['sbr_posts_performer_done'] = 'Сделка завершена.';
+$L['sbr_posts_employer_done'] = 'Сделка завершена.';
+
+$L['sbr_posts_button'] = 'Отправить сообщение';
+
+$L['sbr_posts_to'] = 'Кому';
+$L['sbr_posts_to_all'] = 'Всем';
+$L['sbr_posts_to_performer'] = 'Исполнителю';
+$L['sbr_posts_to_employer'] = 'Заказчику';
+
+$L['sbr_posts_error_textempty'] = 'Сообщение не должно быть пустым';
+
+$L['sbr_posts_from'] = 'Сообщение от';
+$L['sbr_posts_for'] = 'Сообщение для';
+
+$L['sbr_stage_done_payments_desc'] = 'СБР: "{$sbr_title}": Оплата за этап №{$stage_num} ({$stage_title}).';
+$L['sbr_stage_tax_payments_desc'] = 'Доход с СБР: "{$sbr_title}": этап №{$stage_num} ({$stage_title}).';
+$L['sbr_stage_done_title'] = 'Принять работу по этапу';
+
+
+$L['sbr_claim_msg'] = 'Подана жалоба в арбитраж!';
+$L['sbr_claim_error_cost'] = 'Сумма выплат не соответствует общей стоимости этапа данной сделки';
+$L['sbr_claim_add_title'] = 'Обращение в арбитраж';
+$L['sbr_claim_add_error_text'] = 'Не указана причина обращения в арбитраж';
+
+$L['sbr_claim_payments_performer_desc'] = 'СБР: "{$sbr_title}": Оплата за этап №{$stage_num} ({$stage_title}), согласно решению арбитражной комиссии.';
+$L['sbr_claim_payments_employer_desc'] = 'СБР: "{$sbr_title}": Возврат за этап №{$stage_num} ({$stage_title}), согласно решению арбитражной комиссии.';
+$L['sbr_claim_payments_admin_desc'] = 'Доход с СБР: "{$sbr_title}": этап №{$stage_num} ({$stage_title}), согласно решению арбитражной комиссии.';
+
+$L['sbr_claim_decision_button'] = 'Принять решение';
+$L['sbr_claim_decision_title'] = 'Решение арбитражной комиссии';
+$L['sbr_claim_decision_pay_performer'] = 'Оплатить исполнителю';
+$L['sbr_claim_decision_pay_employer'] = 'Вернуть Заказчику';
+
+$L['sbr_claim_decision_error_text'] = 'Не заполнено пояснение к решению арбитражной комиссии';
+$L['sbr_claim_decision_error_pay'] = 'Сумма выплат не соответствует бюджету этапа';
\ No newline at end of file
diff --git a/plugins/sbr/lang/sbr.ru.lang.php b/plugins/sbr/lang/sbr.ru.lang.php
new file mode 100644
index 0000000..ec40c64
--- /dev/null
+++ b/plugins/sbr/lang/sbr.ru.lang.php
@@ -0,0 +1,192 @@
+
Бюджет и сроки ';
+$L['sbr_nav_stagenum'] = 'Этап №';
+
+$L['sbr_employer'] = 'Заказчик';
+$L['sbr_performer'] = 'Исполнитель';
+$L['sbr_performer_placeholder'] = 'Введите логин исполнителя';
+$L['sbr_sbrTitle'] = 'Название сделки';
+$L['sbr_stagetitle'] = 'Название';
+$L['sbr_stagetext'] = 'Техническое задание';
+$L['sbr_stagecost'] = 'Бюджет';
+$L['sbr_stagedays'] = 'Сроки';
+$L['sbr_stagefiles'] = 'Файлы';
+$L['sbr_stagestart'] = 'Старт этапа';
+$L['sbr_stagedone'] = 'Приемка этапа';
+$L['sbr_stageexpiredays'] = 'Осталось';
+$L['sbr_stageexpired'] = 'Срок исполнения истек!';
+$L['sbr_stagemenu'] = 'Решение по этапу';
+$L['sbr_mincost'] = 'минимальный бюджет';
+$L['sbr_maxdays'] = 'отсчет времени начнется с момента резервирования денег, максимальное время этапа';
+
+$L['sbr_sendtoconfirm'] = 'Отправить на согласование';
+
+$L['sbr_info'] = 'Общая информация';
+$L['sbr_stage'] = 'Этап';
+$L['sbr_history'] = 'История сделки';
+$L['sbr_calc_title'] = 'Расчет суммы сделки с учетом комиссии';
+$L['sbr_calc_summ'] = 'Сумма сделки';
+$L['sbr_calc_tax'] = 'Комиссия сервиса';
+$L['sbr_calc_total'] = 'Итого к оплате';
+
+$L['sbr_addstagelink'] = 'Добавить этап';
+
+$L['sbr_status_title'] = 'Статус сделки';
+
+$L['sbr_deals_all'] = 'Все сделки';
+$L['sbr_deals_cancel'] = 'Отмененные';
+$L['sbr_deals_refuse'] = 'Не согласованные';
+$L['sbr_deals_new'] = 'На согласовании';
+$L['sbr_deals_confirm'] = 'Оплатить';
+$L['sbr_deals_process'] = 'В работе';
+$L['sbr_deals_done'] = 'Завершенные';
+$L['sbr_deals_claim'] = 'Арбитраж';
+
+$L['sbr_status_cancel'] = 'Отмененная сделка';
+$L['sbr_status_refuse'] = 'Не согласованная';
+$L['sbr_status_new'] = 'На согласовании';
+$L['sbr_status_confirm'] = 'Ожидает оплаты';
+$L['sbr_status_process'] = 'В работе';
+$L['sbr_status_done'] = 'Завершенная сделка';
+$L['sbr_status_claim'] = 'Арбитраж';
+
+$L['sbr_error_fileToLarge'] = 'Файл слишком большой. Можно загружать файлы не более {$size} Мб.';
+$L['sbr_error_invalidFileType'] = 'Недопустимый тип файла';
+$L['sbr_error_rsbrperformer'] = 'Пользователь с указанным логином не найден';
+$L['sbr_error_rsbrperformernotyou'] = 'Вы не можете быть одновременно Исполнителем и Заказчиком';
+$L['sbr_error_rsbrtitle'] = 'Не указано название сделки';
+$L['sbr_error_rstagetitle'] = 'Не указано название';
+$L['sbr_error_rstagetext'] = 'Не заполнено техническое задание';
+$L['sbr_error_rstagecost'] = 'Не указан бюджет';
+$L['sbr_error_rstagecostmin'] = 'Бюджет слишком маленький';
+$L['sbr_error_rstagecostmax'] = 'Бюджет слишком большой';
+$L['sbr_error_rstagedays'] = 'Не указаны сроки';
+$L['sbr_error_rstagedaysmax'] = 'Сроки слишком большие';
+$L['sbr_error_uploadFile'] = 'Ошибка загрузки файла {$name}
{$error}';
+
+$L['sbr_action_confirm'] = 'Согласиться';
+$L['sbr_action_refuse'] = 'Отказаться';
+$L['sbr_action_cancel'] = 'Отменить сделку';
+$L['sbr_action_edit'] = 'Изменить';
+$L['sbr_action_pay'] = 'Оплатить сделку';
+$L['sbr_action_claim'] = 'Обратиться в арбитраж';
+$L['sbr_action_stagedone'] = 'Принять работу по этапу';
+
+$L['sbr_paydesc'] = 'Оплата сделки "{$sbr_title}"';
+
+$L['sbr_mail_toperformer_new_header'] = 'Согласование сделки "{$sbr_title}"';
+$L['sbr_mail_toperformer_new_body'] = 'Здравствуйте, {$performer_name}. '."\n\n".'
+ Заказчик {$employer_name}, предлагает вам заключить безопастную сделку "{$sbr_title}" с общим бюджетом {$sbr_cost}.
+ Более подробно ознакомиться с условиями сделки можно по ссылке: {$link}';
+
+$L['sbr_mail_toperformer_edited_header'] = 'Изменения в условиях сделки "{$sbr_title}"';
+$L['sbr_mail_toperformer_edited_body'] = 'Здравствуйте, {$performer_name}. '."\n\n".'
+ Заказчик {$employer_name}, изменил условия безопасной сделки "{$sbr_title}" и предлагает вам ознакомиться с ними.
+ Более подробно ознакомиться с условиями сделки можно по ссылке: {$link}';
+
+$L['sbr_mail_posts_header'] = 'Новое сообщение по сделке № {$sbr_id} ({$sbr_title})';
+$L['sbr_mail_posts_body'] = 'Здравствуйте, {$user_name}.
{$sender_name} отправил вам сообщение:
{$post_text}
Подробности смотрите по ссылке: {$link}';
+
+$L['sbr_mail_notification_header'] = 'Уведомнение по сделке № {$sbr_id} ({$sbr_title})';
+$L['sbr_mail_notification_body'] = 'Здравствуйте, {$user_name}.
{$post_text}
Подробности смотрите по ссылке: {$link}';
+
+$L['sbr_posts_performer_new'] = 'Пожалуйста, ознакомьтесь с условиями сделки и подтвердите свое участие. После этого Заказчик произведет оплату сделки и вы сможете приступить к работе.';
+$L['sbr_posts_employer_new'] = 'Сделка отправлена на согласование исполнителю. Как только исполнитель подтвердит свое участие, вы получите уведомление и сможете произвести оплату.';
+
+$L['sbr_posts_performer_edited'] = 'Пожалуйста, ознакомьтесь с новыми условиями сделки и подтвердите свое участие. После этого Заказчик произведет оплату сделки и вы сможете приступить к работе.';
+$L['sbr_posts_employer_edited'] = 'Сделка с изменеными условиями отправлена на согласование исполнителю. Как только исполнитель подтвердит свое участие, вы получите уведомление и сможете произвести оплату.';
+
+$L['sbr_posts_performer_refuse'] = 'Вы отказались от сделки. Заказчик может пересмотреть условия сделки и повторить процедуру согласования.';
+$L['sbr_posts_employer_refuse'] = 'Исполнитель отказался от сделки. Вы можете пересмотреть условия сделки и повторить процедуру согласования.';
+
+$L['sbr_posts_performer_confirm'] = 'Ожидается оплата сделки Заказчиком.';
+$L['sbr_posts_employer_confirm'] = 'Исполнитель подтвердил свое согласие с условиями сделки. Теперь вы можете произвести оплату, чтобы Исполнитель смог приступить к работе.';
+
+$L['sbr_posts_performer_paid'] = 'Сделка оформлена. Можете приступать к работе. Сумма сделки зарезервирована на счету сервиса и будет выплачиваться вам по мере приемки Заказчиком этапов сделки.';
+$L['sbr_posts_employer_paid'] = 'Сделка оформлена. Сумма сделки зарезервирована на счету сервиса и будет выплачиваться Исполнителю по мере вашей приемки этапов сделки.';
+
+$L['sbr_posts_performer_stage_done'] = 'Заказчик принял работу по этапу №{$stage_num} ({$stage_title}). На ваш счет поступила оплата в размере: {$stage_cost} {$valuta}';
+$L['sbr_posts_employer_stage_done'] = 'Вы приняли работы по этапу №{$stage_num} ({$stage_title}). На счет Исполнителя поступила оплата в размере: {$stage_cost} {$valuta}';
+
+$L['sbr_posts_stage_claim'] = '
Подана жалоба в арбитраж! Текст жалобы: {$from_name}: {$claim_text}
Сделка будет рассмотрена арбитражной комиссией. Как только комиссия примет решение, вы получите уведомление по email.';
+
+$L['sbr_posts_performer_stage_claim_decision_payment'] = '
Решение арбитражной комиссии По результатам рассмотрения жалобы по этапу №{$stage_num} ({$stage_title}) арбитражной комиссией было принято следующее решение:
{$decision}
Оплата Исполнителю: {$payperformer} {$valuta}
Возврат Заказчику: {$payemployer} {$valuta}';
+$L['sbr_posts_employer_stage_claim_decision_payment'] = '
Решение арбитражной комиссии По результатам рассмотрения жалобы по этапу №{$stage_num} ({$stage_title}) арбитражной комиссией было принято следующее решение:
{$decision}
Оплата Исполнителю: {$payperformer} {$valuta}
Возврат Заказчику: {$payemployer} {$valuta}';
+
+$L['sbr_posts_performer_cancel'] = 'Сделка отменена Заказчиком.';
+$L['sbr_posts_employer_cancel'] = 'Сделка отменена вами.';
+
+$L['sbr_posts_performer_done'] = 'Сделка завершена.';
+$L['sbr_posts_employer_done'] = 'Сделка завершена.';
+
+$L['sbr_posts_button'] = 'Отправить сообщение';
+
+$L['sbr_posts_to'] = 'Кому';
+$L['sbr_posts_to_all'] = 'Всем';
+$L['sbr_posts_to_performer'] = 'Исполнителю';
+$L['sbr_posts_to_employer'] = 'Заказчику';
+
+$L['sbr_posts_error_textempty'] = 'Сообщение не должно быть пустым';
+
+$L['sbr_posts_from'] = 'Сообщение от';
+$L['sbr_posts_for'] = 'Сообщение для';
+
+$L['sbr_stage_done_payments_desc'] = 'СБР: "{$sbr_title}": Оплата за этап №{$stage_num} ({$stage_title}).';
+$L['sbr_stage_tax_payments_desc'] = 'Доход с СБР: "{$sbr_title}": этап №{$stage_num} ({$stage_title}).';
+$L['sbr_stage_done_title'] = 'Принять работу по этапу';
+
+
+$L['sbr_claim_msg'] = 'Подана жалоба в арбитраж!';
+$L['sbr_claim_error_cost'] = 'Сумма выплат не соответствует общей стоимости этапа данной сделки';
+$L['sbr_claim_add_title'] = 'Обращение в арбитраж';
+$L['sbr_claim_add_error_text'] = 'Не указана причина обращения в арбитраж';
+
+$L['sbr_claim_payments_performer_desc'] = 'СБР: "{$sbr_title}": Оплата за этап №{$stage_num} ({$stage_title}), согласно решению арбитражной комиссии.';
+$L['sbr_claim_payments_employer_desc'] = 'СБР: "{$sbr_title}": Возврат за этап №{$stage_num} ({$stage_title}), согласно решению арбитражной комиссии.';
+$L['sbr_claim_payments_admin_desc'] = 'Доход с СБР: "{$sbr_title}": этап №{$stage_num} ({$stage_title}), согласно решению арбитражной комиссии.';
+
+$L['sbr_claim_decision_button'] = 'Принять решение';
+$L['sbr_claim_decision_title'] = 'Решение арбитражной комиссии';
+$L['sbr_claim_decision_pay_performer'] = 'Оплатить исполнителю';
+$L['sbr_claim_decision_pay_employer'] = 'Вернуть Заказчику';
+
+$L['sbr_claim_decision_error_text'] = 'Не заполнено пояснение к решению арбитражной комиссии';
+$L['sbr_claim_decision_error_pay'] = 'Сумма выплат не соответствует бюджету этапа';
\ No newline at end of file
diff --git a/plugins/sbr/sbr.admin.home.php b/plugins/sbr/sbr.admin.home.php
new file mode 100644
index 0000000..803cf0a
--- /dev/null
+++ b/plugins/sbr/sbr.admin.home.php
@@ -0,0 +1,45 @@
+query("SELECT COUNT(*) FROM $db_sbr WHERE 1");
+$sbrcount = $sbrcount->fetchColumn();
+
+$sbrclaims = $db->query("SELECT COUNT(*) FROM $db_sbr WHERE sbr_status='claim'");
+$sbrclaims = $sbrclaims->fetchColumn();
+
+$sbrdone = $db->query("SELECT COUNT(*) FROM $db_sbr WHERE sbr_status='done'");
+$sbrdone = $sbrdone->fetchColumn();
+
+$tt->assign(array(
+ 'ADMIN_HOME_SBR_URL' => cot_url('admin', 'm=other&p=sbr'),
+ 'ADMIN_HOME_SBR_COUNT' => $sbrcount,
+ 'ADMIN_HOME_CLAIMS_URL' => cot_url('admin', 'm=other&p=sbr&status=claim'),
+ 'ADMIN_HOME_CLAIMS_COUNT' => $sbrclaims,
+ 'ADMIN_HOME_DONE_URL' => cot_url('admin', 'm=other&p=sbr&status=done'),
+ 'ADMIN_HOME_DONE_COUNT' => $sbrdone,
+));
+
+$tt->parse('MAIN');
+
+$line = $tt->text('MAIN');
diff --git a/plugins/sbr/sbr.admin.php b/plugins/sbr/sbr.admin.php
new file mode 100644
index 0000000..5d026b2
--- /dev/null
+++ b/plugins/sbr/sbr.admin.php
@@ -0,0 +1,118 @@
+assign(array(
+ 'STATUS_ROW_ID' => $st,
+ 'STATUS_ROW_TITLE' => $L['sbr_deals_'.$st],
+ ));
+
+ $t->parse('MAIN.STATUS_ROW');
+}
+
+$where = array();
+$order = array();
+
+if(!empty($status))
+{
+ $where['status'] = "sbr_status='" . $db->prep($status) . "'";
+}
+
+//$where['userid'] = "(sbr_employer=" . $usr['id'] . " OR sbr_performer=" . $usr['id'] . ")";
+
+$order['date'] = "sbr_create DESC";
+
+/* === Hook === */
+foreach (cot_getextplugins('sbr.admin.list.query') as $pl)
+{
+ include $pl;
+}
+/* ===== */
+
+$where = ($where) ? 'WHERE ' . implode(' AND ', $where) : '';
+$order = ($order) ? 'ORDER BY ' . implode(', ', $order) : '';
+
+$totalitems = $db->query("SELECT COUNT(*) FROM $db_sbr
+ " . $where . "")->fetchColumn();
+
+$sqllist = $db->query("SELECT * FROM $db_sbr AS s
+ " . $where . "
+ " . $order . "
+ LIMIT $d, " . $cfg['plugin']['sbr']['maxrowsperpage']);
+
+$pagenav = cot_pagenav('sbr', '', $d, $totalitems, $cfg['plugin']['sbr']['maxrowsperpage']);
+
+$sqllist_rowset = $sqllist->fetchAll();
+
+/* === Hook === */
+$extp = cot_getextplugins('sbr.admin.list.loop');
+/* ===== */
+
+foreach ($sqllist_rowset as $sbr)
+{
+ $jj++;
+ $t->assign(cot_generate_usertags($sbr['sbr_employer'], 'SBR_ROW_employer_'));
+ $t->assign(cot_generate_usertags($sbr['sbr_performer'], 'SBR_ROW_PERFORMER_'));
+ $t->assign(cot_generate_sbrtags($sbr, 'SBR_ROW_'));
+
+ /* === Hook - Part2 : Include === */
+ foreach ($extp as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+
+ $t->parse("MAIN.SBR_ROW");
+}
+
+$t->parse("MAIN");
+$pluginBody .= $t->text("MAIN");
\ No newline at end of file
diff --git a/plugins/sbr/sbr.global.php b/plugins/sbr/sbr.global.php
new file mode 100644
index 0000000..3ec4731
--- /dev/null
+++ b/plugins/sbr/sbr.global.php
@@ -0,0 +1,69 @@
+setStatus($pay['pay_id'], PaymentDictionary::STATUS_DONE)) {
+ if ($sbr = $db->query("SELECT * FROM $db_sbr WHERE sbr_id=" . $pay['pay_code'])->fetch()) {
+ // Запуск сделки на исполнение
+ if ($db->update($db_sbr, array('sbr_status' => 'process', 'sbr_begin' => $sys['now']), "sbr_id=" . $pay['pay_code'])){
+
+ // Выбираем исполнителем, если сделка привязана к проекту
+ if ($sbr['sbr_pid'] > 0){
+
+ // находим предыдущего выбранного исполнителя, если есть
+ $lastperformer = $db->query("SELECT u.* FROM $db_projects_offers AS o
+ LEFT JOIN $db_users AS u ON u.user_id=o.offer_userid
+ WHERE offer_pid=" . (int)$sbr['sbr_pid'] . " AND offer_choise='performer'")->fetch();
+
+ if($db->update($db_projects_offers, array("offer_choise" => 'performer', "offer_choise_date" => (int)$sys['now']), "offer_pid=" . (int)$sbr['sbr_pid'] . " AND offer_userid=" . (int)$sbr['sbr_performer'])){
+ if ($db->fieldExists($db_projects, "item_performer")){
+ if($db->update($db_projects, array("item_performer" => $sbr['sbr_performer']), "item_id=" . (int)$sbr['sbr_pid'])){
+ /* === Hook === */
+ foreach (cot_getextplugins('sbr.pay.setperformer') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+ }
+ }
+ }
+ }
+
+ // Активируем на исполнение первый этап сделки
+ $db->update($db_sbr_stages, array('stage_status' => 'process', 'stage_begin' => $sys['now']), "stage_sid=" . $pay['pay_code'] . " AND stage_num=1");
+
+ // Отправка уведомлений
+ cot_sbr_sendpost($pay['pay_code'], $L['sbr_posts_performer_paid'], $sbr['sbr_performer'], 0, 'success', true);
+ cot_sbr_sendpost($pay['pay_code'], $L['sbr_posts_employer_paid'], $sbr['sbr_employer'], 0, 'success', true);
+
+ /* === Hook === */
+ foreach (cot_getextplugins('sbr.pay.done') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+ }
+ }
+ }
+ }
+}
diff --git a/plugins/sbr/sbr.php b/plugins/sbr/sbr.php
new file mode 100644
index 0000000..7a46a28
--- /dev/null
+++ b/plugins/sbr/sbr.php
@@ -0,0 +1,41 @@
+assign([
+ "OFFER_ROW_SBRCREATELINK" => cot_url(
+ 'sbr',
+ 'm=add&pid=' . $id . '&uid=' . $offer['offer_userid'] . '&' . cot_xg()
+ ),
+ ]);
+}
diff --git a/plugins/sbr/sbr.setup.php b/plugins/sbr/sbr.setup.php
new file mode 100644
index 0000000..497757a
--- /dev/null
+++ b/plugins/sbr/sbr.setup.php
@@ -0,0 +1,42 @@
+query('DROP TABLE IF EXISTS ' . cot::$db->quoteTableName(cot::$db->sbr));
+cot::$db->query('DROP TABLE IF EXISTS ' . cot::$db->quoteTableName(cot::$db->sbr_stages));
+cot::$db->query('DROP TABLE IF EXISTS ' . cot::$db->quoteTableName(cot::$db->sbr_posts));
+cot::$db->query('DROP TABLE IF EXISTS ' . cot::$db->quoteTableName(cot::$db->sbr_claims));
+cot::$db->query('DROP TABLE IF EXISTS ' . cot::$db->quoteTableName(cot::$db->sbr_files));
diff --git a/plugins/sbr/setup/sbr.uninstall.sql b/plugins/sbr/setup/sbr.uninstall.sql
new file mode 100644
index 0000000..7df72b3
--- /dev/null
+++ b/plugins/sbr/setup/sbr.uninstall.sql
@@ -0,0 +1,7 @@
+/**
+ * Completely removes sbr data
+ */
+
+DROP TABLE IF EXISTS `cot_sbr`;
+DROP TABLE IF EXISTS `cot_sbr_stages`;
+DROP TABLE IF EXISTS `cot_sbr_posts`;
\ No newline at end of file
diff --git a/plugins/sbr/tpl/sbr.add.tpl b/plugins/sbr/tpl/sbr.add.tpl
new file mode 100644
index 0000000..bf5e48d
--- /dev/null
+++ b/plugins/sbr/tpl/sbr.add.tpl
@@ -0,0 +1,199 @@
+
+
{SBRADD_TITLE}
+
{SBRADD_SUBTITLE}
+
+
+ {FILE "{PHP.cfg.themes_dir}/{PHP.cfg.defaulttheme}/warnings.tpl"}
+
+
+
+
+
+
\ No newline at end of file
diff --git a/plugins/sbr/tpl/sbr.admin.default.tpl b/plugins/sbr/tpl/sbr.admin.default.tpl
new file mode 100644
index 0000000..0a19ddb
--- /dev/null
+++ b/plugins/sbr/tpl/sbr.admin.default.tpl
@@ -0,0 +1,24 @@
+
+
+
{PHP.L.sbr}
+
+
+
+
+
+
+ {SBR_ROW_ID}
+ {SBR_ROW_SHORTTITLE}
+ {SBR_ROW_CREATEDATE}
+ {SBR_ROW_COST} {PHP.cfg.payments.valuta}
+ {SBR_ROW_LOCALSTATUS}
+
+
+
+
+
\ No newline at end of file
diff --git a/plugins/sbr/tpl/sbr.admin.home.tpl b/plugins/sbr/tpl/sbr.admin.home.tpl
new file mode 100644
index 0000000..51325de
--- /dev/null
+++ b/plugins/sbr/tpl/sbr.admin.home.tpl
@@ -0,0 +1,10 @@
+
+
{PHP.L.sbr}
+
+
\ No newline at end of file
diff --git a/plugins/sbr/tpl/sbr.edit.tpl b/plugins/sbr/tpl/sbr.edit.tpl
new file mode 100644
index 0000000..584da42
--- /dev/null
+++ b/plugins/sbr/tpl/sbr.edit.tpl
@@ -0,0 +1,206 @@
+
+
{SBREDIT_TITLE}
+
{SBREDIT_SUBTITLE}
+
+
+
+
\ No newline at end of file
diff --git a/plugins/sbr/tpl/sbr.list.tpl b/plugins/sbr/tpl/sbr.list.tpl
new file mode 100644
index 0000000..839634c
--- /dev/null
+++ b/plugins/sbr/tpl/sbr.list.tpl
@@ -0,0 +1,29 @@
+
+
+
{SBR_TITLE}
+
{PHP.L.sbr_mydeals}
+
+
+
+
+
+
+ {SBR_ROW_ID}
+ {SBR_ROW_SHORTTITLE}
+ {SBR_ROW_CREATEDATE}
+ {SBR_ROW_COST} {PHP.cfg.payments.valuta}
+ {SBR_ROW_LOCALSTATUS}
+
+
+
+
+
\ No newline at end of file
diff --git a/plugins/sbr/tpl/sbr.tpl b/plugins/sbr/tpl/sbr.tpl
new file mode 100644
index 0000000..2a48863
--- /dev/null
+++ b/plugins/sbr/tpl/sbr.tpl
@@ -0,0 +1,318 @@
+
+
{SBR_TITLE}
+
{SBR_LOCALSTATUS}
+
{SBR_SHORTTITLE}
+
+
+
+
+{FILE "{PHP.cfg.themes_dir}/{PHP.usr.theme}/warnings.tpl"}
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {PHP.L.sbr_stagecost}: {STAGE_ROW_COST} {PHP.cfg.payments.valuta},
+ {PHP.L.sbr_stagedays}: {STAGE_ROW_DAYS|cot_declension($this, 'Days')}
+
+
{STAGE_ROW_TEXT}
+
+
{PHP.L.sbr_stagefiles}
+
+
+
+ {FILE_ROW_TITLE}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
{STAGE_TITLE}
+
+ {PHP.L.sbr_stagecost}: {STAGE_COST} {PHP.cfg.payments.valuta},
+
+ {PHP.L.sbr_stagedays}: {STAGE_EXPIRE|cot_date('datetime_fulltext', $this)}
+
+ {PHP.L.sbr_stagedays}: {STAGE_DAYS|cot_declension($this, 'Days')}
+
+
+
{PHP.L.sbr_stagetext}
+
{STAGE_TEXT}
+
+
{PHP.L.sbr_stagefiles}
+
+
+
+ {FILE_ROW_TITLE}
+
+
+
+
+
+
+
+
+ {PHP.L.sbr_stagestart}: {STAGE_BEGIN|date('d.m.Y H:i:s', $this)}
+ {PHP.L.sbr_stageexpiredays}: {STAGE_EXPIREDAYS}{PHP.L.sbr_stageexpired}
+
+
+
+
+
+
+
+
+
+ {PHP.L.sbr_stagestart}: {STAGE_BEGIN|date('d.m.Y H:i:s', $this)}
+ {PHP.L.sbr_stagedone}: {STAGE_DONE|date('d.m.Y H:i:s', $this)}
+
+
+
+
+
+
+
+
{PHP.L.sbr_history}
+
+
+ class="{POST_ROW_TYPE}">
+
+
+ {POST_ROW_FROM_NAME}
+ {POST_ROW_FROM_AVATAR}
+
+
+
+
+ {POST_ROW_DATE}
+
+ {PHP.L.sbr_posts_for}: {POST_ROW_TO_NAME}
+
+
+ {POST_ROW_TEXT}
+
+
+
+ {PHP.L.sbr_stagefiles}
+
+
+
+ {FILE_ROW_TITLE}
+
+
+
+
+
+
+
+
+
+
{PHP.L.sbr_posts_add}
+ {FILE "{PHP.cfg.themes_dir}/{PHP.cfg.defaulttheme}/warnings.tpl"}
+
+
+
+
+
+
+
+
+
+
+
+
+
{PHP.L.sbr_stage_done_title}
+{FILE "{PHP.cfg.themes_dir}/{PHP.cfg.defaulttheme}/warnings.tpl"}
+
+ {STAGEDONE_FORM_TEXT}
+ {PHP.L.Submit}
+
+
+
+
+
+
+
{PHP.L.sbr_claim_add_title}
+{FILE "{PHP.cfg.themes_dir}/{PHP.cfg.defaulttheme}/warnings.tpl"}
+
+ {CLAIM_FORM_TEXT}
+ {PHP.L.Submit}
+
+
+
+
+
+
+
{PHP.L.sbr_claim_decision_title}
+{FILE "{PHP.cfg.themes_dir}/{PHP.cfg.defaulttheme}/warnings.tpl"}
+
+
+
+ {DECISION_FORM_TEXT}
+
+
+ {PHP.L.sbr_claim_decision_pay_performer}:
+ {DECISION_FORM_PAYPERFORMER} {PHP.cfg.payments.valuta}
+
+
+ {PHP.L.sbr_claim_decision_pay_employer}:
+ {DECISION_FORM_PAYEMPLOYER} {PHP.cfg.payments.valuta}
+
+
+ {PHP.L.Submit}
+
+
+
+
+
\ No newline at end of file
diff --git a/plugins/simproducts/README.md b/plugins/simproducts/README.md
new file mode 100644
index 0000000..11ee9cc
--- /dev/null
+++ b/plugins/simproducts/README.md
@@ -0,0 +1,11 @@
+Выводит Похожие товары для фриланс-биржи на Cotonti Siena
+
+Плагин для фриланс-биржи, выводит похожие товары на странице открытого товара.
+
+Инструкция по установке
+
+1. Распакуйте исходники в папку plugins вашего сайта.
+2. Зайдите в панель администратора и установите данный плагин.
+3. Скопируйте в своею тему шаблон карточки товара из модуля market (modules/market/tpl/market.tpl) и добавьте в код шаблона тэг {PRD_SIMPRODUCTS} там где необходимо вывести похожие товары.
+
+В настройках плагина укажите сколько похожих товаров будет выводится, а также релевантность поиска. Чем выше вы укажете показатель релевантности, тем строже будет поиск. Поиск происходит по названиям товаров на схожесть (стандартный полнотекстовый mysql-поиск).
diff --git a/plugins/simproducts/lang/simproducts.en.lang.php b/plugins/simproducts/lang/simproducts.en.lang.php
new file mode 100644
index 0000000..b05b133
--- /dev/null
+++ b/plugins/simproducts/lang/simproducts.en.lang.php
@@ -0,0 +1,18 @@
+query("ALTER TABLE $db_market ADD FULLTEXT(item_title)");
diff --git a/plugins/simproducts/simproducts.market.tags.php b/plugins/simproducts/simproducts.market.tags.php
new file mode 100644
index 0000000..5d95f05
--- /dev/null
+++ b/plugins/simproducts/simproducts.market.tags.php
@@ -0,0 +1,79 @@
+prep($item['item_title'])."*' IN BOOLEAN MODE)>".$cfg['plugin']['simproducts']['relev'];
+
+$simproducts_order['date'] = "item_date DESC";
+
+/* === Hook === */
+foreach (cot_getextplugins('simproducts.query') as $pl)
+{
+ include $pl;
+}
+/* ===== */
+
+$simproducts_where = ($simproducts_where) ? 'WHERE ' . implode(' AND ', $simproducts_where) : '';
+$simproducts_order = ($simproducts_order) ? 'ORDER BY ' . implode(', ', $simproducts_order) : '';
+
+$sqlsimproducts = $db->query("SELECT * FROM $db_market AS m
+ LEFT JOIN $db_users AS u ON u.user_id=m.item_userid
+ " . $simproducts_where . "
+ " . $simproducts_order . "
+ LIMIT " . $cfg['plugin']['simproducts']['limit'])->fetchAll();
+
+foreach ($sqlsimproducts as $simprd)
+{
+ $jj++;
+ $sp_t->assign(cot_generate_usertags($simprd, 'SIMPRD_ROW_OWNER_'));
+
+ $sp_t->assign(cot_generate_markettags($simprd, 'SIMPRD_ROW_', $cfg['market']['shorttextlen'], $usr['isadmin'], $cfg['homebreadcrumb']));
+ $sp_t->assign(array(
+ "SIMPRD_ROW_ODDEVEN" => cot_build_oddeven($jj),
+ ));
+
+ /* === Hook === */
+ foreach (cot_getextplugins('simproducts.loop') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+
+ $sp_t->parse("MAIN.SIMPRD_ROW");
+}
+
+/* === Hook === */
+foreach (cot_getextplugins('simproducts.tags') as $pl)
+{
+ include $pl;
+}
+/* ===== */
+
+$sp_t->parse('MAIN');
+$t->assign('PRD_SIMPRODUCTS', $sp_t->text('MAIN'));
\ No newline at end of file
diff --git a/plugins/simproducts/simproducts.setup.php b/plugins/simproducts/simproducts.setup.php
new file mode 100644
index 0000000..4b52cc8
--- /dev/null
+++ b/plugins/simproducts/simproducts.setup.php
@@ -0,0 +1,35 @@
+
+
+
{PHP.L.simproducts}
+
+
+
+
+
\ No newline at end of file
diff --git a/plugins/simprojects/README.md b/plugins/simprojects/README.md
new file mode 100644
index 0000000..3bdccc5
--- /dev/null
+++ b/plugins/simprojects/README.md
@@ -0,0 +1,11 @@
+Выводит Похожие проекты для фриланс-биржи на Cotonti Siena
+
+Плагин для фриланс-биржи, выводит похожие проекты на странице открытого проекта.
+
+Инструкция по установке
+
+1. Распакуйте исходники в папку plugins вашего сайта.
+2. Зайдите в панель администратора и установите данный плагин.
+3. Скопируйте в свою тему шаблон карточки проекта из модуля projects (modules/projects/tpl/projects.tpl) и добавьте в код шаблона тэг {PRJ_SIMPROJECTS} там где необходимо вывести похожие проекты.
+
+В настройках плагина укажите сколько похожих проектов будет выводится, а также релевантность поиска. Чем выше вы укажете показатель релевантности, тем строже будет поиск. Поиск происходит по названиям проектов на схожесть (стандартный полнотекстовый mysql-поиск).
diff --git a/plugins/simprojects/lang/simprojects.en.lang.php b/plugins/simprojects/lang/simprojects.en.lang.php
new file mode 100644
index 0000000..7534a32
--- /dev/null
+++ b/plugins/simprojects/lang/simprojects.en.lang.php
@@ -0,0 +1,18 @@
+query("ALTER TABLE $db_projects ADD FULLTEXT(item_title)");
diff --git a/plugins/simprojects/simprojects.projects.tags.php b/plugins/simprojects/simprojects.projects.tags.php
new file mode 100644
index 0000000..5a7c76f
--- /dev/null
+++ b/plugins/simprojects/simprojects.projects.tags.php
@@ -0,0 +1,79 @@
+prep($item['item_title'])."*' IN BOOLEAN MODE)>".$cfg['plugin']['simprojects']['relev'];
+
+$simprojects_order['date'] = "item_date DESC";
+
+/* === Hook === */
+foreach (cot_getextplugins('simprojects.query') as $pl)
+{
+ include $pl;
+}
+/* ===== */
+
+$simprojects_where = ($simprojects_where) ? 'WHERE ' . implode(' AND ', $simprojects_where) : '';
+$simprojects_order = ($simprojects_order) ? 'ORDER BY ' . implode(', ', $simprojects_order) : '';
+
+$sqlsimprojects = $db->query("SELECT * FROM $db_projects AS p
+ LEFT JOIN $db_users AS u ON u.user_id=p.item_userid
+ " . $simprojects_where . "
+ " . $simprojects_order . "
+ LIMIT " . $cfg['plugin']['simprojects']['limit'])->fetchAll();
+
+foreach ($sqlsimprojects as $simprj)
+{
+ $jj++;
+ $sp_t->assign(cot_generate_usertags($simprj, 'SIMPRJ_ROW_OWNER_'));
+
+ $sp_t->assign(cot_generate_projecttags($simprj, 'SIMPRJ_ROW_', $cfg['projects']['shorttextlen'], $usr['isadmin'], $cfg['homebreadcrumb']));
+ $sp_t->assign(array(
+ "SIMPRJ_ROW_ODDEVEN" => cot_build_oddeven($jj),
+ ));
+
+ /* === Hook === */
+ foreach (cot_getextplugins('simprojects.loop') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+
+ $sp_t->parse("MAIN.SIMPRJ_ROW");
+}
+
+/* === Hook === */
+foreach (cot_getextplugins('simprojects.tags') as $pl)
+{
+ include $pl;
+}
+/* ===== */
+
+$sp_t->parse('MAIN');
+$t->assign('PRJ_SIMPROJECTS', $sp_t->text('MAIN'));
\ No newline at end of file
diff --git a/plugins/simprojects/simprojects.setup.php b/plugins/simprojects/simprojects.setup.php
new file mode 100644
index 0000000..83c5684
--- /dev/null
+++ b/plugins/simprojects/simprojects.setup.php
@@ -0,0 +1,35 @@
+
+
+
{PHP.L.simprojects}
+
+
+
+
+
\ No newline at end of file
diff --git a/plugins/uproducts/lang/uproducts.en.lang.php b/plugins/uproducts/lang/uproducts.en.lang.php
new file mode 100644
index 0000000..bdf530c
--- /dev/null
+++ b/plugins/uproducts/lang/uproducts.en.lang.php
@@ -0,0 +1,17 @@
+
+
+
{PHP.L.uproducts}
+
+
+
+
+
\ No newline at end of file
diff --git a/plugins/uproducts/uproducts.market.tags.php b/plugins/uproducts/uproducts.market.tags.php
new file mode 100644
index 0000000..d6abacb
--- /dev/null
+++ b/plugins/uproducts/uproducts.market.tags.php
@@ -0,0 +1,72 @@
+query("SELECT * FROM $db_market AS m
+ LEFT JOIN $db_users AS u ON u.user_id=m.item_userid
+ " . $uproducts_where . "
+ " . $uproducts_order . "
+ LIMIT " . $cfg['plugin']['uproducts']['limit'])->fetchAll();
+
+if(count($sqluproducts) > 0)
+{
+ foreach ($sqluproducts as $uprd)
+ {
+ $jj++;
+ $up_t->assign(cot_generate_usertags($uprd, 'PRD_ROW_OWNER_'));
+
+ $up_t->assign(cot_generate_markettags($uprd, 'PRD_ROW_', $cfg['market']['shorttextlen'], $usr['isadmin'], $cfg['homebreadcrumb']));
+ $up_t->assign(array(
+ "PRD_ROW_ODDEVEN" => cot_build_oddeven($jj),
+ ));
+
+ /* === Hook === */
+ foreach (cot_getextplugins('uproducts.loop') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+
+ $up_t->parse("MAIN.PRD_ROW");
+ }
+
+ /* === Hook === */
+ foreach (cot_getextplugins('uproducts.tags') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+
+ $up_t->parse('MAIN');
+ $t->assign('PRD_UPRODUCTS', $up_t->text('MAIN'));
+}
\ No newline at end of file
diff --git a/plugins/uproducts/uproducts.setup.php b/plugins/uproducts/uproducts.setup.php
new file mode 100644
index 0000000..be0cd3c
--- /dev/null
+++ b/plugins/uproducts/uproducts.setup.php
@@ -0,0 +1,24 @@
+
+
+
{PHP.L.uprojects}
+
+
+
+
+
\ No newline at end of file
diff --git a/plugins/uprojects/uprojects.projects.tags.php b/plugins/uprojects/uprojects.projects.tags.php
new file mode 100644
index 0000000..01fb277
--- /dev/null
+++ b/plugins/uprojects/uprojects.projects.tags.php
@@ -0,0 +1,72 @@
+query("SELECT * FROM $db_projects AS p
+ LEFT JOIN $db_users AS u ON u.user_id=p.item_userid
+ " . $uprojects_where . "
+ " . $uprojects_order . "
+ LIMIT " . $cfg['plugin']['uprojects']['limit'])->fetchAll();
+
+if(count($sqluprojects) > 0)
+{
+ foreach ($sqluprojects as $uprj)
+ {
+ $jj++;
+ $up_t->assign(cot_generate_usertags($uprj, 'PRJ_ROW_OWNER_'));
+
+ $up_t->assign(cot_generate_projecttags($uprj, 'PRJ_ROW_', $cfg['projects']['shorttextlen'], $usr['isadmin'], $cfg['homebreadcrumb']));
+ $up_t->assign(array(
+ "PRJ_ROW_ODDEVEN" => cot_build_oddeven($jj),
+ ));
+
+ /* === Hook === */
+ foreach (cot_getextplugins('uprojects.loop') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+
+ $up_t->parse("MAIN.PRJ_ROW");
+ }
+
+ /* === Hook === */
+ foreach (cot_getextplugins('uprojects.tags') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+
+ $up_t->parse('MAIN');
+ $t->assign('PRJ_UPROJECTS', $up_t->text('MAIN'));
+}
\ No newline at end of file
diff --git a/plugins/uprojects/uprojects.setup.php b/plugins/uprojects/uprojects.setup.php
new file mode 100644
index 0000000..88bc0f7
--- /dev/null
+++ b/plugins/uprojects/uprojects.setup.php
@@ -0,0 +1,24 @@
+Forbidden
+
\ No newline at end of file
diff --git a/plugins/usercategories/inc/usercategories.functions.php b/plugins/usercategories/inc/usercategories.functions.php
index 7e774eb..93b984d 100644
--- a/plugins/usercategories/inc/usercategories.functions.php
+++ b/plugins/usercategories/inc/usercategories.functions.php
@@ -17,20 +17,17 @@
// Global variables
function cot_cfg_usercategories()
{
- global $cfg;
-
- $tpaset = str_replace("\r\n", "\n", $cfg['plugin']['usercategories']['catslimit']);
+ $tpaset = str_replace("\r\n", "\n", cot::$cfg['plugin']['usercategories']['catslimit']);
$tpaset = explode("\n", $tpaset);
$paytopset = array();
- foreach ($tpaset as $lineset)
- {
+ $catslimit = [];
+ foreach ($tpaset as $lineset) {
$lines = explode("|", $lineset);
- $lines[0] = trim($lines[0]);
- $lines[1] = trim($lines[1]);
- $lines[2] = trim($lines[2]);
+ $lines[0] = (int) trim($lines[0]);
+ $lines[1] = !empty($lines[1]) ? (int) trim($lines[1]) : 0;
+ $lines[2] = !empty($lines[2]) ? (int) trim($lines[2]) : 0;
- if ($lines[0] > 0 && $lines[1] > 0 && $lines[2] > 0)
- {
+ if ($lines[0] > 0 && $lines[1] > 0 && $lines[2] > 0) {
$catslimit[$lines[0]]['default'] = $lines[1];
$catslimit[$lines[0]]['pro'] = $lines[2];
}
@@ -127,7 +124,10 @@ function cot_usercategories_treecheck($chosen, $name, $parent = '', $template =
return false;
}
- if(!is_array($chosen)){
+ if (!is_array($chosen)) {
+ if (empty($chosen)) {
+ $chosen = [];
+ }
$chosen = explode(',', $chosen);
}
@@ -155,7 +155,8 @@ function cot_usercategories_treecheck($chosen, $name, $parent = '', $template =
foreach ($children as $row)
{
if(cot_auth('usercategories', $row, $userrights)){
- $subcats = $structure['usercategories'][$row]['subcats'];
+ $subcats = isset($structure['usercategories'][$row]['subcats']) ?
+ $structure['usercategories'][$row]['subcats'] : [];
$cattitle = htmlspecialchars($structure['usercategories'][$row]['title']);
if ($i18n_enabled && $i18n_notmain){
$x_i18n = cot_i18n_get_cat($row, $i18n_locale);
@@ -167,7 +168,8 @@ function cot_usercategories_treecheck($chosen, $name, $parent = '', $template =
$t1->assign(array(
"CAT_ROW_CAT" => $row,
"CAT_ROW_CHECKBOX" => (is_array($chosen) && in_array($row, $chosen) || !is_array($chosen) && $row == $chosen) ? cot_checkbox($row, $name, $cattitle, '', $row) : cot_checkbox('', $name, $cattitle, '', $row),
- "CAT_ROW_SUBCAT" => (count($subcats) > 0) ? cot_usercategories_treecheck($chosen, $name, $row, $template, $userrights, $level) : '',
+ "CAT_ROW_SUBCAT" => (!empty($subcats) && count($subcats) > 0) ?
+ cot_usercategories_treecheck($chosen, $name, $row, $template, $userrights, $level) : '',
));
if ($i18n_enabled && $i18n_notmain){
@@ -216,7 +218,7 @@ function cot_usercategories_tree($chosen = '', $parent = '', $template = '', $le
return false;
}
- if(!is_array($chosen)){
+ if (!empty($chosen) && is_array($chosen)) {
$chosen = explode(',', $chosen);
}
@@ -269,18 +271,16 @@ function cot_usercategories_tree($chosen = '', $parent = '', $template = '', $le
$extp = cot_getextplugins('usercategories.tree.loop');
/* ===== */
- foreach ($children as $row)
- {
+ foreach ($children as $row) {
$jj++;
- $subcats = $structure['usercategories'][$row]['subcats'];
+ $subcats = !empty($structure['usercategories'][$row]['subcats']) ?
+ $structure['usercategories'][$row]['subcats'] : [];
$urlparams['cat'] = $row;
- if(is_array($subcats))
- {
- $parent_selected = (is_array($chosen)) ? (bool)count(array_intersect($subcats, $chosen)) : in_array($chosen, $subcats);
- }
- else
- {
+ if (is_array($subcats)) {
+ $parent_selected = (is_array($chosen)) ?
+ (bool) count(array_intersect($subcats, $chosen)) : in_array($chosen, $subcats);
+ } else {
$parent_selected = false;
}
@@ -292,7 +292,7 @@ function cot_usercategories_tree($chosen = '', $parent = '', $template = '', $le
"CAT_ROW_ICON" => $structure['usercategories'][$row]['icon'],
"CAT_ROW_URL" => cot_url("users", $urlparams),
"CAT_ROW_SELECTED" => (is_array($chosen) && in_array($row, $chosen) || !is_array($chosen) && $row == $chosen || $parent_selected) ? 1 : 0,
- "CAT_ROW_SUBCAT" => (count($subcats) > 0) ? cot_usercategories_tree($chosen, $row, $template, $level) : '',
+ "CAT_ROW_SUBCAT" => !empty($subcats) ? cot_usercategories_tree($chosen, $row, $template, $level) : '',
"CAT_ROW_ODDEVEN" => cot_build_oddeven($jj),
"CAT_ROW_JJ" => $jj
));
@@ -381,35 +381,32 @@ function cot_usercategories_catlist($cats, $template = ''){
* Select users cat for search from
*
* @global array $structure
- * @param type $check
- * @param type $name
- * @param type $subcat
- * @param type $hideprivate
- * @return type
+ * @param $check
+ * @param string $name
+ * @param string $subcat
+ * @param bool $hideprivate
+ * @return string
*/
function cot_usercategories_selectcat($check, $name, $subcat = '', $hideprivate = true)
{
global $structure;
- $structure['usercategories'] = (is_array($structure['usercategories'])) ? $structure['usercategories'] : array();
+ cot::$structure['usercategories'] = (!empty(cot::$structure['usercategories']) && is_array(cot::$structure['usercategories'])) ?
+ cot::$structure['usercategories'] : [];
$result_array = array();
- foreach ($structure['usercategories'] as $i => $x)
- {
+ foreach (cot::$structure['usercategories'] as $i => $x) {
$display = ($hideprivate) ? cot_auth('usercategories', $i, 'R') : true;
- if ($display && !empty($subcat) && isset($structure['usercategories'][$subcat]))
- {
- $mtch = $structure['usercategories'][$subcat]['path'].".";
+ if ($display && !empty($subcat) && isset(cot::$structure['usercategories'][$subcat])) {
+ $mtch = cot::$structure['usercategories'][$subcat]['path'].".";
$mtchlen = mb_strlen($mtch);
$display = (mb_substr($x['path'], 0, $mtchlen) == $mtch || $i === $subcat);
}
- if ((!$is_module || cot_auth('usercategories', $i, 'R')) && $i!='all' && $display)
- {
+ if ($i != 'all' && $display && cot_auth('usercategories', $i, 'R')) {
$result_array[$i] = $x['tpath'];
}
}
- $result = cot_selectbox($check, $name, array_keys($result_array), array_values($result_array), true);
- return($result);
+ return cot_selectbox($check, $name, array_keys($result_array), array_values($result_array), true);
}
\ No newline at end of file
diff --git a/plugins/usercategories/index.html b/plugins/usercategories/index.html
new file mode 100644
index 0000000..eba420c
--- /dev/null
+++ b/plugins/usercategories/index.html
@@ -0,0 +1,2 @@
+
Forbidden
+
\ No newline at end of file
diff --git a/plugins/usercategories/js/index.html b/plugins/usercategories/js/index.html
new file mode 100644
index 0000000..eba420c
--- /dev/null
+++ b/plugins/usercategories/js/index.html
@@ -0,0 +1,2 @@
+
Forbidden
+
\ No newline at end of file
diff --git a/plugins/usercategories/setup/index.html b/plugins/usercategories/setup/index.html
new file mode 100644
index 0000000..eba420c
--- /dev/null
+++ b/plugins/usercategories/setup/index.html
@@ -0,0 +1,2 @@
+
Forbidden
+
\ No newline at end of file
diff --git a/plugins/usercategories/setup/patch_2.5.2.inc b/plugins/usercategories/setup/patch_2.5.2.inc
index eb99c6f..e5afc7d 100644
--- a/plugins/usercategories/setup/patch_2.5.2.inc
+++ b/plugins/usercategories/setup/patch_2.5.2.inc
@@ -15,9 +15,8 @@ require_once cot_incfile('extrafields');
require_once cot_incfile('structure');
// Add field if missing
-if (!$db->fieldExists($db_users, "user_cats"))
-{
- $dbres = $db->query("ALTER TABLE `$db_users` ADD COLUMN `user_cats` TEXT collate utf8_unicode_ci NOT NULL");
+if (!$db->fieldExists($db_users, "user_cats")) {
+ $dbres = $db->query("ALTER TABLE `$db_users` ADD COLUMN `user_cats` TEXT NULL DEFAULT NULL");
}
$sql = $db->query("SELECT * FROM $db_usercategories WHERE 1");
diff --git a/plugins/usercategories/setup/patch_2.6.5.inc b/plugins/usercategories/setup/patch_2.6.5.inc
new file mode 100644
index 0000000..f256b0c
--- /dev/null
+++ b/plugins/usercategories/setup/patch_2.6.5.inc
@@ -0,0 +1,10 @@
+query(
+ 'ALTER TABLE ' . Cot::$db->users . ' MODIFY user_cats TEXT NULL DEFAULT NULL'
+);
diff --git a/plugins/usercategories/setup/usercategories.install.php b/plugins/usercategories/setup/usercategories.install.php
index c3bfdcc..9181e09 100644
--- a/plugins/usercategories/setup/usercategories.install.php
+++ b/plugins/usercategories/setup/usercategories.install.php
@@ -3,9 +3,8 @@
* Installation handler
*
* @package usercategories
- * @version 2.5.2
- * @author CMSWorks Team
- * @copyright Copyright (c) CMSWorks.ru, littledev.ru
+ * @author CMSWorks Team, Cotonti Team
+ * @copyright Copyright (c) CMSWorks.ru, littledev.ru, Cotonti Team
* @license BSD
*/
@@ -14,13 +13,14 @@
global $db_users;
require_once cot_incfile('usercategories', 'plug');
-require_once cot_incfile('extrafields');
+//require_once cot_incfile('extrafields');
require_once cot_incfile('structure');
// Add field if missing
-if (!$db->fieldExists($db_users, "user_cats"))
-{
- $dbres = $db->query("ALTER TABLE `$db_users` ADD COLUMN `user_cats` TEXT collate utf8_unicode_ci NOT NULL");
+if (!Cot::$db->fieldExists($db_users, "user_cats")) {
+ Cot::$db->query(
+ 'ALTER TABLE ' . Cot::$db->users . ' ADD COLUMN user_cats TEXT NULL DEFAULT NULL'
+ );
}
cot_structure_add('usercategories', array('structure_area' => 'usercategories', 'structure_code' => 'programming', 'structure_title' => 'Программирование', 'structure_path' => '001'));
diff --git a/plugins/usercategories/tpl/index.html b/plugins/usercategories/tpl/index.html
new file mode 100644
index 0000000..eba420c
--- /dev/null
+++ b/plugins/usercategories/tpl/index.html
@@ -0,0 +1,2 @@
+
Forbidden
+
\ No newline at end of file
diff --git a/plugins/usercategories/usercategories.admin.config.php b/plugins/usercategories/usercategories.admin.config.php
index a13e1cc..dd5ba29 100644
--- a/plugins/usercategories/usercategories.admin.config.php
+++ b/plugins/usercategories/usercategories.admin.config.php
@@ -9,7 +9,10 @@
defined('COT_CODE') or die('Wrong URL');
require_once cot_incfile('usercategories', 'plug');
-$adminhelp = $L['usercategories_help'];
+if (!isset($adminHelp)) {
+ $adminHelp = '';
+}
+$adminHelp .= isset(cot::$L['usercategories_help']) ? cot::$L['usercategories_help'] : '';
if ($p == 'usercategories' && $row['config_name'] == 'catslimit' && $cfg['jquery'])
{
@@ -19,12 +22,11 @@
$tpaset = str_replace("\r\n", "\n", $row['config_value']);
$tpaset = explode("\n", $tpaset);
$jj = 0;
- foreach ($tpaset as $lineset)
- {
+ foreach ($tpaset as $lineset) {
$lines = explode("|", $lineset);
- $lines[0] = (int)trim($lines[0]);
- $lines[1] = (int)trim($lines[1]);
- $lines[2] = (int)trim($lines[2]);
+ $lines[0] = (int) trim($lines[0]);
+ $lines[1] = !empty($lines[1]) ? (int) trim($lines[1]) : 0;
+ $lines[2] = !empty($lines[2]) ? (int) trim($lines[2]) : 0;
if ($lines[0] > 0)
{
@@ -55,9 +57,8 @@
));
$tt->parse('MAIN');
+ $more = isset($config_more) ? '
' . $config_more . '
' : '';
$t->assign(array(
- 'ADMIN_CONFIG_ROW_CONFIG_MORE' => $tt->text('MAIN') . '
' . $config_more . '
'
+ 'ADMIN_CONFIG_ROW_CONFIG_MORE' => $tt->text('MAIN') . $more
));
}
-
-?>
\ No newline at end of file
diff --git a/plugins/usercategories/usercategories.edit.first.php b/plugins/usercategories/usercategories.edit.first.php
index fa479f9..5c086c3 100644
--- a/plugins/usercategories/usercategories.edit.first.php
+++ b/plugins/usercategories/usercategories.edit.first.php
@@ -13,22 +13,32 @@
$rcats = cot_import('rcats', 'P', 'ARR');
-if(is_array($rcats)){
+if (is_array($rcats)) {
$rcats = array_filter($rcats);
$ruser['user_cats'] = implode(',', $rcats);
-
+
if($m == 'edit' || $m == 'profile'){
$groupid = $urr['user_maingrp'];
}else{
$groupid = cot_import('ruserusergroup','P','INT');
+ if (empty($groupid)) {
+ $groupid = $urr['user_maingrp'];
+ }
}
- if(!cot_plugin_active('paypro') || cot_plugin_active('paypro') && !cot_getuserpro($urr))
- {
- cot_check($catslimit[$groupid]['default'] > 0 && count($rcats) > $catslimit[$groupid]['default'], cot_rc($L['usercategories_error_catslimit'], array('limit' => $catslimit[$groupid]['default'])), 'rcats');
- }
- elseif(cot_plugin_active('paypro') && cot_getuserpro($urr))
- {
- cot_check($catslimit[$groupid]['pro'] > 0 && count($rcats) > $catslimit[$groupid]['pro'], cot_rc($L['usercategories_error_catslimit'], array('limit' => $catslimit[$groupid]['pro'])), 'rcats');
- }
+ if (!empty($groupid) && !empty($catslimit) && !empty($catslimit[$groupid])) {
+ if(!cot_plugin_active('paypro') || cot_plugin_active('paypro') && !cot_getuserpro($urr)) {
+ cot_check(
+ $catslimit[$groupid]['default'] > 0 && count($rcats) > $catslimit[$groupid]['default'],
+ cot_rc($L['usercategories_error_catslimit'], array('limit' => $catslimit[$groupid]['default'])),
+ 'rcats'
+ );
+ } elseif(cot_plugin_active('paypro') && cot_getuserpro($urr)) {
+ cot_check(
+ $catslimit[$groupid]['pro'] > 0 && count($rcats) > $catslimit[$groupid]['pro'],
+ cot_rc($L['usercategories_error_catslimit'], array('limit' => $catslimit[$groupid]['pro'])),
+ 'rcats'
+ );
+ }
+ }
}
\ No newline at end of file
diff --git a/plugins/usercategories/usercategories.edit.tags.php b/plugins/usercategories/usercategories.edit.tags.php
index 68b18f9..9ffa382 100644
--- a/plugins/usercategories/usercategories.edit.tags.php
+++ b/plugins/usercategories/usercategories.edit.tags.php
@@ -27,10 +27,12 @@
{
$prfx = 'USERS_PROFILE_';
}
-if ($prfx != 'USERS_REGISTER_')
-{
- $rcats = explode(',', $urr['user_cats']);
+if ($prfx != 'USERS_REGISTER_') {
+ $rcats = [];
+ if (!empty($urr['user_cats'])) {
+ $rcats = explode(',', $urr['user_cats']);
+ }
}
$t->assign(array(
- $prfx . 'CAT' => cot_usercategories_treecheck($rcats, 'rcats[]')
+ $prfx . 'CAT' => cot_usercategories_treecheck(!empty($rcats) ? $rcats : [], 'rcats[]')
));
diff --git a/plugins/usercategories/usercategories.setup.php b/plugins/usercategories/usercategories.setup.php
index d9d6ec8..0b94187 100644
--- a/plugins/usercategories/usercategories.setup.php
+++ b/plugins/usercategories/usercategories.setup.php
@@ -1,15 +1,14 @@
update($db_users, array('user_maingrp'=>$ruser['user_usergroup']), "user_id=".$r_id);
$db->update($db_groups_users, array('gru_groupid' => $ruser['user_usergroup']), "gru_userid=".$r_id." AND gru_groupid=".$urr['user_maingrp']);
}
diff --git a/plugins/usergroupselector/usergroupselector.edit.first.php b/plugins/usergroupselector/usergroupselector.edit.first.php
index 5f87294..ac4b357 100644
--- a/plugins/usergroupselector/usergroupselector.edit.first.php
+++ b/plugins/usergroupselector/usergroupselector.edit.first.php
@@ -19,7 +19,7 @@
require_once cot_langfile('usergroupselector', 'plug');
-if(($cfg['plugin']['usergroupselector']['allowchange'] || $cfg['plugin']['usergroupselector']['required'])
+if (($cfg['plugin']['usergroupselector']['allowchange'] || $cfg['plugin']['usergroupselector']['required'])
&& !empty($cfg['plugin']['usergroupselector']['groups'])
&& $urr['user_maingrp'] != COT_GROUP_SUPERADMINS
&& $urr['user_maingrp'] != COT_GROUP_MODERATORS)
diff --git a/plugins/usergroupselector/usergroupselector.edit.tags.php b/plugins/usergroupselector/usergroupselector.edit.tags.php
index 0eaad86..7c28bea 100644
--- a/plugins/usergroupselector/usergroupselector.edit.tags.php
+++ b/plugins/usergroupselector/usergroupselector.edit.tags.php
@@ -1,5 +1,4 @@
assign(array(
'USERGROUP_ROW_ID' => $v,
'USERGROUP_ROW_TITLE' => $cot_groups[$v]['title'],
'USERGROUP_ROW_ALIAS' => $cot_groups[$v]['alias'],
- 'USERGROUP_ROW_ACTIVEID' => ($usergroup == $cot_groups[$v]['alias']) ? true : false,
+ 'USERGROUP_ROW_ACTIVEID' => (!empty($usergroup) && $usergroup == $cot_groups[$v]['alias']) ? true : false,
));
$t->parse('MAIN.USERGROUP_ROW');
}
-
- if(count($groups_values) == 1)
- {
- $user_f_group = cot_checkbox($urr['user_usergroup'], 'ruserusergroup', $groups_titles[0], '', $groups_values[0]);
- }
- else
- {
- $user_f_group = cot_radiobox($urr['user_usergroup'], 'ruserusergroup', $groups_values, $groups_titles, '', '
');
+
+ $selected = (!empty($urr) && !empty($urr['user_usergroup'])) ? $urr['user_usergroup'] : 0;
+ if(count($groups_values) == 1) {
+ $user_f_group = cot_checkbox($selected, 'ruserusergroup', $groups_titles[0], '', $groups_values[0]);
+ } else {
+ $user_f_group = cot_radiobox($selected, 'ruserusergroup', $groups_values, $groups_titles, '', '
');
}
$t->assign($prfx . 'GROUPSELECT', $user_f_group);
- $t->assign($prfx . 'GROUPSELECTBOX', cot_selectbox($urr['user_usergroup'], 'ruserusergroup', $groups_values, $groups_titles));
+ $t->assign($prfx . 'GROUPSELECTBOX', cot_selectbox($selected, 'ruserusergroup', $groups_values, $groups_titles));
}
\ No newline at end of file
diff --git a/plugins/usergroupselector/usergroupselector.setup.php b/plugins/usergroupselector/usergroupselector.setup.php
index a9549b7..d5b69ec 100644
--- a/plugins/usergroupselector/usergroupselector.setup.php
+++ b/plugins/usergroupselector/usergroupselector.setup.php
@@ -1,14 +1,12 @@
query("SELECT * FROM $db_users WHERE user_id=".$ruserid)->fetch();
- if($urr['user_usergroup'] != $urr['user_maingrp']
- && !empty($urr['user_usergroup'])
- && $urr['user_usergroup'] != COT_GROUP_SUPERADMINS
- && $urr['user_usergroup'] != COT_GROUP_MODERATORS
- && in_array($urr['user_usergroup'], $groupstoselect)
- && $urr['user_maingrp'] != COT_GROUP_SUPERADMINS
- && $urr['user_maingrp'] != COT_GROUP_MODERATORS)
- {
- $db->update($db_users, array('user_maingrp' => $urr['user_usergroup']), "user_id=".$urr['user_id']);
- $db->update($db_groups_users, array('gru_groupid' => $urr['user_usergroup']), "gru_userid=".$urr['user_id']." AND gru_groupid=".$urr['user_maingrp']);
+ if (
+ $row['user_usergroup'] != $row['user_maingrp']
+ && !empty($row['user_usergroup'])
+ && $row['user_usergroup'] != COT_GROUP_SUPERADMINS
+ && $row['user_usergroup'] != COT_GROUP_MODERATORS
+ && in_array($row['user_usergroup'], $groupstoselect)
+ && $row['user_maingrp'] != COT_GROUP_SUPERADMINS
+ && $row['user_maingrp'] != COT_GROUP_MODERATORS
+ ) {
+ Cot::$db->update(Cot::$db->users, ['user_maingrp' => $row['user_usergroup']], 'user_id = ' . $row['user_id']);
+ Cot::$db->update(
+ Cot::$db->groups_users,
+ ['gru_groupid' => $row['user_usergroup']],
+ "gru_userid = {$row['user_id']} AND gru_groupid = {$row['user_maingrp']}"
+ );
}
}
\ No newline at end of file
diff --git a/plugins/usergroupselector/usergroupselector.users.edit.main.php b/plugins/usergroupselector/usergroupselector.users.edit.main.php
index bcd876a..0383310 100644
--- a/plugins/usergroupselector/usergroupselector.users.edit.main.php
+++ b/plugins/usergroupselector/usergroupselector.users.edit.main.php
@@ -1,5 +1,4 @@
registerTable('userpoints');
function cot_setuserpoints($points, $type, $userid, $itemid = 0)
{
global $db, $cfg, $sys, $db_userpoints, $db_users;
- if ($urr = $db->query("SELECT * FROM $db_users WHERE user_id=" . (int)$userid)->fetch())
+ if ($urr = $db->query("SELECT * FROM $db_users WHERE user_id=" . (int) $userid)->fetch())
{
if(preg_match("/([\d\.]{1,}\%)/", $points, $pt))
{
@@ -52,19 +49,18 @@ function cot_setuserpoints($points, $type, $userid, $itemid = 0)
}
}
-function cot_get_topusers ($maingrp, $count, $sqlsearch='', $tpl='index')
+function cot_get_topusers ($maingrp, $count, $sqlsearch = '', $tpl = 'index')
{
global $L, $cfg, $db, $db_users;
- $t1 = new XTemplate(cot_tplfile(array('userpoints', $tpl), 'plug'));
+ $t1 = new XTemplate(cot_tplfile(['userpoints', $tpl], 'plug'));
$sqlsearch = !empty($sqlsearch) ? " AND " . $sqlsearch : '';
$topusers = $db->query("SELECT * FROM $db_users
WHERE user_userpoints>0 AND user_maingrp=".$maingrp." $sqlsearch ORDER BY user_userpoints DESC LIMIT " . $count)->fetchAll();
- foreach ($topusers as $tur)
- {
+ foreach ($topusers as $tur) {
$t1->assign(cot_generate_usertags($tur, 'TOP_ROW_'));
$t1->parse('MAIN.TOP_ROW');
}
@@ -72,6 +68,3 @@ function cot_get_topusers ($maingrp, $count, $sqlsearch='', $tpl='index')
$t1->parse('MAIN');
return $t1->text('MAIN');
}
-
-
-?>
diff --git a/plugins/userpoints/setup/patch_2.0.7.inc b/plugins/userpoints/setup/patch_2.0.7.inc
index a6be801..7a57e33 100644
--- a/plugins/userpoints/setup/patch_2.0.7.inc
+++ b/plugins/userpoints/setup/patch_2.0.7.inc
@@ -4,8 +4,11 @@ defined('COT_CODE') or die('Wrong URL');
global $db_userpoints;
+if (!isset($db_userpoints)) {
+ cot::$db->registerTable('userpoints');
+}
+
// Drop field if missing
-if ($db->fieldExists($db_userpoints, "item_cancel"))
-{
- $db->query("ALTER TABLE `$db_userpoints` DROP COLUMN `item_cancel`");
+if (cot::$db->fieldExists($db_userpoints, "item_cancel")) {
+ cot::$db->query("ALTER TABLE `$db_userpoints` DROP COLUMN `item_cancel`");
}
\ No newline at end of file
diff --git a/plugins/userpoints/setup/patch_2.0.8.sql b/plugins/userpoints/setup/patch_2.0.8.sql
index fab8deb..caaef17 100644
--- a/plugins/userpoints/setup/patch_2.0.8.sql
+++ b/plugins/userpoints/setup/patch_2.0.8.sql
@@ -1,7 +1,7 @@
ALTER TABLE `cot_userpoints`
-CHANGE `item_id` `item_id` int(10) unsigned NOT NULL auto_increment,
-CHANGE `item_userid` `item_userid` int(11) DEFAULT '0',
-CHANGE `item_date` `item_date` int(11) DEFAULT '0',
-CHANGE `item_type` `item_type` varchar(20) collate utf8_unicode_ci DEFAULT '',
-CHANGE `item_point` `item_point` float DEFAULT '0',
-CHANGE `item_itemid` `item_itemid` int(11) DEFAULT '0';
\ No newline at end of file
+CHANGE `item_id` `item_id` int unsigned NOT NULL auto_increment,
+CHANGE `item_userid` `item_userid` int DEFAULT 0,
+CHANGE `item_date` `item_date` int DEFAULT 0,
+CHANGE `item_type` `item_type` varchar(20) DEFAULT '',
+CHANGE `item_point` `item_point` float DEFAULT 0,
+CHANGE `item_itemid` `item_itemid` int DEFAULT 0;
\ No newline at end of file
diff --git a/plugins/userpoints/setup/patch_2.0.9.sql b/plugins/userpoints/setup/patch_2.0.9.sql
index 44539bb..ebc108e 100644
--- a/plugins/userpoints/setup/patch_2.0.9.sql
+++ b/plugins/userpoints/setup/patch_2.0.9.sql
@@ -1,3 +1,3 @@
ALTER TABLE `cot_users`
-CHANGE `user_userpoints` `user_userpoints` float DEFAULT '0',
-CHANGE `user_userpointsauth` `user_userpointsauth` int(11) DEFAULT '0';
\ No newline at end of file
+CHANGE `user_userpoints` `user_userpoints` float DEFAULT 0,
+CHANGE `user_userpointsauth` `user_userpointsauth` int DEFAULT 0;
\ No newline at end of file
diff --git a/plugins/userpoints/setup/userpoints.install.sql b/plugins/userpoints/setup/userpoints.install.sql
index 3131274..00874c7 100644
--- a/plugins/userpoints/setup/userpoints.install.sql
+++ b/plugins/userpoints/setup/userpoints.install.sql
@@ -2,11 +2,11 @@
* Userpoints module DB installation
*/
CREATE TABLE IF NOT EXISTS `cot_userpoints` (
- `item_id` int(10) unsigned NOT NULL auto_increment,
- `item_userid` int(11) DEFAULT '0',
- `item_date` int(11) DEFAULT '0',
- `item_type` varchar(20) collate utf8_unicode_ci DEFAULT '',
- `item_point` float DEFAULT '0',
- `item_itemid` int(11) DEFAULT '0',
+ `item_id` int unsigned NOT NULL auto_increment,
+ `item_userid` int DEFAULT 0,
+ `item_date` int DEFAULT 0,
+ `item_type` varchar(20) DEFAULT '',
+ `item_point` float DEFAULT 0,
+ `item_itemid` int DEFAULT 0,
PRIMARY KEY (`item_id`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
\ No newline at end of file
+)
\ No newline at end of file
diff --git a/plugins/userpoints/userpoints.setup.php b/plugins/userpoints/userpoints.setup.php
index b1d9a2c..6ac8253 100644
--- a/plugins/userpoints/userpoints.setup.php
+++ b/plugins/userpoints/userpoints.setup.php
@@ -4,10 +4,10 @@
* Code=userpoints
* Name=UserPoints
* Description=Система рейтингов пользователей
- * Version=2.1.1
- * Date=21.12.2010
- * Author=CMSWorks Team
- * Copyright=Copyright (c) CMSWorks.ru, littledev.ru
+ * Version=3.0.1
+ * Date=2025-01-20
+ * Author=CMSWorks Team, Cotonti team
+ * Copyright=Copyright (c) CMSWorks.ru, littledev.ru, Cotonti team
* Notes=
* Auth_guests=R
* Lock_guests=W12345A
@@ -31,11 +31,10 @@
* UserPoints plugin
*
* @package userpoints
- * @version 2.1.1
- * @author CMSWorks Team
- * @copyright Copyright (c) CMSWorks.ru, littledev.ru
+ * @author CMSWorks Team, Cotonti team
+ * @copyright Copyright (c) CMSWorks.ru, littledev.ru, Cotonti team
* @license BSD
*/
+
defined('COT_CODE') or die('Wrong URL');
-?>
\ No newline at end of file
diff --git a/plugins/userpoints/userpoints.users.auth.check.php b/plugins/userpoints/userpoints.users.auth.check.php
index 8a0cdf7..9e5025f 100644
--- a/plugins/userpoints/userpoints.users.auth.check.php
+++ b/plugins/userpoints/userpoints.users.auth.check.php
@@ -10,19 +10,22 @@
* UserPoints plugin
*
* @package userpoints
- * @version 2.0.0
- * @author CMSWorks Team
- * @copyright Copyright (c) CMSWorks.ru, littledev.ru
- * @license BSD
+ * @author CMSWorks Team, Cotonti team
+ * @copyright Copyright (c) CMSWorks.ru, littledev.ru, Cotonti team
+ *
+ * @var array $row User data
*/
defined('COT_CODE') or die('Wrong URL.');
require_once cot_incfile('userpoints', 'plug');
-$lastlog = $db->query("SELECT item_date FROM $db_userpoints
- WHERE item_userid=" . $ruserid . " AND item_type='auth' ORDER by item_date DESC LIMIT 1")->fetchColumn();
-if ($lastlog + 86400 < $sys['now'])
-{
- cot_setuserpoints($cfg['plugin']['userpoints']['auth'], 'auth', $ruserid);
- $db->update($db_users, array('user_userpointsauth' => $sys['now']), "user_id=".$ruserid);
+$lastlog = Cot::$db->query(
+ 'SELECT item_date FROM ' . Cot::$db->userpoints
+ . " WHERE item_userid = :userId AND item_type = 'auth' ORDER BY item_date DESC LIMIT 1",
+ ['userId' => $row['user_id']]
+)->fetchColumn();
+
+if ($lastlog + 86400 < Cot::$sys['now']) {
+ cot_setuserpoints(Cot::$cfg['plugin']['userpoints']['auth'], 'auth', $row['user_id']);
+ Cot::$db->update(Cot::$db->users, array('user_userpointsauth' => Cot::$sys['now']), 'user_id = ' . $row['user_id']);
}
\ No newline at end of file
diff --git a/plugins/verification/help.txt b/plugins/verification/help.txt
new file mode 100644
index 0000000..404297e
--- /dev/null
+++ b/plugins/verification/help.txt
@@ -0,0 +1,207 @@
+
+-
+
+ :
+31.10.2013
+:
+1.0 fix
+:
+02.04.2015
+
+ . . .
+
+
+
+1. plugins .
+
+2. .
+
+3. datas/
+ : 1. datas/verification_image/ 2. datas/verification_image/active_user/
+ , .
+
+4. .
+
+
+
+ ( tpl )
+
+{PHP.glb_vrf_link} - . ( )
+{PHP.glb_vrf_link_user} - . ( , )
+{PHP.glb_vrf_link_admin} - , . ( header.tpl)
+
+header.tpl
+
+{HEADER_USER_VRF_ICON} - . ( {HEADER_USER_NAME})
+
+users.edit.tpl
+
+ . ( )
+
+{USERS_EDIT_VRF_TITLE} - .
+{USERS_EDIT_VRF_STATUS} - - . users.profile.tpl .
+{USERS_PROFILE_VRF_TITLE} - .
+{USERS_PROFILE_VRF_STATUS} - .
+
+ tpl
+
+ tpl , , . XxX - VRF_TITLE, VRF_STATUS, VRF_ICON
+
+1. XxX _VRF_TITLE - .
+2. XxX _VRF_STATUS - .
+3. XxX _VRF_ICON - .
+
+ xxx.tpl?
+
+ xxx.tpl. {PRJ_OWNER_NAME} PRJ_OWNER_ . : {PRJ_OWNER_VRF_TITLE}, {PRJ_OWNER_VRF_STATUS}, {PRJ_OWNER_VRF_ICON}.
+
+ {PRJ_ROW_OWNER_NAME}: PRJ_ROW_OWNER_, : {PRJ_ROW_OWNER_VRF_TITLE}, {PRJ_ROW_OWNER_VRF_STATUS}, {PRJ_ROW_OWNER_VRF_ICON} ..
+
+
+
+ tpl :
+
+users.details.tpl: USERS_DETAILS_XxX
+
+projects.tpl: PRJ_OWNER_XxX
+
+projects.index.tpl, projects.list.tpl: PRJ_ROW_OWNER_XxX
+
+projects.offers.tpl: POST_ROW_OWNER_XxX, OFFER_ROW_OWNER_XxX, PERFORMER_XxX
+
+market.list.tpl: PRD_ROW_OWNER_XxX
+
+market.tpl: PRD_OWNER_VRF_XxX
+
+folio.list.tpl: PRD_ROW_OWNER_XxX
+
+folio.tpl: PRD_OWNER_XxX
+
+ paytop paytop.list.tpl : TOP_ROW_XxX
+
+ VRF_TITLE, VRF_STATUS, VRF_ICON
+
+
+
+
+
+ , . . , datas/verification_image/ . user_Id-user_name-secret_key.ext_img user_Id - id . user_name - secret_key - ext_img -
+
+ : 1-Dr2005alex-0fTEUTli.jpg
+
+ email , . - {PHP.glb_vrf_link_admin} - . ( ) , . , datas/verification_image/active_user/ . ? - ( ).
+
+ Verification
+
+ . . .
+
+
+1. plugins .
+2. .
+
+3. datas/
+
+ :
+dats/verification_image/
+dats/verification_image/active_user/
+
+ , .
+
+4. .
+
+
+
+ ( tpl )
+
+{PHP.glb_vrf_link} - . ( )
+{PHP.glb_vrf_link_user} - . ( , )
+{PHP.glb_vrf_link_admin} - , . ( header.tpl)
+
+header.tpl
+.
+{HEADER_USER_VRF_ICON} - . ( {HEADER_USER_NAME})
+users.edit.tpl
+
+ . ( )
+
+{USERS_EDIT_VRF_TITLE} - .
+{USERS_EDIT_VRF_STATUS} - - .
+
+users.profile.tpl
+
+ .
+
+{USERS_PROFILE_VRF_TITLE} - .
+{USERS_PROFILE_VRF_STATUS} - .
+
+ tpl.
+
+ tpl , , . XxX - VRF_TITLE, VRF_STATUS, VRF_ICON
+
+XxX _VRF_TITLE - .
+XxX _VRF_STATUS - .
+XxX _VRF_ICON - .
+
+ xxx.tpl?
+
+ xxx.tpl. {PRJ_OWNER_NAME}
+ PRJ_OWNER_ .
+
+
+{PRJ_OWNER_VRF_TITLE}
+{PRJ_OWNER_VRF_STATUS}
+{PRJ_OWNER_VRF_ICON}
+
+ {PRJ_ROW_OWNER_NAME}, PRJ_ROW_OWNER_
+ -
+{PRJ_ROW_OWNER_VRF_TITLE}
+{PRJ_ROW_OWNER_VRF_STATUS}
+{PRJ_ROW_OWNER_VRF_ICON}
+
+ ..
+
+ tpl .
+
+users.details.tpl : USERS_DETAILS_XxX
+projects.tpl : PRJ_OWNER_XxX
+
+projects.index.tpl,
+projects.list.tpl: PRJ_ROW_OWNER_XxX
+
+projects.offers.tpl: POST_ROW_OWNER_XxX
+ OFFER_ROW_OWNER_XxX
+ PERFORMER_XxX
+
+market.list.tpl : PRD_ROW_OWNER_XxX
+market.tpl : PRD_OWNER_VRF_XxX
+
+folio.list.tpl: PRD_ROW_OWNER_XxX
+folio.tpl: PRD_OWNER_XxX
+
+ paytop
+
+paytop.list.tpl : TOP_ROW_XxX
+
+ VRF_TITLE, VRF_STATUS, VRF_ICON
+
+ .
+
+ , .
+
+ .
+
+ , datas/verification_image/
+ .
+
+user_Id-user_name-secret_key.ext_img
+
+user_Id - id .
+user_name -
+secret_key -
+ext_img -
+
+ : 1-Dr2005alex-0fTEUTli.jpg
+
+ .
+
+ {PHP.glb_vrf_link_admin} .
\ No newline at end of file
diff --git a/plugins/verification/img/LOGOverification.png b/plugins/verification/img/LOGOverification.png
new file mode 100644
index 0000000..614418d
Binary files /dev/null and b/plugins/verification/img/LOGOverification.png differ
diff --git a/plugins/verification/img/v_g.png b/plugins/verification/img/v_g.png
new file mode 100644
index 0000000..56780e0
Binary files /dev/null and b/plugins/verification/img/v_g.png differ
diff --git a/plugins/verification/img/v_m.png b/plugins/verification/img/v_m.png
new file mode 100644
index 0000000..4bee591
Binary files /dev/null and b/plugins/verification/img/v_m.png differ
diff --git a/plugins/verification/img/ver_icon.png b/plugins/verification/img/ver_icon.png
new file mode 100644
index 0000000..c229cf7
Binary files /dev/null and b/plugins/verification/img/ver_icon.png differ
diff --git a/plugins/verification/img/ver_icon.png-- b/plugins/verification/img/ver_icon.png--
new file mode 100644
index 0000000..e35ef49
Binary files /dev/null and b/plugins/verification/img/ver_icon.png-- differ
diff --git a/plugins/verification/img/verification.png b/plugins/verification/img/verification.png
new file mode 100644
index 0000000..d60700f
Binary files /dev/null and b/plugins/verification/img/verification.png differ
diff --git a/plugins/verification/inc/verification.config.php b/plugins/verification/inc/verification.config.php
new file mode 100644
index 0000000..07f982c
--- /dev/null
+++ b/plugins/verification/inc/verification.config.php
@@ -0,0 +1,11 @@
+';
+$R['vrf_link'] = '
{$txt} ';
+$R['vrf_link_admin'] = '
{$txt} ';
\ No newline at end of file
diff --git a/plugins/verification/js/verification.css b/plugins/verification/js/verification.css
new file mode 100644
index 0000000..0b6eb0b
--- /dev/null
+++ b/plugins/verification/js/verification.css
@@ -0,0 +1,66 @@
+.padding10 {padding:10px;}
+.padding20-0 {padding:20px 0px;}
+
+.ver_img_box {padding:10px;}
+.ver_img_box img{max-width:600px;}
+
+#label_confirm{display: inline;}
+
+.jqmWindowVerification {
+display: none;
+position: fixed;
+ top: 3%;
+ left: 20%;
+overflow: auto;
+max-width:800px; max-height:650px;
+background-color: #EEE;
+color: #333;
+border: 1px solid white;
+padding: 7px;
+text-align: left;
+border-radius: 5px;
+-moz-border-radius: 5px;
+-webkit-border-radius: 5px;
+box-shadow: 0px 0px 9px 3px #fff;
+text-shadow: 0px 0px 3px #fff, 1px 1px 0px #fff;
+font-size:13px;
+overflow-y: auto;
+}
+.jqmClose {cursor:pointer;position:absolute; bottom:7px; right:10px;}
+.jqmWindowVerification img{max-width:800px; max-height:600px;}
+.user_identity{ position:relative; top:1px; bottom:1px; width:25px; height:25px; background: url(../img/ver_icon.png) no-repeat; padding:2px 15px;}
+.relative {position:relative;}
+.vrf_info_win {
min-width:200px;
+max-width:300px;
+z-index:10;
position:absolute;
+top:-60px;
+left:0px;
+background-color: #FFFF66;
+padding:5px;
+border-radius: 5px;
+-moz-border-radius: 5px;
+-webkit-border-radius: 5px;
+box-shadow: 2px 2px 7px 1px #999;
+}
+
+.vrf-arrow-border {
+ border-color: #999 transparent transparent transparent;
+ border-style: solid;
+ border-width: 10px 5px 0 5px;
+ height:0;
+ width:0;
+ position:absolute;
+ bottom:-11px;
+ left:48%;
+}
+.vrf-arrow {
+ border-color: #FFFF66 transparent transparent transparent;
+ border-style: solid;
+ border-width: 10px 5px 0 5px;
+ height:0;
+ width:0;
+ position:absolute;
+ bottom:-10px;
+ left:48%;
+}
+.sp_err_conf{display:none; width:300px;height:60px;}
diff --git a/plugins/verification/js/verification.js b/plugins/verification/js/verification.js
new file mode 100644
index 0000000..d8bf6cb
--- /dev/null
+++ b/plugins/verification/js/verification.js
@@ -0,0 +1,39 @@
+
+$(document).on('ready ajaxSuccess', function() {
+ if ($.fn.jqm === undefined) {
+ return;
+ }
+ $('.jqmWindowVerification').jqm({ trigger: 'a.trigger_jgm_vrf'});
+});
+
+function vrf_win_jqm(url) {
+ $('.jqmWindowVerification').jqm({ajax: 'index.php?r=verification&action=image&imgurl='+url});
+}
+
+
+
+function printing_machine(text,id, speed )
+{
+ var pi = pii = 0;
+ var divid = document.getElementById(id);
+
+ inter = setInterval( function(){
+ pii++; pi++;
+ if (pii >= text.length) clearInterval(inter);
+ if(pi <= text.length)divid.innerText = text.substring (0,pi);
+ },speed);
+}
+
+window.onload = function() {
+ const verifyLink = document.getElementById('linkverifi');
+ if (verifyLink === null) {
+ return;
+ }
+ var ch = document.getElementById('confirm');
+ verifyLink.onclick = function () {
+ if (!ch.checked){
+ printing_machine(text_vf_error, 'errors_confirm' , 20);
+ return false;
+ }
+ };
+};
\ No newline at end of file
diff --git a/plugins/verification/lang/verification.en.lang.php b/plugins/verification/lang/verification.en.lang.php
new file mode 100644
index 0000000..32b251b
--- /dev/null
+++ b/plugins/verification/lang/verification.en.lang.php
@@ -0,0 +1,87 @@
+ After checking your status will be changed to «identity confirmed» and next to the text icon will be displayed
';
+$L['ver_file_title']='Select a scanned passport photo';
+$L['ver_file_ext']='Allowed file extensions';
+$L['ver_file_max']='The maximum image size';
+
+$L['ver_mnotif_ttl']='New request for verification.';
+$L['ver_mnotif_txt']='User %1$s, added scan passports to check.';
+
+$L['info_desc'] = 'Proof of identity free-Lancer. Sending a scan of the passport for moderation.';
+
+/**
+ * Plugin Config
+ */
+
+$L['cfg_img_ext'] = 'Extension of uploaded files';
+$L['cfg_img_max_size'] = 'The maximum image size (Mb)';
+$L['cfg_mail_notify'] = array('Email for alerts on new applications.','Leave blank if you do not want to be notified.');
+
+/**
+ * Plugin tools
+ */
+
+$L['ver_tools_title'] = 'Administration passport data users.';
+$L['ver_tools_help'] = 'After approval, the scan passport photos transferred to the folder «'
+ . ($ver_file_patch_new ?? '') . '»';
+$L['ver_tools_link_img'] = 'Link to scan passports';
+$L['ver_tools_view_img'] = 'See photos at full size';
+$L['ver_tools_close'] = 'Close';
+$L['ver_tools_admin_action'] = 'Action';
+$L['ver_tools_admin_action_confirm'] = 'Activate status';
+$L['ver_tools_admin_action_done'] = ' «identity confirmed»';
+$L['ver_tools_delete_confirm'] = 'Are you sure you want to delete the copy of your passport ?';
+$L['ver_tools_yes'] = 'Yes';
+$L['ver_tools_no'] = 'No';
+$L['ver_tools_delete_confirm_done'] = 'Copy of passport removed.';
+$L['ver_tools_add_scan'] = "Requests for verification ";
+/**
+ * Plugin errors
+ */
+$L['ver_filemimemissing'] = 'Error loading: Loading a file with the extension %1$s prohibited.';
+$L['ver_imgnotvalid'] = 'This picture is not a real image %1$s.';
+$L['ver_nofile'] = 'Unspecified image.';
+
+
+$L['verification_help'] = '';
diff --git a/plugins/verification/lang/verification.ru.lang.php b/plugins/verification/lang/verification.ru.lang.php
new file mode 100644
index 0000000..4c1541d
--- /dev/null
+++ b/plugins/verification/lang/verification.ru.lang.php
@@ -0,0 +1,88 @@
+ После проверки ваш статус будет изменен на «личность подтверждена» и рядом с аватаром будет выводиться значок
';
+$L['ver_file_title']='Выберите отсканированное фото паспорта';
+$L['ver_file_ext']='Допустимые расширения файла';
+$L['ver_file_max']='Максимальный размер изображения';
+
+$L['ver_mnotif_ttl']='Новая заявка на верификацию.';
+$L['ver_mnotif_txt']='Пользователь %1$s, добавил скан паспорта на проверку.';
+
+$L['info_desc'] = 'Подтверждение личности фри-лансера. Отправка скана паспорта на модерацию.';
+
+/**
+ * Plugin Config
+ */
+
+$L['cfg_img_ext'] = 'Расширение загружаемых файлов';
+$L['cfg_img_max_size'] = 'Максимальный размер изображения (Mb)';
+$L['cfg_mail_notify'] = array('Email для оповещения о новых заявках.','оставьте пустым, если не хотите получать уведомления.');
+
+/**
+ * Plugin tools
+ */
+
+$L['ver_tools_title'] = 'Администрирование паспортных данных пользователей.';
+$L['ver_tools_help'] = 'После утверждения, фото скана паспорта переносится в папку «'
+ . ($ver_file_patch_new ?? '') . '»';
+$L['ver_tools_link_img'] = 'Ссылка на скан паспорта';
+$L['ver_tools_view_img'] = 'Смотреть фото в полном размере';
+$L['ver_tools_close'] = 'Закрыть';
+$L['ver_tools_admin_action'] = 'Действие';
+$L['ver_tools_admin_action_confirm'] = 'Активировать статус';
+$L['ver_tools_admin_action_done'] = ' «личность подтверждена»';
+$L['ver_tools_delete_confirm'] = 'Вы действительно хотите удалить копию паспорта?';
+$L['ver_tools_yes'] = 'ДА';
+$L['ver_tools_no'] = 'НЕТ';
+$L['ver_tools_delete_confirm_done'] = 'Копия паспорта удалена.';
+$L['ver_tools_add_scan'] = "Заявки на верификацию ";
+/**
+ * Plugin errors
+ */
+$L['ver_filemimemissing'] = 'Ошибка загрузки: Загрузка файла с расширением %1$s запрещена.';
+$L['ver_imgnotvalid'] = 'Это изображение не является действительным изображением %1$s.';
+$L['ver_nofile'] = 'Не выбрано изображение.';
+
+
+$L['verification_help'] = '';
diff --git a/plugins/verification/setup/verification.install.php b/plugins/verification/setup/verification.install.php
new file mode 100644
index 0000000..fa04bf4
--- /dev/null
+++ b/plugins/verification/setup/verification.install.php
@@ -0,0 +1,28 @@
+array('order' => '99', 'name' => 'verification_count','type' => '0', 'default' => '0')),true);
+
+
+
+?>
diff --git a/plugins/verification/setup/verification.uninstall.php b/plugins/verification/setup/verification.uninstall.php
new file mode 100644
index 0000000..6d7e4c8
--- /dev/null
+++ b/plugins/verification/setup/verification.uninstall.php
@@ -0,0 +1,17 @@
+
+
+
+
+
{PHP.L.ver_tools_title}
+
+
+
+
+
+
+
{PHP.L.ver_tools_close}
+
+
+
+
{PHP.L.ver_tools_admin_action_done}
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/plugins/verification/tpl/verification.tpl b/plugins/verification/tpl/verification.tpl
new file mode 100644
index 0000000..b970448
--- /dev/null
+++ b/plugins/verification/tpl/verification.tpl
@@ -0,0 +1,72 @@
+
+
+
+
+
{PHP.L.ver_txt1}
+
+
{PHP.L.ver_txt6}
+
+
+
+
+ {PHP.L.ver_checked}
+ {PHP|cot_rc('vrf_activ_icon')}{PHP.L.ver_name1}
+
+
+
+ {PHP.L.ver_nochecked}
+ {PHP.L.ver_name2}
+
+
+
+
+
{PHP.L.ver_txt2}
+
{PHP.L.ver_txt3} {PHP|cot_rc('vrf_activ_icon')}{PHP.L.ver_txt4}
+
{PHP.L.ver_txt5}
+
+
+
+ {PHP.L.ver_confirm}
+
+
+
+
+
+
+
+
+{FILE "{PHP.cfg.themes_dir}/{PHP.cfg.defaulttheme}/warnings.tpl"}
+
+
+
+
+
{PHP.L.ver_confirm_title}
+
+
+ {PHP.L.ver_file_title}.
+ {FILE "{PHP.cfg.themes_dir}/{PHP.cfg.defaulttheme}/warnings.tpl"}
+
+ {PHP.L.ver_file_ext}: {PHP.ext_txt}
+ {PHP.L.ver_file_max}: {PHP.up_max} Mb
+
+
+
+
+
+
{PHP.L.ver_statusexist_title}
+
{PHP.L.ver_statusexist_desc}
+
+
+
+
{PHP.L.ver_exist_title}
+
{PHP.L.ver_exist_desc}
+
+
+
+
+
{PHP.L.ver_file_send_mess}
+
{PHP.L.ver_file_send_mess_desc}
+
+
+
+
\ No newline at end of file
diff --git a/plugins/verification/verification.ajax.php b/plugins/verification/verification.ajax.php
new file mode 100644
index 0000000..b6a2a03
--- /dev/null
+++ b/plugins/verification/verification.ajax.php
@@ -0,0 +1,89 @@
+parse("MAIN.IMAGE");
+echo $vrft->text("MAIN.IMAGE");
+
+}
+if ($action == 'activate'){
+$vrf_file = explode('/',$imgurl);
+$vrf_filename = $vrf_file[(count($vrf_file) - 1)];
+
+if(is_file($imgurl) && rename($imgurl, $ver_file_patch_new.$vrf_filename ))
+{
+ $cfg['verification_plug']['verification_count']--;
+ cot_config_modify('verification_plug', array('0'=>array('order' => '99', 'name' => 'verification_count','type' => '0', 'value' => "{$cfg['verification_plug']['verification_count']}")),true);
+ if ($cache){
+ $cache->db->remove('cot_cfg', 'system');
+ }
+
+ $db->update($db_users, array('user_verification_status' => 1), "user_id='".$user."'");
+ $vt = new XTemplate(cot_tplfile('verification.tools', 'plug', true));
+ $vt->parse("MAIN.ACTIV");
+ echo $vt->text("MAIN.ACTIV");
+}else echo "error rename file";
+
+}
+
+if ($action == 'delete'){
+$vt = new XTemplate(cot_tplfile('verification.tools', 'plug', true));
+ $vt->assign(array(
+ "DEL_ONCLICK" => "OnClick = \"$('#at_".$index."').fadeOut(600);return ajaxSend({ method: 'GET', url: '".cot_url('plug', 'r=verification&action=remove','',true)."', data:'index=".$index."&user=".$user."&imgurl=".urlencode($imgurl)."' ,divId: 'pth_".$index."', errMsg: '".$L['ajaxSenderror']."' });\"",
+ "BACK_ONCLICK" => "OnClick = \"return ajaxSend({ method: 'GET', url: '".cot_url('plug', 'r=verification&action=back','',true)."', data:'index=".$index."&user=".$user."&imgurl=".urlencode($imgurl)."' ,divId: 'at_".$index."', errMsg: '".$L['ajaxSenderror']."' });\"",
+ ));
+
+$vt->parse("MAIN.DELETE");
+echo $vt->text("MAIN.DELETE");
+}
+
+if ($action == 'back'){
+$vt = new XTemplate(cot_tplfile('verification.tools', 'plug', true));
+
+ $vt->assign(array(
+ "ONCLICK" => "OnClick = \"$('#pth_".$index."').fadeOut(600);return ajaxSend({ method: 'GET', url: '".cot_url('plug', 'r=verification&action=activate','',true)."', data:'index=".$index."&user=".$user."&imgurl=".urlencode($imgurl)."' ,divId: 'at_".$index."', errMsg: '".$L['ajaxSenderror']."' });\"",
+ "DELETE_ONCLICK" => "OnClick = \"return ajaxSend({ method: 'GET', url: '".cot_url('plug', 'r=verification&action=delete','',true)."', data:'index=".$index."&user=".$user."&imgurl=".urlencode($imgurl)."' ,divId: 'at_".$index."', errMsg: '".$L['ajaxSenderror']."' });\"",
+
+ ));
+
+$vt->parse("MAIN.ROW.ADMIN_ACT");
+echo $vt->text("MAIN.ROW.ADMIN_ACT");
+}
+
+if ($action == 'remove'){
+
+ if(file_exists($imgurl))
+ {
+ unlink($imgurl);
+ }
+$cfg['verification_plug']['verification_count']--;
+cot_config_modify('verification_plug', array('0'=>array('order' => '99', 'name' => 'verification_count','type' => '0', 'value' => "{$cfg['verification_plug']['verification_count']}")),true);
+if($cache)$cache->db->remove('cot_cfg', 'system');
+echo $L['ver_tools_delete_confirm_done'];
+}
\ No newline at end of file
diff --git a/plugins/verification/verification.global.php b/plugins/verification/verification.global.php
new file mode 100644
index 0000000..20ce585
--- /dev/null
+++ b/plugins/verification/verification.global.php
@@ -0,0 +1,38 @@
+ cot_url('plug', 'e=verification'),'txt' => $L['ver_vrf_txt'], 'title' => $L['ver_vrf_txt_title']));
+$glb_vrf_link_user = (Cot::$usr['id'] > 0 && !Cot::$usr['profile']['user_verification_status']) ? $glb_vrf_link : '';
+$glb_vrf_link_admin = (Cot::$cfg['verification_plug']['verification_count'] > 0 && $auth_admin)
+ ? cot_rc(
+ 'vrf_link',
+ [
+ 'url' => cot_url('admin', 'm=other&p=verification'),
+ 'txt' => $L['ver_tools_add_scan'] . Cot::$cfg['verification_plug']['verification_count'],
+ 'title' => $L['ver_tools_add_scan'],
+ ]
+ )
+ : '';
+
+
diff --git a/plugins/verification/verification.header.user.tags.php b/plugins/verification/verification.header.user.tags.php
new file mode 100644
index 0000000..1382df4
--- /dev/null
+++ b/plugins/verification/verification.header.user.tags.php
@@ -0,0 +1,25 @@
+assign("HEADER_USER_VRF_ICON" ,cot_rc('vrf_activ_icon',array('title' => $L['ver_checked_user'])));
+
diff --git a/plugins/verification/verification.php b/plugins/verification/verification.php
new file mode 100644
index 0000000..3c74e74
--- /dev/null
+++ b/plugins/verification/verification.php
@@ -0,0 +1,172 @@
+parse("MAIN.START");
+
+if($confirm != "ON" && empty($act) && !empty($type))
+{
+ cot_error($L['ver_confirm_error'], 'confirm');
+ cot_display_messages($t,'MAIN.START');
+ $t->parse("MAIN.START");return;
+
+ }
+
+if($type == 'passport'){ // for verification passport
+
+ if($usr['profile']['user_verification_status']){
+ $t->parse("MAIN.STATUSEXIST"); return;
+ }
+
+
+ $code = 'scanpassport';
+ $ext_img = explode(',', $cfg['plugin']['verification']['img_ext']);
+ $file_exist_error = false;
+
+
+
+ // ����� ������������ �����
+ $dir = opendir($ver_file_patch);
+ while(($file = readdir($dir)) !== false) {
+ $mass_sa = strstr($file,$ver_file_name);
+ if($mass_sa != "") {
+ $file_exist_error = true; $img_mod_url = $ver_file_patch.$mass_sa;
+ }
+ }
+ closedir($dir);
+
+ // data
+ $up_max = ((int)$cfg['plugin']['verification']['img_max_size'] < ((cot_get_uploadmax())/1000 )) ? $cfg['plugin']['verification']['img_max_size'] : (cot_get_uploadmax())/1000;
+
+
+
+ $ext_i = 0;
+ foreach ($ext_img as $ext)
+ {
+ if($ext_i > 0){$ext_file .= ","; $ext_txt .= ", ";}
+ $ext_file .= "image/".$ext;
+ $ext_txt .= $ext;
+ $ext_i++;
+ }
+
+ if($file_exist_error){$t->parse("MAIN.EXIST"); return;}
+
+ if($act == 'sendform'){
+
+ if($_FILES[$code]['size'] > 0 )
+ { // �������� �����
+ @clearstatcache();
+ $file = $_FILES[$code];
+ if (!empty($file['tmp_name']) && $file['size'] > 0 && is_uploaded_file($file['tmp_name']))
+ {
+ $gd_supported = $ext_img;
+
+ $exrarr = explode(".", $file['name']);
+ $file_ext = mb_strtolower(end($exrarr));
+
+ $fcheck = cot_file_check($file['tmp_name'], $file['name'], $file_ext);
+ if(in_array($file_ext, $gd_supported) && $fcheck == 1)
+ {
+ $file['name']= cot_safename($file['name'], true);
+ // ������� ��������� ��� RANDOM
+ $RANDOM = cot_randomstring();
+ $filename_full = $ver_file_name.$RANDOM.'.'.$file_ext;
+ $filepath = $ver_file_patch.$filename_full;
+
+ if(file_exists($filepath))
+ {
+ unlink($filepath);
+ }
+
+ move_uploaded_file($file['tmp_name'], $filepath);
+ @chmod($filepath, $cfg['file_perms']);
+
+ /* === Hook === */
+ foreach (cot_getextplugins('verification.fileload') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+
+ }
+ elseif($fcheck == 2)
+ {
+ cot_error(sprintf($L['ver_filemimemissing'], $file_ext), $code);
+ }
+ else
+ {
+ cot_error(sprintf($L['ver_imgnotvalid'], $file_ext), $code);
+ }
+ }
+
+ }else{
+ cot_error($L['ver_nofile'], $code);
+ }
+
+
+ if (!cot_error_found())
+ {
+ require_once cot_incfile('configuration');
+ /* === Hook === */
+ foreach (cot_getextplugins('verification.fileload.done') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+ $cfg['verification_plug']['verification_count']++;
+ cot_config_modify('verification_plug', array('0'=>array('order' => '99', 'name' => 'verification_count','type' => '0', 'value' => "{$cfg['verification_plug']['verification_count']}")),true);
+
+ if ($cache){
+ $cache->db->remove('cot_cfg', 'system');
+ }
+ $img_mod_url = $filepath;
+ $t->parse("MAIN.SEND");
+
+ if(!empty($cfg['plugin']['verification']['mail_notify'])){
+
+ $rsubject = $L['ver_mnotif_ttl'];
+ $rbody = sprintf($L['ver_mnotif_txt'], htmlspecialchars($usr['name']));
+ cot_mail($cfg['plugin']['verification']['mail_notify'], $rsubject, $rbody);
+
+ }
+
+ return;
+ }
+
+ cot_display_messages($t,'MAIN.FORM');
+
+ }
+
+ $t->parse("MAIN.FORM");
+}
diff --git a/plugins/verification/verification.png b/plugins/verification/verification.png
new file mode 100644
index 0000000..a58a942
Binary files /dev/null and b/plugins/verification/verification.png differ
diff --git a/plugins/verification/verification.rc.php b/plugins/verification/verification.rc.php
new file mode 100644
index 0000000..49979fd
--- /dev/null
+++ b/plugins/verification/verification.rc.php
@@ -0,0 +1,24 @@
+
diff --git a/plugins/verification/verification.tools.php b/plugins/verification/verification.tools.php
new file mode 100644
index 0000000..7eae523
--- /dev/null
+++ b/plugins/verification/verification.tools.php
@@ -0,0 +1,66 @@
+assign(array(
+ "INDEX" => $fi,
+ "FILE_PATH" => $ver_file_patch.$file,
+ "USER" => cot_build_user($vrf_user[0], $vrf_user[1]),
+ "ONCLICK" => "OnClick = \"$('#pth_".$fi."').fadeOut(600);return ajaxSend({ method: 'GET', url: '".cot_url('plug', 'r=verification&action=activate','',true)."', data:'index=".$fi."&user=".$vrf_user[0]."&imgurl=".urlencode($ver_file_patch.$file)."' ,divId: 'at_".$fi."', errMsg: '".$L['ajaxSenderror']."' });\"",
+ "DELETE_ONCLICK" => "OnClick = \"return ajaxSend({ method: 'GET', url: '".cot_url('plug', 'r=verification&action=delete','',true)."', data:'index=".$fi."&user=".$vrf_user[0]."&imgurl=".urlencode($ver_file_patch.$file)."' ,divId: 'at_".$fi."', errMsg: '".$L['ajaxSenderror']."' });\"",
+
+ ));
+ $t->parse("MAIN.ROW.ADMIN_ACT");
+ $t->parse("MAIN.ROW");
+
+
+ }
+ }
+ closedir($dir);
+
+
+
+$t->parse('MAIN');
+if (COT_AJAX)
+{
+ $t->out('MAIN');
+}
+else
+{
+ $adminMain = $t->text('MAIN');
+}
diff --git a/plugins/verification/verification.users.edit.tags.php b/plugins/verification/verification.users.edit.tags.php
new file mode 100644
index 0000000..44a379d
--- /dev/null
+++ b/plugins/verification/verification.users.edit.tags.php
@@ -0,0 +1,28 @@
+assign(array(
+ 'USERS_EDIT_VRF_TITLE' => $L['ver_checked_user'],
+ 'USERS_EDIT_VRF_STATUS' => cot_radiobox($urr['user_verification_status'], 'ruserverification_status', array(1, 0), array($L['Yes'], $L['No']))
+ ));
diff --git a/plugins/verification/verification.users.profile.tags.php b/plugins/verification/verification.users.profile.tags.php
new file mode 100644
index 0000000..7aa8d81
--- /dev/null
+++ b/plugins/verification/verification.users.profile.tags.php
@@ -0,0 +1,28 @@
+assign(array(
+ 'USERS_PROFILE_VRF_TITLE' => $L['ver_vrf_status'],
+ 'USERS_PROFILE_VRF_STATUS' => ($urr['user_verification_status']) ? cot_rc('vrf_activ_icon',array('title' => $L['ver_checked_user'])).$L['ver_txt4'] : $L['ver_nochecked']
+ ));
+
diff --git a/plugins/verification/verification.users.tags.php b/plugins/verification/verification.users.tags.php
new file mode 100644
index 0000000..547d548
--- /dev/null
+++ b/plugins/verification/verification.users.tags.php
@@ -0,0 +1,27 @@
+ $L['ver_checked_user'])).$L['ver_txt4'] : $L['ver_nochecked'];
+ $temp_array['VRF_ICON'] = ($user_data['user_verification_status']) ? cot_rc('vrf_activ_icon',array('title' => $L['ver_checked_user'])):'';
+}
\ No newline at end of file
diff --git a/plugins/vizitedproducts/inc/vizitedproducts.functions.php b/plugins/vizitedproducts/inc/vizitedproducts.functions.php
new file mode 100644
index 0000000..7796f52
--- /dev/null
+++ b/plugins/vizitedproducts/inc/vizitedproducts.functions.php
@@ -0,0 +1,78 @@
+query("SELECT * FROM $db_market AS m
+ LEFT JOIN $db_users AS u ON u.user_id=m.item_userid
+ " . $vizitedproducts_where . "
+ " . $vizitedproducts_order . "
+ LIMIT " . $cfg['plugin']['vizitedproducts']['limit'])->fetchAll();
+
+ if(count($sqlvizitedproducts) > 0)
+ {
+ foreach ($sqlvizitedproducts as $vprd)
+ {
+ $jj++;
+ $t->assign(cot_generate_usertags($vprd, 'PRD_ROW_OWNER_'));
+
+ $t->assign(cot_generate_markettags($vprd, 'PRD_ROW_', $cfg['market']['shorttextlen'], $usr['isadmin'], $cfg['homebreadcrumb']));
+ $t->assign(array(
+ "PRD_ROW_ODDEVEN" => cot_build_oddeven($jj),
+ ));
+
+ /* === Hook === */
+ foreach (cot_getextplugins('vizitedproducts.loop') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+
+ $t->parse("MAIN.PRD_ROW");
+ }
+
+ /* === Hook === */
+ foreach (cot_getextplugins('vizitedproducts.tags') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+
+ $t->parse('MAIN');
+
+ return $t->text('MAIN');
+ }
+ }
+}
\ No newline at end of file
diff --git a/plugins/vizitedproducts/lang/vizitedproducts.en.lang.php b/plugins/vizitedproducts/lang/vizitedproducts.en.lang.php
new file mode 100644
index 0000000..bf49a2d
--- /dev/null
+++ b/plugins/vizitedproducts/lang/vizitedproducts.en.lang.php
@@ -0,0 +1,18 @@
+
+
+
{PHP.L.vizitedproducts}
+
+
+
+
+
+
\ No newline at end of file
diff --git a/plugins/vizitedproducts/tpl/vizitedproducts.tpl b/plugins/vizitedproducts/tpl/vizitedproducts.tpl
new file mode 100644
index 0000000..7cfb60f
--- /dev/null
+++ b/plugins/vizitedproducts/tpl/vizitedproducts.tpl
@@ -0,0 +1,19 @@
+
+
+
{PHP.L.vizitedproducts}
+
+
+
+
+
+
\ No newline at end of file
diff --git a/plugins/vizitedproducts/vizitedproducts.global.php b/plugins/vizitedproducts/vizitedproducts.global.php
new file mode 100644
index 0000000..8df0e16
--- /dev/null
+++ b/plugins/vizitedproducts/vizitedproducts.global.php
@@ -0,0 +1,11 @@
+query("SELECT * FROM $db_projects AS p
+ LEFT JOIN $db_users AS u ON u.user_id=p.item_userid
+ " . $vizitedprojects_where . "
+ " . $vizitedprojects_order . "
+ LIMIT " . $cfg['plugin']['vizitedprojects']['limit'])->fetchAll();
+
+ if(count($sqlvizitedprojects) > 0)
+ {
+ foreach ($sqlvizitedprojects as $vprj)
+ {
+ $jj++;
+ $t->assign(cot_generate_usertags($vprj, 'PRJ_ROW_OWNER_'));
+
+ $t->assign(cot_generate_projecttags($vprj, 'PRJ_ROW_', $cfg['market']['shorttextlen'], $usr['isadmin'], $cfg['homebreadcrumb']));
+ $t->assign(array(
+ "PRJ_ROW_ODDEVEN" => cot_build_oddeven($jj),
+ ));
+
+ /* === Hook === */
+ foreach (cot_getextplugins('vizitedprojects.loop') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+
+ $t->parse("MAIN.PRJ_ROW");
+ }
+
+ /* === Hook === */
+ foreach (cot_getextplugins('vizitedprojects.tags') as $pl)
+ {
+ include $pl;
+ }
+ /* ===== */
+
+ $t->parse('MAIN');
+
+ return $t->text('MAIN');
+ }
+ }
+}
\ No newline at end of file
diff --git a/plugins/vizitedprojects/lang/vizitedprojects.en.lang.php b/plugins/vizitedprojects/lang/vizitedprojects.en.lang.php
new file mode 100644
index 0000000..b2537b9
--- /dev/null
+++ b/plugins/vizitedprojects/lang/vizitedprojects.en.lang.php
@@ -0,0 +1,18 @@
+
+
+
{PHP.L.vizitedprojects}
+
+
+
+
\ No newline at end of file
diff --git a/plugins/vizitedprojects/vizitedprojects.global.php b/plugins/vizitedprojects/vizitedprojects.global.php
new file mode 100644
index 0000000..01a9226
--- /dev/null
+++ b/plugins/vizitedprojects/vizitedprojects.global.php
@@ -0,0 +1,11 @@
+setStatus($pinfo['pay_id'],
+ PaymentDictionary::STATUS_PAID,
+ 'webmoney')
+ ) {
echo "YES";
- }
- else
- {
+ } else {
echo "ERR: Payment failed";
- };
- }
- else
- {
+ }
+ } else {
echo "ERR: Inconsistent parameters";
- };
- };
- }
- else
- {
+ }
+ }
+ } else {
echo "ERR: Inconsistent parameters";
- };
+ }
}
-?>
\ No newline at end of file
diff --git a/plugins/wmbilling/wmbilling.php b/plugins/wmbilling/wmbilling.php
index ec6ea63..b529662 100644
--- a/plugins/wmbilling/wmbilling.php
+++ b/plugins/wmbilling/wmbilling.php
@@ -14,6 +14,11 @@
* @copyright Copyright (c) CMSWorks.ru
* @license BSD
*/
+
+use cot\modules\payments\dictionaries\PaymentDictionary;
+use cot\modules\payments\Repositories\PaymentRepository;
+use cot\modules\payments\Services\PaymentService;
+
defined('COT_CODE') && defined('COT_PLUG') or die('Wrong URL');
require_once cot_incfile('wmbilling', 'plug');
@@ -25,7 +30,7 @@
if (empty($m))
{
// Получаем информацию о заказе
- if (!empty($pid) && $pinfo = cot_payments_payinfo($pid))
+ if (!empty($pid) && $pinfo = PaymentRepository::getInstance()->getById($pid))
{
cot_block($usr['id'] == $pinfo['pay_userid']);
cot_block($pinfo['pay_status'] == 'new' || $pinfo['pay_status'] == 'process');
@@ -56,33 +61,26 @@
));
$t->parse("MAIN.WMFORM");
- cot_payments_updatestatus($pid, 'process'); // Изменяем статус "в процессе оплаты"
- }
- else
- {
+ // Изменяем статус "в процессе оплаты"
+ PaymentService::getInstance()->setStatus($pid, PaymentDictionary::STATUS_PROCESS, 'webmoney');
+ } else {
cot_die();
}
-}
-elseif ($m == 'success')
-{
- $plugin_body = $L['wmbilling_error_incorrect'];
+} elseif ($m == 'success') {
+ $pluginBody = $L['wmbilling_error_incorrect'];
- if (isset($_GET['LMI_PAYMENT_NO']) && preg_match('/^\d+$/', $_GET['LMI_PAYMENT_NO']) == 1)
- {
- $pinfo = cot_payments_payinfo($_GET['LMI_PAYMENT_NO']);
- if ($pinfo['pay_status'] == 'done')
- {
- $plugin_body = $L['wmbilling_error_done'];
+ if (isset($_GET['LMI_PAYMENT_NO']) && preg_match('/^\d+$/', $_GET['LMI_PAYMENT_NO']) == 1) {
+ $pinfo = PaymentRepository::getInstance()->getById((int) $_GET['LMI_PAYMENT_NO']);
+ if ($pinfo['pay_status'] == 'done') {
+ $pluginBody = $L['wmbilling_error_done'];
$redirect = $pinfo['pay_redirect'];
- }
- elseif ($pinfo['pay_status'] == 'paid')
- {
- $plugin_body = $L['wmbilling_error_paid'];
+ } elseif ($pinfo['pay_status'] == 'paid') {
+ $pluginBody = $L['wmbilling_error_paid'];
}
}
$t->assign(array(
"WEBMONEY_TITLE" => $L['wmbilling_error_title'],
- "WEBMONEY_ERROR" => $plugin_body
+ "WEBMONEY_ERROR" => $pluginBody
));
if($redirect){
diff --git a/system/functions.custom.php b/system/functions.custom.php
index b35846c..03aaac9 100644
--- a/system/functions.custom.php
+++ b/system/functions.custom.php
@@ -5,14 +5,12 @@
function cot_load_structure_custom()
{
global $db, $db_structure, $cfg, $cot_extrafields, $structure;
+
$structure = array();
- if (defined('COT_UPGRADE'))
- {
+ if (defined('COT_UPGRADE')) {
$sql = $db->query("SELECT * FROM $db_structure ORDER BY structure_path ASC");
$row['structure_area'] = 'page';
- }
- else
- {
+ } else {
$sql = $db->query("SELECT * FROM $db_structure ORDER BY structure_area ASC, structure_path ASC");
}
@@ -23,6 +21,7 @@ function cot_load_structure_custom()
$path = array(); // code path tree
$tpath = array(); // title path tree
$tpls = array(); // tpl codes tree
+ $subcats = [];
foreach ($sql->fetchAll() as $row)
{
@@ -87,7 +86,7 @@ function cot_load_structure_custom()
{
foreach ($area_structure as $i => $x)
{
- $structure[$area][$i]['subcats'] = $subcats[$area][$i];
+ $structure[$area][$i]['subcats'] = isset($subcats[$area][$i]) ? $subcats[$area][$i] : null;
}
}
}
\ No newline at end of file
diff --git a/themes/admin/fusion/admin.cache.disk.tpl b/themes/admin/fusion/admin.cache.disk.tpl
index 539725a..4c0a9f1 100644
--- a/themes/admin/fusion/admin.cache.disk.tpl
+++ b/themes/admin/fusion/admin.cache.disk.tpl
@@ -1,36 +1,35 @@
-
Disk Cache
- {FILE "{PHP.cfg.themes_dir}/admin/{PHP.cfg.admintheme}/warnings.tpl"}
-
-
-
-
-
- {PHP.L.Item}
- {PHP.L.Files}
- {PHP.L.Size}
- {PHP.L.Delete}
-
-
-
+{FILE "{PHP.cfg.themes_dir}/admin/{PHP.cfg.admintheme}/warnings.tpl"}
+
+
+
+
+
+ {PHP.L.Item}
+ {PHP.L.Files}
+ {PHP.L.Size}
+ {PHP.L.Delete}
+
+
+
-
- {ADMIN_DISKCACHE_ITEM_NAME}
- {ADMIN_DISKCACHE_FILES}
- {ADMIN_DISKCACHE_SIZE}
- {PHP.L.Delete}
-
+
+ {ADMIN_DISKCACHE_ITEM_NAME}
+ {ADMIN_DISKCACHE_FILES}
+ {ADMIN_DISKCACHE_SIZE}
+ {PHP.L.Delete}
+
-
- {PHP.L.Total}:
- {ADMIN_DISKCACHE_CACHEFILES}
- {ADMIN_DISKCACHE_CACHESIZE}
-
-
-
-
-
+
+ {PHP.L.Total}:
+ {ADMIN_DISKCACHE_CACHEFILES}
+ {ADMIN_DISKCACHE_CACHESIZE}
+
+
+
+
+
\ No newline at end of file
diff --git a/themes/admin/fusion/admin.cache.tpl b/themes/admin/fusion/admin.cache.tpl
index 643f16c..1a8c58a 100644
--- a/themes/admin/fusion/admin.cache.tpl
+++ b/themes/admin/fusion/admin.cache.tpl
@@ -1,21 +1,20 @@
-
{PHP.L.adm_internalcache}
- {FILE "{PHP.cfg.themes_dir}/admin/{PHP.cfg.admintheme}/warnings.tpl"}
-
+{FILE "{PHP.cfg.themes_dir}/admin/{PHP.cfg.admintheme}/warnings.tpl"}
+
-
-
{ADMIN_CACHE_MEMORY_DRIVER}
-
-
- {PHP.L.Available}: {ADMIN_CACHE_MEMORY_AVAILABLE} / {ADMIN_CACHE_MEMORY_MAX} {PHP.L.bytes}
-
+
+
{ADMIN_CACHE_MEMORY_DRIVER}
+
+
+ {PHP.L.Available}: {ADMIN_CACHE_MEMORY_AVAILABLE} / {ADMIN_CACHE_MEMORY_MAX} {PHP.L.bytes}
+
+
{PHP.L.Database}
diff --git a/themes/admin/fusion/admin.config.tpl b/themes/admin/fusion/admin.config.tpl
index e8b1619..f97acae 100644
--- a/themes/admin/fusion/admin.config.tpl
+++ b/themes/admin/fusion/admin.config.tpl
@@ -1,8 +1,6 @@
-
{FILE "{PHP.cfg.themes_dir}/admin/{PHP.cfg.admintheme}/warnings.tpl"}
-
{PHP.L.Configuration}
@@ -70,14 +68,7 @@
diff --git a/themes/admin/fusion/admin.extensions.tpl b/themes/admin/fusion/admin.extensions.tpl
index 135509b..b277400 100644
--- a/themes/admin/fusion/admin.extensions.tpl
+++ b/themes/admin/fusion/admin.extensions.tpl
@@ -10,11 +10,7 @@
-
-
-
-
-
+ {ADMIN_EXTENSIONS_ICON}
{ADMIN_EXTENSIONS_TYPE}: {ADMIN_EXTENSIONS_NAME}
@@ -258,12 +254,9 @@
-
-
-
-
-
+ {ADMIN_EXTENSIONS_ICON}
{ADMIN_EXTENSIONS_NAME}
+ {ADMIN_EXTENSIONS_DESCRIPTION|cot_cutstring($this,60)}
{ADMIN_EXTENSIONS_CODE_X}
diff --git a/themes/admin/fusion/admin.home.tpl b/themes/admin/fusion/admin.home.tpl
index ff47c82..8ed66cd 100644
--- a/themes/admin/fusion/admin.home.tpl
+++ b/themes/admin/fusion/admin.home.tpl
@@ -22,59 +22,18 @@
-
-
-
Cotonti
-
-
- {PHP.L.Version}
- {ADMIN_HOME_VERSION}
-
-
- {PHP.L.Database}
- {ADMIN_HOME_DB_VERSION}
-
-
- {PHP.L.home_db_rows}
- {ADMIN_HOME_DB_TOTAL_ROWS}
-
-
- {PHP.L.home_db_indexsize}
- {ADMIN_HOME_DB_INDEXSIZE}
-
-
- {PHP.L.home_db_datassize}
- {ADMIN_HOME_DB_DATASSIZE}
-
-
- {PHP.L.home_db_totalsize}
- {ADMIN_HOME_DB_TOTALSIZE}
-
-
- {PHP.L.Plugins}
- {ADMIN_HOME_TOTALPLUGINS}
-
-
- {PHP.L.Hooks}
- {ADMIN_HOME_TOTALHOOKS}
-
-
-
-
-
-
{PHP.L.home_ql_b1_title}
+
{PHP.L.home_site_props}
-
\ No newline at end of file
diff --git a/themes/admin/fusion/admin.infos.tpl b/themes/admin/fusion/admin.infos.tpl
index 9efe095..1ed11e6 100644
--- a/themes/admin/fusion/admin.infos.tpl
+++ b/themes/admin/fusion/admin.infos.tpl
@@ -1,41 +1,78 @@
- Info
-
-
- {PHP.L.adm_phpver}
- {ADMIN_INFOS_PHPVER}
-
-
- {PHP.L.adm_zendver}
- {ADMIN_INFOS_ZENDVER}
-
-
- {PHP.L.adm_interface}
- {ADMIN_INFOS_INTERFACE}
-
-
- {PHP.L.adm_cachedrivers}
- {ADMIN_INFOS_CACHEDRIVERS}
-
-
- {PHP.L.adm_os}
- {ADMIN_INFOS_OS}
-
-
- {PHP.L.adm_time1}
- {ADMIN_INFOS_DATE}
-
-
- {PHP.L.adm_time2}
- {ADMIN_INFOS_GMDATE} GMT
-
-
- {PHP.L.adm_time3}
- {ADMIN_INFOS_GMTTIME}
-
-
- {PHP.L.adm_time4}
- {ADMIN_INFOS_USRTIME} {ADMIN_INFOS_TIMETEXT}
-
-
+{PHP.L.adm_core_info}:
+
+
+ {PHP.L.Version}
+ {ADMIN_INFOS_VERSION}
+
+
+ {PHP.L.Database}
+ {ADMIN_INFOS_DB_VERSION}
+
+
+ {PHP.L.home_db_rows}
+ {ADMIN_INFOS_DB_TOTAL_ROWS}
+
+
+ {PHP.L.home_db_indexsize}
+ {ADMIN_INFOS_DB_INDEXSIZE}
+
+
+ {PHP.L.home_db_datassize}
+ {ADMIN_INFOS_DB_DATASSIZE}
+
+
+ {PHP.L.home_db_totalsize}
+ {ADMIN_INFOS_DB_TOTALSIZE}
+
+
+ {PHP.L.Plugins}
+ {ADMIN_INFOS_TOTALPLUGINS}
+
+
+ {PHP.L.Hooks}
+ {ADMIN_INFOS_TOTALHOOKS}
+
+
+
+
+{PHP.L.adm_server_info}
+
+
+ {PHP.L.adm_phpver}
+ {ADMIN_INFOS_PHPVER}
+
+
+ {PHP.L.adm_zendver}
+ {ADMIN_INFOS_ZENDVER}
+
+
+ {PHP.L.adm_interface}
+ {ADMIN_INFOS_INTERFACE}
+
+
+ {PHP.L.adm_cachedrivers}
+ {ADMIN_INFOS_CACHEDRIVERS}
+
+
+ {PHP.L.adm_os}
+ {ADMIN_INFOS_OS}
+
+
+ {PHP.L.adm_time1}
+ {ADMIN_INFOS_DATE}
+
+
+ {PHP.L.adm_time2}
+ {ADMIN_INFOS_GMDATE} GMT
+
+
+ {PHP.L.adm_time3}
+ {ADMIN_INFOS_GMTTIME}
+
+
+ {PHP.L.adm_time4}
+ {ADMIN_INFOS_USRTIME} {ADMIN_INFOS_TIMETEXT}
+
+
\ No newline at end of file
diff --git a/themes/admin/fusion/admin.other.tpl b/themes/admin/fusion/admin.other.tpl
index 8ec245d..4b78a04 100644
--- a/themes/admin/fusion/admin.other.tpl
+++ b/themes/admin/fusion/admin.other.tpl
@@ -7,40 +7,47 @@
{PHP.L.Part} {PHP.L.adm_clicktoedit}
-
+ {PHP.R.admin_icon_core}
{PHP.L.adm_internalcache}
{PHP.L.adm_internalcache_desc}
-
+ {PHP.R.admin_icon_core}
{PHP.L.adm_diskcache}
{PHP.L.adm_diskcache_desc}
-
+ {PHP.R.admin_icon_core}
{PHP.L.adm_extrafields}
{PHP.L.adm_extrafields_desc}
-
+ {PHP.R.icon_cfg_info}
{PHP.L.adm_log}
{PHP.L.adm_log_desc}
-
+ {PHP.R.icon_cfg_info}
{PHP.L.adm_infos}
{PHP.L.adm_infos_desc}
+
+ {PHP.R.icon_cfg_info}
+
+ PHP
+ {PHP.L.adm_phpinfo}
+
+