Ejemplo n.º 1
1
 /**
  * Do a batch send
  */
 function send($total = 100)
 {
     $mailqModel = CFactory::getModel('mailq');
     $userModel = CFactory::getModel('user');
     $mails = $mailqModel->get($total);
     $jconfig = JFactory::getConfig();
     $mailer = JFactory::getMailer();
     $config = CFactory::getConfig();
     $senderEmail = $jconfig->getValue('mailfrom');
     $senderName = $jconfig->getValue('fromname');
     if (empty($mails)) {
         return;
     }
     CFactory::load('helpers', 'string');
     foreach ($mails as $row) {
         // @rule: only send emails that is valid.
         // @rule: make sure recipient is not blocked!
         $userid = $userModel->getUserFromEmail($row->recipient);
         $user = CFactory::getUser($userid);
         if (!$user->isBlocked() && !JString::stristr($row->recipient, 'foo.bar')) {
             $mailer->setSender(array($senderEmail, $senderName));
             $mailer->addRecipient($row->recipient);
             $mailer->setSubject($row->subject);
             $tmpl = new CTemplate();
             $raw = isset($row->params) ? $row->params : '';
             $params = new JParameter($row->params);
             $base = $config->get('htmlemail') ? 'email.html' : 'email.text';
             if ($config->get('htmlemail')) {
                 $row->body = JString::str_ireplace(array("\r\n", "\r", "\n"), '<br />', $row->body);
                 $mailer->IsHTML(true);
             } else {
                 //@rule: Some content might contain 'html' tags. Strip them out since this mail should never contain html tags.
                 $row->body = CStringHelper::escape(strip_tags($row->body));
             }
             $tmpl->set('content', $row->body);
             $tmpl->set('template', rtrim(JURI::root(), '/') . '/components/com_community/templates/' . $config->get('template'));
             $tmpl->set('sitename', $config->get('sitename'));
             $row->body = $tmpl->fetch($base);
             // Replace any occurences of custom variables within the braces scoe { }
             if (!empty($row->body)) {
                 preg_match_all("/{(.*?)}/", $row->body, $matches, PREG_SET_ORDER);
                 foreach ($matches as $val) {
                     $replaceWith = $params->get($val[1], null);
                     //if the replacement start with 'index.php', we can CRoute it
                     if (strpos($replaceWith, 'index.php') === 0) {
                         $replaceWith = CRoute::getExternalURL($replaceWith);
                     }
                     if (!is_null($replaceWith)) {
                         $row->body = JString::str_ireplace($val[0], $replaceWith, $row->body);
                     }
                 }
             }
             unset($tmpl);
             $mailer->setBody($row->body);
             $mailer->send();
         }
         $mailqModel->markSent($row->id);
         $mailer->ClearAllRecipients();
     }
 }
Ejemplo n.º 2
0
 /**
  * Inject data from paramter to content tags ({}) .
  *
  * @param	$content	Original content with content tags.
  * @param	$params	Text contain all values need to be replaced.
  * @param	$html	Auto detect url tag and insert inline.
  * @return	$text	The content after replacing.
  **/
 public static function injectTags($content, $paramsTxt, $html = false)
 {
     $params = new CParameter($paramsTxt);
     preg_match_all("/{(.*?)}/", $content, $matches, PREG_SET_ORDER);
     if (!empty($matches)) {
         foreach ($matches as $val) {
             $replaceWith = JString::trim($params->get($val[1], null));
             if (!is_null($replaceWith)) {
                 //if the replacement start with 'index.php', we can CRoute it
                 if (JString::strpos($replaceWith, 'index.php') === 0) {
                     $replaceWith = CRoute::getExternalURL($replaceWith);
                 }
                 if ($html) {
                     $replaceUrl = $params->get($val[1] . '_url', null);
                     if (!is_null($replaceUrl)) {
                         if ($val[1] == 'stream') {
                             $replaceUrl .= '#activity-stream-container';
                         }
                         //if the replacement start with 'index.php', we can CRoute it
                         if (JString::strpos($replaceUrl, 'index.php') === 0) {
                             $replaceUrl = CRoute::getExternalURL($replaceUrl);
                         }
                         $replaceWith = '<a href="' . $replaceUrl . '">' . $replaceWith . '</a>';
                     }
                 }
                 $content = CString::str_ireplace($val[0], $replaceWith, $content);
             }
         }
     }
     return $content;
 }
Ejemplo n.º 3
0
 public function sendEmail($type, $user, $password = null, $requireApproval = false)
 {
     $mainframe = JFactory::getApplication();
     $config = CFactory::getConfig();
     $modelRegister = $this->getModel('register');
     $sitename = $mainframe->getCfg('sitename');
     $mailfrom = $mainframe->getCfg('mailfrom');
     $fromname = $mainframe->getCfg('fromname');
     $siteURL = JURI::base();
     $name = $user->get('name');
     $email = $user->get('email');
     $username = $user->get('username');
     $com_user_config = JComponentHelper::getParams('com_users');
     $com_user_activation_type = $com_user_config->get('useractivation');
     if (is_null($password)) {
         $password = $user->get('password');
     }
     //Disallow control chars in the email
     $password = preg_replace('/[\\x00-\\x1F\\x7F]/', '', $password);
     $params = JComponentHelper::getParams('com_users');
     if ($params->get('sendpassword', 1) == 0) {
         $password = '******';
     }
     // Load Super Administrator email list
     $rows = $modelRegister->getSuperAdministratorEmail();
     //getting superadmin email address.
     if (!$mailfrom || !$fromname) {
         foreach ($rows as $row) {
             if ($row->sendEmail) {
                 $fromname = $row->name;
                 $mailfrom = $row->email;
                 break;
             }
         }
         //if still empty, then we just pick one of the admin email
         if (!$mailfrom || !$fromname) {
             $fromname = $rows[0]->name;
             $mailfrom = $rows[0]->email;
         }
     }
     $subject = JText::sprintf('COM_COMMUNITY_ACCOUNT_DETAILS_FOR', $name, $sitename);
     $subject = html_entity_decode($subject, ENT_QUOTES);
     $baseUrl = JUri::base();
     $activationURL = $baseUrl . 'index.php?option=' . COM_COMMUNITY_NAME . '&view=register&task=activate&' . ACTIVATION_KEYNAME . '=' . $user->get('activation');
     switch ($type) {
         case 'registration':
             // This section will only be called when there are no custom fields created and we just proceed like how Joomla
             // registers a user.
             if ($requireApproval || $com_user_activation_type == 1) {
                 $message = JText::sprintf('COM_COMMUNITY_EMAIL_REGISTRATION_REQUIRES_ACTIVATION', $name, $sitename, $activationURL, $siteURL, $username, $password);
             } else {
                 $message = JText::sprintf('COM_COMMUNITY_EMAIL_REGISTRATION', $name, $sitename, $username, $password);
             }
             break;
         case 'registration_uncomplete':
             $subject = JText::sprintf('COM_COMMUNITY_ACCOUNT_DETAILS_FOR_WELCOME', $sitename);
             $subject = html_entity_decode($subject, ENT_QUOTES);
             if ($requireApproval || $com_user_activation_type == 2) {
                 $message = JText::sprintf('COM_COMMUNITY_EMAIL_REGISTRATION_ACCOUNT_DETAILS_REQUIRES_ACTIVATION', $name, $sitename, $username, $password);
             } else {
                 $message = JText::sprintf('COM_COMMUNITY_EMAIL_REGISTRATION_ACCOUNT_DETAILS', $name, $sitename, $username, $password);
             }
             break;
         case 'registration_complete':
             if ($requireApproval || $com_user_activation_type == 2) {
                 // if approval is required, send an email to both admin and user, admin - to activate the user, user - to wait for admin approval
                 $message = JText::sprintf('COM_COMMUNITY_EMAIL_REGISTRATION_COMPLETED_REQUIRES_ADMIN_ACTIVATION', $name, $sitename, $siteURL);
             } else {
                 $message = JText::sprintf('COM_COMMUNITY_EMAIL_REGISTRATION_COMPLETED_REQUIRES_ACTIVATION', $name, $sitename, $activationURL, $siteURL);
             }
             break;
         case 'resend_activation':
             if ($config->get('activationresetpassword')) {
                 $message = JText::sprintf('COM_COMMUNITY_ACTIVATION_MSG_WITH_PWD', $name, $sitename, $activationURL, $siteURL, $username, $password);
             } else {
                 $message = JText::sprintf('COM_COMMUNITY_ACTIVATION_MSG', $name, $sitename, $activationURL, $siteURL);
             }
             break;
     }
     $message = html_entity_decode($message, ENT_QUOTES);
     $sendashtml = false;
     $copyrightemail = JString::trim($config->get('copyrightemail'));
     // this is used to send the username and password email if the settings of user configuration -> send username and password is enabled from the backend
     if ($type == 'registration_uncomplete' && $com_user_config->get('sendpassword')) {
         //check if HTML emails are set to ON
         if ($config->get('htmlemail')) {
             $sendashtml = true;
             $tmpl = new CTemplate();
             $message = CString::str_ireplace(array("\r\n", "\r", "\n"), '<br />', $message);
             $tmpl->set('name', $name);
             $tmpl->set('email', $email);
             $message = $tmpl->set('unsubscribeLink', CRoute::getExternalURL('index.php?option=com_community&view=profile&task=email'), false)->set('content', $message)->set('copyrightemail', $copyrightemail)->set('sitename', $config->get('sitename'))->fetch('email.html');
         }
         $mail = JFactory::getMailer();
         $mail->sendMail($mailfrom, $fromname, $email, $subject, $message, $sendashtml);
     }
     // Send email to user
     //if ( ! ($type == 'registration_complete' && !$requireApproval && !$needActivation))
     if ($type != 'registration_uncomplete' && ($com_user_activation_type != 0 || $requireApproval)) {
         if ($requireApproval || $com_user_activation_type == 2) {
             $subject = JText::sprintf('COM_COMMUNITY_USER_REGISTERED_WAITING_APPROVAL_TITLE', $sitename);
         }
         //check if HTML emails are set to ON
         if ($config->get('htmlemail')) {
             $sendashtml = true;
             $tmpl = new CTemplate();
             $message = CString::str_ireplace(array("\r\n", "\r", "\n"), '<br />', $message);
             $tmpl->set('name', $name);
             $tmpl->set('email', $email);
             $message = $tmpl->set('unsubscribeLink', CRoute::getExternalURL('index.php?option=com_community&view=profile&task=email'), false)->set('content', $message)->set('copyrightemail', $copyrightemail)->set('sitename', $config->get('sitename'))->fetch('email.html');
         }
         $mail = JFactory::getMailer();
         $mail->sendMail($mailfrom, $fromname, $email, $subject, $message, $sendashtml);
     }
     if ($type == 'registration_complete') {
         //Send notification email to administrators
         if ($requireApproval || $com_user_activation_type == 2) {
             $subject = JText::sprintf('COM_COMMUNITY_USER_REGISTERED_NEEDS_APPROVAL_TITLE', $sitename);
         }
         foreach ($rows as $row) {
             if ($row->sendEmail) {
                 $model = CFactory::getModel('Profile');
                 $profileTypes = $model->getProfileTypes();
                 // second condition indicates that if there is no multiprofile, it will follow the settings from the joomla activation type
                 if ($requireApproval || $com_user_activation_type == 2 && (count($profileTypes) == 0 || !$config->get('profile_multiprofile'))) {
                     $message2 = JText::sprintf(JText::_('COM_COMMUNITY_USER_REGISTERED_NEEDS_APPROVAL'), $row->name, $sitename, $activationURL, $activationURL, $name, $email, $username);
                 } else {
                     $message2 = JText::sprintf(JText::_('COM_COMMUNITY_SEND_MSG_ADMIN'), $row->name, $sitename, $name, $email, $username);
                 }
                 $message2 = html_entity_decode($message2, ENT_QUOTES);
                 //check if HTML emails are set to ON
                 if ($config->get('htmlemail')) {
                     $sendashtml = true;
                     $tmpl = new CTemplate();
                     $message2 = CString::str_ireplace(array("\r\n", "\r", "\n"), '<br />', $message2);
                     $tmpl->set('name', $name);
                     $tmpl->set('email', $row->email);
                     $message2 = $tmpl->set('unsubscribeLink', CRoute::getExternalURL('index.php?option=com_community&view=profile&task=privacy'), false)->set('content', $message2)->set('copyrightemail', $copyrightemail)->set('sitename', $config->get('sitename'))->fetch('email.html');
                 }
                 $mail = JFactory::getMailer();
                 $mail->sendMail($mailfrom, $fromname, $row->email, $subject, $message2, $sendashtml);
             }
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * Do a batch send
  */
 public function send($total = 100)
 {
     $app = JFactory::getApplication();
     $mailqModel = CFactory::getModel('mailq');
     $userModel = CFactory::getModel('user');
     $mails = $mailqModel->get($total);
     $mailer = JFactory::getMailer();
     $config = CFactory::getConfig();
     $senderEmail = $app->getCfg('mailfrom');
     $senderName = $app->getCfg('fromname');
     $sitename = $app->getCfg('config.sitename');
     if (empty($mails)) {
         return;
     }
     foreach ($mails as $row) {
         if ($row->email_type === 'etype_friends_invite_users') {
             /* for invite email */
             $raw = isset($row->params) ? $row->params : '';
             $rowParams = new CParameter($row->params);
             $userid = JUri::getInstance($rowParams->get('actor_url'))->getVar('userid');
         } else {
             // @rule: only send emails that is valid.
             // @rule: make sure recipient is not blocked!
             $userid = $userModel->getUserFromEmail($row->recipient);
         }
         $user = CFactory::getUser($userid);
         //verify user email list settting
         $user_params = $user->getParams();
         $validate = true;
         if (!empty($row->email_type)) {
             $validate = $user_params->get($row->email_type, $config->get($row->email_type)) == 1 ? true : false;
         }
         if (!$user->isBlocked() && !JString::stristr($row->recipient, 'foo.bar') && $validate) {
             $mailer->setSender(array($senderEmail, $senderName));
             $mailer->addRecipient($row->recipient);
             // Replace any occurences of custom variables within the braces scoe { }
             $row->subject = CContentHelper::injectTags($row->subject, $row->params, false);
             $mailer->setSubject($row->subject);
             $tmpl = new CTemplate();
             $raw = isset($row->params) ? $row->params : '';
             $params = new CParameter($row->params);
             $base = $config->get('htmlemail') ? 'email.html' : 'email.text';
             if ($config->get('htmlemail')) {
                 $row->body = CString::str_ireplace(array("<p>\r\n", "<p>\r", "<p>\n"), '<p>', $row->body);
                 $row->body = CString::str_ireplace(array("</p>\r\n", "</p>\r", "</p>\n"), '</p>', $row->body);
                 $row->body = CString::str_ireplace(array("\r\n", "\r", "\n"), '<br />', $row->body);
                 $mailer->IsHTML(true);
             } else {
                 //@rule: Some content might contain 'html' tags. Strip them out since this mail should never contain html tags.
                 $row->body = CStringHelper::escape(strip_tags($row->body));
             }
             $copyrightemail = JString::trim($config->get('copyrightemail'));
             $tmpl->set('email_type', $row->email_type);
             $tmpl->set('avatar', $user->getAvatar());
             $tmpl->set('thumbAvatar', $user->getThumbAvatar());
             $tmpl->set('name', $user->getDisplayName());
             $tmpl->set('email', $user->email);
             $tmpl->set('sitename', $sitename);
             $tmpl->set('unsubscribeLink', CRoute::getExternalURL('index.php?option=com_community&view=profile&task=email'), false);
             $tmpl->set('userid', $userid);
             $tmpl->set('copyrightemail', $copyrightemail);
             $tmpl->set('recepientemail', $row->recipient);
             $tmpl->set('content', $row->body);
             $tmpl->set('template', JURI::root(true) . '/components/com_community/templates/' . $config->get('template'));
             $tmpl->set('sitename', $config->get('sitename'));
             $row->body = $tmpl->fetch($base);
             // Replace any occurences of custom variables within the braces scoe { }
             if (!empty($row->body)) {
                 $row->body = CContentHelper::injectTags($row->body, $row->params, false);
             }
             unset($tmpl);
             $mailer->setBody($row->body);
             if ($mailer->send()) {
                 $validate = true;
             } else {
                 $validate = false;
             }
         }
         if (!$validate) {
             //email is blocked by user settings
             $mailqModel->markEmailStatus($row->id, 2);
         } else {
             $mailqModel->markSent($row->id);
         }
         $mailer->ClearAllRecipients();
     }
 }
Ejemplo n.º 5
0
 private function _sendEMail($type, $user, $password = null, $requireApproval = false)
 {
     $mainframe =& JFactory::getApplication();
     $config = CFactory::getConfig();
     $modelRegister =& $this->getModel('register');
     $usersConfig =& JComponentHelper::getParams('com_users');
     $useractivation = $usersConfig->get('useractivation');
     $newAccountActivation = $usersConfig->get('useractivation');
     $sitename = $mainframe->getCfg('sitename');
     $mailfrom = $mainframe->getCfg('mailfrom');
     $fromname = $mainframe->getCfg('fromname');
     $siteURL = JURI::base();
     $name = $user->get('name');
     $email = $user->get('email');
     $username = $user->get('username');
     if (is_null($password)) {
         $password = $user->get('password');
     }
     //Disallow control chars in the email
     $password = preg_replace('/[\\x00-\\x1F\\x7F]/', '', $password);
     // Load Super Administrator email list
     $rows = $modelRegister->getSuperAdministratorEmail();
     //getting superadmin email address.
     if (!$mailfrom || !$fromname) {
         foreach ($rows as $row) {
             if ($row->sendEmail) {
                 $fromname = $row->name;
                 $mailfrom = $row->email;
                 break;
             }
         }
         //if still empty, then we just pick one of the admin email
         if (!$mailfrom || !$fromname) {
             $fromname = $rows[0]->name;
             $mailfrom = $rows[0]->email;
         }
     }
     $subject = JText::sprintf('COM_COMMUNITY_ACCOUNT_DETAILS_FOR', $name, $sitename);
     $subject = html_entity_decode($subject, ENT_QUOTES);
     $needActivation = $usersConfig->get('useractivation');
     $activationURL = CRoute::getExternalURL('index.php?option=' . COM_USER_NAME . '&task=' . COM_USER_TAKS_ACTIVATE . '&' . ACTIVATION_KEYNAME . '=' . $user->get('activation'), false);
     switch ($type) {
         case 'registration':
             // This section will only be called when there are no custom fields created and we just proceed like how Joomla
             // registers a user.
             if ($needActivation) {
                 $message = sprintf(JText::_('COM_COMMUNITY_EMAIL_REGISTRATION_REQUIRES_ACTIVATION'), $name, $sitename, $activationURL, $siteURL, $username, $password);
             } else {
                 $message = sprintf(JText::_('COM_COMMUNITY_EMAIL_REGISTRATION'), $name, $sitename, $username, $password);
             }
             break;
         case 'registration_uncomplete':
             $subject = JText::sprintf('COM_COMMUNITY_ACCOUNT_DETAILS_FOR_WELCOME', $sitename);
             $subject = html_entity_decode($subject, ENT_QUOTES);
             if ($needActivation) {
                 $message = sprintf(JText::_('COM_COMMUNITY_EMAIL_REGISTRATION_ACCOUNT_DETAILS_REQUIRES_ACTIVATION'), $name, $sitename, $username, $password);
             } else {
                 $message = sprintf(JText::_('COM_COMMUNITY_EMAIL_REGISTRATION_ACCOUNT_DETAILS'), $name, $sitename, $username, $password);
             }
             break;
         case 'registration_complete':
             if ($requireApproval) {
                 //joomla 1.5 does not need email verification if admin approval feature is enable. But Joomla 1.6 requires
                 if (C_JOOMLA_15) {
                     $message = sprintf(JText::_('COM_COMMUNITY_EMAIL_REGISTRATION_COMPLETED_REQUIRES_APPROVAL'), $name, $sitename, $siteURL);
                 } else {
                     $message = JText::sprintf('COM_COMMUNITY_EMAIL_REGISTRATION_COMPLETED_REQUIRES_ADMIN_ACTIVATION', $name, $sitename, $activationURL, $siteURL);
                 }
             } else {
                 if ($needActivation) {
                     $message = JText::sprintf('COM_COMMUNITY_EMAIL_REGISTRATION_COMPLETED_REQUIRES_ACTIVATION', $name, $sitename, $activationURL, $siteURL);
                 } else {
                     $message = sprintf(JText::_('COM_COMMUNITY_EMAIL_REGISTRATION_COMPLETED'), $name, $sitename, $siteURL);
                 }
             }
             break;
         case 'resend_activation':
             if ($config->get('activationresetpassword')) {
                 $message = sprintf(JText::_('COM_COMMUNITY_ACTIVATION_MSG_WITH_PWD'), $name, $sitename, $activationURL, $siteURL, $username, $password);
             } else {
                 $message = sprintf(JText::_('COM_COMMUNITY_ACTIVATION_MSG'), $name, $sitename, $activationURL, $siteURL);
             }
             break;
     }
     $message = html_entity_decode($message, ENT_QUOTES);
     $sendashtml = false;
     $copyrightemail = JString::trim($config->get('copyrightemail'));
     // Send email to user
     if ($type == 'registration_complete' && !$requireApproval && !$needActivation) {
         //don't send email for this case
     } else {
         //check if HTML emails are set to ON
         if ($config->get('htmlemail')) {
             $sendashtml = true;
             $tmpl = new CTemplate();
             $message = CString::str_ireplace(array("\r\n", "\r", "\n"), '<br />', $message);
             //$tmpl->set( 'avatar', $user->getAvatar());
             //$tmpl->set( 'thumbAvatar', $user->getThumbAvatar());
             //$tmpl->set( 'template', rtrim( JURI::root() , '/' ) . '/components/com_community/templates/' . $config->get('template') );
             $tmpl->set('name', $name);
             $tmpl->set('email', $email);
             $message = $tmpl->set('unsubscribeLink', CRoute::getExternalURL('index.php?option=com_community&view=profile&task=privacy'), false)->set('content', $message)->set('copyrightemail', $copyrightemail)->set('sitename', $config->get('sitename'))->fetch('email.html');
         }
         JUtility::sendMail($mailfrom, $fromname, $email, $subject, $message, $sendashtml);
     }
     if ($type == 'registration_complete' && (C_JOOMLA_15 || !$requireApproval && !C_JOOMLA_15)) {
         //Send notification email to administrators
         foreach ($rows as $row) {
             if ($row->sendEmail) {
                 if ($requireApproval) {
                     $message2 = JText::sprintf(JText::_('COM_COMMUNITY_USER_REGISTERED_NEEDS_APPROVAL'), $row->name, $sitename, $name, $email, $username);
                 } else {
                     $message2 = JText::sprintf(JText::_('COM_COMMUNITY_SEND_MSG_ADMIN'), $row->name, $sitename, $name, $email, $username);
                 }
                 $message2 = html_entity_decode($message2, ENT_QUOTES);
                 //check if HTML emails are set to ON
                 if ($config->get('htmlemail')) {
                     $sendashtml = true;
                     $tmpl = new CTemplate();
                     $message2 = CString::str_ireplace(array("\r\n", "\r", "\n"), '<br />', $message2);
                     //$tmpl->set( 'avatar', $user->getAvatar());
                     //$tmpl->set( 'thumbAvatar', $user->getThumbAvatar());
                     //$tmpl->set( 'template', rtrim( JURI::root() , '/' ) . '/components/com_community/templates/' . $config->get('template') );
                     $tmpl->set('name', $name);
                     $tmpl->set('email', $row->email);
                     $message2 = $tmpl->set('unsubscribeLink', CRoute::getExternalURL('index.php?option=com_community&view=profile&task=privacy'), false)->set('content', $message2)->set('copyrightemail', $copyrightemail)->set('sitename', $config->get('sitename'))->fetch('email.html');
                 }
                 JUtility::sendMail($mailfrom, $fromname, $row->email, $subject, $message2, $sendashtml);
             }
         }
     }
 }
Ejemplo n.º 6
0
 /**
  *
  */
 public function notifications()
 {
     $mainframe = JFactory::getApplication();
     if (!$this->accessAllowed('registered')) {
         return;
     }
     $pathway = $mainframe->getPathway();
     $my = CFactory::getUser();
     $menu = JFactory::getApplication()->getMenu()->getActive();
     $pathway->addItem(JText::_($menu->title), CRoute::getExternalURL($menu->link));
     $pathway->addItem(JText::_($my->getDisplayName()), CRoute::_('index.php?option=com_community&view=profile&userid=' . $my->id));
     $pathway->addItem(JText::_('COM_COMMUNITY_PROFILE_NOTIFICATIONS'), '');
     /**
      * Opengraph
      */
     CHeadHelper::setType('website', JText::_('COM_COMMUNITY_PROFILE_NOTIFICATIONS'));
     $user = CFactory::getUser();
     $params = $user->getParams();
     $config = CFactory::getConfig();
     $modelNotification = CFactory::getModel('notification');
     $notifications = $modelNotification->getNotification($my->id, '0', 0);
     $app = CAppPlugins::getInstance();
     $appFields = $app->triggerEvent('onFormDisplay', array('jsform-profile-notifications'));
     $beforeFormDisplay = CFormElement::renderElements($appFields, 'before');
     $afterFormDisplay = CFormElement::renderElements($appFields, 'after');
     $tmpl = new CTemplate();
     echo $tmpl->set('beforeFormDisplay', $beforeFormDisplay)->set('afterFormDisplay', $afterFormDisplay)->set('params', $params)->set('config', $config)->set('submenu', $this->showSubmenu(false))->set('pagination', $modelNotification->getPagination())->set('notifications', $notifications)->fetch('profile.notification');
 }
Ejemplo n.º 7
0
                    </svg>
                    <span><?php 
echo $group->hits;
?>
</span>
                </a>

                <?php 
if ($config->get('enablesharethis') == 1) {
    ?>
                    <a class="joms-button--shared" title="<?php 
    echo JText::_('COM_COMMUNITY_SHARE_THIS');
    ?>
"
                       href="javascript:" onclick="joms.api.pageShare('<?php 
    echo CRoute::getExternalURL('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id);
    ?>
')">
                        <svg viewBox="0 0 16 16" class="joms-icon">
                            <use xlink:href="<?php 
    echo CRoute::getURI();
    ?>
#joms-icon-redo"></use>
                        </svg>
                    </a>
                <?php 
}
?>

                <?php 
if ($enableReporting) {
Ejemplo n.º 8
0
 /**
  * View method to display specific discussion from a group
  * @since 2.4
  * @access	public
  * @param	Object	Data object passed from controller
  */
 public function viewdiscussion()
 {
     $mainframe =& JFactory::getApplication();
     $document = JFactory::getDocument();
     $jconfig = JFactory::getConfig();
     $config = CFactory::getConfig();
     // Load window library
     CFactory::load('libraries', 'window');
     // Load necessary window css / javascript headers.
     CWindow::load();
     // Get necessary variables
     CFactory::load('models', 'groups');
     CFactory::load('models', 'discussions');
     $my = CFactory::getUser();
     $groupId = JRequest::getInt('groupid', '', 'GET');
     $topicId = JRequest::getInt('topicid', '', 'GET');
     // Load necessary library and objects
     $groupModel = CFactory::getModel('groups');
     $group =& JTable::getInstance('Group', 'CTable');
     $discussion =& JTable::getInstance('Discussion', 'CTable');
     $group->load($groupId);
     $discussion->load($topicId);
     $isBanned = $group->isBanned($my->id);
     $document->addCustomTag('<link rel="image_src" href="' . $group->getThumbAvatar() . '" />');
     // @rule: Test if the group is unpublished, don't display it at all.
     if (!$group->published) {
         $this->_redirectUnpublishGroup();
         return;
     }
     $feedLink = CRoute::_('index.php?option=com_community&view=groups&task=viewdiscussion&topicid=' . $topicId . '&format=feed');
     $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('COM_COMMUNITY_GROUPS_LATEST_FEED') . '"  href="' . $feedLink . '"/>';
     $document->addCustomTag($feed);
     CFactory::load('helpers', 'owner');
     if ($group->approvals == 1 && !$group->isMember($my->id) && !COwnerHelper::isCommunityAdmin()) {
         $this->noAccess(JText::_('COM_COMMUNITY_GROUPS_PRIVATE_NOTICE'));
         return;
     }
     // Execute discussion onDisplay filter
     $appsLib =& CAppPlugins::getInstance();
     $appsLib->loadApplications();
     $args = array();
     $args[] =& $discussion;
     $appsLib->triggerEvent('onDiscussionDisplay', $args);
     // Get the discussion creator info
     $creator = CFactory::getUser($discussion->creator);
     // Format the date accordingly.
     //$discussion->created	= CTimeHelper::getDate( $discussion->created );
     $dayinterval = ACTIVITY_INTERVAL_DAY;
     $timeFormat = $config->get('activitiestimeformat');
     $dayFormat = $config->get('activitiesdayformat');
     if ($config->get('activitydateformat') == COMMUNITY_DATE_FIXED) {
         $discussion->created = CTimeHelper::getDate($discussion->created)->toFormat(JText::_('DATE_FORMAT_LC2'), true);
     } else {
         $discussion->created = CTimeHelper::timeLapse(CTimeHelper::getDate($discussion->created));
     }
     // Set page title
     $document->setTitle(JText::sprintf('COM_COMMUNITY_GROUPS_DISCUSSION_TITTLE', $discussion->title));
     // Add pathways
     $this->_addGroupInPathway($group->id);
     $this->addPathway(JText::_('COM_COMMUNITY_GROUPS_DISCUSSION'), CRoute::_('index.php?option=com_community&view=groups&task=viewdiscussions&groupid=' . $group->id));
     $this->addPathway(JText::sprintf('COM_COMMUNITY_GROUPS_DISCUSSION_TITTLE', $discussion->title));
     CFactory::load('helpers', 'owner');
     $isGroupAdmin = $groupModel->isAdmin($my->id, $group->id);
     if ($my->id == $creator->id || $isGroupAdmin || COwnerHelper::isCommunityAdmin()) {
         $title = JText::_('COM_COMMUNITY_DELETE_DISCUSSION');
         $titleLock = $discussion->lock ? JText::_('COM_COMMUNITY_UNLOCK_DISCUSSION') : JText::_('COM_COMMUNITY_LOCK_DISCUSSION');
         $actionLock = $discussion->lock ? JText::_('COM_COMMUNITY_UNLOCK') : JText::_('COM_COMMUNITY_LOCK');
         $this->addSubmenuItem('', $actionLock, "joms.groups.lockTopic('" . $titleLock . "','" . $group->id . "','" . $discussion->id . "');", SUBMENU_RIGHT);
         $this->addSubmenuItem('', JText::_('COM_COMMUNITY_DELETE'), "joms.groups.removeTopic('" . $title . "','" . $group->id . "','" . $discussion->id . "');", SUBMENU_RIGHT);
         $this->addSubmenuItem('index.php?option=com_community&view=groups&task=editdiscussion&groupid=' . $group->id . '&topicid=' . $discussion->id, JText::_('COM_COMMUNITY_EDIT'), '', SUBMENU_RIGHT);
     }
     $this->showSubmenu();
     CFactory::load('libraries', 'wall');
     $wallContent = CWallLibrary::getWallContents('discussions', $discussion->id, $isGroupAdmin, $jconfig->get('list_limit'), 0, 'wall.content', 'groups,discussion');
     $wallCount = CWallLibrary::getWallCount('discussions', $discussion->id);
     $viewAllLink = CRoute::_('index.php?option=com_community&view=groups&task=discussapp&topicid=' . $discussion->id . '&app=walls');
     $wallContent .= CWallLibrary::getViewAllLinkHTML($viewAllLink, $wallCount);
     // Test if the current browser is a member of the group
     $isMember = $group->isMember($my->id);
     $waitingApproval = false;
     // If I have tried to join this group, but not yet approved, display a notice
     if ($groupModel->isWaitingAuthorization($my->id, $group->id)) {
         $waitingApproval = true;
     }
     $wallForm = '';
     $config = CFactory::getConfig();
     // Only get the wall form if user is really allowed to see it.
     if (!$config->get('lockgroupwalls') || $config->get('lockgroupwalls') && $isMember && !$isBanned && !$waitingApproval || COwnerHelper::isCommunityAdmin()) {
         $outputLock = '<div class="warning">' . JText::_('COM_COMMUNITY_DISCUSSION_LOCKED_NOTICE') . '</div>';
         $outputUnLock = CWallLibrary::getWallInputForm($discussion->id, 'groups,ajaxSaveDiscussionWall', 'groups,ajaxRemoveReply');
         $wallForm = '<div class="wall-tittle">' . JText::_('COM_COMMUNITY_REPLIES') . '</div>';
         $wallForm .= $discussion->lock ? $outputLock : $outputUnLock;
     }
     if (empty($wallForm)) {
         //user must join in order to see this page
         $tmpl = new CTemplate();
         $wallForm = $tmpl->set('groupid', $groupId)->fetch('groups.joingroup');
         $outputLock = '<div class="warning">' . JText::_('COM_COMMUNITY_DISCUSSION_LOCKED_NOTICE') . '</div>';
         $outputUnLock = CWallLibrary::getWallInputForm($discussion->id, 'groups,ajaxSaveDiscussionWall', 'groups,ajaxRemoveReply');
         $wallForm2 = '<div class="wall-tittle">' . JText::_('COM_COMMUNITY_REPLIES') . '</div>';
         $wallForm2 .= $discussion->lock ? $outputLock : $outputUnLock;
         $wallForm = $wallForm . '<div style="display:none" class="reply-form">' . $wallForm2 . '</div>';
     }
     $config = CFactory::getConfig();
     // Get creator link
     $creatorLink = CRoute::_('index.php?option=com_community&view=profile&userid=' . $creator->id);
     // Get reporting html
     CFactory::load('libraries', 'reporting');
     $report = new CReportingLibrary();
     $reportHTML = $report->getReportingHTML(JText::_('COM_COMMUNITY_GROUPS_DISCUSSION_REPORT'), 'groups,reportDiscussion', array($discussion->id));
     CFactory::load('libraries', 'bookmarks');
     $bookmarks = new CBookmarks(CRoute::getExternalURL('index.php?option=com_community&view=groups&task=viewdiscussion&groupid=' . $group->id . '&topicid=' . $discussion->id));
     $bookmarksHTML = $bookmarks->getHTML();
     $tmpl = new CTemplate();
     echo $tmpl->set('bookmarksHTML', $bookmarksHTML)->set('discussion', $discussion)->set('creator', $creator)->set('wallContent', $wallContent)->set('wallForm', $wallForm)->set('creatorLink', $creatorLink)->set('reportHTML', $reportHTML)->set('groupid', $groupId)->fetch('groups.viewdiscussion');
 }
Ejemplo n.º 9
0
 public function getPermalink()
 {
     $url = 'index.php?option=com_community&view=videos&task=video';
     if ($this->creator_type == VIDEO_GROUP_TYPE) {
         $url .= '&groupid=' . $this->groupid;
     } else {
         // defaul as user type, VIDEO_USER_TYPE
         $url .= '&userid=' . $this->creator;
     }
     $url .= '&videoid=' . $this->id;
     return CRoute::getExternalURL($url, false);
 }
Ejemplo n.º 10
0
 /**
  * Displays the viewing profile page.
  *
  * @access	public
  * @param	array  An associative array to display the fields
  */
 function profile(&$data)
 {
     $mainframe =& JFactory::getApplication();
     $my = CFactory::getUser();
     $config = CFactory::getConfig();
     $userid = JRequest::getVar('userid', $my->id);
     $user = CFactory::getUser($userid);
     $userId = JRequest::getVar('userid', '', 'GET');
     if ($my->id != 0 && empty($userId)) {
         CFactory::setActiveProfile($my->id);
         $user = $my;
     }
     // Display breadcrumb regardless whether the user is blocked or not
     $pathway =& $mainframe->getPathway();
     $pathway->addItem($user->getDisplayName(), '');
     // Get profile video information
     $params = $user->getParams();
     $videoid = $params->get('profileVideo', 0);
     CFactory::load('helpers', 'owner');
     $blocked = $user->isBlocked();
     if ($blocked && !COwnerHelper::isCommunityAdmin()) {
         $tmpl = new CTemplate();
         echo $tmpl->fetch('profile.blocked');
         return;
     }
     // If the current browser is a site admin, display some notice that user is blocked.
     if ($blocked) {
         $this->addWarning(JText::_('CC USER ACCOUNT BANNED'));
     }
     // access check
     if (!$this->accessAllowed('privacyProfileView')) {
         return;
     }
     require_once JPATH_COMPONENT . DS . 'libraries' . DS . 'userpoints.php';
     $appsLib =& CAppPlugins::getInstance();
     $appsLib->loadApplications();
     CFactory::load('helpers', 'string');
     $document =& JFactory::getDocument();
     $status = $user->getStatus(COMMUNITY_RAW_STATUS);
     $status = empty($status) ? '' : ' : ' . $status;
     $document->setTitle($user->getDisplayName(COMMUNITY_RAW_STATUS) . $status);
     $document->setMetaData('description', JText::sprintf('CC PROFILE META DESCRIPTION', $user->getDisplayName(), $config->get('sitename'), CStringHelper::escape($status)));
     $feedLink = CRoute::_('index.php?option=com_community&view=profile&userid=' . $user->id . '&format=feed');
     $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('CC SUBSCRIBE TO USER FEEDS') . '"  href="' . $feedLink . '"/>';
     $mainframe->addCustomHeadTag($feed);
     $feedLink = CRoute::_('index.php?option=com_community&view=profile&userid=' . $user->id . '&showfriends=true&format=feed');
     $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('CC SUBSCRIBE TO USER FRIENDS FEEDS') . '"  href="' . $feedLink . '"/>';
     $mainframe->addCustomHeadTag($feed);
     $feedLink = CRoute::_('index.php?option=com_community&view=photos&task=myphotos&userid=' . $user->id . '&format=feed');
     $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('CC SUBSCRIBE TO USER PHOTO FEEDS') . '"  href="' . $feedLink . '"/>';
     $mainframe->addCustomHeadTag($feed);
     $feedLink = CRoute::_('index.php?option=com_community&view=videos&userid=' . $user->id . '&format=feed');
     $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('CC SUBSCRIBE TO USER VIDEO FEEDS') . '"  href="' . $feedLink . '"/>';
     $mainframe->addCustomHeadTag($feed);
     // Get profile video information
     $params = $user->getParams();
     $data->videoid = $params->get('profileVideo', 0);
     // Show profile header
     $headerHTML = $this->_showHeader($data);
     // Load user application
     $apps = $data->apps;
     // Load community applications plugin
     $app =& CAppPlugins::getInstance();
     $appsModel = CFactory::getModel('apps');
     $tmpAppData = $app->triggerEvent('onProfileDisplay', '', true);
     $appData = array();
     // @rule: Only display necessary apps.
     $count = count($tmpAppData);
     for ($i = 0; $i < $count; $i++) {
         $app =& $tmpAppData[$i];
         $privacy = $appsModel->getPrivacy($user->id, $app->name);
         if ($this->appPrivacyAllowed($privacy)) {
             $appData[] = $app;
         }
     }
     unset($tmpAppData);
     // Split the apps into different list for different positon
     $appsInPositions = array();
     foreach ($appData as &$app) {
         $appsInPositions[$app->position][] = $app;
     }
     $tmpl = new CTemplate();
     $contenHTML = array();
     $contenHTML['content'] = '';
     $contenHTML['sidebar-top'] = '';
     $contenHTML['sidebar-bottom'] = '';
     $jscript = '';
     foreach ($appsInPositions as $position => $appData) {
         ob_start();
         foreach ($appData as $app) {
             // If the apps content is empty, we ignore this app from showing
             // the header in profile page.
             if (JString::trim($app->data) == "") {
                 continue;
             }
             $tmpl->set('app', $app);
             $tmpl->set('isOwner', COwnerHelper::isMine($my->id, $user->id));
             switch ($position) {
                 case 'sidebar-top':
                 case 'sidebar-bottom':
                     echo $tmpl->fetch('application.widget');
                     break;
                 default:
                     echo $tmpl->fetch('application.box');
             }
         }
         $contenHTML[$position] = ob_get_contents();
         ob_end_clean();
     }
     // Get the config
     $config = CFactory::getConfig();
     // get total group
     $groupsModel = CFactory::getModel('groups');
     $totalgroups = $groupsModel->getGroupsCount($user->id);
     // get total friend
     $friendsModel = CFactory::getModel('friends');
     $totalfriends = $user->getFriendCount();
     // get total photos
     $photosModel = CFactory::getModel('photos');
     $totalphotos = $photosModel->getPhotosCount($user->id);
     // get total activities
     $activitiesModel = CFactory::getModel('activities');
     $totalactivities = $activitiesModel->getActivityCount($user->id);
     $isMine = COwnerHelper::isMine($my->id, $user->id);
     $isCommunityAdmin = COwnerHelper::isCommunityAdmin($user->id);
     // Get reporting html
     CFactory::load('libraries', 'reporting');
     $report = new CReportingLibrary();
     $reportHTML = $isMine ? '' : $report->getReportingHTML(JText::_('CC REPORT BAD USER'), 'profile,reportProfile', array($user->id));
     // Check if user is blocked
     $blockUserModel = CFactory::getModel('block');
     $isBlocked = $blockUserModel->getBlockStatus($user->id, $my->id);
     // Get block user html
     CFactory::load('helpers', 'user');
     $blockUserHTML = $isMine || $isCommunityAdmin ? '' : CUserHelper::getBlockUserHTML($user->id, $isBlocked);
     CFactory::load('libraries', 'bookmarks');
     $bookmarks = new CBookmarks(CRoute::getExternalURL('index.php?option=com_community&view=profile&userid=' . $user->id));
     $bookmarksHTML = $bookmarks->getHTML();
     // Get like
     // cater for buble, blueface template
     $likesHTML = '';
     if ($user->getParams()->get('profileLikes', true)) {
         CFactory::load('libraries', 'like');
         $likes = new CLike();
         $likesHTML = $my->id == 0 ? $likes->getHtmlPublic('profile', $user->id) : $likes->getHTML('profile', $user->id, $my->id);
     }
     $tmpl = new CTemplate();
     $tmpl->set('blockUserHTML', $blockUserHTML);
     $tmpl->set('bookmarksHTML', $bookmarksHTML);
     $tmpl->set('profileOwnerName', $user->getDisplayName());
     $tmpl->set('totalgroups', $totalgroups);
     $tmpl->set('totalfriends', $totalfriends);
     $tmpl->set('totalphotos', $totalphotos);
     $tmpl->set('totalactivities', $totalactivities);
     $tmpl->set('reportsHTML', $reportHTML);
     $tmpl->set('mainframe', $mainframe);
     $tmpl->set('config', $config);
     $tmpl->set('about', $this->_getProfileHTML($data->profile));
     $tmpl->set('friends', $this->_getFriendsHTML());
     $tmpl->set('groups', $this->_getGroupsHTML());
     $tmpl->set('newsfeed', $this->_getNewsfeedHTML());
     $tmpl->set('header', $headerHTML);
     $tmpl->set('adminControlHTML', $this->_getAdminControlHTML($user->id));
     $tmpl->set('content', $contenHTML['content']);
     $tmpl->set('sidebarTop', $contenHTML['sidebar-top']);
     $tmpl->set('sidebarBottom', $contenHTML['sidebar-bottom']);
     $tmpl->set('isMine', $isMine);
     $tmpl->set('jscript', '');
     // maintain for 1.8.0 template compatibility
     $tmpl->setRef('user', $user);
     $tmpl->set('my', $my);
     $tmpl->set('videoid', $data->videoid);
     $tmpl->set('likesHTML', $likesHTML);
     $html = $tmpl->fetch('profile.index');
     echo $html;
 }
Ejemplo n.º 11
0
 /**
  * Method to wrap around getting the correct links within the email
  * DEPRECATED since 1.5
  */
 static function emailLink($url, $xhtml = false)
 {
     return CRoute::getExternalURL($url, $xhtml);
 }
Ejemplo n.º 12
0
 public function getPhotoLink($external = false, $xhtml = true)
 {
     $album =& JTable::getInstance('Album', 'CTable');
     $album->load($this->albumid);
     $url = 'index.php?option=com_community&view=photos&task=photo&albumid=' . $album->id;
     $url .= $album->groupid ? '&groupid=' . $album->groupid : '&userid=' . $album->creator;
     if ($external) {
         return CRoute::getExternalURL($url) . '#photoid=' . $this->id;
     }
     return CRoute::_($url, $xhtml) . '#photoid=' . $this->id;
 }
Ejemplo n.º 13
0
 /**
  * @param $token
  * @return int activation_type where 1 = activate by admin, 0 = self activation
  */
 public function activate($token)
 {
     $config = CFactory::getConfig();
     $db = $this->getDbo();
     $activation_type = 0;
     // Find the user with the token supplied
     $query = $db->getQuery(true);
     $query->select($db->quoteName('id'))->from($db->quoteName('#__users'))->where($db->quoteName('activation') . ' = ' . $db->quote($token))->where($db->quoteName('block') . ' = ' . 1);
     $db->setQuery($query);
     try {
         $userId = (int) $db->loadResult();
     } catch (RuntimeException $e) {
         return false;
     }
     // Check for a valid user id.
     if (!$userId) {
         $this->setError(JText::_('COM_COMMUNITY_INVALID_TOKEN'));
         return false;
     }
     // Load the users plugin group.
     JPluginHelper::importPlugin('user');
     // Activate the user.
     $user = CFactory::getUser($userId);
     $user->set('activation', '');
     $user->set('block', '0');
     $com_user_config = JComponentHelper::getParams('com_users');
     $com_user_activation_type = $com_user_config->get('useractivation');
     if ($user->_profile_id > 0) {
         $multiprofile = JTable::getInstance('MultiProfile', 'CTable');
         $multiprofile->load($user->_profile_id);
         //lets send an email to the user notifying their account has been activated
         if ($multiprofile->approvals == 1 || $com_user_activation_type == 2) {
             // Compile the user activated notification mail values.
             $activation_type = 1;
             // set this to admin activation type
             $data = $user->getProperties();
             $user->setParam('activate', 0);
             $data['fromname'] = $config->get('fromname');
             $data['mailfrom'] = $config->get('mailfrom');
             $data['sitename'] = $config->get('sitename');
             $data['siteurl'] = JUri::base();
             $emailSubject = JText::sprintf('COM_COMMUNITY_EMAIL_ACTIVATED_BY_ADMIN_ACTIVATION_SUBJECT', $data['name'], $data['sitename']);
             $emailBody = JText::sprintf('COM_COMMUNITY_EMAIL_ACTIVATED_BY_ADMIN_ACTIVATION_BODY', $data['name'], $data['siteurl'], $data['username']);
             $message = html_entity_decode($emailBody, ENT_QUOTES);
             $sendashtml = false;
             $copyrightemail = JString::trim($config->get('copyrightemail'));
             //check if HTML emails are set to ON
             if ($config->get('htmlemail')) {
                 $sendashtml = true;
                 $tmpl = new CTemplate();
                 $message = CString::str_ireplace(array("\r\n", "\r", "\n"), '<br />', $message);
                 $tmpl->set('name', $data['username']);
                 $tmpl->set('email', $data['email']);
                 $message = $tmpl->set('unsubscribeLink', CRoute::getExternalURL('index.php?option=com_community&view=profile&task=preferences#email'), false)->set('content', $message)->set('copyrightemail', $copyrightemail)->set('sitename', $config->get('sitename'))->fetch('email.html');
             }
             $return = JFactory::getMailer()->sendMail($data['mailfrom'], $data['fromname'], $data['email'], $emailSubject, $message, $sendashtml);
             // Check for an error.
             if ($return !== true) {
                 $this->setError(JText::_('COM_USERS_REGISTRATION_ACTIVATION_NOTIFY_SEND_MAIL_FAILED'));
                 return false;
             }
         }
     } else {
         if ($com_user_activation_type == 2 && $user->_profile_id == 0) {
             // Compile the user activated notification mail values.
             $activation_type = 1;
             // set this to admin activation type
             $data = $user->getProperties();
             $user->setParam('activate', 0);
             $data['fromname'] = $config->get('fromname');
             $data['mailfrom'] = $config->get('mailfrom');
             $data['sitename'] = $config->get('sitename');
             $data['siteurl'] = JUri::base();
             $emailSubject = JText::sprintf('COM_COMMUNITY_EMAIL_ACTIVATED_BY_ADMIN_ACTIVATION_SUBJECT', $data['name'], $data['sitename']);
             $emailBody = JText::sprintf('COM_COMMUNITY_EMAIL_ACTIVATED_BY_ADMIN_ACTIVATION_BODY', $data['name'], $data['siteurl'], $data['username']);
             $message = html_entity_decode($emailBody, ENT_QUOTES);
             $sendashtml = false;
             $copyrightemail = JString::trim($config->get('copyrightemail'));
             //check if HTML emails are set to ON
             if ($config->get('htmlemail')) {
                 $sendashtml = true;
                 $tmpl = new CTemplate();
                 $message = CString::str_ireplace(array("\r\n", "\r", "\n"), '<br />', $message);
                 $tmpl->set('name', $data['username']);
                 $tmpl->set('email', $data['email']);
                 $message = $tmpl->set('unsubscribeLink', CRoute::getExternalURL('index.php?option=com_community&view=profile&task=email'), false)->set('content', $message)->set('copyrightemail', $copyrightemail)->set('sitename', $config->get('sitename'))->fetch('email.html');
             }
             $return = JFactory::getMailer()->sendMail($data['mailfrom'], $data['fromname'], $data['email'], $emailSubject, $message, $sendashtml);
             // Check for an error.
             if ($return !== true) {
                 $this->setError(JText::_('COM_USERS_REGISTRATION_ACTIVATION_NOTIFY_SEND_MAIL_FAILED'));
                 return false;
             }
         }
     }
     // Store the user object.
     if (!$user->save()) {
         $this->setError(JText::sprintf('COM_USERS_REGISTRATION_ACTIVATION_SAVE_FAILED', $user->getError()));
         return false;
     }
     return $activation_type;
 }
Ejemplo n.º 14
0
 /**
  * Updates user profile
  **/
 public function updateProfile()
 {
     $document = JFactory::getDocument();
     $viewType = $document->getType();
     $viewName = JRequest::getCmd('view', $this->getName());
     $view = $this->getView($viewName, '', $viewType);
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     if (!$this->_isEnabled()) {
         echo JText::_('COM_COMMUNITY_MULTIPROFILE_IS_CURRENTLY_DISABLED');
         return;
     }
     $appsLib = CAppPlugins::getInstance();
     $appsLib->loadApplications();
     $mainframe = JFactory::getApplication();
     $profileType = JRequest::getInt('profileType', 0);
     $model = $this->getModel('Profile');
     $my = CFactory::getUser();
     $data = $model->getEditableProfile($my->id, $profileType);
     $oldProfileType = $my->getProfileType();
     // If there is nothing to edit, we should just redirect
     if (empty($data['fields'])) {
         $multiprofile = JTable::getInstance('MultiProfile', 'CTable');
         $multiprofile->load($profileType);
         $my->_profile_id = $multiprofile->id;
         // Trigger before onProfileTypeUpdate
         $args = array();
         $args[] = $my->id;
         $args[] = $oldProfileType;
         $args[] = $multiprofile->id;
         $result = $appsLib->triggerEvent('onProfileTypeUpdate', $args);
         //CFactory::load( 'helpers' , 'owner' );
         // @rule: If profile requires approval, logout user and update block status. This is not
         // applicable to site administrators.
         if ($multiprofile->approvals && !COwnerHelper::isCommunityAdmin($my->id)) {
             $my->set('block', 1);
             //CFactory::load( 'helpers' , 'owner' );
             $subject = JText::sprintf('COM_COMMUNITY_USER_NEEDS_APPROVAL_SUBJECT', $my->name);
             $message = JText::sprintf('COM_COMMUNITY_USER_PROFILE_CHANGED_NEEDS_APPROVAL', $my->name, $my->email, $my->username, $multiprofile->name, CRoute::getExternalURL('index.php?option=com_community&view=profile&userid=' . $my->id));
             COwnerHelper::emailCommunityAdmins($subject, $message);
             // @rule: Logout user.
             $mainframe->logout();
         }
         $my->save();
         $mainframe->redirect(CRoute::_('index.php?option=com_community&view=multiprofile&task=profileupdated&profileType=' . $multiprofile->id, false));
     }
     if ($jinput->getMethod() == 'POST') {
         $model = $this->getModel('Profile');
         $values = array();
         $profileType = JRequest::getInt('profileType', 0, 'POST');
         //CFactory::load( 'libraries' , 'profile' );
         $profiles = $model->getAllFields(array('published' => '1'), $profileType);
         $errors = array();
         // Delete all user's existing profile values and re-add the new ones
         // @rule: Bind the user data
         foreach ($profiles as $key => $groups) {
             foreach ($groups->fields as $data) {
                 // Get value from posted data and map it to the field.
                 // Here we need to prepend the 'field' before the id because in the form, the 'field' is prepended to the id.
                 $postData = JRequest::getVar('field' . $data->id, '', 'POST');
                 $values[$data->id] = CProfileLibrary::formatData($data->type, $postData);
                 if (get_magic_quotes_gpc()) {
                     $values[$data->id] = stripslashes($values[$data->id]);
                 }
                 // @rule: Validate custom profile if necessary
                 if (!CProfileLibrary::validateField($data->id, $data->type, $values[$data->id], $data->required)) {
                     // If there are errors on the form, display to the user.
                     $message = JText::sprintf('COM_COMMUNITY_FIELD_CONTAIN_IMPROPER_VALUES', $data->name);
                     $mainframe->enqueueMessage($message, 'error');
                     $errors[] = true;
                 }
             }
         }
         // Rebuild new $values with field code
         $valuesCode = array();
         foreach ($values as $key => $val) {
             $fieldCode = $model->getFieldCode($key);
             if ($fieldCode) {
                 // For backward compatibility, we can't pass in an object. We need it to behave
                 // like 1.8.x where we only pass values.
                 $valuesCode[$fieldCode] = $val;
             }
         }
         $args = array();
         $args[] = $my->id;
         $args[] = $valuesCode;
         $saveSuccess = false;
         $result = $appsLib->triggerEvent('onBeforeProfileUpdate', $args);
         // make sure none of the $result is false
         if (!$result || !in_array(false, $result)) {
             $saveSuccess = true;
             $model->saveProfile($my->id, $values);
         }
         $mainframe = JFactory::getApplication();
         if (!$saveSuccess) {
             $mainframe->redirect(CRoute::_('index.php?option=com_community&view=multiprofile&task=updateProfile&profileType=' . $profileType, false), JText::_('COM_COMMUNITY_PROFILE_NOT_SAVED'), 'error');
         }
         // Trigger before onAfterUserProfileUpdate
         $args = array();
         $args[] = $my->id;
         $args[] = $saveSuccess;
         $result = $appsLib->triggerEvent('onAfterProfileUpdate', $args);
         $multiprofile = JTable::getInstance('MultiProfile', 'CTable');
         $multiprofile->load($profileType);
         $my->_profile_id = $multiprofile->id;
         //CFactory::load( 'helpers' , 'owner' );
         // @rule: If profile requires approval, logout user and update block status. This is not
         // applicable to site administrators.
         if ($multiprofile->approvals && !COwnerHelper::isCommunityAdmin($my->id)) {
             $my->set('block', 1);
             //CFactory::load( 'helpers' , 'owner' );
             $subject = JText::sprintf('COM_COMMUNITY_USER_NEEDS_APPROVAL_SUBJECT', $my->name);
             $message = JText::sprintf('COM_COMMUNITY_USER_PROFILE_CHANGED_NEEDS_APPROVAL', $my->name, $my->email, $my->username, $multiprofile->name, CRoute::getExternalURL('index.php?option=com_community&view=profile&userid=' . $my->id));
             COwnerHelper::emailCommunityAdmins($subject, $message);
             // @rule: Logout user.
             $mainframe->logout();
         }
         $my->save();
         // Trigger before onProfileTypeUpdate
         $args = array();
         $args[] = $my->id;
         $args[] = $oldProfileType;
         $args[] = $multiprofile->id;
         $result = $appsLib->triggerEvent('onProfileTypeUpdate', $args);
         if (!in_array(true, $errors)) {
             $mainframe->redirect(CRoute::_('index.php?option=com_community&view=multiprofile&task=profileupdated&profileType=' . $multiprofile->id, false));
         }
     }
     echo $view->get(__FUNCTION__);
 }
Ejemplo n.º 15
0
 /**
  * Method is used to receive POST requests from specific user
  * that wants to join a group
  *
  * @return	void
  **/
 public function joinGroup()
 {
     $mainframe =& JFactory::getApplication();
     $groupId = JRequest::getVar('groupid', '', 'POST');
     // Add assertion to the group id since it must be specified in the post request
     CError::assert($groupId, '', '!empty', __FILE__, __LINE__);
     // Get the current user's object
     $my = CFactory::getUser();
     if ($my->id == 0) {
         return $this->blockUnregister();
     }
     // Load necessary tables
     $groupModel = CFactory::getModel('groups');
     if ($groupModel->isMember($my->id, $groupId)) {
         $url = CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $groupId, false);
         $mainframe->redirect($url, JText::_('CC ALREADY MEMBER OF GROUP'));
     } else {
         $url = CRoute::getExternalURL('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $groupId, false);
         $member = $this->_saveMember($groupId);
         if ($member->approved) {
             $mainframe->redirect($url, JText::_('CC SUCCESS JOIN GROUP'));
         }
         $mainframe->redirect($url, JText::_('CC USER JOIN GROUP NEED APPROVAL'));
     }
 }
Ejemplo n.º 16
0
 /**
  *
  * Cron job will run this function
  * to do all the pending video conversion
  *
  * @since Jomsocial 1.2.0
  */
 public function runConvert()
 {
     $config = CFactory::getConfig();
     $videoFolder = $config->get('videofolder');
     $deleteOriginal = $config->get('deleteoriginalvideos');
     if (!$config->get('enablevideos')) {
         $this->errorMsg[] = 'Video is disabled. Video conversion will not run. ';
         return;
     }
     $zencoder = $config->get('enable_zencoder');
     $model = CFactory::getModel('videos');
     $videos = $model->getPendingVideos();
     if (count($videos) < 1) {
         $this->errorMsg[] = 'No videos pending for conversion. ';
         return;
     }
     if (!$zencoder && !$this->hasFFmpegSupport()) {
         $this->errorMsg[] = 'FFmpeg cannot be executed.';
         return;
     }
     // First of all, lock the videos
     $table = JTable::getInstance('Video', 'CTable');
     foreach ($videos as $video) {
         $table->load($video->id);
         $table->save(array('status' => 'locked'));
         $table->reset();
     }
     // Process each video
     $videoCounter = 0;
     if ($zencoder) {
         $s3BucketPath = $config->get('storages3bucket');
         $s3outputBaseUrl = 'http://' . $s3BucketPath . '.s3.amazonaws.com';
         $videoFolder = $config->get('videofolder') . '/' . VIDEO_FOLDER_NAME;
         list($outputWidth, $outputHeight) = explode('x', $config->get('videosSize'), 2);
         $outputThumbSize = $config->get('videosThumbSize');
         $test = false;
         $path = JPATH_ROOT . '/components/com_community/libraries/zencoder.php';
         if (JFile::exists($path)) {
             include_once $path;
         } else {
             exit('Missing File' . JPATH_ROOT . '/components/com_community/libraries/zencoder.php');
         }
         $job = new CZencoderJob();
         foreach ($videos as $video) {
             $outputFilename = $videoFolder . '/' . $video->creator . '/' . CStringHelper::getRandom() . '.mp4';
             $outputThumbUrl = $s3outputBaseUrl . '/' . $videoFolder . '/' . $video->creator . '/' . VIDEO_THUMB_FOLDER_NAME . '/';
             //Error: "Filename should only be a file name. It should not include path information."
             //zencoder restricted the filename, so we move the path from filename
             $outputBaseUrl = $s3outputBaseUrl . '/' . $videoFolder . '/' . $video->creator;
             $randomFilename = CStringHelper::getRandom();
             $outputFilename = $randomFilename . '.mp4';
             $input = JURI::root() . $video->path;
             $oriPath = JPATH::clean(JPATH_ROOT . '/' . $video->path);
             $videoName = explode('/', $video->path);
             $outputObj = new CZencoderOutput();
             $outputObj->setBaseUrl($outputBaseUrl);
             $outputObj->setWidth($outputWidth);
             $outputObj->setHeight($outputHeight);
             $outputObj->setFilename($outputFilename);
             $outputObj->setThumbnailsNumber(1);
             $outputObj->setThumbnailsSize($outputThumbSize);
             $outputObj->setThumbnailsBaseUrl($outputThumbUrl);
             $outputObj->setThumbnailsPublic(1);
             $outputObj->setPublic(1);
             $outputObj->setNotifications(array(array('format' => 'xml', 'url' => CRoute::getExternalURL('index.php?option=com_community&view=videos&task=zencodercallback&videoid=' . $video->id . '&videoname=' . $videoName[count($videoName) - 1]))));
             //Thumbname need to be video specific now
             $outputObj->setThumbnailsPrefix($randomFilename);
             // we only need 1 output file
             $output = array();
             $output[] = $outputObj->build();
             $result = $job->create($input, $output, $test);
             if ($result) {
                 // save into db
                 //$video->path	= $outputFilename;
                 $video->path = $videoFolder . '/' . $video->creator . '/' . $outputFilename;
                 $video->thumb = $outputThumbUrl . $randomFilename . '_0000.png';
                 $video->duration = 0;
                 $video->storage = 's3';
                 $video->status = 'ready';
                 $storageTable = JTable::getInstance('StorageS3', 'CTable');
                 $storageTable->storageid = $video->path;
                 $storageTable->resource_path = $video->path;
                 $storageTable->store();
                 $table->reset();
                 $table->bind($video);
                 if ($table->store()) {
                     $this->errorMsg[] = $table->getError();
                 }
                 $this->addVideoActivity($table);
                 $videoCounter++;
             } else {
                 $this->errorMsg[] = $job->getError();
             }
         }
     } else {
         $videoSize = CVideosHelper::getVideoSize();
         $injectMetadata = JFile::exists($this->flvtool2);
         foreach ($videos as $video) {
             $videoInFile = JPATH::clean(JPATH_ROOT . '/' . $video->path);
             $videoOutFolder = JPATH::clean(JPATH_ROOT . '/' . $config->get('videofolder') . '/' . VIDEO_FOLDER_NAME . '/' . $video->creator);
             $videoFilename = $this->convertVideo($videoInFile, $videoOutFolder, $videoSize, $deleteOriginal);
             if ($videoFilename) {
                 $videoFullPath = $videoOutFolder . '/' . $videoFilename;
                 if ($injectMetadata) {
                     $this->injectMetadata($videoFullPath);
                 }
                 // Read duration
                 $videoInfo = $this->getVideoInfo($videoFullPath);
                 if (!$videoInfo) {
                     $thumbName = null;
                     $this->errorMsg[] = 'Could not read video information. Video id: ' . $video->id;
                 } else {
                     $videoFrame = CVideosHelper::formatDuration((int) ($videoInfo['duration']['sec'] / 2), 'HH:MM:SS');
                     // Create thumbnail
                     $thumbFolder = JPATH::clean(JPATH_ROOT . '/' . $config->get('videofolder') . '/' . VIDEO_FOLDER_NAME . '/' . $video->creator . '/' . VIDEO_THUMB_FOLDER_NAME);
                     $thumbSize = CVideos::thumbSize();
                     $thumbFileName = $this->createVideoThumb($videoFullPath, $thumbFolder, $videoFrame, $thumbSize);
                 }
                 if (!$thumbFileName) {
                     $this->errorMsg[] = 'Could not create thumbnail for video. Video id: ' . $video->id;
                 }
                 // Save into DB
                 $config = CFactory::getConfig();
                 $videoFolder = $config->get('videofolder');
                 $video->path = $config->get('videofolder') . '/' . VIDEO_FOLDER_NAME . '/' . $video->creator . '/' . $videoFilename;
                 $video->thumb = $config->get('videofolder') . '/' . VIDEO_FOLDER_NAME . '/' . $video->creator . '/' . VIDEO_THUMB_FOLDER_NAME . '/' . $thumbFileName;
                 $video->duration = $videoInfo['duration']['sec'];
                 $video->status = 'ready';
                 $table->reset();
                 $table->bind($video);
                 if (!$table->store()) {
                     $this->errorMsg[] = $table->getError();
                 }
                 // Add into activity streams
                 $this->addVideoActivity($table);
                 $videoCounter++;
                 $params = new CParameter('');
                 $params->set('url', JURI::root() . $table->getViewURI());
                 $params->set('target', $video->creator);
                 CNotificationLibrary::add('videos_convert_success', NULL, $video->creator, JText::sprintf('COM_COMMUNITY_VIDEOS_CONVERT_SUCCESS_SUBJECT', $table->getTitle()), '', 'videos.convert.success', $params, true, '', '', false);
             } else {
                 $this->errorMsg[] = 'Could not convert video id: ' . $video->id;
             }
             $table->reset();
             unset($video);
         }
         // end foreach pending videos
     }
     // Lastly, unlock the videos
     foreach ($videos as $video) {
         $table->load($video->id);
         if ($table->status == 'locked') {
             $table->save(array('status' => 'pending'));
         }
     }
     $this->errorMsg[] = $videoCounter ? $videoCounter . ' videos converted successfully...' : 'No videos was converted';
     $returnMsg = '';
     foreach ($this->errorMsg as $msg) {
         $returnMsg .= "{$msg}\r\n";
     }
     return $returnMsg;
 }
Ejemplo n.º 17
0
 /**
  * Called by status box to add new stream data
  *
  * @param type $message
  * @param type $attachment
  * @return type
  */
 public function ajaxStreamAdd($message, $attachment, $streamFilter = FALSE)
 {
     $streamHTML = '';
     // $attachment pending filter
     $cache = CFactory::getFastCache();
     $cache->clean(array('activities'));
     $my = CFactory::getUser();
     $userparams = $my->getParams();
     if (!COwnerHelper::isRegisteredUser()) {
         return $this->ajaxBlockUnregister();
     }
     //@rule: In case someone bypasses the status in the html, we enforce the character limit.
     $config = CFactory::getConfig();
     if (JString::strlen($message) > $config->get('statusmaxchar')) {
         $message = JHTML::_('string.truncate', $message, $config->get('statusmaxchar'));
     }
     $message = JString::trim($message);
     $objResponse = new JAXResponse();
     $rawMessage = $message;
     // @rule: Autolink hyperlinks
     // @rule: Autolink to users profile when message contains @username
     // $message     = CUserHelper::replaceAliasURL($message); // the processing is done on display side
     $emailMessage = CUserHelper::replaceAliasURL($rawMessage, true);
     // @rule: Spam checks
     if ($config->get('antispam_akismet_status')) {
         $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=' . $my->id));
         $filter->setType('message');
         $filter->setIP($_SERVER['REMOTE_ADDR']);
         if ($filter->isSpam()) {
             $objResponse->addAlert(JText::_('COM_COMMUNITY_STATUS_MARKED_SPAM'));
             return $objResponse->sendResponse();
         }
     }
     $attachment = json_decode($attachment, true);
     switch ($attachment['type']) {
         case 'message':
             //if (!empty($message)) {
             switch ($attachment['element']) {
                 case 'profile':
                     //only update user status if share messgage is on his profile
                     if (COwnerHelper::isMine($my->id, $attachment['target'])) {
                         //save the message
                         $status = $this->getModel('status');
                         /* If no privacy in attachment than we apply default: Public */
                         if (!isset($attachment['privacy'])) {
                             $attachment['privacy'] = COMMUNITY_STATUS_PRIVACY_PUBLIC;
                         }
                         $status->update($my->id, $rawMessage, $attachment['privacy']);
                         //set user status for current session.
                         $today = JFactory::getDate();
                         $message2 = empty($message) ? ' ' : $message;
                         $my->set('_status', $rawMessage);
                         $my->set('_posted_on', $today->toSql());
                         // Order of replacement
                         $order = array("\r\n", "\n", "\r");
                         $replace = '<br />';
                         // Processes \r\n's first so they aren't converted twice.
                         $messageDisplay = str_replace($order, $replace, $message);
                         $messageDisplay = CKses::kses($messageDisplay, CKses::allowed());
                         //update user status
                         $objResponse->addScriptCall("joms.jQuery('#profile-status span#profile-status-message').html('" . addslashes($messageDisplay) . "');");
                     }
                     //if actor posted something to target, the privacy should be under target's profile privacy settings
                     if (!COwnerHelper::isMine($my->id, $attachment['target']) && $attachment['target'] != '') {
                         $attachment['privacy'] = CFactory::getUser($attachment['target'])->getParams()->get('privacyProfileView');
                     }
                     //push to activity stream
                     $act = new stdClass();
                     $act->cmd = 'profile.status.update';
                     $act->actor = $my->id;
                     $act->target = $attachment['target'];
                     $act->title = $message;
                     $act->content = '';
                     $act->app = $attachment['element'];
                     $act->cid = $my->id;
                     $act->access = $attachment['privacy'];
                     $act->comment_id = CActivities::COMMENT_SELF;
                     $act->comment_type = 'profile.status';
                     $act->like_id = CActivities::LIKE_SELF;
                     $act->like_type = 'profile.status';
                     $activityParams = new CParameter('');
                     /* Save cords if exists */
                     if (isset($attachment['location'])) {
                         /* Save geo name */
                         $act->location = $attachment['location'][0];
                         $act->latitude = $attachment['location'][1];
                         $act->longitude = $attachment['location'][2];
                     }
                     $headMeta = new CParameter('');
                     if (isset($attachment['fetch'])) {
                         $headMeta->set('title', $attachment['fetch'][2]);
                         $headMeta->set('description', $attachment['fetch'][3]);
                         $headMeta->set('image', $attachment['fetch'][1]);
                         $headMeta->set('link', $attachment['fetch'][0]);
                         //do checking if this is a video link
                         $video = JTable::getInstance('Video', 'CTable');
                         $isValidVideo = @$video->init($attachment['fetch'][0]);
                         if ($isValidVideo) {
                             $headMeta->set('type', 'video');
                             $headMeta->set('video_provider', $video->type);
                             $headMeta->set('video_id', $video->getVideoId());
                             $headMeta->set('height', $video->getHeight());
                             $headMeta->set('width', $video->getWidth());
                         }
                         $activityParams->set('headMetas', $headMeta->toString());
                     }
                     //Store mood in paramm
                     if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') {
                         $activityParams->set('mood', $attachment['mood']);
                     }
                     $act->params = $activityParams->toString();
                     //CActivityStream::add($act);
                     //check if the user points is enabled
                     if (CUserPoints::assignPoint('profile.status.update')) {
                         /* Let use our new CApiStream */
                         $activityData = CApiActivities::add($act);
                         CTags::add($activityData);
                         $recipient = CFactory::getUser($attachment['target']);
                         $params = new CParameter('');
                         $params->set('actorName', $my->getDisplayName());
                         $params->set('recipientName', $recipient->getDisplayName());
                         $params->set('url', CUrlHelper::userLink($act->target, false));
                         $params->set('message', $message);
                         $params->set('stream', JText::_('COM_COMMUNITY_SINGULAR_STREAM'));
                         $params->set('stream_url', CRoute::_('index.php?option=com_community&view=profile&userid=' . $activityData->actor . '&actid=' . $activityData->id));
                         CNotificationLibrary::add('profile_status_update', $my->id, $attachment['target'], JText::sprintf('COM_COMMUNITY_FRIEND_WALL_POST', $my->getDisplayName()), '', 'wall.post', $params);
                         //email and add notification if user are tagged
                         CUserHelper::parseTaggedUserNotification($message, $my, $activityData, array('type' => 'post-comment'));
                     }
                     break;
                     // Message posted from Group page
                 // Message posted from Group page
                 case 'groups':
                     //
                     $groupLib = new CGroups();
                     $group = JTable::getInstance('Group', 'CTable');
                     $group->load($attachment['target']);
                     // Permission check, only site admin and those who has
                     // mark their attendance can post message
                     if (!COwnerHelper::isCommunityAdmin() && !$group->isMember($my->id) && $config->get('lockgroupwalls')) {
                         $objResponse->addScriptCall("alert('permission denied');");
                         return $objResponse->sendResponse();
                     }
                     $act = new stdClass();
                     $act->cmd = 'groups.wall';
                     $act->actor = $my->id;
                     $act->target = 0;
                     $act->title = $message;
                     $act->content = '';
                     $act->app = 'groups.wall';
                     $act->cid = $attachment['target'];
                     $act->groupid = $group->id;
                     $act->group_access = $group->approvals;
                     $act->eventid = 0;
                     $act->access = 0;
                     $act->comment_id = CActivities::COMMENT_SELF;
                     $act->comment_type = 'groups.wall';
                     $act->like_id = CActivities::LIKE_SELF;
                     $act->like_type = 'groups.wall';
                     $activityParams = new CParameter('');
                     /* Save cords if exists */
                     if (isset($attachment['location'])) {
                         /* Save geo name */
                         $act->location = $attachment['location'][0];
                         $act->latitude = $attachment['location'][1];
                         $act->longitude = $attachment['location'][2];
                     }
                     $headMeta = new CParameter('');
                     if (isset($attachment['fetch'])) {
                         $headMeta->set('title', $attachment['fetch'][2]);
                         $headMeta->set('description', $attachment['fetch'][3]);
                         $headMeta->set('image', $attachment['fetch'][1]);
                         $headMeta->set('link', $attachment['fetch'][0]);
                         //do checking if this is a video link
                         $video = JTable::getInstance('Video', 'CTable');
                         $isValidVideo = @$video->init($attachment['fetch'][0]);
                         if ($isValidVideo) {
                             $headMeta->set('type', 'video');
                             $headMeta->set('video_provider', $video->type);
                             $headMeta->set('video_id', $video->getVideoId());
                             $headMeta->set('height', $video->getHeight());
                             $headMeta->set('width', $video->getWidth());
                         }
                         $activityParams->set('headMetas', $headMeta->toString());
                     }
                     //Store mood in paramm
                     if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') {
                         $activityParams->set('mood', $attachment['mood']);
                     }
                     $act->params = $activityParams->toString();
                     $activityData = CApiActivities::add($act);
                     CTags::add($activityData);
                     CUserPoints::assignPoint('group.wall.create');
                     $recipient = CFactory::getUser($attachment['target']);
                     $params = new CParameter('');
                     $params->set('message', $emailMessage);
                     $params->set('group', $group->name);
                     $params->set('group_url', 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id);
                     $params->set('url', CRoute::getExternalURL('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id, false));
                     //Get group member emails
                     $model = CFactory::getModel('Groups');
                     $members = $model->getMembers($attachment['target'], null, true, false, true);
                     $membersArray = array();
                     if (!is_null($members)) {
                         foreach ($members as $row) {
                             if ($my->id != $row->id) {
                                 $membersArray[] = $row->id;
                             }
                         }
                     }
                     $groupParams = new CParameter($group->params);
                     if ($groupParams->get('wallnotification')) {
                         CNotificationLibrary::add('groups_wall_create', $my->id, $membersArray, JText::sprintf('COM_COMMUNITY_NEW_WALL_POST_NOTIFICATION_EMAIL_SUBJECT', $my->getDisplayName(), $group->name), '', 'groups.post', $params);
                     }
                     //@since 4.1 when a there is a new post in group, dump the data into group stats
                     $statsModel = CFactory::getModel('stats');
                     $statsModel->addGroupStats($group->id, 'post');
                     // Add custom stream
                     // Reload the stream with new stream data
                     $streamHTML = $groupLib->getStreamHTML($group, array('showLatestActivityOnTop' => true));
                     break;
                     // Message posted from Event page
                 // Message posted from Event page
                 case 'events':
                     $eventLib = new CEvents();
                     $event = JTable::getInstance('Event', 'CTable');
                     $event->load($attachment['target']);
                     // Permission check, only site admin and those who has
                     // mark their attendance can post message
                     if (!COwnerHelper::isCommunityAdmin() && !$event->isMember($my->id) && $config->get('lockeventwalls')) {
                         $objResponse->addScriptCall("alert('permission denied');");
                         return $objResponse->sendResponse();
                     }
                     // If this is a group event, set the group object
                     $groupid = $event->type == 'group' ? $event->contentid : 0;
                     //
                     $groupLib = new CGroups();
                     $group = JTable::getInstance('Group', 'CTable');
                     $group->load($groupid);
                     $act = new stdClass();
                     $act->cmd = 'events.wall';
                     $act->actor = $my->id;
                     $act->target = 0;
                     $act->title = $message;
                     $act->content = '';
                     $act->app = 'events.wall';
                     $act->cid = $attachment['target'];
                     $act->groupid = $event->type == 'group' ? $event->contentid : 0;
                     $act->group_access = $group->approvals;
                     $act->eventid = $event->id;
                     $act->event_access = $event->permission;
                     $act->access = 0;
                     $act->comment_id = CActivities::COMMENT_SELF;
                     $act->comment_type = 'events.wall';
                     $act->like_id = CActivities::LIKE_SELF;
                     $act->like_type = 'events.wall';
                     $activityParams = new CParameter('');
                     /* Save cords if exists */
                     if (isset($attachment['location'])) {
                         /* Save geo name */
                         $act->location = $attachment['location'][0];
                         $act->latitude = $attachment['location'][1];
                         $act->longitude = $attachment['location'][2];
                     }
                     $headMeta = new CParameter('');
                     if (isset($attachment['fetch'])) {
                         $headMeta->set('title', $attachment['fetch'][2]);
                         $headMeta->set('description', $attachment['fetch'][3]);
                         $headMeta->set('image', $attachment['fetch'][1]);
                         $headMeta->set('link', $attachment['fetch'][0]);
                         //do checking if this is a video link
                         $video = JTable::getInstance('Video', 'CTable');
                         $isValidVideo = @$video->init($attachment['fetch'][0]);
                         if ($isValidVideo) {
                             $headMeta->set('type', 'video');
                             $headMeta->set('video_provider', $video->type);
                             $headMeta->set('video_id', $video->getVideoId());
                             $headMeta->set('height', $video->getHeight());
                             $headMeta->set('width', $video->getWidth());
                         }
                         $activityParams->set('headMetas', $headMeta->toString());
                     }
                     //Store mood in paramm
                     if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') {
                         $activityParams->set('mood', $attachment['mood']);
                     }
                     $act->params = $activityParams->toString();
                     $activityData = CApiActivities::add($act);
                     CTags::add($activityData);
                     // add points
                     CUserPoints::assignPoint('event.wall.create');
                     $params = new CParameter('');
                     $params->set('message', $emailMessage);
                     $params->set('event', $event->title);
                     $params->set('event_url', 'index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id);
                     $params->set('url', CRoute::getExternalURL('index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id, false));
                     //Get event member emails
                     $members = $event->getMembers(COMMUNITY_EVENT_STATUS_ATTEND, 12, CC_RANDOMIZE);
                     $membersArray = array();
                     if (!is_null($members)) {
                         foreach ($members as $row) {
                             if ($my->id != $row->id) {
                                 $membersArray[] = $row->id;
                             }
                         }
                     }
                     CNotificationLibrary::add('events_wall_create', $my->id, $membersArray, JText::sprintf('COM_COMMUNITY_NEW_WALL_POST_NOTIFICATION_EMAIL_SUBJECT_EVENTS', $my->getDisplayName(), $event->title), '', 'events.post', $params);
                     //@since 4.1 when a there is a new post in event, dump the data into event stats
                     $statsModel = CFactory::getModel('stats');
                     $statsModel->addEventStats($event->id, 'post');
                     // Reload the stream with new stream data
                     $streamHTML = $eventLib->getStreamHTML($event, array('showLatestActivityOnTop' => true));
                     break;
             }
             $objResponse->addScriptCall('__callback', '');
             // /}
             break;
         case 'photo':
             switch ($attachment['element']) {
                 case 'profile':
                     $photoIds = $attachment['id'];
                     //use User Preference for Privacy
                     //$privacy = $userparams->get('privacyPhotoView'); //$privacy = $attachment['privacy'];
                     $photo = JTable::getInstance('Photo', 'CTable');
                     if (!isset($photoIds[0]) || $photoIds[0] <= 0) {
                         //$objResponse->addScriptCall('__callback', JText::sprintf('COM_COMMUNITY_PHOTO_UPLOADED_SUCCESSFULLY', $photo->caption));
                         exit;
                     }
                     //always get album id from the photo itself, do not let it assign by params from user post data
                     $photoModel = CFactory::getModel('photos');
                     $photo = $photoModel->getPhoto($photoIds[0]);
                     /* OK ! If album_id is not provided than we use album id from photo ( it should be default album id ) */
                     $albumid = isset($attachment['album_id']) ? $attachment['album_id'] : $photo->albumid;
                     $album = JTable::getInstance('Album', 'CTable');
                     $album->load($albumid);
                     $privacy = $album->permissions;
                     //limit checking
                     //                        $photoModel = CFactory::getModel( 'photos' );
                     //                        $config       = CFactory::getConfig();
                     //                        $total        = $photoModel->getTotalToday( $my->id );
                     //                        $max      = $config->getInt( 'limit_photo_perday' );
                     //                        $remainingUploadCount = $max - $total;
                     $params = array();
                     foreach ($photoIds as $key => $photoId) {
                         if (CLimitsLibrary::exceedDaily('photos')) {
                             unset($photoIds[$key]);
                             continue;
                         }
                         $photo->load($photoId);
                         $photo->permissions = $privacy;
                         $photo->published = 1;
                         $photo->status = 'ready';
                         $photo->albumid = $albumid;
                         /* We must update this photo into correct album id */
                         $photo->store();
                         $params[] = clone $photo;
                     }
                     if ($config->get('autoalbumcover') && !$album->photoid) {
                         $album->photoid = $photoIds[0];
                         $album->store();
                     }
                     // Break if no photo added, which is likely because of daily limit.
                     if (count($photoIds) < 1) {
                         $objResponse->addScriptCall('__throwError', JText::_('COM_COMMUNITY_PHOTO_UPLOAD_LIMIT_EXCEEDED'));
                         return $objResponse->sendResponse();
                     }
                     // Trigger onPhotoCreate
                     //
                     $apps = CAppPlugins::getInstance();
                     $apps->loadApplications();
                     $apps->triggerEvent('onPhotoCreate', array($params));
                     $act = new stdClass();
                     $act->cmd = 'photo.upload';
                     $act->actor = $my->id;
                     $act->access = $privacy;
                     //$attachment['privacy'];
                     $act->target = $attachment['target'] == $my->id ? 0 : $attachment['target'];
                     $act->title = $message;
                     $act->content = '';
                     // Generated automatically by stream. No need to add anything
                     $act->app = 'photos';
                     $act->cid = $albumid;
                     $act->location = $album->location;
                     /* Comment and like for individual photo upload is linked
                      * to the photos itsel
                      */
                     $act->comment_id = $photo->id;
                     $act->comment_type = 'photos';
                     $act->like_id = $photo->id;
                     $act->like_type = 'photo';
                     $albumUrl = 'index.php?option=com_community&view=photos&task=album&albumid=' . $album->id . '&userid=' . $my->id;
                     $albumUrl = CRoute::_($albumUrl);
                     $photoUrl = 'index.php?option=com_community&view=photos&task=photo&albumid=' . $album->id . '&userid=' . $photo->creator . '&photoid=' . $photo->id;
                     $photoUrl = CRoute::_($photoUrl);
                     $params = new CParameter('');
                     $params->set('multiUrl', $albumUrl);
                     $params->set('photoid', $photo->id);
                     $params->set('action', 'upload');
                     $params->set('stream', '1');
                     $params->set('photo_url', $photoUrl);
                     $params->set('style', COMMUNITY_STREAM_STYLE);
                     $params->set('photosId', implode(',', $photoIds));
                     if (count($photoIds > 1)) {
                         $params->set('count', count($photoIds));
                         $params->set('batchcount', count($photoIds));
                     }
                     //Store mood in param
                     if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') {
                         $params->set('mood', $attachment['mood']);
                     }
                     // Add activity logging
                     // CActivityStream::remove($act->app, $act->cid);
                     $activityData = CActivityStream::add($act, $params->toString());
                     // Add user points
                     CUserPoints::assignPoint('photo.upload');
                     //add a notification to the target user if someone posted photos on target's profile
                     if ($my->id != $attachment['target']) {
                         $recipient = CFactory::getUser($attachment['target']);
                         $params = new CParameter('');
                         $params->set('actorName', $my->getDisplayName());
                         $params->set('recipientName', $recipient->getDisplayName());
                         $params->set('url', CUrlHelper::userLink($act->target, false));
                         $params->set('message', $message);
                         $params->set('stream', JText::_('COM_COMMUNITY_SINGULAR_STREAM'));
                         $params->set('stream_url', CRoute::_('index.php?option=com_community&view=profile&userid=' . $activityData->actor . '&actid=' . $activityData->id));
                         CNotificationLibrary::add('profile_status_update', $my->id, $attachment['target'], JText::sprintf('COM_COMMUNITY_NOTIFICATION_STREAM_PHOTO_POST', count($photoIds)), '', 'wall.post', $params);
                     }
                     //email and add notification if user are tagged
                     CUserHelper::parseTaggedUserNotification($message, $my, $activityData, array('type' => 'post-comment'));
                     $objResponse->addScriptCall('__callback', JText::sprintf('COM_COMMUNITY_PHOTO_UPLOADED_SUCCESSFULLY', $photo->caption));
                     break;
                 case 'events':
                     $event = JTable::getInstance('Event', 'CTable');
                     $event->load($attachment['target']);
                     $privacy = 0;
                     //if this is a group event, we need to follow the group privacy
                     if ($event->type == 'group' && $event->contentid) {
                         $group = JTable::getInstance('Group', 'CTable');
                         $group->load(${$event}->contentid);
                         $privacy = $group->approvals ? PRIVACY_GROUP_PRIVATE_ITEM : 0;
                     }
                     $photoIds = $attachment['id'];
                     $photo = JTable::getInstance('Photo', 'CTable');
                     $photo->load($photoIds[0]);
                     $albumid = isset($attachment['album_id']) ? $attachment['album_id'] : $photo->albumid;
                     $album = JTable::getInstance('Album', 'CTable');
                     $album->load($albumid);
                     $params = array();
                     foreach ($photoIds as $photoId) {
                         $photo->load($photoId);
                         $photo->caption = $message;
                         $photo->permissions = $privacy;
                         $photo->published = 1;
                         $photo->status = 'ready';
                         $photo->albumid = $albumid;
                         $photo->store();
                         $params[] = clone $photo;
                     }
                     // Trigger onPhotoCreate
                     //
                     $apps = CAppPlugins::getInstance();
                     $apps->loadApplications();
                     $apps->triggerEvent('onPhotoCreate', array($params));
                     $act = new stdClass();
                     $act->cmd = 'photo.upload';
                     $act->actor = $my->id;
                     $act->access = $privacy;
                     $act->target = $attachment['target'] == $my->id ? 0 : $attachment['target'];
                     $act->title = $message;
                     //JText::sprintf('COM_COMMUNITY_ACTIVITIES_UPLOAD_PHOTO' , '{photo_url}', $album->name );
                     $act->content = '';
                     // Generated automatically by stream. No need to add anything
                     $act->app = 'photos';
                     $act->cid = $album->id;
                     $act->location = $album->location;
                     $act->eventid = $event->id;
                     $act->group_access = $privacy;
                     // just in case this event belongs to a group
                     //$act->access      = $attachment['privacy'];
                     /* Comment and like for individual photo upload is linked
                      * to the photos itsel
                      */
                     $act->comment_id = $photo->id;
                     $act->comment_type = 'photos';
                     $act->like_id = $photo->id;
                     $act->like_type = 'photo';
                     $albumUrl = 'index.php?option=com_community&view=photos&task=album&albumid=' . $album->id . '&userid=' . $my->id;
                     $albumUrl = CRoute::_($albumUrl);
                     $photoUrl = 'index.php?option=com_community&view=photos&task=photo&albumid=' . $album->id . '&userid=' . $photo->creator . '&photoid=' . $photo->id;
                     $photoUrl = CRoute::_($photoUrl);
                     $params = new CParameter('');
                     $params->set('multiUrl', $albumUrl);
                     $params->set('photoid', $photo->id);
                     $params->set('action', 'upload');
                     $params->set('stream', '1');
                     // this photo uploaded from status stream
                     $params->set('photo_url', $photoUrl);
                     $params->set('style', COMMUNITY_STREAM_STYLE);
                     // set stream style
                     $params->set('photosId', implode(',', $photoIds));
                     // Add activity logging
                     if (count($photoIds > 1)) {
                         $params->set('count', count($photoIds));
                         $params->set('batchcount', count($photoIds));
                     }
                     //Store mood in paramm
                     if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') {
                         $params->set('mood', $attachment['mood']);
                     }
                     // CActivityStream::remove($act->app, $act->cid);
                     $activityData = CActivityStream::add($act, $params->toString());
                     // Add user points
                     CUserPoints::assignPoint('photo.upload');
                     // Reload the stream with new stream data
                     $eventLib = new CEvents();
                     $event = JTable::getInstance('Event', 'CTable');
                     $event->load($attachment['target']);
                     $streamHTML = $eventLib->getStreamHTML($event, array('showLatestActivityOnTop' => true));
                     $objResponse->addScriptCall('__callback', JText::sprintf('COM_COMMUNITY_PHOTO_UPLOADED_SUCCESSFULLY', $photo->caption));
                     break;
                 case 'groups':
                     //
                     $groupLib = new CGroups();
                     $group = JTable::getInstance('Group', 'CTable');
                     $group->load($attachment['target']);
                     $photoIds = $attachment['id'];
                     $privacy = $group->approvals ? PRIVACY_GROUP_PRIVATE_ITEM : 0;
                     $photo = JTable::getInstance('Photo', 'CTable');
                     $photo->load($photoIds[0]);
                     $albumid = isset($attachment['album_id']) ? $attachment['album_id'] : $photo->albumid;
                     $album = JTable::getInstance('Album', 'CTable');
                     $album->load($albumid);
                     $params = array();
                     foreach ($photoIds as $photoId) {
                         $photo->load($photoId);
                         $photo->caption = $message;
                         $photo->permissions = $privacy;
                         $photo->published = 1;
                         $photo->status = 'ready';
                         $photo->albumid = $albumid;
                         $photo->store();
                         $params[] = clone $photo;
                     }
                     // Trigger onPhotoCreate
                     //
                     $apps = CAppPlugins::getInstance();
                     $apps->loadApplications();
                     $apps->triggerEvent('onPhotoCreate', array($params));
                     $act = new stdClass();
                     $act->cmd = 'photo.upload';
                     $act->actor = $my->id;
                     $act->access = $privacy;
                     $act->target = $attachment['target'] == $my->id ? 0 : $attachment['target'];
                     $act->title = $message;
                     //JText::sprintf('COM_COMMUNITY_ACTIVITIES_UPLOAD_PHOTO' , '{photo_url}', $album->name );
                     $act->content = '';
                     // Generated automatically by stream. No need to add anything
                     $act->app = 'photos';
                     $act->cid = $album->id;
                     $act->location = $album->location;
                     $act->groupid = $group->id;
                     $act->group_access = $group->approvals;
                     $act->eventid = 0;
                     //$act->access      = $attachment['privacy'];
                     /* Comment and like for individual photo upload is linked
                      * to the photos itsel
                      */
                     $act->comment_id = $photo->id;
                     $act->comment_type = 'photos';
                     $act->like_id = $photo->id;
                     $act->like_type = 'photo';
                     $albumUrl = 'index.php?option=com_community&view=photos&task=album&albumid=' . $album->id . '&userid=' . $my->id;
                     $albumUrl = CRoute::_($albumUrl);
                     $photoUrl = 'index.php?option=com_community&view=photos&task=photo&albumid=' . $album->id . '&userid=' . $photo->creator . '&photoid=' . $photo->id;
                     $photoUrl = CRoute::_($photoUrl);
                     $params = new CParameter('');
                     $params->set('multiUrl', $albumUrl);
                     $params->set('photoid', $photo->id);
                     $params->set('action', 'upload');
                     $params->set('stream', '1');
                     // this photo uploaded from status stream
                     $params->set('photo_url', $photoUrl);
                     $params->set('style', COMMUNITY_STREAM_STYLE);
                     // set stream style
                     $params->set('photosId', implode(',', $photoIds));
                     // Add activity logging
                     if (count($photoIds > 1)) {
                         $params->set('count', count($photoIds));
                         $params->set('batchcount', count($photoIds));
                     }
                     //Store mood in paramm
                     if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') {
                         $params->set('mood', $attachment['mood']);
                     }
                     // CActivityStream::remove($act->app, $act->cid);
                     $activityData = CActivityStream::add($act, $params->toString());
                     // Add user points
                     CUserPoints::assignPoint('photo.upload');
                     // Reload the stream with new stream data
                     $streamHTML = $groupLib->getStreamHTML($group, array('showLatestActivityOnTop' => true));
                     $objResponse->addScriptCall('__callback', JText::sprintf('COM_COMMUNITY_PHOTO_UPLOADED_SUCCESSFULLY', $photo->caption));
                     break;
                     dafault:
                     return;
             }
             break;
         case 'video':
             switch ($attachment['element']) {
                 case 'profile':
                     // attachment id
                     $fetch = $attachment['fetch'];
                     $cid = $fetch[0];
                     $privacy = isset($attachment['privacy']) ? $attachment['privacy'] : COMMUNITY_STATUS_PRIVACY_PUBLIC;
                     $video = JTable::getInstance('Video', 'CTable');
                     $video->load($cid);
                     $video->set('creator_type', VIDEO_USER_TYPE);
                     $video->set('status', 'ready');
                     $video->set('permissions', $privacy);
                     $video->set('title', $fetch[3]);
                     $video->set('description', $fetch[4]);
                     $video->set('category_id', $fetch[5]);
                     /* Save cords if exists */
                     if (isset($attachment['location'])) {
                         $video->set('location', $attachment['location'][0]);
                         $video->set('latitude', $attachment['location'][1]);
                         $video->set('longitude', $attachment['location'][2]);
                     }
                     // Add activity logging
                     $url = $video->getViewUri(false);
                     $act = new stdClass();
                     $act->cmd = 'videos.linking';
                     $act->actor = $my->id;
                     $act->target = $attachment['target'] == $my->id ? 0 : $attachment['target'];
                     $act->access = $privacy;
                     //filter empty message
                     $act->title = $message;
                     $act->app = 'videos.linking';
                     $act->content = '';
                     $act->cid = $video->id;
                     $act->location = $video->location;
                     /* Save cords if exists */
                     if (isset($attachment['location'])) {
                         /* Save geo name */
                         $act->location = $attachment['location'][0];
                         $act->latitude = $attachment['location'][1];
                         $act->longitude = $attachment['location'][2];
                     }
                     $act->comment_id = $video->id;
                     $act->comment_type = 'videos.linking';
                     $act->like_id = $video->id;
                     $act->like_type = 'videos.linking';
                     $params = new CParameter('');
                     $params->set('video_url', $url);
                     $params->set('style', COMMUNITY_STREAM_STYLE);
                     // set stream style
                     //Store mood in paramm
                     if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') {
                         $params->set('mood', $attachment['mood']);
                     }
                     //
                     $activityData = CActivityStream::add($act, $params->toString());
                     //this video must be public because it's posted on someone else's profile
                     if ($my->id != $attachment['target']) {
                         $video->set('permissions', COMMUNITY_STATUS_PRIVACY_PUBLIC);
                         $params = new CParameter();
                         $params->set('activity_id', $activityData->id);
                         // activity id is used to remove the activity if someone deleted this video
                         $params->set('target_id', $attachment['target']);
                         $video->params = $params->toString();
                         //also send a notification to the user
                         $recipient = CFactory::getUser($attachment['target']);
                         $params = new CParameter('');
                         $params->set('actorName', $my->getDisplayName());
                         $params->set('recipientName', $recipient->getDisplayName());
                         $params->set('url', CUrlHelper::userLink($act->target, false));
                         $params->set('message', $message);
                         $params->set('stream', JText::_('COM_COMMUNITY_SINGULAR_STREAM'));
                         $params->set('stream_url', CRoute::_('index.php?option=com_community&view=profile&userid=' . $activityData->actor . '&actid=' . $activityData->id));
                         CNotificationLibrary::add('profile_status_update', $my->id, $attachment['target'], JText::_('COM_COMMUNITY_NOTIFICATION_STREAM_VIDEO_POST'), '', 'wall.post', $params);
                     }
                     $video->store();
                     // @rule: Add point when user adds a new video link
                     //
                     CUserPoints::assignPoint('video.add', $video->creator);
                     //email and add notification if user are tagged
                     CUserHelper::parseTaggedUserNotification($message, $my, $activityData, array('type' => 'post-comment'));
                     // Trigger for onVideoCreate
                     //
                     $apps = CAppPlugins::getInstance();
                     $apps->loadApplications();
                     $params = array();
                     $params[] = $video;
                     $apps->triggerEvent('onVideoCreate', $params);
                     $this->cacheClean(array(COMMUNITY_CACHE_TAG_VIDEOS, COMMUNITY_CACHE_TAG_FRONTPAGE, COMMUNITY_CACHE_TAG_FEATURED, COMMUNITY_CACHE_TAG_VIDEOS_CAT, COMMUNITY_CACHE_TAG_ACTIVITIES));
                     $objResponse->addScriptCall('__callback', JText::sprintf('COM_COMMUNITY_VIDEOS_UPLOAD_SUCCESS', $video->title));
                     break;
                 case 'groups':
                     // attachment id
                     $fetch = $attachment['fetch'];
                     $cid = $fetch[0];
                     $privacy = 0;
                     //$attachment['privacy'];
                     $video = JTable::getInstance('Video', 'CTable');
                     $video->load($cid);
                     $video->set('status', 'ready');
                     $video->set('groupid', $attachment['target']);
                     $video->set('permissions', $privacy);
                     $video->set('creator_type', VIDEO_GROUP_TYPE);
                     $video->set('title', $fetch[3]);
                     $video->set('description', $fetch[4]);
                     $video->set('category_id', $fetch[5]);
                     /* Save cords if exists */
                     if (isset($attachment['location'])) {
                         $video->set('location', $attachment['location'][0]);
                         $video->set('latitude', $attachment['location'][1]);
                         $video->set('longitude', $attachment['location'][2]);
                     }
                     $video->store();
                     //
                     $groupLib = new CGroups();
                     $group = JTable::getInstance('Group', 'CTable');
                     $group->load($attachment['target']);
                     // Add activity logging
                     $url = $video->getViewUri(false);
                     $act = new stdClass();
                     $act->cmd = 'videos.linking';
                     $act->actor = $my->id;
                     $act->target = $attachment['target'] == $my->id ? 0 : $attachment['target'];
                     $act->access = $privacy;
                     //filter empty message
                     $act->title = $message;
                     $act->app = 'videos';
                     $act->content = '';
                     $act->cid = $video->id;
                     $act->groupid = $video->groupid;
                     $act->group_access = $group->approvals;
                     $act->location = $video->location;
                     /* Save cords if exists */
                     if (isset($attachment['location'])) {
                         /* Save geo name */
                         $act->location = $attachment['location'][0];
                         $act->latitude = $attachment['location'][1];
                         $act->longitude = $attachment['location'][2];
                     }
                     $act->comment_id = $video->id;
                     $act->comment_type = 'videos';
                     $act->like_id = $video->id;
                     $act->like_type = 'videos';
                     $params = new CParameter('');
                     $params->set('video_url', $url);
                     $params->set('style', COMMUNITY_STREAM_STYLE);
                     // set stream style
                     //Store mood in paramm
                     if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') {
                         $params->set('mood', $attachment['mood']);
                     }
                     $activityData = CActivityStream::add($act, $params->toString());
                     // @rule: Add point when user adds a new video link
                     CUserPoints::assignPoint('video.add', $video->creator);
                     // Trigger for onVideoCreate
                     $apps = CAppPlugins::getInstance();
                     $apps->loadApplications();
                     $params = array();
                     $params[] = $video;
                     $apps->triggerEvent('onVideoCreate', $params);
                     $this->cacheClean(array(COMMUNITY_CACHE_TAG_VIDEOS, COMMUNITY_CACHE_TAG_FRONTPAGE, COMMUNITY_CACHE_TAG_FEATURED, COMMUNITY_CACHE_TAG_VIDEOS_CAT, COMMUNITY_CACHE_TAG_ACTIVITIES));
                     $objResponse->addScriptCall('__callback', JText::sprintf('COM_COMMUNITY_VIDEOS_UPLOAD_SUCCESS', $video->title));
                     // Reload the stream with new stream data
                     $streamHTML = $groupLib->getStreamHTML($group, array('showLatestActivityOnTop' => true));
                     break;
                 case 'events':
                     //event videos
                     $fetch = $attachment['fetch'];
                     $cid = $fetch[0];
                     $privacy = 0;
                     //$attachment['privacy'];
                     $video = JTable::getInstance('Video', 'CTable');
                     $video->load($cid);
                     $video->set('status', 'ready');
                     $video->set('eventid', $attachment['target']);
                     $video->set('permissions', $privacy);
                     $video->set('creator_type', VIDEO_EVENT_TYPE);
                     $video->set('title', $fetch[3]);
                     $video->set('description', $fetch[4]);
                     $video->set('category_id', $fetch[5]);
                     /* Save cords if exists */
                     if (isset($attachment['location'])) {
                         $video->set('location', $attachment['location'][0]);
                         $video->set('latitude', $attachment['location'][1]);
                         $video->set('longitude', $attachment['location'][2]);
                     }
                     $video->store();
                     //
                     $eventLib = new CEvents();
                     $event = JTable::getInstance('Event', 'CTable');
                     $event->load($attachment['target']);
                     $group = new stdClass();
                     if ($event->type == 'group' && $event->contentid) {
                         // check if this a group event, and follow the permission
                         $group = JTable::getInstance('Group', 'CTable');
                         $group->load($event->contentid);
                     }
                     // Add activity logging
                     $url = $video->getViewUri(false);
                     $act = new stdClass();
                     $act->cmd = 'videos.linking';
                     $act->actor = $my->id;
                     $act->target = $attachment['target'] == $my->id ? 0 : $attachment['target'];
                     $act->access = $privacy;
                     //filter empty message
                     $act->title = $message;
                     $act->app = 'videos';
                     $act->content = '';
                     $act->cid = $video->id;
                     $act->groupid = 0;
                     $act->group_access = isset($group->approvals) ? $group->approvals : 0;
                     // if this is a group event
                     $act->location = $video->location;
                     /* Save cords if exists */
                     if (isset($attachment['location'])) {
                         /* Save geo name */
                         $act->location = $attachment['location'][0];
                         $act->latitude = $attachment['location'][1];
                         $act->longitude = $attachment['location'][2];
                     }
                     $act->eventid = $event->id;
                     $act->comment_id = $video->id;
                     $act->comment_type = 'videos';
                     $act->like_id = $video->id;
                     $act->like_type = 'videos';
                     $params = new CParameter('');
                     $params->set('video_url', $url);
                     $params->set('style', COMMUNITY_STREAM_STYLE);
                     // set stream style
                     //Store mood in paramm
                     if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') {
                         $params->set('mood', $attachment['mood']);
                     }
                     $activityData = CActivityStream::add($act, $params->toString());
                     // @rule: Add point when user adds a new video link
                     CUserPoints::assignPoint('video.add', $video->creator);
                     // Trigger for onVideoCreate
                     $apps = CAppPlugins::getInstance();
                     $apps->loadApplications();
                     $params = array();
                     $params[] = $video;
                     $apps->triggerEvent('onVideoCreate', $params);
                     $this->cacheClean(array(COMMUNITY_CACHE_TAG_VIDEOS, COMMUNITY_CACHE_TAG_FRONTPAGE, COMMUNITY_CACHE_TAG_FEATURED, COMMUNITY_CACHE_TAG_VIDEOS_CAT, COMMUNITY_CACHE_TAG_ACTIVITIES));
                     $objResponse->addScriptCall('__callback', JText::sprintf('COM_COMMUNITY_VIDEOS_UPLOAD_SUCCESS', $video->title));
                     // Reload the stream with new stream data
                     $streamHTML = $eventLib->getStreamHTML($event, array('showLatestActivityOnTop' => true));
                     break;
                 default:
                     return;
             }
             break;
         case 'event':
             switch ($attachment['element']) {
                 case 'profile':
                     require_once COMMUNITY_COM_PATH . '/controllers/events.php';
                     $eventController = new CommunityEventsController();
                     // Assign default values where necessary
                     $attachment['description'] = $message;
                     $attachment['ticket'] = 0;
                     $attachment['offset'] = 0;
                     $event = $eventController->ajaxCreate($attachment, $objResponse);
                     $objResponse->addScriptCall('window.location="' . $event->getLink() . '";');
                     if (CFactory::getConfig()->get('event_moderation')) {
                         $objResponse->addAlert(JText::sprintf('COM_COMMUNITY_EVENTS_MODERATION_NOTICE', $event->title));
                     }
                     break;
                 case 'groups':
                     require_once COMMUNITY_COM_PATH . '/controllers/events.php';
                     $eventController = new CommunityEventsController();
                     //
                     $groupLib = new CGroups();
                     $group = JTable::getInstance('Group', 'CTable');
                     $group->load($attachment['target']);
                     // Assign default values where necessary
                     $attachment['description'] = $message;
                     $attachment['ticket'] = 0;
                     $attachment['offset'] = 0;
                     $event = $eventController->ajaxCreate($attachment, $objResponse);
                     CEvents::addGroupNotification($event);
                     $objResponse->addScriptCall('window.location="' . $event->getLink() . '";');
                     // Reload the stream with new stream data
                     $streamHTML = $groupLib->getStreamHTML($group, array('showLatestActivityOnTop' => true));
                     if (CFactory::getConfig()->get('event_moderation')) {
                         $objResponse->addAlert(JText::sprintf('COM_COMMUNITY_EVENTS_MODERATION_NOTICE', $event->title));
                     }
                     break;
             }
             break;
         case 'link':
             break;
     }
     //no matter what kind of message it is, always filter the hashtag if there's any
     if (!empty($act->title) && isset($activityData->id) && $activityData->id) {
         //use model to check if this has a tag in it and insert into the table if possible
         $hashtags = CContentHelper::getHashTags($act->title);
         if (count($hashtags)) {
             //$hashTag
             $hashtagModel = CFactory::getModel('hashtags');
             foreach ($hashtags as $tag) {
                 $hashtagModel->addActivityHashtag($tag, $activityData->id);
             }
         }
     }
     // Frontpage filter
     if ($streamFilter != false) {
         $streamFilter = json_decode($streamFilter);
         $filter = $streamFilter->filter;
         $value = $streamFilter->value;
         $extra = false;
         // Append added data to the list.
         if (isset($activityData) && $activityData->id) {
             $model = CFactory::getModel('Activities');
             $extra = $model->getActivity($activityData->id);
         }
         switch ($filter) {
             case 'privacy':
                 if ($value == 'me-and-friends' && $my->id != 0) {
                     $streamHTML = CActivities::getActivitiesByFilter('active-user-and-friends', $my->id, 'frontpage', true, array(), $extra);
                 } else {
                     $streamHTML = CActivities::getActivitiesByFilter('all', $my->id, 'frontpage', true, array(), $extra);
                 }
                 break;
             case 'apps':
                 $streamHTML = CActivities::getActivitiesByFilter('all', $my->id, 'frontpage', true, array('apps' => array($value)), $extra);
                 break;
             case 'hashtag':
                 $streamHTML = CActivities::getActivitiesByFilter('all', $my->id, 'frontpage', true, array($filter => $value), $extra);
                 break;
             default:
                 $defaultFilter = $config->get('frontpageactivitydefault');
                 if ($defaultFilter == 'friends' && $my->id != 0) {
                     $streamHTML = CActivities::getActivitiesByFilter('active-user-and-friends', $my->id, 'frontpage', true, array(), $extra);
                 } else {
                     $streamHTML = CActivities::getActivitiesByFilter('all', $my->id, 'frontpage', true, array(), $extra);
                 }
                 break;
         }
     }
     if (!isset($attachment['filter'])) {
         $attachment['filter'] = '';
         $filter = $config->get('frontpageactivitydefault');
         $filter = explode(':', $filter);
         $attachment['filter'] = isset($filter[1]) ? $filter[1] : $filter[0];
     }
     if (empty($streamHTML)) {
         if (!isset($attachment['target'])) {
             $attachment['target'] = '';
         }
         if (!isset($attachment['element'])) {
             $attachment['element'] = '';
         }
         $streamHTML = CActivities::getActivitiesByFilter($attachment['filter'], $attachment['target'], $attachment['element'], true, array('show_featured' => true, 'showLatestActivityOnTop' => true));
     }
     $objResponse->addAssign('activity-stream-container', 'innerHTML', $streamHTML);
     // Log user engagement
     CEngagement::log($attachment['type'] . '.share', $my->id);
     return $objResponse->sendResponse();
 }
Ejemplo n.º 18
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__);
 }
Ejemplo n.º 19
0
 public function getPhotoLink($external = false, $xhtml = true)
 {
     $url = $this->getRawPhotoURI();
     if ($external) {
         return CRoute::getExternalURL($url);
     }
     return CRoute::_($url, $xhtml);
 }
Ejemplo n.º 20
0
 /**
  * Responsible for displaying the event page.
  **/
 function viewevent()
 {
     $mainframe = JFactory::getApplication();
     $document = JFactory::getDocument();
     $config = CFactory::getConfig();
     $my = CFactory::getUser();
     CFactory::load('libraries', 'tooltip');
     CFactory::load('libraries', 'wall');
     CFactory::load('libraries', 'window');
     CWindow::load();
     $eventid = JRequest::getInt('eventid', 0);
     $eventModel =& CFactory::getModel('events');
     $event =& JTable::getInstance('Event', 'CTable');
     CFactory::load('helpers', 'event');
     $handler = CEventHelper::getHandler($event);
     $event->load($eventid);
     if (!$handler->exists()) {
         $mainframe->enqueueMessage(JText::_('CC EVENTS NOT AVAILABLE'), 'error');
         return;
     }
     if (!$handler->browsable()) {
         echo JText::_('CC NOT ALLOWED TO ACCESS SECTION');
         return;
     }
     // @rule: Test if the group is unpublished, don't display it at all.
     if (!$event->published) {
         echo JText::_('CC EVENTS UNDER MODERATION');
         return;
     }
     $this->showSubmenu();
     $event->hit();
     // Basic page presentation
     if ($event->type == 'group') {
         $groupId = $event->contentid;
         $group =& JTable::getInstance('Group', 'CTable');
         $group->load($groupId);
         // Set pathway for group videos
         // Community > Groups > Group Name > Events
         $this->addPathway(JText::_('CC GROUPS'), CRoute::_('index.php?option=com_community&view=groups'));
         $this->addPathway($group->name, CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $groupId));
     }
     $this->addPathway(JText::_('CC EVENTS'), CRoute::_('index.php?option=com_community&view=events'));
     $this->addPathway(JText::sprintf('CC VIEW EVENTS TITLE', $event->title), '');
     // Permissions and privacies
     CFactory::load('helpers', 'owner');
     $isEventGuest = $event->isMember($my->id);
     $isMine = $my->id == $event->creator;
     $isAdmin = $event->isAdmin($my->id);
     $isCommunityAdmin = COwnerHelper::isCommunityAdmin();
     // Get Event Admins
     $eventAdmins = $event->getAdmins(12, CC_RANDOMIZE);
     $eventAdminsCount = $event->getAdminsCount();
     // Attach avatar of the admin
     for ($i = 0; $i < count($eventAdmins); $i++) {
         $row =& $eventAdmins[$i];
         $eventAdmins[$i] = CFactory::getUser($row->id);
     }
     // Get Attending Event Guests
     $eventMembers = $event->getMembers(COMMUNITY_EVENT_STATUS_ATTEND, 12, CC_RANDOMIZE);
     $eventMembersCount = $event->getMembersCount(COMMUNITY_EVENT_STATUS_ATTEND);
     // Get pending event guests
     $pendingMembers = $event->getMembers(COMMUNITY_EVENT_STATUS_INVITED, 12, CC_RANDOMIZE);
     $pendingMembersCount = $event->getMembersCount(COMMUNITY_EVENT_STATUS_INVITED);
     // Get blocked Event Guests
     $blockedMembers = $event->getMembers(COMMUNITY_EVENT_STATUS_BLOCKED, 12, CC_RANDOMIZE);
     $blockedMembersCount = $event->getMembersCount(COMMUNITY_EVENT_STATUS_BLOCKED);
     // Attach avatar of the admin
     // Pre-load multiple users at once
     $userids = array();
     foreach ($eventMembers as $uid) {
         $userids[] = $uid->id;
     }
     CFactory::loadUsers($userids);
     for ($i = 0; $i < count($eventMembers); $i++) {
         $row =& $eventMembers[$i];
         $eventMembers[$i] = CFactory::getUser($row->id);
     }
     // Pre-load multiple users at once
     $userids = array();
     foreach ($pendingMembers as $uid) {
         $userids[] = $uid->id;
     }
     CFactory::loadUsers($userids);
     for ($i = 0; $i < count($pendingMembers); $i++) {
         $row =& $pendingMembers[$i];
         $pendingMembers[$i] = CFactory::getUser($row->id);
     }
     // Pre-load multiple users at once
     $userids = array();
     foreach ($blockedMembers as $uid) {
         $userids[] = $uid->id;
     }
     CFactory::loadUsers($userids);
     for ($i = 0; $i < count($blockedMembers); $i++) {
         $row =& $blockedMembers[$i];
         $blockedMembers[$i] = CFactory::getUser($row->id);
     }
     $waitingApproval = $event->isPendingApproval($my->id);
     $waitingRespond = false;
     $myStatus = $event->getUserStatus($my->id);
     $hasResponded = $myStatus == COMMUNITY_EVENT_STATUS_ATTEND || $myStatus == COMMUNITY_EVENT_STATUS_WONTATTEND || $myStatus == COMMUNITY_EVENT_STATUS_MAYBE;
     // Get Bookmark HTML
     CFactory::load('libraries', 'bookmarks');
     $bookmarks = new CBookmarks(CRoute::getExternalURL('index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id));
     $bookmarksHTML = $bookmarks->getHTML();
     // Get Reporting HTML
     CFactory::load('libraries', 'reporting');
     $report = new CReportingLibrary();
     $reportHTML = $report->getReportingHTML(JText::_('CC REPORT EVENT'), 'events,reportEvent', array($event->id));
     // Get the Wall
     CFactory::load('libraries', 'wall');
     $wallContent = CWallLibrary::getWallContents('events', $event->id, $isAdmin, 10, 0, 'wall.content', 'events,events');
     $wallCount = CWallLibrary::getWallCount('events', $event->id);
     $viewAllLink = false;
     if (JRequest::getVar('task', '', 'REQUEST') != 'app') {
         $viewAllLink = CRoute::_('index.php?option=com_community&view=events&task=app&eventid=' . $event->id . '&app=walls');
     }
     $wallContent .= CWallLibrary::getViewAllLinkHTML($viewAllLink, $wallCount);
     $wallForm = '';
     if (!$config->get('lockeventwalls') || $config->get('lockeventwalls') && $isEventGuest && !$waitingApproval && $hasResponded || $isCommunityAdmin) {
         $wallForm = CWallLibrary::getWallInputForm($event->id, 'events,ajaxSaveWall', 'events,ajaxRemoveWall');
     }
     // Construct the RVSP radio list
     $arr = array(JHTML::_('select.option', COMMUNITY_EVENT_STATUS_ATTEND, JText::_('CC EVENT ACTION ATTEND')), JHTML::_('select.option', COMMUNITY_EVENT_STATUS_WONTATTEND, JText::_('CC EVENT ACTION DECLINE')), JHTML::_('select.option', COMMUNITY_EVENT_STATUS_MAYBE, JText::_('CC EVENT ACTION UNSURE')));
     $status = $event->getMemberStatus($my->id);
     $radioList = JHTML::_('select.radiolist', $arr, 'status', '', 'value', 'text', $status, false);
     $unapprovedCount = $event->inviteRequestCount();
     //...
     $editEvent = JRequest::getVar('edit', false, 'GET');
     $editEvent = $editEvent == 1 ? true : false;
     // Am I invited in this event?
     $isInvited = false;
     $join = '';
     $friendsCount = 0;
     $isInvited = $eventModel->isInvitedMe(0, $my->id, $event->id);
     // If I was invited, I want to know my invitation informations
     if ($isInvited) {
         $invitor = CFactory::getUser($isInvited[0]->invited_by);
         $join = '<a href="' . CUrlHelper::userLink($invitor->id) . '">' . $invitor->getDisplayName() . '</a>';
         // Get users friends in this group
         $friendsCount = $eventModel->getFriendsCount($my->id, $event->id);
     }
     $friendsModel = CFactory::getModel('Friends');
     $tmpFriends = $friendsModel->getFriends($my->id, 'name', false);
     $friends = array();
     for ($i = 0; $i < count($tmpFriends); $i++) {
         $friend =& $tmpFriends[$i];
         if (!$event->isMember($friend->id)) {
             $friends[] = $friend;
         }
     }
     unset($tmpFriends);
     // Get like
     CFactory::load('libraries', 'like');
     $likes = new CLike();
     $likesHTML = $likes->getHTML('events', $event->id, $my->id);
     // Is this event is a past event?
     $now = new JDate();
     $isPastEvent = $event->getEndDate(false)->toMySQL() < $now->toMySQL(true) ? true : false;
     // Output to template
     $tmpl = new CTemplate();
     CFactory::load('libraries', 'invitation');
     $inviteHTML = CInvitation::getHTML($friends, 'events,inviteUsers', $event->id, CInvitation::SHOW_FRIENDS, CInvitation::HIDE_EMAIL);
     $tmpl->setMetaTags('event', $event);
     $tmpl->set('timezone', CTimeHelper::getTimezone($event->offset));
     $tmpl->set('handler', $handler);
     $tmpl->set('likesHTML', $likesHTML);
     $tmpl->set('inviteHTML', $inviteHTML);
     $tmpl->set('guestStatus', $event->getUserStatus($my->id));
     $tmpl->set('event', $event);
     $tmpl->set('radioList', $radioList);
     $tmpl->set('bookmarksHTML', $bookmarksHTML);
     $tmpl->set('reportHTML', $reportHTML);
     $tmpl->set('isEventGuest', $isEventGuest);
     $tmpl->set('isMine', $isMine);
     $tmpl->set('isAdmin', $isAdmin);
     $tmpl->set('isCommunityAdmin', $isCommunityAdmin);
     $tmpl->set('unapproved', $unapprovedCount);
     $tmpl->set('waitingApproval', $waitingApproval);
     $tmpl->set('wallForm', $wallForm);
     $tmpl->set('wallContent', $wallContent);
     $tmpl->set('eventAdmins', $eventAdmins);
     $tmpl->set('eventAdminsCount', $eventAdminsCount);
     $tmpl->set('eventMembers', $eventMembers);
     $tmpl->set('eventMembersCount', $eventMembersCount);
     $tmpl->set('blockedMembers', $blockedMembers);
     $tmpl->set('blockedMembersCount', $blockedMembersCount);
     $tmpl->set('pendingMembers', $pendingMembers);
     $tmpl->set('pendingMembersCount', $pendingMembersCount);
     $tmpl->set('editEvent', $editEvent);
     $tmpl->set('my', $my);
     $tmpl->set('memberStatus', $myStatus);
     $tmpl->set('waitingRespond', $waitingRespond);
     $tmpl->set('isInvited', $isInvited);
     $tmpl->set('join', $join);
     $tmpl->set('friendsCount', $friendsCount);
     $tmpl->set('isPastEvent', $isPastEvent);
     echo $tmpl->fetch('events.viewevent');
 }
Ejemplo n.º 21
0
 function _userPhoto()
 {
     $mainframe =& JFactory::getApplication();
     $document =& JFactory::getDocument();
     // Get necessary properties and load the libraries
     CFactory::load('models', 'photos');
     CFactory::load('helpers', 'friends');
     $my = CFactory::getUser();
     $model = CFactory::getModel('photos');
     $albumId = JRequest::getVar('albumid', '', 'GET');
     $defaultId = JRequest::getVar('photoid', '', 'GET');
     if (empty($albumId)) {
         echo JText::_('CC NO PROPER ALBUM ID');
         return;
     }
     // Load the album table
     $album =& JTable::getInstance('Album', 'CTable');
     $album->load($albumId);
     // Since the URL might not contain userid, we need to get the user object from the creator
     $user = CFactory::getUser($album->creator);
     if (!$user->block || COwnerHelper::isCommunityAdmin($my->id)) {
         // Set the current user's active profile
         CFactory::setActiveProfile($album->creator);
         // Get list of photos and set some limit to be displayed.
         // @todo: make limit configurable? set to 1000, unlimited?
         $photos = $model->getPhotos($albumId, 1000);
         $pagination = $model->getPagination();
         CFactory::load('helpers', 'pagination');
         // @todo: make limit configurable?
         $paging = CPaginationLibrary::getLinks($pagination, 'photos,ajaxPagination', $albumId, 10);
         // Set document title
         CFactory::load('helpers', 'string');
         $document->setTitle($album->name);
         // @checks: Test if album doesnt have any default photo id. We need to get the first row
         // of the photos to be the default
         if ($album->photoid == '0') {
             $album->photoid = count($photos) >= 1 ? $photos[0]->id : '0';
         }
         // Try to see if there is any photo id in the query
         $defaultId = !empty($defaultId) ? $defaultId : $album->photoid;
         // Load the default photo
         $photo =& JTable::getInstance('Photo', 'CTable');
         $photo->load($defaultId);
         // If default has an id of 0, we need to tell the template to dont process anything
         $default = $photo->id == 0 ? false : $photo;
         // Load User params
         $params =& $user->getParams();
         // site visitor
         $relation = 10;
         // site members
         if ($my->id != 0) {
             $relation = 20;
         }
         // friends
         if (CFriendsHelper::isConnected($my->id, $user->id)) {
             $relation = 30;
         }
         // mine
         if (COwnerHelper::isMine($my->id, $user->id)) {
             $relation = 40;
         }
         if ($my->id != $user->id) {
             $this->attachMiniHeaderUser($user->id);
         }
         CFactory::load('helpers', 'owner');
         // @todo: respect privacy settings
         if ($relation < $params->get('privacyPhotoView') && !COwnerHelper::isCommunityAdmin()) {
             echo JText::_('CC ACCESS FORBIDDEN');
             return;
         }
         CFactory::load('helpers', 'owner');
         //friend list for photo tag
         CFactory::load('libraries', 'phototagging');
         $tagging = new CPhotoTagging();
         for ($i = 0; $i < count($photos); $i++) {
             $item = JTable::getInstance('Photo', 'CTable');
             $item->bind($photos[$i]);
             $photos[$i] = $item;
             $row =& $photos[$i];
             $taggedList = $tagging->getTaggedList($row->id);
             for ($t = 0; $t < count($taggedList); $t++) {
                 $tagItem =& $taggedList[$t];
                 $tagUser = CFactory::getUser($tagItem->userid);
                 $canRemoveTag = 0;
                 // 1st we check the tagged user is the photo owner.
                 //	If yes, canRemoveTag == true.
                 //	If no, then check on user is the tag creator or not.
                 //		If yes, canRemoveTag == true
                 //		If no, then check on user whether user is being tagged
                 if (COwnerHelper::isMine($my->id, $row->creator) || COwnerHelper::isMine($my->id, $tagItem->created_by) || COwnerHelper::isMine($my->id, $tagItem->userid)) {
                     $canRemoveTag = 1;
                 }
                 $tagItem->user = $tagUser;
                 $tagItem->canRemoveTag = $canRemoveTag;
             }
             $row->tagged = $taggedList;
         }
         $friendModel = CFactory::getModel('friends');
         $friends = $friendModel->getFriends($my->id, '', false);
         array_unshift($friends, $my);
         // Show wall contents
         CFactory::load('helpers', 'friends');
         // Load up required objects.
         $user = CFactory::getUser($photo->creator);
         $config = CFactory::getConfig();
         $isConnected = CFriendsHelper::isConnected($my->id, $user->id);
         $isMe = COwnerHelper::isMine($my->id, $user->id);
         $showWall = false;
         $allowTag = false;
         // Check if user is really allowed to post walls on this photo.
         if ($isMe || !$config->get('lockprofilewalls') || $config->get('lockprofilewalls') && $isConnected) {
             $showWall = true;
         }
         //check if we can allow the current viewing user to tag the photos
         if ($isMe || $isConnected) {
             $allowTag = true;
         }
         $tmpl = new CTemplate();
         CFactory::load('libraries', 'bookmarks');
         $bookmarks = new CBookmarks(CRoute::getExternalURL('index.php?option=com_community&view=photos&task=album&albumid=' . $album->id . '&userid=' . $user->id));
         $bookmarksHTML = $bookmarks->getHTML();
         $tmpl->set('showWall', $showWall);
         $tmpl->set('allowTag', $allowTag);
         $tmpl->set('isOwner', COwnerHelper::isMine($my->id, $user->id));
         $tmpl->set('photos', $photos);
         $tmpl->set('pagination', $paging);
         $tmpl->set('default', $default);
         $tmpl->set('album', $album);
         $tmpl->set('config', $config);
         //echo $tmpl->fetch('photos.photo');
     } else {
         CFactory::load('helpers', 'owner');
         $tmpl = new CTemplate();
         echo $tmpl->fetch('profile.blocked');
         return;
     }
 }
Ejemplo n.º 22
0
 /**
  * Get photo list by album.
  */
 public function ajaxGetPhotosByAlbum($albumId, $photoId)
 {
     $filter = JFilterInput::getInstance();
     $albumId = $filter->clean($albumId, 'int');
     $model = CFactory::getModel('photos');
     $photos = $model->getPhotos($albumId, 1000);
     $count = count($photos);
     $list = array();
     $index = 0;
     $my = CFactory::getUser();
     $config = CFactory::getConfig();
     $canEdit = false;
     $album = JTable::getInstance('Album', 'CTable');
     $album->load($albumId);
     if ($album->type == 'group' && !$my->authorise('community.view', 'photos.group.album.' . $album->groupid, $album)) {
         $json = array('title' => $album->name, 'error' => JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_ACCESS_SECTION'));
         die(json_encode($json));
     }
     if ($album->type != 'group' && !$my->authorise('community.view', 'photos.user.album.' . $albumId)) {
         $json = array('title' => $album->name, 'error' => JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_ACCESS_SECTION'));
         die(json_encode($json));
     }
     $canEdit = $album->hasAccess($my->id, 'upload');
     if (!($count > 0)) {
         $json = array('title' => $album->name, 'error' => JText::_('COM_COMMUNITY_PHOTOS_NO_PHOTOS_UPLOADED'));
         die(json_encode($json));
     }
     for ($i = 0; $i < $count; $i++) {
         $photo = $photos[$i];
         $list[$i] = array('id' => $photo->id, 'caption' => $photo->caption, 'thumbnail' => $photo->getThumbURI(), 'original' => $photo->getOriginalURI(), 'url' => $photo->getImageURI());
         if (!$index && $photo->id == $photoId) {
             $index = $i;
         }
     }
     $isTaggable = false;
     if (COwnerHelper::isMine($my->id, $album->creator) || CFriendsHelper::isConnected($my->id, $album->creator)) {
         $isTaggable = true;
     }
     $json = array();
     $json['list'] = $list;
     $json['index'] = $index;
     $json['can_edit'] = $canEdit ? true : false;
     $json['can_tag'] = $isTaggable;
     $json['album_name'] = $album->name;
     $json['album_url'] = CRoute::_('index.php?option=com_community&view=photos&task=album&albumid=' . $album->id . ($album->groupid > 0 ? '&groupid=' . $album->groupid : ''));
     $json['photo_url'] = CRoute::getExternalURL('index.php?option=com_community&view=photos&task=photo&albumid=' . $album->id . '&photoid=___photo_id___' . ($album->groupid > 0 ? '&groupid=' . $album->groupid : ''), false);
     $json['my_id'] = (int) $my->id;
     $json['owner_id'] = (int) $album->creator;
     $json['is_admin'] = (int) COwnerHelper::isCommunityAdmin();
     $json['deleteoriginalphotos'] = $config->get('deleteoriginalphotos');
     $json['enablereporting'] = $config->get('enablereporting');
     // Languages.
     $json['lang'] = array('comments' => JText::_('COM_COMMUNITY_COMMENTS'), 'tag_photo' => JText::_('COM_COMMUNITY_TAG_THIS_PHOTO'), 'done_tagging' => JText::_('COM_COMMUNITY_PHOTO_DONE_TAGGING'), 'options' => JText::_('COM_COMMUNITY_OPTIONS'), 'download' => JText::_('COM_COMMUNITY_DOWNLOAD_IMAGE'), 'set_as_album_cover' => JText::_('COM_COMMUNITY_PHOTOS_SET_AS_ALBUM_COVER'), 'set_as_profile_picture' => JText::_('COM_COMMUNITY_PHOTOS_SET_AVATAR'), 'delete_photo' => JText::_('COM_COMMUNITY_PHOTOS_DELETE'), 'rotate_left' => JText::_('COM_COMMUNITY_PHOTOS_ROTATE_LEFT'), 'rotate_right' => JText::_('COM_COMMUNITY_PHOTOS_ROTATE_RIGHT'), 'next' => JText::_('COM_COMMUNITY_NEXT'), 'prev' => JText::_('COM_COMMUNITY_PREV'), 'share' => JText::_('COM_COMMUNITY_SHARE'), 'report' => JText::_('COM_COMMUNITY_REPORT'), 'upload_photos' => JText::_('COM_COMMUNITY_PHOTOS_UPLOAD_PHOTOS'), 'view_album' => JText::_('COM_COMMUNITY_VIEW_ALBUM'));
     die(json_encode($json));
 }
Ejemplo n.º 23
0
    </div>
    <div class="joms-js--photo-comment"></div>
</div>

<script>
    (function( w ) {
        var album = '<?php 
echo $album->id;
?>
',
            id = '<?php 
echo $photo->id;
?>
',
            url = '<?php 
echo CRoute::getExternalURL("index.php?option=com_community&view=photos&task=photo&albumid=" . $album->id . "&photoid=___photo_id___" . ($album->groupid > 0 ? "&groupid=" . $album->groupid : ""));
?>
',
            img, caption, btnPrev, btnNext, btnTag, tags, tagLabel, tagRemoveLabel, list, index, lang, albumName;

        // Replace url.
        url = url.replace( /&amp;/g, '&' );

        function init() {
            joms.jQuery( document ).on( 'click', function( e ) {
                var $ct;
                try {
                    $ct = joms.jQuery( e.target ).closest('.joms-js--photo-ct,.joms-js--btn-tag');
                    $ct.length || tagCancel();
                } catch (e) {}
            });
Ejemplo n.º 24
0
 /**
  * Method is used to receive POST requests from specific user
  * that wants to join a group
  * @param fastjoin : join from discussion page
  *
  * @return	void
  **/
 public function ajaxJoinGroup($groupId, $fastJoin = 'no')
 {
     $objResponse = new JAXResponse();
     $filter = JFilterInput::getInstance();
     $groupId = $filter->clean($groupId, 'int');
     $fastJoin = $filter->clean($fastJoin, 'string');
     // Add assertion to the group id since it must be specified in the post request
     CError::assert($groupId, '', '!empty', __FILE__, __LINE__);
     // Get the current user's object
     $my = CFactory::getUser();
     if (!$my->authorise('community.join', 'groups.' . $groupId)) {
         return $this->ajaxBlockUnregister();
     }
     // Load necessary tables
     $groupModel = CFactory::getModel('groups');
     if ($fastJoin == 'yes') {
         $member = $this->_saveMember($groupId);
         $this->cacheClean(array(COMMUNITY_CACHE_TAG_GROUPS, COMMUNITY_CACHE_TAG_ACTIVITIES));
         if ($member->approved) {
             $objResponse->addScriptCall("joms.groups.joinComplete('" . JText::_('COM_COMMUNITY_GROUPS_JOIN_SUCCESS_BUTTON') . "');");
         } else {
             $objResponse->addScriptCall("joms.groups.joinComplete('" . JText::_('COM_COMMUNITY_GROUPS_JOIN_SUCCESS_BUTTON') . "');");
             //$objResponse->addScriptCall("joms.jQuery('.group-top').prepend('<div class=\"info\">".JText::_('COM_COMMUNITY_GROUPS_APPROVAL_NEED')."</div>');");
         }
     } else {
         if ($groupModel->isMember($my->id, $groupId)) {
             $objResponse->addScriptCall("joms.jQuery('.group-top').prepend('<div class=\"info\">" . JText::_('COM_COMMUNITY_GROUPS_ALREADY_MEMBER') . "</div>');");
         } else {
             $url = CRoute::getExternalURL('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $groupId, false);
             $member = $this->_saveMember($groupId);
             $this->cacheClean(array(COMMUNITY_CACHE_TAG_GROUPS, COMMUNITY_CACHE_TAG_ACTIVITIES));
             if ($member->approved) {
                 $objResponse->addScriptCall("joms.jQuery('.group-top').prepend('<div class=\"info\">" . JText::_('COM_COMMUNITY_GROUPS_JOIN_SUCCESS') . "</div>');");
                 $objResponse->addScriptCall("window.location.reload()");
             } else {
                 $objResponse->addScriptCall("joms.jQuery('.group-top').prepend('<div class=\"info\">" . JText::_('COM_COMMUNITY_GROUPS_APPROVAL_NEED') . "</div>');");
             }
             $objResponse->addScriptCall("joms.jQuery('.group-join').parent().remove();");
         }
     }
     return $objResponse->sendResponse();
 }
Ejemplo n.º 25
0
                        </svg>
                        <span><?php 
echo number_format($user->getViewCount());
?>
</span>
                    </a>

                    <?php 
if ($config->get('enablesharethis') == 1) {
    ?>
                    <a class="joms-button--shared" title="<?php 
    echo JText::_('COM_COMMUNITY_SHARE_THIS');
    ?>
"
                            href="javascript:" onclick="joms.api.pageShare('<?php 
    echo CRoute::getExternalURL('index.php?option=com_community&view=profile&userid=' . $profile->id);
    ?>
')">
                        <svg viewBox="0 0 16 16" class="joms-icon">
                            <use xlink:href="<?php 
    echo CRoute::getURI();
    ?>
#joms-icon-redo"></use>
                        </svg>
                    </a>
                    <?php 
}
?>

                    <?php 
if ($enableReporting) {
Ejemplo n.º 26
0
                            </svg>
                            <span><?php 
echo $event->hits;
?>
</span>
                        </a>

                        <?php 
if ($config->get('enablesharethis') == 1) {
    ?>
                        <a class="joms-button--shared" title="<?php 
    echo JText::_('COM_COMMUNITY_SHARE_THIS');
    ?>
"
                                href="javascript:" onclick="joms.api.pageShare('<?php 
    echo CRoute::getExternalURL('index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id);
    ?>
')">
                            <svg viewBox="0 0 16 16" class="joms-icon">
                                <use xlink:href="<?php 
    echo CRoute::getURI();
    ?>
#joms-icon-redo"></use>
                            </svg>
                        </a>
                        <?php 
}
?>

                        <?php 
if ($enableReporting) {
Ejemplo n.º 27
0
 public function getFormattedLink($raw, $xhtml = true, $external = false, $route = true)
 {
     $url = '';
     if ($external) {
         $url = $route ? CRoute::getExternalURL($raw, $xhtml) : $raw;
     } else {
         $url = $route ? CRoute::_($raw, $xhtml) : $raw;
     }
     return $url;
 }
Ejemplo n.º 28
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();
 }
Ejemplo n.º 29
0
 public function getPhotoExternalURI($photoId, $albumId)
 {
     return CRoute::getExternalURL('index.php?option=com_community&view=photos&task=photo&albumid=' . $albumId . '&groupid=' . $this->groupid . '&photoid=' . $photoId);
 }
Ejemplo n.º 30
0
 /**
  * Responsible for displaying the event page.
  * */
 public function viewevent()
 {
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $document = JFactory::getDocument();
     $config = CFactory::getConfig();
     $my = CFactory::getUser();
     CWindow::load();
     $eventLib = new CEvents();
     $eventid = JRequest::getInt('eventid', 0);
     $eventModel = CFactory::getModel('events');
     $event = JTable::getInstance('Event', 'CTable');
     $handler = CEventHelper::getHandler($event);
     $event->load($eventid);
     if (empty($event->id)) {
         return JError::raiseWarning(404, JText::_('COM_COMMUNITY_EVENTS_NOT_AVAILABLE_ERROR'));
     }
     if ($event->unlisted && !$event->isMember($my->id) && !$event->getUserStatus($my->id) == 0) {
         $text = JText::_('COM_COMMUNITY_EVENTS_UNLISTED_ERROR');
         $text .= ' <a href="javascript:" onclick="joms.api.eventJoin(\'' . $event->id . '\');">Request Invitation</a>';
         return JError::raiseWarning(403, $text);
     }
     if (!$handler->exists()) {
         $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_EVENTS_NOT_AVAILABLE_ERROR'), 'error');
         return;
     }
     if (!$handler->browsable()) {
         echo JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_ACCESS_SECTION');
         return;
     }
     // @rule: Test if the group is unpublished, don't display it at all.
     if (!$event->isPublished()) {
         echo JText::_('COM_COMMUNITY_EVENTS_UNDER_MODERATION');
         return;
     }
     //$this->showSubmenu();
     $event->hit();
     $isGroupAdmin = false;
     // Basic page presentation
     if ($event->type == 'group') {
         $groupId = $event->contentid;
         $group = JTable::getInstance('Group', 'CTable');
         $group->load($groupId);
         // Set pathway for group videos
         // Community > Groups > Group Name > Events
         $this->addPathway(JText::_('COM_COMMUNITY_GROUPS'), CRoute::_('index.php?option=com_community&view=groups'));
         $this->addPathway($group->name, CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $groupId));
         $groupEventDetails = new stdClass();
         $groupEventDetails->creator = CFactory::getUser($event->creator);
         $groupEventDetails->groupName = $group->name;
         $groupEventDetails->groupLink = CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id);
         $isGroupAdmin = $group->isAdmin($my->id);
     }
     $this->addPathway(JText::_('COM_COMMUNITY_EVENTS'), CRoute::_('index.php?option=com_community&view=events'));
     $this->addPathway($event->title);
     /**
      * Opengraph
      */
     CHeadHelper::setType('website', JText::sprintf('COM_COMMUNITY_EVENT_PAGE_TITLE', $event->title), null, array($event->getCover()));
     // Permissions and privacies
     $isEventGuest = $event->isMember($my->id);
     $isMine = $my->id == $event->creator;
     $isAdmin = $event->isAdmin($my->id) || $isGroupAdmin;
     $isCommunityAdmin = COwnerHelper::isCommunityAdmin();
     // Get Event Admins
     $eventAdmins = $event->getAdmins(12, CC_RANDOMIZE);
     $adminsInArray = array();
     // Attach avatar of the admin
     for ($i = 0; $i < count($eventAdmins); $i++) {
         $row = $eventAdmins[$i];
         $admin = CFactory::getUser($row->id);
         array_push($adminsInArray, '<a href="' . CUrlHelper::userLink($admin->id) . '">' . $admin->getDisplayName() . '</a>');
     }
     $adminsList = ltrim(implode(', ', $adminsInArray), ',');
     // Get Attending Event Guests
     $eventMembers = $event->getMembers(COMMUNITY_EVENT_STATUS_ATTEND, CFactory::getConfig()->get('event_sidebar_members_show_total', 12), CC_RANDOMIZE);
     $eventMembersCount = $event->getMembersCount(COMMUNITY_EVENT_STATUS_ATTEND);
     // Attach avatar of the admin
     // Pre-load multiple users at once
     $userids = array();
     foreach ($eventMembers as $uid) {
         $userids[] = $uid->id;
     }
     CFactory::loadUsers($userids);
     for ($i = 0; $i < count($eventMembers); $i++) {
         $row = $eventMembers[$i];
         $eventMembers[$i] = CFactory::getUser($row->id);
     }
     // Pre-load multiple users at once
     $waitingApproval = $event->isPendingApproval($my->id);
     $waitingRespond = false;
     $myStatus = $event->getUserStatus($my->id);
     $hasResponded = $myStatus == COMMUNITY_EVENT_STATUS_ATTEND || $myStatus == COMMUNITY_EVENT_STATUS_WONTATTEND || $myStatus == COMMUNITY_EVENT_STATUS_MAYBE;
     // Get Bookmark HTML
     $bookmarks = new CBookmarks(CRoute::getExternalURL('index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id));
     $bookmarksHTML = $bookmarks->getHTML();
     // Get the Wall
     $wallContent = CWallLibrary::getWallContents('events', $event->id, $isAdmin, $config->get('stream_default_comments'), 0, 'wall/content', 'events,events');
     $wallCount = CWallLibrary::getWallCount('events', $event->id);
     $viewAllLink = false;
     if ($jinput->request->get('task', '', 'STRING') != 'app') {
         $viewAllLink = CRoute::_('index.php?option=com_community&view=events&task=app&eventid=' . $event->id . '&app=walls');
     }
     $wallContent .= CWallLibrary::getViewAllLinkHTML($viewAllLink, $wallCount);
     $wallForm = '';
     // Construct the RVSP radio list
     $arr = array(JHTML::_('select.option', COMMUNITY_EVENT_STATUS_ATTEND, JText::_('COM_COMMUNITY_EVENTS_YES')), JHTML::_('select.option', COMMUNITY_EVENT_STATUS_WONTATTEND, JText::_('COM_COMMUNITY_EVENTS_NO')), JHTML::_('select.option', COMMUNITY_EVENT_STATUS_MAYBE, JText::_('COM_COMMUNITY_EVENTS_MAYBE')));
     $status = $event->getMemberStatus($my->id);
     $radioList = JHTML::_('select.radiolist', $arr, 'status', '', 'value', 'text', $status, false);
     $unapprovedCount = $event->inviteRequestCount();
     //...
     $editEvent = $jinput->get->get('edit', false, 'NONE');
     $editEvent = $editEvent == 1 ? true : false;
     // Am I invited in this event?
     $isInvited = false;
     $join = '';
     $friendsCount = 0;
     $isInvited = $eventModel->isInvitedMe(0, $my->id, $event->id);
     // If I was invited, I want to know my invitation informations
     if ($isInvited) {
         $invitor = CFactory::getUser($isInvited[0]->invited_by);
         $join = '<a href="' . CUrlHelper::userLink($invitor->id) . '">' . $invitor->getDisplayName() . '</a>';
         // Get users friends in this group
         $friendsCount = $eventModel->getFriendsCount($my->id, $event->id);
     }
     // Get like
     $likes = new CLike();
     $isUserLiked = false;
     if ($isLikeEnabled = $likes->enabled('events')) {
         $isUserLiked = $likes->userLiked('events', $event->id, $my->id);
     }
     $totalLikes = $likes->getLikeCount('events', $event->id);
     // Is this event is a past event?
     $now = new JDate();
     $isPastEvent = $event->getEndDate(false)->toSql() < $now->toSql(true) ? true : false;
     // Get the formated date & time
     $format = $config->get('eventshowampm') ? JText::_('COM_COMMUNITY_EVENTS_TIME_FORMAT_12HR') : JText::_('COM_COMMUNITY_EVENTS_TIME_FORMAT_24HR');
     $startDate = $event->getStartDate(false);
     $endDate = $event->getEndDate(false);
     $allday = false;
     if ($startDate->format('%Y-%m-%d') == $endDate->format('%Y-%m-%d') && $startDate->format('%H:%M:%S') == '00:00:00' && $endDate->format('%H:%M:%S') == '23:59:59') {
         $format = JText::_('COM_COMMUNITY_EVENT_TIME_FORMAT_LC1');
         $allday = true;
     }
     $event->startdateHTML = CTimeHelper::getFormattedTime($event->startdate, $format);
     $event->enddateHTML = CTimeHelper::getFormattedTime($event->enddate, $format);
     if (!isset($event->params)) {
         $event->params = '';
     }
     $params = new CParameter($event->params);
     $event->defaultCover = $event->isDefaultCover();
     // Cover position.
     $event->coverPostion = $params->get('coverPosition', '');
     if (strpos($event->coverPostion, '%') === false) {
         $event->coverPostion = 0;
     }
     // Find cover album and photo.
     $event->coverAlbum = false;
     $event->coverPhoto = false;
     $album = JTable::getInstance('Album', 'CTable');
     $albumId = $album->isCoverExist('event', $event->id);
     if ($albumId) {
         $album->load($albumId);
         $event->coverAlbum = $albumId;
         $event->coverPhoto = $album->photoid;
     }
     $inviteHTML = CInvitation::getHTML(null, 'events,inviteUsers', $event->id, CInvitation::SHOW_FRIENDS, CInvitation::SHOW_EMAIL);
     $status = new CUserStatus($event->id, 'events');
     $tmpl = new CTemplate();
     $creator = new CUserStatusCreator('message');
     $creator->title = $isMine ? JText::_('COM_COMMUNITY_STATUS') : JText::_('COM_COMMUNITY_MESSAGE');
     $creator->html = $tmpl->fetch('status.message');
     $status->addCreator($creator);
     // Upgrade wall to stream @since 2.5
     $event->upgradeWallToStream();
     // Add custom stream
     $streamHTML = $eventLib->getStreamHTML($event);
     if ($event->getMemberStatus($my->id) == COMMUNITY_EVENT_STATUS_ATTEND) {
         $RSVPmessage = JText::_('COM_COMMUNITY_EVENTS_ATTENDING_EVENT_MESSAGE');
     } else {
         if ($event->getMemberStatus($my->id) == COMMUNITY_EVENT_STATUS_WONTATTEND) {
             $RSVPmessage = JText::_('COM_COMMUNITY_EVENTS_NOT_ATTENDING_EVENT_MESSAGE');
         } else {
             $RSVPmessage = JText::_('COM_COMMUNITY_EVENTS_NOT_RESPOND_RSVP_MESSAGE');
         }
     }
     // Get recurring event series
     $eventSeries = null;
     $seriesCount = 0;
     if ($event->isRecurring()) {
         $advance = array('expired' => false, 'return' => 'object', 'limit' => COMMUNITY_EVENT_SERIES_LIMIT, 'exclude' => $event->id, 'published' => 1);
         $tempseries = $eventModel->getEventChilds($event->parent, $advance);
         foreach ($tempseries as $series) {
             $table = JTable::getInstance('Event', 'CTable');
             $table->bind($series);
             $eventSeries[] = $table;
         }
         $seriesCount = $eventModel->getEventChildsCount($event->parent);
     }
     //pending request invitation guest
     $pendingRequestGuests = $event->getMembers(COMMUNITY_EVENT_STATUS_REQUESTINVITE, 0, false, false);
     // Pre-load multiple users at once
     $tempUserInfo = array();
     foreach ($pendingRequestGuests as $uid) {
         $tempUserInfo[] = CFactory::getUser($uid->id);
     }
     $pendingRequestGuests = $tempUserInfo;
     $featured = new CFeatured(FEATURED_EVENTS);
     $featuredList = $featured->getItemIds();
     // Get Attending Event Guests
     $maybeList = $event->getMembers(COMMUNITY_EVENT_STATUS_MAYBE, 12, CC_RANDOMIZE);
     $maybeCount = $event->getMembersCount(COMMUNITY_EVENT_STATUS_MAYBE);
     $tempUserInfo = array();
     foreach ($maybeList as $uid) {
         $tempUserInfo[] = CFactory::getUser($uid->id);
     }
     $maybeList = $tempUserInfo;
     $wontAttendList = $event->getMembers(COMMUNITY_EVENT_STATUS_WONTATTEND, 12, CC_RANDOMIZE);
     $wontAttendCount = $event->getMembersCount(COMMUNITY_EVENT_STATUS_WONTATTEND);
     $tempUserInfo = array();
     foreach ($wontAttendList as $uid) {
         $tempUserInfo[] = CFactory::getUser($uid->id);
     }
     $wontAttendList = $tempUserInfo;
     //gets all the albums related to this photo
     $photosModel = CFactory::getModel('photos');
     $albums = $photosModel->getEventAlbums($event->id);
     $totalPhotos = 0;
     foreach ($albums as $album) {
         $albumParams = new CParameter($album->params);
         $totalPhotos = $totalPhotos + $albumParams->get('count');
     }
     //get total videos
     $videosModel = CFactory::getModel('videos');
     $videos = $videosModel->getEventVideos($eventid);
     $totalVideos = count($videosModel->getEventVideos($eventid));
     // Output to template
     echo $tmpl->setMetaTags('event', $event)->set('status', $status)->set('albums', $albums)->set('videos', $videos)->set('pendingRequestGuests', $pendingRequestGuests)->set('streamHTML', $streamHTML)->set('timezone', CTimeHelper::getTimezone($event->offset))->set('handler', $handler)->set('isUserLiked', $isUserLiked)->set('totalLikes', $totalLikes)->set('inviteHTML', $inviteHTML)->set('guestStatus', $event->getUserStatus($my->id))->set('event', $event)->set('radioList', $radioList)->set('bookmarksHTML', $bookmarksHTML)->set('isLikeEnabled', $isLikeEnabled)->set('isEventGuest', $isEventGuest)->set('isMine', $isMine)->set('isAdmin', $isAdmin)->set('isCommunityAdmin', $isCommunityAdmin)->set('unapproved', $unapprovedCount)->set('waitingApproval', $waitingApproval)->set('wallContent', $wallContent)->set('eventMembers', $eventMembers)->set('eventMembersCount', $eventMembersCount)->set('editEvent', $editEvent)->set('my', $my)->set('creator', CFactory::getUser($event->creator))->set('memberStatus', $myStatus)->set('waitingRespond', $waitingRespond)->set('isInvited', $isInvited)->set('join', $join)->set('friendsCount', $friendsCount)->set('isPastEvent', $isPastEvent)->set('adminsList', $adminsList)->set('RSVPmessage', $RSVPmessage)->set('allday', $allday)->set('eventSeries', $eventSeries)->set('seriesCount', $seriesCount)->set('groupEventDetails', isset($groupEventDetails) ? $groupEventDetails : null)->set('featuredList', $featuredList)->set('photoPermission', $params->get('photopermission'))->set('videoPermission', $params->get('videopermission'))->set('showPhotos', $params->get('photopermission') != -1 && $config->get('enablephotos') && $config->get('eventphotos'))->set('showVideos', $params->get('videopermission') != -1 && $config->get('enablevideos') && $config->get('eventvideos'))->set('totalPhotos', $totalPhotos)->set('totalVideos', $totalVideos)->set('maybeList', $maybeList)->set('maybeCount', $maybeCount)->set('wontAttendList', $wontAttendList)->set('wontAttendCount', $wontAttendCount)->fetch('events/single');
 }