aboutsummaryrefslogtreecommitdiff
path: root/r7r_repo/models.php
diff options
context:
space:
mode:
authorKevin Chabowski <kevin@kch42.de>2012-01-05 23:47:31 +0100
committerKevin Chabowski <kevin@kch42.de>2012-01-05 23:47:31 +0100
commitf8a7871546fcddb745ddfa708f61b6774c913f34 (patch)
tree3f52a64ce01bae9c6bd8f945cdc4e974029eb442 /r7r_repo/models.php
parenta3be4bd82d36576bbcdedf752ccbb9f35320210a (diff)
downloadr7r-repo-f8a7871546fcddb745ddfa708f61b6774c913f34.tar.gz
r7r-repo-f8a7871546fcddb745ddfa708f61b6774c913f34.tar.bz2
r7r-repo-f8a7871546fcddb745ddfa708f61b6774c913f34.zip
Added author property to Package class.
Diffstat (limited to 'r7r_repo/models.php')
-rw-r--r--r7r_repo/models.php17
1 files changed, 10 insertions, 7 deletions
diff --git a/r7r_repo/models.php b/r7r_repo/models.php
index 1eb7caf..44f40bf 100644
--- a/r7r_repo/models.php
+++ b/r7r_repo/models.php
@@ -252,6 +252,7 @@ class Package extends BySQLRowEnabled
$this->id = $sqlrow["id"];
$this->name = $sqlrow["name"];
$this->user = User::by_id($sqlrow["user"]);
+ $this->author = $sqlrow["author"];
$this->lastversion = $sqlrow["lastversion"];
$this->description = $sqlrow["description"];
$this->lastupdate = $sqlrow["lastupdate"];
@@ -272,12 +273,13 @@ class Package extends BySQLRowEnabled
$obj = new self;
$obj->name = $name;
$obj->user = $user;
+ $obj->author = "";
$obj->lastupdate = time();
$obj->lastversion = 0;
$obj->txtversion = "";
$obj->description = "";
- qdb("INSERT INTO `PREFIX_packages` (`name`, `user`, `lastupdate`, `lastversion`, `txtversion`, description`, `description`) VALUES ('%s', %d, UNIX_TIMESTAMP(), 0, '', '')", $name, $user->get_id());
+ qdb("INSERT INTO `PREFIX_packages` (`name`, `user`, `author`, `lastupdate`, `lastversion`, `txtversion`, description`, `description`) VALUES ('%s', %d, '', UNIX_TIMESTAMP(), 0, '', '')", $name, $user->get_id());
$obj->id = mysql_insert_id();
mkdir(dirname(__FILE__) . "/../packages/" . $this->name);
@@ -288,7 +290,7 @@ class Package extends BySQLRowEnabled
public static function by_id($id)
{
- $result = qdb("SELECT `id`, `name`, `user`, `lastversion`, `description`, `lastupdate`, `txtversion` FROM `PREFIX_packages` WHERE `id` = %d", $id);
+ $result = qdb("SELECT `id`, `name`, `author`, `user`, `lastversion`, `description`, `lastupdate`, `txtversion` FROM `PREFIX_packages` WHERE `id` = %d", $id);
$sqlrow = mysql_fetch_assoc($result);
if($sqlrow === False)
throw new DoesNotExistError();
@@ -297,7 +299,7 @@ class Package extends BySQLRowEnabled
public static function by_name($name)
{
- $result = qdb("SELECT `id`, `name`, `user`, `lastversion`, `description`, `lastupdate`, `txtversion` FROM `PREFIX_packages` WHERE `name` = '%s'", $name);
+ $result = qdb("SELECT `id`, `name`, `author`, `user`, `lastversion`, `description`, `lastupdate`, `txtversion` FROM `PREFIX_packages` WHERE `name` = '%s'", $name);
$sqlrow = mysql_fetch_assoc($result);
if($sqlrow === False)
throw new DoesNotExistError();
@@ -307,7 +309,7 @@ class Package extends BySQLRowEnabled
public static function update_lists()
{
$packagelist = array();
- $result = qdb("SELECT `id`, `name`, `user`, `lastversion`, `description`, `lastupdate`, `txtversion` FROM `PREFIX_packages` WHERE 1");
+ $result = qdb("SELECT `id`, `name`, `author`, `user`, `lastversion`, `description`, `lastupdate`, `txtversion` FROM `PREFIX_packages` WHERE 1");
while($sqlrow = mysql_fetch_assoc($result))
$packagelist[] = array($sqlrow["name"], $sqlrow["lastversion"], $sqlrow["description"]);
file_put_contents(dirname(__FILE__) . "/../packagelist", serialize($packagelist));
@@ -316,7 +318,7 @@ class Package extends BySQLRowEnabled
public static function all()
{
$rv = array();
- $result = qdb("SELECT `id`, `name`, `user`, `lastversion`, `description`, `lastupdate`, `txtversion` FROM `PREFIX_packages` WHERE 1");
+ $result = qdb("SELECT `id`, `name`, `author`, `user`, `lastversion`, `description`, `lastupdate`, `txtversion` FROM `PREFIX_packages` WHERE 1");
while($sqlrow = mysql_fetch_assoc($result))
$rv[] = self::by_sqlrow($sqlrow);
return $rv;
@@ -325,7 +327,7 @@ class Package extends BySQLRowEnabled
public static function latest()
{
$rv = array();
- $result = qdb("SELECT `id`, `name`, `user`, `lastversion`, `description`, `lastupdate`, `txtversion` FROM `PREFIX_packages` WHERE 1 ORDER BY `lastupdate` DESC LIMIT 0,15");
+ $result = qdb("SELECT `id`, `name`, `author`, `user`, `lastversion`, `description`, `lastupdate`, `txtversion` FROM `PREFIX_packages` WHERE 1 ORDER BY `lastupdate` DESC LIMIT 0,15");
while($sqlrow = mysql_fetch_assoc($result))
$rv[] = self::by_sqlrow($sqlrow);
return $rv;
@@ -334,7 +336,7 @@ class Package extends BySQLRowEnabled
public static function search($search)
{
$rv = array();
- $result = qdb("SELECT `id`, `name`, `user`, `lastversion`, `description`, `lastupdate`, `txtversion` FROM `PREFIX_packages` WHERE `name` LIKE '%%%s%%' OR `description` LIKE '%%%s%%'", $search, $search);
+ $result = qdb("SELECT `id`, `name`, `author`, `user`, `lastversion`, `description`, `lastupdate`, `txtversion` FROM `PREFIX_packages` WHERE `name` LIKE '%%%s%%' OR `description` LIKE '%%%s%%'", $search, $search);
while($sqlrow = mysql_fetch_assoc($result))
$rv[] = self::by_sqlrow($sqlrow);
return $rv;
@@ -358,6 +360,7 @@ class Package extends BySQLRowEnabled
$this->lastversion = $pkg->versioncount;
$this->txtversion = $pkg->versiontext;
$this->description = $pkg->short_description;
+ $this->author = $pkg->author;
$this->lastupdate = time();
$this->save();