/**
  * Constructor
  * 
  * init superclass, create navigation, init {@link $user}
  */
 function PageOptions($user)
 {
     $this->Page('Options');
     $this->nav = new Navigation('options-menu');
     $this->nav->addEntry('return', 'return', Navigation::previousPageUrl());
     $this->user = $user;
 }
 /**
  * Constructor: ONLY TO BE CALLED by factory method of Page::newPage(...)! 
  *
  * init {@link $contactList}, and menu
  * @param string $search part of a searchtype (e.g. name or email)
  * @param string $searchtype [name|email|www|chat|phone|custom_?] Custom searches defined in config.php, shared with autocomplete.
  * @param boolean $expand whether to expand entries or not
  * @param integer $maxEntriesPerPage limit of entries (default = 0 which means unlimited) 
  */
 function PageSearchList($search, $searchtype, $expand = false, $maxEntriesPerPage = 0)
 {
     $this->Page('Search List');
     $this->search = $search;
     $this->searchtype = $searchtype;
     $this->expand = $expand;
     $this->nav = new Navigation('options-menu');
     $this->nav->addEntry('expand', 'expand', '../contact/searchlist.php?search=' . $search . '&type=' . $searchtype . '&expand=1');
     $this->nav->addEntry('return', 'return', Navigation::previousPageUrl());
     $sql = $this->createQuery();
     $this->contactList = new ContactList($sql);
     $this->contactList->setEntriesPerPage($maxEntriesPerPage);
 }
 /**
  * creates list of contacts, or a no entries found page
  * @return string html-content
  */
 function innerCreate()
 {
     $cont = '<div class="search-result">';
     $cont .= '<div class="search-title">Search results</div>';
     $conts = $this->contactList->getContacts();
     if (count($conts) <= 0) {
         $cont .= '<div class="search-text">No entries found</div>';
     } else {
         $cont .= '<div class="search-text">Multiple entries found. Please select one</div>';
         $cont .= '<ul class="search-contacts">';
         foreach ($conts as $c) {
             $cont .= '<li><a href="../contact/contact.php?id=' . $c->contact['id'] . '">' . $c->contact['lastname'] . ', ' . $c->contact['firstname'] . '</a></li>';
         }
         $cont .= '</ul>';
     }
     $cont .= '<div class="search-text"><a href="' . Navigation::previousPageUrl() . '">return</a></div>';
     $cont .= '</div>';
     return $cont;
 }
 /**
  * create the menu of the contact-card
  */
 function createMenu()
 {
     // Create Menue
     $this->cardMenu = new Navigation('card-menu');
     $this->cardMenu->addEntry("return", "return", Navigation::previousPageUrl());
     $rightsManager = RightsManager::getSingleton();
     if ($rightsManager->currentUserIsAllowedTo('edit', $this->contact)) {
         $this->cardMenu->addEntry("edit", "edit", "../contact/contact.php?mode=edit&amp;id={$this->contact->contact['id']}");
     }
     $this->cardMenu->addEntry("print", "print", "javascript:window.print()");
     if ($_SESSION['user']->isAtLeast('user')) {
         $this->cardMenu->addEntry("incorrect", "incorrect", "javascript:reportIncorrectEntry({$this->contact->contact['id']},'Are you sure you want to report this entry as incorrect? This will automatically generate an email to the person who last edited the contact.')");
     }
     if ($_SESSION['user']->isAtLeast('admin') && !$this->contact->isUser()) {
         if (!empty($this->contact->contact['xsltDisplayType']) && $this->noXSLT == FALSE) {
             $this->cardMenu->addEntry('alt-view', '[change view]', "../contact/contact.php?noxslt=1&amp;id={$this->contact->contact['id']}");
         }
         $this->cardMenu->addEntry('cuser', '[create user]', "../user/register.php?mode=cuser&amp;id={$this->contact->contact['id']}");
     }
 }
 function PageCA($mode, $data, $real = false)
 {
     $this->Page('Certificate Authority');
     $this->menu = new Navigation('wide-menu');
     $this->menu->addEntry('return', 'return', Navigation::previousPageUrl());
     $this->menu->addEntry('usage-track', 'usage-track', 'gencerts.php?mode=utrack');
     $this->menu->addEntry('usage-list', 'usage-list', 'gencerts.php?mode=expired-list');
     //$this->menu->addEntry('added','added','gencerts.php?mode=added');
     //$this->menu->addEntry('deleted','deleted','gencerts.php?mode=deleted');
     //$this->menu->addEntry('expired','expired','gencerts.php?mode=expired');
     $this->menu->addEntry('imported', 'imported', 'gencerts.php?mode=imported');
     $this->menu->addEntry('crl', 'crl', 'gencerts.php?mode=crl');
     $this->menu->addEntry('relist', 'relist', 'gencerts.php?mode=relist');
     $this->menu->addEntry('pwlist', 'pwlist', 'pwlist.php?mode=pwlist');
     $this->menu->addEntry('stats', 'stats', 'gencerts.php?mode=stats');
     $this->menu->addEntry('default', 'default', 'gencerts.php');
     $this->mode = $mode;
     $this->data = $data;
     $this->real = $real;
 }
 /**
  * create the content of recently changed
  * @return string html-content
  * @global Options determine how many days after change the contact should still be shown
  * @param boolean $compact whether list should be displayed with imported link and user who changed contact
  */
 function innerCreate()
 {
     global $db, $CONFIG_DB_PREFIX, $CONFIG_ADMIN_REQUEST_INTERFACE, $CONFIG_ADMIN_REQUEST_BREAKS;
     $db->query("SELECT * FROM `{$CONFIG_DB_PREFIX}AdministrativeRequests` AS request WHERE dateProcessed IS NULL OR ( DATE_ADD(dateProcessed, INTERVAL 14 DAY) >= NOW() )", 'AdministrativeRequest');
     //. TABLE_PROPERTIES . " AS prop
     //WHERE contact.id=prop.id AND prop.label=" . $db->escape($this->featureLabel) . '
     //ORDER BY prop.value ' . ($this->ascending ? 'ASC' : 'DESC') . ($this->limit > 0 ? ' LIMIT '.$this->limit : ''));
     $fields = array('contactId', 'dateAdded', 'requesterId', 'dateProcessed', 'whoProcessedId');
     foreach ($CONFIG_ADMIN_REQUEST_INTERFACE as $k => $v) {
         if (substr($k, 0, 4) != 'html' && $k != 'submit') {
             // not for DB!
             $fields[] = $k;
         }
     }
     $data = array();
     $i = 0;
     while ($c = $db->next('AdministrativeRequest')) {
         $data[$i] = $c;
         if (empty($data[$i]['dateProcessed'])) {
             $id = $data[$i]['requestId'];
             $data[$i]['dateProcessed'] = "<a href='todo?mode=done&id={$id}'>set done</a>";
         }
         if (!empty($data[$i]['whoProcessedId'])) {
             $contact = Contact::newContact($data[$i]['whoProcessedId']);
             $data[$i]['whoProcessedId'] = '<a href="../contact/contact.php?id=' . $contact->contact['id'] . '">' . $contact->contact['lastname'] . (!empty($contact->contact['firstname']) ? ', ' . $contact->contact['firstname'] : '') . '</a>';
         }
         $contact = Contact::newContact($data[$i]['contactId']);
         $data[$i]['contactId'] = '<a href="../contact/contact.php?id=' . $contact->contact['id'] . '">' . $contact->contact['lastname'] . (!empty($contact->contact['firstname']) ? ', ' . $contact->contact['firstname'] : '') . '</a>';
         $contact = Contact::newContact($data[$i]['requesterId']);
         $data[$i]['requesterId'] = '<a href="../contact/contact.php?id=' . $contact->contact['id'] . '">' . $contact->contact['lastname'] . (!empty($contact->contact['firstname']) ? ', ' . $contact->contact['firstname'] : '') . '</a>';
         $i++;
     }
     $cont = '<style>.parr-list { margin: 20px auto 20px auto; width: 90%; } .parr-list th { border: 1px solid; } .parr-list td { border: 1px solid  #AAA; } td.parr-list-tdblank { border: none; } </style>';
     $tGen = new TableGenerator('parr-list', $fields, $CONFIG_ADMIN_REQUEST_BREAKS);
     $cont .= $tGen->generateTable($data, $fields);
     $cont .= '<div><a href="' . Navigation::previousPageUrl() . '">return</a></div><br>';
     return $cont;
 }
 /**
  * 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&amp;id=' . $this->contact->contact['id']);
             }
         }
     }
     if ($_SESSION['user']->isAtLeast('admin')) {
         // no putting on changed list
         $this->menu->addEntry('adminsave', '[adminsave]', 'javascript:adminsaveEntry();');
     }
 }
 /**
  * create the content of recently changed
  * @return string html-content
  * @param boolean $compact whether list should be displayed with imported link and user who changed contact
  * @global Options determine how many days after change the contact should still be shown
  * @global CONFIG_LIST_NAME_SPEC
  */
 function innerCreate()
 {
     global $options, $CONFIG_CHANGEDLIST_NAME_SPEC;
     $contacts = $this->contactList->getContacts();
     $data = array();
     foreach ($contacts as $c) {
         $who = new User(intval($c->contact['whoModified']));
         if (!isset($CONFIG_CHANGEDLIST_NAME_SPEC)) {
             $spec = null;
         } else {
             $spec = $CONFIG_CHANGEDLIST_NAME_SPEC;
         }
         $data[] = array('display_name' => $c->generateFullName('html', $spec), 'chdate' => date('F j', strtotime($c->contact['lastUpdate'])), 'change' => $c->contact['lastModification'], 'reset' => '<a href="../admin/saveadmin.php?id=' . $c->contact['id'] . '&amp;mode=imported">imported</a>', 'who' => isset($who->contact['id']) ? '<a href="../contact/contact.php?id=' . $who->contact['id'] . '">' . $who->contact['lastname'] . (!empty($who->contact['firstname']) ? ', ' . $who->contact['firstname'] : '') . '</a>' : 'null');
     }
     $tGen = new TableGenerator('changed-list');
     $cont = '<table class="changed-list">';
     $cont .= '<caption>Recently changed (past ' . $options->getOption('bdayInterval') . ' days)';
     if (!$this->expanded) {
         $cont .= '&nbsp;<a href="../contact/changedlist.php">expand</a>';
     }
     $cont .= '</caption>';
     if (count($data) > 0) {
         if ($_SESSION['user']->isAtLeast('admin') && $this->expanded) {
             $cont .= $tGen->generateBody($data, array('display_name', 'chdate', 'change', 'reset', 'who'));
         } else {
             $cont .= $tGen->generateBody($data, array('display_name', 'chdate', 'change'));
         }
     } else {
         $cont .= '<tr class="noentry"><td>Nothing changed</td></tr>';
     }
     $cont .= '</table>';
     if ($this->expanded) {
         $cont .= '<div><a href="' . Navigation::previousPageUrl() . '">return</a></div><br>';
     }
     return HTMLHelper::createNestedDivBoxModel('changed-list', $cont);
 }
 /**
  * Constructor
  */
 function PageImport()
 {
     $this->Page('Import');
     $this->nav = new Navigation('admin-menu');
     $this->nav->addEntry('return', 'return', Navigation::previousPageUrl());
 }