예제 #1
0
 /**
  * Constructor for base class.
  *
  * @param string $page_id
  * @param string $title
  * @param string $relative_url
  * @param constant $login_level see pdNavMenuItem.
  * @param boolean $useStdLayout
  */
 public function __construct($page_id, $title = null, $relative_url = null, $login_level = pdNavMenuItem::MENU_NEVER, $useStdLayout = true)
 {
     if (MAINTENANCE == 1) {
         echo 'PapersDB is under maintenance, please check back later';
         exit;
     }
     session_start();
     // start buffering output, it will be displayed in the toHtml() method
     ob_start();
     // initialize session variables
     if (get_class($this) != 'add_pub1' && get_class($this) != 'add_pub2' && get_class($this) != 'add_pub3' && get_class($this) != 'add_pub4' && get_class($this) != 'add_pub_submit' && get_class($this) != 'add_author' && get_class($this) != 'author_confirm' && get_class($this) != 'add_venue') {
         pubSessionInit();
     }
     // a derived page may already have needed access to the database prior
     // to invoking the base class constructor, so only create the database
     // object if not already set
     if (!is_object($this->db)) {
         $this->db = pdDb::defaultNew();
     }
     $this->check_login();
     $this->nav_menu = new pdNavMenu($this->access_level, $page_id);
     if (isset($page_id)) {
         $nav_item = $this->nav_menu->findPageId($page_id);
         if ($nav_item != null) {
             $this->page_id = $page_id;
             $this->page_title = $nav_item->page_title;
             $this->relative_url = $nav_item->url;
             $this->login_level = $nav_item->access_level;
         }
     }
     if (!isset($page_id) || $nav_item == null) {
         $this->page_title = $title;
         $this->relative_url = relativeUrlGet();
         $this->login_level = $login_level;
     }
     if ($relative_url != null) {
         $this->relative_url = $relative_url;
     }
     $this->redirectTimeout = 0;
     $this->table = null;
     $this->form = null;
     $this->renderer = null;
     $this->loginError = false;
     $this->pageError = false;
     $this->useStdLayout = $useStdLayout;
     $this->hasHelpTooltips = false;
     // ensure that the user is logged in if a page requires login access
     if (($this->login_level >= pdNavMenuItem::MENU_LOGIN_REQUIRED || strpos($this->relative_url, 'Admin/') !== false || strpos($this->relative_url, 'diag/') !== false) && $this->access_level < 1) {
         $this->loginError = true;
         return;
     }
 }
예제 #2
0
    $n = count($args);
    if ($n != 4 && $n != 5) {
        echo 'skipping line: ', $key, " only ", $n, " arguments\n";
        continue;
    }
    $firstname = trim($args[1]);
    $info[$key] = array('fullname' => trim($args[0]) . ', ' . $firstname, 'shortname' => trim($args[0]) . ', ' . $firstname[0], 'position' => trim($args[2]), 'start_date' => trim($args[3]));
    if (isset($args[4])) {
        $info[$key]['end_date'] = trim($args[4]);
    }
}
if (count($info) == 0) {
    exit('no data to update database with');
}
//pdDb::debugOn();
$db = pdDb::newFromParams();
$positions =& getAicmlPositions($db);
$staff = array();
foreach ($info as $key => $p) {
    $author_id = getAuthorId($db, $p['fullname']);
    if ($author_id < 0) {
        $author_id = getAuthorId($db, $p['shortname']);
        if ($author_id < 0) {
            // author information will not be added to database
            echo "author ", $p['fullname'], " not in database\n";
            continue;
        }
    }
    // make sure the position matches the one in the database
    if (!in_array($p['position'], array_keys($positions))) {
        if ($p['position'] == 'PI') {
예제 #3
0
파일: pdDb.php 프로젝트: papersdb/papersdb
 public static function debugOn()
 {
     self::$_debug = true;
 }
예제 #4
0
 /**
  * Performs and advanced search.
  */
 private function advancedSearch()
 {
     // VENUE SEARCH ------------------------------------------
     if ($this->sp->venue != '') {
         $parser = new SearchTermParser($this->sp->venue);
         $the_search_array = $parser->getWordList();
         foreach ($the_search_array as $and_terms) {
             $union_array = array();
             foreach ($and_terms as $or_term) {
                 $this->venuesSearch('title', $or_term, $union_array);
                 $this->venuesSearch('name', $or_term, $union_array);
             }
             $this->result_pubs = array_intersect($this->result_pubs, $union_array);
         }
     }
     // CATEGORY SEARCH ----------------------------------------------------
     //
     // if category search found, pass on only the ids found with that match
     // with category
     if ($this->sp->cat_id != '') {
         $temporary_array = NULL;
         $cat_id = $this->sp->cat_id;
         $search_query = "SELECT DISTINCT pub_id FROM pub_cat WHERE cat_id=" . $this->db->quote_smart($cat_id);
         //we then add these matching id's to a temp array
         $this->add_to_array($search_query, $temporary_array);
         //then we only keep the common ids between both arrays
         $this->result_pubs = array_intersect($this->result_pubs, $temporary_array);
     }
     // PUBLICATION FIELDS SEARCH ------------------------------------------
     $fields = array("title", "paper", "abstract", "keywords", "extra_info");
     //same thing happening as category, just with each of these fields
     foreach ($fields as $field) {
         if (isset($this->sp->{$field}) && $this->sp->{$field} != '') {
             $parser = new SearchTermParser($this->sp->{$field});
             $the_search_array = $parser->getWordList();
             foreach ($the_search_array as $and_terms) {
                 $union_array = null;
                 foreach ($and_terms as $or_term) {
                     $this->add_to_array('SELECT DISTINCT pub_id from publication WHERE ' . $field . ' LIKE ' . $this->db->quote_smart('%' . $or_term . '%'), $union_array);
                 }
                 $this->result_pubs = array_intersect($this->result_pubs, $union_array);
             }
         }
     }
     // MYSELF or AUTHOR SELECTED SEARCH -----------------------------------
     $authors = array();
     if (!empty($this->sp->authors)) {
         // need to retrieve author_ids for the selected authors
         $sel_author_names = explode(', ', preg_replace('/\\s\\s+/', ' ', $this->sp->authors));
         $author_ids = array();
         foreach ($sel_author_names as $author_name) {
             if (empty($author_name)) {
                 continue;
             }
             $author_id = array_search($author_name, $this->db_authors);
             if ($author_id !== false) {
                 $author_ids[] = $author_id;
             }
         }
         if (count($author_ids) > 0) {
             $authors = array_merge($authors, $author_ids);
         }
     }
     if (!empty($_SESSION['user'])) {
         if ($this->sp->author_myself != '' && $_SESSION['user']->author_id != '') {
             array_push($authors, $_SESSION['user']->author_id);
         }
     }
     if (count($authors) > 0) {
         foreach ($authors as $auth_id) {
             $author_pubs = array();
             $search_query = "SELECT DISTINCT pub_id from pub_author " . "WHERE author_id=" . $this->db->quote_smart($auth_id);
             $this->add_to_array($search_query, $author_pubs);
             $this->result_pubs = array_intersect($this->result_pubs, $author_pubs);
         }
     }
     // ranking
     if (isset($this->sp->paper_rank)) {
         $union_array = array();
         foreach ($this->sp->paper_rank as $rank_id => $value) {
             if ($value != 'yes') {
                 continue;
             }
             $search_result = $this->db->query('SELECT venue_id from venue_rankings ' . 'WHERE rank_id=' . $this->db->quote_smart($rank_id));
             foreach ($search_result as $row) {
                 if (!empty($row->venue_id)) {
                     $this->add_to_array('SELECT DISTINCT pub_id from publication ' . 'WHERE venue_id=' . $this->db->quote_smart($row->venue_id), $union_array);
                 }
             }
         }
         foreach ($this->sp->paper_rank as $rank_id => $value) {
             if ($value != 'yes') {
                 continue;
             }
             $this->add_to_array('SELECT DISTINCT pub_id from publication ' . 'WHERE rank_id=' . $this->db->quote_smart($rank_id), $union_array);
         }
     }
     if (!empty($this->sp->paper_rank_other)) {
         $this->add_to_array('SELECT DISTINCT pub_id from pub_rankings ' . 'WHERE description LIKE ' . $this->db->quote_smart("%" . $this->sp->paper_rank_other . "%"), $union_array);
     }
     if (isset($union_array) && is_array($union_array) && count($union_array) > 0) {
         $this->result_pubs = array_intersect($this->result_pubs, $union_array);
     }
     // collaboration
     if (isset($this->sp->paper_col)) {
         $union_array = array();
         foreach ($this->sp->paper_col as $col_id => $value) {
             if ($value != 'yes') {
                 continue;
             }
             $this->add_to_array('SELECT DISTINCT pub_id from pub_col ' . 'WHERE col_id=' . $this->db->quote_smart($col_id), $union_array);
         }
         if (count($union_array) > 0) {
             $this->result_pubs = array_intersect($this->result_pubs, $union_array);
         }
     }
     // user info
     if (!empty($this->sp->user_info)) {
         pdDb::debugOn();
         $union_array = array();
         $user_infos = preg_split('/\\s*[;,]\\s*/', $this->sp->user_info);
         foreach ($user_infos as $user_info) {
             $user_info = trim($user_info);
             $this->add_to_array('SELECT DISTINCT pub_id from publication ' . "WHERE user like '%{$user_info}%'", $union_array);
         }
         if (count($union_array) > 0) {
             $this->result_pubs = array_intersect($this->result_pubs, $union_array);
         }
     }
     // DATES SEARCH --------------------------------------
     // adjust date information if user did not enter all the fields
     if (isset($this->sp->startdate['Y']) && !isset($this->sp->startdate['M'])) {
         $this->sp->startdate['M'] = '1';
     }
     if (isset($this->sp->enddate['Y']) && !isset($this->sp->enddate['M'])) {
         $this->sp->enddate['M'] = '12';
     }
     if (isset($this->sp->startdate)) {
         $startdate =& $this->sp->startdate;
         $stime = strtotime(implode('-', $startdate) . '-1');
     }
     if (isset($this->sp->enddate)) {
         $enddate =& $this->sp->enddate;
         $etime = strtotime(implode('-', $enddate) . '-1');
     }
     if (isset($stime) && isset($etime)) {
         if ($stime > $etime) {
             // the user did not enter an end date, default it to now
             $enddate['Y'] = date('Y');
             $enddate['M'] = date('m');
             $etime = strtotime(implode('-', $enddate) . '-1');
         }
         if ($etime > $stime) {
             $startdate_str = date('Y-m-d', mktime(0, 0, 0, $startdate['M'], 1, $startdate['Y']));
             $enddate_str = date('Y-m-d', mktime(0, 0, 0, $enddate['M'] + 1, 0, $enddate['Y']));
             $temporary_array = NULL;
             $search_query = "SELECT DISTINCT pub_id from publication " . "WHERE published BETWEEN " . $this->db->quote_smart($startdate_str) . " AND " . $this->db->quote_smart($enddate_str);
             $this->add_to_array($search_query, $temporary_array);
             $this->result_pubs = array_intersect($this->result_pubs, $temporary_array);
         }
     }
     if ($this->debug) {
         debugVar('result', $this->result_pubs);
     }
     return $this->result_pubs;
 }
예제 #5
0
<?php

/**
 * This script is meant to be called in response to an AJAX request.
 * 
 * It returns a listing of all the publication by a specified author. The
 * author is specified in the URL query string.
 */
require_once '../includes/defines.php';
require_once 'includes/functions.php';
require_once 'includes/htmlUtils.php';
require_once 'includes/pdDb.php';
require_once 'includes/pdAuthor.php';
if (!isset($_GET['author_id'])) {
    exit('script called with invalid arguments');
}
$db = pdDb::defaultNew();
$auth = new pdAuthor();
$auth->dbLoad($db, $_GET['author_id'], pdAuthor::DB_LOAD_PUBS_ALL | pdAuthor::DB_LOAD_INTERESTS);
if (!is_array($auth->pub_list)) {
    exit('Author with id ' . $_GET['author_id'] . ' does not have any publication entries in the database');
}
echo displayPubList($db, $auth->pub_list);