$user = array('first_name' => $_POST['parentFirstName'], 'last_name' => $_POST['parentLastName'], 'u_name' => $_POST['u_name'], 'email' => $_POST['parentEmail'], 'passwd' => md5($u_passwd)); $where_clause = 'isParent'; $centers = array_keys(get_center_for_user($studentID)); /** * If u_name already exits, then this is a paarent adding a child.... * Look up info by u_name to get the user_id etc... */ $parentInfo = make_assoc_array_from_sql(get_user_info_by_username($_POST['u_name']), 'u_name', 'my'); if (count($parentInfo[$_POST['u_name']])) { $parentID = $parentInfo[$_POST['u_name']]['user_id']; } else { $msg = createUser($user, $where_clause, $centers); if ($msg['error']) { $b .= "<span style=\"color:red;\">There was a problem creating your user account.<br> \n Please contact the system administrator {" . $_CONF['admin_name'] . " @ " . $_CONF['admin_email'] . "}.<br>\n The error was " . $msg['message'] . "</span>"; } else { $email_results = email_user_login_info($_POST['parentFirstName'], $_POST['parentLastName'], $_POST['parentEmail'], $_POST['u_name'], $u_passwd, '2'); $parentID = $msg['user_id']; } } /** * Link Parent to Student * */ $sql = "INSERT into parent2student(parent_id, student_id) VALUES(" . $parentID . "," . $studentID . ")"; if ($result = $db->query($sql)) { $b .= "You have successfully create an account and have been linked to your child.<br>\n Please check your email for further instructions.<br>\n If you have any questions you can contact the system administrator {" . $_CONF['admin_name'] . " @ " . $_CONF['admin_email'] . "}.<br>"; } else { $b .= "<span style=\"color:red;\">There was an error linking you to your child. using {" . $sql . "}<br> \n Please contact the system administrator {" . $_CONF['admin_name'] . " @ " . $_CONF['admin_email'] . "}.<br></span>"; } } else { $b .= displayArray2($userInfo);
$b .= $er['error_mesg'] . "<br />"; $c_add = "red"; } else { $b .= "Emailing login for " . $fname . " " . $lname . " " . $u_name . "...<br />"; $b .= $er['error_mesg'] . "<br />"; $c_add = "yellow"; } /** **/ /** now insert the parent if exists**/ if ($pfname != '') { $passwd = rand(); $passwd = md5($passwd); $u_passwd = substr($passwd, 1, 8); $query = "INSERT into users (first_name,last_name,email,u_name,passwd,isParent,center_id,address1,address2,city,state,zip,phone)\n\t\t\t\t\tVALUES('" . $pfname . "','" . $plname . "','" . $pemail . "','" . $puname . "', md5('" . $u_passwd . "'),'Y'," . $_SESSION[$_CONF['sess_name'] . '_adminCenterID'] . ",'" . $address1 . "','" . $address2 . "','" . $city . "','" . $state . "','" . $zip . "','" . $phone . "')"; if ($result = $db->query($query)) { $er = email_user_login_info($pfname, $plname, $pemail, $puname, $u_passwd); //$debug = email_user_login_info($pfname,$plname,"*****@*****.**",$puname,$u_passwd); if ($er['error_value']) { $b .= "There was an error emailing the Parent info for " . $fname . " " . $lname . "...<br />"; $b .= $er['error_mesg'] . "<br />"; $c_add = "red"; } else { $b .= "Emailing login for " . $fname . " " . $lname . " " . $u_name . "...<br />"; $b .= $er['error_mesg'] . "<br />"; $c_add = "yellow"; } /** now create the p2s link **/ $sql = "INSERT into parent2student (parent_id, student_id)\n VALUES(LAST_INSERT_ID()," . $sid . ")"; $result = $db->query($sql); } else { /** there was an error inserting the parent into the db. **/
if (!$userStatus['error']) { $pid = $userStatus['user_id']; /** user was added to db, now send email... **/ $b = "<br />"; if ($usr_lev == 3) { /** now create the teacher folder in teacher_pages & downloads & dropbox & backups**/ reActivate_teacher($pid, $center_id); } if ($usr_lev == 1) { reActivate_student($pid, $center_id); //$path = $configPath."DropBox/".$center_short_name."/students/"; //mkdir(escapeshellarg($path).$_POST['u_name'], 0770); // chown user to be student username //chown($path.$_POST['u_name'],$_POST['u_name']); } $email_results = email_user_login_info($_POST['fname'], $_POST['lname'], $_POST['e_mail'], $_POST['u_name'], $u_passwd, $usr_lev); if ($email_results['error_value'] == true) { $errors = true; $b .= "The user account was created, however, the email did not get sent. The mail server returned the following error, <br /><br />"; $b .= $email_results['error_mesg']; $b .= "<br />Contact the Site Administrator {" . $_CONF['admin_email'] . "}"; $b .= "\n\t\t\t\t\t\t\t<form action=index.php?lev=" . $_SESSION[$_CONF['sess_name'] . '_lev'] . "&cat=" . $_SESSION[$_CONF['sess_name'] . '_cat'] . " method=POST>\n\t\t\t\t\t\t\t<input type=submit class=submit name=link value=\"Continue\">\n\t\t\t\t\t\t\t</form>\n\t\t\t\t\t\t\t</center>"; $color = "red"; } else { $b .= "\n\t\t\t\t\t\t\t<center><form action=index.php?lev=" . $_SESSION[$_CONF['sess_name'] . '_lev'] . "&cat=" . $_SESSION[$_CONF['sess_name'] . '_cat'] . " method=POST>\n\t\t\t\t\t\t\t<input type=submit class=submit name=finish value=Continue></form></center>"; $sql = "SELECT LAST_INSERT_ID()"; if ($usr_lev == 2) { $b .= "<center>\n\t\t\t\t\t\t\t\t<form action=" . $_SERVER['PHP_SELF'] . "?lev=" . $_SESSION[$_CONF['sess_name'] . '_lev'] . "&cat=p2s method=POST>\n\t\t\t\t\t\t\t\t<input type=submit class=submit name=link value=\"Link to Student\">\n\t\t\t\t\t\t\t\t<input type=hidden name=parentid value=" . $pid . ">\n\t\t\t\t\t\t\t\t</form>\n\t\t\t\t\t\t\t\t</center>"; } } // end success emailing login info
$user = array('first_name' => $_POST['parentFirstName'], 'last_name' => $_POST['parentLastName'], 'u_name' => $_POST['u_name'], 'email' => $_POST['parentEmail'], 'passwd' => md5($u_passwd)); $where_clause = 'isParent'; $centers = array_keys(get_center_for_user($studentID)); /** * If u_name already exits, then this is a paarent adding a child.... * Look up info by u_name to get the user_id etc... */ $parentInfo = make_assoc_array_from_sql(get_user_info_by_username($_POST['u_name']), 'u_name', 'my'); if (count($parentInfo[$_POST['u_name']])) { $parentID = $parentInfo[$_POST['u_name']]['user_id']; } else { $msg = createUser($user, $where_clause, $centers); if ($msg['error']) { $b .= "<span style=\"color:red;\">There was a problem creating your user account.<br> \n Please contact the system administrator {" . $_CONF['admin_name'] . " @ " . $_CONF['admin_email'] . "}.<br>\n The error was " . $msg['message'] . "</span>"; } else { $email_results = email_user_login_info(makeSQLsafe($_POST['parentFirstName']), makeSQLsafe($_POST['parentFirstName']), $_POST['parentEmail'], $_POST['u_name'], $u_passwd, '2'); $parentID = $msg['user_id']; } } /** * Link Parent to Student * */ $sql = "INSERT into parent2student(parent_id, student_id) VALUES(" . $parentID . "," . $studentID . ")"; if ($result = $db->query($sql)) { $b .= "You have successfully create an account and have been linked to your child.<br>\n Please check your email for further instructions.<br>\n If you have any questions you can contact the system administrator {" . $_CONF['admin_name'] . " @ " . $_CONF['admin_email'] . "}.<br>"; } else { $b .= "<span style=\"color:red;\">There was an error linking you to your child. using {" . $sql . "}<br> \n Please contact the system administrator {" . $_CONF['admin_name'] . " @ " . $_CONF['admin_email'] . "}.<br></span>"; } } else { $b .= "<span style=\"color:red;\">Some of the supplied student information was incorrect.<br> Please hit your browsers \"Back\" button and try again.</span>";