public function showSeedAlbum() { $album = new Album(); $album->title = 'Some Mad Hope'; $album->artist = 'Matt Nathanson'; $album->genre = 'Acoustic Rock'; $album->year = 2007; $album->save(); $album = new Album(); $album->title = 'Please'; $album->artist = 'Matt Nathanson'; $album->genre = 'Acoustic Rock'; $album->year = 1993; $album->save(); $album = new Album(); $album->title = 'Leaving Throught The Window'; $album->artist = 'Something Corp'; $album->genre = 'Piano Rock'; $album->year = 2002; $album->save(); $album = new Album(); $album->title = '...Anywhere But here'; $album->artist = 'Something Corp'; $album->genre = 'Punk Rock'; $album->year = 1997; $album->save(); $album = new Album(); $album->title = '...Is A Real Boy'; $album->artist = 'Something Corp'; $album->genre = 'Indie Rock'; $album->year = 2006; $album->save(); }
public function actionCreate() { $model = new Album(); if (isset($_POST['Album']) || isset($_POST['Page'])) { if (isset($_POST['Album'])) { $model->setAttributes($_POST['Album']); } if (isset($_POST['Album']['page'])) { $model->page = $_POST['Album']['page']; } if (isset($_POST['Album']['thumbnail'])) { $model->thumbnail = $_POST['Album']['thumbnail']; } try { if ($model->save()) { if (isset($_GET['returnUrl'])) { $this->redirect($_GET['returnUrl']); } else { $this->redirect(array('view', 'id' => $model->id)); } } } catch (Exception $e) { $model->addError('', $e->getMessage()); } } elseif (isset($_GET['Album'])) { $model->attributes = $_GET['Album']; } $this->render('create', array('model' => $model)); }
public function store() { $data = Input::all(); $album = new Album(); $album['title'] = $data['title']; $album['user_id'] = Session::get('user')['id']; $album['privacy'] = $data['privacy']; $file = Input::file('img'); $folder_user = Session::get('user')['account']; $album_path = 'public/upload/' . $folder_user . '/' . uniqid(date('ymdHisu')); foreach ($file as $key => $f) { $name = uniqid() . "." . $f->getClientOriginalExtension(); $f->move($album_path, $name); if ($key == 0) { // $album['album_img'] = $name; $album->save(); FEEntriesHelper::save($album->id, FEEntriesHelper::getId("Album"), $album->user_id, $album->privacy); } $path = $album_path . '/' . $name; $image = new Image(); $image['path'] = $path; $image['user_id'] = Session::get('user')['id']; $image['album_id'] = $album['id']; $image['width'] = getimagesize($path)[0]; $image['height'] = getimagesize($path)[1]; $image->save(); } echo json_encode($file); }
function unpublishSubalbums($album) { global $gallery; $albums = $album->getAlbums(); foreach ($albums as $albumname) { $subalbum = new Album($gallery, $albumname); $subalbum->setShow(false); $subalbum->save(); unpublishSubalbums($subalbum); } }
public function set_album($album_str) { if (!Albums::get_by_name($album_str)) { $album = new Album(); $album->set_name($album_str); $album->save(); } else { $album = Albums::get_by_name($album_str); } $this->music_album = $album->get_id(); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Album(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Album'])) { $model->attributes = $_POST['Album']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
/** * TC12: Create operation on Albums * Test to verify that the database can save new albums * The test is performed by creating an album object with the required input fields * Once the test is complete no errors will appear and the album will be in the database */ public function testCreateAlbum() { //Create the album $album = new Album(); $album['artist_id'] = $this->artist['artist_id']; $album['name'] = 'testalbum2'; $album['added_by_user_id'] = 1; //SYSTEM user $album->save(); //Verify it exist now $this->assertTrue($album->exists()); }
public function postCreate() { //Todo: validate $name = $_POST['name']; if ($name === '') { return View::make('albums.create'); } $album = new Album(); $album->name = $name; $album->owner_id = Auth::user()->id; $album->save(); return Redirect::to('/albums/own'); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $rules = ['nama' => 'required']; $pesan = ['nama.required' => 'Nama harus diisi']; $validasi = Validator::make(Input::all(), $rules, $pesan); if ($validasi->fails()) { return Redirect::back()->withErrors($validasi); } else { $album = new Album(); $album->nm_album = Input::get('nama'); $album->created_by = Sentry::getUser()->username; $album->save(); $theId = DB::getPdo()->lastInsertId(); return Redirect::to('admin/gallery/' . $theId . '/tambahfoto'); } }
public function updateAlbum(Album $album) { $inputs = ['name' => Input::get('name'), 'description' => Input::get('description'), 'user_id' => Input::get('uid')]; $valid = Validator::make($inputs, Album::$rules); if ($valid->passes()) { $album->name = $inputs['name']; $album->description = $inputs['description']; $album->user_id = $inputs['user_id']; if (count($album->getDirty()) > 0) { $album->save(); return Redirect::back()->with('success', Lang::choice('messages.Albums', 1) . ' ' . trans('messages.is updated')); } else { return Redirect::back()->with('success', trans('messages.Nothing to update')); } } else { return Redirect::back()->withErrors($valid)->withInput(); } }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $data = Input::except(array('_token', '_method')); $trimmedData = $this->trimData($data, array()); $album = Album::where('name', $trimmedData['name'])->get()->first(); if (!empty($album)) { Session::flash('flash_error', trans('message.album.error.already_exist')); return Redirect::route('secured.album.create')->withInput(); } $currentUser = $this->getCurrentUser(); $album = new Album(); $album->fill($trimmedData); $album->owner_id = $currentUser->id; if (!$album->save()) { $errors = $album->errors(); return Redirect::route('secured.album.create')->withInput()->withErrors($errors); } return Redirect::route('secured.album.index'); }
function checkAlbumParentid($albumname, $id) { global $gallery; $album = new Album($gallery, $albumname); $oldid = $album->get('parentid'); if ($oldid !== $id) { $album->set('parentid', $id); $album->save(); if (is_null($oldid)) { $oldid = '<em>NULL</em>'; } if (is_null($id)) { $id = '<em>NULL</em>'; } printf('Fixed album <strong>%1$s</strong>: parentid was %2$s should have been %3$s<br />', $albumname, $oldid, $id); } $id = $album->id; $albums = $album->getSubalbums(); foreach ($albums as $albumname) { checkAlbumParentid($albumname, $id); } }
/** * Creates a new album with optional album cover. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $user = $this->getUser(); if ($user->id != Yii::app()->user->id) { throw new CHttpException(403, 'You can create album only on your profile.'); } $this->subLayout = "application.modules.album.views._layout"; $model = new Album(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Album'])) { $_POST = Yii::app()->input->stripClean($_POST); $_POST['containerGuid'] = Yii::app()->user->guid; $_POST['containerClass'] = 'User'; $model->content->populateByForm(); $model->attributes = $_POST['Album']; if ($model->save()) { PublicFile::attachPrecreated($model, Yii::app()->request->getParam('cover')); $this->redirect(['/album/view', 'id' => $model->id, 'username' => $user->username, 'uguid' => $user->guid]); } } $this->render('/album/create', ['model' => $model, 'user' => $user]); }
public function saveAlbum() { $validator = Validator::make(Input::all(), array('album_title' => 'required|unique:albums,title')); if ($validator->fails()) { return Redirect::route('edit-albums')->withInput()->withErrors($validator)->with('modal', '#album_form'); } else { $album = new Album(); $album->title = Input::get('album_title'); $album->release = Input::get('album_release'); $slug = strtolower(Input::get('album_title')); //Make alphanumeric (removes all other characters) $slug = preg_replace("/[^a-z0-9_\\s-]/", "", $slug); //Clean up multiple dashes or whitespaces $slug = preg_replace("/[\\s-]+/", " ", $slug); //Convert whitespaces and underscore to dash $slug = preg_replace("/[\\s_]/", "-", $slug); $album->slug = $slug; if ($album->save()) { return Redirect::route('edit-albums')->with('success', 'The album was added.'); } else { return Redirect::route('edit-albums')->with('fail', 'An error occured while saving the new album.'); } } }
/** * Add an Album to the database or get its key if it exists * @param name str: the name of the album to add * @return int: the primary key added or found */ public function addAlbum($name) { //is this name already in the collection? $q = Doctrine_Query::create()->select('a.id')->from('Album a')->where('a.name = ?', $name); $result = $q->fetchOne(); if (is_object($result) && $result->id > 0) { $retId = $result->id; unset($q, $result); return (int) $retId; } else { $item = new Album(); $item->name = $name; if ($name == 'Unknown Album') { $item->has_art = 1; //there's no point scanning an unknown album for art } $item->scan_id = 1; $item->save(); $id = $item->getId(); $item->free(); unset($item, $q, $result); return (int) $id; } }
public static function get_or_create_default($author_id, $alb_type) { if (empty($author_id)) { throw new CNException(INVALID_ID, "Empty author_id"); } if (!in_array($alb_type, array(IMAGE_ALBUM, AUDIO_ALBUM, VIDEO_ALBUM))) { throw new CNException(INVALID_ID, "Invalid album type: {$alb_type}"); } // Check for existing album; the default will be the first one. $album = new Album(); try { $album->load_first($author_id, $alb_type); // If no exception fired, the album already exists. Logger::Log("Album::get_or_create_default({$alb_type}, {$author_id}) found an existing album: #" . $album->collection_id . ")"); } catch (CNException $e) { if ($e->getCode() != CONTENT_COLLECTION_NOT_FOUND) { throw $e; } // Looks like it doesn't exist, so create it. $album = new Album($alb_type); $album->author_id = $author_id; $album->title = $album->name = $album->description = PA::$config->default_album_titles[$alb_type]; $album->save(); Logger::Log("Album::get_or_create_default({$alb_type}, {$author_id}) created an album: " . $album->collection_id); } return $album; }
} else { $rightsalbum = new Album($gallery, $folder); } if (!$rightsalbum->isMyItem(UPLOAD_RIGHTS)) { if (!zp_apply_filter('admin_managed_albums_access', false, $return)) { header('Location: ' . FULLWEBPATH . '/' . ZENFOLDER . '/admin.php'); exit; } } if ($new) { mkdir_recursive($targetPath, CHMOD_VALUE); $album = new Album($gallery, $folder); $album->setShow($_POST['http_publishalbum']); $album->setTitle(sanitize($_POST['http_albumtitle'])); $album->setOwner($_zp_current_admin_obj->getUser()); $album->save(); } @chmod($targetPath, CHMOD_VALUE); $error = zp_apply_filter('check_upload_quota', UPLOAD_ERR_OK, $tempFile); if (!$error) { if (is_valid_image($name) || is_valid_other_type($name)) { $seoname = seoFriendly($name); if (strrpos($seoname, '.') === 0) { $seoname = sha1($name) . $seoname; } // soe stripped out all the name. $targetFile = $targetPath . '/' . internalToFilesystem($seoname); if (file_exists($targetFile)) { $append = '_' . time(); $seoname = stripSuffix($seoname) . $append . '.' . getSuffix($seoname); $targetFile = $targetPath . '/' . internalToFilesystem($seoname);
public static function add_default_media($user_id, $type = '', $network_info = NULL) { // global var $path_prefix has been removed - please, use PA::$path static variable require_once "api/CNUser/CNUser.php"; require_once "api/CNAlbum/CNAlbum.php"; require_once "api/CNImage/CNImage.php"; require_once "api/CNAudio/CNAudio.php"; require_once "api/CNVideo/CNVideo.php"; require_once "api/CNContentCollection/CNContentCollection.php"; //$extra contains networks extra information $extra = unserialize($network_info->extra); /** setting common variables according to media type */ if ($type == '') { $net_extra_ccid_str = $extra['user_defaults']['default_image_gallery']; $alb_type = IMAGE_ALBUM; $new_img = new CNImage(); } elseif ($type == '_audio') { $net_extra_ccid_str = $extra['user_defaults']['default_audio_gallery']; $alb_type = AUDIO_ALBUM; $new_img = new CNAudio(); } elseif ($type == '_video') { $net_extra_ccid_str = $extra['user_defaults']['default_video_gallery']; $alb_type = VIDEO_ALBUM; $new_img = new CNVideo(); } /** getting array of content collection from comma separated string */ if (!empty($net_extra_ccid_str)) { $net_extra_ccid = explode(',', $net_extra_ccid_str); /** setting all content collection variables */ if (count($net_extra_ccid) >= 1) { for ($i = 0; $i < count($net_extra_ccid); $i++) { $new_im_al = new Album($alb_type); $new_im_al_default = new Album($alb_type); $new_im_al->load((int) $net_extra_ccid[$i]); $content_collection_obj = new ContentCollection(); $content_collection_obj->collection_id = $new_im_al->collection_id; $contents = $content_collection_obj->get_contents_for_collection(); $new_im_al_default->title = $new_im_al->title; $new_im_al_default->description = $new_im_al->description; $new_im_al_default->author_id = $user_id; $new_im_al_default->type = 2; // FOR ALBUM, type is 2 $new_im_al_default->save(); /** Setting content variable */ for ($j = 0; $j < count($contents); $j++) { if ($contents[$j]['type'] != 7) { // If content is not a SB content if ($alb_type == IMAGE_ALBUM) { $new_img_default = new CNImage(); $new_img_default->type = IMAGE; } elseif ($alb_type == AUDIO_ALBUM) { $new_img_default = new CNAudio(); $new_img_default->type = AUDIO; } elseif ($alb_type == VIDEO_ALBUM) { $new_img_default = new CNVideo(); $new_img_default->type = VIDEO; } $new_img->load((int) $contents[$j]['content_id']); $new_img_default->file_name = $new_img->file_name; $new_img_default->file_perm = $new_img->file_perm; $new_img_default->title = $contents[$j]['title']; $new_img_default->body = $contents[$j]['body']; $tags = Tag::load_tags_for_content($contents[$j]['content_id']); $new_img_default->allow_comments = 1; $new_img_default->author_id = $user_id; $new_img_default->parent_collection_id = $new_im_al_default->collection_id; $new_img_default->save(); if (!empty($tags)) { $tag_array = array(); if (is_array($tags)) { for ($i = 0; $i < count($tags); $i++) { $tag_array[] = $tags[$i]['name']; } } Tag::add_tags_to_content($new_img_default->content_id, $tag_array); } } else { // If content is a SB content //TODO: handling of SB content if it is in media gallery. } } } } } }
function uihelper_upload_gallery($uid, $type, $k = 0) { require_once "api/User/User.php"; require_once "api/Tag/Tag.php"; require_once "api/Album/Album.php"; require_once "api/Image/Image.php"; require_once "api/Audio/Audio.php"; require_once "api/Video/Video.php"; require_once "web/includes/classes/CNFileUploader.php"; $logged_in_user = get_login_user(); $error = false; $error_file = NULL; $uploaded = False; $title = NULL; $album_id = NULL; $msg = NULL; $user = new User(); $media_count_no = $k; if ($type == '') { $file_type = "image"; $alb_type = IMAGE_ALBUM; $new_img = new Image(); $perm = 'image_perm'; $new_im_al = new Album($alb_type); } elseif ($type == '_audio') { $file_type = "audio"; $alb_type = AUDIO_ALBUM; $new_img = new Audio(); $perm = 'audio_perm'; $new_im_al = new Album($alb_type); } elseif ($type == '_video') { $file_type = "video"; $alb_type = VIDEO_ALBUM; $new_img = new Video(); $perm = 'video_perm'; $new_im_al = new Album($alb_type); } else { throw new CNException(INVALID_ID, "Invalid album type '{$type}'"); } $file_name_dynamic = "userfile{$type}" . "_" . "{$k}"; if (!empty($_FILES[$file_name_dynamic]['name'])) { //file uploading start $file_name_dynamic_type = $file_name_dynamic; //"$file_name_dynamic"."$type"; $newname = $_FILES[$file_name_dynamic_type]['name']; $uploadfile = PA::$upload_path . basename($_FILES[$file_name_dynamic_type]['name']); $myUploadobj = new FileUploader(); //creating instance of file. $image_type = "{$file_type}"; $value = $file_name_dynamic_type; $file = $myUploadobj->upload_file(PA::$upload_path, $value, true, true, $image_type); if ($file == false) { $msg = $myUploadobj->error; $error = TRUE; } else { $new_img->file_name = "{$file}"; $error_file = FALSE; } } else { if (empty($_FILES[$file_name_dynamic]['name']) && !empty($_POST['userfile' . $type . '_url_' . $k])) { $remote_url = $_POST['userfile' . $type . '_url_' . $k]; if (!strstr($remote_url, "http://")) { $remote_url = "http://" . $remote_url; } $new_img->file_name = $remote_url; } else { $error = TRUE; } } // file uploading end if ($error != TRUE) { try { $user->load((int) $uid); $action = !empty($_GET['action']) ? $_GET['action'] : 'upload'; $colls = Album::load_all($uid, $alb_type); if (isset($_POST['submit' . $type]) && $action != 'delete' && $error_file == FALSE) { $new_img->author_id = $uid; if ($type == '_audio') { $new_img->type = AUDIO; } elseif ($type == '_video') { $new_img->type = VIDEO; } else { $new_img->type = IMAGE; } if (!$_POST['caption' . $type][$k]) { $ext = explode(".", $newname); $_POST['caption' . $type][$k] = $ext[0]; } $new_img->title = stripslashes(trim($_POST['caption' . $type][$k])); //$new_img->title = strip_tags($new_img->title); $new_img->excerpt = stripslashes(trim($_POST['caption' . $type][$k])); $new_img->excerpt = strip_tags($new_img->excerpt); if (empty($_POST['body' . $type][$k])) { $new_img->body = ''; $new_img->body = strip_tags($new_img->body); } else { $new_img->body = stripslashes(trim($_POST['body' . $type][$k])); $new_img->body = strip_tags($new_img->body); } $new_img->file_perm = !empty($_POST[$perm][$k]) ? $_POST[$perm][$k] : 1; $new_img->allow_comments = 1; if (!empty($_POST['new_album' . $type])) { global $new_album_id; if ($k == 0) { $new_im_al->author_id = $uid; $new_im_al->type = 2; $new_im_al->title = $_POST['new_album' . $type]; $new_im_al->name = $_POST['new_album' . $type]; $new_im_al->description = $_POST['new_album' . $type]; $new_im_al->save(); $new_album_id = $new_im_al->collection_id; $new_img->parent_collection_id = $new_im_al->collection_id; $new_img->save(); $album_id = $new_album_id; } else { if ($k > 0) { $new_img->parent_collection_id = $new_album_id; $new_img->save(); $album_id = $new_album_id; } } } else { if (empty($colls)) { $new_im_al->author_id = $uid; $new_im_al->type = 2; $default_album = str_replace("_", "", $type); $new_im_al->title = "My {$default_album} album"; $new_im_al->name = "My {$default_album} album"; $new_im_al->description = "My {$default_album} album"; try { $new_im_al->save(); } catch (CNException $e) { $msg = "{$e->message}"; $error = TRUE; } $new_img->parent_collection_id = $new_im_al->collection_id; $album_id = $new_img->parent_collection_id; } else { foreach ($_POST as $k => $v) { if ($k == 'album' . $type) { $albu_ids = $v; } } if (!isset($albu_ids) || empty($albu_ids)) { $albu_ids = $colls[0]['collection_id']; } $new_img->parent_collection_id = $albu_ids; $album_id = $albu_ids; } try { $new_img->save(); } catch (CNException $e) { $msg = "{$e->message}"; print $msg; $error = TRUE; } } if (!empty($_POST['tags' . $type][$media_count_no])) { $tag_array = Tag::split_tags($_POST['tags' . $type][$media_count_no]); Tag::add_tags_to_content($new_img->content_id, $tag_array); } } else { throw new CNException(USER_NOT_FOUND, 'unable to upload file.'); } if ($msg) { $uploaded = FALSE; } else { $uploaded = TRUE; if (isset($_REQUEST['gid'])) { $mail_type = "group_media_uploaded"; $new_img->group_id = $_REQUEST['gid']; } else { $mail_type = "media_uploaded"; } PANotify::send($mail_type, PA::$network_info, PA::$login_user, $new_img); } } catch (CNException $e) { $msg = "{$e->message}"; $error = TRUE; } } $array_of_error_message = array($error, $msg, $error_file, $uploaded, $new_img->content_id, $title, 'album_id' => $album_id); return $array_of_error_message; }
$userartist = new UserArtist(); $userartist['user_id'] = $_SESSION['user']['user_id']; $userartist['artist_id'] = $db_artist['artist_id']; $userartist->save(); } //add the album $db_album = Doctrine_Query::create() ->from('Album a') ->where('a.name=? and a.artist_id=?', array(trim($album), $db_artist['artist_id'])) ->fetchOne(); if (!$db_album) { $db_album = new Album(); $db_album['name'] = trim($album); $db_album['Artist'] = $db_artist; $db_album['added_by_user_id'] = $_SESSION['user']['user_id']; $db_album->save(); } //Add the link from the album to the user $useralbum = Doctrine_Query::create() ->from('UserAlbum a') ->where('a.user_id=? and a.album_id=?', array($_SESSION['user']['user_id'], $db_album['album_id'])) ->fetchOne(); if (!$useralbum) { $useralbum = new UserAlbum(); $useralbum['user_id'] = $_SESSION['user']['user_id']; $useralbum['album_id'] = $db_album['album_id']; $useralbum->save(); } echo "Artist/Album added <a href='library.php'>Back to Library</a>"; } else { echo "Invalid artist!";
/** * Finds an album by title. Optionally creates a new album if none exists * by that title. * * @bug Only allows one album by title globally, this should be (at least) * on a per-user basis. * * @param string $title title of the album * @param boolean $create (optional) create a new album if none found, * defaults to false * * @return Album loaded instance when found/created, otherwise a bare * instance */ public static function findByTitle($title, $create = false) { $db = Core::getDb(); // Find $qTitle = $db->escape($title); $q = "select id from albums where title='{$qTitle}'"; $id = $db->getSingleValue($q); // Create if it doesn't exist if (!$id && $create) { $album = new Album(); $album->setTitle($title); $album->save(); return $album; } return new Album($id); }
function topics() { list($params, $id) = $this->parse_params(func_get_args()); if ($this->method === 'get') { $a = new Album(); $params['auth'] = $this->auth; $params['flat'] = true; $final = $a->where_related('text', 'id', $id)->listing($params); $this->set_response_data($final); } else { list($text_id, $album_id) = $id; $text = new Text(); $t = $text->get_by_id($text_id); if (is_numeric($album_id)) { $album_id = array($album_id); } else { $album_id = explode(',', $album_id); } $album = new Album(); $albums = $album->where_in('id', $album_id)->get_iterated(); foreach ($albums as $a) { if ($this->method === 'post') { $a->save($t); } else { $a->delete($t); } } $this->redirect("/text/{$text_id}"); exit; } }
function createalbum() { $album_type = $_POST['sb_mc_type']; $album_type = trim(substr($album_type, 6)); if ($album_type == "audio") { $alb_type = AUDIO_ALBUM; $new_al = new Album($alb_type); } else { if ($album_type == "video") { $alb_type = VIDEO_ALBUM; $new_al = new Album($alb_type); } else { if ($album_type == "image") { $alb_type = IMAGE_ALBUM; $new_al = new Album($alb_type); } } } $new_al->author_id = PA::$login_uid; $new_al->type = 2; //it means this collection is album 1 is for groups $new_al->title = $_POST['new_album']; $new_al->name = $_POST['new_album']; $new_al->description = $_POST['new_album']; $album_save_error = ""; try { $new_al->save(); } catch (PAException $e) { $album_save_error = "{$e->message}"; $alb_error = true; } if ($alb_error) { $err = array('error' => TRUE, 'msg' => $album_save_error); return $err; } else { $ccid = $new_al->collection_id; return $ccid; } }
public function addAlbum() { if (!Auth::check()) { return Response::json(array('errCode' => 1, 'message' => '请登录')); } $album_name = Input::get('album_name'); $user_id = Auth::user()->id; $validation = Validator::make(array('album_name' => $album_name), array('album_name' => 'required')); if ($validation->fails()) { return Response::json(array('errCode' => 2, 'message' => '请输入相册名字!')); } $ablum = new Album(); $ablum->title = $album_name; $ablum->user_id = $user_id; if ($ablum->save()) { return Response::json(array('errCode' => 0, 'message' => '新建相册成功!', 'album_id' => $ablum->id)); } return Response::json(array('errCode' => 3, 'message' => '新建相册失败!')); }
if (!empty($_GET['group_id'])) { $perm = 1; $album = $_GET['group_id']; } else { $perm = !empty($_GET['video_perm']) ? $_GET['video_perm'] : 1; // get the actual album for this user!!! $video_albums = Album::load_all(PA::$login_uid, VIDEO_ALBUM); if (!empty($video_albums[0])) { $album = $video_albums[0]['collection_id']; } else { // we need to create one $new_al = new Album(VIDEO_ALBUM); $new_al->author_id = PA::$login_uid; $new_al->type = 2; $new_al->description = $new_im_al->name = $new_al->title = PA::$config->default_album_titles[VIDEO_ALBUM]; $new_al->save(); $album = $new_al->collection_id; } } $new_video->video_perm = $new_video->file_perm = $perm; $new_video->parent_collection_id = $album; $new_video->save(); $default_icon = uihelper_resize_mk_img(null, 86, 92, 'images/default_video.png', "", RESIZE_CROP); $content_url = PA::$url . "/" . FILE_MEDIA_FULL_VIEW . "?cid={$new_video->content_id}"; // echo "<pre>".print_r($new_video,1)."</pre>"; ?> <p><b>Video was uploaded successfully.</p> <script> /* NOTE: this code added by Z.Hron BOF - forward media data to the parent form (if exists)
function get_user_albums() { switch ($this->album_type) { case IMAGE_ALBUM: $caption = 'Default Image Album'; break; case AUDIO_ALBUM: $caption = 'Default Audio Album'; break; case VIDEO_ALBUM: $caption = 'Default Video Album'; break; } $albums = Album::load_all($_SESSION['user']['id'], $this->album_type); if (count($albums) == 0) { $Album = new Album($this->album_type); $Album->author_id = $_SESSION['user']['id']; $Album->type = 2; $Album->title = $caption; $Album->name = $caption; $Album->description = $caption; $Album->save(); $albums = Album::load_all($_SESSION['user']['id'], $this->album_type); } return $albums; }
public function updateImgsOrder($newOrder) { //$newOrder contain all images (old and new if after upload) $order = serialize($newOrder); $record = $this->album; if ($record === null) { $record = new Album(); $record->pid = $this->pid; $record->imgsOrder = $order; if (!$record->save()) { throw new Exception('fbgallery - updateImgsOrder - ' . $this->tr('cantSave')); } } else { $attributes = array("imgsOrder" => $order); $record->saveAttributes($attributes); } //reload image's order $this->imgsOrder = $newOrder; }
$log->add("getting album id..."); if ($artistId != NULL) { $album = new Album("brasil"); $log->add("searching db for icpn=" . $track->getIcpn()); $album->loadFromIcpn($dbc, $track->getIcpn()); // veo si ya esta ingresado en la db if ($album->getMaches() == "1") { // ya esta ingresado, obtengo id $albumId = $album->getId(); $log->add("found album={$albumId}"); } else { $log->add("album not found"); $log->add("fetching album info for icpn=" . $track->getIcpn()); $album->setArtistId($artistId); $album->fetchXML($track->getIcpn(), $log); $savedAlbum = $album->save($dbc, "albums"); if ($savedAlbum === TRUE) { $albumId = $album->getId(); } else { $albumId = NULL; $log->add("ERROR saving album"); } } } // ************************* // ************************* // ASOCIO ALBUM con GENERO $log->add("linking album={$albumId} to group={$genreData->id}..."); $album->assocGroup($dbc, $genreData->id); // ************************* // *************************
$alb_type = AUDIO_ALBUM; $new_im_al = new Album($alb_type); } else { if ($_POST['media_type'] == 'video') { $alb_type = VIDEO_ALBUM; $new_im_al = new Album($alb_type); } } } $new_im_al->author_id = $uid; $new_im_al->type = 2; $new_im_al->title = $_POST['new_album']; $new_im_al->name = $_POST['new_album']; $new_im_al->description = $_POST['new_album']; try { $new_im_al->save(); $new_save->parent_collection_id = $new_im_al->collection_id; } catch (PAException $e) { $error = $e->message; } } else { $new_save->parent_collection_id = $_POST['album']; } if (!$error) { $condition = array('content_id' => $new_save->content_id); $is_active = ACTIVE; if ($extra['network_content_moderation'] == NET_YES) { $content = Content::load_all_content_for_moderation(NULL, $condition); if (!empty($content)) { $is_active = $content[0]['is_active']; }
/** * Creates a "prime" album for the user. Album name is based on the userid */ function createPrimealbum() { // create his album $t = 0; $ext = ''; $filename = str_replace(array('<', '>', ':', '"' . '/' . '\\', '|', '?', '*'), '_', seoFriendly($this->getUser())); while (file_exists(ALBUM_FOLDER_SERVERPATH . '/' . $filename . $ext)) { $t++; $ext = '-' . $t; } $path = ALBUM_FOLDER_SERVERPATH . '/' . $filename . $ext; if (@mkdir_recursive($path, CHMOD_VALUE)) { $album = new Album(new Gallery(), $filename . $ext); $album->save(); $this->setAlbum($album); $objects = $this->getObjects(); $objects[] = array('data' => $filename . $ext, 'name' => $filename . $ext, 'type' => 'album'); $this->setObjects($objects); } }