Example #1
0
function teamForm($form, &$form_state)
{
    global $user;
    $UID = $user->uid;
    $params = drupal_get_query_parameters();
    $new = true;
    if (isset($params["TID"])) {
        // getting the team ID if it's set in the URL's parameters
        $oldTeam = dbGetTeam($params["TID"]);
        $new = false;
    }
    $form = array();
    if ($new) {
        // if user is creating a completely new team
        $form['fields'] = array('#type' => 'fieldset', '#title' => t('Create A New Team'));
    } else {
        // if user is editing a team
        $form['fields'] = array('#type' => 'fieldset', '#title' => t('Edit: ' . $oldTeam['name']));
    }
    if (!$new) {
        // if user wants to cancel any changes they made
        $form['fields']['back'] = array('#prefix' => '<left>', '#limit_validation_errors' => array(), '#submit' => array('backToTeam'), '#type' => 'submit', '#value' => '⇦ Cancel Changes', '#attributes' => array('OnSubmit' => 'if(!confirm("Back?")){return false;}'), '#suffix' => '</left>');
    }
    // setting the team name
    $form['fields']['name'] = array('#prefix' => '<table><tr><td colspan="3" style="text-align:center">', '#default_value' => $new ? '' : $oldTeam['name'], '#type' => 'textfield', '#disabled' => $new ? false : true, '#title' => t('Team Name'), '#suffix' => '</td>');
    // setting the team number
    $form['fields']['number'] = array('#prefix' => '<td colspan="3" style="text-align:center">', '#default_value' => $new ? '' : $oldTeam['number'], '#type' => 'textfield', '#disabled' => $new ? false : true, '#title' => t('Team Number'), '#suffix' => '</td></tr>');
    // setting the type of robotics team (FLL vs FTC vs FRC etc.)
    $form['fields']['type'] = array('#prefix' => '<tr><td colspan="3" style="text-align:center">', '#default_value' => $new ? '' : $oldTeam['type'], '#type' => 'select', '#title' => t('Type of Team'), '#options' => array('FRC' => 'FIRST Robotics Competition', 'FTC' => 'FIRST Technology Challenge', 'FLL' => 'FIRST Lego League', 'Other' => 'Other'), '#chosen' => true, '#suffix' => '</td>');
    // setting the home city
    $form['fields']['city'] = array('#prefix' => '<td colspan="3" style="text-align:center">', '#default_value' => $new ? '' : $oldTeam['city'], '#type' => 'textfield', '#title' => t('City'), '#suffix' => '</td></tr>');
    // setting the home state
    $form['fields']['state'] = array('#prefix' => '<tr><td colspan="3" style="text-align:center">', '#default_value' => $new ? '' : $oldTeam['state'], '#type' => 'select', '#title' => t('State'), '#options' => states_list(), '#chosen' => true, '#suffix' => '</td>');
    // setting the home country of the team
    $form['fields']['country'] = array('#prefix' => '<td colspan="3" style="text-align:center">', '#default_value' => $new ? '' : $oldTeam['country'], '#type' => 'select', '#title' => t('Country'), '#options' => countries_list(), '#default_value' => 'United States', '#chosen' => true, '#suffix' => '</td></tr>');
    // rookie year of team
    $form['fields']['rookieYear'] = array('#prefix' => '<tr><td colspan="6" style="text-align:center">', '#type' => 'textfield', '#title' => t('Rookie Year'), '#default_value' => $new ? NULL : $oldTeam['rookieYear'], '#suffix' => '</td></tr><tr>');
    if (!$new) {
        // if the team is not new and you want to delete permanently, then you can do it via this button
        $form['fields']['delete'] = array('#prefix' => '<td colspan="3" style="text-align:left">', '#type' => 'submit', '#value' => 'Delete Team', '#limit_validation_errors' => array(), '#attributes' => array('onclick' => 'if(!confirm("Are you sure you want to delete this team PERMANENTLY?")){return false;}'), '#submit' => array('deleteTeam'), '#suffix' => '</td>');
        // submitting the info which the user just updated
        $form['fields']['submit'] = array('#prefix' => '<td colspan="3" style="text-align:right">', '#type' => 'submit', '#value' => t('Save'), '#suffix' => '</td>');
    } else {
        // submitting the info which the user just inputted (with a different colspan)
        $form['fields']['submit'] = array('#prefix' => '<td colspan="6" style="text-align:right">', '#type' => 'submit', '#value' => t('Save'), '#suffix' => '</td>');
    }
    $form['fields']['footer'] = array('#markup' => '</tr></table>');
    // checking proper permissions for user
    if (!$new && !hasPermissionForTeam('editTeam', $params['TID'])) {
        drupal_set_message("You don't have permission to edit {$oldTeam['name']}.", 'error');
        drupal_goto('viewTeam', array('query' => array('TID' => $params['TID'])));
    }
    return $form;
}
Example #2
0
if ($user->AsWebMaster == false) {
    $tpl = new templates();
    echo "alert('" . $tpl->javascript_parse_text("{ERROR_NO_PRIVS}") . "');";
    die;
    exit;
}
if (isset($_GET["tabs"])) {
    tabs();
    exit;
}
if (isset($_GET["popup"])) {
    popup();
    exit;
}
if (isset($_GET["countries-list"])) {
    countries_list();
    exit;
}
if (isset($_POST["country"])) {
    save();
    exit;
}
js();
function js()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $title = $tpl->_ENGINE_parse_body("{country_block}");
    $html = "YahooWin3('760','{$page}?popup=yes&servername={$_GET["servername"]}','{$_GET["servername"]}::{$title}');";
    echo $html;
}
Example #3
0
function outreachForm($form, &$form_state)
{
    global $user;
    $UID = $user->uid;
    $params = drupal_get_query_parameters();
    $currentTeam = getCurrentTeam();
    $TID = $currentTeam['TID'];
    $form_state['TID'] = $TID;
    $new = $form_state['new'] = true;
    if (teamIsIneligible($TID)) {
        drupal_set_message('Your team does not have permission to access this page.', 'error');
        drupal_goto($_SERVER['HTTP_REFERER']);
    }
    if (isset($params["OID"])) {
        $form_state['OID'] = $params['OID'];
        $new = $form_state['new'] = false;
        $outreach = dbGetOutreach($params["OID"]);
        $times = dbGetTimesForOutreach($params["OID"]);
        // set to display all times
        $form_state['numRows'] = count($times);
        // record how many were there before (in case user deletes one)
        $form_state['initialNumTimes'] = count($times);
        $TID = $outreach['TID'];
        $form_state['TID'] = $TID;
    }
    $form = array();
    // if the user is editing an old outreach
    if (!$new) {
        // menu hook to duplicate outreach
        $confirmBoxJS = "if(!confirm('Are you sure you want to duplicate this outreach? Any changes you made just now will NOT be saved.')){return false;}";
        $form['duplicate'] = array('#prefix' => "<div style=\"text-align:right\"><a href=\"?q=duplicateOutreach/{$form_state['OID']}/{$TID}\">", '#markup' => "<button onclick=\"{$confirmBoxJS}\" type=\"button\">Duplicate</button>", '#suffix' => '</a>');
    }
    if (!$new) {
        // menu hook to cancel the outreach
        if ($outreach["cancelled"]) {
            $confirmBoxJS = "if(!confirm('Are you sure you want to uncancel this outreach for the team?')){return false;}";
            $form['cancel'] = array('#prefix' => "<a href=\"?q=cancelOutreach/{$form_state['OID']}/{$TID}\">", '#markup' => "<button onclick=\"{$confirmBoxJS}\" type=\"button\">Uncancel Outreach</button>", '#suffix' => '</a></div>');
        } else {
            $confirmBoxJS = "if(!confirm('Are you sure you want to cancel this outreach for the team? This will remove the outreach from current team use.')){return false;}";
            $form['cancel'] = array('#prefix' => "<a href=\"?q=cancelOutreach/{$form_state['OID']}/{$TID}\">", '#markup' => "<button onclick=\"{$confirmBoxJS}\" type=\"button\">Cancel From Team Use</button>", '#suffix' => '</a></div>');
        }
    }
    $teamNumb = dbGetTeamNumber($TID);
    // form title
    $form['fields'] = array('#type' => 'fieldset', '#title' => t('Add Outreach: Team ' . '<b>' . $teamNumb . '</b>'));
    // if editing an outreach, then allow a user to cancel changes
    if (!$new) {
        $form['fields']['back'] = array('#prefix' => '<left>', '#limit_validation_errors' => array(), '#submit' => array('backToEvent'), '#type' => 'submit', '#value' => '⇦ Cancel Changes', '#attributes' => array('OnSubmit' => 'if(!confirm("Back?")){return false;}'), '#suffix' => '</left>');
    }
    $form['fields']['markupOne'] = array('#markup' => '<table>');
    // displays the name of the outreach editing
    $form['fields']['name'] = array('#prefix' => '<tr><td colspan="3" style="text-align:center">', '#type' => 'textfield', '#title' => t('Outreach Name:'), '#default_value' => $new ? '' : $outreach['name'], '#placeholder' => 'Name of the event', '#attributes' => array('onsubmit' => 'return false'), '#suffix' => '</td>');
    $tags = dbGetOutreachTagsForTeam($TID);
    // notifies a user to create outreach tags if the team doesn't have any
    if (empty($tags)) {
        if (hasPermissionForTeam('manageOutreachTags', $TID)) {
            $msg = 'Click <a href="?q=teamOutreachSettings"><b>here</b></a> to change your settings.';
        } else {
            $msg = 'Please have a team admin or owner set up tags for your team.';
        }
        drupal_set_message('To give the outreach a tag, you need to set up the tag options for your team! ' . $msg, 'error');
        $form['fields']['tags'] = array('#prefix' => '<td colspan="3" style="text-align:center">', '#markup' => 'Tags:<br><em>You have no available tags.</em>', '#suffix' => '</td></tr>');
    } else {
        // allows a user to add tags to the outreach
        if (!$new) {
            // get only OTID's to satisfy select field
            $oldTags = dbGetTagsForOutreach($form_state['OID'], true);
        }
        $form['fields']['tags'] = array('#prefix' => '<td colspan="3" style="text-align:center">', '#type' => 'select', '#id' => 'tags_field', '#title' => t('Tags:'), '#options' => $tags, '#default_value' => $new ? '' : $oldTags, '#chosen' => true, '#multiple' => true, '#suffix' => '</td></tr>');
    }
    // allows a user to change the status of the outreach if they have permission
    if (hasPermissionForTeam('manageOutreachTags', $TID)) {
        $form['fields']['status'] = array('#prefix' => '<tr><td colspan="3" style="text-align:center">', '#type' => 'select', '#default_value' => $new ? 'Select' : $outreach['status'], '#options' => array('isIdea' => 'Idea', 'isOutreach' => 'Outreach', 'doingWriteUp' => 'Write-Up', 'locked' => 'Locked'), '#title' => t('Status:'), '#chosen' => true, '#suffix' => '</td>');
        // if the user doesn't have permission, then the status of isIdea displays idea
    } else {
        if (!$new && $outreach['status'] == 'isIdea') {
            $form['fields']['status'] = array('#prefix' => '<tr><td colspan="3" style="text-align:center">', '#type' => 'select', '#title' => t('Status:'), '#options' => array('isIdea' => 'Idea'), '#default_value' => 'isIdea', '#disabled' => true, '#suffix' => '</td>');
            // if the user doesn't have permission, then the status of isOutreach displays outreach
        } else {
            if (!$new && $outreach['status'] == 'isOutreach') {
                $form['fields']['status'] = array('#prefix' => '<tr><td colspan="3" style="text-align:center">', '#type' => 'select', '#title' => t('Status:'), '#options' => array('isOutreach' => 'Outreach'), '#default_value' => 'isOutreach', '#disabled' => true, '#suffix' => '</td>');
                // if the user doesn't have permission, then the status of doingWriteUp displays write-up
            } else {
                if (!$new && $outreach['status'] == 'doingWriteUp') {
                    $form['fields']['status'] = array('#prefix' => '<tr><td colspan="3" style="text-align:center">', '#type' => 'select', '#title' => t('Status:'), '#options' => array('doingWriteUp' => 'Write-Up'), '#default_value' => 'doingWriteUp', '#disabled' => true, '#suffix' => '</td>');
                    // if the user doesn't have permission, then the status of locked displays locked
                } else {
                    if (!$new && $outreach['status'] == 'locked') {
                        $form['fields']['status'] = array('#prefix' => '<tr><td colspan="3" style="text-align:center">', '#type' => 'select', '#title' => t('Status:'), '#options' => array('locked' => 'Locked'), '#default_value' => 'locked', '#disabled' => true, '#suffix' => '</td>');
                        // if the user doesn't have permission, then the events created can only have a status of idea
                    } else {
                        $form['fields']['status'] = array('#prefix' => '<tr><td colspan="3" style="text-align:center">', '#type' => 'select', '#default_value' => $new ? 'Select' : $outreach['status'], '#options' => array('isIdea' => 'Idea'), '#title' => t('Status:'), '#chosen' => true, '#suffix' => '</td>');
                    }
                }
            }
        }
    }
    // allows a user to go to team outreach settings
    $form['fields']['manageTagsBttn'] = array('#prefix' => '<td colspan ="3" style="text-align:center">', '#markup' => '<a href="?q=teamOutreachSettings" target="_blank"><button type="button">Manage Tags</button></a>', '#suffix' => '</td></tr>');
    $form['fields']['description'] = array('#prefix' => '<tr><td colspan="6" style="text-align:center">', '#type' => 'textarea', '#title' => t('Description:'), '#default_value' => $new ? '' : $outreach['description'], '#placeholder' => 'Maximum of 500 characters', '#suffix' => '</td></tr>', '#maxlength_js' => 'TRUE', '#maxlength' => '500');
    $form['fields']['address'] = array('#prefix' => '<tr><td colspan="3" style="text-align:center">', '#type' => 'textfield', '#title' => t('Address:'), '#default_value' => $new ? '' : $outreach['address'], '#suffix' => '</td>');
    $team = dbGetTeam($TID);
    // default value from the team form
    $form['fields']['city'] = array('#prefix' => '<td colspan="1" style="text-align:center">', '#type' => 'textfield', '#title' => t('City:'), '#default_value' => $new ? $team['city'] : $outreach['city'], '#suffix' => '</td></tr>');
    $form['fields']['state'] = array('#prefix' => '<tr><td colspan="3" style="text-align:center">', '#type' => 'select', '#title' => t('State:'), '#options' => states_list(), '#default_value' => $new ? $team['state'] : $outreach['state'], '#chosen' => true, '#suffix' => '</td>');
    $form['fields']['country'] = array('#prefix' => '<td colspan="3" style="text-align:center">', '#type' => 'select', '#title' => t('Country:'), '#options' => countries_list(), '#default_value' => $new ? $team['country'] : $outreach['country'], '#chosen' => true, '#suffix' => '</td></tr>');
    $form['fields']['co_firstName'] = array('#prefix' => '<tr><td colspan="3" style="text-align:center">', '#type' => 'textfield', '#title' => t("Host Contact's First Name:"), '#default_value' => $new ? '' : $outreach['co_firstName'], '#placeholder' => 'Contact for this outreach', '#suffix' => '</td>');
    $form['fields']['co_lastName'] = array('#prefix' => '<td colspan="3" style="text-align:center">', '#type' => 'textfield', '#title' => t("Host Contact's Last Name:"), '#default_value' => $new ? '' : $outreach['co_lastName'], '#suffix' => '</tr>');
    $form['fields']['co_phoneNumber'] = array('#prefix' => '<tr><td colspan="3" style="text-align:center">', '#type' => 'textfield', '#title' => t("Host Contact's Phone Number:"), '#default_value' => $new ? '' : $outreach['co_phoneNumber'], '#placeholder' => 'Format: XXXXXXXXXX', '#suffix' => '</td>');
    $form['fields']['co_email'] = array('#prefix' => '<td colspan="3" style="text-align:center">', '#type' => 'textfield', '#title' => t("Host Contact's Email:"), '#default_value' => $new ? '' : $outreach['co_email'], '#placeholder' => 'Email of outreach contact', '#suffix' => '</td></tr>');
    $form['fields']['co_organization'] = array('#prefix' => '<tr><td colspan="6" style="text-align:center">', '#type' => 'textfield', '#title' => t("Host Organization:"), '#default_value' => $new ? '' : $outreach['co_organization'], '#placeholder' => 'Group participating with for this outreach', '#suffix' => '</td></tr>');
    // allows a user to add dates to an outreach
    if (empty($form_state['numRows'])) {
        $form_state['numRows'] = 1;
    }
    $form['fields']['datesHeader'] = array('#markup' => '<tr><td colspan="6">');
    $form['fields']['dates']['header'] = array('#markup' => '<div id="dates-div"><table>');
    $date = date(DEFAULT_TIME_FORMAT, strtotime('today noon'));
    for ($i = 0; $i < $form_state['numRows']; $i++) {
        $form['fields']['dates']["openFieldOfStart-{$i}"] = array('#markup' => '<tr><td colspan="2" align="left" style="text-align:left">');
        if (!empty($times)) {
            $startTime = date(DEFAULT_TIME_FORMAT, dbDateSQL2PHP($times[$i]['startTime']));
        }
        $form['fields']['dates']["startTime-{$i}"] = array('#type' => 'date_popup', '#title' => t('Start Date:'), '#default_value' => !isset($startTime) ? $date : $startTime, '#date_format' => TIME_FORMAT, '#date_label_position' => 'within', '#date_increment' => 1, '#date_year_range' => '-20:+20', '#datepicker_options' => array(), '#states' => array('invisible' => array(':input[name="status"]' => array('value' => 'isIdea'))));
        if (!$new) {
            $form_state['fields']['dates']["TOID-{$i}"] = $times[$i]['TOID'];
        }
        $form['fields']['dates']["closeFieldOfStart-{$i}"] = array('#markup' => '</td>');
        $form['fields']['dates']["openFieldOfEnd-{$i}"] = array('#markup' => '<td colspan="2" align="right" style="text-align:left">');
        if (!empty($times)) {
            $endTime = date(DEFAULT_TIME_FORMAT, dbDateSQL2PHP($times[$i]['endTime']));
        }
        $form['fields']['dates']["endTime-{$i}"] = array('#type' => 'date_popup', '#title' => t('End Date:'), '#default_value' => !isset($endTime) ? $date : $endTime, '#date_format' => TIME_FORMAT, '#date_label_position' => 'within', '#date_increment' => 1, '#date_year_range' => '-20:+20', '#datepicker_options' => array(), '#states' => array('invisible' => array(':input[name="status"]' => array('value' => 'isIdea'))));
        $form['fields']['dates']["closeFieldOfEnd-{$i}"] = array('#markup' => '</td>');
        if ($i == $form_state['numRows'] - 1) {
            $form['fields']['dates']["addRowButton-{$i}"] = array('#prefix' => '<td colspan="1" style="text-align:center">', '#type' => 'submit', '#submit' => array('addDateRow'), '#value' => '+', '#limit_validation_errors' => array(), '#ajax' => array('callback' => 'modifyDateRows_callback', 'wrapper' => 'dates-div'), '#states' => array('invisible' => array(':input[name="status"]' => array('value' => 'isIdea'))), '#suffix' => '</td>');
        }
        if ($i == $form_state['numRows'] - 1) {
            $form['fields']['dates']["removeRowButton-{$i}"] = array('#prefix' => '<td colspan="1" style="text-align:center">', '#type' => 'submit', '#submit' => array('removeDateRow'), '#value' => '-', '#limit_validation_errors' => array(), '#ajax' => array('callback' => 'modifyDateRows_callback', 'wrapper' => 'dates-div'), '#states' => array('invisible' => array(':input[name="status"]' => array('value' => 'isIdea'))), '#suffix' => '</td>');
        }
        $form['fields']['dates']["rowFooter-{$i}"] = array('#markup' => '</tr>');
    }
    // end of for loop
    $form['fields']['dates']["divFooter-{$i}"] = array('#markup' => '</table></div></td>');
    // allows the user to change the outreach visibility if the status is locked
    if (!$new && $outreach["status"] == "locked") {
        $isPublicOptions = array(0 => t('Private'), 1 => t('Public'));
        $form['fields']['isPublic'] = array('#prefix' => '<tr><td colspan="3" style="text-align:center">', '#type' => 'radios', '#title' => t('Set Event Visibility'), '#options' => $isPublicOptions, '#default_value' => $new ? '1' : $outreach['isPublic'], '#suffix' => '</td></tr>');
    }
    $form['fields']['submit'] = array('#prefix' => '<tr><td colspan="6" style="text-align:right">', '#type' => 'submit', '#value' => t('Save'), '#sorted' => false, '#suffix' => '</td></tr>');
    $form['fields']['finalFooter'] = array('#markup' => '</table>');
    if (!$new && !(hasPermissionForTeam('editAnyOutreach', $TID) || isMyOutreach($params['OID']))) {
        drupal_set_message("You don't have permission to edit this outreach.", 'error');
        drupal_goto('viewOutreach', array('query' => array('OID' => $params['OID'])));
    }
    if (dbGetTeamsForUser($user->uid) == NULL) {
        drupal_set_message("You don't have a team assigned.", 'error');
        drupal_goto($_SERVER['HTTP_REFERER']);
    }
    if (!dbIsUserApprovedForTeam($UID, $TID)) {
        drupal_set_message("You aren't approved for this team.", 'error');
        drupal_goto($_SERVER['HTTP_REFERER']);
    }
    if (dbGetStatusForTeam($TID) == "0" || dbGetStatusForTeam($TID) == FALSE) {
        drupal_set_message("This team isn't active/approved.", 'error');
        drupal_goto($_SERVER['HTTP_REFERER']);
    }
    return $form;
}
Example #4
0
function searchFormSidebar($form, &$form_state)
{
    global $user;
    $params = drupal_get_query_parameters();
    $form_state['TID'] = getCurrentTeam()['TID'];
    if (isset($_SESSION['showAdvanced'])) {
        $form_state['showAdvanced'] = $_SESSION['showAdvanced'];
    } else {
        $form_state['showAdvanced'] = $_SESSION['showAdvanced'] = true;
    }
    // where the current instance of the form is located (e.g. allTeamOutreach)
    $form['fields']['source'] = array('#type' => 'hidden', '#value' => isset($params['source']) ? $params['source'] : '');
    $form['fields']['markupOne'] = array('#markup' => '<div id="searchFormOnSidebar" style="padding:24px 0px 0px 0px"><h2>Search All Outreach</h2>');
    $form['fields']['nameHeader'] = array('#markup' => '<table><tr><td style="padding:0px 5px 0px 0px"><b>Name:</b></td><td style="padding:0px">');
    $form['fields']['name'] = array('#type' => 'textfield', '#default_value' => fillFromSession('name', array()));
    $form['fields']['nameFooter'] = array('#markup' => '</td></tr></table>');
    $form['fields']['statusHeader'] = array();
    $form['fields']['status'] = array('#type' => 'checkboxes', '#prefix' => '<table><tr><td style="vertical-align:top">', '#title' => '<b>Status:</b>', '#options' => array('isIdea' => 'Idea', 'isOutreach' => 'Outreach', 'doingWriteUp' => 'Write-Up', 'locked' => 'Locked'), '#default_value' => fillFromSession('status', array()), '#suffix' => '</td>');
    $teams = dbGetTeamsForUser($user->uid);
    // if user is on multiple teams, allow him to select teams for searching
    if (!empty($teams)) {
        $teamOptions = array();
        foreach ($teams as $team) {
            $teamOptions[$team['TID']] = $team['number'];
        }
        $defaultTeam = array(getCurrentTeam()['TID']);
        $form['fields']['teams'] = array('#prefix' => '<td style="vertical-align:top">', '#type' => 'checkboxes', '#title' => '<b>Team:</b>', '#options' => $teamOptions, '#default_value' => fillFromSession('teams', $defaultTeam), '#suffix' => '</td></tr></table>');
    }
    $form['fields']['typeBttn'] = array('#type' => 'submit', '#submit' => array('toggleShowTypeSection'), '#value' => 'Type', '#limit_validation_errors' => array(), '#ajax' => array('callback' => 'showTypeSection_callback', 'wrapper' => 'type-div'));
    $form['fields']['type'] = array('#prefix' => '<div id="type-div">', '#suffix' => '</div>');
    // merge various data from all the teams of the given user
    $userTIDs = dbGetTIDsforUser($user->uid);
    $tags = array();
    $allUsers = array();
    foreach ($userTIDs as $TID) {
        $teamTags = dbGetOutreachTagsForTeam($TID);
        $users = dbGetUsersListFromTeam($TID);
        if (!empty($teamTags)) {
            $tags = array_replace($tags, $teamTags);
        }
        if (!empty($users)) {
            $allUsers = array_replace($users, $allUsers);
        }
    }
    // toggle display of the "Type" section
    if (isset($_SESSION['showTypeSection']) && $_SESSION['showTypeSection']) {
        if (!empty($tags)) {
            $form['fields']['type']['tags'] = array('#prefix' => '<tr><td colspan="3" style="text-align:center">', '#type' => 'select', '#title' => t('Tags:'), '#attributes' => array('style' => 'width:200px'), '#chosen' => true, '#multiple' => true, '#options' => $tags, '#default_value' => fillFromSession('tags', array()), '#suffix' => '</td>');
        }
        $form['fields']['type']['cancelled'] = array('#type' => 'checkbox', '#title' => t("Cancelled"), '#default_value' => fillFromSession('cancelled'));
    }
    $form['fields']['peopleBttn'] = array('#type' => 'submit', '#submit' => array('toggleShowPeopleSection'), '#value' => 'People', '#limit_validation_errors' => array(), '#ajax' => array('callback' => 'showPeopleSection_callback', 'wrapper' => 'people-div'));
    $form['fields']['people'] = array('#prefix' => '<div id="people-div">', '#suffix' => '</div>');
    if (isset($_SESSION['showPeopleSection']) && $_SESSION['showPeopleSection']) {
        $form['fields']['people']['ownerLabel'] = array('#prefix' => '<table style="margin:0px"><tr><td style="padding:0px">', '#markup' => '<b>Owner:</b>', '#suffix' => '</td>');
        $form['fields']['people']['owner'] = array('#prefix' => '<td style="padding:0px">', '#type' => 'select', '#options' => $allUsers, '#default_value' => fillFromSession('owner'), '#attributes' => array('style' => 'width:200px'), '#chosen' => true, '#multiple' => true, '#suffix' => '</td></tr></table>');
        $form['fields']['people']['signedUpLabel'] = array('#prefix' => '<table style="margin:0px"><tr><td style="padding:0px">', '#markup' => '<b>Signed Up:</b>', '#suffix' => '</td>');
        $form['fields']['people']['signedUp'] = array('#prefix' => '<td style="padding:0px">', '#type' => 'select', '#options' => $allUsers, '#default_value' => fillFromSession('signedUp'), '#attributes' => array('style' => 'width:200px'), '#chosen' => true, '#multiple' => true, '#suffix' => '</td></tr></table>');
        $form['fields']['people']['co_organizationLabel'] = array('#prefix' => '<table style="margin:0px"><tr><td style="padding:0px">', '#markup' => '<b>Organization:</b>', '#suffix' => '</td>');
        $form['fields']['people']['co_organization'] = array('#prefix' => '<td style="padding:0px">', '#type' => 'textfield', '#default_value' => fillFromSession('co_organization'), '#size' => 20, '#suffix' => '</td></tr></table>');
    }
    $form['fields']['locationBttn'] = array('#type' => 'submit', '#submit' => array('toggleShowLocationSection'), '#value' => 'Location', '#limit_validation_errors' => array(), '#ajax' => array('callback' => 'showLocationSection_callback', 'wrapper' => 'location-div'));
    $form['fields']['location'] = array('#prefix' => '<div id="location-div">', '#suffix' => '</div>');
    if (isset($_SESSION['showLocationSection']) && $_SESSION['showLocationSection']) {
        $form['fields']['location']['cityLabel'] = array('#prefix' => '<table style="margin:0px"><tr><td style="padding:0px">', '#markup' => '<b>City:</b>', '#suffix' => '</td>');
        $form['fields']['location']['city'] = array('#prefix' => '<td style="padding:0px">', '#type' => 'textfield', '#size' => 25, '#default_value' => fillFromSession('city'), '#suffix' => '</td></tr></table>');
        $form['fields']['location']['stateLabel'] = array('#prefix' => '<table style="margin:0px"><tr><td style="padding:0px">', '#markup' => '<b>State:</b>', '#suffix' => '</td>');
        $form['fields']['location']['state'] = array('#prefix' => '<td style="padding:0px">', '#type' => 'select', '#options' => states_list(), '#default_value' => fillFromSession('state'), '#chosen' => true, '#suffix' => '</td></tr></table>');
        $form['fields']['location']['countryLabel'] = array('#prefix' => '<table style="margin:0px"><tr><td style="padding:0px">', '#markup' => '<b>Country:</b>', '#suffix' => '</td>');
        $form['fields']['location']['country'] = array('#prefix' => '<td style="padding:0px">', '#type' => 'select', '#options' => countries_list(), '#default_value' => fillFromSession('country'), '#attributes' => array('width' => '200px'), '#chosen' => true, '#suffix' => '</td></tr></table>');
    }
    // if user would like to see advanced fields, show them
    //  if (isset($form_state['showAdvanced']) && $form_state['showAdvanced']){
    //  if (isset($_SESSION['showAdvanced']) && $_SESSION['showAdvanced']){
    $form['fields']['timeBttn'] = array('#type' => 'submit', '#submit' => array('toggleShowTimeSection'), '#value' => 'Time', '#limit_validation_errors' => array(), '#ajax' => array('callback' => 'showTimeSection_callback', 'wrapper' => 'time-div'));
    $form['fields']['time'] = array('#prefix' => '<div id="time-div">', '#suffix' => '</div>');
    if (isset($_SESSION['showTimeSection']) && $_SESSION['showTimeSection']) {
        $form['fields']['time']['timeConstraints'] = array('#markup' => '<table style="table-layout:fixed"><tr></tr>');
        $form['fields']['time']['within5Years'] = array('#prefix' => '<tr style="white-space:nowrap"><td style="padding:0px;display:inline-block">Within 5 Years</td><td style="padding:5px;display:inline-block">', '#type' => 'checkbox', '#default_value' => fillFromSession('within5Years'), '#suffix' => '</td></tr>');
        $form['fields']['time']['dateSelection3'] = array('#markup' => '<tr style="white-space:nowrap"><td style="padding:5px; display:inline-block">Within</td><td style="padding:5px; display:inline-block">');
        // search outreaches within some time of specified date
        $distanceOptions = array('1 day' => '1 day', '1 week' => '1 week', '1 month' => '1 month', '1 year' => '1 year');
        $form['fields']['time']['dateDistance'] = array('#type' => 'select', '#options' => $distanceOptions, '#default_value' => fillFromSession('dateDistance'), '#chosen' => true);
        $form['fields']['time']['dateSelection4'] = array('#markup' => '</td><td style="padding:5px; display:inline-block">of</td><td style="padding:5px;display:inline-block; width:100px">');
        // specify date of outreach for use with dateDistance
        $form['fields']['time']['date'] = array('#type' => 'date_popup', '#date_format' => SHORT_TIME_FORMAT, '#date_label_position' => 'within', '#date_increment' => 1, '#date_year_range' => '-20:+20', '#datepicker_options' => array(), '#default_value' => isset($_SESSION['searchParams']['date']['center']) ? $_SESSION['searchParams']['date']['center'] : '');
        $form['fields']['time']['dateSelection5'] = array('#markup' => '</td></tr><tr style="white-space:nowrap"><td style="padding:0px; display:inline-block">Events In Year</td><td style="display:inline-block">');
        $years = array('select' => '-Select-');
        for ($i = date("Y"); $i >= 1992; $i--) {
            $years[(string) $i] = $i;
        }
        $form['fields']['time']['year'] = array('#type' => 'select', '#options' => $years, '#chosen' => true, '#default_value' => fillFromSession('year'));
        $form['fields']['time']['dateSelection6'] = array('#markup' => '</td></tr></table>');
    }
    $form['fields']['submit'] = array('#type' => 'submit', '#value' => 'Search');
    return $form;
}
Example #5
0
function search_form()
{
    if (isset($_SESSION['user_email']) || isset($_SESSION['user_id'])) {
        $send_search_form_to = SITE_ROOT . "/public/admin/search_list_login.php";
    } else {
        $send_search_form_to = SITE_ROOT . "/public/search_list_logout.php";
    }
    isset($_GET['search_term']) ? $default_text = htmlentities($_GET['search_term']) : ($default_text = "");
    echo '<form name="search_form" action="' . $send_search_form_to . '" method="get">
					<input type="text" name="search_term" id="search_term"  size="45" value="' . $default_text . '"> &nbsp;
					<select name="cn" style="display:none" id="search_category" style="width:110px;" width="15" class="searchBox" onchange="list_select_options(this.id,\'search_type\')" >
					<option value="">Categories</option>';
    categories_list();
    echo '</select>
					<select name="tpn" style="display:none" id="search_type" style="width:85px;" class="searchBox">
					<option value="">Types</option>
					</select>
					<select name="cyn" style="display:none" id="search_country" style="width:100px;"  class="searchBox" onchange="list_select_options(this.id,\'search_state\')">
					<option value="">Countries</option>';
    countries_list();
    echo '</select>
					<select name="sn" style="display:none" id="search_state" style="width:100px;" class="searchBox" onchange="list_select_options(this.id,\'search_city\')">
					<option value="">States</option>
					</select>
					<select name="cin" style="display:none" id="search_city" style="width:90px;" class="searchBox">
					<option value="">Cities</option>
					</select>
					<input type="submit" name="search_submit_button" maxlength="15" style="margin-left:3px" value="Search"/>
				</form>';
}