Пример #1
0
 /**
  * Add Finished
  * @version 1.1.1
  */
 public function add_finished($ran, $request, $mycred)
 {
     if ($ran !== false) {
         // Check if this reference has badges
         $badge_ids = mycred_ref_has_badge($request['ref'], $request);
         if ($badge_ids !== false) {
             mycred_check_if_user_gets_badge(absint($request['user_id']), $badge_ids, $request);
         }
     }
     return $ran;
 }
 /**
  * Email Notice Check
  * @since 1.1
  * @version 1.5
  */
 public function email_check($ran, $request, $mycred)
 {
     // Exit now if $ran is false or new settings is not yet saved.
     if ($ran === false || !isset($this->emailnotices['send'])) {
         return $ran;
     }
     $user_id = absint($request['user_id']);
     // Construct events
     $events = $this->get_events_from_instance($request, $mycred);
     // Badge Related
     if (function_exists('mycred_ref_has_badge')) {
         /*
         	In order for us to save on database queries down the line, we will
         	check if the user got any badges for this instnace and save the badge ids
         	under "badges".
         	
         	Since the process is already completed and we are simply "reacting" to the
         	event, we can manipulte $request without it having any effect on other features.
         */
         $badge_ids = mycred_ref_has_badge($request['ref']);
         if (!empty($badge_ids)) {
             $badges = mycred_check_if_user_gets_badge($user_id, $badge_ids, false);
             if (!empty($badges)) {
                 $events[] = 'badges|positive';
                 $request['badges'] = $badges;
             }
         }
     }
     // Do not send emails now
     if ($this->emailnotices['send'] != '') {
         // Save for cron job
         mycred_add_user_meta($user_id, 'mycred_scheduled_email_notices', '', array('events' => $events, 'request' => $request));
     } else {
         $this->do_email_notices($events, $request);
     }
     return $ran;
 }
Пример #3
0
 /**
  * myCRED Add
  * @version 1.0
  */
 public function mycred_add($reply, $request, $mycred)
 {
     // Declined
     if ($reply === false) {
         return $reply;
     }
     extract($request);
     // Check if this reference has badges
     $badge_ids = mycred_ref_has_badge($ref);
     if ($badge_ids === false) {
         return $reply;
     }
     // Indicate the mycred_check_if_user_gets_badge function that
     // the log entry for this already exists.
     if ($reply == 'done') {
         $request['done'] = true;
     }
     // Assign Badges
     mycred_check_if_user_gets_badge($user_id, $request, $badge_ids);
     return $reply;
 }