function manage_scribd_docs() { echo '<div class="wrap"><h2>Manage Scribd Documents'; insert_help('explain_scribd'); echo '</h2>'; //Form to Upload new doc to Scribd ?> <style> th.label { text-align:right; } </style> <div id="message_box"> </div> <form enctype="multipart/form-data" id="new_doc" action="" method="post" class="media-upload-form type-form validate"> <input type="hidden" name="insert_new" value="1"> <div id="media-items"> <h3>Add a document to your library</h3> <table class="describe"> <tr> <th valign="top" scope="row" class="label"> <label for="datafile">Choose a file</label><span class="alignright"><abbr title="required" class="required">*</abbr></span> </th> <td class="field"> <input type="file" name="datafile" size="40" aria-required="true"> </td></tr> <!-- <tr> <th valign="top" scope="row" class="label"> <label for="doc_type">Document type</label> </th> <td class="field"> <select name="doc_type" id="doc_type"><option value="">---</option><option value="pdf">PDF</option><option value="doc">DOC</option><option value="txt">TXT</option><option value="ppt">PPT</option><option value="">Other</option></select> </td></tr>--> <tr> <th valign="top" scope="row" class="label"> </th> <td class="field"> <input type="submit" class="button" value="Upload new document"></input> </td></tr></table> </div> </form> <?php //handles submit function of form if (isset($_POST['insert_new'])) { upload_new_scribd(); } //&&&&Form to Delete doc //get current user id global $current_user; get_currentuserinfo(); require_once 'classes/scribd.php'; $scribd_api_key = get_option('scribd_api_key'); $scribd_secret = get_option('scribd_secret'); $my_user_id = $current_user->user_login; //creates sub-accounts in the Scribd account based on WP username $scribd = new Scribd($scribd_api_key, $scribd_secret); $scribd->my_user_id = $my_user_id; $current_docs = $scribd->getList(); ?> <br /><br /> <form enctype="multipart/form-data" id="delete_doc" action="" method="post" class="media-upload-form type-form validate"> <div id="media-items"> <h3>Delete a document from your library</h3> <table class="describe"> <tr> <th valign="top" scope="row" class="label"> <span class="alignleft"><label for="my_doc_id">Choose Document</label></span> </th> <td class="field"> <select name="delete_doc_id" aria-required="true"> <option value="">---</option> <?php foreach ($current_docs as $a_doc) { //echo('<input type="radio" name="my_doc_id" value="' .$a_doc[doc_id] .'?' .$a_doc[access_key] .'" aria-required="true">' .$a_doc[title].'</input><br />'); echo '<option value="' . $a_doc[doc_id] . '?' . $a_doc[access_key] . '">' . $a_doc[title] . '</option>'; } ?> </select> </td> </tr> <tr> <td> </td> <td> <input type="submit" class="button" value="Delete document from Scribd"></input> </td></tr></table> </div> </form> <?php //handles submit function of form if (isset($_POST['delete_doc_id'])) { delete_scribd(); } //&&&&Form to *update* doc //get current user id global $current_user; get_currentuserinfo(); require_once 'classes/scribd.php'; $scribd_api_key = get_option('scribd_api_key'); $scribd_secret = get_option('scribd_secret'); $my_user_id = $current_user->user_login; //creates sub-accounts in the Scribd account based on WP username $scribd = new Scribd($scribd_api_key, $scribd_secret); $scribd->my_user_id = $my_user_id; $current_docs = $scribd->getList(); ?> <br /><br /> <script type="text/javascript"> var allDocs = new Array(); var oneDoc = new Array(); <?php foreach ($current_docs as $my_doc) { $my_values = $scribd->getSettings($my_doc[doc_id]); $my_doc[title] = trim($my_doc[title]); $my_doc[description] = trim($my_doc[description]); ?> oneDoc=["<?php echo $my_doc[doc_id]; ?> "," <?php echo $my_doc[title]; ?> ","<?php echo $my_doc[description]; ?> ","<?php echo $my_values[access]; ?> "]; allDocs.push(oneDoc);<?php } ?> function updateScribdUpdate(sel){ //alert('in updateScribdUpdate'); for (i=0;i<allDocs.length;i++) { if(allDocs[i][0] == sel.options[sel.selectedIndex].value) { //alert(allDocs[i][1] + " " + allDocs[i][2]); document.getElementById('doc_title').value = allDocs[i][1]; document.getElementById('doc_description').innerHTML = allDocs[i][2]; if(allDocs[i][3]=="public"){document.getElementById('access_type').selectedIndex = 1;}; } } } </script> <form enctype="multipart/form-data" id="update_doc" action="" method="post" class="media-upload-form type-form validate"> <div id="media-items"> <h3>Update a document in your library</h3> <table class="describe"> <tr> <th valign="top" scope="row" class="label"> <label for="my_doc_id">Choose Document</label> </th> <td class="field"> <select name="update_doc_id" aria-required="true" onchange="return updateScribdUpdate(this)"> <option value="">---</option> <?php foreach ($current_docs as $a_doc) { $a_doc[title] = trim($a_doc[title]); echo '<option value="' . $a_doc[doc_id] . '">' . $a_doc[title] . '</option>'; } ?> </select> </td> </tr> <tr> <th valign="top" scope="row" class="label"> <label for="doc_title">New document title</label> </th> <td class="field"> <input type="text" name="doc_title" id="doc_title" aria-required="true"></input> </td></tr> <tr> <th valign="top" scope="row" class="label"> <label for="doc_description">New document description</label> </th> <td class="field"> <textarea name="doc_description" id="doc_description" cols="40" rows="5" aria-required="true"></textarea> </td></tr> <tr> <th valign="top" scope="row" class="label"> <label for="access_type">Public on Scribd.com?</label> </th> <td class="field"> <select name="access_type" id="access_type" aria-required="true"> <option value="private">private</option> <option value="public">public</option> </select> </td></tr> <tr> <td> </td> <td> <input type="submit" class="button" value="Update document"></input> </td></tr></table> </div> </form> <?php //handles submit function of form if (isset($_POST['update_doc_id'])) { update_scribd(); } echo '</div>'; }
function add_custom_user_profile_fields($user) { global $wpdb; //$wpdb->flush(); $major = get_user_major(); //get_user_major($user->id); $depts = get_depts(); ?> <h3><?php _e('Student Information', 'your_textdomain'); ?> </h3> <table class="form-table"> <tr> <th> <label for="major"><?php _e('Major', 'your_textdomain'); ?> </label></th> <td> <select name="major" id="major"> <option>---</option> <?php foreach ($depts as $dept) { if ($major == $dept->id) { echo "<option value='{$dept->id}' selected='selected'>{$dept->name}</option>"; } else { echo "<option value='{$dept->id}'>{$dept->name}</option>"; } } ?> </select> <span class="description"><?php _e('Select your major.', 'your_textdomain'); insert_help('choose_major'); ?> </span> </td> </tr> </table> <?php }