Commit 4559fe46 authored by Leigh B Stoller's avatar Leigh B Stoller

Add a flag to push a profile to the top of the list.

parent d96333e3
...@@ -336,6 +336,8 @@ sub Create($$$$$$) ...@@ -336,6 +336,8 @@ sub Create($$$$$$)
if (exists($argref->{'listed'}) && $argref->{'listed'}); if (exists($argref->{'listed'}) && $argref->{'listed'});
$cquery .= ",shared=1" $cquery .= ",shared=1"
if (exists($argref->{'shared'}) && $argref->{'shared'}); if (exists($argref->{'shared'}) && $argref->{'shared'});
$cquery .= ",topdog=1"
if (exists($argref->{'topdog'}) && $argref->{'topdog'});
# Create the main entry: # Create the main entry:
if (! DBQueryWarn("insert into apt_profiles set $cquery")) { if (! DBQueryWarn("insert into apt_profiles set $cquery")) {
...@@ -465,7 +467,7 @@ sub UpdateMetaData($$) ...@@ -465,7 +467,7 @@ sub UpdateMetaData($$)
# This is the only metadata we can update. # This is the only metadata we can update.
# #
my %mods = (); my %mods = ();
foreach my $key ("listed", "shared", "public") { foreach my $key ("listed", "shared", "public", "topdog") {
if (exists($argref->{$key})) { if (exists($argref->{$key})) {
$mods{$key} = $argref->{$key}; $mods{$key} = $argref->{$key};
} }
......
...@@ -159,6 +159,8 @@ my %xmlfields = ...@@ -159,6 +159,8 @@ my %xmlfields =
"profile_listed" => ["listed", $SLOT_OPTIONAL|$SLOT_UPDATE], "profile_listed" => ["listed", $SLOT_OPTIONAL|$SLOT_UPDATE],
"profile_public" => ["public", $SLOT_OPTIONAL|$SLOT_UPDATE], "profile_public" => ["public", $SLOT_OPTIONAL|$SLOT_UPDATE],
"profile_shared" => ["shared", $SLOT_OPTIONAL|$SLOT_UPDATE], "profile_shared" => ["shared", $SLOT_OPTIONAL|$SLOT_UPDATE],
"profile_topdog" => ["topdog", $SLOT_OPTIONAL|
$SLOT_UPDATE|$SLOT_ADMINONLY],
"rspec" => ["rspec", $SLOT_REQUIRED|$SLOT_UPDATE], "rspec" => ["rspec", $SLOT_REQUIRED|$SLOT_UPDATE],
"script" => ["script", $SLOT_OPTIONAL|$SLOT_UPDATE], "script" => ["script", $SLOT_OPTIONAL|$SLOT_UPDATE],
); );
......
...@@ -170,6 +170,7 @@ CREATE TABLE `apt_profiles` ( ...@@ -170,6 +170,7 @@ CREATE TABLE `apt_profiles` (
`public` tinyint(1) NOT NULL default '0', `public` tinyint(1) NOT NULL default '0',
`shared` tinyint(1) NOT NULL default '0', `shared` tinyint(1) NOT NULL default '0',
`listed` tinyint(1) NOT NULL default '0', `listed` tinyint(1) NOT NULL default '0',
`topdog` tinyint(1) NOT NULL default '0',
`locked` datetime default NULL, `locked` datetime default NULL,
`locker_pid` int(11) default '0', `locker_pid` int(11) default '0',
PRIMARY KEY (`profileid`), PRIMARY KEY (`profileid`),
......
...@@ -1284,6 +1284,7 @@ REPLACE INTO table_regex VALUES ('apt_profiles','name','text','redirect','images ...@@ -1284,6 +1284,7 @@ REPLACE INTO table_regex VALUES ('apt_profiles','name','text','redirect','images
REPLACE INTO table_regex VALUES ('apt_profiles','public','int','redirect','default:boolean',0,0,NULL); REPLACE INTO table_regex VALUES ('apt_profiles','public','int','redirect','default:boolean',0,0,NULL);
REPLACE INTO table_regex VALUES ('apt_profiles','listed','int','redirect','default:boolean',0,0,NULL); REPLACE INTO table_regex VALUES ('apt_profiles','listed','int','redirect','default:boolean',0,0,NULL);
REPLACE INTO table_regex VALUES ('apt_profiles','shared','int','redirect','default:boolean',0,0,NULL); REPLACE INTO table_regex VALUES ('apt_profiles','shared','int','redirect','default:boolean',0,0,NULL);
REPLACE INTO table_regex VALUES ('apt_profiles','topdog','int','redirect','default:boolean',0,0,NULL);
REPLACE INTO table_regex VALUES ('apt_profiles','description','text','redirect','default:html_fulltext',0,512,NULL); REPLACE INTO table_regex VALUES ('apt_profiles','description','text','redirect','default:html_fulltext',0,512,NULL);
REPLACE INTO table_regex VALUES ('apt_profiles','rspec','text','redirect','default:html_fulltext',0,65535,NULL); REPLACE INTO table_regex VALUES ('apt_profiles','rspec','text','redirect','default:html_fulltext',0,65535,NULL);
REPLACE INTO table_regex VALUES ('apt_profiles','script','text','redirect','default:html_fulltext',0,65535,NULL); REPLACE INTO table_regex VALUES ('apt_profiles','script','text','redirect','default:html_fulltext',0,65535,NULL);
......
#
# Modify APT profiles table.
#
use strict;
use libdb;
sub DoUpdate($$$)
{
my ($dbhandle, $dbname, $version) = @_;
if (!DBSlotExists("apt_profiles", "topdog")) {
DBQueryFatal("alter table apt_profiles add ".
" `topdog` tinyint(1) NOT NULL default '0' ".
" after listed");
}
DBQueryFatal("REPLACE INTO table_regex VALUES ".
"('apt_profiles','topdog','int','redirect',".
"'default:boolean',0,0,NULL)");
}
1;
# Local Variables:
# mode:perl
# End:
...@@ -182,7 +182,8 @@ else { ...@@ -182,7 +182,8 @@ else {
" v.profileid=p.profileid and ". " v.profileid=p.profileid and ".
" v.version=p.version ". " v.version=p.version ".
"$joinclause ". "$joinclause ".
"where locked is null and ($whereclause)"); "where locked is null and ($whereclause) ".
"order by p.topdog desc");
while ($row = mysql_fetch_array($query_result)) { while ($row = mysql_fetch_array($query_result)) {
$profile_array[$row["uuid"]] = $row["name"]; $profile_array[$row["uuid"]] = $row["name"];
if ($row["pid"] == $profile_default_pid && if ($row["pid"] == $profile_default_pid &&
......
...@@ -86,6 +86,7 @@ function (_, sup, filesize, JacksEditor, ShowImagingModal, moment, ...@@ -86,6 +86,7 @@ function (_, sup, filesize, JacksEditor, ShowImagingModal, moment,
candelete: window.CANDELETE, candelete: window.CANDELETE,
canmodify: window.CANMODIFY, canmodify: window.CANMODIFY,
canpublish: window.CANPUBLISH, canpublish: window.CANPUBLISH,
isadmin: window.ISADMIN,
history: window.HISTORY, history: window.HISTORY,
activity: window.ACTIVITY, activity: window.ACTIVITY,
snapuuid: (window.SNAPUUID || null), snapuuid: (window.SNAPUUID || null),
...@@ -270,6 +271,7 @@ function (_, sup, filesize, JacksEditor, ShowImagingModal, moment, ...@@ -270,6 +271,7 @@ function (_, sup, filesize, JacksEditor, ShowImagingModal, moment,
$('#profile_who_public').change(function() { ProfileModified(); }); $('#profile_who_public').change(function() { ProfileModified(); });
$('#profile_who_registered').change(function() { ProfileModified(); }); $('#profile_who_registered').change(function() { ProfileModified(); });
$('#profile_who_private').change(function() { ProfileModified(); }); $('#profile_who_private').change(function() { ProfileModified(); });
$('#profile_topdog').change(function() { ProfileModified(); });
/* /*
* A double click handler that will render the instructions * A double click handler that will render the instructions
......
...@@ -64,6 +64,7 @@ function SPITFORM($formfields, $errors) ...@@ -64,6 +64,7 @@ function SPITFORM($formfields, $errors)
$canpublish = 0; $canpublish = 0;
$history = 0; $history = 0;
$activity = 0; $activity = 0;
$isadmin = (ISADMIN() ? 1 : 0);
$version_uuid = "null"; $version_uuid = "null";
$profile_uuid = "null"; $profile_uuid = "null";
...@@ -153,6 +154,7 @@ function SPITFORM($formfields, $errors) ...@@ -153,6 +154,7 @@ function SPITFORM($formfields, $errors)
echo " window.CANDELETE= $candelete;\n"; echo " window.CANDELETE= $candelete;\n";
echo " window.CANMODIFY= $canmodify;\n"; echo " window.CANMODIFY= $canmodify;\n";
echo " window.CANPUBLISH= $canpublish;\n"; echo " window.CANPUBLISH= $canpublish;\n";
echo " window.ISADMIN = $isadmin;\n";
echo " window.HISTORY = $history;\n"; echo " window.HISTORY = $history;\n";
echo " window.ACTIVITY = $activity;\n"; echo " window.ACTIVITY = $activity;\n";
echo " window.TITLE = '$title';\n"; echo " window.TITLE = '$title';\n";
...@@ -272,6 +274,8 @@ if (! isset($create)) { ...@@ -272,6 +274,8 @@ if (! isset($create)) {
$defaults["profile_who"] = $defaults["profile_who"] =
($profile->shared() ? "shared" : ($profile->shared() ? "shared" :
($profile->ispublic() ? "public" : "private")); ($profile->ispublic() ? "public" : "private"));
$defaults["profile_topdog"] =
($profile->topdog() ? "checked" : "");
# Warm fuzzy message. # Warm fuzzy message.
if (isset($_SESSION["notifyupdate"])) { if (isset($_SESSION["notifyupdate"])) {
...@@ -464,6 +468,17 @@ else { ...@@ -464,6 +468,17 @@ else {
($who == "shared" ? 1 : 0) . "</value></attribute>\n"); ($who == "shared" ? 1 : 0) . "</value></attribute>\n");
fwrite($fp, "<attribute name='profile_public'><value>" . fwrite($fp, "<attribute name='profile_public'><value>" .
($who == "public" ? 1 : 0) . "</value></attribute>\n"); ($who == "public" ? 1 : 0) . "</value></attribute>\n");
if (ISADMIN()) {
fwrite($fp, "<attribute name='profile_topdog'><value>");
if (isset($formfields["profile_topdog"]) &&
$formfields["profile_topdog"] == "checked") {
fwrite($fp, "1");
}
else {
fwrite($fp, "0");
}
fwrite($fp, "</value></attribute>\n");
}
fwrite($fp, "</profile>\n"); fwrite($fp, "</profile>\n");
fclose($fp); fclose($fp);
chmod($xmlname, 0666); chmod($xmlname, 0666);
...@@ -511,7 +526,7 @@ if ($retval) { ...@@ -511,7 +526,7 @@ if ($retval) {
} }
} }
} }
unlink($xmlname); #unlink($xmlname);
if (count($errors)) { if (count($errors)) {
SPITFORM($formfields, $errors); SPITFORM($formfields, $errors);
return; return;
......
...@@ -109,6 +109,7 @@ class Profile ...@@ -109,6 +109,7 @@ class Profile
function script() { return $this->field('script'); } function script() { return $this->field('script'); }
function locked() { return $this->field('status'); } function locked() { return $this->field('status'); }
function status() { return $this->field('locked'); } function status() { return $this->field('locked'); }
function topdog() { return $this->field('topdog'); }
function parent_profileid() { return $this->field('parent_profileid'); } function parent_profileid() { return $this->field('parent_profileid'); }
function parent_version() { return $this->field('parent_version'); } function parent_version() { return $this->field('parent_version'); }
......
...@@ -327,6 +327,24 @@ ...@@ -327,6 +327,24 @@
</div> </div>
</div> </div>
<% if (isadmin) { %>
<div class='row'>
<div class='col-sm-10 col-sm-offset-2'>
<div class='checkbox format-me' data-key='profile_topdog'
data-compact='yep'>
<label>
<input name=formfields[profile_topdog]
<%- formfields.profile_topdog %>
data-key='profile_topdog'
id='profile_topdog' value='checked'
type='checkbox'>Put this profile at the top of
the list.
</label>
</div>
</div>
</div>
<% } %>
<!-- The private URL --> <!-- The private URL -->
<% if (0) { %> <% if (0) { %>
<input name="formfields[profile_version_url]" <input name="formfields[profile_version_url]"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment