function saveHistoricStatus($idOrder, $newStatus, $msg, $log, $iduser) { $sql = "INSERT INTO `historico_estados_ped` (`id`, `pedido`, `newestado`, `iduser`, `comentario`, `log`)\n VALUES ( NULL , {$idOrder}, '{$newStatus}', {$iduser}, '{$msg}', '{$log}' );"; $conexion = new Conexion(); $result = $conexion->mysqli->query($sql) or die("Query Error" . $sql); //solo enviar mail si se aprueba o rechaza if ($newStatus == 3 || $newStatus == 4 || $newStatus == 6) { buildEmail($idOrder); } //Send mail to proveedor if ($newStatus == 3) { sendMailProv($idOrder); } }
function ewiki_page_wiki_email_page($id = 0, $data = 0, $action = 0) { if (isRequestNotSet($_REQUEST["email_page"], $_REQUEST["email_address"])) { if ($action == "emailpage") { getUserInfo($from_email, $from_name); $defined = isUserInfoDefined($from_email, $from_name); $warning = checkEmailField($_REQUEST["email_address"], $_REQUEST["not_first_time"]); $html = htmlFormGenerate($defined, $id, $warning, $from_email, $from_name); return $html; } else { return "You shouldn't be here."; } } else { $emailAddress = $_REQUEST["email_address"]; $emailText = $_REQUEST["email_text"]; getUserInfo($from_email, $from_name); $headers = getHeaders($from_email, $from_name); $subject = getSubject($id); $body = buildEmail($id, $data, $emailText); mail($emailAddress, $subject, $body, $headers); $success_message = "<p><h4>Success!</h4></p><p>Page sent to <a href=mailto:{$emailAddress}>{$emailAddress}</a></p>"; $success_message .= "<p>Click <a href=\"" . ewiki_script("view", $id) . "\">here</a> to return to the page you just sent.</p>"; return ewiki_t($success_message); } }
function buildUser($orig_userId) { global $communityDbH, $courseparkDbH; echo "building user from user $orig_userId" . PHP_EOL; $trainingareas = array(); $sql = ' SELECT u.*, e.email AS primary_email FROM cp_user AS u LEFT JOIN cp_email AS e ON u.primary_email_id = e.id WHERE u.deleted = false AND u.id = ? '; $statment = $courseparkDbH->prepare($sql); $statment->execute(array($orig_userId)); $user = $statment->fetch(PDO::FETCH_ASSOC); // check if the primary email already exists if so, this user already exists $indexResult = index('email', array('where' => array('email' => $user['primary_email']))); if (!$indexResult) { echo 'email check failed, unknown reason' . PHP_EOL; return false; } // user already exists, return their details if (count($indexResult['content'])) { echo 'user already exists, for email: ' . $user['primary_email'] . PHP_EOL; $getResult = get('user', $indexResult['content'][0]['user_id']); return $getResult['content']; } $data = array(); $data['pic'] = $user['profilepic_path']; $data['name'] = $user['firstname'] . ' ' . $user['lastname']; $data['username'] = $user['username'] ? $user['username'] : $user['primary_email']; $data['password'] = $user['password']; // create the user, get the id $postResult = post('user', $data); if (!$postResult) { echo 'user build canceled, unknown error' . PHP_EOL; return false; } if (201 != $postResult['meta']['status-code']) { // assume the user already exists, get the details echo 'user already exists, using it: ' . $data['username'] . PHP_EOL; $indexResult = index('user', array('where' => array('username' => $data['username']))); return $indexResult['content'][0]; } $data['id'] = $postResult['content']['id']; if (!$user['primary_email_id']) { echo 'user does not have email: ' . $user['name'] . PHP_EOL; $data['PrimaryEmail'] = false; } else { $data['PrimaryEmail'] = buildEmail($user['primary_email_id'], $data['id']); if (false === $data['PrimaryEmail']) { echo 'primary email build canceled, no known email' . PHP_EOL; } } $data['primary_email_id'] = $data['PrimaryEmail'] ? $data['PrimaryEmail']['id'] : null; // update the user with $putResult = put('user', $data['id'], array_intersect_key($data, array('primary_email_id' => true))); return $data; }