Пример #1
0
 protected function build_groups(SessionData $session)
 {
     $groups = GroupsService::get_groups();
     foreach ($groups as $idgroup => $array_info) {
         $this->groups_auth[$idgroup] = $array_info['auth'];
     }
     $groups = explode('|', $session->get_cached_data('groups', ''));
     array_unshift($groups, 'r' . $this->level);
     $this->set_groups($groups);
 }
Пример #2
0
         }
     }
 }
 $theme = AppContext::get_current_user()->get_theme();
 //Image associée au rang.
 if (file_exists(TPL_PATH_TO_ROOT . '/templates/' . $theme . '/modules/forum/images/ranks/' . $user_rank_icon)) {
     $rank_img = TPL_PATH_TO_ROOT . '/templates/' . $theme . '/modules/forum/images/ranks/' . $user_rank_icon;
 } else {
     $rank_img = TPL_PATH_TO_ROOT . '/forum/templates/images/ranks/' . $user_rank_icon;
 }
 $user_assoc_img = !empty($user_rank_icon) ? '<img src="' . $rank_img . '" alt="' . $LANG['rank'] . '" />' : '';
 //Affichage des groupes du membre.
 if (!empty($row['groups'])) {
     $user_groups = '';
     $array_user_groups = explode('|', $row['groups']);
     foreach (GroupsService::get_groups() as $idgroup => $array_group_info) {
         if (is_numeric(array_search($idgroup, $array_user_groups))) {
             $user_groups .= !empty($array_group_info['img']) ? '<img src="../images/group/' . $array_group_info['img'] . '" alt="' . $array_group_info['name'] . '" title="' . $array_group_info['name'] . '"/><br />' : $LANG['group'] . ': ' . $array_group_info['name'] . '<br />';
         }
     }
 } else {
     $user_groups = $LANG['group'] . ': ' . $user_group;
 }
 $user_accounts_config = UserAccountsConfig::load();
 //Avatar
 if (empty($row['user_avatar'])) {
     $user_avatar = $user_accounts_config->is_default_avatar_enabled() == '1' ? '<img src="../templates/' . AppContext::get_current_user()->get_theme() . '/images/' . $user_accounts_config->get_default_avatar_name() . '" alt="' . LangLoader::get_message('avatar', 'user-common') . '" />' : '';
 } else {
     $user_avatar = '<img src="' . Url::to_rel($row['user_avatar']) . '" alt="' . LangLoader::get_message('avatar', 'user-common') . '" />';
 }
 //Affichage du nombre de message.
Пример #3
0
 /**
  * @desc Generate a multiple select field for the form which create authorization for ranks, groups and members.
  * @param int $auth_bit The bit emplacement used to set it.
  * @param array $array_auth Array of authorization, allow you to select value authorized for this bit.
  * @param array $array_ranks_default Array of ranks selected by default.
  * @param string $idselect Html id used for the select.
  * @param int $disabled Disabled all option for the select. Set to 1 for disable.
  * @param boolean $disabled_advanced_auth Disable advanced authorizations.
  * @return String The formated select.
  * @static
  */
 public static function generate_select($auth_bit, $array_auth = array(), $array_ranks_default = array(), $idselect = '', $disabled = '', $disabled_advanced_auth = false)
 {
     global $LANG, $array_ranks;
     //Récupération du tableau des rangs.
     $array_ranks = is_array($array_ranks) ? $array_ranks : array('-1' => $LANG['guest'], '0' => $LANG['member'], '1' => $LANG['modo'], '2' => $LANG['admin']);
     //Identifiant du select, par défaut la valeur du bit de l'autorisation.
     $idselect = (string) $idselect == '' ? $auth_bit : $idselect;
     $tpl = new FileTemplate('framework/groups_auth.tpl');
     $tpl->put_all(array('C_NO_ADVANCED_AUTH' => $disabled_advanced_auth ? true : false, 'C_ADVANCED_AUTH' => $disabled_advanced_auth ? false : true, 'IDSELECT' => $idselect, 'DISABLED_SELECT' => empty($disabled) ? 'if (disabled == 0)' : '', 'L_USERS' => $LANG['member_s'], 'L_ADD_USER' => $LANG['add_member'], 'L_REQUIRE_PSEUDO' => addslashes($LANG['require_pseudo']), 'L_RANKS' => $LANG['ranks'], 'L_GROUPS' => $LANG['groups'], 'L_GO' => $LANG['go'], 'L_ADVANCED_AUTHORIZATION' => $LANG['advanced_authorization'], 'L_SELECT_ALL' => $LANG['select_all'], 'L_SELECT_NONE' => $LANG['select_none'], 'L_EXPLAIN_SELECT_MULTIPLE' => $LANG['explain_select_multiple']));
     ##### Génération d'une liste à sélection multiple des rangs et membres #####
     //Liste des rangs
     $j = -1;
     foreach ($array_ranks as $idrank => $group_name) {
         //Si il s'agit de l'administrateur, il a automatiquement l'autorisation
         if ($idrank == 2) {
             $tpl->assign_block_vars('ranks_list', array('ID' => $j, 'IDRANK' => $idrank, 'RANK_NAME' => $group_name, 'DISABLED' => '', 'SELECTED' => ' selected="selected"'));
         } else {
             $selected = '';
             if (array_key_exists('r' . $idrank, $array_auth) && ((int) $array_auth['r' . $idrank] & (int) $auth_bit) !== 0 && empty($disabled)) {
                 $selected = ' selected="selected"';
             }
             $selected = isset($array_ranks_default[$idrank]) && $array_ranks_default[$idrank] === true && empty($disabled) ? 'selected="selected"' : $selected;
             $tpl->assign_block_vars('ranks_list', array('ID' => $j, 'IDRANK' => $idrank, 'RANK_NAME' => $group_name, 'DISABLED' => !empty($disabled) ? 'disabled = "disabled" ' : '', 'SELECTED' => $selected));
         }
         $j++;
     }
     //Liste des groupes.
     $groups_name = GroupsService::get_groups_names();
     foreach ($groups_name as $idgroup => $group_name) {
         $selected = '';
         if (array_key_exists($idgroup, $array_auth) && ((int) $array_auth[$idgroup] & (int) $auth_bit) !== 0 && empty($disabled)) {
             $selected = ' selected="selected"';
         }
         $tpl->assign_block_vars('groups_list', array('IDGROUP' => $idgroup, 'GROUP_NAME' => $group_name, 'DISABLED' => $disabled, 'SELECTED' => $selected));
     }
     ##### Génération du formulaire pour les autorisations membre par membre. #####
     //Recherche des membres autorisé.
     $array_auth_members = array();
     if (is_array($array_auth)) {
         foreach ($array_auth as $type => $auth) {
             if (substr($type, 0, 1) == 'm') {
                 if (array_key_exists($type, $array_auth) && ((int) $array_auth[$type] & (int) $auth_bit) !== 0) {
                     $array_auth_members[$type] = $auth;
                 }
             }
         }
     }
     $advanced_auth = count($array_auth_members) > 0;
     $tpl->put_all(array('ADVANCED_AUTH_STYLE' => $advanced_auth ? 'display:block;' : 'display:none;', 'C_ADVANCED_AUTH_OPEN' => $advanced_auth, 'C_NO_GROUP' => count($groups_name) == 0));
     //Listing des membres autorisés.
     if ($advanced_auth) {
         $result = PersistenceContext::get_querier()->select_rows(DB_TABLE_MEMBER, array('user_id, display_name'), 'WHERE user_id=:user_ids', array('user_ids' => str_replace('m', '', array_keys($array_auth_members))));
         while ($row = $result->fetch()) {
             $tpl->assign_block_vars('members_list', array('USER_ID' => $row['user_id'], 'LOGIN' => $row['display_name']));
         }
         $result->dispose();
     }
     return $tpl->render();
 }
Пример #4
0
 public static function __static()
 {
     self::$db_querier = PersistenceContext::get_querier();
 }
Пример #5
0
    }
    if (!empty($user_id)) {
        if (GroupsService::add_member($user_id, $idgroup)) {
            GroupsCache::invalidate();
            SessionData::recheck_cached_data_from_user_id($user_id);
            AppContext::get_response()->redirect('/admin/admin_groups.php?id=' . $idgroup . '#add');
        } else {
            AppContext::get_response()->redirect('/admin/admin_groups.php?id=' . $idgroup . '&error=already_group#message_helper');
        }
    } else {
        AppContext::get_response()->redirect('/admin/admin_groups.php?id=' . $idgroup . '&error=incomplete#message_helper');
    }
} elseif ($del_mbr && !empty($user_id) && !empty($idgroup)) {
    AppContext::get_session()->csrf_get_protect();
    //Protection csrf
    GroupsService::remove_member($user_id, $idgroup);
    GroupsCache::invalidate();
    SessionData::recheck_cached_data_from_user_id($user_id);
    AppContext::get_response()->redirect('/admin/admin_groups.php?id=' . $idgroup . '#add');
} elseif (!empty($_FILES['upload_groups']['name'])) {
    //Si le dossier n'est pas en écriture on tente un CHMOD 777
    @clearstatcache();
    $dir = PATH_TO_ROOT . '/images/group/';
    if (!is_writable($dir)) {
        $is_writable = @chmod($dir, 0777) ? true : false;
    }
    @clearstatcache();
    $error = '';
    if (is_writable($dir)) {
        $authorized_pictures_extensions = FileUploadConfig::load()->get_authorized_picture_extensions();
        if (!empty($authorized_pictures_extensions)) {
 private function save(HTTPRequestCustom $request)
 {
     $has_error = false;
     $user_id = $this->user->get_id();
     if ($this->form->get_value('delete_account')) {
         UserService::delete_by_id($user_id);
     } else {
         $approbation = $this->internal_auth_infos['approved'];
         if (AppContext::get_current_user()->is_admin()) {
             $old_approbation = $approbation;
             $approbation = $this->form->get_value('approbation');
             $groups = array();
             foreach ($this->form->get_value('groups') as $field => $option) {
                 $groups[] = $option->get_raw_value();
             }
             GroupsService::edit_member($user_id, $groups);
             $this->user->set_groups($groups);
             $this->user->set_level($this->form->get_value('rank')->get_raw_value());
         }
         if ($this->form->has_field('theme')) {
             $this->user->set_theme($this->form->get_value('theme')->get_raw_value());
         }
         $this->user->set_locale($this->form->get_value('lang')->get_raw_value());
         $this->user->set_display_name($this->form->get_value('display_name'));
         $this->user->set_email($this->form->get_value('email'));
         $this->user->set_locale($this->form->get_value('lang')->get_raw_value());
         $this->user->set_editor($this->form->get_value('text-editor')->get_raw_value());
         $this->user->set_show_email(!$this->form->get_value('user_hide_mail'));
         $this->user->set_timezone($this->form->get_value('timezone')->get_raw_value());
         try {
             UserService::update($this->user, $this->member_extended_fields_service);
         } catch (MemberExtendedFieldErrorsMessageException $e) {
             $has_error = true;
             $this->tpl->put('MSG', MessageHelper::display($e->getMessage(), MessageHelper::NOTICE));
         }
         $login = $this->form->get_value('email');
         if ($this->form->get_value('custom_login', false)) {
             $login = $this->form->get_value('login');
         }
         $password = $this->form->get_value('password');
         if ($this->internal_auth_infos === null && !empty($password)) {
             $authentication_method = new PHPBoostAuthenticationMethod($login, $password);
             AuthenticationService::associate($authentication_method, $user_id);
         } elseif (!empty($password)) {
             $old_password = $this->form->get_value('old_password');
             if (!empty($old_password)) {
                 $old_password_hashed = KeyGenerator::string_hash($old_password);
                 if ($old_password_hashed == $this->internal_auth_infos['password']) {
                     PHPBoostAuthenticationMethod::update_auth_infos($user_id, $login, $approbation, KeyGenerator::string_hash($password));
                     $has_error = false;
                 } else {
                     $has_error = true;
                     $this->tpl->put('MSG', MessageHelper::display($this->lang['profile.edit.password.error'], MessageHelper::NOTICE));
                 }
             }
         } else {
             PHPBoostAuthenticationMethod::update_auth_infos($user_id, $login, $approbation);
         }
         if (AppContext::get_current_user()->is_admin()) {
             if ($old_approbation != $approbation && $old_approbation == 0) {
                 //Recherche de l'alerte correspondante
                 $matching_alerts = AdministratorAlertService::find_by_criteria($user_id, 'member_account_to_approbate');
                 //L'alerte a été trouvée
                 if (count($matching_alerts) == 1) {
                     $alert = $matching_alerts[0];
                     $alert->set_status(AdministratorAlert::ADMIN_ALERT_STATUS_PROCESSED);
                     AdministratorAlertService::save_alert($alert);
                     $site_name = GeneralConfig::load()->get_site_name();
                     $subject = StringVars::replace_vars($this->user_lang['registration.subject-mail'], array('site_name' => $site_name));
                     $content = StringVars::replace_vars($this->user_lang['registration.email.mail-administrator-validation'], array('pseudo' => $this->user->get_display_name(), 'site_name' => $site_name, 'signature' => MailServiceConfig::load()->get_mail_signature()));
                     AppContext::get_mail_service()->send_from_properties($this->user->get_email(), $subject, $content);
                 }
             }
             $user_warning = $this->form->get_value('user_warning')->get_raw_value();
             if (!empty($user_warning) && $user_warning != $this->user->get_warning_percentage()) {
                 MemberSanctionManager::caution($user_id, $user_warning, MemberSanctionManager::SEND_MP, str_replace('%level%', $user_warning, LangLoader::get_message('user_warning_level_changed', 'main')));
             } elseif (empty($user_warning)) {
                 MemberSanctionManager::cancel_caution($user_id);
             }
             $user_readonly = $this->form->get_value('user_readonly')->get_raw_value();
             if (!empty($user_readonly) && $user_readonly != $this->user->get_delay_readonly()) {
                 MemberSanctionManager::remove_write_permissions($user_id, time() + $user_readonly, MemberSanctionManager::SEND_MP, str_replace('%date%', $this->form->get_value('user_readonly')->get_label(), LangLoader::get_message('user_readonly_changed', 'main')));
             } elseif (empty($user_readonly)) {
                 MemberSanctionManager::restore_write_permissions($user_id);
             }
             $user_ban = $this->form->get_value('user_ban')->get_raw_value();
             if (!empty($user_ban) && $user_ban != $this->user->get_delay_banned()) {
                 MemberSanctionManager::banish($user_id, time() + $user_ban, MemberSanctionManager::SEND_MAIL);
             } elseif ($user_ban != $this->user->get_delay_banned()) {
                 MemberSanctionManager::cancel_banishment($user_id);
             }
         }
         SessionData::recheck_cached_data_from_user_id($user_id);
     }
     if (!$has_error) {
         AppContext::get_response()->redirect($request->get_url_referrer() ? $request->get_url_referrer() : UserUrlBuilder::edit_profile($user_id), $this->lang['user.message.success.edit']);
     }
 }