]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/ExtendedProfile/ExtendedProfilePlugin.php
Extended profile - Add sammdy to author credits in version info
[quix0rs-gnu-social.git] / plugins / ExtendedProfile / ExtendedProfilePlugin.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 /**
25  * Extra profile bio-like fields
26  *
27  * @package ExtendedProfilePlugin
28  * @maintainer Brion Vibber <brion@status.net>
29  */
30 class ExtendedProfilePlugin extends Plugin
31 {
32
33     function onPluginVersion(&$versions)
34     {
35         $versions[] = array(
36             'name' => 'ExtendedProfile',
37             'version' => STATUSNET_VERSION,
38             'author' => 'Brion Vibber, Samantha Doherty, Zach Copley',
39             'homepage' => 'http://status.net/wiki/Plugin:ExtendedProfile',
40             'rawdescription' => _m(
41                 'UI extensions for additional profile fields.')
42         );
43
44         return true;
45     }
46
47     /**
48      * Autoloader
49      *
50      * Loads our classes if they're requested.
51      *
52      * @param string $cls Class requested
53      *
54      * @return boolean hook return
55      */
56     function onAutoload($cls)
57     {
58         $dir = dirname(__FILE__);
59
60         switch (strtolower($cls))
61         {
62         case 'profiledetailaction':
63         case 'profiledetailsettingsaction':
64         case 'userautocompleteaction':
65             include_once $dir . '/actions/'
66                 . strtolower(mb_substr($cls, 0, -6)) . '.php';
67             return false;
68             break; // Safety first!
69         case 'extendedprofile':
70         case 'extendedprofilewidget':
71             include_once $dir . '/lib/' . strtolower($cls) . '.php';
72             return false;
73             break;
74         case 'profile_detail':
75             include_once $dir . '/classes/' . ucfirst($cls) . '.php';
76             return false;
77             break;
78         default:
79             return true;
80         }
81     }
82
83     /**
84      * Add paths to the router table
85      *
86      * Hook for RouterInitialized event.
87      *
88      * @param Net_URL_Mapper $m URL mapper
89      *
90      * @return boolean hook return
91      */
92     function onStartInitializeRouter($m)
93     {
94         $m->connect(
95             ':nickname/detail',
96             array('action' => 'profiledetail'),
97             array('nickname' => Nickname::DISPLAY_FMT)
98         );
99         $m->connect(
100             '/settings/profile/finduser',
101             array('action' => 'Userautocomplete')
102         );
103         $m->connect(
104             'settings/profile/detail',
105             array('action' => 'profiledetailsettings')
106         );
107
108         return true;
109     }
110
111     function onCheckSchema()
112     {
113         $schema = Schema::get();
114         $schema->ensureTable('profile_detail', Profile_detail::schemaDef());
115
116         return true;
117     }
118
119     function onStartProfilePageActionsSection(HTMLOutputter $out, Profile $profile) {
120         $user = User::staticGet('id', $profile->id);
121         if ($user) {
122             $url = common_local_url('profiledetail', array('nickname' => $user->nickname));
123             $out->element('a', array('href' => $url, 'class' => 'profiledetail'), _m('More details...'));
124         }
125         return true;
126     }
127
128 }