コード例 #1
0
 /**
  * Actually do the work of assigning a quota from the worksheets
  *
  * @param string $quota The amount of the quota
  * @param string $type What type is the quota
  * @param string $user_id Who is the quota for
  * @param string $timeperiod_id What timeperiod is the quota for
  * @param bool $disableActivityStream Should we disable activity streams and create our own entry
  */
 protected function _assignQuota($quota, $type, $user_id, $timeperiod_id, $disableActivityStream = false)
 {
     if ($disableActivityStream) {
         Activity::disable();
         $current_quota = $this->getQuota($user_id, $timeperiod_id, $type);
     }
     // get the updated quota back, this is needed because current_quota might be empty
     // as it could very well not exist yet.
     $quota = $this->commitQuota($quota, $user_id, $timeperiod_id, $type);
     $new_quota = $this->recalcQuotas($user_id, $timeperiod_id, true);
     if ($disableActivityStream) {
         Activity::enable();
         if ($new_quota !== $current_quota->amount) {
             $args = array('isUpdate' => !empty($current_quota->amount), 'dataChanges' => array('amount' => array('field_name' => 'amount', 'field_type' => 'currency', 'before' => $current_quota->amount, 'after' => $new_quota)));
             // Manually Create the Activity Stream Entry!
             SugarAutoLoader::load('modules/ActivityStream/Activities/ActivityQueueManager.php');
             $aqm = new ActivityQueueManager();
             $aqm->eventDispatcher($quota, 'after_save', $args);
         }
     }
 }