Location: PHPKode > projects > PhpChrystal - An Open Intranet System > 0.071Alpha1/phpTransport.php
<?php
  session_start();
  session_set_cookie_params('32758');

  // XML::MODUL   (phpTransport)
  // XML::VERSION (0.071 Alpha1)
  // XML::AUTHOR  (::[CTH]Goldenhawk::)
  // XML::INFO    (Dieses Plugin dient als Frontend für den Mitfahrservice)


  // XML::COMMENT (Vesrion, Name und Autor festlege)
  $PLUGIN_VERSION = "0.071 Alpha1";
  $PLUGIN_NAME    = "phpTransport";
  $PLUGIN_AUTHOR  = "::[CTH]Goldenhawk::";

  // XML::COMMENT (Variablen laden)
  include_once("./classes/CCore.php");

  // XML::FUNC::getInfo ($self->getInfo())
  // XML::DESC::getInfo (liefert Name, Autor und Version des Modules zurück)
  // XML::VERSION::getInfo  (1.0)
  // XML::RETURN::getInfo ($PLUGIN_NAME,$PLUGIN_AUTHOR,$PLUGIN_VERSION)
  function getInfo()
  {
    return $PLUGIN_NAME;
    return $PLUGIN_AUTHOR;
    return $PLUGIN_VERSION;
  }

  // XML::COMMENT (Template initalisieren)
  $cdesign->initalizeTemplate($arNoOpts);
  
  // XML::COMMENT (-----------------------------)
  // XML::COMMENT (------ Ausgaberoutinen ------)
  // XML::COMMENT (-----------------------------)

  if ($_GET['cmd'] == 'show_search')
  {
    if (!$in_string)
    {
      $cl->FormNew("$PHP_SELF?cmd=show_search&naked=1","");

      $desTop[0][text] = $cxml->printString($lang['show.search.subject']);
      $desTop[0][colspan] = 2;
      $cl->cellsTop($desTop);

      $desText[0][text] = $cxml->printString($lang['show.search.hint']);
	  $desText[0][colspan] = 2;
	  $cl->TableText($desText);

	  $cl->cells2Noopt($cxml->printString($lang['show.search.string']),"<input type=text name=in_string>","2");
      $cl->FormSubmit("2",$cxml->printString($lang['show.search.form']));
    }
    else
    {
      $desTop[0][text] = $cxml->printString($lang['show.search.username']);
      $desTop[1][text] = $cxml->printString($lang['show.search.plz']);
      $desTop[2][text] = $cxml->printString($lang['show.search.city']);
      $cl->cellsTop($desTop);

      $m_ar = $ctransport->getTransportPossibilities(array('iPlz' => $in_string, 'szCity' => $in_string));
	  if (is_array($m_ar))
	  {
	    for ($cnt = 0;$cnt<count($m_ar);$cnt++)
	    {
	      $desText[0][text] = $cdesign->createUserLink(array('user' => $m_ar[$cnt][iUserID]));
	      $desText[1][text] = $m_ar[$cnt][iPlz];
	      $desText[2][text] = $m_ar[$cnt][szCity];
	      $cl->TableText($desText);
	    }
	  }
	  else
	  {
	    $desText[0][text] = $cxml->printString($lang['message.no_entries.3']);
	    $desText[0][colspan] = 3;
	    $cl->TableText($desText);
	  }
	}
  }
  // XML::COMMENT (Nachrichten lesen anzeigen)
  elseif ($_GET['cmd'] == 'user_overview')
  {
    if (!isset($_SESSION['active_userid']))
      $cfunc->faultExt($cxml->printString($lang_def["fault.not_loged_in"]));


    $cl->FormNew("$PHP_SELF?cmd=cmd_userupdate&amp;what=addtransport","");
    $arService = $ctransport->getTransportService(array('iUserID' => $_SESSION['active_userid']));
    $cl->cells2Noopt($cxml->printString($lang['user.overview.from_city']),"<input type=text name=in_from_city value=\"".$arService[0][szFromCity]."\">","out");
    $cl->cells2Noopt($cxml->printString($lang['user.overview.from_plz']),"<input type=text name=in_from_plz size=5 maxlength=5 value=\"".$arService[0][iFromPlz]."\">","out");
    $cl->cells2Noopt($cxml->printString($lang['user.overview.to_city']),"<input type=text name=in_to_city value=\"".$arService[0][szToCity]."\">","out");
    $cl->cells2Noopt($cxml->printString($lang['user.overview.cost']),"<input type=text name=in_cost size=4 maxlength=6 value=\"".$arService[0][iCost]."\"> ".$cxml->printString($lang_def['money_sign']),"out");
    $cl->cells2Noopt($cxml->printString($lang['user.overview.places']),"<input type=text name=in_places maxlength=2 size=2 value=\"".$arService[0][iPlaces]."\">","out");
    $cl->cells2Noopt($cxml->printString($lang['user.overview.comment']),"<textarea name=in_body cols=35 rows=7>".$arService[0][szDesc]."</textarea>","out");
	$cl->FormHidden("in_id",$arService[0][id]);
	$cl->FormSubmit("2",$cxml->printString($lang['user.overview.update.form']));

	if ($arService[0][id])
	{
	  $cl->cellsDummy("2","");

      $cl->FormNew("$PHP_SELF?cmd=cmd_userupdate&amp;what=dokickusers","");
	  $desTop[0][text] = $cxml->printString($lang['user.overview.subject.taken_users']);
	  $desTop[0][colspan] = "2";
	  $cl->cellsTop($desTop);

	  $arTakenUsers = $ctransport->getRefTransportService(array('iRefID' => $arService[0][id]));

	  for ($cnt = 0;$cnt<count($arTakenUsers);$cnt++)
	    $cl->cells2Noopt("<input type=checkbox name=in_todel[] value=\"".$arTakenUsers[$cnt][id]."\">",$cdesign->createUserLink(array('user' => $arTakenUsers[$cnt][iUserID])),"out");

	  (!$cnt) ? (($desText[0][colspan] = 2) && ($desText[0][text] = $cxml->printString($lang['message.no_entries'])) && ($cl->TableText($desText))) : ($cl->FormSubmit("2",$cxml->printString($lang['user.overview.delete.form'])));
    }
  }
  elseif ($_GET['cmd'] == 'user_show')
  {
    if (!isset($_SESSION['active_userid']))
      $cfunc->faultExt($cxml->printString($lang_def["fault.not_loged_in"]));


    $cl->FormNew("$PHP_SELF?cmd=cmd_userupdate&amp;what=dotakeusers","");
    $desTop[0][text] = $cxml->printstring($lang['user.show.subject.user_serach']);
    $desTop[0][colspan] = 3;
    $cl->cellsTop($desTop);
	unset($desTop);

	if ($ctransport->checkUserHasFreePlaces($_SESSION['active_userid']))
	  $m_cantake = 1;

	$m_ar = $ctransport->getSearchingUsers($arNoOpts);

	$desTop[0][text] = "&nbsp;";
	$desTop[1][text] = $cxml->printString($lang['user.show.username']);
	$desTop[2][text] = $cxml->printString($lang['user.show.from_to']);
	$cl->cellsTop($desTop);
	unset($desTop);

	for ($cnt = 0;$cnt<count($m_ar);$cnt++)
	{
	  if ($m_ar[$cnt][bStatus] && $m_ar[$cnt][bSearch] && $m_cantake)
	    $m_temp = "<input type=checkbox name=in_add[] value=\"".$m_ar[$cnt][iUserID]."\">";
	  else
	    $m_temp = "&nbsp;";

	  $desText[0][text] = $m_temp;
	  $desText[1][text] = $cdesign->createUserLink(array('user' => $m_ar[$cnt][iUserID]));
	  $desText[2][text] = $cxml->printString($lang['user.show.info_from_to'],$m_ar[$cnt][szFromCity],$m_ar[$cnt][iFromPlz]);
	  $cl->TableText($desText);
	}

	(!$cnt) ? (($desText[0][colspan] = 3) && ($desText[0][text] = $cxml->printString($lang['message.no_entries.2'])) && ($cl->TableText($desText))) : ($dummy);
	($cnt && $m_cantake) ? ($cl->FormSubmit("3",$cxml->printString($lang['user.show.take.form']))) : ($dummy);
	unset($desText);

	$cl->cellsDummy("3","out");
    $desTop[0][text] = $cxml->printstring($lang['user.show.subject.user_drive']);
    $desTop[0][colspan] = 3;
    $cl->cellsTop($desTop);
	unset($desTop);

    $m_ar = $ctransport->getTransportService($arNoOpts);
    for ($cnt = 0;$cnt<count($m_ar);$cnt++)
    {
      $desText[0][text] = "&nbsp";
      $desText[0][title] = $cxml->printString($lang['user.show.empty.title'],$m_ar[$cnt][szDesc],$m_ar[$cnt][iCost],$cxml->printString($lang_def['money_sign']));
      $desText[1][text] = $cdesign->createUserLink(array('user' => $m_ar[$cnt][iUserID]));
      $desText[2][text] = $cxml->printString($lang['user.show.info_from_to'],$m_ar[$cnt][szFromCity],$m_ar[$cnt][iFromPlz]);
      $cl->TableText($desText);
    }
	(!$cnt) ? (($desText[0][colspan] = 3) && ($desText[0][text] = $cxml->printString($lang['message.no_entries.3'])) && ($cl->TableText($desText))) : ($dummy);
  }
  elseif ($_GET['cmd'] == 'user_addsearch')
  {
    if (!isset($_SESSION['active_userid']))
      $cfunc->faultExt($cxml->printString($lang_def["fault.not_loged_in"]));

    ($ctransport->checkUserCanDrive($_SESSION['active_userid'])) ? ($cfunc->faultExt($cxml->printString($lang['fault.user_cannot_add']))) : ($dummy);

    $m_ar = $ctransport->getSearchingUsers(array('iUserID' => $_SESSION['active_userid']));

    $cl->FormNew("$PHP_SELF?cmd=cmd_userupdate&amp;what=addsearch","");
    $cl->cells2Noopt($cxml->printString($lang['user.addsearch.from_city']),"<input type=text name=in_from_city value=\"".$m_ar[0][szFromCity]."\">","out");
    $cl->cells2Noopt($cxml->printString($lang['user.addsearch.from_plz']),"<input type=text name=in_from_plz maxlength=5 size=5 value=\"".$m_ar[0][iFromPlz]."\">","out");
	$cl->FormHidden("in_id",$m_ar[0][id]);
	$cl->FormSubmit("2",$cxml->printString($lang['user.addsearch.form']));
  }
  // XML::COMMENT (Usereinstellungen updaten)
  elseif ($_GET['cmd'] == 'cmd_userupdate')
  {
    if (!isset($_SESSION['active_userid']))
      $cfunc->faultExt($cxml->printString($lang_def["fault.not_loged_in"]));


    if ($_GET['what'] == 'addtransport')
    {
      $arOpts = array('iUserID' => $_SESSION['active_userid'], 'szFromCity' => $in_from_city, 'iFromPlz' => $in_from_plz, 'szToCity' => $in_to_city, 'iCost' => $in_cost, 'iPlaces' => $in_places, 'szDesc' => $in_body);

      if ($in_id)
        $arOpts[id] = $in_id;

	  if ($in_id)
	    $ctransport->setTransportService($arOpts);
	   else
	     $ctransport->addTransportService($arOpts);

      for ($cnt = 0;$cnt<count($in_todel);$cnt++)
        $ctransport->deleteRefTransportService(array('iRefID' => $in_id, 'id' => $in_todel[$cnt]));

    }
    elseif ($_GET['what'] == 'addsearch')
    {
	  if ($in_id)
	    $ctransport->setSearch(array('id' => $in_id, 'iUserID' => $_SESSION['active_userid'], 'iFromPlz' => $in_from_plz, 'szFromCity' => $in_from_city));
      else
        $ctransport->addSearch(array('iUserID' => $_SESSION['active_userid'], 'iFromPlz' => $in_from_plz, 'szFromCity' => $in_from_city));
    }
    elseif ($_GET['what'] == 'dotakeusers')
    {
      $m_id = $ctransport->getTransportIDOfUser($_SESSION['active_userid']);

      if (!$m_id)
        $cfunc->faultExt($cxml->printString($lang['fault.user_has_no_drive_id']));

      for ($cnt = 0;$cnt<count($in_add);$cnt++)
      {
	    $ctransport->setSearch(array('id' => $in_add[$cnt], 'bStatus' => '0','bSearch' => '0'));
	    $ctransport->addRefTransportService(array('iUserID' => $in_add[$cnt], 'iRefID' => $m_id));
      }
    }
    printDanke();
  }
  else
  {
    $cfunc->faultExt($cxml->printString($lang_def['fault.not_registered']));
  }

  // XML::COMMENT (Seite abschließen)
  $cdesign->createSiteFooter($arOpts);
?>
Return current item: PhpChrystal - An Open Intranet System