Example #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;
 }
Example #2
0
 /**
  * Processes a new order
  *
  * @param $order_id
  * @return unknown_type
  */
 function processOrder($order_id)
 {
     // get the order
     $model = JModelLegacy::getInstance('Orders', 'CitruscartModel');
     $model->setId($order_id);
     $order = $model->getItem();
     if ($order->user_id < Citruscart::getGuestIdStart()) {
         //load language from frontend so it has email  language strings
         $lang = JFactory::getLanguage();
         $lang->load('com_citruscart', JPATH_SITE);
         $details = array();
         $details['name'] = $order->billing_first_name . ' ' . $order->billing_last_name;
         $details['username'] = $order->userinfo_email;
         $details['email'] = $order->userinfo_email;
         jimport('joomla.user.helper');
         $details['password'] = JUserHelper::genRandomPassword();
         $details['password2'] = $details['password'];
         $user = CitruscartHelperUser::createNewUser($details);
         $order->user_id = $user->id;
         //update the order to the new user
         $table = $model->getTable();
         $table->load($order->order_id);
         $table->user_id = $user->id;
         $table->save();
         $model->clearCache();
         //
     }
     // find the products in the order that are integrated
     foreach ($order->orderitems as $orderitem) {
         $model = JModelLegacy::getInstance('Products', 'CitruscartModel');
         $model->setId($orderitem->product_id);
         $product = $model->getItem();
         $core_user_change_gid = $product->product_parameters->get('core_user_change_gid');
         $core_user_new_gid = $product->product_parameters->get('core_user_new_gid');
         if (!empty($core_user_change_gid)) {
             DSCAcl::addgroup($order->user_id, $core_user_new_gid);
         }
     }
 }
Example #3
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;
     }
 }