} else { if ($usersDAO->Update($_GET['id'], $_POST['user_group_id'], $_POST['login'], $_POST['email'], $_POST['first_name'], $_POST['last_name'], $_POST['status'])) { $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY'); header('Location: index.php'); exit; } } } } } // end of handle submit // initialize page $userGroupsDAO = new UserGroupsDAO(); if (isset($_GET['id'])) { $usersDAO = new UsersDAO(); $savant->assign('user_row', $usersDAO->getUserByID($_GET['id'])); $savant->assign('show_password', false); } else { $savant->assign('show_password', true); } /*****************************/ /* template starts down here */ global $onload; $onload = 'document.form.login.focus();'; $savant->assign('show_user_group', true); $savant->assign('show_status', true); $savant->assign('all_user_groups', $userGroupsDAO->getAll()); $savant->assign('title', _AC('create_edit_user')); $savant->assign('submit_button_text', _AC('save')); $savant->assign('show_captcha', false); $savant->display('register.tmpl.php');
} else { $glossary_manifest_xml = ''; } */ ob_start(); print_organizations($top_content_parent_id, $content, 0, '', array(), $toc_html); //Exoprt Forum: print_resources_forum(); $organizations_str = ob_get_contents(); ob_end_clean(); // end of modified by Cindy Qi Li on Jan 12, 2010 /* append the Organizations and Resources to the imsmanifest */ $imsmanifest_xml .= str_replace(array('{ORGANIZATIONS}', '{GLOSSARY}', '{RESOURCES}', '{TEST_ITEMS}', '{COURSE_TITLE}'), array($organizations_str, $glossary_manifest_xml, $resources, $test_xml_items, $ims_course_title), $ims_template_xml['final']); // generate the vcard for the instructor/author $usersDAO = new UsersDAO(); $row = $usersDAO->getUserByID($instructor_id); //$sql = "SELECT first_name, last_name, email, website, login, phone FROM ".TABLE_PREFIX."members WHERE member_id=$instructor_id"; //$result = mysql_query($sql, $db); $vcard = new vCard(); if (isset($row)) { $vcard->setName($row['last_name'], $row['first_name'], $row['login']); $vcard->setEmail($row['email']); $vcard->setNote('Originated from an AContent at ' . TR_BASE_HREF . '. See ATutor.ca for additional information.'); $vcard->setURL($row['website']); $imsmanifest_xml = str_replace('{VCARD}', $vcard->getVCard(), $imsmanifest_xml); } else { $imsmanifest_xml = str_replace('{VCARD}', '', $imsmanifest_xml); } /* save the imsmanifest.xml file */ $zipfile->add_file($imsmanifest_xml, 'imsmanifest.xml'); /* Commented by Cindy Qi Li on Jan 12, 2010
$msg->addError($pwd_error); } } } if (!$msg->containsErrors()) { // insert into the db. $password = $addslashes($_POST['form_password_hidden']); $usersDAO = new UsersDAO(); if (!$usersDAO->setPassword($_GET['id'], $password)) { require TR_INCLUDE_PATH . 'header.inc.php'; $msg->printErrors('DB_NOT_UPDATED'); require TR_INCLUDE_PATH . 'footer.inc.php'; exit; } // send email to user $user_row = $usersDAO->getUserByID($_GET['id']); $tmp_message = _AT('password_change_msg') . "\n\n"; $tmp_message .= _AT('web_site') . ' : ' . TR_BASE_HREF . "\n"; $tmp_message .= _AT('login_name') . ' : ' . $user_row['login'] . "\n"; require TR_INCLUDE_PATH . 'classes/phpmailer/transformablemailer.class.php'; $mail = new TransformableMailer(); $mail->From = $_config['contact_email']; $mail->AddAddress($user_row['email']); $mail->Subject = $_config['site_name'] . ': ' . _AT('password_changed'); $mail->Body = $tmp_message; if (!$mail->Send()) { $msg->addError('SENDING_ERROR'); } else { $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY'); } header('Location: index.php');
$savant->display('password_reminder.tmpl.php'); } } else { if (isset($_REQUEST['id']) && isset($_REQUEST['g']) && isset($_REQUEST['h'])) { //coming from an email link //check if expired $current = intval(time() / 60 / 60 / 24); $expiry_date = $_REQUEST['g'] + TR_PASSWORD_REMINDER_EXPIRY; //2 days after creation if ($current > $expiry_date) { $msg->addError('INVALID_LINK'); $savant->display('password_reminder_feedback.tmpl.php'); exit; } //check for valid hash if ($row = $usersDAO->getUserByID(intval($_REQUEST['id']))) { $email = $row['email']; $hash = sha1($_REQUEST['id'] + $_REQUEST['g'] + $row['password']); $hash_bit = substr($hash, 5, 15); if ($_REQUEST['h'] != $hash_bit) { $msg->addError('INVALID_LINK'); $savant->display('password_reminder_feedback.tmpl.php'); } else { if ($_REQUEST['h'] == $hash_bit && !isset($_POST['form_change'])) { $savant->assign('id', $_REQUEST['id']); $savant->assign('g', $_REQUEST['g']); $savant->assign('h', $_REQUEST['h']); $savant->display('password_change.tmpl.php'); } } } else {
require TR_INCLUDE_PATH . 'header.inc.php'; $msg->printInfos('INVALID_USER'); require TR_INCLUDE_PATH . 'footer.inc.php'; exit; } if (isset($_POST['cancel'])) { $msg->addFeedback('CANCELLED'); Header('Location: ../index.php'); exit; } if (isset($_POST['submit'])) { if (isset($_POST['is_author'])) { $is_author = 1; } else { $is_author = 0; } $usersDAO = new UsersDAO(); $user_row = $usersDAO->getUserByID($_SESSION['user_id']); if ($usersDAO->Update($_SESSION['user_id'], $user_row['user_group_id'], $user_row['login'], $user_row['email'], $_POST['first_name'], $_POST['last_name'], $is_author, $_POST['organization'], $_POST['phone'], $_POST['address'], $_POST['city'], $_POST['province'], $_POST['country'], $_POST['postal_code'], $_POST['status'])) { $msg->addFeedback('PROFILE_UPDATED'); } } $row = $_current_user->getInfo(); if (!isset($_POST['submit'])) { $_POST = $row; } /* template starts here */ $savant->assign('row', $row); global $onload; $onload = 'document.form.first_name.focus();'; $savant->display('profile/index.tmpl.php');
$usersDAO->setEmail($id, $e); $msg->addFeedback('CONFIRM_GOOD'); header('Location: ' . $_base_href . 'index.php'); exit; } else { $msg->addError('CONFIRM_BAD'); } } else { $msg->addError('CONFIRM_BAD'); } } else { if (isset($_GET['id'], $_GET['m'])) { $id = intval($_GET['id']); $m = $_GET['m']; $usersDAO = new UsersDAO(); $row = $usersDAO->getUserByID($id); if ($row['status'] == AC_STATUS_UNCONFIRMED) { $code = substr(md5($row['email'] . $row['creation_date'] . $id), 0, 10); if ($code == $m) { $usersDAO->setStatus($id, AC_STATUS_ENABLED); $msg->addFeedback('CONFIRM_GOOD'); header('Location: ' . $_base_href . 'login.php'); exit; } else { $msg->addError('CONFIRM_BAD'); } } else { $msg->addError('CONFIRM_BAD'); } } else { if (isset($_POST['submit'])) {
/** * private * returns username ([first] [last] ([login])) and email of current user * if no looged in user returns false */ private function getUserData() { if (isset($_SESSION['user_id'])) { $userDAO = new UsersDAO(); $user_data = $userDAO->getUserByID($_SESSION['user_id']); $username = trim($user_data['first_name'] . ' ' . $user_data['last_name'] . ' (' . $user_data['login'] . ')'); return array($username, $user_data['email']); } else { return false; } }