public static function _isPurchasable($a_ref_id, $a_vendor_id = 0, $a_check_trustee = false, $a_check_status = false) { global $ilDB; // In the moment it's not possible to sell one object twice $data = array(); $data_types = array(); $query = 'SELECT * FROM payment_objects WHERE ref_id = %s '; $data_types[] = 'integer'; $data[] = $a_ref_id; // check if object is buyable !! if ($a_check_status) { $query .= 'AND status > %s '; $data_types[] = 'integer'; $data[] = 0; } if ($a_vendor_id > 0) { $query .= 'AND vendor_id = %s'; $data_types[] = 'integer'; $data[] = $a_vendor_id; if ($a_check_trustee) { include_once './Services/Payment/classes/class.ilPaymentTrustees.php'; include_once './Services/Payment/classes/class.ilPaymentVendors.php'; $vendors = ilPaymentTrustees::_getVendorsForObjects($a_vendor_id); if (ilPaymentVendors::_isVendor($a_user_id)) { $vendors[] = $a_user_id; } if (is_array($vendors) && count($vendors)) { $query .= ' OR ' . $ilDB->in('vendor_id', $vendors, false, 'integer'); } } } $res = $ilDB->queryf($query, $data_types, $data); $rows = $ilDB->numRows($res); return $rows ? true : false; }
private function __getVendors() { include_once 'Services/Payment/classes/class.ilPaymentVendors.php'; $options = array(); $vendors = array(); if (ilPaymentVendors::_isVendor($this->user_obj->getId())) { $vendors[] = $this->user_obj->getId(); } if ($vend = ilPaymentTrustees::_getVendorsForObjects($this->user_obj->getId())) { $vendors = array_merge($vendors, $vend); } foreach ($vendors as $vendor) { /** @var $tmp_obj ilObjUser */ $tmp_obj = ilObjectFactory::getInstanceByObjId($vendor, false); $options[$vendor] = $tmp_obj->getFullname() . ' [' . $tmp_obj->getLogin() . ']'; } return $options; }