applied Pavel's patch

This commit is contained in:
Roland Gruber 2011-12-23 09:03:44 +00:00
parent bf20b6e895
commit 68691ae92d
1 changed files with 207 additions and 162 deletions

View File

@ -29,7 +29,7 @@
* *
* @package modules * @package modules
* *
* @author Pavel Pozdnyak * @author Pavel Pozdniak
* @author Roland Gruber * @author Roland Gruber
*/ */
@ -118,7 +118,19 @@ class asteriskExtensionNewUI extends baseModule {
"Headline" => _("Suffix to migrate"), "Headline" => _("Suffix to migrate"),
"Text" => _("This is suffix of LDAP tree to migrate entryes after testing or other staff.") "Text" => _("This is suffix of LDAP tree to migrate entryes after testing or other staff.")
), ),
'UseCreatorAsOwner' => array(
"Headline" => _("Use an extension creator as its owner"),
"Text" => _("This feature hide owner's selection button from an extension managment interface and set a logged in user as an extension owner. You can use this feature as a leverage to grand/reject users to manage thair extensions")
),
); );
// configuration settings
$configContainer = new htmlTable();
$configContainer->addElement(new htmlTableExtendedInputCheckbox('asteriskExtension_UseCreatorAsOwner', false, _('Use a creator as an owner'), 'UseCreatorAsOwner', false));
$return['config_options']['all'] = $configContainer;
// profile options // profile options
$profileContainer = new htmlTable(); $profileContainer = new htmlTable();
$profileContainer->addElement(new htmlTableExtendedInputField(_('Account context'), 'AsteriskExtension_AstContext', null, 'AstContext'), true); $profileContainer->addElement(new htmlTableExtendedInputField(_('Account context'), 'AsteriskExtension_AstContext', null, 'AstContext'), true);
@ -126,14 +138,14 @@ class asteriskExtensionNewUI extends baseModule {
$return['profile_mappings'] = array( $return['profile_mappings'] = array(
'AsteriskExtension_AstContext' => 'AstContext', 'AsteriskExtension_AstContext' => 'AstContext',
); );
// available PDF fields // available PDF fields
$return['PDF_fields'] = array( $return['PDF_fields'] = array(
'AstContext' => _('Account context'), 'AstContext' => _('Account context'),
'AstExtension' => _('Extension name'), 'AstExtension' => _('Extension name'),
'member' => _('Extension owners'), 'member' => _('Extension owners'),
'cn' => _('Common name'), 'cn' => _('Common name'),
'rules' => _('Rules'), 'rules' => _('Rules'),
); );
return $return; return $return;
} }
@ -171,11 +183,23 @@ class asteriskExtensionNewUI extends baseModule {
$this->render_extensions_by_priority($extName, $return); $this->render_extensions_by_priority($extName, $return);
// owners // owners
$return->addElement(new htmlOutputText(_("Extension owners") . '*')); if (!$this->isBooleanConfigOptionSet('asteriskExtension_UseCreatorAsOwner')) {
$return->addElement(new htmlAccountPageButton(get_class($this), 'user', 'open', _('Change'))); $this->render_exten_owners_set_controls($return);
$return->addElement(new htmlHelpLink('member')); }
$return->addNewLine();
$return->addElement(new htmlOutputText('')); return $return;
}
/*
* if necessary this function prints managment elements to manipulate owners of an extension.
*/
function render_exten_owners_set_controls($renderContainer) {
$renderContainer->addElement(new htmlOutputText(_("Extension owners") . '*'));
$renderContainer->addElement(new htmlAccountPageButton(get_class($this), 'user', 'open', _('Change')));
$renderContainer->addElement(new htmlHelpLink('member'));
$renderContainer->addNewLine();
$renderContainer->addElement(new htmlOutputText(''));
$ownerList = new htmlTable(); $ownerList = new htmlTable();
if ((!isset($this->extensionOwners) || sizeof($this->extensionOwners) == 0) && isset($this->extensionRows[0]['member'])) { if ((!isset($this->extensionOwners) || sizeof($this->extensionOwners) == 0) && isset($this->extensionRows[0]['member'])) {
$this->extensionOwners = $this->extensionRows[0]['member']; $this->extensionOwners = $this->extensionRows[0]['member'];
@ -185,35 +209,10 @@ class asteriskExtensionNewUI extends baseModule {
$ownerList->addElement(new htmlOutputText(getAbstractDN($this->extensionOwners[$i])), true); $ownerList->addElement(new htmlOutputText(getAbstractDN($this->extensionOwners[$i])), true);
} }
} }
$return->addElement($ownerList); $renderContainer->addElement($ownerList);
/* * **SOME TEST STAFF**** */
$return->addNewLine();
$selectedSuffix = $this->getAccountContainer()->dnSuffix;
$dn_orig_array = explode(",", $this->getAccountContainer()->dn_orig);
$orig_suffix = implode(",", array_slice($dn_orig_array, 1, count($dn_orig_array)));
//$oldSuffix = $this->getAccountContainer()->dn_orig;
$return->addElement(new htmlOutputText($selectedSuffix . "*"));
$return->addElement(new htmlOutputText($orig_suffix . "*"));
/*
$currentDN = $this->getAccountContainer()->dn_orig;
$currentSuffix = $_SESSION['config']->get_suffix('asteriskExtNewUI');
if(isset ($this->moduleSettings['AsteriskExtension_MigrateSuffix'][0]) && $this->moduleSettings['AsteriskExtension_MigrateSuffix'][0] != ""){
$return->addNewLine();
$return->addElement(new htmlButton("migrate_extention", _('Migrate to suffix : ')), false);
$return->addElement(new htmlOutputText($this->moduleSettings['AsteriskExtension_MigrateSuffix'][0]));
}
*/
return $return;
} }
function load_extension_parts($extension) {
function load_extension_parts($extension){
if (!isset($this->extensionRows[0]['astcontext'][0])) { if (!isset($this->extensionRows[0]['astcontext'][0])) {
//$entries = searchLDAPByAttribute("AstExtension", $extension, $searchClass, array('cn', 'AstContext', 'AstPriority', //$entries = searchLDAPByAttribute("AstExtension", $extension, $searchClass, array('cn', 'AstContext', 'AstPriority',
// 'AstApplication', 'AstApplicationData', 'AstExtension', 'member', 'ObjectClass'), array($searchScope)); // 'AstApplication', 'AstApplicationData', 'AstExtension', 'member', 'ObjectClass'), array($searchScope));
@ -241,37 +240,14 @@ class asteriskExtensionNewUI extends baseModule {
$extension = ""; $extension = "";
} }
//Existing extension case
//$searchClass = "AsteriskExtension";
//$searchScope = 'asteriskExtNewUI';
/*
if (!isset($this->extensionRows[0]['astcontext'][0])) {
//$entries = searchLDAPByAttribute("AstExtension", $extension, $searchClass, array('cn', 'AstContext', 'AstPriority',
// 'AstApplication', 'AstApplicationData', 'AstExtension', 'member', 'ObjectClass'), array($searchScope));
$entries = searchLDAP($this->getAccountContainer()->dnSuffix, '(&(objectClass=AsteriskExtension)(AstExtension=' . $extension . '))', array('cn', 'AstContext', 'AstPriority',
'AstApplication', 'AstApplicationData', 'AstExtension', 'member', 'ObjectClass'));
$entries = $this->array_sort($entries, 'astpriority');
$this->extensionRowsOrig = $entries;
$this->extensionRows = $entries;
} else {
$entries = $this->extensionRows;
}
*/
$entries = $this->load_extension_parts($extension); $entries = $this->load_extension_parts($extension);
//$extNameInput = new htmlTableExtendedInputField(_("Extension name"), 'AstExtension', $extension, 'AstExtension');
//$extNameInput->setRequired(true);
if ($this->getAccountContainer()->isNewAccount) { if ($this->getAccountContainer()->isNewAccount) {
$suggestedExtName = $this->generateNextExtensionName(); $suggestedExtName = $this->generateNextExtensionName();
$extNameInput = new htmlTableExtendedInputField(_("Extension name"), 'AstExtension', $suggestedExtName, 'AstExtension'); $extNameInput = new htmlTableExtendedInputField(_("Extension name"), 'AstExtension', $suggestedExtName, 'AstExtension');
$extNameInput->setRequired(true); $extNameInput->setRequired(true);
$renderContainer->addElement($extNameInput, false); $renderContainer->addElement($extNameInput, false);
//$renderContainer->addElement(new htmlButton("generate_extension_name", _('Generate extension name')), true);
$renderContainer->addElement(new htmlOutputText(_("We suggest: " . $suggestedExtName)), true); $renderContainer->addElement(new htmlOutputText(_("We suggest: " . $suggestedExtName)), true);
} else { } else {
$extNameInput = new htmlTableExtendedInputField(_("Extension name"), 'AstExtension', $extension, 'AstExtension'); $extNameInput = new htmlTableExtendedInputField(_("Extension name"), 'AstExtension', $extension, 'AstExtension');
@ -299,7 +275,8 @@ class asteriskExtensionNewUI extends baseModule {
if ($i > 0) { if ($i > 0) {
$upDownButtons->addElement(new htmlButton('rule_up_button_' . $i, 'up.gif', true), false); $upDownButtons->addElement(new htmlButton('rule_up_button_' . $i, 'up.gif', true), false);
} }
if ($i < sizeof($entries) - 1) { if (($i < sizeof($entries) - 1) &&
((sizeof($entries) > 1) || ($this->addRuleFlag) )) {
$upDownButtons->addElement(new htmlButton('rule_down_button_' . $i, 'down.gif', true)); $upDownButtons->addElement(new htmlButton('rule_down_button_' . $i, 'down.gif', true));
} }
$renderContainer->addElement($upDownButtons, true); $renderContainer->addElement($upDownButtons, true);
@ -308,7 +285,16 @@ class asteriskExtensionNewUI extends baseModule {
$displayEntrNum = sizeof($entries); $displayEntrNum = sizeof($entries);
if ($this->addRuleFlag || sizeof($entries) == 0) { if ($this->addRuleFlag || sizeof($entries) == 0) {
$this->render_extension(null, sizeof($entries), $renderContainer); $this->render_extension(null, sizeof($entries), $renderContainer);
if ($this->addRuleFlag) {
$upDownButtons = new htmlTable();
$renderContainer->addElement(new htmlButton("delete_rule_" . $i, _('Delete rule')), false);
$upDownButtons->addElement(new htmlButton('rule_up_button_' . $i, 'up.gif', true), false);
$renderContainer->addElement($upDownButtons, true);
}
$displayEntrNum++; $displayEntrNum++;
$this->addRuleFlag = false; $this->addRuleFlag = false;
} }
@ -533,11 +519,6 @@ class asteriskExtensionNewUI extends baseModule {
$errors = array_merge($errors, $extrow_errors); $errors = array_merge($errors, $extrow_errors);
} }
/*
if(isset($_POST['migrate_extention']) && count($errors) == 0){
$this->move_extention();
}
*/
} else { } else {
//find new not taken extension name //find new not taken extension name
$this->extensionRows[0]['astextension'][0] = $this->generateNextExtensionName(); $this->extensionRows[0]['astextension'][0] = $this->generateNextExtensionName();
@ -549,48 +530,20 @@ class asteriskExtensionNewUI extends baseModule {
function processExtensionRows($extensionName, $extensionContext) { function processExtensionRows($extensionName, $extensionContext) {
$errors = array(); $errors = array();
if (isset($_POST['extension_rows']) && get_preg($_POST['extension_rows'], 'digit')) { if (isset($_POST['extension_rows']) && get_preg($_POST['extension_rows'], 'digit')) {
//handle situation where we mast add current loged user as extension owner
if ($this->isBooleanConfigOptionSet('asteriskExtension_UseCreatorAsOwner')){
$this->setDefaultExtensionOwner();
}
$extensionPriorityCntr = 1; $extensionPriorityCntr = 1;
$this->extensionRows = array(); $this->extensionRows = array();
for ($entryCounter = 0; $entryCounter < $_POST['extension_rows']; $entryCounter++) { for ($entryCounter = 0; $entryCounter < $_POST['extension_rows']; $entryCounter++) {
$extRow = array(); $extRow = array();
if (!isset($_POST['delete_rule_' . $entryCounter])) { if (!isset($_POST['delete_rule_' . $entryCounter])) {
//if (isset($_POST['AstApplication_' . $entryCounter]) && $_POST['AstApplication_' . $entryCounter] != '') {
if (isset($extensionContext[0])) { $singleExtAddErrors = $this->processSingleExtension($extRow,$extensionName, $extensionContext, $entryCounter,$extensionPriorityCntr);
$extRow['astcontext'][0] = $extensionContext[0]; $errors = $errors + $singleExtAddErrors;
}
if (isset($extensionName[0])) {
$extRow['astextension'][0] = $extensionName[0];
}
$extRow["objectclass"][0] = "top";
$extRow["objectclass"][1] = "groupOfNames";
$extRow["objectclass"][2] = "AsteriskExtension";
$extRow['astapplication'][0] = $_POST['AstApplication_' . $entryCounter];
if (!isset($_POST['AstApplication_' . $entryCounter]) || $_POST['AstApplication_' . $entryCounter] == '') {
if ($entryCounter < ($_POST['extension_rows'] - 1)) {
$errors[] = $this->messages['AstApplication'][0];
}
}
$extRow['astpriority'][0] = $extensionPriorityCntr;
$extRow['cn'][0] = $extRow['astextension'][0] . "-" . $extRow['astpriority'][0];
//$extRow['dn'] = "cn=" . $extRow['cn'][0] . "," . $_SESSION['config']->get_Suffix('asteriskExtNewUI');
if (isset($_POST['AstApplicationData_' . $entryCounter]) && $_POST['AstApplicationData_' . $entryCounter] != "") {
$extRow['astapplicationdata'][0] = $_POST['AstApplicationData_' . $entryCounter];
}
//Fille the member filed
$extRow['member'] = $this->extensionOwners;
if (!isset($extRow['member']) || count($extRow['member']) == 0) {
if (!isset($_POST['form_subpage_' . get_class($this) . '_user_open'])) {
$errors[] = $this->messages['member'][0];
}
}
if ((isset($extRow['astapplication'][0]) && $extRow['astapplication'][0] != "") || if ((isset($extRow['astapplication'][0]) && $extRow['astapplication'][0] != "") ||
(isset($extRow['astapplicationdata'][0]) && $extRow['astapplicationdata'][0] != "") (isset($extRow['astapplicationdata'][0]) && $extRow['astapplicationdata'][0] != "")
@ -600,28 +553,92 @@ class asteriskExtensionNewUI extends baseModule {
} }
} }
} }
//trow error banner if last row unporpertly filled (for now the only reason for that is unfilled AstApplication filed) //trow error banner if last row unporpertly filled (for now the only reason for that is unfilled AstApplication filed)
if (isset($_POST['AstApplicationData_' . ($_POST['extension_rows'] - 1)]) && $_POST['AstApplicationData_' . ($_POST['extension_rows'] - 1)] != "" && if (isset($_POST['AstApplicationData_' . ($_POST['extension_rows'] - 1)]) && $_POST['AstApplicationData_' . ($_POST['extension_rows'] - 1)] != "" &&
($_POST['AstApplication_' . ($_POST['extension_rows'] - 1)] == "" || !isset($_POST['AstApplication_' . ($_POST['extension_rows'] - 1)]))) { ($_POST['AstApplication_' . ($_POST['extension_rows'] - 1)] == "" || !isset($_POST['AstApplication_' . ($_POST['extension_rows'] - 1)]))) {
$errors[] = $this->messages['AstApplication'][0]; $errors[] = $this->messages['AstApplication'][0];
} }
//process priority rule
for ($entryCounter = 0; $entryCounter < sizeof($this->extensionRows); $entryCounter++) {
if (isset($_POST["rule_up_button_" . $entryCounter])) {
$this->extensionRows[$entryCounter]['astpriority'][0]--; //process priority change on rule
$this->extensionRows[$entryCounter - 1]['astpriority'][0]++; $this->processPriorityChange();
} else if (isset($_POST["rule_down_button_" . $entryCounter])) {
$this->extensionRows[$entryCounter]['astpriority'][0]++; //finally sort extensions by priority
$this->extensionRows[$entryCounter + 1]['astpriority'][0]--;
}
}
$this->extensionRows = $this->array_sort($this->extensionRows, 'astpriority'); $this->extensionRows = $this->array_sort($this->extensionRows, 'astpriority');
} }
return $errors; return $errors;
} }
/*
* Set extension owner as current logged in user.
*/
function setDefaultExtensionOwner(){
$credentials = $_SESSION['ldap']->decrypt_login();
$login = $credentials[0];
$this->extensionOwners[0] = $login;
}
/*
* Fill fileds of single extension row
* In Asterisk it would only be an extension name,a priority,an application, but LDAP spicific
* add to processing context filed.
* @param $extRow - hash array to store single extension properties;
* @param $entryCounter - counter to distinguish single extensuion properties from $_POST
* @param $extensionPriorityCntr - it is the variable where actual number of extension rules wuld be aggregated
*/
function processSingleExtension(&$extRow,$extensionName, $extensionContext ,$entryCounter,$extensionPriorityCntr) {
$errors = array();
if (isset($extensionContext[0])) {
$extRow['astcontext'][0] = $extensionContext[0];
}
if (isset($extensionName[0])) {
$extRow['astextension'][0] = $extensionName[0];
}
$extRow["objectclass"][0] = "top";
$extRow["objectclass"][1] = "groupOfNames";
$extRow["objectclass"][2] = "AsteriskExtension";
$extRow['astapplication'][0] = $_POST['AstApplication_' . $entryCounter];
if (!isset($_POST['AstApplication_' . $entryCounter]) || $_POST['AstApplication_' . $entryCounter] == '') {
if ($entryCounter < ($_POST['extension_rows'] - 1)) {
$errors[] = $this->messages['AstApplication'][0];
}
}
$extRow['astpriority'][0] = $extensionPriorityCntr;
$extRow['cn'][0] = $extRow['astextension'][0] . "-" . $extRow['astpriority'][0];
if (isset($_POST['AstApplicationData_' . $entryCounter]) && $_POST['AstApplicationData_' . $entryCounter] != "") {
$extRow['astapplicationdata'][0] = $_POST['AstApplicationData_' . $entryCounter];
}
//Fille the member filed
$extRow['member'] = $this->extensionOwners;
if (!isset($extRow['member']) || count($extRow['member']) == 0) {
if (!isset($_POST['form_subpage_' . get_class($this) . '_user_open'])) {
$errors[] = $this->messages['member'][0];
}
}
return $errors;
}
function processPriorityChange() {
for ($entryCounter = 0; $entryCounter < sizeof($this->extensionRows); $entryCounter++) {
if (isset($_POST["rule_up_button_" . $entryCounter])) {
$this->extensionRows[$entryCounter]['astpriority'][0]--;
$this->extensionRows[$entryCounter - 1]['astpriority'][0]++;
} else if (isset($_POST["rule_down_button_" . $entryCounter])) {
$this->extensionRows[$entryCounter]['astpriority'][0]++;
$this->extensionRows[$entryCounter + 1]['astpriority'][0]--;
}
}
}
/* /*
* Search by extension name and retun true if fileds wtith this extension name is presented * Search by extension name and retun true if fileds wtith this extension name is presented
* and false otherwise. * and false otherwise.
@ -679,45 +696,80 @@ class asteriskExtensionNewUI extends baseModule {
$extName = $this->extensionRows[0]['astextension'][0]; $extName = $this->extensionRows[0]['astextension'][0];
} }
// global values // global values
if (isset($this->attributes['AstContext'])) { if (isset($this->attributes['AstContext'])) {
$return[get_class($this) . '_AstContext'] = array('<block><key>' . _('Account context') . '</key><value>' . $this->attributes['AstContext'][0] . '</value></block>'); $return[get_class($this) . '_AstContext'] = array('<block><key>' . _('Account context') . '</key><value>' . $this->attributes['AstContext'][0] . '</value></block>');
} }
if (isset($this->attributes['AstExtension'])) { if (isset($this->attributes['AstExtension'])) {
$return[get_class($this) . '_AstExtension'] = array('<block><key>' . _('Extension name') . '</key><value>' . $this->attributes['AstExtension'][0] . '</value></block>'); $return[get_class($this) . '_AstExtension'] = array('<block><key>' . _('Extension name') . '</key><value>' . $this->attributes['AstExtension'][0] . '</value></block>');
} }
if (isset($this->attributes['member'])) { if (isset($this->attributes['member'])) {
$return[get_class($this) . '_member'] = array('<block><key>' . _('Extension owners') . '</key><value>' . implode('; ', $this->attributes['member']) . '</value></block>'); $return[get_class($this) . '_member'] = array('<block><key>' . _('Extension owners') . '</key><value>' . implode('; ', $this->attributes['member']) . '</value></block>');
} }
if (isset($this->attributes['cn'])) { if (isset($this->attributes['cn'])) {
$return[get_class($this) . '_cn'] = array('<block><key>' . _('Common name') . '</key><value>' . $this->attributes['cn'][0] . '</value></block>'); $return[get_class($this) . '_cn'] = array('<block><key>' . _('Common name') . '</key><value>' . $this->attributes['cn'][0] . '</value></block>');
} }
// rules // rules
$entries = $this->load_extension_parts($extName); $entries = $this->load_extension_parts($extName);
$rulePDF = array(); $rulePDF = array();
$rulePDF[] = '<block><tr><td width="80%"> </td></tr></block>'; $rulePDF[] = '<block><tr><td width="80%"> </td></tr></block>';
$rulePDF[] = '<block><tr><td width="80%"> </td></tr></block>'; $rulePDF[] = '<block><tr><td width="80%"> </td></tr></block>';
$rulePDF[] = '<block><tr><td width="80%"> </td></tr></block>'; $rulePDF[] = '<block><tr><td width="80%"> </td></tr></block>';
$rulePDF[] = '<block><tr>' . $rulePDF[] = '<block><tr>' .
'<td width="20%"><b>' . _('Name') . '</b></td>' . '<td width="20%"><b>' . _('Name') . '</b></td>' .
'<td width="30%"><b>' . _('Application') . '</b></td>' . '<td width="30%"><b>' . _('Application') . '</b></td>' .
'<td width="30%"><b>' . _('Application data') . '</b></td>' . '<td width="30%"><b>' . _('Application data') . '</b></td>' .
'<td width="20%"><b>' . _('Priority') . '</b></td>' . '<td width="20%"><b>' . _('Priority') . '</b></td>' .
'</tr></block>'; '</tr></block>';
for ($i = 0; $i < sizeof($entries); $i++) { for ($i = 0; $i < sizeof($entries); $i++) {
$appdata = ''; $appdata = '';
if (isset($entries[$i]['astapplicationdata'][0])) { if (isset($entries[$i]['astapplicationdata'][0])) {
$appdata = $entries[$i]['astapplicationdata'][0]; $appdata = $entries[$i]['astapplicationdata'][0];
} }
$rulePDF[] = '<block><tr>' . $rulePDF[] = '<block><tr>' .
'<td width="20%" align=\"L\">' . $entries[$i]['cn'][0] . '</td>' . '<td width="20%" align=\"L\">' . $entries[$i]['cn'][0] . '</td>' .
'<td width="30%" align=\"L\">' . $entries[$i]['astapplication'][0] . '</td>' . '<td width="30%" align=\"L\">' . $entries[$i]['astapplication'][0] . '</td>' .
'<td width="30%" align=\"L\">' . $appdata . '</td>' . '<td width="30%" align=\"L\">' . $appdata . '</td>' .
'<td width="20%" align=\"L\">' . $entries[$i]['astpriority'][0] . '</td></tr></block>'; '<td width="20%" align=\"L\">' . $entries[$i]['astpriority'][0] . '</td></tr></block>';
} }
$return[get_class($this) . '_rules'] = $rulePDF; $return[get_class($this) . '_rules'] = $rulePDF;
return $return; return $return;
} }
/**
* In this function the LDAP account is built up.
*
* @param array $rawAccounts list of hash arrays (name => value) from user input
* @param array $partialAccounts list of hash arrays (name => value) which are later added to LDAP
* @param array $ids list of IDs for column position (e.g. "posixAccount_uid" => 5)
* @param array $selectedModules list of selected account modules
* @return array list of error messages if any
*/
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
$messages = array();
for ($i = 0; $i < sizeof($rawAccounts); $i++) {
// add object class
if (!in_array("AsteriskExtension", $partialAccounts[$i]['objectClass']))
$partialAccounts[$i]['objectClass'][] = "AsteriskExtension";
if (!in_array("groupOfNames", $partialAccounts[$i]['objectClass']))
$partialAccounts[$i]['objectClass'][] = "groupOfNames";
// attributes
$partialAccounts[$i]['cn'] = $rawAccounts[$i][$ids['asteriskExtension_cn']];
$partialAccounts[$i]['AstExtension'] = $rawAccounts[$i][$ids['asteriskExtension_AstExtension']];
$partialAccounts[$i]['AstPriority'] = $rawAccounts[$i][$ids['asteriskExtension_AstPriority']];
$partialAccounts[$i]['member'] = explode(';', $rawAccounts[$i][$ids['asteriskExtension_member']]);
if ($rawAccounts[$i][$ids['asteriskExtension_AstApplication']] != "") {
$partialAccounts[$i]['AstApplication'] = $rawAccounts[$i][$ids['asteriskExtension_AstApplication']];
}
if ($rawAccounts[$i][$ids['asteriskExtension_AstApplicationData']] != "") {
$partialAccounts[$i]['AstApplicationData'] = $rawAccounts[$i][$ids['asteriskExtension_AstApplicationData']];
}
if ($rawAccounts[$i][$ids['asteriskExtension_AstContext']] != "") {
$partialAccounts[$i]['AstContext'] = $rawAccounts[$i][$ids['asteriskExtension_AstContext']];
}
}
return $messages;
}
//public //public
function save_attributes() { function save_attributes() {
@ -733,29 +785,23 @@ class asteriskExtensionNewUI extends baseModule {
$row = $this->extensionRows[$rowCounter]; $row = $this->extensionRows[$rowCounter];
if (count($diffVals = array_diff_key($rowOrig, $row)) != 0) { if (count($diffVals = array_diff_key($rowOrig, $row)) != 0) {
//ldap_mod_del($_SESSION['ldap']->server(), "cn=" . $row["cn"][0] . "," . $_SESSION['config']->get_Suffix('asteriskExtNewUI'), $diffVals);
ldap_mod_del($_SESSION['ldap']->server(), "cn=" . $row["cn"][0] . "," . $this->getAccountContainer()->dnSuffix, $diffVals); ldap_mod_del($_SESSION['ldap']->server(), "cn=" . $row["cn"][0] . "," . $this->getAccountContainer()->dnSuffix, $diffVals);
} }
if (count($diffVals = array_diff_key($row, $rowOrig)) != 0) { if (count($diffVals = array_diff_key($row, $rowOrig)) != 0) {
//ldap_mod_add($_SESSION['ldap']->server(), "cn=" . $row["cn"][0] . "," . $_SESSION['config']->get_Suffix('asteriskExtNewUI'), $diffVals);
ldap_mod_add($_SESSION['ldap']->server(), "cn=" . $row["cn"][0] . "," . $this->getAccountContainer()->dnSuffix, $diffVals); ldap_mod_add($_SESSION['ldap']->server(), "cn=" . $row["cn"][0] . "," . $this->getAccountContainer()->dnSuffix, $diffVals);
} }
$diffValsSerialysed = array_diff(array_map("serialize", array_intersect_key($row, $rowOrig)), array_map("serialize", $rowOrig)); $diffValsSerialysed = array_diff(array_map("serialize", array_intersect_key($row, $rowOrig)), array_map("serialize", $rowOrig));
if (count($diffValsSerialysed) != 0) { if (count($diffValsSerialysed) != 0) {
$diffVals = array_map("unserialize", $diffValsSerialysed); $diffVals = array_map("unserialize", $diffValsSerialysed);
//ldap_mod_replace($_SESSION['ldap']->server(), "cn=" . $row["cn"][0] . "," . $_SESSION['config']->get_Suffix('asteriskExtNewUI'), $diffVals);
ldap_mod_replace($_SESSION['ldap']->server(), "cn=" . $row["cn"][0] . "," . $this->getAccountContainer()->dnSuffix, $diffVals); ldap_mod_replace($_SESSION['ldap']->server(), "cn=" . $row["cn"][0] . "," . $this->getAccountContainer()->dnSuffix, $diffVals);
} }
} else { } else {
//ldap_delete($_SESSION['ldap']->server(), "cn=" . $rowOrig["cn"][0] . "," . $_SESSION['config']->get_Suffix('asteriskExtNewUI'));
ldap_delete($_SESSION['ldap']->server(), "cn=" . $rowOrig["cn"][0] . "," . $_SESSION['config']->get_Suffix('asteriskExtNewUI')); ldap_delete($_SESSION['ldap']->server(), "cn=" . $rowOrig["cn"][0] . "," . $_SESSION['config']->get_Suffix('asteriskExtNewUI'));
} }
} }
//Add new config rows //Add new config rows
for ($rowCounter = count($this->extensionRowsOrig); $rowCounter < count($this->extensionRows); $rowCounter++) { for ($rowCounter = count($this->extensionRowsOrig); $rowCounter < count($this->extensionRows); $rowCounter++) {
$row = $this->extensionRows[$rowCounter]; $row = $this->extensionRows[$rowCounter];
//ldap_add($_SESSION['ldap']->server(), "cn=" . $row["cn"][0] . "," . $_SESSION['config']->get_Suffix('asteriskExtNewUI'), $row);
ldap_add($_SESSION['ldap']->server(), "cn=" . $row["cn"][0] . "," . $this->getAccountContainer()->dnSuffix, $row); ldap_add($_SESSION['ldap']->server(), "cn=" . $row["cn"][0] . "," . $this->getAccountContainer()->dnSuffix, $row);
} }
return $this->getAccountContainer()->save_module_attributes($this->orig, $this->orig); return $this->getAccountContainer()->save_module_attributes($this->orig, $this->orig);
@ -774,7 +820,6 @@ class asteriskExtensionNewUI extends baseModule {
$entries = searchLDAPByAttribute("AstExtension", $extension, $searchClass, array('cn', 'AstContext', 'AstPriority', $entries = searchLDAPByAttribute("AstExtension", $extension, $searchClass, array('cn', 'AstContext', 'AstPriority',
'AstApplication', 'AstApplicationData', 'AstExtension', 'member', 'ObjectClass'), array($searchScope)); 'AstApplication', 'AstApplicationData', 'AstExtension', 'member', 'ObjectClass'), array($searchScope));
$entries = $this->array_sort($entries, 'astpriority'); $entries = $this->array_sort($entries, 'astpriority');
//$this->extensionRowsOrig = $entries;
for ($rowCounter = 0; $rowCounter < count($entries); $rowCounter++) { for ($rowCounter = 0; $rowCounter < count($entries); $rowCounter++) {
$rowOrig = $entries[$rowCounter]; $rowOrig = $entries[$rowCounter];