function languages_hook_core($viewing_itemid, $target_menuid)
{
    $request = $_REQUEST;
    $extension = isset($request['extension']) ? $request['extension'] : '';
    $cidnum = isset($request['cidnum']) ? $request['cidnum'] : '';
    $extdisplay = isset($request['extdisplay']) ? $request['extdisplay'] : '';
    $action = isset($request['action']) ? $request['action'] : '';
    $language = isset($request['language']) ? $request['language'] : '';
    //set $extension,$cidnum if we dont already have them
    if (!$extension && !$cidnum) {
        $opts = explode('/', $extdisplay);
        $extension = $opts['0'];
        $cidnum = isset($opts['1']) ? $opts['1'] : '';
    } else {
        $extension = $extension;
        $cidnum = $cidnum;
    }
    //update if we have enough info
    if ($action == 'edtIncoming' || ($extension != '' || $cidnum != '') && $language != '') {
        languages_incoming_update($language = $language, $extension, $cidnum);
    }
    if ($action == 'delIncoming') {
        languages_incoming_delete($extension, $cidnum);
    }
    $html = '';
    if ($target_menuid == 'did') {
        $html .= '
			<!--Language-->
			<div class="element-container">
				<div class="row">
					<div class="col-md-12">
						<div class="row">
							<div class="form-group">
								<div class="col-md-3">
									<label class="control-label" for="language">' . _("Language") . '</label>
									<i class="fa fa-question-circle fpbx-help-icon" data-for="language"></i>
								</div>
								<div class="col-md-9">
		';
        $language = languages_incoming_get($extension, $cidnum);
        if (FreePBX::Modules()->moduleHasMethod('Soundlang', 'getLanguages')) {
            $languages = FreePBX::Soundlang()->getLanguages();
            $html .= '<select class="form-control" id="language" name="language">';
            $html .= '<option value=""' . ($language == "" ? "SELECTED" : "") . '>' . _("Default") . '</option>';
            foreach ($languages as $key => $val) {
                $html .= '<option value="' . $key . '"' . ($language == $key ? "SELECTED" : "") . '>' . $val . '</option>';
            }
            $html .= '</select>';
        } else {
            $html .= '<input type="text" class="form-control" id="language" name="language" value="' . $language . '">';
        }
        $html .= '
								</div>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-md-12">
						<span id="language-help" class="help-block fpbx-help-block">' . _("Allows you to set the language for this DID.") . '</span>
					</div>
				</div>
			</div>
			<!--END Language-->
		';
    }
    return $html;
}
Esempio n. 2
0
function languages_hook_core($viewing_itemid, $target_menuid)
{
    $extension = isset($_REQUEST['extension']) ? $_REQUEST['extension'] : '';
    $cidnum = isset($_REQUEST['cidnum']) ? $_REQUEST['cidnum'] : '';
    $extdisplay = isset($_REQUEST['extdisplay']) ? $_REQUEST['extdisplay'] : '';
    $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
    $language = isset($_REQUEST['language']) ? $_REQUEST['language'] : '';
    //set $extension,$cidnum if we dont already have them
    if (!isset($extension) && !isset($cidnum)) {
        $opts = explode('/', $extdisplay);
        $extension = $opts['0'];
        $cidnum = $opts['1'];
    } else {
        $extension = $extension;
        $cidnum = $cidnum;
    }
    //update if we have enough info
    if ($action == 'edtIncoming' || ($extension != '' || $cidnum != '') && $language != '') {
        languages_incoming_update($language = $language, $extension, $cidnum);
    }
    if ($action == 'delIncoming') {
        languages_incoming_delete($extension, $cidnum);
    }
    $html = '';
    if ($target_menuid == 'did') {
        $html .= '<tr><td colspan="2"><h5>' . _("Language") . '<hr></h5></td></tr>';
        $html .= '<tr><td><a href="#" class="info">' . _('Language') . '<span>' . _("Allows you to set the language for this DID.") . '</span></a>:</td>';
        $html .= '<td><input type="text" name="language" value="' . languages_incoming_get($extension, $cidnum) . '"></td></tr>';
    }
    return $html;
}