Пример #1
0
 /**
  * Helper function to load the node object.
  */
 protected function load()
 {
     if (!$this->groups) {
         $this->groups = og_get_node_groups($this->object);
     }
     $this->loaded = true;
     return $this->groups;
 }
Пример #2
0
function dewey_node_submitted($node)
{
    // Generate group's string.
    $groups = og_get_node_groups($node);
    $group_str = "";
    foreach ($groups as $gid => $title) {
        $group_str .= l($title, "node/" . $gid, array('purl' => array('disabled' => TRUE))) . ", ";
    }
    // Generate timestamp. If posted < 48 hours, use x ago sytax.
    // Else use regular date.
    if (time() - $node->created < 172800) {
        $time = "about " . format_interval(time() - $node->created, 1) . " ago";
    } else {
        $time = "on " . format_date($node->created, 'custom', "j M Y");
    }
    $group_str = trim($group_str, ", ");
    return t('In !group_name by !username <span class="date">!datetime</span> &bull; @replies &bull; !follow', array('!group_name' => $group_str, '!username' => theme('username', $node), '!datetime' => $time, '@replies' => format_plural($node->comment_count, '1 Reply', '@count Replies'), '!follow' => flag_create_link('follow_node', $node->nid)));
}
Пример #3
0
/**
 * Constructs node options to be displayed in the node subscriptions controls.
 *
 * This hook is called by subscriptions_ui module to retrieve parameters for
 * node form (a.k.a subscriptions controls). Subscriptions_OG module provides a
 * convenient function to construct a valid array structure, it is
 * _subscriptions_append_node_option().
 *
 * @param $account
 *   User account to handle permissions if needed.
 * @param $node
 *   A valid node object which let identify the kind of parameters to return.
 *
 * @return
 *   Array structure of node form options.
 *
 * @ingroup form
 *
 * @see _subscriptions_append_node_option()
 */
function _hook_node_options($account, $node)
{
    $options = array();
    $omits = variable_get('subscriptions_omitted_og', array());
    if (!isset($node->og_description)) {
        // Organic Groups node
        $_node_groups = og_get_node_groups($node);
        if (count($_node_groups)) {
            // Fetch group nodes
            $_query = "\n  SELECT\n    *\n  FROM\n    {node} n\n  WHERE\n    nid IN(" . str_repeat("%d,", count($_node_groups) - 1) . "%d)\n      ";
            $_rs = call_user_func_array('db_query', array_merge(array($_query), array_keys($_node_groups)));
            $_groups_types = array();
            while ($_group = db_fetch_object($_rs)) {
                $_groups_types[$_group->nid] = $_group->type;
            }
            foreach ($_node_groups as $_group_nid => $_label) {
                if (!in_array($_groups_types[$_group_nid], $omits)) {
                    _module_append_node_option($options, t('To group: ') . $_label, $_group_nid);
                }
            }
        }
    } else {
        if (!in_array($node->type, $omits)) {
            // Organic Groups "group" node
            _module_append_node_option($options, t('To this group'), $node->nid);
        }
    }
    // It allows our options to be displayed at the very first of node form.
    $options['group_nid']['weight'] = -5;
    return $options;
}