static function save_new_group($ccid, $uid, $title, $body, $picture, $group_tags, $group_category, $access = 0, $reg = 0, $is_mod = 0, $header_image = "", $header_image_action = NULL, $display_header_image = NULL) { if (empty($title)) { throw new PAException(GROUP_PARAMETER_ERROR, "Please fill in the name of the group"); } if ($group_category == 0) { throw new PAException(GROUP_PARAMETER_ERROR, "Please select the category"); } $tags = Tag::split_tags($group_tags); $new = new Group(); if ($ccid) { $new->collection_id = $ccid; } $new->title = $title; $new->description = $body; $new->author_id = $uid; $new->allow_comments = 1; $new->access_type = $access; $new->reg_type = $reg; $new->is_moderated = $is_mod; $new->category_id = $group_category; $new->header_image_action = $header_image_action; $new->display_header_image = $display_header_image; $new->picture = $picture; $new->header_image = $header_image; //TODO; hard coded integers! $new->type = 1; $group_id = $new->save($uid); if ($tags) { Tag::add_tags_to_content_collection($new->collection_id, $tags); } return $group_id; }
} 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']; } } $new_save->is_active = $is_active; $new_save->save(); if (!empty($_POST['tags'])) { $tag_array = Tag::split_tags($_POST['tags']); Tag::add_tags_to_content($new_save->content_id, $tag_array); } $album_id = $_POST['album']; $album = "&album_id=" . $album_id; header("Location: media_gallery.php?msg_id=2007&uid=" . $_SESSION['user']['id'] . "&type=" . $module . $album); } } } $user = new User(); $user->load((int) $uid); function setup_module($column, $moduleName, $obj) { global $show_media, $users, $uid, $cc_info, $user, $_REQUEST; switch ($column) { case 'left':
function uihelper_upload_gallery_for_group($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(); $user = new User(); $media_count_no = $k; $error_file = NULL; $uploaded = False; if ($type == '') { $file_type = "image"; $alb_type = IMAGE_ALBUM; $new_img = new Image(); $new_img->file_perm = @$_POST['image_perm']; } elseif ($type == '_audio') { $file_type = "audio"; $alb_type = AUDIO_ALBUM; $new_img = new Audio(); $new_img->file_perm = @$_POST['audio_perm']; } elseif ($type == '_video') { $file_type = "video"; $alb_type = VIDEO_ALBUM; $new_img = new Video(); $new_img->file_perm = @$_POST['video_perm']; } //file uploading start $file_name_dynamic = "userfile{$type}" . "_" . "{$k}"; $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; } // file uploading end if (empty($error)) { 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 (empty($_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->file_perm = ANYONE; $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->allow_comments = 1; $new_img->parent_collection_id = $_POST['group_id']; $new_img->save(); 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 (!empty($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, 'collection_id' => $new_img->parent_collection_id, 'content_id' => $new_img->content_id); return $array_of_error_message; }
function add_tags_to_content($cid, $tag_string) { if (!empty($tag_string)) { $tag_array = Tag::split_tags($tag_string); Tag::add_tags_to_content($cid, $tag_array); } return; }
function peopleaggregator_newFile($args) { $user = User::from_auth_token($args['authToken']); $title = strip_tags($args['title']); $body = strip_tags($args['content']); $file_type = $args['type']; $tags = $args['tags']; $access = $args['access']; $context = $args['context']; // URL or file? if (!empty($args['url'])) { $upload_type = 'url'; $url = $args['url']; } else { $upload_type = 'file'; $filename = api_sanitize_filename($args['filename']); // strip attempts to ascend the directory tree $data = $args['data']; } $alb_type = API::$album_type_to_id[$file_type]; switch ($alb_type) { case IMAGE_ALBUM: $new_img = new Image(); $new_img->type = IMAGE; break; case AUDIO_ALBUM: $new_img = new Audio(); $new_img->type = AUDIO; break; case VIDEO_ALBUM: $new_img = new Video(); $new_img->type = VIDEO; break; default: throw new PAException(INVALID_ID, "file type must be 'image', 'audio' or 'video' (not {$file_type})"); } // When uploading a file, we can use the special 'default album' context: 'user:123:album:default' if (preg_match("/^user:\\d+:album:default:([a-z]+)\$/", $context, $m)) { $default_alb_type = API::$album_type_to_id[$m[1]]; $collection = Album::get_or_create_default($user->user_id, $default_alb_type); $collection_id = $collection->collection_id; } else { list($collection_id, $collection) = api_validate_album_context($context, $user, "write"); } if ($collection instanceof Album) { $album_file_type = API::$album_type_from_id[(int) $collection->album_type]; if ($album_file_type != $file_type) { throw new PAException(OPERATION_NOT_PERMITTED, "Attempting to upload a file of type '{$file_type}' into an album that can only contain '{$album_file_type}' files"); } } try { switch ($upload_type) { case 'url': // just supplying a URL; no upload to handle $new_img->file_name = $url; break; case 'file': // we're uploading a file - figure out where to put it $upload_path = realpath(PA::$upload_path); // make a filename that isn't already used $fn_munge = ""; $munge_serial = 0; while (1) { $fn = "{$upload_path}/" . $user->user_id . "_" . $fn_munge . $filename; if (!file_exists($fn)) { break; } // we have our filename! $fn_munge = ++$munge_serial . "_"; } // and try to save the file, then put it in the database, // removing the file if an exception occurs at any point. if (file_put_contents($fn, $data) != strlen($data)) { global $php_errormsg; throw new PAException(FILE_NOT_UPLOADED, "An error occurred when saving the file: {$php_errormsg}"); } $new_img->file_name = basename($fn); break; } $access_map = array('nobody' => 0, 'everybody' => 1, 'relations' => 2); $new_img->file_perm = $access_map[$access]; $new_img->author_id = $user->user_id; $new_img->title = $new_img->excerpt = $title; $new_img->body = $body; $new_img->allow_comments = 1; $new_img->parent_collection_id = $collection_id; $new_img->save(); if ($tags) { Tag::add_tags_to_content($new_img->content_id, Tag::split_tags($tags)); } } catch (PAException $e) { if ($upload_type == 'file') { // delete file @unlink($fn); } throw $e; } return array('success' => TRUE, 'id' => "file:{$new_img->content_id}", 'url' => api_get_url_of_file($new_img->file_name)); }
$new_im_al->save(); $new_video->parent_collection_id = $new_im_al->collection_id; } else { $new_video->parent_collection_id = $_GET['album_video']; } $new_video->allow_comments = 1; if (!empty($_GET['group_id'])) { $perm = 1; } else { $perm = !empty($_GET['video_perm']) ? $_GET['video_perm'] : 1; } $new_video->video_perm = $new_video->file_perm = $perm; $new_video->save(); $tag_array = NULL; if (!empty($_GET['tag'])) { $tag_array = Tag::split_tags($_GET['tag']); Tag::add_tags_to_content($new_video->content_id, $tag_array); } global $config_site_name; $uploaded = TRUE; $media_owner_image = uihelper_resize_mk_user_img(PA::$user->picture, 80, 80, 'alt="' . PA::$user->first_name . '" align="left" style="padding: 0px 12px 12px 0px;"'); $params['first_name'] = PA::$user->first_name; $params['user_id'] = PA::$login_uid; $params['user_image'] = $media_owner_image; $params['cid'] = $new_video->content_id; $params['media_title'] = $new_video->title; $params['content_url'] = $redirect_url . '/' . FILE_CONTENT . '?cid=' . $new_video->content_id; $params['config_site_name'] = $config_site_name; $params['media_full_view_url'] = $redirect_url . '/' . FILE_MEDIA_FULL_VIEW . '?cid=' . $new_video->content_id; $params['content_moderation_url'] = $redirect_url . '/' . FILE_NETWORK_MANAGE_CONTENT; $params['network_name'] = PA::$network_info->name;
} 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']; } } $new_save->is_active = $is_active; $new_save->save(); if (!empty($_POST['tags'])) { $_tags = explode(',', strtolower(str_replace(' ', '', $_POST['tags']))); $_tags = implode(',', array_unique($_tags)); $tag_array = Tag::split_tags($_tags); } else { $tag_array = array(); } Tag::add_tags_to_content($new_save->content_id, $tag_array); $album_id = $_POST['album']; $album = "&album_id=" . $album_id; $msg = __(substr($module, 0, 5) . " updated successfully"); header("Location: " . $ret_url . $album . "&msg={$msg}"); } } } $user = new User(); $user->load((int) $uid); function setup_module($column, $moduleName, $obj) {