Пример #1
0
 static function getActivityContentHTML($act)
 {
     // Ok, the activity could be an upload OR a wall comment. In the future, the content should
     // indicate which is which
     $html = '';
     $param = new CParameter($act->params);
     $action = $param->get('action', false);
     $count = $param->get('count', false);
     $config = CFactory::getConfig();
     switch ($action) {
         case CAdminstreamsAction::TOP_USERS:
             $model = CFactory::getModel('user');
             $members = $model->getPopularMember($count);
             $html = '';
             //Get Template Page
             $tmpl = new CTemplate();
             $html = $tmpl->set('members', $members)->fetch('activity.members.popular');
             return $html;
             break;
         case CAdminstreamsAction::TOP_PHOTOS:
             $model = CFactory::getModel('photos');
             $photos = $model->getPopularPhotos($count, 0);
             $tmpl = new CTemplate();
             $html = $tmpl->set('photos', $photos)->fetch('activity.photos.popular');
             return $html;
             break;
         case CAdminstreamsAction::TOP_VIDEOS:
             $model = CFactory::getModel('videos');
             $videos = $model->getPopularVideos($count);
             $tmpl = new CTemplate();
             $html = $tmpl->set('videos', $videos)->fetch('activity.videos.popular');
             return $html;
             break;
     }
 }
Пример #2
0
 public function getFieldHTML($field, $required)
 {
     $html = '';
     $selectedElement = 0;
     $elementSelected = 0;
     $elementCnt = 0;
     $params = new CParameter($field->params);
     $readonly = $params->get('readonly') && !COwnerHelper::isCommunityAdmin() ? ' disabled="disabled"' : '';
     for ($i = 0; $i < count($field->options); $i++) {
         $option = $field->options[$i];
         $selected = $option == $field->value ? ' checked="checked"' : '';
         if (empty($selected)) {
             $elementSelected++;
         }
         $elementCnt++;
     }
     $cnt = 0;
     $html .= '<div style="display:inline-block" title="' . CStringHelper::escape(JText::_($field->tips)) . '">';
     for ($i = 0; $i < count($field->options); $i++) {
         $option = $field->options[$i];
         $selected = html_entity_decode($option) == html_entity_decode($field->value) ? ' checked="checked"' : '';
         $html .= '<label class="lblradio-block">';
         $html .= '<input type="radio" name="field' . $field->id . '" value="' . $option . '"' . $selected . $readonly . ' style="margin: 2px 5px 0 0" />';
         $html .= JText::_($option) . '</label>';
     }
     $html .= '</div>';
     return $html;
 }
Пример #3
0
 public function getFieldHTML($field, $required)
 {
     $html = '';
     $selectedElement = 0;
     $required = $field->required == 1 ? ' data-required="true"' : '';
     $style = ' style="margin: 0 5px 0 0;' . $this->getStyle() . '" ';
     $params = new CParameter($field->params);
     $disabled = '';
     if ($params->get('readonly') == 1) {
         $disabled = 'disabled="disabled"';
     }
     // Gender contain only male and female
     $options = array("" => "COM_COMMUNITY_SELECT_GENDER", "COM_COMMUNITY_MALE" => "COM_COMMUNITY_MALE", "COM_COMMUNITY_FEMALE" => "COM_COMMUNITY_FEMALE");
     $cnt = 0;
     //CFactory::load( 'helpers' , 'string' );
     // REMOVE 3.3
     // $class = !empty($field->tips) ? 'jomNameTips tipRight' : '';
     // REMOVE 3.3
     // $html .= '<div class="' . $class . '" style="display: inline-block;" title="' . CStringHelper::escape(JText::_($field->tips)) . '">';
     $html .= '<select class="joms-select" name="field' . $field->id . '" ' . $required . ' ' . $disabled . ' >';
     foreach ($options as $key => $val) {
         $selected = $key == $field->value ? ' selected="selected" ' : '';
         $html .= '<option value="' . $key . '" ' . $selected . '>' . JText::_($val) . '</option>';
     }
     $html .= '</select>';
     // REMOVE 3.3
     // $html .= '<span id="errfield' . $field->id . 'msg" style="display: none;">&nbsp;</span>';
     // $html .= '</div>';
     return $html;
 }
Пример #4
0
 public function ajaxTogglePublish($id, $type, $eventName = false)
 {
     // Send email notification to owner when a group is published.
     $config = CFactory::getConfig();
     $event = JTable::getInstance('Event', 'CTable');
     $event->load($id);
     // Added published = 2 for new created event under moderation.
     if ($type == 'published' && $event->published == 2) {
         $lang = JFactory::getLanguage();
         $lang->load('com_community', JPATH_ROOT);
         $my = CFactory::getUser();
         // Add notification
         //CFactory::load('libraries', 'notification');
         //CFactory::load('helpers', 'event');
         if ($event->type == CEventHelper::GROUP_TYPE && $event->contentid != 0) {
             $url = 'index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id . '&groupid=' . $event->contentid;
         } else {
             $url = 'index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id;
         }
         //Send notification email to owner
         $params = new CParameter('');
         $params->set('url', 'index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id);
         $params->set('event', $event->title);
         $params->set('event_url', 'index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id);
         CNotificationLibrary::add('events_notify_creator', $my->id, $event->creator, JText::_('COM_COMMUNITY_EVENTS_PUBLISHED_MAIL_SUBJECT'), '', 'events.notifycreator', $params);
         //CFactory::load('libraries', 'events');
         // Add activity stream for new created event.
         $event->published = 1;
         // by pass published checking.
         CEvents::addEventStream($event);
         // send notification email to group's member for new created event.
         CEvents::addGroupNotification($event);
     }
     return parent::ajaxTogglePublish($id, $type, 'events');
 }
Пример #5
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;
 }
Пример #6
0
 public function getMessage($field)
 {
     $params = new CParameter($field['params']);
     if ($params->get('min_char') && $params->get('max_char') && !$this->validLength($field['value'])) {
         return JText::sprintf('COM_COMMUNITY_FIELD_CONTAIN_OUT_OF_RANGE', $field['name'], $params->get('max_char'), $params->get('min_char'));
     }
     return JText::sprintf('COM_COMMUNITY_FIELD_CONTAIN_IMPROPER_VALUES', JText::_($field['name']));
 }
Пример #7
0
 public function getFieldHTML($field, $required)
 {
     $params = new CParameter($field->params);
     $readonly = $params->get('readonly') && !COwnerHelper::isCommunityAdmin() ? ' readonly=""' : '';
     $style = $this->getStyle() ? ' style="' . $this->getStyle() . '"' : '';
     $required = $field->required == 1 ? ' data-required="true"' : '';
     // If maximum is not set, we define it to a default
     $field->max = empty($field->max) ? 200 : $field->max;
     $html = '<input type="text" value="' . $field->value . '" id="field' . $field->id . '" name="field' . $field->id . '" maxlength="' . $field->max . '" class="joms-input" ' . $readonly . $required . $style . ' />';
     return $html;
 }
Пример #8
0
 public static function getConfiguration()
 {
     static $configuration = null;
     if (is_null($configuration)) {
         $plugin = JPluginHelper::getPlugin('community', 'twitter');
         $params = new CParameter($plugin->params);
         $my = CFactory::getUser();
         $oauth = JTable::getInstance('Oauth', 'CTable');
         $loaded = $oauth->load($my->id, 'twitter');
         $accesstoken = unserialize($oauth->accesstoken);
         $configuration = array('consumer_key' => $params->get('consumerKey', '0rSLnHLm1cpX1sTsqkQaQ'), 'consumer_secret' => $params->get('consumerSecret', 'nsCObKFeJFP9YYGOZoHAHAWfvjZIZ4Hv7M8Y1w1flQ'), 'user_token' => $accesstoken['user_token'], 'user_secret' => $accesstoken['user_secret'], 'curl_ssl_verifypeer' => false);
     }
     return $configuration;
 }
Пример #9
0
 public function onGroupJoin($group, $userId)
 {
     //@rule: Clear existing invites fromt he invitation table once the user joined the group
     $groupInvite = JTable::getInstance('GroupInvite', 'CTable');
     $keys = array('groupid' => $group->id, 'userid' => $userId);
     if ($groupInvite->load($keys)) {
         $groupInvite->delete();
     }
     $member = JTable::getInstance('GroupMembers', 'CTable');
     $keys = array('memberId' => $userId, 'groupId' => $group->id);
     $member->load($keys);
     $groupModel = CFactory::getModel('groups');
     $admins = $groupModel->getAdmins($group->id, null);
     $params = $group->getParams();
     //@rule: Send notification when necessary
     if ($params->get('joinrequestnotification') || $params->get('newmembernotification')) {
         $user = CFactory::getUser($userId);
         $subject = JText::sprintf('COM_COMMUNITY_GROUPS_EMAIL_NEW_MEMBER_JOINED_SUBJECT', '{user}', '{group}');
         if (!$member->approved) {
             $subject = JText::sprintf('COM_COMMUNITY_NEW_MEMBER_REQUESTED_TO_JOIN_GROUP_EMAIL_SUBJECT', '{user}', '{group}');
         }
         $params = new CParameter('');
         $params->set('url', 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id);
         $params->set('group', $group->name);
         $params->set('group_url', 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id);
         $params->set('user', $user->getDisplayName());
         $params->set('user_url', 'index.php?option=com_community&view=profile&userid=' . $user->id);
         $params->set('approved', $member->approved);
         foreach ($admins as $admin) {
             CNotificationLibrary::add('groups_member_join', $user->id, $admin->id, $subject, '', 'groups.memberjoin', $params);
         }
     }
 }
Пример #10
0
 public function ajaxEmailPage($uri, $emails, $message = '')
 {
     $filter = JFilterInput::getInstance();
     $uri = $filter->clean($uri, 'string');
     $emails = $filter->clean($emails, 'string');
     $message = $filter->clean($message, 'string');
     $message = stripslashes($message);
     $mainframe =& JFactory::getApplication();
     $bookmarks = CFactory::getBookmarks($uri);
     $mailqModel = CFactory::getModel('mailq');
     $config = CFactory::getConfig();
     $response = new JAXResponse();
     if (empty($emails)) {
         $content = '<div>' . JText::_('COM_COMMUNITY_SHARE_INVALID_EMAIL') . '</div>';
         $actions = '<input type="button" class="button" onclick="joms.bookmarks.show(\'' . $uri . '\');" value="' . JText::_('COM_COMMUNITY_GO_BACK_BUTTON') . '"/>';
     } else {
         $emails = explode(',', $emails);
         $errors = array();
         // Add notification
         CFactory::load('libraries', 'notification');
         foreach ($emails as $email) {
             $email = JString::trim($email);
             CFactory::load('helpers', 'validate');
             if (!empty($email) && CValidateHelper::email($email)) {
                 $params = new CParameter('');
                 $params->set('uri', $uri);
                 $params->set('message', $message);
                 CNotificationLibrary::add('etype_system_bookmarks_email', '', $email, JText::sprintf('COM_COMMUNITY_SHARE_EMAIL_SUBJECT', $config->get('sitename')), '', 'bookmarks', $params);
             } else {
                 // If there is errors with email, inform the user.
                 $errors[] = $email;
             }
         }
         if ($errors) {
             $content = '<div>' . JText::_('COM_COMMUNITY_EMAILS_ARE_INVALID') . '</div>';
             foreach ($errors as $error) {
                 $content .= '<div style="font-weight:700;color: red;">' . $error . '</span>';
             }
             $actions = '<input type="button" class="button" onclick="joms.bookmarks.show(\'' . $uri . '\');" value="' . JText::_('COM_COMMUNITY_GO_BACK_BUTTON') . '"/>';
         } else {
             $content = '<div>' . JText::_('COM_COMMUNITY_EMAIL_SENT_TO_RECIPIENTS') . '</div>';
             $actions = '<input type="button" class="button" onclick="cWindowHide();" value="' . JText::_('COM_COMMUNITY_DONE_BUTTON') . '"/>';
         }
     }
     $response->addAssign('cwin_logo', 'innerHTML', JText::_('COM_COMMUNITY_SHARE_THIS'));
     $response->addScriptCall('cWindowAddContent', $content, $actions);
     return $response->sendResponse();
 }
Пример #11
0
 public function isValid($value, $required)
 {
     if ($required && empty($value) || !isset($this->fieldId)) {
         return false;
     }
     $db =& JFactory::getDBO();
     $query = 'SELECT * FROM ' . $db->nameQuote('#__community_fields') . ' WHERE ' . $db->nameQuote('id') . '=' . $db->quote($this->fieldId);
     $db->setQuery($query);
     $field = $db->loadAssoc();
     $params = new CParameter($field['params']);
     $max_range = $params->get('maxrange');
     $min_range = $params->get('minrange');
     $value = JFactory::getDate(strtotime($value))->toUnix();
     $max_ok = true;
     $min_ok = true;
     //$ret = true;
     if ($max_range) {
         $max_range = JFactory::getDate(strtotime($max_range))->toUnix();
         $max_ok = $value < $max_range;
     }
     if ($min_range) {
         $min_range = JFactory::getDate(strtotime($min_range))->toUnix();
         $min_ok = $value > $min_range;
     }
     return $max_ok && $min_ok ? true : false;
     //return $ret;
 }
Пример #12
0
 public static function sendCommentNotification(CTableWall $wall, $message)
 {
     CFactory::load('libraries', 'notification');
     $my = CFactory::getUser();
     $targetUser = CFactory::getUser($wall->post_by);
     $url = 'index.php?option=com_community&view=profile&userid=' . $wall->contentid;
     $userParams = $targetUser->getParams();
     $params = new CParameter('');
     $params->set('url', $url);
     $params->set('message', $message);
     if ($my->id != $targetUser->id && $userParams->get('notifyWallComment')) {
         CNotificationLibrary::add('etype_profile_submit_wall_comment', $my->id, $targetUser->id, JText::sprintf('PLG_WALLS_WALL_COMMENT_EMAIL_SUBJECT', $my->getDisplayName()), '', 'profile.wallcomment', $params);
         return true;
     }
     return false;
 }
Пример #13
0
 public function getFieldHTML($field, $required)
 {
     $lists = array();
     //a fix for wrong data input
     $field->value = JString::trim($field->value);
     if (is_array($field->value)) {
         $tmplist = $field->value;
     } else {
         if (JString::strrpos($field->value, ',') == JString::strlen($field->value) - 1) {
             $field->value = JString::substr($field->value, 0, -1);
         }
         $tmplist = explode(',', $field->value);
     }
     if ($tmplist) {
         foreach ($tmplist as $value) {
             $lists[] = JString::trim($value);
         }
     }
     $html = '';
     $elementSelected = 0;
     $elementCnt = 0;
     $cnt = 0;
     $params = new CParameter($field->params);
     $readonly = '';
     if ($params->get('readonly') == 1) {
         $readonly = ' disabled="disabled"';
     }
     $html .= '<div style="display:inline-block">';
     if (is_array($field->options)) {
         foreach ($field->options as $option) {
             if (JString::trim($option) == '') {
                 //do not display blank options
                 continue;
             }
             $selected = in_array(JString::trim($option), $lists) ? ' checked="checked"' : '';
             if (empty($selected)) {
                 $elementSelected++;
             }
             $html .= '<label class="lblradio-block">';
             $html .= '<input type="checkbox" name="field' . $field->id . '[]" value="' . $option . '" class="joms-checkbox" ' . $selected . $readonly . ' style="margin: 2px 5px 0 0" />';
             $html .= JText::_($option) . '</label>';
             $elementCnt++;
         }
     }
     $html .= '</div>';
     return $html;
 }
Пример #14
0
 public function ajaxEmailPage($uri, $emails, $message = '')
 {
     $filter = JFilterInput::getInstance();
     $uri = $filter->clean($uri, 'string');
     $emails = $filter->clean($emails, 'string');
     $message = $filter->clean($message, 'string');
     $message = stripslashes($message);
     $mainframe = JFactory::getApplication();
     $bookmarks = CFactory::getBookmarks($uri);
     $mailqModel = CFactory::getModel('mailq');
     $config = CFactory::getConfig();
     $response = new JAXResponse();
     $json = array();
     if (empty($emails)) {
         $json['error'] = JText::_('COM_COMMUNITY_SHARE_INVALID_EMAIL');
     } else {
         $emails = explode(',', $emails);
         $errors = array();
         // Add notification
         //CFactory::load( 'libraries' , 'notification' );
         foreach ($emails as $email) {
             $email = JString::trim($email);
             if (!empty($email) && CValidateHelper::email($email)) {
                 $params = new CParameter('');
                 $params->set('uri', $uri);
                 $params->set('message', $message);
                 CNotificationLibrary::add('system_bookmarks_email', '', $email, JText::sprintf('COM_COMMUNITY_SHARE_EMAIL_SUBJECT', $config->get('sitename')), '', 'bookmarks', $params);
             } else {
                 // If there is errors with email, inform the user.
                 $errors[] = $email;
             }
         }
         if ($errors) {
             $content = '<div>' . JText::_('COM_COMMUNITY_EMAILS_ARE_INVALID') . '</div>';
             foreach ($errors as $error) {
                 $content .= '<div style="font-weight:bold; color:red;">' . $error . '</div>';
             }
             $json['error'] = $content;
         } else {
             $content = JText::_('COM_COMMUNITY_EMAIL_SENT_TO_RECIPIENTS');
             $json['message'] = $content;
         }
     }
     die(json_encode($json));
 }
Пример #15
0
 public function getFieldHTML($field, $required)
 {
     $params = new CParameter($field->params);
     $readonly = $params->get('readonly') ? ' readonly=""' : '';
     $style = $this->getStyle() ? '' : ' style="' . $this->getStyle() . '" ';
     // If maximum is not set, we define it to a default
     $field->max = empty($field->max) ? 200 : $field->max;
     CFactory::load('helpers', 'string');
     $class = $field->required == 1 ? ' required' : '';
     $class .= !empty($field->tips) ? ' jomNameTips tipRight' : '';
     $tooltipcss = "";
     if (!empty($field->tips)) {
         $tooltipcss = "jomNameTips";
     }
     $html = '<input title="' . CStringHelper::escape(JText::_($field->tips)) . '" type="text" value="' . $field->value . '" id="field' . $field->id . '" name="field' . $field->id . '" maxlength="' . $field->max . '" size="40" class="' . $tooltipcss . ' tipRight inputbox' . $class . '" ' . $style . $readonly . ' />';
     $html .= '<span id="errfield' . $field->id . 'msg" style="display:none;">&nbsp;</span>';
     return $html;
 }
Пример #16
0
    public function getFieldHTML($field, $required)
    {
        // If maximum is not set, we define it to a default
        $field->max = empty($field->max) ? 200 : $field->max;
        //get the value in param
        $params = new CParameter($field->params);
        $style = $this->getStyle() ? '' : ' style="' . $this->getStyle() . '" ';
        $class = $field->required == 1 ? ' required' : '';
        $class .= $params->get('min_char') != '' && $params->get('max_char') != '' ? ' minmax_' . $params->get('min_char') . '_' . $params->get('max_char') : '';
        $class .= !empty($field->tips) ? ' jomNameTips tipRight' : '';
        CFactory::load('helpers', 'string');
        ob_start();
        ?>
	<input class="inputbox validate-profile-email<?php 
        echo $class;
        ?>
" title="<?php 
        echo CStringHelper::escape(JText::_($field->tips));
        ?>
" type="text" value="<?php 
        echo $field->value;
        ?>
" id="field<?php 
        echo $field->id;
        ?>
" name="field<?php 
        echo $field->id;
        ?>
" maxlength="<?php 
        echo $field->max;
        ?>
" size="40" <?php 
        echo $style;
        ?>
	 />
	<span id="errfield<?php 
        echo $field->id;
        ?>
msg" style="display:none;">&nbsp;</span>
<?php 
        $html = ob_get_contents();
        ob_end_clean();
        return $html;
    }
Пример #17
0
 public function getFieldHTML($field, $required)
 {
     $params = new CParameter($field->params);
     $readonly = $params->get('readonly') ? ' readonly=""' : '';
     $style = $this->getStyle() ? '' : ' style="' . $this->getStyle() . '" ';
     $config = CFactory::getConfig();
     $js = 'assets/validate-1.5';
     $js .= $config->getBool('usepackedjavascript') ? '.pack.js' : '.js';
     CAssets::attach($js, 'js');
     // If maximum is not set, we define it to a default
     $field->max = empty($field->max) ? 200 : $field->max;
     $class = $field->required == 1 ? ' required' : '';
     $class .= !empty($field->tips) ? ' jomNameTips tipRight' : '';
     CFactory::load('helpers', 'string');
     $html = '<textarea id="field' . $field->id . '" name="field' . $field->id . '" class="inputbox textarea' . $class . '" title="' . CStringHelper::escape(JText::_($field->tips)) . '"' . $style . $readonly . '>' . $field->value . '</textarea>';
     $html .= '<span id="errfield' . $field->id . 'msg" style="display:none;">&nbsp;</span>';
     $html .= '<script type="text/javascript">cvalidate.setMaxLength("#field' . $field->id . '", "' . $field->max . '");</script>';
     return $html;
 }
Пример #18
0
 public function ajaxTogglePublish($id, $type)
 {
     // Send email notification to owner when a group is published.
     $config =& CFactory::getConfig();
     $group =& JTable::getInstance('Group', 'CTable');
     $group->load($id);
     if ($type == 'published' && $group->published == 0 && $config->get('moderategroupcreation')) {
         $lang =& JFactory::getLanguage();
         $lang->load('com_community', JPATH_ROOT);
         $my =& CFactory::getUser();
         // Add notification
         CFactory::load('libraries', 'notification');
         //Send notification email to owner
         $params = new CParameter('');
         $params->set('url', 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id);
         $params->set('groupName', $group->name);
         CNotificationLibrary::add('etype_groups_notify_creator', $my->id, $group->ownerid, JText::sprintf('COM_COMMUNITY_GROUPS_PUBLISHED_MAIL_SUBJECT', $group->name), '', 'groups.notifycreator', $params);
     }
     return parent::ajaxTogglePublish($id, $type, 'groups');
 }
Пример #19
0
 public function getFieldData($field)
 {
     $value = $field['value'];
     if (empty($value)) {
         return $value;
     }
     $params = new CParameter($field['params']);
     $format = $params->get('display');
     if (!class_exists('CFactory')) {
         require_once JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'core.php';
     }
     $ret = '';
     if ($format == 'age') {
         // PHP version > 5.2
         $datetime = new DateTime($value);
         $now = new DateTime('now');
         // PHP version > 5.3
         if (method_exists($datetime, 'diff')) {
             $interval = $datetime->diff($now);
             $ret = $interval->format('%Y');
         } else {
             $mth = $now->format('m') - $datetime->format('m');
             $day = $now->format('d') - $datetime->format('d');
             $ret = $now->format('Y') - $datetime->format('Y');
             if ($mth >= 0) {
                 if ($day < 0 && $mth == 0) {
                     $ret--;
                 }
             } else {
                 $ret--;
             }
         }
     } else {
         require_once JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'models' . DS . 'profile.php';
         $model = CFactory::getModel('profile');
         //overwrite Profile date format in Configuration
         $format = $params->get('date_format');
         $ret = $model->formatDate($value, $format);
     }
     return $ret;
 }
Пример #20
0
 public function onEventCreate($event)
 {
     $config = CFactory::getConfig();
     // Send an email notification to the site admin's when there is a new group created
     if ($config->get('event_moderation')) {
         $userModel = CFactory::getModel('User');
         $my = CFactory::getUser();
         $admins = $userModel->getSuperAdmins();
         // Add notification
         CFactory::load('libraries', 'notification');
         //Send notification email to administrators
         foreach ($admins as $row) {
             if ($row->sendEmail) {
                 $params = new CParameter('');
                 $params->set('url', JURI::root() . 'administrator/index.php?option=com_community&view=events');
                 $params->set('title', $event->title);
                 CNotificationLibrary::add('etype_events_notify_admin', $my->id, $row->id, JText::sprintf('COM_COMMUNITY_EVENTS_MODERATION_NOTICE', $event->title), '', 'events.notifyadmin', $params);
             }
         }
     }
 }
Пример #21
0
 public function request($target, $friends = array())
 {
     // remove duplicate id
     $friends = array_unique($friends);
     $model = CFactory::getModel('friends');
     $targetUser = CFactory::getUser($target);
     $my = JFactory::getUser();
     $params = new CParameter('');
     $params->set('url', 'index.php?option=com_community&view=profile&userid=' . $targetUser->id);
     if ($target == 0 || empty($friends)) {
         return false;
     }
     foreach ($friends as $friendId) {
         $connection = count($model->getFriendConnection($target, $friendId));
         // If stanger id is not in connection and stranger id in not myId, do add
         if ($connection == 0 && $friendId != $my->id) {
             $model->addFriend($friendId, $target);
             CNotificationLibrary::add('friends_request_connection', $targetUser->id, $friendId, JText::sprintf('COM_COMMUNITY_FRIEND_ADD_REQUEST', $targetUser->getDisplayName()), '', 'friends/request-sent', $params);
         }
     }
     return true;
 }
Пример #22
0
 public function getFieldHTML($field, $required)
 {
     $params = new CParameter($field->params);
     $readonly = $params->get('readonly') && !COwnerHelper::isCommunityAdmin() ? ' readonly=""' : '';
     // REMOVE 3.3
     // $style = $this->getStyle() ? ' style="' . $this->getStyle() . '" ' : '';
     //extract the max char since the settings is in params
     $max_char = $params->get('max_char');
     $config = CFactory::getConfig();
     // $js = 'assets/validate-1.5.min.js';
     // CFactory::attach($js, 'js');
     // If maximum is not set, we define it to a default
     $required = $field->required == 1 ? ' data-required="true"' : '';
     // REMOVE 3.3
     // $class .=!empty($field->tips) ? ' jomNameTips tipRight' : '';
     $html = '<textarea id="field' . $field->id . '" name="field' . $field->id . '" class="joms-textarea" ' . $readonly . $required . ' >' . $field->value . '</textarea>';
     // REMOVE 3.3
     // $html .= '<span id="errfield' . $field->id . 'msg" style="display:none;">&nbsp;</span>';
     if (!empty($max_char)) {
         $html .= '<script type="text/javascript">cvalidate.setMaxLength("#field' . $field->id . '", "' . $max_char . '");</script>';
     }
     return $html;
 }
Пример #23
0
 public static function getActivityContentHTML($act)
 {
     // Ok, the activity could be an upload OR a wall comment. In the future, the content should
     // indicate which is which
     $html = '';
     $param = new CParameter($act->params);
     $action = $param->get('action', false);
     CFactory::load('models', 'events');
     if ($action == 'events.create') {
         return CEvents::getEventSummary($act->cid, $param);
     } else {
         if ($action == 'event.join' || $action == 'event.attendence.attend') {
             return CEvents::getEventSummary($act->cid, $param);
         } else {
             if ($action == 'event.wall.create' || $action == 'events.wall.create') {
                 CFactory::load('libraries', 'wall');
                 $wallid = $param->get('wallid', 0);
                 $html = CWallLibrary::getWallContentSummary($wallid);
                 return $html;
             }
         }
     }
     return $html;
 }
Пример #24
0
 public static function getActivityContentHTML($act)
 {
     // Ok, the activity could be an upload OR a wall comment. In the future, the content should
     // indicate which is which
     CFactory::load('models', 'photos');
     $html = '';
     $param = new CParameter($act->params);
     $action = $param->get('action', false);
     $photoid = $param->get('photoid', 0);
     $url = $param->get('url', false);
     CFactory::load('helpers', 'albums');
     if ($action == 'wall') {
         // unfortunately, wall post can also have 'photo' as its $act->apps. If the photo id is availble
         // for (newer activity stream, inside the param), we will show the photo snippet as well. Otherwise
         // just print out the wall content
         // Version 1.6 onwards, $params will contain photoid information
         // older version would have #photoid in the $title, since we link it to the photo
         $photoid = $param->get('photoid', false);
         if ($photoid) {
             $photo = JTable::getInstance('Photo', 'CTable');
             $photo->load($act->cid);
             $helper = new CAlbumsHelper($photo->albumid);
             if ($helper->showActivity()) {
                 $tmpl = new CTemplate();
                 return $tmpl->set('url', $url)->set('photo', $photo)->set('param', $param)->set('act', $act)->fetch('activity.photos.wall');
             }
         }
         return '';
     } elseif ($action == 'upload' && $photoid > 0) {
         $photoModel = CFactory::getModel('photos');
         $album = JTable::getInstance('Album', 'CTable');
         $album->load($act->cid);
         $albumsHelper = new CAlbumsHelper($album);
         if ($albumsHelper->isPublic()) {
             // If content has link to image, we could assume it is "upload photo" action
             // since old content add this automatically.
             // The $act->cid will be the album id, Retrive the recent photos uploaded
             // If $act->activities has data, that means this is an aggregated content
             // display some of them
             if (empty($act->activities)) {
                 $acts[] = $act;
             } else {
                 $acts = $act->activities;
             }
             $tmpl = new CTemplate();
             return $tmpl->set('album', $album)->set('acts', $acts)->set('stream', $param->get('stream', false))->fetch('activity.photos.upload');
         }
     }
     return $html;
 }
Пример #25
0
 public function onEventCreate($event)
 {
     $config = CFactory::getConfig();
     // Send an email notification to the site admin's when there is a new group created
     if ($config->get('event_moderation')) {
         $userModel = CFactory::getModel('User');
         $my = CFactory::getUser();
         $admins = $userModel->getSuperAdmins();
         //Send notification email to administrators
         foreach ($admins as $row) {
             if ($event->type == CEventHelper::GROUP_TYPE && $event->contentid != 0) {
                 $event_url = 'index.php?option=com_community&view=events&task=viewevent&groupid=' . $event->contentid . '&eventid=' . $event->id;
             } else {
                 $event_url = 'index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id;
             }
             $params = new CParameter('');
             $params->set('url', JURI::root() . 'administrator/index.php?option=com_community&view=events');
             $params->set('title', $event->title);
             $params->set('event', $event->title);
             $params->set('event_url', JURI::root() . 'administrator/index.php?option=com_community&view=events');
             CNotificationLibrary::add('events_notify_admin', $my->id, $row->id, JText::sprintf('COM_COMMUNITY_EVENT_CREATION_MODERATION_EMAIL_SUBJECT'), '', 'events.notifyadmin', $params);
         }
     }
 }
Пример #26
0
 public function _getAllAlbumsHTML($albums, $type = PHOTOS_USER_TYPE, $pagination = NULL, $isMyOwnPhoto = false)
 {
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $task = $jinput->getCmd('task');
     $my = CFactory::getUser();
     $config = CFactory::getConfig();
     $groupId = JRequest::getInt('groupid', '', 'REQUEST');
     $handler = $this->_getHandler();
     $tmpl = new CTemplate();
     // Use for redirect after editAlbum
     $displaygrp = $groupId == 0 ? 'display' : 'displaygrp';
     $photoModel = CFactory::getModel('Photos');
     for ($i = 0; $i < count($albums); $i++) {
         $albums[$i]->count = count($photoModel->getPhotos($albums[$i]->id, 1000, 0));
         //change the album name according to the latest name of profile, event or groups avatars
         // act as trigger, have to move this somewhere later. //change album name
         switch ($albums[$i]->type) {
             case 'group.avatar':
                 $table = JTable::getInstance('Group', 'CTable');
                 $table->load($albums[$i]->groupid);
                 $tmpName = JText::sprintf('COM_COMMUNITY_GROUP_AVATAR_NAME', ucfirst($table->name));
                 if ($albums[$i]->name != $tmpName) {
                     $photoModel->updateAlbumName($albums[$i]->id, $tmpName);
                     $albums[$i]->name = $tmpName;
                 }
                 break;
             case 'event.avatar':
                 $table = JTable::getInstance('Event', 'CTable');
                 $table->load($albums[$i]->eventid);
                 $tmpName = JText::sprintf('COM_COMMUNITY_EVENT_AVATAR_NAME', ucfirst($table->title));
                 if ($albums[$i]->name != $tmpName) {
                     $photoModel->updateAlbumName($albums[$i]->id, $tmpName);
                     $albums[$i]->name = $tmpName;
                 }
                 break;
             case 'profile.avatar':
                 $creator = CFactory::getUser($albums[$i]->creator);
                 $tmpName = JText::sprintf('COM_COMMUNITY_PROFILE_AVATAR_NAME', ucfirst($creator->getDisplayName()));
                 if ($albums[$i]->name != $tmpName) {
                     $photoModel->updateAlbumName($albums[$i]->id, $tmpName);
                     $albums[$i]->name = $tmpName;
                 }
                 break;
             case 'user':
                 //default album only
                 if ($albums[$i]->default == 1) {
                     $creator = CFactory::getUser($albums[$i]->creator);
                     $tmpName = JText::sprintf('COM_COMMUNITY_DEFAULT_ALBUM_CAPTION', ucfirst($creator->getDisplayName()));
                     if ($albums[$i]->name != $tmpName) {
                         $photoModel->updateAlbumName($albums[$i]->id, $tmpName);
                         $albums[$i]->name = $tmpName;
                     }
                 }
                 break;
             case 'profile.Cover':
                 $creator = CFactory::getUser($albums[$i]->creator);
                 $tmpName = JText::sprintf('COM_COMMUNITY_PROFILE_COVER_NAME', ucfirst($creator->getDisplayName()));
                 if ($albums[$i]->name != $tmpName) {
                     $photoModel->updateAlbumName($albums[$i]->id, $tmpName);
                     $albums[$i]->name = $tmpName;
                 }
                 break;
             case 'event.Cover':
                 $table = JTable::getInstance('Event', 'CTable');
                 $table->load($albums[$i]->eventid);
                 $tmpName = JText::sprintf('COM_COMMUNITY_EVENT_COVER_NAME', ucfirst($table->title));
                 if ($albums[$i]->name != $tmpName) {
                     $photoModel->updateAlbumName($albums[$i]->id, $tmpName);
                     $albums[$i]->name = $tmpName;
                 }
                 break;
             case 'group.Cover':
                 $table = JTable::getInstance('Group', 'CTable');
                 $table->load($albums[$i]->groupid);
                 $tmpName = JText::sprintf('COM_COMMUNITY_GROUP_COVER_NAME', ucfirst($table->name));
                 if ($albums[$i]->name != $tmpName) {
                     $photoModel->updateAlbumName($albums[$i]->id, $tmpName);
                     $albums[$i]->name = $tmpName;
                 }
                 break;
             case 'group':
                 //group default photo
                 if ($albums[$i]->default == 1) {
                     $table = JTable::getInstance('Group', 'CTable');
                     $table->load($albums[$i]->groupid);
                     $tmpName = JText::sprintf('COM_COMMUNITY_GROUP_DEFAULT_ALBUM_NAME', ucfirst($table->name));
                     if ($albums[$i]->name != $tmpName) {
                         $photoModel->updateAlbumName($albums[$i]->id, $tmpName);
                         $albums[$i]->name = $tmpName;
                     }
                 }
         }
         $albums[$i]->user = CFactory::getUser($albums[$i]->creator);
         $albums[$i]->link = CRoute::_("index.php?option=com_community&view=photos&task=album&albumid={$albums[$i]->id}");
         $albums[$i]->editLink = CRoute::_("index.php?option=com_community&view=photos&task=editAlbum&albumid={$albums[$i]->id}&userid={$albums[$i]->creator}&referrer=myphotos");
         $albums[$i]->uploadLink = "javascript:joms.notifications.showUploadPhoto({$albums[$i]->id});";
         //CRoute::_("index.php?option=com_community&view=photos&task=uploader&albumid={$albums[$i]->id}&userid={$albums[$i]->creator}");
         $albums[$i]->isOwner = $my->id == $albums[$i]->creator;
         $albums[$i]->totalComments = CWallLibrary::getWallCount('albums', $albums[$i]->id);
         //$albums[$i]->totalPhotos = $photosModel->getTotalPhotos($albums[$i]->id);
         if ($type == PHOTOS_GROUP_TYPE) {
             $albums[$i]->link = CRoute::_("index.php?option=com_community&view=photos&task=album&albumid={$albums[$i]->id}&groupid={$albums[$i]->groupid}");
             $albums[$i]->editLink = CRoute::_("index.php?option=com_community&view=photos&task=editAlbum&albumid={$albums[$i]->id}&groupid={$albums[$i]->groupid}&referrer={$displaygrp}");
             $albums[$i]->uploadLink = "javascript:joms.notifications.showUploadPhoto({$albums[$i]->id},{$albums[$i]->groupid});";
             //CRoute::_("index.php?option=com_community&view=photos&task=uploader&albumid={$albums[$i]->id}&groupid={$albums[$i]->groupid}");
             $albums[$i]->isOwner = $my->authorise('community.view', 'photos.group.album.' . $groupId, $albums[$i]);
         }
         // If new albums that has just been created and
         // does not contain any images, the lastupdated will always be 0000-00-00 00:00:00:00
         // Try to use the albums creation date instead.
         if ($albums[$i]->lastupdated == '0000-00-00 00:00:00' || $albums[$i]->lastupdated == '') {
             $albums[$i]->lastupdated = $albums[$i]->created;
             if ($albums[$i]->lastupdated == '' || $albums[$i]->lastupdated == '0000-00-00 00:00:00') {
                 $albums[$i]->lastupdated = JText::_('COM_COMMUNITY_PHOTOS_NO_ACTIVITY');
             } else {
                 $lastUpdated = new JDate($albums[$i]->lastupdated);
                 $albums[$i]->lastupdated = CActivityStream::_createdLapse($lastUpdated, false);
             }
         } else {
             $params = new CParameter($albums[$i]->params);
             $lastUpdated = new JDate($params->get('lastupdated'));
             $albums[$i]->lastupdated = CActivityStream::_createdLapse($lastUpdated, false);
         }
     }
     $featured = new CFeatured(FEATURED_ALBUMS);
     $featuredList = $featured->getItemIds();
     $createLink = $handler->getAlbumCreateLink();
     if ($type == PHOTOS_GROUP_TYPE) {
         $isOwner = CGroupHelper::allowManagePhoto($groupId);
         $baselink = "index.php?option=com_community&view=photos&task=display&groupid=" . $groupId;
         $groupModel = CFactory::getModel('groups');
         $group = JTable::getInstance('Group', 'CTable');
         $group->load($groupId);
         $params = $group->getParams();
         $photopermission = $params->get('photopermission') == GROUP_PHOTO_PERMISSION_ADMINS || $params->get('photopermission') == GROUP_PHOTO_PERMISSION_ALL ? 1 : 0;
         $isMember = $groupModel->isMember($my->id, $group->id);
         $isAdmin = $groupModel->isAdmin($my->id, $group->id);
         $tmpl->set('photoPermission', $photopermission)->set('isMember', $isMember)->set('isAdmin', $isAdmin);
     } else {
         $userId = JRequest::getInt('userid', '', 'REQUEST');
         $user = CFactory::getUser($userId);
         if ($task) {
             $baselink = "index.php?option=com_community&view=photos&task=" . $task;
         } else {
             $baselink = "index.php?option=com_community&view=photos";
         }
         $isOwner = $my->id == $userId ? true : false;
     }
     $sortBy = JRequest::getString('sort', 'date');
     $task = JRequest::getCmd('task', '');
     return $tmpl->set('isMember', $my->id != 0)->set('isMyOwnPhoto', $isMyOwnPhoto)->set('sortBy', $sortBy)->set('baseLink', $baselink)->set('config', $config)->set('isOwner', $isOwner)->set('type', $type)->set('createLink', $createLink)->set('currentTask', $task)->set('showFeatured', $config->get('show_featured'))->set('featuredList', $featuredList)->set('isCommunityAdmin', COwnerHelper::isCommunityAdmin())->set('my', $my)->set('albums', $albums)->set('pagination', $pagination)->set('isSuperAdmin', COwnerHelper::isCommunityAdmin())->set('groupId', $groupId)->set('submenu', $this->showSubmenu(false))->fetch('album/list');
 }
Пример #27
0
 public function notificationApproval($group)
 {
     $lang = JFactory::getLanguage();
     $lang->load('com_community', JPATH_ROOT);
     $my = CFactory::getUser();
     // Add notification
     //Send notification email to owner
     $params = new CParameter('');
     $params->set('url', 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id);
     $params->set('groupName', $group->name);
     $params->set('group', $group->name);
     $params->set('group_url', 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id);
     CNotificationLibrary::add('groups_notify_creator', $my->id, $group->ownerid, JText::_('COM_COMMUNITY_GROUPS_PUBLISHED_MAIL_SUBJECT'), '', 'groups.notifycreator', $params);
 }
Пример #28
0
    $params = $group->getParams();
    $eventsModel = CFactory::getModel('Events');
    $totalEvents = $eventsModel->getTotalGroupEvents($group->id);
    $showEvents = $config->get('group_events') && $config->get('enableevents') && $params->get('eventpermission', 1) >= 1;
    $videoModel = CFactory::getModel('videos');
    $showVideo = $params->get('videopermission') != -1 && $config->get('enablevideos') && $config->get('groupvideos');
    if ($showVideo) {
        $videoModel->getGroupVideos($group->id, '', $params->get('grouprecentvideos', GROUP_VIDEO_RECENT_LIMIT));
        $totalVideos = $videoModel->total ? $videoModel->total : 0;
    }
    $showPhoto = $params->get('photopermission') != -1 && $config->get('enablephotos') && $config->get('groupphotos');
    $photosModel = CFactory::getModel('photos');
    $albums = $photosModel->getGroupAlbums($group->id, true, false, $params->get('grouprecentphotos', GROUP_PHOTO_RECENT_LIMIT));
    $totalPhotos = 0;
    foreach ($albums as $album) {
        $albumParams = new CParameter($album->params);
        $totalPhotos = $totalPhotos + $albumParams->get('count');
    }
    $bulletinModel = CFactory::getModel('bulletins');
    $bulletins = $bulletinModel->getBulletins($group->id);
    $totalBulletin = $bulletinModel->total;
    // Check if "Invite friends" and "Settings" buttons should be added or not.
    $canInvite = false;
    $canEdit = false;
    if ($isMember && !$isBanned || $isCommunityAdmin) {
        $canInvite = true;
        if ($isMine || $isAdmin || $isCommunityAdmin) {
            $canEdit = true;
        }
    }
}
Пример #29
0
 public static function _getWallHTML($wall, $wallComments, $appType, $isOwner, $processFunc, $templateFile, $banned = 0)
 {
     $my = CFactory::getUser();
     $user = CFactory::getUser($wall->post_by);
     $date = CTimeHelper::getDate($wall->date);
     $config = CFactory::getConfig();
     // @rule: for site super administrators we want to allow them to view the remove link
     $isOwner = COwnerHelper::isCommunityAdmin() ? true : $isOwner;
     $isEditable = CWall::isEditable($processFunc, $wall->id);
     $commentsHTML = '';
     $comment = new CComment();
     /*
      * @todo 3.3 revise what is this code about
      */
     // If the wall post is a user wall post (in profile pages), we
     // add wall comment feature
     if ($appType == 'user' || $appType == 'groups' || $appType == 'events') {
         if ($banned == 1) {
             $commentsHTML = $comment->getHTML($wallComments, 'wall-cmt-' . $wall->id, false);
         } else {
             $commentsHTML = $comment->getHTML($wallComments, 'wall-cmt-' . $wall->id, CWall::canComment($wall->type, $wall->contentid));
         }
     }
     $avatarHTML = CUserHelper::getThumb($wall->post_by, 'avatar');
     // Change '->created to lapse format if stream uses lapse format'
     if ($config->get('activitydateformat') == 'lapse') {
         $wall->created = CTimeHelper::timeLapse($date);
     } else {
         $wall->created = $date->Format(JText::_('DATE_FORMAT_LC2'), true);
     }
     $wallParam = new CParameter($wall->params);
     $photoThumbnail = '';
     $paramsHTML = '';
     $image = (array) $wallParam->get('image');
     if ($wallParam->get('attached_photo_id') > 0) {
         $photo = JTable::getInstance('Photo', 'CTable');
         $photo->load($wallParam->get('attached_photo_id'));
         $photoThumbnail = $photo->getThumbURI();
     } else {
         if ($wallParam->get('title')) {
             $video = self::detectVideo($wallParam->get('url'));
             if (is_object($video)) {
                 $paramsHTML .= '<div class="joms-media--video joms-js--video"';
                 $paramsHTML .= ' data-type="' . $video->type . '"';
                 $paramsHTML .= ' data-id="' . $video->id . '"';
                 $paramsHTML .= ' data-path="' . ($video->type === 'file' ? JURI::root(true) . '/' : '') . $video->path . '"';
                 $paramsHTML .= ' style="margin-top:10px;">';
                 $paramsHTML .= '<div class="joms-media__thumbnail">';
                 $paramsHTML .= '<img src="' . $video->getThumbnail() . '">';
                 $paramsHTML .= '<a href="javascript:" class="mejs-overlay mejs-layer mejs-overlay-play joms-js--video-play joms-js--video-play-' . $wall->id . '">';
                 $paramsHTML .= '<div class="mejs-overlay-button"></div>';
                 $paramsHTML .= '</a>';
                 $paramsHTML .= '</div>';
                 $paramsHTML .= '<div class="joms-media__body">';
                 $paramsHTML .= '<h4 class="joms-media__title">' . JHTML::_('string.truncate', $video->title, 50, true, false) . '</h4>';
                 $paramsHTML .= '<p class="joms-media__desc">' . JHTML::_('string.truncate', $video->description, $config->getInt('streamcontentlength'), true, false) . '</p>';
                 $paramsHTML .= '</div>';
                 $paramsHTML .= '</div>';
             } else {
                 $paramsHTML .= '<div class="joms-gap"></div>';
                 $paramsHTML .= '<div class="joms-media--album joms-js--comment-preview">';
                 if ($isOwner) {
                     $paramsHTML .= '<span data-action="remove-preview" class="joms-fetched-close" style="top:0;right:0;left:auto" onclick="joms.api.commentRemovePreview(\'' . $wall->id . '\');"><i class="joms-icon-remove"></i></span>';
                 }
                 if ($wallParam->get('image')) {
                     $paramsHTML .= '<div class="joms-media__thumbnail">';
                     $paramsHTML .= '<a href="' . $wallParam->get('link') ? $wallParam->get('link') : '#' . '">';
                     $paramsHTML .= '<img src="' . array_shift($image) . '" />';
                     $paramsHTML .= '</a>';
                     $paramsHTML .= '</div>';
                 }
                 $url = $wallParam->get('url') ? $wallParam->get('url') : '#';
                 $paramsHTML .= '<div class="joms-media__body">';
                 $paramsHTML .= '<h4 class="joms-media__title"><a href="' . $url . '">' . $wallParam->get('title') . '</a></h4>';
                 $paramsHTML .= '<p class="joms-media__desc">' . CStringHelper::trim_words($wallParam->get('description')) . '</p>';
                 if ($wallParam->get('link')) {
                     $paramsHTML .= '<cite>' . preg_replace('#^https?://#', '', $wallParam->get('link')) . '</cite>';
                 }
                 $paramsHTML .= '</div></div>';
             }
         }
     }
     $CComment = new CComment();
     $wall->originalComment = $wall->comment;
     $wall->comment = $CComment->stripCommentData($wall->comment);
     $CTemplate = new CTemplate();
     $wall->comment = CStringHelper::autoLink($wall->comment);
     $wall->comment = nl2br($wall->comment);
     $wall->comment = CUserHelper::replaceAliasURL($wall->comment);
     $wall->comment = CStringHelper::getEmoticon($wall->comment);
     $wall->comment = CStringHelper::converttagtolink($wall->comment);
     // convert to hashtag
     $canDelete = $my->authorise('community.delete', 'walls', $wall);
     $like = new CLike();
     $likeCount = $like->getLikeCount('comment', $wall->id);
     $isLiked = $like->userLiked('comment', $wall->id, $my->id) == COMMUNITY_LIKE;
     // Create new instance of the template
     $tmpl = new CTemplate();
     return $tmpl->set('id', $wall->id)->set('author', $user->getDisplayName())->set('avatarHTML', $avatarHTML)->set('authorLink', CUrlHelper::userLink($user->id))->set('created', $wall->created)->set('content', $wall->comment)->set('commentsHTML', $commentsHTML)->set('avatar', $user->getThumbAvatar())->set('isMine', $isOwner)->set('canDelete', $canDelete)->set('isEditable', $isEditable)->set('processFunc', $processFunc)->set('config', $config)->set('photoThumbnail', $photoThumbnail)->set('paramsHTML', $paramsHTML)->set('wall', $wall)->set('likeCount', $likeCount)->set('isLiked', $isLiked)->fetch($templateFile);
 }
Пример #30
0
 /**
  * A new message submitted via ajax
  */
 public function ajaxSend($postVars)
 {
     //$postVars pending filtering
     $objResponse = new JAXResponse();
     $config = CFactory::getConfig();
     $my = CFactory::getUser();
     if ($my->id == 0) {
         return $this->ajaxBlockUnregister();
     }
     //CFactory::load( 'helpers', 'time' );
     $inboxModel = $this->getModel('inbox');
     $lastSent = $inboxModel->getLastSentTime($my->id);
     $dateNow = new JDate();
     // We need to make sure that this guy are not spamming other people inbox
     // by checking against his last message time. Make sure it doesn't exceed
     // pmFloodLimit config (in seconds).
     if ($dateNow->toUnix() - $lastSent->toUnix() < $config->get('floodLimit') && !COwnerHelper::isCommunityAdmin()) {
         $json = array();
         $json['title'] = JText::_('COM_COMMUNITY_NOTICE');
         $json['error'] = JText::sprintf('COM_COMMUNITY_PLEASE_WAIT_BEFORE_SENDING_MESSAGE', $config->get('floodLimit'));
         die(json_encode($json));
     }
     // Prevent users to send message to themselves.
     if ($postVars['to'] == $my->id) {
         $json = array();
         $json['title'] = JText::_('COM_COMMUNITY_NOTICE');
         $json['error'] = JText::_('COM_COMMUNITY_INBOX_MESSAGE_CANNOT_SEND_TO_SELF');
         die(json_encode($json));
     }
     $postVars = CAjaxHelper::toArray($postVars);
     $doCont = true;
     $errMsg = "";
     $resizeH = 0;
     if ($this->_isSpam($my, $postVars['subject'] . ' ' . $postVars['body'])) {
         $json = array();
         $json['title'] = JText::_('COM_COMMUNITY_NOTICE');
         $json['error'] = JText::_('COM_COMMUNITY_INBOX_MESSAGE_MARKED_SPAM');
         die(json_encode($json));
     }
     if (empty($postVars['subject']) || JString::trim($postVars['subject']) == '') {
         $json = array();
         $json['title'] = JText::_('COM_COMMUNITY_INBOX_TITLE_WRITE');
         $json['error'] = JText::_('COM_COMMUNITY_INBOX_SUBJECT_MISSING');
         $json['samestep'] = true;
         die(json_encode($json));
     }
     if (empty($postVars['body']) || JString::trim($postVars['body']) == '') {
         $json = array();
         $json['title'] = JText::_('COM_COMMUNITY_INBOX_TITLE_WRITE');
         $json['error'] = JText::_('COM_COMMUNITY_INBOX_MESSAGE_MISSING');
         $json['samestep'] = true;
         die(json_encode($json));
     }
     $data = $postVars;
     $model = $this->getModel('inbox');
     $pattern = "/<br \\/>/i";
     $replacement = "\r\n";
     $data['body'] = preg_replace($pattern, $replacement, $data['body']);
     $data['photo'] = isset($data['photo']) ? $data['photo'] : '';
     $msgid = $model->send($data);
     // Add user points.
     CUserPoints::assignPoint('inbox.message.send');
     // Add notification.
     $params = new CParameter('');
     $params->set('url', 'index.php?option=com_community&view=inbox&task=read&msgid=' . $msgid);
     $params->set('message', $data['body']);
     $params->set('title', $data['subject']);
     $params->set('msg_url', 'index.php?option=com_community&view=inbox&task=read&msgid=' . $msgid);
     $params->set('msg', JText::_('COM_COMMUNITY_PRIVATE_MESSAGE'));
     CNotificationLibrary::add('inbox_create_message', $my->id, $data['to'], JText::sprintf('COM_COMMUNITY_SENT_YOU_MESSAGE'), '', 'inbox.sent', $params);
     // Send response.
     $json = array();
     $json['message'] = JText::_('COM_COMMUNITY_INBOX_MESSAGE_SENT');
     die(json_encode($json));
 }