| 1 |
<?php |
<?php |
| 2 |
// $Id$ |
// $Id: shindig_integrator.install,v 1.2.2.9 2009/08/17 07:19:57 impetus Exp $ |
| 3 |
/** |
/** |
| 4 |
* @file |
* @file |
| 5 |
* Install/Update/Uninstall file for applications |
* Install/Update/Uninstall file for applications |
| 207 |
'description' => t('User\'s ID to whom application setting belongs.'), |
'description' => t('User\'s ID to whom application setting belongs.'), |
| 208 |
'type' => 'int', |
'type' => 'int', |
| 209 |
'unsigned' => TRUE, |
'unsigned' => TRUE, |
| 210 |
'not null' => TRUE), |
'not null' => TRUE), |
|
'module_id' => array( |
|
|
'description' => t('User\'s application id .'), |
|
|
'type' => 'int', |
|
|
'unsigned' => TRUE, |
|
|
'not null' => TRUE), |
|
| 211 |
'name' => array( |
'name' => array( |
| 212 |
'description' => t('Name of setting.'), |
'description' => t('Name of setting.'), |
| 213 |
'type' => 'varchar', |
'type' => 'varchar', |
| 216 |
'default' => ''), |
'default' => ''), |
| 217 |
'value' => array( |
'value' => array( |
| 218 |
'description' => t('Value of Setting.'), |
'description' => t('Value of Setting.'), |
| 219 |
'type' => 'varchar', |
'type' => 'text', |
| 220 |
'length' => 255, |
'length' => 255, |
| 221 |
'not null' => TRUE, |
'not null' => TRUE, |
| 222 |
'default' => '')), |
'default' => '')), |
| 223 |
'indexes' => array( |
'unique keys' => array( |
| 224 |
'application_settings_application_id' => array('application_id', 'user_id', 'module_id', 'name'), |
'application_settings_application_id' => array('application_id', 'user_id', 'name'), |
| 225 |
), |
), |
| 226 |
); |
); |
| 227 |
return $schema; |
return $schema; |
| 245 |
* Create and modify required files to run shindig_integrator |
* Create and modify required files to run shindig_integrator |
| 246 |
*/ |
*/ |
| 247 |
function shindig_integrator_install_files() { |
function shindig_integrator_install_files() { |
| 248 |
|
//On some Unix variants, getcwd() will return FALSE if any one of the parent directories does not have the readable or search mode set, even if the current directory does. Grant all required permissions to all parent directories. |
| 249 |
$path_shindig = drupal_get_path('module', 'shindig_integrator'); |
$path_shindig = drupal_get_path('module', 'shindig_integrator'); |
| 250 |
$success = TRUE; |
$success = TRUE; |
| 251 |
$string = "<?php\n"; |
$string = "<?php\n"; |
| 260 |
"web_prefix" => "'. base_path() . $path_shindig .'/shindig/php", |
"web_prefix" => "'. base_path() . $path_shindig .'/shindig/php", |
| 261 |
"default_js_prefix" => "'. base_path() . $path_shindig .'/shindig/php/gadgets/js/", |
"default_js_prefix" => "'. base_path() . $path_shindig .'/shindig/php/gadgets/js/", |
| 262 |
"default_iframe_prefix" => "'. $path_shindig .'/shindig/php/gadgets/ifr?", |
"default_iframe_prefix" => "'. $path_shindig .'/shindig/php/gadgets/ifr?", |
| 263 |
"include_path" => "'. $_SERVER['DOCUMENT_ROOT'] . base_path() .'includes/", |
"include_path" => "'. getcwd() .'/includes/", |
| 264 |
"settings_php" => "'. $_SERVER['DOCUMENT_ROOT'] . base_path() . conf_path() .'/settings.php", |
"settings_php" => "'. getcwd() ."/". conf_path() .'/settings.php", |
| 265 |
"person_service" => "ShindigIntegratorPeopleService", |
"person_service" => "ShindigIntegratorPeopleService", |
| 266 |
"activity_service" => "ShindigIntegratorActivitiesService", |
"activity_service" => "ShindigIntegratorActivitiesService", |
| 267 |
"app_data_service" => "ShindigIntegratorAppDataService", |
"app_data_service" => "ShindigIntegratorAppDataService", |
| 289 |
} |
} |
| 290 |
fclose($handle); |
fclose($handle); |
| 291 |
} |
} |
| 292 |
|
|
| 293 |
|
/* |
| 294 |
|
* To set path to container.php in shindig config file |
| 295 |
|
*/ |
| 296 |
|
$config_file = "$path_shindig/shindig/php/src/common/Config.php"; |
| 297 |
|
$str = file_get_contents($config_file); |
| 298 |
|
$find_str = "include_once 'config/container.php';"; |
| 299 |
|
$replace_str = " |
| 300 |
|
if (file_exists('config/container.php')) { |
| 301 |
|
include_once 'config/container.php'; |
| 302 |
|
} else { |
| 303 |
|
include_once '$path_shindig/shindig/php/config/container.php'; |
| 304 |
|
} |
| 305 |
|
"; |
| 306 |
|
$str = str_replace($find_str,$replace_str,$str); |
| 307 |
|
file_put_contents($config_file,$str); |
| 308 |
|
|
| 309 |
$filename = "$path_shindig/shindig/config/container.js"; |
$filename = "$path_shindig/shindig/config/container.js"; |
| 310 |
$handle = @fopen($filename, "r"); |
$handle = @fopen($filename, "r"); |
| 313 |
$file_str = fread($handle, filesize($filename)); |
$file_str = fread($handle, filesize($filename)); |
| 314 |
fclose($handle); |
fclose($handle); |
| 315 |
} |
} |
| 316 |
$replace = "http://%host%/social"; |
$replace = "http://%host%"; |
| 317 |
$replace_with = base_path() . $path_shindig ."/shindig/php/social"; |
$replace_with = base_path() . $path_shindig ."/shindig/php"; |
| 318 |
|
$substr = str_replace($replace, $replace_with, $file_str); |
| 319 |
|
|
| 320 |
|
$replace = "/gadgets/files/container/rpc_relay.html"; |
| 321 |
|
$replace_with = base_path() . $path_shindig ."/gadgets/files/container/rpc_relay.html"; |
| 322 |
|
$substr = str_replace($replace, $replace_with, $substr); |
| 323 |
|
|
| 324 |
|
$handle = @fopen($filename, "w"); |
| 325 |
|
if ($handle) { |
| 326 |
|
if (!fwrite($handle, $substr)) { |
| 327 |
|
$success = FALSE; |
| 328 |
|
} |
| 329 |
|
fclose($handle); |
| 330 |
|
} |
| 331 |
|
|
| 332 |
|
|
| 333 |
|
$filename = "$path_shindig/js/container.js"; |
| 334 |
|
$handle = @fopen($filename, "r"); |
| 335 |
|
$file_str = ""; |
| 336 |
|
if ($handle) { |
| 337 |
|
$file_str = fread($handle, filesize($filename)); |
| 338 |
|
fclose($handle); |
| 339 |
|
} |
| 340 |
|
$replace = "/setPrefs"; |
| 341 |
|
$replace_with = base_path() ."setPrefs"; |
| 342 |
$substr = str_replace($replace, $replace_with, $file_str); |
$substr = str_replace($replace, $replace_with, $file_str); |
| 343 |
|
|
| 344 |
|
$replace = "/application_canvas/"; |
| 345 |
|
$replace_with = base_path() ."application_canvas/"; |
| 346 |
|
$substr = str_replace($replace, $replace_with, $substr); |
| 347 |
|
|
| 348 |
|
$replace = "/user/"; |
| 349 |
|
$replace_with = base_path() ."user/"; |
| 350 |
|
$substr = str_replace($replace, $replace_with, $substr); |
| 351 |
|
|
| 352 |
$handle = @fopen($filename, "w"); |
$handle = @fopen($filename, "w"); |
| 353 |
if ($handle) { |
if ($handle) { |
| 354 |
if (!fwrite($handle, $substr)) { |
if (!fwrite($handle, $substr)) { |
| 356 |
} |
} |
| 357 |
fclose($handle); |
fclose($handle); |
| 358 |
} |
} |
| 359 |
|
|
| 360 |
|
|
| 361 |
if (!file_exists("$path_shindig/shindig/php/includes/database.mysql-common.inc")) { |
if (!file_exists("$path_shindig/shindig/php/includes/database.mysql-common.inc")) { |
| 362 |
mkdir("$path_shindig/shindig/php/includes"); |
mkdir("$path_shindig/shindig/php/includes"); |
| 410 |
function shindig_integrator_uninstall_files() { |
function shindig_integrator_uninstall_files() { |
| 411 |
$path_shindig = drupal_get_path('module', 'shindig_integrator'); |
$path_shindig = drupal_get_path('module', 'shindig_integrator'); |
| 412 |
$success = TRUE; |
$success = TRUE; |
| 413 |
|
|
| 414 |
|
$config_file = "$path_shindig/shindig/php/src/common/Config.php"; |
| 415 |
|
$str = file_get_contents($config_file); |
| 416 |
|
$replace_str = "include_once 'config/container.php';"; |
| 417 |
|
$find_str = " |
| 418 |
|
if (file_exists('config/container.php')) { |
| 419 |
|
include_once 'config/container.php'; |
| 420 |
|
} else { |
| 421 |
|
include_once '$path_shindig/shindig/php/config/container.php'; |
| 422 |
|
} |
| 423 |
|
"; |
| 424 |
|
$str = str_replace($find_str,$replace_str,$str); |
| 425 |
|
file_put_contents($config_file,$str); |
| 426 |
|
|
| 427 |
$filename = "$path_shindig/shindig/php/config/local.php"; |
$filename = "$path_shindig/shindig/php/config/local.php"; |
| 428 |
unlink($filename); |
unlink($filename); |
| 429 |
$filename = "$path_shindig/shindig/config/container.js"; |
$filename = "$path_shindig/shindig/config/container.js"; |
| 433 |
$file_str = fread($handle, filesize($filename)); |
$file_str = fread($handle, filesize($filename)); |
| 434 |
fclose($handle); |
fclose($handle); |
| 435 |
} |
} |
| 436 |
$replace_with = "http://%host%/social"; |
$replace_with = "http://%host%"; |
| 437 |
$replace = base_path() . $path_shindig ."/shindig/php/social"; |
$replace = base_path() . $path_shindig ."/shindig/php"; |
| 438 |
$substr = str_replace($replace, $replace_with, $file_str); |
$substr = str_replace($replace, $replace_with, $file_str); |
| 439 |
|
|
| 440 |
|
$replace_with = "/gadgets/files/container/rpc_relay.html"; |
| 441 |
|
$replace = base_path() . $path_shindig ."/gadgets/files/container/rpc_relay.html"; |
| 442 |
|
$substr = str_replace($replace, $replace_with, $substr); |
| 443 |
|
|
| 444 |
$handle = @fopen($filename, "w"); |
$handle = @fopen($filename, "w"); |
| 445 |
if ($handle) { |
if ($handle) { |
| 446 |
if (!fwrite($handle, $substr)) { |
if (!fwrite($handle, $substr)) { |
| 448 |
} |
} |
| 449 |
fclose($handle); |
fclose($handle); |
| 450 |
} |
} |
| 451 |
|
|
| 452 |
|
$filename = "$path_shindig/js/container.js"; |
| 453 |
|
$handle = @fopen($filename, "r"); |
| 454 |
|
$file_str = ""; |
| 455 |
|
if ($handle) { |
| 456 |
|
$file_str = fread($handle, filesize($filename)); |
| 457 |
|
fclose($handle); |
| 458 |
|
} |
| 459 |
|
$replace_with = "/setPrefs"; |
| 460 |
|
$replace = base_path() ."setPrefs"; |
| 461 |
|
$substr = str_replace($replace, $replace_with, $file_str); |
| 462 |
|
|
| 463 |
|
$handle = @fopen($filename, "w"); |
| 464 |
|
if ($handle) { |
| 465 |
|
if (!fwrite($handle, $substr)) { |
| 466 |
|
$success = FALSE; |
| 467 |
|
} |
| 468 |
|
fclose($handle); |
| 469 |
|
} |
| 470 |
return $success; |
return $success; |
| 471 |
} |
} |
| 472 |
|
|