Selaa lähdekoodia

Merge remote-tracking branch 'origin/1.11.x' into ofaj

jmontoyaa 8 vuotta sitten
vanhempi
commit
6728c77190

+ 7 - 2
main/auth/inscription.php

@@ -516,7 +516,8 @@ if ($user_already_registered_show_terms === false) {
     // EXTRA FIELDS
     if (array_key_exists('extra_fields', $allowedFields) || in_array('extra_fields', $allowedFields)) {
         $extraField = new ExtraField('user');
-        $extraFieldList = is_array($allowedFields['extra_fields']) ? $allowedFields['extra_fields'] : [];
+
+        $extraFieldList = isset($allowedFields['extra_fields']) && is_array($allowedFields['extra_fields']) ? $allowedFields['extra_fields'] : [];
         $returnParams = $extraField->addElements($form, 0, [], false, false, $extraFieldList);
     }
 }
@@ -748,6 +749,8 @@ if ($form->validate()) {
         $status = isset($values['status']) ? $values['status'] : STUDENT;
         $phone = isset($values['phone']) ? $values['phone'] : null;
         $values['language'] = isset($values['language']) ? $values['language'] : api_get_interface_language();
+        $values['address'] = isset($values['address']) ? $values['address'] : '';
+
         // Creates a new user
         $user_id = UserManager::create_user(
             $values['firstname'],
@@ -768,7 +771,9 @@ if ($form->validate()) {
             null,
             true,
             false,
-            $values['address']
+            $values['address'],
+            false,
+            $form
         );
 
         //update the extra fields

+ 1 - 1
main/auth/profile.php

@@ -423,7 +423,7 @@ if (is_profile_editable() && api_get_setting('user_selected_theme') == 'true') {
 }
 
 //    EXTENDED PROFILE  this make the page very slow!
-if (api_get_setting('extended_profile') == 'true') {
+if (api_get_setting('extended_profile') === 'true') {
     $width_extended_profile = 500;
     //    MY COMPETENCES
     $form->addHtmlEditor(

+ 0 - 8
main/inc/lib/message.lib.php

@@ -1025,14 +1025,6 @@ class MessageManager
         // get file attachments by message id
         $files_attachments = self::get_links_message_attachment_files($message_id, $source);
 
-        $user_con = self::users_connected_by_id();
-        $band = 0;
-        for ($i = 0; $i < count($user_con); $i++) {
-            if ($user_sender_id == $user_con[$i]) {
-                $band = 1;
-            }
-        }
-
         $title = Security::remove_XSS($row['title'], STUDENT, true);
         $content = Security::remove_XSS($row['content'], STUDENT, true);
 

+ 14 - 30
main/inc/lib/security.lib.php

@@ -396,24 +396,26 @@ class Security
     /**
      *
      * Filter content
-     * @param	string content to be filter
+     * @param	string $text to be filter
      * @return 	string
      */
-    static function filter_terms($text)
+    public static function filter_terms($text)
     {
     	static $bad_terms = array();
 
         if (empty($bad_terms)) {
             $list = api_get_setting('filter_terms');
-            $list = explode("\n", $list);
-            $list = array_filter($list);
             if (!empty($list)) {
-                foreach ($list as $term) {
-                    $term = str_replace(array("\r\n", "\r", "\n", "\t"), '', $term);
-                    $html_entities_value = api_htmlentities($term, ENT_QUOTES, api_get_system_encoding());
-                    $bad_terms[] = $term;
-                    if ($term != $html_entities_value) {
-                        $bad_terms[] = $html_entities_value;
+                $list = explode("\n", $list);
+                $list = array_filter($list);
+                if (!empty($list)) {
+                    foreach ($list as $term) {
+                        $term = str_replace(array("\r\n", "\r", "\n", "\t"), '', $term);
+                        $html_entities_value = api_htmlentities($term, ENT_QUOTES, api_get_system_encoding());
+                        $bad_terms[] = $term;
+                        if ($term != $html_entities_value) {
+                            $bad_terms[] = $html_entities_value;
+                        }
                     }
                 }
                 $bad_terms = array_filter($bad_terms);
@@ -421,30 +423,12 @@ class Security
         }
 
     	$replace = '***';
-
     	if (!empty($bad_terms)) {
-    		//Fast way
+    		// Fast way
     		$new_text = str_ireplace($bad_terms, $replace, $text, $count);
-
-    		//We need statistics
-    		/*
-    		if (strlen($new_text) != strlen($text)) {
-    			$table = Database::get_main_table(TABLE_STATISTIC_TRACK_FILTERED_TERMS);
-    			$attributes = array();
-
-
-    			$attributes['user_id'] 		=
-    			$attributes['course_id'] 	=
-    			$attributes['session_id'] 	=
-    			$attributes['tool_id'] 		=
-    			$attributes['term'] 		=
-    			$attributes['created_at'] 	= api_get_utc_datetime();
-    			$sql = Database::insert($table, $attributes);
-    		}
-    		*/
     		$text = $new_text;
-
     	}
+        
 		return $text;
     }
 

+ 1 - 1
main/inc/lib/sessionmanager.lib.php

@@ -4087,7 +4087,7 @@ class SessionManager
      * @param array $groupBackup
      * @return array
      */
-    static function importCSV(
+    public static function importCSV(
         $file,
         $updateSession,
         $defaultUserId = null,

+ 30 - 1
main/inc/lib/usermanager.lib.php

@@ -212,6 +212,8 @@ class UserManager
      * @param  bool $send_mail
      * @param  bool $isAdmin
      * @param  string $address
+     * @param  bool $sendEmailToAllAdmins
+     * @param FormValidator $form
      *
      * @return mixed   new user id - if the new user creation succeeds, false otherwise
      * @desc The function tries to retrieve user id from the session.
@@ -239,7 +241,9 @@ class UserManager
         $encrypt_method = '',
         $send_mail = false,
         $isAdmin = false,
-        $address = ''
+        $address = '',
+        $sendEmailToAllAdmins = false,
+        $form = null
     ) {
         $currentUserId = api_get_user_id();
         $hook = HookCreateUser::create();
@@ -449,6 +453,31 @@ class UserManager
                         $additionalParameters
                     );
                 }
+
+                if ($sendEmailToAllAdmins) {
+                    $adminList = UserManager::get_all_administrators();
+
+                    $tplContent = new Template(null, false, false, false, false, false);
+                    // variables for the default template
+                    $tplContent->assign('complete_name', stripslashes(api_get_person_name($firstName, $lastName)));
+                    $tplContent->assign('user_added', $user);
+                    /** @var FormValidator $form */
+                    $form->freeze();
+                    $form->removeElement('submit');
+                    $formData = $form->returnForm();
+                    $url = api_get_path(WEB_CODE_PATH).'admin/user_information.php?user_id='.$user->getId();
+                    $tplContent->assign('link', Display::url($url, $url));
+                    $tplContent->assign('form', $formData);
+
+                    $layoutContent = $tplContent->get_template('mail/content_registration_platform_to_admin.tpl');
+                    $emailBody = $tplContent->fetch($layoutContent);
+                    $subject = get_lang('UserAdded');
+
+                    foreach ($adminList as $adminId => $data) {
+                        MessageManager::send_message_simple($adminId, $subject, $emailBody);
+                    }
+
+                }
                 /* ENDS MANAGE EVENT WITH MAIL */
             }
             Event::addEvent(LOG_USER_CREATE, LOG_USER_ID, $return);

+ 19 - 0
main/template/default/mail/content_registration_platform_to_admin.tpl

@@ -0,0 +1,19 @@
+<p>{{ 'UserXWithLangXRegisteredTheSite'| get_lang | format(user_added.completeName, user_added.language) }} </p>
+
+<p>{{ 'HisProfileIs'| get_lang }} </p>
+
+<div class="row">
+    <div class="col-xs-12 col-md-12">
+        <div class="form-horizontal">
+            {{ form }}
+        </div>
+    </div>
+</div>
+
+<p>{{ 'YouCanAssignATutorInThisLinkX'|get_lang | format(link)}} </p>
+
+<p>{{ 'SignatureFormula'|get_lang }}</p>
+<p>{{ _admin.name }}, {{ _admin.surname }}<br>
+    {{ 'Manager'|get_lang }} {{ _s.site_name }}<br>
+    {{ _admin.telephone ? 'T. ' ~ _admin.telephone }}<br>
+    {{ _admin.email ? 'Email'|get_lang ~ ': ' ~ _admin.email }}</p>