Beispiel #1
0
 public function get_qr_image($qrfile_prefix = 'qr_', $size = 4, $outer_margin = 2)
 {
     $url = wpl_global::get_full_url();
     $file_name = $qrfile_prefix . md5($url) . '.png';
     $file_path = wpl_global::get_upload_base_path() . 'qrcode' . DS . $file_name;
     if (!wpl_file::exists($file_path)) {
         if (!wpl_file::exists(dirname($file_path))) {
             wpl_folder::create(dirname($file_path));
         }
         $QRcode = new QRcode();
         $QRcode->png($url, $file_path, 'L', $size, $outer_margin);
     }
     return wpl_global::get_upload_base_url() . 'qrcode/' . $file_name;
 }
Beispiel #2
0
 /**
  * Finalize User Profile
  * @author Howard R <*****@*****.**>
  * @static
  * @param int $user_id
  * @return boolean
  */
 public static function finalize($user_id)
 {
     /** create folder **/
     $folder_path = wpl_items::get_path($user_id, 2);
     if (!wpl_folder::exists($folder_path)) {
         wpl_folder::create($folder_path);
     }
     /** Multilingual **/
     if (wpl_global::check_multilingual_status()) {
         $languages = wpl_addon_pro::get_wpl_languages();
         $current_language = wpl_global::get_current_language();
         foreach ($languages as $language) {
             wpl_global::switch_language($language);
             /** Generate Rendered Data **/
             wpl_users::generate_rendered_data($user_id);
             wpl_users::update_text_search_field($user_id);
         }
         /** Switch to current language again **/
         wpl_global::switch_language($current_language);
     } else {
         /** Generate Rendered Data **/
         wpl_users::generate_rendered_data($user_id);
         wpl_users::update_text_search_field($user_id);
     }
     /** Generate Email Files **/
     wpl_users::generate_email_files($user_id);
     /** throwing event **/
     wpl_events::trigger('user_finalized', $user_id);
     return true;
 }
Beispiel #3
0
 /**
  * This functions will take care of multisite usage
  * @author Howard <*****@*****.**>
  * @param type $blog_id
  * @return string WPL base url for uploaded files
  */
 public static function get_upload_base_url($blog_id = NULL)
 {
     if (!$blog_id) {
         $blog_id = wpl_global::get_current_blog_id();
     }
     $ABSPATH = WPL_UP_ABSPATH;
     if (!$blog_id or $blog_id == 1) {
         return wpl_global::get_wp_site_url() . 'wp-content/uploads/WPL/';
     } else {
         $path = rtrim($ABSPATH, DS) . $blog_id . DS;
         if (!wpl_folder::exists($path)) {
             wpl_folder::create($path);
         }
         return wpl_global::get_wp_site_url() . 'wp-content/uploads/WPL' . $blog_id . '/';
     }
 }
Beispiel #4
0
 /**
  * Returns item directory path. If it's not exist it creates the directory 
  * @author Howard R <*****@*****.**>
  * @static
  * @param int $parent_id
  * @param int $kind
  * @return string
  */
 public static function get_path($parent_id, $kind = 0)
 {
     if ($kind == 2) {
         $path = wpl_global::get_upload_base_path() . 'users' . DS . $parent_id . DS;
     } else {
         $path = wpl_global::get_upload_base_path() . $parent_id . DS;
     }
     if (!wpl_folder::exists($path)) {
         wpl_folder::create($path);
     }
     return $path;
 }
Beispiel #5
0
 /**
  * Moves an uploaded file to a destination folder
  * @author Howard <*****@*****.**>
  * @param string $src
  * @param string $dest
  * @return boolean
  */
 public static function upload($src, $dest)
 {
     // Ensure that the path is valid and clean
     $dest = wpl_path::clean($dest);
     $baseDir = dirname($dest);
     if (!file_exists($baseDir)) {
         wpl_folder::create($baseDir);
     }
     if (is_writable($baseDir) && move_uploaded_file($src, $dest)) {
         // Short circuit to prevent file permission errors
         if (wpl_path::setPermissions($dest)) {
             $ret = true;
         } else {
             $ret = false;
         }
     } else {
         $ret = false;
     }
     return $ret;
 }