Skip to content

Instantly share code, notes, and snippets.

@chrisns
Created September 26, 2011 13:59
Show Gist options
  • Save chrisns/1242295 to your computer and use it in GitHub Desktop.
Save chrisns/1242295 to your computer and use it in GitHub Desktop.
diff U domain_rules.rules.inc domain_rules.rules.inc
--- domain_rules.rules.inc Mon Jan 19 22:26:36 1970
+++ domain_rules.rules.inc Mon Jan 19 22:26:36 1970
@@ -40,0 +41,11 @@
+ 'rules_action_remove_node_domain' => array(
+ 'label' => t('Remove domain from a node'),
+ 'module' => 'Domain',
+ 'arguments' => array(
+ 'node' => array(
+ 'type' => 'node',
+ 'label' => t('Content'),
+ ),
+ ),
+ 'eval input' => array('subdomain'),
+ ),
@@ -144,0 +156,20 @@
+}
+
+function rules_action_remove_node_domain($node, $settings) {
+
+ $domain = domain_lookup(NULL, $settings['subdomain'], TRUE);
+
+ if ($domain['domain_id']) {
+
+ $domain_id = $domain['domain_id'];
+ $nid =$node->nid ;
+
+ // db_query("DELETE FROM {domain_access} WHERE gid ='%d' AND nid='%d'", $domain_id,$nid );
+ db_query("DELETE FROM {domain_access} WHERE gid = '" . mysql_real_escape_string($domain_id) . "' AND nid = '" . mysql_real_escape_string($nid) . "'");
+
+ drupal_set_message(t('Done'), 'error');
+ }
+ else {
+ drupal_set_message(t('Failed cant publish it'), 'error');
+ }
+ // return array('node' => $node);
diff U domain_rules.rules_forms.inc domain_rules.rules_forms.inc
--- domain_rules.rules_forms.inc Mon Jan 19 22:26:36 1970
+++ domain_rules.rules_forms.inc Mon Jan 19 22:26:36 1970
@@ -87,0 +88,10 @@
+function rules_action_remove_node_domain_form($settings = array(), &$form) {
+
+ $form['settings']['subdomain'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Domain address'),
+ '#default_value' => $settings['subdomain'],
+ '#description' => t("The domain address"),
+ );
+}
+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment