Exemple #1
0
function SetLastChanged(&$tpl, $userId, $LastChange)
{
    $last_changed_tpl = new HTML_Template_IT("./");
    $last_changed_tpl->loadTemplatefile("last_changed.tpl.html", true, false);
    if ($userId == -1) {
        $userName = "******";
    } else {
        $userInfos = GetUserInfosById($userId);
        $userName = $userInfos["username"];
    }
    // format date
    $LastChange = date("Y-m-d H:i:s T", MySQLTimeStampToUnixTimeStamp($LastChange));
    // do replacements
    $last_changed_tpl->setVariable("USER_NAME", $userName);
    $last_changed_tpl->setVariable("LAST_CHANGE", $LastChange);
    $tpl->setVariable("LAST_CHANGED", $last_changed_tpl->get());
}
Exemple #2
0
     $AtLeastOneAdmin = true;
     $adminIds = GetAdminUsersId();
     if (!is_array($adminIds)) {
         die($adminIds);
     }
     if (!array_key_exists("is_admin", $_POST)) {
         $adminCount = 0;
         foreach ($adminIds as $adminId) {
             if ($adminId != $_POST["Id"]) {
                 $adminCount++;
             }
         }
         $AtLeastOneAdmin = $adminCount > 0;
     }
     if ($AtLeastOneAdmin) {
         $userInfos = GetUserInfosById($_POST["Id"]);
         if ($userInfos["username"] == GetLoggedUserName() && $userInfos["IsAdmin"] == "Y" && !array_key_exists("is_admin", $_POST)) {
             $result = "You cannot revoke your own admin status. Please ask another admin to do so.";
         } elseif (!array_key_exists("is_admin", $_POST) && !array_key_exists("projects", $_POST)) {
             $result = "Non admin users must have at least one project assigned";
         } else {
             $result = ModifyUser($_POST["Id"], $_POST["md5_hash"], $_POST["full_name"], $_POST["email"], array_key_exists("can_upload", $_POST) ? "Y" : "N", array_key_exists("is_power", $_POST) ? "Y" : "N", array_key_exists("is_admin", $_POST) ? "Y" : "N", array_key_exists("projects", $_POST) ? $_POST["projects"] : array());
         }
     } else {
         $result = "There must always be at least one admin in the system.";
     }
     EndAccessToDB();
 }
 if ($result == "") {
     $msg = "Modification successful";
 } else {
    } elseif ($_POST["email"] == "") {
        $result = "The E-Mail cannot be blank";
    } else {
        $result = ModifyMyDetails(GetLoggedUserId(), $_POST["md5_hash"], $_POST["full_name"], $_POST["email"]);
    }
    if ($result == "") {
        $msg = "Details set successfully";
    } else {
        $msg = "Error while setting details: " . $result;
    }
}
$userId = GetLoggedUserId();
$tpl = new HTML_Template_IT("./");
$tpl->loadTemplatefile("edit_my_details.tpl.html", true, true);
SetCommonLoginStatus($tpl);
SetCommonToolbar($tpl);
SetCommonFooter($tpl);
$userInfos = GetUserInfosById($userId);
$ProjectsList = GetProjectsNamesListFromIds($userInfos["ProjectsList"]);
if (is_string($ProjectsList)) {
    die($ProjectsList);
}
$tpl->setVariable("NAME", $userInfos["username"]);
$tpl->setVariable("FULL_NAME", EncodeString(trim($userInfos["FullName"])));
$tpl->setVariable("EMAIL", trim($userInfos["email"]));
$tpl->setVariable("CAN_UPLOAD", $userInfos["CanUpload"]);
$tpl->setVariable("IS_POWER", $userInfos["IsPower"]);
$tpl->setVariable("IS_ADMIN", $userInfos["IsAdmin"]);
$tpl->setVariable("PROJECTS_LIST", implode(", ", $ProjectsList));
$tpl->setVariable("MESSAGE", $msg);
$tpl->Show();