2 require_once('include/items.php');
3 require_once('include/acl_selectors.php');
4 require_once('include/bbcode.php');
5 require_once('include/security.php');
6 require_once('include/redir.php');
9 function videos_init(&$a) {
12 auto_redir($a, $a->argv[1]);
14 if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
22 $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1",
29 $a->data['user'] = $r[0];
31 $o .= '<div class="vcard">';
32 $o .= '<div class="fn">' . $a->data['user']['username'] . '</div>';
33 $o .= '<div id="profile-photo-wrapper"><img class="photo" style="width: 175px; height: 175px;" src="' . $a->get_cached_avatar_image($a->get_baseurl() . '/photo/profile/' . $a->data['user']['uid'] . '.jpg') . '" alt="' . $a->data['user']['username'] . '" /></div>';
37 /*$sql_extra = permissions_sql($a->data['user']['uid']);
39 $albums = q("SELECT distinct(`album`) AS `album` FROM `photo` WHERE `uid` = %d $sql_extra order by created desc",
40 intval($a->data['user']['uid'])
44 $a->data['albums'] = $albums;
46 $albums_visible = ((intval($a->data['user']['hidewall']) && (! local_user()) && (! remote_user())) ? false : true);
49 $o .= '<div id="side-bar-photos-albums" class="widget">';
50 $o .= '<h3>' . '<a href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '">' . t('Photo Albums') . '</a></h3>';
53 foreach($albums as $album) {
55 // don't show contact photos. We once translated this name, but then you could still access it under
56 // a different language setting. Now we store the name in English and check in English (and translated for legacy albums).
58 if((! strlen($album['album'])) || ($album['album'] === 'Contact Photos') || ($album['album'] === t('Contact Photos')))
60 $o .= '<li>' . '<a href="photos/' . $a->argv[1] . '/album/' . bin2hex($album['album']) . '" >' . $album['album'] . '</a></li>';
64 if(local_user() && $a->data['user']['uid'] == local_user()) {
65 $o .= '<div id="photo-albums-upload-link"><a href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/upload" >' .t('Upload New Photos') . '</a></div>';
71 if(! x($a->page,'aside'))
72 $a->page['aside'] = '';
73 $a->page['aside'] .= $o;
76 $tpl = get_markup_template("videos_head.tpl");
77 $a->page['htmlhead'] .= replace_macros($tpl,array(
78 '$baseurl' => $a->get_baseurl(),
81 $tpl = get_markup_template("videos_end.tpl");
82 $a->page['end'] .= replace_macros($tpl,array(
83 '$baseurl' => $a->get_baseurl(),
93 function videos_post(&$a) {
97 // DELETED -- look at mod/photos.php if you want to implement
102 function videos_content(&$a) {
104 // URLs (most aren't currently implemented):
106 // videos/name/upload
107 // videos/name/upload/xxxxx (xxxxx is album name)
108 // videos/name/album/xxxxx
109 // videos/name/album/xxxxx/edit
110 // videos/name/video/xxxxx
111 // videos/name/video/xxxxx/edit
114 if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
115 notice( t('Public access denied.') . EOL);
120 require_once('include/bbcode.php');
121 require_once('include/security.php');
122 require_once('include/conversation.php');
124 if(! x($a->data,'user')) {
125 notice( t('No videos selected') . EOL );
129 //$phototypes = Photo::supportedTypes();
131 $_SESSION['video_return'] = $a->cmd;
138 $datatype = $a->argv[2];
139 $datum = $a->argv[3];
141 elseif(($a->argc > 2) && ($a->argv[2] === 'upload'))
142 $datatype = 'upload';
144 $datatype = 'summary';
152 // Setup permissions structures
158 $remote_contact = false;
161 $owner_uid = $a->data['user']['uid'];
163 $community_page = (($a->data['user']['page-flags'] == PAGE_COMMUNITY) ? true : false);
165 if((local_user()) && (local_user() == $owner_uid))
168 if($community_page && remote_user()) {
169 if(is_array($_SESSION['remote'])) {
170 foreach($_SESSION['remote'] as $v) {
171 if($v['uid'] == $owner_uid) {
172 $contact_id = $v['cid'];
179 $r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
186 $remote_contact = true;
193 // perhaps they're visiting - but not a community page, so they wouldn't have write access
195 if(remote_user() && (! $visitor)) {
197 if(is_array($_SESSION['remote'])) {
198 foreach($_SESSION['remote'] as $v) {
199 if($v['uid'] == $owner_uid) {
200 $contact_id = $v['cid'];
206 $groups = init_groups_visitor($contact_id);
207 $r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
213 $remote_contact = true;
218 if(! $remote_contact) {
220 $contact_id = $_SESSION['cid'];
221 $contact = $a->contact;
225 if($a->data['user']['hidewall'] && (local_user() != $owner_uid) && (! $remote_contact)) {
226 notice( t('Access to this item is restricted.') . EOL);
230 $sql_extra = permissions_sql($owner_uid,$remote_contact,$groups);
235 $_is_owner = (local_user() && (local_user() == $owner_uid));
236 $o .= profile_tabs($a,$_is_owner, $a->data['user']['nickname']);
243 if($datatype === 'upload') {
244 return; // no uploading for now
246 // DELETED -- look at mod/photos.php if you want to implement
249 if($datatype === 'album') {
251 return; // no albums for now
253 // DELETED -- look at mod/photos.php if you want to implement
257 if($datatype === 'video') {
259 return; // no single video view for now
261 // DELETED -- look at mod/photos.php if you want to implement
264 // Default - show recent videos (no upload link for now)
267 $r = q("SELECT hash FROM `attach` WHERE `uid` = %d AND filetype LIKE '%%video%%'
268 $sql_extra GROUP BY hash",
269 intval($a->data['user']['uid'])
272 $a->set_pager_total(count($r));
273 $a->set_pager_itemspage(20);
276 $r = q("SELECT hash, `id`, `filename`, filetype FROM `attach`
277 WHERE `uid` = %d AND filetype LIKE '%%video%%'
278 $sql_extra GROUP BY hash ORDER BY `created` DESC LIMIT %d , %d",
279 intval($a->data['user']['uid']),
280 intval($a->pager['start']),
281 intval($a->pager['itemspage'])
289 if($a->theme['template_engine'] === 'internal') {
290 $alt_e = template_escape($rr['filename']);
291 $name_e = template_escape($rr['album']);
294 $alt_e = $rr['filename'];
295 $name_e = $rr['album'];
300 'link' => $a->get_baseurl() . '/videos/' . $a->data['user']['nickname'] . '/video/' . $rr['resource-id'],
301 'title' => t('View Video'),
302 'src' => $a->get_baseurl() . '/attach/' . $rr['id'] . '?attachment=0',
304 'mime' => $rr['filetype'],
306 'link' => $a->get_baseurl() . '/videos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($rr['album']),
308 'alt' => t('View Album'),
315 $tpl = get_markup_template('videos_recent.tpl');
316 $o .= replace_macros($tpl, array(
317 '$title' => t('Recent Videos'),
318 '$can_post' => $can_post,
319 '$upload' => array(t('Upload New Videos'), $a->get_baseurl().'/videos/'.$a->data['user']['nickname'].'/upload'),
320 '$videos' => $videos,