Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
/**
* @file custom_glue.module
* TODO: Enter file description here.
*/
function custom_glue_preprocess_html(&$variables) {
$glue = drupal_get_path('module', 'custom_glue') . '/custom_glue.css';
$options = array(
'group' => CSS_THEME + 1,
'weight' => 99,
);
drupal_add_css($glue, $options);
}
function custom_glue_form_alter(&$form, $form_state, $form_id) {
switch ($form_id) {
case 'comment_node_wiki_page_form':
dpm($form);
/*
$criteria = array();
$criteria['entity_id'] = $form['#entity']->nid;
$criteria['uid'] = votingapi_current_user_identifier();
// check if current user has already voted for this node:
$vote = votingapi_select_votes($criteria, 1);
if(!empty($vote)){
// user has already voted: hide rating field:
unset($form['field_vote']);
}
*/
break;
}
}
function custom_glue_comment_view($comment, $view_mode, $langcode) {
// if a comment has the rating field:
if(isset($comment->field_vote)) {
// If user has not voted on this comment:
if($comment->field_vote['und'][0]['count'] == 0) {
// hide rating field:
unset($comment->content['field_vote']);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.