Exemplo n.º 1
0
 public function __construct()
 {
     parent::__construct('aicml_staff');
     if ($this->loginError) {
         return;
     }
     echo '<h1>AICML Staff</h1>';
     $table = new HTML_Table(array('class' => 'stats'));
     $table->addRow(array('Name', 'Start', 'End', 'Num Pubs', 'Pub Ids'));
     $table->setRowType(0, 'th');
     //pdDb::debugOn();
     $staff_list = pdAicmlStaffList::create($this->db);
     foreach ($staff_list as $staff_id => $author_id) {
         $staff = pdAicmlStaff::newFromDb($this->db, $staff_id, pdAicmlStaff::DB_LOAD_PUBS_MIN);
         $author = pdAuthor::newFromDb($this->db, $author_id, pdAuthor::DB_LOAD_MIN);
         //debugVar('staff', array($staff, $author));
         $pub_links = array();
         if (isset($staff->pub_ids)) {
             foreach ($staff->pub_ids as $pub_id) {
                 $pub_links[] = '<a href="../view_publication.php?pub_id=' . $pub_id . '">' . $pub_id . '</a>';
             }
         }
         $table->addRow(array($author->name, $staff->start_date, $staff->end_date, count($staff->pub_ids), implode(', ', $pub_links)), array('class' => 'stats_odd'));
     }
     echo $table->toHtml();
 }
Exemplo n.º 2
0
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) {
    if (!isset($authors[$r->author_id])) {
        $authors[$r->author_id] = pdAuthor::newFromDb($db, $r->author_id, pdAuthor::DB_LOAD_BASIC | pdAuthor::DB_LOAD_INTERESTS);
    }
    $author_info_list[] = array('interest_id' => $r->interest_id, 'new_interest' => array($all_interests[$r->interest_id] => $all_interests[$all_interests[$r->interest_id]]), 'author' => &$authors[$r->author_id]);
}
//debugVar('$author_info_list', $author_info_list);
foreach ($author_info_list as $info) {
    $info['author']->interests = $info['author']->interests + $info['new_interest'];
    unset($info['author']->interests[$info['interest_id']]);
}
//debugVar('$authors', $authors);
foreach ($authors as $author) {
    $author->dbSave($db);
}
debugVar('$numeric_interests', $numeric_interests);
foreach ($numeric_interests as $k => $i) {
    $q = $db->select('author_interest', '*', array('interest_id' => $k));