<?php /** * iZAP izap_videos * * @package Elgg videotizer, by iZAP Web Solutions. * @license GNU Public License version 3 * @Contact iZAP Team "<*****@*****.**>" * @Founder Tarun Jangra "<*****@*****.**>" * @link http://www.izap.in/ * */ gatekeeper(); $user_guid = get_loggedin_userid(); $video = get_entity(get_input('guid', 0)); if (get_input('izap_action', FALSE) == 'remove') { izap_remove_favorited($video); system_message(elgg_echo('izap_videos:favorite_removed')); } else { if ($video instanceof IzapVideos) { izapGetAccess_izap_videos(); $old_array = $video->favorited_by; $new_array = array_merge((array) $old_array, (array) $user_guid); $video->favorited_by = array_unique($new_array); izapRemoveAccess_izap_videos(); system_message(elgg_echo('izap_videos:favorite_saved')); } } forward($_SERVER['HTTP_REFERER']); exit;
/** * Updates the video views */ public function updateViews() { if ($this->converted == 'yes') { izapGetAccess_izap_videos(); $this->views = (int) $this->views + 1; izapRemoveAccess_izap_videos(); } }
function izap_remove_favorited($video, $user_guid = 0) { $users = (array) $video->favorited_by; if (!$user_guid) { $user_guid = elgg_get_logged_in_user_guid(); } $key = array_search($user_guid, $users); if ($key !== false) { unset($users[$key]); } izapGetAccess_izap_videos(); $video->favorited_by = array_unique($users); izapRemoveAccess_izap_videos(); return true; }