示例#1
0
function ninesixtyrobots_username($object)
{
    if ($object->uid && $object->name && module_exists('profile')) {
        profile_load_profile($object);
        if (!empty($object->profile_real_name)) {
            $object->name = $object->profile_real_name;
        }
        // Shorten the name when it is too long or it will break many tables.
        if (drupal_strlen($object->name) > 20) {
            $name = drupal_substr($object->name, 0, 15) . '...';
        } else {
            $name = $object->name;
        }
        if (user_access('access user profiles')) {
            $output = l($name, 'user/' . $object->uid, array('attributes' => array('title' => t('View user profile.'))));
        } else {
            $output = check_plain($name);
        }
    } else {
        if ($object->name) {
            // Sometimes modules display content composed by people who are
            // not registered members of the site (e.g. mailing list or news
            // aggregator modules). This clause enables modules to display
            // the true author of the content.
            if (!empty($object->homepage)) {
                $output = l($object->name, $object->homepage, array('attributes' => array('rel' => 'nofollow')));
            } else {
                $output = check_plain($object->name);
            }
            $output .= ' (' . t('not verified') . ')';
        } else {
            $output = variable_get('anonymous', t('Anonymous'));
        }
    }
    return $output;
}
 /**
  * When viewing the list of samples for this user, get the grid to insert into the page.
  */
 protected static function getSampleListGrid($args, $node, $auth, $attributes)
 {
     global $user;
     // get the CMS User ID attribute so we can filter the grid to this user
     /*
     foreach($attributes as $attrId => $attr) {
       if (strcasecmp($attr['caption'],'CMS User ID')==0) {
         $userIdAttr = $attr['attributeId'];
         break;
       }
     }
     */
     if ($user->uid === 0) {
         // Return a login link that takes you back to this form when done.
         return lang::get('Before using this facility, please <a href="' . url('user/login', array('query' => 'destination=node/' . $node->nid)) . '">login</a> to the website.');
     }
     // use drupal profile to get warehouse user id
     if (function_exists('profile_load_profile')) {
         profile_load_profile($user);
         $userId = $user->profile_indicia_user_id;
     }
     if (!isset($userId)) {
         return lang::get('This form must be used with the indicia \'Easy Login\' module so records can ' . 'be tagged against the warehouse user id.');
     }
     if (isset($args['grid_report'])) {
         $reportName = $args['grid_report'];
     } else {
         // provide a default in case the form settings were saved in an old version of the form
         $reportName = 'reports_for_prebuilt_forms/simple_subject_observation_identifier_list_1';
     }
     if (method_exists(get_called_class(), 'getSampleListGridPreamble')) {
         $r = call_user_func(array(get_called_class(), 'getSampleListGridPreamble'));
     } else {
         $r = '';
     }
     $r .= data_entry_helper::report_grid(array('id' => 'samples-grid', 'dataSource' => $reportName, 'mode' => 'report', 'readAuth' => $auth['read'], 'columns' => call_user_func(array(get_called_class(), 'getReportActions')), 'itemsPerPage' => isset($args['grid_num_rows']) ? $args['grid_num_rows'] : 10, 'autoParamsForm' => true, 'extraParams' => array('survey_id' => $args['survey_id'], 'userID' => $userId)));
     $r .= '<form>';
     if (isset($args['multiple_subject_observation_mode']) && $args['multiple_subject_observation_mode'] == 'either') {
         $r .= '<input type="button" value="' . lang::get('LANG_Add_Sample_Single') . '" onclick="window.location.href=\'' . url('node/' . $node->nid, array('query' => 'newSample')) . '\'">';
         $r .= '<input type="button" value="' . lang::get('LANG_Add_Sample_Grid') . '" onclick="window.location.href=\'' . url('node/' . $node->nid, array('query' => 'newSample&gridmode')) . '\'">';
     } else {
         $r .= '<input type="button" value="' . lang::get('LANG_Add_Sample') . '" onclick="window.location.href=\'' . url('node/' . $node->nid, array('query' => 'newSample')) . '\'">';
     }
     $r .= '</form>';
     return $r;
 }
 /**
  * Return the Indicia form code
  * @param array $args Input parameters.
  * @param array $node Drupal node object
  * @param array $response Response from Indicia services after posting a verification.
  * @return HTML string
  */
 public static function get_form($args, $node, $response)
 {
     global $user;
     $logged_in = $user->uid > 0;
     if (!$logged_in) {
         return '<p>' . lang::get('Please log in before attempting to use this form.') . '</p>';
     }
     // can't really do this automatically: better to give warning
     if (isset($args['locationTypeFilter'])) {
         return '<p>' . lang::get('Please contact the site administrator. This version of the form uses a different method of specifying the location types.') . '</p>';
     }
     iform_load_helpers(array('report_helper'));
     $auth = report_helper::get_read_auth($args['website_id'], $args['password']);
     if (!self::set_up_survey($args, $auth)) {
         return lang::get('set_up_survey returned false: survey_id missing from presets or location_type definition.');
     }
     $reportOptions = self::get_report_calendar_options($args, $auth);
     $reportOptions['id'] = 'calendar-summary-' . $node->nid;
     if (!empty($args['removable_params'])) {
         self::$removableParams = get_options_array_with_user_data($args['removable_params']);
     }
     self::copy_args($args, $reportOptions, array('weekstart', 'weekOneContains', 'weekNumberFilter', 'outputTable', 'outputChart', 'simultaneousOutput', 'tableHeaders', 'chartLabels', 'disableableSeries', 'chartType', 'rowGroupColumn', 'rowGroupID', 'width', 'height', 'includeTableTotalRow', 'includeTableTotalColumn', 'includeChartTotalSeries', 'includeChartItemSeries', 'includeRawData', 'includeSummaryData', 'includeEstimatesData', 'summaryDataCombining', 'dataRound', 'zeroPointAnchor', 'interpolation', 'firstValue', 'lastValue', 'linkURL', 'includeRawGridDownload', 'includeRawListDownload', 'includeSummaryGridDownload', 'includeEstimatesGridDownload', 'includeListDownload', 'avgFields'));
     if (isset($_GET['outputSource'])) {
         $reportOptions['outputSource'] = $_GET['outputSource'];
     }
     if (isset($_GET['outputFormat'])) {
         $reportOptions['outputFormat'] = $_GET['outputFormat'];
     } else {
         $reportOptions['outputFormat'] = $args['defaultOutput'];
     }
     if (isset($_GET['outputSeries'])) {
         $reportOptions['outputSeries'] = $_GET['outputSeries'];
     }
     // default is all
     // Advanced Chart options
     $rendererOptions = trim($args['renderer_options']);
     if (!empty($rendererOptions)) {
         $reportOptions['rendererOptions'] = json_decode($rendererOptions, true);
     }
     $legendOptions = trim($args['legend_options']);
     if (!empty($legendOptions)) {
         $reportOptions['legendOptions'] = json_decode($legendOptions, true);
     }
     $axesOptions = trim($args['axes_options']);
     if (!empty($axesOptions)) {
         $reportOptions['axesOptions'] = json_decode($axesOptions, true);
     }
     if (isset($args['countColumn']) && $args['countColumn'] != '') {
         $reportOptions['countColumn'] = 'attr_occurrence_' . str_replace(' ', '_', strtolower($args['countColumn']));
         // assume that this is an occurrence attribute.
         $reportOptions['extraParams']['occattrs'] = $args['countColumn'];
     }
     // for a normal user, we can only link to those samples we have created
     $reportOptions['location_list'] = array();
     // for a branch user, we have an allowed list of locations for which we can link to the sample.
     self::$branchLocationList = array();
     if (isset($args['branchManagerPermission']) && $args['branchManagerPermission'] != "" && user_access($args['branchManagerPermission'])) {
         // Get list of locations attached to this user via the branch cms user id attribute
         // first need to scan param_presets for survey_id..
         $attrArgs = array('valuetable' => 'location_attribute_value', 'attrtable' => 'location_attribute', 'key' => 'location_id', 'fieldprefix' => 'locAttr', 'extraParams' => $auth, 'survey_id' => self::$siteUrlParams[self::$SurveyKey]);
         if (isset($args['locationTypesFilter']) && $args['locationTypesFilter'] != "") {
             $attrArgs['location_type_id'] = self::$siteUrlParams[self::$locationTypeKey]['value'];
         }
         $locationAttributes = data_entry_helper::getAttributes($attrArgs, false);
         $cmsAttr = self::extract_attr($locationAttributes, $args['branchFilterAttribute']);
         if (!$cmsAttr) {
             return lang::get('Branch Manager location list lookup: missing Branch allocation attribute') . ' {' . print_r($attrArgs, true) . '} : ' . $args['branchFilterAttribute'];
         }
         $attrListArgs = array('extraParams' => array_merge(array('view' => 'list', 'website_id' => $args['website_id'], 'location_attribute_id' => $cmsAttr['attributeId'], 'raw_value' => $user->uid), $auth), 'table' => 'location_attribute_value');
         $attrList = data_entry_helper::get_population_data($attrListArgs);
         if (isset($attrList['error'])) {
             return $attrList['error'];
         }
         if (count($attrList) > 0) {
             foreach ($attrList as $attr) {
                 self::$branchLocationList[] = $attr['location_id'];
             }
         }
         $reportOptions['location_list'] = self::$branchLocationList;
     }
     // for an admin, we can link to all samples.
     if (isset($args['managerPermission']) && $args['managerPermission'] != "" && user_access($args['managerPermission'])) {
         $reportOptions['location_list'] = 'all';
     }
     if (function_exists('module_exists') && module_exists('easy_login') && function_exists('hostsite_get_user_field')) {
         $reportOptions['my_user_id'] = hostsite_get_user_field('indicia_user_id');
     } else {
         $reportOptions['my_user_id'] = $user->uid;
     }
     $retVal = '';
     // Add controls first: set up a control bar
     $retVal .= "\n<table id=\"controls-table\" class=\"ui-widget ui-widget-content ui-corner-all controls-table\"><thead class=\"ui-widget-header\"><tr>";
     $retVal .= self::date_control($args, $auth, $node, $reportOptions);
     $retVal .= '<th>' . self::user_control($args, $auth, $node, $reportOptions) . '</th>';
     $retVal .= '<th>' . self::location_control($args, $auth, $node, $reportOptions) . '</th>';
     // note this includes the location_type control if needed
     $siteUrlParams = self::get_site_url_params();
     if (!empty($args['removable_params'])) {
         foreach (self::$removableParams as $param => $caption) {
             $checked = isset($_GET[$param]) && $_GET[$param] === 'true' ? ' checked="checked"' : '';
             $retVal .= '<th><input type="checkbox" name="removeParam-' . $param . '" id="removeParam-' . $param . '" class="removableParam"' . $checked . '/>' . '<label for="removeParam-' . $param . '" >' . lang::get($caption) . '</label></th>';
         }
         self::set_up_control_change('removeParam-' . $param, $param, array(), true);
     }
     // are there any params that should be set to blank using one of the removable params tickboxes?
     foreach (self::$removableParams as $param => $caption) {
         if (isset($_GET[$param]) && $_GET[$param] === 'true') {
             $reportOptions['extraParams'][$param] = '';
         }
     }
     if (self::$siteUrlParams[self::$userKey]['value'] == '' && self::$siteUrlParams[self::$locationKey]['value'] == '') {
         $checked = self::$siteUrlParams[self::$cacheKey]['value'] === 'true' ? ' checked="checked"' : '';
         $retVal .= '<th><input type="checkbox" name="cachingParam" id="cachingParam" class="cachingParam"' . $checked . '/>' . '<label for="cachingParam" title="' . lang::get("When fetching the full data set, selcting this improves performance by not going to the warehouse to get the data. Occassionally, even when selected, the data will be refreshed, which will appear to slow down the response.") . '" >' . lang::get("Use cached data") . '</label></th>';
         $reportOptions['caching'] = self::$siteUrlParams[self::$cacheKey]['value'] === 'true' ? true : 'store';
         self::set_up_control_change('cachingParam', self::$cacheKey, array(), true);
         $checked = self::$siteUrlParams[self::$downloadKey]['value'] === 'true' ? ' checked="checked"' : '';
         if (self::$siteUrlParams[self::$downloadKey]['value'] !== 'true' && isset($reportOptions['includeListDownload']) && $reportOptions['includeListDownload'] == true) {
             $reportOptions['includeRawGridDownload'] = false;
             $reportOptions['includeRawListDownload'] = false;
             $reportOptions['includeSummaryGridDownload'] = false;
             $reportOptions['includeEstimatesGridDownload'] = false;
             $reportOptions['includeListDownload'] = false;
             for ($i = 1; $i <= 4; $i++) {
                 unset($args['Download' . $i . 'Caption']);
                 unset($args['download_report_' . $i]);
             }
             data_entry_helper::$javascript .= "jQuery('.downloads-table-label').remove();\n" . "jQuery('#downloads-table thead tr').prepend('<th>" . "<label for=\"downloadParam\" title=\"" . lang::get("When fetching the full data set, unselecting this improves performance by not including the download data in the page. This extra data can lead to a significantly increase in download time.") . "\" >" . lang::get("Include Downloads") . "</label>" . "<input type=\"checkbox\" name=\"downloadParam\" id=\"downloadParam\" class=\"downloadParam\"" . $checked . "/>" . "</th>');\n";
             self::set_up_control_change('downloadParam', self::$downloadKey, array(), true);
         }
     }
     if (self::$siteUrlParams[self::$locationTypeKey]['value'] == '') {
         if (isset($args['locationTypesFilter']) && $args['locationTypesFilter'] != "") {
             $types = explode(',', $args['locationTypesFilter']);
             $terms = self::get_sorted_termlist_terms(array('read' => $auth), 'indicia:location_types', array($types[0]));
             $reportOptions['extraParams']['location_type_id'] = $terms[0]['id'];
         }
     } else {
         $reportOptions['extraParams']['location_type_id'] = self::$siteUrlParams[self::$locationTypeKey]['value'];
     }
     $reportOptions['includeReportTimeStamp'] = isset($args['includeFilenameTimestamps']) && $args['includeFilenameTimestamps'];
     $retVal .= '</tr></thead></table>';
     $reportOptions['highlightEstimates'] = true;
     $retVal .= report_helper::report_calendar_summary($reportOptions);
     // upto this point the report options holds the cms user id as user_id: the report_helper converts this to the indicia
     // user_id if relevant to this installation. We now need to do the same for the report links.
     if (isset($reportOptions['extraParams']['user_id'])) {
         $reportOptions['extraParams']['cms_user_id'] = $reportOptions['extraParams']['user_id'];
         if (function_exists('module_exists') && module_exists('easy_login')) {
             $account = user_load($reportOptions['extraParams']['user_id']);
             if (function_exists('profile_load_profile')) {
                 profile_load_profile($account);
             }
             /* will not be invoked for Drupal7 where the fields are already in the account object */
             if (isset($account->profile_indicia_user_id)) {
                 $reportOptions['extraParams']['user_id'] = $account->profile_indicia_user_id;
             }
         }
     }
     if (isset($args['managerPermission']) && $args['managerPermission'] != "" && user_access($args['managerPermission']) || $reportOptions['extraParams']['location_list'] != '' || $reportOptions['extraParams']['user_id'] != '') {
         // if user specified - either me in normal or branch mode, or a manager
         global $indicia_templates;
         $indicia_templates['report_download_link'] = '<th><a href="{link}"><button type="button">{caption}</button></a></th>';
         // format is assumed to be CSV
         $downloadOptions = array('readAuth' => $auth, 'extraParams' => array_merge($reportOptions['extraParams'], array('date_from' => $reportOptions['date_start'], 'date_to' => $reportOptions['date_end'])), 'itemsPerPage' => false);
         // there are problems dealing with location_list as an array if empty, so connvert
         if ($downloadOptions['extraParams']['location_list'] == "") {
             $downloadOptions['extraParams']['location_list'] = "(-1)";
         } else {
             $downloadOptions['extraParams']['location_list'] = '(' . $downloadOptions['extraParams']['location_list'] . ')';
         }
         for ($i = 1; $i <= 4; $i++) {
             if (isset($args['Download' . $i . 'Caption']) && $args['Download' . $i . 'Caption'] != "" && isset($args['download_report_' . $i]) && $args['download_report_' . $i] != "") {
                 $downloadOptions['caption'] = $args['Download' . $i . 'Caption'];
                 $downloadOptions['dataSource'] = $args['download_report_' . $i];
                 $downloadOptions['filename'] = $reportOptions['downloadFilePrefix'] . preg_replace('/[^A-Za-z0-9]/i', '', $args['Download' . $i . 'Caption']);
                 $downloadOptions['filename'] .= isset($reportOptions['includeReportTimeStamp']) && $reportOptions['includeReportTimeStamp'] ? '_' . date('YmdHis') : '';
                 if (isset($args['download_report_' . $i . '_format'])) {
                     $downloadOptions['format'] = $args['download_report_' . $i . '_format'];
                 }
                 data_entry_helper::$javascript .= "\nif(jQuery('#downloads-table th').length==0)\n  jQuery('#downloads-table thead tr').append('<th class=\"downloads-table-label\">" . lang::get("Downloads") . "</th>');\njQuery('#downloads-table thead tr').append('" . report_helper::report_download_link($downloadOptions) . "');\n";
             }
         }
     }
     return $retVal;
 }
 /**
  * Constructs an option question object
  *
  * @param CqUserAnswerInterface $userAnswer
  *   The CqUserAnswerInterface to use for storing the student's answer.
  * @param object $node
  *   Drupal node object that this question belongs to.
  */
 public function __construct(CqUserAnswerInterface &$userAnswer, &$node)
 {
     parent::__construct();
     $this->userAnswer =& $userAnswer;
     $this->node =& $node;
     if (isset($_REQUEST['action'])) {
         if (strtolower($_REQUEST['action']) == 'getanswer') {
             echo $this->userAnswer->getAnswer();
             die;
         }
         if (strtolower($_REQUEST['action']) == 'getdata') {
             echo $this->userAnswer->getData('data');
             die;
         }
         if (strtolower($_REQUEST['action']) == 'getinfo') {
             global $user;
             profile_load_profile(&$user);
             $info = array();
             $info['username'] = $user->name;
             if (isset($user->profile_firstname)) {
                 $info['firstname'] = $user->profile_firstname;
             }
             if (isset($user->profile_middlename)) {
                 $info['middlename'] = $user->profile_middlename;
             }
             if (isset($user->profile_lastname)) {
                 $info['lastname'] = $user->profile_lastname;
             }
             $info['tries'] = $this->userAnswer->getTries();
             $info['onceCorrect'] = $this->userAnswer->onceCorrect();
             $format = '';
             if (isset($_REQUEST['format'])) {
                 $format = strtolower($_REQUEST['format']);
             }
             switch ($format) {
                 case 'xml':
                     $dom = new DOMDocument('1.0', 'utf-8');
                     $root = $dom->createElement('data');
                     $dom->appendChild($root);
                     foreach ($info as $key => $value) {
                         $node = $dom->createElement($key, $value);
                         $root->appendChild($node);
                     }
                     echo $dom->saveXML();
                     die;
                     break;
                 case 'json':
                     drupal_json($info);
                     die;
                     break;
                 case 'flash':
                 default:
                     foreach ($info as $key => $value) {
                         echo '&' . $key . '=' . urlencode($value) . '&';
                     }
                     die;
                     break;
             }
         }
     }
     if (isset($_POST['action'])) {
         if (strtolower($_POST['action']) == 'store') {
             if (isset($_POST['answer'])) {
                 $this->userAnswer->setAnswer($_POST['answer']);
             }
             if (isset($_POST['data'])) {
                 $this->userAnswer->setData('data', $_POST['data']);
             }
             if (isset($_POST['tries'])) {
                 $this->userAnswer->setTries($_POST['tries']);
             }
             if (isset($_POST['correct'])) {
                 $this->userAnswer->setCorrect($_POST['correct']);
                 $this->userAnswer->setData('correct', $_POST['correct']);
             }
             switch ($format) {
                 case 'xml':
                     $dom = new DOMDocument('1.0', 'utf-8');
                     $root = $dom->createElement('result');
                     $dom->appendChild($root);
                     $node = $dom->createElement('success', 'true');
                     $root->appendChild($node);
                     echo $dom->saveXML();
                     die;
                     break;
                 case 'json':
                     drupal_json(array('success' => TRUE));
                     die;
                     break;
                 case 'flash':
                 default:
                     echo '&success=true&';
                     die;
                     break;
             }
         }
     }
 }
示例#5
0
function ogplcommunities_username($object)
{
    // Load profile data
    profile_load_profile($object);
    if ($object->profile_anonymous == 0 && $object->uid && $object->profile_display_name) {
        // Shorten the name when it is too long or it will break many tables.
        /*
            if (drupal_strlen($object->profile_display_name) > 20) {
              $name = drupal_substr($object->profile_display_name, 0, 15) .'...';
            }
            else {*/
        $name = $object->profile_display_name;
        /*}*/
        if (user_access('access user profiles')) {
            $output = l($name, 'user/' . $object->uid, array('title' => t('View user profile.')));
        } else {
            $output = check_plain($name);
        }
    } else {
        $output = variable_get('anonymous', t('Anonymous'));
    }
    return $output;
}
示例#6
0
 protected static function getBoundaryVersionsList($args, $locationId, $auth)
 {
     global $user;
     if (!isset($user->profile_indicia_user_id) && function_exists('profile_load_profile')) {
         profile_load_profile($user);
     }
     iform_load_helpers(array('report_helper'));
     if (!empty($user->profile_indicia_user_id)) {
         $extraParams = array('preferred_boundary_attribute_id' => $args['preferred_boundary_attribute_id'], 'current_user_id' => $user->profile_indicia_user_id, 'count_unit_id' => $locationId, 'count_unit_boundary_location_type_id' => $args['count_unit_boundary_location_type_id'], 'admin_role' => $args['administrator_mode'], 'boundary_start_date_attribute_id' => $args['boundary_start_date_id'], 'boundary_end_date_attribute_id' => $args['boundary_end_date_id']);
     } else {
         $extraParams = array('preferred_boundary_attribute_id' => $args['preferred_boundary_attribute_id'], 'current_user_id' => $user->uid, 'count_unit_id' => $locationId, 'count_unit_boundary_location_type_id' => $args['count_unit_boundary_location_type_id'], 'admin_role' => $args['administrator_mode'], 'boundary_start_date_attribute_id' => $args['boundary_start_date_id'], 'boundary_end_date_attribute_id' => $args['boundary_end_date_id']);
     }
     $optionsForBoundaryVersionsReport = array('dataSource' => 'reports_for_prebuilt_forms/CUDI/get_count_unit_boundaries_for_user_role', 'readAuth' => $auth['read'], 'extraParams' => $extraParams);
     //Get the report options such as the Preset Parameters on the Edit Tab
     $optionsForBoundaryVersionsReport = array_merge(iform_report_get_report_options($args, $readAuth), $optionsForBoundaryVersionsReport);
     //Collect the boundaries from a report.
     $boundaryVersions = report_helper::get_report_data($optionsForBoundaryVersionsReport);
     return $boundaryVersions;
 }
示例#7
0
function ciclo20v2_username($user, $link = TRUE)
{
    if ($user->uid && function_exists('profile_load_profile')) {
        profile_load_profile($user);
    }
    if (isset($user->profile_name)) {
        $name = $user->profile_name . ' ' . $user->profile_last_name;
    } else {
        if (isset($user->name)) {
            $name = $user->name;
        } else {
            $name = variable_get('anonymous', 'Anonymous');
            $link = FALSE;
        }
    }
    if ($link && user_access('access user profiles')) {
        return l($name, 'user/' . $user->uid, array('title' => t('View user profile.')));
    } else {
        return check_plain($name);
    }
}
示例#8
0
/** 
 * Takes a set of report parameters and applies preferences from the user's EasyLogin profile to the report parameters. Assumes
 * parameters called ownData, ownLocality, ownGroups. See the library/occurrences/explore_list report for an example.
 */
function iform_report_apply_explore_user_own_preferences(&$reportOptions)
{
    $allParams = array_merge($reportOptions['paramDefaults'], $reportOptions['extraParams']);
    global $user;
    if (!isset($user->profile_indicia_user_id) && function_exists('profile_load_profile')) {
        profile_load_profile($user);
    }
    // Unless ownData explicitly set, we either default it to unchecked, or we set it unchecked and hidden if the user account
    // is not on the warehouse
    if (!array_key_exists('ownData', $allParams)) {
        if (!empty($user->profile_indicia_user_id)) {
            $reportOptions['paramDefaults']['ownData'] = 0;
        } else {
            $reportOptions['extraParams']['ownData'] = 0;
        }
    }
    // Unless ownLocality explicitly set, we either default it to checked, or we set it unchecked and hidden if the user account
    // has no location preferences set
    if (!array_key_exists('ownLocality', $allParams)) {
        if (!empty($user->profile_location)) {
            $reportOptions['paramDefaults']['ownLocality'] = 1;
        } else {
            $reportOptions['extraParams']['ownLocality'] = 0;
        }
    }
    // Unless ownGroups explicitly set, we either default it to checked, or we set it unchecked and hidden if the user account
    // has no taxon groups set
    if (!array_key_exists('ownGroups', $allParams)) {
        if (!empty($user->profile_taxon_groups)) {
            $reportOptions['paramDefaults']['ownGroups'] = 1;
        } else {
            $reportOptions['extraParams']['ownGroups'] = 0;
        }
    }
}
示例#9
0
文件: sopac_user.php 项目: aadl/sopac
function sopac_lists_page($list_id = 0, $op = NULL, $search = NULL)
{
    global $user;
    profile_load_profile(&$user);
    require_once 'sopac_social.php';
    $insurge = sopac_get_insurge();
    if ($list_id === 'public') {
        // Display a paged list of all the public lists
        $count = 10;
        if ($op == "search") {
            $output .= drupal_get_form('sopac_list_search_form', $search);
            $args = array();
            foreach (explode(' ', $search) as $term) {
                $search_sql .= " AND (title LIKE '%%%s%%' OR description LIKE '%%%s%%')";
                $args[] = $term;
                $args[] = $term;
            }
        } else {
            $output .= drupal_get_form('sopac_list_search_form');
        }
        $output .= "<h1>Public Lists:</h1>";
        $sql = "SELECT * FROM {sopac_lists} WHERE public = 1 {$search_sql} ORDER BY list_id DESC";
        $countsql = "SELECT COUNT(*) FROM {sopac_lists} WHERE public = 1 {$search_sql} ORDER BY list_id DESC";
        $res = pager_query($sql, $count, 0, $countsql, $args);
        $output .= theme('pager', NULL, $count);
        while ($list = db_fetch_array($res)) {
            $list['items'] = $insurge->get_list_items($list['list_id']);
            $output .= theme('sopac_list', $list);
            $list_count++;
        }
        $output .= theme('pager', NULL, $count);
        if ($list_count == $public_limit) {
            $output .= '<ul class="list-overview-actions"><li class="button green">' . l("Next {$public_limit} Lists", 'user/lists/public', array('query' => array('offset' => $public_offset + $public_limit))) . '</li></ul>';
        }
    } else {
        if ($list_id) {
            // display list contents
            $list = db_fetch_array(db_query("SELECT * FROM sopac_lists WHERE list_id = %d LIMIT 1", $list_id));
            if ($list['list_id']) {
                if ($list['public'] || sopac_lists_access($list['list_id'])) {
                    global $pager_page_array, $pager_total;
                    drupal_set_title($list['title']);
                    drupal_set_breadcrumb(array(l('Home', '<front>'), l('Lists', 'user/lists'), l($list['title'], $_GET['q'])));
                    // Update Checkout History?
                    if ($list['title'] == 'Checkout History' && $user->profile_cohist) {
                        sopac_update_history($list);
                        if (empty($_GET['sort'])) {
                            $_GET['sort'] = 'date_newest';
                        }
                    }
                    if ($_GET['perpage']) {
                        $limit = $_GET['perpage'];
                    } else {
                        if ($account->profile_perpage) {
                            $limit = $account->profile_perpage;
                        } else {
                            if ($op == 'print' || $op == 'csv') {
                                $limit = NULL;
                            } else {
                                $limit = variable_get('sopac_results_per_page', 10);
                            }
                        }
                    }
                    $pager_page_array = explode(',', $_GET['page']);
                    // Initialize the pager if need be
                    if ($pager_page_array[0]) {
                        $page = $pager_page_array[0] + 1;
                    } else {
                        $page = 1;
                    }
                    $page_offset = $limit * ($page - 1);
                    $sortopts = array('value', 'title', 'author', 'mat_code');
                    $search_term = $_GET['search'] ? $_GET['search'] : '';
                    if (array_search($_GET['sort'], $sortopts)) {
                        $list['items'] = $insurge->get_list_items($list_id, $_GET['sort'], 'ASC', $search_term);
                    } else {
                        if ($_GET['sort'] == 'date') {
                            $list['items'] = $insurge->get_list_items($list_id, 'tag_date', 'ASC', $search_term);
                        } else {
                            if ($_GET['sort'] == 'date_newest') {
                                $list['items'] = $insurge->get_list_items($list_id, 'tag_date', 'DESC', $search_term);
                            } else {
                                $list['items'] = $insurge->get_list_items($list_id, 'value', 'ASC', $search_term);
                            }
                        }
                    }
                    $list['total_items'] = count($list['items']);
                    if ($limit) {
                        $pager_total[0] = ceil($list['total_items'] / $limit);
                    }
                    // Trim list items to display
                    $list['items'] = array_slice($list['items'], $page_offset, $limit, TRUE);
                    if ($op == 'print') {
                        $output .= theme('sopac_list', $list, TRUE, 'print');
                    } else {
                        if ($op == 'csv') {
                            foreach ($list['items'] as &$item) {
                                unset($item['tid'], $item['repos_id'], $item['group_id'], $item['uid'], $item['tag'], $item['namespace'], $item['predicate'], $item['value']);
                                $item['url'] = 'http://www.aadl.org/catalog/record/' . $item['bnum'];
                            }
                            output_csv($list['items'], 'aadl-list-' . $list['list_id'] . '.csv');
                            exit(0);
                        } else {
                            $output .= theme('sopac_list', $list, TRUE);
                        }
                    }
                    $output .= theme('pager', NULL, $limit, 0, NULL, 6);
                } else {
                    $output .= '<p>You do not have permission to view this list.</p>';
                    $output .= '<ul><li class="button green">';
                    $output .= $user->uid ? l('View your lists', 'user/lists') : l('Log in to create lists', 'user', array('query' => 'destination=user/lists'));
                    $output .= '</li></ul>';
                }
            } else {
                drupal_set_message("No list with list id #{$list_id} exists");
                drupal_goto('user/lists');
            }
        } else {
            if ($user->uid) {
                $output .= "<p style=\"float: right\">" . l('See all Public Lists...', 'user/lists/public') . '</p>';
                $output .= "<h1>My Lists:</h1>";
                // display lists
                $res = db_query("SELECT * FROM {sopac_lists} WHERE uid = %d", $user->uid);
                while ($list = db_fetch_array($res)) {
                    $list['items'] = $insurge->get_list_items($list['list_id']);
                    $output .= theme('sopac_list', $list);
                }
                $output .= '<ul class="list-overview-actions"><li class="button green">' . l('Create New List', 'user/lists/edit') . '</li></ul>';
            } else {
                // Anonymous user
                drupal_set_message('You must log in to create and edit your lists');
                drupal_goto('user', drupal_get_destination());
            }
        }
    }
    return $output;
}
 /**
  * Applies defaults to the options array passed to a report calendar summary control.
  * @param array $options Options array passed to the control.
  * @return array The processed options array.
  */
 private static function get_report_calendar_summary_options($options)
 {
     global $user;
     $options = array_merge(array('mode' => 'report', 'id' => 'calendar-report-output', 'tableContainerID' => 'tablediv-container', 'tableID' => 'report-table', 'tableClass' => 'ui-widget ui-widget-content report-grid', 'thClass' => 'ui-widget-header', 'altRowClass' => 'odd', 'extraParams' => array(), 'viewPreviousIfTooEarly' => true, 'includeWeekNumber' => false, 'weekstart' => 'weekday=7', 'weekNumberFilter' => ':', 'rowGroupColumn' => 'taxon', 'rowGroupID' => 'taxa_taxon_list_id', 'chartContainerID' => 'chartdiv-container', 'chartID' => 'chartdiv', 'chartClass' => 'ui-widget ui-widget-content ui-corner-all', 'headerClass' => 'ui-widget-header ui-corner-all', 'height' => 400, 'chartType' => 'line', 'rendererOptions' => array(), 'legendOptions' => array(), 'axesOptions' => array(), 'includeRawData' => true, 'includeSummaryData' => true, 'includeEstimatesData' => false, 'includeTableTotalColumn' => true, 'includeTableTotalRow' => true, 'tableHeaders' => 'date', 'rawDataCombining' => 'add', 'dataRound' => 'nearest', 'avgFieldRound' => 'nearest', 'avgFields' => '', 'zeroPointAnchor' => ',', 'interpolation' => 'linear', 'firstValue' => 'none', 'lastValue' => 'none', 'highlightEstimates' => false, 'includeRawGridDownload' => false, 'includeRawListDownload' => true, 'includeSummaryGridDownload' => false, 'includeEstimatesGridDownload' => false, 'includeListDownload' => true, 'downloadFilePrefix' => ''), $options);
     $options["extraParams"] = array_merge(array('date_from' => $options['date_start'], 'date_to' => $options['date_end'], 'occattrs' => ''), $options["extraParams"]);
     // Note for the calendar reports, the user_id is initially assumed to be the CMS user id as recorded in the CMS User ID attribute,
     // not the Indicia user id: we do the conversion here.
     if (isset($options["extraParams"]['user_id'])) {
         $options["extraParams"]['cms_user_id'] = $options["extraParams"]['user_id'];
         if (function_exists('module_exists') && module_exists('easy_login') && $options["extraParams"]['user_id'] != '') {
             $account = user_load($options["extraParams"]['user_id']);
             if (function_exists('profile_load_profile')) {
                 profile_load_profile($account);
             }
             /* will not be invoked for Drupal7 where the fields are already in the account object */
             if (isset($account->profile_indicia_user_id)) {
                 $options["extraParams"]['user_id'] = $account->profile_indicia_user_id;
             }
         }
     }
     // Note for the calendar reports, the user_id is assumed to be the CMS user id as recorded in the CMS User ID attribute,
     // not the Indicia user id.
     return $options;
 }
示例#11
0
 private function Load($uid)
 {
     global $user;
     if ($user != null && $uid == $user->uid) {
         $this->_user = $user;
     } else {
         $this->_user = user_load(array('uid' => $uid));
     }
     static $sql = "SELECT `name`, `value` FROM `{application_settings}` WHERE `application_id`=%d AND `user_id`=%d";
     if ($this->_user != FALSE) {
         $this->SetUpProfile();
         profile_load_profile($this->_user);
         $res = db_query($sql, os_poker_get_poker_app_id(), $uid);
         if ($res != FALSE) {
             $this->_isOS = TRUE;
             while (($row = db_fetch_object($res)) != FALSE) {
                 $this->_vars[$row->name] = json_decode($row->value, TRUE);
             }
         }
         return TRUE;
     }
     return FALSE;
 }
示例#12
0
文件: template.php 项目: aakb/alice
function _alice_get_fullname($uid)
{
    $user = user_load($uid);
    profile_load_profile($user);
    return l($user->profile_name, 'users/' . str_replace(' ', '-', $user->name));
}