diff --git a/2016/includes/class-Footer.php b/2016/includes/class-Footer.php index dc6732d..f09d12b 100644 --- a/2016/includes/class-Footer.php +++ b/2016/includes/class-Footer.php @@ -1,156 +1,156 @@ . class Footer { static function spawn( $args = [] ) { $args = array_replace( [ 'home' => true ], $args ); ?>
- +
. /** * Header of the website */ class Header { /** * Spawn the header * * @param $menu_uid string Menu entry UID (if any) or page title * @param $args array Header arguments */ static function spawn( $menu_uid = null, $args = [] ) { $menu = $menu_uid ? menu_entry( $menu_uid ) : null; $args = array_replace( [ 'show-title' => true, 'nav-title' => SITE_NAME_SHORT, 'head-title' => null, 'title' => $menu ? $menu->name : null, 'url' => $menu ? $menu->url : null, 'not-found' => false, 'user-navbar' => true, 'container' => true, 'alert' => null, 'alert.type' => null, 'noindex' => NOINDEX ], $args ); if( ! isset( $args['og'] ) ) { $args['og'] = []; } $args['og'] = array_replace( [ 'image' => STATIC_URL . '/ld-2016-logo-purple.png', // It's better an absolute URL here 'type' => 'website', 'url' => $args['url'], 'title' => $args['title'] ], $args['og'] ); if( $args['head-title'] === null ) { $args['head-title'] = sprintf( __("%s - %s"), $args['title'], $args['nav-title'] ); } header('Content-Type: text/html; charset=' . CHARSET); if( $args['not-found'] ) { header('HTTP/1.1 404 Not Found'); } enqueue_css('materialize'); enqueue_css('materialize.custom'); enqueue_css('materialize.icons'); enqueue_js('jquery'); enqueue_js('materialize'); // Close header - Start $args['container'] && inject_in_module('footer', function() { ?> getISO(); - } else { - $l = 'it'; - } + $l = latest_language()->getISO(); ?> <?= $args['head-title'] ?> $value): ?>
<?php echo __(">

. /** * A recursive function to generate a menu tree. * * @param string $uid The menu identifier * @param int $level Level of the menu, used internally. Default 0. * @param array $args Arguments */ function print_menu($uid = null, $level = 0, $args = [] ) { $args = array_replace( [ 'max-level' => 99, 'main-ul-intag' => 'class="collection"' ], $args ); if( $level > $args['max-level'] ) { return; } $menuEntries = get_children_menu_entries($uid); if( ! $menuEntries ) { return; } ?> > - +
  • - url, $menuEntry->name, $menuEntry->get('title')) ?> + url ), $menuEntry->name, $menuEntry->get('title') ) ?> uid, $level + 1, $args ) ?>
  • $icon"; } function die_with_404() { new Header('404', [ 'title' => __("È un 404! Pagina non trovata :("), 'not-found' => true ] ); error( __("Nott foond! A.k.a. erroro quattrociantoquatto (N.B. eseguire coi permessi di root non risolve la situazione!)") ); new Footer(); exit; } diff --git a/2019/event.php b/2019/event.php index cf51ff7..37ec937 100644 --- a/2019/event.php +++ b/2019/event.php @@ -1,304 +1,306 @@ . require 'load.php'; $conference = FullConference::factoryFromUID( CURRENT_CONFERENCE_UID ) ->queryRow(); if( !$conference ) { die_with_404(); } $event = FullEvent::factoryByConferenceAndUID( $conference->getConferenceID(), @ $_GET['uid'] )->queryRow(); if( !$event ) { die_with_404(); } if( FORCE_PERMALINK ) { $event->forceEventPermalink(); } $args = [ 'conference' => $conference, 'title' => sprintf( __("%s: %s"), $event->getChapterName(), $event->getEventTitle() ), 'url' => $event->getEventURL() ]; if( $event->hasEventImage() ) { $args['og'] = [ 'image' => $event->getEventImage( true ), ]; } template( 'header', $args ); ?>

    getEventTitle() ) ?>

    isEventEditable() ): ?>

    getFullEventEditURL(), __("Modifica") . icon('edit', 'left') ) ?>

    <?= esc_attr( $event->getEventTitle() ) ?>
    getTrackName() ?>
    getTrackLabel() ?>
    getRoomName() ?>
    @ getLocationGeoOSM(), esc_html( $conference->getLocationName() ), $conference->getLocationAddress(), null, 'target="_blank"' ) ?>
    getLocationAddress() ) ?>
    getEventHumanStart() ?>
    getEventStart('d/m/Y'), $event->getEventStart('H:i') ) ?>
    getEventCalURL(), __( "Scarica promemoria calendario" ) ) ?>
    hasEventAbstract() ): ?>

    getEventAbstractHTML( ['p' => 'flow-text'] ) ?>
    hasEventDescription() ): ?>

    getEventDescriptionHTML( ['p' => 'flow-text'] ) ?>
    hasEventNote() ): ?>

    getEventNoteHTML( ['p' => 'flow-text'] ) ?>
    factorySharebleByEvent() ->queryGenerator(); ?> valid() ): ?>

    isSharableDownloadable() ): ?>

    getSharablePath(), icon('attachment', 'left') . $sharable->getSharableTitle(['prop' => true]), null, null, 'target="_blank"' ), $sharable->getSharableLicense()->getLink() ) ?>

    isSharableVideo() ): ?>

    getSharablePath(), icon('share', 'left') . $sharable->getSharableTitle( ['prop' => true] ), null, null, 'target="_blank"' ), $sharable->getSharableLicense()->getLink() ) ?>

    factoryUserByEvent() ->queryGenerator(); ?> valid() ): ?>
    getUserURL(), "

    " . esc_html( $user->getUserFullname() ) . "

    ", sprintf( __("Profilo di %s"), $user->getUserFullname() ), 'valign' ) ?>

    factoryPreviousFullEvent() ->limit( 1 ) ->queryRow(); $next = $event->factoryNextFullEvent() ->limit( 1 ) ->queryRow(); ?>

    getEventURL(), esc_html( $previous->getEventTitle() ) ) ?>

    getEventURL(), esc_html( $next->getEventTitle() ) ) ?>

    true, +] ); diff --git a/2019/index.php b/2019/index.php index 0660111..2199b7a 100644 --- a/2019/index.php +++ b/2019/index.php @@ -1,390 +1,390 @@ . require 'load.php'; enqueue_js('jquery'); enqueue_js('typed'); enqueue_js('leaflet'); enqueue_js('leaflet.init'); enqueue_css('leaflet'); $conference = FullConference::factoryFromUID( CURRENT_CONFERENCE_UID ) ->queryRow(); if( !$conference ) { die_with_404(); } if( FORCE_PERMALINK ) { $conference->forceConferencePermalink(); } template( 'header', [ 'conference' => $conference, 'intro' => true, ] ); ?>

    aula base, l'aula per sistemisti o programmatori e divertiti!" ) ?>

    getConferenceStart(); // query all the events that belongs to this conference // and that belongs to this chapter // order by date $events = FullEvent::factoryByConference( $conference->getConferenceID() ) ->whereStr( Track::UID, $track ) ->orderBy( Event::START, 'ASC' ) ->queryResults(); ?> get( Event::START ) ?>

    getEventTitle() ) ?>

    hasEventSubtitle() ): ?>

    getEventSubtitle() ) ?>

     getEventStart( 'H:i' ) ?> (getHumanEventDuration( [ 'long' => false ] ) ?>)
     

    hasEventAbstract() ): ?>

    getEventAbstractHTML() ?>

     info

     

    isEventEditable() ): ?> getFullEventEditURL(), __( "Modifica" ) ) ?>
    add( $one_hour ); $last_event_end = clone $last_event_start; $last_event_end->add( $one_hour ); ?>
    -

    +

    printLocationLeaflet() ?>

    . /* * This is the footer of the website + * + * Available variables: + * + * $back: when is set, the back button is displayed */ // do not visit directly defined( 'ABSPATH' ) or exit; ?> + + +
    + +
    + +

    get( 'cc-by-sa-4.0' )->getLink() ) ?>

    Templatemo' ) ?>

    get( 'gnu-agpl' )->getLink() ) ?>

    Share your Freedom!

    diff --git a/2019/template/intro.php b/2019/template/intro.php index e7d9336..827de7c 100644 --- a/2019/template/intro.php +++ b/2019/template/intro.php @@ -1,68 +1,64 @@ . /* * This is the introduction of the website */ // do not visit directly defined( 'ABSPATH' ) or exit; ?>
    -

    Linux Day Torino

    ', '' ) ?>
    - - +
    - -
    diff --git a/2019/template/navbar-home.php b/2019/template/navbar-home.php index 16c2269..9e001e2 100644 --- a/2019/template/navbar-home.php +++ b/2019/template/navbar-home.php @@ -1,59 +1,60 @@ . /* * This is the navbar of the website */ /* * Args that should be passed: * * $conference (object) Current conference */ // do not visit directly defined( 'ABSPATH' ) or exit; +$home = keep_url_in_language( CURRENT_CONFERENCE_ROOT . _ ); + $classes = $top_nav_collapse ? 'top-nav-collapse' : 'navbar-fixed-top'; ?> diff --git a/2019/user.php b/2019/user.php index 5e850a5..33e16f7 100644 --- a/2019/user.php +++ b/2019/user.php @@ -1,314 +1,316 @@ . require 'load.php'; $conference = FullConference::factoryFromUID( CURRENT_CONFERENCE_UID ) ->queryRow(); if( !$conference ) { die_with_404(); } $user = User::factoryByUID( $_GET['uid'] ) ->select( [ User::ID, User::UID, User::GRAVATAR, User::NAME, User::SURNAME, User::IMAGE, User::WEBSITE, User::LOVED_LICENSE, User::BIO_L10N(), ] ) ->select( User::allSocialFields() ) ->queryRow(); if( !$user ) { die_with_404(); } if( FORCE_PERMALINK ) { $user->forceUserPermalink(); } enqueue_js('jquery'); template( 'header', [ 'conference' => $conference, 'title' => $user->getUserFullname(), 'og' => [ 'image' => $user->getUserImage( true ), 'url' => $user->getUserURL( true ), 'type' => 'profile', 'profile:first_name' => $user->get( 'user_name' ), 'profile:last_name' => $user->get( 'user_surname' ), ] ] ); ?>

    getUserFullName() ) ?>

    hasPermissionToEditUser() ): ?>

    getUserUID()}", __("Modifica") . icon('edit', 'left') ) ?>

    has( User::WEBSITE ) ): ?> <?= esc_html(
 								$user->getUserFullname()
 							) ?> has( User::WEBSITE ) ): ?>
    user_site ): ?>

    user_site, __("Sito personale") . icon('inbox', 'right'), null, 'btn waves-effect purple darken-2', 'target="_blank"' ) ?>

    factoryUserSkills() ->queryGenerator(); ?> valid() ): ?>

    getSkillCode() ) ?>
    hasUserLovelicense() ): ?>
    getUserLovelicense() ?>

    %s."), $license->getLink() ) ?>

    hasUserBio() ): ?>

    getUserBioHTML( ['p' => 'flow-text'] ) ?>

    whereConference( $conference ) ->whereUser( $user ) ->joinTrackChapterRoom() ->queryGenerator(); ?> valid() ): ?>
    getEventURL(), sprintf( "%s", esc_html( $title = $event->getEventTitle() ) ), sprintf( __("Vedi %s"), $title ) ) ?> getChapterName() ) ?> getTrackName() ) ?> getLocationName() ) ?>
    getRoomName() ) ?>
    %s (il %s)"), $event->getEventStart("H:i"), $event->getEventStart("d/m/Y") ) ?>
    getEventHumanStart() ?>

    joinConference() ->joinLocation() ->joinChapter() ->whereUser( $user ) ->whereConferenceNot( $conference ) ->orderBy( Event::START, 'DESC' ) ->queryGenerator(); ?> valid() ): ?>

    hasConferenceEventsURL() ) { // print the Event permalink echo HTML::a( $event->getEventURL(), esc_html( $event->getEventTitle() ) ); } else { // just print the Event title echo esc_html( $event->getEventTitle() ); } ?> getConferenceTitle() ) ?> getLocationName() ) ?>
    %s (il %s)"), $event->getEventStart("H:i"), $event->getEventStart("d/m/Y") ) ?>
    getEventHumanStart() ?>
    isUserSocial() ): ?>

    has( User::RSS ) and UserSocialBox::spawn( $user, "RSS", $user->get( User::RSS ), 'home.png' ); $user->has( User::FACEBOOK ) and UserSocialBox::spawn( $user, "Facebook", $user->getUserFacebruck(), 'facebook_logo.png' ); $user->has( User::GOOGLE_PLUS ) and UserSocialBox::spawn( $user, "Google+", $user->getUserGuggolpluz(), 'google.png' ); $user->has( User::TWITTER ) and UserSocialBox::spawn( $user, "Twitter", $user->getUserTuitt(), 'twitter.png' ); $user->has( User::LINKEDIN ) and UserSocialBox::spawn( $user, "Linkedin", $user->getUserLinkeddon(), 'linkedin.png' ); $user->has( User::GITHUB ) and UserSocialBox::spawn( $user, "Github", $user->getUserGithubbo(), 'github.png' ); ?>
    true, +] ); diff --git a/includes/class-Conference.php b/includes/class-Conference.php index 77cbc9f..1ecdea7 100644 --- a/includes/class-Conference.php +++ b/includes/class-Conference.php @@ -1,276 +1,273 @@ . trait ConferenceTrait { /** * Get conference ID * * @return int */ public function getConferenceID() { return $this->nonnull( Conference::ID ); } /** * Get conference UID * * @return string */ function getConferenceUID() { return $this->get( Conference::UID ); } /** * Get localized conference title * * @return string */ public function getConferenceTitle() { return __( $this->get( Conference::TITLE ) ); } /** * Get the Conference URL * * @param boolean $absolute Set to true to force an absolute URL * @return string */ public function getConferenceURL( $absolute = false ) { $url = sprintf( PERMALINK_CONFERENCE, $this->getConferenceUID() ); - return site_page( $url, $absolute ); + $url = site_page( $url, $absolute ); + return keep_url_in_language( $url ); } /** * Check if the Conference has URLs for every Event * * @return boolean */ public function hasConferenceEventsURL() { return $this->has( 'conference_events_url' ); } /** * Force this request to the correct Conference permalink */ public function forceConferencePermalink() { - $from = BASE_URL . $_SERVER['REQUEST_URI']; - $to = $this->getConferenceURL( true ); - if( $from !== $to ) { - http_redirect( $to, 303 ); - } + force_permalink( $this->getConferenceURL( true ) ); } function getConferenceHumanStart() { return HumanTime::diff( $this->getConferenceStart() ); } function getConferenceHumanEnd() { return HumanTime::diff( $this->getConferenceEnd() ); } /** * Get the Conference date start * * @param string $format If specified, return the formatted date * @return DateTime|string */ public function getConferenceStart( $format = null ) { $date = $this->get( 'conference_start' ); if( $format ) { return $date->format( $format ); } return $date; } /** * Get the Conference date end * * @param string $format If specified, return the formatted date */ public function getConferenceEnd( $format = null ) { $date = $this->get( 'conference_end' ); if( $format ) { return $date->format( $format ); } return $date; } /** * Get URL to trop-iCal API for this conference * * @param boolean $absolute Set to true for an absolute URL * @return string */ function getConferenceCalURL( $absolute = false ) { $conf = urlencode( $this->getConferenceUID() ); return site_page( "api/tropical.php?conference=$conf", $absolute ); } /** * Get localized conference description * * @return string */ public function getConferenceDescription() { return nl2br( __( $this->get( Conference::DESCRIPTION ) ) ); } /** * Get localized conference quote * * @return string */ public function getConferenceQuote() { return nl2br( __( $this->get( 'conference_quote' ) ) ); } /** * Get localized conference subtitle * * @return string */ public function getConferenceSubtitle() { return __( $this->get( Conference::SUBTITLE ) ); } /** * Factory a FullEvent by this conference * * @return Query */ public function factoryFullEventByConference() { return FullEvent::factoryByConference( $this->getConferenceID() ); } /** * Get the URL to create an Event in this Conference * * @param boolean $absolute Flag to have an absolute URL * @return string */ public function getURLToCreateEventInConference( $args = [], $absolute = false ) { $args['conference'] = $this->getConferenceUID(); return FullEvent::editURL( $args, $absolute ); } /** * Normalize a Conference object */ protected function normalizeConference() { $this->integers( Conference::ID, Conference::DAYS, Location::ID ); $this->datetimes( Conference::START, Conference::END ); } } /** * A Conference is an event in a certain Location */ class Conference extends Queried { use ConferenceTrait; /** * Database table name */ const T = 'conference'; /** * Conference ID column */ const ID = 'conference_ID'; /** * Conference UID column */ const UID = 'conference_uid'; /** * Conference title column */ const TITLE = 'conference_title'; /** * Subtitle column name */ const SUBTITLE = 'conference_subtitle'; /** * Description column name */ const DESCRIPTION = 'conference_description'; /** * Start column name */ const START = 'conference_start'; /** * End column name */ const END = 'conference_end'; /** * Acronym column name */ const ACRONYM = 'conference_acronym'; /** * Persons URL column name */ const PERSONS_URL = 'conference_persons_url'; /** * Events URL column name */ const EVENTS_URL = 'conference_events_url'; /** * Days column name */ const DAYS = 'conference_days'; /** * Complete ID column name */ const ID_ = self::T . DOT . self::ID; /** * Complete Location ID column name */ const LOCATION_ = self::T . DOT . Location::ID; /** * Maximum UID length * * @override */ const MAXLEN_UID = 32; /** * Constructor */ public function __construct() { $this->normalizeConference(); } } diff --git a/includes/class-FullEvent.php b/includes/class-FullEvent.php index cbf48c9..e1add95 100644 --- a/includes/class-FullEvent.php +++ b/includes/class-FullEvent.php @@ -1,220 +1,217 @@ . class_exists('Event'); class_exists('Conference'); class_exists('Location'); class_exists('Room'); class_exists('Chapter'); class_exists('Track'); trait FullEventTrait { /** * Check if the Event has a permalink * * @return bool */ public function hasEventPermalink() { return $this->has( Conference::UID ) && $this->has( Event ::UID ) && $this->has( Chapter ::UID ); } /** * Get the Event URL * * @param boolean $absolute Set to true to force an absolute URL * @return string */ public function getEventURL( $absolute = false ) { return FullEvent::permalink( $this->getConferenceUID(), $this->getEventUID(), $this->getChapterUID(), $absolute ); } /** * Force the current request to the correct Event permalink */ public function forceEventPermalink() { - $from = BASE_URL . $_SERVER['REQUEST_URI']; - $to = $this->getEventURL( true ); - if( $from !== $to ) { - http_redirect( $to, 303 ); - } + force_permalink( $this->getEventURL( true ) ); } /** * Create a Query to find the next Event in the same Room * * @return Query */ public function factoryNextFullEvent() { $date = $this->getEventEnd( 'Y-m-d H:i:s' ); return $this->factoryFullEventInSameContext() ->whereStr( 'event_start', $date, '>=' ) ->orderBy( 'event_start', 'ASC' ); } /** * Create a Query to find the previous Event in the same Room * * @return Query */ public function factoryPreviousFullEvent( $compare = '<=' ) { $date = $this->getEventStart( 'Y-m-d H:i:s' ); return $this->factoryFullEventInSameContext() ->whereStr( 'event_end', $date, '<=' ) ->orderBy( 'event_end', 'DESC' ); } /** * Get the edit URL for this FullEvent * * @param boolean $absolute Flag to require an absolute URL * @return string */ public function getFullEventEditURL( $absolute = false ) { return FullEvent::editURL( [ 'uid' => $this->getEventUID(), 'conference' => $this->getConferenceUID() ], $absolute ); } private function factoryFullEventInSameContext() { return FullEvent::factory() ->whereInt( 'event.conference_ID', $this->getConferenceID() ) ->whereInt( 'event.room_ID', $this->getRoomID() ); } } /** * An Event with all the bells and whistles */ class FullEvent extends Queried { use FullEventTrait; use EventTrait; use ConferenceTrait; use LocationTrait; use ChapterTrait; use RoomTrait; use TrackTrait; public function __construct() { $this->normalizeEvent(); $this->normalizeConference(); $this->normalizeChapter(); $this->normalizeRoom(); $this->normalizeTrack(); } /** * Query constructor * * @return Query */ public static function factory() { return Query::factory( __CLASS__ ) ->from( [ Event ::T, Conference::T, Room ::T, Track ::T, Chapter ::T, ] ) ->equals( Event::CONFERENCE_, Conference::ID_ ) ->equals( Event::ROOM_, Room ::ID_ ) ->equals( Event::TRACK_, Track ::ID_ ) ->equals( Event::CHAPTER_, Chapter ::ID_ ); } static function factoryByConference( $conference_ID ) { return self::factory() ->whereInt( Event::CONFERENCE_, $conference_ID ); } /** * @deprecate Use self::factoryFromConferenceAndUID() instead */ static function factoryByConferenceAndUID( $conference_ID, $event_uid ) { $event_uid = Event::sanitizeUID( $event_uid ); return self::factoryByConference( $conference_ID ) ->whereStr( Event::UID, $event_uid ); } /** * Factory from a Conference object and the Event UID * * @param object $conference * @param string $event_uid * @return Query */ public static function factoryFromConferenceAndEventUID( $conference, $event_uid ) { $event_uid = Event::sanitizeUID( $event_uid ); $conference_ID = $conference->getConferenceID(); return self::factoryByConference( $conference_ID ) ->whereStr( Event::UID, $event_uid ); } static function queryByConferenceAndUID( $conference_ID, $event_uid ) { return self::factoryByConferenceAndUID( $conference_ID, $event_uid ) ->queryRow(); } static function factoryByUser( $user_ID ) { return self::factory() ->from( EventUser::T ) ->equals( EventUser::EVENT_, Event::ID_ ) ->whereInt( EventUser::USER_, $user_ID ) ->orderBy( EventUser::ORDER ); } static function factoryByConferenceChapter( $conference_ID, $chapter_ID ) { return self::factoryByConference( $conference_ID ) ->whereInt( Event::CHAPTER_, $chapter_ID ); } /** * Get an absolute FullEvent permalink * * @param $conference_uid string Conference UID * @param $event_uid string Event UID * @param $chapter_uid string Chapter UID * @param string $absolute Force an absolute URL * @return string */ public static function permalink( $conference_uid, $event_uid, $chapter_uid, $absolute = false ) { $url = sprintf( PERMALINK_EVENT, $conference_uid, $event_uid, $chapter_uid ) ; - return site_page( $url, $absolute ); + $url = site_page( $url, $absolute ); + return keep_url_in_language( $url ); } /** * Get the edit URL to a FullEvent * * @param array $args Arguments for the edit page * @param boolean $absolute Flag to require an absolute URL * @return string */ public static function editURL( $args, $absolute = false ) { $url = http_build_get_query( '/2016/event-edit.php', $args ); return site_page( $url, $absolute ); } } diff --git a/includes/class-User.php b/includes/class-User.php index e0a1f8b..33ca10c 100644 --- a/includes/class-User.php +++ b/includes/class-User.php @@ -1,445 +1,442 @@ . trait UserTrait { /** * Get the user ID * * @return int */ public function getUserID() { return $this->nonnull( User::ID ); } /** * Get the user UID * * @return string */ public function getUserUID() { return $this->get( User::UID ); } /** * Get the user e-mail * * @return string */ public function getUserEmail() { return $this->get( User::EMAIL ); } /** * Check if the user is public * * @return bool */ public function isUserPublic() { return $this->get( User::IS_PUBLIC ); } /** * Check if I can see this user * * @return bool */ public function isUserVisible() { return $this->isUserPublic() || $this->isUserMyself(); } /** * Get the user full name * * @return string */ public function getUserFullname() { return sprintf( __("%s %s"), $this->get( User::NAME ), $this->get( User::SURNAME ) ); } /** * Get the User URL * * The User URL is based on the CURRENT_CONFERENCE_UID. * * @param boolean $absolute Set to true to force an absolute URL * @return string */ public function getUserURL( $absolute = false ) { $url = sprintf( PERMALINK_USER, CURRENT_CONFERENCE_UID, $this->getUserUID() ); - return site_page( $url, $absolute ); + $url = site_page( $url, $absolute ); + return keep_url_in_language( $url ); } /** * Force this request to the correct User permalink */ public function forceUserPermalink() { - $from = BASE_URL . $_SERVER['REQUEST_URI']; - $to = $this->getUserURL( true ); - if( $from !== $to ) { - http_redirect( $to, 303 ); - } + force_permalink( $this->getUserURL( true ) ); } function getUserLink( $base = null, $html_class = null) { $name = $this->getUserFullname(); return HTML::a( $this->getUserURL( $base ), esc_html( $name ), sprintf( __("Profilo utente di %s"), $name ), $html_class ); } /** * Check if the User has a Gravatar image * * @return int */ public function hasUserGravatar() { return $this->has( User::GRAVATAR ) || $this->has( User::EMAIL ); } /** * Get the md5 of the E-mail * * @return string|null */ public function getUserGravatarUID() { return $this->get( User::GRAVATAR ); } /** * Check if the User has an image * * @return boolean */ public function hasUserImage() { return $this->has( User::IMAGE ) || $this->has( User::GRAVATAR ); } /** * Get the URL of the user image * * @param int $size Suggested width * @param boolean $absolute Set true to force an absolute URL * @return string */ public function getUserImage( $size = 256, $absolute = false ) { $image = $this->get( User::IMAGE ); if( ! $image ) { $image = 'https://www.gravatar.com/avatar/' . $this->getUserGravatarUID() . '?s=' . $size; } return site_page( $image, $absolute ); } /** * It has an user bio? * * @return bool */ public function hasUserBio() { return null !== $this->get('user_bio'); } function getUserBio() { return $this->get('user_bio'); } function getUserBioHTML($args = []) { return Markdown::parse( __( $this->getUserBIO() ), $args); } /** * Check if the user is somehow social * * @return bool */ public function isUserSocial() { foreach( User::allSocialFields() as $field ) { if( $this->has( $field ) ) { return true; } } return false; } /** * Get the user Facebook profile URL * * @return string URL */ public function getUserFacebruck() { return 'https://facebook.com/' . $this->get( User::FACEBOOK ); } /** * Get the user Google+ profile URL * * @return string URL */ public function getUserGuggolpluz() { return 'https://plus.google.com/' . $this->get( User::GOOGLE_PLUS ); } /** * Get the user Twitter profile URL * * @return string URL */ public function getUserTuitt() { return 'https://twitter.com/' . $this->get( User::TWITTER ); } /** * Get the user Linkedin profile URL * * @return string URL */ public function getUserLinkeddon() { return 'https://www.linkedin.com/in/' . $this->get( User::LINKEDIN ); } /** * Get the user GitHub profile URL * * @return string URL */ public function getUserGithubbo() { return 'https://github.com/' . $this->get( User::GITHUB ); } /** * Get the edit URL to this user * * @return string */ public function getUserEditURL() { $url = http_build_get_query( '2016/user-edit.php', [ 'uid' => $this->getUserUID(), ] ); return site_page( $url ); } /** * Can you edit this user? * * @return bool */ public function hasPermissionToEditUser() { if( has_permission('edit-users') ) { return true; } if( has_permission('edit-account') && $this->isUserMyself() ) { return true; } return false; } /** * Is this user myself? * * @return bool */ public function isUserMyself() { return is_logged() && get_user()->getUserID() === $this->getUserID(); } /** * Check if the User has a loved license * * @return */ public function hasUserLovelicense() { return $this->has( User::LOVED_LICENSE ); } /** * Get the User loved license * * @return License */ public function getUserLovelicense() { return license( $this->get( User::LOVED_LICENSE ) ); } function factoryUserSkills() { return UserSkill::factorySkillByUser( $this->getUserID() ); } function factoryUserEvents() { return FullEvent::factoryByUser( $this->getUserID() ); } /** * Normalize a User object */ protected function normalizeUser() { $this->integers( User::ID ); $this->booleans( User::IS_PUBLIC, User::IS_ACTIVE ); } } class User extends Sessionuser { use UserTrait; /** * Name column */ const NAME = 'user_name'; /** * Aristocratic title column */ const ARISTOCRATIC_TITLE = 'user_title'; /** * ID column */ const SURNAME = 'user_surname'; /** * He/she public column */ const IS_PUBLIC = 'user_public'; /** * Image column */ const IMAGE = 'user_image'; /** * E-mail */ const EMAIL = 'user_email'; /** * Gravatar column */ const GRAVATAR = 'user_gravatar'; /** * RSS column */ const RSS = 'user_rss'; /** * Facebook username column */ const FACEBOOK = 'user_fb'; /** * Linkedin username column */ const LINKEDIN = 'user_lnkd'; /** * Google+ username column */ const GOOGLE_PLUS = 'user_googl'; /** * Twitter username */ const TWITTER = 'user_twtr'; /** * GitHub username */ const GITHUB = 'user_github'; /** * Personal website column */ const WEBSITE = 'user_site'; /** * Loved license column */ const LOVED_LICENSE = 'user_lovelicense'; /** * Biography column */ const BIO = 'user_bio'; /** * Complete ID column name */ const ID_ = self::T . DOT . self::ID; /** * Maximum UID length */ const MAXLEN_UID = 64; /** * Constructor */ public function __construct() { $this->normalizeUser(); } /** * Get all the user social fields * * @return array */ public static function allSocialFields() { return [ User::RSS, User::FACEBOOK, User::LINKEDIN, User::GOOGLE_PLUS, User::TWITTER, User::GITHUB, ]; } /** * Factory users by an event * * @param $event_ID int * @return Query */ public static function factoryByEvent( $event_ID ) { return self::factory() ->from('event_user') ->equals('event_user.user_ID', 'user.user_ID') ->whereInt('event_user.event_ID', $event_ID ); } /** * Generate the appropriate SELECT for the User Bio * * @return string */ public static function BIO_L10N() { return i18n_coalesce( 'user_bio', 'user_bio_%s' ); } }