]> ruin.nu Git - ndwebbie.git/commitdiff
done
authorMichael Andreen <harv@ruin.nu>
Fri, 15 Dec 2006 12:01:46 +0000 (12:01 +0000)
committerMichael Andreen <harv@ruin.nu>
Fri, 15 Dec 2006 12:01:46 +0000 (12:01 +0000)
alliances.pl
templates/alliances.tmpl

index 101f2db12a9caf69664041cc55b5d3a81ef4afa5..62aae64f71ad2b7a98c5e8e5e81df5012773a30b 100644 (file)
@@ -33,12 +33,31 @@ if (param('alliance') =~ /^(\d+)$/){
        my $query = $DBH->prepare(q{SELECT id,name, relationship FROM alliances WHERE id = ?});
        $alliance = $DBH->selectrow_hashref($query,undef,$1);
 }
-if ($alliance && param ('cmd') eq 'coords'){
-       $DBH->begin_work;
-       $DBH->commit or $error .= "<p> Something went wrong: ".$DBH->errstr."</p>";
-}
 if ($alliance && param ('cmd') eq 'change'){
        $DBH->begin_work;
+       if (param('crelationship')){
+               my $value = escapeHTML(param('relationship'));
+               if ($DBH->do(q{UPDATE alliances SET relationship = ? WHERE id =?}
+                               ,undef,$value,$alliance->{id})){
+                       $alliance->{relationship} = $value;
+                       $LOG->execute($ND::UID,"HC set alliance: $alliance->{id} relationship: $value");
+               }else{
+                       $error .= "<p> Something went wrong: ".$DBH->errstr."</p>";
+               }
+       }
+       my $coords = param('coords');
+       my $addplanet = $DBH->prepare(q{
+UPDATE planets SET alliance_id = ?, nick = coalesce(?,nick)
+WHERE id = (SELECT id FROM current_planet_stats WHERE x = ? AND y = ? AND z = ?);
+               });
+       while ($coords =~ m/(\d+):(\d+):(\d+)(?:\s+nick=\s*(\S+))?/g){
+               if ($addplanet->execute($alliance->{id},$4,$1,$2,$3)){
+                       $error .= "<p> Added planet $1:$2:$3 (nick $4) to this alliance</p>";
+                       $LOG->execute($ND::UID,"HC Added planet $1:$2:$3 (nick $4) to alliance: $alliance->{id}");
+               }else{
+                       $error .= "<p> Something went wrong: ".$DBH->errstr."</p>";
+               }
+       }
        $DBH->commit or $error .= "<p> Something went wrong: ".$DBH->errstr."</p>";
 }
 
index 85f84ffc6f9031019ce90873063d9aaf86c256c4..b090cf07436d3fe8d73b08aa0efac8a2386fea6f 100644 (file)
@@ -4,6 +4,7 @@
        <input type="hidden" name="page" value="alliances"/>
        <input type="hidden" name="cmd" value="change"/>
        <input type="hidden" name="alliance" value="<TMPL_VAR NAME=Id>"/>
+<div class="leftinfo">
        <p>Alliance: <TMPL_VAR NAME=Alliance></p>
        <p>Relationship: <select name="relationship">
                <TMPL_LOOP Relationships>
                </TMPL_LOOP>
                </select>
                <input type="checkbox" name="crelationship"/></p>
-       <p><input type="submit" value="Submit"/></p>
+</div>
+
+<div class="leftinfo">
+       <p>Paste a list of coords that you want to add to this alliance</p>
+       <textarea rows="10" cols="40" name="coords"></textarea>
+</div>
+<div class="clear">&nbsp;</div>
+       <p class="claimlinks"><input type="submit" value="Submit"/></p>
 </fieldset></form>
 <div class="leftinfo">
 <table>
 </table>
 </div>
 <div class="leftinfo">
-<form action="index.pl" method="post"><fieldset> <legend>Coords</legend>
-       <input type="hidden" name="page" value="alliances"/>
-       <input type="hidden" name="cmd" value="coords"/>
-       <input type="hidden" name="alliance" value="<TMPL_VAR NAME=Id>"/>
-       <p>Paste a list of coords that you want to add to this alliance</p>
-       <textarea rows="25" cols="40" name="coords"></textarea>
-       <p><input type="submit" value="Submit"/></p>
-</fieldset></form>
-</div>
-<div class="leftinfo">
 <table>
        <tr>
                <th>Alliance</th><th>Sender</th>