Example #1
0
function getLinesForm($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf, $validationError)
{
    $paloEndPoint = new paloSantoEndPoint($dsnAsterisk, $dsnSqlite);
    $arrSession = getSession();
    $mac = $arrSession["endpoint_configurator"]["mac"];
    if (!$validationError) {
        $arrParameters = $paloEndPoint->getEndpointParameters($mac);
        if ($arrParameters === false) {
            $smarty->assign("mb_title", _tr("ERROR"));
            $smarty->assign("mb_message", _tr("In the query to database endpoint.db"));
            return endpointConfiguratedShow($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf);
        }
        $_DATA = array();
        foreach ($arrParameters as $key => $parameter) {
            $_DATA[$parameter["name"]] = $parameter["value"];
        }
        $_DATA = array_merge($_DATA, $_POST);
        for ($i = 0; $i < $arrSession["endpoint_configurator"]["analog_extension_lines"]; $i++) {
            if (getParameter("user{$i}") == "" || getParameter("authentication_user{$i}") == "") {
                $smarty->assign("mb_title", _tr("Validation Error"));
                $smarty->assign("mb_message", _tr("Fields User and Authentication User can not be empty"));
                return getExtensionsForm($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf, true);
            } else {
                $arrSession["endpoint_configurator"]["user_name{$i}"] = getParameter("user_name{$i}");
                $arrSession["endpoint_configurator"]["user{$i}"] = getParameter("user{$i}");
                $arrSession["endpoint_configurator"]["authentication_user{$i}"] = getParameter("authentication_user{$i}");
            }
        }
        putSession($arrSession);
    } else {
        $_DATA = $_POST;
    }
    if ($arrSession["endpoint_configurator"]["analog_trunk_lines"] > 0) {
        $smarty->assign("REQUIRED_FIELD", _tr("Required field"));
        $smarty->assign("CANCEL", _tr("Cancel"));
        $smarty->assign("SAVE", _tr("Save"));
        $smarty->assign("RETURN", _tr("Return"));
        $smarty->assign("IMG", "/modules/{$module_name}/images/patton.png");
        if ($arrSession["endpoint_configurator"]["analog_extension_lines"] > 0) {
            $smarty->assign("RETURN2", "return2");
        } else {
            $smarty->assign("RETURN2", "return1");
        }
        $fields = "";
        $model = $arrSession["endpoint_model"][$arrSession["endpoint_configurator"]["mac"]];
        $title = _tr("Lines Configuration for Patton") . " {$model}";
        for ($i = 0; $i < $arrSession["endpoint_configurator"]["analog_trunk_lines"]; $i++) {
            if (!isset($_DATA["line{$i}"])) {
                $_DATA["line{$i}"] = 10015 + $i;
            }
            if (!isset($_DATA["ID{$i}"])) {
                $_DATA["ID{$i}"] = 10015 + $i;
            }
            if (!isset($_DATA["authentication_ID{$i}"])) {
                $_DATA["authentication_ID{$i}"] = 10015 + $i;
            }
            $number = $i + 1;
            $fields .= "<tr class='letra12'>\n                          <td><b>" . _tr("Line") . " {$number}:</b> <span  class='required'>*</span></td>\n                          <td width='25%'><input type='text' maxlength='100' style='width: 200px;' value='" . $_DATA["line{$i}"] . "' name='line{$i}'></td>\n                          <td><b>ID {$number}: <span  class='required'>*</span></b></td>\n                          <td><input type='text' maxlength='100' style='width: 200px;' value='" . $_DATA["ID{$i}"] . "' name='ID{$i}'></td>\n                          <td><b>" . _tr("Authentication ID") . " {$number}:</b> <span  class='required'>*</span></td>\n                          <td><input type='text' maxlength='100' style='width: 200px;' value='" . $_DATA["authentication_ID{$i}"] . "' name='authentication_ID{$i}'></td>\n                      </tr>";
        }
        $smarty->assign("fields", $fields);
        $oForm = new paloForm($smarty, array());
        $htmlForm = $oForm->fetchForm("{$local_templates_dir}/patton_lines.tpl", $title, $_DATA);
        $content = "<form  method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>";
    } else {
        $content = savePatton($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf);
    }
    return $content;
}
Example #2
0
/**
 * Display 'Extensions' page.
 */
function pageExtensions()
{
    global $PIVOTX;
    // check if the user has the required userlevel to view this page.
    $PIVOTX['session']->minLevel(PIVOTX_UL_ADMIN);
    $PIVOTX['template']->assign('title', __('Extensions'));
    $PIVOTX['template']->assign('heading', __('Manage installed Extensions'));
    $list = $PIVOTX['extensions']->scanExtensions();
    // Set the 'compact' or 'expanded' view for the current user..
    $currentuser = $PIVOTX['session']->currentUsername();
    $compactview = unserialize($PIVOTX['config']->get('compactview'));
    $PIVOTX['template']->assign('compactview', isset($compactview[$currentuser]) ? "1" : "0");
    // Set the identifier
    $identifiers = $PIVOTX['extensions']->getIdentifiers(array('admin', 'snippet', 'hook'));
    $PIVOTX['template']->assign("identifiers", implode(",", $identifiers));
    $form = getExtensionsForm($list);
    // Get the validation result
    $result = $form->validate();
    if ($result != FORM_OK) {
        $PIVOTX['template']->assign("form", $form->fetch());
    } else {
        // Start out with the current widgets, because we don't want to
        // change those..
        $activated = $PIVOTX['extensions']->getActivated('widget_');
        // Add the selected ones from $_POST
        unset($_POST['csrfcheck']);
        foreach ($_POST as $name => $value) {
            if ($value == 1) {
                $activated[] = $name;
            }
        }
        // Set them as activated.
        $PIVOTX['extensions']->setActivated($activated);
        $PIVOTX['events']->add('activate_extensions', $activated);
        $message = urlencode(__("Your Extension settings have been stored."));
        // Reload the page, because we want to make sure the new extensions are loaded and initialized..
        header("Location: index.php?page=extensions&px_message=" . $message);
        die;
    }
    renderTemplate('extensions.tpl');
}