| 1 |
<?php
|
| 2 |
// $Id$
|
| 3 |
|
| 4 |
/**
|
| 5 |
@file
|
| 6 |
* Includes a class that extends the Flag module for Facebook-style Statuses.
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Adds a new flag type.
|
| 11 |
*/
|
| 12 |
class facebook_status_flag extends flag_flag {
|
| 13 |
function _load_content($content_id) {
|
| 14 |
return is_numeric($content_id) ? facebook_status_load($content_id) : NULL;
|
| 15 |
}
|
| 16 |
function applies_to_content_object($status) {
|
| 17 |
//Check for status_time == 0 so we don't flag blank statuses.
|
| 18 |
if ($status && $status->status_time) {
|
| 19 |
return TRUE;
|
| 20 |
}
|
| 21 |
return FALSE;
|
| 22 |
}
|
| 23 |
function get_content_id($status) {
|
| 24 |
return $status->sid;
|
| 25 |
}
|
| 26 |
function get_labels_token_types() {
|
| 27 |
return array('facebook_status');
|
| 28 |
}
|
| 29 |
function get_views_info() {
|
| 30 |
return array(
|
| 31 |
'views table' => 'facebook_status',
|
| 32 |
'join field' => 'uid',
|
| 33 |
'title field' => 'status',
|
| 34 |
'title' => t('Facebook-style Status'),
|
| 35 |
'help' => t('Display information about the flag set on a status.'),
|
| 36 |
);
|
| 37 |
}
|
| 38 |
function applies_to_content_id_array($content_ids) {
|
| 39 |
foreach ($content_ids as $content_id) {
|
| 40 |
$passed[$content_id] = TRUE;
|
| 41 |
}
|
| 42 |
return $passed;
|
| 43 |
}
|
| 44 |
function get_relevant_action_objects($content_id) {
|
| 45 |
return array(
|
| 46 |
'facebook_status' => $this->fetch_content($content_id),
|
| 47 |
);
|
| 48 |
}
|
| 49 |
function replace_tokens($label, $contexts, $content_id) {
|
| 50 |
if ($content_id && ($status = $this->fetch_content($content_id))) {
|
| 51 |
$contexts['facebook_status'] = $status;
|
| 52 |
}
|
| 53 |
return parent::replace_tokens($label, $contexts, $content_id);
|
| 54 |
}
|
| 55 |
function get_flag_action($content_id) {
|
| 56 |
$flag_action = parent::get_flag_action($content_id);
|
| 57 |
$status = $this->fetch_content($content_id);
|
| 58 |
$flag_action->content_title = $status->status;
|
| 59 |
$flag_action->content_url = _flag_url('user/'. $status->uid);
|
| 60 |
return $flag_action;
|
| 61 |
}
|
| 62 |
function rules_get_event_arguments_definition() {
|
| 63 |
return array(
|
| 64 |
'account' => array(
|
| 65 |
'type' => 'facebook_status',
|
| 66 |
'label' => t('Flagged status'),
|
| 67 |
'handler' => 'flag_rules_get_event_argument',
|
| 68 |
),
|
| 69 |
);
|
| 70 |
}
|
| 71 |
function rules_get_element_argument_definition() {
|
| 72 |
return array('type' => 'facebook_status', 'label' => t('Flagged status'));
|
| 73 |
}
|
| 74 |
}
|