Example #1
0
    /**
     * Set user parameters
     */
    private function set_user_parameters()
    {
        $user_info               = array();
        $user_info['logged']     = 0;
        $this->user_is_logged_in = false;
        if (api_user_is_login()) {
            $user_info           = api_get_user_info(api_get_user_id());
            $user_info['logged'] = 1;

            $user_info['is_admin'] = 0;
            if (api_is_platform_admin()) {
                $user_info['is_admin'] = 1;
            }

            $user_info['messages_count'] = MessageManager::get_new_messages();
            $this->user_is_logged_in     = true;
        }
        //Setting the $_u array that could be use in any template
        $this->assign('_u', $user_info);
    }
 /**
  * @return null|string|void
  */
 public function return_profile_block()
 {
     global $_configuration;
     $user_id = api_get_user_id();
     if (empty($user_id)) {
         return;
     }
     $userGroup = new UserGroup();
     $profile_content = '<ul class="nav nav-pills nav-stacked">';
     //  @todo Add a platform setting to add the user image.
     if (api_get_setting('message.allow_message_tool') == 'true') {
         // New messages.
         $number_of_new_messages = MessageManager::get_new_messages();
         // New contact invitations.
         $number_of_new_messages_of_friend = SocialManager::get_message_number_invitation_by_user_id(api_get_user_id());
         // New group invitations sent by a moderator.
         $group_pending_invitations = $userGroup->get_groups_by_user(api_get_user_id(), GROUP_USER_PERMISSION_PENDING_INVITATION, false);
         $group_pending_invitations = count($group_pending_invitations);
         $total_invitations = $number_of_new_messages_of_friend + $group_pending_invitations;
         $cant_msg = Display::badge($number_of_new_messages);
         $link = '';
         if (api_get_setting('social.allow_social_tool') == 'true') {
             $link = '?f=social';
         }
         $profile_content .= '<li class="inbox-message-social"><a href="' . api_get_path(WEB_PATH) . 'main/messages/inbox.php' . $link . '">' . Display::return_icon('inbox.png', get_lang('Inbox'), null, ICON_SIZE_SMALL) . get_lang('Inbox') . $cant_msg . ' </a></li>';
         $profile_content .= '<li class="new-message-social"><a href="' . api_get_path(WEB_PATH) . 'main/messages/new_message.php' . $link . '">' . Display::return_icon('new-message.png', get_lang('Compose'), null, ICON_SIZE_SMALL) . get_lang('Compose') . ' </a></li>';
         if (api_get_setting('social.allow_social_tool') == 'true') {
             $total_invitations = Display::badge($total_invitations);
             $profile_content .= '<li class="invitations-social"><a href="' . api_get_path(WEB_PATH) . 'main/social/invitations.php">' . Display::return_icon('invitations.png', get_lang('PendingInvitations'), null, ICON_SIZE_SMALL) . get_lang('PendingInvitations') . $total_invitations . '</a></li>';
         }
         if (isset($_configuration['allow_my_files_link_in_homepage']) && $_configuration['allow_my_files_link_in_homepage']) {
             $profile_content .= '<li class="myfiles-social"><a href="' . api_get_path(WEB_PATH) . 'main/social/myfiles.php">' . get_lang('MyFiles') . '</a></li>';
         }
     }
     $editProfileUrl = Display::getProfileEditionLink($user_id);
     $profile_content .= '<li class="profile-social"><a href="' . $editProfileUrl . '">' . Display::return_icon('edit-profile.png', get_lang('EditProfile'), null, ICON_SIZE_SMALL) . get_lang('EditProfile') . '</a></li>';
     $profile_content .= '</ul>';
     $html = self::show_right_block(get_lang('Profile'), $profile_content, 'profile_block', null, 'profile', 'profileCollapse');
     return $html;
 }
    function return_profile_block()
    {
        global $_configuration;
        $user_id = api_get_user_id();

        if (empty($user_id)) {
            return;
        }

        $profile_content = '<ul class="nav nav-list">';

        //  @todo Add a platform setting to add the user image.
        if (api_get_setting('allow_message_tool') == 'true') {
            require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';

            // New messages.
            $number_of_new_messages             = MessageManager::get_new_messages();
            // New contact invitations.
            $number_of_new_messages_of_friend   = SocialManager::get_message_number_invitation_by_user_id(api_get_user_id());

            // New group invitations sent by a moderator.
            $group_pending_invitations = GroupPortalManager::get_groups_by_user(api_get_user_id(), GROUP_USER_PERMISSION_PENDING_INVITATION, false);
            $group_pending_invitations = count($group_pending_invitations);

            $total_invitations = $number_of_new_messages_of_friend + $group_pending_invitations;
            $cant_msg = Display::badge($number_of_new_messages);

            $link = '';
            if (api_get_setting('allow_social_tool') == 'true') {
                $link = '?f=social';
            }
            $profile_content .= '<li class="inbox-social"><a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php'.$link.'">'.get_lang('Inbox').$cant_msg.' </a></li>';
            $profile_content .= '<li class="new-message-social"><a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php'.$link.'">'.get_lang('Compose').' </a></li>';

            if (api_get_setting('allow_social_tool') == 'true') {
                $total_invitations = Display::badge($total_invitations);
                $profile_content .= '<li class="invitations-social"><a href="'.api_get_path(WEB_PATH).'main/social/invitations.php">'.get_lang('PendingInvitations').$total_invitations.'</a></li>';
            }

            if (isset($_configuration['allow_my_files_link_in_homepage']) && $_configuration['allow_my_files_link_in_homepage']) {
                $profile_content .= '<li class="myfiles-social"><a href="'.api_get_path(WEB_PATH).'main/social/myfiles.php">'.get_lang('MyFiles').'</a></li>';
            }
        }

        $editProfileUrl = api_get_path(WEB_CODE_PATH) . 'auth/profile.php';

        if (api_get_setting('sso_authentication') === 'true') {
            $subSSOClass = api_get_setting('sso_authentication_subclass');
            $objSSO = null;

            if (!empty($subSSOClass)) {
                require_once api_get_path(SYS_CODE_PATH) . 'auth/sso/sso.' . $subSSOClass . '.class.php';

                $subSSOClass = 'sso' . $subSSOClass;
                $objSSO = new $subSSOClass();
            } else {
                $objSSO = new sso();
            }

            $editProfileUrl = $objSSO->generateProfileEditingURL();
        }

        $profile_content .= '<li class="profile-social"><a href="' . $editProfileUrl . '">'.get_lang('EditProfile').'</a></li>';
        $profile_content .= '</ul>';
        $html = self::show_right_block(get_lang('Profile'), $profile_content, 'profile_block');
        return $html;
    }
 /**
  * Set user parameters
  */
 private function setUserParameters()
 {
     $user_info = array();
     $user_info['logged'] = 0;
     $this->user_is_logged_in = false;
     $user_info = isset($this->app['current_user']) ? $this->app['current_user'] : null;
     if (api_user_is_login() && !empty($user_info)) {
         $user_info['logged'] = 1;
         $user_info['is_admin'] = 0;
         if (api_is_platform_admin()) {
             $user_info['is_admin'] = 1;
         }
         $new_messages = MessageManager::get_new_messages();
         $user_info['messages_count'] = $new_messages != 0 ? Display::label($new_messages, 'warning') : null;
         $this->user_is_logged_in = true;
     }
     //Setting the $_u array that could be use in any template
     $this->assign('_u', $user_info);
 }