Merge branch '1.10.x' into 1.10.x.doctrine

1.10.x
Julio Montoya 10 years ago
commit 29d6d73c9a
  1. 23
      main/inc/lib/agenda.lib.php
  2. 2
      main/inc/lib/attendance.lib.php
  3. 3
      main/inc/lib/database.constants.inc.php
  4. 1
      main/inc/lib/display.lib.php
  5. 11
      main/inc/lib/formvalidator/Element/DateRangePicker.php
  6. 2
      main/inc/lib/formvalidator/Element/SelectAjax.php
  7. 2
      main/inc/lib/formvalidator/Element/SelectLanguage.php
  8. 10
      main/inc/lib/formvalidator/Element/SelectTheme.php
  9. 2
      main/inc/lib/formvalidator/FormValidator.class.php
  10. 10
      main/inc/lib/message.lib.php
  11. 58
      main/inc/lib/pear/HTML/QuickForm.php
  12. 2
      main/inc/lib/pear/HTML/QuickForm/advmultiselect.php
  13. 2
      main/inc/lib/pear/HTML/QuickForm/select.php
  14. 18
      main/inc/lib/pear/HTML/QuickForm/textarea.php
  15. 189
      main/inc/lib/social.lib.php
  16. 2
      main/inc/lib/statistics.lib.php
  17. 2
      main/inc/lib/usermanager.lib.php
  18. 41
      main/messages/new_message.php
  19. 1
      main/messages/view_message.php
  20. 102
      main/social/profile.php

@ -1597,6 +1597,7 @@ class Agenda
* @param array $sendTo array('users' => [1, 2], 'groups' => [3, 4])
* @param array $attributes
* @param bool $addOnlyItemsInSendTo
* @param bool $required
*/
public function setSendToSelect(
$form,
@ -1604,7 +1605,8 @@ class Agenda
$userList = null,
$sendTo = array(),
$attributes = array(),
$addOnlyItemsInSendTo = false
$addOnlyItemsInSendTo = false,
$required = false
) {
$params = array(
'id' => 'users_to_send_id',
@ -1625,7 +1627,11 @@ class Agenda
$sendToUsers = isset($sendTo['users']) ? $sendTo['users'] : array();
/** @var HTML_QuickForm_select $select */
$select = $form->addElement('select', 'users_to_send', get_lang('To'), null, $params);
$select = $form->addSelect('users_to_send', get_lang('To'), null, $params);
if ($required) {
$form->setRequired($select);
}
$selectedEveryoneOptions = array();
if (isset($sendTo['everyone']) && $sendTo['everyone']) {
@ -1799,7 +1805,7 @@ class Agenda
} else {
$sendTo = isset($params['send_to']) ? $params['send_to'] : null;
if ($this->type == 'course') {
$this->showToForm($form, $sendTo);
$this->showToForm($form, $sendTo, array(), false, true);
}
}
@ -1902,13 +1908,15 @@ class Agenda
* @param array $sendTo array('everyone' => false, 'users' => [1, 2], 'groups' => [3, 4])
* @param array $attributes
* @param bool $addOnlyItemsInSendTo
* @param bool $required
* @return bool
*/
public function showToForm(
$form,
$sendTo = array(),
$attributes = array(),
$addOnlyItemsInSendTo = false
$addOnlyItemsInSendTo = false,
$required = false
) {
if ($this->type != 'course') {
return false;
@ -1936,8 +1944,10 @@ class Agenda
$userList,
$sendTo,
$attributes,
$addOnlyItemsInSendTo
$addOnlyItemsInSendTo,
$required
);
return true;
}
@ -2246,8 +2256,7 @@ class Agenda
);
$selectedValues = $this->parseAgendaFilter($filter);
$this->showToForm($form, $selectedValues, $attributes);
$form = $form->return_form();
$form = $form->returnForm();
}
$actions .= "<a href='".api_get_path(WEB_CODE_PATH)."calendar/agenda.php?".api_get_cidreq()."&action=add&type=course'>".
Display::return_icon('new_event.png', get_lang('AgendaAdd'), '', ICON_SIZE_MEDIUM)."</a>";

@ -1636,7 +1636,7 @@ class Attendance
$users = $this->get_users_rel_course();
$user_ids = array_keys($users);
$course_id = api_get_course_int_id();
$affected_rows = 0;
if ($all_delete) {
$attendance_calendar = $this->get_attendance_calendar($attendance_id);
// get all dates from calendar by current attendance

@ -116,9 +116,6 @@ define('TABLE_MAIN_SESSION_FIELD', 'session_field');
define('TABLE_MAIN_SESSION_FIELD_OPTIONS', 'session_field_options');
define('TABLE_MAIN_SESSION_FIELD_VALUES', 'session_field_values');
// Message
define('TABLE_MAIN_MESSAGE', 'message');
// Term and conditions
define('TABLE_MAIN_LEGAL', 'legal');

@ -2054,6 +2054,7 @@ class Display
* @param string $title
* @param string $footer
* @param string $style
*
* @return string
*/
public static function panel($content, $title = '', $footer = '', $style = '')

@ -2,7 +2,7 @@
/* For licensing terms, see /license.txt */
/**
* Form element to select a date and hour (with popup datepicker)
* Form element to select a range of dates (with popup datepicker)
*/
class DateRangePicker extends HTML_QuickForm_text
{
@ -21,7 +21,7 @@ class DateRangePicker extends HTML_QuickForm_text
}
/**
* HTML code to display this datepicker
* @return string
*/
public function toHtml()
{
@ -100,10 +100,12 @@ class DateRangePicker extends HTML_QuickForm_text
{
$dates = explode('/', $dateRange);
$dates = array_map('trim', $dates);
$start = isset($dates[0]) ? $dates[0] : '';
$end = isset($dates[1]) ? $dates[1] : '';
return array(
'start' => $dates[0],
'end' => $dates[1]
'start' => $start,
'end' => $end
);
}
@ -117,6 +119,7 @@ class DateRangePicker extends HTML_QuickForm_text
if (empty($dates['start']) || empty($dates['end'])) {
return false;
}
$format = 'Y-m-d H:i';
$d = DateTime::createFromFormat($format, $dates['start']);
$resultStart = $d && $d->format($format) == $dates['start'];

@ -11,7 +11,7 @@ class SelectAjax extends HTML_QuickForm_select
*/
function SelectAjax($elementName = null, $elementLabel = null, $options = null, $attributes = null)
{
parent::HTML_QuickForm_Select($elementName, $elementLabel, $options, $attributes);
parent::__construct($elementName, $elementLabel, $options, $attributes);
}
/**

@ -14,7 +14,7 @@ class SelectLanguage extends HTML_QuickForm_select
if (!isset($attributes['class'])) {
$attributes['class'] = 'chzn-select';
}
parent::HTML_QuickForm_Select($elementName, $elementLabel, $options, $attributes);
parent::__construct($elementName, $elementLabel, $options, $attributes);
// Get all languages
$languages = api_get_languages();
$this->_options = array();

@ -11,10 +11,10 @@ class SelectTheme extends HTML_QuickForm_select
*/
function SelectTheme($elementName=null, $elementLabel=null, $options=null, $attributes=null) {
if (!isset($attributes['class'])) {
//todo this was comment due a bug in infocours.php with jquery-ui
//todo this was comment due a bug in infocours.php with jquery-ui
//$attributes['class'] = 'chzn-select';
}
parent::HTML_QuickForm_Select($elementName, $elementLabel, $options, $attributes);
}
parent::__construct($elementName, $elementLabel, $options, $attributes);
// Get all languages
$themes = api_get_themes();
$this->_options = array();
@ -22,6 +22,6 @@ class SelectTheme extends HTML_QuickForm_select
$this->addOption('--',''); // no theme select
for ($i=0; $i< count($themes[0]);$i++) {
$this->addOption($themes[1][$i],$themes[0][$i]);
}
}
}
}
}

@ -576,7 +576,7 @@ EOT;
/**
* @param string $name
* @param string $label
* @param array $options
* @param array $options
* @param array $attributes
*
* @return HTML_QuickForm_select

@ -884,16 +884,20 @@ class MessageManager
$message_content .= $user_image.' ';
}
$receiverUserInfo = api_get_user_info($row['user_receiver_id']);
$message_content .='<tr>';
if (api_get_setting('allow_social_tool') == 'true') {
if ($source == 'outbox') {
$message_content .= get_lang('From').': <a href="'.api_get_path(WEB_PATH).'main/social/profile.php?u='.$user_sender_id.'">'.$name.'</a> '.api_strtolower(get_lang('To')).'&nbsp;<b>'.GetFullUserName($row[2]).'</b>';
$message_content .= get_lang('From').': <a href="'.api_get_path(WEB_PATH).'main/social/profile.php?u='.$user_sender_id.'">'.$name.'</a> '.
api_strtolower(get_lang('To')).'&nbsp;<b>'.$receiverUserInfo['complete_name'].'</b>';
} else {
$message_content .= get_lang('From').' <a href="'.api_get_path(WEB_PATH).'main/social/profile.php?u='.$user_sender_id.'">'.$name.'</a> '.api_strtolower(get_lang('To')).'&nbsp;<b>'.get_lang('Me').'</b>';
$message_content .= get_lang('From').' <a href="'.api_get_path(WEB_PATH).'main/social/profile.php?u='.$user_sender_id.'">'.$name.'</a> '.
api_strtolower(get_lang('To')).'&nbsp;<b>'.get_lang('Me').'</b>';
}
} else {
if ($source == 'outbox') {
$message_content .= get_lang('From').':&nbsp;'.$name.'</b> '.api_strtolower(get_lang('To')).' <b>'.GetFullUserName($row['user_receiver_id']).'</b>';
$message_content .= get_lang('From').':&nbsp;'.$name.'</b> '.api_strtolower(get_lang('To')).' <b>'.$receiverUserInfo['complete_name'].'</b>';
} else {
$message_content .= get_lang('From').':&nbsp;'.$name.'</b> '.api_strtolower(get_lang('To')).' <b>'.get_lang('Me').'</b>';
}

@ -77,6 +77,7 @@ define('QUICKFORM_INVALID_DATASOURCE', -9);
// }}}
/**
* Class HTML_QuickForm
* Create, validate and process HTML forms
*
* @category HTML
@ -98,7 +99,7 @@ class HTML_QuickForm extends HTML_Common
* @var array
* @access private
*/
var $_elements = array();
public $_elements = array();
/**
* Array containing element name to index map
@ -106,7 +107,7 @@ class HTML_QuickForm extends HTML_Common
* @var array
* @access private
*/
var $_elementIndex = array();
public $_elementIndex = array();
/**
* Array containing indexes of duplicate elements
@ -114,7 +115,7 @@ class HTML_QuickForm extends HTML_Common
* @var array
* @access private
*/
var $_duplicateIndex = array();
public $_duplicateIndex = array();
/**
* Array containing required field IDs
@ -122,7 +123,7 @@ class HTML_QuickForm extends HTML_Common
* @var array
* @access private
*/
var $_required = array();
public $_required = array();
/**
* Prefix message in javascript alert if error
@ -130,7 +131,7 @@ class HTML_QuickForm extends HTML_Common
* @var string
* @access public
*/
var $_jsPrefix = 'Invalid information entered.';
public $_jsPrefix = 'Invalid information entered.';
/**
* Postfix message in javascript alert if error
@ -138,7 +139,7 @@ class HTML_QuickForm extends HTML_Common
* @var string
* @access public
*/
var $_jsPostfix = 'Please correct these fields.';
public $_jsPostfix = 'Please correct these fields.';
/**
* Datasource object implementing the informal
@ -147,7 +148,7 @@ class HTML_QuickForm extends HTML_Common
* @var object
* @access private
*/
var $_datasource;
public $_datasource;
/**
* Array of default form values
@ -155,7 +156,7 @@ class HTML_QuickForm extends HTML_Common
* @var array
* @access private
*/
var $_defaultValues = array();
public $_defaultValues = array();
/**
* Array of constant form values
@ -163,7 +164,7 @@ class HTML_QuickForm extends HTML_Common
* @var array
* @access private
*/
var $_constantValues = array();
public $_constantValues = array();
/**
* Array of submitted form values
@ -171,7 +172,7 @@ class HTML_QuickForm extends HTML_Common
* @var array
* @access private
*/
var $_submitValues = array();
public $_submitValues = array();
/**
* Array of submitted form files
@ -179,7 +180,7 @@ class HTML_QuickForm extends HTML_Common
* @var integer
* @access public
*/
var $_submitFiles = array();
public $_submitFiles = array();
/**
* Value for maxfilesize hidden element if form contains file input
@ -187,7 +188,7 @@ class HTML_QuickForm extends HTML_Common
* @var integer
* @access public
*/
var $_maxFileSize = 1048576; // 1 Mb = 1048576
public $_maxFileSize = 1048576; // 1 Mb = 1048576
/**
* Flag to know if all fields are frozen
@ -195,7 +196,7 @@ class HTML_QuickForm extends HTML_Common
* @var boolean
* @access private
*/
var $_freezeAll = false;
public $_freezeAll = false;
/**
* Array containing the form rules
@ -203,14 +204,14 @@ class HTML_QuickForm extends HTML_Common
* @var array
* @access private
*/
var $_rules = array();
public $_rules = array();
/**
* Form rules, global variety
* @var array
* @access private
*/
var $_formRules = array();
public $_formRules = array();
/**
* Array containing the validation errors
@ -218,7 +219,7 @@ class HTML_QuickForm extends HTML_Common
* @var array
* @access private
*/
var $_errors = array();
public $_errors = array();
/**
* Note for required fields in the form
@ -226,14 +227,14 @@ class HTML_QuickForm extends HTML_Common
* @since 1.0
* @access private
*/
var $_requiredNote = '<span style="font-size:80%; color:#ff0000;">*</span><span style="font-size:80%;"> denotes required field</span>';
public $_requiredNote = '<span style="font-size:80%; color:#ff0000;">*</span><span style="font-size:80%;"> denotes required field</span>';
/**
* Whether the form was submitted
* @var boolean
* @access private
*/
var $_flagSubmitted = false;
public $_flagSubmitted = false;
// }}}
// {{{ constructor
@ -258,7 +259,12 @@ class HTML_QuickForm extends HTML_Common
if (isset($attributes['id']) && !empty($attributes['id'])) {
$form_id = Security::remove_XSS($attributes['id']);
}
$attributes = array('action'=>$action, 'method'=>$method, 'name'=>$formName, 'id'=>$form_id) + $target;
$attributes = array(
'action' => $action,
'method' => $method,
'name' => $formName,
'id' => $form_id
) + $target;
$this->updateAttributes($attributes);
if (!$trackSubmit || isset($_REQUEST['_qf__' . $formName])) {
if (1 == get_magic_quotes_gpc()) {
@ -2059,8 +2065,14 @@ class HTML_QuickForm extends HTML_Common
return isset($errorMessages[$value]) ? $errorMessages[$value] : $errorMessages[QUICKFORM_ERROR];
} // end func errorMessage
// }}}
} // end class HTML_QuickForm
/**
* @param HTML_QuickForm_element $element
*/
public function setRequired(HTML_QuickForm_element $element)
{
$this->addRule($element->getName(), get_lang('ThisFieldIsRequired'), 'required');
}
}
/**
* Class for errors thrown by HTML_QuickForm package
@ -2101,6 +2113,4 @@ class HTML_QuickForm_Error extends PEAR_Error {
$this->PEAR_Error("Invalid error code: $code", QUICKFORM_ERROR, $mode, $level, $debuginfo);
}
}
// }}}
} // end class HTML_QuickForm_Error
?>
}

@ -282,7 +282,7 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
$opts = $options;
$options = null; // prevent to use the default select element load options
$this->HTML_QuickForm_select($elementName, $elementLabel, $options, $attributes);
parent::__construct($elementName, $elementLabel, $options, $attributes);
$this->selectAllCheckBox = isset($attributes['select_all_checkbox']) ? $attributes['select_all_checkbox'] : false;

@ -73,7 +73,7 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
* @access public
* @return void
*/
public function HTML_QuickForm_select(
public function __construct(
$elementName = null,
$elementLabel = null,
$options = null,

@ -42,7 +42,7 @@ class HTML_QuickForm_textarea extends HTML_QuickForm_element
* @since 1.0
* @access private
*/
var $_value = null;
public $_value = null;
// }}}
// {{{ constructor
@ -185,7 +185,7 @@ class HTML_QuickForm_textarea extends HTML_QuickForm_element
* @access public
* @return string
*/
function toHtml()
public function toHtml()
{
if ($this->_flagFrozen) {
return $this->getFrozenHtml();
@ -199,10 +199,7 @@ class HTML_QuickForm_textarea extends HTML_QuickForm_element
//
'</textarea>';
}
} //end func toHtml
// }}}
// {{{ getFrozenHtml()
}
/**
* Returns the value of field without HTML tags (in this case, value is changed to a mask)
@ -211,7 +208,7 @@ class HTML_QuickForm_textarea extends HTML_QuickForm_element
* @access public
* @return string
*/
function getFrozenHtml()
public function getFrozenHtml()
{
// Modified by Ivan Tcholakov, 16-MAR-2010.
//$value = htmlspecialchars($this->getValue());
@ -223,9 +220,6 @@ class HTML_QuickForm_textarea extends HTML_QuickForm_element
$html = nl2br($value)."\n";
}
return $html . $this->_getPersistantData();
} //end func getFrozenHtml
// }}}
}
} //end class HTML_QuickForm_textarea
?>
}

@ -11,6 +11,9 @@
*/
class SocialManager extends UserManager
{
/**
* Constructor
*/
public function __construct()
{
@ -25,7 +28,8 @@ class SocialManager extends UserManager
{
$friend_relation_list = array();
$tbl_my_friend_relation_type = Database :: get_main_table(TABLE_MAIN_USER_FRIEND_RELATION_TYPE);
$sql = 'SELECT id,title FROM '.$tbl_my_friend_relation_type.' WHERE id<>6 ORDER BY id ASC';
$sql = 'SELECT id,title FROM '.$tbl_my_friend_relation_type.'
WHERE id<>6 ORDER BY id ASC';
$result = Database::query($sql);
while ($row = Database::fetch_array($result, 'ASSOC')) {
$friend_relation_list[] = $row;
@ -100,14 +104,23 @@ class SocialManager extends UserManager
$tbl_my_friend = Database :: get_main_table(TABLE_MAIN_USER_REL_USER);
$tbl_my_user = Database :: get_main_table(TABLE_MAIN_USER);
$sql = 'SELECT friend_user_id FROM '.$tbl_my_friend.'
WHERE relation_type NOT IN ('.USER_RELATION_TYPE_DELETED.', '.USER_RELATION_TYPE_RRHH.') AND friend_user_id<>'.((int) $user_id).' AND user_id='.((int) $user_id);
WHERE
relation_type NOT IN ('.USER_RELATION_TYPE_DELETED.', '.USER_RELATION_TYPE_RRHH.') AND
friend_user_id<>'.((int) $user_id).' AND
user_id='.((int) $user_id);
if (isset($id_group) && $id_group > 0) {
$sql.=' AND relation_type='.$id_group;
}
if (isset($search_name)) {
$search_name = trim($search_name);
$search_name = str_replace(' ', '', $search_name);
$sql.=' AND friend_user_id IN (SELECT user_id FROM '.$tbl_my_user.' WHERE firstName LIKE "%'.Database::escape_string($search_name).'%" OR lastName LIKE "%'.Database::escape_string($search_name).'%" OR '.(api_is_western_name_order() ? 'concat(firstName, lastName)' : 'concat(lastName, firstName)').' like concat("%","'.Database::escape_string($search_name).'","%") ) ';
$sql.=' AND friend_user_id IN (
SELECT user_id FROM '.$tbl_my_user.'
WHERE
firstName LIKE "%'.Database::escape_string($search_name).'%" OR
lastName LIKE "%'.Database::escape_string($search_name).'%" OR
'.(api_is_western_name_order() ? 'concat(firstName, lastName)' : 'concat(lastName, firstName)').' LIKE concat("%","'.Database::escape_string($search_name).'","%")
) ';
}
$res = Database::query($sql);
@ -144,7 +157,12 @@ class SocialManager extends UserManager
$list_ids = self::get_friends($user_id, $id_group, $search_name);
if (is_array($list_ids)) {
foreach ($list_ids as $values_ids) {
$list_path_image_friend[] = UserManager::get_user_picture_path_by_id($values_ids['friend_user_id'], 'web', false, true);
$list_path_image_friend[] = UserManager::get_user_picture_path_by_id(
$values_ids['friend_user_id'],
'web',
false,
true
);
$combine_friend = array(
'id_friend' => $list_ids,
'path_friend' => $list_path_image_friend
@ -189,7 +207,7 @@ class SocialManager extends UserManager
*/
public static function send_invitation_friend($user_id, $friend_id, $message_title, $message_content)
{
$tbl_message = Database::get_main_table(TABLE_MAIN_MESSAGE);
$tbl_message = Database::get_main_table(TABLE_MESSAGE);
$user_id = intval($user_id);
$friend_id = intval($friend_id);
@ -202,7 +220,11 @@ class SocialManager extends UserManager
$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);';
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');
@ -249,9 +271,11 @@ class SocialManager extends UserManager
*/
public static function get_message_number_invitation_by_user_id($user_receiver_id)
{
$tbl_message = Database::get_main_table(TABLE_MAIN_MESSAGE);
$tbl_message = Database::get_main_table(TABLE_MESSAGE);
$sql = 'SELECT COUNT(*) as count_message_in_box FROM '.$tbl_message.'
WHERE user_receiver_id='.intval($user_receiver_id).' AND msg_status='.MESSAGE_STATUS_INVITATION_PENDING;
WHERE
user_receiver_id='.intval($user_receiver_id).' AND
msg_status='.MESSAGE_STATUS_INVITATION_PENDING;
$res = Database::query($sql);
$row = Database::fetch_array($res, 'ASSOC');
return $row['count_message_in_box'];
@ -265,10 +289,12 @@ class SocialManager extends UserManager
*/
public static function get_list_invitation_of_friends_by_user_id($user_id)
{
$tbl_message = Database::get_main_table(TABLE_MAIN_MESSAGE);
$tbl_message = Database::get_main_table(TABLE_MESSAGE);
$sql = 'SELECT user_sender_id,send_date,title,content
FROM '.$tbl_message.'
WHERE user_receiver_id='.intval($user_id).' AND msg_status = '.MESSAGE_STATUS_INVITATION_PENDING;
WHERE
user_receiver_id='.intval($user_id).' AND
msg_status = '.MESSAGE_STATUS_INVITATION_PENDING;
$res = Database::query($sql);
$list_friend_invitation = array();
while ($row = Database::fetch_array($res, 'ASSOC')) {
@ -286,7 +312,7 @@ class SocialManager extends UserManager
public static function get_list_invitation_sent_by_user_id($user_id)
{
$list_friend_invitation = array();
$tbl_message = Database::get_main_table(TABLE_MAIN_MESSAGE);
$tbl_message = Database::get_main_table(TABLE_MESSAGE);
$sql = 'SELECT user_receiver_id, send_date,title,content
FROM '.$tbl_message.'
WHERE user_sender_id = '.intval($user_id).' AND msg_status = '.MESSAGE_STATUS_INVITATION_PENDING;
@ -306,7 +332,7 @@ class SocialManager extends UserManager
*/
public static function invitation_accepted($user_send_id, $user_receiver_id)
{
$tbl_message = Database::get_main_table(TABLE_MAIN_MESSAGE);
$tbl_message = Database::get_main_table(TABLE_MESSAGE);
$sql = "UPDATE $tbl_message
SET msg_status = ".MESSAGE_STATUS_INVITATION_ACCEPTED."
WHERE
@ -325,7 +351,7 @@ class SocialManager extends UserManager
*/
public static function invitation_denied($user_send_id, $user_receiver_id)
{
$tbl_message = Database::get_main_table(TABLE_MAIN_MESSAGE);
$tbl_message = Database::get_main_table(TABLE_MESSAGE);
$sql = 'DELETE FROM '.$tbl_message.'
WHERE
user_sender_id = '.((int) $user_send_id).' AND
@ -420,7 +446,11 @@ class SocialManager extends UserManager
if (!empty($rss->items)) {
$icon_rss = '';
if (!empty($feed)) {
$icon_rss = Display::url(Display::return_icon('social_rss.png', '', array(), 22), Security::remove_XSS($feed['rssfeeds']), array('target' => '_blank'));
$icon_rss = Display::url(
Display::return_icon('social_rss.png', '', array(), 22),
Security::remove_XSS($feed['rssfeeds']),
array('target' => '_blank')
);
}
$res .= '<h3 class="title-rss">'.$icon_rss.' '.$rss->channel['title'].'</h3>';
@ -1118,7 +1148,7 @@ class SocialManager extends UserManager
*/
public static function sendWallMessage($userId, $friendId, $messageContent, $messageId = 0 ,$messageStatus)
{
$tblMessage = Database::get_main_table(TABLE_MAIN_MESSAGE);
$tblMessage = Database::get_main_table(TABLE_MESSAGE);
$userId = intval($userId);
$friendId = intval($friendId);
$messageId = intval($messageId);
@ -1217,24 +1247,23 @@ class SocialManager extends UserManager
if (empty($start)) {
$start = '0000-00-00';
}
$tblMessage = Database::get_main_table(TABLE_MAIN_MESSAGE);
$tblMessage = Database::get_main_table(TABLE_MESSAGE);
$tblMessageAttachement = Database::get_main_table(TABLE_MESSAGE_ATTACHMENT);
$userId = intval($userId);
$start = Database::escape_string($start);
// TODO: set a maximum of 3 months for messages
//if ($start == '0000-00-00') {
//
//}
$limit = intval($limit);
$messages = array();
$sql = "SELECT id, user_sender_id,user_receiver_id, send_date, content, parent_id,
(SELECT ma.path from message_attachment ma WHERE ma.message_id = tm.id ) as path,
(SELECT ma.filename from message_attachment ma WHERE ma.message_id = tm.id ) as filename
FROM $tblMessage tm
WHERE user_receiver_id = $userId
(SELECT ma.path FROM $tblMessageAttachement ma WHERE ma.message_id = tm.id ) as path,
(SELECT ma.filename FROM $tblMessageAttachement ma WHERE ma.message_id = tm.id ) as filename
FROM $tblMessage tm
WHERE user_receiver_id = $userId
AND send_date > '$start' ";
$sql .= (empty($messageStatus) || is_null($messageStatus)) ? '' : " AND msg_status = '$messageStatus' ";
$sql .= (empty($parentId) || is_null($parentId)) ? '' : " AND parent_id = '$parentId' ";
$sql .= " ORDER BY send_date DESC LIMIT $offset, $limit ";
$messages = array();
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
while ($row = Database::fetch_array($res)) {
@ -1284,7 +1313,7 @@ class SocialManager extends UserManager
if ($isOwnWall) {
$media .= '<div class="pull-right deleted-mgs">';
$media .= '<a title="'.get_lang("SocialMessageDelete").'" href="'.api_get_path(WEB_CODE_PATH).'social/profile.php?messageId='.
$message['id'].'">'.get_lang('x').'</a>';
$message['id'].'">x</a>';
$media .= '</div>';
}
$media .= '<div class="user-image">';
@ -1404,11 +1433,10 @@ class SocialManager extends UserManager
$wallImage = '<a class="thumbnail ajax" href="'.$imageBig.'"><img src="'.$imageSmall.'"></a>';
}
$htmlDelete = '';
if ($isOwnWall) {
$htmlDelete .= '<a title="'.get_lang("SocialMessageDelete").'" href="'.api_get_path(WEB_CODE_PATH).'social/profile.php?messageId='.
$message['id'].'">'.get_lang('x').'</a>';
$message['id'].'">x</a>';
}
$html = '';
@ -1523,6 +1551,7 @@ class SocialManager extends UserManager
/**
* Generate the social block for a user
* @param Template $template
* @param int $userId The user id
* @param string $groupBlock Optional. Highlight link possible values:
* group_add, home, messages, messages_inbox, messages_compose,
@ -1530,7 +1559,7 @@ class SocialManager extends UserManager
* @param int $groupId Optional. Group ID
* @return string The HTML code with the social block
*/
public static function setSocialUserBlock($template, $userId, $groupBlock = '', $groupId = 0)
public static function setSocialUserBlock(Template $template, $userId, $groupBlock = '', $groupId = 0)
{
if (api_get_setting('allow_social_tool') != 'true') {
return '';
@ -1548,4 +1577,106 @@ class SocialManager extends UserManager
$template->assign('profileEditionLink', $profileEditionLink);
$template->assign('social_avatar_block', $template->fetch('default/social/user_block.tpl'));
}
/**
* @param $user_id
* @param $link_shared
* @param $show_full_profile
* @return string
*/
public static function listMyFriends($user_id, $link_shared, $show_full_profile)
{
//SOCIALGOODFRIEND , USER_RELATION_TYPE_FRIEND, USER_RELATION_TYPE_PARENT
$friends = SocialManager::get_friends($user_id, USER_RELATION_TYPE_FRIEND);
$number_of_images = 30;
$number_friends = count($friends);
$friendHtml = '<div class="nav-list"><h3>'.get_lang('SocialFriend').'<span>(' . $number_friends . ')</span></h3></div>';
if ($number_friends != 0) {
if ($number_friends > $number_of_images) {
if (api_get_user_id() == $user_id) {
$friendHtml.= ' : <span><a href="friends.php">'.get_lang('SeeAll').'</a></span>';
} else {
$friendHtml.= ' : <span>'
.'<a href="'.api_get_path(WEB_CODE_PATH).'social/profile_friends_and_groups.inc.php'
.'?view=friends&height=390&width=610&user_id='.$user_id.'"'
.'class="ajax" title="'.get_lang('SeeAll').'" >'.get_lang('SeeAll').'</a></span>';
}
}
$friendHtml.= '<ul class="nav nav-list">';
$j = 1;
for ($k=0; $k < $number_friends; $k++) {
if ($j > $number_of_images) break;
if (isset($friends[$k])) {
$friend = $friends[$k];
$name_user = api_get_person_name($friend['firstName'], $friend['lastName']);
$user_info_friend = api_get_user_info($friend['friend_user_id'], true);
if ($user_info_friend['user_is_online']) {
$statusIcon = Display::span('', array('class' => 'online_user_in_text'));
} else {
$statusIcon = Display::span('', array('class' => 'offline_user_in_text'));
}
$friendHtml.= '<li class="">';
// the height = 92 must be the same in the image_friend_network span style in default.css
$friends_profile = SocialManager::get_picture_user($friend['friend_user_id'], $friend['image'], 20, USER_IMAGE_SIZE_SMALL);
$friendHtml.= '<img src="'.$friends_profile['file'].'" id="imgfriend_'.$friend['friend_user_id'].'" title="'.$name_user.'"/>';
$link_shared = (empty($link_shared)) ? '' : '&'.$link_shared;
$friendHtml.= $statusIcon .'<a href="profile.php?' .'u=' . $friend['friend_user_id'] . $link_shared . '">' . $name_user .'</a>';
$friendHtml.= '</li>';
}
$j++;
}
$friendHtml.='</ul>';
} else {
$friendHtml.= '<div class="">'.get_lang('NoFriendsInYourContactList').'<br />'
.'<a class="btn" href="'.api_get_path(WEB_PATH).'whoisonline.php">'. get_lang('TryAndFindSomeFriends').'</a></div>';
}
return $friendHtml;
}
/**
* @return string
*/
public static function getWallForm()
{
$form = new FormValidator(
'social_wall_main',
'post',
api_get_path(WEB_CODE_PATH).'social/profile.php',
null,
array('enctype' => 'multipart/form-data')
);
$form->addTextarea('social_wall_new_msg_main', null, array('placeholder' => get_lang('SocialWallWhatAreYouThinkingAbout')));
$form->addButtonSend(get_lang('Post'));
$html = Display::panel($form->returnForm(), get_lang('SocialWall'));
return $html;
}
/**
* @param int $userId
* @param int $friendId
* @return string
*/
public static function getWallMessagesByUser($userId, $friendId)
{
$messages = SocialManager::getWallMessagesPostHTML($userId, $friendId);
$html = '';
foreach ($messages as $message) {
$post = $message['html'];
$comment = SocialManager::getWallMessagesHTML($userId, $friendId, $message['id']);
$html .= $post.$comment;
}
return $html;
}
}

@ -703,7 +703,7 @@ class Statistics
*/
public static function getMessages($messageType)
{
$message_table = Database::get_main_table(TABLE_MAIN_MESSAGE);
$message_table = Database::get_main_table(TABLE_MESSAGE);
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);

@ -4062,7 +4062,7 @@ class UserManager
public static function remove_user_rel_user($friend_id, $real_removed = false, $with_status_condition = '')
{
$tbl_my_friend = Database :: get_main_table(TABLE_MAIN_USER_REL_USER);
$tbl_my_message = Database :: get_main_table(TABLE_MAIN_MESSAGE);
$tbl_my_message = Database :: get_main_table(TABLE_MESSAGE);
$friend_id = intval($friend_id);
if ($real_removed) {

@ -118,7 +118,7 @@ $nameTools = get_lang('ComposeMessage');
/**
* Shows the compose area + a list of users to select from.
*/
function show_compose_to_any ($user_id) {
function show_compose_to_any($user_id) {
$online_user_list = MessageManager::get_online_user_list($user_id);
$default['user_list'] = 0;
$online_user_list=null;
@ -129,26 +129,23 @@ function show_compose_to_any ($user_id) {
function show_compose_reply_to_message($message_id, $receiver_id)
{
$table_message = Database::get_main_table(TABLE_MESSAGE);
$query = "SELECT user_sender_id FROM $table_message WHERE user_receiver_id=".intval($receiver_id)." AND id='".intval($message_id)."';";
$query = "SELECT user_sender_id FROM $table_message
WHERE user_receiver_id=".intval($receiver_id)." AND id='".intval($message_id)."';";
$result = Database::query($query);
$row = Database::fetch_array($result,'ASSOC');
if (!isset($row['user_sender_id'])) {
$html = get_lang('InvalidMessageId');
return $html;
}
$pre_html = '<div class="control-group">
<label class="control-label">'.get_lang('SendMessageTo').': </label>
<div class="controls">';
$post = '</div></div>';
$sent_to = $pre_html.'<strong>'.GetFullUserName($row['user_sender_id']).'</strong>'.$post;
$userInfo = api_get_user_info($row['user_sender_id']);
$default['users'] = array($row['user_sender_id']);
$html .= manage_form($default, null, $sent_to);
$html = manage_form($default, null, $userInfo['complete_name']);
return $html;
}
function show_compose_to_user ($receiver_id) {
global $charset;
$html = get_lang('To').':&nbsp;<strong>'.GetFullUserName($receiver_id).'</strong>';
$default['title'] = api_xml_http_response_encode(get_lang('EnterTitle'));
$default['users'] = array($receiver_id);
@ -156,7 +153,8 @@ function show_compose_to_user ($receiver_id) {
return $html;
}
function manage_form($default, $select_from_user_list = null, $sent_to = null) {
function manage_form($default, $select_from_user_list = null, $sent_to = null)
{
$group_id = isset($_REQUEST['group_id']) ? intval($_REQUEST['group_id']) : null;
$message_id = isset($_GET['message_id']) ? intval($_GET['message_id']) : null;
$param_f = isset($_GET['f']) && $_GET['f'] == 'social' ? 'social' : null;
@ -169,7 +167,6 @@ function manage_form($default, $select_from_user_list = null, $sent_to = null) {
get_lang('SendMessageTo'),
true,
array(
'class' => 'span4',
'id'=>'id_text_name',
'onkeyup'=>'send_request_and_search()',
'autocomplete'=>'off'
@ -180,7 +177,7 @@ function manage_form($default, $select_from_user_list = null, $sent_to = null) {
$form->addElement('hidden','user_list', 0, array('id'=>'user_list'));
} else {
if (!empty($sent_to)) {
$form->addElement('html',$sent_to);
$form->addLabel(get_lang('SendMessageTo'), $sent_to);
}
if (empty($default['users'])) {
//fb select
@ -197,7 +194,7 @@ function manage_form($default, $select_from_user_list = null, $sent_to = null) {
$form->addElement('hidden','parent_id',$message_id);
}
$form->addText('title', get_lang('Subject'), true, array('class' => 'col-md-4'));
$form->addText('title', get_lang('Subject'), true);
$form->addHtmlEditor('content', get_lang('Message'), false, false, array('ToolbarSet' => 'Messages', 'Width' => '100%', 'Height' => '250'));
if (isset($_GET['re_id'])) {
@ -223,7 +220,7 @@ function manage_form($default, $select_from_user_list = null, $sent_to = null) {
$form->addElement('advanced_settings','<span id="link-more-attach"><a href="javascript://" onclick="return add_image_form()">'.get_lang('AddOneMoreFile').'</a></span>&nbsp;('.sprintf(get_lang('MaximunFileSizeX'),format_file_size(api_get_setting('message_max_upload_filesize'))).')');
}
$form->addElement('style_submit_button','compose',api_xml_http_response_encode('<i class="fa fa-paper-plane"></i> '.get_lang('SendMessage')),'class="btn-success"');
$form->addButtonSend(get_lang('SendMessage'), 'compose');
$form->setRequiredNote('<span class="form_required">*</span> <small>'.get_lang('ThisFieldIsRequired').'</small>');
if (!empty($group_id) && !empty($message_id)) {
@ -270,13 +267,15 @@ function manage_form($default, $select_from_user_list = null, $sent_to = null) {
$token = Security::get_token();
$form->addElement('hidden','sec_token');
$form->setConstants(array('sec_token' => $token));
$html .= $form->return_form();
$html .= $form->returnForm();
}
return $html;
}
$socialToolIsActive = isset($_GET['f']) && $_GET['f'] == 'social';
/* MAIN SECTION */
if ($_GET['f']=='social') {
if ($socialToolIsActive) {
$this_section = SECTION_SOCIAL;
$interbreadcrumb[]= array ('url' => api_get_path(WEB_PATH).'main/social/home.php','name' => get_lang('SocialNetwork'));
} else {
@ -288,11 +287,13 @@ $group_id = isset($_REQUEST['group_id']) ? intval($_REQUEST['group_id']) : null;
$social_right_content = null;
if ($group_id != 0) {
$social_right_content .= '<div class=actions>';
$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/social/groups.php?id='.$group_id.'">'.Display::return_icon('back.png',api_xml_http_response_encode(get_lang('ComposeMessage'))).'</a>';
$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php?group_id='.$group_id.'">'.Display::return_icon('message_new.png',api_xml_http_response_encode(get_lang('ComposeMessage'))).'</a>';
$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/social/groups.php?id='.$group_id.'">'.
Display::return_icon('back.png',api_xml_http_response_encode(get_lang('ComposeMessage'))).'</a>';
$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php?group_id='.$group_id.'">'.
Display::return_icon('message_new.png',api_xml_http_response_encode(get_lang('ComposeMessage'))).'</a>';
$social_right_content .= '</div>';
} else {
if ($_GET['f']=='social') {
if ($socialToolIsActive) {
} else {
$social_right_content .= '<div class=actions>';
if (api_get_setting('allow_social_tool') == 'true' && api_get_setting('allow_message_tool') == 'true') {
@ -329,7 +330,7 @@ if (!isset($_POST['compose'])) {
} elseif(isset($_GET['send_to_user'])) {
$social_right_content .= show_compose_to_user($_GET['send_to_user']);
} else {
$social_right_content .= show_compose_to_any($_user['user_id']);
$social_right_content .= show_compose_to_any(api_get_user_id());
}
} else {
$restrict = false;

@ -75,7 +75,6 @@ $tpl = new Template(get_lang('View'));
SocialManager::setSocialUserBlock($tpl, $user_id, $show_menu);
if (api_get_setting('allow_social_tool') == 'true') {
$tpl->assign('social_avatar_block', $social_avatar_block);
$tpl->assign('social_menu_block', $social_menu_block);
$tpl->assign('social_right_content', $social_right_content);
$social_layout = $tpl->get_template('social/inbox.tpl');

@ -236,7 +236,7 @@ foreach ($sessionList as $session) {
}
// My friends
$friend_html = listMyFriends($user_id, $link_shared ,$show_full_profile);
$friend_html = SocialManager::listMyFriends($user_id, $link_shared ,$show_full_profile);
$social_left_content = '<div class="well sidebar-nav">' .$friend_html . '</div>';
/*
@ -281,11 +281,11 @@ if ($show_full_profile) {
*/
//Social Block Wall
$wallSocialAddPost = wallSocialAddPost();
$wallSocialAddPost = SocialManager::getWallForm();
$social_wall_block = $wallSocialAddPost;
//Social Post Wall
$post_wall = wallSocialPost($my_user_id,$friendId) ;
$post_wall = SocialManager::getWallMessagesByUser($my_user_id, $friendId) ;
$social_post_wall_block = '<div class="panel panel-default social-post">';
$social_post_wall_block .= '<div class="panel-heading">Mis publicaciones</div>';
$social_post_wall_block .='<div class="panel-body">';
@ -749,99 +749,3 @@ $tpl->assign('formModals', $formModals);
$social_layout = $tpl->get_template('social/profile.tpl');
$tpl->display($social_layout);
/*
* function list my friends
*/
function listMyFriends($user_id, $link_shared, $show_full_profile)
{
//SOCIALGOODFRIEND , USER_RELATION_TYPE_FRIEND, USER_RELATION_TYPE_PARENT
$friends = SocialManager::get_friends($user_id, USER_RELATION_TYPE_FRIEND);
$friendHtml = '';
$number_of_images = 30;
$number_friends = 0;
$number_friends = count($friends);
$friendHtml = '<div class="nav-list"><h3>'.get_lang('SocialFriend').'<span>(' . $number_friends . ')</span></h3></div>';
if ($number_friends != 0) {
if ($number_friends > $number_of_images) {
if (api_get_user_id() == $user_id) {
$friendHtml.= ' : <span><a href="friends.php">'.get_lang('SeeAll').'</a></span>';
} else {
$friendHtml.= ' : <span>'
.'<a href="'.api_get_path(WEB_CODE_PATH).'social/profile_friends_and_groups.inc.php'
.'?view=friends&height=390&width=610&user_id='.$user_id.'"'
.'class="ajax" title="'.get_lang('SeeAll').'" >'.get_lang('SeeAll').'</a></span>';
}
}
$friendHtml.= '<ul class="nav nav-list">';
$j = 1;
for ($k=0; $k < $number_friends; $k++) {
if ($j > $number_of_images) break;
if (isset($friends[$k])) {
$friend = $friends[$k];
$name_user = api_get_person_name($friend['firstName'], $friend['lastName']);
$user_info_friend = api_get_user_info($friend['friend_user_id'], true);
if ($user_info_friend['user_is_online']) {
$statusIcon = Display::span('', array('class' => 'online_user_in_text'));
} else {
$statusIcon = Display::span('', array('class' => 'offline_user_in_text'));
}
$friendHtml.= '<li class="">';
// the height = 92 must be the sqme in the image_friend_network span style in default.css
$friends_profile = SocialManager::get_picture_user($friend['friend_user_id'], $friend['image'], 20, USER_IMAGE_SIZE_SMALL);
$friendHtml.= '<img src="'.$friends_profile['file'].'" id="imgfriend_'.$friend['friend_user_id'].'" title="'.$name_user.'"/>';
$link_shared = (empty($link_shared)) ? '' : '&'.$link_shared;
$friendHtml.= $statusIcon .'<a href="profile.php?' .'u=' . $friend['friend_user_id'] . $link_shared . '">' . $name_user .'</a>';
$friendHtml.= '</li>';
}
$j++;
}
$friendHtml.='</ul>';
} else {
$friendHtml.= '<div class="">'.get_lang('NoFriendsInYourContactList').'<br />'
.'<a class="btn" href="'.api_get_path(WEB_PATH).'whoisonline.php">'. get_lang('TryAndFindSomeFriends').'</a></div>';
}
return $friendHtml;
}
function wallSocialAddPost()
{
$html = '<div class="panel panel-default social-wall">';
$html .= '<div class="panel-heading">' . get_lang('SocialWall') . '</div>';
$html .= '<div class="panel-body">';
$html .=
'<form name="social_wall_main" method="POST" enctype="multipart/form-data">
<label for="social_wall_new_msg_main" class="hide">' . get_lang('SocialWallWhatAreYouThinkingAbout') . '</label>
<textarea name="social_wall_new_msg_main" rows="2" cols="80" style="width: 98%" placeholder="'.get_lang('SocialWallWhatAreYouThinkingAbout').'"></textarea>
<br />
<input class="" name="picture" type="file" accept="image/*" style="width:80%;">
<button type="submit" name="social_wall_new_msg_main_submit" class="pull-right btn btn-success" />
<i class="fa fa-pencil"></i> '.get_lang('Post').'</button>
</form>';
$html.= '</div></div>';
return $html;
}
function wallSocialPost($userId, $friendId)
{
$array = SocialManager::getWallMessagesPostHTML($userId, $friendId);
$html = '';
for($i = 0; $i < count($array); $i++) {
$post = $array[$i]['html'];
$comment = SocialManager::getWallMessagesHTML($userId, $friendId, $array[$i]['id']);
$html .= $post.$comment;
}
return $html;
}

Loading…
Cancel
Save