additional_fields = $this->definition['additional fields']; } /** * Information about options for all kinds of purposes will be held here. * @see [modules]/views/handlers/views_handler_field#option_definition() */ function option_definition() { $options = parent::option_definition(); // This option determintes what will to do when a null privacy is retrieved from the database. $options['null_privacy'] = array( 'default' => SMARTQUEUE_USERS_VIEWS_NULL_PRIVACY_PUBLIC, ); return $options; } /** * Default options form that provides a way to set the above mentioned options. * @see [modules]/views/handlers/views_handler_field#options_form($form, $form_state) */ function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); // Options array for the form API. $options = array( SMARTQUEUE_USERS_VIEWS_NULL_PRIVACY_EMPTY => t('Show empty text'), SMARTQUEUE_USERS_VIEWS_NULL_PRIVACY_PUBLIC => t('Show as public'), ); $form['null_privacy'] = array( '#type' => 'select', '#title' => t('Unknown privacy'), '#description' => t('Select what to show for subqueues that do not belong to Smartqueue per User. These subqueues are usually public.'), '#default_value' => $this->options['null_privacy'], '#options' => $options, ); } /** * Run before any fields are rendered. * * Set the numeric value of the privacy for each result. * * @param $values * An array of all objects returned from the query. * @see modules/acquia/views/handlers/views_handler_field#pre_render($values) */ function pre_render(&$values) { parent::pre_render($values); // Set the numeric value of the privacy for each result foreach ($values as $i => $value) { // Load these variables from the result for easier handling $privacy = $value->{$this->field_alias}; $qid = (int)$value->{$this->aliases['__smartqueue_users__queue_qid']}; $owner = $value->{$this->aliases['__smartqueue_users__queue_owner']}; // If this queue is not a smartqueue_users queue then it is public // Handle the result according to the option in the view settings if ($owner != 'smartqueue_users') { if ($options['null_privacy'] == SMARTQUEUE_USERS_VIEWS_NULL_PRIVACY_PUBLIC) { $values[$i]->{$this->field_alias} = SMARTQUEUE_USERS_PRIVACY_PUBLIC; } else { $values[$i]->{$this->field_alias} = -1; } continue; } // Change to the queue's default privacy if the result from the database // is NULL or the queue doesn't allow user selected privacy if (is_null($privacy) || !_smartqueue_users_settings_get('subqueue_privacy_changeable', $qid)) { $privacy = _smartqueue_users_settings_get('subqueue_privacy_default', $qid); } // Save the resulting privacy $values[$i]->{$this->field_alias} = $privacy; } } /** * Render the field. * * @param $values * The values retrieved from the database. * @see [modules]/views/handlers/views_handler_field#render($values) */ function render($values) { $privacy = $values->{$this->field_alias}; return theme('smartqueue_users_privacy', $privacy); } }