/** * @param $channel Channel ID or channel object * @return array of User */ public static function getSubscribersFromChannel($channel) { if (!$channel instanceof UserChannel) { $channel = UserChannel::find($channel); } return $channel->subscribed_users; }
public function getMemberChannelsName() { $names = array(); $membersStr = $this->members_ids; if ($this->isTicketConv()) { $tech_channel = $this->getTechChannel(); $tech_user = $this->getTechUser(); } if (Utils::stringStartsWith($membersStr, ';')) { $membersStr = substr_replace($membersStr, '', 0, 1); } if (Utils::stringEndsWith($membersStr, ';')) { $membersStr = substr_replace($membersStr, '', -1); } if (strpos($membersStr, ';') !== false) { $membersIds = explode(';', $membersStr); foreach ($membersIds as $memberId) { if (UserChannel::exists($memberId)) { if (isset($tech_channel) && $tech_channel->id == $memberId) { $names[] = StaffContact::getShownName($tech_user); } else { $names[] = UserChannel::find($memberId)->name; } } } } return $names; }
public function subscription($subscriptionId) { $subscription = UserChannel::exists($subscriptionId) ? UserChannel::find($subscriptionId) : UserChannel::find_by_name($subscriptionId); if (is_object($subscription) && !$subscription->belongToUser(Session::get()->id)) { $data = array(); $data['subscriptions'] = Session::get()->getSubscribedChannels(); $data['vids'] = Session::get()->getSubscriptionsVideosFromChannel($subscription->id, 6); return new ViewResponse('feed/feed', $data); } }
public function update($id, $request) { $data = $request->getParameters(); $channel = UserChannel::find($id); $channel->verified = $data['verified']; $channel->description = $data['description']; $channel->save(); $data['channel'] = $channel; $data['channel_admin'] = User::find($channel->owner_id); $r = new ViewResponse('admin/channel/edit', $data); $r->addMessage(ViewMessage::success("Chaîne modifiée")); return $r; }
public static function sendNew($sender, $conversation, $content, $timeOffset = 0) { $id = Message::generateId(6); $timestamp = Utils::tps() + $timeOffset; $message = Message::create(array('id' => $id, 'sender_id' => $sender, 'conversation_id' => $conversation, 'content' => $content, 'timestamp' => $timestamp)); $recep = array(); $members = explode(';', trim(Conversation::find($conversation)->members_ids, ';')); foreach ($members as $id) { if ($id != $sender) { $recep[] = trim(UserChannel::find($id)->admins_ids, ';'); } } $recep = ';' . implode(';', $recep) . ';'; $recep = ChannelAction::filterReceiver($recep, "pm"); ChannelAction::create(array('id' => ChannelAction::generateId(6), 'channel_id' => userChannel::find($sender)->id, 'recipients_ids' => $recep, 'type' => 'pm', 'target' => $conversation, 'timestamp' => $timestamp)); return $message; }
public function chat($id, $request) { if (UserChannel::exists(array('name' => $id))) { $data = []; $channel = UserChannel::find(['name' => $id]); $data['channel'] = $channel; $access = LiveAccess::find(array('channel_id' => $channel->id)); if (is_object($access)) { $data['viewers'] = $access->viewers; } else { $data['viewers'] = 0; } return new ViewResponse('embed/chat', $data, false); } else { return Utils::getNotFoundResponse(); } }
public function get($id, $request) { if (UserChannel::find($id)->belongToUser(Session::get()->id)) { $uploadId = Upload::generateId(6); Upload::create(array('id' => $uploadId, 'channel_id' => $id, 'video_id' => Video::generateId(6), 'expire' => Utils::tps() + 86400)); $data = array(); $data['currentPageTitle'] = 'Mettre en ligne'; $data['uploadId'] = $uploadId; $data['thumbnail'] = Config::getValue_('default-thumbnail'); $data['channelId'] = $id; $data['currentPage'] = 'upload'; //$data['predefined_descriptions'] = PredefinedDescription::getDescriptionByChannelsids($id); return new ViewResponse('upload/upload', $data); } else { return new RedirectResponse(WEBROOT . 'upload'); } }
public function create($request) { if (Session::isActive()) { $req = $request->getParameters(); Session::get()->last_visit = Utils::tps(); Session::get()->save(); if (isset($req['sender'], $req['conversation'], $req['content']) && !empty($req['conversation']) && !empty($req['sender']) && !empty($req['content'])) { $sender = Utils::secure($req['sender']); $conversation = Utils::secure($req['conversation']); $content = Utils::secure($req['content']); $channel = UserChannel::exists($sender) ? UserChannel::find($sender) : false; if ($channel && $channel->belongToUser(Session::get()->id) && ($conv = Conversation::find($conversation))) { if (!$conv->containsChannel($channel)) { return Utils::getUnauthorizedResponse(); } $message = Message::sendNew($sender, $conversation, $content); $messageData = array('id' => $message->id, 'avatar' => $channel->getAvatar(), 'pseudo' => $channel->name, 'text' => $content, 'mine' => 'true'); return new JsonResponse($messageData); } } } return new Response(500); }
public function channel($id, $request) { if (Session::isActive() && ($channel = UserChannel::find($id)) && $channel->belongToUser(Session::get()->id)) { if ($request->acceptsJson()) { $conversations = Conversation::getByChannel($channel); $conversationsData = array(); foreach ($conversations as $conv) { $conversationsData[] = array('id' => $conv->id, 'title' => $conv->object, 'members' => $conv->getMemberChannelsName(), 'avatar' => $conv->getThumbnail(), 'text' => $conv->getLastMessage() ? $conv->getLastMessage()->content : 'Aucun message'); } return new JsonResponse($conversationsData); } } else { return Utils::getUnauthorizedResponse(); } return new Response(500); }
public function destroy($id, $request) { if (Session::isActive() && UserChannel::find(Playlist::find($id)->channel_id)->belongToUser(Session::get()->id)) { Playlist::find($id)->delete(); Playlist::delete_all(array('conditions' => 'id = ?'), $id); return new Response(200); } else { ob_clean(); return new Response(500); } }
function displayComments($video, $parent, $i) { $comments = $video->getComments($parent); if (empty($comments)) { ?> <p>Aucun commentaire à propos de cette video</p> <?php } foreach ($comments as $comment) { $comment->comment = Utils::makeLinks(Utils::secure($comment->comment)); $margin = $i * 8; ?> <div style="width: <?php echo 100 - $margin; ?> %; margin-left:<?php echo $margin; ?> %" class="comment" id="c-<?php echo $comment->id; ?> "> <div class="comment-head"> <div class="user"> <img src="<?php echo UserChannel::find($comment->poster_id)->getAvatar(); ?> " alt="[Avatar]"> <a href="<?php echo WEBROOT . 'channel/' . UserChannel::find($comment->poster_id)->name; ?> "><?php echo UserChannel::getNameById($comment->poster_id); ?> </a> </div> <div class="date"> <p><?php echo Utils::relative_time($comment->timestamp); echo $comment->last_updated_timestamp ? ' (Edité ' . Utils::relative_time($comment->last_updated_timestamp) . ')' : ''; ?> </p> </div> </div> <div class="comment-text"> <p style="word-wrap:break-word"><?php echo $comment->comment; ?> </p> </div> <div class="comment-notation"> <ul> <li class="plus" id="plus-<?php echo $comment->id; ?> " onclick="likeComment('<?php echo $comment->id; ?> ')">+<?php echo $comment->likes; ?> </li> <li class="moins" id="moins-<?php echo $comment->id; ?> " onclick="dislikeComment('<?php echo $comment->id; ?> ')">-<?php echo $comment->dislikes; ?> </li> <li onclick="reportComment('<?php echo $comment->id; ?> ', this)" style="cursor:pointer">Signaler</li> <li onclick="document.location.href='#comments';document.getElementById('response').innerHTML='<b>Répondre à <?php echo UserChannel::getNameById($comment->poster_id); ?> :</b>';document.getElementById('textarea-comment').focus();document.getElementById('parent-comment').value='<?php echo $comment->id; ?> ';" style="cursor:pointer">Répondre</li> <?php if (Session::isActive() && (Session::get()->isModerator() || Session::get()->isAdmin() || $comment->getAuthor()->belongToUser(Session::get()->id))) { ?> <li onclick="editComment('<?php echo $comment->id; ?> ', this)" style="cursor:pointer">Editer</li> <?php } ?> <?php if (Session::isActive() && (Session::get()->isModerator() || Session::get()->isAdmin() || $video->getAuthor()->belongToUser(Session::get()->id) || $comment->getAuthor()->belongToUser(Session::get()->id))) { ?> <li onclick="deleteComment('<?php echo $comment->id; ?> ', this)" style="cursor:pointer">Supprimer</li> <?php } ?> </ul> </div> </div> <?php if (Comment::count(array('conditions' => array('parent = ?', $comment->id))) >= 1) { displayComments($video, $comment->id, $i + 1); } } }
public function videos($id, $request) { if (Session::isActive() && UserChannel::find($id)->belongToUser(Session::get()->id)) { $data['videos'] = UserChannel::find($id)->getPostedVideos(false); $data['currentPageTitle'] = 'Mon compte'; $data['current'] = 'videos'; $response = new ViewResponse('account/videos', $data); if (empty($data['videos'])) { $response->addMessage(ViewMessage::error('Vous n\'avez posté aucune vidéo')); } return $response; } else { return new RedirectResponse(Utils::generateLoginURL()); } }
<div class="content"> <aside class="full-cards-list"> <h3 class="title">Lives en cours</h3> <?php if (count($lives) > 0) { foreach ($lives as $live) { $channel = UserChannel::find($live->channel_id); ?> <div class="card video card--live"> <div class="thumbnail bg-loader" data-background-load-in-view data-background="<?php echo $channel->avatar; ?> "> <a href="<?php echo WEBROOT . 'lives/' . $channel->name; ?> " class="overlay"></a> </div> <div class="description"> <a href="<?php echo WEBROOT . 'lives/' . $channel->name; ?> "><h4>Live de <?php echo $channel->name; ?> </h4></a> <div> <span class="view"><?php echo $live->viewers; ?>
public function dislike($userId) { $voteId = VideoVote::generateId(6); VideoVote::create(array('id' => $voteId, 'user_id' => $userId, 'type' => 'video', 'obj_id' => $this->id, 'action' => 'dislike')); $this->dislikes++; $this->save(); ChannelAction::create(array('id' => ChannelAction::generateId(6), 'channel_id' => User::find($userId)->getMainChannel()->id, 'recipients_ids' => ChannelAction::filterReceiver(UserChannel::find($this->poster_id)->admins_ids, "dislike"), 'type' => 'dislike', 'target' => $this->id, 'timestamp' => Utils::tps())); }
public function getChannel() { return UserChannel::find($this->channel_id); }
<div id="upload-large-modal"> <div class="bg-loader" id="backgroundLoader" data-background="<?php echo UserChannel::find($channelId)->getBackground(); ?> "></div> <section id="message-upload"> <h3>Déposez votre fichier vidéo dans cette zone pour l'uploader</h3> <p>(Ou selectionnez votre fichier manuellement en cliquant sur le nuage)</p> </section> <section id="uploader"> <span id="upload-illustration"> <span class="cloud"> <span id="arrowUpload" data-uploaded-message="Uploaded"></span> </span> </span> <input id="upload-input" type="file" name="video" accept="video/*"> <div id="file-name"></div> </section> <div id="progress-upload"> <div id="progress-bar"></div> </div> </div> <div id="upload-content"> <form id="upload-form" class="form middle" method="post" action="<?php echo WEBROOT . 'videos'; ?> " enctype="multipart/form-data">
public function destroy($id, $request) { if (Session::isActive()) { $user = Session::get(); if (ChannelPost::exists($id)) { $post = ChannelPost::find($id); if (UserChannel::find($post->channel_id) && UserChannel::find($post->channel_id)->belongToUser($user->id)) { $post->erase(); } } } return new Response(200); }
<?php if ($action->infos['nb_subscription'] <= 1) { ?> <a href="<?php echo WEBROOT . 'channel/' . $channel_action->name; ?> "> <div class="avatar bg-loader" data-background-load-in-view data-background="<?php echo $channel_action->getBackground(); ?> "></div> <p><b><?php echo Utils::secure($channel_action->name); ?> </b> s'est abonné à votre chaîne "<b><?php echo Utils::secure(UserChannel::find($action->target)->name); ?> </b>"</p> <?php } else { ?> <a href="<?php echo WEBROOT . 'channel/' . $target_channel->name; ?> "> <div class="avatar bg-loader" data-background-load-in-view data-background="<?php echo $target_channel->getBackground(); ?> "></div> <p><b><?php echo $action->infos['nb_subscription'];
</thead> <tbody> <?php foreach ($videos as $vid) { ?> <tr> <td><a href="<?php echo WEBROOT . 'watch/' . $vid->id; ?> "><?php echo $vid->title; ?> </a></td> <td><?php echo UserChannel::find($vid->poster_id)->name; ?> </td> <td><?php echo number_format($vid->views); ?> </td> <td><?php echo $vid->likes; ?> </td> <td><?php echo $vid->dislikes; ?> </td> <td>
public function video($id, $request) { $video = Video::exists($id) ? Video::find($id) : false; if (!$request->acceptsJson()) { return new RedirectResponse(WEBROOT . 'watch/' . $id); } if (is_object($video)) { $comments = $video->getComments(); $commentsData = array(); foreach ($comments as $comment) { $commentsData[] = array('id' => $comment->id, 'author' => UserChannel::find($comment->poster_id)->name, 'video_id' => $comment->video_id, 'comment' => $comment->comment, 'relativeTime' => Utils::relative_time($comment->timestamp), 'timestamp' => $comment->timestamp, 'likes' => $comment->likes, 'dislikes' => $comment->dislikes); } return new JsonResponse($commentsData); } return new Response(500); }
public static function edit($channelId, $name, $descr, $admins_ids, $avatar, $background) { $chann = UserChannel::find($channelId); $avatar = Utils::upload($avatar, 'img', 'avatar', $channelId, $chann->getAvatar()); $background = Utils::upload($background, 'img', 'background', $channelId, $chann->getBackground()); $chann->name = $name; $chann->description = $descr; $chann->admins_ids = $admins_ids; $chann->avatar = $avatar; $chann->background = $background; $chann->save(); }
public function edit($id, $request) { if (Session::isActive()) { $channel = UserChannel::exists($id) ? UserChannel::find($id) : UserChannel::find_by_name($id); if (!$channel->belongToUser(Session::get()->id)) { return Utils::getForbiddenResponse(); } if (is_object($channel)) { $data = array(); $data['currentPage'] = 'channel'; $data['current'] = 'channels'; $data['currentPageTitle'] = $channel->name . ' - Edition'; $data['id'] = $channel->id; $data['mainChannel'] = $channel->isUsersMainChannel(Session::get()->id); $data['owner_id'] = $channel->owner_id; $data['name'] = $channel->name; $data['description'] = $channel->description; $data['avatar'] = $channel->getAvatar(); $data['background'] = $channel->getBackground(); $admins = explode(';', trim($channel->admins_ids, ';')); $data['admins_ids'] = $admins; $data['admins'] = array(); foreach ($admins as $adm) { $data['admins'][] = User::find_by_id($adm)->getMainChannel(); } return new ViewResponse('channel/edit', $data); } else { return Utils::getNotFoundResponse(); } } else { return new RedirectResponse(Utils::generateLoginURL()); } }
public function edit($id, $request) { if (Session::isActive() && UserChannel::find(Video::find($id)->poster_id)->belongToUser(Session::get()->id)) { if ($video = Video::find($id)) { $data = array(); $data['currentPageTitle'] = $video->title . ' - Modification'; $data['video'] = $video; return new ViewResponse('video/edit', $data); } else { return new RedirectResponse(WEBROOT . 'account/videos'); } } else { return new RedirectResponse(Utils::generateLoginURL()); } }
public function viewers($id, $request) { if (UserChannel::exists($id)) { $channel_id = $id; } elseif (UserChannel::exists(array('name' => $id))) { $channel_id = UserChannel::find(array('name' => $id))->id; } else { return Utils::getNotFoundResponse(); } return new JsonResponse(array(LiveAccess::find(array('channel_id' => $channel_id))->viewers)); }
public static function postNew($authorId, $videoId, $commentContent, $parent) { $timestamp = Utils::tps(); $poster_channel = UserChannel::find(Video::find($videoId)->poster_id); $admins_ids = $poster_channel->admins_ids; $admins_ids = ChannelAction::filterReceiver($admins_ids, "comment"); $admin_ids_array = $poster_channel->getArrayAdminsIds($admins_ids); foreach ($admin_ids_array as $k => $value) { if ($value == Session::get()->id) { unset($admin_ids_array[$k]); break; } } $recipients_ids = ';' . trim(implode(';', $admin_ids_array), ';') . ';'; $comment = Comment::create(array('id' => Comment::generateId(6), 'poster_id' => $authorId, 'video_id' => $videoId, 'comment' => $commentContent, 'likes' => 0, 'dislikes' => 0, 'timestamp' => $timestamp, 'parent' => $parent)); ChannelAction::create(array('id' => ChannelAction::generateId(6), 'channel_id' => $authorId, 'recipients_ids' => $recipients_ids, 'type' => 'comment', 'target' => $videoId, 'complementary_id' => $comment->id, 'timestamp' => $timestamp)); return $comment; }
public static function getVideoCardHTML($vid, $card_new = "") { return '<div class="card video' . $card_new . '"> <div class="thumbnail bg-loader" data-background-load-in-view data-background="' . $vid->getThumbnail() . '"> <div class="time">' . self::sec2ms($vid->duration) . '</div> <a href="' . WEBROOT . 'watch/' . $vid->id . '" class="overlay"></a> </div> <div class="description"> <a href="' . WEBROOT . 'watch/' . $vid->id . '"><h4>' . $vid->title . '</h4></a> <div> <span class="view">' . number_format($vid->views) . '</span> <a class="channel" href="' . WEBROOT . 'channel/' . UserChannel::find($vid->poster_id)->name . '">' . UserChannel::getNameById($vid->poster_id) . '</a> </div> </div> </div>'; }