function users_list_alm_users_user_photo_BeforeShow(&$sender)
{
    $users_list_alm_users_user_photo_BeforeShow = true;
    $Component =& $sender;
    $Container =& CCGetParentContainer($sender);
    global $users_list;
    //Compatibility
    //End users_list_alm_users_user_photo_BeforeShow
    //Custom Code @31-2A29BDB7
    // -------------------------
    // Write your own code here.
    $db = new clsDBdbConnection();
    $user_guid = $users_list->alm_users->guid->GetValue();
    $photo = trim(CCDLookup("photo", "alm_users", "guid = '{$user_guid}'", $db));
    //Default photo
    if (strlen($photo) <= 0) {
        $photo = "user128.png";
    }
    $options = Options::getConsoleOptions();
    $url = $options["console_internal_url"] . $options["console_users_url"] . $photo;
    $users_list->alm_users->user_photo->SetValue($url);
    $db->close();
    // -------------------------
    //End Custom Code
    //Close users_list_alm_users_user_photo_BeforeShow @30-EE399A43
    return $users_list_alm_users_user_photo_BeforeShow;
}
 public function uploadUserPhoto($file, $params = array())
 {
     if (!empty($file) && strlen($params["guid"]) > 0) {
         $db = new clsDBdbConnection();
         $options = Options::getConsoleOptions();
         $uploadTo = $options["console_users_url"];
         $tmpFile = $file["file"]["tmp_name"];
         $fileName = $file["file"]["name"];
         $targetPath = dirname(__FILE__) . "/.." . $uploadTo;
         //because dirname will be positioned in include folder
         $fileExt = "." . pathinfo($fileName, PATHINFO_EXTENSION);
         $targetFilename = Options::getUUIDv6() . $fileExt;
         $targetFile = $targetPath . $targetFilename;
         //Updating an existing image, which will replace the existing one for the new
         $params["guid"] = $db->esc($params["guid"]);
         $existing_photo = CCDLookUp("photo", "alm_users", "guid = '{$params["guid"]}'", $db);
         $existing_photo = trim($existing_photo);
         if (strlen($existing_photo) > 0) {
             //Get the existing image name to re-use it and replace image on upload
             $targetFilename = $existing_photo;
             $targetFile = $targetPath . $targetFilename;
         }
         if (move_uploaded_file($tmpFile, $targetFile)) {
             //File successfully uploaded
             $params["image_name"] = $targetFilename;
             //Saving db file reference
             $this->saveCustomerImage($params);
             $db->close();
             return true;
         } else {
             $db->close();
             return false;
         }
         /*
         $log  = new Logger('almlogs');
         $log->pushHandler(new StreamHandler(MAIN_LOG, Logger::WARNING));
         $log->addWarning($params["guid"].LOG_LINESEPARATOR);
         $log->addWarning($params["title"].LOG_LINESEPARATOR);
         */
     } else {
         return false;
     }
 }
<?php

/**
 * Created by EdwardData
 * BlackCube Technologies 
 * Date: 1/9/14
 * Time: 6:20 PM
 * 
 */
/*
//Development purpose only classes, must be deactivated for production
include_once("../Common.php");
include_once("../Template.php");
include_once("../Sorter.php");
include_once("../Navigator.php");
*/
include_once __DIR__ . "/../vendor/autoload.php";
include_once __DIR__ . "/options.php";
define("MAIN_LOG", __DIR__ . "/logs/alm.log");
define("LOG_LINESEPARATOR", "\n*==================================================================*" . PHP_EOL);
//Getting website options
$options = new Options();
$consoleOptions = $options->getConsoleOptions();
define("WEBSITEURL", $consoleOptions["console_url"]);
 public function deleteLicenseFileByGuid($params = array())
 {
     $result = array("status" => false, "message" => "", "licensefile" => array());
     $licensefile_guid = $params["licensefile_guid"];
     if (strlen($licensefile_guid) > 0) {
         $db = new \clsDBdbConnection();
         $options = \Options::getConsoleOptions();
         //The dot(.) added is because the image will be loaded from the app root and url includes a first slah
         $licensesUrl = "." . $options["console_license_url"];
         $licenseFilename = CCDLookUp("filename", "alm_license_files", "guid = '{$licensefile_guid}' ", $db);
         if (strlen($licenseFilename) > 0) {
             $licenseFilename = $licensesUrl . $licenseFilename;
             if (unlink($licenseFilename)) {
                 //Deleting record after deleting phisical file
                 $sql = "delete from alm_license_files where guid = '{$licensefile_guid}' ";
                 $db->query($sql);
                 $result["status"] = true;
                 $result["message"] = "Command executed successfully.";
             } else {
                 //Checks if file doesnt note exist as well to delete record
                 if (!file_exists($licenseFilename)) {
                     //Deleting record after deleting phisical file
                     $sql = "delete from alm_license_files where guid = '{$licensefile_guid}' ";
                     $db->query($sql);
                 }
                 $result["status"] = false;
                 $result["message"] = "An error ocurred trying to delete file.";
             }
         } else {
             $result["status"] = false;
             $result["message"] = "Invalid Filename";
         }
         $db->close();
         return $result;
     } else {
         $result["status"] = false;
         $result["message"] = "Invalid GUID";
         return $result;
     }
 }