Révision dd54aff9
Ajouté par Assos Assos il y a plus de 10 ans
htmltest/sites/all/modules/entity/entity.features.inc | ||
---|---|---|
148 | 148 |
/** |
149 | 149 |
* Features component callback. |
150 | 150 |
*/ |
151 |
function entity_features_export_options($entity_type) { |
|
151 |
function entity_features_export_options($a1, $a2 = NULL) { |
|
152 |
// Due to a change in the Features API the first parameter might be a feature |
|
153 |
// object or an entity type, depending on the Features version. This check is |
|
154 |
// for backwards compatibility. |
|
155 |
$entity_type = is_string($a1) ? $a1 : $a2; |
|
152 | 156 |
return entity_features_get_controller($entity_type)->export_options(); |
153 | 157 |
} |
154 | 158 |
|
htmltest/sites/all/modules/entity/entity.info | ||
---|---|---|
25 | 25 |
files[] = views/handlers/entity_views_handler_relationship_by_bundle.inc |
26 | 26 |
files[] = views/handlers/entity_views_handler_relationship.inc |
27 | 27 |
files[] = views/plugins/entity_views_plugin_row_entity_view.inc |
28 |
; Information added by drupal.org packaging script on 2013-08-14
|
|
29 |
version = "7.x-1.2"
|
|
28 |
; Information added by Drupal.org packaging script on 2014-01-08
|
|
29 |
version = "7.x-1.3"
|
|
30 | 30 |
core = "7.x" |
31 | 31 |
project = "entity" |
32 |
datestamp = "1376493705"
|
|
32 |
datestamp = "1389210813"
|
|
33 | 33 |
|
htmltest/sites/all/modules/entity/entity.info.inc | ||
---|---|---|
240 | 240 |
$this->propertyInfo += array('bundles' => array()); |
241 | 241 |
foreach ($this->propertyInfo['bundles'] as $bundle_name => $info) { |
242 | 242 |
foreach ($info['properties'] as $name => $property_info) { |
243 |
$extra[$this->entityType][$bundle_name]['display'][$name] = $this->generateExtraFieldInfo($name, $property_info); |
|
243 |
if (empty($property_info['field'])) { |
|
244 |
$extra[$this->entityType][$bundle_name]['display'][$name] = $this->generateExtraFieldInfo($name, $property_info); |
|
245 |
} |
|
244 | 246 |
} |
245 | 247 |
} |
246 | 248 |
return $extra; |
htmltest/sites/all/modules/entity/entity.module | ||
---|---|---|
133 | 133 |
foreach ($info['bundles'] as $bundle_name => $bundle_info) { |
134 | 134 |
// Create an empty entity with just the bundle set to check for access. |
135 | 135 |
$dummy_entity = entity_create($entity_type, array( |
136 |
'bundle' => $bundle_name,
|
|
136 |
$info['entity keys']['bundle'] => $bundle_name,
|
|
137 | 137 |
)); |
138 | 138 |
// If modules use a uid, they can default to the current-user |
139 | 139 |
// in their create() method on the storage controller. |
... | ... | |
166 | 166 |
return entity_ui_get_form($entity_type, $entity, 'add'); |
167 | 167 |
} |
168 | 168 |
|
169 |
/** |
|
170 |
* Page callback for viewing an entity. |
|
171 |
* |
|
172 |
* @param Entity $entity |
|
173 |
* The entity to be rendered. |
|
174 |
* |
|
175 |
* @return array |
|
176 |
* A renderable array of the entity in full view mode. |
|
177 |
*/ |
|
178 |
function entity_ui_entity_page_view($entity) { |
|
179 |
module_load_include('inc', 'entity', 'includes/entity.ui'); |
|
180 |
return $entity->view('full', NULL, TRUE); |
|
181 |
} |
|
182 |
|
|
183 |
/** |
|
184 |
* Gets the page title for the passed operation. |
|
185 |
*/ |
|
186 |
function entity_ui_get_page_title($op, $entity_type, $entity = NULL) { |
|
187 |
module_load_include('inc', 'entity', 'includes/entity.ui'); |
|
188 |
$label = entity_label($entity_type, $entity); |
|
189 |
switch ($op) { |
|
190 |
case 'view': |
|
191 |
return $label; |
|
192 |
case 'edit': |
|
193 |
return t('Edit @label', array('@label' => $label)); |
|
194 |
case 'clone': |
|
195 |
return t('Clone @label', array('@label' => $label)); |
|
196 |
case 'revert': |
|
197 |
return t('Revert @label', array('@label' => $label)); |
|
198 |
case 'delete': |
|
199 |
return t('Delete @label', array('@label' => $label)); |
|
200 |
case 'export': |
|
201 |
return t('Export @label', array('@label' => $label)); |
|
202 |
} |
|
203 |
if (isset($entity)) { |
|
204 |
list(, , $bundle) = entity_extract_ids($entity_type, $entity); |
|
205 |
} |
|
206 |
return entity_ui_get_action_title($op, $entity_type, $bundle); |
|
207 |
} |
|
208 |
|
|
169 | 209 |
/** |
170 | 210 |
* A wrapper around entity_load() to load a single entity by name or numeric id. |
171 | 211 |
* |
... | ... | |
582 | 622 |
} |
583 | 623 |
|
584 | 624 |
/** |
585 |
* Determines whether the given user has access to an entity. |
|
625 |
* Determines whether the given user can perform actions on an entity. |
|
626 |
* |
|
627 |
* For create operations, the pattern is to create an entity and then |
|
628 |
* check if the user has create access. |
|
629 |
* |
|
630 |
* @code |
|
631 |
* $node = entity_create('node', array('type' => 'page')); |
|
632 |
* $access = entity_access('create', 'node', $node, $account); |
|
633 |
* @endcode |
|
586 | 634 |
* |
587 | 635 |
* @param $op |
588 | 636 |
* The operation being performed. One of 'view', 'update', 'create' or |
... | ... | |
881 | 929 |
// implementations. |
882 | 930 |
$originals[$name] = $entity->original; |
883 | 931 |
|
884 |
$entity->{$keys['status']} |= ENTITY_IN_CODE; |
|
932 |
if (!isset($entity->{$keys['status']})) { |
|
933 |
$entity->{$keys['status']} = ENTITY_IN_CODE; |
|
934 |
} |
|
935 |
else { |
|
936 |
$entity->{$keys['status']} |= ENTITY_IN_CODE; |
|
937 |
} |
|
885 | 938 |
$entity->is_rebuild = TRUE; |
886 | 939 |
entity_save($entity_type, $entity); |
887 | 940 |
unset($entity->is_rebuild); |
... | ... | |
1396 | 1449 |
$entity_info['node']['form callback'] = 'entity_metadata_form_node'; |
1397 | 1450 |
$entity_info['user']['form callback'] = 'entity_metadata_form_user'; |
1398 | 1451 |
|
1452 |
// URI callbacks. |
|
1453 |
if (!isset($entity_info['file']['uri callback'])) { |
|
1454 |
$entity_info['file']['uri callback'] = 'entity_metadata_uri_file'; |
|
1455 |
} |
|
1456 |
|
|
1399 | 1457 |
// View callbacks. |
1400 | 1458 |
$entity_info['node']['view callback'] = 'entity_metadata_view_node'; |
1401 | 1459 |
$entity_info['user']['view callback'] = 'entity_metadata_view_single'; |
htmltest/sites/all/modules/entity/entity.test | ||
---|---|---|
997 | 997 |
|
998 | 998 |
// Test field level access. |
999 | 999 |
$this->assertTrue($wrapper->{$this->field_name}->access('view'), 'Field access granted.'); |
1000 |
|
|
1001 |
// Create node owned by anonymous and test access() method on each of its |
|
1002 |
// properties. |
|
1003 |
$node = $this->drupalCreateNode(array('type' => 'page', 'uid' => 0)); |
|
1004 |
$wrapper = entity_metadata_wrapper('node', $node->nid); |
|
1005 |
foreach ($wrapper as $name => $property) { |
|
1006 |
$property->access('view'); |
|
1007 |
} |
|
1008 |
|
|
1009 |
// Property access of entity references takes entity access into account. |
|
1010 |
$node = $this->drupalCreateNode(array('type' => 'article')); |
|
1011 |
$wrapper = entity_metadata_wrapper('node', $node); |
|
1012 |
$unprivileged_user = $this->drupalCreateUser(); |
|
1013 |
$privileged_user = $this->drupalCreateUser(array('access user profiles')); |
|
1014 |
|
|
1015 |
$this->assertTrue($wrapper->author->access('view', $privileged_user)); |
|
1016 |
$this->assertFalse($wrapper->author->access('view', $unprivileged_user)); |
|
1017 |
|
|
1018 |
// Ensure the same works with multiple entity references by testing the |
|
1019 |
// $node->field_tags example. |
|
1020 |
$privileged_user = $this->drupalCreateUser(array('administer taxonomy')); |
|
1021 |
// Terms are view-able with access content, so make sure to remove this |
|
1022 |
// permission first. |
|
1023 |
user_role_revoke_permissions(DRUPAL_ANONYMOUS_RID, array('access content')); |
|
1024 |
$unprivileged_user = drupal_anonymous_user(); |
|
1025 |
|
|
1026 |
$this->assertTrue($wrapper->field_tags->access('view', $privileged_user), 'Privileged user has access.'); |
|
1027 |
$this->assertTrue($wrapper->field_tags->access('view', $unprivileged_user), 'Unprivileged user has access.'); |
|
1028 |
$this->assertTrue($wrapper->field_tags[0]->access('view', $privileged_user), 'Privileged user has access.'); |
|
1029 |
$this->assertFalse($wrapper->field_tags[0]->access('view', $unprivileged_user), 'Unprivileged user has no access.'); |
|
1000 | 1030 |
} |
1001 | 1031 |
|
1002 | 1032 |
/** |
... | ... | |
1087 | 1117 |
} |
1088 | 1118 |
} |
1089 | 1119 |
|
1120 |
/** |
|
1121 |
* Tests basic entity_access() functionality for nodes. |
|
1122 |
* |
|
1123 |
* This code is a modified version of NodeAccessTestCase. |
|
1124 |
* |
|
1125 |
* @see NodeAccessTestCase |
|
1126 |
*/ |
|
1127 |
class EntityMetadataNodeAccessTestCase extends EntityWebTestCase { |
|
1128 |
public static function getInfo() { |
|
1129 |
return array( |
|
1130 |
'name' => 'Entity Metadata Node Access', |
|
1131 |
'description' => 'Test entity_access() for nodes', |
|
1132 |
'group' => 'Entity API', |
|
1133 |
); |
|
1134 |
} |
|
1135 |
|
|
1136 |
/** |
|
1137 |
* Asserts node_access() correctly grants or denies access. |
|
1138 |
*/ |
|
1139 |
function assertNodeMetadataAccess($ops, $node, $account) { |
|
1140 |
foreach ($ops as $op => $result) { |
|
1141 |
$msg = t("entity_access() returns @result with operation '@op'.", array('@result' => $result ? 'TRUE' : 'FALSE', '@op' => $op)); |
|
1142 |
$access = entity_access($op, 'node', $node, $account); |
|
1143 |
$this->assertEqual($result, $access, $msg); |
|
1144 |
} |
|
1145 |
} |
|
1146 |
|
|
1147 |
function setUp() { |
|
1148 |
parent::setUp('entity', 'node'); |
|
1149 |
// Clear permissions for authenticated users. |
|
1150 |
db_delete('role_permission') |
|
1151 |
->condition('rid', DRUPAL_AUTHENTICATED_RID) |
|
1152 |
->execute(); |
|
1153 |
} |
|
1154 |
|
|
1155 |
/** |
|
1156 |
* Runs basic tests for entity_access() function. |
|
1157 |
*/ |
|
1158 |
function testNodeMetadataAccess() { |
|
1159 |
// Author user. |
|
1160 |
$node_author_account = $this->drupalCreateUser(array()); |
|
1161 |
// Make a node object. |
|
1162 |
$settings = array( |
|
1163 |
'uid' => $node_author_account->uid, |
|
1164 |
'type' => 'page', |
|
1165 |
'title' => 'Node ' . $this->randomName(32), |
|
1166 |
); |
|
1167 |
$node = $this->drupalCreateNode($settings); |
|
1168 |
|
|
1169 |
// Ensures user without 'access content' permission can do nothing. |
|
1170 |
$web_user1 = $this->drupalCreateUser(array('create page content', 'edit any page content', 'delete any page content')); |
|
1171 |
$this->assertNodeMetadataAccess(array('create' => FALSE, 'view' => FALSE, 'update' => FALSE, 'delete' => FALSE), $node, $web_user1); |
|
1172 |
|
|
1173 |
// Ensures user with 'bypass node access' permission can do everything. |
|
1174 |
$web_user2 = $this->drupalCreateUser(array('bypass node access')); |
|
1175 |
$this->assertNodeMetadataAccess(array('create' => TRUE, 'view' => TRUE, 'update' => TRUE, 'delete' => TRUE), $node, $web_user2); |
|
1176 |
|
|
1177 |
// User cannot 'view own unpublished content'. |
|
1178 |
$web_user3 = $this->drupalCreateUser(array('access content')); |
|
1179 |
// Create an unpublished node. |
|
1180 |
$settings = array('type' => 'page', 'status' => 0, 'uid' => $web_user3->uid); |
|
1181 |
$node_unpublished = $this->drupalCreateNode($settings); |
|
1182 |
$this->assertNodeMetadataAccess(array('view' => FALSE), $node_unpublished, $web_user3); |
|
1183 |
// User cannot create content without permission. |
|
1184 |
$this->assertNodeMetadataAccess(array('create' => FALSE), $node, $web_user3); |
|
1185 |
|
|
1186 |
// User can 'view own unpublished content', but another user cannot. |
|
1187 |
$web_user4 = $this->drupalCreateUser(array('access content', 'view own unpublished content')); |
|
1188 |
$web_user5 = $this->drupalCreateUser(array('access content', 'view own unpublished content')); |
|
1189 |
$node4 = $this->drupalCreateNode(array('status' => 0, 'uid' => $web_user4->uid)); |
|
1190 |
$this->assertNodeMetadataAccess(array('view' => TRUE, 'update' => FALSE), $node4, $web_user4); |
|
1191 |
$this->assertNodeMetadataAccess(array('view' => FALSE), $node4, $web_user5); |
|
1192 |
|
|
1193 |
// Tests the default access provided for a published node. |
|
1194 |
$node5 = $this->drupalCreateNode(); |
|
1195 |
$this->assertNodeMetadataAccess(array('view' => TRUE, 'update' => FALSE, 'delete' => FALSE, 'create' => FALSE), $node5, $web_user3); |
|
1196 |
} |
|
1197 |
} |
|
1198 |
|
|
1199 |
/** |
|
1200 |
* Test user permissions for node creation. |
|
1201 |
*/ |
|
1202 |
class EntityMetadataNodeCreateAccessTestCase extends EntityWebTestCase { |
|
1203 |
public static function getInfo() { |
|
1204 |
return array( |
|
1205 |
'name' => 'Entity Metadata Node Create Access', |
|
1206 |
'description' => 'Test entity_access() for nodes', |
|
1207 |
'group' => 'Entity API', |
|
1208 |
); |
|
1209 |
} |
|
1210 |
|
|
1211 |
function setUp() { |
|
1212 |
parent::setUp('entity', 'node'); |
|
1213 |
} |
|
1214 |
|
|
1215 |
/** |
|
1216 |
* Addresses the special case of 'create' access for nodes. |
|
1217 |
*/ |
|
1218 |
public function testNodeMetadataCreateAccess() { |
|
1219 |
// Create some users. One with super-powers, one with create perms, |
|
1220 |
// and one with no perms, and a different one to author the node. |
|
1221 |
$admin_account = $this->drupalCreateUser(array( |
|
1222 |
'bypass node access', |
|
1223 |
)); |
|
1224 |
$creator_account = $this->drupalCreateUser(array( |
|
1225 |
'create page content', |
|
1226 |
)); |
|
1227 |
$auth_only_account = $this->drupalCreateUser(array()); |
|
1228 |
$node_author_account = $this->drupalCreateUser(array()); |
|
1229 |
|
|
1230 |
// Make a node object with Entity API (contrib) |
|
1231 |
$settings = array( |
|
1232 |
'uid' => $node_author_account->uid, |
|
1233 |
'type' => 'page', |
|
1234 |
'title' => $this->randomName(32), |
|
1235 |
'body' => array(LANGUAGE_NONE => array(array($this->randomName(64)))), |
|
1236 |
); |
|
1237 |
$node = entity_create('node', $settings); |
|
1238 |
|
|
1239 |
// Test the populated wrapper. |
|
1240 |
$wrapper = entity_metadata_wrapper('node', $node); |
|
1241 |
$this->assertTrue($wrapper->entityAccess('create', $admin_account), 'Create access allowed for ADMIN, for populated wrapper.'); |
|
1242 |
$this->assertTrue($wrapper->entityAccess('create', $creator_account), 'Create access allowed for CREATOR, for populated wrapper.'); |
|
1243 |
$this->assertFalse($wrapper->entityAccess('create', $auth_only_account), 'Create access denied for USER, for populated wrapper.'); |
|
1244 |
|
|
1245 |
// Test entity_acces(). |
|
1246 |
$this->assertTrue(entity_access('create', 'node', $node, $admin_account), 'Create access allowed for ADMIN, for entity_access().'); |
|
1247 |
$this->assertTrue(entity_access('create', 'node', $node, $creator_account), 'Create access allowed for CREATOR, for entity_access().'); |
|
1248 |
$this->assertFalse(entity_access('create', 'node', $node, $auth_only_account), 'Create access denied for USER, for entity_access().'); |
|
1249 |
} |
|
1250 |
} |
|
1251 |
|
|
1252 |
/** |
|
1253 |
* Tests user permissions for node revisions. |
|
1254 |
* |
|
1255 |
* Based almost entirely on NodeRevisionPermissionsTestCase. |
|
1256 |
*/ |
|
1257 |
class EntityMetadataNodeRevisionAccessTestCase extends DrupalWebTestCase { |
|
1258 |
protected $node_revisions = array(); |
|
1259 |
protected $accounts = array(); |
|
1260 |
|
|
1261 |
// Map revision permission names to node revision access ops. |
|
1262 |
protected $map = array( |
|
1263 |
'view' => 'view revisions', |
|
1264 |
'update' => 'revert revisions', |
|
1265 |
'delete' => 'delete revisions', |
|
1266 |
); |
|
1267 |
|
|
1268 |
public static function getInfo() { |
|
1269 |
return array( |
|
1270 |
'name' => 'Entity Metadata Node Revision Access', |
|
1271 |
'description' => 'Tests user permissions for node revision operations.', |
|
1272 |
'group' => 'Entity API', |
|
1273 |
); |
|
1274 |
} |
|
1275 |
|
|
1276 |
function setUp() { |
|
1277 |
parent::setUp('entity', 'node'); |
|
1278 |
|
|
1279 |
// Create a node with several revisions. |
|
1280 |
$node = $this->drupalCreateNode(); |
|
1281 |
$this->node_revisions[] = $node; |
|
1282 |
|
|
1283 |
for ($i = 0; $i < 3; $i++) { |
|
1284 |
// Create a revision for the same nid and settings with a random log. |
|
1285 |
$revision = node_load($node->nid); |
|
1286 |
$revision->revision = 1; |
|
1287 |
$revision->log = $this->randomName(32); |
|
1288 |
node_save($revision); |
|
1289 |
$this->node_revisions[] = node_load($revision->nid); |
|
1290 |
} |
|
1291 |
|
|
1292 |
// Create three users, one with each revision permission. |
|
1293 |
foreach ($this->map as $op => $permission) { |
|
1294 |
// Create the user. |
|
1295 |
$account = $this->drupalCreateUser( |
|
1296 |
array( |
|
1297 |
'access content', |
|
1298 |
'edit any page content', |
|
1299 |
'delete any page content', |
|
1300 |
$permission, |
|
1301 |
) |
|
1302 |
); |
|
1303 |
$account->op = $op; |
|
1304 |
$this->accounts[] = $account; |
|
1305 |
} |
|
1306 |
|
|
1307 |
// Create an admin account (returns TRUE for all revision permissions). |
|
1308 |
$admin_account = $this->drupalCreateUser(array('access content', 'administer nodes')); |
|
1309 |
$admin_account->is_admin = TRUE; |
|
1310 |
$this->accounts['admin'] = $admin_account; |
|
1311 |
|
|
1312 |
// Create a normal account (returns FALSE for all revision permissions). |
|
1313 |
$normal_account = $this->drupalCreateUser(); |
|
1314 |
$normal_account->op = FALSE; |
|
1315 |
$this->accounts[] = $normal_account; |
|
1316 |
} |
|
1317 |
|
|
1318 |
/** |
|
1319 |
* Tests the entity_access() function for revisions. |
|
1320 |
*/ |
|
1321 |
function testNodeRevisionAccess() { |
|
1322 |
// $node_revisions[1] won't be the latest revision. |
|
1323 |
$revision = $this->node_revisions[1]; |
|
1324 |
|
|
1325 |
$parameters = array( |
|
1326 |
'op' => array_keys($this->map), |
|
1327 |
'account' => $this->accounts, |
|
1328 |
); |
|
1329 |
|
|
1330 |
$permutations = $this->generatePermutations($parameters); |
|
1331 |
$entity_type = 'node'; |
|
1332 |
foreach ($permutations as $case) { |
|
1333 |
if (!empty($case['account']->is_admin) || $case['op'] == $case['account']->op) { |
|
1334 |
$access = entity_access($case['op'], $entity_type, $revision, $case['account']); |
|
1335 |
$this->assertTrue($access, "{$this->map[$case['op']]} granted on $entity_type."); |
|
1336 |
} |
|
1337 |
else { |
|
1338 |
$access = entity_access($case['op'], $entity_type, $revision, $case['account']); |
|
1339 |
$this->assertFalse($access, "{$this->map[$case['op']]} NOT granted on $entity_type."); |
|
1340 |
} |
|
1341 |
} |
|
1342 |
} |
|
1343 |
} |
|
1344 |
|
|
1090 | 1345 |
/** |
1091 | 1346 |
* Tests provided entity property info of the core modules. |
1092 | 1347 |
*/ |
... | ... | |
1202 | 1457 |
*/ |
1203 | 1458 |
function testBookModule() { |
1204 | 1459 |
$title = 'Book 1'; |
1205 |
$node = $this->drupalCreateNode(array('title' => $title, 'type' => 'book')); |
|
1206 |
$node2 = $this->drupalCreateNode(array('type' => 'book', 'book' => array('bid' => $node->nid))); |
|
1460 |
$node = $this->drupalCreateNode(array('title' => $title, 'type' => 'book', 'book' => array('bid' => 'new'))); |
|
1461 |
$book = array('bid' => $node->nid, 'plid' => $node->book['mlid']); |
|
1462 |
$node2 = $this->drupalCreateNode(array('type' => 'book', 'book' => $book)); |
|
1207 | 1463 |
$node3 = $this->drupalCreateNode(array('type' => 'page')); |
1208 | 1464 |
|
1209 | 1465 |
// Test whether the properties work. |
1210 | 1466 |
$wrapper = entity_metadata_wrapper('node', $node2); |
1211 |
$this->assertEqual("Book 1", $wrapper->book->title->value(), "Book title returned."); |
|
1467 |
$this->assertEqual($title, $wrapper->book->title->value(), "Book title returned."); |
|
1468 |
$this->assertEqual(array($node->nid), $wrapper->book_ancestors->value(array('identifier' => TRUE)), "Book ancestors returned."); |
|
1212 | 1469 |
$this->assertEqual($node->nid, $wrapper->book->nid->value(), "Book id returned."); |
1213 | 1470 |
|
1214 | 1471 |
// Try using book properties for no book nodes. |
1215 | 1472 |
$wrapper = entity_metadata_wrapper('node', $node3); |
1216 | 1473 |
$this->assertException($wrapper, 'book'); |
1474 |
$this->assertException($wrapper, 'book_ancestors'); |
|
1217 | 1475 |
} |
1218 | 1476 |
|
1219 | 1477 |
/** |
... | ... | |
1222 | 1480 |
function testComments() { |
1223 | 1481 |
$title = 'Node 1'; |
1224 | 1482 |
$node = $this->drupalCreateNode(array('title' => $title, 'type' => 'page')); |
1225 |
$account = $this->drupalCreateUser();
|
|
1483 |
$author = $this->drupalCreateUser(array('access comments', 'post comments', 'edit own comments'));
|
|
1226 | 1484 |
$comment = (object)array( |
1227 | 1485 |
'subject' => 'topic', |
1228 | 1486 |
'nid' => $node->nid, |
1229 |
'uid' => $account->uid,
|
|
1487 |
'uid' => $author->uid,
|
|
1230 | 1488 |
'cid' => FALSE, |
1231 | 1489 |
'pid' => 0, |
1232 | 1490 |
'homepage' => '', |
... | ... | |
1242 | 1500 |
} |
1243 | 1501 |
} |
1244 | 1502 |
$this->assertEmpty($wrapper, 'parent'); |
1503 |
|
|
1504 |
// Test comment entity access. |
|
1505 |
$admin_user = $this->drupalCreateUser(array('access comments', 'administer comments')); |
|
1506 |
// Also grant access to view user accounts to test the comment author |
|
1507 |
// property. |
|
1508 |
$unprivileged_user = $this->drupalCreateUser(array('access comments', 'access user profiles')); |
|
1509 |
// Published comments can be viewed and edited by the author. |
|
1510 |
$this->assertTrue($wrapper->access('view', $author), 'Comment author is allowed to view the published comment.'); |
|
1511 |
$this->assertTrue($wrapper->access('edit', $author), 'Comment author is allowed to edit the published comment.'); |
|
1512 |
// We cannot use $wrapper->access('delete') here because it only understands |
|
1513 |
// view and edit. |
|
1514 |
$this->assertFalse(entity_access('delete', 'comment', $comment, $author), 'Comment author is not allowed to delete the published comment.'); |
|
1515 |
|
|
1516 |
// Administrators can do anything with published comments. |
|
1517 |
$this->assertTrue($wrapper->access('view', $admin_user), 'Comment administrator is allowed to view the published comment.'); |
|
1518 |
$this->assertTrue($wrapper->access('edit', $admin_user), 'Comment administrator is allowed to edit the published comment.'); |
|
1519 |
$this->assertTrue(entity_access('delete', 'comment', $comment, $admin_user), 'Comment administrator is allowed to delete the published comment.'); |
|
1520 |
|
|
1521 |
// Unpriviledged users can only view the published comment. |
|
1522 |
$this->assertTrue($wrapper->access('view', $unprivileged_user), 'Unprivileged user is allowed to view the published comment.'); |
|
1523 |
$this->assertFalse($wrapper->access('edit', $unprivileged_user), 'Unprivileged user is not allowed to edit the published comment.'); |
|
1524 |
$this->assertFalse(entity_access('delete', 'comment', $comment, $unprivileged_user), 'Unprivileged user is not allowed to delete the published comment.'); |
|
1525 |
|
|
1526 |
// Test property view access. |
|
1527 |
$view_access = array('name', 'homepage', 'subject', 'created', 'author', 'node', 'parent', 'url', 'edit_url'); |
|
1528 |
foreach ($view_access as $property_name) { |
|
1529 |
$this->assertTrue($wrapper->{$property_name}->access('view', $unprivileged_user), "Unpriviledged user can view the $property_name property."); |
|
1530 |
} |
|
1531 |
|
|
1532 |
$view_denied = array('hostname', 'mail', 'status'); |
|
1533 |
foreach ($view_denied as $property_name) { |
|
1534 |
$this->assertFalse($wrapper->{$property_name}->access('view', $unprivileged_user), "Unpriviledged user can not view the $property_name property."); |
|
1535 |
$this->assertTrue($wrapper->{$property_name}->access('view', $admin_user), "Admin user can view the $property_name property."); |
|
1536 |
} |
|
1537 |
|
|
1538 |
// The author is allowed to edit the comment subject if they have the |
|
1539 |
// 'edit own comments' permission. |
|
1540 |
$this->assertTrue($wrapper->subject->access('edit', $author), "Author can edit the subject property."); |
|
1541 |
$this->assertFalse($wrapper->subject->access('edit', $unprivileged_user), "Unpriviledged user cannot edit the subject property."); |
|
1542 |
$this->assertTrue($wrapper->subject->access('edit', $admin_user), "Admin user can edit the subject property."); |
|
1543 |
|
|
1544 |
$edit_denied = array('hostname', 'mail', 'status', 'name', 'homepage', 'created', 'parent', 'node', 'author'); |
|
1545 |
foreach ($edit_denied as $property_name) { |
|
1546 |
$this->assertFalse($wrapper->{$property_name}->access('edit', $author), "Author cannot edit the $property_name property."); |
|
1547 |
$this->assertTrue($wrapper->{$property_name}->access('edit', $admin_user), "Admin user can edit the $property_name property."); |
|
1548 |
} |
|
1549 |
|
|
1550 |
// Test access to unpublished comments. |
|
1551 |
$comment->status = COMMENT_NOT_PUBLISHED; |
|
1552 |
comment_save($comment); |
|
1553 |
|
|
1554 |
// Unpublished comments cannot be accessed by the author. |
|
1555 |
$this->assertFalse($wrapper->access('view', $author), 'Comment author is not allowed to view the unpublished comment.'); |
|
1556 |
$this->assertFalse($wrapper->access('edit', $author), 'Comment author is not allowed to edit the unpublished comment.'); |
|
1557 |
$this->assertFalse(entity_access('delete', 'comment', $comment, $author), 'Comment author is not allowed to delete the unpublished comment.'); |
|
1558 |
|
|
1559 |
// Administrators can do anything with unpublished comments. |
|
1560 |
$this->assertTrue($wrapper->access('view', $admin_user), 'Comment administrator is allowed to view the unpublished comment.'); |
|
1561 |
$this->assertTrue($wrapper->access('edit', $admin_user), 'Comment administrator is allowed to edit the unpublished comment.'); |
|
1562 |
$this->assertTrue(entity_access('delete', 'comment', $comment, $admin_user), 'Comment administrator is allowed to delete the unpublished comment.'); |
|
1563 |
|
|
1564 |
// Unpriviledged users cannot access unpublished comments. |
|
1565 |
$this->assertFalse($wrapper->access('view', $unprivileged_user), 'Unprivileged user is not allowed to view the unpublished comment.'); |
|
1566 |
$this->assertFalse($wrapper->access('edit', $unprivileged_user), 'Unprivileged user is not allowed to edit the unpublished comment.'); |
|
1567 |
$this->assertFalse(entity_access('delete', 'comment', $comment, $unprivileged_user), 'Unprivileged user is not allowed to delete the unpublished comment.'); |
|
1245 | 1568 |
} |
1246 | 1569 |
|
1247 | 1570 |
/** |
... | ... | |
1252 | 1575 |
$node = $this->drupalCreateNode(array('title' => $title, 'type' => 'page')); |
1253 | 1576 |
$wrapper = entity_metadata_wrapper('node', $node); |
1254 | 1577 |
foreach ($wrapper as $key => $value) { |
1255 |
if ($key != 'book' && $key != 'source' && $key != 'last_view') { |
|
1578 |
if ($key != 'book' && $key != 'book_ancestors' && $key != 'source' && $key != 'last_view') {
|
|
1256 | 1579 |
$this->assertValue($wrapper, $key); |
1257 | 1580 |
} |
1258 | 1581 |
} |
1259 | 1582 |
$this->assertException($wrapper, 'book'); |
1583 |
$this->assertException($wrapper, 'book_ancestors'); |
|
1260 | 1584 |
$this->assertEmpty($wrapper, 'source'); |
1261 | 1585 |
$this->assertException($wrapper->source, 'title'); |
1262 | 1586 |
$this->assertEmpty($wrapper, 'last_view'); |
1587 |
|
|
1588 |
// Test statistics module integration access. |
|
1589 |
$unpriviledged_user = $this->drupalCreateUser(array('access content')); |
|
1590 |
$this->assertTrue($wrapper->access('view', $unpriviledged_user), 'Unpriviledged user can view the node.'); |
|
1591 |
$this->assertFalse($wrapper->access('edit', $unpriviledged_user), 'Unpriviledged user can not edit the node.'); |
|
1592 |
$count_access_user = $this->drupalCreateUser(array('view post access counter')); |
|
1593 |
$admin_user = $this->drupalCreateUser(array('access content', 'view post access counter', 'access statistics')); |
|
1594 |
|
|
1595 |
$this->assertFalse($wrapper->views->access('view', $unpriviledged_user), "Unpriviledged user cannot view the statistics counter property."); |
|
1596 |
$this->assertTrue($wrapper->views->access('view', $count_access_user), "Count access user can view the statistics counter property."); |
|
1597 |
$this->assertTrue($wrapper->views->access('view', $admin_user), "Admin user can view the statistics counter property."); |
|
1598 |
|
|
1599 |
$admin_properties = array('day_views', 'last_view'); |
|
1600 |
foreach ($admin_properties as $property_name) { |
|
1601 |
$this->assertFalse($wrapper->{$property_name}->access('view', $unpriviledged_user), "Unpriviledged user cannot view the $property_name property."); |
|
1602 |
$this->assertFalse($wrapper->{$property_name}->access('view', $count_access_user), "Count access user cannot view the $property_name property."); |
|
1603 |
$this->assertTrue($wrapper->{$property_name}->access('view', $admin_user), "Admin user can view the $property_name property."); |
|
1604 |
} |
|
1263 | 1605 |
} |
1264 | 1606 |
|
1265 | 1607 |
/** |
... | ... | |
1354 | 1696 |
* Test all properties of a user. |
1355 | 1697 |
*/ |
1356 | 1698 |
function testUserProperties() { |
1357 |
$account = $this->drupalCreateUser(); |
|
1699 |
$account = $this->drupalCreateUser(array('access user profiles', 'change own username'));
|
|
1358 | 1700 |
$account->login = REQUEST_TIME; |
1359 | 1701 |
$account->access = REQUEST_TIME; |
1360 | 1702 |
$wrapper = entity_metadata_wrapper('user', $account); |
1361 | 1703 |
foreach ($wrapper as $key => $value) { |
1362 | 1704 |
$this->assertValue($wrapper, $key); |
1363 | 1705 |
} |
1706 |
|
|
1707 |
// Test property view access. |
|
1708 |
$unpriviledged_user = $this->drupalCreateUser(array('access user profiles')); |
|
1709 |
$admin_user = $this->drupalCreateUser(array('administer users')); |
|
1710 |
$this->assertTrue($wrapper->access('view', $unpriviledged_user), 'Unpriviledged account can view the user.'); |
|
1711 |
$this->assertFalse($wrapper->access('edit', $unpriviledged_user), 'Unpriviledged account can not edit the user.'); |
|
1712 |
|
|
1713 |
$view_access = array('name', 'url', 'edit_url', 'created'); |
|
1714 |
foreach ($view_access as $property_name) { |
|
1715 |
$this->assertTrue($wrapper->{$property_name}->access('view', $unpriviledged_user), "Unpriviledged user can view the $property_name property."); |
|
1716 |
} |
|
1717 |
|
|
1718 |
$view_denied = array('mail', 'last_access', 'last_login', 'roles', 'status', 'theme'); |
|
1719 |
foreach ($view_denied as $property_name) { |
|
1720 |
$this->assertFalse($wrapper->{$property_name}->access('view', $unpriviledged_user), "Unpriviledged user can not view the $property_name property."); |
|
1721 |
$this->assertTrue($wrapper->{$property_name}->access('view', $admin_user), "Admin user can view the $property_name property."); |
|
1722 |
} |
|
1723 |
|
|
1724 |
// Test property edit access. |
|
1725 |
$edit_own_allowed = array('name', 'mail'); |
|
1726 |
foreach ($edit_own_allowed as $property_name) { |
|
1727 |
$this->assertTrue($wrapper->{$property_name}->access('edit', $account), "Account owner can edit the $property_name property."); |
|
1728 |
} |
|
1729 |
|
|
1730 |
$this->assertTrue($wrapper->roles->access('view', $account), "Account owner can view their own roles."); |
|
1731 |
|
|
1732 |
$edit_denied = array('last_access', 'last_login', 'created', 'roles', 'status', 'theme'); |
|
1733 |
foreach ($edit_denied as $property_name) { |
|
1734 |
$this->assertFalse($wrapper->{$property_name}->access('edit', $account), "Account owner cannot edit the $property_name property."); |
|
1735 |
$this->assertTrue($wrapper->{$property_name}->access('edit', $admin_user), "Admin user can edit the $property_name property."); |
|
1736 |
} |
|
1364 | 1737 |
} |
1365 | 1738 |
|
1366 | 1739 |
/** |
htmltest/sites/all/modules/entity/entity_token.info | ||
---|---|---|
5 | 5 |
files[] = entity_token.module |
6 | 6 |
dependencies[] = entity |
7 | 7 |
|
8 |
; Information added by drupal.org packaging script on 2013-08-14
|
|
9 |
version = "7.x-1.2"
|
|
8 |
; Information added by Drupal.org packaging script on 2014-01-08
|
|
9 |
version = "7.x-1.3"
|
|
10 | 10 |
core = "7.x" |
11 | 11 |
project = "entity" |
12 |
datestamp = "1376493705"
|
|
12 |
datestamp = "1389210813"
|
|
13 | 13 |
|
htmltest/sites/all/modules/entity/includes/entity.property.inc | ||
---|---|---|
396 | 396 |
*/ |
397 | 397 |
function entity_property_verbatim_date_get($data, array $options, $name, $type, $info) { |
398 | 398 |
$name = isset($info['schema field']) ? $info['schema field'] : $name; |
399 |
return is_numeric($data[$name]) ? $data[$name] : strtotime($data[$name], REQUEST_TIME); |
|
399 |
if (is_array($data) || (is_object($data) && $data instanceof ArrayAccess)) { |
|
400 |
return is_numeric($data[$name]) ? $data[$name] : strtotime($data[$name], REQUEST_TIME); |
|
401 |
} |
|
402 |
elseif (is_object($data)) { |
|
403 |
return is_numeric($data->$name) ? $data->$name : strtotime($data->$name, REQUEST_TIME); |
|
404 |
} |
|
400 | 405 |
} |
401 | 406 |
|
402 | 407 |
/** |
... | ... | |
507 | 512 |
'label' => t('Text format'), |
508 | 513 |
'options list' => 'entity_metadata_field_text_formats', |
509 | 514 |
'getter callback' => 'entity_property_verbatim_get', |
515 |
'setter callback' => 'entity_property_verbatim_set', |
|
516 |
'setter permissions' => 'administer filters', |
|
510 | 517 |
), |
511 | 518 |
); |
512 | 519 |
} |
htmltest/sites/all/modules/entity/includes/entity.ui.inc | ||
---|---|---|
724 | 724 |
entity_ui_controller($form_state['entity_type'])->$method($form, $form_state); |
725 | 725 |
} |
726 | 726 |
|
727 |
/** |
|
728 |
* Gets the page title for the passed operation. |
|
729 |
*/ |
|
730 |
function entity_ui_get_page_title($op, $entity_type, $entity = NULL) { |
|
731 |
$label = entity_label($entity_type, $entity); |
|
732 |
switch ($op) { |
|
733 |
case 'view': |
|
734 |
return $label; |
|
735 |
case 'edit': |
|
736 |
return t('Edit @label', array('@label' => $label)); |
|
737 |
case 'clone': |
|
738 |
return t('Clone @label', array('@label' => $label)); |
|
739 |
case 'revert': |
|
740 |
return t('Revert @label', array('@label' => $label)); |
|
741 |
case 'delete': |
|
742 |
return t('Delete @label', array('@label' => $label)); |
|
743 |
case 'export': |
|
744 |
return t('Export @label', array('@label' => $label)); |
|
745 |
} |
|
746 |
if (isset($entity)) { |
|
747 |
list(, , $bundle) = entity_extract_ids($entity_type, $entity); |
|
748 |
} |
|
749 |
return entity_ui_get_action_title($op, $entity_type, $bundle); |
|
750 |
} |
|
751 |
|
|
752 | 727 |
/** |
753 | 728 |
* Gets the page/menu title for local action operations. |
754 | 729 |
* |
... | ... | |
820 | 795 |
return $output; |
821 | 796 |
} |
822 | 797 |
|
823 |
/** |
|
824 |
* Page callback for viewing an entity. |
|
825 |
* |
|
826 |
* @param Entity $entity |
|
827 |
* The entity to be rendered. |
|
828 |
* |
|
829 |
* @return array |
|
830 |
* A renderable array of the entity in full view mode. |
|
831 |
*/ |
|
832 |
function entity_ui_entity_page_view($entity) { |
|
833 |
return $entity->view('full', NULL, TRUE); |
|
834 |
} |
htmltest/sites/all/modules/entity/includes/entity.wrapper.inc | ||
---|---|---|
228 | 228 |
* If there is no access information for this property, TRUE is returned. |
229 | 229 |
*/ |
230 | 230 |
public function access($op, $account = NULL) { |
231 |
if (empty($this->info['parent']) && $this instanceof EntityDrupalWrapper) { |
|
232 |
// If there is no parent just incorporate entity based access. |
|
233 |
return $this->entityAccess($op == 'edit' ? 'update' : 'view', $account); |
|
234 |
} |
|
235 | 231 |
return !empty($this->info['parent']) ? $this->info['parent']->propertyAccess($this->info['name'], $op, $account) : TRUE; |
236 | 232 |
} |
237 | 233 |
|
... | ... | |
500 | 496 |
|
501 | 497 |
protected function propertyAccess($name, $op, $account = NULL) { |
502 | 498 |
$info = $this->getPropertyInfo($name); |
503 |
// If the property should be accessed and it's an entity, make sure the user |
|
504 |
// is allowed to view that entity. |
|
505 |
if ($op == 'view' && $this->$name instanceof EntityDrupalWrapper && !$this->$name->entityAccess($op, $account)) { |
|
506 |
return FALSE; |
|
507 |
} |
|
508 |
// If a property should be edited and this is an entity, make sure the user |
|
509 |
// has update access for this entity. |
|
499 |
|
|
500 |
// If a property should be edited and this is part of an entity, make sure |
|
501 |
// the user has update access for this entity. |
|
510 | 502 |
if ($op == 'edit') { |
511 | 503 |
$entity = $this; |
512 | 504 |
while (!($entity instanceof EntityDrupalWrapper) && isset($entity->info['parent'])) { |
... | ... | |
804 | 796 |
return $this->type; |
805 | 797 |
} |
806 | 798 |
|
799 |
/** |
|
800 |
* {@inheritdoc} |
|
801 |
* |
|
802 |
* Note that this method checks property access, but can be used for checking |
|
803 |
* entity access *only* if the wrapper is not a property (i.e. has no parent |
|
804 |
* wrapper). |
|
805 |
* To be safe, better use EntityDrupalWrapper::entityAccess() for checking |
|
806 |
* entity access. |
|
807 |
*/ |
|
808 |
public function access($op, $account = NULL) { |
|
809 |
if (!empty($this->info['parent'])) { |
|
810 |
// If this is a property, make sure the user is able to view the |
|
811 |
// currently referenced entity also. |
|
812 |
return $this->entityAccess('view', $account) && parent::access($op, $account); |
|
813 |
} |
|
814 |
else { |
|
815 |
// This is not a property, so fallback on entity access. |
|
816 |
return $this->entityAccess($op == 'edit' ? 'update' : 'view', $account); |
|
817 |
} |
|
818 |
} |
|
819 |
|
|
807 | 820 |
/** |
808 | 821 |
* Checks whether the operation $op is allowed on the entity. |
809 | 822 |
* |
htmltest/sites/all/modules/entity/modules/book.info.inc | ||
---|---|---|
20 | 20 |
'description' => t("If part of a book, the book to which this book page belongs."), |
21 | 21 |
'getter callback' => 'entity_metadata_book_get_properties', |
22 | 22 |
); |
23 |
} |
|
23 |
$properties['book_ancestors'] = array( |
|
24 |
'label' => t("Book ancestors"), |
|
25 |
'type' => 'list<node>', |
|
26 |
'computed' => TRUE, |
|
27 |
'description' => t("If part of a book, a list of all book pages upwards in the book hierarchy."), |
|
28 |
'getter callback' => 'entity_metadata_book_get_properties', |
|
29 |
); |
|
30 |
} |
htmltest/sites/all/modules/entity/modules/callbacks.inc | ||
---|---|---|
23 | 23 |
if (!isset($node->book['bid'])) { |
24 | 24 |
throw new EntityMetadataWrapperException('This node is no book page.'); |
25 | 25 |
} |
26 |
return $node->book['bid']; |
|
26 |
switch ($name) { |
|
27 |
case 'book': |
|
28 |
return $node->book['bid']; |
|
29 |
|
|
30 |
case 'book_ancestors': |
|
31 |
$ancestors = array(); |
|
32 |
while (!empty($node->book['plid'])) { |
|
33 |
$link = book_link_load($node->book['plid']); |
|
34 |
array_unshift($ancestors, $link['nid']); |
|
35 |
$node = node_load($link['nid']); |
|
36 |
} |
|
37 |
return $ancestors; |
|
38 |
} |
|
27 | 39 |
} |
28 | 40 |
|
29 | 41 |
/** |
... | ... | |
125 | 137 |
|
126 | 138 |
case 'edit_url': |
127 | 139 |
return url('node/' . $node->nid . '/edit', $options); |
140 |
|
|
141 |
case 'author': |
|
142 |
return !empty($node->uid) ? $node->uid : drupal_anonymous_user(); |
|
128 | 143 |
} |
129 | 144 |
} |
130 | 145 |
|
... | ... | |
191 | 206 |
} |
192 | 207 |
} |
193 | 208 |
|
209 |
/** |
|
210 |
* Access callback for restricted node statistics properties. |
|
211 |
*/ |
|
212 |
function entity_metadata_statistics_properties_access($op, $property, $entity = NULL, $account = NULL) { |
|
213 |
if ($property == 'views' && user_access('view post access counter', $account)) { |
|
214 |
return TRUE; |
|
215 |
} |
|
216 |
return user_access('access statistics', $account); |
|
217 |
} |
|
218 |
|
|
194 | 219 |
/** |
195 | 220 |
* Callback for getting site-wide properties. |
196 | 221 |
* @see entity_metadata_system_entity_info_alter() |
... | ... | |
612 | 637 |
* |
613 | 638 |
* This function does not implement hook_node_access(), thus it may not be |
614 | 639 |
* called entity_metadata_node_access(). |
640 |
* |
|
641 |
* @see entity_access() |
|
642 |
* |
|
643 |
* @param $op |
|
644 |
* The operation being performed. One of 'view', 'update', 'create' or |
|
645 |
* 'delete'. |
|
646 |
* @param $node |
|
647 |
* A node to check access for. Must be a node object. Must have nid, |
|
648 |
* except in the case of 'create' operations. |
|
649 |
* @param $account |
|
650 |
* The user to check for. Leave it to NULL to check for the global user. |
|
651 |
* |
|
652 |
* @throws EntityMalformedException |
|
653 |
* |
|
654 |
* @return boolean |
|
655 |
* TRUE if access is allowed, FALSE otherwise. |
|
615 | 656 |
*/ |
616 | 657 |
function entity_metadata_no_hook_node_access($op, $node = NULL, $account = NULL) { |
658 |
// First deal with the case where a $node is provided. |
|
617 | 659 |
if (isset($node)) { |
660 |
if ($op == 'create') { |
|
661 |
if (isset($node->type)) { |
|
662 |
return node_access($op, $node->type, $account); |
|
663 |
} |
|
664 |
else { |
|
665 |
throw new EntityMalformedException('Permission to create a node was requested but no node type was given.'); |
|
666 |
} |
|
667 |
} |
|
618 | 668 |
// If a non-default revision is given, incorporate revision access. |
619 | 669 |
$default_revision = node_load($node->nid); |
620 |
if ($node->vid != $default_revision->vid) { |
|
621 |
return _node_revision_access($node, $op); |
|
670 |
if ($node->vid !== $default_revision->vid) {
|
|
671 |
return _node_revision_access($node, $op, $account);
|
|
622 | 672 |
} |
623 | 673 |
else { |
624 | 674 |
return node_access($op, $node, $account); |
625 | 675 |
} |
626 | 676 |
} |
627 |
// Is access to all nodes allowed? |
|
677 |
// No node is provided. Check for access to all nodes. |
|
678 |
if (user_access('bypass node access', $account)) { |
|
679 |
return TRUE; |
|
680 |
} |
|
628 | 681 |
if (!user_access('access content', $account)) { |
629 | 682 |
return FALSE; |
630 | 683 |
} |
631 |
if (user_access('bypass node access', $account) || (!isset($account) && $op == 'view' && node_access_view_all_nodes())) {
|
|
684 |
if ($op == 'view' && node_access_view_all_nodes($account)) {
|
|
632 | 685 |
return TRUE; |
633 | 686 |
} |
634 | 687 |
return FALSE; |
... | ... | |
690 | 743 |
return FALSE; |
691 | 744 |
} |
692 | 745 |
} |
746 |
|
|
747 |
// Comment administrators are allowed to perform all operations on all |
|
748 |
// comments. |
|
749 |
if (user_access('administer comments', $account)) { |
|
750 |
return TRUE; |
|
751 |
} |
|
752 |
|
|
753 |
// Unpublished comments can never be accessed by non-admins. |
|
754 |
if (isset($entity->status) && $entity->status == COMMENT_NOT_PUBLISHED) { |
|
755 |
return FALSE; |
|
756 |
} |
|
757 |
|
|
693 | 758 |
if (isset($entity) && $op == 'update') { |
694 | 759 |
// Because 'comment_access' only checks the current user, we need to do our |
695 | 760 |
// own access checking if an account was specified. |
... | ... | |
697 | 762 |
return comment_access('edit', $entity); |
698 | 763 |
} |
699 | 764 |
else { |
700 |
return ($account->uid && $account->uid == $entity->uid && $entity->status == COMMENT_PUBLISHED && user_access('edit own comments', $account)) || user_access('administer comments', $account);
|
|
765 |
return $account->uid && $account->uid == $entity->uid && user_access('edit own comments', $account);
|
|
701 | 766 |
} |
702 | 767 |
} |
703 |
if (user_access('administer comments', $account) || user_access('access comments', $account) && $op == 'view') {
|
|
768 |
if (user_access('access comments', $account) && $op == 'view') { |
|
704 | 769 |
return TRUE; |
705 | 770 |
} |
706 | 771 |
return FALSE; |
707 | 772 |
} |
708 | 773 |
|
774 |
/** |
|
775 |
* Access callback for restricted comment properties. |
|
776 |
*/ |
|
777 |
function entity_metadata_comment_properties_access($op, $property, $entity = NULL, $account = NULL) { |
|
778 |
return user_access('administer comments', $account); |
|
779 |
} |
|
780 |
|
|
709 | 781 |
/** |
710 | 782 |
* Access callback for the taxonomy entities. |
711 | 783 |
*/ |
... | ... | |
912 | 984 |
/** |
913 | 985 |
* Callback to get the form of a vocabulary. |
914 | 986 |
*/ |
915 |
function entity_metadata_form_taxonomy_vocabulary($term) {
|
|
987 |
function entity_metadata_form_taxonomy_vocabulary($vocab) {
|
|
916 | 988 |
// Pre-populate the form-state with the right form include. |
917 |
$form_state['build_info']['args'] = array($term);
|
|
989 |
$form_state['build_info']['args'] = array($vocab);
|
|
918 | 990 |
form_load_include($form_state, 'inc', 'taxonomy', 'taxonomy.admin'); |
919 |
return drupal_build_form('taxonomy_form_term', $form_state);
|
|
991 |
return drupal_build_form('taxonomy_form_vocabulary', $form_state);
|
|
920 | 992 |
} |
921 | 993 |
|
922 | 994 |
/** |
... | ... | |
972 | 1044 |
$result = $query->execute(); |
973 | 1045 |
return !empty($result[$entity_type]) ? array_keys($result[$entity_type]) : array(); |
974 | 1046 |
} |
1047 |
|
|
1048 |
/** |
|
1049 |
* Implements entity_uri() callback for file entities. |
|
1050 |
*/ |
|
1051 |
function entity_metadata_uri_file($file) { |
|
1052 |
return array( |
|
1053 |
'path' => file_create_url($file->uri), |
|
1054 |
); |
|
1055 |
} |
htmltest/sites/all/modules/entity/modules/comment.info.inc | ||
---|---|---|
24 | 24 |
$properties['hostname'] = array( |
25 | 25 |
'label' => t("IP Address"), |
26 | 26 |
'description' => t("The IP address of the computer the comment was posted from."), |
27 |
'access callback' => 'entity_metadata_comment_properties_access', |
|
27 | 28 |
'schema field' => 'hostname', |
28 | 29 |
); |
29 | 30 |
$properties['name'] = array( |
... | ... | |
40 | 41 |
'description' => t("The email address left by the comment author."), |
41 | 42 |
'getter callback' => 'entity_metadata_comment_get_properties', |
42 | 43 |
'setter callback' => 'entity_property_verbatim_set', |
43 |
'setter permission' => 'administer comments', |
|
44 | 44 |
'validation callback' => 'valid_email_address', |
45 |
'access callback' => 'entity_metadata_comment_properties_access', |
|
45 | 46 |
'schema field' => 'mail', |
46 | 47 |
); |
47 | 48 |
$properties['homepage'] = array( |
... | ... | |
56 | 57 |
'label' => t("Subject"), |
57 | 58 |
'description' => t("The subject of the comment."), |
58 | 59 |
'setter callback' => 'entity_property_verbatim_set', |
59 |
'setter permission' => 'administer comments', |
|
60 | 60 |
'sanitize' => 'filter_xss', |
61 | 61 |
'required' => TRUE, |
62 | 62 |
'schema field' => 'subject', |
... | ... | |
88 | 88 |
'description' => t("The comment's parent, if comment threading is active."), |
89 | 89 |
'type' => 'comment', |
90 | 90 |
'getter callback' => 'entity_metadata_comment_get_properties', |
91 |
'setter permission' => 'administer comments', |
|
91 | 92 |
'schema field' => 'pid', |
92 | 93 |
); |
93 | 94 |
$properties['node'] = array( |
... | ... | |
116 | 117 |
// it is an integer, so we follow the schema definition. |
117 | 118 |
'type' => 'integer', |
118 | 119 |
'options list' => 'entity_metadata_status_options_list', |
119 |
'setter permission' => 'administer comments',
|
|
120 |
'access callback' => 'entity_metadata_comment_properties_access',
|
|
120 | 121 |
'schema field' => 'status', |
121 | 122 |
); |
122 | 123 |
return $info; |
htmltest/sites/all/modules/entity/modules/node.info.inc | ||
---|---|---|
118 | 118 |
'label' => t("Author"), |
119 | 119 |
'type' => 'user', |
120 | 120 |
'description' => t("The author of the node."), |
121 |
'getter callback' => 'entity_metadata_node_get_properties', |
|
121 | 122 |
'setter callback' => 'entity_property_verbatim_set', |
122 | 123 |
'setter permission' => 'administer nodes', |
123 | 124 |
'required' => TRUE, |
htmltest/sites/all/modules/entity/modules/statistics.info.inc | ||
---|---|---|
19 | 19 |
'type' => 'integer', |
20 | 20 |
'getter callback' => 'entity_metadata_statistics_node_get_properties', |
21 | 21 |
'computed' => TRUE, |
22 |
'access callback' => 'entity_metadata_statistics_properties_access', |
|
22 | 23 |
); |
23 | 24 |
$properties['day_views'] = array( |
24 | 25 |
'label' => t("Views today"), |
... | ... | |
26 | 27 |
'type' => 'integer', |
27 | 28 |
'getter callback' => 'entity_metadata_statistics_node_get_properties', |
28 | 29 |
'computed' => TRUE, |
30 |
'access callback' => 'entity_metadata_statistics_properties_access', |
|
29 | 31 |
); |
30 | 32 |
$properties['last_view'] = array( |
31 | 33 |
'label' => t("Last view"), |
... | ... | |
33 | 35 |
'type' => 'date', |
34 | 36 |
'getter callback' => 'entity_metadata_statistics_node_get_properties', |
35 | 37 |
'computed' => TRUE, |
38 |
'access callback' => 'entity_metadata_statistics_properties_access', |
|
36 | 39 |
); |
37 | 40 |
} |
htmltest/sites/all/modules/entity/modules/user.info.inc | ||
---|---|---|
59 | 59 |
'description' => t("The date the user last accessed the site."), |
60 | 60 |
'getter callback' => 'entity_metadata_user_get_properties', |
61 | 61 |
'type' => 'date', |
62 |
'access callback' => 'entity_metadata_user_properties_access', |
|
62 | 63 |
'schema field' => 'access', |
63 | 64 |
); |
64 | 65 |
$properties['last_login'] = array( |
... | ... | |
66 | 67 |
'description' => t("The date the user last logged in to the site."), |
67 | 68 |
'getter callback' => 'entity_metadata_user_get_properties', |
68 | 69 |
'type' => 'date', |
70 |
'access callback' => 'entity_metadata_user_properties_access', |
|
69 | 71 |
'schema field' => 'login', |
70 | 72 |
); |
71 | 73 |
$properties['created'] = array( |
... | ... | |
73 | 75 |
'description' => t("The date the user account was created."), |
74 | 76 |
'type' => 'date', |
75 | 77 |
'schema field' => 'created', |
78 |
'setter permission' => 'administer users', |
|
76 | 79 |
); |
77 | 80 |
$properties['roles'] = array( |
78 | 81 |
'label' => t("User roles"), |
... | ... | |
80 | 83 |
'type' => 'list<integer>', |
81 | 84 |
'getter callback' => 'entity_metadata_user_get_properties', |
82 | 85 |
'setter callback' => 'entity_metadata_user_set_properties', |
83 |
'setter permission' => 'administer users', |
|
84 | 86 |
'options list' => 'entity_metadata_user_roles', |
85 | 87 |
'access callback' => 'entity_metadata_user_properties_access', |
86 | 88 |
); |
... | ... | |
92 | 94 |
// it is an integer, so we follow the schema definition. |
93 | 95 |
'type' => 'integer', |
94 | 96 |
'options list' => 'entity_metadata_user_status_options_list', |
95 |
'setter permission' => 'administer users',
|
|
97 |
'access callback' => 'entity_metadata_user_properties_access',
|
|
96 | 98 |
'schema field' => 'status', |
97 | 99 |
); |
98 | 100 |
$properties['theme'] = array( |
htmltest/sites/all/modules/entity/tests/entity_feature.info | ||
---|---|---|
6 | 6 |
dependencies[] = entity_test |
7 | 7 |
hidden = TRUE |
8 | 8 |
|
9 |
; Information added by drupal.org packaging script on 2013-08-14
|
|
10 |
version = "7.x-1.2"
|
|
9 |
; Information added by Drupal.org packaging script on 2014-01-08
|
|
10 |
version = "7.x-1.3"
|
|
11 | 11 |
core = "7.x" |
12 | 12 |
project = "entity" |
13 |
datestamp = "1376493705"
|
|
13 |
datestamp = "1389210813"
|
|
14 | 14 |
|
htmltest/sites/all/modules/entity/tests/entity_test.info | ||
---|---|---|
7 | 7 |
dependencies[] = entity |
8 | 8 |
hidden = TRUE |
9 | 9 |
|
10 |
; Information added by drupal.org packaging script on 2013-08-14
|
|
11 |
version = "7.x-1.2"
|
|
10 |
; Information added by Drupal.org packaging script on 2014-01-08
|
|
11 |
version = "7.x-1.3"
|
|
12 | 12 |
core = "7.x" |
13 | 13 |
project = "entity" |
14 |
datestamp = "1376493705"
|
|
14 |
datestamp = "1389210813"
|
|
15 | 15 |
|
htmltest/sites/all/modules/entity/tests/entity_test.module | ||
---|---|---|
267 | 267 |
if (empty($node->entity)) { |
268 | 268 |
$node->entity = array('type' => 'user', 'id' => $node->uid); |
269 | 269 |
} |
270 |
|
|
270 | 271 |
// We have to return the entity wrapped. |
271 |
return entity_metadata_wrapper($node->entity['type'], $node->entity['id']); |
|
272 |
// Special handling for anonymous user. |
|
273 |
if ($node->entity['type'] === 'user' && empty($node->entity['id'])) { |
|
274 |
return entity_metadata_wrapper('user', drupal_anonymous_user()); |
|
275 |
} |
|
276 |
else { |
|
277 |
return entity_metadata_wrapper($node->entity['type'], $node->entity['id']); |
|
278 |
} |
|
272 | 279 |
} |
273 | 280 |
|
274 | 281 |
/** |
htmltest/sites/all/modules/entity/tests/entity_test_i18n.info | ||
---|---|---|
5 | 5 |
package = Multilingual - Internationalization |
6 | 6 |
core = 7.x |
7 | 7 |
hidden = TRUE |
8 |
; Information added by drupal.org packaging script on 2013-08-14
|
|
9 |
version = "7.x-1.2"
|
|
8 |
; Information added by Drupal.org packaging script on 2014-01-08
|
|
9 |
version = "7.x-1.3"
|
|
10 | 10 |
core = "7.x" |
11 | 11 |
project = "entity" |
12 |
datestamp = "1376493705"
|
|
12 |
datestamp = "1389210813"
|
|
13 | 13 |
|
htmltest/sites/all/modules/entity/views/handlers/entity_views_field_handler_helper.inc | ||
---|---|---|
157 | 157 |
} |
158 | 158 |
|
159 | 159 |
if (method_exists($handler->query, 'get_result_wrappers')) { |
160 |
list($handler->entity_type, $handler->wrappers) = $handler->query->get_result_wrappers($values, $handler->relationship, $handler->real_field);
|
|
160 |
list($handler->entity_type, $handler->wrappers) = $handler->query->get_result_wrappers($values, NULL, $handler->real_field);
|
|
161 | 161 |
} |
162 | 162 |
else { |
163 |
list($handler->entity_type, $entities) = $handler->query->get_result_entities($values, $handler->relationship, $handler->real_field);
|
|
163 |
list($handler->entity_type, $entities) = $handler->query->get_result_entities($values, NULL, $handler->real_field);
|
|
164 | 164 |
$handler->wrappers = array(); |
165 | 165 |
foreach ($entities as $id => $entity) { |
166 | 166 |
$handler->wrappers[$id] = entity_metadata_wrapper($handler->entity_type, $entity); |
... | ... | |
196 | 196 |
if ($handler->relationship) { |
197 | 197 |
$current_handler = $handler; |
198 | 198 |
$view = $current_handler->view; |
199 |
while (!empty($current_handler->relationship) && !empty($view->relationship[$current_handler->relationship])) { |
|
200 |
$current_handler = $view->relationship[$current_handler->relationship]; |
|
199 |
$relationships = array(); |
|
200 |
// Collect all relationships, keyed by alias. |
|
201 |
foreach ($view->relationship as $key => $relationship) { |
|
202 |
$key = $relationship->alias ? $relationship->alias : $key; |
|
203 |
$relationships[$key] = $relationship; |
|
204 |
} |
|
205 |
while (!empty($current_handler->relationship) && !empty($relationships[$current_handler->relationship])) { |
|
206 |
$current_handler = $relationships[$current_handler->relationship]; |
|
201 | 207 |
$return = $current_handler->real_field . ($return ? ":$return" : ''); |
202 | 208 |
} |
203 | 209 |
} |
htmltest/sites/all/modules/ldap/ldap_authentication/LdapAuthenticationConf.class.php | ||
---|---|---|
15 | 15 |
* |
16 | 16 |
* @var array |
17 | 17 |
* |
18 |
* @see LdapServer::sid()
|
|
18 |
* @see LdapServer->sid()
|
|
19 | 19 |
*/ |
20 | 20 |
public $sids = array(); |
21 | 21 |
|
... | ... | |
24 | 24 |
* |
25 | 25 |
* @var associative array of LdapServer objects keyed on sids |
26 | 26 |
* |
27 |
* @see LdapServer::sid
|
|
27 |
* @see LdapServer->sid()
|
|
28 | 28 |
* @see LdapServer |
29 | 29 |
*/ |
30 | 30 |
public $enabledAuthenticationServers = array(); |
... | ... | |
107 | 107 |
* @var int |
108 | 108 |
*/ |
109 | 109 |
public $emailUpdate = LDAP_AUTHENTICATION_EMAIL_UPDATE_ON_LDAP_CHANGE_DEFAULT; |
110 |
|
|
111 |
/** |
|
112 |
* Email default handling option |
|
113 |
* |
|
114 |
* This affects how email addresses that are empty are handled by |
|
115 |
* the authentication process. |
|
116 |
* |
|
117 |
* LDAP_AUTHENTICATION_EMAIL_TEMPLATE_NONE -- leaves the email empty |
|
118 |
* LDAP_AUTHENTICATION_EMAIL_TEMPLATE_IF_EMPTY (default) -- if the email is empty, it will be replaced |
|
119 |
* LDAP_AUTHENTICATION_EMAIL_TEMPLATE_ALWAYS -- always use the template |
|
120 |
* |
|
121 |
* @var int |
|
122 |
*/ |
|
123 |
public $emailTemplateHandling = LDAP_AUTHENTICATION_EMAIL_TEMPLATE_DEFAULT; |
|
124 |
|
|
125 |
/** |
|
126 |
* Email template. |
|
127 |
* |
|
128 |
* @var string |
|
129 |
*/ |
|
130 |
public $emailTemplate = LDAP_AUTHENTICATION_DEFAULT_TEMPLATE; |
|
131 |
|
|
132 |
/** |
|
133 |
* Whether or not to display a notification to the user on login, prompting |
|
134 |
* them to change their email. |
|
135 |
* |
|
136 |
* @var boolean |
|
137 |
*/ |
|
138 |
public $templateUsagePromptUser = LDAP_AUTHENTICATION_TEMPLATE_USAGE_PROMPT_USER_DEFAULT; |
|
139 |
|
|
140 |
/** |
|
141 |
* Whether or not to avoid updating the email address of the user if the |
|
142 |
* template was used to generate it. |
|
143 |
* |
|
144 |
* @var boolean |
|
145 |
*/ |
|
146 |
public $templateUsageNeverUpdate = LDAP_AUTHENTICATION_TEMPLATE_USAGE_NEVER_UPDATE_DEFAULT; |
|
147 |
|
|
148 |
/** |
|
149 |
* Whether or not to use the email template if there is a user with a different |
|
150 |
* login name but same email address in the system. |
|
151 |
* |
|
152 |
* @var boolean |
|
153 |
*/ |
|
154 |
public $templateUsageResolveConflict = LDAP_AUTHENTICATION_TEMPLATE_USAGE_RESOLVE_CONFLICT_DEFAULT; |
|
155 |
|
|
156 |
/** |
|
157 |
* A PCRE regular expression (minus the delimiter and flags) that will be used |
|
158 |
* if $templateUsagePromptUser is set to true to determine if the email |
|
159 |
* address is a fake one or not. |
|
160 |
* |
|
161 |
* By allowing this to be customized, we let the administrators handle older |
|
162 |
* patterns should they decide to change the existing one, as well as avoiding |
|
163 |
* the complexity of determining a proper regex from the template. |
|
164 |
* |
|
165 |
* @var string |
|
166 |
*/ |
|
167 |
public $templateUsagePromptRegex = LDAP_AUTHENTICATION_DEFAULT_TEMPLATE_REGEX; |
|
168 |
|
|
169 |
/** |
|
170 |
* Controls whether or not we should check on login if the email template was |
|
171 |
* used and redirect the user if needed. |
|
172 |
* |
|
173 |
* @var boolean |
|
174 |
*/ |
|
175 |
public $templateUsageRedirectOnLogin = LDAP_AUTHENTICATION_REDIRECT_ON_LOGIN_DEFAULT; |
|
176 |
|
|
110 | 177 |
|
111 | 178 |
|
112 | 179 |
/** |
... | ... | |
191 | 258 |
'ssoNotifyAuthentication', |
192 | 259 |
'ldapImplementation', |
193 | 260 |
'cookieExpire', |
261 |
'emailTemplate', |
|
262 |
'emailTemplateHandling', |
|
263 |
'templateUsagePromptUser', |
|
264 |
'templateUsageNeverUpdate', |
|
265 |
'templateUsageResolveConflict', |
|
266 |
'templateUsagePromptRegex', |
|
267 |
'templateUsageRedirectOnLogin', |
|
194 | 268 |
); |
195 | 269 |
|
196 | 270 |
public function hasEnabledAuthenticationServers() { |
htmltest/sites/all/modules/ldap/ldap_authentication/LdapAuthenticationConfAdmin.class.php | ||
---|---|---|
79 | 79 |
LDAP_AUTHENTICATION_EMAIL_UPDATE_ON_LDAP_CHANGE_ENABLE => t('Update stored email if LDAP email differs at login but don\'t notify user.'), |
80 | 80 |
LDAP_AUTHENTICATION_EMAIL_UPDATE_ON_LDAP_CHANGE_DISABLE => t('Don\'t update stored email if LDAP email differs at login.'), |
81 | 81 |
); |
82 |
$values['emailTemplateHandlingOptions'] = array( |
|
83 |
LDAP_AUTHENTICATION_EMAIL_TEMPLATE_NONE => t('Never use the template.'), |
|
84 |
LDAP_AUTHENTICATION_EMAIL_TEMPLATE_IF_EMPTY => t('Use the template if no email address was provided by the LDAP server.'), |
|
85 |
LDAP_AUTHENTICATION_EMAIL_TEMPLATE_ALWAYS => t('Always use the template.'), |
|
86 |
); |
|
82 | 87 |
|
83 | 88 |
|
84 | 89 |
/** |
... | ... | |
182 | 187 |
|
183 | 188 |
public $emailUpdateDefault = LDAP_AUTHENTICATION_EMAIL_UPDATE_ON_LDAP_CHANGE_ENABLE_NOTIFY; |
184 | 189 |
public $emailUpdateOptions; |
185 |
|
|
190 |
|
|
191 |
public $emailTemplateHandlingDefault = LDAP_AUTHENTICATION_EMAIL_TEMPLATE_DEFAULT; |
|
192 |
public $emailTemplateHandlingOptions; |
|
193 |
|
|
194 |
public $emailTemplateDefault = LDAP_AUTHENTICATION_DEFAULT_TEMPLATE; |
|
195 |
|
|
196 |
public $templateUsagePromptUserDefault = LDAP_AUTHENTICATION_TEMPLATE_USAGE_PROMPT_USER_DEFAULT; |
|
197 |
|
|
198 |
public $templateUsagePromptRegexDefault = LDAP_AUTHENTICATION_DEFAULT_TEMPLATE_REGEX; |
|
199 |
|
|
200 |
public $templateUsageNeverUpdateDefault = LDAP_AUTHENTICATION_TEMPLATE_USAGE_NEVER_UPDATE_DEFAULT; |
|
186 | 201 |
|
187 | 202 |
/** |
188 | 203 |
* 5. Single Sign-On / Seamless Sign-On |
... | ... | |
391 | 406 |
'#default_value' => $this->emailUpdate, |
392 | 407 |
'#options' => $this->emailUpdateOptions, |
393 | 408 |
); |
394 |
|
|
409 |
|
|
410 |
$form['email']['template'] = array( |
|
411 |
'#type' => 'fieldset', |
|
412 |
'#collapsible' => TRUE, |
|
413 |
'#title' => t('Email Templates'), |
|
414 |
); |
|
415 |
|
|
416 |
$form['email']['template']['emailTemplateHandling'] = array( |
|
417 |
'#type' => 'radios', |
|
418 |
'#title' => t('Email Template Handling'), |
|
419 |
'#required' => 1, |
|
420 |
'#default_value' => $this->emailTemplateHandling, |
|
421 |
'#options' => $this->emailTemplateHandlingOptions |
|
422 |
); |
|
423 |
|
|
424 |
$form['email']['template']['emailTemplate'] = array( |
|
425 |
'#type' => 'textfield', |
|
426 |
'#title' => t('Email Template'), |
|
427 |
'#required' => 0, |
|
428 |
'#default_value' => $this->emailTemplate, |
|
429 |
); |
|
430 |
|
|
431 |
$form['email']['template']['templateUsageResolveConflict'] = array( |
|
432 |
'#type' => 'checkbox', |
|
433 |
'#title' => t('If a Drupal account already exists with the same email, but different account name, use the email template instead of the LDAP email.'), |
|
434 |
'#default_value' => $this->templateUsageResolveConflict, |
|
435 |
); |
|
436 |
|
|
437 |
$form['email']['template']['templateUsageNeverUpdate'] = array( |
|
438 |
'#type' => 'checkbox', |
|
439 |
'#title' => t('Ignore the Email Update settings and never update the stored email if the template is used.'), |
|
440 |
'#default_value' => $this->templateUsageNeverUpdate, |
|
441 |
); |
|
442 |
|
|
443 |
$form['email']['prompts'] = array( |
|
444 |
'#type' => 'fieldset', |
|
445 |
'#collapsible' => TRUE, |
|
446 |
'#title' => t('User Email Prompt'), |
|
447 |
'#description' => t('These settings allow the user to fill in their email address after logging in if the template was used to generate their email address.'), |
|
448 |
); |
|
449 |
|
|
450 |
$form['email']['prompts']['templateUsagePromptUser'] = array( |
|
451 |
'#type' => 'checkbox', |
|
452 |
'#title' => t('Prompt user for email on every page load.'), |
|
453 |
'#default_value' => $this->templateUsagePromptUser, |
|
454 |
); |
|
455 |
|
|
456 |
$form['email']['prompts']['templateUsageRedirectOnLogin'] = array( |
|
457 |
'#type' => 'checkbox', |
|
458 |
'#title' => t('Redirect the user to the form after logging in.'), |
|
459 |
'#default_value' => $this->templateUsageRedirectOnLogin, |
|
460 |
); |
|
461 |
|
|
462 |
$form['email']['prompts']['templateUsagePromptRegex'] = array( |
|
463 |
'#type' => 'textfield', |
|
464 |
'#default_value' => $this->templateUsagePromptRegex, |
|
465 |
'#title' => t('Template Regex'), |
|
466 |
'#description' => t('This regex will be used to determine if the template was used to create an account.'), |
|
467 |
); |
|
468 |
|
|
395 | 469 |
|
396 | 470 |
$form['password'] = array( |
397 | 471 |
'#type' => 'fieldset', |
... | ... | |
559 | 633 |
$this->ssoNotifyAuthentication = ($values['ssoNotifyAuthentication']) ? (int)$values['ssoNotifyAuthentication'] : NULL; |
560 | 634 |
$this->cookieExpire = ($values['cookieExpire']) ? (int)$values['cookieExpire'] : NULL; |
561 | 635 |
$this->ldapImplementation = ($values['ldapImplementation']) ? (string)$values['ldapImplementation'] : NULL; |
636 |
$this->emailTemplateHandling = ($values['emailTemplateHandling']) ? (int) $values['emailTemplateHandling'] : NULL; |
|
637 |
$this->emailTemplate = ($values['emailTemplate']) ? $values['emailTemplate'] : ''; |
|
638 |
$this->templateUsagePromptUser = ($values['templateUsagePromptUser']) ? 1 : 0; |
|
639 |
$this->templateUsageResolveConflict = ($values['templateUsageResolveConflict']) ? 1 : 0; |
|
640 |
$this->templateUsagePromptRegex = ($values['templateUsagePromptRegex']) ? $values['templateUsagePromptRegex'] : ''; |
|
641 |
$this->templateUsageRedirectOnLogin = ($values['templateUsageRedirectOnLogin']) ? 1 : 0; |
|
642 |
$this->templateUsageNeverUpdate = ($values['templateUsageNeverUpdate']) ? 1 : 0; |
|
562 | 643 |
} |
563 | 644 |
|
564 | 645 |
public function drupalFormSubmit($values) { |
htmltest/sites/all/modules/ldap/ldap_authentication/ldap_authentication.inc | ||
---|---|---|
60 | 60 |
if (isset($auth_conf->loginUIPasswordTxt)) { |
61 | 61 |
$form['pass']['#description'] = t($auth_conf->loginUIPasswordTxt); |
62 | 62 |
} |
63 |
if ($auth_conf->templateUsageRedirectOnLogin) { |
|
64 |
$form['#submit'][] = 'ldap_authentication_check_for_email_template'; |
|
65 |
} |
|
63 | 66 |
} |
64 | 67 |
} |
65 | 68 |
|
... | ... | |
115 | 118 |
} |
116 | 119 |
} |
117 | 120 |
|
121 |
/** |
|
122 |
* Replaces the email address in $ldap_user with one from the template in |
|
123 |
* $auth_conf. |
|
124 |
* |
|
125 |
* @param array $ldap_user |
|
126 |
* LDAP user entry |
|
127 |
* @param LdapAuthenticationConf $auth_conf |
|
128 |
* LDAP authentication configuration class. |
|
129 |
*/ |
|
130 |
function _ldap_authentication_replace_user_email(&$ldap_user, $auth_conf, $tokens) { |
|
131 |
// fallback template in case one was not specified. |
|
132 |
$template = '@username@localhost'; |
|
133 |
if (!empty($auth_conf->emailTemplate)) { |
|
134 |
$template = $auth_conf->emailTemplate; |
|
135 |
} |
|
136 |
$ldap_user['mail'] = format_string($template, $tokens); |
|
137 |
} |
|
118 | 138 |
|
119 | 139 |
/** |
120 | 140 |
* user form validation will take care of username, pwd fields |
... | ... | |
242 | 262 |
} |
243 | 263 |
$watchdog_tokens['%drupal_accountname'] = $drupal_accountname; |
244 | 264 |
|
265 |
// @todo maybe we can add more tokens? |
|
266 |
$email_template_tokens = array( |
|
267 |
'@username' => $drupal_accountname, |
|
268 |
); |
|
269 |
|
|
270 |
$email_template_used = FALSE; |
|
271 |
|
|
272 |
/** |
|
273 |
* Ensures that we respect the email template handling settings. |
|
274 |
*/ |
|
275 |
if (!empty($auth_conf->emailTemplate)) { |
|
276 |
switch ($auth_conf->emailTemplateHandling) { |
|
277 |
case LDAP_AUTHENTICATION_EMAIL_TEMPLATE_IF_EMPTY: |
|
278 |
if (!empty($ldap_user['mail'])) { |
|
279 |
break; |
|
280 |
} |
|
281 |
// deliberate fallthrough |
|
282 |
case LDAP_AUTHENTICATION_EMAIL_TEMPLATE_ALWAYS: |
Formats disponibles : Unified diff
Weekly update of contrib modules