| 1 |
<?php
|
| 2 |
// Modeline for drupal
|
| 3 |
// vim: set expandtab tabstop=2 shiftwidth=2 autoindent smartindent filetype=php:
|
| 4 |
|
| 5 |
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
| 6 |
* ZINA (Zina is not Andromeda)
|
| 7 |
*
|
| 8 |
* Zina is a graphical interface to your MP3 collection, a personal
|
| 9 |
* jukebox, an MP3 streamer. It can run on its own, embeded into an
|
| 10 |
* existing website, or as a Drupal/Joomla/Wordpress/etc. module.
|
| 11 |
*
|
| 12 |
* http://www.pancake.org/zina
|
| 13 |
* Author: Ryan Lathouwers <ryanlath@pacbell.net>
|
| 14 |
* Support: http://sourceforge.net/projects/zina/
|
| 15 |
* License: GNU GPL2 <http://www.gnu.org/copyleft/gpl.html>
|
| 16 |
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
| 17 |
|
| 18 |
/**
|
| 19 |
* Implementation of hook_install().
|
| 20 |
*/
|
| 21 |
function zina_install() {
|
| 22 |
global $zc;
|
| 23 |
#drupal_install_schema('zina');
|
| 24 |
#variable_set('zina',$options);
|
| 25 |
$conf['time'] = microtime(true);
|
| 26 |
$conf['embed'] = 'drupal';
|
| 27 |
$conf['index_abs'] = dirname(__FILE__);
|
| 28 |
$conf['charset'] = 'utf-8';
|
| 29 |
require_once('zina.module');
|
| 30 |
require_once('zina/index.php');
|
| 31 |
require_once('zina/install.php');
|
| 32 |
zina_init($conf);
|
| 33 |
if ($zc['database']) {
|
| 34 |
zina_install_database();
|
| 35 |
} else {
|
| 36 |
drupal_set_message(t('Zina database could not be installed. It will need to be set-up manually.'), 'error');
|
| 37 |
}
|
| 38 |
global $user;
|
| 39 |
variable_set('zina_drupal_uid', $user->uid);
|
| 40 |
|
| 41 |
$vocabulary = array(
|
| 42 |
'name' => t('Genres'),
|
| 43 |
'multiple' => 1,
|
| 44 |
'tags' => 1,
|
| 45 |
'required' => 0,
|
| 46 |
'hierarchy' => 0,
|
| 47 |
'relations' => 0,
|
| 48 |
'module' => 'zina',
|
| 49 |
'weight' => -10,
|
| 50 |
'nodes' => array('zina' => 1),
|
| 51 |
);
|
| 52 |
taxonomy_save_vocabulary($vocabulary);
|
| 53 |
|
| 54 |
variable_set('zina_genre_vocabulary', $vocabulary['vid']);
|
| 55 |
|
| 56 |
$dir_id = zdbq_single("SELECT id FROM {dirs} WHERE parent_id = 0 AND path = '.'");
|
| 57 |
#todo: redundant with database.php
|
| 58 |
if (!empty($dir_id)) {
|
| 59 |
$cms_id = zina_cms_insert(t('Artists'));
|
| 60 |
if (!empty($cms_id)) {
|
| 61 |
if (zdbq("UPDATE {dirs} SET cms_id = %d WHERE id = %d", array($cms_id, $dir_id))) {
|
| 62 |
if (function_exists('path_set_alias')) {
|
| 63 |
path_set_alias('node/'. $cms_id, __ZINA__);
|
| 64 |
}
|
| 65 |
} else {
|
| 66 |
zina_debug(zt('dbViewLog: Could not update cms_id: @dir (@cmsid)',array('@dir'=>$path_cur,'@cmsid'=>$cms_id)));
|
| 67 |
}
|
| 68 |
} else {
|
| 69 |
zina_debug(zt('dbViewLog: Could not get cms_id: @dir',array('@dir'=>$path_cur)));
|
| 70 |
}
|
| 71 |
}
|
| 72 |
}
|
| 73 |
|
| 74 |
/**
|
| 75 |
* Implementation of hook_uninstall().
|
| 76 |
*/
|
| 77 |
function zina_uninstall() {
|
| 78 |
global $zc;
|
| 79 |
#drupal_uninstall_schema('zina');
|
| 80 |
|
| 81 |
$conf['time'] = microtime(true);
|
| 82 |
$conf['embed'] = 'drupal';
|
| 83 |
$conf['index_abs'] = dirname(__FILE__);
|
| 84 |
require_once('zina/index.php');
|
| 85 |
zina_init($conf);
|
| 86 |
|
| 87 |
if ($zc['database']) zdb_uninstall_database();
|
| 88 |
|
| 89 |
for($i=1; $i<=5; $i++) {
|
| 90 |
variable_del('zina_block_'.$i.'_type');
|
| 91 |
variable_del('zina_block_'.$i.'_period');
|
| 92 |
variable_del('zina_block_'.$i.'_page');
|
| 93 |
variable_del('zina_block_'.$i.'_items');
|
| 94 |
}
|
| 95 |
|
| 96 |
$result = db_query("SELECT nid FROM {node} WHERE type = 'zina'");
|
| 97 |
while ($node = db_fetch_object($result)) { node_delete($node->nid); }
|
| 98 |
|
| 99 |
variable_del('zina_drupal_uid');
|
| 100 |
$vid = variable_get('zina_genre_vocabulary', 0);
|
| 101 |
taxonomy_del_vocabulary($vid);
|
| 102 |
variable_del('zina_genre_vocabulary');
|
| 103 |
}
|
| 104 |
|
| 105 |
/**
|
| 106 |
* Implementation of hook_schema().
|
| 107 |
*/
|
| 108 |
#function zina_schema() { }
|
| 109 |
|
| 110 |
function zina_update_6105() {
|
| 111 |
return zina_helper_update(7);
|
| 112 |
}
|
| 113 |
|
| 114 |
function zina_update_6104() {
|
| 115 |
$vid = variable_get('zina_genre_vocabulary', 0);
|
| 116 |
$vocabularies = taxonomy_get_vocabularies();
|
| 117 |
if (!isset($vocabularies[$vid])) {
|
| 118 |
$vocabulary = array(
|
| 119 |
'name' => t('Genres'),
|
| 120 |
'multiple' => 1,
|
| 121 |
'tags' => 1,
|
| 122 |
'required' => 0,
|
| 123 |
'hierarchy' => 0,
|
| 124 |
'relations' => 0,
|
| 125 |
'module' => 'zina',
|
| 126 |
'weight' => -10,
|
| 127 |
'nodes' => array('zina' => 1),
|
| 128 |
);
|
| 129 |
taxonomy_save_vocabulary($vocabulary);
|
| 130 |
|
| 131 |
variable_set('zina_genre_vocabulary', $vocabulary['vid']);
|
| 132 |
}
|
| 133 |
|
| 134 |
global $user;
|
| 135 |
variable_set('zina_drupal_uid', $user->uid);
|
| 136 |
return zina_helper_update(6);
|
| 137 |
}
|
| 138 |
|
| 139 |
function zina_update_6103() {
|
| 140 |
return zina_helper_update(5);
|
| 141 |
}
|
| 142 |
|
| 143 |
function zina_update_6102() {
|
| 144 |
return zina_helper_update(4);
|
| 145 |
}
|
| 146 |
|
| 147 |
function zina_update_6101() {
|
| 148 |
return zina_helper_update(3);
|
| 149 |
}
|
| 150 |
|
| 151 |
function zina_update_6100() {
|
| 152 |
return zina_helper_update(2);
|
| 153 |
}
|
| 154 |
|
| 155 |
function zina_helper_update($update) {
|
| 156 |
global $zc;
|
| 157 |
$conf['time'] = microtime(true);
|
| 158 |
$conf['embed'] = 'drupal';
|
| 159 |
$conf['index_abs'] = dirname(__FILE__);
|
| 160 |
require_once('zina/index.php');
|
| 161 |
require_once('zina/update.php');
|
| 162 |
zina_init($conf);
|
| 163 |
|
| 164 |
if ($zc['database']) {
|
| 165 |
$success = zina_updates_embed($update);
|
| 166 |
$ret[] = array('success'=>$success,'query'=>'Zina Update');
|
| 167 |
} else {
|
| 168 |
global $db_type;
|
| 169 |
$ret[] = array('success'=>false,'query'=>'Zina Update: Drupal db not compatible ('.$db_type.'). Must setup manually via Zina administrative menu.');
|
| 170 |
}
|
| 171 |
|
| 172 |
return $ret;
|
| 173 |
}
|