| 57 |
|
|
| 58 |
// Check the schema to see if we're using OG 1.x or 2.x |
// Check the schema to see if we're using OG 1.x or 2.x |
| 59 |
$schema = drupal_get_schema('og_ancestry'); |
$schema = drupal_get_schema('og_ancestry'); |
| 60 |
if(isset($schema['fields']['is_public'])) { |
if (isset($schema['fields']['is_public'])) { |
| 61 |
// OG 1.x |
// OG 1.x |
| 62 |
db_query("UPDATE {og_ancestry} og INNER JOIN {node} n ON og.nid = n.nid |
db_query("UPDATE {og_ancestry} |
| 63 |
SET is_public = %d WHERE og.group_nid = %d |
SET is_public = %d |
| 64 |
AND n.type = '%s'", $is_public, $this->group->nid, $type); |
WHERE group_nid = %d |
| 65 |
|
AND nid IN ( |
| 66 |
|
SELECT nid |
| 67 |
|
FROM {node} |
| 68 |
|
WHERE type = '%s' |
| 69 |
|
)", $is_public, $this->group->nid, $type); |
| 70 |
} |
} |
| 71 |
else { |
else { |
| 72 |
// OG 2.x |
// OG 2.x |
| 73 |
db_query("UPDATE {og_access_post} og_p |
db_query("UPDATE {og_access_post} |
| 74 |
INNER JOIN {og_ancestry} og_a ON og_p.nid = og_a.nid |
SET og_public = %d |
| 75 |
INNER JOIN {node} n ON og_p.nid = n.nid |
WHERE nid IN ( |
| 76 |
SET og_public = %d WHERE og_a.group_nid = %d |
SELECT og_a.nid |
| 77 |
AND n.type = '%s'", $is_public, $this->group->nid, $type); |
FROM {og_ancestry} og_a |
| 78 |
|
JOIN {node} n ON og_a.nid = n.nid |
| 79 |
|
WHERE og_a.group_nid = %d |
| 80 |
|
AND n.type = '%s' |
| 81 |
|
)", $is_public, $this->group->nid, $type); |
| 82 |
} |
} |
| 83 |
} |
} |
| 84 |
} |
} |
| 1055 |
function _spaces_enforce_feature($gid, &$node) { |
function _spaces_enforce_feature($gid, &$node) { |
| 1056 |
$map = spaces_features_map('node'); |
$map = spaces_features_map('node'); |
| 1057 |
$space = spaces_load('og', $gid); |
$space = spaces_load('og', $gid); |
| 1058 |
$feature_name = $map[$node->type]; |
if ($space) { |
| 1059 |
if ($space && $space->feature_access($feature_name)) { |
if (isset($map[$node->type])) { |
| 1060 |
$privacy = $space->features[$feature_name]; |
$privacy = $space->features[$map[$node->type]]; |
| 1061 |
|
} |
| 1062 |
|
// Use reasonable defaults for types that are not included in a feature. |
| 1063 |
|
else { |
| 1064 |
|
$privacy = $space->group->og_private ? SPACES_OG_PRIVATE : SPACES_OG_PUBLIC; |
| 1065 |
|
} |
| 1066 |
switch ($privacy) { |
switch ($privacy) { |
| 1067 |
case SPACES_OG_PRIVATE: |
case SPACES_OG_PRIVATE: |
| 1068 |
$node->og_public = OG_VISIBLE_GROUPONLY; |
$node->og_public = OG_VISIBLE_GROUPONLY; |
| 1083 |
function _spaces_og_group_options($type, $uid = 0) { |
function _spaces_og_group_options($type, $uid = 0) { |
| 1084 |
$types = spaces_features_map('node'); |
$types = spaces_features_map('node'); |
| 1085 |
$group_options = array(); |
$group_options = array(); |
| 1086 |
$args = array($types[$type], 0); |
|
| 1087 |
|
$where = $join = ''; |
| 1088 |
|
$args = array(); |
| 1089 |
|
|
| 1090 |
|
// Only join to features table if this node is part of a feature. |
| 1091 |
|
if (isset($types[$type])) { |
| 1092 |
|
$join .= " JOIN {spaces_features} sf ON sf.sid = og.nid"; |
| 1093 |
|
$where .= " AND sf.id = '%s' AND sf.value != '%s'"; |
| 1094 |
|
$args = array($types[$type], 0); |
| 1095 |
|
} |
| 1096 |
if ($uid) { |
if ($uid) { |
| 1097 |
$join = "JOIN {og_uid} ogu ON ogu.nid = og.nid"; |
$join .= " JOIN {og_uid} ogu ON ogu.nid = og.nid"; |
| 1098 |
$where = "AND ogu.uid = %d AND ogu.is_active >= 1"; |
$where .= " AND ogu.uid = %d AND ogu.is_active >= 1"; |
| 1099 |
$args[] = $uid; |
$args[] = $uid; |
| 1100 |
} |
} |
| 1101 |
$result = db_query( |
$result = db_query( |
| 1102 |
"SELECT og.nid, n.title |
"SELECT og.nid, n.title |
| 1103 |
FROM {og} og |
FROM {og} og |
| 1104 |
JOIN {node} n ON og.nid = n.nid |
JOIN {node} n ON og.nid = n.nid |
|
JOIN {spaces_features} sf ON sf.sid = og.nid |
|
| 1105 |
$join |
$join |
| 1106 |
WHERE n.status = 1 |
WHERE n.status = 1 |
|
AND sf.id = '%s' |
|
|
AND sf.value != '%s' |
|
| 1107 |
$where |
$where |
| 1108 |
ORDER BY n.title ASC", |
ORDER BY n.title ASC", |
| 1109 |
$args); |
$args); |