/**
  * create the content of upcoming dates
  * @return string html-content
  * @global Options determine how many days before event should contact be shown?
  */
 function innerCreate()
 {
     global $options, $CONFIG_DATELIST_NAME_SPEC;
     $contacts = $this->contactList->getContacts();
     $dates = $this->contactList->getDates();
     $data = array();
     $time = getdate();
     if (!isset($CONFIG_DATELIST_NAME_SPEC)) {
         $spec = null;
     } else {
         $spec = $CONFIG_DATELIST_NAME_SPEC;
     }
     foreach ($contacts as $k => $c) {
         $data[] = array('display_name' => $c->generateFullName('html', $spec), 'type' => $dates[$k]['type'], 'time' => date('M j', strtotime('1975-' . $dates[$k]['month'] . '-' . $dates[$k]['day'])) . ($dates[$k]['year'] != '0000' ? ', ' . $dates[$k]['year'] : ''), 'age' => intval($time['year'] - $dates[$k]['year']) . 'y', 'daysAway' => $dates[$k]['daysAway'] > 0 ? $dates[$k]['daysAway'] . 'd' : 'today');
     }
     $tGen = new TableGenerator('changed-list');
     $cont = '<table class="changed-list">';
     $cont .= '<caption>Upcoming dates (Next ' . $options->getOption('bdayInterval') . ' days)</caption>';
     if (count($data) > 0) {
         $cont .= $tGen->generateBody($data, array('display_name', 'type', 'time', 'age', 'daysAway'));
     } else {
         $cont .= '<tr class="noentry"><td>Nothing upcoming</td></tr>';
     }
     $cont .= '</table>';
     return HTMLHelper::createNestedDivBoxModel('changed-list', $cont);
 }
 /**
  * create the content of recently changed
  * @return string html-content
  * @global Options determine how many days after change the contact should still be shown
  */
 function innerCreate()
 {
     global $options;
     global $db;
     $db->query('SELECT *
         FROM ' . TABLE_CONTACT . ' AS contact, ' . TABLE_PROPERTIES . " AS prop \r\n            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 : ''));
     $data = array();
     while ($c = $db->next()) {
         $data[] = array('display_name' => $c['lastname'] . ', ' . $c['firstname'], 'feature' => $c['value']);
     }
     $tGen = new TableGenerator('changed-list');
     $cont = '<table class="changed-list">';
     $cont .= '<caption>Ranklist';
     $cont .= '</caption>';
     if (count($data) > 0) {
         $cont .= $tGen->generateBody($data, array('display_name', 'feature'));
     } else {
         $cont .= '<tr class="noentry"><td>Not found</td></tr>';
     }
     $cont .= '</table>';
     return $cont;
 }
 /**
  * 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);
 }
 /**
  * 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 $options;
     global $db;
     $db->query('SELECT *
         FROM ' . TABLE_CONTACT . ' AS contact, ' . TABLE_GROUPS . ' AS groups, ' . TABLE_GROUPLIST . ' AS grouplist  
         WHERE ( certState="issued" OR  certState="used" ) AND ( DATE_ADD(certLastUsed, INTERVAL 3 MONTH) < NOW() OR certLastUsed IS NULL ) AND contact.id=groups.id AND groups.groupid=grouplist.groupid
         ORDER BY groupname, certLastUsed DESC', 1);
     $mailto = '';
     $currentGroup = null;
     $data = array();
     $neverUsed = 0;
     while (1) {
         $c = $db->next(1);
         if ($currentGroup != $c['groupname'] || $c == null) {
             if ($currentGroup != null) {
                 $subject = htmlentities($options->getOption('adminEmailSubject') . ': Security Certificate Expiration Notice');
                 $body = str_replace("\n", '%0A', htmlentities($options->getOption('adminEmailFooter')));
                 $data[] = array('display_name' => "Expired: <a href='mailto:?bcc={$mailto}&subject=" . $subject . '&body=' . $body . "'>mailto expired</a>", 'certLastUsed' => '&nbsp;', 'certState' => '&nbsp;', 'groupname' => $currentGroup);
                 $mailto = '';
             }
             if ($c == null) {
                 break;
             }
             $currentGroup = $c['groupname'];
         }
         $data[] = array('display_name' => '<a href="../../contact/contact.php?id=' . $c['id'] . '">' . $c['lastname'] . ', ' . $c['firstname'] . '</a>', 'certLastUsed' => $c['certLastUsed'], 'certState' => $c['certState'], 'groupname' => $c['groupname']);
         if ($c['certState'] == 'issued') {
             // never used
             $neverUsed++;
         }
         $co = new Contact($c['id']);
         $mailto .= $co->getFirstEmail() . ',';
     }
     // START OUTPUT
     $cont = '<div>&nbsp;</div>';
     $db->query('SELECT MAX(certLastUsed) AS number 
         FROM ' . TABLE_CONTACT . ' AS contact 
         WHERE certState="issued" OR  certState="used"');
     $r = $db->next();
     $cont .= '<div>Newest update: ' . $r['number'] . '</div><br>';
     $db->query('SELECT COUNT(*) AS number 
         FROM ' . TABLE_CONTACT . ' AS contact 
         WHERE certState="issued" OR  certState="used"');
     $r = $db->next();
     $cont .= '<div>Certificates (issued or used): ' . $r['number'] . '</div><br>';
     $db->query('SELECT COUNT(*) AS number 
         FROM ' . TABLE_CONTACT . ' AS contact 
         WHERE certState="used" AND DATE_ADD(certLastUsed, INTERVAL 3 MONTH) >= NOW()');
     $r = $db->next();
     $cont .= '<div>Certificates used within last 3 month: ' . $r['number'] . '</div><br>';
     $cont .= '<div>Unused certificates (entries in this list): ' . count($data) . ' (multi grouped entries listed multiple times)</div><br>';
     $cont .= '<div>Never used (issued): ' . $neverUsed . '</div><br>';
     // generate Table
     $tGen = new TableGenerator('changed-list');
     $cont .= '<table class="changed-list">';
     $cont .= '<caption>Unused Certificates (unused >3 month)</caption>';
     if (count($data) > 0) {
         $cont .= $tGen->generateBody($data, array('display_name', 'certLastUsed', 'certState'), '', 'groupname', false);
     } else {
         $cont .= '<tr class="noentry"><td>Not found</td></tr>';
     }
     $cont .= '</table>';
     $cont .= '<div><a href="gencerts.php">return</a></div><br>';
     return $cont;
 }
 /**
  * create the table containing the contacts
  *
  * @uses Contact
  * @return string html-content
  * @uses TableGenerator
  */
 function createTable()
 {
     // create big table
     $contacts = $this->contactList->getContacts();
     $mailtohref = '';
     // email link
     $data = array();
     $htmlId = 0;
     foreach ($contacts as $c) {
         if ($this->expand) {
             $p = Page::newPage('PageContact', $c);
             $data[] = array('cont' => $p->innerCreate(), 'css_class' => 'list-expanded-card', 'group_n' => $groupNormalizer->normalize(mb_substr($c->contact['lastname'], 0, 1)));
             continue;
         }
         // fetch first email ...
         $mails = $c->getValueGroup('email');
         $e = EmailHelper::sendEmailHref($c->rawEmail($mails[0]));
         $mailtohref .= $e . ',';
         $r = $c->generateListRowArray();
         //$r[] = "<input type='checkbox' checked=1 name='$e' id='cx$htmlId' onchange='generateMailto();'/>";
         $data[] = $r;
         $htmlId++;
     }
     $tGen = new TableGenerator('contact-list');
     $cont = '<table class="contact-list">';
     //$cont .= '<caption>' . $this->contactList->getGroupCaption() . '</caption>';
     if (count($data) > 0) {
         if ($this->expand) {
             $cont .= $tGen->generateBody($data, array('cont'), 'css_class', $this->isSorted ? 'group_n' : null);
         } else {
             $cont .= $tGen->generateBody($data, range(0, count($data[0]) - 3), 'css_class', $this->isSorted ? 'group_n' : null);
         }
     } else {
         $cont .= '<tr class="noentry"><td>No Entries.</td></tr>';
     }
     $cont .= '</table>';
     //$this->nav->addEntry('mailtoSelected','mail to selected',"mailto:$mailtohref");
     return $cont;
 }
 /**
  * create the table containing the contacts
  *
  * @uses Contact
  * @return string html-content
  * @global GroupNormalizer used to modify the contact names, in order to get them correctly grouped
  * @uses TableGenerator
  */
 function createTable()
 {
     global $groupNormalizer;
     // create big table
     $contacts = $this->contactList->getContacts();
     $data = array();
     foreach ($contacts as $c) {
         if ($this->expand) {
             $p = Page::newPage('PageContact', $c);
             $data[] = array('cont' => $p->innerCreate(), 'css_class' => 'list-expanded-card', 'group_n' => $groupNormalizer->normalize(mb_substr($c->contact['lastname'], 0, 1)));
             continue;
         }
         $data[] = $c->generateListRowArray();
     }
     $tGen = new TableGenerator('contact-list');
     $cont = '<table class="contact-list">';
     $cont .= '<caption>' . $this->contactList->getGroupCaption() . '</caption>';
     if (count($data) > 0) {
         if ($this->expand) {
             $cont .= $tGen->generateBody($data, array('cont'), 'css_class', 'group_n');
         } else {
             $cont .= $tGen->generateBody($data, range(0, count($data[0]) - 3), 'css_class', 'group_n');
         }
     } else {
         $cont .= '<tr class="noentry"><td>No Entries.</td></tr>';
     }
     $cont .= '</table>';
     return HTMLHelper::createNestedDivBoxModel('contact-list', $cont);
 }
 function passwordTable()
 {
     // font suitable for faxing
     $cont = "\n" . '<style type="text/css"> .sslca-fax { font-family: courier; font-size: 20px; border: solid 1px; } </style>';
     $tGen = new TableGenerator('', array('company' => 'Company', 'name' => 'Name', 'password' => 'Password'));
     $data = array();
     foreach ($this->data->getContacts() as $c) {
         $gr = $c->getValueGroup('groups');
         $gr = $gr[0]['groupname'];
         $data[] = array('company' => $gr, 'name' => $c->contact['firstname'] . ' ' . $c->contact['lastname'], 'password' => $c->contact['certPassword'], 'hint' => '[0,1,lion,OK]');
     }
     $cont .= "\n<table class='sslca-fax' width='80%'>";
     //$cont .= '<caption>Password List</caption>';
     //$cont .= $tGen->generateHead(array('name','password'));
     $cont .= $tGen->generateBody($data, array('name', 'password', 'hint'), 'sslca-fax', 'company', false);
     $cont .= '</table>';
     return $cont;
 }