Beispiel #1
0
 function handle(&$params)
 {
     $app =& Dataface_Application::getInstance();
     if (df_get_database_version() == df_get_file_system_version()) {
         $app->redirect(DATAFACE_SITE_HREF . '?--msg=' . urlencode('The application database is up to date at version ' . df_get_database_version()));
     }
     if (df_get_database_version() > df_get_file_system_version()) {
         $app->redirect(DATAFACE_SITE_HREF . '?--msg=' . urlencode('The database version is greater than the file system version.  Please upgrade your application to match the version in the database (version ' . df_get_database_version()));
     }
     $res = xf_db_query("select count(*) from dataface__version", df_db());
     if (!$res) {
         throw new Exception(xf_db_error(df_db()));
     }
     $row = xf_db_fetch_row($res);
     if ($row[0] == 0) {
         $res2 = xf_db_query("insert into dataface__version (`version`) values (0)", df_db());
         if (!$res2) {
             throw new Exception(xf_db_error(df_db()));
         }
     }
     if (file_exists('conf/Installer.php')) {
         import('conf/Installer.php');
         $installer = new conf_Installer();
         $methods = get_class_methods('conf_Installer');
         $methods = preg_grep('/^update_([0-9]+)$/', $methods);
         $updates = array();
         foreach ($methods as $method) {
             preg_match('/^update_([0-9]+)$/', $method, $matches);
             $version = intval($matches[1]);
             if ($version > df_get_database_version() and $version <= df_get_file_system_version()) {
                 $updates[] = $version;
             }
         }
         sort($updates);
         foreach ($updates as $update) {
             $method = 'update_' . $update;
             $res = $installer->{$method}();
             if (PEAR::isError($res)) {
                 return $res;
             }
             $res = xf_db_query("update dataface__version set `version`='" . addslashes($update) . "'", df_db());
             if (!$res) {
                 throw new Exception(xf_db_error(df_db()), E_USER_ERROR);
             }
         }
     }
     $res = xf_db_query("update dataface__version set `version`='" . addslashes(df_get_file_system_version()) . "'", df_db());
     if (!$res) {
         throw new Exception(xf_db_error(df_db()), E_USER_ERROR);
     }
     if (function_exists('apc_clear_cache')) {
         apc_clear_cache('user');
     }
     df_clear_views();
     df_clear_cache();
     $app->redirect(DATAFACE_SITE_HREF . '?--msg=' . urlencode('The database has been successfully updated to version ' . df_get_file_system_version()));
 }
Beispiel #2
0
 function update_4802()
 {
     $sql[] = "CREATE OR REPLACE VIEW `swete_strings` AS\n            select  s.string_id,\n                    s.normalized_value as normalized_string,\n                    s.normalized_value as string,\n                    s.num_words,\n                    t.normalized_translation_value,\n                    if(tml.webpage_id is null,hrl.proxy_request_url, concat(ws.website_url,w.webpage_url)) as request_url,\n                    ifnull(tml.translation_memory_id,tm.translation_memory_id) as translation_memory_id,\n                    tm.translation_memory_uuid,\n                    tm.translation_memory_name,\n                    tm.source_language,\n                    tm.destination_language,\n                    ws.website_name,\n                    ws.website_id,\n                    tml.date_inserted\n                    from \n                    xf_tm_strings s\n                    inner join xf_tm_translation_memories tm on 1\n                    left join xf_tm_translation_memory_strings tms on s.string_id=tms.string_id and tms.translation_memory_id=tm.translation_memory_id\n                    left join xf_tm_translations t on tms.current_translation_id=t.translation_id\n                    left join translation_miss_log tml on tml.string_id=s.string_id and tml.translation_memory_id=tm.translation_memory_id\n                    left join http_request_log hrl on tml.http_request_log_id=hrl.http_request_log_id\n                    left join webpages w on tml.webpage_id=w.webpage_id\n                    left join websites ws on (tml.website_id=ws.website_id OR tm.translation_memory_id=ws.translation_memory_id)\n                    where ifnull(tml.translation_memory_id,tm.translation_memory_id) IS NOT NULL\n            ";
     try {
         df_q($sql);
         df_clear_views();
         df_clear_cache();
     } catch (Exception $ex) {
     }
 }