/**
  * Constructor
  * 
  * init superclass, create navigation
  */
 function PageAdminPanel()
 {
     // MANDATORY SECURITY CHECK IN CONSTRUCTOR OF EACH PAGE
     $rightsManager = RightsManager::getSingleton();
     if (!$rightsManager->currentUserIsAllowedTo('administrate')) {
         ErrorHandler::getSingleton()->standardError('PERMISSION_DENIED', basename($_SERVER['SCRIPT_NAME']));
     }
     $this->Page('Admin Panel');
     $this->nav = new Navigation('admin-menu');
     $this->nav->addEntry('return', 'return', Navigation::mainPageUrl());
 }
 /**
  * Constructor: ONLY TO BE CALLED like this: Page::newPage(classname,$id,$add) factory method!! 
  * 
  * @param $idOrContact integer|Contact the id of the contact, or the contact that is to be edited
  * @param $add boolean whether the contact is to be added or not (cannot be detected through {@link $id}, because a contact can be passed if an error occurs to preserve already inserted information)
  * @param $xsltProcessing boolean allows to deactivate XSLT processing if FALSE. default: TRUE
  * @global Options admin options
  */
 function PageContactEdit($idOrContact, $add = false, $enableXSLTProcessing = TRUE)
 {
     global $options;
     $this->counters = array();
     $this->add = $add;
     $this->enableXSLTProcessing = $enableXSLTProcessing;
     if ($idOrContact === null) {
         $this->contact = Contact::newContact();
         $this->add = TRUE;
     } elseif (is_numeric($idOrContact)) {
         $this->contact = Contact::newContact($idOrContact);
     } else {
         $this->contact =& $idOrContact;
     }
     // MANDATORY SECURITY CHECK IN CONSTRUCTOR OF EACH PAGE
     $rightsManager = RightsManager::getSingleton();
     if ($add) {
         if (!$rightsManager->currentUserIsAllowedTo('create')) {
             ErrorHandler::getSingleton()->standardError('PERMISSION_DENIED', basename($_SERVER['SCRIPT_NAME']));
         }
         $this->Page('Add new entry');
     } else {
         if (!$rightsManager->currentUserIsAllowedTo('edit', $this->contact)) {
             ErrorHandler::getSingleton()->standardError('PERMISSION_DENIED', basename($_SERVER['SCRIPT_NAME']));
         }
         $this->Page($this->contact->contact['firstname'] . ' ' . $this->contact->contact['lastname']);
     }
     $this->menu = new Navigation('edit-menu');
     // disable save when XSLT will be processed. XSLT files MUST provide their own save button.
     if (!($this->enableXSLTProcessing && !empty($this->contact->contact['xsltDisplayType']))) {
         $this->menu->addEntry('save', 'save', 'javascript:saveEntry();');
     }
     if (isset($this->contact->contact['id'])) {
         $this->menu->addEntry('cancel', 'cancel', '?id=' . $this->contact->contact['id']);
     } else {
         $this->menu->addEntry('cancel', 'cancel', Navigation::previousPageUrl());
     }
     if (!$this->add) {
         $rightsManager = RightsManager::getSingleton();
         if ($rightsManager->mayDeleteContact($this->contact)) {
             $this->menu->addEntry('delete', 'delete', 'javascript:deleteEntry(' . $this->contact->contact['id'] . ');');
             if ($_SESSION['user']->isAtLeast('admin') && $options->getOption('deleteTrashMode')) {
                 $this->menu->addEntry('trash', 'trash', '?mode=trash&id=' . $this->contact->contact['id']);
             }
         }
     }
     if ($_SESSION['user']->isAtLeast('admin')) {
         // no putting on changed list
         $this->menu->addEntry('adminsave', '[adminsave]', 'javascript:adminsaveEntry();');
     }
 }