From d561c7d87a3f61737889d6bd681f9368462b1c38 Mon Sep 17 00:00:00 2001 From: Sjur Hernes Date: Thu, 21 Jul 2011 06:47:07 +0200 Subject: [PATCH] made admin-interface for blimed-form and changed artist so it links to an event + external link --- .../plugins/neuf-artist/neuf-artist.php | 25 +- .../plugins/studio-blimed/studio-blimed.php | 370 +++++++++++++----- wp-content/themes/studio11 | 2 +- 3 files changed, 306 insertions(+), 91 deletions(-) diff --git a/wp-content/plugins/neuf-artist/neuf-artist.php b/wp-content/plugins/neuf-artist/neuf-artist.php index 1cb2aa8..a023800 100644 --- a/wp-content/plugins/neuf-artist/neuf-artist.php +++ b/wp-content/plugins/neuf-artist/neuf-artist.php @@ -83,6 +83,7 @@ if (!class_exists("StudioArtist")) { $artist_font = get_post_meta($post->ID, 'studio_artist_font' , true); $artist_link = get_post_meta($post->ID, 'studio_artist_link', true); + $artist_event = get_post_meta($post->ID, 'studio_artist_event', true); echo "Fontstørrelse:"; echo ''; + echo '
'; + + echo 'Event: + "; + + echo '
Artisturl:
'; @@ -123,6 +142,7 @@ if (!class_exists("StudioArtist")) { // Get posted data $studart['studio_artist_font'] = $_POST['studio_artist_font' ]; $studart['studio_artist_link'] = $_POST['studio_artist_link']; + $studart['studio_artist_event'] = $_POST['studio_artist_event']; foreach($studart as $key=>$value) if ( !update_post_meta($post_id, $key, $value)) @@ -144,8 +164,9 @@ if (!class_exists("StudioArtist")) { while ( $artister->have_posts() ) { $artister->the_post(); + $link = get_post_meta($post->ID, 'studio_artist_event', true); $size = get_post_meta($post->ID, 'studio_artist_font', true); - $html .= '
  • ' . get_the_title() . '
  • '; + $html .= '
  • ' . get_the_title() . '
  • '; } $html .= ''; diff --git a/wp-content/plugins/studio-blimed/studio-blimed.php b/wp-content/plugins/studio-blimed/studio-blimed.php index 34243d8..7569d7e 100644 --- a/wp-content/plugins/studio-blimed/studio-blimed.php +++ b/wp-content/plugins/studio-blimed/studio-blimed.php @@ -9,16 +9,19 @@ Author: Sjur Hernes Author URI: */ - +//include_once './studio-blimed-admin.php'; register_activation_hook( __FILE__, 'studio_blimed_install' ); register_deactivation_hook( __FILE__, 'studio_blimed_uninstall' ); +/** drops table on deactivation TODO : Get backup on deactivation */ + function studio_blimed_uninstall() { global $wpdb; $studio_blimed_table = $wpdb->prefix . "studio_blimed_table"; $wpdb->query("DROP TABLE IF EXISTS $studio_blimed_table ;"); } +/** Activation of plugin, creates the tables */ function studio_blimed_install() { global $wpdb; @@ -32,12 +35,9 @@ function studio_blimed_install() { studsted tinytext NOT NULL, mail tinytext NOT NULL, tlf tinytext NOT NULL, - teknisk tinyint(1) NOT NULL, - trivsel tinyint(1) NOT NULL, - transport tinyint(1) NOT NULL, - bar tinyint(1) NOT NULL, - konsert tinyint(1) NOT NULL, - artist tinyint(1) NOT NULL, + valg1 tinytext NOT NULL, + valg2 tinytext NOT NULL, + valg3 tinytext NOT NULL, morgen tinyint(1) NOT NULL, dag tinyint(1) NOT NULL, kveld tinyint(1) NOT NULL, @@ -57,6 +57,10 @@ function studio_blimed_install() { } } + +/** + * Shows form and inserts on _POST + */ function blimed_form( ) { global $wpdb; $table_name = $wpdb->prefix . 'studio_blimed_table'; @@ -64,31 +68,27 @@ function blimed_form( ) { if (isset($_POST['save'])) { - if ($_POST['funk_name'] != '' && - $_POST['funk_mail'] != '' && - $_POST['funk_tlf'] != '' && - ($_POST['funk_artist'] == 't' || - $_POST['funk_bar'] == 't' || - $_POST['funk_teknisk'] == 't' || - $_POST['funk_transport'] == 't' || - $_POST['funk_konsert'] == 't' || - $_POST['funk_trivsel'] == 't')) { - + // Some values should allways be there + if ($_POST['funk_name'] != '' && + $_POST['funk_mail'] != '' && + $_POST['funk_tlf'] != '' && + $_POST['funk_valg1'] != '') { + + // Insert into db. $settinnidb will have value if successfull :) $settinnidb = $wpdb->insert( $table_name, array( 'name' => mysql_real_escape_string($_POST['funk_name']) , 'tlf' => mysql_real_escape_string($_POST['funk_tlf']) , 'mail' => mysql_real_escape_string($_POST['funk_mail']) , 'studsted' => mysql_real_escape_string($_POST['funk_studsted']) , - 'artist' => $_POST['funk_artist'] == "t" , - 'konsert' => $_POST['funk_konsert'] == "t" , - 'bar' => $_POST['funk_bar'] == "t" , - 'teknisk' => $_POST['funk_teknisk'] == "t" , - 'transport' => $_POST['funk_transport'] == "t" , - 'trivsel' => $_POST['funk_trivsel'] == "t" , - 'morgen' => $_POST['funk_morgen'] == "t" , - 'dag' => $_POST['funk_dag'] == "t" , - 'kveld' => $_POST['funk_kveld'] == "t" , - 'natt' => $_POST['funk_natt'] == "t" , + 'valg1' => mysql_real_escape_string($_POST['funk_valg1']) , + 'valg2' => mysql_real_escape_string($_POST['funk_valg2']) , + 'valg3' => mysql_real_escape_string($_POST['funk_valg3']) , + + 'morgen' => $_POST['funk_morgen'] == "t" , + 'dag' => $_POST['funk_dag'] == "t" , + 'kveld' => $_POST['funk_kveld'] == "t" , + 'natt' => $_POST['funk_natt'] == "t" , + 'man1' => $_POST['funk_1man'] == "t" , 'tir1' => $_POST['funk_1tir'] == "t" , 'ons1' => $_POST['funk_1ons'] == "t" , @@ -110,6 +110,7 @@ function blimed_form( ) { 'fre3' => $_POST['funk_3fre'] == "t" , 'lor3' => $_POST['funk_3lør'] == "t" , 'son3' => $_POST['funk_3søn'] == "t" , + 'kommentar' => mysql_real_escape_string($_POST['funk_kommentar']) ) ); @@ -158,70 +159,97 @@ function blimed_form( ) { Hva vil du gjøre? - - - - - - - - - - -
    Artist   Bar   Teknisk   Transport   Konsert   Trivsel  
    + 1.valg oppgaver + + - - - + + + + - - + + + + +
    Ukeman  tir  ons  tor  fre  lør  søn 
    uke 1:  - - - - - - - - - - - - - -
    2.valg oppgaver
    uke 2:   - - - - - - - - - - - - - -
    3.valg oppgaver
    - uke 3:   - - - - - - - - - - - - - - + + + -
    Ukeman  tir  ons  tor  fre  lør  søn 
    uke 1:  + + + + + + + + + + + + + +
    + uke 2:   + + + + + + + + + + + + + + + + + uke 3:   + + + + + + + + + + + + + + + + Andre bemerkelser: @@ -229,7 +257,173 @@ Hva vil du gjøre? echo ''; if ($backspinn != '') echo $backspinn; - else echo 'Bli med'; + else echo 'Bli med'; } add_shortcode('blimed_form', 'blimed_form'); + +function blimed_admin_content($param, $date){ + + global $wpdb; + + $show_query = "SELECT * FROM wp_studio_blimed_table"; + $show_query2 = "SELECT * FROM wp_studio_blimed_table"; + $show_query3 = "SELECT * FROM wp_studio_blimed_table"; + + if ($param == 'all' && $date == 'all') { + $show_query .= ""; + } elseif ($param == 'all' && $date != 'all') { + $show_query .= " WHERE ".$date." = 1;"; + } elseif ($param != 'all' && $date == 'all') { + $show_query .= " WHERE valg1 = '".$param."'"; + $show_query2 .= " WHERE valg2 = '".$param."'"; + $show_query3 .= " WHERE valg3 = '".$param."'"; + } elseif ($param != 'all' && $date != 'all') { + $show_query .= " WHERE valg1 = '".$param."' AND '".$date."' = 1"; + $show_query2 .= " WHERE valg2 = '".$param."' AND '".$date."' = 1"; + $show_query3 .= " WHERE valg3 = '".$param."' AND '".$date."' = 1"; + } + + if ($param == 'all') { + echo "Søket som er utført er: " . $show_query . "

    "; + $funks = $wpdb->get_results($show_query); + + blimed_print_table($funks); + + } elseif ($param != 'all') { + + $funks = $wpdb->get_results($show_query); + $funks2 = $wpdb->get_results($show_query2); + $funks3 = $wpdb->get_results($show_query3); + + echo "

    Førstevalget: " . $param . "



    "; + + echo "Søket som er utført er: " . $show_query . "

    "; + + blimed_print_table($funks); + + echo "

    Andrevalget: " . $param . "



    "; + + echo "Søket som er utført er: " . $show_query2 . "

    "; + + blimed_print_table($funks2); + + echo "

    Tredjeevalget: ".$param."


    "; + + echo "Søket som er utført er: ".$show_query3 . "

    "; + + blimed_print_table($funks3); + + + } + +} + +function blimed_print_table( $funks ){ + + $dagvariabler = array('man1', 'tir1', 'ons1', 'tor1', 'fre1', 'lor1', 'son1', + 'man2', 'tir2', 'ons2', 'tor2', 'fre2', 'lor2', 'son2', + 'man3', 'tir3', 'ons3', 'tor3', 'fre3', 'lor3', 'son3'); + + $tidvar = array('morgen', 'dag', 'kveld', 'natt'); + echo " + + + + + + + + + + + + + "; + foreach ($funks as $funk) { + $dager = ""; $tider = ""; + foreach ($dagvariabler as $dag) { + if ($funk->$dag == 1) $dager .= $dag . ", "; + } + + foreach ($tidvar as $tid) { + if ($funk->$tid == 1) $tider .= $tid . ", "; + } + + echo " + + + + + + + + + + + " ; + } + echo "
    NavnEpostTelefonStudiestedFørstevalgAndrevalgTredjevalgDagerTiderKommentar
    $funk->name$funk->mail$funk->tlf$funk->studsted$funk->valg1$funk->valg2$funk->valg3$dager$tider$funk->kommentar


    "; +} + + +function blimed_admin() { + echo ' +
    +

    test

    + +
    + hvem skal vises: + + + +
    + '; + + if($_POST['sort']) + blimed_admin_content($_POST['blimed_admin_sort'], $_POST['blimed_admin_date']); + else + blimed_admin_content('all', 'all'); + echo ' +
    '; +} + +function blimed_admin_test() { + add_menu_page('blimed', 'blimed', 'manage_options', 'blimed-admin-slug', 'blimed_admin'); +} + +add_action('admin_menu', 'blimed_admin_test'); + diff --git a/wp-content/themes/studio11 b/wp-content/themes/studio11 index 2e5e481..ad94588 160000 --- a/wp-content/themes/studio11 +++ b/wp-content/themes/studio11 @@ -1 +1 @@ -Subproject commit 2e5e4814d7a0d16e03158ea703a643a028a1c5e5 +Subproject commit ad945881aefb414cc0645d899f7751eb805faf81