Skip to content

Commit

Permalink
[Bug #725] Zorg Code Version wird nun im Footer auf https://zorg.ch/
Browse files Browse the repository at this point in the history
…angezeigt
  • Loading branch information
oliveratgithub committed Feb 4, 2018
1 parent 6dce9b0 commit 5d8bf6b
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion www/includes/smarty.fnc.php
Expand Up @@ -1281,7 +1281,7 @@ function smarty_modifier_rendertime($mode='begin')
,'online_users' => array(var_online_users(), 'Usersystem', 'Array mit allen zur Zeit eingeloggten Usern', false)
,'num_new_events' => array(Events::getNumNewEvents(), 'Events', 'Zeigt Anzahl neu erstellter Events an', true)
,'login_error' => array($login_error, 'Usersystem', 'Ist leer oder enthält Fehlermeldung eines versuchten aber fehlgeschlagenen Logins eines Benutzers', false)

,'code_info' => array(getGitCodeVersion(), 'Code Info', 'Holt die aktuellen Code Infos (Version, last commit, etc.) aus dem Git HEAD', false)

);

Expand Down
42 changes: 42 additions & 0 deletions www/includes/util.inc.php
Expand Up @@ -70,6 +70,20 @@ function timename($timestamp) {

}

/**
* Funktion um ein Datum-Zeit String in einen Timestamp umzuweandeln
* @author IneX
* @date 04.02.2018
* @param @datetime Must be valid full Date-Time String, e.g. 2016-03-11 11:00:00
* @return string
*/
function datetimeToTimestamp($datetime)
{
$d = new DateTime($datetime, new DateTimeZone('Europe/Zurich'));
return $d->getTimestamp();
}


function emailusername($username) {
$username = strtolower($username);
$username = str_replace("ä", "ae", $username);
Expand Down Expand Up @@ -517,3 +531,31 @@ function urlExists($url)
}
return false;
}


/**
* Get Code information from Git
* Usage: echo getGitVersion();
* Result: MyApplication v1.2.3-dev.474a1d0 (2016-11-02 14:11:22)
*
* @author IneX
* @date 04.02.2018
* @version 1.0
* @link https://stackoverflow.com/a/33986403/5750030
* @return array
*/
function getGitCodeVersion()
{
try {
$codeVersion['version'] = trim(exec('git describe --tags --abbrev=0'));
$codeVersion['last_commit'] = trim(exec('git log --pretty="%h" -n1 HEAD'));
$lastCommitDatetime = trim(exec('git log -n1 --pretty=%ci HEAD'));

$codeVersion['last_update'] = datetimeToTimestamp($lastCommitDatetime);

return $codeVersion;

} catch (Exception $e) {
error_log($e->getMessage());
}
}
3 changes: 3 additions & 0 deletions www/templates/layout/footer.tpl
Expand Up @@ -21,6 +21,9 @@
<a href="spaceweather.php">[more]</a>
{/if}
<br /><a href="/?word=impressum">Impressum</a> | <a href="/?word=privacy">Privacy-Policy</a> | <a href="/?word=verein">Zorg Verein</a>
{if $code_info.version != ''}
| Code Version: {$code_info.version}, {$code_info.last_commit} (updated: {$code_info.last_update|datename}){if $user->typ == 2} <a href="https://bitbucket.org/zorgvorstand/zorg.ch/commits/{$code_info.last_commit}" target="_blank">[view]</a>{/if}
{/if}
</td>
</tr>
</table>
Expand Down

0 comments on commit 5d8bf6b

Please sign in to comment.