public function removeActivity($app, $uniqueId) { $db = $this->getDBO(); /* * @todo add in additional info if needed * when removing photo app, we need to remove the likes and comments as well */ $additionalQuery = ''; switch ($app) { case 'photos': //before we remove anything, lets check if this photo is included in the params of activity // that might be more than one photo $db->setQuery("SELECT albumid FROM " . $db->quoteName('#__community_photos') . " WHERE id=" . $db->quote($uniqueId)); $albumId = $db->loadResult(); $db->setQuery("SELECT id, params FROM " . $db->quoteName('#__community_activities') . " WHERE " . $db->quoteName('app') . '=' . $db->Quote($app) . " AND " . $db->quoteName('cid') . '=' . $db->Quote($uniqueId)); $activities = $db->loadObjectList(); if (count($activities) == 0) { return; } //search through the parameters of the activities foreach ($activities as $activity) { $params = new CParameter($activity->params); $photoIds = $params->get('photosId'); $photoIds = explode(',', $photoIds); if (in_array($uniqueId, $photoIds)) { if (count($photoIds) > 1) { //do not delete this activities as there is another photo associated with this activity if (($key = array_search($uniqueId, $photoIds)) !== false) { unset($photoIds[$key]); } $params->set('photosId', implode(',', $photoIds)); $activityTable = JTable::getInstance('Activity', 'CTable'); $activityTable->load($uniqueId); //just update the activity will do $activityTable->params = $params->toString(); $activityTable->store(); } else { // just delete the activity $db->setQuery("DELETE FROM " . $db->quoteName('#__community_activities') . " WHERE " . $db->quoteName('id') . ' = ' . $db->quote($activity->id)); $db->execute(); } } } return; //return as the additional steps are not needed //we should remove the likes and comments <-- we should reaccess this query $additionalQuery = '(' . $db->quoteName('app') . '=' . $db->Quote($app) . ' OR ' . $db->quoteName('app') . '=' . $db->Quote('photos.comment') . ' OR ' . $db->quoteName('app') . '=' . $db->Quote('album.like') . ' OR ' . $db->quoteName('app') . '=' . $db->Quote('profile.avatar.upload') . ' OR ' . $db->quoteName('app') . '=' . $db->Quote('photo.like') . ')'; break; case 'videos': $additionalQuery = '(' . $db->quoteName('app') . '=' . $db->Quote($app) . ' OR ' . $db->quoteName('app') . '=' . $db->Quote('videos.linking') . ' OR ' . $db->quoteName('app') . '=' . $db->Quote('videos.comment') . ' OR ' . $db->quoteName('app') . '=' . $db->Quote('videos.like') . ')'; break; case 'albums': $additionalQuery = $db->quoteName('app') . ' like' . $db->Quote('%' . $app . '%'); break; default: // this is the default state $additionalQuery = $db->quoteName('app') . '=' . $db->Quote($app); } $query = 'DELETE FROM ' . $db->quoteName('#__community_activities') . ' ' . 'WHERE ' . $additionalQuery . ' ' . 'AND ' . $db->quoteName('cid') . '=' . $db->Quote($uniqueId); $db->setQuery($query); $status = $db->query(); if ($db->getErrorNum()) { JError::raiseError(500, $db->stderr()); } return $status; }
private function _createPhotoUploadStream($album, $jsonObj) { $obj = json_decode($jsonObj); $photoIds = array(); $batchcount = count($obj->files); foreach ($obj->files as $file) { $photoIds[] = $file->photoId; } $photoTable = JTable::getInstance('Photo', 'cTable'); $photoTable->load($photoIds[count($photoIds) - 1]); $my = CFactory::getUser(); $handler = $this->_getHandler($album); // Generate activity stream $act = new stdClass(); $act->cmd = 'photo.upload'; $act->actor = $my->id; $act->access = $album->permissions; $act->target = 0; $act->title = ''; // Empty title, auto-generated by stream $act->content = ''; // Gegenerated automatically by stream. No need to add anything $act->app = 'photos'; $act->cid = $album->id; $act->location = $album->location; // Store group info // I hate to load group here, but unfortunately, album does // not store group permission setting $group = JTable::getInstance('Group', 'CTable'); $group->load($album->groupid); $act->groupid = $album->groupid; $act->group_access = $group->approvals; // Allow comment on the album $act->comment_type = 'photos'; $act->comment_id = $photoTable->id; // Allow like on the album $act->like_type = 'photo'; $act->like_id = $photoTable->id; $params = new CParameter(''); $params->set('multiUrl', $handler->getAlbumURI($album->id, false)); $params->set('photoid', $photoTable->id); $params->set('action', 'upload'); $params->set('photo_url', $photoTable->getThumbURI()); $params->set('style', COMMUNITY_STREAM_STYLE); // Get the upload count per session $session = JFactory::getSession(); $uploadSessionCount = $session->get('album-' . $album->id . '-upload', 0); $params->set('count', $uploadSessionCount); $params->set('batchcount', $batchcount); $params->set('photosId', implode(',', $photoIds)); // Add activity logging CActivityStream::add($act, $params->toString()); }
/** * @param $uniqueId * @param $message * @param $appType * @param $creator * @param $isOwner * @param string $processFunc * @param string $templateFile * @param int $wallId * @param int $photoId to attach photoid in the wall if exists * @return stdClass */ public static function saveWall($uniqueId, $message, $appType, &$creator, $isOwner, $processFunc = '', $templateFile = 'wall/content', $wallId = 0, $photoId = 0) { $my = CFactory::getUser(); // Add some required parameters, otherwise assert here CError::assert($uniqueId, '', '!empty', __FILE__, __LINE__); CError::assert($appType, '', '!empty', __FILE__, __LINE__); CError::assert($my->id, '', '!empty', __FILE__, __LINE__); // Load the models $wall = JTable::getInstance('Wall', 'CTable'); $wall->load($wallId); if ($wallId == 0) { // Get current date $now = JFactory::getDate(); $now = $now->toSql(); // Set the wall properties $wall->type = $appType; $wall->contentid = $uniqueId; $wall->post_by = $creator->id; $wall->date = $now; $wall->published = 1; // @todo: set the ip address $wall->ip = $_SERVER['REMOTE_ADDR']; } //if photo id is not 0, this wall is appended with a picture if ($photoId > 0) { //lets check if the photo belongs to the uploader $photo = JTable::getInstance('Photo', 'CTable'); $photo->load($photoId); //save the data into the wall table $wallParam = new CParameter($wall->params); if ($photo->creator == $my->id && $photo->albumid == '-1') { $wallParam->set('attached_photo_id', $photoId); //sets the status to ready so that it wont be deleted on cron run $photo->status = 'ready'; $photo->store(); } $wall->params = $wallParam->toString(); } elseif ($photoId == -1) { //if there is nothing, remove the param if applicable $wallParam = new CParameter($wall->params); //delete from db and files $photoModel = CFactory::getModel('photos'); if ($wallParam->get('attached_photo_id') > 0) { $photoTable = $photoModel->getPhoto($wallParam->get('attached_photo_id')); $photoTable->delete(); } $wallParam->set('attached_photo_id', 0); $wall->params = $wallParam->toString(); } /* URL fetch */ $graphObject = CParsers::linkFetch($message); if ($graphObject) { $graphObject->merge(new CParameter($wall->params)); $wall->params = $graphObject->toString(); } $wall->comment = $message; // Store the wall message $wall->store(); // Convert it to array so that the walls can be processed by plugins $args = array(); $args[0] = $wall; //Process wall comments $comment = new CComment(); $wallComments = $wall->comment; $wall->comment = $comment->stripCommentData($wall->comment); // Trigger the wall comments CWall::triggerWallComments($args); $wallData = new stdClass(); $wallData->id = $wall->id; $wallData->content = CWallLibrary::_getWallHTML($wall, $wallComments, $appType, $isOwner, $processFunc, $templateFile); $wallData->content = CStringHelper::replaceThumbnails($wallData->content); CTags::add($wall); return $wallData; }
public function ajaxeditComment($id, $value, $photoId = 0) { $config = CFactory::getConfig(); $my = CFactory::getUser(); $actModel = CFactory::getModel('activities'); $objResponse = new JAXResponse(); $json = array(); if ($my->id == 0) { $this->blockUnregister(); } $wall = JTable::getInstance('wall', 'CTable'); $wall->load($id); $cid = isset($wall->contentid) ? $wall->contentid : null; $activity = $actModel->getActivity($cid); $ownPost = $my->id == $wall->post_by; $targetPost = $activity->target == $my->id; $allowEdit = COwnerHelper::isCommunityAdmin() || ($ownPost || $targetPost) && !empty($my->id); $value = trim($value); if (empty($value)) { $json['error'] = JText::_('COM_COMMUNITY_CANNOT_EDIT_COMMENT_ERROR'); } else { if ($config->get('wallediting') && $allowEdit) { $params = new CParameter($wall->params); //if photo id is not 0, this wall is appended with a picture if ($photoId > 0 && $params->get('attached_photo_id') != $photoId) { //lets check if the photo belongs to the uploader $photo = JTable::getInstance('Photo', 'CTable'); $photo->load($photoId); if ($photo->creator == $my->id && $photo->albumid == '-1') { $params->set('attached_photo_id', $photoId); //sets the status to ready so that it wont be deleted on cron run $photo->status = 'ready'; $photo->store(); } } else { if ($photoId == -1) { //if there is nothing, remove the param if applicable //delete from db and files $photoModel = CFactory::getModel('photos'); $photoTable = $photoModel->getPhoto($params->get('attached_photo_id')); $photoTable->delete(); $params->set('attached_photo_id', 0); } } $wall->params = $params->toString(); $wall->comment = $value; $wall->store(); $CComment = new CComment(); $value = $CComment->stripCommentData($value); // Need to perform basic formatting here // 1. support nl to br, // 2. auto-link text $CTemplate = new CTemplate(); $value = $origValue = $CTemplate->escape($value); $value = CStringHelper::autoLink($value); $value = nl2br($value); $value = CUserHelper::replaceAliasURL($value); $value = CStringHelper::getEmoticon($value); $json['comment'] = $value; $json['originalComment'] = $origValue; // $objResponse->addScriptCall("joms.jQuery('div[data-commentid=" . $id . "] .cStream-Content span.comment').html", $value); // $objResponse->addScriptCall('joms.jQuery("div[data-commentid=' . $id . '] [data-type=stream-comment-editor] textarea").val', $origValue); // $objResponse->addScriptCall('joms.jQuery("div[data-commentid=' . $id . '] [data-type=stream-comment-editor] textarea").removeData', 'initialized'); // if ($photoId == -1) { // $objResponse->addScriptCall('joms.jQuery("div[data-commentid=' . $id . '] .joms-stream-thumb").parent().remove', ''); // $objResponse->addScriptCall('joms.jQuery("div[data-commentid=' . $id . '] .joms-stream-attachment").css("display", "none").attr("data-no_thumb", 1);'); // $objResponse->addScriptCall('joms.jQuery("div[data-commentid=' . $id . '] .joms-thumbnail").html', '<img/>'); // } else if ($photoId != 0) { // $objResponse->addScriptCall('joms.jQuery("div[data-commentid=' . $id . '] .joms-fetch-wrapper").remove', ''); // $objResponse->addScriptCall('joms.jQuery("div[data-commentid=' . $id . '] .joms-stream-thumb").parent().remove', ''); // $objResponse->addScriptCall('joms.jQuery("div[data-commentid=' . $id . '] [data-type=stream-comment-content] .cStream-Meta").before', '<div style="padding: 5px 0"><img class="joms-stream-thumb" src="' . JUri::root(true) ."/". $photo->thumbnail . '" /></div>'); // $objResponse->addScriptCall('joms.jQuery("div[data-commentid=' . $id . '] .joms-stream-attachment").css("display", "block").removeAttr("data-no_thumb");'); // $objResponse->addScriptCall('joms.jQuery("div[data-commentid=' . $id . '] .joms-thumbnail img").attr("src", "' . JUri::root(true) ."/". $photo->thumbnail . '").attr("data-photo_id", "0").data("photo_id", 0);'); // } } else { $json['error'] = JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_EDIT'); } } if (!isset($json['error'])) { $json['success'] = true; } die(json_encode($json)); }
/** * Function to share status * @param [Int] $activityId [description] * @param [JSON] $attachment [description] */ public static function addShare($activityId, $attachment) { $my = CFactory::getUser(); $params = new CParameter(''); $attachment = json_decode($attachment); $act = new stdClass(); $act->cmd = 'profile.status.share'; $act->actor = $my->id; $act->target = $my->id; $act->title = $attachment->msg; $act->content = ''; $act->app = 'profile.status.share'; $act->verb = 'share'; $act->cid = $my->id; $act->comment_id = CActivities::COMMENT_SELF; $act->comment_type = 'profile.status.share'; $act->like_id = CActivities::LIKE_SELF; $act->like_type = 'profile.status.share'; $act->access = $attachment->privacy; $params->set('activityId', $activityId); $act->params = $params->toString(); return self::add($act); }
public function removecover() { $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; $message = ''; $userId = $jinput->post->get('userid', 0, 'INT'); $my = CFactory::getUser(); if ($userId == 0) { /* redirect back to current user profile */ $url = CRoute::_('index.php?option=com_community&view=profile', false); } else { /* redirect back to viewing user profile */ $url = CRoute::_('index.php?option=com_community&view=profile&userid=' . $userId, false); } if ($my->id == 0) { return $this->blockUnregister(); } //Admin and owner can use this function if (COwnerHelper::isCommunityAdmin($my->id) || $userId == $my->id) { $user = CFactory::getUser($userId); // User id should be valid and admin should not be allowed to block themselves. if ($user->id) { $userModel = CFactory::getModel('User'); $userModel->removeProfileCover($user->id); $userTable = JTable::getInstance('Profile', 'CTable'); $userTable->load($user->id); $params = new CParameter($userTable->params); $params->set('coverPosition', 0); $userTable->params = $params->toString(); $userTable->store(); $message = JText::_('COM_COMMUNITY_PROFILE_COVER_REMOVED'); } else { $message = JText::_('COM_COMMUNITY_INVALID_PROFILE'); } } else { $message = JText::_('COM_COMMUNITY_ADMIN_ACCESS_ONLY'); } $mainframe->redirect($url, $message); }
/** * AJAX method to save a field * * @param int id Current field id * @param Array data The fields data * * @return JAXResponse object Azrul's AJAX Response object **/ public function ajaxSaveField($id, $data) { $user = JFactory::getUser(); if ($user->get('guest')) { JError::raiseError(403, JText::_('COM_COMMUNITY_ACCESS_FORBIDDEN')); return; } $response = new JAXResponse(); // Load the JTable Object. $row = JTable::getInstance('profiles', 'CommunityTable'); $row->load($id); $isValid = true; $row->bindAjaxPost($data); // override the option visiable, registration and required for label type. if ($row->type == 'label') { //$row->visible = 0; $row->required = 0; } // Do some validation before blindly saving the profile. if (empty($row->name)) { $error = JText::_('COM_COMMUNITY_PROFILE_NAME_EMPTY_WARN'); $response->addScriptCall('joms.jQuery("#error-notice").html("' . $error . '");'); $isValid = false; } if (empty($row->fieldcode)) { $error = JText::_('COM_COMMUNITY_PROFILE_FIELD_CODE_EMPTY_WARN'); $response->addScriptCall('joms.jQuery("#error-notice").html("' . $error . '");'); $isValid = false; } if (($row->type == 'select' || $row->type == 'singleselect' || $row->type == 'list' || $row->type == 'radio' || $row->type == 'checkbox') && empty($row->options)) { $error = JText::_('COM_COMMUNITY_PROFILE_FIELD_OPTIONS_EMPTY_WARN'); $response->addScriptCall('joms.jQuery("#error-notice").html("' . $error . '");'); $isValid = false; } if ($row->required && !$row->registration) { $error = JText::_('COM_COMMUNITY_PROFILE_FIELD_REQUIRED_CHECK_WARN'); $response->addScriptCall('joms.jQuery("#error-notice").html("' . $error . '");'); $isValid = false; } if ($isValid) { $groupOrdering = isset($data['group']) ? $data['group'] : ''; /* Now, save optional params items */ $xmlPath = JPATH_ROOT . '/components/com_community/libraries/fields/' . $row->type . '.xml'; if (JFile::exists($xmlPath)) { $postvars = $data; $post = array(); // convert $postvars to normal post $pattern = "'params\\[(.*?)\\]'s"; for ($i = 0; $i < count($postvars); $i++) { if (!empty($postvars[$i]) && is_array($postvars[$i])) { $key = $postvars[$i][0]; // @TODO: support 'usergroup' param type preg_match($pattern, $key, $matches); if ($matches) { $key = $matches[1]; $post[$key] = $postvars[$i][1]; } } } $params = new CParameter('', $xmlPath); $params->bind($post); $row->params = $params->toString(); } if ($row->type == 'gender') { $row->options = "COM_COMMUNITY_MALE\nCOM_COMMUNITY_FEMALE"; } elseif ($row->type == 'country') { $row->options = 'Afghanistan' . "\n" . 'Albania' . "\n" . 'Algeria' . "\n" . 'American Samoa' . "\n" . 'Andorra' . "\n" . 'Angola' . "\n" . 'Anguilla' . "\n" . 'Antarctica' . "\n" . 'Antigua and Barbuda' . "\n" . 'Argentina' . "\n" . 'Armenia' . "\n" . 'Aruba' . "\n" . 'Australia' . "\n" . 'Austria' . "\n" . 'Azerbaijan' . "\n" . 'Bahamas' . "\n" . 'Bahrain' . "\n" . 'Bangladesh' . "\n" . 'Barbados' . "\n" . 'Belarus' . "\n" . 'Belgium' . "\n" . 'Belize' . "\n" . 'Benin' . "\n" . 'Bermuda' . "\n" . 'Bhutan' . "\n" . 'Bolivia' . "\n" . 'Bosnia and Herzegovina' . "\n" . 'Botswana' . "\n" . 'Bouvet Island' . "\n" . 'Brazil' . "\n" . 'British Indian Ocean Territory' . "\n" . 'Brunei Darussalam' . "\n" . 'Bulgaria' . "\n" . 'Burkina Faso' . "\n" . 'Burundi' . "\n" . 'Cambodia' . "\n" . 'Cameroon' . "\n" . 'Canada' . "\n" . 'Cape Verde' . "\n" . 'Cayman Islands' . "\n" . 'Central African Republic' . "\n" . 'Chad' . "\n" . 'Chile' . "\n" . 'China' . "\n" . 'Christmas Island' . "\n" . 'Cocos (Keeling) Islands' . "\n" . 'Colombia' . "\n" . 'Comoros' . "\n" . 'Congo' . "\n" . 'Cook Islands' . "\n" . 'Costa Rica' . "\n" . 'Cote D\'Ivoire (Ivory Coast)' . "\n" . 'Croatia (Hrvatska)' . "\n" . 'Cuba' . "\n" . 'Cyprus' . "\n" . 'Czechoslovakia (former)' . "\n" . 'Czech Republic' . "\n" . 'Denmark' . "\n" . 'Djibouti' . "\n" . 'Dominica' . "\n" . 'Dominican Republic' . "\n" . 'East Timor' . "\n" . 'Ecuador' . "\n" . 'Egypt' . "\n" . 'El Salvador' . "\n" . 'Equatorial Guinea' . "\n" . 'Eritrea' . "\n" . 'Estonia' . "\n" . 'Ethiopia' . "\n" . 'Falkland Islands (Malvinas)' . "\n" . 'Faroe Islands' . "\n" . 'Fiji' . "\n" . 'Finland' . "\n" . 'France' . "\n" . 'France, Metropolitan' . "\n" . 'French Guiana' . "\n" . 'French Polynesia' . "\n" . 'French Southern Territories' . "\n" . 'Gabon' . "\n" . 'Gambia' . "\n" . 'Georgia' . "\n" . 'Germany' . "\n" . 'Ghana' . "\n" . 'Gibraltar' . "\n" . 'Great Britain (UK)' . "\n" . 'Greece' . "\n" . 'Greenland' . "\n" . 'Grenada' . "\n" . 'Guadeloupe' . "\n" . 'Guam' . "\n" . 'Guatemala' . "\n" . 'Guinea' . "\n" . 'Guinea-Bissau' . "\n" . 'Guyana' . "\n" . 'Haiti' . "\n" . 'Heard and McDonald Islands' . "\n" . 'Honduras' . "\n" . 'Hong Kong' . "\n" . 'Hungary' . "\n" . 'Iceland' . "\n" . 'India' . "\n" . 'Indonesia' . "\n" . 'Iran' . "\n" . 'Iraq' . "\n" . 'Ireland' . "\n" . 'Israel' . "\n" . 'Italy' . "\n" . 'Jamaica' . "\n" . 'Japan' . "\n" . 'Jordan' . "\n" . 'Kazakhstan' . "\n" . 'Kenya' . "\n" . 'Kiribati' . "\n" . 'Korea, North' . "\n" . 'South Korea' . "\n" . 'Kuwait' . "\n" . 'Kyrgyzstan' . "\n" . 'Laos' . "\n" . 'Latvia' . "\n" . 'Lebanon' . "\n" . 'Lesotho' . "\n" . 'Liberia' . "\n" . 'Libya' . "\n" . 'Liechtenstein' . "\n" . 'Lithuania' . "\n" . 'Luxembourg' . "\n" . 'Macau' . "\n" . 'Macedonia' . "\n" . 'Madagascar' . "\n" . 'Malawi' . "\n" . 'Malaysia' . "\n" . 'Maldives' . "\n" . 'Mali' . "\n" . 'Malta' . "\n" . 'Marshall Islands' . "\n" . 'Martinique' . "\n" . 'Mauritania' . "\n" . 'Mauritius' . "\n" . 'Mayotte' . "\n" . 'Mexico' . "\n" . 'Micronesia' . "\n" . 'Moldova' . "\n" . 'Monaco' . "\n" . 'Mongolia' . "\n" . 'Montserrat' . "\n" . 'Morocco' . "\n" . 'Mozambique' . "\n" . 'Myanmar' . "\n" . 'Namibia' . "\n" . 'Nauru' . "\n" . 'Nepal' . "\n" . 'Netherlands' . "\n" . 'Netherlands Antilles' . "\n" . 'Neutral Zone' . "\n" . 'New Caledonia' . "\n" . 'New Zealand' . "\n" . 'Nicaragua' . "\n" . 'Niger' . "\n" . 'Nigeria' . "\n" . 'Niue' . "\n" . 'Norfolk Island' . "\n" . 'Northern Mariana Islands' . "\n" . 'Norway' . "\n" . 'Oman' . "\n" . 'Pakistan' . "\n" . 'Palau' . "\n" . 'Panama' . "\n" . 'Papua New Guinea' . "\n" . 'Paraguay' . "\n" . 'Peru' . "\n" . 'Philippines' . "\n" . 'Pitcairn' . "\n" . 'Poland' . "\n" . 'Portugal' . "\n" . 'Puerto Rico' . "\n" . 'Qatar' . "\n" . 'Reunion' . "\n" . 'Romania' . "\n" . 'Russian Federation' . "\n" . 'Rwanda' . "\n" . 'Saint Kitts and Nevis' . "\n" . 'Saint Lucia' . "\n" . 'Saint Vincent and the Grenadines' . "\n" . 'Samoa' . "\n" . 'San Marino' . "\n" . 'Sao Tome and Principe' . "\n" . 'Saudi Arabia' . "\n" . 'Senegal' . "\n" . 'Seychelles' . "\n" . 'S. Georgia and S. Sandwich Isls.' . "\n" . 'Sierra Leone' . "\n" . 'Singapore' . "\n" . 'Slovak Republic' . "\n" . 'Slovenia' . "\n" . 'Solomon Islands' . "\n" . 'Somalia' . "\n" . 'South Africa' . "\n" . 'Spain' . "\n" . 'Sri Lanka' . "\n" . 'St. Helena' . "\n" . 'St. Pierre and Miquelon' . "\n" . 'Sudan' . "\n" . 'Suriname' . "\n" . 'Svalbard and Jan Mayen Islands' . "\n" . 'Swaziland' . "\n" . 'Sweden' . "\n" . 'Switzerland' . "\n" . 'Syria' . "\n" . 'Taiwan' . "\n" . 'Tajikistan' . "\n" . 'Tanzania' . "\n" . 'Thailand' . "\n" . 'Togo' . "\n" . 'Tokelau' . "\n" . 'Tonga' . "\n" . 'Trinidad and Tobago' . "\n" . 'Tunisia' . "\n" . 'Turkey' . "\n" . 'Turkmenistan' . "\n" . 'Turks and Caicos Islands' . "\n" . 'Tuvalu' . "\n" . 'Uganda' . "\n" . 'Ukraine' . "\n" . 'United Arab Emirates' . "\n" . 'United Kingdom' . "\n" . 'United States' . "\n" . 'Uruguay' . "\n" . 'US Minor Outlying Islands' . "\n" . 'USSR (former)' . "\n" . 'Uzbekistan' . "\n" . 'Vanuatu' . "\n" . 'Vatican City State (Holy Sea)' . "\n" . 'Venezuela' . "\n" . 'Viet Nam' . "\n" . 'Virgin Islands (British)' . "\n" . 'Virgin Islands (U.S.)' . "\n" . 'Wallis and Futuna Islands' . "\n" . 'Western Sahara' . "\n" . 'Yemen' . "\n" . 'Yugoslavia' . "\n" . 'Zaire' . "\n" . 'Zambia' . "\n" . 'Zimbabwe'; } $row->store($groupOrdering); $parent = ''; // Get the view $view = $this->getView('profiles', 'html'); if ($id != 0) { $name = '<a href="javascript:void(0);" onclick="azcommunity.editField(\'' . $row->id . '\');">' . $row->name . '</a>'; $type = '<span id="type' . $row->id . '" onclick="$(\'typeOption\').style.display = \'block\';$(this).style.display = \'none\';">' . JString::ucfirst($row->type) . '</span>'; $publish = $view->getPublish($row, 'published', 'profiles,ajaxTogglePublish'); if ($row->type == 'label') { $required = $view->showPublish($row, 'required'); //$visible = $view->showPublish( $row , 'visible'); $visible = $view->getPublish($row, 'visible', 'profiles,ajaxTogglePublish'); } else { $required = $view->getPublish($row, 'required', 'profiles,ajaxTogglePublish'); $visible = $view->getPublish($row, 'visible', 'profiles,ajaxTogglePublish'); } $registration = $view->getPublish($row, 'registration', 'profiles,ajaxTogglePublish'); // Set the parent id $parent = $row->id; $response->addScriptCall('location.reload();'); } else { $response->addScriptCall('location.reload();'); } $response->addScriptCall('cWindowHide();'); } else { //release the form input back to enabled. $response->addScriptCall('joms.jQuery(\'#cWindowContent\').find(\'input, textarea, button\').attr(\'disabled\', false)'); } $response->sendResponse(); }
function deleteFromCommunityActivities($user) { $db = JFactory::getDBO(); $sql = "DELETE\r\n\r\n\t\t\t\tFROM\r\n\t\t\t\t\t\t" . $db->quoteName("#__community_activities") . "\r\n\t\t\t\tWHERE\r\n\t\t\t\t\t\t(" . $db->quoteName("actor") . " = " . $db->quote($user['id']) . " OR\r\n\t\t\t\t\t\t" . $db->quoteName("target") . " = " . $db->quote($user['id']) . ") AND\r\n\t\t\t\t\t\t" . $db->quoteName("archived") . " = " . $db->quote(0); $db->setQuery($sql); $db->Query(); //remove from any user participation activity $db = JFactory::getDBO(); $query = $db->getQuery(true); $query->select('*')->from($db->quoteName('#__community_activities'))->where($db->quoteName('actors') . ' LIKE ' . $db->quote('%"id":"' . $user['id'] . '"%')); $db->setQuery($query); $results = $db->loadObjectList(); foreach ($results as $result) { // lets start with actors column $actors = new CParameter($result->actors); $actorsArr = $actors->get('userid'); foreach ($actorsArr as $key => $actor) { if ($user['id'] == $actor->id) { unset($actorsArr[$key]); break; } } $actorsArr = array_values($actorsArr); $actors->set('userid', $actorsArr); $actorsUpdate = $actors->toString(); // followed by the params $actors = new CParameter($result->params); $actorsArr = $actors->get('actors'); $actorsArr = explode(',', $actorsArr); foreach ($actorsArr as $key => $actor) { if ($user['id'] == $actor) { unset($actorsArr[$key]); break; } } $actorsArr = implode(',', $actorsArr); $actors->set('actors', $actorsArr); $params = $actors->toString(); $activityRec = new stdClass(); $activityRec->id = $result->id; $activityRec->actors = $actorsUpdate; $activityRec->params = $params; JFactory::getDbo()->updateObject('#__community_activities', $activityRec, 'id'); } if ($db->getErrorNum()) { JError::raiseError(500, $db->stderr()); } }
jimport('joomla.filesystem.file'); $logFile = COMMUNITY_COM_PATH . '/access.log'; $content = ''; if (JFile::exists($logFile)) { $content = JFile::read(COMMUNITY_COM_PATH . '/access.log'); } $params = new CParameter($content); $today = strftime('%Y-%m-%d'); $loadTime = $params->get($today, 0); if ($loadTime > 0) { $loadTime = ($loadTime + (xdebug_time_index() - $tm)) / 2; } else { $loadTime = xdebug_time_index() - $tm; } $params->set($today, $loadTime); $paramsText = $params->toString(); JFile::write(COMMUNITY_COM_PATH . '/access.log', $paramsText); } echo getJomSocialPoweredByLink(); // getTriggerCount // $appLib = CAppPlugins::getInstance(); // echo 'Trigger count: '. $appLib->triggerCount . '<br/>'; // $time_end = microtime(true); // $time = $time_end - $time_start; // echo $time; } /** * Entry poitn for all ajax call */ function communityAjaxEntry($func, $args = null) {
public function addMood($mood) { $params = new CParameter($this->params); $params->set('mood', $mood); $this->params = $params->toString(); if ($this->store()) { return true; } return false; }
public function save() { // Check for request forgeries JRequest::checkToken('request') or jexit('Invalid Token'); // initialise $postData = array(); $logo_file = array(); $logo_replace = 0; $save_image_ok = null; // get post data $postData = JRequest::get('post'); $logo_file = JRequest::get('files'); $session = JFactory::getSession(); $token = $session->getFormToken(false); if (!empty($logo_file['network_Filedata'])) { $logo_image = $logo_file['network_Filedata']; } if (isset($postData['network_replace_image'])) { if ($postData['network_replace_image'] == 1) { $logo_replace = 1; } } // instanstiate the table JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . '/tables'); $table = JTable::getInstance('configuration', 'CommunityTable'); $table->load('config'); $params = new CParameter($table->params); // save logo image if (!empty($logo_image['name']) && $logo_image['size'] > 0) { $save_image_ok = $this->saveImage($logo_image, $logo_replace); } // clean and limits to maximum 10 tags/keywords $filteredTags = explode(",", $postData['network_keywords']); foreach ($filteredTags as $key => $filteredTag) { $filteredTags[$key] = trim($filteredTag); } $filteredTags = array_unique($filteredTags); foreach ($filteredTags as $key => $filteredTag) { if (empty($filteredTag)) { unset($filteredTags[$key]); } } $filteredTags = array_slice($filteredTags, 0, 10); $postData['network_keywords'] = implode(", ", $filteredTags); // set data properly foreach ($postData as $key => $value) { // exclude unnecessary keys from form $wanted_keys = array('network_enable', 'network_description', 'network_keywords', 'network_join_url', 'network_logo_url', 'network_cron_freq', 'network_cron_last_run'); if (in_array($key, $wanted_keys)) { $params->set($key, $value); } } // update data if new logo image saved if ($save_image_ok) { $params->set('logo_url', $save_image_ok); } // convert final data in INI string and put in table $table->params = $params->toString(); // Save it if (!$table->store()) { return false; } return true; }
static function addJSGroup($name, $description, $course_id, $website) { if (file_exists(JPATH_ADMINISTRATOR . '/components/com_community/tables/cache.php')) { require_once JPATH_ADMINISTRATOR . '/components/com_community/tables/cache.php'; } require_once JPATH_SITE . '/components/com_community/libraries/core.php'; require_once JPATH_SITE . '/components/com_community/models/groups.php'; $mainframe = JFactory::getApplication(); // Get my current data. $validated = true; $group = JTable::getInstance('Group', 'CTable'); $model = CFactory::getModel('groups'); // @rule: Test for emptyness if (empty($name)) { $validated = false; } // @rule: Test if group exists if ($model->groupExist($name)) { $validated = false; } // @rule: Test for emptyness if (empty($description)) { $validated = false; } $categoryId = JoomdleHelperGroups::get_main_category(); if (empty($categoryId)) { $validated = false; } if ($validated) { // Assertions // Category Id must not be empty and will cause failure on this group if its empty. CError::assert($categoryId, '', '!empty', __FILE__, __LINE__); // @rule: Retrieve params and store it back as raw string $params = new CParameter(''); $discussordering = JRequest::getVar('discussordering', DISCUSSION_ORDER_BYLASTACTIVITY, 'REQUEST'); $params->set('discussordering', $discussordering); $photopermission = JRequest::getVar('photopermission', GROUP_PHOTO_PERMISSION_ADMINS, 'REQUEST'); $params->set('photopermission', $photopermission); $videopermission = JRequest::getVar('videopermission', GROUP_PHOTO_PERMISSION_ADMINS, 'REQUEST'); $params->set('videopermission', $videopermission); $grouprecentphotos = JRequest::getVar('grouprecentphotos', GROUP_PHOTO_RECENT_LIMIT, 'REQUEST'); $params->set('grouprecentphotos', $grouprecentphotos); $grouprecentvideos = JRequest::getVar('grouprecentvideos', GROUP_VIDEO_RECENT_LIMIT, 'REQUEST'); $params->set('grouprecentvideos', $grouprecentvideos); $newmembernotification = JRequest::getVar('newmembernotification', '1', 'REQUEST'); $params->set('newmembernotification', $newmembernotification); $joinrequestnotification = JRequest::getVar('joinrequestnotification', '1', 'REQUEST'); $params->set('joinrequestnotification', $joinrequestnotification); $params->set('course_id', $course_id); CFactory::load('helpers', 'owner'); $group->name = $name; $group->description = $description; $group->categoryid = $categoryId; $group->website = $website; $group->ownerid = JoomdleHelperSystem::get_admin_id(); $group->created = gmdate('Y-m-d H:i:s'); $group->approvals = 1; $group->params = $params->toString(); // Set the default thumbnail and avatar for the group just in case // the user decides to skip this // $group->thumb = 'components/com_community/assets/group_thumb.jpg'; // $group->avatar = 'components/com_community/assets/group.jpg'; $group->published = 1; // Store the group now. $group->store(); // Since this is storing groups, we also need to store the creator / admin // into the groups members table $member = JTable::getInstance('GroupMembers', 'CTable'); $member->groupid = $group->id; $member->memberid = $group->ownerid; // Creator should always be 1 as approved as they are the creator. $member->approved = 1; // @todo: Setup required permissions in the future $member->permissions = '1'; $member->store(); // Increment the member count $group->updateStats(); $group->store(); } return "OK"; }
public function upload() { $my = CFactory::getUser(); $config = CFactory::getConfig(); // If user is using a flash browser, their session might get reset when mod_security is around if ($my->id == 0) { $tokenId = JRequest::getVar('token', '', 'REQUEST'); $userId = JRequest::getVar('uploaderid', '', 'REQUEST'); $my = CFactory::getUserFromTokenId($tokenId, $userId); $session =& JFactory::getSession(); $session->set('user', $my); } CFactory::load('libraries', 'limits'); if (CLimitsLibrary::exceedDaily('photos', $my->id)) { $this->_showUploadError(true, JText::_('COM_COMMUNITY_PHOTOS_LIMIT_PERDAY_REACHED')); return; } // We can't use blockUnregister here because practically, the CFactory::getUser() will return 0 if ($my->id == 0) { return; } // Load up required models and properties CFactory::load('libraries', 'photos'); CFactory::load('models', 'photos'); CFactory::load('helpers', 'image'); $photos = JRequest::get('Files'); $albumId = JRequest::getVar('albumid', '', 'REQUEST'); $album =& JTable::getInstance('Album', 'CTable'); $album->load($albumId); $handler = $this->_getHandler($album); foreach ($photos as $imageFile) { $result = $this->_checkUploadedFile($imageFile, $album, $handler); if (!$result['photoTable']) { continue; } //assign the result of the array and assigned to the right variable $photoTable = $result['photoTable']; $storage = $result['storage']; $albumPath = $result['albumPath']; $hashFilename = $result['hashFilename']; $thumbPath = $result['thumbPath']; $originalPath = $result['originalPath']; $imgType = $result['imgType']; $isDefaultPhoto = $result['isDefaultPhoto']; // Remove the filename extension from the caption if (JString::strlen($photoTable->caption) > 4) { $photoTable->caption = JString::substr($photoTable->caption, 0, JString::strlen($photoTable->caption) - 4); } // @todo: configurable options? // Permission should follow album permission $photoTable->published = '1'; $photoTable->permissions = $album->permissions; // Set the relative path. // @todo: configurable path? $storedPath = $handler->getStoredPath($storage, $albumId); $storedPath = $storedPath . DS . $albumPath . $hashFilename . CImageHelper::getExtension($imageFile['type']); $photoTable->image = CString::str_ireplace(JPATH_ROOT . DS, '', $storedPath); $photoTable->thumbnail = CString::str_ireplace(JPATH_ROOT . DS, '', $thumbPath); //In joomla 1.6, CString::str_ireplace is not replacing the path properly. Need to do a check here if ($photoTable->image == $storedPath) { $photoTable->image = str_ireplace(JPATH_ROOT . DS, '', $storedPath); } if ($photoTable->thumbnail == $thumbPath) { $photoTable->thumbnail = str_ireplace(JPATH_ROOT . DS, '', $thumbPath); } //photo filesize, use sprintf to prevent return of unexpected results for large file. $photoTable->filesize = sprintf("%u", filesize($originalPath)); // @rule: Set the proper ordering for the next photo upload. $photoTable->setOrdering(); // Store the object $photoTable->store(); // We need to see if we need to rotate this image, from EXIF orientation data // Only for jpeg image. if ($config->get('photos_auto_rotate') && $imgType == 'image/jpeg') { $this->_rotatePhoto($imageFile, $photoTable, $storedPath, $thumbPath); } // Trigger for onPhotoCreate CFactory::load('libraries', 'apps'); $apps =& CAppPlugins::getInstance(); $apps->loadApplications(); $params = array(); $params[] =& $photoTable; $apps->triggerEvent('onPhotoCreate', $params); // Set image as default if necessary // Load photo album table if ($isDefaultPhoto) { // Set the photo id $album->photoid = $photoTable->id; $album->store(); } // @rule: Set first photo as default album cover if enabled if (!$isDefaultPhoto && $config->get('autoalbumcover')) { $photosModel = CFactory::getModel('Photos'); $totalPhotos = $photosModel->getTotalPhotos($album->id); if ($totalPhotos <= 1) { $album->photoid = $photoTable->id; $album->store(); } } // Generate activity stream $act = new stdClass(); $act->cmd = 'photo.upload'; $act->actor = $my->id; $act->access = $album->permissions; $act->target = 0; //$act->title = JText::sprintf( $handler->getUploadActivityTitle() , '{photo_url}', $album->name ); $act->title = JText::sprintf($handler->getUploadActivityTitle(), '{multiUrl}', $album->name); $act->content = ''; // Gegenerated automatically by stream. No need to add anything $act->app = 'photos'; $act->cid = $albumId; $act->location = $album->location; // Store group info // I hate to load group here, but unfortunately, album does // not store group permission setting $group =& JTable::getInstance('Group', 'CTable'); $group->load($album->groupid); $act->groupid = $album->groupid; $act->group_access = $group->approvals; // Allow comment on the album $act->comment_type = 'photos.album'; $act->comment_id = $albumId; // Allow like on the album $act->like_type = 'photos.album'; $act->like_id = $albumId; $params = new CParameter(''); $params->set('multiUrl', $handler->getAlbumURI($albumId, false)); $params->set('photoid', $photoTable->id); $params->set('action', 'upload'); $params->set('photo_url', $photoTable->getThumbURI()); // Add activity logging CFactory::load('libraries', 'activities'); CActivityStream::add($act, $params->toString()); //add user points CFactory::load('libraries', 'userpoints'); CUserPoints::assignPoint('photo.upload'); // Photo upload was successfull, display a proper message $this->_showUploadError(false, JText::sprintf('COM_COMMUNITY_PHOTO_UPLOADED_SUCCESSFULLY', $photoTable->caption), $photoTable->getThumbURI(), $albumId, $photoTable->id); } $this->cacheClean(array(COMMUNITY_CACHE_TAG_FRONTPAGE, COMMUNITY_CACHE_TAG_ACTIVITIES)); exit; }
/** * @param $message A message that is submitted by the user * @param $uniqueId The unique id for this group * @param int $photoId */ public function ajaxSaveWall($message, $uniqueId, $photoId = 0) { $filter = JFilterInput::getInstance(); $uniqueId = $filter->clean($uniqueId, 'int'); $photoId = $filter->clean($photoId, 'int'); if (!COwnerHelper::isRegisteredUser()) { return $this->ajaxBlockUnregister(); } $response = new JAXResponse(); $json = array(); $my = CFactory::getUser(); $video = JTable::getInstance('Video', 'CTable'); $video->load($uniqueId); // If the content is false, the message might be empty. if (empty($message) && $photoId == 0) { $json['error'] = JText::_('COM_COMMUNITY_WALL_EMPTY_MESSAGE'); } else { $config = CFactory::getConfig(); // @rule: Spam checks if ($config->get('antispam_akismet_walls')) { //CFactory::load( 'libraries' , 'spamfilter' ); $filter = CSpamFilter::getFilter(); $filter->setAuthor($my->getDisplayName()); $filter->setMessage($message); $filter->setEmail($my->email); $filter->setURL(CRoute::_('index.php?option=com_community&view=videos&task=video&videoid=' . $uniqueId)); $filter->setType('message'); $filter->setIP($_SERVER['REMOTE_ADDR']); if ($filter->isSpam()) { $json['error'] = JText::_('COM_COMMUNITY_WALLS_MARKED_SPAM'); die(json_encode($json)); } } //CFactory::load( 'libraries' , 'wall' ); $wall = CWallLibrary::saveWall($uniqueId, $message, 'videos', $my, $my->id == $video->creator, 'videos,video', 'wall/content', 0, $photoId); // Add activity logging $url = $video->getViewUri(false); $params = new CParameter(''); $params->set('videoid', $uniqueId); $params->set('action', 'wall'); $params->set('wallid', $wall->id); $params->set('video_url', $url); $act = new stdClass(); $act->cmd = 'videos.wall.create'; $act->actor = $my->id; $act->access = $video->permissions; $act->target = 0; $act->title = JText::sprintf('COM_COMMUNITY_VIDEOS_ACTIVITIES_WALL_POST_VIDEO', '{video_url}', $video->title); $act->app = 'videos.comment'; $act->cid = $uniqueId; $act->params = $params->toString(); $act->groupid = $video->groupid; $act->eventid = $video->eventid; CActivityStream::add($act); // Add notification //CFactory::load( 'libraries' , 'notification' ); $params = new CParameter(''); $params->set('url', $url); $params->set('message', CUserHelper::replaceAliasURL($message)); $params->set('video', $video->title); $params->set('video_url', $url); if ($my->id !== $video->creator) { CNotificationLibrary::add('videos_submit_wall', $my->id, $video->creator, JText::sprintf('COM_COMMUNITY_VIDEO_WALL_EMAIL_SUBJECT'), '', 'videos.wall', $params); } else { //for activity reply action //get relevent users in the activity $wallModel = CFactory::getModel('wall'); $users = $wallModel->getAllPostUsers('videos', $video->id, $video->creator); if (!empty($users)) { CNotificationLibrary::add('videos_reply_wall', $my->id, $users, JText::sprintf('COM_COMMUNITY_VIDEO_WALLREPLY_EMAIL_SUBJECT'), '', 'videos.wallreply', $params); } } //email and add notification if user are tagged $info = array('type' => 'video-comment', 'video_id' => $video->id); CUserHelper::parseTaggedUserNotification($message, CFactory::getUser($video->creator), $wall, $info); // Add user points CUserPoints::assignPoint('videos.comment'); //@since 4.1 we dump the info into photo stats $statsModel = CFactory::getModel('stats'); $statsModel->addVideoStats($video->id, 'comment'); // Log user engagement CEngagement::log('video.comment', $my->id); $json['html'] = $wall->content; $json['success'] = true; } $this->cacheClean(array(COMMUNITY_CACHE_TAG_ACTIVITIES)); die(json_encode($json)); }
/** * */ public function ajaxSaveSettings($postvars) { // Check permissions $my = CFactory::getUser(); $filter = JFilterInput::getInstance(); $postvars = $filter->clean($postvars, 'array'); if ($my->id == 0) { return $this->ajaxBlockUnregister(); } $json = array(); $appsModel = CFactory::getModel('apps'); $appName = $postvars['appname']; $id = $postvars['appid']; // @rule: Test if app is core app as we need to add into the db $pluginId = $appsModel->getPluginId($appName); $appParam = new CParameter($appsModel->getPluginParams($pluginId)); if ($pluginId && $my->id != 0 && $appParam->get('coreapp')) { // Add new app in the community plugins table $appsModel->addApp($my->id, $appName); // @rule: For core applications, the ID might be referring to Joomla's id. Get the correct id if needed. $id = $appsModel->getUserApplicationId($appName, $my->id); } // Make sure this is valid for current user. if (!$appsModel->isOwned($my->id, $id)) { $json['error'] = JText::_('COM_COMMUNITY_PERMISSION_ERROR'); die(json_encode($json)); } $post = array(); // convert $postvars to normal post $pattern = "'params\\[(.*?)\\]'s"; for ($i = 0; $i < count($postvars); $i++) { if (!empty($postvars[$i]) && is_array($postvars[$i])) { $key = $postvars[$i][0]; // Blogger view preg_match($pattern, $key, $matches); if ($matches) { $key = $matches[1]; } $post[$key] = $postvars[$i][1]; } } //$xmlPath = JPATH_COMPONENT.'/applications/'.$appName.'/'.$appName.'.xml'; $xmlPath = CPluginHelper::getPluginPath('community', $appName) . '/config.xml'; $params = new CParameter($appsModel->getUserAppParams($id), $xmlPath); $params->bind($post); //echo $params->toString(); $appsModel->storeParams($id, $params->toString()); $json['success'] = true; die(json_encode($json)); }
/** * To regenerate the parameters for the joined group members in activity to retrieve the right calculation * @param $actid * @param $event * @return bool|int */ public static function updateGroupJoinMembers($actid, $group) { $groupModel = CFactory::getModel('groups'); $members = $groupModel->getMembersId($group->id, true); $membersArr = array(); foreach ($members as $member) { $membersArr[] = $member; } $activity = JTable::getInstance('Activity', 'CTable'); $activity->load($actid); $params = new CParameter($activity->params); $params->set('actors', implode(',', $membersArr)); $activity->params = $params->toString(); if ($activity->store()) { return $group->getMembersCount(); } return false; }
public function ajaxSubmitForm($form = null) { if (!is_array($form)) { return false; } // validation if (!$form['email']) { $form['_error'] = 'You need to enter an email'; $this->ajaxShowForm($form); } if ($form['password'] == '' || $form['password'] !== $form['password2']) { $form['_error'] = 'Password empty or do not match'; $this->ajaxShowForm($form); } if (!isset($form['terms_of_service'])) { $form['_error'] = 'You did not agree to the Term of Service'; $this->ajaxShowForm($form); } $data = array('terms_of_service' => 0, 'email' => '', 'password' => '', 'affiliate_code' => 'jomsocial', 'newsletter' => 0); // something is weird with the returning value of jax.getFormValues // we can't use array_merge here :( //array_merge($form, $values); $data['email'] = $form['email']; $data['password'] = $form['password2']; $data['terms_of_service'] = $form['terms_of_service']; $data = json_encode($data); CFactory::load('libraries', 'zencoder'); $curl = new CZenCoderCURL(); if (!$curl->post('https://app.zencoder.com/api/account', $data)) { $this->ajaxShowSuccss($curl->getError()); } $content = ''; $code = $curl->getStatusCode(); $result = $curl->getResults(); $result = json_decode($result); if (isset($result->errors)) { foreach ($result->errors as $error) { $content .= $error . '<br />'; } } if (isset($result->api_key)) { $content .= 'Your API key: ' . $result->api_key . '<br />'; $content .= 'Password: '******'configuration', 'CommunityTable'); $config->load('config'); $params = new CParameter($config->params); $params->set('zencoder_api_key', $result->api_key); $config->params = $params->toString(); $config->store(); } if (!isset($result->errors) && !isset($result->api_key)) { $content = 'Something is wrong here...'; } $this->ajaxShowSuccss($content); }
public function ajaxUpdateStatus($eventId, $status) { $filter = JFilterInput::getInstance(); $eventId = $filter->clean($eventId, 'int'); $status = $filter->clean($status, 'int'); $target = NULL; if (!COwnerHelper::isRegisteredUser()) { return $this->ajaxBlockUnregister(); } $my = CFactory::getUser(); $objResponse = new JAXResponse(); $memberId = $my->id; $modal =& $this->getModel('events'); $event =& JTable::getInstance('Event', 'CTable'); $event->load($eventId); CFactory::load('helpers', 'event'); $handler = CEventHelper::getHandler($event); if (!$handler->isAllowed()) { $objResponse->addAlert(JText::_('COM_COMMUNITY_ACCESS_FORBIDDEN')); return $objResponse->sendResponse(); } if ($event->ticket && ($status == COMMUNITY_EVENT_STATUS_ATTEND && $event->confirmedcount + 1 > $event->ticket)) { $objResponse->addAlert(JText::_('COM_COMMUNITY_EVENTS_TICKET_FULL')); return $objResponse->sendResponse(); } $eventMember =& JTable::getInstance('EventMembers', 'CTable'); $eventMember->load($memberId, $eventId); if ($eventMember->permission != 1 && $eventMember->permission != 2) { $eventMember->permission = 3; } $date =& JFactory::getDate(); $eventMember->created = $date->toMYSQL(); $eventMember->status = $status; $eventMember->store(); $event->updateGuestStats(); $event->store(); //activities stream goes here. $url = $handler->getFormattedLink('index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id, false); CFactory::load('helpers', 'event'); // We update the activity only if a user attend an event and the event was set to public event if ($status == COMMUNITY_EVENT_STATUS_ATTEND && $handler->isPublic()) { $command = 'events.attendence.attend'; $actor = $my->id; $target = 0; $content = ''; $cid = $event->id; $app = 'events'; $act = $handler->getActivity($command, $actor, $target, $content, $cid, $app); $act->eventid = $event->id; $params = new CParameter(''); $action_str = 'events.attendence.attend'; $params->set('eventid', $event->id); $params->set('action', $action_str); $params->set('event_url', $url); // Add activity logging CFactory::load('libraries', 'activities'); CActivityStream::add($act, $params->toString()); } //trigger goes here. CFactory::load('libraries', 'apps'); $appsLib =& CAppPlugins::getInstance(); $appsLib->loadApplications(); $params = array(); $params[] =& $event; $params[] = $my->id; $params[] = $status; if (!is_null($target)) { $params[] = $target; } $this->cacheClean(array(COMMUNITY_CACHE_TAG_EVENTS, COMMUNITY_CACHE_TAG_ACTIVITIES)); CFactory::load('libraries', 'events'); $html = CEvents::getEventMemberHTML($event->id); if ($status == COMMUNITY_EVENT_STATUS_ATTEND) { $RSVPmessage = JText::_('COM_COMMUNITY_EVENTS_ATTENDING_EVENT_MESSAGE'); } else { $RSVPmessage = JText::_('COM_COMMUNITY_EVENTS_NOT_ATTENDING_EVENT_MESSAGE'); } $objResponse->addScriptCall('__callback', $html); $objResponse->addScriptCall("joms.jQuery('#community-event-rsvp-alert .cdata').html('{$RSVPmessage}');"); return $objResponse->sendResponse(); }
jimport('joomla.filesystem.file'); $logFile = COMMUNITY_COM_PATH . DS . 'access.log'; $content = ''; if (JFile::exists($logFile)) { $content = JFile::read(COMMUNITY_COM_PATH . DS . 'access.log'); } $params = new CParameter($content); $today = strftime('%Y-%m-%d'); $loadTime = $params->get($today, 0); if ($loadTime > 0) { $loadTime = ($loadTime + (xdebug_time_index() - $tm)) / 2; } else { $loadTime = xdebug_time_index() - $tm; } $params->set($today, $loadTime); JFile::write(COMMUNITY_COM_PATH . DS . 'access.log', $params->toString()); } echo getJomSocialPoweredByLink(); // getTriggerCount // $appLib = CAppPlugins::getInstance(); // echo 'Trigger count: '. $appLib->triggerCount . '<br/>'; // $time_end = microtime(true); // $time = $time_end - $time_start; // echo $time; } /** * Entry poitn for all ajax call */ function communityAjaxEntry($func, $args = null) { // For AJAX calls, we need to load the language file manually.
private function _enableModule($module) { $db = JFactory::getDBO(); $module = 'mod_community_' . $module; $default = array('mod_community_memberssearch' => '', 'mod_community_eventscalendar' => '', 'mod_community_members' => '', 'mod_community_photos' => '', 'mod_community_videos' => '', 'mod_community_groups' => '', 'mod_community_events' => ''); $defaultPosition = array('mod_community_memberssearch' => 'js_side_frontpage_top', 'mod_community_members' => 'js_side_frontpage_top', 'mod_community_photos' => 'js_side_frontpage', 'mod_community_videos' => 'js_side_frontpage', 'mod_community_groups' => 'js_side_frontpage_bottom', 'mod_community_events' => 'js_side_frontpage_bottom'); $params = new CParameter(''); $params->set('default', $default[$module]); $query = 'SELECT * FROM ' . $db->quoteName('#__modules') . ' WHERE '; $query .= $db->quoteName('module') . '=' . $db->Quote($module); $db->setQuery($query); $result = $db->loadObject(); if (empty($result->position)) { $query = 'UPDATE ' . $db->quoteName('#__modules') . ' SET ' . $db->quoteName('published') . ' = ' . $db->quote(1) . ' , ' . $db->quoteName('position') . ' = ' . $db->quote($defaultPosition[$module]) . ' , ' . $db->quoteName('ordering') . ' = ' . $db->quote(1) . ' , ' . $db->quoteName('params') . ' = ' . $db->quote($params->toString()) . ' WHERE ' . $db->quoteName('module') . ' = ' . $db->quote($module); $db->setQuery($query); if (!$db->query()) { return $db->getErrorNum() . ':' . $db->getErrorMsg(); } } $query = 'SELECT COUNT(*) FROM ' . $db->quoteName('#__modules_menu') . ' WHERE ' . $db->quoteName('moduleid') . ' = ' . $db->quote($result->id); $db->setQuery($query); $count = $db->loadResult(); if ($count < 1) { $query = 'INSERT INTO ' . $db->quoteName('#__modules_menu') . '(' . $db->quoteName('moduleid') . ', ' . $db->quoteName('menuid') . ')' . 'VALUES(' . $db->quote($result->id) . ', ' . $db->quote('') . ')'; $db->setQuery($query); $db->Query(); } }
/** * AJAX method to save a field * * @param int id Current field id * @param Array data The fields data * * @return JAXResponse object Azrul's AJAX Response object **/ public function ajaxSaveField($id, $data) { $user =& JFactory::getUser(); if ($user->get('guest')) { JError::raiseError(403, JText::_('COM_COMMUNITY_ACCESS_FORBIDDEN')); return; } $response = new JAXResponse(); // Load the JTable Object. $row =& JTable::getInstance('profiles', 'CommunityTable'); $row->load($id); $isValid = true; $row->bindAjaxPost($data); // override the option visiable, registration and required for label type. if ($row->type == 'label') { $row->visible = 0; $row->required = 0; } // Do some validation before blindly saving the profile. if (empty($row->name)) { $error = JText::_('COM_COMMUNITY_PROFILE_NAME_EMPTY_WARN'); $response->addScriptCall('joms.jQuery("#error-notice").html("' . $error . '");'); $isValid = false; } if (empty($row->fieldcode)) { $error = JText::_('COM_COMMUNITY_PROFILE_FIELD_CODE_EMPTY_WARN'); $response->addScriptCall('joms.jQuery("#error-notice").html("' . $error . '");'); $isValid = false; } if (($row->type == 'select' || $row->type == 'singleselect' || $row->type == 'list' || $row->type == 'radio' || $row->type == 'checkbox') && empty($row->options)) { $error = JText::_('COM_COMMUNITY_PROFILE_FIELD_OPTIONS_EMPTY_WARN'); $response->addScriptCall('joms.jQuery("#error-notice").html("' . $error . '");'); $isValid = false; } if ($row->required && !$row->registration) { $error = JText::_('COM_COMMUNITY_PROFILE_FIELD_REQUIRED_CHECK_WARN'); $response->addScriptCall('joms.jQuery("#error-notice").html("' . $error . '");'); $isValid = false; } if ($isValid) { $groupOrdering = isset($data['group']) ? $data['group'] : ''; /* Now, save optional params items */ $xmlPath = JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'fields' . DS . $row->type . '.xml'; if (JFile::exists($xmlPath)) { $postvars = $data; $post = array(); // convert $postvars to normal post $pattern = "'params\\[(.*?)\\]'s"; for ($i = 0; $i < count($postvars); $i++) { if (!empty($postvars[$i]) && is_array($postvars[$i])) { $key = $postvars[$i][0]; // @TODO: support 'usergroup' param type preg_match($pattern, $key, $matches); if ($matches) { $key = $matches[1]; $post[$key] = $postvars[$i][1]; } } } $params = new CParameter('', $xmlPath); $params->bind($post); $row->params = $params->toString(); } $row->store($groupOrdering); $parent = ''; // Get the view $view =& $this->getView('profiles', 'html'); if ($id != 0) { $name = '<a href="javascript:void(0);" onclick="azcommunity.editField(\'' . $row->id . '\');">' . $row->name . '</a>'; $type = '<span id="type' . $row->id . '" onclick="$(\'typeOption\').style.display = \'block\';$(this).style.display = \'none\';">' . JString::ucfirst($row->type) . '</span>'; $publish = $view->getPublish($row, 'published', 'profiles,ajaxTogglePublish'); if ($row->type == 'label') { $required = $view->showPublish($row, 'required'); $visible = $view->showPublish($row, 'visible'); } else { $required = $view->getPublish($row, 'required', 'profiles,ajaxTogglePublish'); $visible = $view->getPublish($row, 'visible', 'profiles,ajaxTogglePublish'); } $registration = $view->getPublish($row, 'registration', 'profiles,ajaxTogglePublish'); // Set the parent id $parent = $row->id; // Update the rows in the table at the page. //@todo: need to update the title in a way looks like Joomla initialize the tooltip on document ready $response->addAssign('name' . $row->id, 'innerHTML', $name); $response->addAssign('type' . $row->id, 'innerHTML', $type); $response->addAssign('published' . $row->id, 'innerHTML', $publish); $response->addAssign('required' . $row->id, 'innerHTML', $required); $response->addAssign('visible' . $row->id, 'innerHTML', $visible); $response->addAssign('registration' . $row->id, 'innerHTML', $registration); $response->addAssign('min' . $row->id, 'value', $row->min); $response->addAssign('max' . $row->id, 'value', $row->max); } else { $response->addScriptCall('window.location.href = "' . JURI::base() . 'index.php?option=com_community&view=profiles";'); } $response->addScriptCall('cWindowHide();'); } else { //release the form input back to enabled. $response->addScriptCall('joms.jQuery(\'#cWindowContent\').find(\'input, textarea, button\').attr(\'disabled\', false)'); } $response->sendResponse(); }
/** * Ajax function to accept Private Group Request * **/ public function ajaxGroupJoinRequest($memberId, $groupId) { $filter = JFilterInput::getInstance(); $groupId = $filter->clean($groupId, 'int'); $memberId = $filter->clean($memberId, 'int'); if (!COwnerHelper::isRegisteredUser()) { return $this->ajaxBlockUnregister(); } $objResponse = new JAXResponse(); $my = CFactory::getUser(); $model = $this->getModel('groups'); //CFactory::load( 'helpers' , 'owner' ); if (!$model->isAdmin($my->id, $groupId) && !COwnerHelper::isCommunityAdmin()) { $objResponse->addScriptCall(JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_ACCESS_SECTION')); } else { //Load Necessary Table $member = JTable::getInstance('GroupMembers', 'CTable'); $group = JTable::getInstance('Group', 'CTable'); // Load the group and the members table $group->load($groupId); $keys = array('groupId' => $groupId, 'memberId' => $memberId); $member->load($keys); // Only approve members that is really not approved yet. if ($member->approved) { $objResponse->addScriptCall('joms.jQuery("#error-request-' . $group->id . '").html("' . JText::_('COM_COMMUNITY_EVENTS_NOT_INVITED_NOTIFICATION') . '");'); $objResponse->addScriptCall('joms.jQuery("#error-request-' . $group->id . '").attr("class", "error");'); } else { $member->approve(); $user = CFactory::getUser($memberId); $user->updateGroupList(true); // Add notification //CFactory::load( 'libraries' , 'notification' ); $params = new CParameter(''); $params->set('url', CRoute::getExternalURL('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id)); $params->set('group', $group->name); $params->set('group_url', 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id); CNotificationLibrary::add('groups_member_approved', $group->ownerid, $user->id, JText::sprintf('COM_COMMUNITY_GROUP_MEMBER_APPROVED_EMAIL_SUBJECT'), '', 'groups.memberapproved', $params); $act = new stdClass(); $act->cmd = 'group.join'; $act->actor = $memberId; $act->target = 0; $act->title = ''; //JText::sprintf('COM_COMMUNITY_GROUPS_ACTIVITIES_MEMBER_JOIN_GROUP' , '{group_url}' , $group->name ); $act->content = ''; $act->app = 'groups.join'; $act->cid = $group->id; $params = new CParameter(''); $params->set('action', 'group.join'); $params->set('group_url', 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id); // Add activity logging if (CUserPoints::assignPoint('group.join', $memberId)) { CActivityStream::addActor($act, $params->toString()); } //trigger for onGroupJoinApproved $this->triggerEvents('onGroupJoinApproved', $group, $memberId); $this->triggerEvents('onGroupJoin', $group, $memberId); // UPdate group stats(); $group->updateStats(); $group->store(); $url = CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id); $objResponse->addScriptCall('joms.jQuery("#msg-request-' . $memberId . '").html("' . addslashes(JText::sprintf('COM_COMMUNITY_EVENTS_ACCEPTED', $group->name, $url)) . '");'); $objResponse->addScriptCall('joms.notifications.updateNotifyCount();'); $objResponse->addScriptCall('joms.jQuery("#noti-request-group-' . $memberId . '").fadeOut(1000, function() { joms.jQuery("#noti-request-group-' . $memberId . '").remove();} );'); $objResponse->addScriptCall('aspan = joms.jQuery(".cMenu-Icon b"); aspan.html(parseInt(aspan.html())-1);'); } } return $objResponse->sendResponse(); }
/** * */ public function ajaxSaveSettings($postvars) { // Check permissions $my =& JFactory::getUser(); $filter = JFilterInput::getInstance(); $postvars = $filter->clean($postvars, 'array'); if ($my->id == 0) { return $this->ajaxBlockUnregister(); } $objResponse = new JAXResponse(); $appsModel = CFactory::getModel('apps'); $appName = $postvars['appname']; $id = $postvars['appid']; // @rule: Test if app is core app as we need to add into the db $pluginId = $appsModel->getPluginId($appName); $appParam = new CParameter($appsModel->getPluginParams($pluginId)); if ($pluginId && $my->id != 0 && $appParam->get('coreapp')) { // Add new app in the community plugins table $appsModel->addApp($my->id, $appName); // @rule: For core applications, the ID might be referring to Joomla's id. Get the correct id if needed. $id = $appsModel->getUserApplicationId($appName, $my->id); } // Make sure this is valid for current user if (!$appsModel->isOwned($my->id, $id)) { // It could be that the app is a core app. $objResponse->addAlert('COM_COMMUNITY_PERMISSION_ERROR'); return $objResponse->sendResponse(); } $post = array(); // convert $postvars to normal post $pattern = "'params\\[(.*?)\\]'s"; for ($i = 0; $i < count($postvars); $i++) { if (!empty($postvars[$i]) && is_array($postvars[$i])) { $key = $postvars[$i][0]; // Blogger view preg_match($pattern, $key, $matches); if ($matches) { $key = $matches[1]; } $post[$key] = $postvars[$i][1]; } } $xmlPath = JPATH_COMPONENT . DS . 'applications' . DS . $appName . DS . $appName . '.xml'; $params = new CParameter($appsModel->getUserAppParams($id), $xmlPath); $params->bind($post); //echo $params->toString(); $appsModel->storeParams($id, $params->toString()); $objResponse->addScriptCall('cWindowHide'); return $objResponse->sendResponse(); }
/** * Show the message reading window */ public function read($data) { $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; if (!$this->accessAllowed('registered')) { return; } $config = CFactory::getConfig(); if (!$config->get('enablepm')) { echo JText::_('COM_COMMUNITY_PRIVATE_MESSAGING_DISABLED'); return; } //page title $document = JFactory::getDocument(); $inboxModel = CFactory::getModel('inbox'); $my = CFactory::getUser(); $msgid = $jinput->request->get('msgid', 0, 'INT'); if (!$inboxModel->canRead($my->id, $msgid)) { $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_PERMISSION_DENIED_WARNING'), 'error'); return; } $pathway = $mainframe->getPathway(); $pathway->addItem($this->escape(JText::_('COM_COMMUNITY_INBOX_TITLE')), CRoute::_('index.php?option=com_community&view=inbox')); $parentData = ''; $html = ''; $messageHeading = ''; $recipient = array(); $parentData = $inboxModel->getMessage($msgid); if (!empty($data->messages)) { $document = JFactory::getDocument(); $pathway->addItem($this->escape(htmlspecialchars_decode($parentData->subject))); $document->setTitle(htmlspecialchars_decode($parentData->subject)); require_once COMMUNITY_COM_PATH . '/libraries/apps.php'; $appsLib = CAppPlugins::getInstance(); $appsLib->loadApplications(); $config = CFactory::getConfig(); $pagination = intval($config->get('stream_default_comments', 5)); $count = count($data->messages); $hide = true; foreach ($data->messages as $row) { $count--; if ($count < $pagination) { $hide = false; } // onMessageDisplay Event trigger $args = array(); $originalBodyContent = $row->body; $row->body = new JRegistry($row->body); if ($row->body == '{}') { //backward compatibility, save the old data into content parameter if needed $newParam = new CParameter(); $newParam->set('content', $originalBodyContent); $table = JTable::getInstance('Message', 'CTable'); $table->load($row->id); $table->body = $newParam->toString(); $table->store(); $row->body = new CParameter($table->body); } // Escape content $content = $originalContent = $row->body->get('content'); $content = CTemplate::escape($content); $content = CStringHelper::autoLink($content); $content = nl2br($content); $content = CStringHelper::getEmoticon($content); $content = CStringHelper::converttagtolink($content); $content = CUserHelper::replaceAliasURL($content); $params = $row->body; $args[] = $row; $appsLib->triggerEvent('onMessageDisplay', $args); $user = CFactory::getUser($row->from); //construct the delete link $deleteLink = CRoute::_('index.php?option=com_community&view=inbox&task=remove&msgid=' . $row->id); $authorLink = CRoute::_('index.php?option=com_community&view=profile&userid=' . $user->id); //get thumbnail if available $photoThumbnail = ''; if ($params->get('attached_photo_id')) { $photo = JTable::getInstance('Photo', 'CTable'); $photo->load($params->get('attached_photo_id')); $photoThumbnail = $photo->getThumbURI(); } $tmpl = new CTemplate(); $html .= $tmpl->set('user', $user)->set('msg', $row)->set('hide', $hide)->set('originalContent', $originalContent)->set('content', $content)->set('params', $params)->set('isMine', COwnerHelper::isMine($my->id, $user->id))->set('removeLink', $deleteLink)->set('authorLink', $authorLink)->set('photoThumbnail', $photoThumbnail)->fetch('inbox.message'); } $myLink = CRoute::_('index.php?option=com_community&view=profile&userid=' . $my->id); $recipient = $inboxModel->getRecepientMessage($msgid); $recepientCount = count($recipient); $textOther = $recepientCount > 1 ? 'COM_COMMUNITY_MSG_OTHER' : 'COM_COMMUNITY_MSG_OTHER_SINGULAR'; $messageHeading = JText::sprintf('COM_COMMUNITY_MSG_BETWEEN_YOU_AND_USER', $myLink, '#', JText::sprintf($textOther, $recepientCount)); } else { $html = '<div class="text">' . JText::_('COM_COMMUNITY_INBOX_MESSAGE_EMPTY') . '</div>'; } //end if $tmplMain = new CTemplate(); echo $tmplMain->set('messageHeading', $messageHeading)->set('recipient', $recipient)->set('limit', $pagination)->set('messages', $data->messages)->set('parentData', $parentData)->set('htmlContent', $html)->set('my', $my)->set('submenu', $this->showSubmenu(false))->fetch('inbox.read'); }
/** * AJAX method to add predefined activity * */ public function ajaxAddPredefined($key, $message = '', $privacy = 0) { $objResponse = new JAXResponse(); $my = CFactory::getUser(); $filter = JFilterInput::getInstance(); $key = $filter->clean($key, 'string'); $message = $filter->clean($message, 'string'); $privacy = $filter->clean($privacy, 'int'); if (!COwnerHelper::isCommunityAdmin() || empty($message)) { return; } // Predefined system custom activity. $system = array('system.registered', 'system.populargroup', 'system.totalphotos', 'system.popularprofiles', 'system.popularphotos', 'system.popularvideos'); $act = new stdClass(); $act->actor = 0; //$my->id; System message should not capture actor. Otherwise the stream filter will be inaccurate $act->target = 0; $act->app = 'system'; $act->access = !$privacy ? 0 : $privacy; $params = new CParameter(''); if (in_array($key, $system)) { switch ($key) { case 'system.registered': // $usersModel = CFactory::getModel( 'user' ); // $now = new JDate(); // $date = CTimeHelper::getDate(); // $title = JText::sprintf('COM_COMMUNITY_TOTAL_USERS_REGISTERED_THIS_MONTH_ACTIVITY_TITLE', $usersModel->getTotalRegisteredByMonth($now->format('Y-m')) , $date->_monthToString($now->format('m'))); $act->app = 'system.members.registered'; $act->cmd = 'system.registered'; $act->title = ''; $act->content = ''; $params->set('action', 'registered_users'); break; case 'system.populargroup': // $groupsModel = CFactory::getModel('groups'); // $activeGroup = $groupsModel->getMostActiveGroup(); // $title = JText::sprintf('COM_COMMUNITY_MOST_POPULAR_GROUP_ACTIVITY_TITLE', $activeGroup->name); // $act->cmd = 'groups.popular'; // $act->cid = $activeGroup->id; // $act->title = $title; $act->app = 'system.groups.popular'; $params->set('action', 'top_groups'); // $params->set('group_url', CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid='.$activeGroup->id)); break; case 'system.totalphotos': // $photosModel = CFactory::getModel( 'photos' ); // $total = $photosModel->getTotalSitePhotos(); $act->app = 'system.photos.total'; $act->cmd = 'photos.total'; $act->title = ''; //JText::sprintf('COM_COMMUNITY_TOTAL_PHOTOS_ACTIVITY_TITLE', $total); $params->set('action', 'total_photos'); // $params->set('photos_url', CRoute::_('index.php?option=com_community&view=photos')); break; case 'system.popularprofiles': $act->app = 'system.members.popular'; $act->cmd = 'members.popular'; $act->title = ''; //JText::sprintf('COM_COMMUNITY_ACTIVITIES_TOP_PROFILES', 5); $params->set('action', 'top_users'); // $params->set('count', 5); break; case 'system.popularphotos': $act->app = 'system.photos.popular'; $act->cmd = 'photos.popular'; $act->title = ''; //JText::sprintf('COM_COMMUNITY_ACTIVITIES_TOP_PHOTOS', 5); $params->set('action', 'top_photos'); // $params->set('count', 5); break; case 'system.popularvideos': $act->app = 'system.videos.popular'; $act->cmd = 'videos.popular'; $act->title = ''; //JText::sprintf( 'COM_COMMUNITY_ACTIVITIES_TOP_VIDEOS', 5 ); $params->set('action', 'top_videos'); // $params->set('count', 5); break; } } else { // For additional custom activities, we only take the content passed by them. if (!empty($message)) { $message = CStringHelper::escape($message); $app = explode('.', $key); $app = isset($app[0]) ? $app[0] : 'system'; $act->app = 'system.message'; $act->title = $message; $params->set('action', 'message'); } } $this->cacheClean(array(COMMUNITY_CACHE_TAG_ACTIVITIES)); // Allow comments on all these $act->comment_id = CActivities::COMMENT_SELF; $act->comment_type = $key; // Allow like for all admin activities $act->like_id = CActivities::LIKE_SELF; $act->like_type = $key; // Add activity logging CActivityStream::add($act, $params->toString()); $objResponse->addAssign('activity-stream-container', 'innerHTML', $this->_getActivityStream()); $objResponse->addScriptCall("joms.jQuery('.jomTipsJax').addClass('jomTips');"); $objResponse->addScriptCall('joms.tooltip.setup();'); return $objResponse->sendResponse(); }
/** * */ public static function joinApproved($groupId, $userid) { $group = JTable::getInstance('Group', 'CTable'); $member = JTable::getInstance('GroupMembers', 'CTable'); $group->load($groupId); $act = new stdClass(); $act->cmd = 'group.join'; $act->actor = $userid; $act->target = 0; $act->title = ''; //JText::sprintf('COM_COMMUNITY_GROUPS_GROUP_JOIN' , '{group_url}' , $group->name ); $act->content = ''; $act->app = 'groups.join'; $act->cid = $group->id; $act->groupid = $group->id; $params = new CParameter(''); $params->set('group_url', 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id); $params->set('action', 'group.join'); // Add logging if (CUserPoints::assignPoint('group.join')) { CActivityStream::addActor($act, $params->toString()); } // Store the group and update stats $group->updateStats(); $group->store(); }
/** * To remove url fetching * @param $msgId */ public function ajaxRemovePreview($msgId) { $filter = JFilterInput::getInstance(); $msgId = $filter->clean($msgId, 'int'); $my = CFactory::getUser(); $messageTable = $photo = JTable::getInstance('Message', 'CTable'); $messageTable->load($msgId); $params = new CParameter($messageTable->body); //if there is a fetched content if ($params->get('url')) { $newParam = new CParameter(); $newParam->set('content', $params->get('content')); $messageTable->body = $newParam->toString(); $messageTable->store(); $params = $newParam; } $deleteLink = CRoute::_('index.php?option=com_community&view=inbox&task=remove&msgid=' . $messageTable->id); $authorLink = CRoute::_('index.php?option=com_community&view=profile&userid=' . $messageTable->from); // Escape content $content = $originalContent = $params->get('content'); $content = CTemplate::escape($content); $content = CStringHelper::autoLink($content); $content = nl2br($content); $content = CStringHelper::getEmoticon($content); $content = CStringHelper::converttagtolink($content); //get thumbnail if available $photoThumbnail = ''; if ($params->get('attached_photo_id')) { $photo = JTable::getInstance('Photo', 'CTable'); $photo->load($params->get('attached_photo_id')); $photoThumbnail = $photo->getThumbURI(); } $tmpl = new CTemplate(); $tmpl->set('user', CFactory::getUser($messageTable->from)); $tmpl->set('msg', $messageTable); $tmpl->set('originalContent', $originalContent); $tmpl->set('content', $content); $tmpl->set('params', $params); $tmpl->set('removeLink', $deleteLink); $tmpl->set('authorLink', $authorLink); $tmpl->set('photoThumbnail', $photoThumbnail); $html = $tmpl->fetch('inbox.message'); $json = array(); $json['success'] = true; $json['html'] = $html; die(json_encode($json)); }
/** * In 2.4, wall is removed and converted to stream data * On first load, import old wall to stream data */ public function upgradeWallToStream() { $params = new CParameter($this->params); if ($params->get('stream') != 1) { $this->groupActivitiesMigrate(); /* UPDATE `jos_community_activities` as a SET a.`title` = a.`content` , a.`content` = '', a.`groupid`= a.`cid`, a.`comment_type` = 'groups.wall', a.`comment_id` = a.`id`, a.`like_type` = 'groups.wall', a.`like_id` = a.`id`, a.`params` = '' WHERE a.`app` = 'groups.wall' AND a.`groupid` IS NULL $query = 'UPDATE '. $this->_db->quoteName('#__community_activities') . ' as a ' .' SET ' .' a.'. $this->_db->quoteName('title'). ' = '. $this->_db->quoteName('content'). ' , ' .' a.'. $this->_db->quoteName('content'). ' = '. $this->_db->Quote(''). ', ' .' a.'. $this->_db->quoteName('groupid'). '= a.'. $this->_db->quoteName('cid'). ', ' .' a.'. $this->_db->quoteName('comment_type'). ' = '. $this->_db->Quote('groups.wall'). ', ' .' a.'. $this->_db->quoteName('comment_id'). ' = a.'. $this->_db->quoteName('id'). ', ' .' a.'. $this->_db->quoteName('like_type'). ' = '. $this->_db->Quote('groups.wall'). ', ' .' a.'. $this->_db->quoteName('like_id'). ' = a.'. $this->_db->quoteName('id'). ', ' .' a.'. $this->_db->quoteName('params'). ' = '. $this->_db->Quote('') .' WHERE ' .' a.'. $this->_db->quoteName('app'). ' = '. $this->_db->Quote('groups.wall') .' AND a.'. $this->_db->quoteName('groupid'). ' IS NULL '; $this->_db->setQuery($query); $this->_db->Query(); */ // Mark this group as upgraded $params = new CParameter($this->params); $params->set('stream', 1); $this->params = $params->toString(); // Store will upgrade save the params AND update stream group_access data $this->store(); } }
public function saveGroup() { $group = JTable::getInstance('Groups', 'CommunityTable'); $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; $id = $jinput->post->get('id', '', 'INT'); if (empty($id)) { JError::raiseError('500', JText::_('COM_COMMUNITY_INVALID_ID')); } $postData = JRequest::get('post'); $description = JRequest::getVar('description', '', 'post', 'string', JREQUEST_ALLOWRAW); $postData['description'] = $description; if (!isset($postData['groupdiscussionfilesharing'])) { $postData['groupdiscussionfilesharing'] = 0; } if (!isset($postData['groupannouncementfilesharing'])) { $postData['groupannouncementfilesharing'] = 0; } $group->load($id); $groupParam = new CParameter($group->params); $group->bind($postData); foreach ($postData as $key => $data) { if (!is_null($groupParam->get($key, NULL))) { $groupParam->set($key, $data); } } $group->params = $groupParam->toString(); $message = ''; if ($group->store()) { $message = JText::_('COM_COMMUNITY_GROUP_SAVED'); } else { $message = JText::_('COM_COMMUNITY_GROUP_SAVE_ERROR'); } $mainframe = JFactory::getApplication(); $mainframe->redirect('index.php?option=com_community&view=groups', $message, 'message'); }
/** * Add stream for new created event. * @since 2.6 **/ public static function addEventStream($event) { //CFactory::load( 'helpers' , 'event' ); $handler = CEventHelper::getHandler($event); $my = CFactory::getUser(); //CFactory::load( 'helpers' , 'event' ); $handler = CEventHelper::getHandler($event); // Activity stream purpose if the event is a public event $action_str = 'events.create'; if ($event->isPublished() && !$event->isUnlisted()) { $actor = $event->creator; $target = 0; $content = ''; $cid = $event->id; $app = 'events'; $act = $handler->getActivity('events.create', $actor, $target, $content, $cid, $app); $url = $handler->getFormattedLink('index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id, false, true, false); // Set activity group id if the event is in group $act->groupid = $event->type == 'group' ? $event->contentid : null; $act->eventid = $event->id; $act->location = $event->location; $act->comment_id = $event->id; $act->comment_type = 'events'; $act->like_id = $event->id; $act->like_type = 'events'; $params = new CParameter(''); $cat_url = $handler->getFormattedLink('index.php?option=com_community&view=events&task=display&categoryid=' . $event->catid, false, true, false); $params->set('action', $action_str); $params->set('event_url', $url); $params->set('event_category_url', $cat_url); // Add activity logging CActivityStream::add($act, $params->toString()); } }