You are here

function fasttoggle_comment_fasttoggle_available_links in Fasttoggle 7

Implements hook_fasttoggle_available_links().

File

module/fasttoggle_comment/fasttoggle_comment.module, line 96

Code

function fasttoggle_comment_fasttoggle_available_links($type = NULL, $obj = NULL) {
  $result = array();
  if (is_null($type) || $type == "node") {
    $result['node'] = array(
      'fields' => array(
        'status' => array(
          'instances' => array(
            'comment' => array(
              'description' => t('Topic opened/closed <small>(users are allowed/disallowed to post comments)</small>'),
              'access' => array(
                'fasttoggle_comment_access_status',
              ),
              'labels' => array(
                FASTTOGGLE_LABEL_ACTION => array(
                  0 => t('lock comments'),
                  1 => t('unlock comments'),
                  2 => t('hide comments'),
                ),
                FASTTOGGLE_LABEL_STATUS => array(
                  0 => t('comments disabled'),
                  1 => t('comments read only'),
                  2 => t('comments read/write'),
                ),
              ),
            ),
          ),
        ),
      ),
    );
    if (variable_get('fasttoggle_comments_rw_only', FALSE)) {
      $result['node']['fields']['status']['instances']['comment']['allowed_values'] = array(
        1,
        2,
      );
    }
  }
  if (is_null($type) || $type == "comment") {
    $result['comment'] = array(
      'id_field' => 'cid',
      'title_field' => 'title',
      'object_type' => 'comment',
      'save_fn' => 'fasttoggle_comment_save',
      'extra_settings' => array(
        'fasttoggle_comments_rw_only' => array(
          '#type' => 'checkbox',
          '#title' => t('Toggle comments between read/write and readonly only? (Not completely disabled as well)'),
          '#default_value' => variable_get('fasttoggle_comments_rw_only', FALSE),
          '#weight' => 50,
        ),
        'help_text' => array(
          '#value' => t('Configure access restrictions for these settings on the <a href="@url">access control</a> page.', array(
            '@url' => url('admin/user/permissions', array(
              'fragment' => 'module-fasttoggle',
            )),
          )),
          '#prefix' => '<div>',
          '#suffix' => '</div>',
        ),
      ),
      'fields' => array(
        'status' => array(
          'instances' => array(
            'status' => array(
              'description' => t('Status <small>(published/unpublished)</small>'),
              'access' => array(
                'fasttoggle_comment_access_status',
              ),
              'labels' => array(
                FASTTOGGLE_LABEL_ACTION => array(
                  0 => t('publish'),
                  1 => t('unpublish'),
                ),
                FASTTOGGLE_LABEL_STATUS => array(
                  0 => t('not published'),
                  1 => t('published'),
                ),
              ),
            ),
          ),
        ),
      ),
    );
  }
  return $result;
}