Esempio n. 1
0
 /**
  * Retrieves all TenantObjects, optionally associated with the given Tenant.
  * @param string $max The maximum number of TenantObjects to return
  * @param Tenant $tenant The tenant whose TenantObjects to return (or null to return all TenantObjects) 
  * @return TenantObject[] array of TenantObjects residing on the server and optionally associated with the specified Tenant
  */
 public static function Get($max = null, $tenant = null)
 {
     global $MySQL;
     $retval = array();
     if ($tenant == null) {
         $tenant = Tenant::GetCurrent();
     }
     if ($tenant == null) {
         return $retval;
     }
     $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "TenantObjects WHERE object_TenantID = " . $tenant->ID;
     if (is_numeric($max)) {
         $query .= " LIMIT " . $max;
     }
     $result = $MySQL->query($query);
     if ($result === false) {
         return $retval;
     }
     $count = $result->num_rows;
     for ($i = 0; $i < $count; $i++) {
         $values = $result->fetch_assoc();
         $retval[] = TenantObject::GetByAssoc($values);
     }
     return $retval;
 }
 public static function GetByID($id)
 {
     if (!is_numeric($id)) {
         return null;
     }
     $tenant = Tenant::GetCurrent();
     $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "TenantEnumerations WHERE enum_ID = " . $id . " AND enum_TenantID = " . $tenant->ID;
     $result = $MySQL->query($query);
     if ($result === false) {
         return null;
     }
     $count = $result->num_rows;
     if ($count == 0) {
         return null;
     }
     $values = $result->fetch_assoc();
     return TenantEnumeration::GetByAssoc($values);
 }
Esempio n. 3
0
 public static function Log($message, $params = null, $severity = LogMessageSeverity::Error)
 {
     $bt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
     if ($params == null) {
         $params = array();
     }
     global $MySQL;
     $tenant = Tenant::GetCurrent();
     $query = "INSERT INTO " . System::$Configuration["Database.TablePrefix"] . "DebugMessages (message_TenantID, message_Content, message_SeverityID, message_Timestamp, message_IPAddress) VALUES (";
     $query .= ($tenant == null ? "NULL" : $tenant->ID) . ", ";
     $query .= "'" . $MySQL->real_escape_string($message) . "', ";
     $query .= $severity . ", ";
     $query .= "NOW(), ";
     $query .= "'" . $MySQL->real_escape_string($_SERVER["REMOTE_ADDR"]) . "'";
     $query .= ")";
     $MySQL->query($query);
     $msgid = $MySQL->insert_id;
     foreach ($bt as $bti) {
         $filename = "(unknown)";
         $lineNumber = "(unknown)";
         if (isset($bti["file"])) {
             $filename = $bti["file"];
         }
         if (isset($bti["line"])) {
             $lineNumber = $bti["line"];
         }
         $query = "INSERT INTO " . System::$Configuration["Database.TablePrefix"] . "DebugMessageBacktraces (bt_MessageID, bt_FileName, bt_LineNumber) VALUES (";
         $query .= $msgid . ", ";
         $query .= "'" . $MySQL->real_escape_string($filename) . "', ";
         $query .= $lineNumber;
         $query .= ")";
         $MySQL->query($query);
     }
     foreach ($params as $key => $value) {
         $query = "INSERT INTO " . System::$Configuration["Database.TablePrefix"] . "DebugMessageParameters (mp_MessageID, mp_Name, mp_Value) VALUES (";
         $query .= $msgid . ", ";
         $query .= "'" . $MySQL->real_escape_string($key) . "', ";
         $query .= "'" . $MySQL->real_escape_string($value) . "'";
         $query .= ")";
         $MySQL->query($query);
     }
 }
Esempio n. 4
0
 public static function RegisterUser($loginID, $password, $longName, $shortName, $emailAddress = null)
 {
     $CurrentTenant = Tenant::GetCurrent();
     // create an instance of the User object in this tenant
     $obj = $CurrentTenant->GetObject("User");
     // retrieve the salted password from the User object
     $pwsalt = $obj->GetMethod("SaltPassword")->Execute();
     // tell the User object to hash the password
     $pwhash = $obj->GetMethod("HashPassword")->Execute(array(new TenantObjectMethodParameterValue("input", $pwsalt . $password)));
     $inst = $obj->CreateInstance(array(new TenantObjectInstancePropertyValue($obj->GetInstanceProperty("LoginID"), $loginID), new TenantObjectInstancePropertyValue($obj->GetInstanceProperty("DisplayName"), $longName), new TenantObjectInstancePropertyValue($obj->GetInstanceProperty("URL"), $shortName), new TenantObjectInstancePropertyValue($obj->GetInstanceProperty("EmailAddress"), $emailAddress), new TenantObjectInstancePropertyValue($obj->GetInstanceProperty("PasswordHash"), $pwhash), new TenantObjectInstancePropertyValue($obj->GetInstanceProperty("PasswordSalt"), $pwsalt)));
     if ($inst != null) {
         return UserRegistrationStatus::AwaitingVerification;
     }
     global $MySQL;
     RegistrationManager::$ErrorCode = $MySQL->errno;
     // DataFX::$Errors->Items[0]->Code;
     RegistrationManager::$ErrorMessage = $MySQL->error;
     // DataFX::$Errors->Items[0]->Message;
     return UserRegistrationStatus::GeneralError;
 }
Esempio n. 5
0
function displayProfileTitle()
{
    $path = System::GetVirtualPath();
    $id = $path[1];
    $CurrentTenant = Tenant::GetCurrent();
    $objUser = $CurrentTenant->GetObject("User");
    $thisuser = $objUser->GetInstance(new TenantQueryParameter("URL", $id));
    if ($thisuser == null) {
        return;
    }
    ?>
	<div class="ProfileTitle">
		<?php 
    mmo_display_user_badges_by_user($thisuser);
    ?>
		<span class="ProfileUserName"><?php 
    echo $thisuser->LongName;
    ?>
</span>
		<?php 
    if ($action != "customize") {
        ?>
			<span class="ProfileControlBox">
			<?php 
        if ($CurrentUser != null && $thisuser->ID != $CurrentUser->ID) {
            if (mmo_has_user_friend_request(null, $thisuser)) {
                ?>
				<a href="<?php 
                echo System::$Configuration["Application.BasePath"];
                ?>
/community/members/<?php 
                echo $id;
                ?>
/Disconnect">Withdraw Friend Request</a>
				<?php 
            } else {
                if (mmo_has_user_friend_request($thisuser, $CurrentUser)) {
                    ?>
				<a href="<?php 
                    echo System::$Configuration["Application.BasePath"];
                    ?>
/community/members/<?php 
                    echo $id;
                    ?>
/Connect/<?php 
                    echo mmo_get_user_friendship_auth_key($thisuser, $CurrentUser);
                    ?>
">Confirm Friendship</a>
				<?php 
                } else {
                    if ($CurrentUser->HasFriend($thisuser)) {
                        ?>
				<a href="<?php 
                        echo System::$Configuration["Application.BasePath"];
                        ?>
/community/members/<?php 
                        echo $id;
                        ?>
/Disconnect"><?php 
                        echo LanguageString::GetByName("friend_disconnect");
                        ?>
</a>
				<?php 
                    } else {
                        ?>
				<a href="<?php 
                        echo System::$Configuration["Application.BasePath"];
                        ?>
/community/members/<?php 
                        echo $id;
                        ?>
/Connect"><?php 
                        echo LanguageString::GetByName("friend_connect");
                        ?>
</a>
				<?php 
                    }
                }
            }
            ?>
			<form action="<?php 
            echo System::$Configuration["Application.BasePath"];
            ?>
/Account/Messages/Create" method="POST">
				<input type="hidden" name="message_receiver" value="<?php 
            echo $thisuser->ID;
            ?>
" />
				<input class="LinkButton" type="submit" value="<?php 
            echo LanguageString::GetByName("message_send");
            ?>
" />
			</form>
			<a href="<?php 
            echo System::$Configuration["Application.BasePath"];
            ?>
/community/members/<?php 
            echo $id;
            ?>
/trade/"><?php 
            echo LanguageString::GetByName("resource_trade");
            ?>
</a>
			<a href="<?php 
            echo System::$Configuration["Application.BasePath"];
            ?>
/community/members/<?php 
            echo $id;
            ?>
/block" onclick="/* ReportBlockDialog.Show(); return false; */">Report/Block</a>
			<?php 
        }
        if ($thisuser->IsAuthenticated) {
            ?>
				<a href="<?php 
            echo System::$Configuration["Application.BasePath"];
            ?>
/community/members/<?php 
            echo $id;
            ?>
/Customize">Customize Profile</a>
			<?php 
        }
    }
    ?>
			</span>
	</div>
<?php 
}
Esempio n. 6
0
    protected function RenderContent()
    {
        $CurrentTenant = Tenant::GetCurrent();
        $objUser = $CurrentTenant->GetObject("User");
        $CurrentUser = $objUser->GetMethod("GetCurrentUser")->Execute();
        $members = $objUser->GetInstances();
        $count = count($members);
        foreach ($members as $member) {
            $description = $member->GetPropertyValue("Description");
            // SingleInstance<Gender>
            $gender = $member->GetPropertyValue("Gender");
            // SingleInstance<Gender>
            if ($gender != null) {
                $gender = $gender->ToString();
            }
            $age = null;
            $birthdate = $member->GetPropertyValue("BirthDate");
            // DateTime
            if ($birthdate != null) {
                // TODO: calculate age from birth date
                $age = $birthdate;
            }
            $location = $member->GetPropertyValue("Location");
            // SingleInstance<Place>
            if ($location != null) {
                $location = $location->ToString();
            }
            ?>
<div class="Card MemberCard">
	<div class="Title">
		<table style="width: 100%;">
			<tr>
				<td rowspan="2" style="width: 96px;"><img src="<?php 
            echo System::ExpandRelativePath("~/community/members/" . $member->GetPropertyValue("URL") . "/images/avatar/thumbnail.png");
            ?>
" alt="<?php 
            echo $member->GetPropertyValue("DisplayName");
            ?>
" title="<?php 
            echo $member->GetPropertyValue("DisplayName");
            ?>
" /></td>
				<td class="MemberName"><?php 
            echo $member->GetPropertyValue("DisplayName");
            ?>
</td>
			</tr>
			<tr>
				<td><?php 
            if ($gender != null) {
                echo $gender . " - ";
            }
            if ($age != null) {
                echo $age . " - ";
            }
            if ($location != null) {
                echo $location->ToString();
            }
            ?>
</td>
			</tr>
		</table>
	</div>
	<?php 
            if ($description != null) {
                ?>
<div class="Content"><?php 
                echo $description;
                ?>
</div><?php 
            }
            ?>
	<div class="Actions Horizontal">
		<div class="Left" style="background-color: #3366FF;">
			<div style="padding-left: 16px; color: #FFFFFF; font-weight: bold;">Member</div>
		</div>
		<div class="Right">
		<?php 
            if ($CurrentUser != null) {
                $hasfriend = false;
                /*
                $hasfriend = $CurrentUser->GetMethod("HasFriend")->Execute(array
                (
                	new TenantQueryParameter("member", $member)
                ));
                */
                if ($hasfriend) {
                    ?>
					<strong>Friends</strong>
					<?php 
                } else {
                    ?>
					<a href="#" title="Add Friend"><i class="fa fa-plus"></i> <span class="Text">Add Friend</span></a>
					<?php 
                }
                ?>
			<a href="#" title="Poke"><i class="fa fa-hand-o-right"></i> <span class="Text">Poke</span></a>
			<a href="#" title="View Profile"><i class="fa fa-eye"></i> <span class="Text">View Profile</span></a>
			<?php 
            }
            ?>
		</div>
	</div>
</div>
<?php 
        }
        ?>
</div>
<?php 
    }
Esempio n. 7
0
 public static function GetCurrent()
 {
     $CurrentTenant = Tenant::GetCurrent();
     if ($CurrentTenant == null) {
         return null;
     }
     // prevent a NOTICE from cluttering the log
     if (!isset($_SESSION["CurrentUserName[" . $CurrentTenant->ID . "]"]) || !isset($_SESSION["CurrentPassword[" . $CurrentTenant->ID . "]"])) {
         return null;
     }
     return User::GetByCredentials($_SESSION["CurrentUserName[" . $CurrentTenant->ID . "]"], $_SESSION["CurrentPassword[" . $CurrentTenant->ID . "]"]);
 }
Esempio n. 8
0
function IsAuthenticated()
{
    $CurrentTenant = Tenant::GetCurrent();
    if (isset($_SESSION["CurrentUserName[" . $CurrentTenant->ID . "]"]) && isset($_SESSION["CurrentPassword[" . $CurrentTenant->ID . "]"])) {
        $user = $CurrentTenant->GetObject("User")->GetMethod("ValidateCredentials")->Execute(array(new TenantObjectMethodParameterValue("username", $_SESSION["CurrentUserName[" . $CurrentTenant->ID . "]"]), new TenantObjectMethodParameterValue("password", $_SESSION["CurrentPassword[" . $CurrentTenant->ID . "]"])));
        return $user != null;
    }
    return false;
}