Exemplo n.º 1
1
/**
 * Processes variables for block.tpl.php.
 *
 * Prepares the values passed to the theme_block function to be passed
 * into a pluggable template engine. Uses block properties to generate a
 * series of template file suggestions. If none are found, the default
 * block.tpl.php is used.
 *
 * Most themes utilize their own copy of block.tpl.php. The default is located
 * inside "modules/block/block.tpl.php". Look in there for the full list of
 * variables.
 *
 * The $variables array contains the following arguments:
 * - $block
 *
 * @see block.tpl.php
 */
function scsmetronic_subtheme_preprocess_page(&$variables)
{
    global $user;
    if (variable_get('scsmetronic_redirect_to_login') && $user->uid == 0 && arg(0) != 'user') {
        //header('Location: ' . url('user/login', array( 'absolute' => TRUE)), TRUE, 302);
        // Handle redirection to the login form.
        // using drupal_goto() with destination set causes a recursive redirect loop
        $login_path = 'user/login';
        $code = 302;
        // The code in drupal_get_destination() doesn't preserve any query string
        // on 403 pages, so reproduce the part we want here.
        $path = isset($_GET['destination']) ? $_GET['destination'] : '<front>';
        $query = drupal_http_build_query(drupal_get_query_parameters(NULL, array('q', 'destination')));
        if ($query != '') {
            $path .= '?' . $query;
        }
        $destination = array('destination' => $path);
        header('Location: ' . url($login_path, array('query' => $destination, 'absolute' => TRUE)), TRUE, 302);
        drupal_exit();
    }
    $variables['navbar_top'] = 'navbar-static-top';
    $theme_header = theme_get_setting('theme_header', 'scsmetronic');
    if (!empty($theme_header) && $theme_header !== 'default') {
        $variables['navbar_top'] = 'navbar-fixed-top';
    }
    //Get the entire main menu tree
    $main_menu_name = theme_get_setting('theme_main_menu', 'scsmetronic');
    $main_menu_tree = menu_tree_all_data($main_menu_name);
    $user_menu_tree = menu_tree_all_data('user-menu');
    //Add the rendered output to the $main_menu_expanded variable
    $variables['main_menu_expanded'] = menu_tree_output($main_menu_tree);
    $variables['user_menu_expanded'] = menu_tree_output($user_menu_tree);
    if ($modal_form_paths = theme_get_setting('theme_modal')) {
        $modal_forms = explode("\r\n", $modal_form_paths);
        drupal_add_js(array('scsmetronic_forms_modal' => $modal_forms), 'setting');
    }
    if ($user->uid) {
        $name = theme('username', array('account' => $user, 'link_path' => NULL));
    } else {
        $name = variable_get('anonymous', t('Guest'));
    }
    $variables['loggedin_user_name'] = $name;
    $variables['image'] = scsmetronic_login_user_image($user);
}
function _myu_language_dropdown($type = 'language')
{
    if (drupal_multilingual()) {
        global $language_url;
        $path = drupal_is_front_page() ? '<front>' : $_GET['q'];
        //$type = 'language_url';
        $languages = language_negotiation_get_switch_links($type, $path);
        $items = array();
        foreach ($languages->links as $lang_code => $lang_options) {
            if ($lang_options['language']->language === $language_url->language) {
                // Icon for the selected language
                if (module_exists('languageicons')) {
                    $icon = theme('languageicons_icon', array('language' => (object) array('language' => $lang_code), 'title' => $language_url->native));
                }
                $active_language_text = $icon . '<span class="langname">' . strtoupper($language_url->language) . '</span><i class="fa fa-angle-down"></i>';
                $active_language_link = l($active_language_text, 'javascript:;', array('html' => TRUE, 'external' => TRUE, 'attributes' => array('class' => 'dropdown-toggle', 'data-close-others' => 'true', 'data-hover' => 'dropdown', 'data-toggle' => 'dropdown')));
            } else {
                if (!isset($lang_options['query'])) {
                    $lang_options['query'] = drupal_get_query_parameters();
                }
                $items[] = l($lang_options['title'], $lang_options['href'], $lang_options);
            }
        }
        $language_flag_list = theme('item_list', array('items' => $items, 'type' => 'ul', 'attributes' => array('class' => 'dropdown-menu dropdown-menu-default')));
        return '<ul class="menu nav navbar-nav language"><li class="dropdown dropdown-language">' . $active_language_link . $language_flag_list . '</li></ul>';
    }
}
Exemplo n.º 3
0
function viewUserStats()
{
    global $user;
    $params = drupal_get_query_parameters();
    if (isset($params["UID"])) {
        $UID = $params["UID"];
    } else {
        $UID = $user->uid;
    }
    $currentTeam = getCurrentTeam();
    $TID = $currentTeam['TID'];
    $teamNumber = $currentTeam['number'];
    $numOfOutreachesForUser = dbGetNumOutreachForUser($UID);
    $markup = "<script src=\"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-beta1/jquery.js\"></script>";
    $markup .= '<script src="numberCounting.js"></script>';
    $form['script'] = array('#markup' => $markup);
    // create page header and table
    $form['mainHeader'] = array('#markup' => '<h1>My Dashboard</h1>');
    $form['table'] = array('#markup' => '<table><tr><td>');
    // displays users total stats
    $markup = '<table id="myTotalStats"><tr><td colspan="2" style="text-align:center">';
    $markup .= '<div class="help tooltip2">';
    $markup .= '<h2><b>My Total Stats</b></h2>';
    $markup .= '<span id="helptext"; class="helptext tooltiptext2">';
    $markup .= 'These are your total numbers of hours and outreaches.';
    $markup .= '</span></div>';
    $markup .= '</td></tr>';
    $markup .= '<tr><td style="text-align:center"><a href="?q=viewHours&UID=' . $UID . '"><b>HOURS</b></a></td>';
    $markup .= '<td style="text-align:center"><a href="?q=outreach"><b>OUTREACHES</b></a></td></tr>';
    $markup .= '<tr style="font-size:48pt; font-family: "Open Sans", sans-serif;"><td style="text-align:center"><b class="countUp">' . dbGetUserHours($UID) . '</b></td>';
    $markup .= '<td style="text-align:center"><b class="countUp">' . $numOfOutreachesForUser;
    $markup .= '</b></td></tr></table></td>';
    $form['myStatsTable'] = array('#markup' => $markup);
    // if user has more than one team, displays stats for user on current team
    if (count(dbGetTeamsForUser($UID)) > 1) {
        // dropdown allows user to switch teams
        $form['TID'] = array('#prefix' => '<td><table id="myStatsOnTeamNumber"><tr><td id ="myStatsOnMultTeams1" style="text-align:right; padding:0px"><div class="help tooltip2"><h2><b>My Stats On</b></h2><span id="helptext"; class="helptext tooltiptext2">These are your total numbers of hours and outreaches for your currently active team.</span></div></td><td id="myStatsOnMultTeams2"> ', '#type' => 'select', '#attributes' => array('onChange' => 'document.getElementById("viewuserstats").submit();'), '#chosen' => true, '#options' => dbGetTeamsListForUser($UID), '#default_value' => $TID, '#suffix' => '</td></tr>');
        $markup = '<tr><td style="text-align:center"><a href="?q=userHoursForTeam&UID=' . $UID . '&TID=' . $TID . '"><b>HOURS</b></a></td>';
        $markup .= '<td style="text-align:center"><a href="?q=userEventsForTeam&UID=' . $UID . '&TID=' . $TID . '"><b>OUTREACHES</b></a></td></tr>';
        $markup .= '<tr style="font-size:48pt; font-family:"Open Sans", sans-serif;"><td style="text-align:center"><b class="countUp">' . dbGetUserHoursForTeam($UID, $TID) . '</b></td>';
        $markup .= '<td style="text-align:center"><b class="countUp">' . dbGetNumOutreachesForUserForTeam($UID, $TID) . '</b></td></tr></table></td></tr></table>';
        $form['teamStatsTable'] = array('#markup' => $markup);
        $form['submit'] = array('#type' => 'submit', '#value' => 'Update', '#attributes' => array('style' => array('display: none;')));
    } else {
        // if user does not have more than one team, displays what team the user is on
        $markup = '<td><table id="myStatsOnTeamNumber"><tr><td colspan="2" style="text-align:center">';
        $markup .= '<div class="help tooltip2">';
        $markup .= '<h2>My Team</h2>';
        $markup .= '<span id="helptext"; class="helptext tooltiptext2">';
        $markup .= 'This is the team number and CROMA permission for your user.';
        $markup .= '</span></div>';
        $markup .= '</td></tr>';
        $markup .= '<tr style="font-size:48pt; font-family:"Open Sans", sans-serif;"><td style="text-align:center"><b>' . $currentTeam['number'] . '</b></td></tr>';
        $role = dbGetRoleForTeam($UID, $TID) == '' ? 'Team Member' : dbGetRoleForTeam($UID, $TID);
        $markup .= '<tr><td style="text-align:center"><b>CROMA Role: </b>' . $role . '</td></tr>';
        $markup .= '</table></td></tr></table>';
        $form['TID'] = array('#markup' => $markup);
    }
    return $form;
}
/**
 * This function is handles the callback from Box API.
 * @return string
 */
function _soc_boxauth_get_code_from_box_handler()
{
    // get query string parameters
    $qs = drupal_get_query_parameters();
    watchdog(SOC_BOXAUTH_MODULENAME, "Got code back from Box", $qs, WATCHDOG_INFO);
    // Stage post data and create http query
    $post_data = ['grant_type' => 'authorization_code', 'code' => $qs['code'], 'client_id' => variable_get(SOC_BOXAUTH_CLIENTID_VARIABLE), 'client_secret' => variable_get(SOC_BOXAUTH_CLIENTSECRET_VARIABLE)];
    $result = BoxFolderOperations::doPost('https://api.box.com/oauth2/token', $post_data, 'Content-type: application/x-www-form-urlencoded', 'QUERY');
    // save to session. Decoded json object into php array
    $_SESSION['box'] = drupal_json_decode($result);
    $_SESSION['box']['expires_time'] = time() + SOC_BOXAUTH_EXPIREOFFSET;
    // If successful, the ['box']['access_token'] will exists. Log and report
    // to user.
    if (isset($_SESSION['box']['access_token'])) {
        drupal_set_message(t(variable_get(SOC_BOXAUTH_SUCCESSMESSAGE_VARIABLE)));
        watchdog(SOC_BOXAUTH_MODULENAME, 'Successful box access_token');
        $next_steps = variable_get(SOC_BOXAUTH_NEXTSTEPS_VARIABLE, ['value' => t('Next steps...')]);
        return $next_steps['value'];
    } else {
        $message = t(variable_get(SOC_BOXAUTH_FAILUREMESSAGE_VARIABLE));
        drupal_set_message($message, 'error');
        watchdog(SOC_BOXAUTH_MODULENAME, 'Failed box access_token');
        return $message;
    }
}
Exemplo n.º 5
0
function notificationForm_submit($form, $form_state)
{
    global $user;
    $params = drupal_get_query_parameters();
    $OID = $params['OID'];
    // generate the notification
    $notification = getFields(array('dateTargeted', 'message'), $form_state['values']);
    $notification = stripTags($notification);
    // allow some tags
    $notification['dateTargeted'] = dbDatePHP2SQL(strtotime($notification['dateTargeted']));
    $notification['bttnTitle'] = 'View Outreach';
    $notification['bttnLink'] = '?q=viewOutreach&OID=' . $OID;
    $notification['OID'] = $OID;
    $notification['TID'] = dbGetTeamForOutreach($OID);
    $notification['dateCreated'] = dbDatePHP2SQL(time());
    foreach ($form_state['values']['UID'] as $UID) {
        if ($UID != null) {
            $notification['UID'] = $UID;
            $result = dbAddNotification($notification);
        }
    }
    if ($result) {
        drupal_set_message('Notification added!');
        drupal_goto('manageNotifications', array('query' => array('OID' => $OID)));
    } else {
        drupal_set_message('There was an error.', 'error');
    }
}
Exemplo n.º 6
0
function transferTeamOwnershipForm($form, &$form_state)
{
    global $user;
    $params = drupal_get_query_parameters();
    if (isset($params['TID'])) {
        $form_state['TID'] = $TID = $params['TID'];
    } else {
        drupal_set_message('You need to choose a team.', 'error');
        drupal_goto('showUsersForTeam');
    }
    $team = dbGetTeam($TID);
    if ($user->uid != $team['UID']) {
        // if the user is not the team owner
        drupal_set_message("You are not the owner of team {$team['name']}", 'error');
        drupal_goto($_SERVER['HTTP_REFERER']);
    }
    $people = dbGetUsersListFromTeam($TID);
    unset($people[$user->uid]);
    // shouldn't be able to transfer to self
    $people[0] = '';
    // field needs a default value
    $form['header'] = array('#markup' => "<h1>Transfer Ownership of {$team['name']}</h1>");
    $form['fields'] = array('#type' => 'fieldset');
    $form['fields']['table'] = array('#prefix' => '<table><tr>', '#suffix' => '</tr></table>');
    $form['fields']['table']['info'] = array('#prefix' => '<td>', '#markup' => 'Transferring ownership of this team will make you into a team admin (at which point you may leave the team if you wish). The new owner you choose will be notified of their promotion via email, and will gain the <strong>ability to delete the team at will</strong>. His/her notification email will also include your email for contact purposes in case of an error. If you wish to become the team owner again, the new owner must transfer ownership.', '#suffix' => '</td>');
    $form['fields']['table']['newOwner'] = array('#prefix' => '<td>', '#type' => 'select', '#title' => t('New Team Owner:'), '#default_value' => 0, '#options' => $people, '#chosen' => true, '#suffix' => '</td>');
    $form['submit'] = array('#prefix' => '<div align="right">', '#attributes' => array('onclick' => 'return confirm("Are you sure you want to transfer ownership?");'), '#type' => 'submit', '#value' => 'Submit', '#suffix' => '</div>');
    return $form;
}
Exemplo n.º 7
0
function _cignaglobal_preprocess_node_landing_page(&$vars)
{
    // Convert title token to location from URL if used.
    $queries = drupal_get_query_parameters();
    $title =& $vars['content']['title'][0]['#markup'];
    if (strpos($title, '{location}') !== FALSE && isset($queries['location'])) {
        $title = str_replace('{location}', $queries['location'], $title);
        $title = ucwords($title);
    }
}
Exemplo n.º 8
0
function usersSearchHeader()
{
    global $user;
    $params = drupal_get_query_parameters();
    if (isset($params["UID"])) {
        $UID = $params["UID"];
    } else {
        $UID = $user->uid;
    }
    // create table and header
    $markup = '<table><tr><div class="help tooltip2"><h2>Team Members</h2><span id="helptext"; class="helptext tooltiptext2">Click here to search for a team member or manage your teams permissions.</tr></span></div><th>Search For A Team Member</th></table>';
    return $markup;
}
Exemplo n.º 9
0
function viewUserEventsForTeam()
{
    global $user;
    $params = drupal_get_query_parameters();
    // if user does not have a team
    if (dbGetTeamsForUser($user->uid) == NULL) {
        drupal_set_message("You don't have a team assigned.", 'error');
        drupal_goto($_SERVER['HTTP_REFERER']);
    }
    if (isset($params['UID'])) {
        $UID = $params['UID'];
    } else {
        $UID = $user->uid;
    }
    if (isset($params['TID'])) {
        $TID = $params['TID'];
    } else {
        $currentTeam = getCurrentTeam();
        $TID = $currentTeam['TID'];
    }
    $outreaches = dbGetOutreachesForUserForTeam($UID, $TID);
    $teamName = dbGetTeamName($TID);
    // create page header and table
    $markup = "<table><h1>My Outreaches For {$teamName}</h1></table>";
    $markup .= '<table class="infoTable">';
    $markup .= '<tr>';
    $markup .= '<th colspan="3">Outreach Name</th>';
    $markup .= '<th colspan="3">Description</th>';
    $markup .= '<th colspan="2">Hours</th>';
    $markup .= "</tr>";
    // if user has outreaches for the current team
    if (!empty($outreaches)) {
        foreach ($outreaches as $outreach) {
            $markup .= "<tr>";
            $markup .= '<td colspan="3">' . '<a href="?q=viewOutreach&OID=' . $outreach['OID'] . '">' . chopString($outreach["name"], 30) . '</a>' . "</td>";
            $markup .= '<td colspan="3">' . chopString($outreach["description"], 30) . "</td>";
            $markup .= '<td colspan="2">' . dbGetHoursForUserFromOutreach($UID, $outreach['OID']) . "</tr>";
            $markup .= "</tr>";
        }
        $markup .= "</table>";
    } else {
        // if the user does not have any outreaches for the current team
        $markup .= '<tr><td style="text-align:center" colspan="10"><em>[None]</em></td>';
        $markup .= "</tr>";
    }
    $markup .= "</table>";
    $retArray = array();
    $retArray['#markup'] = $markup;
    return $retArray;
}
Exemplo n.º 10
0
function dismissNotification($NID)
{
    $params = drupal_get_query_parameters();
    dbDeleteNotification($NID);
    drupal_set_message('Notification has been dismissed.');
    // go back to the "View All Notifications" page
    if (isset($params["allnote"])) {
        drupal_goto('viewAllNotifications');
    } else {
        if (isset($_SERVER['HTTP_REFERER'])) {
            drupal_goto($_SERVER['HTTP_REFERER']);
        } else {
            drupal_goto('myDashboard');
        }
    }
}
Exemplo n.º 11
0
/**
 * Main search controller.
 * 
 * @param string $key
 */
function find_search($key)
{
    drupal_add_css(drupal_get_path('module', 'find') . '/css/find_search.css', array('group' => CSS_DEFAULT, 'every_page' => true));
    drupal_add_css(drupal_get_path('module', 'find') . '/css/find_print.css', array('group' => CSS_DEFAULT, 'every_page' => true, 'media' => 'print'));
    drupal_add_js('http://maps.google.com/maps/api/js?sensor=false&libraries=geometry,places', array('group' => JS_LIBRARY));
    drupal_add_library('system', 'ui.sortable');
    drupal_add_js(drupal_get_path('module', 'area') . '/css/overlay-style.js');
    drupal_add_js(drupal_get_path('module', 'area') . '/js/geometry.js');
    drupal_add_js(drupal_get_path('module', 'find') . '/js/find.js');
    drupal_add_css(drupal_get_path('module', 'gallery') . '/css/jquery.lightbox.css', array('group' => CSS_DEFAULT, 'every_page' => TRUE));
    drupal_add_js(drupal_get_path('module', 'gallery') . '/js/jquery.lightbox.js', array('weight' => 100));
    drupal_add_js(drupal_get_path('module', 'gallery') . '/js/gallery.lightbox.js');
    $variables = array('#theme' => 'find.search');
    // fetch $_GET parameters
    $params = find_query_params(array('search' => '', 'geo' => array(), 'date' => array(), 'class' => array(), 'user' => array(), 'family' => array(), 'genus' => array(), 'town' => array(), 'canton' => array(), 'redlist' => array(), 'habitat' => array(), 'image_type' => array(), 'columns' => array(), 'sort' => array()));
    $params['uid'] = $GLOBALS['user']->uid;
    try {
        $client = new Elastica_Client();
        $status = $client->getStatus();
        // ping to make sure elasticsearch is running
        $index = $client->getIndex('naturwerk');
        $parameters = new Parameters($params);
        $variables['#organisms'] = new Organisms($index, $parameters);
        $variables['#sightings'] = new Sightings($index, $parameters);
        $variables['#inventories'] = new Inventories($index, $parameters);
        $variables['#areas'] = new Areas($index, $parameters);
        $variables['#images'] = new Images($index, $parameters);
        // make parameters available to JavaScript
        $parameters = drupal_get_query_parameters();
        if (count($parameters) == 0) {
            $parameters = new stdClass();
            // force empty JSON object
        }
        drupal_add_js(array('find' => array('url' => url($_GET['q']), 'parameters' => $parameters, 'geo' => $params['geo'])), 'setting');
        $variables['#key'] = $key;
        $variables['#current'] = $variables['#' . $key];
        $output = array();
        $output['search'] = $variables;
        return $output;
    } catch (Elastica_Exception_Client $e) {
        watchdog('find', $e->getMessage(), array(), WATCHDOG_ERROR);
        drupal_set_message(t('Search error. Elasticsearch running?'), 'error');
        return array();
    }
}
Exemplo n.º 12
0
/**
 * Implements hook_menu_link__menu_search().
 *
 * Add classes to search menu to style like tabs.
 */
function osha_frontend_menu_link__menu_search($variables)
{
    $element = $variables['element'];
    $active = '';
    if (in_array('active-trail', $element['#attributes']['class'])) {
        $active = 'is-active active';
    }
    if (empty($element['#localized_options'])) {
        $element['#localized_options'] = array();
    }
    $query_parameters = drupal_get_query_parameters();
    if (!empty($query_parameters['search_block_form'])) {
        $element['#localized_options']['query']['search_block_form'] = $query_parameters['search_block_form'];
    }
    $element['#attributes']['class'] = array('tabs-primary__tab', $active);
    $element['#localized_options']['attributes']['class'] = array('tabs-primary__tab-link', $active);
    $output = l($element['#title'], $element['#href'], $element['#localized_options']);
    return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . "</li>\n";
}
Exemplo n.º 13
0
function approveTeam($TID)
{
    $params = drupal_get_query_parameters();
    dbApproveTeam($TID);
    $UID = dbGetOwnerForTeam($TID);
    $teamName = dbGetTeamName($TID);
    drupal_mail('adminFunctions', 'teamApproved', dbGetUserPrimaryEmail($UID), variable_get('language_default'), $params = array('teamName' => $teamName, 'fullName' => dbGetUserName($UID)), $from = NULL, $send = TRUE);
    drupal_set_message('The team has been approved and the team owner has been notified!');
    $notification = array('UID' => $UID, 'TID' => $TID, 'dateCreated' => dbDatePHP2SQL(time()), 'dateTargeted' => dbDatePHP2SQL(time()));
    $notification['message'] = "Your team, team \"{$teamName}\" has just been approved!";
    $notification['bttnTitle'] = 'View';
    $notification['bttnLink'] = "?q=viewTeam&TID={$TID}";
    dbAddNotification($notification);
    if (isset($params['show'])) {
        drupal_goto('adminPage', array('query' => array($params['show'])));
    } else {
        drupal_goto('adminPage');
    }
}
Exemplo n.º 14
0
function addTeamMember($form, &$form_state)
{
    $params = drupal_get_query_parameters();
    if (isset($params['TID'])) {
        $form_state['TID'] = $params['TID'];
    }
    if (!isset($form_state['TID'])) {
        drupal_set_message('You need to specify a team.', 'error');
    }
    $teamName = dbGetTeamName($form_state['TID']);
    $form['fields'] = array('#type' => 'fieldset', '#title' => t("Add Team Member to {$teamName}"));
    $form['fields']['tableHeader'] = array('#markup' => '<table>');
    $form['fields']['primaryEmail'] = array('#prefix' => '<tr><td colspan="2" style="text-align:center">', '#type' => 'textfield', '#title' => t('Email'), '#suffix' => '</td></tr><tr><td>', '#ajax' => array('callback' => 'fillUserName', 'keypress' => true, 'wrapper' => 'div_user_name_wrapper'));
    $form['fields']['name']['firstName'] = array('#prefix' => '<div id="div_user_name_wrapper"><table><tr><td style="text-align:center">', '#type' => 'textfield', '#title' => t('First Name'), '#suffix' => '</td>');
    $form['fields']['name']['lastName'] = array('#prefix' => '<td style="text-align:center">', '#type' => 'textfield', '#title' => t('Last Name'), '#suffix' => '</td></tr></table></div></td></tr>');
    $form['fields']['submit'] = array('#prefix' => '<td colspan="2" style="text-align:right">', '#type' => 'submit', '#value' => t('Save'), '#suffix' => '</td>');
    $form['footer'] = array('#markup' => '</tr></table>');
    return $form;
}
Exemplo n.º 15
0
function manageNotifications()
{
    $params = drupal_get_query_parameters();
    if (isset($params['OID'])) {
        $OID = $params['OID'];
        $outreachName = dbGetOutreachName($OID);
        // create page header, table, and add notification button
        $markup = '';
        $markup .= '<table>';
        $markup .= "<tr><td><h1>Manage Notifications for \"{$outreachName}\" </h1>";
        $markup .= '</td><td style="text-align:right">';
        $markup .= '<a href="?q=notificationForm&OID=' . $OID . '"><button>Add Notification</button></a></td></tr></table>';
        $markup .= '<table class="infoTable"><tr><th colspan="3">Target Users</th><th colspan="3">Notification Message</th><th colspan="2">Date To Be Sent</th><th colspan="2"></th></tr>';
        $notifications = dbGetNotificationsForOutreach($OID);
        // if outreach already has notifications
        if (!empty($notifications)) {
            foreach ($notifications as $notification) {
                $markup .= '<tr>';
                $markup .= '<td colspan="3">' . dbGetUserName($notification['UID']) . '</td>';
                $markup .= '<td colspan="3">' . $notification['message'] . '</td>';
                $date = dbDateSQL2PHP($notification['dateTargeted']);
                $markup .= '<td colspan="2">' . date(TIME_FORMAT, $date) . '</td>';
                $markup .= '<td colspan="2"><a href="?q=deleteNotification/' . $notification['NID'];
                $markup .= "/{$OID}\"><button>Delete</button></a></td>";
                $markup .= '</td>';
            }
            $markup .= '</table>';
        } else {
            // if outreach does not have notifications
            $markup .= "<tr>";
            $markup .= '<td style="text-align:center" colspan="10"><em>[None]</em></td>';
            $markup .= "</tr>";
        }
        $markup .= "</table>";
        return array('#markup' => $markup);
    } else {
        // returns message if OID is not correct
        drupal_set_message('No outreach selected.', 'error');
        drupal_goto($_SERVER['HTTP_REFERER']);
    }
}
Exemplo n.º 16
0
 /**
  * Gets a page description for all pages.
  *
  * Only type aanbod UiT domein, theme and location need to be prepared for search engines.
  *
  * @see culturefeed_search_ui_search_page()
  *
  * @return string
  *   Description for this type of page.
  */
 public function getPageDescription()
 {
     $message = "";
     $query = drupal_get_query_parameters(NULL, array('q'));
     if (empty($query)) {
         $message = t("A summary of all pages on @site", array('@site' => variable_get('site_name', '')));
     } else {
         $message = t("A summary of all pages on @site", array('@site' => variable_get('site_name', '')));
         if (!empty($query['regId'])) {
             $term = culturefeed_search_get_term_translation($query['regId']);
             $message .= t(" in @region", array('@region' => $term));
         } elseif (!empty($query['location'])) {
             $message .= t(" in @region", array('@region' => $query['location']));
         }
         if (!empty($query['facet']['category_actortype_id'][0])) {
             $term = culturefeed_search_get_term_translation($query['facet']['category_actortype_id'][0]);
             $message .= t(" of the type @type", array('@type' => $term));
         }
     }
     return $message;
 }
Exemplo n.º 17
0
function viewEventsForTeam()
{
    global $user;
    $params = drupal_get_query_parameters();
    if (dbGetTeamsForUser($user->uid) == NULL) {
        drupal_set_message("You don't have a team assigned.", 'error');
        drupal_goto($_SERVER['HTTP_REFERER']);
        return;
    }
    if (isset($params['UID'])) {
        $UID = $params['UID'];
    } else {
        $UID = $user->uid;
    }
    if (isset($params['TID'])) {
        $TID = $params['TID'];
    } else {
        $currentTeam = getCurrentTeam();
        $TID = $currentTeam['TID'];
    }
    $outreaches = dbGetOutreachesForUserForTeam($UID, $TID);
    $markup = '<div style="width:50%;align-text:right;"><h2>Outreaches You Have <b>Signed Up</b> For</h2></div>';
    $markup .= '<table>';
    $markup .= '<tr>';
    $markup .= "<th>Name</th>";
    $markup .= "<th>Description</th>";
    $markup .= "<th>Hours</th>";
    $markup .= "</tr>";
    foreach ($outreaches as $outreach) {
        $markup .= "<tr>";
        $markup .= "<td>" . '<b><a href="?q=viewOutreach&OID=' . $outreach['OID'] . '">' . chopString($outreach["name"], 15) . '</a>' . "<b></td>";
        $markup .= "<td>" . chopString($outreach["description"], 15) . "</td>";
        $markup .= "<td>" . dbGetHoursForUserFromOutreach($UID, $outreach['OID']) . "</tr>";
        $markup .= "</tr>";
    }
    $markup .= "</table></div>";
    $retArray = array();
    $retArray['#markup'] = $markup;
    return $retArray;
}
/**
 * Overrides theme_pager().
 */
function bootstrap_psdpt_pager_link($variables)
{
    $text = $variables['text'];
    $page_new = $variables['page_new'];
    $element = $variables['element'];
    $parameters = $variables['parameters'];
    $attributes = $variables['attributes'];
    $page = isset($_GET['page']) ? $_GET['page'] : '';
    if ($new_page = implode(',', pager_load_array($page_new[$element], $element, explode(',', $page)))) {
        $parameters['page'] = $new_page;
    }
    $query = array();
    if (count($parameters)) {
        $query = drupal_get_query_parameters($parameters, array());
    }
    if ($query_pager = pager_get_query_parameters()) {
        $query = array_merge($query, $query_pager);
    }
    // Set each pager link title
    if (!isset($attributes['title'])) {
        static $titles = NULL;
        if (!isset($titles)) {
            $titles = array(t('« first') => t('Go to first page'), t('‹ previous') => t('Go to previous page'), t('next ›') => t('Go to next page'), t('last »') => t('Go to last page'));
        }
        if (isset($titles[$text])) {
            $attributes['title'] = $titles[$text];
        } elseif (is_numeric($text)) {
            $attributes['title'] = t('Go to page @number', array('@number' => $text));
        }
    }
    // @todo l() cannot be used here, since it adds an 'active' class based on the
    //   path only (which is always the current path for pager links). Apparently,
    //   none of the pager links is active at any time - but it should still be
    //   possible to use l() here.
    // @see http://drupal.org/node/1410574
    $attributes['href'] = url($_GET['q'], array('query' => $query));
    $text = filter_xss($text, array('span', 'em', 'strong'));
    return '<a' . drupal_attributes($attributes) . '>' . $text . '</a>';
}
Exemplo n.º 19
0
function macragecn_pager_link($variables)
{
    $text = $variables['text'];
    $page_new = $variables['page_new'];
    $element = $variables['element'];
    $parameters = $variables['parameters'];
    $attributes = $variables['attributes'];
    $page = isset($_GET['page']) ? $_GET['page'] : '';
    if ($new_page = implode(',', pager_load_array($page_new[$element], $element, explode(',', $page)))) {
        $parameters['page'] = $new_page;
    }
    $query = array();
    if (count($parameters)) {
        $query = drupal_get_query_parameters($parameters, array());
    }
    if ($query_pager = pager_get_query_parameters()) {
        $query = array_merge($query, $query_pager);
    }
    // Set each pager link title
    if (!isset($attributes['title'])) {
        static $titles = NULL;
        if (!isset($titles)) {
            $titles = array(t('« 第一 页') => t('前往首 页'), t('‹ 上一页') => t('前往上一 页'), t('下一页 ›') => t('前往下一页'), t('最后一 页 »') => t('前往尾 页'));
        }
        if (isset($titles[$text])) {
            $attributes['title'] = $titles[$text];
        } elseif (is_numeric($text)) {
            $attributes['title'] = t('前往第@number页', array('@number' => $text));
        }
    }
    // @todo l() cannot be used here, since it adds an 'active' class based on the
    //   path only (which is always the current path for pager links). Apparently,
    //   none of the pager links is active at any time - but it should still be
    //   possible to use l() here.
    // @see http://drupal.org/node/1410574
    $attributes['href'] = url($_GET['q'], array('query' => $query));
    return '<a' . drupal_attributes($attributes) . '>' . check_plain($text) . '</a>';
}
Exemplo n.º 20
0
function deleteTeamPage($form, &$form_state)
{
    global $user;
    $params = drupal_get_query_parameters();
    if (isset($params['TID'])) {
        $TID = $form_state['TID'] = $params['TID'];
    } else {
        drupal_set_message('You must specify a team.', 'error');
        return;
    }
    // check permissions
    if (!dbUserHasPermissionForTeam($user->uid, 'deleteTeam', $TID)) {
        drupal_set_message('You do not have permission to delete this team.', 'error');
        return;
    }
    $teamName = dbGetTeamName($form_state['TID']);
    $form['header'] = array('#markup' => "<h1>Delete Team {$teamName}</h1>");
    $form['warning'] = array('#markup' => t('The team will be deleted and all users will be removed. Note however that the outreaches created will remain, as will the hours logged. This is to maintain correct hour logging for users with multiple teams. The outreaches will be neither viewable nor editable however.'));
    $form['acknowledgement'] = array('#type' => 'checkbox', '#title' => t('By checking this box, I acknowledge that I am permanently deleting this team and have the permissions to perform such an action.'));
    $form['misc'] = array('#type' => 'textarea', '#title' => t('Feedback'));
    $form['delete'] = array('#prefix' => '<div align="right">', '#type' => 'submit', '#value' => 'Delete Team', '#suffix' => '</div>');
    return $form;
}
Exemplo n.º 21
0
function applyForTeamForm()
{
    global $user;
    $params = drupal_get_query_parameters();
    $profile = dbGetUserProfile($user->uid);
    if (isset($params['url'])) {
        $form['back'] = array('#markup' => "<a href=\"?q={$params['url']}\"><button type=\"button\">Cancel</button></a>");
    }
    $form['fields'] = array('#type' => 'fieldset', '#title' => t('Apply to Join a Team'));
    $form['fields']['tableHeader'] = array('#markup' => '<table>');
    $form['fields']['number'] = array('#prefix' => '<tr><td>', '#type' => 'textfield', '#title' => t('Team Number:'), '#suffix' => '</td><td>', '#ajax' => array('callback' => 'fillTeamName', 'keypress' => true, 'wrapper' => 'div_team_name_wrapper'));
    // this form will be filled in via AJAX
    $form['fields']['teamName'] = array('#prefix' => '<div id="div_team_name_wrapper">', '#type' => 'textfield', '#title' => t('Team Name:'), '#disabled' => true, '#suffix' => '</div>');
    // this form is filled in from previous data
    $form['fields']['personName'] = array('#prefix' => '</td></tr><tr><td>', '#type' => 'textfield', '#title' => t('Your Name:'), '#default_value' => "{$profile['firstName']} {$profile['lastName']}", '#disabled' => true, '#suffix' => '</td>');
    // user email is filled in, but still editable
    $form['fields']['email'] = array('#prefix' => '<td>', '#type' => 'textfield', '#title' => t('Your Email:'), '#default_value' => dbGetUserPrimaryEmail($user->uid), '#suffix' => '</td></tr>');
    $defaultMessage = "Hi, I'd like to join your team!";
    $form['fields']['message'] = array('#prefix' => '<tr><td colspan="2">', '#type' => 'textarea', '#title' => t('Personal Message:'), '#default_value' => $defaultMessage, '#suffix' => '</td></tr>');
    $form['fields']['submit'] = array('#prefix' => '<tr><td colspan="2" style="text-align:right">', '#type' => 'submit', '#value' => t('Submit'), '#suffix' => '</td></tr>');
    $form['fields']['tableFooter'] = array('#markup' => '</table>');
    return $form;
}
Exemplo n.º 22
0
function tagManager($form, &$form_state)
{
    $team = getCurrentTeam();
    $form_state['TID'] = $TID = $team['TID'];
    if (teamIsIneligible($TID)) {
        drupal_set_message('Your team does not have permission to access this page.', 'error');
        drupal_goto($_SERVER['HTTP_REFERER']);
    }
    $currentURL = getCurrentURL();
    // if browser didn't end up here by coming from the current page
    if ($currentURL != getAjaxURL() && (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] != $currentURL)) {
        switchTagEditMode(false);
        // be sure to start with just viewing the tags
        if (!empty(drupal_get_query_parameters())) {
            // clear any other drupal_query_parameters
            drupal_goto(parseURLAlias($_SERVER['QUERY_STRING']));
        }
    }
    $markup = "<h1>Team {$team['number']} Outreach Settings</h1>";
    $editMode = checkTagEditMode();
    // create the wrapper-div used by AJAX
    $form['tags'] = array('#prefix' => '<div id="tags-div">', '#suffix' => '</div>');
    $tableHeader = '<table><tr><td><div class="help tooltip2"><h2>Outreach Tags</h2><span id="helptext"; class="helptext tooltiptext2">Outreach Tags are used to tag similar outreaches.</span></div></td><td><div align="right">';
    $form['tags']['tableHeader'] = array('#markup' => $tableHeader);
    // only show edit button if in "view mode" and the user has proper permissions
    if (!$editMode && hasPermissionForTeam('manageOutreachTags', $TID)) {
        $form['tags']['buttons'] = array('#type' => 'image_button', '#src' => '/images/icons/editWhite.png', '#attributes' => array('class' => array('editIcon')), '#limit_validation_errors' => array(), '#submit' => array('switchTagEditMode'));
    }
    // finish off the title and buttons table, then start the table for the tags themselves
    $tableHeader2 = '</div></td></tr></table>';
    $tableHeader2 .= '<table class="infoTable"><tr><th>Tag Name</th>';
    if (!$editMode) {
        $tableHeader2 .= '<th style="text-align:center">Matched Outreaches</th>';
    } else {
        $tableHeader2 .= '<th></th><th></th>';
    }
    $form['tags']['tableHeader2'] = array('#markup' => $tableHeader2);
    $tags = dbGetOutreachTagsForTeam($TID);
    if (!$editMode) {
        // if in "view" mode (aka not acting as a form)
        $tableContents = '';
        $tableContents .= '</tr>';
        if (!empty($tags)) {
            foreach ($tags as $OTID => $tagName) {
                // display the name
                $tableContents .= '<tr><td>' . $tagName . '</td>';
                // show the number of matching outreaches (which can be clicked on to search the outreach form by tags)
                $numMatched = dbGetOutreachMatchingTags(array($tagName), $TID, true);
                // "true" indicates only a count is returned
                $tableContents .= "<td style=\"text-align:center\"><a href=\"?q=outreach&tag={$OTID}\">{$numMatched}</a></td></tr>";
            }
        } else {
            $tableContents = '<tr><td colspan="2" style="text-align:center"><em>[None]</em></td></tr>';
        }
        $form['tags']['tableContents'] = array('#markup' => $tableContents);
    } else {
        // -------------------------------- in "edit" mode
        $i = 0;
        if (!empty($tags)) {
            foreach ($tags as $OTID => $tagName) {
                $i++;
                $form['tags']["tagName-{$i}"] = array('#prefix' => '<tr><td colspan="2">', '#type' => 'textfield', '#maxlength' => 50, '#default_value' => $tagName, '#suffix' => '</td>');
                $numMatching = dbGetOutreachMatchingTags(array(dbGetTagName($OTID)), $TID, true);
                $confirmBoxJS = '';
                if ($numMatching > 0) {
                    $confirmBoxJS = "if(!confirm('This tag matches {$numMatching} outreach(es). Are you sure you want to delete it?')){return false;}";
                }
                $form['tags']["deleteBttn-{$i}"] = array('#prefix' => "<td><a href=\"?q=deleteTag/{$OTID}/{$TID}\">", '#markup' => "<button onclick=\"{$confirmBoxJS}\" type=\"button\"><img src=\"/images/icons/trashWhite.png\" class=\"trashIcon\"></button>", '#suffix' => '</a></td></tr>');
                $form_state["OTID-{$i}"] = $OTID;
            }
            // end of foreach
        }
        // end of if
        $form_state['numTags'] = $i;
        // initialize the 'numNewRows' variable
        if (empty($form_state['numNewRows'])) {
            $form_state['numNewRows'] = 1;
        }
        $x;
        // PHP is weird and makes you declare a variable before the loop
        // create the empty row for creating new tags
        for ($x = 1; $x <= $form_state['numNewRows']; $x++) {
            // have to be sure to not overwrite anything
            // create row to allow entry of a new tag
            $form['tags']["newTagName-{$x}"] = array('#prefix' => '<tr><td>', '#type' => 'textfield', '#maxlength' => 50, '#suffix' => '</td>');
            // if this is the last row (and not the only row), add a "-" button
            if ($form_state['numNewRows'] > 1 && $x == $form_state['numNewRows']) {
                $form['tags']["newRemoveBttn-{$x}"] = array('#prefix' => '<td>', '#type' => 'submit', '#submit' => array('removeTagRow'), '#value' => '-', '#limit_validation_errors' => array(), '#ajax' => array('callback' => 'modifyTagRows_callback', 'wrapper' => 'tags-div'), '#suffix' => '</td>');
            } else {
                // add a placeholder instead of the "-" button
                $form['tags']["removeBttnPlaceHolder-{$x}"] = array('#markup' => '<td></td>');
            }
            // if this is the last row, add a "+" button
            if ($x == $form_state['numNewRows']) {
                $form['tags']["newAddBttn-{$x}"] = array('#prefix' => '<td>', '#type' => 'submit', '#submit' => array('addTagRow'), '#value' => '+', '#limit_validation_errors' => array(), '#ajax' => array('callback' => 'modifyTagRows_callback', 'wrapper' => 'tags-div'), '#suffix' => '</td>');
            } else {
                // add a placeholder instead of the "+" button
                $form['tags']["addBttnPlaceHolder-{$x}"] = array('#markup' => '<td></td>');
            }
            $for['tags']["rowFooter-{$x}"] = array('#markup' => '</tr>');
        }
        // end of for loop
    }
    // end of else (aka edit mode code)
    $form['tags']['tableFooter'] = array('#markup' => '</table>');
    // allow the user to cancel and return to the previous page
    // (note that the URL for cancel has a random extra parameter to ensure the mode is changed to view)
    if ($editMode) {
        $form['cancel'] = array('#prefix' => '<table><tr><td style="text-align:left">', '#markup' => '<a href="?q=teamOutreachSettings&notEdit"><button type="button">Cancel</button></a>', '#suffix' => '</td>');
        $form['submit'] = array('#prefix' => '<td style="text-align:right">', '#type' => 'submit', '#value' => 'Confirm', '#suffix' => '</td></tr></table>');
    }
    return $form;
}
Exemplo n.º 23
0
function viewOutreach()
{
    global $user;
    $UID = $user->uid;
    $params = drupal_get_query_parameters();
    $markup = "<script src=\"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-beta1/jquery.js\"></script>";
    $markup .= '<script src="numberCounting.js"></script>';
    $markup .= '<h1>Outreach</h1><br>';
    // if doing a custom search
    if (isset($params['query']) && $params['query'] == 'search') {
        $sql = generateSearchSQL($_SESSION['searchParams'], $_SESSION['proxyFields']);
        $outreaches = dbSearchOutreach($sql, $_SESSION['proxyFields']);
        $header = '<h2>Custom Search Results (';
        $header .= empty($outreaches) ? '0' : count($outreaches);
        $header .= ' matches)</h2>';
    } else {
        if (isset($params['tag'])) {
            $_SESSION['searchParams'] = array('tags' => array($params['tag']));
            $_SESSION['proxyFields'] = array();
            $sql = generateSearchSQL($_SESSION['searchParams'], $_SESSION['proxyFields']);
            $outreaches = dbSearchOutreach($sql, $_SESSION['proxyFields']);
            $header = '<h2>Outreaches Tagged "' . dbGetTagName($params['tag']) . '"</h2>';
        } else {
            if (isset($params['owned'])) {
                $outreaches = dbGetOwnedOutreachForUser($UID);
                $header = '<h2>Outreaches I Own</h2>';
            } else {
                if (isset($params['signedUp'])) {
                    $outreaches = dbGetOutreachForUser($UID);
                    $header = '<h2>Outreaches I Am Signed Up For</h2>';
                } else {
                    if (isset($params['allTeamOutreach'])) {
                        $TID = getCurrentTeam()['TID'];
                        $_SESSION['searchParams'] = array('TID' => array('value' => $TID, 'matchType' => 'exact'));
                        $_SESSION['proxyFields'] = array(':TID' => $TID);
                        $sql = generateSearchSQL($_SESSION['searchParams'], $_SESSION['proxyFields']);
                        $outreaches = dbSearchOutreach($sql, $_SESSION['proxyFields']);
                        $teamName = dbGetTeamName($TID);
                        $header = "<h2>All Outreach for {$teamName}</h2>";
                    } else {
                        $_SESSION['searchParams'] = array();
                        $_SESSION['proxyFields'] = array();
                        $header = "<h2>No Search Selected</h2>";
                    }
                }
            }
        }
    }
    if (isset($_SESSION['searchParams']['teams']) && count($_SESSION['searchParams']['teams']) > 1) {
        $multipleTeamsInResult = true;
    } else {
        $multipleTeamsInResult = false;
    }
    $markup .= $header;
    // set $outreaches to an array rather than false (so that later functions don't have errors)
    if (empty($outreaches)) {
        $outreaches = array();
    }
    $totalFilterOutreaches = count($outreaches);
    $totalFilterHours = 0;
    foreach ($outreaches as &$outreach) {
        $outreach['hours'] = dbGetHoursForOutreach($outreach['OID']);
        $totalFilterHours += $outreach['hours'];
    }
    unset($outreach);
    $sortParam = isset($params["sort"]) ? $params['sort'] : 'name';
    $isAscending = isset($params['isAscending']) ? true : false;
    orderByValue($outreaches, $sortParam, $isAscending);
    // custom function (see helperFunctions.inc)
    $markup .= '<table style="margin:0px">';
    $markup .= '<tr><td style="padding:0px; text-align:left"><b>Outreaches with Current Filters: </b><span class="countUp">' . $totalFilterOutreaches . '</span></td>';
    $markup .= '<td style="padding:0px; text-align:right" align="right"><b>Hours with Current Filters: </b><span class="countUp">' . $totalFilterHours . '</span></td></tr>';
    $markup .= '<tr><td style="padding:0px" align="left">Sort By: ';
    // remove special params (since they should not be added every time)
    unset($params['isAscending']);
    unset($params['sort']);
    $markup .= sortHeader($sortParam, $params, $isAscending, 'Name', 'name', 'outreach') . ' | ';
    $markup .= sortHeader($sortParam, $params, $isAscending, 'Status', 'status', 'outreach') . ' | ';
    $markup .= sortHeader($sortParam, $params, $isAscending, 'Hours', 'hours', 'outreach') . ' | ';
    $markup .= sortHeader($sortParam, $params, $isAscending, 'Event Date', 'eventDate', 'outreach');
    $markup .= '</td><td style="padding:0px; text-align:right">';
    if (!isset($params['owned'])) {
        $markup .= '<a href="?q=outreach&owned"><div class="help tooltip4"><button>Owned</button><span id="helptext"; class="helptext tooltiptext4">Click here to sort by outreach you own.</span></div></a>';
    } else {
        $markup .= '<a href="?q=outreach&allTeamOutreach"><button>All Team Outreach</button></a>';
    }
    if (!isset($params['signedUp'])) {
        $markup .= '<a href="?q=outreach&signedUp"><div class="help tooltip3"><button>Signed Up</button><span id="helptext"; class="helptext tooltiptext3">Click here to sort by outreach you are signed up for.</span></div></a>';
    } else {
        $markup .= '<a href="?q=outreach&allTeamOutreach"><button>All Team Outreach</button></a>';
    }
    $markup .= '</td></tr></table>';
    $markup .= '<table class="infoTable" style="margin:0px"><tr><th colspan="2">Status</th>';
    if ($multipleTeamsInResult) {
        $markup .= '<th colspan="2">Team</th>';
    }
    $markup .= '<th colspan="4">Name</th>';
    $markup .= '<th colspan="2">Hours</th>';
    $markup .= '<th colspan="2">Event Date</th>';
    if (empty($outreaches)) {
        $markup .= '<tr><td colspan="11">No outreach found! Click <a href="?q=outreachForm">here</a> to create new outreach!</td></tr></table>';
        return array('#markup' => $markup);
    }
    foreach ($outreaches as $outreach) {
        $OID = $outreach['OID'];
        $hours = dbGetHoursForOutreach($OID);
        $status;
        switch ($outreach['status']) {
            case 'isOutreach':
                $status = '<span title="Outreach Event"><img class="eventIndicatorIcon" src="/images/icons/outreachBlue.png"></span>';
                break;
            case 'isIdea':
                $status = '<span title="Idea"><img class="eventIndicatorIcon" src="/images/icons/ideaBlue.png"></span>';
                break;
            case 'doingWriteUp':
                $status = '<span title="Write Up"><img class="eventIndicatorIcon" src="/images/icons/writeUpBlue.png"></span>
';
                break;
            case 'locked':
                $status = '<span title="Locked Event"><img class="eventIndicatorIcon" src="/images/icons/lockedBlue.png"></span>';
                break;
            default:
                drupal_set_message('Invalid outreach data.');
                break;
        }
        $markup .= '<tr><td colspan="2" style="padding: 0px 0px 0px 14px;">';
        $markup .= showOutreachStatusIcon($outreach['status']) . '</td>';
        if ($multipleTeamsInResult) {
            $markup .= '<td colspan="2"><a href="?q=viewTeam&TID=' . $outreach['TID'] . '">' . dbGetTeamNumber($outreach['TID']) . '</a></td>';
        }
        $markup .= '<td colspan="4"><a href="?q=viewOutreach&OID=' . $OID . '">' . chopString($outreach['name'], 15) . '</a></td>';
        $markup .= '<td colspan="2">' . $hours . '</td>';
        if (dbGetEarliestTimeForOutreach($OID) != false) {
            $markup .= '<td colspan="2">' . date(TIME_FORMAT, dbDateSQL2PHP(dbGetEarliestTimeForOutreach($OID))) . '</td>';
        } else {
            $markup .= '<td colspan="2">[none]</td>';
        }
    }
    $markup .= '</table>';
    return array('#markup' => $markup);
}
Exemplo n.º 24
0
/**
 * Return an array suitable for theme_links() rather than marked up HTML link.
 */
function tao_pager_link($vars)
{
    $text = $vars['text'];
    $page_new = $vars['page_new'];
    $element = $vars['element'];
    $parameters = $vars['parameters'];
    $attributes = $vars['attributes'];
    $page = isset($_GET['page']) ? $_GET['page'] : '';
    if ($new_page = implode(',', pager_load_array($page_new[$element], $element, explode(',', $page)))) {
        $parameters['page'] = $new_page;
    }
    $query = array();
    if (count($parameters)) {
        $query = drupal_get_query_parameters($parameters, array());
    }
    if ($query_pager = pager_get_query_parameters()) {
        $query = array_merge($query, $query_pager);
    }
    // Set each pager link title
    if (!isset($attributes['title'])) {
        static $titles = NULL;
        if (!isset($titles)) {
            $titles = array(t('« first') => t('Go to first page'), t('‹ previous') => t('Go to previous page'), t('next ›') => t('Go to next page'), t('last »') => t('Go to last page'));
        }
        if (isset($titles[$text])) {
            $attributes['title'] = $titles[$text];
        } else {
            if (is_numeric($text)) {
                $attributes['title'] = t('Go to page @number', array('@number' => $text));
            }
        }
    }
    return array('title' => $text, 'href' => $_GET['q'], 'attributes' => $attributes, 'query' => count($query) ? $query : NULL);
}
Exemplo n.º 25
0
function stability_pager_link($variables)
{
    $text = $variables['text'];
    $page_new = $variables['page_new'];
    $element = $variables['element'];
    $parameters = $variables['parameters'];
    $attributes = $variables['attributes'];
    $page = isset($_GET['page']) ? $_GET['page'] : '';
    if ($new_page = implode(',', pager_load_array($page_new[$element], $element, explode(',', $page)))) {
        $parameters['page'] = $new_page;
    }
    $query = array();
    if (count($parameters)) {
        $query = drupal_get_query_parameters($parameters, array());
    }
    if ($query_pager = pager_get_query_parameters()) {
        $query = array_merge($query, $query_pager);
    }
    // Set each pager link title
    if (!isset($attributes['title'])) {
        static $titles = NULL;
        if (!isset($titles)) {
            $titles = array(t('« first') => t('Go to first page'), t('‹ previous') => t('Go to previous page'), t('next ›') => t('Go to next page'), t('last »') => t('Go to last page'));
        }
        if (isset($titles[$text])) {
            $attributes['title'] = $titles[$text];
        } elseif (is_numeric($text)) {
            $attributes['title'] = t('Go to page @number', array('@number' => $text));
        }
    }
    $replace_titles = array(t('‹ previous') => '«', t('next ›') => '»');
    $text = isset($replace_titles[$text]) ? $replace_titles[$text] : $text;
    if (!theme_get_setting('pager') || theme_get_setting('pager') == 1) {
        $attributes['class'] = array('btn', 'btn-sm', 'btn-default');
    }
    $attributes['href'] = url($_GET['q'], array('query' => $query));
    return '<a' . drupal_attributes($attributes) . '>' . check_plain($text) . '</a>';
}
Exemplo n.º 26
0
function md_orenmode_preprocess_commerce_product_filter_price(&$vars)
{
    $query_parameters = drupal_get_query_parameters();
    if (empty($vars['url'])) {
        $vars['url'] = $GLOBALS['base_url'] . '/' . current_path();
    }
    $vars['htmlId'] = drupal_html_id('slider');
    $price_min = variable_get('gprice_min', 0);
    $price_max = variable_get('gprice_max', 10000);
    $settings['price_min'] = isset($query_parameters['price_min']) && !empty($query_parameters['price_min']) ? $query_parameters['price_min'] : $price_min;
    $settings['price_max'] = isset($query_parameters['price_max']) && !empty($query_parameters['price_max']) ? $query_parameters['price_max'] : $price_max;
    $settings['config_price_min'] = $price_min;
    $settings['config_price_max'] = $price_max;
    $settings['currentFilters'] = empty($query_parameters) ? new stdClass() : $query_parameters;
    $settings['baseUrl'] = $vars['url'];
    $settings['htmlId'] = $vars['htmlId'];
    drupal_add_js(array('priceFilter' => array('setting' => $settings)), 'setting');
    drupal_add_js(drupal_get_path('theme', 'md_orenmode') . '/js/front/custom/product-filter-price.js');
}
Exemplo n.º 27
0
function progressive_sub_pager_link($variables)
{
    $text = $variables['text'];
    $page_new = $variables['page_new'];
    $element = $variables['element'];
    $parameters = $variables['parameters'];
    $attributes = $variables['attributes'];
    $page = isset($_GET['page']) ? $_GET['page'] : '';
    if ($new_page = implode(',', pager_load_array($page_new[$element], $element, explode(',', $page)))) {
        $parameters['page'] = $new_page;
    }
    $query = array();
    if (count($parameters)) {
        $query = drupal_get_query_parameters($parameters, array());
    }
    if ($query_pager = pager_get_query_parameters()) {
        $query = array_merge($query, $query_pager);
    }
    // Set each pager link title
    if (!isset($attributes['title'])) {
        static $titles = NULL;
        if (!isset($titles)) {
            $titles = array(t('«') => t('Go to first page'), t('‹') => t('Go to previous page'), t('›') => t('Go to next page'), t('»') => t('Go to last page'));
        }
        if (isset($titles[$text])) {
            $attributes['title'] = $titles[$text];
        } elseif (is_numeric($text)) {
            $attributes['title'] = t('Go to page @number', array('@number' => $text));
        }
    }
    $replace_titles = array(t('« first') => '<i class="fa fa-angle-double-left"></i>', t('‹ previous') => '<i class="fa fa-angle-left"></i>', t('next ›') => '<i class="fa fa-angle-right"></i>', t('last »') => '<i class="fa fa-angle-double-right"></i>');
    $text = isset($replace_titles[$text]) ? $replace_titles[$text] : check_plain($text);
    $attributes['href'] = url($_GET['q'], array('query' => $query));
    return '<a' . drupal_attributes($attributes) . '>' . $text . '</a>';
}
Exemplo n.º 28
0
function viewUserOutreach()
{
    global $user;
    $UID = $user->uid;
    $userName = dbGetUserName($UID);
    $params = drupal_get_query_parameters();
    $currentYear = date("Y");
    $totalFilterHours = 0;
    $markup = "<h1>All Outreach for {$userName}</h1>";
    if (isset($params["cancelled"])) {
        $outreaches = dbGetCancelledOutreach($TID);
    } else {
        if (isset($params['query']) && $params['query'] == 'search') {
            $outreaches = dbSearchOutreach($_SESSION['searchSQL'], $_SESSION['proxyFields']);
        } else {
            $outreaches = dbGetOutreachesForTeam($TID);
            if (isset($params['status']) && $params['status'] != 'all') {
                $proxyFields = array();
                $outreaches = dbSearchOutreach(generateSearchSQL(array('status' => array($params['status'])), $proxyFields), $proxyFields);
            }
        }
    }
    foreach ($outreaches as &$outreach) {
        $outreach['hours'] = dbGetHoursForOutreach($outreach['OID']);
        $totalFilterHours += $outreach['hours'];
    }
    unset($outreach);
    $markup .= '<div style="float:left"><h4>Hours With Current Filters: ' . $totalFilterHours . '</h4></div><br><br>';
    $sortParam = isset($params["sort"]) ? $params['sort'] : 'name';
    $statusParam = isset($params["status"]) ? $params['status'] : 'all';
    orderByValue($outreaches, $sortParam, true);
    // custom function (see helperFunctions.inc)
    $markup .= '<div align="left" style="float: left">Sort By: ';
    switch ($sortParam) {
        case 'name':
            $markup .= '<b>Name</b><b> | </b><a href="?q=allTeamOutreach&status=' . $statusParam . '&sort=status">Status</a><b> | </b><a href="?q=allTeamOutreach&status=' . $statusParam . '&sort=hours">Hours</a><b> | </b><a href="?q=allTeamOutreach&status=' . $statusParam . '&sort=logDate">Log Date</a><br>';
            break;
        case 'status':
            $markup .= '<a href="?q=allTeamOutreach&status=' . $statusParam . '&sort=name">Name</a><b> | </b><b>Status | </b><a href="?q=allTeamOutreach&status=' . $statusParam . '&sort=hours">Hours</a><b> | </b><a href="?q=allTeamOutreach&status=' . $statusParam . '&sort=logDate">Log Date</a><br>';
            break;
        case 'hours':
            $markup .= '<a href="?q=allTeamOutreach&status=' . $statusParam . '&sort=name">Name</a><b> | </b><a href="?q=allTeamOutreach&status=' . $statusParam . '&sort=status">Status</a><b> | </b><b>Hours | </b><a href="?q=allTeamOutreach&status=' . $statusParam . '&sort=logDate">Log Date</a><br>';
            break;
        case 'logDate':
            $markup .= '<a href="?q=allTeamOutreach&status=' . $statusParam . '&sort=name">Name</a><b> | </b><a href="?q=allTeamOutreach&status=' . $statusParam . '&sort=status">Status</a><b> | </b><a href="?q=allTeamOutreach&status=' . $statusParam . '&sort=hours">Hours</a><b> | </b><b>Log Date</b><br>';
            break;
    }
    $markup .= 'Include Status: ';
    switch ($statusParam) {
        case 'isIdea':
            $markup .= '<a href="?q=allTeamOutreach&sort=' . $sortParam . '">All</a><b> | </b><b>Idea | </b><a href="?q=allTeamOutreach&status=isOutreach&sort=' . $sortParam . '">Outreach</a><b> | </b><a href="?q=allTeamOutreach&status=doingWriteUp&sort=' . $sortParam . '">Write Up</a><br>';
            break;
        case 'isOutreach':
            $markup .= '<a href="?q=allTeamOutreach&sort=' . $sortParam . '">All</a><b> | </b><a href="?q=allTeamOutreach&status=isIdea&sort=' . $sortParam . '">Idea</a><b> | </b><b>Outreach | </b><a href="?q=allTeamOutreach&status=doingWriteUp&sort=' . $sortParam . '">Write Up</a><br>';
            break;
        case 'doingWriteUp':
            $markup .= '<a href="?q=allTeamOutreach&sort=' . $sortParam . '">All</a><b> | </b><a href="?q=allTeamOutreach&status=isIdea&sort=' . $sortParam . '">Idea</a><b> | </b><a href="?q=allTeamOutreach&status=isOutreach&sort=' . $sortParam . '">Outreach</a><b> | </b><b>Write Up</b><br>';
            break;
        default:
            $markup .= '<b>All</b><b> | </b><a href="?q=allTeamOutreach&status=isIdea&sort=' . $sortParam . '">Idea</a><b> | </b><a href="?q=allTeamOutreach&status=isOutreach&sort=' . $sortParam . '">Outreach</a><b> | </b><a href="?q=allTeamOutreach&status=doingWriteUp&sort=' . $sortParam . '">Write Up</a><br>';
    }
    $markup .= '</div>';
    orderByValue($outreaches, $sortParam, true);
    // custom function (see helperFunctions.inc)
    // Begin Displaying Outreach Events
    $markup .= '<div align="right" style="float:right"><a href="?q=searchForm"><button>Search</button></a>';
    if (!isset($params["cancelled"])) {
        $markup .= '<a href="?q=allTeamOutreach&cancelled"><button>Cancelled</button></a>';
    } else {
        $markup .= '<a href="?q=allTeamOutreach"><button>All Outreaches</button></a>';
    }
    $markup .= '<a href="?q=viewOutreachSettings"><button';
    $markup .= dbGetRIDForTeam($user->uid, $TID) > 0 ? '' : ' disabled';
    $markup .= '>Outreach Settings</button></a>';
    $markup .= '</div><br>';
    $markup .= '<table><tr><th>Name</th>';
    $markup .= '<th>Description</th>';
    $markup .= '<th>Status</th>';
    $markup .= '<th>Hours</th>';
    $markup .= '<th>Log Date</th>';
    foreach ($outreaches as $outreach) {
        $hours = dbGetHoursForOutreach($outreach['OID']);
        $status;
        switch ($outreach['status']) {
            case 'isOutreach':
                $status = 'Outreach';
                break;
            case 'isIdea':
                $status = 'Idea';
                break;
            case 'doingWriteUp':
                $status = 'Write-Up';
                break;
            default:
                $status = '[none]';
                break;
        }
        $markup .= "<tr><td><a href='?q=viewOutreach&OID={$outreach['OID']}'>{$outreach['name']}</a></td>";
        if (isset($outreach['description'])) {
            $markup .= "<td>" . chopString($outreach['description'], 50) . "</td>";
        } else {
            $markup .= '<td>[none]</td>';
        }
        $markup .= "<td>{$status}</td>";
        $markup .= "<td>{$hours}</td>";
        $eventDate = date(TIME_FORMAT, dbDateSQL2PHP($outreach['logDate']));
        $markup .= "<td>{$eventDate}</td></tr>";
    }
    $markup .= '</table>';
    return array('#markup' => $markup);
}
Exemplo n.º 29
0
function dguk_get_search_content_type()
{
    if ($is_search_page = arg(0) == 'search' && arg(1) == 'everything') {
        $query = drupal_get_query_parameters();
        foreach ($query['f'] as $facet) {
            if (strpos($facet, 'bundle') === 0) {
                return substr($facet, 7);
            }
        }
    }
}
Exemplo n.º 30
0
function viewUsersForTeam($form, &$form_state)
{
    global $user;
    $params = drupal_get_query_parameters();
    if (isset($params['TID'])) {
        $TID = $params['TID'];
    } else {
        $TID = getCurrentTeam()['TID'];
    }
    if (teamIsIneligible($TID) || !isMyTeam($TID)) {
        drupal_set_message('You do not have permission to access that page.', 'error');
        drupal_goto($_SERVER['HTTP_REFERER']);
    }
    $form_state['TID'] = $TID;
    $canManageTeamMembers = hasPermissionForTeam('manageTeamMembers', $TID);
    $canManageTeamOwners = hasPermissionForTeam('manageTeamOwners', $TID);
    $markup = '<table><tr><td colspan="3">';
    if (isset($params['query'])) {
        $persons = dbSearchUsersFromTeam($TID, $params['query']);
    } else {
        $type = isset($params['type']) ? $params['type'] : '';
        // filter by type (student vs mentor vs alumni)
        $persons = dbGetUsersFromTeam($TID, $type);
    }
    if (empty($persons)) {
        drupal_set_message('No users found.', 'error');
        drupal_goto($_SERVER['HTTP_REFERER']);
    } else {
        if (isset($params['query'])) {
            $markup .= '<h1>Search Results (' . count($persons) . ' matches)</h1></td>';
        } else {
            $markup .= '<h1>' . count($persons) . ' users on Team ' . dbGetTeamNumber($TID) . '</h1></td>';
        }
    }
    // create page header, table, and pending users/view all button
    $markup .= '<td colspan="3" style="text-align:right">';
    if ($canManageTeamMembers) {
        if (!empty(dbGetUsersAwaitingApproval($TID))) {
            $markup .= '<a href="?q=viewUsersToBeApproved&TID=' . $TID;
            $markup .= '"><button type="button">View Pending Users</button></a>';
        } else {
            $markup .= '<button type="button" disabled>No Pending Users</button>';
        }
        $markup .= '<a href="?q=addTeamMember&TID=' . $TID;
        $markup .= '&destination=' . current_path();
        $markup .= '"><button type="button">Add User</button></a>';
    }
    if (isset($params['type'])) {
        $markup .= '<a href="?q=showUsersForTeam&TID=' . $TID;
        $markup .= '"><button type="button">View All</button></a>';
    }
    $markup .= '</td></tr></table>';
    // sets up the table to display name, role, and grade of every user on the certain team
    $markup .= '<table class="infoTable"><th>Name</th>';
    $markup .= '<th>Email</td></th>';
    $markup .= '<th>Team Role</td></th>';
    $markup .= '<th>CROMA Role</th>';
    // if user is an admin, they see a new column where they can change the role of other team members
    if ($canManageTeamMembers) {
        $markup .= '<th>Admin Functions</th>';
    } else {
        $markup .= '<th></th>';
    }
    $form['tableHeader'] = array('#markup' => $markup);
    $i = 0;
    foreach ($persons as $person) {
        $form_state["UID-{$i}"] = $person['UID'];
        $markup = '<tr><td><a href="?q=viewUser&UID=' . $person["UID"] . ' ">';
        // hyperlinks the name so every name is linked to its user profile
        $markup .= $person["firstName"] . " " . $person["lastName"] . '</a></td>';
        $form["name-{$i}"] = array('#markup' => $markup);
        $email = dbGetUserPrimaryEmail($person['UID']);
        $markup = "<td><a href=\"mailto:{$email}\" target=\"_top\">{$email}</a></td>";
        $form["email-{$i}"] = array('#markup' => $markup);
        $markup = '<td>' . ucfirst(dbGetUserProfile($person['UID'])['type']) . '</td>';
        $form["isStudent-{$i}"] = array('#markup' => $markup);
        $RID = dbGetRIDForTeam($person['UID'], $TID);
        $teamOwnerRID = dbGetRID('teamOwner');
        $personIsTeamOwner = $RID == $teamOwnerRID;
        // allow current user to change roles (but not change the role of the team owner)
        if ($canManageTeamMembers && !$personIsTeamOwner) {
            // if the person in question doesn't have a role
            if (!$RID) {
                $RID = 0;
            }
            $roles = dbGetAllRoles();
            $roles[0] = 'Team Member';
            // if current user can't create team owners
            if (!$canManageTeamOwners) {
                unset($roles[$teamOwnerRID]);
            }
            // make sure the roles are still in order
            ksort($roles);
            $form["RID-{$i}"] = array('#prefix' => '<td class="roleSelector">', '#type' => 'select', '#default_value' => $RID, '#options' => $roles, '#suffix' => '</td>', '#ajax' => array('event' => 'change', 'callback' => 'callback', 'wrapper' => 'confirm-div', 'method' => 'replace'));
        } else {
            // if the current user can't change the role
            if ($RID == 0) {
                $role = 'Member';
            } else {
                $role = dbGetRoleName($RID);
            }
            $form["role-{$i}"] = array('#prefix' => '<td>', '#markup' => $role, '#suffix' => '</td>');
        }
        // if the person in question is the current user
        if ($person['UID'] == $user->uid) {
            // if the person is the team owner -- transfer ownership
            if ($personIsTeamOwner) {
                $markup = "<td><a href=\"?q=transferTeamOwnership&TID={$TID}\">";
                $markup .= "<button type=\"button\">Transfer Ownership</button></a></td>";
            } else {
                // allow user to leave team
                $markup = "<td><a href=\"?q=leaveTeam/{$TID}\">";
                $markup .= "<button type=\"button\">Leave Team</button></a></td>";
            }
            // if the current user can remove users
        } else {
            if ($canManageTeamMembers && !$personIsTeamOwner) {
                $markup = "<td><a href=\"?q=kickUserFromTeam/{$person['UID']}/{$TID}\">";
                $markup .= "<button type=\"button\" onclick=\"if(!confirm('Are you sure you want to remove this user from your team?')){return false;}\">Kick User</button></a></td>";
            } else {
                // or just some random person
                $markup = '<td></td>';
            }
        }
        $form["adminFunctions-{$i}"] = array('#markup' => $markup);
        $form["rowFooter-{$i}"] = array('#markup' => '</tr>');
        $i++;
    }
    // end of foreach
    $form_state['numUsers'] = $i;
    $form['tableFooter'] = array('#markup' => '</table>');
    if ($canManageTeamMembers) {
        $form['buttons'] = array('#prefix' => '<div id="confirm-div" style="visibility:hidden">', '#suffix' => '</div>');
        $form['buttons']['confirm'] = array('#type' => 'submit', '#value' => 'Confirm');
    }
    return $form;
}