public static function newInstance()
 {
     if (!self::$instance instanceof self) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Exemple #2
0
function nc_osc_get_public_picture_link($user_id)
{
    $ext = ProfilePicture::newInstance()->getPictureExt($user_id);
    if ($ext['name'] == null) {
        $name = $user_id . '.' . $ext['pic_ext'];
    } else {
        $name = 'default.png';
    }
    return osc_current_web_theme_url() . 'profile_picture/' . $name;
}
Exemple #3
0
 /**
  * Method to lookup a Mosets Profile Picture plugin image path
  *
  * @param     integer    $id    The user slug
  *
  * @return    string            The profile url
  */
 protected static function lookupMosets($id)
 {
     static $exists = null;
     if (is_null($exists)) {
         $lib = JPATH_LIBRARIES . '/mosets/profilepicture/profilepicture.php';
         $exists = file_exists($lib);
         if ($exists) {
             require_once $lib;
         }
     }
     $default = JURI::root(true) . '/media/com_projectfork/projectfork/images/icons/avatar.jpg';
     if (!$exists) {
         return $default;
     }
     $pic = new ProfilePicture((int) $id);
     if (!$pic->exists()) {
         return $default;
     }
     $url = str_replace('\\', '/', $pic->getURL());
     return $url;
 }
            if (file_exists("../profile_picture/" . osc_logged_user_id() . '.' . 'jpeg')) {
                unlink("../profile_picture/" . osc_logged_user_id() . '.' . 'jpeg');
            }
            if (file_exists("../profile_picture/" . osc_logged_user_id() . '.' . 'jpg')) {
                unlink("../profile_picture/" . osc_logged_user_id() . '.' . 'jpg');
            }
            if (file_exists("../profile_picture/" . osc_logged_user_id() . '.' . 'png')) {
                unlink("../profile_picture/" . osc_logged_user_id() . '.' . 'png');
            }
            $sourcePath = $_FILES['userfile']['tmp_name'];
            // Storing source path of the file in a variable
            $targetPath = "../profile_picture/" . osc_logged_user_id() . '.' . $file_extension;
            // Target path where file is to be stored
            move_uploaded_file($sourcePath, $targetPath);
            //  Moving Uploaded file
            $result = ProfilePicture::newInstance()->findPictureExist(osc_logged_user_id());
            if ($result == true) {
                ProfilePicture::newInstance()->updatePictureExt(osc_logged_user_id(), $file_extension);
            } else {
                echo ProfilePicture::newInstance()->insertPictureData(osc_logged_user_id(), $file_extension);
            }
            echo "<span id='success'>Image Uploaded Successfully...!!</span><br/>";
            echo "<br/><b>File Name:</b> " . $_FILES["userfile"]["name"] . "<br>";
            echo "<b>Type:</b> " . $_FILES["userfile"]["type"] . "<br>";
            echo "<b>Size:</b> " . $_FILES["userfile"]["size"] / 1024 . " kB<br>";
            echo "<b>Temp file:</b> " . $_FILES["userfile"]["tmp_name"] . "<br>";
        }
    } else {
        echo "<span id='invalid'>***Invalid file Size or Type***<span>";
    }
}
 public function actionPicture()
 {
     $formModel = new PictureForm();
     $img = ProfilePicture::getPictureInfo('', 'thumb.profile');
     $this->render('picture', array('model' => $formModel, 'img' => $img));
 }