You are here

function fb_autopost_entity_rules_action_info in Facebook Autopost 7

Implements hook_rules_action_info().

File

fb_autopost_entity/fb_autopost_entity.rules.inc, line 11
Rules integration.

Code

function fb_autopost_entity_rules_action_info() {

  // TODO: Implement access control.
  $actions['publish_to_facebook'] = array(
    'label' => t('Publish to Facebook page'),
    'group' => t('Facebook Autopost'),
    'parameter' => array(
      'publication' => array(
        'type' => 'facebook_publication',
        'label' => t('Facebook publication'),
      ),
      'pages' => array(
        'type' => 'text',
        'label' => t('Facebook pages'),
        'options list' => 'fb_autopost_entity_available_facebook_pages',
        'access callback' => 'can_administer_facebook_publications',
      ),
    ),
    'base' => 'rules_action_publish_to_facebook',
    'provides' => array(
      'facebook_publication_id' => array(
        'type' => 'text',
        'label' => t('Facebook publication returned ID'),
      ),
    ),
  );
  $actions['publish_to_facebook_timeline'] = $actions['publish_to_facebook'];
  $actions['publish_to_facebook_timeline']['label'] = t("Publish to Facebook user's timeline");
  $actions['publish_to_facebook_timeline']['base'] = 'rules_action_publish_to_facebook_timeline';
  unset($actions['publish_to_facebook_timeline']['parameter']['pages']);

  // Add privacy form to timeline publish.
  $actions['publish_to_facebook_timeline']['parameter']['privacy'] = array(
    'type' => 'text',
    'label' => t('Privacy settings'),
    'options list' => 'fb_autopost_entity_available_privacy_values',
    'access callback' => 'can_administer_facebook_publications',
  );
  $actions['publish_to_facebook_timeline']['parameter']['retry'] = array(
    'type' => 'boolean',
    'label' => t('Retry publication'),
    'description' => t('Users without a valid token to publish in the moment will be redirected to Facebook to authorize and taken back to finish the Facebook publication.'),
    'default value' => TRUE,
    'access callback' => 'can_administer_facebook_publications',
  );
  $actions['delete_from_facebook'] = array(
    'label' => t('Delete from Facebook'),
    'group' => t('Facebook Autopost'),
    'parameter' => array(
      'publication_id' => array(
        'type' => 'facebook_publication',
        'label' => t('Target Facebook publication entity'),
        'description' => t('The ID returned from Facebook when creating the publication. Typically stored in the facebook_id property of your FacebookPublicationEntity.'),
      ),
    ),
    'base' => 'rules_action_delete_from_facebook',
  );
  $actions['edit_in_facebook'] = array(
    'label' => t('Update in Facebook'),
    'group' => t('Facebook Autopost'),
    'parameter' => array(
      'publication_id' => array(
        'type' => 'facebook_publication',
        'label' => t('Target Facebook publication entity'),
        'description' => t('The publication entity you want to edit. The ID returned from Facebook when creating the publication must be present on the entity for this action to work'),
      ),
      'privacy' => array(
        'type' => 'text',
        'label' => t('Privacy settings'),
        'options list' => 'fb_autopost_entity_available_privacy_values',
        'access callback' => 'can_administer_facebook_publications',
        'description' => 'Privacy only applies for publications on timelines',
      ),
      'retry' => array(
        'type' => 'boolean',
        'label' => t('Retry publication'),
        'description' => t('Users without a valid token to publish in the moment will be redirected to Facebook to authorize and taken back to finish the Facebook publication.'),
        'default value' => TRUE,
        'access callback' => 'can_administer_facebook_publications',
      ),
      'destination' => array(
        'type' => 'text',
        'label' => t('Facebook destinations'),
        'options list' => 'available_facebook_destinations',
        'access callback' => 'can_administer_facebook_publications',
        'description' => t('The destination must match the original destination the publication was first published.'),
      ),
    ),
    'base' => 'rules_action_edit_in_facebook',
    'provides' => array(
      'facebook_publication_id' => array(
        'type' => 'text',
        'label' => t('Facebook publication returned ID'),
      ),
    ),
  );
  return $actions;
}