~ubuntu-branches/ubuntu/vivid/zentyal-core/vivid-proposed

« back to all changes in this revision

Viewing changes to src/EBox/SysInfo/Model/TimeZone.pm

  • Committer: Package Import Robot
  • Author(s): Jorge Salamero Sanz
  • Date: 2012-08-28 10:03:33 UTC
  • Revision ID: package-import@ubuntu.com-20120828100333-oz3n5kpav4z0tl27
Tags: 2.3.21+quantal1
New upstream release for Quantal

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2012 eBox Technologies S.L.
 
2
#
 
3
# This program is free software; you can redistribute it and/or modify
 
4
# it under the terms of the GNU General Public License, version 2, as
 
5
# published by the Free Software Foundation.
 
6
#
 
7
# This program is distributed in the hope that it will be useful,
 
8
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
# GNU General Public License for more details.
 
11
#
 
12
# You should have received a copy of the GNU General Public License
 
13
# along with this program; if not, write to the Free Software
 
14
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
 
 
16
# Class: EBox::SysInfo::Model::TimeZone
 
17
#
 
18
#   This model is used to configure the system time zone
 
19
#
 
20
 
 
21
package EBox::SysInfo::Model::TimeZone;
 
22
 
 
23
use strict;
 
24
use warnings;
 
25
 
 
26
use Error qw(:try);
 
27
use File::Slurp;
 
28
 
 
29
use EBox::Gettext;
 
30
use EBox::Types::TimeZone;
 
31
 
 
32
use base 'EBox::Model::DataForm';
 
33
 
 
34
use constant TZ_FILE => '/etc/timezone';
 
35
 
 
36
sub new
 
37
{
 
38
    my $class = shift;
 
39
 
 
40
    my $self = $class->SUPER::new(@_);
 
41
    bless ($self, $class);
 
42
 
 
43
    return $self;
 
44
}
 
45
 
 
46
sub _table
 
47
{
 
48
    my ($self) = @_;
 
49
 
 
50
    my @tableHead = (new EBox::Types::TimeZone( fieldName    => 'timezone',
 
51
                                                editable     => 1,
 
52
                                                defaultValue => \&_getTimezone,
 
53
                                                help =>  __('You will probably have to restart some services after ' .
 
54
                                                            'changing the time zone.')));
 
55
 
 
56
    my $dataTable =
 
57
    {
 
58
        'tableName' => 'TimeZone',
 
59
        'printableTableName' => __('Time zone'),
 
60
        'modelDomain' => 'SysInfo',
 
61
        'defaultActions' => [ 'editField' ],
 
62
        'tableDescription' => \@tableHead,
 
63
    };
 
64
 
 
65
    return $dataTable;
 
66
}
 
67
 
 
68
sub _getTimezone
 
69
{
 
70
    my $tz = read_file(TZ_FILE);
 
71
    chomp $tz;
 
72
    return $tz;
 
73
}
 
74
 
 
75
1;