Location: PHPKode > projects > PushOk SEMA > html/web/my_objects/my_objects.php
<?PHP

function web_MyObjectsDefaultViewShow(&$oIn, &$oOut)
{
	if ( !is_array($oIn) || !isset($oIn['layout']) )
		return false;
		
	global $arProjectStatus;
	$this = &$oIn['layout'];
	
	$_oIn = array('idcontact'=>$_SESSION['iduser'], 'key'=>'objects');
	$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_CONTACT_PREFERENCE_SEARCH", $_oIn, $arData);
	
	$this->formSection(_LW("My objects")." ".$this->singleItem("link", _LW("Add"), array('href'=>"?page=/web/my_objects/my_objects_form.php")));
    $this->formItem("" ,"subitem");
    $this->tableStart("default_sub");
    $arHeader = array( 
		array('value'=>_LW('Title'), 'colspan'=>0, 'align'=>'left'),
		array('value'=>_LW('Type'), 'colspan'=>0, 'align'=>'left'),
		array('value'=>_LW('Action'), 'colspan'=>0, 'align'=>'left')
						);
	$this->tableHeader($arHeader);
	
	if ( isset($arData['value']) && $arData['value']!= "" ) {
		$arObjects = split(",", $arData['value']);
		foreach ($arObjects as $key => $val) {
			// show object's info
			$this->tableRow();
			// get object title
			$_oIn = array('idobject' => $val);
			$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_OBJECT_INFO", $_oIn, $oObject);
			if (isset($oObject['object']))
			{
				$this->tableCol($this->singleItem("link", $oObject['object']['title'], array('href'=>"?page=/web/object_view.php&id=$val")));
				$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_OBJECT_REGISTER", $_oIn=array(), $arObjects=array());
				$this->tableCol($arObjects[$oObject['object']['type']]);
			}
			else
			{
				$this->tableCol();
				$this->tableCol();
			}

			$this->tableCol();
			echo $this->singleItem("link", _LW("drop"), array('href'=>"?page=/web/my_objects/my_objects.php&action=forget&id=$val"))." ";

			// prepare actions for current task
			$_oIn=array('idobject'=>$val, 'type'=>$oObject['object']['type'], 'level'=>1);
			$GLOBALS['WEB_DISPATCHER']->ProcessMessage("WM_ACTION_MENU_CREATE", $_oIn, $_oOut=array());
			if ( count($_oOut) )
			{
				krsort($_oOut);
				foreach ($_oOut as $nPriority=>$arMenues) 
					foreach ($arMenues as $sName => $arData) 
						echo $this->singleItem("action",$sName,$arData);
			}
		}
	}
    $this->tableEnd();
    $this->formSectionEnd();
	
	return true;
}

function web_MyObjectsAddValue(&$oIn, &$oOut) {
	if (!is_array($oIn))
		return false;
		
	if ($oIn['step'] == 2) {
		$_oIn = array('idcontact'=>$_SESSION['iduser'], 'idobject'=>$oIn['post']['value'], 'mask'=>'R');
		$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_CONTACT_HAS_MASK", $_oIn, $_oOut=array());
		if (isset($_oOut['result']) && $_oOut['result']) {
			$oIn['post']['key'] = "objects";
			$oIn['post']['idcontact'] = $_SESSION['iduser'];
			$oIn['post']['separator'] = ",";
			$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_CONTACT_PREFS_ADDVALUE", $oIn['post'], $oOut);
		}
	}
}

//================================================================================================================
// process some get params
if (isset($_GET) && count($_GET)) {
	if (isset($_GET['action']) && $_GET['action'] != "") {
		// switch what to do
		switch ($_GET['action']) {
			case "forget":
				if (isset($_GET['id']) && $_GET['id']>0) {
					$_oIn = array('idcontact'=>$_SESSION['iduser'], 'key'=>'objects');
					$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_CONTACT_PREFERENCE_SEARCH", $_oIn, $arData);
					if (isset($arData['value'])) {
						$arObjects = split(",",$arData['value']);
						foreach ($arObjects as $key=>$val)
							if ($val == $_GET['id']) {
								unset($arObjects[$key]);
								break;
							}
						if (count($arObjects))
							$_oIn['value'] = implode(",", $arObjects);
						else 
							$_oIn['value'] = "";
						$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_CONTACT_PREFS_CREATEUPDATE", $_oIn, $_oOut);
					}
				}
				break;
		}
		web_RedirectRelative("sema.php");
	}
}

?>
Return current item: PushOk SEMA