You are here

sgrid.module in Sortable Grid Views Plugin 7

Same filename and directory in other branches
  1. 6 sgrid.module

File

sgrid.module
View source
<?php

require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'sgrid') . '/sgrid_theme.inc';
function sgrid_menu() {
  $items['save_order'] = array(
    'page callback' => 'sgrid_save_order',
    'page arguments' => array(
      1,
      2,
      3,
    ),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );
  return $items;
}
function sgrid_save_order($view, $display, $reset = FALSE) {
  db_delete('sgrid')
    ->condition('view_display', $view . '_' . $display)
    ->execute();
  if (!$reset) {
    foreach ($_GET['sgrid_item'] as $index => $name) {
      db_insert('sgrid')
        ->fields(array(
        'nid' => $name,
        'rank' => $index,
        'view_display' => $view . '_' . $display,
      ))
        ->execute();
    }
  }
  print t("Order saved");
}

/**
 * Implements of hook_views_api().
 * @return Array with Views API version.
 */
function sgrid_views_api() {
  return array(
    'api' => 3.0,
  );
}
function sgrid_permission() {
  return array(
    'sort Sortable Grid Views' => array(
      'title' => t('sort Sortable Grid Views'),
      'description' => t('Allows users with this permission to use Sgrid features'),
    ),
  );
}