Location: PHPKode > projects > PushOk SEMA > html/web/contact/contact_prefs.php
<?PHP
// Pushok's SEMA (Small Enterprise Management Application)
//
// Copyright (C) 2004 Pushok Software http://www.pushok.com
//
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html

/*
subscription: contain form to create new preference or modify existing.
*/
class web_Contact extends web_Layout 
{
	function Info()
	{
		$this->formStart("");
		$this->MenuPrefs();
		$this->EmailEncodPrefs();
		$this->ClientEncodingPrefs();
		$this->SemaLanguagePrefs();
		$this->formEnd();
		?>
		<?PHP
	}
	
	function MenuPrefs() {
		$_oIn = array('idcontact'=>$_SESSION['iduser'], 'key'=>'web_mylinks');
		$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_CONTACT_PREFERENCE_SEARCH", $_oIn, $arPrefs);
		$this->formSection(_LW("My menues"));
		$this->formItem("", "subitem");
		$this->tableStart();
		$arHeader = array( 
			array('value'=>_LW('Priority'), 'colspan'=>0, 'align'=>'left'),
			array('value'=>_LW('Name'), 'colspan'=>0, 'align'=>'left'),
			array('value'=>_LW('Link'), 'colspan'=>0, 'align'=>'left'),
			array('value'=>_LW('Action'), 'colspan'=>0, 'align'=>'left')
							);
		$this->tableHeader($arHeader);
		
		if ( isset($arPrefs['value']) && strlen($arPrefs['value']) )
		{
			$arMenues = unserialize($arPrefs['value']);
			foreach ($arMenues as $key=>$arInfo) {
				$this->tableRow();
				$this->tableCol($arInfo['priority']);
				$this->tableCol($arInfo['name']);
				$this->tableCol($arInfo['link']);
				
				$_oIn=array('idobject'=>$_SESSION['iduser'], 'type'=>ID_SEMA_CONTACT, 'form_name'=>"GT_CONTACT_WEBLINKS", 'id'=>$key);
				$GLOBALS['WEB_DISPATCHER']->ProcessMessage("WM_ACTION_MENU_CREATE", $_oIn, $_oOut=array());
				
				$this->tableCol();
				if (count($_oOut)) {
					krsort($_oOut);
					foreach ($_oOut as $nPriority=>$arMenues) 
						foreach ($arMenues as $sName => $arData)
        	            	echo $this->singleItem("action",$sName,$arData);
				}
			}
		}
		$this->tableRow();
		echo "<FORM method=\"POST\">\n";
        echo "<INPUT type=\"hidden\" name=\"idform\" value=\"FM_CONTACT_PREFS_WLINKS\"></INPUT>\n";
        echo "<INPUT type=\"hidden\" name=\"onsuccess\" value=\"?".web_GetPageGetParams()."\"></INPUT>\n";
        echo "<INPUT type=\"hidden\" name=\"onerror\" value=\"?".web_GetPageGetParams()."\"></INPUT>\n";
        echo "<INPUT type=\"hidden\" name=\"idcontact\" value=\"".$_SESSION['iduser']."\"></INPUT>\n";
        echo "<INPUT type=\"hidden\" name=\"key\" value=\"web_mylinks\"></INPUT>\n";
        $this->tableCol($this->singleInputItem(false, "edit", 'priority', "", array('size'=>5)));
        $this->tableCol($this->singleInputItem(false, "edit", 'name', "", array('size'=>15)));
        $this->tableCol($this->singleInputItem(false, "edit", 'link', "", array('size'=>20)));
        $this->tableCol($this->singleInputItem(_LW("Add"), "submit"));
        echo "</FORM>\n";
        $this->tableEnd();
	}
	
	function EmailEncodPrefs() {
		$_oIn = array('idcontact'=>$_SESSION['iduser'], 'key'=>'web_email_encode');
		$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_CONTACT_PREFERENCE_SEARCH", $_oIn, $arPrefs);
		$sFieldValue = "";
		if (isset($arPrefs['id']) && $arPrefs['id']>0)
			$sFieldValue = $arPrefs['value'];
		$this->formSection(_LW("E-mail encoding"));
		echo "<FORM method=\"POST\">\n";
        echo "<INPUT type=\"hidden\" name=\"idform\" value=\"FM_CONTACT_PREFS_EMAILENCODE\"></INPUT>\n";
        echo "<INPUT type=\"hidden\" name=\"onsuccess\" value=\"?".web_GetPageGetParams()."\"></INPUT>\n";
        echo "<INPUT type=\"hidden\" name=\"onerror\" value=\"?".web_GetPageGetParams()."\"></INPUT>\n";
        echo "<INPUT type=\"hidden\" name=\"idcontact\" value=\"".$_SESSION['iduser']."\"></INPUT>\n";
        echo "<INPUT type=\"hidden\" name=\"key\" value=\"web_email_encode\"></INPUT>\n";
        $arCharSets = array('koi8-r'=>"Cyrillic koi8-r", 'windows-1251'=>"Cyrillic Windows-1251", 'windows-1252'=>"Western Windows-1252", 'iso-8859-1'=>"Western ISO-8859-1");
        $this->formInputItem(_LW("Charset"), "select", "charset", $sFieldValue, $arCharSets);
        $this->formInputItem(_LW("Set"), "submit");
        echo "</FORM>\n";
	}
	
	function ClientEncodingPrefs() {
		$_oIn = array('idcontact'=>$_SESSION['iduser'], 'key'=>'web_client_encode');
		$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_CONTACT_PREFERENCE_SEARCH", $_oIn, $arPrefs);
		$sFieldValue = "";
		if (isset($arPrefs['id']) && $arPrefs['id']>0)
			$sFieldValue = $arPrefs['value'];
		$this->formSection(_LW("Client encoding"));
		echo "<FORM method=\"POST\">\n";
        echo "<INPUT type=\"hidden\" name=\"idform\" value=\"FM_CONTACT_PREFS_CLIENTENCODE\"></INPUT>\n";
        echo "<INPUT type=\"hidden\" name=\"onsuccess\" value=\"?".web_GetPageGetParams()."\"></INPUT>\n";
        echo "<INPUT type=\"hidden\" name=\"onerror\" value=\"?".web_GetPageGetParams()."\"></INPUT>\n";
        echo "<INPUT type=\"hidden\" name=\"idcontact\" value=\"".$_SESSION['iduser']."\"></INPUT>\n";
        echo "<INPUT type=\"hidden\" name=\"key\" value=\"web_client_encode\"></INPUT>\n";
        $arCharSets = array('koi8-r'=>"Cyrillic koi8-r", 'windows-1251'=>"Cyrillic Windows-1251", 'windows-1252'=>"Western Windows-1252", 'iso-8859-1'=>"Western ISO-8859-1",'utf-8'=>"Unicode utf-8");
        $this->formInputItem(_LW("Charset"), "select", "charset", $sFieldValue, $arCharSets);
        $this->formInputItem(_LW("Set"), "submit");
        echo "</FORM>\n";
	}
	
	function SemaLanguagePrefs() {
		$_oIn = array('idcontact'=>$_SESSION['iduser'], 'key'=>'web_sema_lang');
		$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_CONTACT_PREFERENCE_SEARCH", $_oIn, $arPrefs);
		$sFieldValue = "";
		if (isset($arPrefs['id']) && $arPrefs['id']>0)
			$sFieldValue = $arPrefs['value'];
		$this->formSection(_LW("SEMA language"));
		echo "<FORM method=\"POST\">\n";
        echo "<INPUT type=\"hidden\" name=\"idform\" value=\"FM_CONTACT_PREFS_SEMALANG\"></INPUT>\n";
        echo "<INPUT type=\"hidden\" name=\"onsuccess\" value=\"?".web_GetPageGetParams()."\"></INPUT>\n";
        echo "<INPUT type=\"hidden\" name=\"onerror\" value=\"?".web_GetPageGetParams()."\"></INPUT>\n";
        echo "<INPUT type=\"hidden\" name=\"idcontact\" value=\"".$_SESSION['iduser']."\"></INPUT>\n";
        echo "<INPUT type=\"hidden\" name=\"key\" value=\"web_sema_lang\"></INPUT>\n";
        $arCharSets = array('ru'=>"ru_RU", 'en'=>"en_US", 'it'=>"it");
        $this->formInputItem(_LW("Language"), "select", "lang", $sFieldValue, $arCharSets);
        $this->formInputItem(_LW("Set"), "submit");
        echo "</FORM>\n";
	}
		
}

$oPage = new web_Contact;
$oPage->m_windowHeader = _LW("Create preferences");
$oPage->WebStack("contact_prefs.php", $oPage->m_windowHeader, $oPage->m_windowHeader, web_GetPageGetParams());

if ( !isset($_SESSION['iduser']) )
	web_RedirectRelative("sema.php");
	
$oPage->idobject = $_SESSION['iduser'];
$oPage->object_type = ID_SEMA_CONTACT;
$oPage->m_menuFLvl = "Contacts";
$oPage->RenderPage();

?>
Return current item: PushOk SEMA