| 1 |
<?php
|
| 2 |
/**
|
| 3 |
* $Id: ziki.module,v 1.6 2007/11/21 17:42:21 narno Exp $
|
| 4 |
* Ziki's API integration in Drupal.
|
| 5 |
* @author Arnaud 'Narno' Ligny <arnaud.ligny@narno.com>
|
| 6 |
* @copyright Narno.com
|
| 7 |
*/
|
| 8 |
|
| 9 |
require_once(drupal_get_path('module', 'ziki') . '/ziki.inc');
|
| 10 |
|
| 11 |
define('ZIKI_API_XML', 'http://www.ziki.com/en/%s.xml');
|
| 12 |
define('ZIKI_API_XML_SEARCH', 'http://www.ziki.com/en/search.xml?name=%s');
|
| 13 |
define('ZIKI_PROFILE_URL', 'http://my.ziki.com/%s');
|
| 14 |
define('ZIKI_PROFILE_URL_DRUPAL', 'ziki/%s');
|
| 15 |
define('ZIKI_PROFILE_PHOTO_URL', 'http://my.ziki.com/%s/image/thumb');
|
| 16 |
|
| 17 |
/**
|
| 18 |
* Implementation of hook_help().
|
| 19 |
*/
|
| 20 |
function ziki_help($section) {
|
| 21 |
switch ($section) {
|
| 22 |
case 'admin/help#ziki':
|
| 23 |
$output = t("This module display your Ziki's profile (<a href=\"!zikiwebsite\">Ziki.com</a>)", array('!zikiwebsite' => url('http://ambassadeurs.ziki.com/z/134/CD121/')));
|
| 24 |
break;
|
| 25 |
}
|
| 26 |
return $output;
|
| 27 |
}
|
| 28 |
|
| 29 |
/**
|
| 30 |
* Implementation of hook_menu().
|
| 31 |
*/
|
| 32 |
function ziki_menu($may_cache) {
|
| 33 |
$items = array();
|
| 34 |
if ($may_cache) {
|
| 35 |
$items[] = array(
|
| 36 |
'path' => 'admin/settings/ziki',
|
| 37 |
'title' => t('Ziki'),
|
| 38 |
'description' => t('Your Ziki\'s profile.'),
|
| 39 |
'callback' => 'drupal_get_form',
|
| 40 |
'callback arguments' => array('ziki_admin_settings'),
|
| 41 |
'access' => user_access('administer site configuration'),
|
| 42 |
'type' => MENU_NORMAL_ITEM
|
| 43 |
);
|
| 44 |
$items[] = array(
|
| 45 |
'path' => 'admin/settings/ziki/general',
|
| 46 |
'title' => t('General settings'),
|
| 47 |
'type' => MENU_DEFAULT_LOCAL_TASK
|
| 48 |
);
|
| 49 |
$items[] = array(
|
| 50 |
'path' => 'admin/settings/ziki/api',
|
| 51 |
'title' => t('API settings'),
|
| 52 |
'description' => t('API settings.'),
|
| 53 |
'callback' => 'drupal_get_form',
|
| 54 |
'callback arguments' => array('ziki_admin_api_settings'),
|
| 55 |
'access' => user_access('administer site configuration'),
|
| 56 |
'type' => MENU_LOCAL_TASK
|
| 57 |
);
|
| 58 |
// clear cache callback
|
| 59 |
$items[] = array(
|
| 60 |
'path' => 'admin/settings/ziki/clearcache',
|
| 61 |
'title' => t('Clear cache'),
|
| 62 |
'callback' => 'ziki_clear_cache',
|
| 63 |
'access' => user_access('administer site configuration'),
|
| 64 |
'type' => MENU_CALLBACK
|
| 65 |
);
|
| 66 |
}
|
| 67 |
|
| 68 |
return $items;
|
| 69 |
}
|
| 70 |
|
| 71 |
/**
|
| 72 |
* admin settings for the Ziki module
|
| 73 |
*/
|
| 74 |
function ziki_admin_settings() {
|
| 75 |
$form = array();
|
| 76 |
$form['ziki_cache'] = array(
|
| 77 |
'#type' => 'fieldset',
|
| 78 |
'#title' => t('Cache')
|
| 79 |
);
|
| 80 |
$form['ziki_cache']['ziki_cache_people'] = array(
|
| 81 |
'#type' => 'checkbox',
|
| 82 |
'#title' => t('Cache the people informations stream for performance (<a href="!clearcache">clear the cache</a>)', array('!clearcache' => url('admin/settings/ziki/clearcache', drupal_get_destination()))),
|
| 83 |
'#default_value' => variable_get('ziki_cache_people', FALSE),
|
| 84 |
'#description' => t("This reduces the load of the XML file from the Ziki's webserver.")
|
| 85 |
);
|
| 86 |
$form['ziki_cache']['ziki_cache_people_photo'] = array(
|
| 87 |
'#type' => 'checkbox',
|
| 88 |
'#title' => t('Cache the people photo for performance'),
|
| 89 |
'#default_value' => variable_get('ziki_cache_people_photo', FALSE),
|
| 90 |
'#description' => t('The photo will be stored in "file/ziki/" directory')
|
| 91 |
);
|
| 92 |
if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PRIVATE) {
|
| 93 |
$form['ziki_cache']['ziki_cache_people_photo']['#disabled'] = TRUE;
|
| 94 |
$form['ziki_cache']['ziki_cache_people_photo']['#description'] .= t(' (<a href="!url">Public file transfers</a> must be enabled to allow local photo)', array('!url' => url('admin/settings/file-system', drupal_get_destination())));
|
| 95 |
}
|
| 96 |
return system_settings_form($form);
|
| 97 |
}
|
| 98 |
|
| 99 |
function ziki_admin_api_settings() {
|
| 100 |
//cache_clear_all('ziki', 'cache', TRUE);
|
| 101 |
$form = array();
|
| 102 |
$form['ziki_paths_xml'] = array(
|
| 103 |
'#type' => 'fieldset',
|
| 104 |
'#title' => t('XML Paths')
|
| 105 |
);
|
| 106 |
$form['ziki_paths_xml']['ziki_paths_xml'] = array(
|
| 107 |
'#type' => 'textfield',
|
| 108 |
'#title' => t('Data for a Ziki'),
|
| 109 |
'#default_value' => variable_get('ziki_api_xml', ZIKI_API_XML),
|
| 110 |
'#description' => t('Fill the url to the XML stream.')
|
| 111 |
);
|
| 112 |
$form['ziki_paths_xml']['ziki_paths_xml_search'] = array(
|
| 113 |
'#type' => 'textfield',
|
| 114 |
'#title' => t('People Search'),
|
| 115 |
'#default_value' => variable_get('ziki_api_xml_search', ZIKI_API_XML_SEARCH),
|
| 116 |
'#description' => t('Fill the url to the XML stream.')
|
| 117 |
);
|
| 118 |
$form['ziki_paths_url'] = array(
|
| 119 |
'#type' => 'fieldset',
|
| 120 |
'#title' => t('URL Paths')
|
| 121 |
);
|
| 122 |
$form['ziki_paths_url']['ziki_paths_url'] = array(
|
| 123 |
'#type' => 'textfield',
|
| 124 |
'#title' => t('Ziki profile'),
|
| 125 |
'#default_value' => variable_get('ziki_profile_url', ZIKI_PROFILE_URL),
|
| 126 |
'#description' => t('Fill the url to the HTML page.')
|
| 127 |
);
|
| 128 |
$form['ziki_paths_url']['ziki_paths_photo'] = array(
|
| 129 |
'#type' => 'textfield',
|
| 130 |
'#title' => t('Ziki photo'),
|
| 131 |
'#default_value' => variable_get('ziki_photo_url', ZIKI_PROFILE_PHOTO_URL),
|
| 132 |
'#description' => t('Fill the url to the photo page.')
|
| 133 |
);
|
| 134 |
return system_settings_form($form);
|
| 135 |
}
|
| 136 |
|
| 137 |
/**
|
| 138 |
* callback function for clearing the cache
|
| 139 |
*/
|
| 140 |
function ziki_clear_cache($wildcard='ziki') {
|
| 141 |
cache_clear_all($wildcard, 'cache', TRUE);
|
| 142 |
drupal_set_message('Cache cleared.');
|
| 143 |
drupal_goto();
|
| 144 |
}
|
| 145 |
?>
|