From: <zy...@us...> - 2016-07-12 02:54:24
|
Revision: 13213 http://sourceforge.net/p/xoops/svn/13213 Author: zyspec Date: 2016-07-12 02:54:19 +0000 (Tue, 12 Jul 2016) Log Message: ----------- update calls to XOOPS studlyCaps functions, fix index declaration in SQL file, remove trailing slash for HTML void elements Modified Paths: -------------- XoopsModules/modulepacks/x257basicmodulepack/branches/zyspec/contact/admin/admin_footer.php XoopsModules/modulepacks/x257basicmodulepack/branches/zyspec/contact/admin/admin_header.php XoopsModules/modulepacks/x257basicmodulepack/branches/zyspec/contact/admin/contact.php XoopsModules/modulepacks/x257basicmodulepack/branches/zyspec/contact/admin/menu.php XoopsModules/modulepacks/x257basicmodulepack/branches/zyspec/contact/blocks/stats.php XoopsModules/modulepacks/x257basicmodulepack/branches/zyspec/contact/class/contact.php XoopsModules/modulepacks/x257basicmodulepack/branches/zyspec/contact/class/formvalidatedinput.php XoopsModules/modulepacks/x257basicmodulepack/branches/zyspec/contact/docs/ajax.html XoopsModules/modulepacks/x257basicmodulepack/branches/zyspec/contact/docs/changelog.txt XoopsModules/modulepacks/x257basicmodulepack/branches/zyspec/contact/header.php XoopsModules/modulepacks/x257basicmodulepack/branches/zyspec/contact/include/functions.php XoopsModules/modulepacks/x257basicmodulepack/branches/zyspec/contact/include/waiting.plugin.php XoopsModules/modulepacks/x257basicmodulepack/branches/zyspec/contact/language/english/help/help.html XoopsModules/modulepacks/x257basicmodulepack/branches/zyspec/contact/language/english/help/module_index.html XoopsModules/modulepacks/x257basicmodulepack/branches/zyspec/contact/language/english/modinfo.php XoopsModules/modulepacks/x257basicmodulepack/branches/zyspec/contact/sql/mysql.sql XoopsModules/modulepacks/x257basicmodulepack/branches/zyspec/contact/templates/admin/contact_contact.tpl XoopsModules/modulepacks/x257basicmodulepack/branches/zyspec/contact/xoops_version.php Modified: XoopsModules/modulepacks/x257basicmodulepack/branches/zyspec/contact/admin/admin_footer.php =================================================================== --- XoopsModules/modulepacks/x257basicmodulepack/branches/zyspec/contact/admin/admin_footer.php 2016-05-29 22:57:53 UTC (rev 13212) +++ XoopsModules/modulepacks/x257basicmodulepack/branches/zyspec/contact/admin/admin_footer.php 2016-07-12 02:54:19 UTC (rev 13213) @@ -24,7 +24,7 @@ echo "<div class='adminfooter'>\n" . " <div class='center'>\n" - . " <a href='" . $GLOBALS['xoopsModule']->getInfo('author_website_url') . "' target='_blank'><img src='{$pathIcon32}/xoopsmicrobutton.gif' alt='" . $GLOBALS['xoopsModule']->getInfo('author_website_name') . "' title='" . $GLOBALS['xoopsModule']->getInfo('author_website_name') . "' /></a>\n" + . " <a href='" . $GLOBALS['xoopsModule']->getInfo('author_website_url') . "' target='_blank'><img src='{$pathIcon32}/xoopsmicrobutton.gif' alt='" . $GLOBALS['xoopsModule']->getInfo('author_website_name') . "' title='" . $GLOBALS['xoopsModule']->getInfo('author_website_name') . "'></a>\n" . " </div>\n" . " <div class='center smallsmall italic pad5'>\n" . " " . _AM_CONTACT_MAINTAINED_BY Modified: XoopsModules/modulepacks/x257basicmodulepack/branches/zyspec/contact/admin/admin_header.php =================================================================== --- XoopsModules/modulepacks/x257basicmodulepack/branches/zyspec/contact/admin/admin_header.php 2016-05-29 22:57:53 UTC (rev 13212) +++ XoopsModules/modulepacks/x257basicmodulepack/branches/zyspec/contact/admin/admin_header.php 2016-07-12 02:54:19 UTC (rev 13213) @@ -46,4 +46,4 @@ // Contact Module specific pieces include_once $GLOBALS['xoops']->path("/modules/{$moduleDirname}/include/functions.php"); -$contactHandler =& xoops_getModuleHandler('contact', $moduleDirname); +$contactHandler = xoops_getModuleHandler('contact', $moduleDirname); Modified: XoopsModules/modulepacks/x257basicmodulepack/branches/zyspec/contact/admin/contact.php =================================================================== --- XoopsModules/modulepacks/x257basicmodulepack/branches/zyspec/contact/admin/contact.php 2016-05-29 22:57:53 UTC (rev 13212) +++ XoopsModules/modulepacks/x257basicmodulepack/branches/zyspec/contact/admin/contact.php 2016-07-12 02:54:19 UTC (rev 13213) @@ -1,207 +1,207 @@ -<?php -/* - You may not change or alter any portion of this comment or credits - of supporting developers from this source code or any supporting source code - which is considered copyrighted (c) material of the original comment or credit authors. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - */ - -/** - * Contact module - * - * @copyright {@link http://sourceforge.net/projects/xoops/ The XOOPS Project} - * @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license} - * @package contact - * @subpackage admin - * @author Kazumi Ono (aka Onokazu) - * @author Trabis <lus...@gm...> - * @author Hossein Azizabadi (AKA Voltan) - * @version $Id: $ - */ - -// Call header -require __DIR__ . '/admin_header.php'; -// Display Admin header -xoops_cp_header(); - -//Get input -$op = XoopsRequest::getString('op', 'list'); -$contactId = XoopsRequest::getInt('id', '0'); -$level = ''; - -// Define scripts -$xoTheme->addScript('browse.php?Frameworks/jquery/jquery.js'); -$xoTheme->addScript('browse.php?Frameworks/jquery/plugins/jquery.ui.js'); -$xoTheme->addScript($GLOBALS['xoops']->url('www/modules/contact/assets/js/admin.js')); - -// Add module stylesheet -$xoTheme->addStylesheet($GLOBALS['xoops']->url('www/modules/contact/assets/css/admin.css')); - -//add system module stylesheets -$moduleHandler =& xoops_gethandler('module'); -$systemModule =& $moduleHandler->getByDirname('system'); -$configHandler =& xoops_gethandler('config'); -if ($systemModule instanceof XoopsModule) { - $moduleConfig =& $configHandler->getConfigsByCat(0, $systemModule->getVar('mid')); - if (isset($moduleConfig['jquery_theme'])) { - $xoTheme->addStylesheet($GLOBALS['xoops']->url("www/modules/system/css/ui/{$moduleConfig['jquery_theme']}/ui.all.css")); - } -} -$xoTheme->addStylesheet($GLOBALS['xoops']->url('www/modules/system/css/admin.css')); - -switch ($op) { - case 'list': - default: - $pageSettingsObj = new stdClass(); // create a new stdClass object - $pageSettingsObj->perpage = (int) $GLOBALS['xoopsModuleConfig']['admin_perpage']; - $pageSettingsObj->order = 'DESC'; - $pageSettingsObj->sort = 'contact_id'; - $pageSettingsObj->limit = XoopsRequest::getInt('limit', $pageSettingsObj->perpage); - $pageSettingsObj->start = XoopsRequest::getInt('start', 0); - - $contactCount = $contactHandler->contactGetCount('contact_cid'); //count all contacts - $contacts = $contactHandler->getAdminList($pageSettingsObj, 'contact_cid'); - - if ($contactCount > $pageSettingsObj->limit) { - $contactPageNavObj = new XoopsPageNav($contactCount, $pageSettingsObj->limit, $pageSettingsObj->start, 'start', 'limit=' . $pageSettingsObj->limit); - $contactPagenav = $contactPageNavObj->renderNav(4); - } else { - $contactPagenav = ''; - } - - $GLOBALS['xoopsTpl']->assign(array('use_depts' => $GLOBALS['xoopsModuleConfig']['form_dept'] ? 1 : 0, - 'contacts' => $contacts, - 'contact_pagenav' => $contactPagenav) - ); - $level = 'list'; - break; - - case 'reply': - if ($contactId > 0) { - $obj = $contactHandler->get($contactId); - if (!($obj instanceof contact) || (0 != $obj->getVar('contact_cid'))) { - redirect_header($_SERVER['PHP_SELF'], 3, _AM_CONTACT_REPLY_CANT); - } - - $form = $obj->replyForm(); - $GLOBALS['xoopsTpl']->assign(array('replyform' => $form->render(), - 'replylist' => $contactHandler->contactGetReply($contactId), - 'use_depts' => $GLOBALS['xoopsModuleConfig']['form_dept'] ? 1 : 0, - ) - ); - } else { - redirect_header($_SERVER['PHP_SELF'], 3, _AM_CONTACT_MSG_NOTEXIST); - } - $level = 'reply'; - break; - - case 'doreply': - $formInput = $contactHandler->infoProcessing('POST'); - $mailObj = (object) $formInput; - unset($formInput); - $deptEmails = array(); - $message = array(); - - // verfiy we're sending to a valid email - if ((!$mailObj->contact_mail || !(checkEmail($mailObj->contact_mail))) && !$GLOBALS['xoopsModuleConfig']['form_dept']) { - redirect_header($_SERVER['PHP_SELF'], 3, _MD_CONTACT_MSG_NOVALIDEMAIL); - } - - // verify valid message body - $mailObj->contact_message = $contactHandler->replyBodyFormat($mailObj, (bool) $mailObj->inc_orig); - if ($mailObj->contact_message) { - // successfully retrieved message body so insert into dB - if ($saveinfo = true) { - $contactObj = $contactHandler->create(); - $contactObj->prepareToInsert($mailObj); - if (!$contactHandler->insert($contactObj)) { - redirect_header($_SERVER['PHP_SELF'], 3, _AM_CONTACT_MSG_NOTSAVED); - } - $contactHandler->contactAddReply($contactObj->getVar('contact_cid')); - } else { - $message[] = _AM_CONTACT_MSG_NOTSAVED; // did not save message - } - - // send mail can send message if $sendmail = true - if ($sendmail = true) { - $message[] = $contactHandler->contactReplyMail($mailObj); - } elseif ($saveinfo = true) { - $message = _MD_CONTACT_MSG_SAVEINDB; - } else { - $message[] = _MD_CONTACT_MSG_SENDERROR; - } - - } else { - //failed to set message body - $message[] = _AM_CONTACT_MSG_NOBODY; - } - - redirect_header($_SERVER['PHP_SELF'], 3, implode('<br />', $message)); - - $level = 'doreply'; - break; - - case 'view': - $obj = $contactHandler->get($contactId); - - if (!$obj) { - redirect_header($_SERVER['PHP_SELF'], 3, _AM_CONTACT_MSG_NOTEXIST); - exit (); - } - $user_timezone = ($GLOBALS['xoopsUser'] instanceof XoopsUser) ? $GLOBALS['xoopsUser']->timezone() : null; - - $contact = $obj->getValues(); - $contact['contact_owner'] = XoopsUser::getUnameFromId($contact['contact_uid']); - $contact['contact_create'] = formatTimestamp($contact['contact_create'], 'm', $user_timezone); - - $GLOBALS['xoopsTpl']->assign(array('use_depts' => $GLOBALS['xoopsModuleConfig']['form_dept'] ? 1 : 0, - 'contact' => $contact, - 'replylist' => $contactHandler->contactGetReply($contactId)) - ); - - $level = 'view'; - break; - - case 'delete': - if (!$contactId) { - redirect_header($_SERVER['PHP_SELF'], 3, _AM_CONTACT_MSG_NOTEXIST); - } - // Prompt message - xoops_confirm(array('id' => $contactId, 'op' => 'dodelete'), $_SERVER['PHP_SELF'], _AM_CONTACT_MSG_DELETE); - $level = 'delete'; - break; - - case 'dodelete': - // check to make sure this passes form submission security - if ( ($GLOBALS['xoopsSecurity'] instanceof XoopsSecurity) ) { - if ( !$GLOBALS['xoopsSecurity']->check() ) { - // failed xoops security check - redirect_header('index.php', 3, $GLOBALS['xoopsSecurity']->getErrors(true)); - } - } else { - redirect_header('index.php', 3, _MD_CONTACT_INVALID_SECURITY_TOKEN); - } - - if (!$contactId) { - $msg = _AM_CONTACT_MSG_NOTEXIST; - } else { - $criteria = new CriteriaCompo (); - $criteria->add(new Criteria ('contact_id', $contactId)); //messages - $criteria->add(new Criteria ('contact_cid', $contactId), 'OR'); //replies - $msg = (!$contactHandler->deleteAll($criteria)) ? _AM_CONTACT_MSG_DELETEERROR : _AM_CONTACT_MSG_DELETED; - } - redirect_header($_SERVER['PHP_SELF'], 3, $msg); - break; -} - -$GLOBALS['xoopsTpl']->assign(array('navigation' => $admin_class->addNavigation('contact.php'), - 'level' => $level) -); - -// Call template file -$GLOBALS['xoopsTpl']->display($GLOBALS['xoops']->path('www/modules/contact/templates/admin/contact_contact.tpl')); -// Call footer -require __DIR__ . '/admin_footer.php'; +<?php +/* + You may not change or alter any portion of this comment or credits + of supporting developers from this source code or any supporting source code + which is considered copyrighted (c) material of the original comment or credit authors. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + */ + +/** + * Contact module + * + * @copyright {@link http://sourceforge.net/projects/xoops/ The XOOPS Project} + * @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license} + * @package contact + * @subpackage admin + * @author Kazumi Ono (aka Onokazu) + * @author Trabis <lus...@gm...> + * @author Hossein Azizabadi (AKA Voltan) + * @version $Id: $ + */ + +// Call header +require __DIR__ . '/admin_header.php'; +// Display Admin header +xoops_cp_header(); + +//Get input +$op = XoopsRequest::getString('op', 'list'); +$contactId = XoopsRequest::getInt('id', '0'); +$level = ''; + +// Define scripts +$xoTheme->addScript('browse.php?Frameworks/jquery/jquery.js'); +$xoTheme->addScript('browse.php?Frameworks/jquery/plugins/jquery.ui.js'); +$xoTheme->addScript($GLOBALS['xoops']->url('www/modules/contact/assets/js/admin.js')); + +// Add module stylesheet +$xoTheme->addStylesheet($GLOBALS['xoops']->url('www/modules/contact/assets/css/admin.css')); + +//add system module stylesheets +$moduleHandler = xoops_getHandler('module'); +$systemModule = $moduleHandler->getByDirname('system'); +$configHandler = xoops_getHandler('config'); +if ($systemModule instanceof XoopsModule) { + $moduleConfig = $configHandler->getConfigsByCat(0, $systemModule->getVar('mid')); + if (isset($moduleConfig['jquery_theme'])) { + $xoTheme->addStylesheet($GLOBALS['xoops']->url("www/modules/system/css/ui/{$moduleConfig['jquery_theme']}/ui.all.css")); + } +} +$xoTheme->addStylesheet($GLOBALS['xoops']->url('www/modules/system/css/admin.css')); + +switch ($op) { + case 'list': + default: + $pageSettingsObj = new stdClass(); // create a new stdClass object + $pageSettingsObj->perpage = (int) $GLOBALS['xoopsModuleConfig']['admin_perpage']; + $pageSettingsObj->order = 'DESC'; + $pageSettingsObj->sort = 'contact_id'; + $pageSettingsObj->limit = XoopsRequest::getInt('limit', $pageSettingsObj->perpage); + $pageSettingsObj->start = XoopsRequest::getInt('start', 0); + + $contactCount = $contactHandler->contactGetCount('contact_cid'); //count all contacts + $contacts = $contactHandler->getAdminList($pageSettingsObj, 'contact_cid'); + + if ($contactCount > $pageSettingsObj->limit) { + $contactPageNavObj = new XoopsPageNav($contactCount, $pageSettingsObj->limit, $pageSettingsObj->start, 'start', 'limit=' . $pageSettingsObj->limit); + $contactPagenav = $contactPageNavObj->renderNav(4); + } else { + $contactPagenav = ''; + } + + $GLOBALS['xoopsTpl']->assign(array('use_depts' => $GLOBALS['xoopsModuleConfig']['form_dept'] ? 1 : 0, + 'contacts' => $contacts, + 'contact_pagenav' => $contactPagenav) + ); + $level = 'list'; + break; + + case 'reply': + if ($contactId > 0) { + $obj = $contactHandler->get($contactId); + if (!($obj instanceof contact) || (0 != $obj->getVar('contact_cid'))) { + redirect_header($_SERVER['PHP_SELF'], 3, _AM_CONTACT_REPLY_CANT); + } + + $form = $obj->replyForm(); + $GLOBALS['xoopsTpl']->assign(array('replyform' => $form->render(), + 'replylist' => $contactHandler->contactGetReply($contactId), + 'use_depts' => $GLOBALS['xoopsModuleConfig']['form_dept'] ? 1 : 0, + ) + ); + } else { + redirect_header($_SERVER['PHP_SELF'], 3, _AM_CONTACT_MSG_NOTEXIST); + } + $level = 'reply'; + break; + + case 'doreply': + $formInput = $contactHandler->infoProcessing('POST'); + $mailObj = (object) $formInput; + unset($formInput); + $deptEmails = array(); + $message = array(); + + // verfiy we're sending to a valid email + if ((!$mailObj->contact_mail || !(checkEmail($mailObj->contact_mail))) && !$GLOBALS['xoopsModuleConfig']['form_dept']) { + redirect_header($_SERVER['PHP_SELF'], 3, _MD_CONTACT_MSG_NOVALIDEMAIL); + } + + // verify valid message body + $mailObj->contact_message = $contactHandler->replyBodyFormat($mailObj, (bool) $mailObj->inc_orig); + if ($mailObj->contact_message) { + // successfully retrieved message body so insert into dB + if ($saveinfo = true) { + $contactObj = $contactHandler->create(); + $contactObj->prepareToInsert($mailObj); + if (!$contactHandler->insert($contactObj)) { + redirect_header($_SERVER['PHP_SELF'], 3, _AM_CONTACT_MSG_NOTSAVED); + } + $contactHandler->contactAddReply($contactObj->getVar('contact_cid')); + } else { + $message[] = _AM_CONTACT_MSG_NOTSAVED; // did not save message + } + + // send mail can send message if $sendmail = true + if ($sendmail = true) { + $message[] = $contactHandler->contactReplyMail($mailObj); + } elseif ($saveinfo = true) { + $message = _MD_CONTACT_MSG_SAVEINDB; + } else { + $message[] = _MD_CONTACT_MSG_SENDERROR; + } + + } else { + //failed to set message body + $message[] = _AM_CONTACT_MSG_NOBODY; + } + + redirect_header($_SERVER['PHP_SELF'], 3, implode('<br>', $message)); + + $level = 'doreply'; + break; + + case 'view': + $obj = $contactHandler->get($contactId); + + if (!$obj) { + redirect_header($_SERVER['PHP_SELF'], 3, _AM_CONTACT_MSG_NOTEXIST); + exit (); + } + $user_timezone = ($GLOBALS['xoopsUser'] instanceof XoopsUser) ? $GLOBALS['xoopsUser']->timezone() : null; + + $contact = $obj->getValues(); + $contact['contact_owner'] = XoopsUser::getUnameFromId($contact['contact_uid']); + $contact['contact_create'] = formatTimestamp($contact['contact_create'], 'm', $user_timezone); + + $GLOBALS['xoopsTpl']->assign(array('use_depts' => $GLOBALS['xoopsModuleConfig']['form_dept'] ? 1 : 0, + 'contact' => $contact, + 'replylist' => $contactHandler->contactGetReply($contactId)) + ); + + $level = 'view'; + break; + + case 'delete': + if (!$contactId) { + redirect_header($_SERVER['PHP_SELF'], 3, _AM_CONTACT_MSG_NOTEXIST); + } + // Prompt message + xoops_confirm(array('id' => $contactId, 'op' => 'dodelete'), $_SERVER['PHP_SELF'], _AM_CONTACT_MSG_DELETE); + $level = 'delete'; + break; + + case 'dodelete': + // check to make sure this passes form submission security + if ( ($GLOBALS['xoopsSecurity'] instanceof XoopsSecurity) ) { + if ( !$GLOBALS['xoopsSecurity']->check() ) { + // failed xoops security check + redirect_header('index.php', 3, $GLOBALS['xoopsSecurity']->getErrors(true)); + } + } else { + redirect_header('index.php', 3, _MD_CONTACT_INVALID_SECURITY_TOKEN); + } + + if (!$contactId) { + $msg = _AM_CONTACT_MSG_NOTEXIST; + } else { + $criteria = new CriteriaCompo (); + $criteria->add(new Criteria ('contact_id', $contactId)); //messages + $criteria->add(new Criteria ('contact_cid', $contactId), 'OR'); //replies + $msg = (!$contactHandler->deleteAll($criteria)) ? _AM_CONTACT_MSG_DELETEERROR : _AM_CONTACT_MSG_DELETED; + } + redirect_header($_SERVER['PHP_SELF'], 3, $msg); + break; +} + +$GLOBALS['xoopsTpl']->assign(array('navigation' => $admin_class->addNavigation('contact.php'), + 'level' => $level) +); + +// Call template file +$GLOBALS['xoopsTpl']->display($GLOBALS['xoops']->path('www/modules/contact/templates/admin/contact_contact.tpl')); +// Call footer +require __DIR__ . '/admin_footer.php'; Modified: XoopsModules/modulepacks/x257basicmodulepack/branches/zyspec/contact/admin/menu.php =================================================================== --- XoopsModules/modulepacks/x257basicmodulepack/branches/zyspec/contact/admin/menu.php 2016-05-29 22:57:53 UTC (rev 13212) +++ XoopsModules/modulepacks/x257basicmodulepack/branches/zyspec/contact/admin/menu.php 2016-07-12 02:54:19 UTC (rev 13213) @@ -1,56 +1,56 @@ -<?php -/* - You may not change or alter any portion of this comment or credits - of supporting developers from this source code or any supporting source code - which is considered copyrighted (c) material of the original comment or credit authors. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - */ - -/** - * Contact module - * - * @copyright {@link http://sourceforge.net/projects/xoops/ The XOOPS Project} - * @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license} - * @package contact - * @subpackage admin - * @author Kazumi Ono (aka Onokazu) - * @author Trabis <lus...@gm...> - * @author Hossein Azizabadi (AKA Voltan) - * @version $Id$ - */ - -// defined("XOOPS_ROOT_PATH") || exit("Restricted access"); - -$moduleHandler = xoops_gethandler('module'); -$module = $moduleHandler->getByDirname(basename(dirname(__DIR__))); -$pathIcon32 = '../../' . $module->getInfo('icons32'); -xoops_loadLanguage('modinfo', $module->dirname()); - -$adminmenu = array(array('title' => _MI_CONTACT_MENU_HOME, - 'link' => "admin/index.php", - 'desc' => _MI_CONTACT_MENU_HOME_DESC, - 'icon' => "{$pathIcon32}/home.png"), - - array('title' => _MI_CONTACT_MENU_CONTACT, - 'link' => "admin/contact.php", - 'desc' => _MI_CONTACT_MENU_CONTACT_DESC, - 'icon' => "{$pathIcon32}/content.png"), - - array('title' => _MI_CONTACT_MENU_LOGS, - 'link' => "admin/log.php", - 'desc' => _MI_CONTACT_MENU_LOGS_DESC, - 'icon' => "{$pathIcon32}/exec.png"), - - array('title' => _MI_CONTACT_MENU_PRUNE, - 'link' => "admin/prune.php", - 'desc' => _MI_CONTACT_MENU_PRUNE_DESC, - 'icon' => "{$pathIcon32}/prune.png"), - - array('title' => _MI_CONTACT_MENU_ABOUT, - 'link' => "admin/about.php", - 'desc' => _MI_CONTACT_MENU_ABOUT_DESC, - 'icon' => "{$pathIcon32}/about.png") -); +<?php +/* + You may not change or alter any portion of this comment or credits + of supporting developers from this source code or any supporting source code + which is considered copyrighted (c) material of the original comment or credit authors. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + */ + +/** + * Contact module + * + * @copyright {@link http://sourceforge.net/projects/xoops/ The XOOPS Project} + * @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license} + * @package contact + * @subpackage admin + * @author Kazumi Ono (aka Onokazu) + * @author Trabis <lus...@gm...> + * @author Hossein Azizabadi (AKA Voltan) + * @version $Id$ + */ + +// defined("XOOPS_ROOT_PATH") || exit("Restricted access"); + +$moduleHandler = xoops_getHandler('module'); +$module = $moduleHandler->getByDirname(basename(dirname(__DIR__))); +$pathIcon32 = '../../' . $module->getInfo('icons32'); +xoops_loadLanguage('modinfo', $module->dirname()); + +$adminmenu = array(array('title' => _MI_CONTACT_MENU_HOME, + 'link' => "admin/index.php", + 'desc' => _MI_CONTACT_MENU_HOME_DESC, + 'icon' => "{$pathIcon32}/home.png"), + + array('title' => _MI_CONTACT_MENU_CONTACT, + 'link' => "admin/contact.php", + 'desc' => _MI_CONTACT_MENU_CONTACT_DESC, + 'icon' => "{$pathIcon32}/content.png"), + + array('title' => _MI_CONTACT_MENU_LOGS, + 'link' => "admin/log.php", + 'desc' => _MI_CONTACT_MENU_LOGS_DESC, + 'icon' => "{$pathIcon32}/exec.png"), + + array('title' => _MI_CONTACT_MENU_PRUNE, + 'link' => "admin/prune.php", + 'desc' => _MI_CONTACT_MENU_PRUNE_DESC, + 'icon' => "{$pathIcon32}/prune.png"), + + array('title' => _MI_CONTACT_MENU_ABOUT, + 'link' => "admin/about.php", + 'desc' => _MI_CONTACT_MENU_ABOUT_DESC, + 'icon' => "{$pathIcon32}/about.png") +); Modified: XoopsModules/modulepacks/x257basicmodulepack/branches/zyspec/contact/blocks/stats.php =================================================================== --- XoopsModules/modulepacks/x257basicmodulepack/branches/zyspec/contact/blocks/stats.php 2016-05-29 22:57:53 UTC (rev 13212) +++ XoopsModules/modulepacks/x257basicmodulepack/branches/zyspec/contact/blocks/stats.php 2016-07-12 02:54:19 UTC (rev 13213) @@ -29,7 +29,7 @@ * * Show Contact Us stats block * - * @uses xoops_getmodulehandler + * @uses xoops_getModuleHandler * @uses CriteriaCompo * @uses ContactContact * @uses ContactContactHandler @@ -43,7 +43,7 @@ $block = array(); - $contactHandler =& xoops_getmodulehandler('contact', $moduleDirname); + $contactHandler = xoops_getModuleHandler('contact', $moduleDirname); $criteria = new CriteriaCompo(); $criteria->add(new Criteria('contact_cid', 0)); $criteria->add(new Criteria('contact_type', 'Contact')); Modified: XoopsModules/modulepacks/x257basicmodulepack/branches/zyspec/contact/class/contact.php =================================================================== --- XoopsModules/modulepacks/x257basicmodulepack/branches/zyspec/contact/class/contact.php 2016-05-29 22:57:53 UTC (rev 13212) +++ XoopsModules/modulepacks/x257basicmodulepack/branches/zyspec/contact/class/contact.php 2016-07-12 02:54:19 UTC (rev 13213) @@ -1,648 +1,650 @@ -<?php -/* - You may not change or alter any portion of this comment or credits - of supporting developers from this source code or any supporting source code - which is considered copyrighted (c) material of the original comment or credit authors. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - */ - -/** - * Contact module - * - * @copyright {@link http://sourceforge.net/projects/xoops/ The XOOPS Project} - * @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license} - * @package contact - * @subpackage class - * @author Kazumi Ono (aka Onokazu) - * @author Trabis <lus...@gm...> - * @author Hossein Azizabadi (AKA Voltan) - * @version $Id: $ - */ - -//defined("XOOPS_ROOT_PATH") || exit("Restricted access - " . basename($_SERVER['PHP_SELF'], '.php') . PHP_EOL); -class Contact extends XoopsObject -{ - - public function __construct() - { - $this->XoopsObject(); - $this->initVar("contact_id", XOBJ_DTYPE_INT, null, false, 11); - $this->initVar("contact_uid", XOBJ_DTYPE_INT, null, false, 11); - $this->initVar("contact_cid", XOBJ_DTYPE_INT, null, false, 11); - $this->initVar("contact_name", XOBJ_DTYPE_TXTBOX, null, false); - $this->initVar("contact_subject", XOBJ_DTYPE_TXTBOX, null, false); - $this->initVar("contact_mail", XOBJ_DTYPE_EMAIL, null, false); - $this->initVar("contact_url", XOBJ_DTYPE_TXTBOX, null, false); - $this->initVar("contact_create", XOBJ_DTYPE_INT, null, false); - $this->initVar("contact_icq", XOBJ_DTYPE_TXTBOX, null, false); - $this->initVar("contact_company", XOBJ_DTYPE_TXTBOX, null, false); - $this->initVar("contact_location", XOBJ_DTYPE_TXTBOX, null, false); - $this->initVar("contact_phone", XOBJ_DTYPE_TXTBOX, null, false); - $this->initVar("contact_department", XOBJ_DTYPE_TXTBOX, null, false); - $this->initVar("contact_ip", XOBJ_DTYPE_TXTBOX, null, false); - $this->initVar("contact_message", XOBJ_DTYPE_TXTAREA, null, false); - $this->initVar("contact_address", XOBJ_DTYPE_TXTAREA, null, false); - $this->initVar("contact_reply", XOBJ_DTYPE_INT, null, false, 1); - $this->initVar("contact_platform", XOBJ_DTYPE_ENUM, null, false, '', '', array('Android', 'Ios', 'Web')); - $this->initVar("contact_type", XOBJ_DTYPE_ENUM, null, false, '', '', array('Contact', 'Phone', 'Mail')); - - $this->db = $GLOBALS['xoopsDB']; - $this->table = $this->db->prefix('contact'); - } - - public function contactForm() - { - - if ($this->isNew()) { - if (($GLOBALS['xoopsUser'] instanceof XoopsUser) && ($GLOBALS['xoopsUser']->uid())) { - $contact_uid = $GLOBALS['xoopsUser']->getVar('uid'); - $contact_name = $GLOBALS['xoopsUser']->getVar('uname'); - $contact_mail = $GLOBALS['xoopsUser']->getVar('email'); - $contact_mail2 = $GLOBALS['xoopsUser']->getVar('email'); - $contact_url = $GLOBALS['xoopsUser']->getVar('url'); - $contact_icq = $GLOBALS['xoopsUser']->getVar('user_icq'); - $contact_location = $GLOBALS['xoopsUser']->getVar('user_from'); - - } else { - $contact_uid = 0; - $contact_name = ''; - $contact_mail = ''; - $contact_mail2 = ''; - $contact_url = ''; - $contact_icq = ''; - $contact_location = ''; - } - } else { - $contact_uid = $this->getVar('contact_uid'); - $contact_name = $this->getVar('contact_name'); - $contact_mail = $this->getVar('contact_mail'); - $contact_mail2 = $this->getVar('contact_mail'); - $contact_url = $this->getVar('contact_url'); - $contact_icq = $this->getVar('contact_icq'); - $contact_location = $this->getVar('contact_location'); - } - - xoops_load('FormValidatedInput', 'contact'); - $form = new XoopsThemeForm(_MD_CONTACT_FORM, 'save', 'index.php', 'post', true); - $form->setExtra('enctype="multipart/form-data"'); - $form->addElement(new XoopsFormHidden('op', 'save')); - $form->addElement(new XoopsFormHidden('contact_id', $this->getVar('contact_id', 'e'))); - $form->addElement(new XoopsFormHidden('contact_uid', $contact_uid)); - if ($contact_uid > 0) { - // XOOPS user so don't allow entry of name/email (changed in v1.82) - $form->addElement(new XoopsFormHidden('contact_name', $contact_name)); - $form->addElement(new XoopsFormHidden('contact_mail', $contact_mail)); - /** @internal re-enable following code (and disable previous) if you want XoopsUser to edit their name/email */ - /* - $form->addElement(new ContactFormValidatedInput(_MD_CONTACT_NAME, 'contact_name', 50, 255, $contact_name), true); - $form->addElement(new ContactFormValidatedInput(_MD_CONTACT_MAIL, 'contact_mail', 50, 255, $contact_mail, 'email'), true); - */ - } else { - $form->addElement(new ContactFormValidatedInput(_MD_CONTACT_NAME, 'contact_name', 50, 255, $contact_name), true); - $form->addElement(new ContactFormValidatedInput(_MD_CONTACT_MAIL, 'contact_mail', 50, 255, $contact_mail, 'email'), true); - } - - if (!$GLOBALS['xoopsUser'] && $GLOBALS['xoopsModuleConfig']['form_req_email2']) { - $form->addElement(new ContactFormValidatedInput(_MD_CONTACT_MAIL2, 'contact_mail2', 50, 255, $contact_mail2, 'email'), true); - } - if ($GLOBALS['xoopsModuleConfig']['form_url']) { - $form->addElement(new ContactFormValidatedInput(_MD_CONTACT_URL, 'contact_url', 50, 255, $contact_url, 'url'), false); - } - if ($GLOBALS['xoopsModuleConfig']['form_icq']) { - $form->addElement(new ContactFormValidatedInput(_MD_CONTACT_ICQ, 'contact_icq', 50, 255, $contact_icq), false); - } - if ($GLOBALS['xoopsModuleConfig']['form_company']) { - $form->addElement(new ContactFormValidatedInput(_MD_CONTACT_COMPANY, 'contact_company', 50, 255, $this->getVar('contact_company')), false); - } - if ($GLOBALS['xoopsModuleConfig']['form_location']) { - $form->addElement(new ContactFormValidatedInput(_MD_CONTACT_LOCATION, 'contact_location', 50, 255, $contact_location), false); - } - if ($GLOBALS['xoopsModuleConfig']['form_phone']) { - $form->addElement(new ContactFormValidatedInput(_MD_CONTACT_PHONE, 'contact_phone', 50, 255, $this->getVar('contact_phone'), 'tel'), false); - } - if ($GLOBALS['xoopsModuleConfig']['form_address']) { - $form->addElement(new XoopsFormTextArea(_MD_CONTACT_ADDRESS, 'contact_address', $this->getVar('contact_address', 'e'), 3, 60), false); - } - if ($GLOBALS['xoopsModuleConfig']['form_dept']) { - // show a drop down with the departments listed - $departmentlist = new XoopsFormSelect(_MD_CONTACT_DEPARTMENT, 'contact_department'); - $departments = $GLOBALS['xoopsModuleConfig']['contact_dept']; - $listOptions = array(); - foreach ($departments as $val) { - $valexplode = explode(',', $val); - $listOptions[$valexplode[0]] = $valexplode[0]; -// $departmentlist->addOption($valexplode[0]); - } - asort($listOptions); - $departmentlist->addOptionArray($listOptions); - $form->addElement($departmentlist); - } else { - $form->addElement(new XoopsFormHidden('contact_department', '')); - } - - $form->addElement(new ContactFormValidatedInput(_MD_CONTACT_SUBJECT, 'contact_subject', 50, 255, $this->getVar('contact_subject')), true); - $form->addElement(new XoopsFormTextArea(_MD_CONTACT_MESSAGE, 'contact_message', $this->getVar('contact_message', 'e'), 5, 60), true); - - // check captcha - if ((!$GLOBALS['xoopsUser'] && $GLOBALS['xoopsModuleConfig']['captchaAnonymous']) - || ($GLOBALS['xoopsUser'] && !$GLOBALS['xoopsUser']->isAdmin() && $GLOBALS['xoopsModuleConfig']['captchaRegistered']) - ) { - xoops_load('XoopsFormCaptcha'); - $form->addElement(new XoopsFormCaptcha('','xoopscaptcha',false), true); - } - - $form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit')); - - return $form; - } - - /** - * - * Get the Contact Reply Form Object - * - * @return object {@see XoopsThemeForm} - */ - public function replyForm() - { - xoops_load('FormValidatedInput', 'contact'); - $form = new XoopsThemeForm(_AM_CONTACT_REPLY, 'doreply', 'contact.php', 'post', true); - $form->setExtra('enctype="multipart/form-data"'); - $form->addElement(new XoopsFormHidden('op', 'doreply')); - $form->addElement(new XoopsFormHidden('contact_id', $this->getVar('contact_id', 'e'))); - $form->addElement(new XoopsFormHidden('contact_uid', $this->getVar('contact_uid', 'e'))); - $form->insertBreak(_AM_CONTACT_FROM, "big bolder uppercase"); - - if ($GLOBALS['xoopsModuleConfig']['form_dept']) { - // add dropdown to allow administrator to change "From" department - include_once "../include/functions.php"; - $dept_values = $dept_keys = contactGetDepartmentNames(); - $dept_options = array_combine($dept_keys, $dept_values); - $dept_select = new XoopsFormSelect(_AM_CONTACT_DEPARTMENT, 'contact_department', $this->getVar('contact_department')); - $dept_select->addOptionArray($dept_options); - $form->addElement($dept_select, true); - $bccbox = new XoopsFormCheckBox('', 'send_dept', 0); - $bccbox->addOption(1, _AM_CONTACT_SEND_DEPT); - $form->addElement($bccbox); - } else { - $form->addElement(new XoopsFormHidden('send_dept', 0)); // not necessary, but included for completeness - $form->addElement(new ContactFormValidatedInput(_AM_CONTACT_NAMEFROM, 'contact_namefrom', 50, 255, XoopsUser::getUnameFromId($GLOBALS['xoopsUser']->uid())), true); - $form->addElement(new ContactFormValidatedInput(_AM_CONTACT_MAILFROM, 'contact_mailfrom', 50, 255, $GLOBALS['xoopsConfig']['adminmail'], 'email'), true); - } - - $form->insertBreak(_AM_CONTACT_TO, "big bolder uppercase"); - $form->addElement(new XoopsFormLabel(_AM_CONTACT_NAMETO, $this->getVar('contact_name'))); - $form->addElement(new XoopsFormHidden('contact_name', $this->getVar('contact_name'))); - $form->addElement(new XoopsFormLabel(_AM_CONTACT_MAILTO, $this->getVar('contact_mail'))); - $form->addElement(new XoopsFormHidden('contact_mail', $this->getVar('contact_mail'))); - $form->addElement(new ContactFormValidatedInput(_AM_CONTACT_SUBJECT, 'contact_subject', 50, 255, _RE . " " . $this->getVar('contact_subject')), true); - $orig_message = new XoopsFormTextArea(_AM_CONTACT_MESSAGE_ORIG, 'c_orig_message', $this->getVar('contact_message'), 5, 60); - $orig_message->setExtra("disabled"); - $form->addElement($orig_message); - $form->addElement(new XoopsFormHidden('contact_orig_message', $this->getVar('contact_message'))); //have to include this since c_orig_message is hidden - $form->addElement(new XoopsFormRadioYN(_AM_CONTACT_MESSAGE_INC_ORIG, 'inc_orig', 0), true); - $form->addElement(new XoopsFormTextArea(_AM_CONTACT_MESSAGE, 'contact_message', '', 5, 60), true); - $form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit')); - - return $form; - } - - /** - * - * Maps Form/Mail Object to Contact Object - * - * @param stdClass $mailObj - */ - public function prepareToInsert(stdClass &$mailObj) - { - $vars_array = array(); - $mail_array = (array) $mailObj; //cast to an array - unset($mail_array['contact_id']); // remove the id, can't set it directly - $class_array = $this->getValues(); - foreach ($mail_array as $key => $item) { - if (array_key_exists($key, $class_array)) { - $vars_array[$key] = $item; - } - } - if (!empty($vars_array)) { - $this->setVars($vars_array); - } - } -} - -class ContactContactHandler extends XoopsPersistableObjectHandler -{ - public function __construct(&$db) - { - parent::__construct($db, 'contact', 'Contact', 'contact_id', 'contact_mail'); - } - - /** - * - * Clean all the incoming Vars from Form(s) - * @param $global global var array (POST, GET, REQUEST) - * @uses {@link XoopsRequest} - * - * @return array containing clean versions of form variables - */ - public function infoProcessing($global) - { - xoops_load('XoopsRequest'); - - $contact = array(); - if (empty($global)) { // will get from $_REQUEST - $from = null; - } elseif (('POST' == strtoupper($global)) || ('GET' == strtoupper($global))) { - $from = strtoupper($global); // will get specifically from $_GET or $_POST - } else { // don't allow other sources - return $contact; - } - $contact['contact_cid'] = XoopsRequest::getInt('contact_id', '', $from); - $contact['contact_uid'] = XoopsRequest::getInt('contact_uid', '', $from); - $contact['contact_name'] = XoopsRequest::getText('contact_name', '', $from); - $contact['contact_namefrom'] = XoopsRequest::getText('contact_namefrom', '', $from); - /* - $contact['contact_nameto'] = XoopsRequest::getText('contact_nameto', '', $from); - */ - $contact['contact_subject'] = XoopsRequest::getText('contact_subject', '', $from); - $email = XoopsRequest::getText('contact_mailfrom', '', $from); - $contact['contact_mailfrom'] = checkEmail($email); - $email = XoopsRequest::getText('contact_mail', '', $from); - $contact['contact_mail'] = checkEmail($email); - $email = XoopsRequest::getText('contact_mail2', '', $from); - $contact['contact_mail2'] = checkEmail($email); - /* - $email = XoopsRequest::getText('contact_mailto', '', $from); - $contact['contact_mailto'] = checkEmail($email); - */ - $url = XoopsRequest::getText('contact_url', '', $from); - $contact['contact_url'] = (!empty($url)) ? filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED) : ''; - $contact['contact_create'] = time(); - $contact['contact_icq'] = XoopsRequest::getText('contact_icq', '', $from); - $contact['contact_company'] = XoopsRequest::getText('contact_company', '', $from); - $contact['contact_location'] = XoopsRequest::getText('contact_location', '', $from); - $contact['contact_phone'] = XoopsRequest::getInt('contact_phone', '', $from); - $contact['contact_department'] = XoopsRequest::getText('contact_department', _MD_CONTACT_DEFULTDEP, $from); - $contact['contact_ip'] = getenv("REMOTE_ADDR"); - $contact['contact_message'] = XoopsRequest::getText('contact_message', '', $from); - $contact['contact_address'] = XoopsRequest::getText('contact_address', '', $from); - $platform = XoopsRequest::getText('contact_platform', '', $from); - $contact['contact_platform'] = $this->contactPlatform($platform); - $type = XoopsRequest::getText('contact_type', '', $from); - $contact['contact_type'] = $this->contactType($type); - $contact['send_dept'] = XoopsRequest::getInt('send_dept' , 0, $from); - $contact['contact_orig_message'] = XoopsRequest::getText('contact_orig_message' , '', $from); - $contact['inc_orig'] = XoopsRequest::getInt('inc_orig', 0, $from); - - return $contact; - } - - /** - * - * Send Mail to Admin or Department(s) if enabled - * @param object $mailObj contains to/from, subject, & message - * - * @uses XoopsMailer - * @uses contactGetDepartmentEmails - * @return string indicates success or error messages - */ - public function contactSendMail(stdClass &$mailObj) - { - include_once $GLOBALS['xoops']->path("modules/contact/include/functions.php"); - xoops_load('XoopsFilterInput'); - $xoopsMailer = xoops_getMailer(); - $xoopsMailer->useMail(); - $deptEmailAddresses = contactGetDepartmentEmails($mailObj->contact_department); - if (!empty($deptEmailAddresses)) { - // using departments and departments exist in list - $xoopsMailer->setToEmails($deptEmailAddresses); - } else { - $xoopsMailer->setToEmails($GLOBALS['xoopsConfig']['adminmail']); //just send to admin - } -/* - if (!in_array($GLOBALS['xoopsConfig']['adminmail'], $deptEmailAddresses)) { - $xoopsMailer->multimailer->addBCC($GLOBALS['xoopsConfig']['adminmail'], 'Administrator'); - } -*/ - xoops_loadLanguage('modinfo', 'contact'); // get the language string(s) - $myts =& MyTextSanitizer::getInstance(); - // pre-process FromName since it came from input field - $fromName = XoopsFilterInput::getString($mailObj->contact_name, 'STRING'); -// $fromName = stripslashes(strip_tags(html_entity_decode($mailObj->contact_name, ENT_QUOTES, 'UTF-8'))); - // pre-process Subject since it came from input field - $mailSubject = XoopsFilterInput::getString($mailObj->contact_subject, 'STRING'); -// $mailSubject = stripslashes(strip_tags(html_entity_decode($mailObj->contact_subject, ENT_QUOTES, 'UTF-8'))); - - $xoopsMailer->setFromName(ucwords($fromName)); - $xoopsMailer->setFromEmail($mailObj->contact_mail); - $thisBody = stripslashes(html_entity_decode($mailObj->contact_message, ENT_QUOTES, 'UTF-8')); -// $thisBody = $xoopsMailer->multimailer->WrapText($thisBody, 80); -// $xoopsMailer->multimailer->set('FromName', ucwords($fromName)); - $xoopsMailer->multimailer->setFrom($mailObj->contact_mail, ucwords($fromName)); - $xoopsMailer->multimailer->set('Subject', $mailSubject); - $xoopsMailer->multimailer->WordWrap = 80; // force wrap of body text at 80 chars for 'bad' clients - $xoopsMailer->multimailer->set('Body', $thisBody); - $xoopsMailer->multimailer->set('AltBody', $thisBody); - $xoopsMailer->setSubject($mailSubject); - $xoopsMailer->setBody($thisBody); - if ($xoopsMailer->send($debug = false)) { - if ($debug) { - $message = $xoopsMailer->getSuccess(); - } else { - $message = $myts->htmlSpecialChars($GLOBALS['xoopsModuleConfig']['contact_thankyou']); - } - } else { - $message = $xoopsMailer->getErrors(); - } - - return $message; - } - - /** - * - * Send Reply mail to individual contact - * @param object $mailObj information to include in email (to, from, name, subject, body) - * - * @return string error or success message to be displayed after email sent - */ - public function contactReplyMail(stdClass &$mailObj) - { - $xoopsMailer = xoops_getMailer(); - $xoopsMailer->useMail(); - $toEmails = $mailObj->contact_mail; - include_once $GLOBALS['xoops']->path("modules/contact/include/functions.php"); - $deptEmailAddresses = contactGetDepartmentEmails($mailObj->contact_department); //get emails for department (if enabled) - if (!empty($deptEmailAddresses)) { //get emails for department (if enabled) - $xoopsMailer->setFromEmail($deptEmailAddresses[0]); // set to dept email to first one - $xoopsMailer->setFromName(stripslashes(strip_tags(html_entity_decode($mailObj->contact_department, ENT_QUOTES, 'UTF-8')))); - if ($mailObj->send_dept) { //send copy of reply to dept - $toEmails = array_merge(array($toEmails), $deptEmailAddresses); - } - } else { // does not use departments or department field does not contain valid email addresses - if (!empty($mailObj->contact_namefrom)) { //take value from ReplyForm, if valid - $fromName = $mailObj->contact_namefrom; - } elseif ($GLOBALS['xoopsConfig']['sitename']) { // or take site name if set - $fromName = html_entity_decode($GLOBALS['xoopsConfig']['sitename'], ENT_QUOTES, 'UTF-8'); - } elseif ($GLOBALS['xoopsUser']->uname()) { // or finally use this user's uname - $fromName = $GLOBALS['xoopsUser']->uname(); - } - $xoopsMailer->setFromName($fromName); - - if (!empty($mailObj->contact_mailfrom)) { - // use mail addr from ReplyForm - $xoopsMailer->setFromName($mailObj->contact_mailfrom); - } else { - // otherwise use default site admin email - $xoopsMailer->setFromEmail($GLOBALS['xoopsConfig']['adminmail']); - } - } - $xoopsMailer->setToEmails($toEmails); - $xoopsMailer->setSubject(stripslashes(strip_tags(html_entity_decode($mailObj->contact_subject, ENT_QUOTES, 'UTF-8')))); - $thisBody = stripslashes(html_entity_decode($mailObj->contact_message, ENT_QUOTES, 'UTF-8')); - $thisBody = $xoopsMailer->multimailer->WrapText($thisBody, 80); - $xoopsMailer->setBody($thisBody); - - if ($xoopsMailer->send()) { - $myts =& MyTextSanitizer::getInstance(); - $message = $myts->htmlSpecialChars(_AM_CONTACT_MSG_REPLY_SENT); - } else { - $message = $xoopsMailer->getErrors(); - } - - return $message; - } - - /** - * - * Set the Reply flag for this contact id - * @param int $contact_id - * - * @return bool success - true or false - */ - public function contactAddReply($contact_id) - { - $obj = $this->get((int) $contact_id); - $obj->setVar('contact_reply', 1); - return $this->insert($obj) ? true : false; - } - - /** - * - * Get the Contact Reply - * @param int $contact_id identifier for contact requested - * - * @return array|false false if nothing found, array with reply info on success - */ - public function contactGetReply($contact_id) - { - $user_timezone = ($GLOBALS['xoopsUser'] instanceof XoopsUser) ? $GLOBALS['xoopsUser']->timezone() : null; - $criteria = new CriteriaCompo(); - $criteria->add(new Criteria('contact_cid', (int) $contact_id)); - $criteria->add(new Criteria('contact_type', 'Contact')); - $criteria->setSort('contact_create'); - $criteria->setOrder('DESC'); - $contactObjs = $this->getObjects($criteria, false); - - $ret = (!empty($contactObjs)) ? array() : false; - foreach ($contactObjs as $thisContact) { - $tab = $thisContact->getValues(); - $tab['contact_owner'] = $GLOBALS['xoopsUser']->getUnameFromId($thisContact->getVar('contact_uid')); - $tab['contact_create'] = formatTimestamp($thisContact->getVar('contact_create'), 'm', $user_timezone); - $ret [] = $tab; - } - return $ret; - } - - /** - * - * Get a list of Admin Contacts - * @param object $pgObj sort, order, start, and limit for list {@see stdClass} - * @param string $column dB index for either contact id or user id - * - * @return array contact Obj as array w/ contact_owner and date_created - */ - public function getAdminList(stdClass $pgObj, $column='contact_cid') - { - $ret = array(); - if (in_array($column, array('contact_cid', 'contact_uid'))) { - $criteria = new CriteriaCompo(); - $criteria->add(new Criteria($column, '0')); - $criteria->add(new Criteria('contact_type', 'Contact')); - $criteria->setSort($pgObj->sort); - $criteria->setOrder($pgObj->order); - $criteria->setStart($pgObj->start); - $criteria->setLimit($pgObj->limit); - $contactObjs = $this->getObjects($criteria, false); - $user_timezone = ($GLOBALS['xoopsUser'] instanceof XoopsUser) ? $GLOBALS['xoopsUser']->timezone() : null; - foreach($contactObjs as $thisContact) { - $tab = $thisContact->getValues(); - $tab['contact_owner'] = XoopsUser::getUnameFromId($thisContact->getVar('contact_uid')); - $tab['contact_create'] = formatTimestamp($thisContact->getVar('contact_create'), 'm', $user_timezone); - $ret [] = $tab; - } - } - - return $ret; - } - - /** - * Get Count by dB column - * @param string $column dB column to count for Contact - * - * @return bool|int false on failure, integer count of column items - */ - public function contactGetCount($column) - { - $count = false; - if (in_array($column, array('contact_uid', 'contact_cid', 'contact_reply'))) { - $criteria = new CriteriaCompo(); - $criteria->add(new Criteria($column, '0')); - $criteria->add(new Criteria('contact_type', 'Contact')); - $count = $this->getCount($criteria); - } - - return $count; - } - - /** - * Contact Delete Before Date - * @param int $timestamp Unix timestamp - * @param bool $onlyreply - true only delete replies, false delete everything - * - * @return bool success - */ - public function deleteBeforeDate($timestamp=0, $onlyreply=false) - { - $criteria = new CriteriaCompo(); - if (!empty($timestamp)) { - $criteria->add(new Criteria('contact_create', (int) $timestamp, '<=')); - } - if ($onlyreply) { - $criteria->add(new Criteria('contact_reply', 1)); - } - - return $this->deleteAll($criteria); - } - - /** - * Contact Platform - * - * @param string $platform (Android,Ios, or Web) case-insensitive - * - * @return string representation of Platform - */ - public function contactPlatform($platform) - { - $platform = (isset($platform)) ? strtolower($platform) : ''; - switch ($platform) { - case 'android': - $ret = 'Android'; - break; - - case 'ios': - $ret = 'Ios'; - break; - - case 'web': - default: - $ret = 'Web'; - break; - } - - return $ret; - } - - /** - * Contact type - * @param string $type contact type - * - * @return string representation of contact type - */ - public function contactType($type) - { - $type = (isset($type)) ? strtolower($type) : ''; - switch ($type) { - case 'mail': - $ret = 'Mail'; - break; - - case 'phone': - $ret = 'Phone'; - break; - - case 'contact': - default: - $ret = 'Contact'; - break; - } - - return $ret; - } - - /** - * Contact logs - * @param string $column dB column to retrieve - * @param null|string $date null: retrieve all, string: get all before this representation of USER date (e.g. 11/21/2014) - * - * @return array of {@link Contact} objects meeting criteria - */ - public function contactLogs($column, $date = null) - { - $ret = array(); - $column = trim(strtolower($column)); - if (in_array($column, array('contact_mail', 'contact_url', 'contact_phone', 'contact_icq'))) { - $criteria = new CriteriaCompo(); - $criteria->add(new Criteria('contact_cid', '0')); - $criteria->add(new Criteria('contact_type', 'Contact')); - if (!empty($date)) { - $timestamp = strtotime($date); - $criteria->add(new Criteria('contact_create', (int) $timestamp, '<=')); - } - $criteria->add(new Criteria($column, '', '<>')); - $criteria->setSort('contact_create'); - $criteria->setOrder('DESC'); - $criteria->setGroupby($column); //reduces number of times through loop below - $contactArray = $this->getObjects($criteria, false, false); - foreach ($contactArray as $thisContact) { - if ($thisContact[$column]) { - $thisPhone = $thisContact['contact_phone'] ? " (<a href='tel:{$thisContact['contact_phone']}'>{$thisContact['contact_phone']}</a>)" : ''; - if ($thisContact['contact_uid']) { - $tmp_link = "<a href='" . $GLOBALS['xoops']->url("www/userinfo.php?uid={$thisContact['contact_uid']}") . "'>{$thisContact['contact_name']}</a>"; - } elseif ($thisContact['contact_mail']) { - $tmp_link = "<a href='mailto:{$thisContact['contact_mail']} ({$thisContact['contact_name']})'>{$thisContact['contact_name']}</a>"; - } else { - $tmp_link = $thisContact['contact_name']; - } - $ret[] = $tmp_link . $thisPhone; - } - } - } - - return array_unique($ret); - } - - /** - * - * Format Reply message body - adds original message to reply - * @param object $mailObj must include 'contact_orig_message', ['contact_message'] keys - * @param bool $inc_orig true: include original message body in reply, false: don't - * - * @return string reply message body - */ - public function replyBodyFormat(stdClass &$mailObj, $inc_orig=false) - { - if ($inc_orig) { - //merge original message body with reply body - $body = $mailObj->contact_message - . "\n\n" - . str_repeat("=", 10) . _AM_CONTACT_MESSAGE_ORIG . str_repeat("=", 10) . "\n" - . trim($mailObj->contact_orig_message); - } else { - $body = $mailObj->contact_message; - } - - return $body; - } -} +<?php +/* + You may not change or alter any portion of this comment or credits + of supporting developers from this source code or any supporting source code + which is considered copyrighted (c) material of the original comment or credit authors. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + */ + +/** + * Contact module + * + * @copyright {@link http://sourceforge.net/projects/xoops/ The XOOPS Project} + * @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license} + * @package contact + * @subpackage class + * @author Kazumi Ono (aka Onokazu) + * @author Trabis <lus...@gm...> + * @author Hossein Azizabadi (AKA Voltan) + * @version $Id: $ + */ + +//defined("XOOPS_ROOT_PATH") || exit("Restricted access - " . basename($_SERVER['PHP_SELF'], '.php') . PHP_EOL); +class Contact extends Xo... [truncated message content] |