function ccenter_com_approve(&$comment) { global $xoopsDB, $xoopsUser, $xoopsModule, $xoopsConfig; $msgid = $comment->getVar('com_itemid'); $res = $xoopsDB->query("SELECT uid, touid, email, onepass, fidref, title, status FROM " . CCMES . ", " . FORMS . " WHERE msgid={$msgid} AND formid=fidref"); $comid = $comment->getVar('com_id'); if ($res && $xoopsDB->getRowsNum($res)) { $data = $xoopsDB->fetchArray($res); $email = $data['email']; $s = $data['status']; $uid = is_object($xoopsUser) ? $xoopsUser->getVar('uid') : 0; $msg = _CC_LOG_COMMENT; $status = ''; // new status $now = time(); $values = array('mtime=' . $now); if ($uid && $uid == $data['touid']) { // comment by charge // status to replyed if ($s == _STATUS_ACCEPT) { $status = _STATUS_REPLY; } $msg .= _CC_LOG_BYCHARGE; } elseif ($uid == 0 || $uid == $data['uid']) { // comment by order person // status back to contacting if ($s == _STATUS_REPLY || $s == _STATUS_CLOSE) { $status = _STATUS_ACCEPT; } $values[] = 'atime=' . $now; } if ($status && $status != $s) { global $msg_status; $msg .= "\n" . sprintf(_CC_LOG_STATUS, $msg_status[$s], $msg_status[$status]); $values[] = 'status=' . $xoopsDB->quoteString($status); } $xoopsDB->query("UPDATE " . CCMES . " SET " . join(',', $values) . " WHERE msgid={$msgid}"); cc_log_message($data['fidref'], $msg . " (comid={$comid})", $msgid); // notification for guest contact if (is_object($xoopsUser) && $data['uid'] == 0 && $email) { $subj = $data['title']; $url = XOOPS_URL . "/modules/" . basename(dirname(__FILE__)) . "/message.php?id={$msgid}&p=" . urlencode($data['onepass']) . "#comment{$comid}"; $tags = array('X_MODULE' => $xoopsModule->getVar('name'), 'X_ITEM_TYPE' => '', 'X_ITEM_NAME' => $subj, 'X_COMMENT_URL' => $url, 'FROM_EMAIL' => $email, 'SUBJECT' => $subj); $xoopsMailer =& getMailer(); $xoopsMailer->useMail(); $xoopsMailer->setFromEmail($xoopsConfig['adminmail']); $xoopsMailer->setFromName($xoopsModule->getVar('name')); $xoopsMailer->setSubject(_MD_NOTIFY_SUBJ); $xoopsMailer->assign($tags); $tpl = 'guest_notify.tpl'; $xoopsMailer->setTemplateDir(template_dir($tpl)); $xoopsMailer->setTemplate($tpl); $xoopsMailer->setToEmails($email); $xoopsMailer->send(); } } }
function cc_log_status($data, $nstat) { global $msg_status; $fid = empty($data['fidref']) ? $data['formid'] : $data['fidref']; $log = sprintf(_CC_LOG_STATUS, $msg_status[$data['status']], $msg_status[$nstat]); return cc_log_message($fid, $log, $data['msgid']); }
list($fid) = $xoopsDB->fetchRow($res); if (change_message_status($msgid, $uid, $stat)) { if ($stat == 'x') { $redirect = "reception.php?form={$fid}"; } // delete the message redirect_header($redirect, 1, _MD_UPDATE_STATUS); exit; } redirect_header($redirect, 3, _MD_UPDATE_FAILED); } else { switch ($_POST['op']) { case 'myself': $res = $xoopsDB->query("SELECT fidref,status,title FROM " . CCMES . " LEFT JOIN " . FORMS . " ON formid=fidref WHERE msgid={$msgid} AND touid=0"); if ($res && $xoopsDB->getRowsNum($res)) { list($fid, $s, $title) = $xoopsDB->fetchRow($res); $now = time(); $set = "SET mtime={$now}, touid={$uid}, status=" . $xoopsDB->quoteString('a'); $res = $xoopsDB->query("UPDATE " . CCMES . " {$set} WHERE msgid={$msgid}"); $log = sprintf(_CC_LOG_TOUSER, _CC_USER_NONE, $xoopsUser->getVar('uname')); $log .= "\n" . sprintf(_CC_LOG_STATUS, $msg_status[$s], $msg_status['a']); $notification_handler =& xoops_gethandler('notification'); $notification_handler->subscribe('message', $msgid, 'comment'); //$notification_handler->subscribe('message', $msgid, 'status'); cc_log_message($fid, $log, $msgid); } break; } redirect_header($redirect, 1, _MD_UPDATE_STATUS); exit; }
break; default: $log .= sprintf(_CC_LOG_VALUE, $lab, $data[$k], $v); } } } if (count($sets)) { $sets[] = 'mtime=' . time(); $res = $xoopsDB->query("UPDATE " . CCMES . " SET " . join(",", $sets) . " WHERE msgid=" . $msgid); if ($res && $touid) { // switch person in charge $notification_handler =& xoops_gethandler('notification'); $notification_handler->subscribe('message', $msgid, 'comment', null, null, $touid); $notification_handler->subscribe('message', $msgid, 'status', null, null, $touid); } cc_log_message($data['fidref'], $log, $msgid); redirect_header($back, 1, _AM_MSG_UPDATED); exit; } } redirect_header($back, 3, _AM_MSG_UPDATE_FAIL); exit; } elseif (!empty($op)) { $uid = $xoopsUser->getVar('uid'); foreach ($_POST['ids'] as $msgid) { change_message_status(intval($msgid), 0, $op); } $back = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : "msgadm.php"; redirect_header($back, 1, _AM_MSG_UPDATED); exit; }