X-Git-Url: http://git.dj3c1t.com/?a=blobdiff_plain;f=mw%2Fapp%2Fdata%2Fmodules%2Fshare%2Fmw_data_versions.php;h=82ef591c1b69d78febed72a0f3320bbcabf1c5ad;hb=HEAD;hp=26bc0ee6a94d46348bb3acbcd86d05e0b828e833;hpb=a4819cb78b71363db14f8c568a9a2552ee8f58da;p=mtweb diff --git a/mw/app/data/modules/share/mw_data_versions.php b/mw/app/data/modules/share/mw_data_versions.php index 26bc0ee..82ef591 100644 --- a/mw/app/data/modules/share/mw_data_versions.php +++ b/mw/app/data/modules/share/mw_data_versions.php @@ -2,7 +2,7 @@ class mw_data_versions extends mw_data{ - function version($application_name){ + public function version($application_name){ if( $version = $this->data_read( array( @@ -15,4 +15,52 @@ return false; } + public function set_version($application_name, $version){ + if( + ( + $data_version = $this->data_read( + array( + "table_name" => "versions", + "index_name" => "application", + "index_value" => $application_name + ) + ) + ) === false + ){ + return false; + } + if($data_version){ + if( + !$this->data_update( + array( + "table_name" => "versions", + "index_name" => "id", + "index_value" => $data_version["id"], + "values" => array( + "version" => $version + ) + ) + ) + ){ + return false; + } + } + else{ + if( + !$this->data_insert( + array( + "table_name" => "versions", + "values" => array( + "application" => $application_name, + "version" => $version + ) + ) + ) + ){ + return false; + } + } + return true; + } + }