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 $profilephoto = $a->get_cached_avatar_image($a->get_baseurl() . '/photo/profile/' . $a->data['user']['uid'] . '.jpg');
33 $tpl = get_markup_template("vcard-widget.tpl");
35 $vcard_widget = replace_macros($tpl, array(
36 '$name' => $a->data['user']['username'],
37 '$photo' => $profilephoto
41 /*$sql_extra = permissions_sql($a->data['user']['uid']);
43 $albums = q("SELECT distinct(`album`) AS `album` FROM `photo` WHERE `uid` = %d $sql_extra order by created desc",
44 intval($a->data['user']['uid'])
48 $a->data['albums'] = $albums;
50 $albums_visible = ((intval($a->data['user']['hidewall']) && (! local_user()) && (! remote_user())) ? false : true);
53 $o .= '<div id="side-bar-photos-albums" class="widget">';
54 $o .= '<h3>' . '<a href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '">' . t('Photo Albums') . '</a></h3>';
57 foreach($albums as $album) {
59 // don't show contact photos. We once translated this name, but then you could still access it under
60 // a different language setting. Now we store the name in English and check in English (and translated for legacy albums).
62 if((! strlen($album['album'])) || ($album['album'] === 'Contact Photos') || ($album['album'] === t('Contact Photos')))
64 $o .= '<li>' . '<a href="photos/' . $a->argv[1] . '/album/' . bin2hex($album['album']) . '" >' . $album['album'] . '</a></li>';
68 if(local_user() && $a->data['user']['uid'] == local_user()) {
69 $o .= '<div id="photo-albums-upload-link"><a href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/upload" >' .t('Upload New Photos') . '</a></div>';
75 if(! x($a->page,'aside'))
76 $a->page['aside'] = '';
77 $a->page['aside'] .= $vcard_widget;
80 $tpl = get_markup_template("videos_head.tpl");
81 $a->page['htmlhead'] .= replace_macros($tpl,array(
82 '$baseurl' => $a->get_baseurl(),
85 $tpl = get_markup_template("videos_end.tpl");
86 $a->page['end'] .= replace_macros($tpl,array(
87 '$baseurl' => $a->get_baseurl(),
97 function videos_post(&$a) {
101 // DELETED -- look at mod/photos.php if you want to implement
106 function videos_content(&$a) {
108 // URLs (most aren't currently implemented):
110 // videos/name/upload
111 // videos/name/upload/xxxxx (xxxxx is album name)
112 // videos/name/album/xxxxx
113 // videos/name/album/xxxxx/edit
114 // videos/name/video/xxxxx
115 // videos/name/video/xxxxx/edit
118 if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
119 notice( t('Public access denied.') . EOL);
124 require_once('include/bbcode.php');
125 require_once('include/security.php');
126 require_once('include/conversation.php');
128 if(! x($a->data,'user')) {
129 notice( t('No videos selected') . EOL );
133 //$phototypes = Photo::supportedTypes();
135 $_SESSION['video_return'] = $a->cmd;
142 $datatype = $a->argv[2];
143 $datum = $a->argv[3];
145 elseif(($a->argc > 2) && ($a->argv[2] === 'upload'))
146 $datatype = 'upload';
148 $datatype = 'summary';
156 // Setup permissions structures
162 $remote_contact = false;
165 $owner_uid = $a->data['user']['uid'];
167 $community_page = (($a->data['user']['page-flags'] == PAGE_COMMUNITY) ? true : false);
169 if((local_user()) && (local_user() == $owner_uid))
172 if($community_page && remote_user()) {
173 if(is_array($_SESSION['remote'])) {
174 foreach($_SESSION['remote'] as $v) {
175 if($v['uid'] == $owner_uid) {
176 $contact_id = $v['cid'];
183 $r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
190 $remote_contact = true;
197 // perhaps they're visiting - but not a community page, so they wouldn't have write access
199 if(remote_user() && (! $visitor)) {
201 if(is_array($_SESSION['remote'])) {
202 foreach($_SESSION['remote'] as $v) {
203 if($v['uid'] == $owner_uid) {
204 $contact_id = $v['cid'];
210 $groups = init_groups_visitor($contact_id);
211 $r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
217 $remote_contact = true;
222 if(! $remote_contact) {
224 $contact_id = $_SESSION['cid'];
225 $contact = $a->contact;
229 if($a->data['user']['hidewall'] && (local_user() != $owner_uid) && (! $remote_contact)) {
230 notice( t('Access to this item is restricted.') . EOL);
234 $sql_extra = permissions_sql($owner_uid,$remote_contact,$groups);
239 $_is_owner = (local_user() && (local_user() == $owner_uid));
240 $o .= profile_tabs($a,$_is_owner, $a->data['user']['nickname']);
247 if($datatype === 'upload') {
248 return; // no uploading for now
250 // DELETED -- look at mod/photos.php if you want to implement
253 if($datatype === 'album') {
255 return; // no albums for now
257 // DELETED -- look at mod/photos.php if you want to implement
261 if($datatype === 'video') {
263 return; // no single video view for now
265 // DELETED -- look at mod/photos.php if you want to implement
268 // Default - show recent videos (no upload link for now)
271 $r = q("SELECT hash FROM `attach` WHERE `uid` = %d AND filetype LIKE '%%video%%'
272 $sql_extra GROUP BY hash",
273 intval($a->data['user']['uid'])
276 $a->set_pager_total(count($r));
277 $a->set_pager_itemspage(20);
280 $r = q("SELECT hash, `id`, `filename`, filetype FROM `attach`
281 WHERE `uid` = %d AND filetype LIKE '%%video%%'
282 $sql_extra GROUP BY hash ORDER BY `created` DESC LIMIT %d , %d",
283 intval($a->data['user']['uid']),
284 intval($a->pager['start']),
285 intval($a->pager['itemspage'])
293 if($a->theme['template_engine'] === 'internal') {
294 $alt_e = template_escape($rr['filename']);
295 $name_e = template_escape($rr['album']);
298 $alt_e = $rr['filename'];
299 $name_e = $rr['album'];
304 'link' => $a->get_baseurl() . '/videos/' . $a->data['user']['nickname'] . '/video/' . $rr['resource-id'],
305 'title' => t('View Video'),
306 'src' => $a->get_baseurl() . '/attach/' . $rr['id'] . '?attachment=0',
308 'mime' => $rr['filetype'],
310 'link' => $a->get_baseurl() . '/videos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($rr['album']),
312 'alt' => t('View Album'),
319 $tpl = get_markup_template('videos_recent.tpl');
320 $o .= replace_macros($tpl, array(
321 '$title' => t('Recent Videos'),
322 '$can_post' => $can_post,
323 '$upload' => array(t('Upload New Videos'), $a->get_baseurl().'/videos/'.$a->data['user']['nickname'].'/upload'),
324 '$videos' => $videos,