public function __construct() { parent::__construct('delete_interest', 'Delete Interest', 'Admin/delete_interest.php'); if ($this->loginError) { return; } $form = new HTML_QuickForm('deleter'); $interest_list = new pdAuthInterests($this->db); $form->addElement('select', 'interests', 'Select interest(s) to delete:', $interest_list->list, array('multiple' => 'multiple', 'size' => 15)); $form->addGroup(array(HTML_QuickForm::createElement('button', 'cancel', 'Cancel', array('onclick' => 'history.back()')), HTML_QuickForm::createElement('submit', 'submit', 'Delete')), null, null, ' ', false); if ($form->validate()) { $values = $form->exportValues(); foreach ($values['interests'] as $interest_id) { $names[] = $interest_list->list[$interest_id]; } $interest_list->dbDelete($this->db, $values['interests']); echo 'You have successfully removed the following interest from the ', 'database: <br/><b>', implode(', ', $names), '</b></p>', '<br><a href="', $_SERVER['PHP_SELF'], '">Delete another interest</a>'; } else { $renderer =& $form->defaultRenderer(); $form->accept($renderer); $this->form =& $form; $this->renderer =& $renderer; echo '<h3>Delete Interest </h3>'; } }
public function __construct() { parent::__construct('add_author'); $this->loadHttpVars(); $this->use_mootools = true; $this->all_interests = pdAuthInterests::createList($this->db); // before showing a loggin error, show the correct title for the page if (isset($_SESSION['state']) && $_SESSION['state'] == 'pub_add') { $pub =& $_SESSION['pub']; if (isset($pub->pub_id)) { $this->page_title = 'Edit Publication'; } else { $this->page_title = 'Add Publication'; } } else { if ($this->author_id == null) { $this->page_title = 'Add Author'; } else { $this->page_title = 'Edit Author'; } } if ($this->loginError) { return; } $author = new pdAuthor(); if ($this->author_id != null) { $result = $author->dbLoad($this->db, $this->author_id, pdAuthor::DB_LOAD_BASIC | pdAuthor::DB_LOAD_INTERESTS); if (!$result) { $this->pageError = true; return; } } $form = new HTML_QuickForm('authorForm'); $form->addElement('hidden', 'author_id', $this->author_id); if ($this->author_id == null) { $form->addElement('header', 'add_author_hdr', '<span class="Tips1" title="Adding an Author::Input the author\'s first name, last name, email address and organization. Optionally, interests may be selected from the list given or new interest can be added to the database. <p/> Multiple interests can be selected by holding down the control key and then left-clicking on the text. If you do not see the appropriate interests you can add them using the <b>Add Interest</b> link. <p/> Clicking the <b>Add Interest</b> link will bring up a new field each it is pressed. Type the text of the new interest into the this field.">Add Author</span>'); } else { $form->addElement('header', null, 'Edit Author'); } $form->addElement('text', 'firstname', 'First Name:', array('size' => 50, 'maxlength' => 250)); $form->registerRule('invalid_punct', 'regex', '/^[^()\\/\\*\\^\\?#!@$%+=,\\"\'><~\\[\\]{}]+$/'); $form->addRule('firstname', 'the first name cannot contain punctuation', 'invalid_punct', null, 'client'); $form->addElement('text', 'lastname', 'Last Name:', array('size' => 50, 'maxlength' => 250)); $form->addElement('select', 'authors_in_db', null, pdAuthorList::create($this->db), array('style' => 'overflow: hidden; visibility: hidden; width: 1px; height: 0;')); $tooltip = 'Title::The author\'s formal title. For example: <ul> <li>Professor</li> <li>PostDoc</li> <li>PhD Student</li> <li>MSc Student</li> <li>Colleague</li> </ul>'; $form->addElement('text', 'title', "<span class=\"Tips1\" title=\"{$tooltip}\">Title:</span>", array('size' => 50, 'maxlength' => 250)); $form->addElement('text', 'email', 'email:', array('size' => 50, 'maxlength' => 250)); $form->addRule('email', 'invalid email address', 'email', null, 'client'); $form->addElement('text', 'organization', 'Organization:', array('size' => 50, 'maxlength' => 250)); $form->addElement('text', 'webpage', 'Webpage:', array('size' => 50, 'maxlength' => 250)); $ref = '<br/><div class="small"><a href="javascript:dataKeep(' . ($this->numNewInterests + 1) . ')">[Add Interest]</a></div>'; $ams = $form->addElement('advmultiselect', 'interests', null, $this->all_interests, array('size' => 15, 'class' => 'pool', 'style' => 'width:200px;')); $ams->setLabel(array('Interests:' . $ref, 'Available', 'Selected')); $ams->setButtonAttributes('add', array('value' => 'Add >>', 'class' => 'inputCommand')); $ams->setButtonAttributes('remove', array('value' => '<< Remove', 'class' => 'inputCommand')); $template = <<<TEMPLATE_END {javascript} <table{class}> <thead> <tr> <!-- BEGIN label_2 --><tr><th align="center">{label_2}</th><!-- END label_2 --> <!-- BEGIN label_3 --><th align="center">{label_3}</th><!-- END label_3 --> <tr> </thead> <tr> <td>{unselected}</td> <td>{selected}</td> </tr> <tr> <td>{add}</td> <td>{remove}</td> </tr> </table> TEMPLATE_END; $ams->setElementTemplate($template); if (isset($_SESSION['state']) && $_SESSION['state'] == 'pub_add') { $form->addElement('static', null, null, '<span class="small">When done adding new authors press the "Next Step" button</span>'); } for ($i = 0; $i < $this->numNewInterests; $i++) { $form->addElement('text', 'newInterests[' . $i . ']', 'Interest Name ' . ($i + 1) . ':', array('size' => 50, 'maxlength' => 250)); } if (isset($_SESSION['state']) && $_SESSION['state'] == 'pub_add') { $pos = strpos($_SERVER['PHP_SELF'], 'papersdb'); $next_page = substr($_SERVER['PHP_SELF'], 0, $pos) . 'papersdb/Admin/add_pub2.php'; $url = substr($_SERVER['PHP_SELF'], 0, $pos) . 'papersdb'; $buttons[] = HTML_QuickForm::createElement('button', 'prev_step', '<< Previous Step', array('onClick' => "location.href='" . $next_page . "';")); $buttons[] = HTML_QuickForm::createElement('button', 'cancel', 'Cancel', array('onclick' => "cancelConfirm();")); $buttons[] = HTML_QuickForm::createElement('reset', 'reset', 'Reset'); $buttons[] = HTML_QuickForm::createElement('submit', 'add_another', 'Submit and Add Another Author'); $buttons[] = HTML_QuickForm::createElement('submit', 'next_step', 'Next Step >>'); if ($pub->pub_id != '') { $buttons[] = HTML_QuickForm::createElement('submit', 'finish', 'Finish'); } $form->addGroup($buttons, 'buttons', '', ' ', false); add_pub_base::addPubDisableMenuItems(); } else { $form->addRule('firstname', 'a first name is required', 'required', null, 'client'); $form->addRule('lastname', 'a last name is required', 'required', null, 'client'); if ($this->author_id == null) { $button_label = 'Add Author'; } else { $button_label = 'Submit'; } $form->addGroup(array(HTML_QuickForm::createElement('reset', 'reset', 'Reset'), HTML_QuickForm::createElement('submit', 'submit', $button_label)), null, null, ' '); } $form->addElement('hidden', 'numNewInterests', $this->numNewInterests); $this->form =& $form; if ($form->validate()) { $this->processForm(); } else { $this->renderForm($author); } }
<?php /** * Script that reports statistics for thepublications made by AICML PIs, PDFs, * students and staff. * * @package PapersDB */ /** Requries the base class and classes to access the database. */ require_once '../includes/functions.php'; require_once '../includes/pdDb.php'; require_once '../includes/pdAuthor.php'; require_once '../includes/pdAuthInterests.php'; require_once '../includes/pdAuthorList.php'; $db = new pdDb(array('name' => 'pubDB')); $all_interests = pdAuthInterests::createList($db); $numeric_interests = array(); foreach ($all_interests as $k => $i) { if (is_numeric($i)) { $numeric_interests[$k] = $i; } } if (count($numeric_interests) == 0) { exit(0); } //pdDb::debugOn(); //debugVar('n', $numeric_interests); $q = $db->select(array('author', 'author_interest', 'interest'), array('author.author_id', 'interest.interest_id', 'interest.interest'), array('interest.interest_id' => array_keys($numeric_interests), 'interest.interest_id=author_interest.interest_id', 'author.author_id=author_interest.author_id')); $authors = array(); $author_info_list = array(); foreach ($q as $r) {
public function dbSaveInterests(&$db) { if (isset($this->author_id)) { $db->delete('author_interest', array('author_id' => $this->author_id), 'pdAuthor::dbSaveInterests'); } if (count($this->interests) > 0) { $db_interests = pdAuthInterests::createList($db); // only add interests not in the database $arr = array(); foreach ($this->interests as $k => $i) { if (empty($i)) { unset($this->interests[$k]); continue; } if (!in_array($i, $db_interests)) { array_push($arr, array('interest_id' => 'NULL', 'interest' => $i)); } } if (count($arr) > 0) { $db->insert('interest', $arr, 'pdAuthor::dbSave'); } } // link the interest to this author $arr = array(); if (isset($this->interests)) { foreach ($this->interests as $key => $i) { $q = $db->selectRow('interest', 'interest_id', array('interest' => $i), 'pdAuthor::dbSaveInterests'); assert('($q !== false)'); array_push($arr, array('author_id' => $this->author_id, 'interest_id' => $q->interest_id)); $this->interests[$q->interest_id] = $i; unset($this->interests[$key]); } } if (count($arr) > 0) { $db->insert('author_interest', $arr, 'pdAuthor::dbSaveInterests'); } }