skala
Julio Montoya 13 years ago
commit 32d9f76f6a
  1. 54
      main/auth/inscription.php
  2. 16
      main/inc/lib/message.lib.php
  3. 38
      main/inc/lib/notification.lib.php
  4. 15
      main/inc/lib/usermanager.lib.php

@ -366,43 +366,29 @@ if ($form->validate()) {
$sql = "UPDATE ".$TABLE_USER." SET active='0' WHERE user_id='".$user_id."'";
Database::query($sql);
$table_main_admin = Database::get_main_table(TABLE_MAIN_ADMIN);
if ($_configuration['multiple_access_urls']) {
$access_url_id = api_get_current_access_url_id();
$tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$sql_get_id_admin = "SELECT admin.user_id FROM ".$tbl_url_rel_user." as url, ".$table_main_admin." as admin WHERE access_url_id='".$access_url_id."' AND admin.user_id=url.user_id";
// 2. Send mail to all platform admin
$emailsubject = get_lang('ApprovalForNewAccount',null,$values['language']).': '.$values['username'];
$emailbody = get_lang('ApprovalForNewAccount',null,$values['language'])."\n";
$emailbody .= get_lang('UserName',null,$values['language']).': '.$values['username']."\n";
if (api_is_western_name_order()) {
$emailbody .= get_lang('FirstName',null,$values['language']).': '.$values['firstname']."\n";
$emailbody .= get_lang('LastName',null,$values['language']).': '.$values['lastname']."\n";
} else {
$sql_get_id_admin = "SELECT * FROM ".$table_main_admin;
$emailbody .= get_lang('LastName',null,$values['language']).': '.$values['lastname']."\n";
$emailbody .= get_lang('FirstName',null,$values['language']).': '.$values['firstname']."\n";
}
$result = Database::query($sql_get_id_admin);
while ($row = Database::fetch_array($result)) {
$sql_admin_list = "SELECT * FROM ".$TABLE_USER." WHERE user_id='".$row['user_id']."'";
$result_list = Database::query($sql_admin_list);
$admin_list = Database::fetch_array($result_list);
$emailto = $admin_list['email'];
// 2. send mail to the platform admin
$emailsubject = get_lang('ApprovalForNewAccount',null,$values['language']).': '.$values['username'];
$emailbody = get_lang('ApprovalForNewAccount',null,$values['language'])."\n";
$emailbody .= get_lang('UserName',null,$values['language']).': '.$values['username']."\n";
if (api_is_western_name_order()) {
$emailbody .= get_lang('FirstName',null,$values['language']).': '.$values['firstname']."\n";
$emailbody .= get_lang('LastName',null,$values['language']).': '.$values['lastname']."\n";
} else {
$emailbody .= get_lang('LastName',null,$values['language']).': '.$values['lastname']."\n";
$emailbody .= get_lang('FirstName',null,$values['language']).': '.$values['firstname']."\n";
}
$emailbody .= get_lang('Email',null,$values['language']).': '.$values['email']."\n";
$emailbody .= get_lang('Status',null,$values['language']).': '.$values['status']."\n\n";
$emailbody .= get_lang('ManageUser',null,$values['language']).': '.api_get_path(WEB_CODE_PATH).'admin/user_edit.php?user_id='.$user_id;
$sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
$email_admin = api_get_setting('emailAdministrator');
@api_mail('', $emailto, $emailsubject, $emailbody, $sender_name, $email_admin);
$emailbody .= get_lang('Email',null,$values['language']).': '.$values['email']."\n";
$emailbody .= get_lang('Status',null,$values['language']).': '.$values['status']."\n\n";
$url_edit = Display::url(api_get_path(WEB_CODE_PATH).'admin/user_edit.php?user_id='.$user_id, api_get_path(WEB_CODE_PATH).'admin/user_edit.php?user_id='.$user_id);
$emailbody .= get_lang('ManageUser',null,$values['language']).": $url_edit";
$admins = UserManager::get_all_administrators();
foreach ($admins as $admin_info) {
MessageManager::send_message($admin_info['user_id'], $emailsubject, $emailbody, null, null, null, null, null, null, $user_id);
}
// 3. exit the page
unset($user_id);

@ -198,7 +198,8 @@ class MessageManager
}
return $message_list;
}
/**
* Sends a message to a user/group
*
@ -210,17 +211,21 @@ class MessageManager
* @param int group id (optional)
* @param int parent id (optional)
* @param int message id for updating the message (optional)
* @param bool sent an email or not (@todo)
* @param int sender id (optional) the default value is the current user_id
* @return bool
*/
public static function send_message($receiver_user_id, $subject, $content, $file_attachments = array(), $file_comments = array(), $group_id = 0, $parent_id = 0, $edit_message_id = 0, $topic_id = 0) {
public static function send_message($receiver_user_id, $subject, $content, $file_attachments = array(), $file_comments = array(), $group_id = 0, $parent_id = 0, $edit_message_id = 0, $topic_id = 0, $sender_id = null) {
$table_message = Database::get_main_table(TABLE_MESSAGE);
$group_id = intval($group_id);
$receiver_user_id = intval($receiver_user_id);
$parent_id = intval($parent_id);
$edit_message_id = intval($edit_message_id);
$topic_id = intval($topic_id);
$user_sender_id = api_get_user_id();
$topic_id = intval($topic_id);
if (empty($sender_id)) {
$user_sender_id = api_get_user_id();
} else {
$user_sender_id = intval($sender_id);
}
$total_filesize = 0;
if (is_array($file_attachments)) {
@ -245,7 +250,6 @@ class MessageManager
if (!empty($receiver_user_id) || !empty($group_id)) {
// message for user friend
$clean_subject = Database::escape_string($subject);
$clean_content = Database::escape_string($content);

@ -13,23 +13,23 @@
//default values
//mail_notify_message ("At once", "Daily", "No")
define('NOTIFY_MESSAGE_AT_ONCE', '1');
define('NOTIFY_MESSAGE_DAILY', '8');
define('NOTIFY_MESSAGE_WEEKLY', '12');
define('NOTIFY_MESSAGE_NO', '0');
define('NOTIFY_MESSAGE_AT_ONCE', '1');
define('NOTIFY_MESSAGE_DAILY', '8');
define('NOTIFY_MESSAGE_WEEKLY', '12');
define('NOTIFY_MESSAGE_NO', '0');
//mail_notify_invitation ("At once", "Daily", "No")
define('NOTIFY_INVITATION_AT_ONCE', '1');
define('NOTIFY_INVITATION_DAILY', '8');
define('NOTIFY_INVITATION_WEEKLY', '12');
define('NOTIFY_INVITATION_NO', '0');
define('NOTIFY_INVITATION_AT_ONCE', '1');
define('NOTIFY_INVITATION_DAILY', '8');
define('NOTIFY_INVITATION_WEEKLY', '12');
define('NOTIFY_INVITATION_NO', '0');
// mail_notify_group_message ("At once", "Daily", "No")
define('NOTIFY_GROUP_AT_ONCE', '1');
define('NOTIFY_GROUP_DAILY', '8');
define('NOTIFY_GROUP_WEEKLY', '12');
define('NOTIFY_GROUP_NO', '0');
define('NOTIFY_GROUP_AT_ONCE', '1');
define('NOTIFY_GROUP_DAILY', '8');
define('NOTIFY_GROUP_WEEKLY', '12');
define('NOTIFY_GROUP_NO', '0');
define('NOTIFICATION_TYPE_MESSAGE', 1);
define('NOTIFICATION_TYPE_INVITATION', 2);
@ -63,7 +63,7 @@ class Notification extends Model {
public function send($frec = NOTIFY_MESSAGE_DAILY) {
$notifications = $this->find('all',array('where'=>array('sent_at IS NULL AND send_freq = ?'=>$frec)));
if (!empty($notifications)) {
foreach($notifications as $item_to_send) {
foreach ($notifications as $item_to_send) {
//Sending email
api_mail_html($item_to_send['dest_mail'], $item_to_send['dest_mail'], Security::filter_terms($item_to_send['title']), Security::filter_terms($item_to_send['content']), $this->admin_name, $this->admin_email);
@ -80,7 +80,7 @@ class Notification extends Model {
/**
* Save message notification
* @param array message type NOTIFICATION_TYPE_MESSAGE, NOTIFICATION_TYPE_INVITATION, NOTIFICATION_TYPE_GROUP
* @param array user list of ids
* @param array recipients: user list of ids
* @param string title
* @param string content of the message
* @param array result of api_get_user_info() or GroupPortalManager:get_group_data()
@ -106,16 +106,18 @@ class Notification extends Model {
}
if (!empty($user_list)) {
foreach($user_list as $user_id) {
foreach ($user_list as $user_id) {
$extra_data = UserManager::get_extra_user_data($user_id);
$params = array();
$params = array();
if ($avoid_my_self) {
if ($user_id == api_get_user_id()) {
continue;
}
}
$user_setting = $extra_data[$setting_to_check];
$user_info = api_get_user_info($user_id);
$user_setting = $extra_data[$setting_to_check];
switch ($user_setting) {
//No notifications
case NOTIFY_MESSAGE_NO:
@ -140,7 +142,7 @@ class Notification extends Model {
$params['send_freq'] = $user_setting;
$this->save($params);
break;
}
}
}
}
}

@ -2870,9 +2870,18 @@ class UserManager {
*/
public function get_all_administrators() {
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$table_admin = Database::get_main_table(TABLE_MAIN_ADMIN);
$sql = "SELECT user_id, username, firstname, lastname, email from $table_user as u, $table_admin as a WHERE u.user_id=a.user_id";
$table_admin = Database::get_main_table(TABLE_MAIN_ADMIN);
$tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_id = api_get_current_access_url_id();
if (api_get_multiple_access_url()) {
$access_url_id = api_get_current_access_url_id();
$sql = "SELECT admin.user_id, username, firstname, lastname, email FROM $tbl_url_rel_user as url INNER JOIN $table_admin as admin
ON (admin.user_id=url.user_id) INNER JOIN $table_user u ON (u.user_id=admin.user_id)
WHERE access_url_id ='".$access_url_id."'";
} else {
$sql = "SELECT admin.user_id, username, firstname, lastname, email FROM $table_admin as admin
INNER JOIN $table_user u ON (u.user_id=admin.user_id)";
}
$result = Database::query($sql);
$return = array();
if (Database::num_rows($result)> 0) {

Loading…
Cancel
Save