| 1 |
<?php
|
| 2 |
// $Id: lmo.common.inc,v 1.2 2008/08/25 18:15:17 martinsfromb Exp $
|
| 3 |
// contains common functions of the lmo module for use with drupal 5 and drupal 6
|
| 4 |
|
| 5 |
function lmo_help($section) {
|
| 6 |
switch ($section) {
|
| 7 |
case 'admin/modules#description':
|
| 8 |
return t('Integrates the famous LigaManagerOnline into drupal 6');
|
| 9 |
}
|
| 10 |
}
|
| 11 |
|
| 12 |
function lmo_perm() {
|
| 13 |
return array('administer lmo');
|
| 14 |
}
|
| 15 |
|
| 16 |
function lmo_settings_form() {
|
| 17 |
|
| 18 |
$form['lmo_local_path'] = array(
|
| 19 |
'#type' => 'textfield',
|
| 20 |
'#title' => t('local LMO path'),
|
| 21 |
'#default_value' => variable_get('lmo_local_path', 'Default setting'),
|
| 22 |
/* '#size' => 20,*/
|
| 23 |
'#maxlength' => 255,
|
| 24 |
'#description' => t('Path to your local lmo installation.'),
|
| 25 |
);
|
| 26 |
|
| 27 |
$form['lmo_admin'] = array(
|
| 28 |
'#type' => 'textfield',
|
| 29 |
'#title' => t('lmo admin username'),
|
| 30 |
'#default_value' => variable_get('lmo_admin', 'admin'),
|
| 31 |
/* '#size' => 20,*/
|
| 32 |
'#maxlength' => 255,
|
| 33 |
'#description' => t('Give the username of an administrator created in LMO.'),
|
| 34 |
);
|
| 35 |
|
| 36 |
$form['lmo_admin_pass'] = array(
|
| 37 |
'#type' => 'password',
|
| 38 |
'#title' => t('lmo admin pasword'),
|
| 39 |
'#default_value' => variable_get('lmo_admin_pass', 'lmo'),
|
| 40 |
/* '#size' => 20,*/
|
| 41 |
'#maxlength' => 255,
|
| 42 |
'#description' => t('Give the password of the user above.'),
|
| 43 |
);
|
| 44 |
return system_settings_form($form);
|
| 45 |
}
|
| 46 |
|
| 47 |
function lmo_page(){
|
| 48 |
drupal_add_css(drupal_get_path('module', 'lmo').'/lmo.css');
|
| 49 |
$bc = array();
|
| 50 |
$bc[] = l(t('Home'), '');
|
| 51 |
if ($_GET['file'] != '') {
|
| 52 |
$bc[] = l(t('League Manager Online'), 'lmo');
|
| 53 |
}
|
| 54 |
if ($_GET['action'] != '') {
|
| 55 |
$bc[] = l($_GET['file'], 'lmo', array(), 'file='.$_GET['file']);
|
| 56 |
}
|
| 57 |
drupal_set_breadcrumb($bc);
|
| 58 |
drupal_set_title('');
|
| 59 |
$_SESSION["lmouserok"] = 0;
|
| 60 |
if (!isset($_SESSION["lmouserlang"])){ $_SESSION["lmouserlang"] = "English";};
|
| 61 |
ob_start();
|
| 62 |
require(variable_get('lmo_local_path','').'/lmo-start.php');
|
| 63 |
$content = ob_get_contents();
|
| 64 |
ob_end_clean();
|
| 65 |
$content = lmo_rework_lmo_output($content);
|
| 66 |
print theme('page', $content);
|
| 67 |
}
|
| 68 |
|
| 69 |
function lmo_page_backend() {
|
| 70 |
$lmo_path= variable_get('lmo_local_path','');
|
| 71 |
$lmo_url = str_replace($_SERVER['DOCUMENT_ROOT'], '', $lmo_path);
|
| 72 |
$lmo_url = substr($lmo_url,1);
|
| 73 |
drupal_set_message(t('The lmo backend in drupal is still broken in some cases, so please use the original backend at').' '.l($lmo_url.'/lmoadmin.php',$lmo_url.'/lmoadmin.php').'!');
|
| 74 |
drupal_add_css(drupal_get_path('module', 'lmo').'/lmo.css');
|
| 75 |
drupal_set_title(t('LMO Backend'));
|
| 76 |
$dirligen= 'test';
|
| 77 |
ob_start();
|
| 78 |
define('LMO_AUTH', 1);
|
| 79 |
require($lmo_path.'/init.php');
|
| 80 |
|
| 81 |
$subdir='';
|
| 82 |
if(!isset($_SESSION["lmouserfile"])){$_SESSION["lmouserfile"]="";}
|
| 83 |
if(!isset($_SESSION["lmouserokerweitert"])){$_SESSION["lmouserokerweitert"]=0;}
|
| 84 |
|
| 85 |
$_POST["xusername"] = variable_get('lmo_admin', '');
|
| 86 |
$_POST["xuserpass"] = variable_get('lmo_admin_pass', '');
|
| 87 |
$_SESSION["lmouserok"] = 0;
|
| 88 |
|
| 89 |
$todo=isset($_REQUEST['todo'])?$_REQUEST['todo']:"";
|
| 90 |
$st=isset($_REQUEST['st'])?$_REQUEST['st']:NULL;
|
| 91 |
if($todo=="logout"){
|
| 92 |
$_SESSION['lmouserok']=0;
|
| 93 |
$_SESSION['lmouserpass']="";
|
| 94 |
}
|
| 95 |
|
| 96 |
$action="admin";
|
| 97 |
$array = array();
|
| 98 |
|
| 99 |
if (($todo == 'delete') || ($todo == 'download'))
|
| 100 |
{
|
| 101 |
$dirliga = $lmo_path.'/'.$dirliga;
|
| 102 |
}
|
| 103 |
|
| 104 |
require(variable_get('lmo_local_path','').'/lmo-admincheck_auth.php');
|
| 105 |
$file=!empty($_REQUEST['file'])?$_REQUEST['file']:'';
|
| 106 |
|
| 107 |
if (!empty($file) && ($todo=="open" || $todo=="")) $todo="edit";
|
| 108 |
if ((!empty($file) && check_hilfsadmin($file)) || empty($file)) require(variable_get('lmo_local_path','').'/lmo-adminmain.php');
|
| 109 |
$content = ob_get_contents();
|
| 110 |
ob_end_clean();
|
| 111 |
|
| 112 |
if (variable_get('clean_url',0) == 1) {
|
| 113 |
$content = str_replace('index.php', 'admin/content/lmo', $content);
|
| 114 |
} else {
|
| 115 |
$content = str_replace('index.php?', 'index.php?q=admin/content/lmo&', $content);
|
| 116 |
$content = str_replace('index.php"', 'index.php?q=admin/content/lmo"', $content);
|
| 117 |
//drupal_set_message(t("Sorry ... forms in admin section doesn't work without clean_url enabled yet!"), 'error');
|
| 118 |
}
|
| 119 |
|
| 120 |
$content = utf8_encode($content);
|
| 121 |
print theme('page', $content);
|
| 122 |
}
|
| 123 |
|
| 124 |
function lmo_rework_lmo_output($input) {
|
| 125 |
$content = $input;
|
| 126 |
$lmo_path= variable_get('lmo_local_path','');
|
| 127 |
$lmo_url = str_replace($_SERVER['DOCUMENT_ROOT'], '', $lmo_path);
|
| 128 |
if (variable_get('clean_url',0) == 1) {
|
| 129 |
$content = str_replace($lmo_url.'/?', '/lmo?', $content);
|
| 130 |
$content = str_replace('index.php', 'lmo', $content);
|
| 131 |
} else {
|
| 132 |
$content = str_replace($lmo_url.'/?', '/index.php?q=lmo&', $content);
|
| 133 |
$content = str_replace('index.php?', 'index.php?q=lmo&', $content);
|
| 134 |
$content = str_replace("index.php'", "index.php?q=lmo'", $content);
|
| 135 |
}
|
| 136 |
return utf8_encode($content);
|
| 137 |
}
|
| 138 |
|
| 139 |
|
| 140 |
function lmo_getblocksdata() {
|
| 141 |
$blocks = array();
|
| 142 |
$sql = "SELECT * FROM {lmo_blocks}";
|
| 143 |
$result = db_query($sql);
|
| 144 |
while ($block = db_fetch_object($result)) {
|
| 145 |
$blocks[$block->id]['delta'] = $block->id;
|
| 146 |
$blocks[$block->id]['type'] = $block->type;
|
| 147 |
$blocks[$block->id]['option1'] = $block->option1;
|
| 148 |
$blocks[$block->id]['option2'] = $block->option2;
|
| 149 |
$blocks[$block->id]['option3'] = $block->option3;
|
| 150 |
$blocks[$block->id]['title'] = $block->title;
|
| 151 |
$blocks[$block->id]['intro'] = $block->intro;
|
| 152 |
$blocks[$block->id]['conclusion'] = $block->conclusion;
|
| 153 |
}
|
| 154 |
return $blocks;
|
| 155 |
}
|
| 156 |
|
| 157 |
function lmo_getblock($id) {
|
| 158 |
$sql = "SELECT * FROM {lmo_blocks} WHERE id='".$id."'";
|
| 159 |
$result = db_query($sql);
|
| 160 |
$blockdata = db_fetch_object($result);
|
| 161 |
$block['delta'] = $blockdata->id;
|
| 162 |
$block['type'] = $blockdata->type;
|
| 163 |
$block['option1'] = $blockdata->option1;
|
| 164 |
$block['option2'] = $blockdata->option2;
|
| 165 |
$block['option3'] = $blockdata->option3;
|
| 166 |
$block['title'] = $blockdata->title;
|
| 167 |
$block['intro'] = $blockdata->intro;
|
| 168 |
$block['conclusion'] = $blockdata->conclusion;
|
| 169 |
return $block;
|
| 170 |
}
|
| 171 |
|
| 172 |
function lmo_check_blockstatus ($block, $verbose = false) {
|
| 173 |
$status = array();
|
| 174 |
switch ($block['type']) {
|
| 175 |
case 'minitab':
|
| 176 |
$status['ok'] = true;
|
| 177 |
if ($block['option1'] == '') {
|
| 178 |
$status['message'] = t('No league file provided!').'<br>';
|
| 179 |
$status['ok'] = false;
|
| 180 |
}
|
| 181 |
if ($block['option2'] == '') {
|
| 182 |
$status['message'] .= t('No template file provided!').'<br>';
|
| 183 |
$status['ok'] = false;
|
| 184 |
}
|
| 185 |
$status['visible'] = false;
|
| 186 |
break;
|
| 187 |
default:
|
| 188 |
$status['ok'] = false;
|
| 189 |
$status['visible'] = false;
|
| 190 |
$status['message'] = t('This type of block is not supported yet.');
|
| 191 |
}
|
| 192 |
return $status;
|
| 193 |
}
|
| 194 |
|
| 195 |
function lmo_block($op = 'list', $delta = 0) {
|
| 196 |
$blockarray = lmo_getblocksdata();
|
| 197 |
if ($op == 'list') {
|
| 198 |
foreach ($blockarray as $blockdata)
|
| 199 |
{
|
| 200 |
$blocks[$blockdata['delta']]['info'] = 'LMO:'.$blockdata['type'].':'.$blockdata['option1'];
|
| 201 |
}
|
| 202 |
return $blocks;
|
| 203 |
}
|
| 204 |
else if ($op == 'view' && user_access('access content')) {
|
| 205 |
switch ($blockarray[$delta]['type']) {
|
| 206 |
case 'minitab':
|
| 207 |
if ($blockarray[$delta]['title'] != '') {
|
| 208 |
$block['subject'] = $blockarray[$delta]['title'];
|
| 209 |
} else $block['subject'] = t('Standings').' '.$blockarray[$delta]['option1'];
|
| 210 |
$block['content'] = get_minitab_block_content($blockarray[$delta]);//theme('minitab_block', $blockarray[$delta]);
|
| 211 |
break;
|
| 212 |
default:
|
| 213 |
$block['subject'] = t('No Block');
|
| 214 |
$block['content'] = t('There is no content in no block!');
|
| 215 |
}
|
| 216 |
return $block;
|
| 217 |
}
|
| 218 |
}
|
| 219 |
|
| 220 |
function get_minitab_block_content ($blockdata) {
|
| 221 |
$lmopath = variable_get('lmo_local_path','');
|
| 222 |
$output = '';
|
| 223 |
if ($blockdata['intro'] != '') $output .= $blockdata['intro'];
|
| 224 |
$mini_liga = $blockdata['option1'];
|
| 225 |
$mini_template = $blockdata['option2'];
|
| 226 |
$mini_unter=100;
|
| 227 |
$mini_platz=1;
|
| 228 |
require($lmopath.'/init.php');
|
| 229 |
ob_start();
|
| 230 |
include($lmopath.'/addon/mini/lmo-minitab.php');
|
| 231 |
$table = ob_get_contents();
|
| 232 |
$output .= lmo_rework_lmo_output($table);
|
| 233 |
ob_end_clean();
|
| 234 |
if ($blockdata['conclusion'] != '') $output .= $blockdata['conclusion'];
|
| 235 |
return $output;
|
| 236 |
}
|
| 237 |
|
| 238 |
?>
|