示例#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
/**
 * Returns the HTML text to display the icons to link to the PDF, view,
 * edit, or delete the publication entry.
 *
 * @param object $pub pdPublication object to display the icons for.
 * @param integer $flags the icons to display. 0x1 for the PDF/PS file,
 * 0x2 for the view icon, 0x4 for the edit icon, 0x8 for the delete icon.
 * @param string $url_prefix the prefix to use for URLs.
 * @return HTML text.
 */
function getPubIcons(&$db, &$pub, $flags = 0xf, $url_prefix = NULL)
{
    $html = '';
    $access_level = pdUser::check_login($db);
    if (!isset($url_prefix)) {
        // get url_prefix from script's name
        $url_prefix = '';
        if (strstr(relativeUrlGet(), '/')) {
            $url_prefix = '../';
        }
    }
    if ($flags & 0x1 && strtolower($pub->paper) != 'no paper') {
        $html .= '<a href="' . $pub->paperAttGetUrl() . '">';
        if (preg_match("/\\.(pdf|PDF)\$/", $pub->paper)) {
            $html .= '<img src="' . $url_prefix . 'images/pdf.gif" alt="PDF" ' . 'height="18" width="17" border="0" align="top" />';
        } else {
            if (preg_match("/\\.(ppt|PPT)\$/", $pub->paper)) {
                $html .= '<img src="' . $url_prefix . 'images/ppt.gif" alt="PPT" height="18" ' . 'width="17" border="0" align="top" />';
            } else {
                if (preg_match("/\\.(ps|PS)\$/", $pub->paper)) {
                    $html .= '<img src="' . $url_prefix . 'images/ps.gif" alt="PS" height="18" ' . 'width="17" border="0" align="top" />';
                }
            }
        }
        $html .= '</a>';
    }
    if ($flags & 0x2) {
        $html .= '<a href="' . $url_prefix . 'view_publication.php?pub_id=' . $pub->pub_id . '">' . '<img src="' . $url_prefix . 'images/viewmag.gif" title="view" alt="view" ' . ' height="16" width="16" border="0" align="top" /></a>';
    }
    if ($flags & 0x4 && $access_level > 0) {
        $html .= '<a href="' . $url_prefix . 'Admin/add_pub1.php?pub_id=' . $pub->pub_id . '">' . '<img src="' . $url_prefix . 'images/pencil.gif" title="edit" alt="edit" ' . ' height="16" width="16" border="0" align="top" />' . '</a>';
    }
    if ($flags & 0x8 && $access_level > 0) {
        $html .= '<a href="' . $url_prefix . 'Admin/delete_publication.php?pub_id=' . $pub->pub_id . '">' . '<img src="' . $url_prefix . 'images/kill.gif" title="delete" alt="delete" ' . 'height="16" width="16" border="0" align="top" /></a>';
    }
    return $html;
}