Moving constants into class constants

skala
Julio Montoya 12 years ago
parent 7d85fdf268
commit df88d50a8f
  1. 4
      main/inc/lib/message.lib.php
  2. 186
      main/inc/lib/notification.lib.php
  3. 222
      main/inc/lib/social.lib.php
  4. 24
      main/survey/survey.lib.php

@ -285,7 +285,7 @@ class MessageManager
$sender_info = api_get_user_info($user_sender_id);
if (empty($group_id)) {
$notification->save_notification(NOTIFICATION_TYPE_MESSAGE, array($receiver_user_id), $subject, $content, $sender_info);
$notification->save_notification(Notification::NOTIFICATION_TYPE_MESSAGE, array($receiver_user_id), $subject, $content, $sender_info);
} else {
$group_info = GroupPortalManager::get_group_data($group_id);
$group_info['topic_id'] = $topic_id;
@ -301,7 +301,7 @@ class MessageManager
$new_user_list[] = $user_data['user_id'];
}
$group_info = array('group_info' => $group_info, 'user_info' => $sender_info);
$notification->save_notification(NOTIFICATION_TYPE_GROUP, $new_user_list, $subject, $content, $group_info);
$notification->save_notification(Notification::NOTIFICATION_TYPE_GROUP, $new_user_list, $subject, $content, $group_info);
}
return $inbox_last_id;
}

@ -1,93 +1,86 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This class provides methods for the Notification management.
* Include/require it in your code to use its features.
* @package chamilo.library
*/
* This class provides methods for the Notification management.
* Include/require it in your code to use its features.
* @package chamilo.library
*/
/**
* Code
*/
//@todo put constants in an array
//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');
//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');
// 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('NOTIFICATION_TYPE_MESSAGE', 1);
define('NOTIFICATION_TYPE_INVITATION', 2);
define('NOTIFICATION_TYPE_GROUP', 3);
/**
* Notification class
* @package chamilo.library
*/
class Notification extends Model {
var $table;
var $columns = array('id','dest_user_id','dest_mail','title','content','send_freq','created_at','sent_at');
var $max_content_length = 254; //Max lenght of the notification.content field
var $debug = false;
class Notification extends Model
{
public $table;
public $columns = array('id', 'dest_user_id', 'dest_mail', 'title', 'content', 'send_freq', 'created_at', 'sent_at');
public $max_content_length = 254; //Max lenght of the notification.content field
public $debug = false;
/* message, invitation, group messages */
var $type;
var $admin_name;
var $admin_email;
public function __construct() {
$this->table = Database::get_main_table(TABLE_NOTIFICATION);
$this->admin_email = api_get_setting('noreply_email_address');
$this->admin_name = api_get_setting('siteName');
public $type;
public $admin_name;
public $admin_email;
//mail_notify_message ("At once", "Daily", "No")
const NOTIFY_MESSAGE_AT_ONCE = 1;
const NOTIFY_MESSAGE_DAILY = 8;
const NOTIFY_MESSAGE_WEEKLY = 12;
const NOTIFY_MESSAGE_NO = 0;
//mail_notify_invitation ("At once", "Daily", "No")
const NOTIFY_INVITATION_AT_ONCE = 1;
const NOTIFY_INVITATION_DAILY = 8;
const NOTIFY_INVITATION_WEEKLY = 12;
const NOTIFY_INVITATION_NO = 0;
// mail_notify_group_message ("At once", "Daily", "No")
const NOTIFY_GROUP_AT_ONCE = 1;
const NOTIFY_GROUP_DAILY = 8;
const NOTIFY_GROUP_WEEKLY = 12;
const NOTIFY_GROUP_NO = 0;
const NOTIFICATION_TYPE_MESSAGE = 1;
const NOTIFICATION_TYPE_INVITATION = 2;
const NOTIFICATION_TYPE_GROUP = 3;
public function __construct()
{
$this->table = Database::get_main_table(TABLE_NOTIFICATION);
$this->admin_email = api_get_setting('noreply_email_address');
$this->admin_name = api_get_setting('siteName');
// If no-reply email doesn't exist use the admin email
if (empty($this->admin_email)) {
$this->admin_email = api_get_setting('emailAdministrator');
$this->admin_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
$this->admin_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
}
}
}
/**
* Send the notifications
* @param int notification frecuency
*/
public function send($frec = NOTIFY_MESSAGE_DAILY) {
$notifications = $this->find('all',array('where'=>array('sent_at IS NULL AND send_freq = ?'=>$frec)));
public function send($frec = 8)
{
$notifications = $this->find('all', array('where' => array('sent_at IS NULL AND send_freq = ?' => $frec)));
if (!empty($notifications)) {
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
);
if ($this->debug) { error_log('Sending message to: '.$item_to_send['dest_mail']); }
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);
if ($this->debug) {
error_log('Sending message to: '.$item_to_send['dest_mail']);
}
//Updating
$item_to_send['sent_at'] = api_get_utc_datetime();
$this->update($item_to_send);
if ($this->debug) { error_log('Updating record : '.print_r($item_to_send,1)); }
if ($this->debug) {
error_log('Updating record : '.print_r($item_to_send, 1));
}
}
}
}
@ -100,26 +93,27 @@ class Notification extends Model {
* @param string content of the message
* @param array result of api_get_user_info() or GroupPortalManager:get_group_data()
*/
public function save_notification($type, $user_list, $title, $content, $sender_info = array()) {
public function save_notification($type, $user_list, $title, $content, $sender_info = array())
{
$this->type = intval($type);
$content = $this->format_content($content, $sender_info);
$content = $this->format_content($content, $sender_info);
$setting_to_check = '';
$avoid_my_self = false;
$avoid_my_self = false;
switch ($this->type) {
case NOTIFICATION_TYPE_MESSAGE;
case self::NOTIFICATION_TYPE_MESSAGE;
$setting_to_check = 'mail_notify_message';
$default_status = NOTIFY_MESSAGE_AT_ONCE;
$default_status = self::NOTIFY_MESSAGE_AT_ONCE;
break;
case NOTIFICATION_TYPE_INVITATION;
case self::NOTIFICATION_TYPE_INVITATION;
$setting_to_check = 'mail_notify_invitation';
$default_status = NOTIFY_INVITATION_AT_ONCE;
$default_status = self::NOTIFY_INVITATION_AT_ONCE;
break;
case NOTIFICATION_TYPE_GROUP;
case self::NOTIFICATION_TYPE_GROUP;
$setting_to_check = 'mail_notify_group_message';
$default_status = NOTIFY_GROUP_AT_ONCE;
$avoid_my_self = true;
$default_status = self::NOTIFY_GROUP_AT_ONCE;
$avoid_my_self = true;
break;
}
@ -146,14 +140,14 @@ class Notification extends Model {
switch ($user_setting) {
//No notifications
case NOTIFY_MESSAGE_NO:
case NOTIFY_INVITATION_NO:
case NOTIFY_GROUP_NO:
case self::NOTIFY_MESSAGE_NO:
case self::NOTIFY_INVITATION_NO:
case self::NOTIFY_GROUP_NO:
break;
//Send notification right now!
case NOTIFY_MESSAGE_AT_ONCE:
case NOTIFY_INVITATION_AT_ONCE:
case NOTIFY_GROUP_AT_ONCE:
case self::NOTIFY_MESSAGE_AT_ONCE:
case self::NOTIFY_INVITATION_AT_ONCE:
case self::NOTIFY_GROUP_AT_ONCE:
if (!empty($user_info['mail'])) {
$name = api_get_person_name($user_info['firstname'], $user_info['lastname']);
if (!empty($sender_info['complete_name']) && !empty($sender_info['email'])) {
@ -165,16 +159,16 @@ class Notification extends Model {
api_mail_html($name, $user_info['mail'], Security::filter_terms($title), Security::filter_terms($content), $this->admin_name, $this->admin_email);
}
}
$params['sent_at'] = api_get_utc_datetime();
//Saving the notification to be sent some day
$params['sent_at'] = api_get_utc_datetime();
//Saving the notification to be sent some day
default:
$params['dest_user_id'] = $user_id;
$params['dest_mail'] = $user_info['mail'];
$params['title'] = $title;
$params['content'] = cut($content, $this->max_content_length);
$params['send_freq'] = $user_setting;
$this->save($params);
break;
$params['dest_user_id'] = $user_id;
$params['dest_mail'] = $user_info['mail'];
$params['title'] = $title;
$params['content'] = cut($content, $this->max_content_length);
$params['send_freq'] = $user_setting;
$this->save($params);
break;
}
}
}
@ -185,11 +179,12 @@ class Notification extends Model {
* @param string the content
* @param array result of api_get_user_info() or GroupPortalManager:get_group_data()
* */
public function format_content($content, $sender_info) {
public function format_content($content, $sender_info)
{
$new_message_text = $link_to_new_message = '';
switch($this->type) {
case NOTIFICATION_TYPE_MESSAGE:
switch ($this->type) {
case self::NOTIFICATION_TYPE_MESSAGE:
if (!empty($sender_info)) {
$sender_name = api_get_person_name($sender_info['firstname'], $sender_info['lastname'], null, PERSON_NAME_EMAIL_ADDRESS);
//$sender_mail = $sender_info['email'] ;
@ -197,7 +192,7 @@ class Notification extends Model {
}
$link_to_new_message = Display::url(get_lang('SeeMessage'), api_get_path(WEB_CODE_PATH).'messages/inbox.php');
break;
case NOTIFICATION_TYPE_INVITATION:
case self::NOTIFICATION_TYPE_INVITATION:
if (!empty($sender_info)) {
$sender_name = api_get_person_name($sender_info['firstname'], $sender_info['lastname'], null, PERSON_NAME_EMAIL_ADDRESS);
//$sender_mail = $sender_info['email'] ;
@ -205,15 +200,14 @@ class Notification extends Model {
}
$link_to_new_message = Display::url(get_lang('SeeInvitation'), api_get_path(WEB_CODE_PATH).'social/invitations.php');
break;
case NOTIFICATION_TYPE_GROUP:
$topic_page = intval($_REQUEST['topics_page_nr']);
case self::NOTIFICATION_TYPE_GROUP:
$topic_page = intval($_REQUEST['topics_page_nr']);
if (!empty($sender_info)) {
$sender_name = $sender_info['group_info']['name'];
$new_message_text = sprintf(get_lang('YouHaveReceivedANewMessageInTheGroupX'), $sender_name);
$new_message_text = sprintf(get_lang('YouHaveReceivedANewMessageInTheGroupX'), $sender_name);
$sender_name = api_get_person_name($sender_info['user_info']['firstname'], $sender_info['user_info']['lastname'], null, PERSON_NAME_EMAIL_ADDRESS);
$sender_name = Display::url($sender_name , api_get_path(WEB_CODE_PATH).'social/profile.php?'.$sender_info['user_info']['user_id']);
$new_message_text .= '<br />'.get_lang('User').': '.$sender_name;
$sender_name = Display::url($sender_name, api_get_path(WEB_CODE_PATH).'social/profile.php?'.$sender_info['user_info']['user_id']);
$new_message_text .= '<br />'.get_lang('User').': '.$sender_name;
}
$group_url = api_get_path(WEB_CODE_PATH).'social/group_topics.php?id='.$sender_info['group_info']['id'].'&topic_id='.$sender_info['group_info']['topic_id'].'&msg_id='.$sender_info['group_info']['msg_id'].'&topics_page_nr='.$topic_page;
$link_to_new_message = Display::url(get_lang('SeeMessage'), $group_url);
@ -232,8 +226,8 @@ class Notification extends Model {
}
// You have received this message because you are subscribed text
$content = $content.'<br /><hr><i>'.
sprintf(get_lang('YouHaveReceivedThisNotificationBecauseYouAreSubscribedOrInvolvedInItToChangeYourNotificationPreferencesPleaseClickHereX'), Display::url($preference_url, $preference_url)).'</i>';
$content = $content.'<br /><hr><i>'.
sprintf(get_lang('YouHaveReceivedThisNotificationBecauseYouAreSubscribedOrInvolvedInItToChangeYourNotificationPreferencesPleaseClickHereX'), Display::url($preference_url, $preference_url)).'</i>';
return $content;
}
}

@ -31,7 +31,7 @@ class SocialManager extends UserManager {
/**
* Allow to see contacts list
* @author isaac flores paz
* @author isaac flores paz
* @return array
*/
public static function show_list_type_friends () {
@ -50,14 +50,14 @@ class SocialManager extends UserManager {
return $friend_relation_list;
}
}
/**
* Get relation type contact by name
* @param string names of the kind of relation
* @return int
* @author isaac flores paz
* @author isaac flores paz
*/
public static function get_relation_type_by_name ($relation_type_name) {
public static function get_relation_type_by_name ($relation_type_name) {
$list_type_friend = self::show_list_type_friends();
foreach ($list_type_friend as $value_type_friend) {
if (strtolower($value_type_friend['title'])==$relation_type_name) {
@ -65,13 +65,13 @@ class SocialManager extends UserManager {
}
}
}
/**
* Get the kind of relation between contacts
* @param int user id
* @param int user friend id
* @param string
* @author isaac flores paz
* @author isaac flores paz
*/
public static function get_relation_between_contacts ($user_id,$user_friend) {
$tbl_my_friend_relation_type = Database :: get_main_table(TABLE_MAIN_USER_FRIEND_RELATION_TYPE);
@ -95,7 +95,7 @@ class SocialManager extends UserManager {
* @param bool true will load firstname, lastname, and image name
* @return array
* @author Julio Montoya <gugli100@gmail.com> Cleaning code, function renamed, $load_extra_info option added
* @author isaac flores paz
* @author isaac flores paz
*/
public static function get_friends($user_id, $id_group = null, $search_name = null, $load_extra_info = true) {
$list_ids_friends=array();
@ -131,9 +131,9 @@ class SocialManager extends UserManager {
* @param int group id
* @param string name to search
* @param array
* @author isaac flores paz
* @author isaac flores paz
*/
public static function get_list_path_web_by_user_id ($user_id,$id_group=null,$search_name=null) {
public static function get_list_path_web_by_user_id ($user_id,$id_group=null,$search_name=null) {
$combine_friend = array();
$list_ids = self::get_friends($user_id,$id_group,$search_name);
if (is_array($list_ids)) {
@ -152,7 +152,7 @@ class SocialManager extends UserManager {
* @param int user id
* @return array
*/
public static function get_list_web_path_user_invitation_by_user_id ($user_id) {
public static function get_list_web_path_user_invitation_by_user_id ($user_id) {
$list_ids = self::get_list_invitation_of_friends_by_user_id((int)$user_id);
$list_path_image_friend = array();
foreach ($list_ids as $values_ids) {
@ -175,30 +175,30 @@ class SocialManager extends UserManager {
$tbl_message = Database::get_main_table(TABLE_MAIN_MESSAGE);
$user_id = intval($user_id);
$friend_id = intval($friend_id);
//Just in case we replace the and \n and \n\r while saving in the DB
$message_content = str_replace(array("\n", "\n\r"), '<br />', $message_content);
$message_content = str_replace(array("\n", "\n\r"), '<br />', $message_content);
$clean_message_title = Database::escape_string($message_title);
$clean_message_content = Database::escape_string($message_content);
$now = api_get_utc_datetime();
$sql_exist='SELECT COUNT(*) AS count FROM '.$tbl_message.' WHERE user_sender_id='.$user_id.' AND user_receiver_id='.$friend_id.' AND msg_status IN(5,6,7);';
$res_exist = Database::query($sql_exist);
$row_exist = Database::fetch_array($res_exist,'ASSOC');
if ($row_exist['count']==0) {
$sql=' INSERT INTO '.$tbl_message.'(user_sender_id,user_receiver_id,msg_status,send_date,title,content)
$sql=' INSERT INTO '.$tbl_message.'(user_sender_id,user_receiver_id,msg_status,send_date,title,content)
VALUES('.$user_id.','.$friend_id.','.MESSAGE_STATUS_INVITATION_PENDING.',"'.$now.'","'.$clean_message_title.'","'.$clean_message_content.'") ';
Database::query($sql);
Database::query($sql);
$sender_info = api_get_user_info($user_id);
$notification = new Notification();
$notification->save_notification(NOTIFICATION_TYPE_INVITATION, array($friend_id), $message_title, $message_content, $sender_info);
$notification = new Notification();
$notification->save_notification(Notification::NOTIFICATION_TYPE_INVITATION, array($friend_id), $message_title, $message_content, $sender_info);
return true;
} else {
//invitation already exist
@ -216,7 +216,7 @@ class SocialManager extends UserManager {
}
/**
* Get number messages of the inbox
* @author isaac flores paz
* @author isaac flores paz
* @param int user receiver id
* @return int
*/
@ -230,7 +230,7 @@ class SocialManager extends UserManager {
/**
* Get invitation list received by user
* @author isaac flores paz
* @author isaac flores paz
* @param int user id
* @return array()
*/
@ -267,7 +267,7 @@ class SocialManager extends UserManager {
* Accepts invitation
* @param int user sender id
* @param int user receiver id
* @author isaac flores paz
* @author isaac flores paz
* @author Julio Montoya <gugli100@gmail.com> Cleaning code
*/
public static function invitation_accepted ($user_send_id,$user_receiver_id) {
@ -279,7 +279,7 @@ class SocialManager extends UserManager {
* Denies invitation
* @param int user sender id
* @param int user receiver id
* @author isaac flores paz
* @author isaac flores paz
* @author Julio Montoya <gugli100@gmail.com> Cleaning code
*/
public static function invitation_denied ($user_send_id,$user_receiver_id) {
@ -291,7 +291,7 @@ class SocialManager extends UserManager {
}
/**
* allow attach to group
* @author isaac flores paz
* @author isaac flores paz
* @param int user to qualify
* @param int kind of rating
* @return void()
@ -311,15 +311,15 @@ class SocialManager extends UserManager {
*/
public static function send_invitation_friend_user($userfriend_id, $subject_message = '', $content_message = '') {
global $charset;
$user_info = array();
$user_info = api_get_user_info($userfriend_id);
$succes = get_lang('MessageSentTo');
$succes.= ' : '.api_get_person_name($user_info['firstName'], $user_info['lastName']);
if (isset($subject_message) && isset($content_message) && isset($userfriend_id)) {
$send_message = MessageManager::send_message($userfriend_id, $subject_message, $content_message);
$send_message = MessageManager::send_message($userfriend_id, $subject_message, $content_message);
if ($send_message) {
echo Display::display_confirmation_message($succes,true);
} else {
@ -327,7 +327,7 @@ class SocialManager extends UserManager {
}
return false;
} elseif (isset($userfriend_id) && !isset($subject_message)) {
$count_is_true = false;
$count_is_true = false;
if (isset($userfriend_id) && $userfriend_id>0) {
$message_title = get_lang('Invitation');
$count_is_true = self::send_invitation_friend(api_get_user_id(), $userfriend_id, $message_title, $content_message);
@ -394,13 +394,13 @@ class SocialManager extends UserManager {
// Table definitions
$main_user_table = Database :: get_main_table(TABLE_MAIN_USER);
$tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
$course_code = $my_course['code'];
$course_visual_code = $my_course['course_info']['official_code'];
$course_title = $my_course['course_info']['title'];
$course_info = Database :: get_course_info($course_code);
$course_id = $course_info['real_id'];
$course_access_settings = CourseManager :: get_access_settings($course_code);
@ -420,7 +420,7 @@ class SocialManager extends UserManager {
return; //do not display this course entry
}
}
$s_htlm_status_icon = Display::return_icon('course.gif', get_lang('Course'));
//display course entry
@ -506,7 +506,7 @@ class SocialManager extends UserManager {
}
$active = ($date_start <= $now && $date_end >= $now)?true:false;
}
}
}
$my_course['id_session'] = isset($my_course['id_session']) ? $my_course['id_session'] : 0;
$output = array ($my_course['user_course_cat'], $result, $my_course['id_session'], $session, 'active'=>$active);
} else {
@ -528,18 +528,18 @@ class SocialManager extends UserManager {
public static function show_social_menu($show = '', $group_id = 0, $user_id = 0, $show_full_profile = false, $show_delete_account_button = false) {
if (empty($user_id)) {
$user_id = api_get_user_id();
}
}
$user_info = api_get_user_info($user_id, true);
$current_user_id = api_get_user_id();
$current_user_info = api_get_user_info($current_user_id, true);
if ($current_user_id == $user_id) {
$user_friend_relation = null;
} else {
$user_friend_relation = SocialManager::get_relation_between_contacts($current_user_id, $user_id);
}
$show_groups = array('groups', 'group_messages', 'messages_list', 'group_add', 'mygroups', 'group_edit', 'member_list', 'invite_friends', 'waiting_list', 'browse_groups');
//$show_messages = array('messages', 'messages_inbox', 'messages_outbox', 'messages_compose');
@ -552,30 +552,30 @@ class SocialManager extends UserManager {
$group_pending_invitations = count($group_pending_invitations);
$total_invitations = $number_of_new_messages_of_friend + $group_pending_invitations;
$total_invitations = (!empty($total_invitations) ? Display::badge($total_invitations) :'');
$html = '<div class="social-menu">';
if (in_array($show, $show_groups) && !empty($group_id)) {
//--- Group image
$group_info = GroupPortalManager::get_group_data($group_id);
$big = GroupPortalManager::get_picture_group($group_id, $group_info['picture_uri'],160,GROUP_IMAGE_SIZE_BIG);
$html .= '<div class="social-content-image">';
$html .= '<div class="well social-background-content">';
$html .= '<div class="social-content-image">';
$html .= '<div class="well social-background-content">';
$html .= Display::url('<img src='.$big['file'].' class="social-groups-image" /> </a><br /><br />', api_get_path(WEB_PATH).'main/social/groups.php?id='.$group_id);
if (GroupPortalManager::is_group_admin($group_id, api_get_user_id())) {
$html .= '<div id="edit_image" class="hidden_message" style="display:none"><a href="'.api_get_path(WEB_PATH).'main/social/group_edit.php?id='.$group_id.'">'.get_lang('EditGroup').'</a></div>';
}
$html .= '</div>';
$html .= '</div>';
} else {
$img_array = UserManager::get_user_picture_path_by_id($user_id,'web',true,true);
$img_array = UserManager::get_user_picture_path_by_id($user_id,'web',true,true);
$big_image = UserManager::get_picture_user($user_id, $img_array['file'],'', USER_IMAGE_SIZE_BIG);
$big_image = $big_image['file'].'?'.uniqid();
$normal_image = $img_array['dir'].$img_array['file'].'?'.uniqid();
//--- User image
$html .= '<div class="well social-background-content">';
if ($img_array['file'] != 'unknown.jpg') {
$html .= '<a class="thumbnail thickbox" href="'.$big_image.'"><img src='.$normal_image.' /> </a>';
@ -586,12 +586,12 @@ class SocialManager extends UserManager {
$html .= '<div id="edit_image" class="hidden_message" style="display:none">';
$html .= '<a href="'.api_get_path(WEB_PATH).'main/auth/profile.php">'.get_lang('EditProfile').'</a></div>';
}
$html .= '</div>';
$html .= '</div>';
}
if (!in_array($show, array('shared_profile', 'groups', 'group_edit', 'member_list','waiting_list','invite_friends'))) {
if (!in_array($show, array('shared_profile', 'groups', 'group_edit', 'member_list','waiting_list','invite_friends'))) {
$html .= '<div class="well sidebar-nav"><ul class="nav nav-list">';
$html .= '<div class="well sidebar-nav"><ul class="nav nav-list">';
$active = $show=='home' ? 'active' : null;
$html .= '<li class="'.$active.'"><a href="'.api_get_path(WEB_PATH).'main/social/home.php">'.Display::return_icon('home.png',get_lang('Home'),array()).get_lang('Home').'</a></li>';
$active = $show=='messages' ? 'active' : null;
@ -600,7 +600,7 @@ class SocialManager extends UserManager {
//Invitations
$active = $show=='invitations' ? 'active' : null;
$html .= '<li class="'.$active.'"><a href="'.api_get_path(WEB_PATH).'main/social/invitations.php">'.Display::return_icon('invitation.png',get_lang('Invitations'),array()).get_lang('Invitations').$total_invitations.'</a></li>';
//Shared profile and groups
$active = $show=='shared_profile' ? 'active' : null;
$html .= '<li class="'.$active.'"><a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.Display::return_icon('my_shared_profile.png',get_lang('ViewMySharedProfile'),array()).get_lang('ViewMySharedProfile').'</a></li>';
@ -612,14 +612,14 @@ class SocialManager extends UserManager {
//Search users
$active = $show=='search' ? 'active' : null;
$html .= '<li class="'.$active.'"><a href="'.api_get_path(WEB_PATH).'main/social/search.php">'.Display::return_icon('zoom.png',get_lang('Search'), array()).get_lang('Search').'</a></li>';
//My files
$active = $show=='myfiles' ? 'active' : null;
$html .= '<li class="'.$active.'"><a href="'.api_get_path(WEB_PATH).'main/social/myfiles.php">'.Display::return_icon('briefcase.png',get_lang('MyFiles'),array(), 16).get_lang('MyFiles').'</span></a></li>';
$html .= '<li class="'.$active.'"><a href="'.api_get_path(WEB_PATH).'main/social/myfiles.php">'.Display::return_icon('briefcase.png',get_lang('MyFiles'),array(), 16).get_lang('MyFiles').'</span></a></li>';
$html .='</ul>
</div>';
</div>';
}
if (in_array($show, $show_groups) && !empty($group_id)) {
$html .= GroupPortalManager::show_group_column_information($group_id, api_get_user_id(), $show);
}
@ -644,12 +644,12 @@ class SocialManager extends UserManager {
$active = $show=='myfiles' ? 'active' : null;
$html .= '<li class="'.$active.'"><a href="'.api_get_path(WEB_PATH).'main/social/myfiles.php">'.Display::return_icon('briefcase.png',get_lang('MyFiles'),array(),16).get_lang('MyFiles').'</a></li>';
}
// My friend profile
if ($user_id != api_get_user_id()) {
$html .= '<li><a href="javascript:void(0);" onclick="javascript:send_message_to_user(\''.$user_id.'\');" title="'.get_lang('SendMessage').'">';
$html .= Display::return_icon('compose_message.png',get_lang('SendMessage')).'&nbsp;&nbsp;'.get_lang('SendMessage').'</a></li>';
$html .= Display::return_icon('compose_message.png',get_lang('SendMessage')).'&nbsp;&nbsp;'.get_lang('SendMessage').'</a></li>';
}
//check if I already sent an invitation message
@ -674,7 +674,7 @@ class SocialManager extends UserManager {
$chat_icon = $user_info['user_is_online_in_chat'] ? Display::return_icon('online.png', get_lang('Online')) : Display::return_icon('offline.png', get_lang('Offline'));
$html .= Display::tag('li', Display::url($chat_icon.'&nbsp;&nbsp;'.get_lang('Chat'), 'javascript:void(0);', $options));
} else {
// Do something?
// Do something?
}
}
}
@ -703,10 +703,10 @@ class SocialManager extends UserManager {
$announcements = array();
foreach ($course_list_code as $course) {
$course_info = api_get_course_info($course['code']);
if (!empty($course_info)) {
$content = AnnouncementManager::get_all_annoucement_by_user_course($course_info['code'], $my_announcement_by_user_id);
if (!empty($content)) {
if (!empty($course_info)) {
$content = AnnouncementManager::get_all_annoucement_by_user_course($course_info['code'], $my_announcement_by_user_id);
if (!empty($content)) {
$url = Display::url(Display::return_icon('announcement.png',get_lang('Announcements')).$course_info['name'].' ('.$content['count'].')', api_get_path(WEB_CODE_PATH).'announcements/announcements.php?cidReq='.$course['code']);
$announcements[] = Display::tag('li', $url);
}
@ -724,16 +724,16 @@ class SocialManager extends UserManager {
}
}
}
if ($show_delete_account_button) {
$html .= '<div class="sidebar-nav"><ul><li>';
if ($show_delete_account_button) {
$html .= '<div class="sidebar-nav"><ul><li>';
$url = api_get_path(WEB_CODE_PATH).'auth/unsubscribe_account.php';
$html .= Display::url(Display::return_icon('delete.png',get_lang('Unsubscribe'), array(), ICON_SIZE_TINY).get_lang('Unsubscribe'), $url);
$html .= '</li></ul></div>';
}
$html .= '</li></ul></div>';
}
$html .= '</div>';
return $html;
}
@ -741,32 +741,32 @@ class SocialManager extends UserManager {
* Displays a sortable table with the list of online users.
* @param array $user_list
*/
public static function display_user_list($user_list) {
public static function display_user_list($user_list) {
if ($_GET['id'] == '') {
$column_size = '9';
$column_size = '9';
$add_row = false;
if (api_is_anonymous()) {
$column_size = '12';
$column_size = '12';
$add_row = true;
}
$extra_params = array();
$course_url = '';
if (strlen($_GET['cidReq']) > 0) {
$extra_params['cidReq'] = Security::remove_XSS($_GET['cidReq']);
$course_url = '&amp;cidReq='.Security::remove_XSS($_GET['cidReq']);
}
}
if ($add_row) {
$html .='<div class="row">';
}
$html .= '<div class="span'.$column_size.'">';
$html .= '<ul id="online_grid_container" class="thumbnails">';
$html .= '<div class="span'.$column_size.'">';
$html .= '<ul id="online_grid_container" class="thumbnails">';
foreach ($user_list as $uid) {
$user_info = api_get_user_info($uid);
$user_info = api_get_user_info($uid);
//Anonymous users can't have access to the profile
if (!api_is_anonymous()) {
if (api_get_setting('allow_social_tool')=='true') {
@ -778,35 +778,35 @@ class SocialManager extends UserManager {
$url = '#';
}
$image_array = UserManager::get_user_picture_path_by_id($uid, 'system', false, true);
// reduce image
$name = $user_info['complete_name'];
$status_icon = Display::span('', array('class' => 'online_user_in_text'));
$user_status = $user_info['status'] == 1 ? Display::span('', array('class' => 'teacher_online')) : Display::span('', array('class' => 'student_online'));
if ($image_array['file'] == 'unknown.jpg' || !file_exists($image_array['dir'].$image_array['file'])) {
$friends_profile['file'] = api_get_path(WEB_CODE_PATH).'img/unknown_180_100.jpg';
$friends_profile['file'] = api_get_path(WEB_CODE_PATH).'img/unknown_180_100.jpg';
$img = '<img title = "'.$name.'" alt="'.$name.'" src="'.$friends_profile['file'].'">';
} else {
$friends_profile = UserManager::get_picture_user($uid, $image_array['file'], 80, USER_IMAGE_SIZE_ORIGINAL);
$img = '<img title = "'.$name.'" alt="'.$name.'" src="'.$friends_profile['file'].'">';
}
$friends_profile = UserManager::get_picture_user($uid, $image_array['file'], 80, USER_IMAGE_SIZE_ORIGINAL);
$img = '<img title = "'.$name.'" alt="'.$name.'" src="'.$friends_profile['file'].'">';
}
$name = '<a href="'.$url.'">'.$status_icon.$user_status.$name.'</a><br>';
$html .= '<li class="span'.($column_size/3).'"><div class="thumbnail">'.$img.'<div class="caption">'.$name.'</div</div></li>';
}
$html .= '<li class="span'.($column_size/3).'"><div class="thumbnail">'.$img.'<div class="caption">'.$name.'</div</div></li>';
}
$counter = $_SESSION['who_is_online_counter'];
$html .= '</ul></div>';
$html .= '</ul></div>';
if (count($user_list) >= 9) {
$html .= '<div class="span'.$column_size.'"><a class="btn btn-large" id="link_load_more_items" data_link="'.$counter.'" >'.get_lang('More').'</a></div>';
}
if ($add_row) {
$html .= '</div>';
$html .= '</div>';
}
}
return $html;
}
}
/**
* Displays the information of an individual user
* @param int $user_id
@ -819,14 +819,14 @@ class SocialManager extends UserManager {
$sql = "SELECT * FROM $user_table WHERE user_id = ".$safe_user_id;
$result = Database::query($sql);
if (Database::num_rows($result) == 1) {
$user_object = Database::fetch_object($result);
$user_object = Database::fetch_object($result);
$alt = GetFullUserName($user_id).($_SESSION['_uid'] == $user_id ? '&nbsp;('.get_lang('Me').')' : '');
$status = get_status_from_code($user_object->status);
$interbreadcrumb[] = array('url' => 'whoisonline.php', 'name' => get_lang('UsersOnLineList'));
Display::display_header($alt, null, $alt);
Display::display_header($alt, null, $alt);
echo '<div class ="thumbnail">';
if (strlen(trim($user_object->picture_uri)) > 0) {
$sysdir_array = UserManager::get_user_picture_path_by_id($safe_user_id, 'system');
@ -835,9 +835,9 @@ class SocialManager extends UserManager {
$webdir = $webdir_array['dir'];
$fullurl = $webdir.$user_object->picture_uri;
$system_image_path = $sysdir.$user_object->picture_uri;
list($width, $height, $type, $attr) = @getimagesize($system_image_path);
list($width, $height, $type, $attr) = @getimagesize($system_image_path);
$height += 30;
$width += 30;
$width += 30;
// get the path,width and height from original picture
$big_image = $webdir.'big_'.$user_object->picture_uri;
$big_image_size = api_getimagesize($big_image);
@ -847,18 +847,18 @@ class SocialManager extends UserManager {
//echo '<a href="javascript:void()" onclick="javascript: return show_image(\''.$url_big_image.'\',\''.$big_image_width.'\',\''.$big_image_height.'\');" >';
echo '<img src="'.$fullurl.'" alt="'.$alt.'" />';
} else {
echo Display::return_icon('unknown.jpg', get_lang('Unknown'));
}
echo Display::return_icon('unknown.jpg', get_lang('Unknown'));
}
if (!empty($status)) {
echo '<div class="caption">'.$status.'</div>';
}
echo '</div>';
if (api_get_setting('show_email_addresses') == 'true') {
echo Display::encrypted_mailto_link($user_object->email,$user_object->email).'<br />';
}
if ($user_object->competences) {
echo Display::page_subheader(get_lang('MyCompetences'));
echo '<p>'.$user_object->competences.'</p>';
@ -876,7 +876,7 @@ class SocialManager extends UserManager {
echo Display::page_subheader(get_lang('MyPersonalOpenArea'));
echo '<p>'.$user_object->openarea.'</p>';
}
} else {
Display::display_header(get_lang('UsersOnLineList'));
echo '<div class="actions-title">';
@ -884,7 +884,7 @@ class SocialManager extends UserManager {
echo '</div>';
}
}
/**
* Display productions in whoisonline
* @param int $user_id User id
@ -934,7 +934,7 @@ class SocialManager extends UserManager {
echo '</ul></dd>';
}
}
public static function social_wrapper_div($content, $span_count) {
$span_count = intval($span_count);
$html = '<div class="span'.$span_count.'">';
@ -942,9 +942,9 @@ class SocialManager extends UserManager {
$html .= $content;
$html .= '</div></div>';
return $html;
}
/**
* Dummy function
*

@ -26,6 +26,12 @@ $htmlHeadXtra[] = '<script>
class survey_manager {
/**
* Deletes all survey invitations of a user
* @param int $user_id
* @return boolean
* @assert ('') === false
*/
public static function delete_all_survey_invitations_by_user($user_id) {
$user_id = intval($user_id);
@ -36,9 +42,18 @@ class survey_manager {
$sql = "DELETE FROM $table_survey_invitation WHERE user = '$user_id'";
Database::query($sql);
}
/**
*
* @param type $course_code
* @param type $session_id
* @return type
* @assert ('') === false
*/
public static function get_surveys($course_code, $session_id = 0) {
$table_survey = Database :: get_course_table(TABLE_SURVEY);
if (empty($course_code)) {
return false;
}
$course_info = api_get_course_info($course_code);
$session_condition = api_get_session_condition($session_id, true, true);
@ -48,12 +63,8 @@ class survey_manager {
return $result;
}
/***
* SYRVEY FUNCTIONS
*/
/**
* This function retrieves all the survey information
* Retrieves all the survey information
*
* @param integer $survey_id the id of the survey
* @param boolean $shared this parameter determines if we have to get the information of a survey from the central (shared) database or from the
@ -62,6 +73,7 @@ class survey_manager {
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version February 2007
* @assert ('') === false
*
* @todo this is the same function as in create_new_survey.php
*/

Loading…
Cancel
Save