Location: PHPKode > projects > Homeless Mangement Information System > hmis/edit_questions.php
<?php
//*Client Data System, Copyright (C) 2000, 2001, 2002 Tedd Kelleher.  This is free software, subject to the 
//*GNU GENERAL PUBLIC LICENSE, Version 2, June 1991 (in file named gpl.txt), which should accompany 
//*any distribution of this file.  Tedd Kelleher can be contacted at hide@address.com

$page_access_levels = ":10:20:30:";

////Header for every page that finds the include directory, connects to db, authenticates user access 
include("initialize_pointer.php");
if(!include($include_root."authenticate.inc")){echo "No Authentication"; exit; };


include($include_root."Questions_into_array_class.inc");
//include($include_root."questions_display_edit.inc");
include($include_root."questions_display.inc");
//include($include_root."Questions_answers_validation_class.inc");
include($include_root."head.inc");	
include($include_root."template_parser.inc");
include($include_root."Questions_answers_validation_class.inc");
include($include_root."edit_questions_class.inc");
include($include_root."reports_class.inc");
include($include_root."page_elements_display.inc");
include($include_root."services_functions.inc");

convert_post_and_get_variable ("new_question_answer");

//If they submitted report type to edit, process the request
if ($HTTP_GET_VARS["edit_page_id"]) {
    $page_id = "edit_questions";
    //echo "Edit a specific report<p>";

    //Vet the page id
    if( ereg("[^A-Za-z0-9]\_", $HTTP_GET_VARS["edit_page_id"]) ) {
        $edit_page_id = "";
        echo "Improper page id";
        exit;
    }
    else    {
        $edit_page_id = $HTTP_GET_VARS["edit_page_id"];
    }

    $raw_report_array = pull_array_of_report_type_id ($edit_page_id);  
    $page_title = "Edit Questions for Form: ".$raw_report_array["report_title"];
    

    if (check_that_report_type_exists ($HTTP_GET_VARS["edit_page_id"]) == 1 )  {
        display_report_edit_options ($access_level);

    }
    else    {
        echo "Report type does not exist"; exit;
    }
    


    $pull_questions_edit = new Questions_into_array ($edit_page_id, $access_level, $org_id, $group_id, "edit");

    $pull_questions_optional = new Questions_into_array ($edit_page_id, $access_level, $org_id, $group_id, "optional_only");

    $edit_class = new Edit_questions();
    $optional_questions = new Optional_questions();
    $optional_questions->pull_optional_questions_status ();

    if ( $_POST['form_submitted'] == 'edit_questions' ){
         $optional_questions->process_edited_optional_questions ($pull_questions_optional->questions,
         $HTTP_POST_VARS["form_answer_optional_question"]);

	    if ($new_question_answer["question_title"])	{
		    $edit_class->process_new_question_entry ($new_question_answer);
	    }

	    
    }

    $pull_questions_edit_two = new Questions_into_array ($edit_page_id, $access_level, $org_id, $group_id, "edit");

    $optional_questions->pull_optional_questions_status ();

    if ( $access_level == '10' )	{
		    $tag_values["{FORM_END}"] .= "<a href=\"".$system_directory."edit_ecma.php?edit_page_id=".$edit_page_id."\"
             target=\"_blank\">Click Here to Edit ECMA for these Questions</a><p/>";

            $tag_values["{FORM_END}"] .= "<a href=\"".$system_directory."dump_system_questions.php\" target=\"_blank\">
            Click Here to Dump Setup SQL for All Questions in System</a><p/>";
            
            $tag_values["{FORM_END}"] .= "<a href=\"".$system_directory."dump_system_questions.php?report_name=".$edit_page_id."\"
             target=\"_blank\">
            Click Here to Dump Setup SQL for this report</a><p/>";
                       
            $rpt_prof = new Edit_report_type_profile($edit_page_id);
            if ( $_POST['edit_report_profile'] == 'yes' )  {
                //echo "EDIT VALUES ON REPORT PROFILE";
                $rpt_prof->process_submitted_report_profile($form_answer);
            }
            $tag_values["{EDIT_REPORT_TYPE_PROFILE}"] = $rpt_prof->display_report_type_profile();
    }
    else {
        $tag_values["{EDIT_REPORT_TYPE_PROFILE}"] = " ";
    }

        //Define the values for tags contained in the html template
		if ( $access_level == '10' || $access_level == '20' || $access_level == '30'  )
		{
			$tag_values["{EDIT_QUESTIONS_TABLE}"] = '<table><tr><td class="generictabletop">Edit Custom Questions on Your Report Form by Modifying the Following</td></tr></table>';
	    	$tag_values["{EDIT_QUESTIONS_TABLE}"] .= $edit_class->edit_questions_table ($pull_questions_edit_two->questions, $pull_questions_edit_two->question_elements);
			
			$tag_values["{NEW_QUESTION_ENTRY}"] = '<table><tr><td class="generictabletop">Add New Custom Questions By Filling in Form Blank Below</td></tr></table>';
	    	$tag_values["{NEW_QUESTION_ENTRY}"] .= $edit_class->display_new_question_entry ();
		}
		else
		{
			$tag_values["{EDIT_QUESTIONS_TABLE}"] = ' ';
			$tag_values["{NEW_QUESTION_ENTRY}"] = ' ';
		}
        
	    $tag_values["{OPTIONAL_QUESTIONS_TABLE}"] = $optional_questions->display_optional_questions_table (
                                                                                    $pull_questions_optional->questions, 
                                                                                    $pull_questions_optional->question_elements );
		
		//if not sys admin and no optional questions to add then no submit button needed.
		if (count($pull_questions_optional->questions)>0 || $access_level == '10' || $access_level == '20' || $access_level == '30' )
		{
			$tag_values["{FORM_START}"] = form_start ($this_page."?edit_page_id=".$edit_page_id);
			$tag_values["{FORM_END}"] .= form_end ("Submit Edited Questions");
		}
		else //no questions to submit
		{
			$tag_values["{FORM_START}"] = ' ';
			$tag_values["{FORM_END}"] .= 'There are currently no optional questions available. ';
		}
}

//They didn't submit a get variable "page_id", of give them a list of choices
else {
    $page_id = "edit_questions_choices";
    $page_title = "Edit Forms";
    $tag_values["{EDIT_REPORT_OPTIONS}"] = display_report_edit_options($access_level);
}


$tag_values["{MENU}"] = menu();
$tag_values["{FOOTER}"] = footer();
$tag_values["{PAGE TITLE}"] = page_title_table();
$tag_values["{HEAD}"] = head ($page_title, $head_page_specific, $head_dynamic_style);


//Substitute the specific question tags, leftover question tags, and specific tags in the html template with dynamic values, and display the result
template_parser ($page_id.".html", $tag_values);
//template_parser($page_id.".html","", "", $tag_values, $validation->form_answer);


///////////////////////////

function display_report_edit_options ($access_level) {
    GLOBAL $HTTP_POST_VARS, $form_answer;
   
    
    if ( $access_level == '10' )    {
    
        $rp = new Add_report_profile ();
        if ( $_POST['form_submitted'] == 'edit_questions_choices' )  {
                $rp->process_new_report_profile($form_answer);
        }
        $new_report_html = $rp->display_add_report_type_profile_form();
     
    }
   
   
   
    $available_reports = pull_names_of_all_reports_available_for_editing ($access_level);
    
    $html .= "<table>";
    $html .= "<tr><td colspan=\"2\" class=\"generictabletop\">Choose from a form below to edit</td></tr>";
    foreach ($available_reports AS $report_type_id => $current_report)  {
        $html .= "<tr><td><a href=\"".$system_directory."edit_questions.php?edit_page_id=".$report_type_id."\">".$current_report["report_title"]."</a></td><td class=\"smaller75\">".$current_report["report_description"]."</td></tr>";
    
    
    }

    $html .= "</table><p>".$new_report_html;
    
    
    
    
    
    return $html;
    
}	




?>
Return current item: Homeless Mangement Information System