<?php 
require("common_begin.php");

$userID = $_GET['id'];
if (!isset($userID))
  die("no user ID set");

$elementID = $_POST['id'];
$newContent = $_POST['value'];
if (!isset($elementID) || !isset($newContent))
  die("editable components not sent");

$lst = Listopia::getInstance();

if ($lst->isLoggedIn() && (Session::getInstance()->gl_userid == $userID || $lst->isAdminUser() || $lst->isBannedUser($userID)))
{
  // update the user-description field
  if ($elementID == 'ui-subtitle-bar')
  {
    $newContent = ($newContent);
    
    $data = array(
      'user_description' => $newContent
    );
    if (!$lst->Database()->update('users', $data, "user_id = ".((int)$userID) ))
    {
      echo "<i>update failed</i>";
    }
    else
    {
      echo $newContent;
    }
  }
}
// not logged in / user id spoofed
else
{
  echo "<i>edit failed</i>";
}

require("common_end.php");

