Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
589 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
set_include_path("../"); | ||
include_once("head.php"); | ||
|
||
if(!User::isLoggedIn()) | ||
exit; | ||
|
||
$clip = ClipFactory::getObject(isset($_POST['clipID'])?$_POST['clipID']:0); | ||
if($clip->getClipID() == 0) | ||
exit; | ||
|
||
$flag = new Flag(); | ||
$flag->setUserID(User::$currentUser->getUserID()); | ||
$flag->setSourceID($clip->getSourceID()); | ||
$flag->setTime($clip->getStart() + (isset($_POST['time'])?$_POST['time']:0)); | ||
$flag->setType((isset($_POST['type'])?$_POST['type']:"")); | ||
$flag->save(); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
<?php | ||
require_once("ContextFactory.php"); | ||
class Context { | ||
# Instance Variables | ||
private $contextID; | ||
private $sourceID; | ||
private $time; | ||
private $title; | ||
private $url; | ||
private $description; | ||
private $dateCreated; | ||
|
||
# Data Methods | ||
public function __construct() { | ||
$this->contextID = 0; | ||
$this->sourceID = 0; | ||
$this->time = ""; | ||
$this->title = ""; | ||
$this->url = ""; | ||
$this->description = ""; | ||
$this->dateCreated = 0; | ||
} | ||
|
||
public function load($dataArray) { | ||
$this->contextID = $dataArray['contextID']; | ||
$this->sourceID = $dataArray['sourceID']; | ||
$this->time = $dataArray['time']; | ||
$this->title = $dataArray['title']; | ||
$this->url = $dataArray['url']; | ||
$this->description = $dataArray['description']; | ||
$this->dateCreated = $dataArray['dateCreated']; | ||
} | ||
|
||
public function validate() { | ||
return true; | ||
} | ||
|
||
public function save() { | ||
if(!$this->validate()) | ||
return false; | ||
|
||
$mysqli = DBConn::mysqli_connect(); | ||
if($this->getContextID() != 0) { | ||
// Update an existing context | ||
$queryString = "UPDATE contexts | ||
set contexts.sourceID = '".$this->getSourceID()."', | ||
contexts.time = ".$this->getTime()."', | ||
contexts.title = '".DBConn::clean_for_mysql($this->getTitle())."', | ||
contexts.url = '".DBConn::clean_for_mysql($this->getURL())."', | ||
contexts.description = '".DBConn::clean_for_mysql($this->getDescription())."' | ||
where contexts.id = ".$this->getContextID(); | ||
|
||
$mysqli->query($queryString) | ||
or print($mysqli->error); | ||
} | ||
else { | ||
// Create a new context | ||
$queryString = "INSERT into contexts | ||
values (0, | ||
".$this->getSourceID().", | ||
".$this->getTime().", | ||
'".DBConn::clean_for_mysql($this->getTitle())."', | ||
'".DBConn::clean_for_mysql($this->getURL())."', | ||
'".DBConn::clean_for_mysql($getDescription)."', | ||
NOW())"; | ||
|
||
$mysqli->query($queryString) | ||
or print($mysqli->error); | ||
|
||
$this->userID = $mysqli->insert_id; | ||
} | ||
} | ||
|
||
|
||
# Getters | ||
public function getContextID() { return $this->contextID; } | ||
|
||
public function getSourceID() { return $this->sourceID; } | ||
|
||
public function getTime() { return $this->time; } | ||
|
||
public function getTitle() { return $this->title; } | ||
|
||
public function getURL() { return $this->url; } | ||
|
||
public function getDescription() { return $this->description; } | ||
|
||
public function getDateCreated() { return $this->dateCreated; } | ||
|
||
|
||
# Setters | ||
public function setSourceID($int) { $this->sourceID = $int; } | ||
|
||
public function setTime($int) { $this->time = $int; } | ||
|
||
public function setTitle($str) { $this->title = $str;} | ||
|
||
public function setURL($str) { $this->url = $str;} | ||
|
||
public function setDescription($str) { $this->description = $str;} | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<?php | ||
require_once("DBConn.php"); | ||
require_once("Context.php"); | ||
class ContextFactory { | ||
public static function getObject($objectID) { | ||
$objectID = (int)$objectID; | ||
$mysqli = DBConn::mysqli_connect(); | ||
$dataArray = array(); | ||
|
||
$this->contextID = $dataArray['contextID']; | ||
$this->sourceID = $dataArray['sourceID']; | ||
$this->time = $dataArray['time']; | ||
$this->title = $dataArray['title']; | ||
$this->url = $dataArray['url']; | ||
$this->description = $dataArray['description']; | ||
$this->dateCreated = $dataArray['dateCreated']; | ||
// Load the object data | ||
$queryString = "select contexts.id as contextID, | ||
contexts.source_id as sourceID, | ||
contexts.time as time, | ||
contexts.title as title, | ||
contexts.url as url, | ||
contexts.description as description, | ||
contexts.creation_date as dateCreated | ||
from contexts | ||
where contexts.id = ".$objectID; | ||
|
||
$result = $mysqli->query($queryString) | ||
or print($mysqli->error); | ||
|
||
if($result->num_rows == 0) { | ||
$result->free(); | ||
return new Clip(); | ||
} | ||
|
||
$resultArray = $result->fetch_assoc(); | ||
$result->free(); | ||
|
||
$dataArray['contextID'] = $resultArray['contextID']; | ||
$dataArray['sourceID'] = $resultArray['sourceID']; | ||
$dataArray['time'] = $resultArray['time']; | ||
$dataArray['title'] = $resultArray['title']; | ||
$dataArray['url'] = $resultArray['url']; | ||
$dataArray['description'] = $resultArray['description']; | ||
$dataArray['dateCreated'] = $resultArray['dateCreated']; | ||
|
||
$newObject = new Context(); | ||
$newObject->load($dataArray); | ||
return $newObject; | ||
} | ||
|
||
public static function getObjects($objects) { | ||
$objectIDs = array(); | ||
foreach($objects as $object) | ||
$objectIDs[] = (int)$object; | ||
|
||
// If there are no objects being request, return an empty array | ||
if(sizeof($objectIDs) == 0) | ||
return array(); | ||
|
||
$objectIDString = implode(",",$objectIDs); | ||
$mysqli = DBConn::mysqli_connect(); | ||
$dataArrays = array(); | ||
|
||
// Load the object data | ||
$queryString = "select contexts.id as contextID, | ||
contexts.source_id as sourceID, | ||
contexts.time as time, | ||
contexts.title as title, | ||
contexts.url as url, | ||
contexts.description as description, | ||
contexts.creation_date as dateCreated | ||
from contexts | ||
where contexts.id IN (".$objectIDString.") | ||
order by contexts.time"; | ||
|
||
$result = $mysqli->query($queryString) | ||
or print($mysqli->error); | ||
while($resultArray = $result->fetch_assoc()) { | ||
$dataArray = array(); | ||
$dataArray['contextID'] = $resultArray['contextID']; | ||
$dataArray['sourceID'] = $resultArray['sourceID']; | ||
$dataArray['time'] = $resultArray['time']; | ||
$dataArray['title'] = $resultArray['title']; | ||
$dataArray['url'] = $resultArray['url']; | ||
$dataArray['description'] = $resultArray['description']; | ||
$dataArray['dateCreated'] = $resultArray['dateCreated']; | ||
$dataArrays[] = $dataArray; | ||
} | ||
|
||
// Create the objects | ||
$objectArray = array(); | ||
foreach($dataArrays as $dataArray) { | ||
$newObject = new Context(); | ||
$newObject->load($dataArray); | ||
$objectArray[] = $newObject; | ||
} | ||
return $objectArray; | ||
} | ||
} | ||
?> |
Oops, something went wrong.