Ejemplo n.º 1
0
 public static function setQuotaSubscriptions(Quota $bean, $event, $args)
 {
     if ($event !== 'before_save') {
         return false;
     }
     // Subscribe the user making the quota change
     global $current_user;
     Subscription::subscribeUserToRecord($current_user, $bean);
     // Subscribe the user whose quota is getting changed
     $assignee = BeanFactory::retrieveBean('Users', $bean->user_id);
     Subscription::subscribeUserToRecord($assignee, $bean);
     return true;
 }
Ejemplo n.º 2
0
 public function subscribeToRecord(ServiceBase $api, array $args)
 {
     $this->requireArgs($args, array('module', 'record'));
     $bean = BeanFactory::retrieveBean($args['module'], $args['record']);
     if (empty($bean)) {
         throw new SugarApiExceptionNotFound('Could not find parent record ' . $args['record'] . ' in module ' . $args['module']);
     }
     if (!$bean->ACLAccess('view')) {
         $moduleName = null;
         if (isset($args['module'])) {
             $failed_module_strings = return_module_language($GLOBALS['current_language'], $args['module']);
             $moduleName = $failed_module_strings['LBL_MODULE_NAME'];
         }
         $args = null;
         if (!empty($moduleName)) {
             $args = array('moduleName' => $moduleName);
         }
         throw new SugarApiExceptionNotAuthorized('EXCEPTION_SUBSCRIBE_MODULE_NOT_AUTHORIZED', $args);
     }
     return Subscription::subscribeUserToRecord($api->user, $bean);
 }
Ejemplo n.º 3
0
 /**
  * Wraps the call to Subscription::subscribeUserToRecord so that we can mock it out in unit tests.
  *
  * @param User      $user
  * @param SugarBean $bean
  * @return bool|string
  */
 protected function subscribeUserToRecord(User $user, SugarBean $bean)
 {
     return Subscription::subscribeUserToRecord($user, $bean);
 }