Attached is a 'schac.inc' module, that adds editing for SCHAC, SCHema
for ACademia (
http://www.terena.org/activities/tf-emc2/schac.html),
which is (usually?) required in EduRoam environment. Since SCHAC doesn't
have any specific logo, I used a very generic 'Bookmark.png'.
It's probably a little rough around the edges, but it works.
It has one 'specialty' - if the SchacUUID attribute is empty when you
edit the user, it is automatically generated and saved in LDAP
(unfortunately it doesn't show up the first time one enters the Schac
module - but if one cycles from Schac to some other module and then
back, it shows up).
It would be nice if one could turn this behavior off in module settings,
but my programming skills are not good enough for that...
Regards, Danilo
--
Danilo Godec, sistemska podpora / system administration
Predlog! Obiscite prenovljeno spletno stran www.agenda.si
ODPRTA KODA IN LINUX
STORITVE : POSLOVNE RESITVE : UPRAVLJANJE IT : INFRASTRUKTURA IT : IZOBRAZEVANJE : PROGRAMSKA OPREMA
Visit our updated web page at www.agenda.si
OPEN SOURCE AND LINUX
SERVICES : BUSINESS SOLUTIONS : IT MANAGEMENT : IT INFRASTRUCTURE : TRAINING : SOFTWARE
tomaz.zaman@...)
*/
/**
* Manages the schac extension for user accounts.
*
* @package modules
*/
class schac extends baseModule {
/**
* Creates a new eduPerson object.
*
* @param string $scope account type (user, group, host)
*/
function __construct($scope) {
parent::__construct($scope);
$this->autoAddObjectClasses = false;
}
/**
* This function fills the error message array with messages.
**/
function load_Messages() {
$this->messages['UUID'][0] = array('ERROR', _('Users') . ': ' . _('UUID number'), _("UUID number program is invalid!"));
}
/**
* Returns meta data that is interpreted by parent class
*
* @return array array with meta data
*
* @see baseModule::get_metaData()
**/
function get_metaData() {
$return = array();
$return['icon'] = 'Bookmark.png';
$return["account_types"] = array("user");
$return["alias"] = _("Schac");
$return['dependencies'] = array('depends' => array(), 'conflicts' => array());
# $return['objectClasses'] = array('schac');
$return['objectClasses'] = array('schacPersonalCharacteristics','schacContactLocation',
'schacEmployeeInfo','schacLinkageIdentifiers',
'schacEntryMetadata','schacEntryConfidentiality',
'schacUserEntitlements');
$return['attributes'] = array('schacMotherTongue','schacGender','schacDateOfBirth','schacPlaceOfBirth',
'schacCountryOfCitizenship','schacSn1','schacSn2','schacPersonalTitle',
'schacHomeOrganization','schacHomeOrganizationType','schacUserPresenceID',
'schacPersonalPosition','schacPersonalUniqueCode','schacPersonalUniqueID',
'schacUUID','schacExpiryDate');
// $return["RDN"] = array('schacUserPresenceID' => 'low');
// lists for dates
$day = array(); $mon = array(); $year = array();
for ( $i=1; $i<=31; $i++ ) $day[] = $i;
for ( $i=1; $i<=12; $i++ ) $mon[] = $i;
for ( $i=2036; $i>=1900; $i-- ) $year[] = $i;
$return['help'] = array(
'schacMotherTongue' => array(
"Headline" => _("Mother tongue"),
"Text" => _("Specifies the person's mother's tongue")
),
'schacGender' => array(
"Headline" => _("Gender"),
"Text" => _("Specifies the person's gender")
),
'schacDateOfBirth' => array(
"Headline" => _("Date of birth"),
"Text" => _("Specifies the person's date of birth")
),
'schacPlaceOfBirth' => array(
"Headline" => _("Place of birth"),
"Text" => _("Specifies the person's place of birth")
),
'schacCountryOfCitizenship' => array(
"Headline" => _("Country of citizenship"),
"Text" => _("Specifies the person's citizenship")
),
'schacSn1' => array(
"Headline" => _("First second name"),
"Text" => _("Specifies the person's first second name")
),
'schacSn2' => array(
"Headline" => _("Second second name"),
"Text" => _("Specifies the person's second second name")
),
'schacPersonalTitle' => array(
"Headline" => _("Title"),
"Text" => _("Specifies the person's title")
),
'schacHomeOrganization' => array(
"Headline" => _("Home organization"),
"Text" => _("Specifies the person's registered DNS organization name")
),
'schacHomeOrganizationType' => array(
"Headline" => _("Home organization type"),
"Text" => _("Specifies the person's registered DNS organization type")
),
'schacUserPresenceID' => array(
"Headline" => _("User presence id"),
"Text" => _("Specifies the person's e-availability, e.g. website, msn,...")
),
'schacPersonalPosition' => array(
"Headline" => _("Personal position"),
"Text" => _("Specifies the person's official position within the organization")
),
'schacPersonalUniqueCode' => array(
"Headline" => _("Personal unique code"),
"Text" => _("Specifies the person's id within the organization")
),
'schacPersonalUniqueID' => array(
"Headline" => _("Personal unique ID"),
"Text" => _("Specifies the person's id outisde the organization - national level")
),
'schacUUID' => array(
"Headline" => _("Personal UUID"),
"Text" => _("Specifies the person's universally unique identifier")
),
'schacExpiryDate' => array(
"Headline" => _("Expiry date"),
"Text" => _("Specifies this user's record expiry date and time")
)
);
return $return;
}
/**
* Returns the HTML meta data for the main account page.
*
* @return htmlElement HTML meta data
*/
function display_html_attributes() {
$return = new htmlTable();
if (in_array('schacContactLocation', $this->attributes['objectClass'])) {
// schacMotherTongue
$tongue = '';
if(isset($this->attributes['schacMotherTongue'])) {
$tongue = $this->attributes['schacMotherTongue'][0];
}
$return->addElement(new htmlTableExtendedInputField(_('Mother\'s toungue'), 'schacMotherTongue', $tongue, 'schacMotherTongue'), true);
// schacGender
$gender = '';
if(isset($this->attributes['schacGender'])) {
$gender = ($this->attributes['schacGender'][0] == '1')? array('male' =>'1') : array('female' => '2');
}
$select = new htmlTableExtendedSelect('schacGender', array('male' => '1', 'female' => '2'), $gender, _('Gender'), 'schacGender');
$select->setHasDescriptiveElements(true);
$return->addElement($select, true);
// schacDateOfBirth
$birthdate = "";
if (isset($this->attributes['schacDateOfBirth'][0])) {
$birthdate = $this->attributes['schacDateOfBirth'][0];
}
$return->addElement(new htmlOutputText(_('Date of birth')));
$dobTable = new htmlTable();
$dobTable->addElement(new htmlOutputText($birthdate, false));
$dobTable->addElement(new htmlAccountPageButton('schac', 'dob', 'open', _('Change')));
$return->addElement($dobTable);
$return->addElement(new htmlHelpLink('schacDateOfBirth'), true);
// schacPlaceOfBirth
$birthplace = '';
if(isset($this->attributes['schacPlaceOfBirth'])) {
$birthplace = $this->attributes['schacPlaceOfBirth'][0];
}
$return->addElement(new htmlTableExtendedInputField(_('Place of birth'), 'schacPlaceOfBirth', $birthplace, 'schacPlaceOfBirth'), true);
// schacCountryOfCitizenship
$citizenship = '';
if(isset($this->attributes['schacCountryOfCitizenship'])) {
$citizenship = $this->attributes['schacCountryOfCitizenship'][0];
}
$return->addElement(new htmlTableExtendedInputField(_('Country of citizenship'), 'schacCountryOfCitizenship', $citizenship, 'schacCountryOfCitizenship'), true);
// schacSn1
$sn1 = '';
if(isset($this->attributes['schacSn1'])) {
$sn1 = $this->attributes['schacSn1'][0];
}
$return->addElement(new htmlTableExtendedInputField(_('Sn 1'), 'schacSn1', $sn1, 'schacSn1'), true);
// schacSn2
$sn2 = '';
if(isset($this->attributes['schacSn2'])) {
$sn2 = $this->attributes['schacSn2'][0];
}
$return->addElement(new htmlTableExtendedInputField(_('Sn 2'), 'schacSn2', $sn2, 'schacSn2'), true);
// schacHomeOrganization
$homeOrg = '';
if(isset($this->attributes['schacHomeOrganization'])) {
$homeOrg = $this->attributes['schacHomeOrganization'][0];
}
$return->addElement(new htmlTableExtendedInputField(_('Home organization'), 'schacHomeOrganization', $homeOrg, 'schacHomeOrganization'), true);
// schacHomeOrganizationType
$homeOrgType = '';
if(isset($this->attributes['schacHomeOrganizationType'])) {
$homeOrgType = $this->attributes['schacHomeOrganizationType'][0];
}
$return->addElement(new htmlTableExtendedInputField(_('Home organization type'), 'schacHomeOrganizationType', $homeOrgType, 'schacHomeOrganizationType'), true);
// schacUserPresenceID
$presenceId = '';
if(isset($this->attributes['schacUserPresenceID'])) {
$presenceId = $this->attributes['schacUserPresenceID'][0];
}
$return->addElement(new htmlTableExtendedInputField(_('User presence ID'), 'schacUserPresenceID', $presenceId, 'schacUserPresenceID'), true);
// schacPersonalPosition
$position = '';
if(isset($this->attributes['schacPersonalPosition'])) {
$position = $this->attributes['schacPersonalPosition'][0];
}
$return->addElement(new htmlTableExtendedInputField(_('Personal position'), 'schacPersonalPosition', $position, 'schacPersonalPosition'), true);
// schacPersonalUniqueCode
$uniquecode = '';
if(isset($this->attributes['schacPersonalUniqueCode'])) {
$uniquecode = $this->attributes['schacPersonalUniqueCode'][0];
}
$return->addElement(new htmlTableExtendedInputField(_('Personal unique code'), 'schacPersonalUniqueCode', $uniquecode, 'schacPersonalUniqueCode'), true);
// schacPersonalUniqueID
$uniqueid = '';
if(isset($this->attributes['schacPersonalUniqueID'])) {
$uniqueid = $this->attributes['schacPersonalUniqueID'][0];
}
$return->addElement(new htmlTableExtendedInputField(_('Personal unique ID'), 'schacPersonalUniqueID', $uniqueid, 'schacPersonalUniqueID'), true);
// schacUUID
$uuid = '';
if(isset($this->attributes['schacUUID'])) {
$uuid = $this->attributes['schacUUID'][0];
}
$return->addElement(new htmlTableExtendedInputField(_('UUID'), 'schacUUID', $uuid, 'schacUUID'), true);
// schacExpiryDate
// $expdate = '';
// if(isset($this->attributes['schacExpiryDate'])) {
// $expdate = $this->attributes['schacExpiryDate'][0];
// }
// $return->addElement(new htmlTableExtendedInputField(_('ExpiryDate'), 'schacExpiryDate', $expdate, 'schacExpiryDate'), true);
$expdate = "";
if (isset($this->attributes['schacExpiryDate'][0])) {
$expdate = $this->attributes['schacExpiryDate'][0];
}
$return->addElement(new htmlOutputText(_('Expiry date')));
$expTable = new htmlTable();
$expTable->addElement(new htmlOutputText($expdate, false));
$expTable->addElement(new htmlAccountPageButton('schac', 'exp', 'open', _('Change')));
$return->addElement($expTable);
$return->addElement(new htmlHelpLink('schacExpiryDate'), true);
$return->addElement(new htmlSpacer(null, '10px'), true);
$addButton = new htmlButton('remObjectClass', _('Remove schac extension'));
$addButton->colspan = 3;
$return->addElement($addButton);
} else {
$return->addElement(new htmlButton('addObjectClass', _('Add schac extension')));
}
return $return;
}
/**
* Processes user input of the primary module page.
* It checks if all input values are correct and updates the associated LDAP attributes.
*
* @return array list of info/error messages
*/
function process_attributes() {
if (isset($_POST['addObjectClass'])) {
for ($i = 0; $i < sizeof($this->meta['objectClasses']); $i++) {
$this->attributes['objectClass'][] = $this->meta['objectClasses'][$i] ;
}
return array();
} elseif (isset($_POST['remObjectClass'])) {
$this->attributes['objectClass'] = array_delete($this->meta['objectClasses'], $this->attributes['objectClass']);
for ($i = 0; $i < sizeof($this->meta['attributes']); $i++) {
if (isset($this->attributes[$this->meta['attributes'][$i]])) {
unset($this->attributes[$this->meta['attributes'][$i]]);
}
}
return array();
}
if (!in_array('schacContactLocation', $this->attributes['objectClass'])) {
return array();
}
$errors = array();
if ( isset($_POST['schacMotherTongue']) ) {
$this->attributes['schacMotherTongue'][0] = $_POST['schacMotherTongue'];
}
if ( isset($_POST['schacGender'] ) ) {
$this->attributes['schacGender'][0] = $_POST['schacGender'];
}
if ( isset($_POST['schacDateOfBirth']) ) {
$this->attributes['schacDateOfBirth'][0] = $_POST['schacDateOfBirth'];
}
if ( isset($_POST['schacPlaceOfBirth']) ) {
$this->attributes['schacPlaceOfBirth'][0] = $_POST['schacPlaceOfBirth'];
}
if ( isset($_POST['schacCountryOfCitizenship']) ) {
$this->attributes['schacCountryOfCitizenship'][0] = $_POST['schacCountryOfCitizenship'];
}
if ( isset($_POST['schacSn1'])){
$this->attributes['schacSn1'][0] = $_POST['schacSn1'];
}
if ( isset($_POST['schacSn2']) ) {
$this->attributes['schacSn2'][0] = $_POST['schacSn2'];
}
if ( isset($_POST['schacHomeOrganization']) ){
$this->attributes['schacHomeOrganization'][0] = $_POST['schacHomeOrganization'];
}
if ( isset($_POST['schacHomeOrganizationType']) ){
$this->attributes['schacHomeOrganizationType'][0] = $_POST['schacHomeOrganizationType'];
}
if ( isset($_POST['schacUserPresenceID']) ){
$this->attributes['schacUserPresenceID'][0] = $_POST['schacUserPresenceID'];
}
if ( isset($_POST['schacPersonalPosition']) ) {
$this->attributes['schacPersonalPosition'][0] = $_POST['schacPersonalPosition'];
}
if ( isset($_POST['schacPersonalUniqueCode']) ) {
$this->attributes['schacPersonalUniqueCode'][0] = $_POST['schacPersonalUniqueCode'];
}
if ( isset($_POST['schacPersonalUniqueID']) ) {
$this->attributes['schacPersonalUniqueID'][0] = $_POST['schacPersonalUniqueID'];
}
if ( !isset($_POST['schacUUID']) || $_POST['schacUUID'] == '' ) {
$this->attributes['schacUUID'][0] = $this->getUUID ( $errors ) ;
} else {
$this->attributes['schacUUID'][0] = $_POST['schacUUID'];
}
if ( isset($_POST['schacExpiryDate']) ){
$this->attributes['schacExpiryDate'][0] = $_POST['schacExpiryDate'];
}
return $errors;
}
/**
* Returns UUID number.
*
* @param array $errors list of error messages where errors can be added
* @return mixed Null if no UIDs are free else an array of free UIDs.
*/
function getUUID(&$errors) {
$ret = array();
exec('uuidgen -t', $ret, $error);
if($error != 0) {
$errors[] = $this->messages['UUID'][0];
$ret = array () ;
}
return $ret[0];
}
/**
* This function will create the meta HTML code to show a page with the date of birth.
*
* @return array meta HTML code
*/
function display_html_dob() {
$return = new htmlTable();
$bod = 0 ;
if (isset($this->attributes['schacDateOfBirth'][0])) {
$dob = $this->attributes['schacDateOfBirth'][0];
}
for ( $i=1; $i<=31; $i++ ) $mday[] = sprintf("%02d",$i);
for ( $i=1; $i<=12; $i++ ) $mon[] = sprintf("%02d",$i);
for ( $i=1900; $i<=2050; $i++ ) $year[] = $i;
$return->addElement(new htmlOutputText(_('Date of birth')));
$expTable = new htmlTable();
$expTable->addElement(new htmlSelect('dob_day', $mday, array(substr($dob,6,2))));
$expTable->addElement(new htmlSelect('dob_mon', $mon, array(substr($dob,4,2))));
$expTable->addElement(new htmlSelect('dob_yea', $year, array(substr($dob,0,4))));
$return->addElement($expTable);
$return->addElement(new htmlSpacer(null, '10px'), true);
$buttonTable = new htmlTable();
$buttonTable->addElement(new htmlAccountPageButton('schac', 'attributes', 'change', _('Change')));
if (isset($this->attributes['schacDateOfBirth'][0])) {
$buttonTable->addElement(new htmlAccountPageButton('schac', 'attributes', 'del', _('Remove')));
}
$buttonTable->addElement(new htmlAccountPageButton('schac', 'attributes', 'back', _('Cancel')));
$buttonTable->colspan=3;
$return->addElement($buttonTable);
return $return;
}
function process_dob () {
$errors = array();
// set dateofbirth
if (isset($_POST['form_subpage_schac_attributes_change'])) {
$this->attributes['schacDateOfBirth'][0] = $_POST['dob_yea'] . $_POST['dob_mon'] . $_POST['dob_day'] ;
}
// remove dateofbirth
elseif (isset($_POST['form_subpage_schac_attributes_del'])) {
unset($this->attributes['schacDateOfBirth']);
}
return $errors;
}
/**
* This function will create the meta HTML code to show a page with expiration date.
*
* @return array meta HTML code
*/
function display_html_exp() {
$return = new htmlTable();
$exp = 0 ;
if (isset($this->attributes['schacExpiryDate'][0])) {
$exp = $this->attributes['schacExpiryDate'][0];
}
for ( $i=1; $i<=31; $i++ ) $mday[] = sprintf("%02d",$i);
for ( $i=1; $i<=12; $i++ ) $mon[] = sprintf("%02d",$i);
for ( $i=1900; $i<=2050; $i++ ) $year[] = $i;
for ( $i=0; $i<=23; $i++ ) $hour[] = sprintf("%02d",$i);
for ( $i=0; $i<=59; $i++ ) $minsec[] = sprintf("%02d",$i);
$return->addElement(new htmlOutputText(_('Expiry date')));
$expTable = new htmlTable();
$expTable->addElement(new htmlSelect('exp_day', $mday, array(substr($exp,6,2))));
$expTable->addElement(new htmlSelect('exp_mon', $mon, array(substr($exp,4,2))));
$expTable->addElement(new htmlSelect('exp_yea', $year, array(substr($exp,0,4))));
$expTable->addElement(new htmlSelect('exp_hr', $hour, array(substr($exp,8,2))));
$expTable->addElement(new htmlSelect('exp_min', $minsec, array(substr($exp,10,2))));
$expTable->addElement(new htmlSelect('exp_sec', $minsec, array(substr($exp,12,2))));
$return->addElement($expTable);
$return->addElement(new htmlSpacer(null, '10px'), true);
$buttonTable = new htmlTable();
$buttonTable->addElement(new htmlAccountPageButton('schac', 'attributes', 'change', _('Change')));
if (isset($this->attributes['schacExpiryDate'][0])) {
$buttonTable->addElement(new htmlAccountPageButton('schac', 'attributes', 'del', _('Remove')));
}
$buttonTable->addElement(new htmlAccountPageButton('schac', 'attributes', 'back', _('Cancel')));
$buttonTable->colspan=3;
$return->addElement($buttonTable);
return $return;
}
function process_exp () {
$errors = array();
// set expiration date
if (isset($_POST['form_subpage_schac_attributes_change'])) {
$this->attributes['schacExpiryDate'][0] = $_POST['exp_yea'] . $_POST['exp_mon'] . $_POST['exp_day'] . $_POST['exp_hr'] . $_POST['exp_min'] . $_POST['exp_sec'] . 'Z';
}
// remove expiration date
elseif (isset($_POST['form_subpage_schac_attributes_del'])) {
unset($this->attributes['schacExpiryDate']);
}
return $errors;
}
} // end of class
?>
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/_______________________________________________
Lam-public mailing list
Lam-public@...
https://lists.sourceforge.net/lists/listinfo/lam-public