Example #1
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;
 }
Example #2
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();
 }
Example #3
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'] = '&nbsp;';
     $json['html'] = $html;
     die(json_encode($json));
 }
Example #4
0
 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();
 }
Example #5
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;
 }
Example #6
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;
 }
Example #7
0
 /**
  *	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;
     }
 }
Example #8
0
 /**
  * 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;
 }
Example #9
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;
     }
 }
Example #10
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;
 }
Example #11
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;
 }
Example #12
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();
 }
Example #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();
 }
Example #14
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;
 }
 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;
 }
Example #16
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;
 }
Example #17
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;
 }
Example #18
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;
 }
Example #19
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;
 }
Example #20
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;
 }
Example #21
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();
 }
Example #22
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;
 }
Example #23
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;
 }
Example #24
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;
 }
Example #25
0
 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;
 }
Example #26
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));
 }
Example #27
0
 public static function getMediaPermission($eventid)
 {
     // load COwnerHelper::isCommunityAdmin()
     //CFactory::load( 'helpers' , 'owner' );
     $my = CFactory::getUser();
     $isSuperAdmin = COwnerHelper::isCommunityAdmin();
     $isAdmin = false;
     $isMember = false;
     // Load the group table.
     $event = JTable::getInstance('Event', 'CTable');
     $event->load($eventid);
     $params = new CParameter($event->params);
     if (!$isSuperAdmin) {
         $isAdmin = $event->isAdmin($my->id, $event->id);
         $isMember = $event->isMember($my->id);
     }
     $permission = new stdClass();
     $permission->isMember = $isMember;
     $permission->isAdmin = $isAdmin;
     $permission->isSuperAdmin = $isSuperAdmin;
     $permission->params = $params;
     return $permission;
 }
Example #28
0
 public function advanceSearch()
 {
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $document = JFactory::getDocument();
     //load calendar behavior
     JHtml::_('behavior.calendar');
     JHtml::_('behavior.tooltip');
     /**
      * Opengraph
      */
     CHeadHelper::setType('website', JText::_('COM_COMMUNITY_TITLE_CUSTOM_SEARCH'));
     //$this->showSubMenu();
     $this->addPathway(JText::_('COM_COMMUNITY_TITLE_CUSTOM_SEARCH'));
     $profileType = $jinput->get('profiletype', 0, 'INT');
     $my = CFactory::getUser();
     $config = CFactory::getConfig();
     $result = null;
     $fields = CAdvanceSearch::getFields($profileType);
     $data = new stdClass();
     $post = JRequest::get('GET');
     $keyList = isset($post['key-list']) ? $post['key-list'] : '';
     $avatarOnly = $jinput->get('avatar', '', 'NONE');
     if (JString::strlen($keyList) > 0) {
         //formatting the assoc array
         $filter = array();
         $key = explode(',', $keyList);
         $joinOperator = isset($post['operator']) ? $post['operator'] : '';
         foreach ($key as $idx) {
             $obj = new stdClass();
             $obj->field = $post['field' . $idx];
             $obj->condition = $post['condition' . $idx];
             $obj->fieldType = $post['fieldType' . $idx];
             if ($obj->fieldType == 'email') {
                 $obj->condition = 'equal';
             }
             // we need to check whether the value contain start and end kind of values.
             // if yes, make them an array.
             if (isset($post['value' . $idx . '_2'])) {
                 if ($obj->fieldType == 'date') {
                     $startDate = empty($post['value' . $idx]) ? '01/01/1970' : $post['value' . $idx];
                     $endDate = empty($post['value' . $idx . '_2']) ? '01/01/1970' : $post['value' . $idx . '_2'];
                     // Joomla 1.5 uses "/"
                     // Joomla 1.6 uses "-"
                     $delimeter = '-';
                     if (strpos($startDate, '/')) {
                         $delimeter = '/';
                     }
                     $sdate = explode($delimeter, $startDate);
                     $edate = explode($delimeter, $endDate);
                     if (isset($sdate[2]) && isset($edate[2])) {
                         $obj->value = array($sdate[0] . '-' . $sdate[1] . '-' . $sdate[2] . ' 00:00:00', $edate[0] . '-' . $edate[1] . '-' . $edate[2] . ' 23:59:59');
                     } else {
                         $obj->value = array(0, 0);
                     }
                 } else {
                     $obj->value = array($post['value' . $idx], $post['value' . $idx . '_2']);
                 }
             } else {
                 if ($obj->fieldType == 'date') {
                     $startDate = empty($post['value' . $idx]) ? '01/01/1970' : $post['value' . $idx];
                     $delimeter = '-';
                     if (strpos($startDate, '/')) {
                         $delimeter = '/';
                     }
                     $sdate = explode($delimeter, $startDate);
                     if (isset($sdate[2])) {
                         $obj->value = $sdate[2] . '-' . $sdate[1] . '-' . $sdate[0] . ' 00:00:00';
                     } else {
                         $obj->value = 0;
                     }
                 } else {
                     if ($obj->fieldType == 'checkbox') {
                         if (empty($post['value' . $idx])) {
                             //this mean user didnot check any of the option.
                             $obj->value = '';
                         } else {
                             $obj->value = isset($post['value' . $idx]) ? implode(',', $post['value' . $idx]) : '';
                         }
                     } else {
                         $obj->value = isset($post['value' . $idx]) ? $post['value' . $idx] : '';
                     }
                 }
             }
             $filter[] = $obj;
         }
         $data->search = CAdvanceSearch::getResult($filter, $joinOperator, $avatarOnly, '', $profileType);
         $data->filter = $post;
     }
     $rows = !empty($data->search) ? $data->search->result : array();
     $pagination = !empty($data->search) ? $data->search->pagination : '';
     $filter = !empty($data->filter) ? $data->filter : array();
     $resultRows = array();
     $friendsModel = CFactory::getModel('friends');
     for ($i = 0; $i < count($rows); $i++) {
         $row = $rows[$i];
         //filter the user profile type
         if ($profileType && $row->_profile_id != $profileType) {
             continue;
         }
         $obj = new stdClass();
         $obj->user = $row;
         $obj->friendsCount = $row->getFriendCount();
         $obj->profileLink = CRoute::_('index.php?option=com_community&view=profile&userid=' . $row->id);
         $isFriend = CFriendsHelper::isConnected($row->id, $my->id);
         $obj->addFriend = !$isFriend && $my->id != 0 && $my->id != $row->id ? true : false;
         $resultRows[] = $obj;
     }
     if (class_exists('Services_JSON')) {
         $json = new Services_JSON();
     } else {
         require_once AZRUL_SYSTEM_PATH . '/pc_includes/JSON.php';
         $json = new Services_JSON();
     }
     $tmpl = new CTemplate();
     $multiprofileArr = array();
     $hasMultiprofile = false;
     //let see if we have any multiprofile enabled
     if ($config->get('profile_multiprofile')) {
         $hasMultiprofile = true;
         //lets get the available profile
         $profileModel = CFactory::getModel('Profile');
         $profiles = $profileModel->getProfileTypes();
         if ($profiles) {
             $multiprofileArr[] = array('url' => CRoute::_('index.php?option=com_community&view=search&task=advancesearch'), 'name' => JText::_('COM_COMMUNITY_ALL_PROFILE'), 'selected' => !$profileType ? 1 : 0);
             foreach ($profiles as $profile) {
                 $multiprofileArr[] = array('url' => CRoute::_('index.php?option=com_community&view=search&task=advancesearch&profiletype=' . $profile->id), 'name' => $profile->name, 'selected' => $profile->id == $profileType ? 1 : 0);
             }
         }
     }
     $searchForm = $tmpl->set('fields', $fields)->set('hasMultiprofile', $hasMultiprofile)->set('multiprofileArr', $multiprofileArr)->set('keyList', $keyList)->set('profileType', $profileType)->set('avatarOnly', $avatarOnly)->set('filterJson', $json->encode($filter))->set('postresult', isset($post['key-list']))->set('submenu', $this->showSubmenu(false))->fetch('search.advancesearch');
     if (isset($post['key-list'])) {
         //result template
         $tmplResult = new CTemplate();
         $featured = new CFeatured(FEATURED_USERS);
         $featuredList = $featured->getItemIds();
         $tmpl->set('featuredList', $featuredList);
         $searchForm .= $tmplResult->set('my', $my)->set('showFeaturedList', false)->set('multiprofileArr', $multiprofileArr)->set('featuredList', $featuredList)->set('data', $resultRows)->set('isAdvanceSearch', true)->set('hasMultiprofile', $hasMultiprofile)->set('sortings', '')->set('pagination', $pagination)->set('filter', $filter)->set('featuredList', $featuredList)->set('isCommunityAdmin', COwnerHelper::isCommunityAdmin())->fetch('people.browse');
     }
     echo $searchForm;
 }
Example #29
0
 public function isWallsAllowed($photoId)
 {
     $photo = JTable::getInstance('Photo', 'CTable');
     $photo->load($photoId);
     $config = CFactory::getConfig();
     $isConnected = CFriendsHelper::isConnected($this->my->id, $photo->creator);
     $isMe = COwnerHelper::isMine($this->my->id, $photo->creator);
     // Check if user is really allowed to post walls on this photo.
     if ($isMe || !$config->get('lockphotoswalls') || $config->get('lockphotoswalls') && $isConnected || COwnerHelper::isCommunityAdmin()) {
         return true;
     }
     return false;
 }
    ?>
	</div>
	<div></div>
	<?php 
    echo JHTML::_('form.token');
    ?>
	</form>

	<div id="community-photo-items" class="photo-list-item" style="display:none">
		<div class="container"></div>
	</div>
	<br/>
	<div id="photoUploadedCounter" class="hints">
		<?php 
    if ($photoUploadLimit <= 0 || $photoUploadLimit > 0 && $photoUploaded / $photoUploadLimit >= COMMUNITY_SHOW_LIMIT) {
        if ($photoUploadLimit >= 0 && !COwnerHelper::isCommunityAdmin()) {
            echo JText::sprintf('COM_COMMUNITY_UPLOAD_LIMIT_STATUS', $photoUploaded, $photoUploadLimit);
        }
    }
    ?>
	</div>
	<?php 
    // This section only proceeds when user selects an album
    if (!empty($albumId) && $albumId != -1) {
        ?>
	<script type="text/javascript" language="javascript">
	joms.uploader.postUrl 		= '<?php 
        echo CRoute::_('index.php?option=com_community&view=photos&task=jsonupload&no_html=1&tmpl=component&defaultphoto=DEFAULT_PHOTOS&nextupload=NXUP&albumid=' . $albumId, false);
        ?>
';
	joms.uploader.uploadText	= '<?php