| 1 | <?PHP |
| 2 | include_once('../slack.php'); |
| 3 | include_once('security.php'); |
| 4 | if ($_COOKIE['level'] == 'user'){ |
| 5 | slack_general('ADMIN: Redirect User Home ('.$_COOKIE['name'].') ('.$_COOKIE['level'].')','md-petition'); |
| 6 | header('Location: user_home.php'); |
| 7 | } |
| 8 | include_once('header.php'); |
| 9 | slack_general('ADMIN: petition manager Loaded ('.$_COOKIE['name'].') ('.$_COOKIE['level'].')','md-petition'); |
| 10 | $group_id = $_COOKIE['group_id']; |
| 11 | |
| 12 | if(empty($_POST['petition_id']) && isset($_POST['petition_name']) ){ // new |
| 13 | $web_short_name = $petition->real_escape_string($_POST['web_short_name']); |
| 14 | $web_color = $petition->real_escape_string($_POST['web_color']); |
| 15 | $petition_name = $petition->real_escape_string($_POST['petition_name']); |
| 16 | $petition->query("insert into petitions (web_short_name,web_color,group_id,petition_name) values ('$web_short_name','$web_color','$group_id','$petition_name') "); |
| 17 | header('Location: petitions.php'); |
| 18 | } |
| 19 | if(isset($_POST['petition_id']) && isset($_POST['petition_name']) ){ // edit |
| 20 | $petition_id = $petition->real_escape_string($_POST['petition_id']); |
| 21 | $web_short_name = $petition->real_escape_string($_POST['web_short_name']); |
| 22 | $web_color = $petition->real_escape_string($_POST['web_color']); |
| 23 | $petition_name = $petition->real_escape_string($_POST['petition_name']); |
| 24 | $petition_sign_text_box = $petition->real_escape_string($_POST['petition_sign_text_box']); |
| 25 | $petition_circulator_text_box = $petition->real_escape_string($_POST['petition_circulator_text_box']); |
| 26 | $eligibleVoterListWarning = $petition->real_escape_string($_POST['eligibleVoterListWarning']); |
| 27 | $eligibleVoterListEnforce = $petition->real_escape_string($_POST['eligibleVoterListEnforce']); |
| 28 | $eligibleVoterListField = strtoupper($petition->real_escape_string($_POST['eligibleVoterListField'])); |
| 29 | $eligibleVoterListEquals = $petition->real_escape_string($_POST['eligibleVoterListEquals']); |
| 30 | $eligibleVoterSigMatch = $petition->real_escape_string($_POST['eligibleVoterSigMatch']); |
| 31 | $signature_goal = $petition->real_escape_string($_POST['signature_goal']); |
| 32 | |
| 33 | // custom landing page - paid feature one day? |
| 34 | $tab_name = $petition->real_escape_string($_POST['tab_name']); |
| 35 | $text_title = $petition->real_escape_string($_POST['text_title']); |
| 36 | $text_block = $petition->real_escape_string($_POST['text_block']); |
| 37 | $logo_url = $petition->real_escape_string($_POST['logo_url']); |
| 38 | |
| 39 | $petition->query("update petitions set signature_goal='$signature_goal', logo_url='$logo_url', text_block='$text_block', text_title='$text_title', tab_name='$tab_name', eligibleVoterSigMatch='$eligibleVoterSigMatch', eligibleVoterListWarning='$eligibleVoterListWarning', web_short_name='$web_short_name', web_color='$web_color', petition_name='$petition_name', petition_sign_text_box='$petition_sign_text_box', petition_circulator_text_box='$petition_circulator_text_box', eligibleVoterListEnforce='$eligibleVoterListEnforce', eligibleVoterListField='$eligibleVoterListField', eligibleVoterListEquals='$eligibleVoterListEquals' where petition_id = '$petition_id' "); |
| 40 | header('Location: petitions.php'); |
| 41 | } |
| 42 | ?> |
| 43 | <h1>Petitions</h1> |
| 44 | <?PHP |
| 45 | if($_COOKIE['level'] == 'admin'){ |
| 46 | $q="SELECT * FROM petitions"; |
| 47 | }else{ |
| 48 | $q="SELECT * FROM petitions where group_id = '$group_id'"; |
| 49 | } |
| 50 | $r = $petition->query($q); |
| 51 | while($d = mysqli_fetch_array($r)){ |
| 52 | echo "<li><a href='?edit=$d[petition_id]'>EDIT</a> $d[admin_status] $d[web_short_name] $d[web_color] $d[group_id] $d[petition_name] $d[eligibleVoterListField] $d[eligibleVoterListEquals] $d[eligibleVoterListEnforce]</li>"; |
| 53 | } |
| 54 | ?> |
| 55 | |
| 56 | <?PHP |
| 57 | if (isset($_GET['edit'])){ |
| 58 | $id = intval($_GET['edit']); |
| 59 | $q = "SELECT * FROM petitions where petition_id = '$id' "; |
| 60 | $r = $petition->query($q); |
| 61 | $d = mysqli_fetch_array($r); |
| 62 | ?> |
| 63 | <h1>Edit Petition Setup</h1> |
| 64 | <h3>Please keep whatever text you use in a word or google doc that you control, copy and paste here.</h3> |
| 65 | <form method='post'> |
| 66 | <input type='hidden' name='petition_id' value='<?PHP echo $id;?>'> |
| 67 | <table> |
| 68 | <tr><td><b>Required</b></td><td> </td></tr> |
| 69 | <tr><td>Web Short Name*</td><td><input name='web_short_name' value='<?PHP echo $d['web_short_name'];?>' required></td></tr> |
| 70 | <tr><td>Web Color</td><td><input type="color" name='web_color' value='<?PHP echo $d['web_color'];?>' required></td></tr> |
| 71 | <tr><td>Petition Name</td><td><input name='petition_name' value='<?PHP echo $d['petition_name'];?>' required></td></tr> |
| 72 | <tr><td>Petition Sign Text Box</td><td><textarea rows='5' cols='50' name='petition_sign_text_box' required><?PHP echo $d['petition_sign_text_box'];?></textarea></td></tr> |
| 73 | <tr><td>Petition Circulator Text Box</td><td><textarea rows='5' cols='50' name='petition_circulator_text_box' required><?PHP echo $d['petition_circulator_text_box'];?></textarea></td></tr> |
| 74 | <tr><td>eligibleVoterList Enforce</td><td><select name='eligibleVoterListEnforce'><option><?PHP echo $d['eligibleVoterListEnforce'];?></option><option>NO</option><option>YES</option></select></td></tr> |
| 75 | <tr><td>eligibleVoterList Field</td><td><input name='eligibleVoterListField' value='<?PHP echo $d['eligibleVoterListField'];?>' required></td></tr> |
| 76 | <tr><td>eligibleVoterList Equals</td><td><input name='eligibleVoterListEquals' value="<?PHP echo $d['eligibleVoterListEquals'];?>" required></td></tr> |
| 77 | <tr><td>eligibleVoterList Warning</td><td><textarea rows='5' cols='50' name='eligibleVoterListWarning' required><?PHP echo $d['eligibleVoterListWarning'];?></textarea></td></tr> |
| 78 | <tr><td>VoterList Signature Match Required</td><td><select name='eligibleVoterSigMatch' required><option><?PHP echo $d['eligibleVoterSigMatch'];?></option><option>NO</option><option>YES</option></select></td></tr> |
| 79 | <tr><td><b>Not Required</b></td><td> </td></tr> |
| 80 | <tr><td>Signature Goal</td><td><input name='signature_goal' value="<?PHP echo $d['signature_goal'];?>"></td></tr> |
| 81 | <tr><td>Landing Page Title</td><td><input name='tab_name' value="<?PHP echo $d['tab_name'];?>"></td></tr> |
| 82 | <tr><td>Landing Page Header</td><td><input name='text_title' value="<?PHP echo $d['text_title'];?>"></td></tr> |
| 83 | <tr><td>Landing Page Body</td><td><textarea rows='5' cols='50' name='text_block'><?PHP echo $d['text_block'];?></textarea></td></tr> |
| 84 | <tr><td>Logo URL</td><td><input name='logo_url' value="<?PHP echo $d['logo_url'];?>"></td></tr> |
| 85 | |
| 86 | |
| 87 | |
| 88 | <tr><td></td><td><input type='submit'></td></tr> |
| 89 | </table> |
| 90 | </form> |
| 91 | * changes may break already sent invites! |
| 92 | |
| 93 | <?PHP |
| 94 | } |
| 95 | ?> |
| 96 | <h1>New Petition</h1> |
| 97 | <form method='post'> |
| 98 | web_short_name <input name='web_short_name' required> |
| 99 | web_color <input type="color" name='web_color' required> |
| 100 | petition_name <input name='petition_name' required> |
| 101 | <input type='submit'> |
| 102 | </form> |
| 103 | <br><br><br> |
| 104 | <?PHP |
| 105 | include_once('footer.php'); |
| 106 | ?> |