Example #1
0
 function setFamilyModActivation()
 {
     if (isset($_POST["id"])) {
         if (Users::isUserMod($_POST["id"])) {
             Users::revokeUserMod($_POST["id"]);
         } else {
             Users::grantUserMod($_POST["id"]);
         }
     }
 }
Example #2
0
 function setSessionAndCookie($_userId)
 {
     //se souvenir de moi
     $rememberMe = isset($_POST["chkConnection"]) ? $_POST["chkConnection"] : "";
     $_SESSION["id"] = $_userId;
     $_SESSION["role"] = Users::isUserAdmin($_userId) ? ROLE_SYSADMIN : (Users::isUserFamilyOwner($_userId) ? ROLE_FAMOWNER : (Users::isUserMod($_userId) ? ROLE_MOD : ROLE_USER));
     if (!empty($rememberMe)) {
         $tokenCode = self::generateCode(32);
         Users::deleteCookieToken($_userId);
         Users::setCookieToken($_userId, $tokenCode);
         setcookie("userToken", $tokenCode, time() + 86400 * 7, "/");
     }
 }
Example #3
0
 function render()
 {
     //Obtenir l'objet de base du user en cours
     $familyOwner = (int) self::getFamilyOwner($_SESSION["id"]);
     $objet = Objects::getFirstRacine($familyOwner);
     $id = -1;
     if (!empty($objet) && !is_null($objet)) {
         $id = (int) $objet[0][0];
     }
     $array = self::loadObjectArray($id, $_SESSION["id"], 50);
     $infos = self::loadObjectInfo($id, $_SESSION["id"]);
     $famille = self::loadFamilyUsers($_SESSION["id"], $id);
     $first = is_null($array[0]["name"]);
     $user = Users::getUser($_SESSION["id"]);
     $completeName = $user["UserInfoFirstName"] . " " . $user["UserInfoLastName"];
     $owned = Users::isUserMod($_SESSION["id"]);
     if (!$owned) {
         $owned = Users::isUserFamilyOwner($_SESSION["id"]);
         if (!$owned) {
             $owned = $infos["ownerID"] == $_SESSION["id"];
         }
     }
     // Chargement des images
     $images = Resources::getImage($id);
     // Encodage des images
     for ($i = 0; $i < count($images); $i++) {
         $images[$i]["ImageBlob"] = "data:image;base64," . base64_encode($images[$i]["ImageBlob"]);
     }
     if (count($images) == 0) {
         $currentImage = PUBLIC_ABSOLUTE_PATH . "/assets/no-image.gif";
         $currentImageId = "";
     } else {
         $currentImage = $images[0]["ImageBlob"];
         $currentImageId = $images[0]["ImageId"];
     }
     $contact = self::loadContactArray($_SESSION["id"]);
     $data = array("PUBLIC_ABSOLUTE_PATH" => PUBLIC_ABSOLUTE_PATH, "SERVER_ABSOLUTE_PATH" => SERVER_ABSOLUTE_PATH, "donnees" => $array, "user" => $_SESSION["id"], "infos" => $infos, "contacts" => $contact, "famille" => $famille, "first" => $first, "username" => $completeName, "isSystemAdmin" => $_SESSION["role"] == ROLE_SYSADMIN, "isFamilyAdmin" => $_SESSION["role"] == ROLE_FAMOWNER, "isMod" => $_SESSION["role"] == ROLE_MOD, "currentImage" => $currentImage, "currentImageId" => $currentImageId, "images" => $images, "owned" => $owned);
     $this->renderTemplate(file_get_contents(ITEMS_PAGE), $data);
 }