new type API

This commit is contained in:
Roland Gruber 2017-04-01 09:57:03 +02:00
parent 3a3c88ba4b
commit 267cdcb31b
43 changed files with 49 additions and 46 deletions

View File

@ -803,11 +803,12 @@ abstract class baseModule {
* <br>
* 'myAttribute' => '<block><key>AttrName</key><tr><td align=\"L\">123</td></tr></block><block><tr><td align=\"L\">456</td></tr></block><block><tr><td align=\"L\">789</td></tr></block>'
*
* @param string $typeId type id (user, group, host)
* @return array PDF entries
*
* @see baseModule::get_metaData()
*/
public function get_pdfFields() {
public function get_pdfFields($typeId) {
return ((isset($this->meta['PDF_fields'])) ? $this->meta['PDF_fields'] : array());
}
@ -815,9 +816,10 @@ abstract class baseModule {
* Returns the PDF entries for this module.
*
* @param array $pdfKeys list of PDF keys that are included in document
* @param string $typeId type id (user, group, host)
* @return PDFEntry[] list of key => PDFEntry
*/
public function get_pdfEntries($pdfKeys) {
public function get_pdfEntries($pdfKeys, $typeId) {
return array();
}

View File

@ -413,7 +413,7 @@ function getAvailablePDFFields($typeId) {
$return = array();
for ($i = 0; $i < sizeof($mods); $i++) {
$module = moduleCache::getModule($mods[$i], \LAM\TYPES\getScopeFromTypeId($typeId));
$fields = $module->get_pdfFields();
$fields = $module->get_pdfFields($typeId);
$return[$mods[$i]] = array();
if (is_array($fields)) {
foreach ($fields as $fieldID => $fieldLabel) {
@ -2010,12 +2010,13 @@ class accountContainer {
* Returns a list of possible PDF entries for this account.
*
* @param array $pdfKeys list of PDF keys that are included in document
* @param string $typeId type id (user, group, host)
* @return PDFEntry[] list of key => PDFEntry
*/
function get_pdfEntries($pdfKeys) {
function get_pdfEntries($pdfKeys, $typeId) {
$return = array();
while(($current = current($this->module)) != null) {
$return = array_merge($return,$current->get_pdfEntries($pdfKeys));
$return = array_merge($return,$current->get_pdfEntries($pdfKeys, $typeId));
next($this->module);
}
$dn = $this->dn_orig;

View File

@ -223,7 +223,7 @@ class account extends baseModule {
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
*/
function get_pdfEntries($pdfKeys) {
function get_pdfEntries($pdfKeys, $typeId) {
$return = array();
$this->addSimplePDFField($return, 'description', _('Description'));
$this->addSimplePDFField($return, 'uid', _('User name'));

View File

@ -978,7 +978,7 @@ class asteriskAccount extends baseModule implements passwordService {
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
*/
function get_pdfEntries($pdfKeys) {
function get_pdfEntries($pdfKeys, $typeId) {
$return = array();
$this->addSimplePDFField($return, 'AstAccountCallerID', _('Caller ID'));
$this->addSimplePDFField($return, 'AstAccountContext', _('Account context'));

View File

@ -800,7 +800,7 @@ class asteriskExtension extends baseModule {
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
*/
function get_pdfEntries($pdfKeys) {
function get_pdfEntries($pdfKeys, $typeId) {
$a = $this->attributes;
$o = $this->orig;
$return = array();

View File

@ -365,7 +365,7 @@ class asteriskVoicemail extends baseModule implements passwordService {
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
*/
function get_pdfEntries($pdfKeys) {
function get_pdfEntries($pdfKeys, $typeId) {
$return = array();
$this->addSimplePDFField($return, 'AstVoicemailMailbox', _('Mailbox'));
$this->addSimplePDFField($return, 'AstContext', _('Account context'));

View File

@ -224,7 +224,7 @@ class authorizedServiceObject extends baseModule {
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
*/
function get_pdfEntries($pdfKeys) {
function get_pdfEntries($pdfKeys, $typeId) {
$return = array();
if (in_array('authorizedServiceObject', $this->attributes['objectClass'])) {
$this->addSimplePDFField($return, 'authorizedService', _('Authorized Services'));

View File

@ -398,7 +398,7 @@ class ddns extends baseModule {
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
*/
public function get_pdfEntries($pdfKeys) {
public function get_pdfEntries($pdfKeys, $typeId) {
// attributes are taken from DHCP server object
$this->attributes = &$this->getAccountContainer()->getAccountModule('dhcp_settings')->attributes;
$this->orig = &$this->getAccountContainer()->getAccountModule('dhcp_settings')->orig;

View File

@ -660,7 +660,7 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
*/
function get_pdfEntries($pdfKeys) {
function get_pdfEntries($pdfKeys, $typeId) {
$nodeType = $this->getDHCPOption('netbios-node-type');
$nodeTypeValue = '';
if (isset($this->all_netbios_node_types[$nodeType])) {

View File

@ -551,7 +551,7 @@ class eduPerson extends baseModule {
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
*/
function get_pdfEntries($pdfKeys) {
function get_pdfEntries($pdfKeys, $typeId) {
$return = array();
$this->addSimplePDFField($return, 'primaryAffiliation', _('Primary affiliation'), 'eduPersonPrimaryAffiliation');
$this->addSimplePDFField($return, 'scopedAffiliation', _('Scoped affiliations'), 'eduPersonScopedAffiliation');

View File

@ -734,7 +734,7 @@ class fixed_ip extends baseModule {
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
*/
function get_pdfEntries($pdfKeys) {
function get_pdfEntries($pdfKeys, $typeId) {
$return = array();
if (is_array($this->fixed_ip) && (sizeof($this->fixed_ip) > 0)) {
$pdfTable = new PDFTable();

View File

@ -688,7 +688,7 @@ class freeRadius extends baseModule {
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
*/
function get_pdfEntries($pdfKeys) {
function get_pdfEntries($pdfKeys, $typeId) {
$return = array();
$this->addSimplePDFField($return, 'radiusFramedIPAddress', _('IP address'));
$this->addSimplePDFField($return, 'radiusFramedIPNetmask', _('Net mask'));

View File

@ -198,7 +198,7 @@ class hostObject extends baseModule {
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
*/
function get_pdfEntries($pdfKeys) {
function get_pdfEntries($pdfKeys, $typeId) {
$return = array();
$this->addSimplePDFField($return, 'hosts', _('Host list'), 'host');
return $return;

View File

@ -158,7 +158,7 @@ class ieee802device extends baseModule {
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
*/
function get_pdfEntries($pdfKeys) {
function get_pdfEntries($pdfKeys, $typeId) {
$return = array();
$this->addSimplePDFField($return, 'macAddress', _('MAC addresses'));
return $return;

View File

@ -347,7 +347,7 @@ class inetLocalMailRecipient extends baseModule {
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
*/
function get_pdfEntries($pdfKeys) {
function get_pdfEntries($pdfKeys, $typeId) {
$return = array();
$this->addSimplePDFField($return, 'routingAdr', _('Routing address'), 'mailRoutingAddress');
$this->addSimplePDFField($return, 'localAdr', _('Local address list'), 'mailLocalAddress');

View File

@ -1975,7 +1975,7 @@ class inetOrgPerson extends baseModule implements passwordService {
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
*/
function get_pdfEntries($pdfKeys) {
function get_pdfEntries($pdfKeys, $typeId) {
$return = array();
$this->addSimplePDFField($return, 'description', _('Description'));
$this->addSimplePDFField($return, 'title', _('Job title'));

View File

@ -393,7 +393,7 @@ class kolabGroup extends baseModule {
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
*/
function get_pdfEntries($pdfKeys) {
function get_pdfEntries($pdfKeys, $typeId) {
$return = array();
$this->addSimplePDFField($return, 'mail', _('Email address'));
$this->addSimplePDFField($return, 'kolabAllowSMTPRecipient', _('Allowed recipients'));

View File

@ -513,7 +513,7 @@ class kolabSharedFolder extends baseModule { // TODO folder type
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
*/
function get_pdfEntries($pdfKeys) {
function get_pdfEntries($pdfKeys, $typeId) {
$return = array();
$this->addSimplePDFField($return, 'cn', _('Name'));
$this->addSimplePDFField($return, 'mail', _('Email address'));

View File

@ -702,7 +702,7 @@ class kolabUser extends baseModule {
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
*/
function get_pdfEntries($pdfKeys) {
function get_pdfEntries($pdfKeys, $typeId) {
$return = array();
$this->addSimplePDFField($return, 'mailHost', _('Mailbox home server'));
// invitation policies

View File

@ -285,7 +285,7 @@ class ldapPublicKey extends baseModule {
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
*/
function get_pdfEntries($pdfKeys) {
function get_pdfEntries($pdfKeys, $typeId) {
$return = array();
if (sizeof($this->attributes['sshPublicKey']) > 0) {
$pdfTable = new PDFTable(_('SSH public keys'));

View File

@ -468,7 +468,7 @@ class nisMailAlias extends baseModule {
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
*/
function get_pdfEntries($pdfKeys) {
function get_pdfEntries($pdfKeys, $typeId) {
$return = array();
$this->addSimplePDFField($return, 'alias', _('Alias name'), 'cn');
$this->addSimplePDFField($return, 'recipients', _('Recipient list'), 'rfc822MailMember');

View File

@ -525,7 +525,7 @@ class nisMailAliasUser extends baseModule {
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
*/
function get_pdfEntries($pdfKeys) {
function get_pdfEntries($pdfKeys, $typeId) {
$return = array();
$aliases = $this->getMailAliasList();
$foundAliases = array();

View File

@ -253,7 +253,7 @@ class nisNetGroupHost extends nisNetGroupUser {
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
*/
function get_pdfEntries($pdfKeys) {
function get_pdfEntries($pdfKeys, $typeId) {
$return = array();
$pdfTable = new PDFTable();
$pdfRow = new PDFTableRow();

View File

@ -471,7 +471,7 @@ class nisNetGroupUser extends baseModule {
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
*/
function get_pdfEntries($pdfKeys) {
function get_pdfEntries($pdfKeys, $typeId) {
$return = array();
$pdfTable = new PDFTable();
$pdfRow = new PDFTableRow();

View File

@ -575,7 +575,7 @@ class nisnetgroup extends baseModule {
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
*/
function get_pdfEntries($pdfKeys) {
function get_pdfEntries($pdfKeys, $typeId) {
$return = array();
$this->addSimplePDFField($return, 'cn', _('Group name'));
$this->addSimplePDFField($return, 'description', _('Description'));

View File

@ -1818,7 +1818,7 @@ class posixAccount extends baseModule implements passwordService {
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
*/
function get_pdfEntries($pdfKeys) {
function get_pdfEntries($pdfKeys, $typeId) {
$uidLabel = _('User name');
if ($this->get_scope() == 'host') {
$uidLabel = _('Host name');

View File

@ -616,7 +616,7 @@ class posixGroup extends baseModule implements passwordService {
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
*/
function get_pdfEntries($pdfKeys) {
function get_pdfEntries($pdfKeys, $typeId) {
$return = array();
$this->addSimplePDFField($return, 'memberUid', _('Group members'));
$this->addSimplePDFField($return, 'cn', _('Group name'));

View File

@ -401,7 +401,7 @@ class puppetClient extends baseModule {
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
*/
function get_pdfEntries($pdfKeys) {
function get_pdfEntries($pdfKeys, $typeId) {
$return = array();
if (!in_array('puppetClient', $this->attributes['objectClass'])) {
return $return;

View File

@ -256,7 +256,7 @@ class pykotaBillingCode extends baseModule {
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
*/
function get_pdfEntries($pdfKeys) {
function get_pdfEntries($pdfKeys, $typeId) {
$return = array();
$this->loadCodeCache();
$this->addSimplePDFField($return, 'pykotaBillingCode', _('Billing code'));

View File

@ -462,7 +462,7 @@ class pykotaGroup extends baseModule {
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
*/
function get_pdfEntries($pdfKeys) {
function get_pdfEntries($pdfKeys, $typeId) {
$return = array();
$this->addSimplePDFField($return, 'cn', _('Common name'));
$this->addSimplePDFField($return, 'pykotaGroupName', _('PyKota group name'));

View File

@ -579,7 +579,7 @@ class pykotaPrinter extends baseModule {
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
*/
function get_pdfEntries($pdfKeys) {
function get_pdfEntries($pdfKeys, $typeId) {
$return = array();
$this->loadPrinterNameCache();
$this->addSimplePDFField($return, 'cn', _('Printer name'));

View File

@ -887,7 +887,7 @@ class pykotaUser extends baseModule {
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
*/
function get_pdfEntries($pdfKeys) {
function get_pdfEntries($pdfKeys, $typeId) {
$return = array();
$this->addSimplePDFField($return, 'cn', _('Common name'));
$this->addSimplePDFField($return, 'uid', _('User name'));

View File

@ -609,7 +609,7 @@ class quota extends baseModule {
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
*/
function get_pdfEntries($pdfKeys) {
function get_pdfEntries($pdfKeys, $typeId) {
$this->initQuotas();
if (!isset($this->quota) || !is_array($this->quota)) return array();
if (sizeof($this->quota) > 0) {

View File

@ -767,7 +767,7 @@ class range extends baseModule {
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
*/
function get_pdfEntries($pdfKeys) {
function get_pdfEntries($pdfKeys, $typeId) {
$return = array();
if (is_array($this->ranges) && (sizeof($this->ranges) > 0)) {
$pdfTable = new PDFTable(_('Ranges'));

View File

@ -593,7 +593,7 @@ class sambaDomain extends baseModule {
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
*/
function get_pdfEntries($pdfKeys) {
function get_pdfEntries($pdfKeys, $typeId) {
$return = array();
$this->addSimplePDFField($return, 'domainName', _('Domain name'), 'sambaDomainName');
$this->addSimplePDFField($return, 'domainSID', _('Domain SID'), 'sambaSID');

View File

@ -535,7 +535,7 @@ class sambaGroupMapping extends baseModule {
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
*/
function get_pdfEntries($pdfKeys) {
function get_pdfEntries($pdfKeys, $typeId) {
$return = array();
$this->addSimplePDFField($return, 'gidNumber', _('GID number'));
$this->addSimplePDFField($return, 'sambaSID', _('Windows group'));

View File

@ -1905,7 +1905,7 @@ class sambaSamAccount extends baseModule implements passwordService {
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
*/
function get_pdfEntries($pdfKeys) {
function get_pdfEntries($pdfKeys, $typeId) {
$return = array();
$this->addSimplePDFField($return, 'displayName', _('Display name'));
$this->addSimplePDFField($return, 'sambaHomePath', _('Home path'));

View File

@ -550,7 +550,7 @@ class shadowAccount extends baseModule implements passwordService {
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
*/
function get_pdfEntries($pdfKeys) {
function get_pdfEntries($pdfKeys, $typeId) {
$timeZone = getTimeZone();
$shadowLastChange = '';
if (!empty($this->attributes['shadowLastChange'][0])) {

View File

@ -376,7 +376,7 @@ class systemQuotas extends baseModule {
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
*/
public function get_pdfEntries($pdfKeys) {
public function get_pdfEntries($pdfKeys, $typeId) {
$return = array();
if (isset($this->attributes['quota'][0])) {
$pdfTable = new PDFTable();

View File

@ -910,7 +910,7 @@ class windowsGroup extends baseModule {
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
*/
public function get_pdfEntries($pdfKeys) {
public function get_pdfEntries($pdfKeys, $typeId) {
$return = array();
$this->addSimplePDFField($return, 'cn', _('Group name'));
$this->addSimplePDFField($return, 'description', _('Description'));

View File

@ -284,7 +284,7 @@ class windowsHost extends baseModule {
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
*/
public function get_pdfEntries($pdfKeys) {
public function get_pdfEntries($pdfKeys, $typeId) {
$return = array();
$this->addSimplePDFField($return, 'cn', _('Host name'));
$this->addSimplePDFField($return, 'description', _('Description'));

View File

@ -2415,7 +2415,7 @@ class windowsUser extends baseModule implements passwordService {
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
*/
public function get_pdfEntries($pdfKeys) {
public function get_pdfEntries($pdfKeys, $typeId) {
$return = array();
$this->addSimplePDFField($return, 'userPrincipalName', _('User name'));
$this->addSimplePDFField($return, 'cn', _('Common name'));

View File

@ -104,7 +104,7 @@ function createModulePDF($accounts, $pdf_structure="default", $returnAsString =
$pdf->AddPage();
// Get PDF entries for the current account
$entries = $account->get_pdfEntries($pdfKeys);
$entries = $account->get_pdfEntries($pdfKeys, $account_type->getId());
// Now create the PDF file acording to the structure with the submitted values
foreach($structure as $entry) {