public function testGetUsersByRole() { $role = 'Review Manager'; $users = OshaWorkflowPermissions::getUsersByRole($role); $this->assertNotEmpty($users); $role = user_role_load_by_name('Review Manager'); $users = OshaWorkflowPermissions::getUsersByRole($role->rid); $this->assertNotEmpty($users); }
/** * Called from hook_preprocess_node */ function fill_related_publications(&$vars) { $vars['total_related_publications'] = 0; // get 3 related publications by common tags $tags_tids = array(); if (!empty($vars['field_tags'])) { $tags_tids = $vars['field_tags'][LANGUAGE_NONE]; } if (!empty($tags_tids)) { // query all publications with the same tags $tids = array(); foreach ($tags_tids as $tid) { array_push($tids, $tid['tid']); } $query = new EntityFieldQuery(); // exclude self $excluded_nids = array(); array_push($excluded_nids, $vars['node']->nid); $query->entityCondition('entity_type', 'node')->entityCondition('bundle', 'publication')->entityCondition('entity_id', $excluded_nids, 'NOT IN')->fieldCondition('field_tags', 'tid', $tids, 'IN')->fieldOrderBy('field_publication_date', 'value', 'DESC'); $result = $query->execute(); $limit = 3; global $user; if (!empty($result)) { $vars['total_related_publications'] = sizeof($result['node']); $vars['tagged_related_publications'] = array(); $count = 0; foreach ($result['node'] as $n) { $node = node_load($n->nid); if ($node->status == 0) { // add unpublished only for admin, do not include in count if (OshaWorkflowPermissions::userHasRole('administrator', $user)) { $vars['tagged_related_publications'][] = node_view($node, 'teaser'); } } else { $vars['tagged_related_publications'][] = node_view($node, 'teaser'); $count++; } if ($count == $limit) { // max 3 related publications break; } } } } }