/** * Implements hook_preprocess_reply(). */ function dguk_preprocess_reply(&$variables) { global $user; if ($user->uid && $user->uid == $variables['reply']->uid) { $variables['classes_array'][] = 'own-reply'; } $variables['classes_array'][] = 'boxed'; $variables['classes_array'][] = 'parent-' . $variables['reply']->parent; // Add $avatar variable with rendered user picture linked to user profile; $fields = field_info_instances('user', 'user'); $field_id = $fields['field_avatar']['field_id']; $account = new stdClass(); $account->uid = $variables['reply']->uid; field_attach_load('user', array($account->uid => $account), FIELD_LOAD_CURRENT, array('field_id' => $field_id)); if (!empty($account->field_avatar)) { $field = field_get_items('user', $account, 'field_avatar'); $image = field_view_value('user', $account, 'field_avatar', $field[0], array('settings' => array('image_style' => 'avatar'))); } else { $image_info = dguk_default_field_image('field_avatar'); $image = field_view_value('user', $account, 'field_avatar', (array) $image_info, array('settings' => array('image_style' => 'avatar'))); } $colour = $variables['reply']->uid % 10; if ($variables['reply']->uid) { $variables['avatar'] = l(render($image), 'user/' . $variables['reply']->uid, array('html' => true, 'attributes' => array('class' => array('field-avatar', 'bg-colour-' . $colour)))); } else { $variables['avatar'] = '<div class="field-avatar bg-colour-0">' . render($image) . '</div>'; } $variables['theme_hook_suggestions'][] = 'reply__' . $variables['bundle']; }
public function initialize() { // Add the purchase fields. field_attach_load('ms_products_purchase', array($this->id => $this)); if (!empty($this->bundle) && ($bundle_info = ms_products_get_bundle($this->bundle))) { foreach ($bundle_info['purchase_fields'] as $field_name => $field_info) { $this->fields[$field_name] = ms_products_get_purchase_field($this->bundle, $this->id, $field_name); } } // Add the purchase options. $result = db_select('ms_products_purchase_options', 'po')->fields('po')->condition('po.pid', $this->id)->execute(); foreach ($result as $option) { $this->options[$option->name] = $option; } }