/** * Post Comment * * @params $subject_id: Id of item on which user comment * $guid: User id * $comment: Comment * $type: Post or Entity * * @return bool; */ public function PostComment($subject_id, $guid, $comment, $type = 'post') { if ($subject_id < 1 || $guid < 1 || empty($comment)) { return false; } $this->subject_guid = $subject_id; $this->owner_guid = $guid; $this->type = "comments:{$type}"; $this->value = $comment; if ($this->addAnnotation()) { if (isset($this->comment_image)) { $image = base64_decode($this->comment_image); $file = ossn_string_decrypt(base64_decode($image)); $file_path = rtrim(ossn_validate_filepath($file), '/'); $_FILES['attachment'] = array('name' => $file_path, 'tmp_name' => $file_path, 'type' => 'image/jpeg', 'size' => filesize($file_path), 'error' => UPLOAD_ERR_OK); $file = new OssnFile(); $file->type = 'annotation'; $file->subtype = 'comment:photo'; $file->setFile('attachment'); $file->setPath('comment/photo/'); $file->owner_guid = $this->getAnnotationId(); if ($file->owner_guid !== 0) { $file->addFile(); unlink($file_path); unset($_FILES['attachment']); } } return true; } return false; }
/** * OpenSource-SocialNetwork * * @package (Informatikon.com).ossn * @author OSSN Core Team <*****@*****.**> * @copyright 2014 iNFORMATIKON TECHNOLOGIES * @license General Public Licence http://opensource-socialnetwork.com/licence * @link http://www.opensource-socialnetwork.com/licence */ $file = new OssnFile(); $file->owner_guid = ossn_loggedin_user()->guid; $file->type = 'user'; $file->subtype = 'profile:photo'; $file->setFile('userphoto'); $file->setPath('profile/photo/'); if ($file->addFile()) { $resize = $file->getFiles(); if (isset($resize->{0}->value)) { $guid = ossn_loggedin_user()->guid; $datadir = ossn_get_userdata("user/{$guid}/{$resize->{0}->value}"); $file_name = str_replace('profile/photo/', '', $resize->{0}->value); $sizes = ossn_user_image_sizes(); foreach ($sizes as $size => $params) { $params = explode('x', $params); $width = $params[1]; $height = $params[0]; $resized = ossn_resize_image($datadir, $width, $height, true); file_put_contents(ossn_get_userdata("user/{$guid}/profile/photo/{$size}_{$file_name}"), $resized); } }
<?php /** * OpenSource-SocialNetwork * * @package (Informatikon.com).ossn * @author OSSN Core Team <*****@*****.**> * @copyright 2014 iNFORMATIKON TECHNOLOGIES * @license General Public Licence http://opensource-socialnetwork.com/licence * @link http://www.opensource-socialnetwork.com/licence */ $file = new OssnFile(); $file->owner_guid = ossn_loggedin_user()->guid; $file->type = 'user'; $file->subtype = 'profile:cover'; $file->setFile('coverphoto'); $file->setPath('profile/cover/'); if ($file->addFile()) { $ossnprofile = new OssnProfile(); $ossnprofile->ResetCoverPostition($file->owner_guid); echo 1; } else { echo 0; }