Example #1
1
 /**
  * Do a batch send
  */
 function send($total = 100)
 {
     $mailqModel = CFactory::getModel('mailq');
     $userModel = CFactory::getModel('user');
     $mails = $mailqModel->get($total);
     $jconfig = JFactory::getConfig();
     $mailer = JFactory::getMailer();
     $config = CFactory::getConfig();
     $senderEmail = $jconfig->getValue('mailfrom');
     $senderName = $jconfig->getValue('fromname');
     if (empty($mails)) {
         return;
     }
     CFactory::load('helpers', 'string');
     foreach ($mails as $row) {
         // @rule: only send emails that is valid.
         // @rule: make sure recipient is not blocked!
         $userid = $userModel->getUserFromEmail($row->recipient);
         $user = CFactory::getUser($userid);
         if (!$user->isBlocked() && !JString::stristr($row->recipient, 'foo.bar')) {
             $mailer->setSender(array($senderEmail, $senderName));
             $mailer->addRecipient($row->recipient);
             $mailer->setSubject($row->subject);
             $tmpl = new CTemplate();
             $raw = isset($row->params) ? $row->params : '';
             $params = new JParameter($row->params);
             $base = $config->get('htmlemail') ? 'email.html' : 'email.text';
             if ($config->get('htmlemail')) {
                 $row->body = JString::str_ireplace(array("\r\n", "\r", "\n"), '<br />', $row->body);
                 $mailer->IsHTML(true);
             } else {
                 //@rule: Some content might contain 'html' tags. Strip them out since this mail should never contain html tags.
                 $row->body = CStringHelper::escape(strip_tags($row->body));
             }
             $tmpl->set('content', $row->body);
             $tmpl->set('template', rtrim(JURI::root(), '/') . '/components/com_community/templates/' . $config->get('template'));
             $tmpl->set('sitename', $config->get('sitename'));
             $row->body = $tmpl->fetch($base);
             // Replace any occurences of custom variables within the braces scoe { }
             if (!empty($row->body)) {
                 preg_match_all("/{(.*?)}/", $row->body, $matches, PREG_SET_ORDER);
                 foreach ($matches as $val) {
                     $replaceWith = $params->get($val[1], null);
                     //if the replacement start with 'index.php', we can CRoute it
                     if (strpos($replaceWith, 'index.php') === 0) {
                         $replaceWith = CRoute::getExternalURL($replaceWith);
                     }
                     if (!is_null($replaceWith)) {
                         $row->body = JString::str_ireplace($val[0], $replaceWith, $row->body);
                     }
                 }
             }
             unset($tmpl);
             $mailer->setBody($row->body);
             $mailer->send();
         }
         $mailqModel->markSent($row->id);
         $mailer->ClearAllRecipients();
     }
 }
Example #2
0
 function getFieldHTML($field, $required)
 {
     $html = '';
     $selectedElement = 0;
     $class = $field->required == 1 ? ' required validate-custom-radio' : '';
     $elementSelected = 0;
     $elementCnt = 0;
     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;
     CFactory::load('helpers', 'string');
     $class = !empty($field->tips) ? 'jomTips tipRight' : '';
     $html .= '<div class="' . $class . '" style="display: inline-block;" title="' . JText::_($field->name) . '::' . CStringHelper::escape(JText::_($field->tips)) . '">';
     for ($i = 0; $i < count($field->options); $i++) {
         $option = $field->options[$i];
         $selected = $option == $field->value ? ' checked="checked"' : '';
         $html .= '<label class="lblradio-block">';
         $html .= '<input type="radio" name="field' . $field->id . '" value="' . $option . '"' . $selected . '  class="radio ' . $class . '" style="margin: 0 5px 0 0;" />';
         $html .= JText::_($option) . '</label>';
     }
     $html .= '<span id="errfield' . $field->id . 'msg" style="display: none;">&nbsp;</span>';
     $html .= '</div>';
     return $html;
 }
Example #3
0
 /**
  * Method is called during the status update triggers. 
  **/
 public function onProfileStatusUpdate($userid, $oldMessage, $newMessage)
 {
     $config = CFactory::getConfig();
     $my = CFactory::getUser();
     if ($config->get('fbconnectpoststatus')) {
         CFactory::load('libraries', 'facebook');
         $facebook = new CFacebook();
         if ($facebook) {
             $fbuserid = $facebook->getUser();
             $connectModel = CFactory::getModel('Connect');
             $connectTable =& JTable::getInstance('Connect', 'CTable');
             $connectTable->load($fbuserid);
             // Make sure the FB session match the user session
             if ($connectTable->userid == $my->id) {
                 /**
                  * Check post status to facebook settings
                  */
                 //echo "posting to facebook"; exit;
                 $targetUser = CFactory::getUser($my->id);
                 $userParams = $targetUser->getParams();
                 if ($userParams->get('postFacebookStatus')) {
                     $result = $facebook->postStatus($newMessage);
                     //print_r($result); exit;
                 }
             }
         }
     }
 }
 function deletegroupmembers($data)
 {
     require_once JPATH_SITE . '/components/com_community/libraries/core.php';
     CFactory::load('libraries', 'apps');
     $error_messages = array();
     $success_messages = array();
     $response = NULL;
     $validated = true;
     if ("" == $data['groupid'] || 0 == $data['groupid']) {
         $validated = false;
         $error_messages[] = array("id" => 1, "fieldname" => "groupid", "message" => "Groupid cannot be blank");
     }
     if (false == array_key_exists('memberids', $data) || 0 == sizeof($data['memberids'])) {
         $validated = false;
         $error_messages[] = array("id" => 1, "fieldname" => "memberids", "message" => "Memberids cannot be blank");
     }
     if (true == $validated) {
         $model =& CFactory::getModel('groups');
         $group =& JTable::getInstance('Group', 'CTable');
         $group->id = $data['groupid'];
         $group->ownerid = $data['ownerid'];
     }
     if ($data['ownerid'] == $data['memberids']) {
         $validated = false;
         $error_messages[] = array("id" => 1, "fieldname" => "ownerid/memberid", "message" => "owner id and member id are same.please update 'ownwrid or memberid' fields in request");
     } else {
         $groupMember =& JTable::getInstance('GroupMembers', 'CTable');
         $memberId = $data['memberids'];
         $groupId = $data['groupid'];
         $groupMember->load($memberId, $groupId);
         $data = new stdClass();
         $data->groupid = $groupId;
         $data->memberid = $memberId;
         $data = new stdClass();
         $data->groupid = $groupId;
         $data->memberid = $memberId;
         $model->removeMember($data);
         $db =& JFactory::getDBO();
         $query = 'SELECT COUNT(1) FROM ' . $db->nameQuote('#__community_groups_members') . ' ' . 'WHERE groupid=' . $db->Quote($groupId) . ' ' . 'AND approved=' . $db->Quote('1');
         $db->setQuery($query);
         $membercount = $db->loadResult();
         $members = new stdClass();
         $members->id = $groupId;
         $members->membercount = $membercount;
         $db->updateObject('#__community_groups', $members, 'id');
         //add user points
         CFactory::load('libraries', 'userpoints');
         CUserPoints::assignPoint('group.member.remove', $memberId);
     }
     if (true == isset($error_messages) && 0 < sizeof($error_messages)) {
         $res = array();
         foreach ($error_messages as $key => $error_message) {
             $res[] = $error_message;
         }
         $response = array("id" => 0, 'errors' => $res);
     } else {
         $response = array('id' => $memberId);
     }
     return $response;
 }
Example #5
0
	public function __construct() {
		$this->integration = KunenaIntegration::getInstance ('jomsocial');
		if (! $this->integration || ! $this->integration->isLoaded())
			return;
		CFactory::load('libraries', 'messaging');
		$this->priority = 40;
	}
Example #6
0
 function export($event)
 {
     CFactory::load('helpers', 'event');
     $handler = CEventHelper::getHandler($event);
     if (!$handler->showExport()) {
         echo JText::_('CC ACCESS FORBIDDEN');
         return;
     }
     header('Content-type: text/Calendar');
     header('Content-Disposition: attachment; filename="calendar.ics"');
     $creator = CFactory::getUser($event->creator);
     $offset = $creator->getUtcOffset();
     $date = new JDate($event->startdate);
     $dtstart = $date->toFormat('%Y%m%dT%H%M%S');
     $date = new JDate($event->enddate);
     $dtend = $date->toFormat('%Y%m%dT%H%M%S');
     $url = $handler->getFormattedLink('index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id, false, true);
     $tmpl = new CTemplate();
     $tmpl->set('dtstart', $dtstart);
     $tmpl->set('dtend', $dtend);
     $tmpl->set('url', $url);
     $tmpl->set('event', $event);
     $raw = $tmpl->fetch('events.ical');
     unset($tmpl);
     echo $raw;
     exit;
 }
Example #7
0
 public function showGroupMiniHeader($groupId)
 {
     CMiniHeader::load();
     $option = JRequest::getVar('option', '', 'REQUEST');
     JFactory::getLanguage()->load('com_community');
     CFactory::load('models', 'groups');
     $group =& JTable::getInstance('Group', 'CTable');
     $group->load($groupId);
     $my = CFactory::getUser();
     // @rule: Test if the group is unpublished, don't display it at all.
     if (!$group->published) {
         return '';
     }
     if (!empty($group->id) && $group->id != 0) {
         $isMember = $group->isMember($my->id);
         $config = CFactory::getConfig();
         $tmpl = new CTemplate();
         $tmpl->set('my', $my);
         $tmpl->set('group', $group);
         $tmpl->set('isMember', $isMember);
         $tmpl->set('config', $config);
         $showMiniHeader = $option == 'com_community' ? $tmpl->fetch('groups.miniheader') : '<div id="community-wrap" style="min-height:50px;">' . $tmpl->fetch('groups.miniheader') . '</div>';
         return $showMiniHeader;
     }
 }
Example #8
0
 public function _buildQuery()
 {
     $db =& JFactory::getDBO();
     $actor = JRequest::getVar('actor', '');
     $archived = JRequest::getInt('archived', 0);
     $app = JRequest::getVar('app', 'none');
     $where = array();
     CFactory::load('helpers', 'user');
     $userId = cGetUserId($actor);
     if ($userId != 0) {
         $where[] = 'actor=' . $db->Quote($userId) . ' ';
     }
     if ($archived != 0) {
         $archived = $archived - 1;
         $where[] = 'archived=' . $db->Quote($archived) . ' ';
     }
     if ($app != 'none') {
         $where[] = 'app=' . $db->Quote($app);
     }
     $query = 'SELECT * FROM ' . $db->nameQuote('#__community_activities');
     if (!empty($where)) {
         for ($i = 0; $i < count($where); $i++) {
             if ($i == 0) {
                 $query .= ' WHERE ';
             } else {
                 $query .= ' AND ';
             }
             $query .= $where[$i];
         }
     }
     $query .= ' ORDER BY created DESC';
     return $query;
 }
Example #9
0
 /**
  * The default method that will display the output of this view which is called by
  * Joomla
  * 
  * @param	string template	Template file name
  **/
 public function display($tpl = null)
 {
     $document = JFactory::getDocument();
     $config =& CFactory::getConfig();
     // Get required data's
     $events = $this->get('Events');
     $categories = $this->get('Categories');
     $pagination = $this->get('Pagination');
     $mainframe =& JFactory::getApplication();
     $filter_order = $mainframe->getUserStateFromRequest("com_community.events.filter_order", 'filter_order', 'a.title', 'cmd');
     $filter_order_Dir = $mainframe->getUserStateFromRequest("com_community.events.filter_order_Dir", 'filter_order_Dir', '', 'word');
     $search = $mainframe->getUserStateFromRequest("com_community.events.search", 'search', '', 'string');
     // table ordering
     $lists['order_Dir'] = $filter_order_Dir;
     $lists['order'] = $filter_order;
     // We need to assign the users object to the groups listing to get the users name.
     for ($i = 0; $i < count($events); $i++) {
         $row =& $events[$i];
         $row->user = JFactory::getUser($row->creator);
         // Truncate the description
         CFactory::load('helpers', 'string');
         $row->description = CStringHelper::truncate($row->description, $config->get('tips_desc_length'));
     }
     $catHTML = $this->_getCategoriesHTML($categories);
     $this->assignRef('events', $events);
     $this->assignRef('categories', $catHTML);
     $this->assignRef('search', $search);
     $this->assignRef('lists', $lists);
     $this->assignRef('pagination', $pagination);
     parent::display($tpl);
 }
Example #10
0
 function onAfterVote($poll, $option_id)
 {
     $user =& JFactory::getUser();
     $points = JPATH_ROOT . '/components/com_community/libraries/core.php';
     $activity = JPATH_ROOT . '/components/com_community/libraries/core.php';
     if ($this->params->get('points', '0') == '1' && file_exists($points)) {
         require_once $points;
         CUserPoints::assignPoint('com_acepolls.vote');
     }
     if ($this->params->get('activity', '0') == '1' && file_exists($activity)) {
         require_once $activity;
         $text = JText::_('COM_ACEPOLLS_ACTIVITY_TEXT');
         $link = JRoute::_('index.php?option=com_acepolls&amp;view=poll&amp;id=' . $poll->id . ":" . $poll->alias . self::getItemid($poll->id));
         $act = new stdClass();
         $act->cmd = 'wall.write';
         $act->actor = $user->id;
         $act->target = 0;
         $act->title = JText::_('{actor} ' . $text . ' <a href="' . $link . '">' . $poll->title . '</a>');
         $act->content = '';
         $act->app = 'wall';
         $act->cid = 0;
         CFactory::load('libraries', 'activities');
         CActivityStream::add($act);
     }
 }
Example #11
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 #12
0
 function onProfileCreate($user)
 {
     // Upon registering, users should get 4 default photo albums:
     // Fiskeplasser, Fangstrapporter, Turer, and Klekker (Spots/Catches/Trips/Hatches)
     $config = CFactory::getConfig();
     CFactory::load('models', 'photos');
     $albumNames = array('Fiskeplasser', 'Fangstrapporter', 'Turer', 'Klekker');
     foreach ($albumNames as $album_name) {
         $album =& JTable::getInstance('Album', 'CTable');
         $album->creator = $user->id;
         $album->name = $album_name;
         $album->description = "";
         $album->type = "user";
         $album->created = gmdate('Y-m-d H:i:s');
         $params = $user->getParams();
         $album->permissions = $params->get('privacyPhotoView');
         $album->permanent = 1;
         // don't let users delete default albums
         $storage = JPATH_ROOT . DS . $config->getString('photofolder');
         $albumPath = $storage . DS . 'photos' . DS . $user->id . DS;
         $albumPath = JString::str_ireplace(JPATH_ROOT . DS, '', $albumPath);
         $albumPath = JString::str_ireplace('\\', '/', $albumPath);
         $album->path = $albumPath;
         $album->store();
     }
 }
Example #13
0
 function add($actor, $target, $title, $content, $appname = '', $cid = 0, $params = '', $points = 1, $access = 0)
 {
     jimport('joomla.utilities.date');
     $db =& $this->getDBO();
     $today =& JFactory::getDate();
     $obj = new StdClass();
     $obj->actor = $actor;
     $obj->target = $target;
     $obj->title = $title;
     $obj->content = $content;
     $obj->app = $appname;
     $obj->cid = $cid;
     $obj->params = $params;
     $obj->created = $today->toMySQL();
     $obj->points = $points;
     $obj->access = $access;
     // Trigger for onBeforeStreamCreate event.
     CFactory::load('libraries', 'apps');
     $appsLib =& CAppPlugins::getInstance();
     $appsLib->loadApplications();
     $params = array();
     $params[] =& $obj;
     $result = $appsLib->triggerEvent('onBeforeStreamCreate', $params);
     if (in_array(true, $result) || empty($result)) {
         return $db->insertObject('#__community_activities', $obj);
     }
     return false;
 }
Example #14
0
 /**
  * This method should handle any login logic and report back to the subject
  *
  * @access	public
  * @param 	array 	holds the user data
  * @param 	array    extra options
  * @return	boolean	True on success
  * @since	1.5
  */
 function onLoginUser($user, $options)
 {
     CFactory::load('helpers', 'user');
     $id = cGetUserId($user['username']);
     CFactory::setActiveProfile($id);
     return true;
 }
Example #15
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 #16
0
 /**
  * Adds a notification item in JomSocial
  *
  * @access	public
  * @param 	TableBlog	$blog 	The blog table.
  */
 public function addNotification($title, $type, $target, $author, $link)
 {
     jimport('joomla.filesystem.file');
     // @since this only works with JomSocial 2.6, we need to test certain files.
     $file = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'notificationtypes.php';
     if (!$this->exists || empty($target) || $target[0] == $author->getId() || !JFile::exists($file)) {
         return false;
     }
     CFactory::load('helpers', 'notificationtypes');
     CFactory::load('helpers', 'content');
     CFactory::load('libraries', 'notificationtypes');
     // @task: Set the necessary parameters first.
     $params = EasyBlogHelper::getRegistry('');
     $params->set('url', str_replace("administrator/", "", $author->getProfileLink()));
     // @task: Obtain model from jomsocial.
     $model = CFactory::getModel('Notification');
     // @task: Currently we are not using this, so we should just skip this.
     $requireAction = 0;
     if (!is_array($target)) {
         $target = array($target);
     }
     foreach ($target as $targetId) {
         JTable::addIncludePath(JPATH_ROOT . '/components/com_community/tables');
         $notification = JTable::getInstance('Notification', 'CTable');
         $notification->actor = $author->getId();
         $notification->target = $targetId;
         $notification->content = $title;
         $notification->created = EasyBlogHelper::getDate()->toMySQL();
         $notification->params = $params->toString();
         $notification->cmd_type = CNotificationTypesHelper::convertNotifId($type);
         $notification->type = 0;
         $notification->store();
     }
     return true;
 }
Example #17
0
 /**
  * remove friend
  */
 public function removeFriend($friendid)
 {
     $mainframe =& JFactory::getApplication();
     $model = CFactory::getModel('friends');
     $my = CFactory::getUser();
     $viewName = JRequest::getVar('view', '', 'GET');
     $view = CFactory::getView($viewName);
     if ($model->deleteFriend($my->id, $friendid)) {
         // Substract the friend count
         $model->updateFriendCount($my->id);
         $model->updateFriendCount($friendid);
         //add user points
         // we deduct poinst to both parties
         CFactory::load('libraries', 'userpoints');
         CUserPoints::assignPoint('friends.remove');
         CUserPoints::assignPoint('friends.remove', $friendid);
         $friend = CFactory::getUser($friendId);
         $view->addInfo(JText::sprintf('COM_COMMUNITY_FRIENDS_REMOVED', $friend->getDisplayName()));
         //@todo notify friend after remove them from our friend list
         //trigger for onFriendRemove
         $eventObject = new stdClass();
         $eventObject->profileOwnerId = $my->id;
         $eventObject->friendId = $friendid;
         $this->_triggerFriendEvents('onFriendRemove', $eventObject);
         unset($eventObject);
     } else {
         $view->addinfo(JText::_('COM_COMMUNITY_FRIENDS_REMOVING_FRIEND_ERROR'));
     }
 }
Example #18
0
    public function getFieldHTML($field, $required)
    {
        $class = $field->required == 1 ? ' required' : '';
        $class .= !empty($field->tips) ? ' jomNameTips tipRight' : '';
        $lists = explode(',', $field->value);
        CFactory::load('helpers', 'string');
        $html = '<select id="field' . $field->id . '" name="field' . $field->id . '[]" type="select-multiple" multiple="multiple" class="jomNameTips tipRight select' . $class . '" title="' . CStringHelper::escape(JText::_($field->tips)) . '">';
        $elementSelected = 0;
        foreach ($field->options as $option) {
            $selected = in_array($option, $lists) ? ' selected="selected"' : '';
            if (empty($selected)) {
                $elementSelected++;
            }
            $html .= '<option value="' . $option . '"' . $selected . '>' . JText::_($option) . '</option>';
        }
        if ($elementSelected == 0) {
            //if nothing is selected, we default the 1st option to be selected.
            $elementName = 'field' . $field->id;
            $html .= <<<HTML
\t\t\t\t   
\t\t\t\t   <script type='text/javascript'>
\t\t\t\t\t   var slt = document.getElementById('{$elementName}');
\t\t\t\t\t   if(slt != null){
\t\t\t\t\t      slt.options[0].selected = true;\t\t\t\t\t       
\t\t\t\t\t   }
\t\t\t\t   </script>
HTML;
        }
        $html .= '</select>';
        $html .= '<span id="errfield' . $field->id . 'msg" style="display:none;">&nbsp;</span>';
        return $html;
    }
Example #19
0
 public function getFieldHTML($field, $required)
 {
     $class = $field->required == 1 ? ' required validate-custom-checkbox' : '';
     $lists = is_array($field->value) ? $field->value : explode(',', $field->value);
     $html = '';
     $elementSelected = 0;
     $elementCnt = 0;
     $style = ' style="margin: 0 5px 5px 0;' . $this->getStyle() . '" ';
     $cnt = 0;
     CFactory::load('helpers', 'string');
     $class .= !empty($field->tips) ? ' jomNameTips tipRight' : '';
     $html .= '<div class="' . $class . '" style="display: inline-block;" title="' . CStringHelper::escape(JText::_($field->tips)) . '">';
     if (is_array($field->options)) {
         foreach ($field->options as $option) {
             $selected = in_array(JString::trim($option), $lists) ? ' checked="checked"' : '';
             if (empty($selected)) {
                 $elementSelected++;
             }
             $html .= '<label class="lblradio-block">';
             $html .= '<input type="checkbox" name="field' . $field->id . '[]" value="' . $option . '"' . $selected . ' class="checkbox ' . $class . $style . ' />';
             $html .= JText::_($option) . '</label>';
             $elementCnt++;
         }
     }
     $html .= '<span id="errfield' . $field->id . 'msg" style="display: none;">&nbsp;</span>';
     $html .= '</div>';
     return $html;
 }
Example #20
0
 /**
  * The default method that will display the output of this view which is called by
  * Joomla
  * 
  * @param	string template	Template file name
  **/
 public function display($tpl = null)
 {
     $mainframe = JFactory::getApplication();
     $filter_order = $mainframe->getUserStateFromRequest("com_community.eventcategories.filter_order", 'filter_order', 'name', 'cmd');
     $filter_order_Dir = $mainframe->getUserStateFromRequest("com_community.eventcategories.filter_order_Dir", 'filter_order_Dir', '', 'word');
     // table ordering
     $lists['order_Dir'] = $filter_order_Dir;
     $lists['order'] = $filter_order;
     $categories = $this->get('Categories');
     $pagination = $this->get('Pagination');
     $catCount = $this->get('CategoriesCount');
     // Escape the output
     CFactory::load('helpers', 'string');
     foreach ($categories as $row) {
         $row->name = CStringHelper::escape($row->name);
         $row->description = CStringHelper::escape($row->description);
         if ($row->parent == 0) {
             $row->pname = JText::_("COM_COMMUNITY_NO_PARENT");
         } else {
             $parent =& JTable::getInstance('eventcategories', 'CommunityTable');
             $parent->load($row->parent);
             $row->pname = CStringHelper::escape($parent->name);
         }
     }
     $this->assignRef('lists', $lists);
     $this->assignRef('categories', $categories);
     $this->assignRef('catCount', $catCount);
     $this->assignRef('pagination', $pagination);
     parent::display($tpl);
 }
Example #21
0
 /**
  * Browse all available apps
  */
 public function browse($data)
 {
     $this->addPathway(JText::_('COM_COMMUNITY_APPS_BROWSE'));
     // Load window library
     CFactory::load('libraries', 'window');
     // Load necessary window css / javascript headers.
     CWindow::load();
     $mainframe =& JFactory::getApplication();
     $my = CFactory::getUser();
     $pathway =& $mainframe->getPathway();
     $document = JFactory::getDocument();
     $document->setTitle(JText::_('COM_COMMUNITY_APPS_BROWSE'));
     // Attach apps-related js
     $this->showSubMenu();
     // Get application's favicon
     $addedAppCount = 0;
     foreach ($data->applications as $appData) {
         if (JFile::exists(CPluginHelper::getPluginPath('community', $appData->name) . DS . $appData->name . DS . 'favicon_64.png')) {
             $appData->appFavicon = rtrim(JURI::root(), '/') . CPluginHelper::getPluginURI('community', $appData->name) . '/' . $appData->name . '/favicon_64.png';
         } else {
             $appData->appFavicon = rtrim(JURI::root(), '/') . '/components/com_community/assets/app_favicon.png';
         }
         // Get total added applications
         $addedAppCount = $appData->added == 1 ? $addedAppCount + 1 : $addedAppCount;
     }
     $tmpl = new CTemplate();
     echo $tmpl->set('applications', $data->applications)->set('pagination', $data->pagination)->set('addedAppCount', $addedAppCount)->fetch('applications.browse');
 }
 function deletewallpost($data)
 {
     require_once JPATH_SITE . '/components/com_community/libraries/core.php';
     $error_messages = array();
     $response = NULL;
     $validated = true;
     $db =& JFactory::getDBO();
     if ($data['wall_id'] == "" || $data['wall_id'] == "0") {
         $validated = false;
         $error_messages[] = array("id" => 1, "fieldname" => "wallid", "message" => "Wall id cannot be blank");
     }
     //@rule: Check if user is really allowed to remove the current wall
     $my = CFactory::getUser();
     $model =& CFactory::getModel('wall');
     $wall = $model->get($data['wall_id']);
     $groupModel =& CFactory::getModel('groups');
     $group =& JTable::getInstance('Group', 'CTable');
     $group->load($wall->contentid);
     $query = "SELECT contentid FROM #__community_wall WHERE id ='" . $data['wall_id'] . "' AND type = 'groups'";
     $db->setQuery($query);
     $contentid = $db->LoadResult();
     CFactory::load('helpers', 'owner');
     $query = "SELECT id FROM #__community_wall WHERE id ='" . $data['wall_id'] . "' AND type = 'groups'";
     $db->setQuery($query);
     $isdiscussion = $db->LoadResult();
     if (!$isdiscussion) {
         $error_messages[] = array("id" => 1, "fieldname" => "wallid", "message" => "wall id for type groups does not exists. Modify the wall_id field");
     } else {
         if (!$model->deletePost($data['wall_id'])) {
             $validated = false;
             //$error_messages[] = 'wall id does not exists. Modify the wall_id fields in request';
             $error_messages[] = array("id" => 1, "fieldname" => "wallid", "message" => "wall id does not exists. Modify the wall_id field");
         } else {
             if ($wall->post_by != 0) {
                 //add user points
                 CFactory::load('libraries', 'userpoints');
                 CUserPoints::assignPoint('wall.remove', $wall->post_by);
             }
         }
         //$groupModel->substractWallCount( $data['wall_id'] );
         // Substract the count
         $query = 'SELECT COUNT(*) FROM ' . $db->nameQuote('#__community_wall') . ' ' . 'WHERE contentid=' . $db->Quote($contentid) . ' ' . 'AND type="groups"';
         $db->setQuery($query);
         $wall_count = $db->loadResult();
         $wallcount = new stdClass();
         $wallcount->id = $contentid;
         $wallcount->wallcount = $wall_count;
         $db->updateObject('#__community_groups', $wallcount, 'id');
     }
     if (true == isset($error_messages) && 0 < sizeof($error_messages)) {
         $res = array();
         foreach ($error_messages as $key => $error_message) {
             $res[] = $error_message;
         }
         $response = array("id" => 0, 'errors' => $res);
     } else {
         $response = array('id' => $wall->id);
     }
     return $response;
 }
Example #23
0
 function display($data = null)
 {
     $mainframe = JFactory::getApplication();
     $config = CFactory::getConfig();
     $document =& JFactory::getDocument();
     $document->setTitle(JText::sprintf('CC FRONTPAGE TITLE', $config->get('sitename')));
     $document->setLink(CRoute::_('index.php?option=com_community'));
     $my = CFactory::getUser();
     CFactory::load('libraries', 'activities');
     CFactory::load('helpers', 'string');
     $act = new CActivityStream();
     $rows = $act->getFEED('', '', null, $mainframe->getCfg('feed_limit'));
     if ($config->get('showactivitystream') == COMMUNITY_SHOW || $config->get('showactivitystream') == COMMUNITY_MEMBERS_ONLY && $my->id != 0) {
         foreach ($rows->data as $row) {
             if ($row->type != 'title') {
                 // load individual item creator class
                 $item = new JFeedItem();
                 // cannot escape the title. it's already formated. we should
                 // escape it during CActivityStream::add
                 //$item->title 		= CStringHelper::escape($row->title);
                 $item->title = $row->title;
                 $item->link = CRoute::_('index.php?option=com_community&view=profile&userid=' . $row->actor);
                 $item->description = "<img src=\"{$row->favicon}\" alt=\"\"/>&nbsp;" . $row->title;
                 $item->date = $row->createdDate;
                 $item->category = '';
                 //$row->category;
                 // Make sure url is absolute
                 $item->description = JString::str_ireplace('href="/', 'href="' . JURI::base(), $item->description);
                 // loads item info into rss array
                 $document->addItem($item);
             }
         }
     }
 }
Example #24
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 #25
0
 public function ajaxInvite()
 {
     CFactory::load('libraries', 'facebook');
     $facebook = new CFacebook();
     $config = CFactory::getConfig();
     $tmpl = new CTemplate();
     echo $tmpl->set('facebook', $facebook)->set('config', $config)->set('sitename', $config->get('sitename'))->fetch('facebook.inviteframe');
 }
Example #26
0
 private function _updateGroupStats()
 {
     CFactory::load('models', 'groups');
     $group =& JTable::getInstance('Group', 'CTable');
     $group->load($this->groupid);
     $group->updateStats();
     $group->store();
 }
Example #27
0
 public function getFieldHTML($field, $required)
 {
     CFactory::load('helpers', 'string');
     $class = !empty($field->tips) ? ' jomNameTips tipRight' : '';
     $html = '<textarea title="' . CStringHelper::escape(JText::_($field->tips)) . '" id="field' . $field->id . '" name="field' . $field->id . '"  class="textarea inputbox' . $class . '" cols="20" rows="5" readonly="readonly">' . CStringHelper::escape($field->tips) . '</textarea>';
     $html .= '<span id="errfield' . $field->id . 'msg" style="display:none;">&nbsp;</span>';
     return $html;
 }
Example #28
0
 /**
  * Displays the viewing profile page.
  * 	 	
  * @access	public
  * @param	array  An associative array to display the fields
  */
 public function profile(&$data)
 {
     $mainframe = JFactory::getApplication();
     $friendsModel = CFactory::getModel('friends');
     $showfriends = JRequest::getVar('showfriends', false);
     $userid = JRequest::getVar('userid', '');
     $user = CFactory::getUser($userid);
     $linkUrl = CRoute::_('index.php?option=com_community&view=profile&userid=' . $user->id);
     $document = JFactory::getDocument();
     $document->setTitle(JText::sprintf('COM_COMMUNITY_USERS_FEED_TITLE', $user->getDisplayName()));
     $document->setDescription(JText::sprintf('COM_COMMUNITY_USERS_FEED_DESCRIPTION', $user->getDisplayName(), $user->lastvisitDate));
     $document->setLink($linkUrl);
     include_once JPATH_COMPONENT . DS . 'libraries' . DS . 'activities.php';
     $act = new CActivityStream();
     $friendIds = $friendsModel->getFriendIds($user->id);
     $friendIds = $showfriends ? $friendIds : null;
     $rows = $act->getFEED($user->id, $friendIds, null, $mainframe->getCfg('feed_limit'));
     // add the avatar image
     $rssImage = new JFeedImage();
     $rssImage->url = $user->getThumbAvatar();
     $rssImage->link = $linkUrl;
     $rssImage->width = 64;
     $rssImage->height = 64;
     $document->image = $rssImage;
     CFactory::load('helpers', 'string');
     CFactory::load('helpers', 'time');
     foreach ($rows->data as $row) {
         if ($row->type != 'title') {
             // Get activities link
             $pattern = '/<a href=\\"(.*?)\\"/';
             preg_match_all($pattern, $row->title, $matches);
             // Use activity owner link when activity link is not available
             if (!empty($matches[1][1])) {
                 $linkUrl = $matches[1][1];
             } else {
                 if (!empty($matches[1][0])) {
                     $linkUrl = $matches[1][0];
                 }
             }
             // load individual item creator class
             $item = new JFeedItem();
             $item->title = $row->title;
             $item->link = $linkUrl;
             $item->description = "<img src=\"{$row->favicon}\" alt=\"\" />&nbsp;" . $row->title;
             $item->date = CTimeHelper::getDate($row->createdDateRaw)->toRFC822();
             $item->category = '';
             //$row->category;
             $item->description = CString::str_ireplace('_QQQ_', '"', $item->description);
             // Make sure url is absolute
             $pattern = '/href="(.*?)index.php/';
             $replace = 'href="' . JURI::base() . 'index.php';
             $string = $item->description;
             $item->description = preg_replace($pattern, $replace, $string);
             // loads item info into rss array
             $document->addItem($item);
         }
     }
 }
Example #29
0
 public static function showMiniHeader($userId)
 {
     CMiniHeader::load();
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     JFactory::getLanguage()->load('com_community');
     $option = $jinput->get('option', '', 'STRING');
     //JRequest::getVar('option', '' , 'REQUEST');
     $my = CFactory::getUser();
     $config = CFactory::getConfig();
     if (!empty($userId)) {
         $user = CFactory::getUser($userId);
         $params = $user->getParams();
         //links information
         $photoEnabled = $config->get('enablephotos') ? true : false;
         $eventEnabled = $config->get('enableevents') ? true : false;
         $groupEnabled = $config->get('enablegroups') ? true : false;
         $videoEnabled = $config->get('enablevideos') ? true : false;
         //likes
         CFactory::load('libraries', 'like');
         $like = new Clike();
         $isLikeEnabled = $like->enabled('profile') && $params->get('profileLikes', 1) ? 1 : 0;
         $isUserLiked = $like->userLiked('profile', $user->id, $my->id);
         /* likes count */
         $likes = $like->getLikeCount('profile', $user->id);
         //profile
         $profileModel = CFactory::getModel('profile');
         $profile = $profileModel->getViewableProfile($user->id, $user->getProfileType());
         $profile = JArrayHelper::toObject($profile);
         $profile->largeAvatar = $user->getAvatar();
         $profile->defaultAvatar = $user->isDefaultAvatar();
         $profile->status = $user->getStatus();
         $profile->defaultCover = $user->isDefaultCover();
         $profile->cover = $user->getCover();
         $profile->coverPostion = $params->get('coverPosition', '');
         if (strpos($profile->coverPostion, '%') === false) {
             $profile->coverPostion = 0;
         }
         $groupmodel = CFactory::getModel('groups');
         $profile->_groups = $groupmodel->getGroupsCount($profile->id);
         $eventmodel = CFactory::getModel('events');
         $profile->_events = $eventmodel->getEventsCount($profile->id);
         $profile->_friends = $user->_friendcount;
         $videoModel = CFactory::getModel('Videos');
         $profile->_videos = $videoModel->getVideosCount($profile->id);
         $photosModel = CFactory::getModel('photos');
         $profile->_photos = $photosModel->getPhotosCount($profile->id);
         /* is featured */
         $modelFeatured = CFactory::getModel('Featured');
         $profile->featured = $modelFeatured->isExists(FEATURED_USERS, $profile->id);
         $sendMsg = CMessaging::getPopup($user->id);
         $tmpl = new CTemplate();
         $tmpl->set('my', $my)->set('user', $user)->set('isBlocked', $user->isBlocked())->set('isMine', COwnerHelper::isMine($my->id, $user->id))->set('sendMsg', $sendMsg)->set('config', $config)->set('isWaitingApproval', CFriendsHelper::isWaitingApproval($my->id, $user->id))->set('isLikeEnabled', $isLikeEnabled)->set('photoEnabled', $photoEnabled)->set('eventEnabled', $eventEnabled)->set('groupEnabled', $groupEnabled)->set('videoEnabled', $videoEnabled)->set('profile', $profile)->set('isUserLiked', $isUserLiked)->set('likes', $likes)->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;
     }
 }
Example #30
0
 public function onMessageDisplay($row)
 {
     CFactory::load('helpers', 'string');
     CError::assert($row->body, '', '!empty', __FILE__, __LINE__);
     // @rule: Only nl2br text that doesn't contain html tags
     if (!CStringHelper::isHTML($row->body)) {
         $row->body = CStringHelper::nl2br($row->body);
     }
 }