</tr> </thead> <tbody> <?php $nb = 0; foreach ($data as $row) { $row_user = new User($row['user']); $song = new Song($row['object_id']); $agent = ''; $time_string = '-'; $has_allowed_agent = true; $has_allowed_time = true; $is_allowed = Access::check('interface', '100') || $GLOBALS['user']->id == $row_user->id; if (!$is_allowed) { $has_allowed_time = Preference::get_by_user($row_user->id, 'allow_personal_info_time'); $has_allowed_agent = Preference::get_by_user($row_user->id, 'allow_personal_info_agent'); } if ($is_allowed || $has_allowed_agent) { $agent = $row['agent']; if (!empty($row['geo_name'])) { $agent .= ' - ' . $row['geo_name']; } } if ($is_allowed || $has_allowed_time) { $interval = intval(time() - $row['date']); if ($interval < 60) { $time_string = sprintf(ngettext('%d second ago', '%d seconds ago', $interval), $interval); } elseif ($interval < 3600) { $interval = floor($interval / 60); $time_string = sprintf(ngettext('%d minute ago', '%d minutes ago', $interval), $interval); } elseif ($interval < 86400) {
/** * create * This takes a key'd array of data as input and inserts a new shoutbox entry, it returns the auto_inc id */ public static function create(array $data) { if (!Core::is_library_item($data['object_type'])) { return false; } $sticky = isset($data['sticky']) ? 1 : 0; $user = intval($data['user'] ?: $GLOBALS['user']->id); $date = intval($data['date'] ?: time()); $comment = strip_tags($data['comment']); $sql = "INSERT INTO `user_shout` (`user`,`date`,`text`,`sticky`,`object_id`,`object_type`, `data`) " . "VALUES (? , ?, ?, ?, ?, ?, ?)"; Dba::write($sql, array($user, $date, $comment, $sticky, $data['object_id'], $data['object_type'], $data['data'])); $insert_id = Dba::insert_id(); // Never send email in case of user impersonation if (!isset($data['user']) && $insert_id) { $libitem = new $data['object_type']($data['object_id']); $item_owner_id = $libitem->get_user_owner(); if ($item_owner_id) { if (Preference::get_by_user($item_owner_id, 'notify_email')) { $item_owner = new User($item_owner_id); if (!empty($item_owner->email)) { $libitem->format(); $mailer = new Mailer(); $mailer->set_default_sender(); $mailer->recipient = $item_owner->email; $mailer->recipient_name = $item_owner->fullname; $mailer->subject = T_('New shout on your content'); $mailer->message = sprintf(T_("You just received a new shout from %s on your content `%s`.\n\n\n ----------------------\n %s\n ----------------------\n\n %s\n "), $GLOBALS['user']->fullname, $libitem->get_fullname(), $comment, AmpConfig::get('web_path') . "/shout.php?action=show_add_shout&type=" . $data['object_type'] . "&id=" . $data['object_id'] . "#shout" . $insert_id); $mailer->send(); } } } } return $insert_id; }
$browse->store(); ?> </div> <div id="followers" class="tab_content"> <?php $follower_ids = $client->get_followers(); $browse = new Browse(); $browse->set_type('user'); $browse->set_simple_browse(false); $browse->show_objects($follower_ids); $browse->store(); ?> </div> <div id="timeline" class="tab_content"> <?php if (Preference::get_by_user($client->id, 'allow_personal_info_recent')) { $activities = Useractivity::get_activities($client->id); Useractivity::build_cache($activities); foreach ($activities as $aid) { $activity = new Useractivity($aid); $activity->show(); } } ?> </div> <?php } ?> </div> </div>
public static function create(array $data) { $subject = trim(strip_tags($data['subject'])); $message = trim(strip_tags($data['message'])); if (empty($subject)) { AmpError::add('subject', T_('Error: Subject Required')); } $to_user = User::get_from_username($data['to_user']); if (!$to_user->id) { AmpError::add('to_user', T_('Error: Unknown user')); } if (!AmpError::occurred()) { $from_user = $data['from_user'] ?: $GLOBALS['user']->id; $creation_date = $data['creation_date'] ?: time(); $is_read = $data['is_read'] ?: 0; $sql = "INSERT INTO `user_pvmsg` (`subject`, `message`, `from_user`, `to_user`, `creation_date`, `is_read`) " . "VALUES (?, ?, ?, ?, ?, ?)"; if (Dba::write($sql, array($subject, $message, $from_user, $to_user->id, $creation_date, $is_read))) { $insert_id = Dba::insert_id(); // Never send email in case of user impersonation if (!isset($data['from_user']) && $insert_id) { if (Preference::get_by_user($to_user->id, 'notify_email')) { if (!empty($to_user->email)) { $mailer = new Mailer(); $mailer->set_default_sender(); $mailer->recipient = $to_user->email; $mailer->recipient_name = $to_user->fullname; $mailer->subject = "[" . T_('Private Message') . "] " . $subject; $mailer->message = sprintf(T_("You just received a new private message from %s.\n\n\n ----------------------\n %s\n ----------------------\n\n %s\n "), $GLOBALS['user']->fullname, $message, AmpConfig::get('web_path') . "/pvmsg.php?action=show&pvmsg_id=" . $insert_id); $mailer->send(); } } } return $insert_id; } } return false; }
public static function addUser($xml, $user) { $xuser = $xml->addChild('user'); $xuser->addAttribute('username', $user->username); $xuser->addAttribute('email', $user->email); $xuser->addAttribute('scrobblingEnabled', 'true'); $isManager = $user->access >= 75; $isAdmin = $user->access >= 100; $xuser->addAttribute('adminRole', $isAdmin ? 'true' : 'false'); $xuser->addAttribute('settingsRole', 'true'); $xuser->addAttribute('downloadRole', Preference::get_by_user($user->id, 'download') ? 'true' : 'false'); $xuser->addAttribute('playlistRole', 'true'); $xuser->addAttribute('coverArtRole', $isManager ? 'true' : 'false'); $xuser->addAttribute('commentRole', 'false'); $xuser->addAttribute('podcastRole', 'false'); $xuser->addAttribute('streamRole', 'true'); $xuser->addAttribute('jukeboxRole', 'false'); $xuser->addAttribute('shareRole', Preference::get_by_user($user->id, 'share') ? 'true' : 'false'); }
/** * timeline * This get an user timeline * @param array $input */ public static function timeline($input) { if (AmpConfig::get('sociable')) { $username = $input['username']; $limit = intval($input['limit']); $since = intval($input['since']); if (!empty($username)) { $user = User::get_from_username($username); if ($user !== null) { if (Preference::get_by_user($user->id, 'allow_personal_info_recent')) { $activities = Useractivity::get_activities($user->id, $limit, $since); ob_end_clean(); echo XML_Data::timeline($activities); } } } else { debug_event('api', 'Username required on timeline function call.', 1); } } else { debug_event('api', 'Sociable feature is not enabled.', 3); } }