} $has_lastTickets = count($lastTickets); unset($lastTickets); } switch ($op) { case "addEmail": if ($_POST['newEmail'] == '') { $message = _XHELP_MESSAGE_NO_EMAIL; redirect_header(XHELP_BASE_URL . "/ticket.php?id={$xhelp_id}", 3, $message); } //Check if email is valid $validator = new ValidateEmail($_POST['newEmail']); if (!$validator->isValid()) { redirect_header(xhelpMakeURI('ticket.php', array('id' => $xhelp_id), false), 3, _XHELP_MESSAGE_NO_EMAIL); } if (!($newUser = xhelpEmailIsXoopsUser($_POST['newEmail']))) { // If a user doesn't exist with this email $user_id = 0; } else { $user_id = $newUser->getVar('uid'); } // Check that the email doesn't already exist for this ticket $hTicketEmails =& xhelpGetHandler('ticketEmails'); $crit = new CriteriaCompo(new Criteria('ticketid', $xhelp_id)); $crit->add(new Criteria('email', $_POST['newEmail'])); $existingUsers =& $hTicketEmails->getObjects($crit); if (count($existingUsers) > 0) { $message = _XHELP_MESSAGE_EMAIL_USED; redirect_header(XHELP_BASE_URL . "/ticket.php?id={$xhelp_id}", 3, $message); } // Create new ticket email object
//Mark field with error $fields[$fieldname]['haserrors'] = true; $fields[$fieldname]['errors'] = $errors; } else { $fields[$fieldname]['haserrors'] = false; } } if (!empty($errors)) { $_xhelpSession->set('xhelp_validateError', $fields); $message = _XHELP_MESSAGE_VALIDATE_ERROR; header("Location: " . XHELP_BASE_URL . "/anon_addTicket.php"); exit; } //Check email address $user_added = false; if (!($xoopsUser =& xhelpEmailIsXoopsUser($_POST['email']))) { // Email is already used by a member switch ($xoopsConfigUser['activation_type']) { case 1: $level = 1; break; case 0: case 2: default: $level = 0; } if ($anon_user =& xhelpXoopsAccountFromEmail($_POST['email'], '', $password, $level)) { // If new user created $member_handler =& xoops_gethandler('member'); $xoopsUser =& $member_handler->loginUserMd5($anon_user->getVar('uname'), $anon_user->getVar('pass')); $user_added = true;
//Connect to the mailbox if ($mbox->connect()) { //Check for new messages if ($mbox->hasMessages()) { //Retrieve / Store each message while ($msg =& $mbox->getMessage()) { $msg_logs = array(); $skip_msg = false; //Check if there are any errors parsing msg if ($parsed =& $msgParser->parseMessage($msg)) { //Sanity Check: Disallow emails from other department mailboxes if (_isDepartmentEmail($parsed->getEmail())) { $msg_logs[_XHELP_MAIL_CLASS3][] = sprintf(_XHELP_MESSAGE_EMAIL_DEPT_MBOX, $parsed->getEmail()); } else { //Create new user account if necessary if (!($xoopsUser =& xhelpEmailIsXoopsUser($parsed->getEmail()))) { if ($xoopsModuleConfig['xhelp_allowAnonymous']) { switch ($xoopsConfigUser['activation_type']) { case 1: $level = 1; break; case 0: case 2: default: $level = 0; } $xoopsUser =& xhelpXoopsAccountFromEmail($parsed->getEmail(), $parsed->getName(), $password, $level); $_eventsrv->trigger('new_user_by_email', array($password, $xoopsUser)); } else { $msg_logs[_XHELP_MAIL_CLASS3][] = sprintf(_XHELP_MESSAGE_NO_ANON, $parsed->getEmail()); $skip_msg = true;