Kimai_Database_Mysql::save_timeframe PHP Method

save_timeframe() public method

saves timeframe of user in database (table conf)
Author: th
public save_timeframe ( string $timeframeBegin, string $timeframeEnd, string $user ) : boolean
$timeframeBegin string unix seconds
$timeframeEnd string unix seconds
$user string ID of user
return boolean
    public function save_timeframe($timeframeBegin, $timeframeEnd, $user)
    {
        if ($timeframeBegin == 0 && $timeframeEnd == 0) {
            $mon = date("n");
            $day = date("j");
            $Y = date("Y");
            $timeframeBegin = mktime(0, 0, 0, $mon, $day, $Y);
            $timeframeEnd = mktime(23, 59, 59, $mon, $day, $Y);
        }
        if ($timeframeEnd == mktime(23, 59, 59, date('n'), date('j'), date('Y'))) {
            $timeframeEnd = 0;
        }
        $values['timeframeBegin'] = MySQL::SQLValue($timeframeBegin, MySQL::SQLVALUE_NUMBER);
        $values['timeframeEnd'] = MySQL::SQLValue($timeframeEnd, MySQL::SQLVALUE_NUMBER);
        $table = $this->kga['server_prefix'] . "users";
        $filter['userID'] = MySQL::SQLValue($user, MySQL::SQLVALUE_NUMBER);
        $query = MySQL::BuildSQLUpdate($table, $values, $filter);
        if (!$this->conn->Query($query)) {
            $this->logLastError('save_timeframe');
            return false;
        }
        return true;
    }
Kimai_Database_Mysql