Esempio n. 1
0
 /**
  * Determines if a user can download the file
  * only using datetime if it is present
  *
  * @param unknown_type $user_id
  * @param unknown_type $datetime
  * @return unknown_type
  */
 function canDownload($user_id, $datetime = null)
 {
     // if the user is super admin, yes
     if (DSCAcl::isAdmin()) {
         return true;
     }
     // if the product file doesn't require purchase
     if (empty($this->purchase_required)) {
         return true;
     }
     // or because they have purchased it and the num_downloads is < max (or max == -1)
     // Check if they have an unlimited number of downloads
     $productdownloads = JTable::getInstance('ProductDownloads', 'CitruscartTable');
     $productdownloads->load(array('productfile_id' => $this->productfile_id, 'user_id' => $user_id));
     if ($productdownloads->productdownload_id) {
         if ($productdownloads->productdownload_max == '-1' || $productdownloads->productdownload_max > '0') {
             return true;
         }
     }
     // otherwise no
     return false;
 }
Esempio n. 2
0
 /**
  * Show the edit form or the field value based on the eav status
  * @param EavAttribute $eav
  * @param unknown_type $value
  */
 public static function showField($eav, $value = null)
 {
     $isAdmin = DSCAcl::isAdmin();
     switch ($eav->editable_by) {
         // No one
         case "0":
             return self::showValue($eav, $value);
             break;
             // Admin
         // Admin
         case "1":
             if ($isAdmin) {
                 return self::editForm($eav, $value);
             } else {
                 return self::showValue($eav, $value);
             }
             break;
         case "2":
         default:
             return self::editForm($eav, $value);
             break;
     }
 }