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());
79 $tpl = get_markup_template("videos_end.tpl");
80 $a->page['end'] .= replace_macros($tpl,array());
89 function videos_post(&$a) {
93 // DELETED -- look at mod/photos.php if you want to implement
98 function videos_content(&$a) {
100 // URLs (most aren't currently implemented):
102 // videos/name/upload
103 // videos/name/upload/xxxxx (xxxxx is album name)
104 // videos/name/album/xxxxx
105 // videos/name/album/xxxxx/edit
106 // videos/name/video/xxxxx
107 // videos/name/video/xxxxx/edit
110 if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
111 notice( t('Public access denied.') . EOL);
116 require_once('include/bbcode.php');
117 require_once('include/security.php');
118 require_once('include/conversation.php');
120 if(! x($a->data,'user')) {
121 notice( t('No videos selected') . EOL );
125 //$phototypes = Photo::supportedTypes();
127 $_SESSION['video_return'] = $a->cmd;
134 $datatype = $a->argv[2];
135 $datum = $a->argv[3];
137 elseif(($a->argc > 2) && ($a->argv[2] === 'upload'))
138 $datatype = 'upload';
140 $datatype = 'summary';
148 // Setup permissions structures
154 $remote_contact = false;
157 $owner_uid = $a->data['user']['uid'];
159 $community_page = (($a->data['user']['page-flags'] == PAGE_COMMUNITY) ? true : false);
161 if((local_user()) && (local_user() == $owner_uid))
164 if($community_page && remote_user()) {
165 if(is_array($_SESSION['remote'])) {
166 foreach($_SESSION['remote'] as $v) {
167 if($v['uid'] == $owner_uid) {
168 $contact_id = $v['cid'];
175 $r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
182 $remote_contact = true;
189 // perhaps they're visiting - but not a community page, so they wouldn't have write access
191 if(remote_user() && (! $visitor)) {
193 if(is_array($_SESSION['remote'])) {
194 foreach($_SESSION['remote'] as $v) {
195 if($v['uid'] == $owner_uid) {
196 $contact_id = $v['cid'];
202 $groups = init_groups_visitor($contact_id);
203 $r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
209 $remote_contact = true;
214 if(! $remote_contact) {
216 $contact_id = $_SESSION['cid'];
217 $contact = $a->contact;
221 if($a->data['user']['hidewall'] && (local_user() != $owner_uid) && (! $remote_contact)) {
222 notice( t('Access to this item is restricted.') . EOL);
226 $sql_extra = permissions_sql($owner_uid,$remote_contact,$groups);
231 $_is_owner = (local_user() && (local_user() == $owner_uid));
232 $o .= profile_tabs($a,$_is_owner, $a->data['user']['nickname']);
239 if($datatype === 'upload') {
240 return; // no uploading for now
242 // DELETED -- look at mod/photos.php if you want to implement
245 if($datatype === 'album') {
247 return; // no albums for now
249 // DELETED -- look at mod/photos.php if you want to implement
253 if($datatype === 'video') {
255 return; // no single video view for now
257 // DELETED -- look at mod/photos.php if you want to implement
260 // Default - show recent videos (no upload link for now)
263 $r = q("SELECT hash FROM `attach` WHERE `uid` = %d AND filetype LIKE '%%video%%'
264 $sql_extra GROUP BY hash",
265 intval($a->data['user']['uid'])
268 $a->set_pager_total(count($r));
269 $a->set_pager_itemspage(20);
272 $r = q("SELECT hash, `id`, `filename`, filetype FROM `attach`
273 WHERE `uid` = %d AND filetype LIKE '%%video%%'
274 $sql_extra GROUP BY hash ORDER BY `created` DESC LIMIT %d , %d",
275 intval($a->data['user']['uid']),
276 intval($a->pager['start']),
277 intval($a->pager['itemspage'])
285 if($a->theme['template_engine'] === 'internal') {
286 $alt_e = template_escape($rr['filename']);
287 $name_e = template_escape($rr['album']);
290 $alt_e = $rr['filename'];
291 $name_e = $rr['album'];
296 'link' => $a->get_baseurl() . '/videos/' . $a->data['user']['nickname'] . '/video/' . $rr['resource-id'],
297 'title' => t('View Video'),
298 'src' => $a->get_baseurl() . '/attach/' . $rr['id'] . '?attachment=0',
300 'mime' => $rr['filetype'],
302 'link' => $a->get_baseurl() . '/videos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($rr['album']),
304 'alt' => t('View Album'),
311 $tpl = get_markup_template('videos_recent.tpl');
312 $o .= replace_macros($tpl, array(
313 '$title' => t('Recent Videos'),
314 '$can_post' => $can_post,
315 '$upload' => array(t('Upload New Videos'), $a->get_baseurl().'/videos/'.$a->data['user']['nickname'].'/upload'),
316 '$videos' => $videos,