diff --git a/supann/contrib/etc/cmsformat b/supann/contrib/etc/cmsformat new file mode 100644 index 0000000000000000000000000000000000000000..f0f303cf664c92bae751bcb2b1d6081878230761 --- /dev/null +++ b/supann/contrib/etc/cmsformat @@ -0,0 +1,3 @@ +# Formats +# TECHONOLOGY:ENCODING;label +MIFARE:XLSB;Mifare XLSB diff --git a/supann/contrib/etc/cmstype b/supann/contrib/etc/cmstype new file mode 100644 index 0000000000000000000000000000000000000000..58cbc40943778b5341f051c8084f2778694a8d14 --- /dev/null +++ b/supann/contrib/etc/cmstype @@ -0,0 +1,11 @@ +# Nomenclature SupAnn +etudiant;étudiant +personnel;professionnelle +visiteur;visiteur, anonyme +invite;invité, nominative +lecteur;lecteur de bibliothèque +prestataire;prestataire de services +vehicule;véhicule +externe;externe +# Ajouter ici les types locaux étiqueté si besoin +# {ORIGINE}type_local;Type de carte défini localement par l'établissement ORIGINE diff --git a/supann/personal/supann/class_SupannCMSAffectationAttribute.inc b/supann/personal/supann/class_SupannCMSAffectationAttribute.inc new file mode 100644 index 0000000000000000000000000000000000000000..95a96343c69825d82193cc1bb5f90892b2cf42b1 --- /dev/null +++ b/supann/personal/supann/class_SupannCMSAffectationAttribute.inc @@ -0,0 +1,90 @@ +attributes[3]->getValue() !== TRUE) { + /* Card is not valid */ + return; + } + foreach ($this->attributes as &$attribute) { + $shortname = preg_replace('/^([^_]+)_.*$/', '\\1', $attribute->getLdapName()); + if ($shortname == 'none') { + continue; + } + $value = $attribute->getValue(); + if (!isset($values[$shortname])) { + $values[$shortname] = []; + } + if ($value == '') { + continue; + } + $values[$shortname][$value] = $value; + } + unset($attribute); + $format = $this->attributes[1]->getValue(); + $id = $this->attributes[2]->getValue(); + $supannCMSIdEtiquette = '{'.$format.'}'.$id; + $supannCMSId = 'x-'.strtolower(str_replace(':', '-', $format)).';'.$id; + $values['supannCMSIdEtiquette'][$supannCMSIdEtiquette] = $supannCMSIdEtiquette; + $values['supannCMSId'][$supannCMSId] = $supannCMSId; + } +} diff --git a/supann/personal/supann/class_TaggedAttribute.inc b/supann/personal/supann/class_TaggedAttribute.inc new file mode 100644 index 0000000000000000000000000000000000000000..45e31b12ecb0c1be80bb0bcc2d1018c1cb8df5f4 --- /dev/null +++ b/supann/personal/supann/class_TaggedAttribute.inc @@ -0,0 +1,80 @@ +value = []; + $pattern = '/^'.preg_quote($this->getLdapName(), '/').';(.+)$/'; + for ($i = 0; $i < $attrs['count']; $i++) { + if ($attrs[$i] == $this->getLdapName()) { + for ($j = 0; $j < $attrs[$attrs[$i]]['count']; $j++) { + $this->value[] = ';'.$attrs[$attrs[$i]][$j]; + } + } elseif (preg_match($pattern, $attrs[$i], $m)) { + for ($j = 0; $j < $attrs[$attrs[$i]]['count']; $j++) { + $this->value[] = $m[1].';'.$attrs[$attrs[$i]][$j]; + } + } + } + $this->sortValues(); + } + + function computeLdapValue () + { + throw new FusionDirectoryException('nope'); + } + + /*! \brief Fill LDAP value in the attrs array + */ + function fillLdapValue (array &$attrs) + { + if ($this->isInLdap()) { + $initialValues = $this->getInitialValue(); + foreach ($initialValues as $value) { + list($tag, $tagvalue) = explode(';', $value, 2); + if (empty($tag)) { + $attrs[$this->getLdapName()] = []; + } else { + $attrs[$this->getLdapName().';'.$tag] = []; + } + } + if (empty($this->value)) { + $attrs[$this->getLdapName()] = []; + } else { + foreach ($this->value as $value) { + list($tag, $tagvalue) = explode(';', $value, 2); + if (empty($tag)) { + $attrs[$this->getLdapName()][] = $tagvalue; + } else { + $attrs[$this->getLdapName().';'.$tag][] = $tagvalue; + } + } + } + } + } +} diff --git a/supann/personal/supann/class_supannCMS.inc b/supann/personal/supann/class_supannCMS.inc new file mode 100644 index 0000000000000000000000000000000000000000..ce2cfc158b14ca8ffa4600d08fed578c6258fa02 --- /dev/null +++ b/supann/personal/supann/class_supannCMS.inc @@ -0,0 +1,94 @@ + _('Multiservice card'), + 'plDescription' => _('SupAnn CMS management'), + 'plIcon' => 'geticon.php?context=applications&icon=supann&size=48', + 'plSmallIcon' => 'geticon.php?context=applications&icon=supann&size=16', + 'plSelfModify' => TRUE, + 'plPriority' => 16, + 'plObjectClass' => ['supannCMS'], + 'plObjectType' => ['user'], + + 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()) + ]; + } + + static function getAttributesInfo (): array + { + return [ + 'status' => [ + 'name' => _('Cards'), + 'class' => ['fullwidth'], + 'attrs' => [ + new HiddenArrayAttribute('supannCMSType', FALSE, []), + new TaggedAttribute(new StringAttribute('', '', 'supannCMSId', FALSE)), + new HiddenArrayAttribute('supannCMSIdEtiquette', FALSE, []), + new HiddenArrayAttribute('supannCMSSource', FALSE, []), + new HiddenArrayAttribute('supannCMSDateFin', FALSE, []), + new SupannOrderedArrayAttribute( + new SupannCMSAffectationAttribute( + _('Cards'), _('SupAnn CMS Affectation'), + 'supannCMSAffectation' + ), + // no order + FALSE, + [], + // edit button + TRUE + ), + ] + ], + ]; + } + + function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE) + { + global $config; + + parent::__construct($dn, $object, $parent, $mainTab); + + $this->attributesAccess['supannCMSId']->setVisible(FALSE); + $this->attributesAccess['supannCMSAffectation']->setLinearRendering(FALSE); + $this->attributesAccess['supannCMSAffectation']->setHeaders([ + _('Type'), + _('Format'), + _('Id'), + _('Valid'), + _('Source'), + _('End date'), + '' + ]); + } + + protected function prepare_save (): array + { + $this->attributesAccess['supannCMSAffectation']->supannPrepareSave(); + return parent::prepare_save(); + } +}