Exemple #1
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;
 }
Exemple #2
0
 /**
  * Update the user status
  * 
  * @param	int		user id
  * @param	string	the message. Should be < 140 char (controller check)	 	 	 
  */
 function update($id, $status)
 {
     $db =& $this->getDBO();
     $my = CFactory::getUser();
     // @todo: posted_on should be constructed to make sure we take into account
     // of Joomla server offset
     // Current user and update id should always be the same
     CError::assert($my->id, $id, 'eq', __FILE__, __LINE__);
     // Trigger onStatusUpdate
     require_once COMMUNITY_COM_PATH . DS . 'libraries' . DS . 'apps.php';
     $appsLib =& CAppPlugins::getInstance();
     $appsLib->loadApplications();
     $args = array();
     $args[] = $my->id;
     // userid
     $args[] = $my->getStatus();
     // old status
     $args[] = $status;
     // new status
     $appsLib->triggerEvent('onProfileStatusUpdate', $args);
     $today =& JFactory::getDate();
     $data = new stdClass();
     $data->userid = $id;
     $data->status = $status;
     $data->posted_on = $today->toMySQL();
     $db->updateObject('#__community_users', $data, 'userid');
     if ($db->getErrorNum()) {
         JError::raiseError(500, $db->stderr());
     }
 }
 /**
  * Add new notification
  * @return  true
  */
 public function add($from, $to, $content, $cmd = '', $type = '', $params = '')
 {
     jimport('joomla.utilities.date');
     $db = $this->getDBO();
     $date = JFactory::getDate();
     $config = CFactory::getConfig();
     $notification = JTable::getInstance('notification', 'CTable');
     //respect notification setting
     //filter result by cmd_type
     $validate = true;
     $user = CFactory::getUser($to);
     $user_params = $user->getParams();
     if (!empty($cmd)) {
         $validate = $user_params->get($cmd, $config->get($cmd)) == 1 ? true : false;
     }
     if ($validate) {
         $notification->actor = $from;
         $notification->target = $to;
         $notification->content = $content;
         $notification->created = $date->toSql();
         $notification->params = is_object($params) && method_exists($params, 'toString') ? $params->toString() : '';
         $notification->cmd_type = $cmd;
         $notification->type = $type;
         $notification->store();
     }
     $appsLib = CAppPlugins::getInstance();
     $appsLib->triggerEvent('onNotificationAdd', array($notification));
     //delete the oldest notification
     $this->deleteOldest($to);
     return true;
 }
Exemple #4
0
 public function register($data = null)
 {
     //require_once (JPATH_COMPONENT.'/libraries/profile.php');
     $mainframe = JFactory::getApplication();
     $my = CFactory::getUser();
     $config = CFactory::getConfig();
     /**
      * Opengraph
      */
     CHeadHelper::setType('website', JText::_('COM_COMMUNITY_REGISTER_NEW'));
     // Hide this form for logged in user
     if ($my->id) {
         $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_REGISTER_ALREADY_USER'), 'warning');
         return;
     }
     // If user registration is not allowed, show 403 not authorized.
     $usersConfig = JComponentHelper::getParams('com_users');
     if ($usersConfig->get('allowUserRegistration') == '0') {
         //show warning message
         $this->addWarning(JText::_('COM_COMMUNITY_REGISTRATION_DISABLED'));
         return;
     }
     $fields = array();
     $post = JRequest::get('post');
     $isUseFirstLastName = CUserHelper::isUseFirstLastName();
     $data = array();
     $data['fields'] = $fields;
     $data['html_field']['jsname'] = empty($post['jsname']) ? '' : $post['jsname'];
     $data['html_field']['jsusername'] = empty($post['jsusername']) ? '' : $post['jsusername'];
     $data['html_field']['jsemail'] = empty($post['jsemail']) ? '' : $post['jsemail'];
     $data['html_field']['jsfirstname'] = empty($post['jsfirstname']) ? '' : $post['jsfirstname'];
     $data['html_field']['jslastname'] = empty($post['jslastname']) ? '' : $post['jslastname'];
     // $js = 'assets/validate-1.5.min.js';
     // CFactory::attach($js, 'js');
     $recaptcha = new CRecaptchaHelper();
     $recaptchaHTML = $recaptcha->html();
     $fbHtml = '';
     if ($config->get('fbconnectkey') && $config->get('fbconnectsecret') && !$config->get('usejfbc')) {
         //CFactory::load( 'libraries' , 'facebook' );
         $facebook = new CFacebook();
         $fbHtml = $facebook->getLoginHTML();
     }
     if ($config->get('usejfbc')) {
         if (class_exists('JFBCFactory')) {
             $providers = JFBCFactory::getAllProviders();
             foreach ($providers as $p) {
                 $fbHtml .= $p->loginButton();
             }
         }
     }
     $tmpl = new CTemplate();
     $content = $tmpl->set('data', $data)->set('recaptchaHTML', $recaptchaHTML)->set('config', $config)->set('isUseFirstLastName', $isUseFirstLastName)->set('fbHtml', $fbHtml)->fetch('register/base');
     $appsLib = CAppPlugins::getInstance();
     $appsLib->loadApplications();
     $args = array(&$content);
     $appsLib->triggerEvent('onUserRegisterFormDisplay', $args);
     echo $this->_getProgressBar(1);
     echo $content;
 }
Exemple #5
0
 public function register($data = null)
 {
     require_once JPATH_COMPONENT . DS . 'libraries' . DS . 'profile.php';
     $mainframe =& JFactory::getApplication();
     $my = CFactory::getUser();
     $config = CFactory::getConfig();
     $document = JFactory::getDocument();
     $document->setTitle(JText::_('COM_COMMUNITY_REGISTER_NEW'));
     // Hide this form for logged in user
     if ($my->id) {
         $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_REGISTER_ALREADY_USER'), 'warning');
         return;
     }
     // If user registration is not allowed, show 403 not authorized.
     $usersConfig =& JComponentHelper::getParams('com_users');
     if ($usersConfig->get('allowUserRegistration') == '0') {
         //show warning message
         $this->addWarning(JText::_('COM_COMMUNITY_REGISTRATION_DISABLED'));
         return;
     }
     $fields = array();
     $empty_html = array();
     $post = JRequest::get('post');
     CFactory::load('helpers', 'user');
     $isUseFirstLastName = CUserHelper::isUseFirstLastName();
     $data = array();
     $data['fields'] = $fields;
     $data['html_field']['jsname'] = empty($post['jsname']) ? '' : $post['jsname'];
     $data['html_field']['jsusername'] = empty($post['jsusername']) ? '' : $post['jsusername'];
     $data['html_field']['jsemail'] = empty($post['jsemail']) ? '' : $post['jsemail'];
     $data['html_field']['jsfirstname'] = empty($post['jsfirstname']) ? '' : $post['jsfirstname'];
     $data['html_field']['jslastname'] = empty($post['jslastname']) ? '' : $post['jslastname'];
     $js = 'assets/validate-1.5';
     $js .= $config->getBool('usepackedjavascript') ? '.pack.js' : '.js';
     CAssets::attach($js, 'js');
     // @rule: Load recaptcha if required.
     CFactory::load('helpers', 'recaptcha');
     $recaptchaHTML = getRecaptchaHTMLData();
     $fbHtml = '';
     if ($config->get('fbconnectkey') && $config->get('fbconnectsecret')) {
         CFactory::load('libraries', 'facebook');
         $facebook = new CFacebook();
         $fbHtml = $facebook->getLoginHTML();
     }
     $tmpl = new CTemplate();
     $content = $tmpl->set('data', $data)->set('recaptchaHTML', $recaptchaHTML)->set('config', $config)->set('isUseFirstLastName', $isUseFirstLastName)->set('fbHtml', $fbHtml)->fetch('register.index');
     $appsLib =& CAppPlugins::getInstance();
     $appsLib->loadApplications();
     $args = array(&$content);
     $appsLib->triggerEvent('onUserRegisterFormDisplay', $args);
     echo $this->_getProgressBar(1);
     echo $content;
 }
Exemple #6
0
 /**
  * add points to user based on the action.
  * @param $action
  * @param null $userId
  */
 public static function assignPoint($action, $userId = null)
 {
     //get the rule points
     //must use the JFactory::getUser to get the aid
     $juser = JFactory::getUser($userId);
     //since 4.0, check if this action is published, else return false (boolean)
     $userPointModel = CFactory::getModel('Userpoints');
     $point = $userPointModel->getPointData($action);
     if (!isset($point->published) || !$point->published) {
         return false;
     }
     if ($juser->id != 0) {
         if (!method_exists($juser, 'getAuthorisedViewLevels')) {
             $aid = $juser->aid;
             // if the aid is null, means this is not the current logged-in user.
             // so we need to manually get this aid for this user.
             if (is_null($aid)) {
                 $aid = 0;
                 //defautl to 0
                 // Get an ACL object
                 $acl = JFactory::getACL();
                 $grp = $acl->getAroGroup($juser->id);
                 $group = 'USERS';
                 if ($acl->is_group_child_of($grp->name, $group)) {
                     $aid = 1;
                     // Fudge Authors, Editors, Publishers and Super Administrators into the special access group
                     if ($acl->is_group_child_of($grp->name, 'Registered') || $acl->is_group_child_of($grp->name, 'Public Backend')) {
                         $aid = 2;
                     }
                 }
             }
         } else {
             //joomla 1.6
             $aid = $juser->getAuthorisedViewLevels();
         }
         $points = CUserPoints::_getActionPoint($action, $aid);
         $user = CFactory::getUser($userId);
         $points += $user->getKarmaPoint();
         $user->_points = $points;
         $profile = JTable::getInstance('Profile', 'CTable');
         $profile->load($user->id);
         $user->_thumb = $profile->thumb;
         $user->_avatar = $profile->avatar;
         $user->save();
         //Event trigger
         $appsLib = CAppPlugins::getInstance();
         $appsLib->loadApplications();
         $params = array('action' => $action, 'points' => $points, 'userId' => $user->id);
         $appsLib->triggerEvent('onAfterAssignPoint', $params);
         return true;
     }
 }
Exemple #7
0
 public function ajaxShowBookmarks($uri)
 {
     $filter = JFilterInput::getInstance();
     $uri = $filter->clean($uri, 'string');
     $config = CFactory::getConfig();
     $shareviaemail = $config->get('shareviaemail');
     //CFactory::load( 'libraries' , 'bookmarks' );
     $bookmarks = new CBookmarks($uri);
     //CFactory::load( 'libraries' , 'apps' );
     $appsLib = CAppPlugins::getInstance();
     $appsLib->loadApplications();
     // @onLoadBookmarks deprecated.
     // since 1.5
     $appsLib->triggerEvent('onLoadBookmarks', array($bookmarks));
     $tmpl = new CTemplate();
     $tmpl->set('config', $config)->set('bookmarks', $bookmarks->getBookmarks());
     $json = array('title' => JText::_('COM_COMMUNITY_SHARE_THIS'), 'html' => $tmpl->fetch('bookmarks.list'), 'btnShare' => JText::_('COM_COMMUNITY_SHARE_BUTTON'), 'btnCancel' => JText::_('COM_COMMUNITY_CANCEL_BUTTON'), 'viaEmail' => $shareviaemail ? true : false);
     die(json_encode($json));
 }
Exemple #8
0
 function run()
 {
     jimport('joomla.filesystem.file');
     set_time_limit(120);
     $this->_sendEmails();
     $this->_convertVideos();
     $this->_sendSiteDetails();
     $this->_archiveActivities();
     $this->_cleanRSZFiles();
     $this->_processPhotoStorage();
     $this->_updatePhotoFileSize();
     $this->_updateVideoFileSize();
     $this->_removeDeletedPhotos();
     $this->_processVideoStorage();
     $this->_processUserAvatarStorage();
     // Include CAppPlugins library
     require_once JPATH_COMPONENT . DS . 'libraries' . DS . 'apps.php';
     // Trigger system event onCronRun
     $appsLib =& CAppPlugins::getInstance();
     $appsLib->loadApplications();
     $args = array();
     $appsLib->triggerEvent('onCronRun', $args);
 }
Exemple #9
0
 /**
  * Add new activity into stream
  * @param array|object $data
  * @return CActivity|boolean
  */
 public static function add($data)
 {
     $activity = new CActivity($data);
     /**
      * @todo We'll move all event trigger into this class not in table class or anywhere
      * @todo Anything else we want to include when posting please put here
      */
     /* Event trigger */
     $appsLib = CAppPlugins::getInstance();
     $appsLib->loadApplications();
     $params = array();
     $params[] =& $activity;
     /* We do raise event here that will allow user change $activity properties before save it */
     $appsLib->triggerEvent('onBeforeActivitySave', $params);
     if ($activity->get('cmd')) {
         /* Userpoints */
         $userPointModel = CFactory::getModel('Userpoints');
         $point = $userPointModel->getPointData($activity->get('cmd'));
         if ($point) {
             /**
              * @todo Need clearly about this !
              * for every unpublished user points the stream will be disabled for that item
              * but not sure if this for 3rd party API, this feature should be available or not?
              */
             if (!$point->published) {
                 //return;
             }
         }
     }
     if ($activity->save()) {
         $params = array();
         $params[] =& $activity;
         $appsLib->triggerEvent('onAfterActivitySave', $params);
         return $activity;
     }
     return false;
 }
Exemple #10
0
 public function ajaxShowBookmarks($uri)
 {
     $filter = JFilterInput::getInstance();
     $uri = $filter->clean($uri, 'string');
     CFactory::load('libraries', 'bookmarks');
     $bookmarks = new CBookmarks($uri);
     CFactory::load('libraries', 'apps');
     $appsLib =& CAppPlugins::getInstance();
     $appsLib->loadApplications();
     // @onLoadBookmarks deprecated.
     // since 1.5
     $appsLib->triggerEvent('onLoadBookmarks', array($bookmarks));
     $response = new JAXResponse();
     $tmpl = new CTemplate();
     $tmpl->set('bookmarks', $bookmarks->getBookmarks());
     $html = $tmpl->fetch('bookmarks.list');
     $total = $bookmarks->getTotalBookmarks();
     $height = $total * 10;
     $actions = '<input type="button" class="button" onclick="joms.bookmarks.email(\'' . $uri . '\');" value="' . JText::_('COM_COMMUNITY_SHARE_BUTTON') . '"/>';
     $actions .= '<input type="button" class="button" onclick="cWindowHide();" value="' . JText::_('COM_COMMUNITY_CANCEL_BUTTON') . '"/>';
     $response->addAssign('cwin_logo', 'innerHTML', JText::_('COM_COMMUNITY_SHARE_THIS'));
     $response->addScriptCall('cWindowAddContent', $html, $actions);
     return $response->sendResponse();
 }
Exemple #11
0
 /**
  * Step 4
  * Update the users profile.
  */
 public function registerUpdateProfile()
 {
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $model = $this->getModel('register');
     // Check for request forgeries
     $mySess = JFactory::getSession();
     $ipAddress = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
     $token = $mySess->get('JS_REG_TOKEN', '');
     $formToken = $jinput->request->get('authkey', '', 'STRING');
     //JRequest::getVar( 'authkey', '', 'REQUEST');
     //$authKey   = $model->getAssignedAuthKey($token, $ipAddress);
     if (!$token) {
         //(empty($formToken) || empty($authKey) || ($formToken != $authKey))
         echo '<div class="error-box">' . JText::_('COM_COMMUNITY_INVALID_SESSION') . '</div>';
         return;
     }
     //intercept validation process in custom profile
     $post = JRequest::get('post');
     /*
      * Rules:
      * First we let 3rd party plugin to intercept the validation.
      * if there is not error return, we then proceed with our validation.
      */
     $errMsg = array();
     $errTrigger = null;
     $appsLib = CAppPlugins::getInstance();
     $appsLib->loadApplications();
     $params = array();
     $params[] = $post;
     $errTrigger = $appsLib->triggerEvent('onRegisterProfileValidate', $params);
     if (!is_null($errTrigger)) {
         if (!empty($errTrigger[0]) && count($errTrigger[0]) > 0) {
             //error found.
             foreach ($errTrigger[0] as $err) {
                 $mainframe->enqueueMessage($err, 'error');
             }
             $this->registerProfile();
             return;
         }
     }
     // get required obj for registration
     $pModel = $this->getModel('profile');
     $values = array();
     $filter = array('published' => '1', 'registration' => '1');
     $profileType = JRequest::getInt('profileType', 0, 'POST');
     $profiles = $pModel->getAllFields($filter, $profileType);
     foreach ($profiles as $key => $groups) {
         foreach ($groups->fields as $data) {
             $fieldValue = new stdClass();
             // Get value from posted data and map it to the field.
             // Here we need to prepend the 'field' before the id because in the form, the 'field' is prepended to the id.
             $postData = $jinput->post->get('field' . $data->id, '', 'NONE');
             //JRequest::getVar('field'.$data->id, '', 'POST');
             // Retrieve the privacy data for this particular field.
             $fieldValue->access = JRequest::getInt('privacy' . $data->id, 0, 'POST');
             $fieldValue->value = CProfileLibrary::formatData($data->type, $postData);
             if (get_magic_quotes_gpc()) {
                 $fieldValue->value = stripslashes($fieldValue->value);
             }
             $values[$data->id] = $fieldValue;
             // @rule: Validate custom profile if necessary
             if (!CProfileLibrary::validateField($data->id, $data->type, $values[$data->id]->value, $data->required)) {
                 // If there are errors on the form, display to the user.
                 $message = JText::sprintf('COM_COMMUNITY_FIELD_CONTAIN_IMPROPER_VALUES', $data->name);
                 $mainframe->enqueueMessage($message, 'error');
                 $this->registerProfile();
                 return;
             }
         }
     }
     $profileType = $jinput->post->get('profileType', 0, 'NONE');
     //JRequest::getVar('profileType', 0, 'POST');
     $multiprofile = JTable::getInstance('MultiProfile', 'CTable');
     $multiprofile->load($profileType);
     $tmpUser = $model->getTempUser($token);
     $user = $this->_createUser($tmpUser, $multiprofile->approvals, $multiprofile->id);
     //update the first/last name if it exist in the profile configuration
     $this->_updateFirstLastName($user);
     $pModel->saveProfile($user->id, $values);
     // Update user location data
     $pModel->updateLocationData($user->id);
     $this->sendEmail('registration_complete', $user, null, $multiprofile->approvals);
     // now we need to set it for later avatar upload page
     // do the clear up job for tmp user.
     $mySess->set('tmpUser', $user);
     $model->removeTempUser($token);
     $model->removeAuthKey($token);
     //redirect to avatar upload page.
     $mainframe->redirect(CRoute::_('index.php?option=com_community&view=register&task=registerAvatar&profileType=' . $profileType, false));
 }
Exemple #12
0
 function uploadAvatar()
 {
     $document =& JFactory::getDocument();
     $document->setTitle(JText::_('CC UPLOAD EVENT AVATAR'));
     $eventid = JRequest::getVar('eventid', '0');
     $this->_addEventInPathway($eventid);
     $this->addPathway(JText::_('CC UPLOAD EVENT AVATAR'));
     $this->showSubmenu();
     $event =& JTable::getInstance('Event', 'CTable');
     $event->load($eventid);
     CFactory::load('helpers', 'event');
     $handler = CEventHelper::getHandler($event);
     if (!$handler->manageable()) {
         $this->noAccess();
         return;
     }
     $config = CFactory::getConfig();
     $uploadLimit = (double) $config->get('maxuploadsize');
     $uploadLimit .= 'MB';
     CFactory::load('models', 'events');
     $event =& JTable::getInstance('Event', 'CTable');
     $event->load($eventid);
     CFactory::load('libraries', 'apps');
     $app =& CAppPlugins::getInstance();
     $appFields = $app->triggerEvent('onFormDisplay', array('jsform-events-uploadavatar'));
     $beforeFormDisplay = CFormElement::renderElements($appFields, 'before');
     $afterFormDisplay = CFormElement::renderElements($appFields, 'after');
     $tmpl = new CTemplate();
     $tmpl->set('beforeFormDisplay', $beforeFormDisplay);
     $tmpl->set('afterFormDisplay', $afterFormDisplay);
     $tmpl->set('eventId', $eventid);
     $tmpl->set('avatar', $event->getAvatar('avatar'));
     $tmpl->set('thumbnail', $event->getAvatar());
     $tmpl->set('uploadLimit', $uploadLimit);
     echo $tmpl->fetch('events.uploadavatar');
 }
Exemple #13
0
 /**
  * Execute a request
  */
 public function execute($task = '')
 {
     global $mainframe;
     $document =& JFactory::getDocument();
     $my =& JFactory::getUser();
     $pathway =& $mainframe->getPathway();
     $menus =& JSite::getMenu();
     $menuitem =& $menus->getActive();
     $userId = JRequest::getInt('userid', '', 'GET');
     $tmpl = JRequest::getVar('tmpl', '', 'REQUEST');
     $format = JRequest::getVar('format', '', 'REQUEST');
     $nohtml = JRequest::getVar('no_html', '', 'REQUEST');
     if ($tmpl != 'component' && $format != 'feed' && $format != 'ical' && $nohtml != 1 && $format != 'raw') {
         // This is to fix MSIE that has incorrect user agent because jquery doesn't detect correctly.
         $ieFix = "<!--[if IE 6]><script type=\"text/javascript\">var jomsIE6 = true;</script><![endif]-->";
         $document->addCustomTag($ieFix);
     }
     // Add custom css for the specific view if needed.
     $config = CFactory::getConfig();
     $viewName = JString::strtolower(JRequest::getVar('view', '', 'REQUEST'));
     jimport('joomla.filesystem.file');
     if ($config->get('enablecustomviewcss')) {
         CTemplate::addStylesheet($viewName);
     }
     $env = CTemplate::getTemplateEnvironment();
     $html = '<div id="community-wrap" class="on-' . $env->joomlaTemplate . ' ' . $document->direction . '">';
     // Build the component menu module
     ob_start();
     CTemplate::renderModules('js_top');
     $moduleHTML = ob_get_contents();
     ob_end_clean();
     $html .= $moduleHTML;
     // Build the content HTML
     CFactory::load('helpers', 'azrul');
     $inbox =& $this->getModel('inbox');
     $unread = $inbox->countUnRead(array('user_id' => $my->id));
     $param = array('inbox' => $unread);
     if (!empty($task) && method_exists($this, $task)) {
         ob_start();
         if (method_exists($this, '_viewEnabled') && !$this->_viewEnabled()) {
             echo property_exists($this, '_disabledMessage') ? $this->_disabledMessage : JText::_('Function is disabled');
         } else {
             $this->{$task}();
         }
         $output = ob_get_contents();
         ob_end_clean();
     } else {
         ob_start();
         $this->display();
         $output = ob_get_contents();
         ob_end_clean();
     }
     // Build toolbar HTML
     ob_start();
     $view =& $this->getView(JRequest::getCmd('view', 'frontpage'));
     $view->showToolbar($param);
     // Header title will use view->title. If not specified, we will
     // use current page title
     $headerTitle = !empty($view->title) ? $view->title : $document->getTitle();
     $view->showHeader($headerTitle, $this->_icon);
     $header = ob_get_contents();
     ob_end_clean();
     $html .= $header;
     // @rule: Super admin should always be allowed regardless of their block status
     // block member to access profile owner details
     CFactory::load('helpers', 'owner');
     CFactory::load('libraries', 'block');
     $getBlockStatus = new blockUser();
     $blocked = $getBlockStatus->isUserBlocked($userId, $viewName);
     if ($blocked) {
         if (COwnerHelper::isCommunityAdmin()) {
             $mainframe =& JFactory::getApplication();
             $mainframe->enqueueMessage(JText::_('CC YOU ARE BLOCKED BY USER', 'error'));
         } else {
             $tmpl = new CTemplate();
             $output .= $tmpl->fetch('block.denied');
         }
     }
     // Build the component bottom module
     ob_start();
     CTemplate::renderModules('js_bottom');
     $moduleHTML = ob_get_contents();
     ob_end_clean();
     $html .= $output . $moduleHTML . '</div>';
     CFactory::load('helpers', 'string');
     $html = CStringHelper::replaceThumbnails($html);
     $html = JString::str_ireplace(array('{error}', '{warning}', '{info}'), '', $html);
     // Trigger onModuleDisplay()
     CFactory::load('libraries', 'apps');
     $appsLib = CAppPlugins::getInstance();
     $appsLib->loadApplications();
     $moduleHTML = $appsLib->triggerEvent('onModuleRender');
     $mods = array();
     foreach ($moduleHTML as $modules) {
         foreach ($modules as $position => $content) {
             if (empty($mods[$position])) {
                 $mods[$position] = '';
             }
             $mods[$position] .= $content;
         }
     }
     foreach ($mods as $position => $module) {
         $html = str_replace('<!-- ' . $position . ' -->', $module, $html);
     }
     // Display viewType switcher
     // $browser = CBrowser::getInstance();
     // if( $browser->_mobile )
     // {
     // 	CFactory::load('libraries', 'mobile');
     // 	ob_start();
     // 		CMobile::showSwitcher();
     // 		$switcherHTML = ob_get_contents();
     // 	ob_end_clean();
     // 	$html .= $switcherHTML;
     // }
     echo $html;
 }
Exemple #14
0
 /**
  * Formats the comment in the rows
  * 
  * @param Array	An array of wall objects	 	 
  **/
 function triggerWallComments(&$rows)
 {
     CError::assert($rows, 'array', 'istype', __FILE__, __LINE__);
     require_once COMMUNITY_COM_PATH . DS . 'libraries' . DS . 'apps.php';
     $appsLib =& CAppPlugins::getInstance();
     $appsLib->loadApplications();
     for ($i = 0; $i < count($rows); $i++) {
         $args = array();
         $args[] =& $rows[$i];
         $appsLib->triggerEvent('onWallDisplay', $args);
     }
     return true;
 }
Exemple #15
0
 public function ajaxRefreshLayout($id, $position)
 {
     $objResponse = new JAXResponse();
     $filter = JFilterInput::getInstance();
     $id = $filter->clean($id, 'string');
     $position = $filter->clean($position, 'string');
     $my = CFactory::getUser();
     $appsModel = CFactory::getModel('apps');
     $element = $appsModel->getAppName($id);
     $pluginId = $appsModel->getPluginId($element);
     $params =& JPluginHelper::getPlugin('community', JString::strtolower($element));
     $dispatcher =& JDispatcher::getInstance();
     $pluginClass = 'plgCommunity' . $element;
     //$plugin = new $pluginClass($dispatcher, (array)($params));
     $plugin = JTable::getInstance('App', 'CTable');
     $plugin->loadUserApp($my->id, $element);
     switch ($position) {
         case "apps-sortable-side-top":
             $position = "sidebar-top";
             break;
         case "apps-sortable-side-bottom":
             $position = "sidebar-bottom";
             break;
         case "apps-sortable":
         default:
             $position = "content";
             break;
     }
     $appInfo = $appsModel->getAppInfo($element);
     //$plugin->setNewLayout($position);
     $plugin->postion = $position;
     $appsLib =& CAppPlugins::getInstance();
     $app = $appsLib->triggerPlugin('onProfileDisplay', $appInfo->name, $my->id);
     $tmpl = new CTemplate();
     $tmpl->set('app', $app);
     $tmpl->set('isOwner', $appsModel->isOwned($my->id, $id));
     switch ($position) {
         case 'sidebar-top':
         case 'sidebar-bottom':
             $wrapper = $tmpl->fetch('application.widget');
             break;
         default:
             $wrapper = $tmpl->fetch('application.box');
     }
     $wrapper = str_replace("\r\n", "", $wrapper);
     $wrapper = str_replace("\n", "", $wrapper);
     $wrapper = addslashes($wrapper);
     $objResponse->addScriptCall("jQuery('#jsapp-" . $id . "').before('{$wrapper}').remove();");
     //$objResponse->addScriptCall('joms.plugin.'.$element.'.refresh()');
     //$refreshActions = $plugin->getRefreshAction();
     return $objResponse->sendResponse();
 }
Exemple #16
0
 /**
  *	Deletes a wall entry
  *	
  * @param	id int Specific id for the wall
  * 	 
  */
 public function deletePost($id)
 {
     CError::assert($id, '', '!empty', __FILE__, __LINE__);
     $db = JFactory::getDBO();
     //@todo check content id belong valid user b4 delete
     $query = 'DELETE FROM ' . $db->nameQuote('#__community_wall') . ' ' . 'WHERE ' . $db->nameQuote('id') . '=' . $db->Quote($id);
     $db->setQuery($query);
     $db->query();
     if ($db->getErrorNum()) {
         JError::raiseError(500, $db->stderr());
     }
     // Post an event trigger
     $args = array();
     $args[] = $id;
     CFactory::load('libraries', 'apps');
     $appsLib =& CAppPlugins::getInstance();
     $appsLib->loadApplications();
     $appsLib->triggerEvent('onAfterWallDelete', $args);
     return true;
 }
Exemple #17
0
<?php

/**
 * @copyright (C) 2013 iJoomla, Inc. - All rights reserved.
 * @license GNU General Public License, version 2 (http://www.gnu.org/licenses/gpl-2.0.html)
 * @author iJoomla.com <*****@*****.**>
 * @url https://www.jomsocial.com/license-agreement
 * The PHP code portions are distributed under the GPL license. If not otherwise stated, all images, manuals, cascading style sheets, and included JavaScript *are NOT GPL, and are released under the IJOOMLA Proprietary Use License v1.0
 * More info at https://www.jomsocial.com/license-agreement
 */
defined('_JEXEC') or die;
if (!isset($isSingleActivity)) {
    $isSingleActivity = false;
}
$appLib = CAppPlugins::getInstance();
$filter = JFactory::getApplication()->input->get('filter', $filter);
$filterValue = JFactory::getApplication()->input->get('value');
$actId = JFactory::getApplication()->input->get('actid');
$date = JFactory::getDate();
if ($config->get('activitydateformat') == "lapse") {
    $createdTime = CTimeHelper::timeLapse($date);
} else {
    $createdTime = $date->format($config->get('profileDateFormat'));
}
// 2. welcome message for new installation
if (isset($freshInstallMsg)) {
    ?>
    <div class="cAlert" style="margin-top: 10px">
        <?php 
    echo $freshInstallMsg;
    ?>
Exemple #18
0
 /**
  * Formats the comment in the rows
  *
  * @param Array    An array of wall objects
  * */
 public static function triggerWallComments(&$rows, $newlineReplace = true)
 {
     CError::assert($rows, 'array', 'istype', __FILE__, __LINE__);
     require_once COMMUNITY_COM_PATH . '/libraries/apps.php';
     $appsLib = CAppPlugins::getInstance();
     $appsLib->loadApplications();
     for ($i = 0; $i < count($rows); $i++) {
         if (isset($rows[$i]->comment) && !empty($rows[$i]->comment)) {
             $args = array();
             if (!$newlineReplace) {
                 // if newline replace is false, pass the information to the comment to leave out the newline
                 // replace in wall.trigger
                 $rows[$i]->newlineReplace = false;
             }
             $args[] = $rows[$i];
             $appsLib->triggerEvent('onWallDisplay', $args);
         }
     }
     return true;
 }
Exemple #19
0
 /**
 	get field value of $userId accordimg to $fieldCode
 */
 public function getInfo($userId, $fieldCode)
 {
     // Run Query to return 1 value
     $db = JFactory::getDBO();
     $query = 'SELECT b.* FROM ' . $db->nameQuote('#__community_fields') . ' AS a ' . 'INNER JOIN ' . $db->nameQuote('#__community_fields_values') . ' AS b ' . 'ON b.' . $db->nameQuote('field_id') . '=a.' . $db->nameQuote('id') . ' ' . 'AND b.' . $db->nameQuote('user_id') . '=' . $db->Quote($userId) . ' ' . 'INNER JOIN ' . $db->nameQuote('#__community_users') . ' AS c ' . 'ON c.' . $db->nameQuote('userid') . '= b.' . $db->nameQuote('user_id') . 'WHERE a.' . $db->nameQuote('fieldcode') . ' =' . $db->Quote($fieldCode);
     $db->setQuery($query);
     $result = $db->loadObject();
     $field = JTable::getInstance('FieldValue', 'CTable');
     $field->bind($result);
     if ($db->getErrorNum()) {
         JError::raiseError(500, $db->stderr());
     }
     $config = CFactory::getConfig();
     // @rule: Only trigger 3rd party apps whenever they override extendeduserinfo configs
     if ($config->getBool('extendeduserinfo')) {
         CFactory::load('libraries', 'apps');
         $apps = CAppPlugins::getInstance();
         $apps->loadApplications();
         $params = array();
         $params[] = $fieldCode;
         $params[] =& $field->value;
         $apps->triggerEvent('onGetUserInfo', $params);
     }
     // Respect privacy settings.
     if (!XIPT_JOOMLA_15) {
         $my = CFactory::getUser();
         CFactory::load('libraries', 'privacy');
         if (!CPrivacy::isAccessAllowed($my->id, $userId, 'custom', $field->access)) {
             return false;
         }
     }
     return $field->value;
 }
Exemple #20
0
$jaxFuncNames[] = 'files,ajaxFileDownload';
$jaxFuncNames[] = 'files,ajaxgetFileList';
$jaxFuncNames[] = 'files,ajaxviewMore';
/**
 * @since 3.2
 */
$jaxFuncNames[] = 'location,ajaxGetCoordsByIp';
$jaxFuncNames[] = 'location,ajaxGetAddressFromCoords';
$jaxFuncNames[] = 'location,ajaxGetCoordsByAddress';
/**
 * @since 3.3
 */
$jaxFuncNames[] = 'search,ajaxSearch';
$jaxFuncNames[] = 'system,ajaxGetAdagency';
$jaxFuncNames[] = 'system,ajaxAdagencyGetImpression';
$jaxFuncNames[] = 'profile,ajaxFetchCard';
$jaxFuncNames[] = 'videos,ajaxConfirmRemoveVideo';
$jaxFuncNames[] = 'videos,ajaxGetInfo';
$jaxFuncNames[] = 'profile,ajaxRotateAvatar';
$jaxFuncNames[] = 'videos,ajaxSaveDescription';
$jaxFuncNames[] = 'system,ajaxModuleCall';
$jaxFuncNames[] = 'register,ajaxCheckPass';
$jaxFuncNames[] = 'system,ajaxGetLoginFormToken';
$jaxFuncNames[] = 'files,ajaxUpdateHit';
// Dont process other plugin ajax definitions for back end
if (!JString::stristr(JPATH_COMPONENT, 'administrator/components/com_community') && !JString::stristr(JPATH_COMPONENT, 'administrator\\components\\com_community')) {
    // Include CAppPlugins library
    require_once JPATH_ROOT . '/components/com_community/libraries/apps.php';
    // Load Ajax plugins jax file.
    CAppPlugins::loadAjaxPlugins();
}
Exemple #21
0
 /**
  * Delete an album
  * Set all photo within the album to have albumid = 0
  * Do not yet delete the photos, this could be very slow on an album that
  * has huge amount of photos
  */
 public function delete($pk = null)
 {
     //lets get all the photo info under the album
     $photoModel = CFactory::getModel('photos');
     $photos = $photoModel->getAllPhotos($this->id, $this->type);
     $db = JFactory::getDBO();
     $strSQL = 'UPDATE ' . $db->quoteName('#__community_photos') . ' SET ' . $db->quoteName('albumid') . '=' . $db->Quote(0) . ', ' . $db->quoteName('status') . ' = ' . $db->quote('temp') . ' WHERE ' . $db->quoteName('albumid') . '=' . $db->Quote($this->id);
     $db->setQuery($strSQL);
     $result = $db->query();
     // The whole local folder should be deleted, regardless of the storage type
     // BUT some old version of JomSocial might store other photo in the same
     // folder, we check in db first
     $strSQL = 'SELECT count(*) FROM ' . $db->quoteName('#__community_photos') . ' WHERE ' . $db->quoteName('image') . ' LIKE ' . $db->Quote('%' . dirname($this->path) . '%');
     $db->setQuery($strSQL);
     $result = $db->loadResult();
     if ($result == 0) {
         if (JFolder::exists(JPATH_ROOT . '/' . rtrim($this->path, '/') . '/' . $this->id)) {
             JFolder::delete(JPATH_ROOT . '/' . rtrim($this->path, '/') . '/' . $this->id);
         }
     }
     // We need to delete all activity stream related to this album
     CActivityStream::remove('photos', $this->id);
     //we need to delete all activity related to the photos inside the album as well
     if (isset($photos) && count($photos) > 0) {
         foreach ($photos as $photo) {
             CActivityStream::remove('photos', $photo->id);
         }
     }
     /* Delete album directory */
     $config = CFactory::getConfig();
     $dirPath = JPATH_ROOT . '/' . $config->getString('imagefolder') . '/photos/' . $this->creator . '/' . $this->id;
     if (JFolder::exists($dirPath)) {
         JFolder::delete($dirPath);
     }
     $appsLib = CAppPlugins::getInstance();
     $appsLib->loadApplications();
     $appsLib->triggerEvent('onAfterAlbumDelete', array($this));
     // @rule: remove from featured item if item is featured
     $featured = new CFeatured(FEATURED_ALBUMS);
     $featured->delete($this->id);
     // if this is an avatar, we have to remove the avatar from the respective user
     if ($this->type == 'profile.avatar') {
         $user = CFactory::getUser($this->creator);
         $userModel = CFactory::getModel('User');
         $userModel->removeProfilePicture($user->id, 'avatar');
         $userModel->removeProfilePicture($user->id, 'thumb');
         $activityModel = CFactory::getModel('activities');
         $activityModel->removeAvatarActivity('profile.avatar.upload', $user->id);
     } elseif ($this->type == 'event.avatar') {
         $eventTable = JTable::getInstance('Event', 'CTable');
         $eventTable->load($this->eventid);
         $eventTable->removeAvatar();
         $activityModel = CFactory::getModel('activities');
         $activityModel->removeAvatarActivity('events.avatar.upload', $this->eventid);
     } elseif ($this->type == 'group.avatar') {
         $eventTable = JTable::getInstance('Group', 'CTable');
         $eventTable->load($this->groupid);
         $eventTable->removeAvatar();
         $activityModel = CFactory::getModel('activities');
         $activityModel->removeAvatarActivity('groups.avatar.upload', $this->groupid);
     }
     //add user points
     CUserPoints::assignPoint('album.remove');
     // Remove from activity stream
     //CActivityStream::remove('photos', $this->id);
     // Remove from activity stream
     CActivityStream::remove('albums', $this->id);
     // Remove likes activity
     $likeModel = CFactory::getModel('like');
     $likeModel->removeLikes('album', $this->id);
     // Remove comment
     $wallModel = CFactory::getModel('wall');
     $wallModel->deletePostByType('albums', $this->id);
     return parent::delete();
 }
Exemple #22
0
/**
 * Entry poitn for all ajax call
 */
function communityAjaxEntry($func, $args = null)
{
    // For AJAX calls, we need to load the language file manually.
    $lang =& JFactory::getLanguage();
    $lang->load('com_community');
    $response = new JAXResponse();
    $output = '';
    require_once JPATH_COMPONENT . DS . 'libraries' . DS . 'apps.php';
    $appsLib =& CAppPlugins::getInstance();
    $appsLib->loadApplications();
    $triggerArgs = array();
    $triggerArgs[] = $func;
    $triggerArgs[] = $args;
    $triggerArgs[] = $response;
    $results = $appsLib->triggerEvent('onAjaxCall', $triggerArgs);
    if (in_array(false, $results)) {
        $output = $response->sendResponse();
    } else {
        $calls = explode(',', $func);
        if (is_array($calls) && $calls[0] == 'plugins') {
            // Plugins ajax calls go here
            $func = $_REQUEST['func'];
            // Load CAppPlugins
            if (!class_exists('CAppPlugins')) {
                require_once JPATH_COMPONENT . DS . 'libraries' . DS . 'apps.php';
            }
            $apps =& CAppPlugins::getInstance();
            $plugin =& $apps->get($calls[1]);
            $method = $calls[2];
            // Move the $response object to be the first in the array so that the plugin knows
            // the first argument is always the JAXResponse object
            array_unshift($args, $response);
            // Call plugin AJAX method. Caller method's should only return the JAXResponse object.
            $response = call_user_func_array(array($plugin, $method), $args);
            $output = $response->sendResponse();
        } else {
            // Built-in ajax calls go here
            $config = array();
            $func = $_REQUEST['func'];
            $callArray = explode(',', $func);
            $viewController = JString::strtolower($callArray[0]);
            $viewControllerFile = JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'controllers' . DS . $viewController . '.php';
            if (JFile::exists($viewControllerFile)) {
                require_once JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'controllers' . DS . $viewController . '.php';
                $viewController = JString::ucfirst($viewController);
                $viewController = 'Community' . $viewController . 'Controller';
                $controller = new $viewController($config);
                // Perform the Request task
                $output = call_user_func_array(array(&$controller, $callArray[1]), $args);
            } else {
                echo JText::sprintf('Controller %1$s not found!', $viewController);
                exit;
            }
        }
    }
    return $output;
}
Exemple #23
0
 /**
  * Called during photo uploading.
  * @return type
  */
 public function upload()
 {
     $my = CFactory::getUser();
     $config = CFactory::getConfig();
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     // If user is using a flash browser, their session might get reset when mod_security is around
     if ($my->id == 0) {
         $tokenId = $jinput->request->get('token', '', 'NONE');
         $userId = $jinput->request->get('uploaderid', '', 'NONE');
         $my = CFactory::getUserFromTokenId($tokenId, $userId);
         $session = JFactory::getSession();
         $session->set('user', $my);
     }
     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
     $photos = JRequest::get('Files');
     $albumId = $jinput->request->get('albumid', '', 'INT');
     $album = $this->_getRequestUserAlbum($albumId);
     // Uploaded images count in this batch
     $batchCount = $jinput->request->get('batchcount', '', 'INT');
     $handler = $this->_getHandler($album);
     /* Do process for all photos */
     foreach ($photos as $imageFile) {
         /* Validating */
         $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, $album->id);
         $storedPath = $storedPath . '/' . $albumPath . $hashFilename . CImageHelper::getExtension($imageFile['type']);
         $photoTable->image = CString::str_ireplace(JPATH_ROOT . '/', '', $storedPath);
         $photoTable->thumbnail = CString::str_ireplace(JPATH_ROOT . '/', '', $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 . '/', '', $storedPath);
         }
         if ($photoTable->thumbnail == $thumbPath) {
             $photoTable->thumbnail = str_ireplace(JPATH_ROOT . '/', '', $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
         $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();
             }
         }
         // Set the upload count per session
         $session = JFactory::getSession();
         $uploadSessionCount = $session->get('album-' . $album->id . '-upload', 0);
         $uploadSessionCount++;
         $session->set('album-' . $album->id . '-upload', $uploadSessionCount);
         //add user points
         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(), $album->id, $photoTable->id);
     }
     $this->cacheClean(array(COMMUNITY_CACHE_TAG_FRONTPAGE, COMMUNITY_CACHE_TAG_ACTIVITIES));
     exit;
 }
Exemple #24
0
 /**
  * Called by status box to add new stream data
  *
  * @param type $message
  * @param type $attachment
  * @return type
  */
 public function ajaxStreamAdd($message, $attachment, $streamFilter = FALSE)
 {
     $streamHTML = '';
     // $attachment pending filter
     $cache = CFactory::getFastCache();
     $cache->clean(array('activities'));
     $my = CFactory::getUser();
     $userparams = $my->getParams();
     if (!COwnerHelper::isRegisteredUser()) {
         return $this->ajaxBlockUnregister();
     }
     //@rule: In case someone bypasses the status in the html, we enforce the character limit.
     $config = CFactory::getConfig();
     if (JString::strlen($message) > $config->get('statusmaxchar')) {
         $message = JHTML::_('string.truncate', $message, $config->get('statusmaxchar'));
     }
     $message = JString::trim($message);
     $objResponse = new JAXResponse();
     $rawMessage = $message;
     // @rule: Autolink hyperlinks
     // @rule: Autolink to users profile when message contains @username
     // $message     = CUserHelper::replaceAliasURL($message); // the processing is done on display side
     $emailMessage = CUserHelper::replaceAliasURL($rawMessage, true);
     // @rule: Spam checks
     if ($config->get('antispam_akismet_status')) {
         $filter = CSpamFilter::getFilter();
         $filter->setAuthor($my->getDisplayName());
         $filter->setMessage($message);
         $filter->setEmail($my->email);
         $filter->setURL(CRoute::_('index.php?option=com_community&view=profile&userid=' . $my->id));
         $filter->setType('message');
         $filter->setIP($_SERVER['REMOTE_ADDR']);
         if ($filter->isSpam()) {
             $objResponse->addAlert(JText::_('COM_COMMUNITY_STATUS_MARKED_SPAM'));
             return $objResponse->sendResponse();
         }
     }
     $attachment = json_decode($attachment, true);
     switch ($attachment['type']) {
         case 'message':
             //if (!empty($message)) {
             switch ($attachment['element']) {
                 case 'profile':
                     //only update user status if share messgage is on his profile
                     if (COwnerHelper::isMine($my->id, $attachment['target'])) {
                         //save the message
                         $status = $this->getModel('status');
                         /* If no privacy in attachment than we apply default: Public */
                         if (!isset($attachment['privacy'])) {
                             $attachment['privacy'] = COMMUNITY_STATUS_PRIVACY_PUBLIC;
                         }
                         $status->update($my->id, $rawMessage, $attachment['privacy']);
                         //set user status for current session.
                         $today = JFactory::getDate();
                         $message2 = empty($message) ? ' ' : $message;
                         $my->set('_status', $rawMessage);
                         $my->set('_posted_on', $today->toSql());
                         // Order of replacement
                         $order = array("\r\n", "\n", "\r");
                         $replace = '<br />';
                         // Processes \r\n's first so they aren't converted twice.
                         $messageDisplay = str_replace($order, $replace, $message);
                         $messageDisplay = CKses::kses($messageDisplay, CKses::allowed());
                         //update user status
                         $objResponse->addScriptCall("joms.jQuery('#profile-status span#profile-status-message').html('" . addslashes($messageDisplay) . "');");
                     }
                     //if actor posted something to target, the privacy should be under target's profile privacy settings
                     if (!COwnerHelper::isMine($my->id, $attachment['target']) && $attachment['target'] != '') {
                         $attachment['privacy'] = CFactory::getUser($attachment['target'])->getParams()->get('privacyProfileView');
                     }
                     //push to activity stream
                     $act = new stdClass();
                     $act->cmd = 'profile.status.update';
                     $act->actor = $my->id;
                     $act->target = $attachment['target'];
                     $act->title = $message;
                     $act->content = '';
                     $act->app = $attachment['element'];
                     $act->cid = $my->id;
                     $act->access = $attachment['privacy'];
                     $act->comment_id = CActivities::COMMENT_SELF;
                     $act->comment_type = 'profile.status';
                     $act->like_id = CActivities::LIKE_SELF;
                     $act->like_type = 'profile.status';
                     $activityParams = new CParameter('');
                     /* Save cords if exists */
                     if (isset($attachment['location'])) {
                         /* Save geo name */
                         $act->location = $attachment['location'][0];
                         $act->latitude = $attachment['location'][1];
                         $act->longitude = $attachment['location'][2];
                     }
                     $headMeta = new CParameter('');
                     if (isset($attachment['fetch'])) {
                         $headMeta->set('title', $attachment['fetch'][2]);
                         $headMeta->set('description', $attachment['fetch'][3]);
                         $headMeta->set('image', $attachment['fetch'][1]);
                         $headMeta->set('link', $attachment['fetch'][0]);
                         //do checking if this is a video link
                         $video = JTable::getInstance('Video', 'CTable');
                         $isValidVideo = @$video->init($attachment['fetch'][0]);
                         if ($isValidVideo) {
                             $headMeta->set('type', 'video');
                             $headMeta->set('video_provider', $video->type);
                             $headMeta->set('video_id', $video->getVideoId());
                             $headMeta->set('height', $video->getHeight());
                             $headMeta->set('width', $video->getWidth());
                         }
                         $activityParams->set('headMetas', $headMeta->toString());
                     }
                     //Store mood in paramm
                     if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') {
                         $activityParams->set('mood', $attachment['mood']);
                     }
                     $act->params = $activityParams->toString();
                     //CActivityStream::add($act);
                     //check if the user points is enabled
                     if (CUserPoints::assignPoint('profile.status.update')) {
                         /* Let use our new CApiStream */
                         $activityData = CApiActivities::add($act);
                         CTags::add($activityData);
                         $recipient = CFactory::getUser($attachment['target']);
                         $params = new CParameter('');
                         $params->set('actorName', $my->getDisplayName());
                         $params->set('recipientName', $recipient->getDisplayName());
                         $params->set('url', CUrlHelper::userLink($act->target, false));
                         $params->set('message', $message);
                         $params->set('stream', JText::_('COM_COMMUNITY_SINGULAR_STREAM'));
                         $params->set('stream_url', CRoute::_('index.php?option=com_community&view=profile&userid=' . $activityData->actor . '&actid=' . $activityData->id));
                         CNotificationLibrary::add('profile_status_update', $my->id, $attachment['target'], JText::sprintf('COM_COMMUNITY_FRIEND_WALL_POST', $my->getDisplayName()), '', 'wall.post', $params);
                         //email and add notification if user are tagged
                         CUserHelper::parseTaggedUserNotification($message, $my, $activityData, array('type' => 'post-comment'));
                     }
                     break;
                     // Message posted from Group page
                 // Message posted from Group page
                 case 'groups':
                     //
                     $groupLib = new CGroups();
                     $group = JTable::getInstance('Group', 'CTable');
                     $group->load($attachment['target']);
                     // Permission check, only site admin and those who has
                     // mark their attendance can post message
                     if (!COwnerHelper::isCommunityAdmin() && !$group->isMember($my->id) && $config->get('lockgroupwalls')) {
                         $objResponse->addScriptCall("alert('permission denied');");
                         return $objResponse->sendResponse();
                     }
                     $act = new stdClass();
                     $act->cmd = 'groups.wall';
                     $act->actor = $my->id;
                     $act->target = 0;
                     $act->title = $message;
                     $act->content = '';
                     $act->app = 'groups.wall';
                     $act->cid = $attachment['target'];
                     $act->groupid = $group->id;
                     $act->group_access = $group->approvals;
                     $act->eventid = 0;
                     $act->access = 0;
                     $act->comment_id = CActivities::COMMENT_SELF;
                     $act->comment_type = 'groups.wall';
                     $act->like_id = CActivities::LIKE_SELF;
                     $act->like_type = 'groups.wall';
                     $activityParams = new CParameter('');
                     /* Save cords if exists */
                     if (isset($attachment['location'])) {
                         /* Save geo name */
                         $act->location = $attachment['location'][0];
                         $act->latitude = $attachment['location'][1];
                         $act->longitude = $attachment['location'][2];
                     }
                     $headMeta = new CParameter('');
                     if (isset($attachment['fetch'])) {
                         $headMeta->set('title', $attachment['fetch'][2]);
                         $headMeta->set('description', $attachment['fetch'][3]);
                         $headMeta->set('image', $attachment['fetch'][1]);
                         $headMeta->set('link', $attachment['fetch'][0]);
                         //do checking if this is a video link
                         $video = JTable::getInstance('Video', 'CTable');
                         $isValidVideo = @$video->init($attachment['fetch'][0]);
                         if ($isValidVideo) {
                             $headMeta->set('type', 'video');
                             $headMeta->set('video_provider', $video->type);
                             $headMeta->set('video_id', $video->getVideoId());
                             $headMeta->set('height', $video->getHeight());
                             $headMeta->set('width', $video->getWidth());
                         }
                         $activityParams->set('headMetas', $headMeta->toString());
                     }
                     //Store mood in paramm
                     if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') {
                         $activityParams->set('mood', $attachment['mood']);
                     }
                     $act->params = $activityParams->toString();
                     $activityData = CApiActivities::add($act);
                     CTags::add($activityData);
                     CUserPoints::assignPoint('group.wall.create');
                     $recipient = CFactory::getUser($attachment['target']);
                     $params = new CParameter('');
                     $params->set('message', $emailMessage);
                     $params->set('group', $group->name);
                     $params->set('group_url', 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id);
                     $params->set('url', CRoute::getExternalURL('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id, false));
                     //Get group member emails
                     $model = CFactory::getModel('Groups');
                     $members = $model->getMembers($attachment['target'], null, true, false, true);
                     $membersArray = array();
                     if (!is_null($members)) {
                         foreach ($members as $row) {
                             if ($my->id != $row->id) {
                                 $membersArray[] = $row->id;
                             }
                         }
                     }
                     $groupParams = new CParameter($group->params);
                     if ($groupParams->get('wallnotification')) {
                         CNotificationLibrary::add('groups_wall_create', $my->id, $membersArray, JText::sprintf('COM_COMMUNITY_NEW_WALL_POST_NOTIFICATION_EMAIL_SUBJECT', $my->getDisplayName(), $group->name), '', 'groups.post', $params);
                     }
                     //@since 4.1 when a there is a new post in group, dump the data into group stats
                     $statsModel = CFactory::getModel('stats');
                     $statsModel->addGroupStats($group->id, 'post');
                     // Add custom stream
                     // Reload the stream with new stream data
                     $streamHTML = $groupLib->getStreamHTML($group, array('showLatestActivityOnTop' => true));
                     break;
                     // Message posted from Event page
                 // Message posted from Event page
                 case 'events':
                     $eventLib = new CEvents();
                     $event = JTable::getInstance('Event', 'CTable');
                     $event->load($attachment['target']);
                     // Permission check, only site admin and those who has
                     // mark their attendance can post message
                     if (!COwnerHelper::isCommunityAdmin() && !$event->isMember($my->id) && $config->get('lockeventwalls')) {
                         $objResponse->addScriptCall("alert('permission denied');");
                         return $objResponse->sendResponse();
                     }
                     // If this is a group event, set the group object
                     $groupid = $event->type == 'group' ? $event->contentid : 0;
                     //
                     $groupLib = new CGroups();
                     $group = JTable::getInstance('Group', 'CTable');
                     $group->load($groupid);
                     $act = new stdClass();
                     $act->cmd = 'events.wall';
                     $act->actor = $my->id;
                     $act->target = 0;
                     $act->title = $message;
                     $act->content = '';
                     $act->app = 'events.wall';
                     $act->cid = $attachment['target'];
                     $act->groupid = $event->type == 'group' ? $event->contentid : 0;
                     $act->group_access = $group->approvals;
                     $act->eventid = $event->id;
                     $act->event_access = $event->permission;
                     $act->access = 0;
                     $act->comment_id = CActivities::COMMENT_SELF;
                     $act->comment_type = 'events.wall';
                     $act->like_id = CActivities::LIKE_SELF;
                     $act->like_type = 'events.wall';
                     $activityParams = new CParameter('');
                     /* Save cords if exists */
                     if (isset($attachment['location'])) {
                         /* Save geo name */
                         $act->location = $attachment['location'][0];
                         $act->latitude = $attachment['location'][1];
                         $act->longitude = $attachment['location'][2];
                     }
                     $headMeta = new CParameter('');
                     if (isset($attachment['fetch'])) {
                         $headMeta->set('title', $attachment['fetch'][2]);
                         $headMeta->set('description', $attachment['fetch'][3]);
                         $headMeta->set('image', $attachment['fetch'][1]);
                         $headMeta->set('link', $attachment['fetch'][0]);
                         //do checking if this is a video link
                         $video = JTable::getInstance('Video', 'CTable');
                         $isValidVideo = @$video->init($attachment['fetch'][0]);
                         if ($isValidVideo) {
                             $headMeta->set('type', 'video');
                             $headMeta->set('video_provider', $video->type);
                             $headMeta->set('video_id', $video->getVideoId());
                             $headMeta->set('height', $video->getHeight());
                             $headMeta->set('width', $video->getWidth());
                         }
                         $activityParams->set('headMetas', $headMeta->toString());
                     }
                     //Store mood in paramm
                     if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') {
                         $activityParams->set('mood', $attachment['mood']);
                     }
                     $act->params = $activityParams->toString();
                     $activityData = CApiActivities::add($act);
                     CTags::add($activityData);
                     // add points
                     CUserPoints::assignPoint('event.wall.create');
                     $params = new CParameter('');
                     $params->set('message', $emailMessage);
                     $params->set('event', $event->title);
                     $params->set('event_url', 'index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id);
                     $params->set('url', CRoute::getExternalURL('index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id, false));
                     //Get event member emails
                     $members = $event->getMembers(COMMUNITY_EVENT_STATUS_ATTEND, 12, CC_RANDOMIZE);
                     $membersArray = array();
                     if (!is_null($members)) {
                         foreach ($members as $row) {
                             if ($my->id != $row->id) {
                                 $membersArray[] = $row->id;
                             }
                         }
                     }
                     CNotificationLibrary::add('events_wall_create', $my->id, $membersArray, JText::sprintf('COM_COMMUNITY_NEW_WALL_POST_NOTIFICATION_EMAIL_SUBJECT_EVENTS', $my->getDisplayName(), $event->title), '', 'events.post', $params);
                     //@since 4.1 when a there is a new post in event, dump the data into event stats
                     $statsModel = CFactory::getModel('stats');
                     $statsModel->addEventStats($event->id, 'post');
                     // Reload the stream with new stream data
                     $streamHTML = $eventLib->getStreamHTML($event, array('showLatestActivityOnTop' => true));
                     break;
             }
             $objResponse->addScriptCall('__callback', '');
             // /}
             break;
         case 'photo':
             switch ($attachment['element']) {
                 case 'profile':
                     $photoIds = $attachment['id'];
                     //use User Preference for Privacy
                     //$privacy = $userparams->get('privacyPhotoView'); //$privacy = $attachment['privacy'];
                     $photo = JTable::getInstance('Photo', 'CTable');
                     if (!isset($photoIds[0]) || $photoIds[0] <= 0) {
                         //$objResponse->addScriptCall('__callback', JText::sprintf('COM_COMMUNITY_PHOTO_UPLOADED_SUCCESSFULLY', $photo->caption));
                         exit;
                     }
                     //always get album id from the photo itself, do not let it assign by params from user post data
                     $photoModel = CFactory::getModel('photos');
                     $photo = $photoModel->getPhoto($photoIds[0]);
                     /* OK ! If album_id is not provided than we use album id from photo ( it should be default album id ) */
                     $albumid = isset($attachment['album_id']) ? $attachment['album_id'] : $photo->albumid;
                     $album = JTable::getInstance('Album', 'CTable');
                     $album->load($albumid);
                     $privacy = $album->permissions;
                     //limit checking
                     //                        $photoModel = CFactory::getModel( 'photos' );
                     //                        $config       = CFactory::getConfig();
                     //                        $total        = $photoModel->getTotalToday( $my->id );
                     //                        $max      = $config->getInt( 'limit_photo_perday' );
                     //                        $remainingUploadCount = $max - $total;
                     $params = array();
                     foreach ($photoIds as $key => $photoId) {
                         if (CLimitsLibrary::exceedDaily('photos')) {
                             unset($photoIds[$key]);
                             continue;
                         }
                         $photo->load($photoId);
                         $photo->permissions = $privacy;
                         $photo->published = 1;
                         $photo->status = 'ready';
                         $photo->albumid = $albumid;
                         /* We must update this photo into correct album id */
                         $photo->store();
                         $params[] = clone $photo;
                     }
                     if ($config->get('autoalbumcover') && !$album->photoid) {
                         $album->photoid = $photoIds[0];
                         $album->store();
                     }
                     // Break if no photo added, which is likely because of daily limit.
                     if (count($photoIds) < 1) {
                         $objResponse->addScriptCall('__throwError', JText::_('COM_COMMUNITY_PHOTO_UPLOAD_LIMIT_EXCEEDED'));
                         return $objResponse->sendResponse();
                     }
                     // Trigger onPhotoCreate
                     //
                     $apps = CAppPlugins::getInstance();
                     $apps->loadApplications();
                     $apps->triggerEvent('onPhotoCreate', array($params));
                     $act = new stdClass();
                     $act->cmd = 'photo.upload';
                     $act->actor = $my->id;
                     $act->access = $privacy;
                     //$attachment['privacy'];
                     $act->target = $attachment['target'] == $my->id ? 0 : $attachment['target'];
                     $act->title = $message;
                     $act->content = '';
                     // Generated automatically by stream. No need to add anything
                     $act->app = 'photos';
                     $act->cid = $albumid;
                     $act->location = $album->location;
                     /* Comment and like for individual photo upload is linked
                      * to the photos itsel
                      */
                     $act->comment_id = $photo->id;
                     $act->comment_type = 'photos';
                     $act->like_id = $photo->id;
                     $act->like_type = 'photo';
                     $albumUrl = 'index.php?option=com_community&view=photos&task=album&albumid=' . $album->id . '&userid=' . $my->id;
                     $albumUrl = CRoute::_($albumUrl);
                     $photoUrl = 'index.php?option=com_community&view=photos&task=photo&albumid=' . $album->id . '&userid=' . $photo->creator . '&photoid=' . $photo->id;
                     $photoUrl = CRoute::_($photoUrl);
                     $params = new CParameter('');
                     $params->set('multiUrl', $albumUrl);
                     $params->set('photoid', $photo->id);
                     $params->set('action', 'upload');
                     $params->set('stream', '1');
                     $params->set('photo_url', $photoUrl);
                     $params->set('style', COMMUNITY_STREAM_STYLE);
                     $params->set('photosId', implode(',', $photoIds));
                     if (count($photoIds > 1)) {
                         $params->set('count', count($photoIds));
                         $params->set('batchcount', count($photoIds));
                     }
                     //Store mood in param
                     if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') {
                         $params->set('mood', $attachment['mood']);
                     }
                     // Add activity logging
                     // CActivityStream::remove($act->app, $act->cid);
                     $activityData = CActivityStream::add($act, $params->toString());
                     // Add user points
                     CUserPoints::assignPoint('photo.upload');
                     //add a notification to the target user if someone posted photos on target's profile
                     if ($my->id != $attachment['target']) {
                         $recipient = CFactory::getUser($attachment['target']);
                         $params = new CParameter('');
                         $params->set('actorName', $my->getDisplayName());
                         $params->set('recipientName', $recipient->getDisplayName());
                         $params->set('url', CUrlHelper::userLink($act->target, false));
                         $params->set('message', $message);
                         $params->set('stream', JText::_('COM_COMMUNITY_SINGULAR_STREAM'));
                         $params->set('stream_url', CRoute::_('index.php?option=com_community&view=profile&userid=' . $activityData->actor . '&actid=' . $activityData->id));
                         CNotificationLibrary::add('profile_status_update', $my->id, $attachment['target'], JText::sprintf('COM_COMMUNITY_NOTIFICATION_STREAM_PHOTO_POST', count($photoIds)), '', 'wall.post', $params);
                     }
                     //email and add notification if user are tagged
                     CUserHelper::parseTaggedUserNotification($message, $my, $activityData, array('type' => 'post-comment'));
                     $objResponse->addScriptCall('__callback', JText::sprintf('COM_COMMUNITY_PHOTO_UPLOADED_SUCCESSFULLY', $photo->caption));
                     break;
                 case 'events':
                     $event = JTable::getInstance('Event', 'CTable');
                     $event->load($attachment['target']);
                     $privacy = 0;
                     //if this is a group event, we need to follow the group privacy
                     if ($event->type == 'group' && $event->contentid) {
                         $group = JTable::getInstance('Group', 'CTable');
                         $group->load(${$event}->contentid);
                         $privacy = $group->approvals ? PRIVACY_GROUP_PRIVATE_ITEM : 0;
                     }
                     $photoIds = $attachment['id'];
                     $photo = JTable::getInstance('Photo', 'CTable');
                     $photo->load($photoIds[0]);
                     $albumid = isset($attachment['album_id']) ? $attachment['album_id'] : $photo->albumid;
                     $album = JTable::getInstance('Album', 'CTable');
                     $album->load($albumid);
                     $params = array();
                     foreach ($photoIds as $photoId) {
                         $photo->load($photoId);
                         $photo->caption = $message;
                         $photo->permissions = $privacy;
                         $photo->published = 1;
                         $photo->status = 'ready';
                         $photo->albumid = $albumid;
                         $photo->store();
                         $params[] = clone $photo;
                     }
                     // Trigger onPhotoCreate
                     //
                     $apps = CAppPlugins::getInstance();
                     $apps->loadApplications();
                     $apps->triggerEvent('onPhotoCreate', array($params));
                     $act = new stdClass();
                     $act->cmd = 'photo.upload';
                     $act->actor = $my->id;
                     $act->access = $privacy;
                     $act->target = $attachment['target'] == $my->id ? 0 : $attachment['target'];
                     $act->title = $message;
                     //JText::sprintf('COM_COMMUNITY_ACTIVITIES_UPLOAD_PHOTO' , '{photo_url}', $album->name );
                     $act->content = '';
                     // Generated automatically by stream. No need to add anything
                     $act->app = 'photos';
                     $act->cid = $album->id;
                     $act->location = $album->location;
                     $act->eventid = $event->id;
                     $act->group_access = $privacy;
                     // just in case this event belongs to a group
                     //$act->access      = $attachment['privacy'];
                     /* Comment and like for individual photo upload is linked
                      * to the photos itsel
                      */
                     $act->comment_id = $photo->id;
                     $act->comment_type = 'photos';
                     $act->like_id = $photo->id;
                     $act->like_type = 'photo';
                     $albumUrl = 'index.php?option=com_community&view=photos&task=album&albumid=' . $album->id . '&userid=' . $my->id;
                     $albumUrl = CRoute::_($albumUrl);
                     $photoUrl = 'index.php?option=com_community&view=photos&task=photo&albumid=' . $album->id . '&userid=' . $photo->creator . '&photoid=' . $photo->id;
                     $photoUrl = CRoute::_($photoUrl);
                     $params = new CParameter('');
                     $params->set('multiUrl', $albumUrl);
                     $params->set('photoid', $photo->id);
                     $params->set('action', 'upload');
                     $params->set('stream', '1');
                     // this photo uploaded from status stream
                     $params->set('photo_url', $photoUrl);
                     $params->set('style', COMMUNITY_STREAM_STYLE);
                     // set stream style
                     $params->set('photosId', implode(',', $photoIds));
                     // Add activity logging
                     if (count($photoIds > 1)) {
                         $params->set('count', count($photoIds));
                         $params->set('batchcount', count($photoIds));
                     }
                     //Store mood in paramm
                     if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') {
                         $params->set('mood', $attachment['mood']);
                     }
                     // CActivityStream::remove($act->app, $act->cid);
                     $activityData = CActivityStream::add($act, $params->toString());
                     // Add user points
                     CUserPoints::assignPoint('photo.upload');
                     // Reload the stream with new stream data
                     $eventLib = new CEvents();
                     $event = JTable::getInstance('Event', 'CTable');
                     $event->load($attachment['target']);
                     $streamHTML = $eventLib->getStreamHTML($event, array('showLatestActivityOnTop' => true));
                     $objResponse->addScriptCall('__callback', JText::sprintf('COM_COMMUNITY_PHOTO_UPLOADED_SUCCESSFULLY', $photo->caption));
                     break;
                 case 'groups':
                     //
                     $groupLib = new CGroups();
                     $group = JTable::getInstance('Group', 'CTable');
                     $group->load($attachment['target']);
                     $photoIds = $attachment['id'];
                     $privacy = $group->approvals ? PRIVACY_GROUP_PRIVATE_ITEM : 0;
                     $photo = JTable::getInstance('Photo', 'CTable');
                     $photo->load($photoIds[0]);
                     $albumid = isset($attachment['album_id']) ? $attachment['album_id'] : $photo->albumid;
                     $album = JTable::getInstance('Album', 'CTable');
                     $album->load($albumid);
                     $params = array();
                     foreach ($photoIds as $photoId) {
                         $photo->load($photoId);
                         $photo->caption = $message;
                         $photo->permissions = $privacy;
                         $photo->published = 1;
                         $photo->status = 'ready';
                         $photo->albumid = $albumid;
                         $photo->store();
                         $params[] = clone $photo;
                     }
                     // Trigger onPhotoCreate
                     //
                     $apps = CAppPlugins::getInstance();
                     $apps->loadApplications();
                     $apps->triggerEvent('onPhotoCreate', array($params));
                     $act = new stdClass();
                     $act->cmd = 'photo.upload';
                     $act->actor = $my->id;
                     $act->access = $privacy;
                     $act->target = $attachment['target'] == $my->id ? 0 : $attachment['target'];
                     $act->title = $message;
                     //JText::sprintf('COM_COMMUNITY_ACTIVITIES_UPLOAD_PHOTO' , '{photo_url}', $album->name );
                     $act->content = '';
                     // Generated automatically by stream. No need to add anything
                     $act->app = 'photos';
                     $act->cid = $album->id;
                     $act->location = $album->location;
                     $act->groupid = $group->id;
                     $act->group_access = $group->approvals;
                     $act->eventid = 0;
                     //$act->access      = $attachment['privacy'];
                     /* Comment and like for individual photo upload is linked
                      * to the photos itsel
                      */
                     $act->comment_id = $photo->id;
                     $act->comment_type = 'photos';
                     $act->like_id = $photo->id;
                     $act->like_type = 'photo';
                     $albumUrl = 'index.php?option=com_community&view=photos&task=album&albumid=' . $album->id . '&userid=' . $my->id;
                     $albumUrl = CRoute::_($albumUrl);
                     $photoUrl = 'index.php?option=com_community&view=photos&task=photo&albumid=' . $album->id . '&userid=' . $photo->creator . '&photoid=' . $photo->id;
                     $photoUrl = CRoute::_($photoUrl);
                     $params = new CParameter('');
                     $params->set('multiUrl', $albumUrl);
                     $params->set('photoid', $photo->id);
                     $params->set('action', 'upload');
                     $params->set('stream', '1');
                     // this photo uploaded from status stream
                     $params->set('photo_url', $photoUrl);
                     $params->set('style', COMMUNITY_STREAM_STYLE);
                     // set stream style
                     $params->set('photosId', implode(',', $photoIds));
                     // Add activity logging
                     if (count($photoIds > 1)) {
                         $params->set('count', count($photoIds));
                         $params->set('batchcount', count($photoIds));
                     }
                     //Store mood in paramm
                     if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') {
                         $params->set('mood', $attachment['mood']);
                     }
                     // CActivityStream::remove($act->app, $act->cid);
                     $activityData = CActivityStream::add($act, $params->toString());
                     // Add user points
                     CUserPoints::assignPoint('photo.upload');
                     // Reload the stream with new stream data
                     $streamHTML = $groupLib->getStreamHTML($group, array('showLatestActivityOnTop' => true));
                     $objResponse->addScriptCall('__callback', JText::sprintf('COM_COMMUNITY_PHOTO_UPLOADED_SUCCESSFULLY', $photo->caption));
                     break;
                     dafault:
                     return;
             }
             break;
         case 'video':
             switch ($attachment['element']) {
                 case 'profile':
                     // attachment id
                     $fetch = $attachment['fetch'];
                     $cid = $fetch[0];
                     $privacy = isset($attachment['privacy']) ? $attachment['privacy'] : COMMUNITY_STATUS_PRIVACY_PUBLIC;
                     $video = JTable::getInstance('Video', 'CTable');
                     $video->load($cid);
                     $video->set('creator_type', VIDEO_USER_TYPE);
                     $video->set('status', 'ready');
                     $video->set('permissions', $privacy);
                     $video->set('title', $fetch[3]);
                     $video->set('description', $fetch[4]);
                     $video->set('category_id', $fetch[5]);
                     /* Save cords if exists */
                     if (isset($attachment['location'])) {
                         $video->set('location', $attachment['location'][0]);
                         $video->set('latitude', $attachment['location'][1]);
                         $video->set('longitude', $attachment['location'][2]);
                     }
                     // Add activity logging
                     $url = $video->getViewUri(false);
                     $act = new stdClass();
                     $act->cmd = 'videos.linking';
                     $act->actor = $my->id;
                     $act->target = $attachment['target'] == $my->id ? 0 : $attachment['target'];
                     $act->access = $privacy;
                     //filter empty message
                     $act->title = $message;
                     $act->app = 'videos.linking';
                     $act->content = '';
                     $act->cid = $video->id;
                     $act->location = $video->location;
                     /* Save cords if exists */
                     if (isset($attachment['location'])) {
                         /* Save geo name */
                         $act->location = $attachment['location'][0];
                         $act->latitude = $attachment['location'][1];
                         $act->longitude = $attachment['location'][2];
                     }
                     $act->comment_id = $video->id;
                     $act->comment_type = 'videos.linking';
                     $act->like_id = $video->id;
                     $act->like_type = 'videos.linking';
                     $params = new CParameter('');
                     $params->set('video_url', $url);
                     $params->set('style', COMMUNITY_STREAM_STYLE);
                     // set stream style
                     //Store mood in paramm
                     if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') {
                         $params->set('mood', $attachment['mood']);
                     }
                     //
                     $activityData = CActivityStream::add($act, $params->toString());
                     //this video must be public because it's posted on someone else's profile
                     if ($my->id != $attachment['target']) {
                         $video->set('permissions', COMMUNITY_STATUS_PRIVACY_PUBLIC);
                         $params = new CParameter();
                         $params->set('activity_id', $activityData->id);
                         // activity id is used to remove the activity if someone deleted this video
                         $params->set('target_id', $attachment['target']);
                         $video->params = $params->toString();
                         //also send a notification to the user
                         $recipient = CFactory::getUser($attachment['target']);
                         $params = new CParameter('');
                         $params->set('actorName', $my->getDisplayName());
                         $params->set('recipientName', $recipient->getDisplayName());
                         $params->set('url', CUrlHelper::userLink($act->target, false));
                         $params->set('message', $message);
                         $params->set('stream', JText::_('COM_COMMUNITY_SINGULAR_STREAM'));
                         $params->set('stream_url', CRoute::_('index.php?option=com_community&view=profile&userid=' . $activityData->actor . '&actid=' . $activityData->id));
                         CNotificationLibrary::add('profile_status_update', $my->id, $attachment['target'], JText::_('COM_COMMUNITY_NOTIFICATION_STREAM_VIDEO_POST'), '', 'wall.post', $params);
                     }
                     $video->store();
                     // @rule: Add point when user adds a new video link
                     //
                     CUserPoints::assignPoint('video.add', $video->creator);
                     //email and add notification if user are tagged
                     CUserHelper::parseTaggedUserNotification($message, $my, $activityData, array('type' => 'post-comment'));
                     // Trigger for onVideoCreate
                     //
                     $apps = CAppPlugins::getInstance();
                     $apps->loadApplications();
                     $params = array();
                     $params[] = $video;
                     $apps->triggerEvent('onVideoCreate', $params);
                     $this->cacheClean(array(COMMUNITY_CACHE_TAG_VIDEOS, COMMUNITY_CACHE_TAG_FRONTPAGE, COMMUNITY_CACHE_TAG_FEATURED, COMMUNITY_CACHE_TAG_VIDEOS_CAT, COMMUNITY_CACHE_TAG_ACTIVITIES));
                     $objResponse->addScriptCall('__callback', JText::sprintf('COM_COMMUNITY_VIDEOS_UPLOAD_SUCCESS', $video->title));
                     break;
                 case 'groups':
                     // attachment id
                     $fetch = $attachment['fetch'];
                     $cid = $fetch[0];
                     $privacy = 0;
                     //$attachment['privacy'];
                     $video = JTable::getInstance('Video', 'CTable');
                     $video->load($cid);
                     $video->set('status', 'ready');
                     $video->set('groupid', $attachment['target']);
                     $video->set('permissions', $privacy);
                     $video->set('creator_type', VIDEO_GROUP_TYPE);
                     $video->set('title', $fetch[3]);
                     $video->set('description', $fetch[4]);
                     $video->set('category_id', $fetch[5]);
                     /* Save cords if exists */
                     if (isset($attachment['location'])) {
                         $video->set('location', $attachment['location'][0]);
                         $video->set('latitude', $attachment['location'][1]);
                         $video->set('longitude', $attachment['location'][2]);
                     }
                     $video->store();
                     //
                     $groupLib = new CGroups();
                     $group = JTable::getInstance('Group', 'CTable');
                     $group->load($attachment['target']);
                     // Add activity logging
                     $url = $video->getViewUri(false);
                     $act = new stdClass();
                     $act->cmd = 'videos.linking';
                     $act->actor = $my->id;
                     $act->target = $attachment['target'] == $my->id ? 0 : $attachment['target'];
                     $act->access = $privacy;
                     //filter empty message
                     $act->title = $message;
                     $act->app = 'videos';
                     $act->content = '';
                     $act->cid = $video->id;
                     $act->groupid = $video->groupid;
                     $act->group_access = $group->approvals;
                     $act->location = $video->location;
                     /* Save cords if exists */
                     if (isset($attachment['location'])) {
                         /* Save geo name */
                         $act->location = $attachment['location'][0];
                         $act->latitude = $attachment['location'][1];
                         $act->longitude = $attachment['location'][2];
                     }
                     $act->comment_id = $video->id;
                     $act->comment_type = 'videos';
                     $act->like_id = $video->id;
                     $act->like_type = 'videos';
                     $params = new CParameter('');
                     $params->set('video_url', $url);
                     $params->set('style', COMMUNITY_STREAM_STYLE);
                     // set stream style
                     //Store mood in paramm
                     if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') {
                         $params->set('mood', $attachment['mood']);
                     }
                     $activityData = CActivityStream::add($act, $params->toString());
                     // @rule: Add point when user adds a new video link
                     CUserPoints::assignPoint('video.add', $video->creator);
                     // Trigger for onVideoCreate
                     $apps = CAppPlugins::getInstance();
                     $apps->loadApplications();
                     $params = array();
                     $params[] = $video;
                     $apps->triggerEvent('onVideoCreate', $params);
                     $this->cacheClean(array(COMMUNITY_CACHE_TAG_VIDEOS, COMMUNITY_CACHE_TAG_FRONTPAGE, COMMUNITY_CACHE_TAG_FEATURED, COMMUNITY_CACHE_TAG_VIDEOS_CAT, COMMUNITY_CACHE_TAG_ACTIVITIES));
                     $objResponse->addScriptCall('__callback', JText::sprintf('COM_COMMUNITY_VIDEOS_UPLOAD_SUCCESS', $video->title));
                     // Reload the stream with new stream data
                     $streamHTML = $groupLib->getStreamHTML($group, array('showLatestActivityOnTop' => true));
                     break;
                 case 'events':
                     //event videos
                     $fetch = $attachment['fetch'];
                     $cid = $fetch[0];
                     $privacy = 0;
                     //$attachment['privacy'];
                     $video = JTable::getInstance('Video', 'CTable');
                     $video->load($cid);
                     $video->set('status', 'ready');
                     $video->set('eventid', $attachment['target']);
                     $video->set('permissions', $privacy);
                     $video->set('creator_type', VIDEO_EVENT_TYPE);
                     $video->set('title', $fetch[3]);
                     $video->set('description', $fetch[4]);
                     $video->set('category_id', $fetch[5]);
                     /* Save cords if exists */
                     if (isset($attachment['location'])) {
                         $video->set('location', $attachment['location'][0]);
                         $video->set('latitude', $attachment['location'][1]);
                         $video->set('longitude', $attachment['location'][2]);
                     }
                     $video->store();
                     //
                     $eventLib = new CEvents();
                     $event = JTable::getInstance('Event', 'CTable');
                     $event->load($attachment['target']);
                     $group = new stdClass();
                     if ($event->type == 'group' && $event->contentid) {
                         // check if this a group event, and follow the permission
                         $group = JTable::getInstance('Group', 'CTable');
                         $group->load($event->contentid);
                     }
                     // Add activity logging
                     $url = $video->getViewUri(false);
                     $act = new stdClass();
                     $act->cmd = 'videos.linking';
                     $act->actor = $my->id;
                     $act->target = $attachment['target'] == $my->id ? 0 : $attachment['target'];
                     $act->access = $privacy;
                     //filter empty message
                     $act->title = $message;
                     $act->app = 'videos';
                     $act->content = '';
                     $act->cid = $video->id;
                     $act->groupid = 0;
                     $act->group_access = isset($group->approvals) ? $group->approvals : 0;
                     // if this is a group event
                     $act->location = $video->location;
                     /* Save cords if exists */
                     if (isset($attachment['location'])) {
                         /* Save geo name */
                         $act->location = $attachment['location'][0];
                         $act->latitude = $attachment['location'][1];
                         $act->longitude = $attachment['location'][2];
                     }
                     $act->eventid = $event->id;
                     $act->comment_id = $video->id;
                     $act->comment_type = 'videos';
                     $act->like_id = $video->id;
                     $act->like_type = 'videos';
                     $params = new CParameter('');
                     $params->set('video_url', $url);
                     $params->set('style', COMMUNITY_STREAM_STYLE);
                     // set stream style
                     //Store mood in paramm
                     if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') {
                         $params->set('mood', $attachment['mood']);
                     }
                     $activityData = CActivityStream::add($act, $params->toString());
                     // @rule: Add point when user adds a new video link
                     CUserPoints::assignPoint('video.add', $video->creator);
                     // Trigger for onVideoCreate
                     $apps = CAppPlugins::getInstance();
                     $apps->loadApplications();
                     $params = array();
                     $params[] = $video;
                     $apps->triggerEvent('onVideoCreate', $params);
                     $this->cacheClean(array(COMMUNITY_CACHE_TAG_VIDEOS, COMMUNITY_CACHE_TAG_FRONTPAGE, COMMUNITY_CACHE_TAG_FEATURED, COMMUNITY_CACHE_TAG_VIDEOS_CAT, COMMUNITY_CACHE_TAG_ACTIVITIES));
                     $objResponse->addScriptCall('__callback', JText::sprintf('COM_COMMUNITY_VIDEOS_UPLOAD_SUCCESS', $video->title));
                     // Reload the stream with new stream data
                     $streamHTML = $eventLib->getStreamHTML($event, array('showLatestActivityOnTop' => true));
                     break;
                 default:
                     return;
             }
             break;
         case 'event':
             switch ($attachment['element']) {
                 case 'profile':
                     require_once COMMUNITY_COM_PATH . '/controllers/events.php';
                     $eventController = new CommunityEventsController();
                     // Assign default values where necessary
                     $attachment['description'] = $message;
                     $attachment['ticket'] = 0;
                     $attachment['offset'] = 0;
                     $event = $eventController->ajaxCreate($attachment, $objResponse);
                     $objResponse->addScriptCall('window.location="' . $event->getLink() . '";');
                     if (CFactory::getConfig()->get('event_moderation')) {
                         $objResponse->addAlert(JText::sprintf('COM_COMMUNITY_EVENTS_MODERATION_NOTICE', $event->title));
                     }
                     break;
                 case 'groups':
                     require_once COMMUNITY_COM_PATH . '/controllers/events.php';
                     $eventController = new CommunityEventsController();
                     //
                     $groupLib = new CGroups();
                     $group = JTable::getInstance('Group', 'CTable');
                     $group->load($attachment['target']);
                     // Assign default values where necessary
                     $attachment['description'] = $message;
                     $attachment['ticket'] = 0;
                     $attachment['offset'] = 0;
                     $event = $eventController->ajaxCreate($attachment, $objResponse);
                     CEvents::addGroupNotification($event);
                     $objResponse->addScriptCall('window.location="' . $event->getLink() . '";');
                     // Reload the stream with new stream data
                     $streamHTML = $groupLib->getStreamHTML($group, array('showLatestActivityOnTop' => true));
                     if (CFactory::getConfig()->get('event_moderation')) {
                         $objResponse->addAlert(JText::sprintf('COM_COMMUNITY_EVENTS_MODERATION_NOTICE', $event->title));
                     }
                     break;
             }
             break;
         case 'link':
             break;
     }
     //no matter what kind of message it is, always filter the hashtag if there's any
     if (!empty($act->title) && isset($activityData->id) && $activityData->id) {
         //use model to check if this has a tag in it and insert into the table if possible
         $hashtags = CContentHelper::getHashTags($act->title);
         if (count($hashtags)) {
             //$hashTag
             $hashtagModel = CFactory::getModel('hashtags');
             foreach ($hashtags as $tag) {
                 $hashtagModel->addActivityHashtag($tag, $activityData->id);
             }
         }
     }
     // Frontpage filter
     if ($streamFilter != false) {
         $streamFilter = json_decode($streamFilter);
         $filter = $streamFilter->filter;
         $value = $streamFilter->value;
         $extra = false;
         // Append added data to the list.
         if (isset($activityData) && $activityData->id) {
             $model = CFactory::getModel('Activities');
             $extra = $model->getActivity($activityData->id);
         }
         switch ($filter) {
             case 'privacy':
                 if ($value == 'me-and-friends' && $my->id != 0) {
                     $streamHTML = CActivities::getActivitiesByFilter('active-user-and-friends', $my->id, 'frontpage', true, array(), $extra);
                 } else {
                     $streamHTML = CActivities::getActivitiesByFilter('all', $my->id, 'frontpage', true, array(), $extra);
                 }
                 break;
             case 'apps':
                 $streamHTML = CActivities::getActivitiesByFilter('all', $my->id, 'frontpage', true, array('apps' => array($value)), $extra);
                 break;
             case 'hashtag':
                 $streamHTML = CActivities::getActivitiesByFilter('all', $my->id, 'frontpage', true, array($filter => $value), $extra);
                 break;
             default:
                 $defaultFilter = $config->get('frontpageactivitydefault');
                 if ($defaultFilter == 'friends' && $my->id != 0) {
                     $streamHTML = CActivities::getActivitiesByFilter('active-user-and-friends', $my->id, 'frontpage', true, array(), $extra);
                 } else {
                     $streamHTML = CActivities::getActivitiesByFilter('all', $my->id, 'frontpage', true, array(), $extra);
                 }
                 break;
         }
     }
     if (!isset($attachment['filter'])) {
         $attachment['filter'] = '';
         $filter = $config->get('frontpageactivitydefault');
         $filter = explode(':', $filter);
         $attachment['filter'] = isset($filter[1]) ? $filter[1] : $filter[0];
     }
     if (empty($streamHTML)) {
         if (!isset($attachment['target'])) {
             $attachment['target'] = '';
         }
         if (!isset($attachment['element'])) {
             $attachment['element'] = '';
         }
         $streamHTML = CActivities::getActivitiesByFilter($attachment['filter'], $attachment['target'], $attachment['element'], true, array('show_featured' => true, 'showLatestActivityOnTop' => true));
     }
     $objResponse->addAssign('activity-stream-container', 'innerHTML', $streamHTML);
     // Log user engagement
     CEngagement::log($attachment['type'] . '.share', $my->id);
     return $objResponse->sendResponse();
 }
Exemple #25
0
 /**
  * Add reply via ajax
  * @todo: check permission and message ownership
  */
 public function ajaxAddReply($msgId, $reply, $photoId = 0)
 {
     $filter = JFilterInput::getInstance();
     $msgId = $filter->clean($msgId, 'int');
     //$reply = $filter->clean($reply, 'string');
     $photoId = $filter->clean($photoId, 'int');
     $my = CFactory::getUser();
     $model = $this->getModel('inbox');
     $message = $model->getMessage($msgId);
     $messageRecipient = $model->getParticipantsID($msgId, $my->id);
     if ($my->id == 0) {
         return $this->ajaxBlockUnregister();
     }
     // Block users
     $getBlockStatus = new blockUser();
     $userModel = CFactory::getModel('User');
     $bannedList = $userModel->getBannedUser();
     $newRecipient = array();
     foreach ($messageRecipient as $recipient) {
         if ($getBlockStatus->isUserBlocked($recipient, 'inbox')) {
             continue;
         }
         $newRecipient[] = $recipient;
     }
     $messageRecipient = $newRecipient;
     // @rule: Spam checks
     if ($this->_isSpam($my, $reply)) {
         $json = array('error' => JText::_('COM_COMMUNITY_INBOX_MESSAGE_MARKED_SPAM'));
         die(json_encode($json));
     }
     if (empty($reply) && $photoId == 0) {
         $json = array('error' => JText::_('COM_COMMUNITY_INBOX_MESSAGE_CANNOT_BE_EMPTY'));
         die(json_encode($json));
     }
     if (empty($messageRecipient)) {
         $json = array('error' => JText::_('COM_COMMUNITY_INBOX_MESSAGE_CANNOT_FIND_RECIPIENT'));
         die(json_encode($json));
     }
     // make sure we can only reply to message that belogn to current user
     if (!$model->canReply($my->id, $msgId)) {
         $json = array('error' => JText::_('COM_COMMUNITY_PERMISSION_DENIED_WARNING'));
         die(json_encode($json));
     }
     if (in_array($messageRecipient[0], $bannedList)) {
         $json = array('error' => JText::_('COM_COMMUNITY_USER_BANNED'));
         die(json_encode($json));
     }
     $date = JFactory::getDate();
     //get the time without any offset!
     $obj = new stdClass();
     $obj->id = null;
     $obj->from = $my->id;
     $obj->posted_on = $date->toSql();
     $obj->from_name = $my->name;
     $obj->subject = 'RE:' . $message->subject;
     $obj->body = $reply;
     $body = new JRegistry();
     $body->set('content', $obj->body);
     // photo attachment
     if ($photoId > 0) {
         //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') {
             $body->set('attached_photo_id', $photoId);
             //sets the status to ready so that it wont be deleted on cron run
             $photo->status = 'ready';
             $photo->store();
         }
     }
     /**
      * @since 3.2.1
      * Message URL fetching
      */
     if (preg_match("/\\b(?:(?:https?|ftp):\\/\\/|www\\.)[-a-z0-9+&@#\\/%?=~_|!:,.;]*[-a-z0-9+&@#\\/%=~_|]/i", $obj->body)) {
         $graphObject = CParsers::linkFetch($obj->body);
         if ($graphObject) {
             $graphObject->merge($body);
             $obj->body = $graphObject->toString();
         }
     } else {
         $obj->body = $body->toString();
     }
     $model->sendReply($obj, $msgId);
     $deleteLink = CRoute::_('index.php?option=com_community&view=inbox&task=remove&msgid=' . $obj->id);
     $authorLink = CRoute::_('index.php?option=com_community&view=profile&userid=' . $my->id);
     //add user points
     CUserPoints::assignPoint('inbox.message.reply');
     // Add notification
     foreach ($messageRecipient as $row) {
         $params = new CParameter('');
         $params->set('message', $reply);
         $params->set('title', $obj->subject);
         $params->set('url', 'index.php?option=com_community&view=inbox&task=read&msgid=' . $msgId);
         $params->set('msg_url', 'index.php?option=com_community&view=inbox&task=read&msgid=' . $msgId);
         $params->set('msg', JText::_('COM_COMMUNITY_PRIVATE_MESSAGE'));
         $params->set('msg', JText::_('COM_COMMUNITY_PRIVATE_MESSAGE'));
         CNotificationLibrary::add('inbox_create_message', $my->id, $row, JText::_('COM_COMMUNITY_SENT_YOU_MESSAGE'), '', 'inbox.sent', $params);
     }
     // onMessageDisplay Event trigger
     $appsLib = CAppPlugins::getInstance();
     $appsLib->loadApplications();
     $args = array();
     $args[] = $obj;
     $appsLib->triggerEvent('onMessageDisplay', $args);
     $params = new JRegistry($obj->body);
     // 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($obj->from));
     $tmpl->set('msg', $obj);
     $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('success' => true, 'html' => $html);
     die(json_encode($json));
 }
Exemple #26
0
 /**
  * Application full view
  **/
 public function appFullView()
 {
     $document = JFactory::getDocument();
     $document->setTitle(JText::_('COM_COMMUNITY_VIDEOS_WALL_TITLE'));
     $applicationName = JString::strtolower(JRequest::getVar('app', '', 'GET'));
     if (empty($applicationName)) {
         JError::raiseError(500, 'COM_COMMUNITY_APP_ID_REQUIRED');
     }
     $output = '';
     if ($applicationName == 'walls') {
         CFactory::load('libraries', 'wall');
         $limit = JRequest::getVar('limit', 5, 'REQUEST');
         $limitstart = JRequest::getVar('limitstart', 0, 'REQUEST');
         $videoId = JRequest::getInt('videoid', '', 'GET');
         $my = CFactory::getUser();
         $config = CFactory::getConfig();
         $videoModel = CFactory::getModel('videos');
         $video =& JTable::getInstance('Video', 'CTable');
         $video->load($videoId);
         CFactory::load('helpers', 'owner');
         CFactory::load('helpers', 'friends');
         if (!$config->get('lockvideoswalls') || $config->get('lockvideoswalls') && CFriendsHelper::isConnected($my->id, $video->creator) || COwnerHelper::isCommunityAdmin()) {
             $viewAllLink = false;
             if (JRequest::getVar('task', '', 'REQUEST') != 'app') {
                 $viewAllLink = CRoute::_('index.php?option=com_community&view=videos&task=app&videoid=' . $video->id . '&app=walls');
             }
             $output .= CWallLibrary::getWallInputForm($video->id, 'videos,ajaxSaveWall', 'videos,ajaxRemoveWall', $viewAllLink);
         }
         // Get the walls content
         $output .= '<div id="wallContent">';
         $output .= CWallLibrary::getWallContents('videos', $video->id, COwnerHelper::isCommunityAdmin() || COwnerHelper::isMine($my->id, $video->creator), $limit, $limitstart);
         $output .= '</div>';
         jimport('joomla.html.pagination');
         $wallModel = CFactory::getModel('wall');
         $pagination = new JPagination($wallModel->getCount($video->id, 'videos'), $limitstart, $limit);
         $output .= '<div class="pagination-container">' . $pagination->getPagesLinks() . '</div>';
     } else {
         $model = CFactory::getModel('apps');
         $applications =& CAppPlugins::getInstance();
         $applicationId = $model->getUserApplicationId($applicationName);
         $application = $applications->get($applicationName, $applicationId);
         // Get the parameters
         $manifest = CPluginHelper::getPluginPath('community', $applicationName) . DS . $applicationName . DS . $applicationName . '.xml';
         $params = new CParameter($model->getUserAppParams($applicationId), $manifest);
         $application->params =& $params;
         $application->id = $applicationId;
         $output = $application->onAppDisplay($params);
     }
     echo $output;
 }
Exemple #27
0
 public function triggerEvent($eventName, &$args, $target = null)
 {
     CError::assert($args, 'object', 'istype', __FILE__, __LINE__);
     require_once COMMUNITY_COM_PATH . '/libraries/apps.php';
     $appsLib = CAppPlugins::getInstance();
     $appsLib->loadApplications();
     $params = array();
     $params[] = $args;
     if (!is_null($target)) {
         $params[] = $target;
     }
     $appsLib->triggerEvent($eventName, $params);
     return true;
 }
Exemple #28
0
 /**
  * Return the an array of HTML part of bulletings in viewGroups
  * and the total number of bulletin	 
  */
 protected function _getBulletinListHTML($groupId)
 {
     $result = array();
     $bulletinModel = CFactory::getModel('bulletins');
     $bulletins = $bulletinModel->getBulletins($groupId);
     $totalBulletin = $bulletinModel->total;
     // Get the creator of the discussions
     for ($i = 0; $i < count($bulletins); $i++) {
         $row =& $bulletins[$i];
         $row->creator = CFactory::getUser($row->created_by);
     }
     // Only trigger the bulletins if there is really a need to.
     if (!empty($bulletins)) {
         $appsLib =& CAppPlugins::getInstance();
         $appsLib->loadApplications();
         // Format the bulletins
         // the bulletins need to be an array or reference to work around
         // PHP 5.3 pass by value
         $args = array();
         foreach ($bulletins as &$b) {
             $args[] =& $b;
         }
         $appsLib->triggerEvent('onBulletinDisplay', $args);
     }
     // Process bulletins HTML output
     $tmpl = new CTemplate();
     $bulletinsHTML = $tmpl->set('bulletins', $bulletins)->set('groupId', $groupId)->fetch('groups.bulletinlist');
     unset($tmpl);
     $result['HTML'] = $bulletinsHTML;
     $result['total'] = $totalBulletin;
     $result['data'] = $bulletins;
     return $result;
 }
Exemple #29
0
 /**
  * Application full view
  * */
 public function appFullView()
 {
     /**
      * Opengraph
      */
     // CHeadHelper::setType('website', JText::_('COM_COMMUNITY_PHOTOS_WALL_TITLE'));
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $applicationName = JString::strtolower($jinput->get->get('app', '', 'STRING'));
     if (empty($applicationName)) {
         JError::raiseError(500, JText::_('COM_COMMUNITY_APP_ID_REQUIRED'));
     }
     $output = '<div class="joms-page">';
     $output .= '<h3 class="joms-page__title">' . JText::_('COM_COMMUNITY_PHOTOS_WALL_TITLE') . '</h3>';
     if ($applicationName == 'walls') {
         //CFactory::load( 'libraries' , 'wall' );
         $limit = $jinput->request->get('limit', 5, 'INT');
         //JRequest::getVar( 'limit' , 5 , 'REQUEST' );
         $limitstart = $jinput->request->get('limitstart', 0, 'INT');
         //JRequest::getVar( 'limitstart', 0, 'REQUEST' );
         $albumId = JRequest::getInt('albumid', '');
         $my = CFactory::getUser();
         $album = JTable::getInstance('Album', 'CTable');
         $album->load($albumId);
         //CFactory::load( 'helpers' , 'owner' );
         //CFactory::load( 'helpers' , 'friends' );
         // Get the walls content
         $viewAllLink = false;
         $wallCount = false;
         if ($jinput->request->get('task', '') != 'app') {
             $viewAllLink = CRoute::_('index.php?option=com_community&view=photos&task=app&albumid=' . $album->id . '&app=walls');
             $wallCount = CWallLibrary::getWallCount('album', $album->id);
         }
         $output .= CWallLibrary::getWallContents('albums', $album->id, COwnerHelper::isCommunityAdmin() || COwnerHelper::isMine($my->id, $album->creator), $limit, $limitstart);
         if (CFriendsHelper::isConnected($my->id, $album->creator) || COwnerHelper::isCommunityAdmin()) {
             $output .= CWallLibrary::getWallInputForm($album->id, 'photos,ajaxAlbumSaveWall', 'photos,ajaxAlbumRemoveWall');
         }
         $output .= CWallLibrary::getViewAllLinkHTML($viewAllLink, $wallCount);
         jimport('joomla.html.pagination');
         $wallModel = CFactory::getModel('wall');
         $pagination = new JPagination($wallModel->getCount($album->id, 'albums'), $limitstart, $limit);
         $output .= '<div class="cPagination">' . $pagination->getPagesLinks() . '</div>';
     } else {
         $model = CFactory::getModel('apps');
         $applications = CAppPlugins::getInstance();
         $applicationId = $model->getUserApplicationId($applicationName);
         $application = $applications->get($applicationName, $applicationId);
         if (is_callable(array($application, 'onAppDisplay'), true)) {
             // Get the parameters
             $manifest = CPluginHelper::getPluginPath('community', $applicationName) . '/' . $applicationName . '/' . $applicationName . '.xml';
             $params = new CParameter($model->getUserAppParams($applicationId), $manifest);
             $application->params = $params;
             $application->id = $applicationId;
             $output = $application->onAppDisplay($params);
         } else {
             JError::raiseError(500, JText::_('COM_COMMUNITY_APPS_NOT_FOUND'));
         }
     }
     $output .= '</div>';
     echo $output;
 }
Exemple #30
0
 /**
  *
  */
 public function showAbout($appName)
 {
     $app = CFactory::getModel('apps');
     $appObj = $app->getAppInfo($appName);
     // Load application language so that JText can properly translate it.
     CAppPlugins::loadLanguage('plg_' . $appObj->name, JPATH_ADMINISTRATOR);
     // Trim out tab's in xml files.
     $appObj->description = JString::trim($appObj->description);
     $tmpl = new CTemplate();
     return $tmpl->set('app', $appObj)->fetch('apps.about');
 }