예제 #1
0
 /**
  * Determines whether the current album is public or not
  *
  * @params
  * @return Boolean    True upon success
  **/
 public function isPublic()
 {
     $my = CFactory::getUser();
     if (COwnerHelper::isCommunityAdmin()) {
         return true;
     }
     switch ($this->album->permissions) {
         case self::PRIVACY_PRIVATE:
             return $my->id == $this->album->creator;
             break;
         case self::PRIVACY_FRIENDS:
             return CFriendsHelper::isConnected($my->id, $this->album->creator);
             break;
         case self::PRIVACY_MEMBERS:
             if ($my->id != 0) {
                 return true;
             }
             break;
         case self::PRIVACY_PUBLIC:
         case self::PRIVACY_PUBLIC_LEGACY:
             return true;
             break;
     }
     return false;
 }
예제 #2
0
파일: album.php 프로젝트: bizanto/Hooked
 /**
  *	Allows us to test if the user has access to the album
  **/
 function hasAccess($userId, $permissionType)
 {
     CFactory::load('helpers', 'owner');
     CFactory::load('helpers', 'group');
     // @rule: For super admin, regardless of what permission, they should be able to access
     if (COwnerHelper::isCommunityAdmin()) {
         return true;
     }
     switch ($this->type) {
         case PHOTOS_USER_TYPE:
             if ($permissionType == 'upload') {
                 return $this->creator == $userId;
             }
             if ($permissionType == 'deletephotos') {
                 return $this->creator == $userId;
             }
             break;
         case PHOTOS_GROUP_TYPE:
             CFactory::load('models', 'groups');
             $group =& JTable::getInstance('Group', 'CTable');
             $group->load($this->groupid);
             if ($permissionType == 'upload') {
                 return CGroupHelper::allowManagePhoto($group->id);
             }
             if ($permissionType == 'deletephotos') {
                 return $this->creator == $userId || $group->isAdmin($userId);
             }
             return false;
             break;
     }
 }
예제 #3
0
 public static function getAccessLevel($actorId, $targetId)
 {
     $actor = CFactory::getUser($actorId);
     $target = CFactory::getUser($targetId);
     CFactory::load('helpers', 'owner');
     CFactory::load('helpers', 'friends');
     // public guest
     $access = 0;
     // site members
     if ($actor->id > 0) {
         $access = 20;
     }
     // they are friends
     if ($target->id > 0 && CFriendsHelper::isConnected($actor->id, $target->id)) {
         $access = 30;
     }
     // mine, target and actor is the same person
     if ($target->id > 0 && COwnerHelper::isMine($actor->id, $target->id)) {
         $access = 40;
     }
     if (COwnerHelper::isCommunityAdmin()) {
         $access = 40;
     }
     return $access;
 }
예제 #4
0
 /**
  * Feature the given user
  *
  * @param  int $memberId userid to feature
  * @return [type]           [description]
  */
 public function ajaxAddFeatured($memberId)
 {
     $filter = JFilterInput::getInstance();
     $memberId = $filter->clean($memberId, 'int');
     $my = CFactory::getUser();
     if ($my->id == 0) {
         return $this->ajaxBlockUnregister();
     }
     if (COwnerHelper::isCommunityAdmin()) {
         $model = CFactory::getModel('Featured');
         if (!$model->isExists(FEATURED_USERS, $memberId)) {
             $featured = new CFeatured(FEATURED_USERS);
             $member = CFactory::getUser($memberId);
             $config = CFactory::getConfig();
             $limit = $config->get('featured' . FEATURED_USERS . 'limit', 10);
             if ($featured->add($memberId, $my->id) === true) {
                 $html = JText::sprintf('COM_COMMUNITY_MEMBER_IS_FEATURED', $member->getDisplayName());
             } else {
                 $html = JText::sprintf('COM_COMMUNITY_MEMBER_LIMIT_REACHED_FEATURED', $member->getDisplayName(), $limit);
             }
         } else {
             $html = JText::_('COM_COMMUNITY_USER_ALREADY_FEATURED');
         }
     } else {
         $html = JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_ACCESS_SECTION');
     }
     $this->cacheClean(array(COMMUNITY_CACHE_TAG_FEATURED));
     $json = array();
     $json['title'] = ' ';
     $json['html'] = $html;
     die(json_encode($json));
 }
예제 #5
0
 public function ajaxAddFeatured($memberId)
 {
     $filter = JFilterInput::getInstance();
     $memberId = $filter->clean($memberId, 'int');
     $objResponse = new JAXResponse();
     CFactory::load('helpers', 'owner');
     $my = CFactory::getUser();
     if ($my->id == 0) {
         return $this->ajaxBlockUnregister();
     }
     if (COwnerHelper::isCommunityAdmin()) {
         $model = CFactory::getModel('Featured');
         if (!$model->isExists(FEATURED_USERS, $memberId)) {
             CFactory::load('libraries', 'featured');
             $featured = new CFeatured(FEATURED_USERS);
             $member = CFactory::getUser($memberId);
             $featured->add($memberId, $my->id);
             $html = JText::sprintf('COM_COMMUNITY_MEMBER_IS_FEATURED', $member->getDisplayName());
         } else {
             $html = JText::_('COM_COMMUNITY_USER_ALREADY_FEATURED');
         }
     } else {
         $html = JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_ACCESS_SECTION');
     }
     $actions = '<input type="button" class="button" onclick="window.location.reload();" value="' . JText::_('COM_COMMUNITY_BUTTON_CLOSE_BUTTON') . '"/>';
     $objResponse->addScriptCall('cWindowAddContent', $html, $actions);
     $this->cacheClean(array(COMMUNITY_CACHE_TAG_FEATURED));
     return $objResponse->sendResponse();
 }
예제 #6
0
 /**
  * 	Allows us to test if the user has access to the album
  * */
 public function hasAccess($userId, $permissionType)
 {
     //CFactory::load( 'helpers' , 'owner' );
     // @rule: For super admin, regardless of what permission, they should be able to access
     if (COwnerHelper::isCommunityAdmin()) {
         return true;
     }
     $album = JTable::getInstance('Album', 'CTable');
     $album->load($this->albumid);
     switch ($album->type) {
         case PHOTOS_USER_TYPE:
             if ($permissionType == 'delete') {
                 return $this->creator == $userId;
             }
             break;
         case PHOTOS_GROUP_TYPE:
             //CFactory::load( 'models' , 'groups' );
             $group = JTable::getInstance('Group', 'CTable');
             $group->load($album->groupid);
             if ($permissionType == 'delete') {
                 return $album->creator == $userId || $group->isAdmin($userId);
             }
             return false;
             break;
     }
 }
예제 #7
0
 function showMiniHeader($userId)
 {
     CMiniHeader::load();
     CFactory::load('helpers', 'friends');
     CFactory::load('helpers', 'owner');
     $option = JRequest::getVar('option', '', 'REQUEST');
     $lang =& JFactory::getLanguage();
     $lang->load('com_community');
     $my = CFactory::getUser();
     $config = CFactory::getConfig();
     if (!empty($userId)) {
         $user = CFactory::getUser($userId);
         CFactory::load('libraries', 'messaging');
         $sendMsg = CMessaging::getPopup($user->id);
         $tmpl = new CTemplate();
         $tmpl->set('my', $my);
         $tmpl->set('user', $user);
         $tmpl->set('isMine', COwnerHelper::isMine($my->id, $user->id));
         $tmpl->set('sendMsg', $sendMsg);
         $tmpl->set('config', $config);
         $tmpl->set('isFriend', CFriendsHelper::isConnected($user->id, $my->id) && $user->id != $my->id);
         $showMiniHeader = $option == 'com_community' ? $tmpl->fetch('profile.miniheader') : '<div id="community-wrap" style="min-height:50px;">' . $tmpl->fetch('profile.miniheader') . '</div>';
         return $showMiniHeader;
     }
 }
예제 #8
0
파일: privacy.php 프로젝트: bizanto/Hooked
 /**
  * Return true if actor have access to target's item
  * @param type where the privacy setting should be extracted, {user, group, global, custom}
  * Site super admin waill always have access to all area	 
  */
 static function isAccessAllowed($actorId, $targetId, $type, $userPrivacyParam)
 {
     $actor = CFactory::getUser($actorId);
     $target = CFactory::getUser($targetId);
     CFactory::load('helpers', 'owner');
     CFactory::load('helpers', 'friends');
     // Load User params
     $params =& $target->getParams();
     // guest
     $relation = 10;
     // site members
     if ($actor->id != 0) {
         $relation = 20;
     }
     // friends
     if (CFriendsHelper::isConnected($actorId, $targetId)) {
         $relation = 30;
     }
     // mine, target and actor is the same person
     if (COwnerHelper::isMine($actor->id, $target->id)) {
         $relation = 40;
     }
     // @todo: respect privacy settings
     // If type is 'custom', then $userPrivacyParam will contain the exact
     // permission level
     $permissionLevel = $type == 'custom' ? $userPrivacyParam : $params->get($userPrivacyParam);
     if ($relation < $permissionLevel && !COwnerHelper::isCommunityAdmin($actorId)) {
         return false;
     }
     return true;
 }
예제 #9
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;
 }
예제 #10
0
파일: search.php 프로젝트: bizanto/Hooked
 public function ajaxAddFeatured($memberId)
 {
     $objResponse = new JAXResponse();
     CFactory::load('helpers', 'owner');
     $my = CFactory::getUser();
     if ($my->id == 0) {
         return $this->ajaxBlockUnregister();
     }
     if (COwnerHelper::isCommunityAdmin()) {
         $model = CFactory::getModel('Featured');
         if (!$model->isExists(FEATURED_USERS, $memberId)) {
             CFactory::load('libraries', 'featured');
             $featured = new CFeatured(FEATURED_USERS);
             $member = CFactory::getUser($memberId);
             $featured->add($memberId, $my->id);
             $objResponse->addAssign('cWindowContent', 'innerHTML', JText::sprintf('CC MEMBER IS FEATURED', $member->getDisplayName()));
         } else {
             $objResponse->addAssign('cWindowContent', 'innerHTML', JText::_('CC USER ALREADY FEATURED'));
         }
     } else {
         $objResponse->addAssign('cWindowContent', 'innerHTML', JText::_('CC NOT ALLOWED TO ACCESS SECTION'));
     }
     $buttons = '<input type="button" class="button" onclick="window.location.reload();" value="' . JText::_('CC BUTTON CLOSE') . '"/>';
     $objResponse->addScriptCall('cWindowActions', $buttons);
     return $objResponse->sendResponse();
 }
예제 #11
0
 /**
  * Retrieve menu items in JomSocial's toolbar
  * 
  * @access	public
  * @param
  * 
  * @return	Array	An array of #__menu objects.
  **/
 public function getItems()
 {
     $config = CFactory::getConfig();
     $db = JFactory::getDBO();
     $menus = array();
     // For menu access
     $my = CFactory::getUser();
     //joomla 1.6
     $menutitlecol = !C_JOOMLA_15 ? 'title' : 'name';
     $query = 'SELECT a.' . $db->nameQuote('id') . ', a.' . $db->nameQuote('link') . ', a.' . $menutitlecol . ' as name, a.' . $db->nameQuote(TABLE_MENU_PARENTID) . ', false as script ' . ' FROM ' . $db->nameQuote('#__menu') . ' AS a ' . ' LEFT JOIN ' . $db->nameQuote('#__menu') . ' AS b ' . ' ON b.' . $db->nameQuote('id') . '=a.' . $db->nameQuote(TABLE_MENU_PARENTID) . ' AND b.' . $db->nameQuote('published') . '=' . $db->Quote(1) . ' ' . ' WHERE a.' . $db->nameQuote('published') . '=' . $db->Quote(1) . ' ' . ' AND a.' . $db->nameQuote('menutype') . '=' . $db->Quote($config->get('toolbar_menutype'));
     if ($my->id == 0) {
         $query .= ' AND a.' . $db->nameQuote('access') . '=' . $db->Quote(0);
     }
     CFactory::load('helpers', 'owner');
     if ($my->id > 0 && !COwnerHelper::isCommunityAdmin()) {
         //			$query	.= ' AND a.' . $db->nameQuote( 'access' ) . '>=' . $db->Quote( 0 ) . ' AND a.' . $db->nameQuote( 'access' ) . '<' . $db->Quote( 2 );
         //we haven't supported access level setting for toolbar menu yet.
         $query .= ' AND a.' . $db->nameQuote('access') . '>=' . $db->Quote(0);
     }
     if (COwnerHelper::isCommunityAdmin()) {
         $query .= ' AND a.' . $db->nameQuote('access') . '>=' . $db->Quote(0);
     }
     $ordering_field = TABLE_MENU_ORDERING_FIELD;
     $query .= ' ORDER BY a.' . $db->nameQuote($ordering_field);
     $db->setQuery($query);
     $result = $db->loadObjectList();
     // remove disabled apps base on &view=value in result's link
     $this->cleanMenus($result);
     //avoid multiple count execution
     $parentColumn = TABLE_MENU_PARENTID;
     $menus = array();
     foreach ($result as $i => $row) {
         //get top main links on toolbar
         //add Itemid if not our components and dont add item id for external link
         $row->link = CString::str_ireplace('https://', 'http://', $row->link);
         if (strpos($row->link, 'com_community') == false && strpos($row->link, 'http://') === false) {
             $row->link .= "&Itemid=" . $row->id;
         }
         if ($row->{$parentColumn} == MENU_PARENT_ID) {
             $obj = new stdClass();
             $obj->item = $row;
             $obj->item->script = false;
             $obj->childs = null;
             $menus[$row->id] = $obj;
         }
     }
     // Retrieve child menus from the original result.
     // Since we reduce the number of sql queries, we need to use php to split the menu's out
     // accordingly.
     foreach ($result as $i => $row) {
         if ($row->{$parentColumn} != MENU_PARENT_ID && isset($menus[$row->{$parentColumn}])) {
             if (!is_array($menus[$row->{$parentColumn}]->childs)) {
                 $menus[$row->{$parentColumn}]->childs = array();
             }
             $menus[$row->{$parentColumn}]->childs[] = $row;
         }
     }
     return $menus;
 }
예제 #12
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;
 }
예제 #13
0
 public function ajaxResetNotification($params)
 {
     $response = new JAXResponse();
     if (!COwnerHelper::isCommunityAdmin()) {
         $response->addAssign('notification-update-result', 'innerHTML', JText::_('COM_COMMUNITY_NOT_ALLOWED'));
         return $response->sendResponse();
     }
     $model = $this->getModel('Configuration');
     $model->updateNotification($params);
     $response->addAssign('notification-update-result', 'innerHTML', JText::_('COM_COMMUNITY_FRONTPAGE_ALL_NOTIFICATION_RESET'));
     $response->addScriptCall("joms.jQuery('#notification-update-result').parent().find('input').val('" . JText::_('COM_COMMUNITY_CONFIGURATION_PRIVACY_RESET_EXISTING_NOTIFICATION_BUTTON') . "');");
     return $response->sendResponse();
 }
예제 #14
0
 public function ajaxResetPrivacy($photoPrivacy = 0, $profilePrivacy = 0, $friendsPrivacy = 0)
 {
     $response = new JAXResponse();
     CFactory::load('helpers', 'owner');
     if (!COwnerHelper::isCommunityAdmin()) {
         $response->addScriptCall(JText::_('COM_COMMUNITY_NOT_ALLOWED'));
         return $response->sendResponse();
     }
     $model = $this->getModel('Configuration');
     $model->updatePrivacy($photoPrivacy, $profilePrivacy, $friendsPrivacy);
     $response->addAssign('privacy-update-result', 'innerHTML', JText::_('COM_COMMUNITY_FRONTPAGE_ALL_PRIVACY_RESET'));
     return $response->sendResponse();
 }
예제 #15
0
 public static function wallsDelete($userid, $wall)
 {
     $my = CFactory::getUser();
     //community admin can always delete
     if (COwnerHelper::isCommunityAdmin()) {
         return true;
     }
     //bear in mind that not all contentid is activity id, it could be photo id or album id depending on the type
     $cid = 0;
     if ($wall->params != '' && $wall->params != '{}') {
         if ($wall->params instanceof JRegistry) {
             $cid = $wall->params->get('activityId', 0);
         } else {
             $wall->params = new JRegistry($wall->params);
             $cid = $wall->params->get('activityId', 0);
         }
     } elseif ($wall->type == 'profile.status') {
         //in the case of profile status, the contentid is linked to the activity id
         $cid = $wall->contentid;
     }
     //check if this is a photo owner, if he is, he can always remove the comment under the photo
     if ($wall->type == 'photos') {
         $photoTable = JTable::getInstance('photo', 'CTable');
         $photoTable->load($wall->contentid);
         if ($photoTable->creator == $my->id) {
             return true;
         }
     } elseif ($wall->type == 'videos') {
         $photoTable = JTable::getInstance('video', 'CTable');
         $photoTable->load($wall->contentid);
         if ($photoTable->creator == $my->id) {
             return true;
         }
     } elseif ($wall->type == 'discussions') {
         $photoTable = JTable::getInstance('discussion', 'CTable');
         $photoTable->load($wall->contentid);
         if ($photoTable->creator == $my->id) {
             return true;
         }
     }
     $actModel = CFactory::getModel('activities');
     $activity = $actModel->getActivity($cid);
     $ownPost = $my->id == $wall->post_by;
     $targetPost = $activity->target == $my->id;
     $allowRemove = ($ownPost || $targetPost || $activity->actor == $my->id) && $my->id;
     return $allowRemove;
 }
예제 #16
0
 public static function getStreamPermissionHTML($privacy, $actorId = NULL)
 {
     $my = CFactory::getUser();
     if ($my->id != $actorId && !is_null($actorId) && !COwnerHelper::isCommunityAdmin()) {
         return;
     }
     $html = '<span class="joms-share-meta joms-share-privacy">' . JText::_(self::$_permission[$privacy]) . '</span>';
     $html .= '<div class="joms-privacy-dropdown joms-stream-privacy">';
     $html .= '<button type="button" class="dropdown-toggle" data-value="" data-toggle="dropdown"><span class="dropdown-value"><i class="' . self::$_icons[$privacy] . '"></i></span><span class="dropdown-caret joms-icon-caret-down"></span></button>';
     $html .= '<ul class="dropdown-menu">';
     $permissions = self::$_permission;
     unset($permissions[0]);
     foreach ($permissions as $value => $permission) {
         $html .= '<li><a href="javascript:" data-option-value="' . $value . '"><i class="' . self::$_icons[$value] . '"></i><span>' . JText::_($permission) . '</span></a></li>';
     }
     $html .= '</ul></div>';
     return $html;
 }
예제 #17
0
 public static function exceededPhotoUpload($id, $type = PHOTOS_USER_TYPE)
 {
     // @rule: Administrator should not be restricted
     //CFactory::load( 'helpers' , 'owner' );
     if (COwnerHelper::isCommunityAdmin()) {
         return false;
     }
     // Get the configuration for uploader tool
     $config = CFactory::getConfig();
     $model = CFactory::getModel('photos');
     $photoLimit = $config->get('photouploadlimit');
     if ($type == PHOTOS_GROUP_TYPE) {
         $photoLimit = $config->get('groupphotouploadlimit');
     }
     $totalPhotos = $model->getPhotosCount($id, $type);
     if ($totalPhotos >= $photoLimit && $photoLimit != 0) {
         return true;
     }
     return false;
 }
예제 #18
0
 public static function getStreamPermissionHTML($privacy, $actorId = NULL)
 {
     $my = CFactory::getUser();
     if ($my->id != $actorId && !is_null($actorId) && !COwnerHelper::isCommunityAdmin()) {
         return;
     }
     $html = ' <span class="joms-stream__meta--separator">&bull;</span> ';
     $html .= '<span class="joms-stream__privacy" data-ui-object="stream-privacy">';
     $html .= '<button class="joms-stream__privacy--button" data-ui-object="stream-privacy-button"><i class="joms-icon ' . self::$_icons[$privacy] . '"></i>';
     $html .= '<span class="joms-icon joms-icon__caret-down"></span></button>';
     $html .= '<div class="joms-stream__privacy--dropdown" data-ui-object="stream-privacy-dropdown">';
     $permissions = self::$_permission;
     unset($permissions[0]);
     foreach ($permissions as $value => $permission) {
         $html .= '<a href="#" data-ui-object="stream-privacy-dropdown-item" data-value="' . $value . '"' . ($value == $privacy ? ' class="active"' : '') . '>';
         $html .= '<i class="joms-icon ' . self::$_icons[$value] . '"></i><span>' . JText::_($permission) . '</span></a>';
     }
     $html .= '</div>';
     $html .= '</span>';
     return $html;
 }
예제 #19
0
 /**
  * Get the user status
  * 
  * @param int	userid
  * 
  * @todo: this should return the status object. Use Jtable for this	 	 	 	 
  */
 public function get($id, $limit = 1)
 {
     $db =& $this->getDBO();
     $config = CFactory::getConfig();
     CFactory::load('helpers', 'owner');
     //enforce user's status privacy
     $andWhere = array();
     $andWhere[] = $db->nameQuote('userid') . '=' . $db->Quote($id);
     if ($config->get('respectactivityprivacy')) {
         $my = CFactory::getUser();
         if ($my->id == 0) {
             // for guest, it is enough to just test access <= 0
             $andWhere[] = '(' . $db->nameQuote('status_access') . ' <= 10)';
         } elseif (!COwnerHelper::isCommunityAdmin($my->id)) {
             $orWherePrivacy = array();
             $orWherePrivacy[] = '(' . $db->nameQuote('status_access') . ' = 0) ';
             $orWherePrivacy[] = '(' . $db->nameQuote('status_access') . ' = 10) ';
             $orWherePrivacy[] = '((' . $db->nameQuote('status_access') . ' = 20) AND ( ' . $db->Quote($my->id) . ' != 0)) ';
             if ($my->id != 0) {
                 $orWherePrivacy[] = '((' . $db->nameQuote('status_access') . ' = ' . $db->Quote(40) . ') AND (' . $db->Quote($id) . ' = ' . $db->Quote($my->id) . ')) ';
                 $orWherePrivacy[] = '((' . $db->nameQuote('status_access') . ' = ' . $db->Quote(30) . ') AND ((' . $db->Quote($my->id) . 'IN (SELECT c.' . $db->nameQuote('connect_to') . ' FROM ' . $db->nameQuote('#__community_connection') . ' as c' . ' WHERE c.' . $db->nameQuote('connect_from') . ' = ' . $db->Quote($id) . ' AND c.' . $db->nameQuote('status') . ' = ' . $db->Quote(1) . ' ) ) OR (' . $db->Quote($id) . ' = ' . $db->Quote($my->id) . ') )) ';
             }
             $OrPrivacy = implode(' OR ', $orWherePrivacy);
             $andWhere[] = "(" . $OrPrivacy . ")";
         }
     }
     $whereAnd = implode(' AND ', $andWhere);
     $sql = 'SELECT * from ' . $db->nameQuote('#__community_users') . ' WHERE ' . $whereAnd . ' ORDER BY ' . $db->nameQuote('posted_on') . ' DESC LIMIT ' . $limit;
     $db->setQuery($sql);
     $result = $db->loadObjectList();
     // Return the first row
     if (!empty($result)) {
         $result = $result[0];
     } else {
         $result = new stdClass();
         $result->status = '';
     }
     return $result;
 }
예제 #20
0
 public static function videosUserVideoView($userid, $asset)
 {
     //first
     $video = JTable::getInstance('Video', 'CTable');
     $video->load($asset);
     if ($userid == $video->creator || COwnerHelper::isCommunityAdmin()) {
         return true;
         // creator always be able to view his own album
     }
     $owner = CFactory::getUser($video->creator);
     $permission = $video->permissions;
     if ($permission == COMMUNITY_STATUS_PRIVACY_FRIENDS && $owner->isFriendWith($userid)) {
         return true;
     }
     if ($permission == COMMUNITY_STATUS_PRIVACY_MEMBERS && $userid) {
         return true;
     }
     if ($permission <= COMMUNITY_STATUS_PRIVACY_PUBLIC) {
         return true;
     }
     return false;
 }
예제 #21
0
파일: textarea.php 프로젝트: Jougito/DynWeb
 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;
 }
예제 #22
0
 public function ajaxShowSaveForm()
 {
     CFactory::load('helpers', 'owner');
     require_once JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_menus' . DS . 'helpers' . DS . 'helper.php';
     if (!COwnerHelper::isCommunityAdmin()) {
         echo JText::_('CC RESTRICTED ACCESS');
         return;
     }
     $response = new JAXResponse();
     $args = func_get_args();
     if (!isset($args[0])) {
         $response->addScriptCall('alert', 'CC INVALID ID');
         return $resopnse->sendResponse();
     }
     $condition = $args[0];
     array_shift($args);
     $avatarOnly = $args[0];
     array_shift($args);
     $filters = $args;
     $menuTypes = MenusHelper::getMenuTypeList();
     $menuAccess = new stdClass();
     $menuAccess->access = 0;
     $tmpl = new CTemplate();
     $tmpl->set('condition', $condition);
     $tmpl->set('menuTypes', $menuTypes);
     $tmpl->set('menuAccess', $menuAccess);
     $tmpl->set('avatarOnly', $avatarOnly);
     $tmpl->set('filters', $filters);
     $html = $tmpl->fetch('ajax.memberlistform');
     $response->addAssign('cwin_logo', 'innerHTML', JText::_('CC SEARCH FILTER'));
     $response->addAssign('cWindowContent', 'innerHTML', $html);
     $action = '<button  class="button" onclick="cWindowHide();">' . JText::_('CC BUTTON CANCEL') . '</button>';
     $action .= '<button  class="button" onclick="joms.memberlist.submit();">' . JText::_('CC BUTTON SAVE') . '</button>';
     $response->addScriptCall('cWindowActions', $action);
     return $response->sendResponse();
 }
예제 #23
0
 public function isAlbumBrowsable($albumId)
 {
     $album = JTable::getInstance('Album', 'CTable');
     $album->load($albumId);
     $group = JTable::getInstance('Group', 'CTable');
     $group->load($album->groupid);
     $document = JFactory::getDocument();
     $mainframe = JFactory::getApplication();
     //@rule: Do not allow non members to view albums for private group
     if ($group->approvals == COMMUNITY_PRIVATE_GROUP && !$group->isMember($this->my->id) && !$group->isAdmin($this->my->id) && !COwnerHelper::isCommunityAdmin()) {
         /**
          * Opengraph
          */
         CHeadHelper::setType('website', JText::_('COM_COMMUNITY_RESTRICTED_ACCESS'));
         $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_RESTRICTED_ACCESS', 'notice'));
         echo JText::_('COM_COMMUNITY_GROUPS_ALBUM_MEMBER_PERMISSION');
         return false;
     }
     return true;
 }
예제 #24
0
파일: default.php 프로젝트: bizanto/Hooked
 $friendModel = CFactory::getModel('friends');
 $profileid = JRequest::getVar('userid', 0, 'GET');
 $params->def('unreadCount', $inboxModel->countUnRead($filter));
 $params->def('pending', $friendModel->countPending($my->id));
 $params->def('myLink', CRoute::_('index.php?option=com_community&view=profile&userid=' . $my->id));
 $params->def('myName', $my->getDisplayName());
 $params->def('myAvatar', $my->getAvatar());
 $params->def('myId', $my->id);
 $params->def('myKarma', CUserPoints::getPointsImage($my));
 $params->def('enablephotos', $config->get('enablephotos'));
 $params->def('enablevideos', $config->get('enablevideos'));
 $params->def('enablegroups', $config->get('enablegroups'));
 $params->def('enableevents', $config->get('enableevents'));
 $enablekarma = $config->get('enablekarma') ? $params->get('show_karma', 1) : $config->get('enablekarma');
 $params->def('enablekarma', $enablekarma);
 $js = modHelloMeHelper::getHelloMeScript($my->getStatus(), COwnerHelper::isMine($my->id, $profileid));
 $document = JFactory::getDocument();
 $document->addScriptDeclaration($js);
 if ($params->get('enable_facebookconnect', '1')) {
     $params->def('facebookuser', modHelloMeHelper::isFacebookUser());
 } else {
     $params->def('facebookuser', false);
 }
 CFactory::load('helpers', 'string');
 $unreadCount = $params->get('unreadCount', 1);
 $pending = $params->get('pending', 1);
 $myLink = $params->get('myLink', 1);
 $myName = $params->get('myName', 1);
 $myAvatar = $params->get('myAvatar', 1);
 $myId = $params->get('myId', 1);
 $myKarma = $params->get('myKarma', 1);
예제 #25
0
파일: like.php 프로젝트: bizanto/Hooked
 /**
  *
  * @return string
  */
 public function getHTML($element, $itemId, $userId)
 {
     // @rule: Only display likes html codes when likes is allowed.
     $config =& CFactory::getConfig();
     if (!$config->get('likes_' . $element)) {
         return;
     }
     // TODO: WRAP into another function
     $likesModel =& CFactory::getModel('Like');
     $info = $likesModel->getInfo($element, $itemId);
     $likes = 0;
     $dislikes = 0;
     $userLiked = COMMUNITY_UNLIKE;
     if ($info) {
         $like =& JTable::getInstance('Like', 'CTable');
         $like->load($info->id);
         $likesInArray = array();
         $dislikesInArray = array();
         if ($like) {
             $likesInArray = explode(',', $like->like);
             $dislikesInArray = explode(',', $like->dislike);
         }
         $likes = count($likesInArray) - 1;
         $dislikes = count($dislikesInArray) - 1;
         $userLiked = $this->userLiked($element, $itemId, $userId);
     }
     $tmpl = new CTemplate();
     $tmpl->set('likeId', 'like' . '-' . $element . '-' . $itemId);
     $tmpl->set('likes', $likes);
     $tmpl->set('dislikes', $dislikes);
     $tmpl->set('userLiked', $userLiked);
     if (!COwnerHelper::isRegisteredUser()) {
         return $this->getHtmlPublic($element, $itemId);
     } else {
         return $tmpl->fetch('like.html');
     }
 }
예제 #26
0
 public function getVideos($userid, $limitstart, $limit)
 {
     $photoType = PHOTOS_USER_TYPE;
     //privacy settings
     //CFactory::load('libraries', 'privacy');
     $permission = CPrivacy::getAccessLevel($this->_my->id, $userid);
     //get videos from the user
     //CFactory::load('models', 'videos');
     $model = CFactory::getModel('Videos');
     if ($this->_my->id == $userid || COwnerHelper::isCommunityAdmin()) {
         $permission = 40;
     } elseif (CFriendsHelper::isConnected($this->_my->id, $userid)) {
         $permission = 30;
     } elseif ($this->_my->id != 0) {
         $permission = 20;
     } else {
         $permission = 10;
     }
     $videos = $model->getUserTotalVideos($userid, $permission);
     return $videos;
 }
예제 #27
0
 /**
  * Return formatted comment given the wall item
  */
 public static function formatComment($wall)
 {
     $config = CFactory::getConfig();
     $my = CFactory::getUser();
     $actModel = CFactory::getModel('activities');
     $like = new CLike();
     $likeCount = $like->getLikeCount('comment', $wall->id);
     $isLiked = $like->userLiked('comment', $wall->id, $my->id);
     $user = CFactory::getUser($wall->post_by);
     // Censor if the user is banned
     if ($user->block) {
         $wall->comment = $origComment = JText::_('COM_COMMUNITY_CENSORED');
     } else {
         // strip out the comment data
         $CComment = new CComment();
         $wall->comment = $CComment->stripCommentData($wall->comment);
         // Need to perform basic formatting here
         // 1. support nl to br,
         // 2. auto-link text
         $CTemplate = new CTemplate();
         $wall->comment = $origComment = $CTemplate->escape($wall->comment);
         $wall->comment = CStringHelper::autoLink($wall->comment);
     }
     $commentsHTML = '';
     $commentsHTML .= '<div class="cComment wall-coc-item" id="wall-' . $wall->id . '"><a href="' . CUrlHelper::userLink($user->id) . '"><img src="' . $user->getThumbAvatar() . '" alt="" class="wall-coc-avatar" /></a>';
     $date = new JDate($wall->date);
     $commentsHTML .= '<a class="wall-coc-author" href="' . CUrlHelper::userLink($user->id) . '">' . $user->getDisplayName() . '</a> ';
     $commentsHTML .= $wall->comment;
     $commentsHTML .= '<span class="wall-coc-time">' . CTimeHelper::timeLapse($date);
     $cid = isset($wall->contentid) ? $wall->contentid : null;
     $activity = $actModel->getActivity($cid);
     $ownPost = $my->id == $wall->post_by;
     $allowRemove = $my->authorise('community.delete', 'walls', $wall);
     $canEdit = $config->get('wallediting') && $my->id == $wall->post_by || COwnerHelper::isCommunityAdmin();
     // only poster can edit
     if ($allowRemove) {
         $commentsHTML .= ' <span class="wall-coc-remove-link">&#x2022; <a href="#removeComment">' . JText::_('COM_COMMUNITY_WALL_REMOVE') . '</a></span>';
     }
     $commentsHTML .= '</span>';
     $commentsHTML .= '</div>';
     $editHTML = '';
     if ($config->get('wallediting') && $ownPost || COwnerHelper::isCommunityAdmin()) {
         $editHTML .= '<a href="javascript:" class="joms-button--edit">';
         $editHTML .= '<svg viewBox="0 0 16 16" class="joms-icon"><use xlink:href="' . CRoute::getURI() . '#joms-icon-pencil"></use></svg>';
         $editHTML .= '<span>' . JText::_('COM_COMMUNITY_EDIT') . '</span>';
         $editHTML .= '</a>';
     }
     $removeHTML = '';
     if ($allowRemove) {
         $removeHTML .= '<a href="javascript:" class="joms-button--remove">';
         $removeHTML .= '<svg viewBox="0 0 16 16" class="joms-icon"><use xlink:href="' . CRoute::getURI() . '#joms-icon-remove"></use></svg>';
         $removeHTML .= '<span>' . JText::_('COM_COMMUNITY_WALL_REMOVE') . '</span>';
         $removeHTML .= '</a>';
     }
     $removeTagHTML = '';
     if (CActivitiesHelper::hasTag($my->id, $wall->comment)) {
         $removeTagHTML = '<span><a data-action="remove-tag" data-id="' . $wall->id . '" href="javascript:">' . JText::_('COM_COMMUNITY_WALL_REMOVE_TAG') . '</a></span>';
     }
     /* user deleted */
     if ($user->guest == 1) {
         $userLink = '<span class="cStream-Author">' . $user->getDisplayName() . '</span> ';
     } else {
         $userLink = '<a class="cStream-Avatar cStream-Author cFloat-L" href="' . CUrlHelper::userLink($user->id) . '"> <img class="cAvatar" src="' . $user->getThumbAvatar() . '"> </a> ';
     }
     $params = $wall->params;
     $paramsHTML = '';
     $image = (array) $params->get('image');
     $photoThumbnail = false;
     if ($params->get('attached_photo_id') > 0) {
         $photo = JTable::getInstance('Photo', 'CTable');
         $photo->load($params->get('attached_photo_id'));
         $photoThumbnail = $photo->getThumbURI();
         $paramsHTML .= '<div style="padding: 5px 0"><img class="joms-stream-thumb" src="' . $photoThumbnail . '" /></div>';
     } else {
         if ($params->get('title')) {
             $video = self::detectVideo($params->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-relative joms-js--comment-preview">';
                 if ($user->id == $my->id || COwnerHelper::isCommunityAdmin()) {
                     $paramsHTML .= '<span class="joms-media__remove" data-action="remove-preview" onClick="joms.api.commentRemovePreview(\'' . $wall->id . '\');"><svg viewBox="0 0 16 16" class="joms-icon"><use xlink:href="#joms-icon-remove"></use></svg></span>';
                 }
                 if ($params->get('image')) {
                     $paramsHTML .= $params->get('link');
                     $paramsHTML .= '<div class="joms-media__thumbnail">';
                     $paramsHTML .= '<a href="' . $params->get('link') ? $params->get('link') : '#' . '">';
                     $paramsHTML .= '<img src="' . array_shift($image) . '" />';
                     $paramsHTML .= '</a>';
                     $paramsHTML .= '</div>';
                 }
                 $url = $params->get('url') ? $params->get('url') : '#';
                 $paramsHTML .= '<div class="joms-media__body">';
                 $paramsHTML .= '<a href="' . $url . '">';
                 $paramsHTML .= '<h4 class="joms-media__title">' . $params->get('title') . '</h4>';
                 $paramsHTML .= '<p class="joms-media__desc reset-gap">' . CStringHelper::trim_words($params->get('description')) . '</p>';
                 if ($params->get('link')) {
                     $paramsHTML .= '<span class="joms-text--light"><small>' . preg_replace('#^https?://#', '', $params->get('link')) . '</small></span>';
                 }
                 $paramsHTML .= '</a></div></div>';
             }
         }
     }
     if (!$params->get('title') && $params->get('url')) {
         $paramsHTML .= '<div class="joms-gap"></div>';
         $paramsHTML .= '<div class="joms-media--album">';
         $paramsHTML .= '<a href="' . $params->get('url') . '">';
         $paramsHTML .= '<img class="joms-stream-thumb" src="' . $params->get('url') . '" />';
         $paramsHTML .= '</a>';
         $paramsHTML .= '</div>';
     }
     $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
     $template = new CTemplate();
     $template->set('wall', $wall)->set('originalComment', $origComment)->set('date', $date)->set('isLiked', $isLiked)->set('likeCount', $likeCount)->set('canRemove', $allowRemove)->set('canEdit', $canEdit)->set('canRemove', $allowRemove)->set('user', $user)->set('photoThumbnail', $photoThumbnail)->set('paramsHTML', $paramsHTML);
     $commentsHTML = $template->fetch('stream/single-comment');
     return $commentsHTML;
 }
예제 #28
0
파일: photos.php 프로젝트: Jougito/DynWeb
 public function getAllAlbums($userId = 0, $limit = 0, $sortBy = 'date')
 {
     $db = $this->getDBO();
     $isAdmin = (int) COwnerHelper::isCommunityAdmin();
     // Get limit
     $limit = $limit == 0 ? $this->getState('limit') : $limit;
     $limitstart = $this->getState('limitstart');
     $extraSQL = '';
     $permissions = $userId == 0 ? 10 : 20;
     $permissions = COwnerHelper::isCommunityAdmin() ? 40 : $permissions;
     $extraSQL .= ' WHERE (( permissions <=' . $db->Quote($permissions) . ' OR (creator=' . $db->Quote($userId) . ' AND permissions <=' . $db->Quote(40) . ') )';
     //need to grab friends' album that has "Friends only" permission as well
     $friendmodel = CFactory::getModel('friends');
     $friends = $friendmodel->getFriendIds($userId);
     if (!empty($friends)) {
         $extraSQL .= ' OR (creator IN(' . implode(',', $friends) . ') AND permissions = ' . $db->Quote(30) . ') ';
     }
     /* if not administrator than we'll filter profile cover album */
     if (!$isAdmin) {
         $extraSQL .= ' AND ( ';
         /* get own profile' cover album */
         $extraSQL .= ' ( ' . $db->quoteName('type') . ' = ' . $db->quote('profile.cover') . ' AND ' . $db->quoteName('creator') . ' = ' . $userId . ' ) ';
         /* or get none profile' cover album */
         $extraSQL .= ' OR ( ' . $db->quoteName('type') . ' != ' . $db->quote('profile.cover') . ' ) ';
         $extraSQL .= ' ) ';
     }
     $extraSQL .= ' ) ';
     $query = 'SELECT * FROM ' . $db->quoteName('#__community_photos_albums');
     $query .= $extraSQL;
     switch ($sortBy) {
         case 'featured':
             $featured = new CFeatured(FEATURED_ALBUMS);
             $featuredAlbums = implode(',', $featured->getItemIds());
             if ($featuredAlbums) {
                 $query .= " ORDER BY (`id` IN (" . $featuredAlbums . ")) DESC, id ";
             }
             break;
         case 'featured_only':
             $featured = new CFeatured(FEATURED_ALBUMS);
             $featuredAlbums = implode(',', $featured->getItemIds());
             if ($featuredAlbums) {
                 $query .= ' AND `id` IN (' . $featuredAlbums . ')';
             }
             break;
         case 'hit':
             $query .= " ORDER BY `hits` DESC ";
             break;
         case 'name':
             $query .= " ORDER BY `name` ASC ";
             break;
         default:
             $query .= " ORDER BY `created` DESC ";
             break;
     }
     $db->setQuery($query);
     $result = $db->loadObjectList();
     $total = count($result);
     if ($db->getErrorNum()) {
         JError::raiseError(500, $db->stderr());
     }
     //do not limit if this is a sort by featured only because its supposed to be a filter
     if ($sortBy == 'featured_only') {
         $db->setQuery($query);
     } else {
         $db->setQuery($query . 'LIMIT ' . $limitstart . ',' . $limit);
     }
     $result = $db->loadObjectList();
     if ($db->getErrorNum()) {
         JError::raiseError(500, $db->stderr());
     }
     // Update their correct Thumbnails and check album permissions
     //$this->_updateThumbnail($result);
     $data = $this->sortAlbums($result, $sortBy);
     jimport('joomla.html.pagination');
     // Apply pagination based on counted data
     $this->_pagination = new JPagination($total, $limitstart, $limit);
     $tmpData = array();
     foreach ($data as $_data) {
         $tmpData[] = $_data;
     }
     return $tmpData;
 }
예제 #29
0
                <li><a href="<?php 
        echo CRoute::_('index.php?option=com_community&view=events&task=import&groupid=' . $group->id);
        ?>
"><?php 
        echo JText::_('COM_COMMUNITY_GROUPS_IMPORT_EVENT');
        ?>
</a></li>
            <?php 
    }
    ?>



            <?php 
    // @TODO: CAccess - Leave group
    if ($isMember && !$isMine && !$waitingApproval && COwnerHelper::isRegisteredUser()) {
        ?>
                <li><a href="javascript:" onclick="joms.api.groupLeave('<?php 
        echo $group->id;
        ?>
');"><?php 
        echo JText::_('COM_COMMUNITY_GROUPS_LEAVE');
        ?>
</a></li>
            <?php 
    }
    ?>


            <?php 
    // @TODO: CAccess - Grou padmin actions
예제 #30
0
파일: inbox.php 프로젝트: Jougito/DynWeb
 /**
  * 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));
 }