function manipulateImage($parameterArray = null, $dsid, $file, $file_ext, $folder)
 {
     $height = $parameterArray['height'];
     $width = $parameterArray['width'];
     $file_suffix = '_' . $dsid . '.' . $file_ext;
     $returnValue = TRUE;
     $image = imageapi_image_open($file);
     if (!$image) {
         drupal_set_message(t("Error opening image"));
         return false;
     }
     if (!empty($height) || !empty($width)) {
         $returnValue = imageapi_image_scale($image, $height, $width);
     }
     if (!$returnValue) {
         drupal_set_message(t("Error scaling image"));
         return $returnValue;
     }
     $filename = substr(strrchr($file, '/'), 1);
     $output_path = $_SERVER['DOCUMENT_ROOT'] . base_path() . file_directory_path() . '/' . $folder . '/' . $filename . $file_suffix;
     $returnValue = imageapi_image_close($image, $output_path);
     if ($returnValue) {
         $_SESSION['fedora_ingest_files']["{$dsid}"] = $file . $file_suffix;
         return TRUE;
     } else {
         return $returnValue;
     }
 }
Example #2
0
/**
 * Select a diferent footer image at every reload. 
 *
 * @return CSS
 */
function satellite_header_background()
{
    global $base_path;
    $theme = drupal_get_path('theme', 'satellite');
    $file_directory_path = file_directory_path();
    $token = token_get_values('esn');
    $data = array_combine($token->tokens, $token->values);
    $css = '';
    if (file_exists($data['header'])) {
        if ($data['default_header'] == 1) {
            $css .= '<style type="text/css" media="all"> #wrapper #container #footer-fade {background: url("' . $base_path . $file_directory_path . '/imagecache/header/' . $data['header'] . '") top left no-repeat;}</style>';
        }
        if ($data['default_header'] == 0) {
            $css .= '<style type="text/css" media="all"> #wrapper #container #footer-fade {background: url("' . $base_path . $file_directory_path . '/imagecache/header/' . $data['header'] . '") top left no-repeat;}</style>';
            $css .= '<style type="text/css" media="all"> #shadow-top { background: transparent url("' . $base_path . $theme . '/images/layout/shadow_top_clean.png") top center no-repeat;}</style>';
        }
        if ($data['default_header'] == 2) {
            $css .= '<style type="text/css" media="all"> #wrapper #container #footer-fade { background: transparent url("' . $base_path . $file_directory_path . '/imagecache/header_star/' . $data['header'] . '") no-repeat 0 35px;}</style>';
            $css .= '<style type="text/css" media="all"> #shadow-top { background: transparent url("' . $base_path . $theme . '/images/layout/shadow_top_clean.png") top center no-repeat;}</style>';
        }
    } else {
        $css .= '<style type="text/css" media="all">  #wrapper #container #header #header-title {background: url("' . $base_path . $theme . '/images/default_header.png") top left no-repeat;}</style>';
    }
    return $css;
}
Example #3
0
/**
 * Implementation of hook_settings() for themes.
 */
function singular_settings($settings)
{
    // Add js & css
    drupal_add_css('misc/farbtastic/farbtastic.css', 'module', 'all', FALSE);
    drupal_add_js('misc/farbtastic/farbtastic.js');
    drupal_add_js(drupal_get_path('theme', 'singular') . '/js/settings.js');
    drupal_add_css(drupal_get_path('theme', 'singular') . '/css/settings.css');
    file_check_directory(file_directory_path(), FILE_CREATE_DIRECTORY, 'file_directory_path');
    // Check for a new uploaded logo, and use that instead.
    if ($file = file_save_upload('background_file', array('file_validate_is_image' => array()))) {
        $parts = pathinfo($file->filename);
        $filename = 'singular_background.' . $parts['extension'];
        if (file_copy($file, $filename, FILE_EXISTS_REPLACE)) {
            $settings['background_path'] = $file->filepath;
        }
    }
    $form = array();
    $form['layout'] = array('#title' => t('Layout'), '#type' => 'select', '#options' => array('fixed' => t('Fixed width'), 'fluid' => t('Fluid width')), '#default_value' => !empty($settings['layout']) ? $settings['layout'] : 'fixed');
    $form['messages'] = array('#type' => 'fieldset', '#tree' => FALSE, '#title' => t('Autoclose messages'), '#descriptions' => t('Select the message types to close automatically after a few seconds.'));
    $form['messages']['autoclose'] = array('#type' => 'checkboxes', '#options' => array('status' => t('Status'), 'warning' => t('Warning'), 'error' => t('Error')), '#default_value' => !empty($settings['autoclose']) ? $settings['autoclose'] : array('status'));
    $form['style'] = array('#title' => t('Styles'), '#type' => 'select', '#options' => singular_get_styles(), '#default_value' => !empty($settings['style']) ? $settings['style'] : 'sea');
    $form['custom'] = array('#tree' => FALSE, '#type' => 'fieldset', '#attributes' => array('class' => $form['style']['#default_value'] == 'custom' ? 'singular-custom-settings' : 'singular-custom-settings hidden'));
    $form['custom']['background_file'] = array('#type' => 'file', '#title' => t('Background image'), '#maxlength' => 40);
    if (!empty($settings['background_path'])) {
        $form['custom']['background_preview'] = array('#type' => 'markup', '#value' => !empty($settings['background_path']) ? theme('image', $settings['background_path'], NULL, NULL, array('width' => '100'), FALSE) : '');
    }
    $form['custom']['background_path'] = array('#type' => 'value', '#value' => !empty($settings['background_path']) ? $settings['background_path'] : '');
    $form['custom']['background_color'] = array('#title' => t('Background color'), '#type' => 'textfield', '#size' => '7', '#maxlength' => '7', '#default_value' => !empty($settings['background_color']) ? $settings['background_color'] : '#888888', '#suffix' => '<div id="singular-colorpicker"></div>');
    $form['custom']['background_repeat'] = array('#title' => t('Tile'), '#type' => 'select', '#options' => array('no-repeat' => t('Don\'t tile'), 'repeat-x' => t('Horizontal'), 'repeat-y' => t('Vertical'), 'repeat' => t('Both')), '#default_value' => !empty($settings['background_repeat']) ? $settings['background_repeat'] : 'no-repeat');
    return $form;
}
Example #4
0
 public function __construct($wsdl_root, $wsdl_keys = array('Authentication' => NULL, 'DataAccess' => NULL), $ui_root)
 {
     $this->wsdl_root = trim($wsdl_root, '/') . '/';
     $this->wsdl_keys = $wsdl_keys;
     $this->ui_root = trim($ui_root, '/') . '/';
     $this->cache_dir = realpath(file_directory_path());
     $this->errors = array();
 }
Example #5
0
function _ad_blueprint_write_css()
{
    // Set the location of the custom.css file
    $file_path = file_directory_path() . '/ad_blueprint/custom.css';
    // If the directory doesn't exist, create it
    file_check_directory(dirname($file_path), FILE_CREATE_DIRECTORY);
    // Generate the CSS
    $file_contents = _ad_blueprint_build_css();
    $output = '<div class="description">' . t('This CSS is generated by the settings chosen above and placed in the files directory: ' . l($file_path, $file_path) . '. The file is generated each time this page (and only this page) is loaded. <strong class="marker">Make sure to refresh your page to see the changes</strong>') . '</div>';
    file_save_data($file_contents, $file_path, FILE_EXISTS_REPLACE);
    return $output;
}
Example #6
0
 function log($str)
 {
     if (!file_exists(file_directory_path() . '/kaltura.log')) {
         $klog = fopen(file_directory_path() . '/kaltura.log', 'w');
         if ($klog) {
             fclose($klog);
         }
     }
     if (file_exists(file_directory_path() . '/kaltura.log')) {
         $klog = fopen(file_directory_path() . '/kaltura.log', 'a');
         if (!$klog) {
             watchdog('kaltura client', $str);
         } else {
             fwrite($klog, $str . PHP_EOL);
             fclose($klog);
         }
     }
 }
Example #7
0
 function add_datastream_from_file($datastream_file, $datastream_id, $datastream_label = null, $datastream_mimetype = '', $controlGroup = 'M')
 {
     module_load_include('php', 'fedora_repository', 'mimetype');
     if (empty($datastream_mimetype)) {
         // Get mime type from the file extension.
         $mimetype_helper = new mimetype();
         $datastream_mimetype = $mimetype_helper->getType($datastream_file);
     }
     $original_path = $datastream_file;
     // Temporarily move file to a web-accessible location.
     file_copy($datastream_file, file_directory_path());
     $datastream_url = drupal_urlencode($datastream_file);
     $url = file_create_url($datastream_url);
     $return_value = $this->add_datastream_from_url($url, $datastream_id, $datastream_label, $datastream_mimetype, $controlGroup);
     if ($original_path != $datastream_file) {
         file_delete($datastream_file);
     }
     return $return_value;
 }
Example #8
0
 function log($str)
 {
     // @todo Replace undefined function or remove the class if not used.
     if (!file_exists(file_directory_path() . '/kaltura.log')) {
         $klog = fopen(file_directory_path() . '/kaltura.log', 'w');
         if ($klog) {
             fclose($klog);
         }
     }
     if (file_exists(file_directory_path() . '/kaltura.log')) {
         $klog = fopen(file_directory_path() . '/kaltura.log', 'a');
         if (!$klog) {
             watchdog('kaltura client', $str);
         } else {
             fwrite($klog, $str . PHP_EOL);
             fclose($klog);
         }
     }
 }
Example #9
0
/**
 * Exports a fedora collection object and all of its children in a format
 * that will let you import them into another repository.
 * @param <type> $format
 */
function export_collection($collection_pid, $relationship = 'isMemberOfCollection', $format = 'info:fedora/fedora-system:FOXML-1.1')
{
    $collection_item = new Fedora_Item($collection_pid);
    $foxml = $collection_item->export_as_foxml();
    $file_dir = file_directory_path();
    // Create a temporary directory to contain the exported FOXML files.
    $container = tempnam($file_dir, 'export_');
    file_delete($container);
    print $container;
    if (mkdir($container) && mkdir($container . '/' . $collection_pid)) {
        $foxml_dir = $container . '/' . $collection_pid;
        $file = fopen($foxml_dir . '/' . $collection_pid . '.xml', 'w');
        fwrite($file, $foxml);
        fclose($file);
        $member_pids = get_related_items_as_array($collection_pid, $relationship);
        foreach ($member_pids as $member) {
            $file = fopen($foxml_dir . '/' . $member . '.xml', 'w');
            $item = new Fedora_Item($member);
            $item_foxml = $item->export_as_foxml();
            fwrite($file, $item_foxml);
            fclose($file);
        }
        if (system("cd {$container};zip -r {$collection_pid}.zip {$collection_pid}/* >/dev/null") == 0) {
            header("Content-type: application/zip");
            header('Content-Disposition: attachment; filename="' . $collection_pid . '.zip' . '"');
            $fh = fopen($container . '/' . $collection_pid . '.zip', 'r');
            $theData = fread($fh, filesize($container . '/' . $collection_pid . '.zip'));
            fclose($fh);
            echo $theData;
        }
        if (file_exists($container . '/' . $collection_pid)) {
            system("rm -rf {$container}");
            // I'm sorry.
        }
    } else {
        drupal_set_message("Error creating temp directory for batch export.", 'error');
        return false;
    }
    return true;
}
/**
 * Prepare a CCK field array for use with Devel Generate.
 *
 * @return
 *   A keyed array with keys defined as necessary for the $field array passed
 *   to your modules implementation of Devel Generates hook_content_generate().
 */
function hook_custom_formatters_field_prepare()
{
    file_check_directory($path = file_directory_path() . '/._tmp.custom_formatters', TRUE);
    return array('widget' => array('file_extensions' => 'jpg png', 'file_path' => '._tmp.custom_formatters'));
}
Example #11
0
<?php

/**
 * Insert this code in the phpfilter of the content type 'Setting', text field 'Section'.
 */
$ya_xml_resources = array('http://center.youthagora.org/xml/esn-satellite/sections.xml', 'http://galaxy.esn.org/sections/xml');
$ya_xml_local_file = file_directory_path() . '/' . 'sections.xml';
if (file_exists($ya_xml_local_file)) {
    array_unshift($ya_xml_resources, $ya_xml_local_file);
}
$ya_xml = false;
foreach ($ya_xml_resources as $ya_xml_resource) {
    $ya_xml = @simplexml_load_file($ya_xml_resource, 'SimpleXMLElement', LIBXML_NOCDATA);
    if ($ya_xml) {
        break;
    }
}
if ($ya_xml) {
    foreach ($ya_xml->section as $item) {
        $elements['id'] = (string) $item->id;
        $elements['sc'] = (string) $item->sc;
        $elements['sectionname'] = (string) $item->sectionname;
        $elements['l'] = (string) $item->l;
        $elements['universityname'] = (string) $item->universityname;
        $elements['street'] = (string) $item->street;
        $elements['postaladdress'] = (string) $item->postaladdress;
        $elements['telephonenumber'] = (string) $item->telephonenumber;
        $elements['facsimiletelephonenumber'] = (string) $item->facsimiletelephonenumber;
        $elements['mail'] = (string) $item->mail;
        $elements['universitywebsite'] = (string) $item->universitywebsite;
        $elements['sectionpin'] = (string) $item->sectionpin;
Example #12
0
$issue->field_operating_system[0]['value'] = 'Other';
//Body has full OS
$issue->changed = $issue->created;
$issue->format = 5;
// Markdown, allows filtered HTML, as well.
$issue->comment = 2;
// Allow comments, otherwise they're invisible!
if ($private) {
    $issue->private = 1;
}
node_save($issue);
$nid = $issue->nid;
if ($validation || $configcheck || $collected) {
    // Process attachments
    $issue_dir = variable_get('project_directory_issues', 'issues');
    $dest = file_directory_path() . '/' . $issue_dir;
    // Drupal's standard files path
    if (!file_check_directory($dest)) {
        echo "<br>Error processing attachments.  Event has been logged and an administrator notified.\n";
        error_log("Attachment directory {$dest} does not exist or is not writable.");
        exit;
    }
    foreach (array($validation, $configcheck, $collected) as $attachment) {
        if (empty($attachment)) {
            continue;
        }
        // Generate a randomish unique file name
        $file_id = $nid . "_" . time() . posix_getpid() . ++$acount;
        // Save the file and put the path into $file
        $file = file_save_data($attachment, "{$dest}/{$file_id}", $replace = FILE_EXISTS_RENAME);
        // Make it a node in Drupal
Example #13
0
 function ingestAudio($file)
 {
     $filename = substr(strrchr($file, '/'), 1);
     $output_path = $_SERVER['DOCUMENT_ROOT'] . base_path() . file_directory_path() . '/' . $filename;
     $_SESSION['fedora_ingest_files']["MP3"] = $output_path;
 }
Example #14
0
File: install.php Project: EWB/lrcs
/**
 * The Drupal installation happens in a series of steps. We begin by verifying
 * that the current environment meets our minimum requirements. We then go
 * on to verify that settings.php is properly configured. From there we
 * connect to the configured database and verify that it meets our minimum
 * requirements. Finally we can allow the user to select an installation
 * profile and complete the installation process.
 *
 * @param $phase
 *   The installation phase we should proceed to.
 */
function install_main()
{
    require_once './includes/bootstrap.inc';
    drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION);
    // This must go after drupal_bootstrap(), which unsets globals!
    global $profile, $install_locale, $conf;
    require_once './modules/system/system.install';
    require_once './includes/file.inc';
    // Ensure correct page headers are sent (e.g. caching)
    drupal_page_header();
    // Set up $language, so t() caller functions will still work.
    drupal_init_language();
    // Load module basics (needed for hook invokes).
    include_once './includes/module.inc';
    $module_list['system']['filename'] = 'modules/system/system.module';
    $module_list['filter']['filename'] = 'modules/filter/filter.module';
    module_list(TRUE, FALSE, FALSE, $module_list);
    drupal_load('module', 'system');
    drupal_load('module', 'filter');
    // Install profile chosen, set the global immediately.
    // This needs to be done before the theme cache gets
    // initialized in drupal_maintenance_theme().
    if (!empty($_GET['profile'])) {
        $profile = preg_replace('/[^a-zA-Z_0-9]/', '', $_GET['profile']);
    }
    // Set up theme system for the maintenance page.
    drupal_maintenance_theme();
    // Check existing settings.php.
    $verify = install_verify_settings();
    if ($verify) {
        // Since we have a database connection, we use the normal cache system.
        // This is important, as the installer calls into the Drupal system for
        // the clean URL checks, so we should maintain the cache properly.
        require_once './includes/cache.inc';
        $conf['cache_inc'] = './includes/cache.inc';
        // Establish a connection to the database.
        require_once './includes/database.inc';
        db_set_active();
        // Check if Drupal is installed.
        $task = install_verify_drupal();
        if ($task == 'done') {
            install_already_done_error();
        }
    } else {
        // Since no persistent storage is available yet, and functions that check
        // for cached data will fail, we temporarily replace the normal cache
        // system with a stubbed-out version that short-circuits the actual
        // caching process and avoids any errors.
        require_once './includes/cache-install.inc';
        $conf['cache_inc'] = './includes/cache-install.inc';
        $task = NULL;
    }
    // No profile was passed in GET, ask the user.
    if (empty($_GET['profile'])) {
        if ($profile = install_select_profile()) {
            install_goto("install.php?profile={$profile}");
        } else {
            install_no_profile_error();
        }
    }
    // Load the profile.
    require_once "./profiles/{$profile}/{$profile}.profile";
    // Locale selection
    if (!empty($_GET['locale'])) {
        $install_locale = preg_replace('/[^a-zA-Z_0-9\\-]/', '', $_GET['locale']);
    } elseif (($install_locale = install_select_locale($profile)) !== FALSE) {
        install_goto("install.php?profile={$profile}&locale={$install_locale}");
    }
    // Tasks come after the database is set up
    if (!$task) {
        global $db_url;
        if (!$verify && !empty($db_url)) {
            // Do not install over a configured settings.php.
            install_already_done_error();
        }
        // Check the installation requirements for Drupal and this profile.
        install_check_requirements($profile, $verify);
        // Verify existence of all required modules.
        $modules = drupal_verify_profile($profile, $install_locale);
        // If any error messages are set now, it means a requirement problem.
        $messages = drupal_set_message();
        if (!empty($messages['error'])) {
            install_task_list('requirements');
            drupal_set_title(st('Requirements problem'));
            print theme('install_page', '');
            exit;
        }
        // Change the settings.php information if verification failed earlier.
        // Note: will trigger a redirect if database credentials change.
        if (!$verify) {
            install_change_settings($profile, $install_locale);
        }
        // The default lock implementation uses a database table,
        // so we cannot use it for install, but we still need
        // the API functions available.
        require_once './includes/lock-install.inc';
        $conf['lock_inc'] = './includes/lock-install.inc';
        lock_init();
        // Install system.module.
        drupal_install_system();
        // Ensure that all of Drupal's standard directories have appropriate
        // .htaccess files. These directories will have already been created by
        // this point in the installer, since Drupal creates them during the
        // install_check_requirements() task. Note that we cannot create them any
        // earlier than this, since the code below relies on system.module in order
        // to work.
        file_create_htaccess(file_directory_path());
        file_create_htaccess(file_directory_temp());
        // Save the list of other modules to install for the 'profile-install'
        // task. variable_set() can be used now that system.module is installed
        // and drupal is bootstrapped.
        variable_set('install_profile_modules', array_diff($modules, array('system')));
    }
    // The database is set up, turn to further tasks.
    install_tasks($profile, $task);
}
Example #15
0
            $fck_cwd = getcwd();
            chdir($drupal_path);
            require_once './includes/bootstrap.inc';
            drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
            $authenticated = user_access('allow fckeditor file uploads');
            if (isset($_SESSION['FCKeditor']['UserFilesPath'], $_SESSION['FCKeditor']['UserFilesAbsolutePath'])) {
                $GLOBALS['fck_user_files_path'] = $_SESSION['FCKeditor']['UserFilesPath'];
                $GLOBALS['fck_user_files_absolute_path'] = $_SESSION['FCKeditor']['UserFilesAbsolutePath'];
            }
            chdir($fck_cwd);
        }
    }
    return $authenticated;
}
/**
 * Note:
 * Although in FCKeditor 2.5 $Config['Enabled'] is not used anymore,
 * CheckAuthentication() must be called once to initialize session
 * before sending any content
 * Static $authenticated variable is being assigned, so
 * application performance is not affected
 */
$Config['Enabled'] = CheckAuthentication();
if (!empty($fck_user_files_path)) {
    $Config['UserFilesPath'] = $fck_user_files_path;
    $Config['UserFilesAbsolutePath'] = $fck_user_files_absolute_path;
} else {
    // Nothing in session? Shouldn't happen... anyway let's try to upload it in the (almost) right place
    // Path to user files relative to the document root.
    $Config['UserFilesPath'] = strtr(base_path(), array('/modules/fckeditor/fckeditor/editor/filemanager/connectors/php' => '', '/modules/fckeditor/fckeditor/editor/filemanager/browser/default/connectors/php' => '', '/modules/fckeditor/fckeditor/editor/filemanager/upload/php' => '')) . file_directory_path() . '/';
}
 /**
  * Delete created files and temporary files directory, delete the tables created by setUp(),
  * and reset the database prefix.
  */
 protected function tearDown()
 {
     global $db_prefix, $user, $language;
     $emailCount = count(variable_get('simpletest_emails', array()));
     if ($emailCount) {
         $message = format_plural($emailCount, t('!count e-mail was sent during this test.'), t('!count e-mails were sent during this test.'), array('!count' => $emailCount));
         $this->pass($message, t('E-mail'));
     }
     if (preg_match('/simpletest\\d+/', $db_prefix)) {
         // Delete temporary files directory and reset files directory path.
         file_unmanaged_delete_recursive(file_directory_path());
         variable_set('file_directory_path', $this->originalFileDirectory);
         // Remove all prefixed tables (all the tables in the schema).
         $schema = drupal_get_schema(NULL, TRUE);
         $ret = array();
         foreach ($schema as $name => $table) {
             db_drop_table($ret, $name);
         }
         // Return the database prefix to the original.
         $db_prefix = $this->originalPrefix;
         // Return the user to the original one.
         $user = $this->originalUser;
         drupal_save_session(TRUE);
         // Ensure that internal logged in variable and cURL options are reset.
         $this->loggedInUser = FALSE;
         $this->additionalCurlOptions = array();
         // Reload module list and implementations to ensure that test module hooks
         // aren't called after tests.
         module_list(TRUE);
         module_implements(MODULE_IMPLEMENTS_CLEAR_CACHE);
         // Reset the Field API.
         field_cache_clear();
         // Rebuild caches.
         $this->refreshVariables();
         // Reset language.
         $language = $this->originalLanguage;
         if ($this->originalLanguageDefault) {
             $GLOBALS['conf']['language_default'] = $this->originalLanguageDefault;
         }
         // Close the CURL handler.
         $this->curlClose();
     }
 }
 /**
  * Delete created files and temporary files directory, delete the tables created by setUp(),
  * and reset the database prefix.
  */
 protected function tearDown()
 {
     global $db_prefix, $user;
     if (preg_match('/simpletest\\d+/', $db_prefix)) {
         // Delete temporary files directory and reset files directory path.
         file_unmanaged_delete_recursive(file_directory_path());
         variable_set('file_directory_path', $this->originalFileDirectory);
         // Remove all prefixed tables (all the tables in the schema).
         $schema = drupal_get_schema(NULL, TRUE);
         $ret = array();
         foreach ($schema as $name => $table) {
             db_drop_table($ret, $name);
         }
         // Return the database prefix to the original.
         $db_prefix = $this->originalPrefix;
         // Return the user to the original one.
         $user = $this->originalUser;
         drupal_save_session(TRUE);
         // Ensure that internal logged in variable and cURL options are reset.
         $this->loggedInUser = FALSE;
         $this->additionalCurlOptions = array();
         // Reload module list and implementations to ensure that test module hooks
         // aren't called after tests.
         module_list(TRUE);
         module_implements(MODULE_IMPLEMENTS_CLEAR_CACHE);
         // Reset the Field API.
         field_cache_clear();
         // Rebuild caches.
         $this->refreshVariables();
         // Close the CURL handler.
         $this->curlClose();
     }
 }
 /**
  * Generates a random database prefix, runs the install scripts on the
  * prefixed database and enable the specified modules. After installation
  * many caches are flushed and the internal browser is setup so that the
  * page requests will run on the new prefix. A temporary files directory
  * is created with the same name as the database prefix.
  *
  * @param ...
  *   List of modules to enable for the duration of the test.
  */
 protected function setUp()
 {
     global $db_prefix, $user, $language;
     // Store necessary current values before switching to prefixed database.
     $this->originalLanguage = $language;
     $this->originalLanguageDefault = variable_get('language_default');
     $this->originalPrefix = $db_prefix;
     $this->originalFileDirectory = file_directory_path();
     $this->originalProfile = drupal_get_profile();
     $clean_url_original = variable_get('clean_url', 0);
     // Generate temporary prefixed database to ensure that tests have a clean starting point.
     $db_prefix_new = Database::getConnection()->prefixTables('{simpletest' . mt_rand(1000, 1000000) . '}');
     db_update('simpletest_test_id')->fields(array('last_prefix' => $db_prefix_new))->condition('test_id', $this->testId)->execute();
     $db_prefix = $db_prefix_new;
     // Create test directory ahead of installation so fatal errors and debug
     // information can be logged during installation process.
     // Use temporary files directory with the same prefix as the database.
     $public_files_directory = $this->originalFileDirectory . '/simpletest/' . substr($db_prefix, 10);
     $private_files_directory = $public_files_directory . '/private';
     $temp_files_directory = $private_files_directory . '/temp';
     // Create the directories
     file_prepare_directory($public_files_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
     file_prepare_directory($private_files_directory, FILE_CREATE_DIRECTORY);
     file_prepare_directory($temp_files_directory, FILE_CREATE_DIRECTORY);
     $this->generatedTestFiles = FALSE;
     // Log fatal errors.
     ini_set('log_errors', 1);
     ini_set('error_log', $public_files_directory . '/error.log');
     // Reset all statics so that test is performed with a clean environment.
     drupal_static_reset();
     include_once DRUPAL_ROOT . '/includes/install.inc';
     drupal_install_system();
     $this->preloadRegistry();
     // Include the default profile
     variable_set('install_profile', 'standard');
     $profile_details = install_profile_info('standard', 'en');
     // Install the modules specified by the default profile.
     drupal_install_modules($profile_details['dependencies'], TRUE);
     drupal_static_reset('_node_types_build');
     if ($modules = func_get_args()) {
         // Install modules needed for this test.
         drupal_install_modules($modules, TRUE);
     }
     // Because the schema is static cached, we need to flush
     // it between each run. If we don't, then it will contain
     // stale data for the previous run's database prefix and all
     // calls to it will fail.
     drupal_get_schema(NULL, TRUE);
     // Run default profile tasks.
     $install_state = array();
     drupal_install_modules(array('standard'), TRUE);
     // Rebuild caches.
     node_types_rebuild();
     actions_synchronize();
     _drupal_flush_css_js();
     $this->refreshVariables();
     $this->checkPermissions(array(), TRUE);
     // Log in with a clean $user.
     $this->originalUser = $user;
     drupal_save_session(FALSE);
     $user = user_load(1);
     // Restore necessary variables.
     variable_set('install_task', 'done');
     variable_set('clean_url', $clean_url_original);
     variable_set('site_mail', '*****@*****.**');
     // Set up English language.
     unset($GLOBALS['conf']['language_default']);
     $language = language_default();
     // Set path variables
     variable_set('file_public_path', $public_files_directory);
     variable_set('file_private_path', $private_files_directory);
     variable_set('file_temporary_path', $temp_files_directory);
     // Use the test mail class instead of the default mail handler class.
     variable_set('mail_system', array('default-system' => 'TestingMailSystem'));
     drupal_set_time_limit($this->timeLimit);
 }
Example #19
0
function budgets_supplier_form_submit($form_id, &$form_values)
{
    $supplier =& $form_values['values'];
    guifi_log(GUIFILOG_TRACE, 'function budgets_supplier_submit()', $supplier);
    /*
     * Delete logo
     */
    if (isset($supplier['Delete'])) {
        $result = file_delete($supplier['logo']);
        guifi_log(GUIFILOG_TRACE, 'function budgets_supplier_submit(DELETE)', $result);
        $supplier['logo'] = null;
        $form_values['#redirect'] = FALSE;
        $form_values['rebuild'] = TRUE;
        return;
    }
    #this leads us to sites/mysite.example.com/files/
    $dir = file_directory_path();
    $dir .= '/suppliers';
    guifi_log(GUIFILOG_TRACE, 'function budgets_supplier_submit(DIR)', $dir);
    # unlike form submissions, multipart form submissions are not in
    # $form_state, but rather in $FILES, which requires more checking
    if (isset($_FILES) && !empty($_FILES) && $_FILES['files']['size']['logo'] != 0) {
        #this structure is kind of wacky
        $name = $_FILES['files']['name']['logo'];
        $size = $_FILES['files']['size']['logo'];
        $type = $_FILES['files']['type']['logo'];
        #this is the actual place where we store the file
        $file = file_save_upload('logo', array(), $dir);
        if ($file) {
            drupal_set_message(t('You uploaded %name', array('%name' => $name)));
            guifi_log(GUIFILOG_TRACE, 'file', $file->filepath);
            $supplier['logo'] = $file->filepath;
            file_set_status($file, FILE_STATUS_PERMANENT);
        } else {
            drupal_set_message("Something went wrong saving your file.");
        }
    } else {
        drupal_set_message("Your file doesn't appear to be here.");
    }
    $form_values['#redirect'] = FALSE;
    $form_values['rebuild'] = TRUE;
}
 /**
  * Delete created files and temporary files directory, delete the tables created by setUp(),
  * and reset the database prefix.
  */
 function tearDown()
 {
     global $db_prefix;
     if (preg_match('/simpletest\\d+/', $db_prefix)) {
         // Delete temporary files directory and reset files directory path.
         simpletest_clean_temporary_directory(file_directory_path());
         variable_set('file_directory_path', $this->original_file_directory);
         $schema = drupal_get_schema(NULL, TRUE);
         $ret = array();
         foreach ($schema as $name => $table) {
             db_drop_table($ret, $name);
         }
         $db_prefix = $this->db_prefix_original;
         $this->_logged_in = FALSE;
         $this->curlClose();
     }
     parent::tearDown();
 }
Example #21
0
 /**
  * Delete created files and temporary files directory, delete the tables created by setUp(),
  * and reset the database prefix.
  */
 protected function tearDown()
 {
     global $db_prefix;
     if (preg_match('/simpletest\\d+/', $db_prefix)) {
         // Delete temporary files directory and reset files directory path.
         simpletest_clean_temporary_directory(file_directory_path());
         variable_set('file_directory_path', $this->originalFileDirectory);
         // Remove all prefixed tables (all the tables in the schema).
         $schema = drupal_get_schema(NULL, TRUE);
         $ret = array();
         foreach ($schema as $name => $table) {
             db_drop_table($ret, $name);
         }
         // Return the database prefix to the original.
         $db_prefix = $this->originalPrefix;
         // Ensure that the internal logged in variable is reset.
         $this->isLoggedIn = FALSE;
         // Reload module list and implementations to ensure that test module hooks
         // aren't called after tests.
         module_list(TRUE);
         module_implements(MODULE_IMPLEMENTS_CLEAR_CACHE);
         // Rebuild caches.
         $this->refreshVariables();
         // Close the CURL handler.
         $this->curlClose();
     }
 }
Example #22
0
 /**
  * Generates a random database prefix, runs the install scripts on the
  * prefixed database and enable the specified modules. After installation
  * many caches are flushed and the internal browser is setup so that the
  * page requests will run on the new prefix. A temporary files directory
  * is created with the same name as the database prefix.
  *
  * @param ...
  *   List of modules to enable for the duration of the test.
  */
 function setUp()
 {
     global $db_prefix, $user, $language;
     // $language (Drupal 6).
     global $install_locale;
     // Store necessary current values before switching to prefixed database.
     $this->db_prefix_original = $db_prefix;
     $clean_url_original = variable_get('clean_url', 0);
     // Generate temporary prefixed database to ensure that tests have a clean starting point.
     $db_prefix = 'simpletest' . mt_rand(1000, 1000000);
     include_once './includes/install.inc';
     drupal_install_system();
     // Add the specified modules to the list of modules in the default profile.
     $args = func_get_args();
     // Add language and basic i18n modules
     $install_locale = $this->install_locale;
     $i18n_modules = array('locale', 'translation', 'i18n', 'i18n_test');
     $modules = array_unique(array_merge(drupal_verify_profile('default', $this->install_locale), $args, $i18n_modules));
     drupal_install_modules($modules);
     // Install locale
     if ($this->install_locale != 'en') {
         $this->addLanguage($this->install_locale, TRUE);
     }
     // Run default profile tasks.
     $task = 'profile';
     default_profile_tasks($task, '');
     // Rebuild caches.
     actions_synchronize();
     _drupal_flush_css_js();
     $this->refreshVariables();
     $this->checkPermissions(array(), TRUE);
     user_access(NULL, NULL, TRUE);
     // Drupal 6.
     // Log in with a clean $user.
     $this->originalUser = $user;
     //    drupal_save_session(FALSE);
     //    $user = user_load(1);
     session_save_session(FALSE);
     $user = user_load(1);
     // Restore necessary variables.
     variable_set('install_profile', 'default');
     variable_set('install_task', 'profile-finished');
     variable_set('clean_url', $clean_url_original);
     variable_set('site_mail', '*****@*****.**');
     // Use temporary files directory with the same prefix as database.
     $this->originalFileDirectory = file_directory_path();
     variable_set('file_directory_path', file_directory_path() . '/' . $db_prefix);
     $directory = file_directory_path();
     // Create the files directory.
     file_check_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
     drupal_set_time_limit($this->timeLimit);
     // Some more includes
     require_once 'includes/language.inc';
     // Refresh theme
     $this->initTheme();
     // Set path languages so we can retrieve pages in different languages
     variable_set('language_negotiation', LANGUAGE_NEGOTIATION_PATH);
 }
Example #23
0
 /**
  * Delete created files and temporary files directory, delete the tables created by setUp(),
  * and reset the database prefix.
  */
 protected function tearDown()
 {
     global $db_prefix, $user, $language;
     // In case a fatal error occured that was not in the test process read the
     // log to pick up any fatal errors.
     $db_prefix_temp = $db_prefix;
     $db_prefix = $this->originalPrefix;
     simpletest_log_read($this->testId, $db_prefix, get_class($this), TRUE);
     $db_prefix = $db_prefix_temp;
     $emailCount = count(variable_get('drupal_test_email_collector', array()));
     if ($emailCount) {
         $message = format_plural($emailCount, t('!count e-mail was sent during this test.'), t('!count e-mails were sent during this test.'), array('!count' => $emailCount));
         $this->pass($message, t('E-mail'));
     }
     if (preg_match('/simpletest\\d+/', $db_prefix)) {
         // Delete temporary files directory.
         //      file_unmanaged_delete_recursive(file_directory_path());
         simpletest_clean_temporary_directory(file_directory_path());
         // Remove all prefixed tables (all the tables in the schema).
         $schema = drupal_get_schema(NULL, TRUE);
         $ret = array();
         foreach ($schema as $name => $table) {
             db_drop_table($ret, $name);
         }
         // Return the database prefix to the original.
         $db_prefix = $this->originalPrefix;
         // Return the user to the original one.
         $user = $this->originalUser;
         //      drupal_save_session(TRUE);
         session_save_session(TRUE);
         // Bring back default language. (Drupal 6)
         if (module_exists('locale')) {
             drupal_init_language();
             locale(NULL, NULL, TRUE);
         }
         // Ensure that internal logged in variable and cURL options are reset.
         $this->loggedInUser = FALSE;
         $this->additionalCurlOptions = array();
         // Reload module list and implementations to ensure that test module hooks
         // aren't called after tests.
         module_list(TRUE);
         //      module_implements('', FALSE, TRUE);
         module_implements('', '', TRUE);
         // Reset the Field API.
         //      field_cache_clear();
         // Rebuild caches.
         $this->refreshVariables();
         //      // Reset language.
         //      $language = $this->originalLanguage;
         //      if ($this->originalLanguageDefault) {
         //        $GLOBALS['conf']['language_default'] = $this->originalLanguageDefault;
         //      }
         // Close the CURL handler.
         $this->curlClose();
     }
 }
 /**
  * Generates a random database prefix, runs the install scripts on the
  * prefixed database and enable the specified modules. After installation
  * many caches are flushed and the internal browser is setup so that the
  * page requests will run on the new prefix. A temporary files directory
  * is created with the same name as the database prefix.
  *
  * @param ...
  *   List of modules to enable for the duration of the test. This can be
  *   either a single array or a variable number of string arguments.
  */
 protected function setUp()
 {
     global $user, $language, $conf;
     // Generate a temporary prefixed database to ensure that tests have a clean starting point.
     $this->databasePrefix = 'simpletest' . mt_rand(1000, 1000000);
     db_update('simpletest_test_id')->fields(array('last_prefix' => $this->databasePrefix))->condition('test_id', $this->testId)->execute();
     // Clone the current connection and replace the current prefix.
     $connection_info = Database::getConnectionInfo('default');
     Database::renameConnection('default', 'simpletest_original_default');
     foreach ($connection_info as $target => $value) {
         $connection_info[$target]['prefix'] = array('default' => $value['prefix']['default'] . $this->databasePrefix);
     }
     Database::addConnectionInfo('default', 'default', $connection_info['default']);
     // Store necessary current values before switching to prefixed database.
     $this->originalLanguage = $language;
     $this->originalLanguageDefault = variable_get('language_default');
     $this->originalFileDirectory = file_directory_path();
     $this->originalProfile = drupal_get_profile();
     $clean_url_original = variable_get('clean_url', 0);
     // Save and clean shutdown callbacks array because it static cached and
     // will be changed by the test run. If we don't, then it will contain
     // callbacks from both environments. So testing environment will try
     // to call handlers from original environment.
     $callbacks =& drupal_register_shutdown_function();
     $this->originalShutdownCallbacks = $callbacks;
     $callbacks = array();
     // Create test directory ahead of installation so fatal errors and debug
     // information can be logged during installation process.
     // Use temporary files directory with the same prefix as the database.
     $public_files_directory = $this->originalFileDirectory . '/simpletest/' . substr($this->databasePrefix, 10);
     $private_files_directory = $public_files_directory . '/private';
     $temp_files_directory = $private_files_directory . '/temp';
     // Create the directories
     file_prepare_directory($public_files_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
     file_prepare_directory($private_files_directory, FILE_CREATE_DIRECTORY);
     file_prepare_directory($temp_files_directory, FILE_CREATE_DIRECTORY);
     $this->generatedTestFiles = FALSE;
     // Log fatal errors.
     ini_set('log_errors', 1);
     ini_set('error_log', $public_files_directory . '/error.log');
     // Reset all statics and variables to perform tests in a clean environment.
     $conf = array();
     drupal_static_reset();
     // Set the test information for use in other parts of Drupal.
     $test_info =& $GLOBALS['drupal_test_info'];
     $test_info['test_run_id'] = $this->databasePrefix;
     $test_info['in_child_site'] = FALSE;
     include_once DRUPAL_ROOT . '/includes/install.inc';
     drupal_install_system();
     $this->preloadRegistry();
     // Set path variables.
     variable_set('file_public_path', $public_files_directory);
     variable_set('file_private_path', $private_files_directory);
     variable_set('file_temporary_path', $temp_files_directory);
     // Include the default profile.
     variable_set('install_profile', 'standard');
     $profile_details = install_profile_info('standard', 'en');
     // Install the modules specified by the default profile.
     module_enable($profile_details['dependencies'], FALSE);
     // Install modules needed for this test. This could have been passed in as
     // either a single array argument or a variable number of string arguments.
     // @todo Remove this compatibility layer in Drupal 8, and only accept
     // $modules as a single array argument.
     $modules = func_get_args();
     if (isset($modules[0]) && is_array($modules[0])) {
         $modules = $modules[0];
     }
     if ($modules) {
         module_enable($modules, TRUE);
     }
     // Run default profile tasks.
     module_enable(array('standard'), FALSE);
     // Rebuild caches.
     drupal_static_reset();
     drupal_flush_all_caches();
     // Register actions declared by any modules.
     actions_synchronize();
     // Reload global $conf array and permissions.
     $this->refreshVariables();
     $this->checkPermissions(array(), TRUE);
     // Reset statically cached schema for new database prefix.
     drupal_get_schema(NULL, TRUE);
     // Run cron once in that environment, as install.php does at the end of
     // the installation process.
     drupal_cron_run();
     // Log in with a clean $user.
     $this->originalUser = $user;
     drupal_save_session(FALSE);
     $user = user_load(1);
     // Restore necessary variables.
     variable_set('install_task', 'done');
     variable_set('clean_url', $clean_url_original);
     variable_set('site_mail', '*****@*****.**');
     variable_set('date_default_timezone', date_default_timezone_get());
     // Set up English language.
     unset($GLOBALS['conf']['language_default']);
     $language = language_default();
     // Use the test mail class instead of the default mail handler class.
     variable_set('mail_system', array('default-system' => 'TestingMailSystem'));
     drupal_set_time_limit($this->timeLimit);
 }
Example #25
0
                do {
                    $drupal_path .= '/..';
                    $depth = substr_count($drupal_path, '..');
                } while (!($bootstrap_file_found = file_exists($drupal_path . '/includes/bootstrap.inc')) && $depth < 10);
            }
        }
        if (!isset($bootstrap_file_found) || $bootstrap_file_found) {
            $current_cwd = getcwd();
            chdir($drupal_path);
            require_once './includes/bootstrap.inc';
            drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
            $authenticated = user_access('allow CKFinder file uploads');
            if (isset($_SESSION['ckeditor']['UserFilesPath'], $_SESSION['ckeditor']['UserFilesAbsolutePath'])) {
                $GLOBALS['ckfinder_user_files_path'] = $_SESSION['ckeditor']['UserFilesPath'];
                $GLOBALS['ckfinder_user_files_absolute_path'] = $_SESSION['ckeditor']['UserFilesAbsolutePath'];
            }
            chdir($current_cwd);
        }
    }
    return $authenticated;
}
CheckAuthentication();
if (!empty($ckfinder_user_files_path)) {
    $baseUrl = $ckfinder_user_files_path;
    $baseDir = $ckfinder_user_files_absolute_path;
} else {
    // Nothing in session? Shouldn't happen... anyway let's try to upload it in the (almost) right place
    // Path to user files relative to the document root.
    $baseUrl = strtr(base_path(), array('/modules/ckeditor/ckfinder/core/connector/php' => '')) . file_directory_path() . '/';
    $baseDir = resolveUrl($baseUrl);
}
Example #26
0
    if (module_exists('node')) {
        foreach (node_get_types() as $type => $name) {
            unset($settings['toggle_node_info_' . $type]);
        }
    }
    // Save default theme settings.
    variable_set(str_replace('/', '_', 'theme_' . $theme_key . '_settings'), array_merge($defaults, $settings));
    // Force refresh of Drupal internals
    theme_get_setting('', TRUE);
}
// Appearance Stylesheet.  Controls the colors, fonts and borders of the theme
if (theme_get_setting('sky_wireframe') == 0) {
    drupal_add_css(path_to_theme() . '/css/appearance.css', 'theme', 'all', TRUE);
}
// Theme Settings Generated CSS
$custom_css = file_directory_path() . '/sky/custom.css';
if (file_exists($custom_css)) {
    drupal_add_css($custom_css, 'theme', 'all', TRUE);
}
// Conditional stylesheets for IE
function _sky_conditional_stylesheets()
{
    $output = "\n" . '<!--[if IE 6.0]><link rel="stylesheet" href="' . base_path() . path_to_theme() . '/css/ie-6.css" type="text/css" media="all" charset="utf-8" /><![endif]-->' . "\n";
    $output .= '<!--[if IE 7.0]><link rel="stylesheet" href="' . base_path() . path_to_theme() . '/css/ie-7.css" type="text/css" media="all" charset="utf-8" /><![endif]-->' . "\n";
    return $output;
}
// Sky Javascipt
drupal_add_js(path_to_theme() . '/js/sky.js');
function sky_preprocess_page(&$variables, $hook)
{
    // Add a page title variable using the site slogan on the front page
Example #27
0
 protected function constructPubPath($docid)
 {
     return file_directory_path() . "/pubnode/{$docid}";
 }
   <?php 
// find an image to display
if ($page == 0) {
    $find = "/src=\"(.+?)\"/i";
    $text2search = $view->result[0]->node_revisions_body;
    preg_match($find, $text2search, $matches);
    if ($matches[1]) {
        $imgttl = check_plain($title);
        $found_image = "<a href='{$node_url}'><img src='" . $matches[1] . "' style='float: left; padding: 5px;' alt='{$imgttl}' title='{$imgttl}' class='teaser'></a>";
    } else {
        $found_image = "";
    }
}
?>
     <?php 
$img_name = explode('/', $matches[1]);
$imgr = array_reverse($img_name);
$img = $imgr[0];
$imagecache_path = file_create_url(file_directory_path() . '/' . $img);
print theme('imagecache', 'teasr', $img, '', '»ллюстраци¤', array('class' => 'teaser'));
print l($view->result[0]->node_revisions_teaser . " <img src=\"themes/basic/css/images/readmore.gif\" class=\"readmore\" />", 'node/' . $view->result[0]->nid, array('attributes' => array(), 'html' => TRUE));
// print_r($view->field['view_node']);
// print_r($view);
//    $view->field['teaser_1']->render($row);
?>

<?php 
/*echo "</pre>"*/
?>

 /**
  * Installs Atrium instead of Drupal
  * 
  * Generates a random database prefix, runs the install scripts on the
  * prefixed database and enable the specified modules. After installation
  * many caches are flushed and the internal browser is setup so that the
  * page requests will run on the new prefix. A temporary files directory
  * is created with the same name as the database prefix.
  *
  * @param ...
  *   List of modules to enable for the duration of the test.
  */
 protected function setUp()
 {
     global $db_prefix, $user, $language, $profile, $install_locale;
     // $language (Drupal 6).
     // Store necessary current values before switching to prefixed database.
     $this->originalPrefix = $db_prefix;
     $this->originalLanguage = clone $language;
     $clean_url_original = variable_get('clean_url', 0);
     // Must reset locale here, since schema calls t().  (Drupal 6)
     if (module_exists('locale')) {
         $language = (object) array('language' => 'en', 'name' => 'English', 'native' => 'English', 'direction' => 0, 'enabled' => 1, 'plurals' => 0, 'formula' => '', 'domain' => '', 'prefix' => '', 'weight' => 0, 'javascript' => '');
         locale(NULL, NULL, TRUE);
     }
     // Generate temporary prefixed database to ensure that tests have a clean starting point.
     //    $db_prefix = Database::getConnection()->prefixTables('{simpletest' . mt_rand(1000, 1000000) . '}');
     $db_prefix = 'simpletest' . mt_rand(1000, 1000000);
     $install_locale = $this->install_locale;
     $profile = $this->install_profile;
     //    include_once DRUPAL_ROOT . '/includes/install.inc';
     include_once './includes/install.inc';
     drupal_install_system();
     //    $this->preloadRegistry();
     // Set up theme system for the maintenance page.
     // Otherwise we have trouble: https://ds.openatrium.com/dsi/node/18426#comment-38118
     // @todo simpletest module patch
     drupal_maintenance_theme();
     // Add the specified modules to the list of modules in the default profile.
     $args = func_get_args();
     //    $modules = array_unique(array_merge(drupal_get_profile_modules('default', 'en'), $args));
     $modules = array_unique(array_merge(drupal_verify_profile($this->install_profile, $this->install_locale), $args));
     //    drupal_install_modules($modules, TRUE);
     drupal_install_modules($modules);
     // Because the schema is static cached, we need to flush
     // it between each run. If we don't, then it will contain
     // stale data for the previous run's database prefix and all
     // calls to it will fail.
     drupal_get_schema(NULL, TRUE);
     if ($this->install_profile == 'openatrium') {
         // Download and import translation if needed
         if ($this->install_locale != 'en') {
             $this->installLanguage($this->install_locale);
         }
         // Install more modules
         $modules = _openatrium_atrium_modules();
         drupal_install_modules($modules);
         // Configure intranet
         // $profile_tasks = $this->install_profile . '_profile_tasks';
         _openatrium_intranet_configure();
         _openatrium_intranet_configure_check();
         variable_set('atrium_install', 1);
         // Clear views cache before rebuilding menu tree. Requires patch
         // [patch_here] to Views, as new modules have been included and
         // default views need to be re-detected.
         module_exists('views') ? views_get_all_views(TRUE) : TRUE;
         menu_rebuild();
     }
     _drupal_flush_css_js();
     $this->refreshVariables();
     $this->checkPermissions(array(), TRUE);
     user_access(NULL, NULL, TRUE);
     // Drupal 6.
     // Log in with a clean $user.
     $this->originalUser = $user;
     //    drupal_save_session(FALSE);
     //    $user = user_load(1);
     session_save_session(FALSE);
     $user = user_load(array('uid' => 1));
     // Restore necessary variables.
     variable_set('install_profile', $this->install_profile);
     variable_set('install_task', 'profile-finished');
     variable_set('clean_url', $clean_url_original);
     variable_set('site_mail', '*****@*****.**');
     // Use temporary files directory with the same prefix as database.
     $this->originalFileDirectory = file_directory_path();
     variable_set('file_directory_path', file_directory_path() . '/' . $db_prefix);
     $directory = file_directory_path();
     // Create the files directory.
     file_check_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
     set_time_limit($this->timeLimit);
 }
				<?php 
print t("Chips") . ": <b class='chips'>" . $os_user->Chips(TRUE) . "</b><br/>";
$s = $os_user->StatusEx($level, $maxl);
print t("Status") . ": {$s} ({$level}/{$maxl})";
?>
			</p>
		</div>

		<?php 
//			if (($num_rewards = $os_user->GetNumRewards()))
if (1) {
    $num_rewards = $os_user->GetNumRewards();
    $rewards = $os_user->Rewards();
    $reward_key = $os_user->GetLastReward();
    $reward_last = $rewards[$reward_key];
    $imagePath = '/' . file_directory_path() . "/poker_rewards/";
    $defaultPicture = $imagePath . "reward_default.gif";
    ?>

			<div class="fleft reward_separator">
				<img src="<?php 
    print drupal_get_path("theme", "poker") . "/images/brief_separator.png";
    ?>
" alt="avatar"/>
			</div>
			<div class="fleft">
			    <p class="reward_title"><strong>
					<?php 
    print t("Your rewards") . ":";
    ?>
			    </strong></p>