From f8a7871546fcddb745ddfa708f61b6774c913f34 Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Thu, 5 Jan 2012 23:47:31 +0100 Subject: Added author property to Package class. --- r7r_repo/main.php | 2 ++ r7r_repo/models.php | 17 ++++++++++------- r7r_repo/templates/src/home.html | 4 +++- r7r_repo/templates/src/master.html | 4 ++-- 4 files changed, 17 insertions(+), 10 deletions(-) (limited to 'r7r_repo') diff --git a/r7r_repo/main.php b/r7r_repo/main.php index d28cb44..6c097a8 100644 --- a/r7r_repo/main.php +++ b/r7r_repo/main.php @@ -15,6 +15,7 @@ if(!SKIP_TABLE_CREATION) $db_structure = "CREATE TABLE IF NOT EXISTS `PREFIX_packages` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` text COLLATE utf8_unicode_ci NOT NULL, + `author` text COLLATE utf8_unicode_ci NOT NULL, `lastversion` int(11) NOT NULL, `user` int(11) NOT NULL, `description` text COLLATE utf8_unicode_ci NOT NULL, @@ -121,6 +122,7 @@ $url_handlers = array( $ste->vars["latest_pkgs"] = array_map(function($pkg) { return array( "name" => $pkg->get_name(), "version" => $pkg->txtversion, + "author" => $pkg->author, "description" => $pkg->description, "last_update" => $pkg->lastversion ); }, $latest); 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(); diff --git a/r7r_repo/templates/src/home.html b/r7r_repo/templates/src/home.html index 26711d1..4206fc2 100644 --- a/r7r_repo/templates/src/home.html +++ b/r7r_repo/templates/src/home.html @@ -10,6 +10,7 @@ Package Name Version Description + Author Last update @@ -23,13 +24,14 @@ $pkg[name] $pkg[version] $pkg[description] + $pkg[author] $pkg[last_update] - No Packages available. + No Packages available. diff --git a/r7r_repo/templates/src/master.html b/r7r_repo/templates/src/master.html index 9e9b8df..78f8e0b 100644 --- a/r7r_repo/templates/src/master.html +++ b/r7r_repo/templates/src/master.html @@ -34,7 +34,7 @@ ?{$repo[public]|Upload Package|} - My Plugins + My Plugins My Account Logout @@ -45,6 +45,7 @@
+

Repository Base URL

@@ -79,7 +80,6 @@
-
-- cgit v1.2.3-70-g09d2