示例#1
0
 /**
  * Notify site admins that a group is created and it is pending moderation.
  *
  * @since	1.2
  * @access	public
  * @param	string
  * @return
  */
 public function notifyAdminsModeration(SocialGroup $group)
 {
     // Push arguments to template variables so users can use these arguments
     $params = array('title' => $group->getName(), 'creatorName' => $group->getCreator()->getName(), 'categoryTitle' => $group->getCategory()->get('title'), 'avatar' => $group->getAvatar(SOCIAL_AVATAR_LARGE), 'permalink' => JURI::root() . 'administrator/index.php?option=com_easysocial&view=groups&layout=pending', 'reject' => FRoute::controller('groups', array('external' => true, 'task' => 'rejectGroup', 'id' => $group->id, 'key' => $group->key)), 'approve' => FRoute::controller('groups', array('external' => true, 'task' => 'approveGroup', 'id' => $group->id, 'key' => $group->key)), 'alerts' => false);
     // Set the e-mail title
     $title = JText::sprintf('COM_EASYSOCIAL_EMAILS_GROUP_CREATED_MODERATOR_EMAIL_TITLE', $group->getName());
     // Get a list of super admins on the site.
     $usersModel = FD::model('Users');
     $admins = $usersModel->getSiteAdmins();
     foreach ($admins as $admin) {
         // Ensure that the user is a site admin or the Receive System email is turned off
         if (!$admin->isSiteAdmin() || !$admin->sendEmail) {
             continue;
         }
         // Immediately send out emails
         $mailer = FD::mailer();
         // Set the admin's name.
         $params['adminName'] = $admin->getName();
         // Get the email template.
         $mailTemplate = $mailer->getTemplate();
         // Set recipient
         $mailTemplate->setRecipient($admin->getName(), $admin->email);
         // Set title
         $mailTemplate->setTitle($title);
         // Set the template
         $mailTemplate->setTemplate('site/group/moderate', $params);
         // Set the priority. We need it to be sent out immediately since this is user registrations.
         $mailTemplate->setPriority(SOCIAL_MAILER_PRIORITY_IMMEDIATE);
         // Try to send out email to the admin now.
         $state = $mailer->create($mailTemplate);
     }
     return true;
 }