Пример #1
0
 public function social_login()
 {
     $res = '';
     $social = new Social();
     if (!$social->enabled()) {
         // we don't show the box if there is nothing enabled..
         return $res;
     }
     $res .= '<div id="social_login">';
     $res .= Form::openForm('social_form', Get::rel_path('lms') . '/index.php?modname=login&amp;op=social') . '<span>' . Lang::t('_LOGIN_WITH', 'login') . ' </span>';
     if ($social->isActive('facebook')) {
         $res .= '<a href="index.php?modname=login&amp;op=facebook_login">' . Get::img('social/facebook-24.png') . '</a>';
     }
     if ($social->isActive('twitter')) {
         $res .= '<a href="index.php?modname=login&amp;op=twitter_login">' . Get::img('social/twitter-24.png') . '</a>';
     }
     if ($social->isActive('linkedin')) {
         $res .= '<a href="index.php?modname=login&amp;op=linkedin_login">' . Get::img('social/linkedin-24.png') . '</a>';
     }
     if ($social->isActive('google')) {
         $res .= '<a href="index.php?modname=login&amp;op=google_login">' . Get::img('social/google-24.png') . '</a>';
     }
     $res .= Form::closeForm();
     $res .= '</div>';
     return $res;
 }
Пример #2
0
 function homeUserProfile($picture = false, $viewer = false, $intest = false)
 {
     $this->loadUserData($this->getViewer());
     $acl_man =& Docebo::user()->getAclManager();
     list($class_picture, $this->max_dim_avatar) = $this->getPhotoLimit($picture);
     $html = '<div class="up_dashboard"><div class="content">';
     $html .= '<p class="logo">' . ($this->user_info[ACL_INFO_AVATAR] != "" ? $this->getPASrc($this->user_info[ACL_INFO_AVATAR], $this->_lang->def('_AVATAR'), 'boxed') : '<img class="boxed" src="' . getPathImage() . 'standard/user.png" alt="' . $this->_lang->def('_NOAVATAR') . '" />') . '</p>';
     $html .= '' . '<p class="userinfo">' . '<b>' . $this->_lang->def('_USERNAME') . '</b><br/> ' . $this->acl_man->relativeId($this->user_info[ACL_INFO_USERID]) . '</p>' . '<p class="userinfo">' . '<b>' . $this->_lang->def('_LASTNAME') . '</b><br/> ' . $this->acl_man->relativeId($this->user_info[ACL_INFO_LASTNAME]) . '</p>' . '<p class="userinfo">' . '<b>' . $this->_lang->def('_FIRSTNAME') . '</b><br/> ' . $this->acl_man->relativeId($this->user_info[ACL_INFO_FIRSTNAME]) . '</p>' . '<p class="userinfo">' . '<b>' . $this->_lang->def('_EMAIL') . '</b><br/> ' . ($this->user_info[ACL_INFO_EMAIL] !== false ? '<a href="mailto:' . $this->user_info[ACL_INFO_EMAIL] . '">' . $this->user_info[ACL_INFO_EMAIL] . '</a>' : $this->_lang->def('_HIDDEN')) . '</p>' . '<div class="nofloat"></div>';
     $social = new Social();
     if ($social->enabled()) {
         if (!$social->allConnected()) {
             $html .= '<b class="social-accounts-title">' . Lang::t('_CONNECT_YOUR_ACCOUNT_WITH', 'social') . '</b>';
             $html .= '<ul class="social-accounts">';
             if ($social->isActive('facebook') && !$social->connectedToUser('facebook')) {
                 $social = new Social();
                 $social->includeFacebookLib();
                 $client_id = Get::sett('social_fb_api');
                 $client_secret = Get::sett('social_fb_secret');
                 $redirect_uri = Get::sett('url') . 'index.php?modname=login&op=facebook_login';
                 $serviceFactory = new \OAuth\ServiceFactory();
                 $storage = new Session();
                 $credentials = new Credentials($client_id, $client_secret, $redirect_uri);
                 $facebookService = $serviceFactory->createService('facebook', $credentials, $storage, array());
                 //, 'userinfo_profile'
                 $loginUrl = $facebookService->getAuthorizationUri();
                 $html .= '<li><a href="' . $loginUrl . '" ' . 'title="' . Lang::t('_CONNECT', 'social') . ': ' . Lang::t('_FACEBOOK', 'social') . '"><span>' . Get::img('social/facebook.png', Lang::t('_FACEBOOK', 'social')) . '</span></a></li>';
             }
             if ($social->isActive('twitter') && !$social->connectedToUser('twitter')) {
                 $html .= '<li><a href="' . Get::sett('url') . 'index.php?modname=login&amp;op=twitter_login&amp;connect=1" ' . 'title="' . Lang::t('_CONNECT', 'social') . ': ' . Lang::t('_TWITTER', 'social') . '"><span>' . Get::img('social/twitter.png', Lang::t('_TWITTER', 'social')) . '</span></a></li>';
             }
             if ($social->isActive('linkedin') && !$social->connectedToUser('linkedin')) {
                 $html .= '<li><a href="' . Get::sett('url') . 'index.php?modname=login&amp;op=linkedin_login&amp;connect=1" ' . 'title="' . Lang::t('_CONNECT', 'social') . ': ' . Lang::t('_LINKEDIN', 'social') . '"><span>' . Get::img('social/linkedin.png', Lang::t('_LINKEDIN', 'social')) . '</span></a></li>';
             }
             if ($social->isActive('google') && !$social->connectedToUser('google')) {
                 $html .= '<li><a href="' . Get::sett('url') . 'index.php?modname=login&amp;op=google_login&amp;connect=1" ' . 'title="' . Lang::t('_CONNECT', 'social') . ': ' . Lang::t('_GOOGLE', 'social') . '"><span>' . Get::img('social/google.png', $this->user_info[ACL_INFO_GOOGLE_ID]) . '</span></a></li>';
             }
             $html .= '</ul><br/>';
         }
         if ($social->someConnected()) {
             $html .= '<b class="social-accounts-title">' . Lang::t('_CONNECTED_ACCOUNTS', 'social') . '</b>';
             $html .= '<ul class="social-accounts">';
             if ($social->connectedToUser('facebook')) {
                 $html .= '<li><a id="disconnect_facebook" href="index.php?r=SocialConnect/disconnect&amp;network=facebook" ' . 'title="' . Lang::t('_DISCONNECT', 'social') . ': ' . Lang::t('_FACEBOOK', 'social') . '"><span>' . Get::img('social/facebook.png', Lang::t('_FACEBOOK', 'social')) . '</span></a></li>';
             }
             if ($social->connectedToUser('twitter')) {
                 $html .= '<li><a id="disconnect_twitter" href="index.php?r=SocialConnect/disconnect&amp;network=twitter" ' . 'title="' . Lang::t('_DISCONNECT', 'social') . ': ' . Lang::t('_TWITTER', 'social') . '"><span>' . Get::img('social/twitter.png', Lang::t('_TWITTER', 'social')) . '</span></a></li>';
             }
             if ($social->connectedToUser('linkedin')) {
                 $html .= '<li><a id="disconnect_linkedin" href="index.php?r=SocialConnect/disconnect&amp;network=linkedin" ' . 'title="' . Lang::t('_DISCONNECT', 'social') . ': ' . Lang::t('_LINKEDIN', 'social') . '"><span>' . Get::img('social/linkedin.png', Lang::t('_LINKEDIN', 'social')) . '</span></a></li>';
             }
             if ($social->connectedToUser('google')) {
                 $html .= '<li><a id="disconnect_google" href="index.php?r=SocialConnect/disconnect&amp;network=google" ' . 'title="' . Lang::t('_DISCONNECT', 'social') . ': ' . Lang::t('_GOOGLE', 'social') . '"><span>' . Get::img('social/google.png', $this->user_info[ACL_INFO_GOOGLE_ID]) . '</span></a></li>';
             }
             $html .= '</ul>';
         }
         /* $html.=Util::widget('dialog', array(
         				'id' => 'confirm_disconnect',
         				'dynamicContent' => false,
         				'body'=>'mm',
         				'directSubmit'=>true,
         				'ajaxUrl' => '"ajax.adm_server.php?r=alms/enrollrules/add"',
         				'dynamicAjaxUrl' => true,
         				'callback' => 'function() {
         					this.destroy();
         				}',
         				'callEvents' => array(
         					array('caller' => 'disconnect_facebook', 'event' => 'click'),
         					array('caller' => 'disconnect_twitter', 'event' => 'click'),
         					array('caller' => 'disconnect_linkedin', 'event' => 'click'),
         					array('caller' => 'disconnect_google', 'event' => 'click'),
         				)
         			), true); */
     }
     $html .= '</div></div>';
     // box carriera
     require_once $GLOBALS['where_lms'] . '/lib/lib.middlearea.php';
     require_once $GLOBALS['where_lms'] . '/modules/course/course.php';
     $ma = new Man_MiddleArea();
     $access_career = $ma->currentCanAccessObj('career');
     //if($this->acl_man->relativeId($this->user_info[ACL_INFO_USERID]) == 'alberto' && $access_career) {
     if ($access_career) {
         $url = $this->_url_man;
         $course_stats = userCourseList($url, false, false);
         //TODO:  review this call . use course list to compute carreer
         $base_url = 'index.php?r=' . _after_login_ . '&amp;filter=';
         $end = 0;
         if (isset($course_stats['with_ustatus'][_CUS_END]) && $course_stats['with_ustatus'][_CUS_END] != 0) {
             $end = $course_stats['with_ustatus'][_CUS_END];
         }
         $html .= '<div class="inline_block">' . '<h2 class="heading">' . $this->_lang->def('_CAREER') . '</h2>' . '<div class="content">' . '<div class="course_stat">' . '<table summary="">' . '<tr><th scope="row">' . $this->_lang->def('_TOTAL_COURSE') . ' :</th><td>' . ($course_stats['total'] - $end) . '</td></tr>' . (isset($course_stats['with_ustatus'][_CUS_END]) && $course_stats['with_ustatus'][_CUS_END] != 0 ? '<tr><th scope="row">' . $this->_lang->def('_COURSE_END') . ' :</th><td>' . $course_stats['with_ustatus'][_CUS_END] . '</td></tr>' : '') . (isset($course_stats['expiring']) && $course_stats['expiring'] != 0 ? '<tr><th scope="row">' . $this->_lang->def('_COURSE_EXPIRING') . ' :</th><td>' . $course_stats['expiring'] . '</td></tr>' : '');
         if (count($course_stats['with_ulevel']) > 1) {
             require_once $GLOBALS['where_lms'] . '/lib/lib.levels.php';
             $lvl = CourseLevel::getLevels();
             foreach ($course_stats['with_ulevel'] as $lvl_num => $quantity) {
                 $html .= '' . '<tr><th scope="row">' . str_replace('[level]', $lvl[$lvl_num], $this->_lang->def('_COURSE_AS')) . ' :</th><td>' . $quantity . '</td></tr>';
             }
             //end foreach
         }
         $query = "SELECT c.idMetaCertificate, m.idCertificate" . " FROM " . $GLOBALS['prefix_lms'] . "_certificate_meta_course as c" . " JOIN " . $GLOBALS['prefix_lms'] . "_certificate_meta as m ON c.idMetaCertificate = m.idMetaCertificate" . " WHERE c.idUser = '******'" . " GROUP BY c.idMetaCertificate" . " ORDER BY m.title, m.description";
         $result = sql_query($query);
         $num_meta_cert = mysql_num_rows($result);
         while (list($id_meta, $id_certificate) = sql_fetch_row($result)) {
             $query_released = "SELECT on_date" . " FROM " . $GLOBALS['prefix_lms'] . "_certificate_meta_assign" . " WHERE idUser = '******'" . " AND idMetaCertificate = '" . $id_meta . "'";
             $result_released = sql_query($query_released);
             $query = "SELECT user_release" . " FROM " . $GLOBALS['prefix_lms'] . "_certificate" . " WHERE id_certificate = '" . $id_certificate . "'";
             list($user_release) = sql_fetch_row(sql_query($query));
             if (mysql_num_rows($result_released)) {
             } elseif ($user_release == 0) {
                 $num_meta_cert--;
             } else {
                 $query = "SELECT idCourse" . " FROM " . $GLOBALS['prefix_lms'] . "_certificate_meta_course" . " WHERE idUser = '******'" . " AND idMetaCertificate = '" . $id_meta . "'";
                 $result_int = sql_query($query);
                 $control = true;
                 while (list($id_course) = sql_fetch_row($result_int)) {
                     $query = "SELECT COUNT(*)" . " FROM " . $GLOBALS['prefix_lms'] . "_courseuser" . " WHERE idCourse = '" . $id_course . "'" . " AND idUser = '******'" . " AND status = '" . _CUS_END . "'";
                     list($number) = sql_fetch_row(sql_query($query));
                     if (!$number) {
                         $control = false;
                     }
                 }
                 if (!$control) {
                     $num_meta_cert--;
                 }
             }
         }
         $tot_cert = $num_meta_cert + $course_stats['cert_relesable'];
         $html .= '' . (isset($course_stats['cert_relesable']) && $tot_cert != 0 ? '<tr><th scope="row">' . $this->_lang->def('_CERT_RELESABLE') . ' :</th><td><a href="index.php?modname=mycertificate&amp;op=mycertificate">' . $tot_cert . '</a></td></tr>' : '') . ($pendent != 0 ? '<tr><th scope="row">' . $this->_lang->def('_FRIEND_PENDENT') . ' :</th><td><a href="index.php?modname=myfriends&amp;op=myfriends">' . $pendent . '</a></td></tr>' : '') . '</table>' . '</div>' . '</div>' . '</div>';
     }
     /*
     		$html = '<div class="user_presentation">'."\n"
     
     			.( $intest
     				? '<div class="mini_block">'."\n\t"
     						.'<h1>'."\n\t\t"
     							.$this->_lang->def('_WELCOME').'<br/>'."\n\t\t"
     							.'<span>'.$this->resolveUsername().'</span>'."\n\t"
     						.'</h1>'."\n\t"
     						.'<div class="spacer"></div>'."\n\t"
     					.'</div>'."\n"
     
     				: '' );
     
     		if($this->_user_profile->useAvatar()) {
     			$html .= '<div class="mini_block avatar_photo">'."\n\t";
     		}
     		if($this->_user_profile->useAvatar()) {
     
     			$html .= '<p>'."\n\t"
     						.( ($this->user_info[ACL_INFO_AVATAR] != "")
     							? $this->getPASrc($this->user_info[ACL_INFO_AVATAR], $this->_lang->def('_AVATAR'), 'boxed')
     							: '<img class="boxed" src="'.getPathImage().'standard/user.png" alt="'.$this->_lang->def('_NOAVATAR').'" />' )."\n\t\t"
     						.'<br />'."\n\t\t"
     						.$this->_lang->def('_AVATAR')."\n\t\t"
     					.'</p>'."\n\t";
     		}
     		if($this->_user_profile->useAvatar()) {
     
     			$html .= '<div class="nofloat"></div>'."\n\t"
     					.'<div class="spacer"></div>'."\n"
     					.'</div>'."\n";
     		}
     
     		$html .= '<div class="mini_block">'."\n\t"
     				.'<p class="userinfo">'."\n\t\t"
     					.'<b>'.$this->_lang->def('_USERNAME').':</b> '.$this->acl_man->relativeId($this->user_info[ACL_INFO_USERID])
     				.'</p>'."\n\t"
     				.'<p class="userinfo">'."\n\t\t"
     					.'<b>'.$this->_lang->def('_EMAIL').':</b> '
     					.( $this->user_info[ACL_INFO_EMAIL] !== false
     						? '<a href="mailto:'.$this->user_info[ACL_INFO_EMAIL].'">'.$this->user_info[ACL_INFO_EMAIL].'</a>'
     						: $this->_lang->def('_HIDDEN')
     					)."\n\t"
     				.'</p>'."\n\t"
     			.'</div>'."\n"
     
     		.'</div>'."\n";
     */
     return $html;
 }
Пример #3
0
 function _first_of_all($options, $platform)
 {
     $social = new Social();
     $lang =& DoceboLanguage::createInstance('register', $platform);
     $out = '';
     if ($options['use_advanced_form'] == 'off') {
         $out .= Form::getHidden('next_step', 'next_step', 'opt_in');
     } else {
         $out .= Form::getHidden('next_step', 'next_step', 'special_field');
     }
     $mand_sym = '<span class="mandatory">*</span>';
     $out .= '<div class="reg_note">' . $lang->def('_REG_NOTE') . '</div>' . '<ul class="reg_instruction">' . '<li>' . str_replace('[mandatory]', $mand_sym, $lang->def('_REG_MANDATORY')) . '</li>';
     if ($options['pass_min_char']) {
         $out .= '<li>' . str_replace('[min_char]', $options['pass_min_char'], $lang->def('_REG_PASS_MIN_CHAR')) . '</li>';
     }
     if ($options['pass_alfanumeric'] == 'on') {
         $out .= '<li>' . $lang->def('_REG_PASS_MUST_BE_ALPNUM') . '</li>';
     }
     //$out .= '<li>'.str_replace('[hour]', $options['hour_request_limit'], $lang->def('_REG_HOUR_REQUEST_LIMIT')).'</li>';
     if ($options['privacy_policy'] == 'on') {
         $out .= '<li>' . $lang->def('_REG_REMEMBER_PRIVACY') . '</li>';
     }
     $extra = '';
     // facebook register:
     if ($social->isActive('facebook')) {
         require_once _lms_ . "/modules/login/facebook.php";
         if (isset($_SESSION['fb_info']) && is_array($_SESSION['fb_info']) && !isset($_POST['register'])) {
             setFbRegData($_SESSION['fb_info']);
             $out .= '<li>' . $lang->def('_ACCOUNT_WILL_BE_CONNECTED_FB', 'login', 'cms') . '</li>';
         } else {
             $extra = getFbRegisterBox();
         }
     }
     // ----
     $out .= '</ul>' . $extra . Form::openElementSpace('reg_form');
     $out .= Form::getTextfield($lang->def('_USERNAME') . ' ' . $mand_sym, 'register_userid', 'register[userid]', 255, isset($_POST['register']['userid']) ? stripslashes($_POST['register']['userid']) : '') . Form::getTextfield($lang->def('_EMAIL') . ' ' . $mand_sym, 'register_email', 'register[email]', 255, isset($_POST['register']['email']) ? stripslashes($_POST['register']['email']) : '') . Form::getTextfield($lang->def('_FIRSTNAME') . ($options['lastfirst_mandatory'] == 'on' ? ' ' . $mand_sym : ''), 'register_firstname', 'register[firstname]', 255, isset($_POST['register']['firstname']) ? stripslashes($_POST['register']['firstname']) : '') . Form::getTextfield($lang->def('_LASTNAME') . ($options['lastfirst_mandatory'] == 'on' ? ' ' . $mand_sym : ''), 'register_lastname', 'register[lastname]', 255, isset($_POST['register']['lastname']) ? stripslashes($_POST['register']['lastname']) : '');
     if ($options['use_advanced_form'] == 'off') {
         $extra_field = new FieldList();
         $out .= $extra_field->playFieldsForUser(0, false, false);
     }
     $lang_sel = getLanguage();
     $full_langs = array();
     $langs = Docebo::langManager()->getAllLangCode();
     $full_langs = array();
     foreach ($langs as $v) {
         $full_langs[$v] = $v;
     }
     $out .= Form::getHidden('sop', 'sop', 'changelang');
     $out .= Form::getDropdown($lang->def('_LANGUAGE'), 'new_lang', 'new_lang', $full_langs, $lang_sel, '', '', ' onchange="submit();"');
     $out .= Form::getPassword($lang->def('_PASSWORD') . ' ' . $mand_sym, 'register_pwd', 'register[pwd]', 255, $lang->def('_PASSWORD')) . Form::getPassword($lang->def('_RETYPE_PASSWORD') . ' ' . $mand_sym, 'register_pwd_retype', 'register[pwd_retype]', 255, $lang->def('_RETYPE_PASSWORD'));
     $registration_code_type = Get::sett('registration_code_type', '0');
     $code_is_mandatory = Get::sett('mandatory_code', 'off');
     switch ($registration_code_type) {
         case "0":
             //nothin to do
             break;
         case "tree_course":
         case "code_module":
         case "tree_man":
             // we must ask the user to insert a manual code
             $out .= Form::getTextfield($lang->def('_CODE') . ($code_is_mandatory ? ' ' . $mand_sym : ''), 'reg_code', 'reg_code', 24, Get::req('reg_code', DOTY_MIXED, ''));
             break;
         case "tree_drop":
             // we must show to the user a selection of code
             $uma = new UsermanagementAdm();
             $tree_names = $uma->getAllFolderNames(true);
             $out .= Form::getDropdown($lang->def('_CODE') . ($code_is_mandatory ? ' ' . $mand_sym : ''), 'reg_code', 'reg_code', $tree_names, Get::req('reg_code', DOTY_MIXED, ''));
             break;
     }
     $out .= '<div class="reg_title_privacy">' . $lang->def('_REG_PRIVACY_POLICY_TILTE') . '</div>' . '<div class="privacy_box">' . $lang->def('_REG_PRIVACY_POLICY') . '</div>';
     if ($options['privacy_policy'] == 'on') {
         $out .= Form::getCheckbox($lang->def('_REG_PRIVACY_ACCEPT'), 'register_privacy', 'register[privacy]', 'ok', isset($_POST['register']['privacy']));
     }
     if ($options['use_advanced_form'] == 'on') {
         $acl_man =& Docebo::user()->getAclManager();
         $groups =& $acl_man->getAllGroupsId(array('free', 'moderate'));
         if (!empty($groups)) {
             $tb = new Table(0, $lang->def('_SELECT_GROUP'), $lang->def('_SELECT_GROUP_SUMMARY'));
             $type_h = array('image', 'nowrap', '');
             $cont_h = array('<span class="access-only">' . $lang->def('_SUBSCRIBE') . '</span>', $lang->def('_NAME'), $lang->def('_DESCRIPTION'));
             $tb->setColsStyle($type_h);
             $tb->addHead($cont_h);
             while (list($id, $info) = each($groups)) {
                 $cont = array(Form::getInputCheckbox('group_sel_' . $id, 'group_sel[]', $id, isset($_POST['group_sel'][$id]), ''), '<label for="group_sel_' . $id . '">' . $info['type_ico'] . ' ' . $info['groupid'] . '</label>', $info['description']);
                 $tb->addBody($cont);
             }
             $out .= $tb->getTable();
         }
     }
     $out .= Form::closeElementSpace() . Form::openButtonSpace('reg_form_button') . Form::getButton('reg_button', 'reg_button', $lang->def('_REGISTER')) . Form::closeButtonSpace();
     return $out;
 }