| 1 |
<?php |
<?php |
| 2 |
// $Id: domain_source.module,v 1.3.2.6 2009/05/31 18:26:44 agentken Exp $ |
// $Id: domain_source.module,v 1.3.2.7 2009/10/15 13:57:53 agentken Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @defgroup domain_source Domain Source: editor-defined links. |
* @defgroup domain_source Domain Source: editor-defined links. |
| 44 |
// Is this node assigned to a source that the user can control? |
// Is this node assigned to a source that the user can control? |
| 45 |
$source = $form['#node']->domain_source; |
$source = $form['#node']->domain_source; |
| 46 |
if (isset($source)) { |
if (isset($source)) { |
| 47 |
if ($user->domain_user[$domain['domain_id']] == $source) { |
if ($user->domain_user[$source] == $source) { |
| 48 |
$show = TRUE; |
$show = TRUE; |
| 49 |
} |
} |
| 50 |
else { |
else { |
| 102 |
function domain_source_nodeapi(&$node, $op, $a3, $a4) { |
function domain_source_nodeapi(&$node, $op, $a3, $a4) { |
| 103 |
switch ($op) { |
switch ($op) { |
| 104 |
case 'validate': |
case 'validate': |
| 105 |
|
// If not set, we ignore. |
| 106 |
|
if (!isset($node->domain_source)) { |
| 107 |
|
return; |
| 108 |
|
} |
| 109 |
// Cast the key from zero to -1 to match the data coming from the input. |
// Cast the key from zero to -1 to match the data coming from the input. |
| 110 |
($node->domain_source == 0) ? $key = -1 : $key = $node->domain_source; |
($node->domain_source == 0) ? $key = -1 : $key = $node->domain_source; |
| 111 |
|
// Check the domain and domains_raw variables to set up the allowed source list. |
| 112 |
|
$allowed = array(); |
| 113 |
|
if (!empty($node->domains) && is_array($node->domains)) { |
| 114 |
|
$allowed = $node->domains; |
| 115 |
|
} |
| 116 |
|
if (!empty($node->domains_raw) && is_array($node->domains_raw)) { |
| 117 |
|
$allowed = array_merge($allowed, $node->domains_raw); |
| 118 |
|
} |
| 119 |
if ($node->domain_site && $key == -1) { |
if ($node->domain_site && $key == -1) { |
| 120 |
// This case is acceptable, so we let it pass. |
// This case is acceptable, so we let it pass. |
| 121 |
// I find this code easier to read than a compound IF statement. |
// I find this code easier to read than a compound IF statement. |
| 122 |
} |
} |
| 123 |
// Here we account for both the 'domains_raw' and 'domains' options. |
// Here we account for both the 'domains_raw' and 'domains' options. |
| 124 |
// If selected, these clauses will not be zero. |
else if (!in_array($key, $allowed)) { |
|
else if ((!empty($node->domains) && !$node->domains[$key]) || (!empty($node->domains_raw) && !in_array($key, $node->domains_raw))) { |
|
| 125 |
form_set_error('domain_source', t('The source affiliate must be selected as a publishing option.')); |
form_set_error('domain_source', t('The source affiliate must be selected as a publishing option.')); |
| 126 |
} |
} |
| 127 |
break; |
break; |