* @license https://files.froxlor.org/misc/COPYING.txt GPLv2 */ namespace Froxlor\Customer; use Froxlor\Database\Database; use PDO; class Customer { /** * Get value of a a specific field from a given customer * * @param int $customerid * @param string $varname * @return false|mixed * @throws \Exception */ public static function getCustomerDetail(int $customerid, string $varname) { $customer_stmt = Database::prepare(" SELECT `" . $varname . "` FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `customerid` = :customerid "); $customer = Database::pexecute_first($customer_stmt, [ 'customerid' => $customerid ]); if (isset($customer[$varname])) { return $customer[$varname]; } return false; } /** * returns the loginname of a customer by given uid * * @param int $uid uid of customer * * @return string customers loginname * @throws \Exception */ public static function getLoginNameByUid(int $uid) { $result_stmt = Database::prepare(" SELECT `loginname` FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `guid` = :guid "); $result = Database::pexecute_first($result_stmt, [ 'guid' => $uid ]); if ($result && isset($result['loginname'])) { return $result['loginname']; } return false; } /** * Function customerHasPerlEnabled * * returns true or false whether perl is * enabled for the given customer * * @param int $cid customer-id * * @return bool * @throws \Exception */ public static function customerHasPerlEnabled(int $cid = 0) { if ($cid > 0) { $result_stmt = Database::prepare(" SELECT `perlenabled` FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `customerid` = :cid"); $result = Database::pexecute_first($result_stmt, [ 'cid' => $cid ]); if ($result && isset($result['perlenabled'])) { return (bool)$result['perlenabled']; } } return false; } }