123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 |
- <?php
- defined('GNUSOCIAL') || die();
- include_once __DIR__ . '/lib/profiletools.php';
- class ExtendedProfilePlugin extends Plugin
- {
- const PLUGIN_VERSION = '3.0.2';
- public function onPluginVersion(array &$versions): bool
- {
- $versions[] = [
- 'name' => 'ExtendedProfile',
- 'version' => self::PLUGIN_VERSION,
- 'author' => 'Brion Vibber, Samantha Doherty, Zach Copley, Max Shinn, Diogo Cordeiro',
- 'homepage' => GNUSOCIAL_ENGINE_REPO_URL . 'tree/master/plugins/ExtendedProfile',
-
- 'rawdescription' => _m('UI extensions for additional profile fields.')
- ];
- return true;
- }
-
- public function onStartInitializeRouter(URLMapper $m)
- {
- $m->connect(
- ':nickname/detail',
- ['action' => 'profiledetail'],
- ['nickname' => Nickname::DISPLAY_FMT]
- );
- $m->connect(
- '/settings/profile/finduser',
- ['action' => 'Userautocomplete']
- );
- $m->connect(
- 'settings/profile/detail',
- ['action' => 'profiledetailsettings']
- );
- $m->connect(
- 'panel/profilefields',
- ['action' => 'profilefieldsAdminPanel']
- );
- return true;
- }
- public function onCheckSchema()
- {
- $schema = Schema::get();
- $schema->ensureTable('profile_detail', Profile_detail::schemaDef());
- $schema->ensureTable('gnusocialprofileextensionfield', GNUsocialProfileExtensionField::schemaDef());
- $schema->ensureTable('gnusocialprofileextensionresponse', GNUsocialProfileExtensionResponse::schemaDef());
- return true;
- }
- public function onEndShowAccountProfileBlock(HTMLOutputter $out, Profile $profile)
- {
- $user = User::getKV('id', $profile->id);
- if ($user) {
- $url = common_local_url('profiledetail', ['nickname' => $user->nickname]);
-
- $out->element('a', ['href' => $url, 'class' => 'profiledetail'], _m('More details...'));
- }
- }
-
- public function onEndAccountSettingsNav(Action $action)
- {
- $action_name = $action->trimmed('action');
- $action->menuItem(
- common_local_url('profiledetailsettings'),
-
- _m('MENU', 'Full Profile'),
-
- _m('Change your extended profile settings'),
- $action_name === 'profiledetailsettings'
- );
- return true;
- }
-
- public function onEndShowStyles(Action $action): bool
- {
- $action->cssLink('/plugins/ExtendedProfile/css/profiledetail.css');
- return true;
- }
- public function onEndShowScripts(Action $action): bool
- {
- $action->script('plugins/ExtendedProfile/js/profiledetail.js');
- return true;
- }
- public function onEndAdminPanelNav(AdminPanelNav $nav): bool
- {
- if (AdminPanelAction::canAdmin('profilefields')) {
- $action_name = $nav->action->trimmed('action');
- $nav->out->menuItem(
- common_local_url('profilefieldsAdminPanel'),
- _m('Profile Fields'),
- _m('Custom profile fields'),
- $action_name == 'profilefieldsAdminPanel',
- 'nav_profilefields_admin_panel'
- );
- }
- return true;
- }
- }
|