/** * 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->setExtension(array('jpg', 'png', 'jpeg', 'gif')); $file->owner_guid = $this->getAnnotationId(); if ($file->owner_guid !== 0) { $file->addFile(); unlink($file_path); unset($_FILES['attachment']); } } return true; } return false; }
/** * Upload component * * Requires component package file, * * @return boolean */ public function upload() { $archive = new ZipArchive(); $data_dir = ossn_get_userdata('tmp/themes'); if (!is_dir($data_dir)) { mkdir($data_dir, 0755, true); } $file = new OssnFile(); $file->setFile('theme_file'); $file->setExtension(array('zip')); $zip = $file->file; $newfile = "{$data_dir}/{$zip['name']}"; if (move_uploaded_file($zip['tmp_name'], $newfile)) { if ($archive->open($newfile) === TRUE) { $archive->extractTo($data_dir); $archive->close(); $validate = pathinfo($zip['name'], PATHINFO_FILENAME); if (is_file("{$data_dir}/{$validate}/ossn_theme.php") && is_file("{$data_dir}/{$validate}/ossn_theme.xml")) { $archive->open($newfile); $archive->extractTo(ossn_route()->themes); $archive->close(); OssnFile::DeleteDir($data_dir); return true; } } } return false; }
* * @package (Informatikon.com).ossn * @author OSSN Core Team <*****@*****.**> * @copyright 2014 iNFORMATIKON TECHNOLOGIES * @license General Public Licence http://www.opensource-socialnetwork.org/licence * @link http://www.opensource-socialnetwork.org/licence */ $profile = new OssnProfile(); $file = new OssnFile(); $user = ossn_loggedin_user(); $file->owner_guid = $user->guid; $file->type = 'user'; $file->subtype = 'profile:photo'; $file->setFile('userphoto'); $file->setPath('profile/photo/'); $file->setExtension(array('jpg', 'png', 'jpeg', 'gif')); if ($file->addFile()) { //update user icon time, this time has nothing to do with photo entity time $user->data->icon_time = time(); $user->save(); //get a all user photo files $resize = $file->getFiles(); //add a wall post for photo update $profile->addPhotoWallPost($file->owner_guid, $resize->{0}->guid); if (isset($resize->{0}->value)) { $guid = $user->guid; $datadir = ossn_get_userdata("user/{$guid}/{$resize->{0}->value}"); $file_name = str_replace('profile/photo/', '', $resize->{0}->value); //create sub photos $sizes = ossn_user_image_sizes(); foreach ($sizes as $size => $params) {