]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/ExtendedProfile/extendedprofile.php
work in progress: prepping for storage of extended profile details
[quix0rs-gnu-social.git] / plugins / ExtendedProfile / extendedprofile.php
1 <?php
2 /*
3  * StatusNet - the distributed open-source microblogging tool
4  * Copyright (C) 2011, StatusNet, Inc.
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Affero General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU Affero General Public License for more details.
15  *
16  * You should have received a copy of the GNU Affero General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20 if (!defined('STATUSNET')) {
21     exit(1);
22 }
23
24 class ExtendedProfile
25 {
26     function __construct(Profile $profile)
27     {
28         $this->profile = $profile;
29         $this->sections = $this->getSections();
30         $this->fields = $this->loadFields();
31     }
32
33     function loadFields()
34     {
35         $detail = new Profile_detail();
36         $detail->profile_id = $this->profile->id;
37         $detail->find();
38         
39         while ($detail->get()) {
40             $fields[$detail->field][] = clone($detail);
41         }
42         return $fields;
43     }
44
45     function getSections()
46     {
47         return array(
48             'basic' => array(
49                 'label' => _m('Personal'),
50                 'fields' => array(
51                     'fullname' => array(
52                         'label' => _m('Full name'),
53                         'profile' => 'fullname',
54                         'vcard' => 'fn',
55                     ),
56                     'title' => array(
57                         'label' => _m('Title'),
58                         'vcard' => 'title',
59                     ),
60                     'manager' => array(
61                         'label' => _m('Manager'),
62                         'type' => 'person',
63                         'vcard' => 'x-manager',
64                     ),
65                     'location' => array(
66                         'label' => _m('Location'),
67                         'profile' => 'location'
68                     ),
69                     'bio' => array(
70                         'label' => _m('Bio'),
71                         'type' => 'textarea',
72                         'profile' => 'bio',
73                     ),
74                     'tags' => array(
75                         'label' => _m('Tags'),
76                         'type' => 'tags',
77                         'profile' => 'tags',
78                     ),
79                 ),
80             ),
81             'contact' => array(
82                 'label' => _m('Contact'),
83                 'fields' => array(
84                     'phone' => array(
85                         'label' => _m('Phone'),
86                         'type' => 'phone',
87                         'multi' => true,
88                         'vcard' => 'tel',
89                     ),
90                     'im' => array(
91                         'label' => _m('IM'),
92                         'type' => 'im',
93                         'multi' => true,
94                     ),
95                     'website' => array(
96                         'label' => _m('Websites'),
97                         'type' => 'website',
98                         'multi' => true,
99                     ),
100                 ),
101             ),
102             'personal' => array(
103                 'label' => _m('Personal'),
104                 'fields' => array(
105                     'birthday' => array(
106                         'label' => _m('Birthday'),
107                         'type' => 'date',
108                         'vcard' => 'bday',
109                     ),
110                     'spouse' => array(
111                         'label' => _m('Spouse\'s name'),
112                         'vcard' => 'x-spouse',
113                     ),
114                     'kids' => array(
115                         'label' => _m('Kids\' names')
116                     ),
117                 ),
118             ),
119             'experience' => array(
120                 'label' => _m('Work experience'),
121                 'fields' => array(
122                     'experience' => array(
123                         'type' => 'experience',
124                         'label' => _m('Employer'),
125                     ),
126                 ),
127             ),
128             'education' => array(
129                 'label' => _m('Education'),
130                 'fields' => array(
131                     'education' => array(
132                         'type' => 'education',
133                         'label' => _m('Institution'),
134                     ),
135                 ),
136             ),
137         );
138     }
139 }