function activity_form($activity_id = 0) { global $mysqli; global $backend; if ($activity_id) { $activity = new Activity($activity_id); $form_type = 'update'; } else { $activity = new Activity(); $form_type = 'insert'; } $html = ''; $fields = array('title' => array('var' => 'title', 'label' => 'Activity Title', 'desc' => 'Required. This is the public title of the activity. You may change this later.', 'type' => 'text', 'std' => $activity->title, 'validate' => 'required', 'filter' => 'trim|sanitize_string', 'param' => 's'), 'folder' => array('var' => 'folder', 'label' => 'Activity folder', 'desc' => 'Required. Name of the folder to create on the ASHP server. Just enter the name of the folder <strong>without any slashes</strong>.', 'type' => 'text', 'std' => $activity->folder, 'validate' => 'required|alpha_dash', 'filter' => 'trim|sanitize_string', 'param' => 's'), 'url' => array('var' => 'url', 'label' => 'Live Activity URL', 'desc' => 'The full URL of the activity, including <strong>http://</strong><br />You can leave blank to default to http://ashpadvantagemedia.com/ActivityFolder.<br /><span class="text-danger">Remember to use <strong>http://www.ashpadvantagemedia.com</strong> instead of <strong>http://www.ashpadvantage.com</strong>.</span>', 'type' => 'text', 'std' => $activity->url, 'validate' => 'valid_url', 'filter' => 'trim|sanitize_string', 'param' => 's'), 'sponsor' => array('var' => 'sponsor', 'label' => 'Activity Sponsor', 'desc' => 'The sponsor of the activity.', 'type' => 'text', 'std' => $activity->sponsor, 'validate' => '', 'filter' => 'trim|sanitize_string', 'param' => 's'), 'type_id' => array('var' => 'type_id', 'label' => 'Activity Type', 'desc' => 'Select the type of activity.', 'type' => 'select', 'options' => $backend->activity_types, 'std' => $activity->type_id, 'validate' => 'required', 'filter' => 'trim|sanitize_string', 'param' => 'i'), 'live_website' => array('var' => 'live_website', 'label' => 'Live Website Template', 'desc' => 'Choose which template to display on the live site..', 'type' => 'select', 'options' => $backend->website_types, 'std' => $activity->live_website, 'validate' => 'required', 'filter' => 'trim|sanitize_string', 'param' => 's'), 'has_live' => array('var' => 'has_live', 'label' => 'Has Live Component', 'desc' => 'Select the live component this activity has.', 'type' => 'radio', 'options' => array('none', 'webcast', 'webinar'), 'std' => $activity->has_live, 'validate' => 'required', 'filter' => 'trim|sanitize_string', 'param' => 's'), 'director_id' => array('var' => 'director_id', 'label' => 'Scientific Project Director', 'desc' => '', 'type' => 'select', 'options' => $backend->directors, 'std' => $activity->director_id, 'validate' => 'required', 'filter' => 'trim|sanitize_string', 'param' => 'i'), 'manager_id' => array('var' => 'manager_id', 'label' => 'Project Manager', 'desc' => '', 'type' => 'select', 'options' => $backend->managers, 'std' => $activity->manager_id, 'validate' => 'required', 'filter' => 'trim|sanitize_string', 'param' => 'i'), 'vendor_id' => array('var' => 'vendor_id', 'label' => 'Web Vendor', 'desc' => '', 'type' => 'select', 'options' => $backend->vendors, 'std' => $activity->vendor_id, 'validate' => 'required', 'filter' => 'trim|sanitize_string', 'param' => 'i')); if (isset($_POST['submit'])) { $gump = new GUMP(); foreach ($_POST['form'] as $k => $v) { //update the std value for form output below $fields[$k]['std'] = $v; if (!empty($fields[$k]['validate'])) { $validate[$k] = $fields[$k]['validate']; } if (!empty($fields[$k]['filter'])) { $filter[$k] = $fields[$k]['filter']; } } $error_text = ''; $gump->validation_rules($validate); $gump->filter_rules($filter); $validated_data = $gump->run($_POST['form']); if ($form_type == 'insert' && activity_folder_exists($validated_data['folder'])) { $validated_data = false; $error_text .= 'Folder already exists. Please choose another folder name.<br />'; } if ($validated_data === false) { $errors = $gump->get_readable_errors(false); foreach ($errors as $error) { $error_text .= $error . '<br />'; } echo edgimo_error($error_text); } else { if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit; } if ($validated_data['url'] == '') { $validated_data['url'] = 'http://ashpadvantagemedia.com/' . $validated_data['folder']; } if ($form_type == 'update') { $query = $mysqli->prepare("UPDATE ashp_activities SET title=?, url=?, folder=?, sponsor=?, type_id=?, director_id=?, manager_id=?, vendor_id=?, live_website=?, has_live=? WHERE activity_id=?"); $query->bind_param('ssssiiiiiss', $validated_data['title'], $validated_data['url'], $validated_data['folder'], $validated_data['sponsor'], $validated_data['type_id'], $validated_data['director_id'], $validated_data['manager_id'], $validated_data['vendor_id'], $validated_data['live_website'], $validated_data['has_live'], $activity_id); echo edgimo_success('Activity details have been updated.'); $query->execute(); $query->close(); echo '<script>edgimo_redirect("edit.php?table=ashp_activities&id=' . $activity_id . '");</script>'; } if ($form_type == 'insert') { $query = $mysqli->prepare("INSERT INTO ashp_activities (title, url, folder, sponsor, type_id, director_id, manager_id, vendor_id, live_website, has_live) VALUES (?,?,?,?,?,?,?,?,?,?)"); $query->bind_param('ssssiiiiss', $validated_data['title'], $validated_data['url'], $validated_data['folder'], $validated_data['sponsor'], $validated_data['type_id'], $validated_data['director_id'], $validated_data['manager_id'], $validated_data['vendor_id'], $validated_data['live_website'], $validated_data['has_live']); $query->execute(); $query->close(); $activity_id = $mysqli->query("SELECT activity_id FROM ashp_activities WHERE title = '{$validated_data['title']}'"); $vars = $activity_id->fetch_array(MYSQLI_ASSOC); $activity_id = $vars['activity_id']; $insert_fields = array_merge($backend->get_fields(0, $validated_data['has_live']), $backend->get_fields($validated_data['type_id'], $validated_data['has_live'])); foreach ($insert_fields as $field) { if (strstr($field['copy'], '{{LIVE_OPTIONS}}')) { $field['copy'] = live_options_replace($field['copy'], $validated_data['has_live']); } $query = $mysqli->prepare("INSERT INTO ashp_activity_content (activity_id, field_id, heading, copy, field_type, hook_name) VALUES (?,?,?,?,?,?)"); $query->bind_param('iissss', $activity_id, $field['field_id'], $field['heading'], $field['copy'], $field['field_type'], $field['hook_name']); $query->execute(); $query->close(); } create_site($validated_data['folder'], $activity_id); echo edgimo_success('New activity created.'); echo '<script>edgimo_redirect("edit.php?table=ashp_activities&id=' . $activity_id . '");</script>'; } } } $html .= '<form class="form-horizontal" role="form" method="post">'; foreach ($fields as $field) { isset($errors) && array_key_exists($field['var'], $errors) ? $error = 'has-error' : ($error = ''); $html .= '<div class="form-group ' . $error . '">'; switch ($field['type']) { case 'text': if (!isset($type)) { $type = 'text'; } $html .= ' <label class="col-lg-2 control-label" for="form[' . $field['var'] . ']">' . $field['label'] . '</label> <div class="col-lg-6"> <input class="form-control" type="' . $type . '" name="form[' . $field['var'] . ']" value="' . $field['std'] . '"> </div>'; break; case 'select': $html .= ' <label class="col-lg-2 control-label" for="form[' . $field['var'] . ']">' . $field['label'] . '</label> <div class="col-lg-6"> <select class="form-control" name="form[' . $field['var'] . ']">'; foreach ($field['options'] as $option) { $field['std'] == $option[0] ? $selected = 'selected' : ($selected = ''); $html .= '<option ' . $selected . ' value="' . $option[0] . '">' . $option[1] . '</option>'; } $html .= '</select> </div>'; break; case 'radio': $html .= ' <label class="col-lg-2 control-label" for="form[' . $field['var'] . ']">' . $field['label'] . '</label> <div class="col-lg-6"> '; foreach ($field['options'] as $option) { $field['std'] == $option ? $checked = 'checked' : ($checked = ''); $html .= ' <div class="radio-inline"> <label> <input type="radio" name="form[' . $field['var'] . ']" value="' . $option . '" ' . $checked . '> ' . ucfirst($option) . ' </label> </div>'; } $html .= ' </div>'; break; } $html .= ' <div class="col-lg-4"> <p class="description">' . $field['desc'] . '</p> </div> </div>'; } $html .= ' <hr> <div class="form-group"> <div class="col-lg-6 col-lg-offset-2"> <button type="submit" class="btn btn-primary" name="submit">Submit</button> </div> </div> </form> '; return $html; }
function faculty_form($faculty_id = 0) { global $mysqli; global $backend; global $user; if ($faculty_id) { $faculty = new Faculty($faculty_id); $form_type = 'update'; if (!$user->is_allowed('edit_ashp_faculty')) { echo edgimo_error('Your user role (' . $user->role . ') is not allowed to make edits on this page.'); return; } } else { $faculty = new Faculty(); $form_type = 'insert'; if (!$user->is_allowed('add_faculty')) { echo edgimo_error('Your user role (' . $user->role . ') is not allowed to make edits on this page.'); return; } } $html = ''; $fields = array('first_name' => array('var' => 'first_name', 'label' => 'First Name', 'desc' => '', 'type' => 'text', 'std' => $faculty->first_name, 'validate' => 'required|valid_name', 'filter' => 'trim|sanitize_string', 'param' => 's'), 'middle_name' => array('var' => 'middle_name', 'label' => 'Middle Name', 'desc' => '', 'type' => 'text', 'std' => $faculty->middle_name, 'validate' => '', 'filter' => 'trim|sanitize_string', 'param' => 's'), 'last_name' => array('var' => 'last_name', 'label' => 'Last Name', 'desc' => '', 'type' => 'text', 'std' => $faculty->last_name, 'validate' => 'required|valid_name', 'filter' => 'trim|sanitize_string', 'param' => 's'), 'credentials' => array('var' => 'credentials', 'label' => 'Credentials', 'desc' => '', 'type' => 'text', 'std' => $faculty->credentials, 'validate' => '', 'filter' => 'trim|sanitize_string', 'param' => 's'), 'title' => array('var' => 'title', 'label' => 'Title', 'desc' => '', 'type' => 'textarea_basic', 'std' => $faculty->title, 'validate' => '', 'filter' => 'trim|basic_tags', 'param' => 's'), 'bio' => array('var' => 'bio', 'label' => 'Bio', 'desc' => '', 'type' => 'textarea', 'std' => $faculty->bio, 'validate' => '', 'filter' => 'trim', 'param' => 's'), 'image' => array('var' => 'image', 'label' => 'Image', 'desc' => 'Upload the faculty photo and alert your web vendor so that it can be resized and processed. To replace an existing photo, just upload a new file.', 'type' => 'file', 'std' => $faculty->image, 'validate' => '', 'filter' => 'trim|sanitize_string', 'param' => 's')); if (isset($_POST['submit'])) { $gump = new GUMP(); foreach ($_POST['form'] as $k => $v) { //update the std value for form output below $fields[$k]['std'] = $v; $faculty->{$k} = $v; if ($fields[$k]['type'] == 'textarea_basic') { $_POST['form'][$k] = nl2br($_POST['form'][$k]); } if (!empty($fields[$k]['validate'])) { $validate[$k] = $fields[$k]['validate']; } if (!empty($fields[$k]['filter'])) { $filter[$k] = $fields[$k]['filter']; } } $gump->validation_rules($validate); $gump->filter_rules($filter); $validated_data = $gump->run($_POST['form']); $duplicate = false; if ($form_type == 'insert' && is_duplicate_faculty($validated_data['first_name'], $validated_data['last_name'])) { $validated_data = false; $duplicate = true; } $redirect = true; if (!$duplicate && $form_type == 'insert' && is_similar_faculty($validated_data['last_name'])) { echo edgimo_error('Warning: Similar faculty name found in database.'); $redirect = false; } if ($validated_data === false) { $errors = $gump->get_readable_errors(false); $error_text = ''; foreach ($errors as $error) { $error_text .= $error . '<br />'; } } if ($duplicate) { $errors['first_name'] = true; $errors['last_name'] = true; $error_text .= 'Duplicate faculty member found.<br />'; } if (isset($error_text)) { echo edgimo_error($error_text); } if ($validated_data !== false) { if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit; } if (!isset($validated_data['image'])) { $validated_data['image'] = ''; } if ($_FILES['form']['name']['image'] !== '') { $image = $_FILES['form']['name']['image']; $ext = pathinfo($image, PATHINFO_EXTENSION); $validated_data['image'] = slugify($validated_data['last_name']) . '-' . slugify($validated_data['first_name']) . '.' . $ext; if (move_uploaded_file($_FILES['form']['tmp_name']['image'], FACULTY_IMAGES_DIR . $validated_data['image'])) { } else { echo edgimo_error("Sorry, there was a problem uploading your file."); } } else { if ($form_type == 'update') { $validated_data['image'] = $faculty->image; } } if ($form_type == 'update') { $query = $mysqli->prepare("UPDATE ashp_faculty SET first_name=?, middle_name=?, last_name=?, credentials=?, title=?, image=?, bio=? WHERE faculty_id=?"); $query->bind_param('sssssssi', $validated_data['first_name'], $validated_data['middle_name'], $validated_data['last_name'], $validated_data['credentials'], $validated_data['title'], $validated_data['image'], $validated_data['bio'], $faculty_id); echo edgimo_success('Faculty details have been updated.'); echo '<script>edgimo_redirect("faculty.php");</script>'; } if ($form_type == 'insert') { $query = $mysqli->prepare("INSERT INTO ashp_faculty (first_name, middle_name, last_name, credentials, title, image, bio) VALUES (?,?,?,?,?,?,?)"); $query->bind_param('sssssss', $validated_data['first_name'], $validated_data['middle_name'], $validated_data['last_name'], $validated_data['credentials'], $validated_data['title'], $validated_data['image'], $validated_data['bio']); echo edgimo_success('New faculty member added.'); if ($redirect) { echo '<script>edgimo_redirect("faculty.php");</script>'; } } $query->execute(); $query->close(); } } $html .= '<div class="row"><div class="col-lg-10 col-lg-offset-2"><p class="description">Last updated: ' . date('F j, Y', strtotime($faculty->updated)) . '</p></div></div>'; $html .= '<form enctype="multipart/form-data" class="form-horizontal" role="form" method="post">'; foreach ($fields as $field) { isset($errors) && array_key_exists($field['var'], $errors) ? $error = 'has-error' : ($error = ''); $html .= '<div class="form-group ' . $error . '">'; switch ($field['type']) { case 'text': if (!isset($type)) { $type = 'text'; } $html .= ' <label class="col-lg-2 control-label" for="form[' . $field['var'] . ']">' . $field['label'] . '</label> <div class="col-lg-6"> <input class="form-control" type="' . $type . '" name="form[' . $field['var'] . ']" value="' . $field['std'] . '"> </div>'; break; case 'select': $html .= ' <label class="col-lg-2 control-label" for="form[' . $field['var'] . ']">' . $field['label'] . '</label> <div class="col-lg-6"> <select class="form-control" name="form[' . $field['var'] . ']">'; foreach ($field['options'] as $k => $v) { $field['std'] == $k ? $selected = 'selected' : ($selected = ''); $html .= '<option ' . $selected . ' value="' . $k . '">' . $v . '</option>'; } $html .= '</select> </div>'; break; case 'textarea': $html .= ' <label class="col-lg-2 control-label" for="form[' . $field['var'] . ']">' . $field['label'] . '</label> <div class="col-lg-6"> <textarea class="wysiwyg" name="form[' . $field['var'] . ']">' . $field['std'] . '</textarea> </div> '; break; case 'textarea_basic': $html .= ' <label class="col-lg-2 control-label" for="form[' . $field['var'] . ']">' . $field['label'] . '</label> <div class="col-lg-6"> <textarea class="basic" name="form[' . $field['var'] . ']">' . str_replace('<br />', "", $field['std']) . '</textarea> </div> '; break; case 'file': $html .= ' <label class="col-lg-2 control-label" for="form[' . $field['var'] . ']">' . $field['label'] . '</label> <div class="col-lg-6"> <input class="form-control" type="file" name="form[' . $field['var'] . ']" value="' . $field['std'] . '"> <img class="preview" src="' . FACULTY_IMAGES_DIR . $field['std'] . '"> </div>'; break; } $html .= ' <div class="col-lg-4"> <p class="description">' . $field['desc'] . '</p> </div> </div>'; } $html .= ' <hr> <div class="form-group"> <div class="col-lg-6 col-lg-offset-2"> <button type="submit" class="btn btn-primary" name="submit">Submit</button> </div> </div> </form> '; return $html; }
function user_form($user_id = 0) { global $mysqli; global $user; if ($user_id) { $form_user = new User(get_user_email_by_id($user_id)); $form_type = 'update'; if ($form_user->email != $_SESSION['email'] && !$user->is_allowed('edit_ashp_users')) { echo edgimo_error('Your user role (' . $user->role . ') is not allowed to make edits on this page.'); return; } } else { if (!$user->is_allowed('add_user')) { echo edgimo_error('Your user role (' . $user->role . ') is not allowed to add users.'); return; } $form_user = new User(); $form_type = 'insert'; } $html = ''; $fields = array('first_name' => array('var' => 'first_name', 'label' => 'First Name', 'type' => 'text', 'std' => $form_user->first_name, 'validate' => 'required|valid_name', 'filter' => 'trim|sanitize_string', 'param' => 's', 'desc' => ''), 'last_name' => array('var' => 'last_name', 'label' => 'Last Name', 'type' => 'text', 'std' => $form_user->last_name, 'validate' => 'required|valid_name', 'filter' => 'trim|sanitize_string', 'param' => 's', 'desc' => ''), 'email' => array('var' => 'email', 'label' => 'Email', 'type' => 'text', 'std' => $form_user->email, 'validate' => 'required|valid_email', 'filter' => 'trim|sanitize_string', 'param' => 's', 'desc' => ''), 'password' => array('var' => 'password', 'label' => 'Password', 'type' => 'password', 'std' => '', 'validate' => 'required', 'filter' => '', 'param' => 's', 'desc' => '')); if ($user->is_allowed('change_roles')) { $fields['role'] = array('var' => 'role', 'label' => 'Role', 'type' => 'select', 'options' => unserialize(ROLES), 'std' => $form_user->role, 'validate' => 'required', 'filter' => 'trim|sanitize_string', 'param' => 's', 'desc' => ''); } //special instructions for updating password if ($form_type == 'update') { $fields['password']['desc'] = 'Only enter a new password here if you wish to update the existing password'; } if (isset($_POST['submit'])) { $gump = new GUMP(); //password can be left blank when updating account. If it is, just plug in the saved value if ($form_type == 'update') { if ($_POST['form']['password'] === '') { $_POST['form']['password'] = $form_user->password; } } //add values to the validate and filter gump arrays foreach ($_POST['form'] as $k => $v) { //update the std value for form output below $fields[$k]['std'] = $v; if (!empty($fields[$k]['validate'])) { $validate[$k] = $fields[$k]['validate']; } if (!empty($fields[$k]['filter'])) { $filter[$k] = $fields[$k]['filter']; } } //run gump $gump->validation_rules($validate); $gump->filter_rules($filter); //get validated data $validated_data = $gump->run($_POST['form']); if (empty($validated_data['role'])) { $validated_data['role'] = $form_user->role; } if ($validated_data === false) { $errors = $gump->get_readable_errors(false); $error_text = ''; foreach ($errors as $error) { $error_text .= $error . '<br />'; } echo edgimo_error($error_text); } else { if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit; } if ($form_type == 'update') { $query = $mysqli->prepare("UPDATE ashp_users SET first_name=?, last_name=?, email=?, role=?, password=? WHERE user_id=?"); $password = sha1($validated_data['password']); $query->bind_param('sssssi', $validated_data['first_name'], $validated_data['last_name'], $validated_data['email'], $validated_data['role'], $password, $form_user->user_id); echo edgimo_success('Account details have been updated.'); } if ($form_type == 'insert') { $query = $mysqli->prepare("INSERT INTO ashp_users (email, first_name, last_name, password, role, status) VALUES (?,?,?,?,?,?)"); $password = sha1($validated_data['password']); $status = 'active'; $query->bind_param('ssssss', $validated_data['email'], $validated_data['first_name'], $validated_data['last_name'], $password, $validated_data['role'], $status); echo edgimo_success('New user created.'); } $query->execute(); $query->close(); $new_user = new User($validated_data['email']); $user_vars = get_object_vars($new_user); echo '<script>table_insert(' . json_encode($user_vars) . ');</script>'; } } $html .= '<form class="form-horizontal" role="form" method="post">'; foreach ($fields as $field) { isset($errors) && array_key_exists($field['var'], $errors) ? $error = 'has-error' : ($error = ''); $html .= '<div class="form-group ' . $error . '">'; switch ($field['type']) { case 'password': $type = 'password'; $field['std'] = ''; case 'text': if (!isset($type)) { $type = 'text'; } $html .= ' <label class="col-lg-2 control-label" for="form[' . $field['var'] . ']">' . $field['label'] . '</label> <div class="col-lg-6"> <input class="form-control" type="' . $type . '" name="form[' . $field['var'] . ']" value="' . $field['std'] . '"> </div>'; break; case 'select': $html .= ' <label class="col-lg-2 control-label" for="form[' . $field['var'] . ']">' . $field['label'] . '</label> <div class="col-lg-6"> <select class="form-control" name="form[' . $field['var'] . ']">'; foreach ($field['options'] as $option) { $field['std'] == $option ? $selected = 'selected' : ($selected = ''); $html .= '<option ' . $selected . ' value="' . $option . '">' . $option . '</option>'; } $html .= '</select> </div>'; break; } $html .= ' <div class="col-lg-4"> <p class="description">' . $field['desc'] . '</p> </div> </div>'; } $html .= ' <div class="form-group"> <div class="col-lg-6 col-lg-offset-2"> <button type="submit" class="btn btn-primary" name="submit">Submit</button> </div> </div> </form> '; return $html; }
function login_form() { if (isset($_POST['login_submit'])) { //clear the message(s) unset($_GET['message']); $gump = new GUMP(); $gump->validation_rules(array('email' => 'required|valid_email', 'password' => 'required')); $gump->filter_rules(array('email' => 'trim|sanitize_email', 'password' => 'sanitize_string')); $validated_data = $gump->run($_POST); if ($validated_data === false) { $errors = $gump->get_readable_errors(false); $error_text = ''; foreach ($errors as $error) { $error_text .= $error . '<br />'; } echo edgimo_error($error_text); } else { $email = $validated_data['email']; $password = $validated_data['password']; if (login($email, $password)) { $user = new User($email); $_SESSION['email'] = $user->email; $_SESSION['timeout'] = time(); echo '<script>edgimo_redirect("index.php");</script>'; } else { echo edgimo_error('Invalid email or password. Please try again'); } } } //end submit if (isset($_GET['message'])) { $message = edgimo_success('You have been logged out.'); } else { $message = ''; } echo $message; ?> <div class="row"> <div class="col-md-4 col-md-offset-4"> <div class="panel panel-default"> <div class="panel-heading"> <h3 class="panel-title">Log In</h3> </div> <div class="panel-body"> <form class="form-horizontal" role="form" method="post"> <?php isset($errors) && array_key_exists('email', $errors) ? $error = 'has-error' : ($error = ''); ?> <div class="form-group <?php echo $error; ?> "> <label for="email" class="col-lg-4 control-label">Email</label> <div class="col-lg-8"> <input type="text" class="form-control" name="email" placeholder="Email"> </div> </div> <?php isset($errors) && array_key_exists('password', $errors) ? $error = 'has-error' : ($error = ''); ?> <div class="form-group <?php echo $error; ?> "> <label for="password" class="col-lg-4 control-label">Password</label> <div class="col-lg-8"> <input type="password" class="form-control" name="password" placeholder="Password"> </div> </div> <div class="form-group"> <div class="col-lg-offset-4 col-lg-8"> <button type="submit" name="login_submit" class="btn btn-primary">Sign in</button> </div> </div> </form> </div> </div> </div> </div> <?php }
function stockfiles_form($stock_file_id = 0) { global $user; global $backend; global $mysqli; if ($stock_file_id) { $stock_file = new StockFile($stock_file_id); $form_type = 'update'; if (!$user->is_allowed('edit_ashp_stock_files')) { echo edgimo_error('Your user role (' . $user->role . ') is not allowed to make edits on this page.'); return; } } else { $stock_file = new StockFile(); $form_type = 'insert'; if (!$user->is_allowed('add_stock_file')) { echo edgimo_error('Your user role (' . $user->role . ') is not allowed to make edits on this page.'); return; } } $html = ''; $fields = array('display_name' => array('var' => 'display_name', 'label' => 'Display Name', 'desc' => 'This will be displayed publicly as the name of the file.', 'type' => 'text', 'std' => $stock_file->display_name, 'validate' => 'required', 'filter' => 'trim|sanitize_string', 'param' => 's'), 'file_name' => array('var' => 'file_name', 'label' => 'File', 'desc' => 'File will be renamed based on what you enter in Display Name.', 'type' => 'file', 'std' => $stock_file->file_name, 'validate' => 'required', 'filter' => 'trim|sanitize_string', 'param' => 's'), 'hook_name' => array('var' => 'hook_name', 'label' => 'Hook Name', 'desc' => 'Use all lowercase with no space. Make it short but easy to remember.', 'type' => 'text', 'std' => $stock_file->hook_name, 'validate' => 'required|alpha_dash', 'filter' => 'trim|sanitize_string', 'param' => 's')); if (isset($_POST['submit'])) { $gump = new GUMP(); foreach ($_POST['form'] as $k => $v) { $fields[$k]['std'] = $v; $stock_file->{$k} = $v; if (!empty($fields[$k]['validate'])) { $validate[$k] = $fields[$k]['validate']; } if (!empty($fields[$k]['filter'])) { $filter[$k] = $fields[$k]['filter']; } } $gump->validation_rules($validate); $gump->filter_rules($filter); $validated_data = $gump->run($_POST['form']); if ($validated_data === false) { $errors = $gump->get_readable_errors(false); $error_text = ''; foreach ($errors as $error) { $error_text .= $error . '<br />'; } echo edgimo_error($error_text); } else { $validated_data['hook_name'] = strtolower($validated_data['hook_name']); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit; } if (!isset($validated_data['file_name'])) { $validated_data['file_name'] = ''; } if ($_FILES['form']['name']['file_name'] !== '') { $uploaded_file = $_FILES['form']['name']['file_name']; $ext = pathinfo($uploaded_file, PATHINFO_EXTENSION); $validated_data['file_name'] = slugify($validated_data['display_name']) . '.' . $ext; if (move_uploaded_file($_FILES['form']['tmp_name']['file_name'], STOCK_FILES_DIR . $validated_data['file_name'])) { echo edgimo_success("File uploaded as " . $validated_data['file_name'] . "."); } else { echo edgimo_error("Sorry, there was a problem uploading your file."); } } else { if ($form_type == 'update') { $validated_data['file_name'] = $stock_file->file_name; } } if ($form_type == 'update') { $query = $mysqli->prepare("UPDATE ashp_stock_files SET display_name=?, file_name=?, hook_name=? WHERE stock_file_id=?"); $query->bind_param('sssi', $validated_data['display_name'], $validated_data['file_name'], $validated_data['hook_name'], $stock_file_id); $query->execute(); $query->close(); echo edgimo_success('Stock File details have been updated.'); header('refresh: 1; URL=stockfiles.php'); } if ($form_type == 'insert') { $query = $mysqli->prepare("INSERT INTO ashp_stock_files (display_name, file_name, hook_name) VALUES (?,?,?)"); $query->bind_param('sss', $validated_data['display_name'], $validated_data['file_name'], $validated_data['hook_name']); $query->execute(); $query->close(); echo edgimo_success('New stock file added.'); header('refresh: 1; URL=stockfiles.php'); } } } $html .= '<form enctype="multipart/form-data" class="form-horizontal" role="form" method="post">'; foreach ($fields as $field) { isset($errors) && array_key_exists($field['var'], $errors) ? $error = 'has-error' : ($error = ''); $html .= '<div class="form-group ' . $error . '">'; switch ($field['type']) { case 'text': if (!isset($type)) { $type = 'text'; } $html .= ' <label class="col-lg-2 control-label" for="form[' . $field['var'] . ']">' . $field['label'] . '</label> <div class="col-lg-6"> <input class="form-control" type="' . $type . '" name="form[' . $field['var'] . ']" value="' . $field['std'] . '"> </div>'; break; case 'select': $html .= ' <label class="col-lg-2 control-label" for="form[' . $field['var'] . ']">' . $field['label'] . '</label> <div class="col-lg-6"> <select class="form-control" name="form[' . $field['var'] . ']">'; foreach ($field['options'] as $k => $v) { $field['std'] == $k ? $selected = 'selected' : ($selected = ''); $html .= '<option ' . $selected . ' value="' . $k . '">' . $v . '</option>'; } $html .= '</select> </div>'; break; case 'textarea': $html .= ' <label class="col-lg-2 control-label" for="form[' . $field['var'] . ']">' . $field['label'] . '</label> <div class="col-lg-6"> <textarea class="wysiwyg" name="form[' . $field['var'] . ']">' . $field['std'] . '</textarea> </div> '; break; case 'file': $html .= ' <label class="col-lg-2 control-label" for="form[' . $field['var'] . ']">' . $field['label'] . '</label> <div class="col-lg-6"> <input class="form-control" type="file" name="form[' . $field['var'] . ']" value="' . $field['std'] . '"> <p class="form-control-static"><strong>Currently</strong>: <a href="' . STOCK_FILES_DIR . $field['std'] . '" target="_blank">' . $field['std'] . '</a></p> </div>'; break; } $html .= ' <div class="col-lg-4"> <p class="description">' . $field['desc'] . '</p> </div> </div>'; } $html .= ' <hr> <div class="form-group"> <div class="col-lg-6 col-lg-offset-2"> <button type="submit" class="btn btn-primary" name="submit">Submit</button> </div> </div> </form> '; return $html; }
function stock_form($activity_type_id) { global $user; global $backend; global $mysqli; if ($user->is_allowed('edit_ashp_fields')) { $disabled = ''; $submit = ' <div class="form-group"> <button type="submit" class="btn btn-primary" name="submit">Update</button> </div>'; } else { $disabled = 'disabled'; echo edgimo_error('You may view the stock settings, but your user role (' . $user->role . ') is not allowed to make edits.'); $submit = ''; } if (isset($_POST['submit'])) { $old = $backend->get_stock_fields($activity_type_id); $new = array(); foreach ($_POST['form'] as $k => $v) { if ($k == 58) { var_dump($_POST['form'][$k]['copy']); } $_POST['form'][$k]['copy'] = nl2br($_POST['form'][$k]['copy']); $new[$k]['copy'] = $_POST['form'][$k]['copy']; $new[$k]['heading'] = $_POST['form'][$k]['heading']; $new[$k]['field_id'] = $k; if ($new[$k]['heading'] !== $old[$k]['heading']) { sync_activity_stock_field('heading', $old[$k]['heading'], $new[$k]['heading'], $k); } if ($new[$k]['copy'] !== $old[$k]['copy']) { sync_activity_stock_field('copy', $old[$k]['copy'], $new[$k]['copy'], $k); } $query = $mysqli->prepare("UPDATE ashp_fields SET heading=?, copy=? WHERE field_id=?"); $query->bind_param('ssi', $_POST['form'][$k]['heading'], $_POST['form'][$k]['copy'], $k); $query->execute(); $query->close(); } echo edgimo_success('Stock fields have been updated.'); } $fields = $backend->get_stock_fields($activity_type_id); $activity_types = $backend->activity_types; ?> <h3><?php echo get_activity_type($activity_type_id); ?> </h3> <form class="form" role="form" method="post"> <?php foreach ($fields as $field) { echo ' <div class="field-wrap row" id="' . $field['field_id'] . '"> <p class="meta description">Field ID: ' . $field['field_id'] . '</p>'; if ($field['field_type'] == 'objectives_intro') { echo '<h4 class="field-group-subheading">' . $field['heading'] . '</h4> <input type="hidden" name="form[' . $field['field_id'] . '][heading]" value="' . $field['heading'] . '">'; } else { echo ' <div class="col-lg-12"> <div class="form-group"> <label for="form[' . $field['field_id'] . '][heading]">Heading</label> <input ' . $disabled . ' class="form-control input input-bold" type="text" name="form[' . $field['field_id'] . '][heading]" value="' . $field['heading'] . '"> </div> </div> <div class="clearfix"></div>'; } $button = ' <p class="description">No stock copy exists for this field.</p> <p><a class="btn btn-default btn-info btn-xs" data-toggle="collapse" data-target=".collapse-' . $field['field_id'] . '">Add Stock Copy</a></p>'; $collapse = 'collapse collapse-' . $field['field_id']; if ($field['copy'] != '') { $button = ''; $collapse = ''; } switch ($field['field_type']) { case 'wysiwyg': echo ' <div class="col-lg-12"> ' . $button . ' <div class="form-group ' . $collapse . '"> <label for="form[' . $field['field_id'] . '][copy]">Copy</label> <textarea ' . $disabled . ' class="wysiwyg" name="form[' . $field['field_id'] . '][copy]">' . $field['copy'] . '</textarea> </div> </div> <div class="clearfix"></div>'; break; case 'textarea': echo ' <div class="col-lg-12"> ' . $button . ' <div class="form-group ' . $collapse . '"> <label for="form[' . $field['field_id'] . '][copy]">Copy</label> <textarea class="basic" name="form[' . $field['field_id'] . '][copy]">' . str_replace('<br />', "", $field['copy']) . '</textarea> </div> </div> <div class="clearfix"></div>'; break; case 'text': case 'objectives_intro': echo ' <div class="col-lg-8"> ' . $button . ' <div class="form-group ' . $collapse . '"> <label for="form[' . $field['field_id'] . '][copy]">Copy</label> <input ' . $disabled . ' class="form-control input-sm" type="text" name="form[' . $field['field_id'] . '][copy]" value="' . $field['copy'] . '"> </div> </div> <div class="clearfix"></div>'; break; case 'date': case 'time': $field['field_type'] == 'date' ? $class = 'date' : ($class = 'time'); echo ' <div class="col-lg-3"> ' . $button . ' <div class="form-group ' . $collapse . '"> <label for="form[' . $field['field_id'] . '][copy]">Copy</label> <input ' . $disabled . ' class="form-control input-sm ' . $class . '" name="form[' . $field['field_id'] . '][copy]" value="' . $field['copy'] . '"> </div> </div> <div class="clearfix"></div>'; break; case 'select': echo ' <div class="col-lg-4"> ' . $button . ' <div class="form-group ' . $collapse . '"> <label for="form[' . $field['field_id'] . '][copy]">Copy</label> <select class="form-control" name="form[' . $field['field_id'] . '][copy]">'; echo '<option value="0" selected>-- Choose Faculty Member --</option>'; foreach ($backend->faculty_list as $faculty) { $field['copy'] == $faculty['faculty_id'] ? $selected = 'selected' : ($selected = ''); echo '<option value="' . $faculty['faculty_id'] . '" ' . $selected . '>' . $faculty['faculty_name'] . '</option>'; } echo ' </select> </div> </div> <div class="clearfix"></div>'; break; } echo ' </div><hr>'; } ?> <hr> <?php echo $submit; ?> </form> <?php }
function send_email_blast($id) { global $mysqli; $activity = new Activity($id); $subject = $mysqli->query("SELECT copy FROM ashp_activity_content WHERE activity_id = {$id} AND field_id = 57"); $subject = $subject->fetch_array(MYSQLI_ASSOC); $master_subject = $subject['copy']; $body = $mysqli->query("SELECT copy FROM ashp_activity_content WHERE activity_id = {$id} AND field_id = 58"); $body = $body->fetch_array(MYSQLI_ASSOC); $master_body = str_replace('<br />', "", $body['copy']); $headers = 'From: elearning@ashp.org' . "\r\n" . 'Reply-To: elearning@ashp.org' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); if ($mysqli->affected_rows < 1) { echo edgimo_error('Reminder already sent. Reset to send again.'); return; } $query = "SELECT reminder_sent FROM ashp_activities WHERE activity_id = {$id} AND reminder_sent = 0"; $result = $mysqli->query($query); $list = $mysqli->query("SELECT name, email, message FROM ashp_reminder_list WHERE activity_id = {$id}"); while ($vars = $list->fetch_array(MYSQLI_ASSOC)) { $body = convert_tags($master_body, $vars['name'], $vars['message'], $activity); $subject = convert_tags($master_subject, $vars['name'], $vars['message'], $activity); $mail = mail($vars['email'], $subject, $body, $headers); if ($mail) { echo edgimo_success('Email sent to ' . $vars['email']); } else { echo edgimo_error('Email failed to ' . $vars['email']); } } }
function activity_content_form($id) { global $user; global $backend; global $mysqli; if (isset($_GET['blast'])) { if (!$user->is_allowed('send_email_blast')) { echo edgimo_error('Your user role is not allowed to send an email blast.'); } else { if ($_GET['blast'] == 'true') { $time = time(); $query = "SELECT reminder_sent FROM ashp_activities WHERE activity_id = {$id} AND reminder_sent = 0"; $result = $mysqli->query($query); if ($mysqli->affected_rows > 0) { send_email_blast($id); $query = "UPDATE ashp_activities SET reminder_sent={$time} WHERE activity_id = {$id}"; $result = $mysqli->query($query); } } if ($_GET['blast'] == 'reset') { echo edgimo_success('Reminder email reset.'); $query = "UPDATE ashp_activities SET reminder_sent=0 WHERE activity_id = {$id}"; $result = $mysqli->query($query); } } unset($_GET['blast']); } if (isset($_POST['template_change'])) { $live_website = $_POST['template_change']; $query = $mysqli->prepare("UPDATE ashp_activities SET live_website=? WHERE activity_id=?"); $query->bind_param('si', $live_website, $id); echo edgimo_success('Template has been changed.'); $query->execute(); $query->close(); } if (isset($_POST['notes_submit'])) { $notes = htmlspecialchars($_POST['notes']); $query = $mysqli->prepare("UPDATE ashp_activities SET notes=? WHERE activity_id=?"); $query->bind_param('si', $notes, $id); echo edgimo_success('Activity notes have been updated.'); $query->execute(); $query->close(); } if (isset($_POST['activity_submit'])) { if (!empty($_FILES)) { $site_folder = get_site_folder($id); foreach ($_FILES['form']['name'] as $file_id => $file_name) { $uploaded_files[$file_id] = $file_name['copy']; } foreach ($_FILES['form']['tmp_name'] as $file_id => $tmp_name) { if ($_FILES['form']['tmp_name'][$file_id]['copy'] != '') { if (move_uploaded_file($_FILES['form']['tmp_name'][$file_id]['copy'], '../' . $site_folder . '/files/' . $uploaded_files[$file_id])) { echo edgimo_success("File uploaded as " . $site_folder . '/files/' . $uploaded_files[$file_id] . "."); $_POST['form'][$file_id]['copy'] = 'files/' . $uploaded_files[$file_id]; } else { echo edgimo_error("Sorry, there was a problem uploading your file."); } } else { $_POST['form'][$file_id]['copy'] = get_activity_copy_by_id($id, $file_id); } } } foreach ($_POST['form'] as $k => $v) { $temp = nl2br($_POST['form'][$k]['copy']); $_POST['form'][$k]['copy'] = $temp; $query = $mysqli->prepare("UPDATE ashp_activity_content SET heading=?, copy=? WHERE field_id=? AND activity_id=?"); $query->bind_param('ssii', $_POST['form'][$k]['heading'], $_POST['form'][$k]['copy'], $k, $id); $query->execute(); $query->close(); } echo edgimo_success('Activity details have been updated.'); } if ($user->is_allowed('edit_ashp_activities')) { $disabled = ''; $submit = ' <div class="form-group"> <button type="submit" class="btn btn-primary" name="activity_submit">Update Activity Copy</button> </div>'; } else { $disabled = 'disabled'; echo edgimo_error('You may view the activity settings, but your user role (' . $user->role . ') is not allowed to make edits.'); $submit = ''; } $activity = new Activity($id); echo ' <h2 class="activity-title">' . $activity->title . '</h2> <form class="form notes_change" method="post"> <label for="notes">Notes For Web Vendor</label> <div class="form-group"> <textarea class="form-control" name="notes">' . $activity->notes . '</textarea> </div> <div class="form-group"><input type="submit" name="notes_submit" value="Update Notes" class="btn btn-xs btn-info"></div> </form> <h3>General Info</h3> <p class="description">Below is the general info about this activity. Click Edit General Info to change information.</p> <p><a href="edit.php?table=activity_settings&id=' . $id . '" class="btn btn-sm btn-info">Edit General Info</a> <a href="' . $activity->url . '" target="_blank" class="btn btn-sm btn-default">View Live Site</a></p> <p class="hidden web-vendor"><a target="_blank" href="http://ashpadvantagemedia.com/' . $activity->folder . '/cheatsheet.php" class="btn btn-sm btn-default">View Cheatsheet</a></p> <table class="table"> <tr> <td>Live Template</td> <td> <form class="form template_change" method="post"> <div class="form-group"> <select class="form-control input-sm" id="template_change" name="template_change">'; foreach ($backend->website_types as $option) { $activity->live_website == $option[0] ? $selected = 'selected' : ($selected = ''); echo '<option ' . $selected . ' value="' . $option[0] . '">' . $option[1] . '</option>'; } echo '</select> </div> </form> </td> </tr> <tr> <td>Sponsor</td> <td>' . $activity->sponsor . '</td> </tr> <tr> <td>Scientific Project Director</td> <td>' . get_user_name($activity->director_id) . '</td> </tr> <tr> <td>Project Manager</td> <td>' . get_user_name($activity->manager_id) . '</td> </tr> <tr> <td>Web Vendor</td> <td>' . get_user_name($activity->vendor_id) . '</td> </tr> </table> <h3>Preview Templates</h3> <p class="description">Click on a template button to preview the site. Dark blue indicates current template.</p>'; foreach ($backend->website_types as $option) { $activity->live_website == $option[0] ? $selected = 'btn-primary' : ($selected = 'btn-info'); echo '<a target="_blank" class="btn ' . $selected . ' btn-sm" href="' . $activity->url . '?preview=' . $option[0] . '">' . $option[1] . '</a> '; } echo ' <hr> <h3 class="toggle">Email List <small>Click to view/hide</small></h3>'; $table = 'ashp_email_list'; $fields = array('last_name', 'first_name', 'email', 'city', 'state', 'submitted'); $sort = 'last_name'; $order = 'ASC'; $edit = false; $where = "WHERE activity_id = {$id}"; $email_list = dashboard_table($table, $fields, $sort, $order, $edit, $where); if ($email_list) { echo '<div class="toggle-target">' . $email_list . '</div>'; echo '<a class="btn btn-success btn-xs" href="edit.php?table=ashp_activities&id=' . $id . '&download=true">Download as CSV</a>'; } else { echo '<p>No email signups yet.</p>'; } echo ' <hr> <h3 class="toggle">Reminder List <small>Click to view/hide</small></h3>'; $table = 'ashp_reminder_list'; $fields = array('name', 'email', 'message', 'submitted'); $sort = 'submitted'; $order = 'ASC'; $edit = false; $where = "WHERE activity_id = {$id}"; $reminder_list = dashboard_table($table, $fields, $sort, $order, $edit, $where); if ($reminder_list) { echo '<div class="toggle-target">' . $reminder_list . '</div>'; if ($activity->reminder_sent == 0) { echo '<p class="text-warning">Reminder has not been sent yet for this activity</p>'; if ($user->is_allowed('send_email_blast')) { echo '<p><a onclick="return confirm(\'This will send a mass email to all email addresses listed in the table. Continue?\');" href="edit.php?table=ashp_activities&id=' . $id . '&blast=true" class="btn btn-warning btn-xs">Send Email Blast</a></p>'; } } else { echo '<p class="text-success">Reminder sent on ' . date('F j, Y', $activity->reminder_sent) . '.</p>'; if ($user->is_allowed('send_email_blast')) { echo '<p><a href="edit.php?table=ashp_activities&id=' . $id . '&blast=reset" class="btn btn-success btn-xs">Reset Email Blast</a></p>'; } } } else { echo '<p>No reminder signups yet.</p>'; } ?> <hr> <h3>Activity Copy</h3> <?php $fields = $activity->get_activity_content(); $fields = $activity->sort_fields($fields); $descriptions = array('general' => 'Information in the general tab is used for the Midyear Symposia pre- and post-pages, MCM webinar registration page, and the On-demand MCM Archive overview page.', 'midyear' => 'Information in the midyear tab is used for the Midyear Symposia pre- and post-pages.', 'virtual' => 'Information in the fields below will be used (as appropriate) on the Midyear Virtual Activity (webinar, webcast) overview page.', 'enduring' => 'Information in the fields below will be used (as appropriate) on the post-Midyear landing page that links to the enduring activities.', 'webinar1' => 'Information in Webinar tab will be used to create webinars not related to the Midyear Activity.', 'webinar2' => 'Information in Webinar tab will be used to create webinars not related to the Midyear Activity.', 'webinar3' => 'Information in Webinar tab will be used to create webinars not related to the Midyear Activity.'); ?> <form enctype="multipart/form-data" class="form" role="form" method="post" id="activity-content-form"> <ul class="nav nav-tabs" role="tablist"> <li class="active"><a href="#general" role="tab" data-toggle="tab">General</a></li> <li><a href="#midyear" role="tab" data-toggle="tab">Midyear</a></li> <li><a href="#enduring" role="tab" data-toggle="tab">Enduring</a></li> <li><a href="#webinar1" role="tab" data-toggle="tab">Webinar 1</a></li> </ul> <div class="tab-content"> <?php foreach ($fields as $tab_group => $value) { $tab_group == 'general' ? $active = 'active' : ($active = ''); echo ' <div class="tab-pane ' . $active . '" id="' . $tab_group . '"> <p class="tab-description">' . $descriptions[$tab_group] . '</p>'; foreach ($fields[$tab_group] as $group_order => $value) { foreach ($fields[$tab_group][$group_order] as $group_name => $value) { echo ' <h3 class="field-group-heading">' . $group_name . '</h3> <div class="field-group">'; foreach ($fields[$tab_group][$group_order][$group_name] as $field_order => $value) { foreach ($fields[$tab_group][$group_order][$group_name][$field_order] as $field) { $has_stock = has_stock_copy($field['field_id']); $using_stock = using_stock_copy($field['field_id'], $id, $activity->type_id, $activity->has_live); $button = ''; $collapse = ''; if ($using_stock) { $button = ' <p class="text-info"><em>This field is using stock copy.</em></p> <p><a class="btn btn-default btn-info btn-xs" data-toggle="collapse" data-target=".collapse-' . $field['field_id'] . '">Customize Stock Copy</a></p>'; $collapse = 'collapse collapse-' . $field['field_id']; } if ($has_stock && !$using_stock) { $button = ' <p class="text-warning"><em>This field is using customized stock copy.</em></p> <p><a class="btn btn-default btn-warning btn-xs revert-stock" data-id="' . $field['field_id'] . '">Revert to Original Stock Copy</a></p>'; $collapse = ''; } echo ' <div class="field-wrap row"> <p class="meta description hidden web-vendor">Field ID: ' . $field['field_id'] . '</p>'; if ($field['heading'] != $group_name) { echo '<h4 class="field-group-subheading">' . $field['heading'] . '</h4>'; } if (in_array($field['field_id'], $backend->editable_headings)) { echo ' <div class="col-lg-12"> <div class="form-group"> <label for="form[' . $field['field_id'] . '][heading]">Heading</label> <input ' . $disabled . ' class="form-control input input-bold" type="text" name="form[' . $field['field_id'] . '][heading]" value="' . $field['heading'] . '"> </div> </div> '; } else { echo '<input type="hidden" ' . $disabled . ' name="form[' . $field['field_id'] . '][heading]" value="' . $field['heading'] . '">'; } if (!$using_stock && $has_stock) { echo ' <div class="hidden-stock" data-id="' . $field['field_id'] . '"> ' . trim(live_options_replace(get_stock_copy($field['field_id']), $activity->has_live)) . ' </div>'; } switch ($field['field_type']) { case 'wysiwyg': if ($using_stock) { echo ' <div class="col-lg-12"> <div class="form-group"> <label for="form[' . $field['field_id'] . '][copy]">Copy</label> <div class="well form-control-static">' . $field['copy'] . '</div> </div> </div> '; } echo ' <div class="col-lg-12"> ' . $button . ' <div class="form-group ' . $collapse . '"> <textarea id="wysiwyg-' . $field['field_id'] . '" ' . $disabled . ' class="wysiwyg" name="form[' . $field['field_id'] . '][copy]">' . $field['copy'] . '</textarea> </div> </div> '; break; case 'textarea': if ($using_stock) { echo ' <div class="col-lg-12"> <div class="form-group"> <label for="form[' . $field['field_id'] . '][copy]">Copy</label> <div class="well form-control-static">' . $field['copy'] . '</div> </div> </div> '; } echo ' <div class="col-lg-12"> ' . $button . ' <div class="form-group ' . $collapse . '"> <textarea class="basic" name="form[' . $field['field_id'] . '][copy]">' . str_replace('<br />', "", $field['copy']) . '</textarea> </div> </div> '; break; case 'text': if ($using_stock) { echo ' <div class="col-lg-8"> <div class="form-group"> <div class="well form-control-static">' . $field['copy'] . '</div> </div> </div> '; } echo ' <div class="col-lg-8"> ' . $button . ' <div class="form-group ' . $collapse . '"> <input id="input-' . $field['field_id'] . '" ' . $disabled . ' class="form-control input-sm" type="text" name="form[' . $field['field_id'] . '][copy]" value="' . $field['copy'] . '"> </div> </div> '; break; case 'date': case 'time': $field['field_type'] == 'date' ? $class = 'date' : ($class = 'time'); $field['field_type'] == 'date' ? $size = 'col-lg-6' : ($size = 'col-lg-3'); echo ' <div class="' . $size . '"> <div class="form-group"> <input ' . $disabled . ' class="form-control input-sm ' . $class . '" name="form[' . $field['field_id'] . '][copy]" value="' . $field['copy'] . '"> </div> </div> '; break; case 'select': echo ' <div class="col-lg-4"> <div class="form-group"> <label for="form[' . $field['field_id'] . '][copy]">Select</label> <select class="form-control" name="form[' . $field['field_id'] . '][copy]">'; echo '<option value="0" selected>-- Choose Faculty Member --</option>'; foreach ($backend->faculty_list as $faculty) { $field['copy'] == $faculty['faculty_id'] ? $selected = 'selected' : ($selected = ''); echo '<option value="' . $faculty['faculty_id'] . '" ' . $selected . '>' . $faculty['faculty_name'] . '</option>'; } echo ' </select> </div> </div> '; break; case 'file': echo ' <div class="col-lg-4"> <div class="form-group"> <input class="form-control" type="file" name="form[' . $field['field_id'] . '][copy]" value="' . $field['copy'] . '"> <p class="form-control-static"> <strong>Currently</strong>: <a href="../' . $activity->folder . '/' . $field['copy'] . '" target="_blank">' . $field['copy'] . '</a> </p> </div> </div>'; break; case 'objectives_intro': $obj_copy = get_stock_copy($field['field_id']); $field['copy'] == $obj_copy ? $knowledge = 'checked' : ($knowledge = ''); $field['copy'] == str_replace('knowledge', 'application', $obj_copy) ? $application = 'checked' : ($application = ''); $application == '' && $knowledge == '' ? $custom = 'checked' : ($custom = ''); echo ' <div class="hidden"> <span id="knowledge-copy">' . $obj_copy . '</span> <span id="application-copy">' . str_replace('knowledge', 'application', $obj_copy) . '</span> </div> <div class="col-lg-8"> <div class="form-group"> <div class="radio-inline"> <label> <input type="radio" name="objectives_intro-' . $field['field_id'] . '" id="knowledge" value="knowledge" ' . $knowledge . '> Knowledge based </label> </div> <div class="radio-inline"> <label> <input type="radio" name="objectives_intro-' . $field['field_id'] . '" id="application" value="application" ' . $application . '> Application based </label> </div> <div class="radio-inline"> <label> <input type="radio" name="objectives_intro-' . $field['field_id'] . '" id="custom" value="custom" ' . $custom . '> Custom </label> </div> </div> </div> <div class="col-lg-8"> <div class="form-group" id="objectives_intro-' . $field['field_id'] . '"> <input id="input-' . $field['field_id'] . '" class="form-control input-sm" type="text" name="form[' . $field['field_id'] . '][copy]" value="' . $field['copy'] . '"> </div> </div> '; break; } echo ' </div>'; } } echo '</div>'; } } echo ' </div>'; } ?> </div> <?php /* $first = ''; $section_toggle = 'hook-midyear'; foreach( $backend->groups as $group_name => $group_field_id ){ $heading_displayed = false; foreach( $fields as $field ){ if ( !in_array($field['field_id'], $backend->groups[$group_name]) ){ continue; } $has_stock = has_stock_copy( $field['field_id'] ); $using_stock = using_stock_copy( $field['field_id'], $id, $activity->type_id, $activity->has_live ); $button = ''; $collapse = ''; if ( $using_stock ){ $button = ' <p class="text-info"><em>This field is using stock copy.</em></p> <p><a class="btn btn-default btn-info btn-xs" data-toggle="collapse" data-target=".collapse-'.$field['field_id'].'">Customize Stock Copy</a></p>'; $collapse = 'collapse collapse-'.$field['field_id']; } if ( $has_stock && !$using_stock){ $button = ' <p class="text-warning"><em>This field is using customized stock copy.</em></p> <p><a class="btn btn-default btn-warning btn-xs revert-stock" data-id="'.$field['field_id'].'">Revert to Original Stock Copy</a></p>'; $collapse = ''; } if ( $group_name == 'Enduring Summary Statement' ){ $section_toggle = 'hook-enduring'; } if ( !$heading_displayed ){ echo $first . '<h3 class="field-group-heading '.$section_toggle.'">'.$group_name.'</h3> <div class="field-group '.$section_toggle.'">'; $heading_displayed = true; $first = '</div>'; } echo ' <div class="field-wrap row"> <p class="meta description hidden web-vendor">Field ID: '.$field['field_id'].'</p>'; if ( $field['heading'] != $group_name ){ echo '<h4 class="field-group-subheading">'.$field['heading'].'</h4>'; } if ( in_array($field['field_id'], $backend->editable_headings) ){ echo' <div class="col-lg-12"> <div class="form-group"> <label for="form['.$field['field_id'].'][heading]">Heading</label> <input '.$disabled.' class="form-control input input-bold" type="text" name="form['.$field['field_id'].'][heading]" value="'.$field['heading'].'"> </div> </div> '; } else{ echo '<input type="hidden" '.$disabled.' name="form['.$field['field_id'].'][heading]" value="'.$field['heading'].'">'; } if ( !$using_stock && $has_stock ){ echo ' <div class="hidden-stock" data-id="'.$field['field_id'].'"> '.trim( live_options_replace( get_stock_copy($field['field_id']), $activity->has_live ) ).' </div>'; } switch ( $field['field_type'] ){ case 'wysiwyg' : if ( $using_stock ){ echo ' <div class="col-lg-12"> <div class="form-group"> <label for="form['.$field['field_id'].'][copy]">Copy</label> <div class="well form-control-static">'.$field['copy'].'</div> </div> </div> '; } echo ' <div class="col-lg-12"> '.$button.' <div class="form-group '.$collapse.'"> <textarea id="wysiwyg-'.$field['field_id'].'" '.$disabled.' class="wysiwyg" name="form['.$field['field_id'].'][copy]">'.$field['copy'].'</textarea> </div> </div> '; break; case 'textarea' : if ( $using_stock ){ echo ' <div class="col-lg-12"> <div class="form-group"> <label for="form['.$field['field_id'].'][copy]">Copy</label> <div class="well form-control-static">'.$field['copy'].'</div> </div> </div> '; } echo ' <div class="col-lg-12"> '.$button.' <div class="form-group '.$collapse.'"> <textarea class="basic" name="form['.$field['field_id'].'][copy]">'.str_replace('<br />',"",$field['copy']).'</textarea> </div> </div> '; break; case 'text' : if ( $using_stock ){ echo ' <div class="col-lg-8"> <div class="form-group"> <div class="well form-control-static">'.$field['copy'].'</div> </div> </div> '; } echo ' <div class="col-lg-8"> '.$button.' <div class="form-group '.$collapse.'"> <input id="input-'.$field['field_id'].'" '.$disabled.' class="form-control input-sm" type="text" name="form['.$field['field_id'].'][copy]" value="'.$field['copy'].'"> </div> </div> '; break; case 'date' : case 'time' : $field['field_type'] == 'date' ? $class = 'date' : $class = 'time'; $field['field_type'] == 'date' ? $size = 'col-lg-6' : $size = 'col-lg-3'; echo ' <div class="'.$size.'"> <div class="form-group"> <input '.$disabled.' class="form-control input-sm '.$class.'" name="form['.$field['field_id'].'][copy]" value="'.$field['copy'].'"> </div> </div> '; break; case 'select' : echo ' <div class="col-lg-4"> <div class="form-group"> <label for="form['.$field['field_id'].'][copy]">Select</label> <select class="form-control" name="form['.$field['field_id'].'][copy]">'; echo '<option value="0" selected>-- Choose Faculty Member --</option>'; foreach ($backend->faculty_list as $faculty) { $field['copy'] == $faculty['faculty_id'] ? $selected = 'selected' : $selected = ''; echo '<option value="'.$faculty['faculty_id'].'" '.$selected.'>'.$faculty['faculty_name'].'</option>'; } echo' </select> </div> </div> '; break; case 'file' : echo ' <div class="col-lg-4"> <div class="form-group"> <input class="form-control" type="file" name="form['.$field['field_id'].'][copy]" value="'.$field['copy'].'"> <p class="form-control-static"> <strong>Currently</strong>: <a href="../' . $activity->folder . '/' . $field['copy'] .'" target="_blank">'.$field['copy'].'</a> </p> </div> </div>'; break; case 'objectives_intro' : $obj_copy = get_stock_copy( $field['field_id'] ); $field['copy'] == $obj_copy ? $knowledge = 'checked' : $knowledge = ''; $field['copy'] == str_replace('knowledge', 'application', $obj_copy ) ? $application = 'checked' : $application = ''; $application == '' && $knowledge == '' ? $custom = 'checked' : $custom = ''; echo ' <div class="hidden"> <span id="knowledge-copy">'.$obj_copy.'</span> <span id="application-copy">'.str_replace('knowledge', 'application', $obj_copy ).'</span> </div> <div class="col-lg-8"> <div class="form-group"> <div class="radio-inline"> <label> <input type="radio" name="objectives_intro" id="knowledge" value="knowledge" '.$knowledge.'> Knowledge based </label> </div> <div class="radio-inline"> <label> <input type="radio" name="objectives_intro" id="application" value="application" '.$application.'> Application based </label> </div> <div class="radio-inline"> <label> <input type="radio" name="objectives_intro" id="custom" value="custom" '.$custom.'> Custom </label> </div> </div> </div> <div class="col-lg-8"> <div class="form-group" id="objectives_intro"> <input id="input-'.$field['field_id'].'" class="form-control input-sm" type="text" name="form['.$field['field_id'].'][copy]" value="'.$field['copy'].'"> </div> </div> '; break; } echo ' </div>'; } } */ echo '<hr>'; echo $submit; echo '</form>'; }