/** * Adds an asset to the list of all watched assets. * @param type $user * @param type $album * @param type $asset * @return boolean */ function user_prefs_watched_add($user, $album, $asset) { // Sanity check if (!isset($user) || $user == '') { return false; } if (!ezmam_album_exists($album)) { return false; } // 1) set the repository path $user_files_path = user_prefs_repository_path(); if ($user_files_path === false) { return false; } // 2) if the album is not in the list yet // set user's file path $user_path = $user_files_path . '/' . $user; // if the user's directory doesn't exist yet, we create it if (!file_exists($user_path)) { mkdir($user_path, 0755, true); } // Get the albums list $exist = false; $watched_list = user_prefs_watchedlist_get($user); foreach ($watched_list as $index => $watched) { if ($watched['album'] == $album) { $exist = true; if (!in_array($asset, $watched['assets'])) { array_push($watched['assets'], $asset); } else { return false; } } $watched_list[$index]['assets'] = serialize($watched['assets']); } if (!$exist) { $serialized_asset = serialize(array($asset)); $watched_list[] = array('album' => $album, 'assets' => $serialized_asset); } // converts the array in xml file return assoc_array2xml_file($watched_list, $user_path . "/_watched_assets.xml", "watched_assets", "watched"); }
function acl_update_watched_assets() { global $repository_path; global $user_files_path; ezmam_repository_path($repository_path); user_prefs_repository_path($user_files_path); $watched_assets = array(); if (acl_user_is_logged()) { $album_tokens_list = acl_album_tokens_get(); foreach ($album_tokens_list as $album_token) { $global_count[$album_token['album']] = ezmam_asset_count($album_token['album']); } $watched_assets = user_prefs_watchedlist_get($_SESSION['user_login'], false); $_SESSION['acl_global_count'] = $global_count; } $_SESSION['acl_watched_assets'] = $watched_assets; }