public static function displayPublicAdminBar($okt)
    {
        $aBasesUrl = new ArrayObject();
        $aPrimaryAdminBar = new ArrayObject();
        $aSecondaryAdminBar = new ArrayObject();
        $aBasesUrl['admin'] = $okt->config->app_path . OKT_ADMIN_DIR;
        $aBasesUrl['logout'] = $aBasesUrl['admin'] . '/index.php?logout=1';
        $aBasesUrl['profil'] = $aBasesUrl['admin'];
        # -- CORE TRIGGER : publicAdminBarBeforeDefaultsItems
        $okt->triggers->callTrigger('publicAdminBarBeforeDefaultsItems', $okt, $aPrimaryAdminBar, $aSecondaryAdminBar, $aBasesUrl);
        # éléments première barre
        $aPrimaryAdminBar[10] = array('intitle' => '<img src="' . OKT_PUBLIC_URL . '/img/notify/error.png" width="22" height="22" alt="' . __('c_c_warning') . '" />', 'items' => array());
        $aPrimaryAdminBar[100] = array('href' => $aBasesUrl['admin'], 'intitle' => __('c_c_administration'));
        $aPrimaryAdminBar[200] = array('intitle' => __('c_c_action_Add'), 'items' => array());
        # éléments seconde barre
        $aSecondaryAdminBar[100] = array('href' => $aBasesUrl['profil'], 'intitle' => sprintf(__('c_c_user_hello_%s'), html::escapeHTML(oktAuth::getUserCN($okt->user->username, $okt->user->lastname, $okt->user->firstname))));
        if (!$okt->languages->unique) {
            $iStartIdx = 150;
            foreach ($okt->languages->list as $aLanguage) {
                if ($aLanguage['code'] == $okt->user->language) {
                    continue;
                }
                $aSecondaryAdminBar[$iStartIdx++] = array('href' => html::escapeHTML($okt->config->app_path . $aLanguage['code'] . '/'), 'title' => html::escapeHTML($aLanguage['title']), 'intitle' => '<img src="' . OKT_PUBLIC_URL . '/img/flags/' . $aLanguage['img'] . '" alt="' . html::escapeHTML($aLanguage['title']) . '" />');
            }
        }
        $aSecondaryAdminBar[200] = array('href' => $aBasesUrl['logout'], 'intitle' => __('c_c_user_log_off_action'));
        # infos super-admin
        if ($okt->checkPerm('is_superadmin')) {
            # avertissement nouvelle version disponible
            if ($okt->config->update_enabled && is_readable(OKT_DIGESTS)) {
                $updater = new oktUpdate($okt->config->update_url, 'okatea', $okt->config->update_type, OKT_CACHE_PATH . '/versions');
                $new_v = $updater->check(util::getVersion());
                if ($updater->getNotify() && $new_v) {
                    # locales
                    l10n::set(OKT_LOCALES_PATH . '/' . $okt->user->language . '/admin.update');
                    $aPrimaryAdminBar[10]['items'][100] = array('href' => $aBasesUrl['admin'] . '/configuration.php?action=update', 'intitle' => sprintf(__('c_a_update_okatea_%s_available'), $new_v));
                }
            }
            # avertissement mode maintenance est activé sur la partie publique
            if ($okt->config->public_maintenance_mode) {
                $aPrimaryAdminBar[10]['items'][300] = array('href' => $aBasesUrl['admin'] . '/configuration.php?action=advanced#tab_others', 'intitle' => sprintf(__('c_a_public_maintenance_mode_enabled'), $new_v));
            }
            # avertissement mode maintenance est activé sur l'admin
            if ($okt->config->admin_maintenance_mode) {
                $aPrimaryAdminBar[10]['items'][400] = array('href' => $aBasesUrl['admin'] . '/configuration.php?action=advanced#tab_others', 'intitle' => sprintf(__('c_a_admin_maintenance_mode_enabled'), $new_v));
            }
            # info execution
            $aExecInfos = array();
            $aExecInfos['execTime'] = util::getExecutionTime();
            if (OKT_XDEBUG) {
                $aExecInfos['memUsage'] = util::l10nFileSize(xdebug_memory_usage());
                $aExecInfos['peakUsage'] = util::l10nFileSize(xdebug_peak_memory_usage());
            } else {
                $aExecInfos['memUsage'] = util::l10nFileSize(memory_get_usage());
                $aExecInfos['peakUsage'] = util::l10nFileSize(memory_get_peak_usage());
            }
            $aSecondaryAdminBar[1000] = array('title' => $aExecInfos['execTime'] . ' s - ' . $aExecInfos['memUsage'], 'intitle' => '<img src="' . OKT_PUBLIC_URL . '/img/ico/terminal.gif" width="16" height="16" alt="" />', 'items' => array(array('intitle' => 'Temps d\'execution du script&nbsp;: ' . $aExecInfos['execTime'] . ' s'), array('intitle' => 'Mémoire utilisée par PHP&nbsp;: ' . $aExecInfos['memUsage']), array('intitle' => 'Pic mémoire allouée par PHP&nbsp;: ' . $aExecInfos['peakUsage']), array('intitle' => 'Router lang&nbsp;: ' . $okt->router->getLanguage()), array('intitle' => 'Router path&nbsp;: ' . $okt->router->getPath()), array('intitle' => 'Router route ID&nbsp;: ' . $okt->router->getFindedRouteId())));
            if (!empty($okt->page->module)) {
                $aSecondaryAdminBar[1000]['items'][] = array('intitle' => '$okt->page->module&nbsp;: ' . $okt->page->module);
            }
            if (!empty($okt->page->action)) {
                $aSecondaryAdminBar[1000]['items'][] = array('intitle' => '$okt->page->action&nbsp;: ' . $okt->page->action);
            }
        }
        # -- CORE TRIGGER : publicAdminBarItems
        $okt->triggers->callTrigger('publicAdminBarItems', $okt, $aPrimaryAdminBar, $aSecondaryAdminBar, $aBasesUrl);
        # sort items of by keys
        $aPrimaryAdminBar->ksort();
        $aSecondaryAdminBar->ksort();
        # remove empty values of admins bars
        $aPrimaryAdminBar = array_filter((array) $aPrimaryAdminBar);
        $aSecondaryAdminBar = array_filter((array) $aSecondaryAdminBar);
        # reverse sedond bar items
        $aSecondaryAdminBar = array_reverse($aSecondaryAdminBar);
        $class = '';
        ?>
		<div id="oktadminbar" class="<?php 
        echo $class;
        ?>
" role="navigation">
			<a class="screen-reader-shortcut" href="#okt-toolbar" tabindex="1"><?php 
        _e('Skip to toolbar');
        ?>
			</a>
			<div class="quicklinks" id="okt-toolbar" role="navigation"
				aria-label="<?php 
        echo util::escapeAttrHTML(__('Top navigation toolbar.'));
        ?>
"
				tabindex="0">
				<ul class="ab-top-menu">
					<?php 
        foreach ($aPrimaryAdminBar as $aPrimaryItem) {
            echo self::getItems($aPrimaryItem);
        }
        ?>
				</ul>
				<ul class="ab-top-secondary ab-top-menu">
					<?php 
        foreach ($aSecondaryAdminBar as $aSecondaryItem) {
            echo self::getItems($aSecondaryItem);
        }
        ?>
				</ul>
			</div>
			<a class="screen-reader-shortcut"
				href="<?php 
        echo $aBasesUrl['logout'];
        ?>
"><?php 
        _e('c_c_user_log_off_action');
        ?>
			</a>
		</div>
		<?php 
    }
Example #2
0
$okt->page->messages->setItems($okt->page->flashMessages->getMessages('success'));
$okt->page->warnings->setItems($okt->page->flashMessages->getMessages('warning'));
$okt->page->errors->setItems($okt->page->flashMessages->getMessages('error'));
# construction du menu principal
$mainMenuHtml = null;
if (!defined('OKT_DISABLE_MENU')) {
    $mainMenuHtml = $okt->page->mainMenu->build();
    $okt->page->accordion(array('heightStyle' => 'auto', 'active' => $mainMenuHtml['active'] === null ? 0 : $mainMenuHtml['active']), '#mainMenu-' . ($okt->config->admin_sidebar_position == 0 ? 'left' : 'right'));
}
# init user bars
$aUserBarA = new ArrayObject();
$aUserBarB = new ArrayObject();
# logged in user
if (!$okt->user->is_guest) {
    # profil link
    $sProfilLink = html::escapeHTML(oktAuth::getUserCN($okt->user->username, $okt->user->lastname, $okt->user->firstname));
    if ($okt->modules->moduleExists('users')) {
        $sProfilLink = '<a href="module.php?m=users&amp;action=profil&amp;id=' . $okt->user->id . '">' . $sProfilLink . '</a>';
    }
    $aUserBarA[10] = sprintf(__('c_c_user_hello_%s'), $sProfilLink);
    unset($sProfilLink);
    # log off link
    $aUserBarA[90] = '<a href="?logout=1">' . __('c_c_user_log_off_action') . '</a>';
    # last visit info
    $aUserBarB[10] = sprintf(__('c_c_user_last_visit_on_%s'), dt::str('%A %d %B %Y %H:%M', $okt->user->last_visit));
} else {
    $aUserBarA[10] = __('c_c_user_hello_you_are_not_logged');
}
# languages switcher
if ($okt->config->admin_lang_switcher && !$okt->languages->unique) {
    $sBaseUri = $okt->config->self_uri;
Example #3
0
 /**
  * Retourne l'auteur d'un article
  *
  * @return string
  */
 public function getPostAuthor()
 {
     return oktAuth::getUserCN($this->username, $this->lastname, $this->firstname);
 }
Example #4
0
 protected function fileRecord($rs)
 {
     if ($rs->isEmpty()) {
         return null;
     }
     if (!$this->isFileExclude($this->root . '/' . $rs->media_file) && is_file($this->root . '/' . $rs->media_file)) {
         $f = new fileItem($this->root . '/' . $rs->media_file, $this->root, $this->root_url);
         if ($this->type && $f->type_prefix != $this->type) {
             return null;
         }
         $meta = @simplexml_load_string($rs->media_meta);
         $f->editable = true;
         $f->media_id = $rs->media_id;
         $f->media_title = $rs->media_title;
         $f->media_meta = $meta instanceof SimpleXMLElement ? $meta : simplexml_load_string('<meta></meta>');
         $f->media_user_id = $rs->user_id;
         $f->media_user = oktAuth::getUserCN($rs->username, $rs->lastname, $rs->firstname);
         $f->media_priv = (bool) $rs->media_private;
         $f->media_dt = strtotime($rs->media_dt);
         $f->media_dtstr = dt::str('%Y-%m-%d %H:%M', $f->media_dt);
         $f->media_image = false;
         if (!$this->okt->checkPerm('media_admin') && $this->okt->user->id != $f->media_user_id) {
             $f->del = false;
             $f->editable = false;
         }
         $type_prefix = explode('/', $f->type);
         $type_prefix = $type_prefix[0];
         switch ($type_prefix) {
             case 'image':
                 $f->media_image = true;
                 $f->media_icon = 'image';
                 break;
             case 'audio':
                 $f->media_icon = 'audio';
                 break;
             case 'text':
                 $f->media_icon = 'text';
                 break;
             case 'video':
                 $f->media_icon = 'video';
                 break;
             default:
                 $f->media_icon = 'blank';
         }
         switch ($f->type) {
             case 'application/msword':
             case 'application/vnd.oasis.opendocument.text':
             case 'application/vnd.sun.xml.writer':
             case 'application/pdf':
             case 'application/postscript':
                 $f->media_icon = 'document';
                 break;
             case 'application/msexcel':
             case 'application/vnd.oasis.opendocument.spreadsheet':
             case 'application/vnd.sun.xml.calc':
                 $f->media_icon = 'spreadsheet';
                 break;
             case 'application/mspowerpoint':
             case 'application/vnd.oasis.opendocument.presentation':
             case 'application/vnd.sun.xml.impress':
                 $f->media_icon = 'presentation';
                 break;
             case 'application/x-debian-package':
             case 'application/x-gzip':
             case 'application/x-java-archive':
             case 'application/rar':
             case 'application/x-redhat-package-manager':
             case 'application/x-tar':
             case 'application/x-gtar':
             case 'application/zip':
                 $f->media_icon = 'package';
                 break;
             case 'application/octet-stream':
                 $f->media_icon = 'executable';
                 break;
             case 'application/x-shockwave-flash':
                 $f->media_icon = 'video';
                 break;
             case 'application/ogg':
                 $f->media_icon = 'audio';
                 break;
             case 'text/html':
                 $f->media_icon = 'html';
                 break;
         }
         $f->media_type = $f->media_icon;
         $f->media_icon = sprintf($this->icon_img, $f->media_icon);
         # Thumbnails
         $f->media_thumb = array();
         $p = path::info($f->relname);
         $thumb = sprintf($this->thumb_tp, $this->root . '/' . $p['dirname'], $p['base'], '%s');
         $thumb_url = sprintf($this->thumb_tp, $this->root_url . $p['dirname'], $p['base'], '%s');
         # Cleaner URLs
         $thumb_url = preg_replace('#\\./#', '/', $thumb_url);
         $thumb_url = preg_replace('#(?<!:)/+#', '/', $thumb_url);
         foreach ($this->thumb_sizes as $suffix => $s) {
             if (file_exists(sprintf($thumb, $suffix))) {
                 $f->media_thumb[$suffix] = sprintf($thumb_url, $suffix);
             }
         }
         if (isset($f->media_thumb['sq']) && $f->media_type == 'image') {
             $f->media_icon = $f->media_thumb['sq'];
         }
         return $f;
     }
     return null;
 }
 /**
  * Réalise une inscription.
  *
  */
 protected function performRegister()
 {
     # default data
     $this->aUserRegisterData = array('civility' => 1, 'username' => '', 'lastname' => '', 'firstname' => '', 'password' => '', 'password_confirm' => '', 'email' => '', 'group_id' => $this->okt->users->config->default_group, 'timezone' => $this->okt->config->timezone, 'language' => $this->okt->config->language);
     # Champs personnalisés
     if ($this->okt->users->config->enable_custom_fields) {
         $aPostedData = array();
         # Liste des champs
         $this->rsUserFields = $this->okt->users->fields->getFields(array('status' => true, 'user_editable' => true, 'register' => true, 'language' => $this->okt->user->language));
         # Valeurs des champs
         $rsFieldsValues = $this->okt->users->fields->getUserValues($this->okt->user->id);
         $aFieldsValues = array();
         while ($rsFieldsValues->fetch()) {
             $aFieldsValues[$rsFieldsValues->field_id] = $rsFieldsValues->value;
         }
         # Initialisation des données des champs
         while ($this->rsUserFields->fetch()) {
             switch ($this->rsUserFields->type) {
                 default:
                 case 1:
                     # Champ texte
                 # Champ texte
                 case 2:
                     # Zone de texte
                     $aPostedData[$this->rsUserFields->id] = !empty($_POST[$this->rsUserFields->html_id]) ? $_POST[$this->rsUserFields->html_id] : (!empty($aFieldsValues[$this->rsUserFields->id]) ? $aFieldsValues[$this->rsUserFields->id] : '');
                     break;
                 case 3:
                     # Menu déroulant
                     $aPostedData[$this->rsUserFields->id] = isset($_POST[$this->rsUserFields->html_id]) ? $_POST[$this->rsUserFields->html_id] : (!empty($aFieldsValues[$this->rsUserFields->id]) ? $aFieldsValues[$this->rsUserFields->id] : '');
                     break;
                 case 4:
                     # Boutons radio
                     $aPostedData[$this->rsUserFields->id] = isset($_POST[$this->rsUserFields->html_id]) ? $_POST[$this->rsUserFields->html_id] : (!empty($aFieldsValues[$this->rsUserFields->id]) ? $aFieldsValues[$this->rsUserFields->id] : '');
                     break;
                 case 5:
                     # Cases à cocher
                     $aPostedData[$this->rsUserFields->id] = !empty($_POST[$this->rsUserFields->html_id]) && is_array($_POST[$this->rsUserFields->html_id]) ? $_POST[$this->rsUserFields->html_id] : (!empty($aFieldsValues[$this->rsUserFields->id]) ? $aFieldsValues[$this->rsUserFields->id] : '');
                     break;
             }
         }
     }
     # ajout d'un utilisateur
     if (!empty($_POST['add_user'])) {
         $this->aUserRegisterData = array('active' => 1, 'username' => !empty($_POST['add_username']) ? $_POST['add_username'] : '', 'lastname' => !empty($_POST['add_lastname']) ? $_POST['add_lastname'] : '', 'firstname' => !empty($_POST['add_firstname']) ? $_POST['add_firstname'] : '', 'password' => !empty($_POST['add_password']) ? $_POST['add_password'] : '', 'password_confirm' => !empty($_POST['add_password_confirm']) ? $_POST['add_password_confirm'] : '', 'email' => !empty($_POST['add_email']) ? $_POST['add_email'] : '', 'group_id' => $this->okt->users->config->user_choose_group && !empty($_POST['add_group_id']) && in_array($_POST['add_group_id'], $this->getGroups()) ? $_POST['add_group_id'] : $this->okt->users->config->default_group, 'timezone' => !empty($_POST['add_timezone']) ? $_POST['add_timezone'] : $this->okt->config->timezone, 'language' => !empty($_POST['add_language']) && in_array($_POST['add_language'], $this->getLanguages()) ? $_POST['add_language'] : $this->okt->config->language, 'civility' => !empty($_POST['add_civility']) ? $_POST['add_civility'] : '');
         if ($this->okt->users->config->merge_username_email) {
             $this->aUserRegisterData['username'] = $this->aUserRegisterData['email'];
         }
         # vérification des champs personnalisés obligatoires
         if ($this->okt->users->config->enable_custom_fields) {
             while ($this->rsUserFields->fetch()) {
                 if ($this->rsUserFields->active == 2 && empty($aPostedData[$this->rsUserFields->id])) {
                     $this->okt->error->set('Vous devez renseigner le champ "' . html::escapeHtml($this->rsUserFields->title) . '".');
                 }
             }
         }
         if (($new_id = $this->okt->users->addUser($this->aUserRegisterData)) !== false) {
             $_POST['user_id'] = $new_id;
             # -- CORE TRIGGER : adminModUsersRegisterProcess
             $this->okt->triggers->callTrigger('adminModUsersRegisterProcess', $this->okt, $_POST);
             $rsUser = $this->okt->users->getUser($new_id);
             if ($this->okt->users->config->enable_custom_fields) {
                 while ($this->rsUserFields->fetch()) {
                     $this->okt->users->fields->setUserValues($new_id, $this->rsUserFields->id, $aPostedData[$this->rsUserFields->id]);
                 }
             }
             # Initialisation du mailer et envoi du mail
             $oMail = new oktMail($this->okt);
             $oMail->setFrom();
             if ($this->okt->users->config->validate_users_registration) {
                 $template_file = 'welcom_waiting.tpl';
             } else {
                 $template_file = 'welcom.tpl';
             }
             $oMail->useFile(__DIR__ . '/../locales/' . $rsUser->language . '/templates/' . $template_file, array('SITE_TITLE' => util::getSiteTitle($rsUser->language), 'SITE_URL' => $this->okt->config->app_url, 'USER_CN' => oktAuth::getUserCN($rsUser->username, $rsUser->lastname, $rsUser->firstname), 'USERNAME' => $rsUser->username, 'PASSWORD' => $this->aUserRegisterData['password']));
             $oMail->message->setTo($rsUser->email);
             $oMail->send();
             # Initialisation du mailer et envoi du mail à l'administrateur
             if ($this->okt->users->config->mail_new_registration) {
                 $oMail = new oktMail($this->okt);
                 $oMail->setFrom();
                 if ($this->okt->users->config->validate_users_registration) {
                     $template_file = 'registration_validate.tpl';
                 } else {
                     $template_file = 'registration.tpl';
                 }
                 $rsAdministrators = $this->okt->users->getUsers(array('group_id' => oktAuth::admin_group_id));
                 while ($rsAdministrators->fetch()) {
                     $oMail->useFile(__DIR__ . '/../locales/' . $rsAdministrators->language . '/templates/' . $template_file, array('SITE_TITLE' => util::getSiteTitle($rsUser->language), 'SITE_URL' => $this->okt->config->app_url, 'USER_CN' => oktAuth::getUserCN($rsUser->username, $rsUser->lastname, $rsUser->firstname), 'PROFIL' => $this->okt->config->app_url . OKT_ADMIN_DIR . '/module.php?m=users&action=edit&id=' . $rsUser->id));
                     $oMail->message->setTo($rsAdministrators->email);
                     $oMail->send();
                 }
             }
             # eventuel connexion du nouvel utilisateur
             if (!$this->okt->users->config->validate_users_registration && $this->okt->users->config->auto_log_after_registration) {
                 $this->okt->user->login($this->aUserRegisterData['username'], $this->aUserRegisterData['password'], false);
             }
             $this->performRedirect();
             //	$this->unsetSessionRedirectUrl();
             //	http::redirect(usersHelpers::getRegisterUrl().'?registered=1');
         }
     }
 }
Example #6
0
</span>
				<?php 
            }
            ?>
				</p>
			<?php 
        }
        ?>
			</td>

			<td class="<?php 
        echo $rsPosts->odd_even;
        ?>
">
				<?php 
        echo html::escapeHTML(oktAuth::getUserCN($rsPosts->username, $rsPosts->lastname, $rsPosts->firstname));
        ?>
			</td>

			<td class="<?php 
        echo $rsPosts->odd_even;
        ?>
 small nowrap">
				<ul class="actions">
				<?php 
        if ($rsPosts->active == 0) {
            ?>
					<li><a href="module.php?m=news&amp;action=index&amp;switch_status=<?php 
            echo $rsPosts->id;
            ?>
"
Example #7
0
# récupération des infos utilisateur
$user_id = !empty($_REQUEST['id']) ? $_REQUEST['id'] : null;
if ($user_id === null || $user_id != $okt->user->id) {
    $okt->redirect('index.php');
}
$rsUser = $okt->users->getUser($user_id);
$edit_username = $rsUser->username;
$edit_email = $rsUser->email;
$edit_civility = $rsUser->civility;
$edit_lastname = $rsUser->lastname;
$edit_firstname = $rsUser->firstname;
$edit_language = $rsUser->language;
$edit_timezone = $rsUser->timezone;
$edit_password = '';
$edit_password_confirm = '';
$sUserCN = oktAuth::getUserCN($rsUser->username, $rsUser->lastname, $rsUser->firstname);
unset($rsUser);
/* Traitements
----------------------------------------------------------*/
# Suppression des cookies
if (!empty($_REQUEST['delete_cookies'])) {
    $aCookies = array_keys($_COOKIE);
    unset($aCookies[OKT_COOKIE_AUTH_NAME]);
    foreach ($aCookies as $c) {
        unset($_COOKIE[$c]);
        setcookie($c, null);
    }
    $okt->page->flashMessages->addSuccess(__('m_users_cookies_has_been_deleted'));
    $okt->redirect('module.php?m=users&action=profil&id=' . $user_id);
}
# Formulaire de changement de mot de passe
Example #8
0
<?php 
# début Okatea : ajout du CHEMIN du fichier LESS
$okt->page->css->addLessFile(__DIR__ . '/styles.less');
# fin Okatea : ajout du CHEMIN du fichier LESS
?>


<div id="userbar">
<?php 
if (!$okt->user->infos->is_guest) {
    ?>

	<p>
		<?php 
    printf(__('c_c_user_hello_%s'), html::escapeHTML(oktAuth::getUserCN($okt->user->username, $okt->user->lastname, $okt->user->firstname)));
    ?>

		<?php 
    # début Okatea : lien page profil
    if ($okt->users->config->enable_profile_page) {
        ?>
		- <a href="<?php 
        echo html::escapeHTML(usersHelpers::getProfileUrl());
        ?>
"><?php 
        _e('c_c_user_profile');
        ?>
</a>
		<?php 
    }