Last active
December 16, 2015 08:49
-
-
Save ogredude/5408562 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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