eof; require_once($config["htmlRootDir"]."/lib/aStudent.php"); $student = new aStudent($db,$config); $user = new user($db,$config,""); switch($action){ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //registeronline //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// case"registeronline": //make sure we've got a license.. if($db->getOne("SELECT licenseCount FROM courseLicenses WHERE course_id='$get->course_id' AND user_id='$session->sUser_id'")==0){ print<<Error

You do not seem to have a valid license to take this course. If you believe you should, please contact us.

eof; include("inc/foot.php"); exit; } $student_id = $db->getOne("SELECT student_id FROM students WHERE user_id='$session->sUser_id'"); if($db->getOne("SELECT COUNT(*) FROM studentsToCourses WHERE student_id='$student_id' AND course_id='$get->course_id'")>0){ print<<Error

You are already registered for this course.

You can access the course by visiting the courses page.

eof; include("inc/foot.php"); exit; } $licenseCount = $db->getOne("SELECT licenseCount FROM courseLicenses WHERE course_id='$get->course_id' AND user_id='$session->sUser_id'"); // grant the license and register... if($student_id==""){ $db->query("INSERT INTO students (student_id,user_id,created,modified) VALUES(null,'$session->sUser_id',NOW(),NOW())"); $student_id=$db->getOne("SELECT student_id FROm students ORDER BY student_id DESC LIMIT 1"); } $db->query("INSERT INTO studentsToCourses(STC_id,student_id,course_id,created,modified) VALUES(null,'$student_id','$get->course_id',NOW(),NOW())"); $newLicenseCount = $licenseCount-1; $db->query("UPDATE courseLicenses SET licenseCount='$newLicenseCount' WHERE course_id='$get->course_id' AND user_id='$session->sUser_id'"); if($db->getOne("SELECT licenseCount FROM courseLicenses WHERE course_id='$get->course_id' AND user_id='$session->sUser_id'")==0){ $db->query("DELETE FROM courseLicenses WHERE course_id='$get->course_id' AND user_id='$session->sUser_id'"); } // remove th elicense... print<<Success

You are now enrolled in the course.

Click here to start the course!

eof; break; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //assignlicenses //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// case"assignlicenses": // can check to see if the user exists here if ($post->emailAddress==""){ $errors++; $msg.="You must enter an email address
"; } if ($post->emailAddress!=$post->confirmEmailAddress){ $errors++; $msg.="The email addresses you entered did not match
"; } if($post->firstname==""){ $errors++; $msg.="You must enter a first name.
"; } if ($post->lastname==""){ $errors++; $msg.="You must enter a last name.
"; } if ($errors!=0){ print<<Error

The following error(s) occured while trying to process your request. Please review your errors, make your corrections and click "Submit" to continue.

$msg

eof; $newaction=$post->action; $row = $post; include("forms/assignLicenseForm.php"); print""; include("inc/foot.php"); exit; } $courseLicense_id = $user->assignCourseLicense($_POST); print<<Success

The licenses have been assigned.

Click here to assign more licenses.

eof; break; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //assignlicenses //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// case"assignlicense": print<<Assign Course Licenses

To assign the below course license(s), fill in the full name and email address of the person or people who will be taking the course. If you are taking this course yourself, click "Register for this course".

eof; $res=$db->query("SELECT courses.*, courseLicenses.* FROM courseLicenses LEFT JOIN courses USING(course_id) WHERE courseLicenses.user_id='$session->sUser_id' AND courseLicenses.course_id='$get->course_id'"); if($res->numRows()==0){ print<<You have no course licenses.

Click here to purchase more.

eof; } $res->fetchInto($row); include("forms/assignLicenseForm.php"); break; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //viewlicenses //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// case"viewlicenses": print<<My Course Licenses

Below is a list of your course licenses. You can choose to use these licenses to take courses yourself, or you can assign them to another user.

eof; $res=$db->query("SELECT courses.*, courseLicenses.* FROM courseLicenses LEFT JOIN courses USING(course_id) WHERE courseLicenses.user_id='$session->sUser_id' ORDER BY courses.course_id ASC"); if($res->numRows()==0){ print<<You have no course licenses.

Click here to purchase more.

eof; } while($res->fetchInto($row)){ print<<$row->courseName

You have $row->licenseCount license(s) for $row->courseName

Click here to assign the license(s) or to take the course yourself.

eof; } $res->free(); break; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //editprofile //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// case"editprofile": print<<Edit your Profile

Go Back

Use the form below to edit your profile. Fill in all required fields, and click "Save Profile" to continue.

eof; $user = new user($db,$config,"user"); $row = $user->fetchUserInfo($session->sUser_id); $address=$user->fetchPrimaryAddress($session->sUser_id); $newaction="saveprofile"; include("forms/profileForm.php"); break; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //saveprofile //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// case"saveprofile": $errors = 0; $msg=""; if ($post->emailAddress==""){ $errors++; $msg.="You must enter your email address
"; } if ($post->emailAddress !=$post->confirmEmailAddress){ $errors++; $msg.="The email addresses you entered did not match
"; } // let's make sure that we don't have this person already. if ($errors==0){ if($db->getOne("SELECT count(user_id) FROM users WHERE emailAddress='$post->emailAddress' AND user_id!='$post->user_id'")>0){ print<<Error

We already have an account associated with that email address and it doesn't appear to be you.

Go Back

eof; include("inc/foot.php"); exit; } } if ($post->userFirstname==""){ $errors++; $msg.="You must enter your first name
"; } if ($post->userLastname==""){ $errors++; $msg.="You must enter your last name
"; } if($post->address1==""){ $errors++; $msg.="You must enter an address
"; } if ($post->city ==""){ $errors++; $msg.="You must enter a city
"; } if ($post->state ==""){ $errors++; $msg.="You must enter a state/province
"; } if ($post->zip ==""){ $errors++; $msg.="You must enter a postal code
"; } if ($errors!=0){ print<<Error

The following error(s) occured while trying to process your request. Please review your errors, make your corrections and click "Submit" to continue.

$msg

eof; $newaction=$post->action; $row = $post; $address= $post; include("forms/profileForm.php"); print""; include("inc/foot.php"); exit; } $user = new user($db,$config,"user"); $_POST["addressFirstname"] = $_POST["userFirstname"]; $_POST["addressLastname"] = $_POST["userLastname"]; $_POST["addressMiddlename"] = $_POST["userMiddlename"]; $_POST["addressPhone"] = $_POST["userPhone"]; $_POST["addressPhoneExt"] = $_POST["userPhoneExt"]; $_POST["addressFax"] = $_POST["userFax"]; $_POST["addressNickname"]="Primary Address"; $user->saveUser($_POST); $user->setUser($session->sUser_id); $user->saveAddress($_POST,$user->user_id,"Primary"); print<<Success

Your profile has been saved.

Return to member page.

eof; $user->printUserInfo($post->user_id,"Y"); break; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //addaddress //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// case"addaddress": print<<Add Address

Go Back

Use the form below to add an address to your profile. Fill in all required fields and click "Save Address" to continue.

eof; $user = new user($db,$config,"user"); $user->setUser($session->sUser_id); $row->addressFirstname=$user->userFirstname; $row->addressMiddlename=$user->userMiddlename; $row->addressLastname = $user->userLastname; $newaction="saveaddress"; include("forms/addressForm.php"); break; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //addaddress //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// case"viewaddresses": print<<Saved Addresses

Below are your saved addresses. Click "Edit" to edit and "Delete" to delete.

Add New Address

eof; $user = new user($db,$config,"user"); print<< Nickname Address Type Address Edit Delete eof; $res = $db->query("SELECT * FROM addresses WHERE user_id='$session->sUser_id' ORDER BY address_id ASC"); while($res->fetchInto($row)){ $addressLine = str_replace("

","
","$row->address1
$row->address2
"); if($printed%2!=0){$class="list1";}else{$class="list2";} // editing primary goes to profile, and we can't delete it if($row->addressType=="Primary"){ $editLink="Edit"; $deleteLink="Delete"; }else{ $editLink="address_id\">Edit"; $deleteLink="address_id\">Delete"; } print<< $row->addressNickname $row->addressType $addressLine $row->city, $row->state $row->zip
$row->country $editLink $deleteLink eof; $printed++; } print""; break; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //saveAddress //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// case"saveaddress"; $errors = 0; $msg=""; if ($post->addressFirstname==""){ $errors++; $msg.="You must enter your first name
"; } if ($post->addressLastname==""){ $errors++; $msg.="You must enter your last name
"; } if($post->address1==""){ $errors++; $msg.="You must enter an address
"; } if ($post->city ==""){ $errors++; $msg.="You must enter a city
"; } if ($post->state ==""){ $errors++; $msg.="You must enter a state/province
"; } if ($post->zip ==""){ $errors++; $msg.="You must enter a postal code
"; } if($post->address_id!=""){ if($session->sUser_id!=$db->getOne("SELECT user_id FROM addresses WHERE address_id='$post->address_id'")){ $errors++; $msg.="The address id supplied does not appear to belong to you or there was a system error.
"; } } if ($errors!=0){ print<<Error

The following error(s) occured while trying to process your request. Please review your errors, make your corrections and click "Submit" to continue.

$msg

eof; $newaction=$post->action; $row = $post; include("forms/addressForm.php"); print""; include("inc/foot.php"); exit; } $user = new user($db,$config,"user"); $user->saveAddress($_POST,$session->sUser_id,$_POST["addressType"]); print<<Success

Your address has been saved.

Return to address page

eof; break; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //editaddressl //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// case"editaddress": print<<Edit Address

Go Back

Use the form below to edit this address. Fill in all required fields and click "Save Address" to continue.

eof; $user = new user($db,$config,"user"); $row=$user->fetchAddress($session->sUser_id,$get->address_id); if($row->user_id!=$session->sUser_id){ print<<This is not your address or there has been a system error. If this problem continues, please contact an administrator.

Go Back

eof; include("inc/foot.php"); exit; } $newaction="saveaddress"; include("forms/addressForm.php"); break; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //deleteaddress //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// case"deleteaddress": if($get->really=="y"){ if($session->sUser_id!=$db->getOne("SELECT user_id FROM addresses WHERE address_id='$get->address_id'")){ print<<Error

The address id supplied does not appear to belong to you or there was a system error.

Return to your address

eof; }else{ $db->query("DELETE FROM addresses WHERE address_id='$get->address_id'"); print<<Success

Your address has been deleted.

Return to addresses

eof; } }else{ if($session->sUser_id!=$db->getOne("SELECT user_id FROM addresses WHERE address_id='$get->address_id'")){ print<<Error

The address id supplied does not appear to belong to you or there was a system error.

Return to your address

eof; }else{ if($db->getOne("SELECT addressType FROM addresses WHERE address_id='$get->address_id'")=="Primary"){ print<<Error

You cannot delete your primary address.

Return to your member page.

eof; }else{ print<<Confirm Address Deletion

You are about to delete this address. Are you sure you want to do that?

Yes. Delete this address

No. Take me back.

eof; } } } break; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //changepass //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// case"changepass": print<<Change Password

Go Back

Use the form below to change your password. Fill in both fields and click "Save Password" to continue.

eof; $row = $user->fetchUserInfo($session->sUser_id); $newaction="savepass"; include("forms/passwordForm.php"); break; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //savepass //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// case"savepass": $errorArray = array(); if($post->password==""){ array_push($errorArray,"You must enter a password"); } if($post->password!=$post->confirmPassword){ array_push($errorArray,"The passwords you entered did not match"); } if(count($errorArray)>0){ print<<Error

The following errors occured while trying to process your request. Please review your error(s), make your corrections and click "Save Password" to continue.

    eof; foreach($errorArray AS $key=>$msg){ print"
  • $msg
  • "; } print"
"; $row= $post; $newaction=$post->action; include("forms/passwordForm.php"); include("inc/foot.php"); exit; } $cryptPass=md5($post->password); $db->query("UPDATE users SET userPassword = '$cryptPass' where user_id='$session->sUser_id'"); $user->sendPasswordEmail($post->user_id,$post->password); print<<Success

The password has been saved and we've sent you an email reminder.

Return to your profile

eof; break; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //vieworders //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// case"vieworders": $res = $db->query("SELECT * FROM orders WHERE user_id='{$_SESSION[sUser_id]}' ORDER BY order_id DESC"); if ($res->numRows()==0){ print<<Your Orders

You have no orders on file with us. Why not go shopping.

eof; include("inc/foot.php"); exit; } print<<Your Order History eof; $printed=0; $time = new timeConversion; while($res->fetchInto($row)){ if($printed%2!=0){$class="list1";}else{$class="list2";} $time->dbdate = $row->created; $orderDate = $time->datetime2short(); print<< eof; $printed++; } print"
Order ID Date Total Status View/Print
$row->order_id $orderDate $$row->orderTotal $row->orderStatus View/Print
"; break; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //wholesale //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// case"wholesalestatus": $user = new user($db,$config,"user"); $user->setUser($session->sUser_id); if($user->userStatus=="Wholesale"){ print<<Wholesale Status

You are currently a wholesale customer.

eof; }else{ print<<Wholesale Status

You are not currently a wholesale customer.

If you would like to become a wholesale customer at {$config["siteShortURL"]}, you can apply by completing the form below.

eof; include("forms/wholesaleForm.php"); } break; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //default //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// default: $user = new user($db,$config,"user"); $row = $user->fetchUserInfo($session->sUser_id); print<<Welcome $session->sFullname

Welcome to the {$config["siteShortURL"]} member's section. From here you can edit your profile, manage your addresses, change your password, and enter student mode.

eof; if($student->isStudent($session->sUser_id)){ print<<Student Mode

Click here to change into student mode.

eof; } $time = new timeConversion(); $threadCount = $db->getOne("SELECT COUNT(*) FROM forumThreads WHERE user_id='{$session->sUser_id}'"); $postCount = $db->getOne("SELECT COUNT(*) FROM forumPosts WHERE user_id='{$session->sUser_id}'"); if(($forumCount>0)||($postCount>0)){ print<<Forum Updates

You have started $threadCount forum threads and have $postCount forum posts.

Your Posts
eof; $res = $db->query("SELECT forumThreads.thread_id, forumPosts.* FROM forumPosts LEFT JOIN forumThreads USING (thread_id) WHERE forumPosts.user_id='{$session->sUser_id}' ORDER BY forumPosts.thread_id, forumPosts.modified DESC"); while($res->fetchInto($row)){ $time->dbdate= $db->getOne("SELECT modified FROM forumPosts WHERE thread_id='$row->thread_id' ORDER BY modified DESC LIMIT 1"); $updateDate = $time->timestamp2long(); print<<$row->postTitle - Updated $updateDate

eof; } } if($db->getOne("SELECT COUNT(*) FROM courseLicenses WHERE user_id='$session->sUser_id'")>0){ print<<My Course Licenses

View/Assign your course licenses.

eof; } $user->printUserInfo($session->sUser_id,"Y"); break; } print""; include("inc/foot.php"); ?>