function gallery_assist_init in Gallery Assist 7
Same name and namespace in other branches
- 6 gallery_assist.module \gallery_assist_init()
Implements hook_init();
@todo: Optimation and centralization of the GA js code.
File
- ./
gallery_assist.module, line 20 - Extend drupal with gallery functionalities. Manage galleries.
Code
function gallery_assist_init() {
global $user, $language;
gallery_assist_add_css('gallery_assist');
// gallery_assist_add_js('gallery_assist');
gallery_assist_add_js('gallery_assist_functions');
// gallery_assist_add_js('tests');
// Create the user gallery_assist directory if the user has the right permission.
$gallery_assist_paths[] = variable_get('gallery_assist_directory', FALSE);
$gallery_assist_paths[] = $user->uid;
if (file_prepare_directory($gallery_assist_paths[0], FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
$gallery_assist_user_upload_path = implode('/', $gallery_assist_paths);
if (!is_dir($gallery_assist_user_upload_path)) {
$create = 0;
$types = node_type_get_names();
foreach (array_keys($types) as $type) {
if (user_access('create gallery_assist content') || user_access('create gallery_assist_' . $type . ' content')) {
++$create;
}
}
if ($create > 0) {
if (file_prepare_directory($gallery_assist_user_upload_path, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
drupal_set_message(t("A gallery enviroment for user @user has been sucessfull created.", array(
'@user' => $user->name,
)));
watchdog('action', t("A gallery enviroment for user @user has been sucessfull created.", array(
'@user' => $user->name,
)));
}
else {
drupal_set_message(t("It was not possible to create the @user's gallery enviroment.", array(
'@user' => $user->name,
)));
watchdog('action', t("It was not possible to create the @user's gallery enviroment.", array(
'@user' => $user->name,
)));
}
}
}
}
}