public function onGroupJoin($group, $userId)
 {
     //@rule: Clear existing invites fromt he invitation table once the user joined the group
     $groupInvite =& JTable::getInstance('GroupInvite', 'CTable');
     if ($groupInvite->load($group->id, $userId)) {
         $groupInvite->delete();
     }
     $member =& JTable::getInstance('GroupMembers', 'CTable');
     $member->load($userId, $group->id);
     $groupModel = CFactory::getModel('groups');
     $admins = $groupModel->getAdmins($group->id, null);
     $params = $group->getParams();
     //@rule: Send notification when necessary
     if ($params->get('joinrequestnotification') || $params->get('newmembernotification')) {
         $user = CFactory::getUser($userId);
         $subject = JText::sprintf('COM_COMMUNITY_GROUPS_EMAIL_NEW_MEMBER_JOINED_SUBJECT', $user->getDisplayName(), $group->name);
         if (!$member->approved) {
             $subject = JText::sprintf('COM_COMMUNITY_NEW_MEMBER_REQUESTED_TO_JOIN_GROUP_EMAIL_SUBJECT', $user->getDisplayName(), $group->name);
         }
         // Add notification
         CFactory::load('libraries', 'notification');
         $params = new CParameter('');
         $params->set('url', 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id);
         $params->set('group', $group->name);
         $params->set('user', $user->getDisplayName());
         $params->set('approved', $member->approved);
         foreach ($admins as $admin) {
             CNotificationLibrary::add('etype_groups_member_join', $user->id, $admin->id, $subject, '', 'groups.memberjoin', $params);
         }
     }
 }
Exemple #2
0
 public function onGroupJoin($group, $userId)
 {
     //@rule: Clear existing invites fromt he invitation table once the user joined the group
     $groupInvite =& JTable::getInstance('GroupInvite', 'CTable');
     if ($groupInvite->load($group->id, $userId)) {
         $groupInvite->delete();
     }
     $member =& JTable::getInstance('GroupMembers', 'CTable');
     $member->load($userId, $group->id);
     $params = $group->getParams();
     //@rule: Send notification when necessary
     if ($params->get('joinrequestnotification') || $params->get('newmembernotification')) {
         $user = CFactory::getUser($userId);
         $subject = JText::sprintf('CC NEW MEMBER JOIN EMAIL SUBJECT', $user->getDisplayName(), $group->name);
         if (!$member->approved) {
             $subject = JText::sprintf('CC NEW MEMBER REQUESTED TO JOIN GROUP EMAIL SUBJECT', $user->getDisplayName(), $group->name);
         }
         // Add notification
         CFactory::load('libraries', 'notification');
         $params = new JParameter('');
         $params->set('url', 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id);
         $params->set('group', $group->name);
         $params->set('user', $user->getDisplayName());
         $params->set('approved', $member->approved);
         CNotificationLibrary::add('groups.member.join', $user->id, $group->ownerid, $subject, '', 'groups.memberjoin', $params);
     }
 }
Exemple #3
0
 public function ajaxTogglePublish($id, $type, $eventName = false)
 {
     // Send email notification to owner when a group is published.
     $config = CFactory::getConfig();
     $event = JTable::getInstance('Event', 'CTable');
     $event->load($id);
     // Added published = 2 for new created event under moderation.
     if ($type == 'published' && $event->published == 2) {
         $lang = JFactory::getLanguage();
         $lang->load('com_community', JPATH_ROOT);
         $my = CFactory::getUser();
         // Add notification
         //CFactory::load('libraries', 'notification');
         //CFactory::load('helpers', 'event');
         if ($event->type == CEventHelper::GROUP_TYPE && $event->contentid != 0) {
             $url = 'index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id . '&groupid=' . $event->contentid;
         } else {
             $url = 'index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id;
         }
         //Send notification email to owner
         $params = new CParameter('');
         $params->set('url', 'index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id);
         $params->set('event', $event->title);
         $params->set('event_url', 'index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id);
         CNotificationLibrary::add('events_notify_creator', $my->id, $event->creator, JText::_('COM_COMMUNITY_EVENTS_PUBLISHED_MAIL_SUBJECT'), '', 'events.notifycreator', $params);
         //CFactory::load('libraries', 'events');
         // Add activity stream for new created event.
         $event->published = 1;
         // by pass published checking.
         CEvents::addEventStream($event);
         // send notification email to group's member for new created event.
         CEvents::addGroupNotification($event);
     }
     return parent::ajaxTogglePublish($id, $type, 'events');
 }
Exemple #4
0
 public function ajaxSendMessage($title, $message, $limit = 1)
 {
     if (!$title || !$message) {
         $response = new JAXResponse();
         $response->addScriptCall("joms.jQuery('#error').remove();");
         $response->addScriptCall('joms.jQuery("#messaging-form").prepend("<p id=error style=color:red>Error:Title or Message cannot be empty</p>");');
         return $response->sendResponse();
     }
     $limitstart = $limit - 1;
     $model =& $this->getModel('users');
     $userId = $model->getSiteUsers($limitstart, 1);
     $response = new JAXResponse();
     $response->addScriptCall('joms.jQuery("#messaging-form").hide();');
     $response->addScriptCall('joms.jQuery("#messaging-result").show();');
     $user = CFactory::getUser($userId);
     $my =& JFactory::getUser();
     if (!empty($userId)) {
         require_once JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'notification.php';
         CNotificationLibrary::add('etype_system_messaging', $my->id, $user->id, $title, $message);
         $response->addScriptCall('joms.jQuery("#no-progress").css("display","none");');
         $response->addScriptCall('joms.jQuery("#progress-status").append("<div>' . JText::sprintf('Sending message to <strong>%1$s</strong>', str_replace(array("\r", "\n"), ' ', $user->getDisplayname())) . '<span style=\\"color: green;margin-left: 5px;\\">' . JText::_('COM_COMMUNITY_SUCCESS') . '</span></div>");');
         $response->addScriptCall('sendMessage', $title, $message, $limit + 1);
     } else {
         $response->addScriptCall('joms.jQuery("#progress-status").append("<div style=\\"font-weight:700;\\">' . JText::_('COM_COMMUNITY_UPDATED') . '</div>");');
     }
     return $response->sendResponse();
 }
Exemple #5
0
 public static function sendCommentNotification(CTableWall $wall, $message)
 {
     CFactory::load('libraries', 'notification');
     $my = CFactory::getUser();
     $targetUser = CFactory::getUser($wall->post_by);
     $url = 'index.php?option=com_community&view=events&task=viewevent&eventid=' . $wall->contentid;
     $params = $targetUser->getParams();
     $params = new JParameter('');
     $params->set('url', $url);
     $params->set('message', $message);
     CNotificationLibrary::add('events.submit.wall.comment', $my->id, $targetUser->id, JText::sprintf('PLG_WALLS WALL COMMENT EMAIL SUBJECT', $my->getDisplayName()), '', 'events.wallcomment', $params);
     return true;
 }
Exemple #6
0
 public function ajaxEmailPage($uri, $emails, $message = '')
 {
     $filter = JFilterInput::getInstance();
     $uri = $filter->clean($uri, 'string');
     $emails = $filter->clean($emails, 'string');
     $message = $filter->clean($message, 'string');
     $message = stripslashes($message);
     $mainframe =& JFactory::getApplication();
     $bookmarks = CFactory::getBookmarks($uri);
     $mailqModel = CFactory::getModel('mailq');
     $config = CFactory::getConfig();
     $response = new JAXResponse();
     if (empty($emails)) {
         $content = '<div>' . JText::_('COM_COMMUNITY_SHARE_INVALID_EMAIL') . '</div>';
         $actions = '<input type="button" class="button" onclick="joms.bookmarks.show(\'' . $uri . '\');" value="' . JText::_('COM_COMMUNITY_GO_BACK_BUTTON') . '"/>';
     } else {
         $emails = explode(',', $emails);
         $errors = array();
         // Add notification
         CFactory::load('libraries', 'notification');
         foreach ($emails as $email) {
             $email = JString::trim($email);
             CFactory::load('helpers', 'validate');
             if (!empty($email) && CValidateHelper::email($email)) {
                 $params = new CParameter('');
                 $params->set('uri', $uri);
                 $params->set('message', $message);
                 CNotificationLibrary::add('etype_system_bookmarks_email', '', $email, JText::sprintf('COM_COMMUNITY_SHARE_EMAIL_SUBJECT', $config->get('sitename')), '', 'bookmarks', $params);
             } else {
                 // If there is errors with email, inform the user.
                 $errors[] = $email;
             }
         }
         if ($errors) {
             $content = '<div>' . JText::_('COM_COMMUNITY_EMAILS_ARE_INVALID') . '</div>';
             foreach ($errors as $error) {
                 $content .= '<div style="font-weight:700;color: red;">' . $error . '</span>';
             }
             $actions = '<input type="button" class="button" onclick="joms.bookmarks.show(\'' . $uri . '\');" value="' . JText::_('COM_COMMUNITY_GO_BACK_BUTTON') . '"/>';
         } else {
             $content = '<div>' . JText::_('COM_COMMUNITY_EMAIL_SENT_TO_RECIPIENTS') . '</div>';
             $actions = '<input type="button" class="button" onclick="cWindowHide();" value="' . JText::_('COM_COMMUNITY_DONE_BUTTON') . '"/>';
         }
     }
     $response->addAssign('cwin_logo', 'innerHTML', JText::_('COM_COMMUNITY_SHARE_THIS'));
     $response->addScriptCall('cWindowAddContent', $content, $actions);
     return $response->sendResponse();
 }
Exemple #7
0
 public static function sendCommentNotification(CTableWall $wall, $message)
 {
     CFactory::load('libraries', 'notification');
     $my = CFactory::getUser();
     $targetUser = CFactory::getUser($wall->post_by);
     $url = 'index.php?option=com_community&view=profile&userid=' . $wall->contentid;
     $userParams = $targetUser->getParams();
     $params = new CParameter('');
     $params->set('url', $url);
     $params->set('message', $message);
     if ($my->id != $targetUser->id && $userParams->get('notifyWallComment')) {
         CNotificationLibrary::add('etype_profile_submit_wall_comment', $my->id, $targetUser->id, JText::sprintf('PLG_WALLS_WALL_COMMENT_EMAIL_SUBJECT', $my->getDisplayName()), '', 'profile.wallcomment', $params);
         return true;
     }
     return false;
 }
Exemple #8
0
 public function ajaxEmailPage($uri, $emails, $message = '')
 {
     $message = stripslashes($message);
     $mainframe =& JFactory::getApplication();
     $bookmarks = CFactory::getBookmarks($uri);
     $mailqModel = CFactory::getModel('mailq');
     $config = CFactory::getConfig();
     $response = new JAXResponse();
     if (empty($emails)) {
         $content = '<div>' . JText::_('CC SHARE INVALID EMAIL') . '</div>';
         $buttons = '<input type="button" class="button" onclick="joms.bookmarks.show(\'' . $uri . '\');" value="' . JText::_('CC BUTTON GO BACK') . '"/>';
     } else {
         $emails = explode(',', $emails);
         $errors = array();
         // Add notification
         CFactory::load('libraries', 'notification');
         foreach ($emails as $email) {
             $email = JString::trim($email);
             if (!empty($email) && preg_match("/^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,4})\$/i", $email)) {
                 $params = new JParameter('');
                 $params->set('uri', $uri);
                 $params->set('message', $message);
                 CNotificationLibrary::add('system.bookmarks.email', '', $email, JText::sprintf('CC SHARE EMAIL SUBJECT', $config->get('sitename')), '', 'bookmarks', $params);
             } else {
                 // If there is errors with email, inform the user.
                 $errors[] = $email;
             }
         }
         if ($errors) {
             $content = '<div>' . JText::_('CC EMAILS ARE INVALID') . '</div>';
             foreach ($errors as $error) {
                 $content .= '<div style="font-weight:700;color: red;">' . $error . '</span>';
             }
             $buttons = '<input type="button" class="button" onclick="joms.bookmarks.show(\'' . $uri . '\');" value="' . JText::_('CC BUTTON GO BACK') . '"/>';
         } else {
             $content = '<div>' . JText::_('CC EMAIL SENT TO RECIPIENTS') . '</div>';
             $buttons = '<input type="button" class="button" onclick="cWindowHide();" value="' . JText::_('CC BUTTON DONE') . '"/>';
         }
     }
     $response->addAssign('cwin_logo', 'innerHTML', JText::_('CC SHARE THIS'));
     $response->addAssign('cWindowContent', 'innerHTML', $content);
     $response->addScriptCall('cWindowActions', $buttons);
     $response->addScriptCall('cWindowResize', 100);
     return $response->sendResponse();
 }
Exemple #9
0
 public function ajaxEmailPage($uri, $emails, $message = '')
 {
     $filter = JFilterInput::getInstance();
     $uri = $filter->clean($uri, 'string');
     $emails = $filter->clean($emails, 'string');
     $message = $filter->clean($message, 'string');
     $message = stripslashes($message);
     $mainframe = JFactory::getApplication();
     $bookmarks = CFactory::getBookmarks($uri);
     $mailqModel = CFactory::getModel('mailq');
     $config = CFactory::getConfig();
     $response = new JAXResponse();
     $json = array();
     if (empty($emails)) {
         $json['error'] = JText::_('COM_COMMUNITY_SHARE_INVALID_EMAIL');
     } else {
         $emails = explode(',', $emails);
         $errors = array();
         // Add notification
         //CFactory::load( 'libraries' , 'notification' );
         foreach ($emails as $email) {
             $email = JString::trim($email);
             if (!empty($email) && CValidateHelper::email($email)) {
                 $params = new CParameter('');
                 $params->set('uri', $uri);
                 $params->set('message', $message);
                 CNotificationLibrary::add('system_bookmarks_email', '', $email, JText::sprintf('COM_COMMUNITY_SHARE_EMAIL_SUBJECT', $config->get('sitename')), '', 'bookmarks', $params);
             } else {
                 // If there is errors with email, inform the user.
                 $errors[] = $email;
             }
         }
         if ($errors) {
             $content = '<div>' . JText::_('COM_COMMUNITY_EMAILS_ARE_INVALID') . '</div>';
             foreach ($errors as $error) {
                 $content .= '<div style="font-weight:bold; color:red;">' . $error . '</div>';
             }
             $json['error'] = $content;
         } else {
             $content = JText::_('COM_COMMUNITY_EMAIL_SENT_TO_RECIPIENTS');
             $json['message'] = $content;
         }
     }
     die(json_encode($json));
 }
Exemple #10
0
 public function ajaxTogglePublish($id, $type)
 {
     // Send email notification to owner when a group is published.
     $config =& CFactory::getConfig();
     $group =& JTable::getInstance('Group', 'CTable');
     $group->load($id);
     if ($type == 'published' && $group->published == 0 && $config->get('moderategroupcreation')) {
         $lang =& JFactory::getLanguage();
         $lang->load('com_community', JPATH_ROOT);
         $my =& CFactory::getUser();
         // Add notification
         CFactory::load('libraries', 'notification');
         //Send notification email to owner
         $params = new CParameter('');
         $params->set('url', 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id);
         $params->set('groupName', $group->name);
         CNotificationLibrary::add('etype_groups_notify_creator', $my->id, $group->ownerid, JText::sprintf('COM_COMMUNITY_GROUPS_PUBLISHED_MAIL_SUBJECT', $group->name), '', 'groups.notifycreator', $params);
     }
     return parent::ajaxTogglePublish($id, $type, 'groups');
 }
Exemple #11
0
 function ajaxSendMessage($title, $message, $limit = 1)
 {
     $limitstart = $limit - 1;
     $model =& $this->getModel('users');
     $userId = $model->getSiteUsers($limitstart, 1);
     $response = new JAXResponse();
     $response->addScriptCall('joms.jQuery("#messaging-form").hide();');
     $response->addScriptCall('joms.jQuery("#messaging-result").show();');
     $user = CFactory::getUser($userId);
     $my =& JFactory::getUser();
     if (!empty($userId)) {
         require_once JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'notification.php';
         CNotificationLibrary::add('system.messaging', $my->id, $user->id, $title, $message);
         $response->addScriptCall('joms.jQuery("#no-progress").css("display","none");');
         $response->addScriptCall('joms.jQuery("#progress-status").append("<div>' . JText::sprintf('Sending message to <strong>%1$s</strong>', $user->getDisplayname()) . '<span style=\\"color: green;margin-left: 5px;\\">' . JText::_('CC SUCCESS') . '</span></div>");');
         $response->addScriptCall('sendMessage', $title, $message, $limit + 1);
     } else {
         $response->addScriptCall('joms.jQuery("#progress-status").append("<div style=\\"font-weight:700;\\">' . JText::_('CC UPDATE COMPLETED') . '</div>");');
     }
     return $response->sendResponse();
 }
 public function onEventCreate($event)
 {
     $config = CFactory::getConfig();
     // Send an email notification to the site admin's when there is a new group created
     if ($config->get('event_moderation')) {
         $userModel = CFactory::getModel('User');
         $my = CFactory::getUser();
         $admins = $userModel->getSuperAdmins();
         // Add notification
         CFactory::load('libraries', 'notification');
         //Send notification email to administrators
         foreach ($admins as $row) {
             if ($row->sendEmail) {
                 $params = new CParameter('');
                 $params->set('url', JURI::root() . 'administrator/index.php?option=com_community&view=events');
                 $params->set('title', $event->title);
                 CNotificationLibrary::add('etype_events_notify_admin', $my->id, $row->id, JText::sprintf('COM_COMMUNITY_EVENTS_MODERATION_NOTICE', $event->title), '', 'events.notifyadmin', $params);
             }
         }
     }
 }
 public function onEventCreate($event)
 {
     $config = CFactory::getConfig();
     // Send an email notification to the site admin's when there is a new group created
     if ($config->get('event_moderation')) {
         $userModel = CFactory::getModel('User');
         $my = CFactory::getUser();
         $admins = $userModel->getSuperAdmins();
         //Send notification email to administrators
         foreach ($admins as $row) {
             if ($event->type == CEventHelper::GROUP_TYPE && $event->contentid != 0) {
                 $event_url = 'index.php?option=com_community&view=events&task=viewevent&groupid=' . $event->contentid . '&eventid=' . $event->id;
             } else {
                 $event_url = 'index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id;
             }
             $params = new CParameter('');
             $params->set('url', JURI::root() . 'administrator/index.php?option=com_community&view=events');
             $params->set('title', $event->title);
             $params->set('event', $event->title);
             $params->set('event_url', JURI::root() . 'administrator/index.php?option=com_community&view=events');
             CNotificationLibrary::add('events_notify_admin', $my->id, $row->id, JText::sprintf('COM_COMMUNITY_EVENT_CREATION_MODERATION_EMAIL_SUBJECT'), '', 'events.notifyadmin', $params);
         }
     }
 }
Exemple #14
0
 public function onAfterThankyou($actor, $target, $message)
 {
     CFactory::load('libraries', 'userpoints');
     CUserPoints::assignPoint('com_kunena.thread.thankyou', $target);
     $actor = CFactory::getUser($actor);
     $target = CFactory::getUser($target);
     //Create CParameter use for params
     $params = new CParameter('');
     $params->set('actorName', $actor->getDisplayName());
     $params->set('recipientName', $target->getDisplayName());
     $params->set('recipientUrl', 'index.php?option=com_community&view=profile&userid=' . $target->id);
     // Actor Link
     $params->set('url', JUri::getInstance()->toString(array('scheme', 'host', 'port')) . $message->getPermaUrl(null));
     // {url} tag for activity. Used when hovering over avatar in notification window, as well as in email notification
     $params->set('title', $message->displayField('subject'));
     // (title) tag in language file
     $params->set('title_url', $message->getPermaUrl());
     // Make the title in notification - linkable
     $params->set('message', $message->message);
     // (message) tag in language file
     $params->set('actor', $actor->getDisplayName());
     // Actor in the stream
     $params->set('actor_url', 'index.php?option=com_community&view=profile&userid=' . $actor->id);
     // Actor Link
     // Finally, send notifications
     CNotificationLibrary::add('kunena_thankyou', $actor->id, $target->id, JText::sprintf('PLG_KUNENA_COMMUNITY_ACTIVITY_THANKYOU_TITLE_ACT'), JText::sprintf('PLG_KUNENA_COMMUNITY_ACTIVITY_THANKYOU_TEXT'), '', $params);
     $act = new stdClass();
     $act->cmd = 'wall.write';
     $act->actor = $actor->id;
     $act->target = $target->id;
     $act->title = JText::sprintf('PLG_KUNENA_COMMUNITY_ACTIVITY_THANKYOU_WALL', $params->get('actor_url'), $params->get('actor'), $params->get('recipientUrl'), $params->get('recipientName'), $params->get('url'), $params->get('title'));
     $act->content = NULL;
     $act->app = 'kunena.message.thankyou';
     $act->cid = $target->id;
     $act->access = $this->getAccess($message->getCategory());
     // Comments and like support
     $act->comment_id = $target->id;
     $act->comment_type = 'kunena.message.thankyou';
     $act->like_id = $target->id;
     $act->like_type = 'kunena.message.thankyou';
     // Do not add private activities
     if ($act->access > 20) {
         return;
     }
     CFactory::load('libraries', 'activities');
     $table = CActivityStream::add($act);
     if (is_object($table)) {
         $table->like_id = $table->id;
         $table->store();
     }
 }
Exemple #15
0
 /**
  * Show Invite
  */
 public function invitefriends()
 {
     $document = JFactory::getDocument();
     $viewType = $document->getType();
     $viewName = JRequest::getCmd('view', $this->getName());
     $view =& $this->getView($viewName, '', $viewType);
     $my = CFactory::getUser();
     $invited = JRequest::getVar('invite-list', '', 'POST');
     $inviteMessage = JRequest::getVar('invite-message', '', 'POST');
     $eventId = JRequest::getInt('eventid', '', 'REQUEST');
     $model =& $this->getModel('events');
     $event =& JTable::getInstance('Event', 'CTable');
     $event->load($eventId);
     if ($my->id == 0) {
         return $this->blockUnregister();
     }
     $status = $event->getUserStatus($my->id);
     $allowed = array(COMMUNITY_EVENT_STATUS_INVITED, COMMUNITY_EVENT_STATUS_ATTEND, COMMUNITY_EVENT_STATUS_WONTATTEND, COMMUNITY_EVENT_STATUS_MAYBE);
     $accessAllowed = in_array($status, $allowed) && $status != COMMUNITY_EVENT_STATUS_BLOCKED ? true : false;
     $accessAllowed = COwnerHelper::isCommunityAdmin() ? true : $accessAllowed;
     if (!($accessAllowed && $event->allowinvite) && !$event->isAdmin($my->id)) {
         echo JText::_('COM_COMMUNITY_ACCESS_FORBIDDEN');
         return;
     }
     if (JRequest::getMethod() == 'POST') {
         // Check for request forgeries
         JRequest::checkToken() or jexit(JText::_('COM_COMMUNITY_INVALID_TOKEN'));
         if (!empty($invited)) {
             $mainframe =& JFactory::getApplication();
             $invitedCount = 0;
             foreach ($invited as $invitedUserId) {
                 $date =& JFactory::getDate();
                 $eventMember =& JTable::getInstance('EventMembers', 'CTable');
                 $eventMember->eventid = $event->id;
                 $eventMember->memberid = $invitedUserId;
                 $eventMember->status = COMMUNITY_EVENT_STATUS_INVITED;
                 $eventMember->invited_by = $my->id;
                 $eventMember->created = $date->toMySQL();
                 $eventMember->store();
                 $invitedCount++;
             }
             //now update the invited count in event
             $event->invitedcount = $event->invitedcount + $invitedCount;
             $event->store();
             // Send notification to the invited user.
             CFactory::load('libraries', 'notification');
             $params = new CParameter('');
             $params->set('url', CRoute::getExternalURL('index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id));
             $params->set('eventTitle', $event->title);
             $params->set('message', $inviteMessage);
             CNotificationLibrary::add('etype_events_invite', $my->id, $invited, JText::sprintf('COM_COMMUNITY_EVENTS_JOIN_INVITE', $event->title), '', 'events.invite', $params);
             $view->addInfo(JText::_('COM_COMMUNITY_EVENTS_INVITATION_SENT'));
         } else {
             $view->addWarning(JText::_('COM_COMMUNITY_INVITE_NEED_AT_LEAST_1_FRIEND'));
         }
     }
     echo $view->get(__FUNCTION__);
 }
Exemple #16
0
 /**
  * Preview a photo upload
  * @return type
  *
  */
 public function ajaxPreview()
 {
     $jinput = JFactory::getApplication()->input;
     $my = CFactory::getUser();
     $config = CFactory::getConfig();
     $groupId = $jinput->get('groupid', '0', 'INT');
     $type = $groupId == 0 ? PHOTOS_USER_TYPE : PHOTOS_GROUP_TYPE;
     $albumId = $groupId == 0 ? $my->id : $groupId;
     if (CLimitsLibrary::exceedDaily('photos')) {
         $this->_showUploadError(true, JText::_('COM_COMMUNITY_PHOTOS_LIMIT_REACHED'));
         return;
     }
     // We can't use blockUnregister here because practically, the CFactory::getUser() will return 0
     if ($my->id == 0) {
         $this->_showUploadError(true, JText::_('COM_COMMUNITY_PROFILE_NEVER_LOGGED_IN'));
         return;
     }
     // Get default album or create one
     $model = CFactory::getModel('photos');
     $album = $model->getDefaultAlbum($albumId, $type);
     $newAlbum = false;
     if (empty($album)) {
         $album = JTable::getInstance('Album', 'CTable');
         $album->load();
         $handler = $this->_getHandler($album);
         $newAlbum = true;
         $now = new JDate();
         $album->creator = $my->id;
         $album->created = $now->toSql();
         $album->type = $handler->getType();
         $album->default = '1';
         $album->groupid = $groupId;
         switch ($type) {
             case PHOTOS_USER_TYPE:
                 $album->name = JText::sprintf('COM_COMMUNITY_DEFAULT_ALBUM_CAPTION', $my->getDisplayName());
                 break;
             case PHOTOS_GROUP_TYPE:
                 $group = JTable::getInstance('Group', 'CTable');
                 $group->load($groupId);
                 $album->name = JText::sprintf('COM_COMMUNITY_GROUP_DEFAULT_ALBUM_NAME', $group->name);
                 break;
         }
         $albumPath = $handler->getAlbumPath($album->id);
         $albumPath = CString::str_ireplace(JPATH_ROOT . '/', '', $albumPath);
         $albumPath = CString::str_ireplace('\\', '/', $albumPath);
         $album->path = $albumPath;
         $album->store();
         if ($type == PHOTOS_GROUP_TYPE) {
             $group = JTable::getInstance('Group', 'CTable');
             $group->load($groupId);
             $modelGroup = $this->getModel('groups');
             $groupMembers = array();
             $groupMembers = $modelGroup->getMembersId($album->groupid, true);
             $params = new CParameter('');
             $params->set('albumName', $album->name);
             $params->set('group', $group->name);
             $params->set('group_url', 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id);
             $params->set('album', $album->name);
             $params->set('album_url', 'index.php?option=com_community&view=photos&task=album&albumid=' . $album->id . '&groupid=' . $group->id);
             $params->set('url', 'index.php?option=com_community&view=photos&task=album&albumid=' . $album->id . '&groupid=' . $group->id);
             CNotificationLibrary::add('groups_create_album', $my->id, $groupMembers, JText::sprintf('COM_COMMUNITY_GROUP_NEW_ALBUM_NOTIFICATION'), '', 'groups.album', $params);
         }
     } else {
         $albumId = $album->id;
         $album = JTable::getInstance('Album', 'CTable');
         $album->load($albumId);
         $handler = $this->_getHandler($album);
     }
     $photos = JRequest::get('Files');
     //$jinput->files->get('filedata');
     foreach ($photos as $image) {
         // @todo: foreach here is redundant since we exit on the first loop
         $result = $this->_checkUploadedFile($image, $album, $handler);
         if (!$result['photoTable']) {
             continue;
         }
         //assign the result of the array and assigned to the right variable
         $photoTable = $result['photoTable'];
         $storage = $result['storage'];
         $albumPath = $result['albumPath'];
         $hashFilename = $result['hashFilename'];
         $thumbPath = $result['thumbPath'];
         $originalPath = $result['originalPath'];
         $imgType = $result['imgType'];
         $isDefaultPhoto = $result['isDefaultPhoto'];
         // Remove the filename extension from the caption
         if (JString::strlen($photoTable->caption) > 4) {
             $photoTable->caption = JString::substr($photoTable->caption, 0, JString::strlen($photoTable->caption) - 4);
         }
         // @todo: configurable options?
         // Permission should follow album permission
         $photoTable->published = '1';
         $photoTable->permissions = $album->permissions;
         $photoTable->status = 'temp';
         // Set the relative path.
         // @todo: configurable path?
         $storedPath = $handler->getStoredPath($storage, $album->id);
         $storedPath = $storedPath . '/' . $albumPath . $hashFilename . CImageHelper::getExtension($image['type']);
         $photoTable->image = CString::str_ireplace(JPATH_ROOT . '/', '', $storedPath);
         $photoTable->thumbnail = CString::str_ireplace(JPATH_ROOT . '/', '', $thumbPath);
         // In joomla 1.6, CString::str_ireplace is not replacing the path properly. Need to do a check here
         if ($photoTable->image == $storedPath) {
             $photoTable->image = str_ireplace(JPATH_ROOT . '/', '', $storedPath);
         }
         if ($photoTable->thumbnail == $thumbPath) {
             $photoTable->thumbnail = str_ireplace(JPATH_ROOT . '/', '', $thumbPath);
         }
         // Photo filesize, use sprintf to prevent return of unexpected results for large file.
         $photoTable->filesize = sprintf("%u", filesize($originalPath));
         // @rule: Set the proper ordering for the next photo upload.
         $photoTable->setOrdering();
         // Store the object
         $photoTable->store();
         if ($newAlbum) {
             $album->photoid = $photoTable->id;
             $album->store();
         }
         // We need to see if we need to rotate this image, from EXIF orientation data
         // Only for jpeg image.
         if ($config->get('photos_auto_rotate') && $imgType == 'image/jpeg') {
             $this->_rotatePhoto($image, $photoTable, $storedPath, $thumbPath);
         }
         $tmpl = new CTemplate();
         $tmpl->set('photo', $photoTable);
         $tmpl->set('filename', $image['name']);
         $html = $tmpl->fetch('status.photo.item');
         $photo = new stdClass();
         $photo->id = $photoTable->id;
         $photo->thumbnail = $photoTable->thumbnail;
         $photo->html = rawurlencode($html);
         echo json_encode($photo);
     }
     exit;
 }
Exemple #17
0
 /**
  * @param $message
  * @param $actor
  * @param $object
  * @param array $info
  * @return bool
  */
 static function parseTaggedUserNotification($message, $actor, $object = null, $info = array())
 {
     $pattern = '/@\\[\\[(\\d+):([a-z]+):([^\\]]+)\\]\\]/';
     preg_match_all($pattern, $message, $matches);
     if (isset($matches[1]) && count($matches[1]) > 0) {
         //lets count total recipients and blast notifications
         $taggedIds = array();
         foreach ($matches[1] as $uid) {
             $taggedIds[] = CFactory::getUser($uid)->get('id') != 0 ? $uid : null;
         }
         if ($info['type'] == 'discussion-comment') {
             //link to lead the user to the discussion
             $url = CRoute::emailLink('index.php?option=com_community&view=groups&task=viewdiscussion&groupid=' . $info['group_id'] . '&topicid=' . $info['discussion_id'] . '#activity-stream-container');
             $params = new CParameter();
             $params->set('url', $url);
             $params->set('content', $message);
             $params->set('discussion', '<a href="' . $url . '">' . JText::_('COM_COMMUNITY_DISCUSSION') . '</a>');
             $emailSubject = JText::sprintf('COM_COMMUNITY_DISCUSSION_USER_TAGGED_EMAIL_SUBJECT');
             $emailContent = JText::sprintf('COM_COMMUNITY_USER_TAGGED_COMMENT_EMAIL_CONTENT', $url);
             $notificationMessage = JText::_('COM_COMMUNITY_NOTIFICATION_DISCUSSION_USER_TAGGED');
         } else {
             if ($info['type'] == 'album-comment') {
                 //link to lead the user to the album
                 $url = CRoute::emailLink('index.php?option=com_community&view=photos&task=album&userid=' . $info['album_creator_id'] . '&albumid=' . $info['album_id'] . '#activity-stream-container');
                 $params = new CParameter();
                 $params->set('url', $url);
                 $params->set('content', $message);
                 $params->set('album', '<a href="' . $url . '">' . JText::_('COM_COMMUNITY_SINGULAR_ALBUM') . '</a>');
                 $emailSubject = JText::sprintf('COM_COMMUNITY_ALBUM_USER_TAGGED_EMAIL_SUBJECT');
                 $emailContent = JText::sprintf('COM_COMMUNITY_USER_TAGGED_COMMENT_EMAIL_CONTENT', $url);
                 $notificationMessage = JText::_('COM_COMMUNITY_NOTIFICATION_ALBUM_USER_TAGGED');
             } else {
                 if ($info['type'] == 'video-comment') {
                     //link to lead the user to the video
                     $url = CRoute::emailLink('index.php?option=com_community&view=videos&task=video&userid=' . $actor->id . '&videoid=' . $info['video_id'] . '#activity-stream-container');
                     $params = new CParameter();
                     $params->set('url', $url);
                     $params->set('content', $message);
                     $params->set('video', '<a href="' . $url . '">' . JText::_('COM_COMMUNITY_SINGULAR_PHOTO') . '</a>');
                     $emailSubject = JText::sprintf('COM_COMMUNITY_VIDEO_USER_TAGGED_EMAIL_SUBJECT');
                     $emailContent = JText::sprintf('COM_COMMUNITY_USER_TAGGED_COMMENT_EMAIL_CONTENT', $url);
                     $notificationMessage = JText::_('COM_COMMUNITY_NOTIFICATION_VIDEO_USER_TAGGED');
                 } else {
                     if ($info['type'] == 'image-comment') {
                         //link to lead the user to the picture
                         $url = CRoute::emailLink('index.php?option=com_community&view=photos&task=photo&userid=' . $actor->id . '&albumid=' . $info['album_id'] . '&photoid=' . $info['image_id'] . '#activity-stream-container');
                         $params = new CParameter();
                         $params->set('url', $url);
                         $params->set('content', $message);
                         $params->set('photo', '<a href="' . $url . '">' . JText::_('COM_COMMUNITY_SINGULAR_PHOTO') . '</a>');
                         $emailSubject = JText::sprintf('COM_COMMUNITY_PHOTO_USER_TAGGED_EMAIL_SUBJECT');
                         $emailContent = JText::sprintf('COM_COMMUNITY_USER_TAGGED_COMMENT_EMAIL_CONTENT', $url);
                         $notificationMessage = JText::_('COM_COMMUNITY_NOTIFICATION_PHOTO_USER_TAGGED');
                     } else {
                         if ($info['type'] == 'post-comment' && $object != null) {
                             //default notification, and object is activity
                             //set parameter to be replaced in the template
                             $url = CRoute::emailLink('index.php?option=com_community&view=profile&userid=' . $object->actor . '&actid=' . $object->id . '#activity-stream-container');
                             $params = new CParameter();
                             $params->set('url', $url);
                             $params->set('content', $message);
                             $params->set('post', '<a href="' . $url . '">' . JText::_('COM_COMMUNITY_SINGULAR_POST') . '</a>');
                             $emailSubject = JText::sprintf('COM_COMMUNITY_PROFILE_USER_TAGGED_EMAIL_SUBJECT');
                             $emailContent = JText::sprintf('COM_COMMUNITY_PROFILE_USER_TAGGED_COMMENT_EMAIL_CONTENT', $url);
                             $notificationMessage = JText::_('COM_COMMUNITY_NOTIFICATION_USER_TAGGED');
                         } else {
                             return false;
                         }
                     }
                 }
             }
         }
         //add to notifications
         CNotificationLibrary::add('users_tagged', $actor->id, $taggedIds, $emailSubject, $emailContent, '', $params, true, '', $notificationMessage);
         return true;
     }
     return false;
 }
Exemple #18
0
 /**
  * Deprecated since 1.8.x
  */
 public function _notify($cmd, $from, $to, $subject, $body, $template = '', $params = '')
 {
     CFactory::load('libraries', 'notification');
     return CNotificationLibrary::add($cmd, $from, $to, $subject, $body, $template, $params);
 }
Exemple #19
0
        /**
         * Ajax function to save a new wall entry
         * 	 
         * @param message	A message that is submitted by the user
         * @param uniqueId	The unique id for this group
         * 
         **/
        function ajaxSaveWall($response, $message, $uniqueId, $cache_id = "")
        {
            $my = CFactory::getUser();
            $user = CFactory::getUser($uniqueId);
            $config = CFactory::getConfig();
            JPlugin::loadLanguage('plg_walls', JPATH_ADMINISTRATOR);
            // Load libraries
            CFactory::load('models', 'photos');
            CFactory::load('libraries', 'wall');
            CFactory::load('helpers', 'url');
            CFactory::load('libraries', 'activities');
            $message = JString::trim($message);
            $message = strip_tags($message);
            if (empty($message)) {
                $response->addAlert(JText::_('PLG_WALLS_PLEASE_ADD_MESSAGE'));
            } else {
                $maxchar = $this->params->get('charlimit', 0);
                if (!empty($maxchar)) {
                    $msglength = strlen($message);
                    if ($msglength > $maxchar) {
                        $message = substr($message, 0, $maxchar);
                    }
                }
                // @rule: Spam checks
                if ($config->get('antispam_akismet_walls')) {
                    CFactory::load('libraries', 'spamfilter');
                    $filter = CSpamFilter::getFilter();
                    $filter->setAuthor($my->getDisplayName());
                    $filter->setMessage($message);
                    $filter->setEmail($my->email);
                    $filter->setURL(CRoute::_('index.php?option=com_community&view=profile&userid=' . $user->id));
                    $filter->setType('message');
                    $filter->setIP($_SERVER['REMOTE_ADDR']);
                    if ($filter->isSpam()) {
                        $response->addAlert(JText::_('COM_COMMUNITY_WALLS_MARKED_SPAM'));
                        return $response->sendResponse();
                    }
                }
                $wall = CWallLibrary::saveWall($uniqueId, $message, 'user', $my, $my->id == $user->id, 'profile,profile');
                CFactory::load('libraries', 'activities');
                CFactory::load('helpers', 'videos');
                $matches = cGetVideoLinkMatches($message);
                $activityParams = '';
                // We only want the first result of the video to be in the activity
                if ($matches) {
                    $videoLink = $matches[0];
                    CFactory::load('libraries', 'videos');
                    $videoLib = new CVideoLibrary();
                    $provider = $videoLib->getProvider($videoLink);
                    $activityParams .= 'videolink=' . $videoLink . "\r\n";
                    if ($provider->isValid()) {
                        $activityParams .= 'url=' . $provider->getThumbnail();
                    }
                }
                $act = new stdClass();
                $act->cmd = 'profile.wall.create';
                $act->actor = $my->id;
                $act->target = $uniqueId;
                $act->title = JText::_('COM_COMMUNITY_ACTIVITIES_WALL_POST_PROFILE');
                $act->content = '';
                $act->app = 'walls';
                $act->cid = $wall->id;
                // Allow comments on all these
                $act->comment_id = CActivities::COMMENT_SELF;
                $act->comment_type = 'walls';
                CActivityStream::add($act, $activityParams);
                // @rule: Send notification to the profile user.
                if ($my->id != $user->id) {
                    CFactory::load('libraries', 'notification');
                    $params = new CParameter('');
                    $params->set('url', 'index.php?option=com_community&view=profile&userid=' . $user->id);
                    $params->set('message', $message);
                    CNotificationLibrary::add('etype_profile_submit_wall', $my->id, $user->id, JText::sprintf('PLG_WALLS_NOTIFY_EMAIL_SUBJECT', $my->getDisplayName()), '', 'profile.wall', $params);
                }
                //add user points
                CFactory::load('libraries', 'userpoints');
                CUserPoints::assignPoint('profile.wall.create');
                $response->addScriptCall('joms.walls.insert', $wall->content);
                $response->addScriptCall('if(joms.jQuery(".content-nopost").length){
											joms.jQuery("#wall-empty-container").remove();
										}');
                $cache =& JFactory::getCache('plgCommunityWalls');
                $cache->remove($cache_id);
                $cache =& JFactory::getCache('plgCommunityWalls_fullview');
                $cache->remove($cache_id);
            }
            return $response;
        }
Exemple #20
0
 /**
  * Ajax function to accept Private Group Request
  *
  **/
 public function ajaxGroupJoinRequest($memberId, $groupId)
 {
     $filter = JFilterInput::getInstance();
     $groupId = $filter->clean($groupId, 'int');
     $memberId = $filter->clean($memberId, 'int');
     if (!COwnerHelper::isRegisteredUser()) {
         return $this->ajaxBlockUnregister();
     }
     $objResponse = new JAXResponse();
     $my = CFactory::getUser();
     $model = $this->getModel('groups');
     //CFactory::load( 'helpers' , 'owner' );
     if (!$model->isAdmin($my->id, $groupId) && !COwnerHelper::isCommunityAdmin()) {
         $objResponse->addScriptCall(JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_ACCESS_SECTION'));
     } else {
         //Load Necessary Table
         $member = JTable::getInstance('GroupMembers', 'CTable');
         $group = JTable::getInstance('Group', 'CTable');
         // Load the group and the members table
         $group->load($groupId);
         $keys = array('groupId' => $groupId, 'memberId' => $memberId);
         $member->load($keys);
         // Only approve members that is really not approved yet.
         if ($member->approved) {
             $objResponse->addScriptCall('joms.jQuery("#error-request-' . $group->id . '").html("' . JText::_('COM_COMMUNITY_EVENTS_NOT_INVITED_NOTIFICATION') . '");');
             $objResponse->addScriptCall('joms.jQuery("#error-request-' . $group->id . '").attr("class", "error");');
         } else {
             $member->approve();
             $user = CFactory::getUser($memberId);
             $user->updateGroupList(true);
             // Add notification
             //CFactory::load( 'libraries' , 'notification' );
             $params = new CParameter('');
             $params->set('url', CRoute::getExternalURL('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id));
             $params->set('group', $group->name);
             $params->set('group_url', 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id);
             CNotificationLibrary::add('groups_member_approved', $group->ownerid, $user->id, JText::sprintf('COM_COMMUNITY_GROUP_MEMBER_APPROVED_EMAIL_SUBJECT'), '', 'groups.memberapproved', $params);
             $act = new stdClass();
             $act->cmd = 'group.join';
             $act->actor = $memberId;
             $act->target = 0;
             $act->title = '';
             //JText::sprintf('COM_COMMUNITY_GROUPS_ACTIVITIES_MEMBER_JOIN_GROUP' , '{group_url}' , $group->name );
             $act->content = '';
             $act->app = 'groups.join';
             $act->cid = $group->id;
             $params = new CParameter('');
             $params->set('action', 'group.join');
             $params->set('group_url', 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id);
             // Add activity logging
             if (CUserPoints::assignPoint('group.join', $memberId)) {
                 CActivityStream::addActor($act, $params->toString());
             }
             //trigger for onGroupJoinApproved
             $this->triggerEvents('onGroupJoinApproved', $group, $memberId);
             $this->triggerEvents('onGroupJoin', $group, $memberId);
             // UPdate group stats();
             $group->updateStats();
             $group->store();
             $url = CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id);
             $objResponse->addScriptCall('joms.jQuery("#msg-request-' . $memberId . '").html("' . addslashes(JText::sprintf('COM_COMMUNITY_EVENTS_ACCEPTED', $group->name, $url)) . '");');
             $objResponse->addScriptCall('joms.notifications.updateNotifyCount();');
             $objResponse->addScriptCall('joms.jQuery("#noti-request-group-' . $memberId . '").fadeOut(1000, function() { joms.jQuery("#noti-request-group-' . $memberId . '").remove();} );');
             $objResponse->addScriptCall('aspan = joms.jQuery(".cMenu-Icon b"); aspan.html(parseInt(aspan.html())-1);');
         }
     }
     return $objResponse->sendResponse();
 }
Exemple #21
0
 /**
  * Add comment to the stream
  *
  * @param int   $actid acitivity id
  * @param string $comment
  * @return obj
  */
 public function ajaxStreamAddComment($actid, $comment, $photoId = 0)
 {
     $filter = JFilterInput::getInstance();
     $actid = $filter->clean($actid, 'int');
     $my = CFactory::getUser();
     $wallModel = CFactory::getModel('wall');
     $rawComment = $comment;
     $json = array();
     $photoId = $filter->clean($photoId, 'int');
     // Pull the activity record and find out the actor
     // only allow comment if the actor is a friend of current user
     $act = JTable::getInstance('Activity', 'CTable');
     $act->load($actid);
     //who can add comment
     $obj = $act;
     if ($act->groupid > 0) {
         $obj = JTable::getInstance('Group', 'CTable');
         $obj->load($act->groupid);
     } else {
         if ($act->eventid > 0) {
             $obj = JTable::getInstance('Event', 'CTable');
             $obj->load($act->eventid);
         }
     }
     //link the actual comment from video page itself to the stream
     if (isset($obj->comment_type) && $obj->comment_type == 'videos.linking') {
         $obj->comment_type = 'videos';
     }
     $params = new CParameter($act->params);
     $batchcount = $params->get('batchcount', 0);
     $wallParam = new CParameter('');
     if ($act->app == 'photos' && $batchcount > 1) {
         $photo = JTable::getInstance('Photo', 'CTable');
         $photo->load($params->get('photoid'));
         $act->comment_type = 'albums';
         $act->comment_id = $photo->albumid;
         $wallParam->set('activityId', $act->id);
     }
     //if photo id is not 0, this wall is appended with a picture
     if ($photoId > 0) {
         //lets check if the photo belongs to the uploader
         $photo = JTable::getInstance('Photo', 'CTable');
         $photo->load($photoId);
         if ($photo->creator == $my->id && $photo->albumid == '-1') {
             $wallParam->set('attached_photo_id', $photoId);
             //sets the status to ready so that it wont be deleted on cron run
             $photo->status = 'ready';
             $photo->store();
         }
     }
     // Allow comment for system post
     $allowComment = false;
     if ($act->app == 'system') {
         $allowComment = !empty($my->id);
     }
     if ($my->authorise('community.add', 'activities.comment.' . $act->actor, $obj) || $allowComment) {
         $table = JTable::getInstance('Wall', 'CTable');
         $table->type = $act->comment_type;
         $table->contentid = $act->comment_id;
         $table->post_by = $my->id;
         $table->comment = $comment;
         $table->params = $wallParam->toString();
         if (preg_match("/\\b(?:(?:https?|ftp):\\/\\/|www\\.)[-a-z0-9+&@#\\/%?=~_|!:,.;]*[-a-z0-9+&@#\\/%=~_|]/i", $comment)) {
             $graphObject = CParsers::linkFetch($comment);
             if ($graphObject) {
                 $graphObject->merge($wallParam);
                 $table->params = $graphObject->toString();
             }
         }
         $table->store();
         $cache = CFactory::getFastCache();
         $cache->clean(array('activities'));
         if ($act->app == 'photos') {
             $table->contentid = $act->id;
         }
         $table->params = new CParameter($table->get('params'));
         $args[] = $table;
         CWall::triggerWallComments($args, false);
         $comment = CWall::formatComment($table);
         $json['html'] = $comment;
         //notification for activity comment
         //case 1: user's activity
         //case 2 : group's activity
         //case 3 : event's activity
         if ($act->groupid == 0 && $act->eventid == 0) {
             // //CFactory::load( 'libraries' , 'notification' );
             $params = new CParameter('');
             $params->set('message', $table->comment);
             $url = 'index.php?option=com_community&view=profile&userid=' . $act->actor . '&actid=' . $actid;
             $params->set('url', $url);
             $params->set('actor', $my->getDisplayName());
             $params->set('actor_url', CRoute::_('index.php?option=com_community&view=profile&userid=' . $my->id));
             $params->set('stream', JText::_('COM_COMMUNITY_SINGULAR_STREAM'));
             $params->set('stream_url', $url);
             if ($my->id != $act->actor) {
                 $command = 'profile_activity_add_comment';
                 /* Notifications to all poster in this activity except myself */
                 $users = $wallModel->getAllPostUsers($act->comment_type, $act->id, $my->id);
                 if (!empty($users)) {
                     if (!in_array($act->actor, $users)) {
                         array_push($users, $act->actor);
                     }
                     $commenters = array_diff($users, array($act->actor));
                     // this will sent notification to the participant only
                     CNotificationLibrary::add('profile_activity_add_comment', $my->id, $commenters, JText::sprintf('COM_COMMUNITY_ACTIVITY_WALL_PARTICIPANT_EMAIL_SUBJECT'), '', 'profile.activityreply', $params);
                     // this will sent a notification to the poster, reason is that the title should be different
                     CNotificationLibrary::add('profile_activity_add_comment', $my->id, $act->actor, JText::sprintf('COM_COMMUNITY_ACITIVY_WALL_EMAIL_SUBJECT'), '', 'profile.activityreply', $params);
                 } else {
                     CNotificationLibrary::add('profile_activity_add_comment', $my->id, $act->actor, JText::sprintf('COM_COMMUNITY_ACITIVY_WALL_EMAIL_SUBJECT'), '', 'profile.activitycomment', $params);
                 }
             } else {
                 //for activity reply action
                 //get relevent users in the activity
                 $users = $wallModel->getAllPostUsers($act->comment_type, $act->id, $act->actor);
                 if (!empty($users)) {
                     CNotificationLibrary::add('profile_activity_reply_comment', $my->id, $users, JText::sprintf('COM_COMMUNITY_ACITIVY_WALL_USER_REPLY_EMAIL_SUBJECT'), '', 'profile.activityreply', $params);
                 }
             }
         } elseif ($act->groupid != 0 && $act->eventid == 0) {
             /* Group activity */
             $params = new CParameter('');
             $params->set('message', $table->comment);
             $url = 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $act->groupid . '&actid=' . $actid;
             $params->set('url', $url);
             $params->set('actor', $my->getDisplayName());
             $params->set('actor_url', CRoute::_('index.php?option=com_community&view=profile&userid=' . $my->id));
             $params->set('stream', JText::_('COM_COMMUNITY_SINGULAR_STREAM'));
             $params->set('stream_url', $url);
             if ($my->id != $act->actor) {
                 /**
                  * Adds notification data into the mailq table
                  * @uses Make sure your provide body parameter or email content will be empty
                  * @param type $command
                  * @param null $actorId
                  * @param type $recipients
                  * @param type $subject
                  * @param type $body
                  * @param type $templateFile
                  * @param type $mailParams
                  * @param type $sendEmail
                  * @param type $favicon
                  * @param type $altSubject
                  * @return type
                  */
                 CNotificationLibrary::add('groups_activity_add_comment', $my->id, $act->actor, JText::sprintf('COM_COMMUNITY_ACITIVY_WALL_GROUP_EMAIL_SUBJECT'), $table->comment, 'group.activitycomment', $params);
                 $users = $wallModel->getAllPostUsers($act->comment_type, $act->id, $act->actor);
             } else {
                 //for activity reply action
                 //get relevent users in the activity
                 $users = $wallModel->getAllPostUsers($act->comment_type, $act->id, $act->actor);
                 if (!empty($users)) {
                     CNotificationLibrary::add('groups_activity_add_comment', $my->id, $users, JText::sprintf('COM_COMMUNITY_ACITIVY_WALL_USER_REPLY_EMAIL_SUBJECT'), $table->comment, 'group.activityreply', $params);
                 }
             }
         } elseif ($act->eventid != 0) {
             $event = JTable::getInstance('Event', 'CTable');
             $event->load($act->eventid);
             $params = new CParameter('');
             $params->set('message', $table->comment);
             $url = 'index.php?option=com_community&view=events&task=viewevent&eventid=' . $act->eventid . '&actid=' . $actid;
             $params->set('url', $url);
             $params->set('actor', $my->getDisplayName());
             $params->set('actor_url', CRoute::_('index.php?option=com_community&view=profile&userid=' . $my->id));
             $params->set('stream', JText::_('COM_COMMUNITY_SINGULAR_STREAM'));
             $params->set('stream_url', $url);
             $params->set('event', $event->title);
             if ($my->id != $act->actor) {
                 CNotificationLibrary::add('events_submit_wall_comment', $my->id, $act->actor, JText::sprintf('COM_COMMUNITY_ACITIVY_WALL_EVENT_EMAIL_SUBJECT'), '', 'events.wallcomment', $params);
             } else {
                 //for activity reply action
                 //get relevent users in the activity
                 $users = $wallModel->getAllPostUsers($act->comment_type, $act->id, $act->actor);
                 if (!empty($users)) {
                     CNotificationLibrary::add('events_activity_reply_comment', $my->id, $users, JText::sprintf('COM_COMMUNITY_ACITIVY_WALL_USER_REPLY_EMAIL_SUBJECT'), '', 'event.activityreply', $params);
                 }
             }
         }
         //notifications
         CUserHelper::parseTaggedUserNotification($rawComment, $my, $act, array('type' => 'post-comment'));
         //Add tag
         CTags::add($table);
         // Log user engagement
         CEngagement::log($act->app . '.comment', $my->id);
     } else {
         $json['error'] = 'Permission denied.';
     }
     if (!isset($json['error'])) {
         $json['success'] = true;
     }
     die(json_encode($json));
 }
Exemple #22
0
 public function addLike($element, $itemId)
 {
     $my = CFactory::getUser();
     $like = JTable::getInstance('Like', 'CTable');
     $like->loadInfo($element, $itemId);
     $like->element = $element;
     $like->uid = $itemId;
     // Check if user already like
     $likesInArray = explode(',', trim($like->like, ','));
     /* Like once time */
     if (in_array($my->id, $likesInArray)) {
         return;
     }
     array_push($likesInArray, $my->id);
     $likesInArray = array_unique($likesInArray);
     $like->like = ltrim(implode(',', $likesInArray), ',');
     // Check if the user already dislike
     $dislikesInArray = explode(',', trim($like->dislike, ','));
     if (in_array($my->id, $dislikesInArray)) {
         // Remove user dislike from array
         $key = array_search($my->id, $dislikesInArray);
         unset($dislikesInArray[$key]);
         $like->dislike = implode(',', $dislikesInArray);
     }
     switch ($element) {
         case 'comment':
             //get the instance of the wall
             $wall = JTable::getInstance('Wall', 'CTable');
             $wall->load($itemId);
             if (!$wall->id) {
                 break;
             }
             if ($wall->type == "profile.status") {
                 $wall->type = "profile";
             }
             //load the stream id from activity stream
             $stream = JTable::getInstance('Activity', 'CTable');
             $stream->load(array('comment_id' => $wall->contentid, 'app' => $wall->type));
             if ($stream->id) {
                 $profile = CFactory::getUser($stream->actor);
                 $url = 'index.php?option=com_community&view=profile&userid=' . $profile->id . '&actid=' . $stream->id . '#activity-stream-container';
                 $params = new CParameter('');
                 $params->set('url', $url);
                 $params->set('comment', JText::_('COM_COMMUNITY_SINGULAR_COMMENT'));
                 $params->set('comment_url', $url);
                 $params->set('actor', $my->getDisplayName());
                 //add to notifications
                 CNotificationLibrary::add('comments_like', $my->id, $wall->post_by, JText::sprintf('COM_COMMUNITY_PROFILE_WALL_LIKE_EMAIL_SUBJECT'), '', 'comments.like', $params);
             }
             break;
         case 'photo':
             $photo = JTable::getInstance('Photo', 'CTable');
             $photo->load($itemId);
             if ($photo->id) {
                 $url = $photo->getRawPhotoURI();
                 $params = new CParameter('');
                 $params->set('url', $url);
                 $params->set('photo', JText::_('COM_COMMUNITY_SINGULAR_PHOTO'));
                 $params->set('photo_url', $url);
                 CNotificationLibrary::add('photos_like', $my->id, $photo->creator, JText::sprintf('COM_COMMUNITY_PHOTO_LIKE_EMAIL_SUBJECT'), '', 'photos.like', $params);
                 /* Adding user points */
                 CUserPoints::assignPoint('photos.like');
             }
             break;
         case 'album':
             $album = JTable::getInstance('Album', 'CTable');
             $album->load($itemId);
             if ($album->id) {
                 if ($album->groupid) {
                     $url = 'index.php?option=com_community&view=photos&task=album&albumid=' . $album->id . '&groupid=' . $album->groupid;
                 } else {
                     $url = 'index.php?option=com_community&view=photos&task=album&albumid=' . $album->id;
                 }
                 $params = new CParameter('');
                 $params->set('url', $url);
                 $params->set('album', $album->name);
                 $params->set('album_url', $url);
                 CNotificationLibrary::add('photos_like', $my->id, $album->creator, JText::sprintf('COM_COMMUNITY_ALBUM_LIKE_EMAIL_SUBJECT'), '', 'album.like', $params);
                 /* Adding user points */
                 CUserPoints::assignPoint('album.like');
             }
             break;
         case 'videos':
             $video = JTable::getInstance('Video', 'CTable');
             $video->load($itemId);
             if ($video->id) {
                 if ($video->groupid) {
                     $url = 'index.php?option=com_community&view=videos&task=video&groupid=' . $video->groupid . '&videoid=' . $video->id;
                 } else {
                     $url = 'index.php?option=com_community&view=videos&task=video&videoid=' . $video->id;
                 }
                 $params = new CParameter('');
                 $params->set('url', $url);
                 $params->set('video', $video->title);
                 $params->set('video_url', $url);
                 CNotificationLibrary::add('videos_like', $my->id, $video->creator, JText::sprintf('COM_COMMUNITY_VIDEO_LIKE_EMAIL_SUBJECT'), '', 'videos.like', $params);
                 /* Adding user points */
                 CUserPoints::assignPoint('videos.like');
             }
             break;
         case 'profile':
             $profile = CFactory::getUser($itemId);
             if ($profile->id) {
                 $url = 'index.php?option=com_community&view=profile&userid=' . $profile->id;
                 $params = new CParameter('');
                 $params->set('url', $url);
                 $params->set('profile', strtolower(JText::_('COM_COMMUNITY_NOTIFICATIONGROUP_PROFILE')));
                 $params->set('profile_url', $url);
                 CNotificationLibrary::add('profile_like', $my->id, $profile->id, JText::sprintf('COM_COMMUNITY_PROFILE_LIKE_EMAIL_SUBJECT'), '', 'profile.like', $params);
                 /* Adding user points */
                 CUserPoints::assignPoint('profile.like');
             }
             break;
         case 'profile.status':
             $stream = JTable::getInstance('Activity', 'CTable');
             $stream->load($itemId);
             if ($stream->id) {
                 $profile = CFactory::getUser($stream->actor);
                 $url = 'index.php?option=com_community&view=profile&userid=' . $profile->id . '&actid=' . $stream->id;
                 $params = new CParameter('');
                 $params->set('url', $url);
                 $params->set('stream', JText::_('COM_COMMUNITY_SINGULAR_STREAM'));
                 $params->set('stream_url', $url);
                 CNotificationLibrary::add('profile_stream_like', $my->id, $profile->id, JText::sprintf('COM_COMMUNITY_PROFILE_STREAM_LIKE_EMAIL_SUBJECT'), '', 'profile.stream.like', $params);
                 /* Adding user points */
                 CUserPoints::assignPoint('profile.stream.like');
             }
             break;
         case 'cover.upload':
             $photo = JTable::getInstance('Photo', 'CTable');
             $photo->load(CPhotosHelper::getPhotoOfStream($itemId));
             if ($photo->id) {
                 $url = $photo->getRawPhotoURI();
                 $params = new CParameter('');
                 $params->set('url', $url);
                 $params->set('photo', JText::_('COM_COMMUNITY_SINGULAR_PHOTO'));
                 $params->set('photo_url', $url);
                 CNotificationLibrary::add('photos_like', $my->id, $photo->creator, JText::sprintf('COM_COMMUNITY_COVER_LIKE_EMAIL_SUBJECT'), '', 'photos.like', $params);
                 /* Adding user points */
                 CUserPoints::assignPoint('photos.like');
             }
             break;
         case 'profile.avatar.upload':
             $stream = JTable::getInstance('Activity', 'CTable');
             $stream->load($itemId);
             if ($stream->id) {
                 $profile = CFactory::getUser($stream->actor);
                 $url = 'index.php?option=com_community&view=profile&userid=' . $profile->id . '&actid=' . $stream->id;
                 $params = new CParameter('');
                 $params->set('url', $url);
                 $params->set('stream', JText::_('COM_COMMUNITY_SINGULAR_STREAM'));
                 $params->set('stream_url', $url);
                 CNotificationLibrary::add('profile_stream_like', $my->id, $profile->id, JText::sprintf('COM_COMMUNITY_PROFILE_AVATAR_LIKE_EMAIL_SUBJECT'), '', 'profile.stream.like', $params);
                 /* Adding user points */
                 CUserPoints::assignPoint('profile.stream.like');
             }
             break;
         case 'album.self.share':
             $stream = JTable::getInstance('Activity', 'CTable');
             $stream->load($itemId);
             $profile = CFactory::getUser($stream->actor);
             //get total photo(s) uploaded and determine the string
             $actParam = new CParameter($stream->params);
             if ($actParam->get('batchcount') > 1) {
                 $content = JText::sprintf('COM_COMMUNITY_ACTIVITY_ALBUM_PICTURES_LIKE_SUBJECT');
             } else {
                 $content = JText::sprintf('COM_COMMUNITY_ACTIVITY_ALBUM_PICTURE_LIKE_SUBJECT');
             }
             $url = 'index.php?option=com_community&view=profile&userid=' . $profile->id . '&actid=' . $stream->id;
             $params = new CParameter('');
             $params->set('url', $url);
             $params->set('stream', JText::_('COM_COMMUNITY_SINGULAR_STREAM'));
             $params->set('stream_url', $url);
             CNotificationLibrary::add('profile_stream_like', $my->id, $profile->id, $content, '', 'profile.stream.like', $params);
         default:
             CUserPoints::assignPoint($element . '.like');
     }
     // Log user engagement
     CEngagement::log($element . '.like', $my->id);
     $like->store();
 }
Exemple #23
0
    function savecomment($response, $id, $value)
    {
        require_once JPATH_PLUGINS . DS . 'community' . DS . 'activitycomment' . DS . 'helper.php';
        JPlugin::loadLanguage('plg_activitycomment', JPATH_ADMINISTRATOR);
        $my =& CFactory::getUser();
        if ($my->id == 0) {
            return 'invalid';
        }
        if (empty($value)) {
            $response->addScriptCall(ActivityComments::getjs() . '("#activity-' . $id . '-comment-errors").html("' . JText::_('COMMENT CANNOT BE EMPTY') . '").css("color","red");');
            return $response->sendResponse();
        }
        $my =& CFactory::getUser();
        require_once JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'models' . DS . 'wall.php';
        $wall =& JTable::getInstance('Wall', 'CTable');
        CFactory::load('helpers', 'linkgenerator');
        $params = ActivityComments::getParams();
        $value = strip_tags($value);
        $value = cGenerateURILinks($value, true, $params->get('shareurltarget'));
        // Get current date
        $date =& JFactory::getDate();
        $now = $date->toMySQL();
        $wall->type = 'activity';
        $wall->contentid = $id;
        $wall->post_by = $my->id;
        $wall->comment = $value;
        $wall->date = $now;
        $wall->published = 1;
        $wall->ip = $_SERVER['REMOTE_ADDR'];
        $wall->store();
        $params = ActivityComments::getParams();
        $sendEmail = $params->get('notifycomment', 0);
        $db =& JFactory::getDBO();
        if ($sendEmail == 1) {
            $query = 'select actor from #__community_activities where id=' . $db->Quote($id);
            $db->setQuery($query);
            $actorId = $db->loadResult();
            if ($actorId != $my->id) {
                $actor =& CFactory::getUser($actorId);
                CFactory::load('libraries', 'notification');
                $notification = new CNotificationLibrary();
                $current = CRoute::emailLink(ActivityComments::getCurrent(), false) . '#profile-newsfeed-item' . $id;
                $notification->add('profile.activity.comment', $my->id, $actorId, JText::sprintf('SOMEONE COMMENTED MAIL SUBJECT', $my->getDisplayName()), JText::sprintf('SOMEONE COMMENTED MAIL CONTENT', $actor->getDisplayName(), $my->getDisplayName(), $current));
            }
        }
        // send emails to subscribers
        $a = 'select * from #__activity_subscribe where ' . '`activity_id`=' . $db->Quote($id) . ' ' . 'and `type`=' . $db->Quote('profile');
        $db->setQuery($a);
        $subscribers = $db->loadObjectList();
        if ($subscribers) {
            $emails = array();
            foreach ($subscribers as $subscriber) {
                $emails[] = $subscriber->user_id;
            }
            CFactory::load('libraries', 'notification');
            $notification = new CNotificationLibrary();
            $current = CRoute::emailLink(ActivityComments::getCurrent(), false) . '#profile-newsfeed-item' . $id;
            $notification->add('profile.activity.comment', $my->id, $emails, JText::sprintf('SUBSCRIBE SOMEONE COMMENTED MAIL SUBJECT', $my->getDisplayName()), JText::sprintf('SUBSCRIBE SOMEONE COMMENTED MAIL CONTENT', $my->getDisplayName(), $current));
        }
        $joomla = JFactory::getConfig();
        $offset = $my->getParam('timezone', $joomla->getValue('offset'));
        $config = CFactory::getConfig();
        $date->setOffset($offset + $config->get('daylightsavingoffset'));
        ob_start();
        ?>
		<div class="wallcmt small" id="activity-comment-item-<?php 
        echo $wall->id;
        ?>
">
			<a href="<?php 
        echo CRoute::_('index.php?option=com_community&view=profile&userid=' . $my->id);
        ?>
"><img class="wall-coc-avatar" src="<?php 
        echo $my->getThumbAvatar();
        ?>
"/></a>
			<a href="<?php 
        echo CRoute::_('index.php?option=com_community&view=profile&userid=' . $my->id);
        ?>
" class="wall-coc-author"><?php 
        echo $my->getDisplayName();
        ?>
</a> <?php 
        echo JText::_('POST ON');
        ?>
			<span class="wall-coc-date"><?php 
        echo $date->toFormat(JText::_('DATE_FORMAT_LC2'));
        ?>
</span>
					<?php 
        if (ActivityComments::isSiteAdmin()) {
            ?>
					 | <span class="coc-remove"><a href="javascript:void(0);" onclick="jax.call('community','plugins,activitycomment,removecomment','<?php 
            echo $wall->id;
            ?>
');"><?php 
            echo JText::_('REMOVE COMMENT');
            ?>
</a></span>
					<?php 
        }
        ?>
			<p><?php 
        echo $wall->comment;
        ?>
</p>
		</div>
	<?php 
        $contents = ob_get_contents();
        ob_end_clean();
        $closeComment = $params->get('autoclose', 0);
        if ($closeComment) {
            $response->addScriptCall('activityHideComment', $id);
        }
        $response->addScriptCall(ActivityComments::getjs() . '("#activity-' . $id . '-comment-errors").html("' . JText::_('COMMENT ADDED') . '").css("color","green");');
        $response->addScriptCall('activityInsertComment', $id, $contents, $params->get('commentordering', 'asc'));
        return $response->sendResponse();
    }
Exemple #24
0
 public function request($target, $friends = array())
 {
     // remove duplicate id
     $friends = array_unique($friends);
     $model = CFactory::getModel('friends');
     $targetUser = CFactory::getUser($target);
     $my = JFactory::getUser();
     $params = new CParameter('');
     $params->set('url', 'index.php?option=com_community&view=profile&userid=' . $targetUser->id);
     if ($target == 0 || empty($friends)) {
         return false;
     }
     foreach ($friends as $friendId) {
         $connection = count($model->getFriendConnection($target, $friendId));
         // If stanger id is not in connection and stranger id in not myId, do add
         if ($connection == 0 && $friendId != $my->id) {
             $model->addFriend($friendId, $target);
             CNotificationLibrary::add('friends_request_connection', $targetUser->id, $friendId, JText::sprintf('COM_COMMUNITY_FRIEND_ADD_REQUEST', $targetUser->getDisplayName()), '', 'friends/request-sent', $params);
         }
     }
     return true;
 }
Exemple #25
0
 /**
  * Executes a default action
  */
 public function executeDefaultAction()
 {
     $db =& JFactory::getDBO();
     // Send notification to specified emails notifying them the action has been taken.
     $jConfig =& JFactory::getConfig();
     $config = CFactory::getConfig();
     $from = $jConfig->getValue('mailfrom');
     $fromName = $jConfig->getValue('fromname');
     $recipients = $config->get('notifyMaxReport');
     $recipients = explode(',', $recipients);
     $query = 'SELECT * FROM ' . $db->nameQuote('#__community_reports_actions') . ' ' . 'WHERE ' . $db->nameQuote('reportid') . '=' . $db->Quote($this->report->id) . ' ' . 'AND ' . $db->nameQuote('defaultaction') . '=' . $db->Quote(1) . ' ' . 'ORDER BY ' . $db->nameQuote('id') . ' LIMIT 1';
     $db->setQuery($query);
     $result = $db->loadObject();
     // No defaultaction specified for this current
     if (!$result) {
         return false;
     }
     // Execute the default action
     $method = explode(',', $result->method);
     $args = explode(',', $result->parameters);
     if (is_array($method) && $method[0] != 'plugins') {
         $controller = JString::strtolower($method[0]);
         require_once JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'controllers' . DS . 'controller.php';
         require_once JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'controllers' . DS . $controller . '.php';
         $controller = JString::ucfirst($controller);
         $controller = 'Community' . $controller . 'Controller';
         $controller = new $controller();
         if (method_exists($controller, $method[1])) {
             $resultData = call_user_func_array(array(&$controller, $method[1]), $args);
         } else {
             // Continue adding the action as there might be changes to the method name.
             return false;
         }
     } else {
         if (is_array($method) && $method[0] == 'plugins') {
             // Application method calls
             $element = JString::strtolower($method[1]);
             require_once CPluginHelper::getPluginPath('community', $element) . DS . $element . '.php';
             $className = 'plgCommunity' . JString::ucfirst($element);
             $plugin = new $className();
             if (method_exists($plugin, $method[2])) {
                 $resultData = call_user_func_array(array($plugin, $method[2]), $args);
             } else {
                 // Continue adding the action as there might be changes to the method name.
                 return false;
             }
         } else {
             return false;
         }
     }
     // Send notification to specified emails notifying them the action has been taken.
     $jConfig =& JFactory::getConfig();
     $config = CFactory::getConfig();
     $from = $jConfig->getValue('mailfrom');
     $fromName = $jConfig->getValue('fromname');
     $recipients = $config->get('notifyMaxReport');
     $recipients = explode(',', $recipients);
     $subject = JText::sprintf('COM_COMMUNITY_REPORT_THRESHOLD_REACHED_SUBJECT', $this->report->link);
     CFactory::load('libraries', 'notification');
     $params = new CParameter('');
     $params->set('url', $this->report->link);
     CNotificationLibrary::add('etype_system_reports_threshold', $from, $recipients, $subject, '', 'reports.threshold', $params);
     $this->report->status = 1;
     $this->report->store();
     return true;
 }
Exemple #26
0
 public static function sendnotification($referrerid, $assignpoints, $newtotal, $result, $force = 0)
 {
     $app = JFactory::getApplication();
     $lang = JFactory::getLanguage();
     $lang->load('com_alphauserpoints', JPATH_SITE);
     if (!$referrerid || $referrerid == 'GUEST') {
         return;
     }
     $db = JFactory::getDBO();
     jimport('joomla.mail.helper');
     // get params definitions
     $params = JComponentHelper::getParams('com_alphauserpoints');
     $jsNotification = $params->get('jsNotification', 0);
     $jsNotificationAdmin = $params->get('fromIdUddeim', 0);
     $SiteName = $app->getCfg('sitename');
     $MailFrom = $app->getCfg('mailfrom');
     $FromName = $app->getCfg('fromname');
     $sef = $app->getCfg('sef');
     $userinfo = AlphaUserPointsHelper::getUserInfo($referrerid);
     $email = $userinfo->email;
     $rule_name = $result->rule_name;
     $subject = $result->emailsubject;
     $body = $result->emailbody;
     $formatMail = $result->emailformat;
     $bcc2admin = $result->bcc2admin;
     if (!$userinfo->block || $force) {
         if ($subject != '' && $body != '') {
             $subject = str_replace('{username}', $userinfo->username, $subject);
             $subject = str_replace('{points}', AlphaUserPointsHelper::getFPoints(abs($assignpoints)), $subject);
             $subject = str_replace('{newtotal}', AlphaUserPointsHelper::getFPoints($newtotal), $subject);
             $body = str_replace('{username}', $userinfo->username, $body);
             $body = str_replace('{points}', AlphaUserPointsHelper::getFPoints(abs($assignpoints)), $body);
             $body = str_replace('{newtotal}', AlphaUserPointsHelper::getFPoints($newtotal), $body);
             $body = str_replace('{datareference}', $result->datareference, $body);
         } else {
             // default message
             if ($assignpoints > 0) {
                 $subject = JText::_('AUP_EMAILNOTIFICATION_SUBJECT');
                 $body = sprintf(JText::_('AUP_EMAILNOTIFICATION_MSG'), $SiteName, AlphaUserPointsHelper::getFPoints($assignpoints), AlphaUserPointsHelper::getFPoints($newtotal), JText::_($rule_name));
             } elseif ($assignpoints < 0) {
                 $subject = JText::_('AUP_EMAILNOTIFICATION_SUBJECT_ACCOUNT_UPDATED');
                 $body = sprintf(JText::_('AUP_EMAILNOTIFICATION_MSG_REMOVE_POINTS'), $SiteName, AlphaUserPointsHelper::getFPoints(abs($assignpoints)), AlphaUserPointsHelper::getFPoints($newtotal), JText::_($rule_name));
             }
         }
         $subject = JMailHelper::cleanSubject($subject);
         //$body    = JMailHelper::cleanBody($body);
         if (!$jsNotification) {
             $mailer = JFactory::getMailer();
             $mailer->setSender(array($MailFrom, $FromName));
             $mailer->setSubject($subject);
             $mailer->isHTML((bool) $formatMail);
             $mailer->CharSet = "utf-8";
             $mailer->setBody($body);
             $mailer->addRecipient($email);
             if ($bcc2admin) {
                 // get all users allowed to receive e-mail system
                 $query = "SELECT email" . " FROM #__users" . " WHERE sendEmail='1' AND block='0'";
                 $db->setQuery($query);
                 $rowsAdmins = $db->loadObjectList();
                 foreach ($rowsAdmins as $rowsAdmin) {
                     $mailer->addBCC($rowsAdmin->email);
                 }
             }
             $send = $mailer->Send();
         } else {
             require_once JPATH_ROOT . '/components/com_community/libraries/core.php';
             //$actor = CFactory::getUser();
             $params = new CParameter('');
             CNotificationLibrary::add('system_messaging', $jsNotificationAdmin, $userinfo->id, $subject, $body, '', $params);
             if ($bcc2admin) {
                 // get all users allowed to receive e-mail system
                 $query = "SELECT id" . " FROM #__users" . " WHERE sendEmail='1' AND block='0'";
                 $db->setQuery($query);
                 $rowsAdmins = $db->loadObjectList();
                 foreach ($rowsAdmins as $rowsAdmin) {
                     $mailer->addBCC($rowsAdmin->id);
                     CNotificationLibrary::add('system_messaging', $userinfo->id, $rowsAdmin->id, $subject, $body, '', $params);
                 }
             }
         }
     }
 }
Exemple #27
0
 /**
  * A new message submitted via ajax
  */
 public function ajaxSend($postVars)
 {
     //$postVars pending filtering
     $objResponse = new JAXResponse();
     $config = CFactory::getConfig();
     $my = CFactory::getUser();
     if ($my->id == 0) {
         return $this->ajaxBlockUnregister();
     }
     //CFactory::load( 'helpers', 'time' );
     $inboxModel = $this->getModel('inbox');
     $lastSent = $inboxModel->getLastSentTime($my->id);
     $dateNow = new JDate();
     // We need to make sure that this guy are not spamming other people inbox
     // by checking against his last message time. Make sure it doesn't exceed
     // pmFloodLimit config (in seconds).
     if ($dateNow->toUnix() - $lastSent->toUnix() < $config->get('floodLimit') && !COwnerHelper::isCommunityAdmin()) {
         $json = array();
         $json['title'] = JText::_('COM_COMMUNITY_NOTICE');
         $json['error'] = JText::sprintf('COM_COMMUNITY_PLEASE_WAIT_BEFORE_SENDING_MESSAGE', $config->get('floodLimit'));
         die(json_encode($json));
     }
     // Prevent users to send message to themselves.
     if ($postVars['to'] == $my->id) {
         $json = array();
         $json['title'] = JText::_('COM_COMMUNITY_NOTICE');
         $json['error'] = JText::_('COM_COMMUNITY_INBOX_MESSAGE_CANNOT_SEND_TO_SELF');
         die(json_encode($json));
     }
     $postVars = CAjaxHelper::toArray($postVars);
     $doCont = true;
     $errMsg = "";
     $resizeH = 0;
     if ($this->_isSpam($my, $postVars['subject'] . ' ' . $postVars['body'])) {
         $json = array();
         $json['title'] = JText::_('COM_COMMUNITY_NOTICE');
         $json['error'] = JText::_('COM_COMMUNITY_INBOX_MESSAGE_MARKED_SPAM');
         die(json_encode($json));
     }
     if (empty($postVars['subject']) || JString::trim($postVars['subject']) == '') {
         $json = array();
         $json['title'] = JText::_('COM_COMMUNITY_INBOX_TITLE_WRITE');
         $json['error'] = JText::_('COM_COMMUNITY_INBOX_SUBJECT_MISSING');
         $json['samestep'] = true;
         die(json_encode($json));
     }
     if (empty($postVars['body']) || JString::trim($postVars['body']) == '') {
         $json = array();
         $json['title'] = JText::_('COM_COMMUNITY_INBOX_TITLE_WRITE');
         $json['error'] = JText::_('COM_COMMUNITY_INBOX_MESSAGE_MISSING');
         $json['samestep'] = true;
         die(json_encode($json));
     }
     $data = $postVars;
     $model = $this->getModel('inbox');
     $pattern = "/<br \\/>/i";
     $replacement = "\r\n";
     $data['body'] = preg_replace($pattern, $replacement, $data['body']);
     $data['photo'] = isset($data['photo']) ? $data['photo'] : '';
     $msgid = $model->send($data);
     // Add user points.
     CUserPoints::assignPoint('inbox.message.send');
     // Add notification.
     $params = new CParameter('');
     $params->set('url', 'index.php?option=com_community&view=inbox&task=read&msgid=' . $msgid);
     $params->set('message', $data['body']);
     $params->set('title', $data['subject']);
     $params->set('msg_url', 'index.php?option=com_community&view=inbox&task=read&msgid=' . $msgid);
     $params->set('msg', JText::_('COM_COMMUNITY_PRIVATE_MESSAGE'));
     CNotificationLibrary::add('inbox_create_message', $my->id, $data['to'], JText::sprintf('COM_COMMUNITY_SENT_YOU_MESSAGE'), '', 'inbox.sent', $params);
     // Send response.
     $json = array();
     $json['message'] = JText::_('COM_COMMUNITY_INBOX_MESSAGE_SENT');
     die(json_encode($json));
 }
Exemple #28
0
 public function deleteProfile()
 {
     $jinput = JFactory::getApplication()->input;
     $view = $this->getView('profile');
     $method = $jinput->getMethod();
     $my = CFactory::getUser();
     $config = CFactory::getConfig();
     if ($my->id == 0) {
         return $this->blockUnregister();
     }
     //not allow to delete admin profile
     if (COwnerHelper::isCommunityAdmin($my->id)) {
         echo JText::_('COM_COMMUNITY_CANNOT_DELETE_PROFILE_ADMIN');
         return;
     }
     if (!$my->authorise('community.delete', 'profile.' . $my->id, $my)) {
         echo JText::_('COM_COMMUNITY_RESTRICTED_ACCESS');
         return;
     }
     if ($method == 'POST') {
         // Instead of delete the user straight away,
         // we'll block the user and notify the admin.
         // Admin then would delete the user from backend
         JRequest::checkToken() or jexit(JText::_('COM_COMMUNITY_INVALID_TOKEN'));
         $my->set('block', 1);
         $my->save();
         // Remove profile connect.
         $connectTable = JTable::getInstance('Connect', 'CTable');
         $connectTable->delete($my->id);
         // send notification email
         $model = CFactory::getModel('profile');
         $emails = $model->getAdminEmails();
         $url = JURI::root() . 'administrator/index.php?option=com_community&view=users&layout=edit&id=' . $my->id;
         // Add notification
         $params = new CParameter('');
         $params->set('userid', $my->id);
         $params->set('username', $my->getDisplayName());
         $params->set('url', $url);
         $subject = JText::sprintf('COM_COMMUNITY_USER_ACCOUNT_DELETED_SUBJECT');
         CNotificationLibrary::add('user_profile_delete', $my->id, $emails, $subject, '', 'user.deleted', $params);
         //reduce counter for group member
         $groupTable = JTable::getInstance('Group', 'CTable');
         $groupsModel = CFactory::getModel('groups');
         $groups = $groupsModel->getGroups($my->id);
         //do processing
         foreach ($groups as $group) {
             $group->membercount -= 1;
             $groupTable->bind($group);
             $groupTable->store();
             //Delete Group Member
             $groupTable->deleteMember($group->id, $my->id);
         }
         //reduce counter for event member count
         $eventTable = JTable::getInstance('Event', 'CTable');
         $eventModel = CFactory::getModel('events');
         $events = $eventModel->getEvents(null, $my->id);
         foreach ($events as $event) {
             $event->confirmedcount -= 1;
             $eventTable->bind($event);
             $eventTable->store();
             //remove guest
             $eventTable->removeGuest($my->id, $event->id);
         }
         // logout and redirect the user
         $mainframe = JFactory::getApplication();
         $mainframe->logout($my->id);
         $mainframe->redirect(CRoute::_('index.php?option=com_community', false));
     }
     echo $view->get(__FUNCTION__);
 }
Exemple #29
0
 public function notificationApproval($group)
 {
     $lang = JFactory::getLanguage();
     $lang->load('com_community', JPATH_ROOT);
     $my = CFactory::getUser();
     // Add notification
     //Send notification email to owner
     $params = new CParameter('');
     $params->set('url', 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id);
     $params->set('groupName', $group->name);
     $params->set('group', $group->name);
     $params->set('group_url', 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id);
     CNotificationLibrary::add('groups_notify_creator', $my->id, $group->ownerid, JText::_('COM_COMMUNITY_GROUPS_PUBLISHED_MAIL_SUBJECT'), '', 'groups.notifycreator', $params);
 }
Exemple #30
0
 /**
  * AJAX method to toggle publish status
  *
  * @param	int	id	Current field id
  * @param	string field	The field publish type
  *
  * @return	JAXResponse object	Azrul's AJAX Response object
  **/
 public function ajaxTogglePublish($id, $field, $viewName)
 {
     $user = JFactory::getUser();
     // @rule: Disallow guests.
     if ($user->get('guest')) {
         JError::raiseError(403, JText::_('COM_COMMUNITY_ACCESS_FORBIDDEN'));
         return;
     }
     $response = new JAXResponse();
     // Load the JTable Object.
     $row = JTable::getInstance($viewName, 'CommunityTable');
     $row->load($id);
     if ($row->{$field} == 1) {
         $row->{$field} = 0;
         $row->store();
         $image = 'publish_x.png';
     } else {
         $row->{$field} = 1;
         $row->store();
         $image = 'tick.png';
     }
     // Get the view
     $view = $this->getView($viewName, 'html');
     $html = $view->getPublish($row, $field, $viewName . ',ajaxTogglePublish');
     $response->addAssign($field . $id, 'innerHTML', $html);
     if ($viewName == 'videos' && $row->{$field} == 0) {
         $params = new CParameter('');
         $params->set('url', '');
         $params->set('target', $row->creator);
         CNotificationLibrary::add('system_messaging', NULL, $row->creator, JText::sprintf('COM_COMMUNITY_VIDEO_UNPUBLISHED', $row->title), '', '', $params);
     }
     return $response->sendResponse();
 }