public function ajaxResetNotification($params)
 {
     $response = new JAXResponse();
     if (!COwnerHelper::isCommunityAdmin()) {
         $response->addAssign('notification-update-result', 'innerHTML', JText::_('COM_COMMUNITY_NOT_ALLOWED'));
         return $response->sendResponse();
     }
     $model = $this->getModel('Configuration');
     $model->updateNotification($params);
     $response->addAssign('notification-update-result', 'innerHTML', JText::_('COM_COMMUNITY_FRONTPAGE_ALL_NOTIFICATION_RESET'));
     $response->addScriptCall("joms.jQuery('#notification-update-result').parent().find('input').val('" . JText::_('COM_COMMUNITY_CONFIGURATION_PRIVACY_RESET_EXISTING_NOTIFICATION_BUTTON') . "');");
     return $response->sendResponse();
 }
 public function ajaxResetPrivacy($photoPrivacy = 0, $profilePrivacy = 0, $friendsPrivacy = 0)
 {
     $response = new JAXResponse();
     CFactory::load('helpers', 'owner');
     if (!COwnerHelper::isCommunityAdmin()) {
         $response->addScriptCall(JText::_('COM_COMMUNITY_NOT_ALLOWED'));
         return $response->sendResponse();
     }
     $model = $this->getModel('Configuration');
     $model->updatePrivacy($photoPrivacy, $profilePrivacy, $friendsPrivacy);
     $response->addAssign('privacy-update-result', 'innerHTML', JText::_('COM_COMMUNITY_FRONTPAGE_ALL_PRIVACY_RESET'));
     return $response->sendResponse();
 }
Exemple #3
0
 public function ajaxAddFeatured($memberId)
 {
     $objResponse = new JAXResponse();
     CFactory::load('helpers', 'owner');
     $my = CFactory::getUser();
     if ($my->id == 0) {
         return $this->ajaxBlockUnregister();
     }
     if (COwnerHelper::isCommunityAdmin()) {
         $model = CFactory::getModel('Featured');
         if (!$model->isExists(FEATURED_USERS, $memberId)) {
             CFactory::load('libraries', 'featured');
             $featured = new CFeatured(FEATURED_USERS);
             $member = CFactory::getUser($memberId);
             $featured->add($memberId, $my->id);
             $objResponse->addAssign('cWindowContent', 'innerHTML', JText::sprintf('CC MEMBER IS FEATURED', $member->getDisplayName()));
         } else {
             $objResponse->addAssign('cWindowContent', 'innerHTML', JText::_('CC USER ALREADY FEATURED'));
         }
     } else {
         $objResponse->addAssign('cWindowContent', 'innerHTML', JText::_('CC NOT ALLOWED TO ACCESS SECTION'));
     }
     $buttons = '<input type="button" class="button" onclick="window.location.reload();" value="' . JText::_('CC BUTTON CLOSE') . '"/>';
     $objResponse->addScriptCall('cWindowActions', $buttons);
     return $objResponse->sendResponse();
 }
Exemple #4
0
 public function ajaxAddFeatured($memberId)
 {
     $filter = JFilterInput::getInstance();
     $memberId = $filter->clean($memberId, 'int');
     $objResponse = new JAXResponse();
     CFactory::load('helpers', 'owner');
     $my = CFactory::getUser();
     if ($my->id == 0) {
         return $this->ajaxBlockUnregister();
     }
     if (COwnerHelper::isCommunityAdmin()) {
         $model = CFactory::getModel('Featured');
         if (!$model->isExists(FEATURED_USERS, $memberId)) {
             CFactory::load('libraries', 'featured');
             $featured = new CFeatured(FEATURED_USERS);
             $member = CFactory::getUser($memberId);
             $featured->add($memberId, $my->id);
             $html = JText::sprintf('COM_COMMUNITY_MEMBER_IS_FEATURED', $member->getDisplayName());
         } else {
             $html = JText::_('COM_COMMUNITY_USER_ALREADY_FEATURED');
         }
     } else {
         $html = JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_ACCESS_SECTION');
     }
     $actions = '<input type="button" class="button" onclick="window.location.reload();" value="' . JText::_('COM_COMMUNITY_BUTTON_CLOSE_BUTTON') . '"/>';
     $objResponse->addScriptCall('cWindowAddContent', $html, $actions);
     $this->cacheClean(array(COMMUNITY_CACHE_TAG_FEATURED));
     return $objResponse->sendResponse();
 }
Exemple #5
0
 public function ajaxSendMessage($title, $message, $limit = 1)
 {
     if (!$title || !$message) {
         $response = new JAXResponse();
         $response->addScriptCall("joms.jQuery('#error').remove();");
         $response->addScriptCall('joms.jQuery("#messaging-form").prepend("<p id=error style=color:red>Error:Title or Message cannot be empty</p>");');
         return $response->sendResponse();
     }
     $limitstart = $limit - 1;
     $model =& $this->getModel('users');
     $userId = $model->getSiteUsers($limitstart, 1);
     $response = new JAXResponse();
     $response->addScriptCall('joms.jQuery("#messaging-form").hide();');
     $response->addScriptCall('joms.jQuery("#messaging-result").show();');
     $user = CFactory::getUser($userId);
     $my =& JFactory::getUser();
     if (!empty($userId)) {
         require_once JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'notification.php';
         CNotificationLibrary::add('etype_system_messaging', $my->id, $user->id, $title, $message);
         $response->addScriptCall('joms.jQuery("#no-progress").css("display","none");');
         $response->addScriptCall('joms.jQuery("#progress-status").append("<div>' . JText::sprintf('Sending message to <strong>%1$s</strong>', str_replace(array("\r", "\n"), ' ', $user->getDisplayname())) . '<span style=\\"color: green;margin-left: 5px;\\">' . JText::_('COM_COMMUNITY_SUCCESS') . '</span></div>");');
         $response->addScriptCall('sendMessage', $title, $message, $limit + 1);
     } else {
         $response->addScriptCall('joms.jQuery("#progress-status").append("<div style=\\"font-weight:700;\\">' . JText::_('COM_COMMUNITY_UPDATED') . '</div>");');
     }
     return $response->sendResponse();
 }
Exemple #6
0
 public function render()
 {
     // When dispatch() is called from JApplication,
     // the rendered content is immediately stored
     // in the component buffer, so instead of rerendering
     // our component, we'll extract it out from the buffer.
     $this->content = $this->_buffer['component'][''];
     unset($this->_buffer);
     // and send the document back within jax response.
     $objResponse = new JAXResponse();
     $objResponse->addScriptCall('__callback', $this);
     return $objResponse->sendResponse();
 }
Exemple #7
0
 public function ajaxEmailPage($uri, $emails, $message = '')
 {
     $filter = JFilterInput::getInstance();
     $uri = $filter->clean($uri, 'string');
     $emails = $filter->clean($emails, 'string');
     $message = $filter->clean($message, 'string');
     $message = stripslashes($message);
     $mainframe =& JFactory::getApplication();
     $bookmarks = CFactory::getBookmarks($uri);
     $mailqModel = CFactory::getModel('mailq');
     $config = CFactory::getConfig();
     $response = new JAXResponse();
     if (empty($emails)) {
         $content = '<div>' . JText::_('COM_COMMUNITY_SHARE_INVALID_EMAIL') . '</div>';
         $actions = '<input type="button" class="button" onclick="joms.bookmarks.show(\'' . $uri . '\');" value="' . JText::_('COM_COMMUNITY_GO_BACK_BUTTON') . '"/>';
     } else {
         $emails = explode(',', $emails);
         $errors = array();
         // Add notification
         CFactory::load('libraries', 'notification');
         foreach ($emails as $email) {
             $email = JString::trim($email);
             CFactory::load('helpers', 'validate');
             if (!empty($email) && CValidateHelper::email($email)) {
                 $params = new CParameter('');
                 $params->set('uri', $uri);
                 $params->set('message', $message);
                 CNotificationLibrary::add('etype_system_bookmarks_email', '', $email, JText::sprintf('COM_COMMUNITY_SHARE_EMAIL_SUBJECT', $config->get('sitename')), '', 'bookmarks', $params);
             } else {
                 // If there is errors with email, inform the user.
                 $errors[] = $email;
             }
         }
         if ($errors) {
             $content = '<div>' . JText::_('COM_COMMUNITY_EMAILS_ARE_INVALID') . '</div>';
             foreach ($errors as $error) {
                 $content .= '<div style="font-weight:700;color: red;">' . $error . '</span>';
             }
             $actions = '<input type="button" class="button" onclick="joms.bookmarks.show(\'' . $uri . '\');" value="' . JText::_('COM_COMMUNITY_GO_BACK_BUTTON') . '"/>';
         } else {
             $content = '<div>' . JText::_('COM_COMMUNITY_EMAIL_SENT_TO_RECIPIENTS') . '</div>';
             $actions = '<input type="button" class="button" onclick="cWindowHide();" value="' . JText::_('COM_COMMUNITY_DONE_BUTTON') . '"/>';
         }
     }
     $response->addAssign('cwin_logo', 'innerHTML', JText::_('COM_COMMUNITY_SHARE_THIS'));
     $response->addScriptCall('cWindowAddContent', $content, $actions);
     return $response->sendResponse();
 }
Exemple #8
0
 public function ajaxEmailPage($uri, $emails, $message = '')
 {
     $message = stripslashes($message);
     $mainframe =& JFactory::getApplication();
     $bookmarks = CFactory::getBookmarks($uri);
     $mailqModel = CFactory::getModel('mailq');
     $config = CFactory::getConfig();
     $response = new JAXResponse();
     if (empty($emails)) {
         $content = '<div>' . JText::_('CC SHARE INVALID EMAIL') . '</div>';
         $buttons = '<input type="button" class="button" onclick="joms.bookmarks.show(\'' . $uri . '\');" value="' . JText::_('CC BUTTON GO BACK') . '"/>';
     } else {
         $emails = explode(',', $emails);
         $errors = array();
         // Add notification
         CFactory::load('libraries', 'notification');
         foreach ($emails as $email) {
             $email = JString::trim($email);
             if (!empty($email) && preg_match("/^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,4})\$/i", $email)) {
                 $params = new JParameter('');
                 $params->set('uri', $uri);
                 $params->set('message', $message);
                 CNotificationLibrary::add('system.bookmarks.email', '', $email, JText::sprintf('CC SHARE EMAIL SUBJECT', $config->get('sitename')), '', 'bookmarks', $params);
             } else {
                 // If there is errors with email, inform the user.
                 $errors[] = $email;
             }
         }
         if ($errors) {
             $content = '<div>' . JText::_('CC EMAILS ARE INVALID') . '</div>';
             foreach ($errors as $error) {
                 $content .= '<div style="font-weight:700;color: red;">' . $error . '</span>';
             }
             $buttons = '<input type="button" class="button" onclick="joms.bookmarks.show(\'' . $uri . '\');" value="' . JText::_('CC BUTTON GO BACK') . '"/>';
         } else {
             $content = '<div>' . JText::_('CC EMAIL SENT TO RECIPIENTS') . '</div>';
             $buttons = '<input type="button" class="button" onclick="cWindowHide();" value="' . JText::_('CC BUTTON DONE') . '"/>';
         }
     }
     $response->addAssign('cwin_logo', 'innerHTML', JText::_('CC SHARE THIS'));
     $response->addAssign('cWindowContent', 'innerHTML', $content);
     $response->addScriptCall('cWindowActions', $buttons);
     $response->addScriptCall('cWindowResize', 100);
     return $response->sendResponse();
 }
Exemple #9
0
 function ajaxTogglePublish($id, $type)
 {
     $user =& JFactory::getUser();
     // @rule: Disallow guests.
     if ($user->get('guest')) {
         JError::raiseError(403, JText::_('CC ACCESS FORBIDDEN'));
         return;
     }
     $response = new JAXResponse();
     // Load the JTable Object.
     $row =& JTable::getInstance('MultiProfile', 'CTable');
     $row->load($id);
     $row->publish($row->id, (int) (!$row->published));
     $row->load($id);
     $image = $row->published ? 'publish_x.png' : 'tick.png';
     $view =& $this->getView('multiprofile', 'html');
     $html = $view->getPublish($row, 'published', 'multiprofile,ajaxTogglePublish');
     $response->addAssign($type . $id, 'innerHTML', $html);
     return $response->sendResponse();
 }
Exemple #10
0
 function ajaxSendMessage($title, $message, $limit = 1)
 {
     $limitstart = $limit - 1;
     $model =& $this->getModel('users');
     $userId = $model->getSiteUsers($limitstart, 1);
     $response = new JAXResponse();
     $response->addScriptCall('joms.jQuery("#messaging-form").hide();');
     $response->addScriptCall('joms.jQuery("#messaging-result").show();');
     $user = CFactory::getUser($userId);
     $my =& JFactory::getUser();
     if (!empty($userId)) {
         require_once JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'notification.php';
         CNotificationLibrary::add('system.messaging', $my->id, $user->id, $title, $message);
         $response->addScriptCall('joms.jQuery("#no-progress").css("display","none");');
         $response->addScriptCall('joms.jQuery("#progress-status").append("<div>' . JText::sprintf('Sending message to <strong>%1$s</strong>', $user->getDisplayname()) . '<span style=\\"color: green;margin-left: 5px;\\">' . JText::_('CC SUCCESS') . '</span></div>");');
         $response->addScriptCall('sendMessage', $title, $message, $limit + 1);
     } else {
         $response->addScriptCall('joms.jQuery("#progress-status").append("<div style=\\"font-weight:700;\\">' . JText::_('CC UPDATE COMPLETED') . '</div>");');
     }
     return $response->sendResponse();
 }
Exemple #11
0
 function ajaxEditRelations($listing_id, $cat_id = '', $single_select = 0)
 {
     $objResponse = new JAXResponse();
     if (is_numeric($listing_id)) {
         JRequest::setVar('listing_id', $listing_id);
     }
     if ($cat_id) {
         JRequest::setVar('cat', $cat_id);
     }
     if ($single_select) {
         JRequest::setVar('ss', $single_select);
     }
     JRequest::setVar('view', 'edit');
     JFactory::getDocument()->setType('html');
     ob_start();
     $this->display();
     $html = ob_get_contents();
     ob_end_clean();
     $objResponse->addAssign('cWindowContent', 'innerHTML', $html);
     $objResponse->addScriptCall('cWindowResize', 395);
     $objResponse->addScriptCall('_initEditRelations', $listing_id, $cat_id, $single_select);
     return $objResponse->sendResponse();
 }
Exemple #12
0
    /**
     * AJAX method to display the form
     *
     * @param   int fieldId The fieldId that we are editing
     * @param   boolean isGroup Determines whether the current field is a group
     *
     * @return  JAXResponse object  Azrul's AJAX Response object
     **/
    public function ajaxEditField($fieldId, $isGroup = false)
    {
        $user = JFactory::getUser();
        //CFactory::load( 'helpers' , 'string' );
        if ($user->get('guest')) {
            JError::raiseError(403, JText::_('COM_COMMUNITY_ACCESS_FORBIDDEN'));
            return;
        }
        $response = new JAXResponse();
        $model = $this->getModel('profiles');
        $fieldGroups = $model->getGroups();
        // Load the JTable Object.
        $row = JTable::getInstance('profiles', 'CommunityTable');
        $row->load($fieldId);
        $windowTitle = $row->id == 0 ? JText::_('COM_COMMUNITY_NEW_FIELD') : JText::_('COM_COMMUNITY_PROFILE_EDIT_FIELD');
        $group = $model->getFieldGroup($row->ordering);
        ob_start();
        ?>
<div class="alert alert-info">
    <?php 
        echo JText::_('COM_COMMUNITY_NEW_CUSTOM_PROFILE_LABEL');
        ?>
</div>
<div id="error-notice" style="color:red"></div>
<div style="clear: both;"></div>
<form action="#" method="post" name="editField" id="editField">
<table cellspacing="0" border="0" width="100%">
    <tbody>
        <tr>
            <td class="key"><span class="js-tooltip" title="<?php 
        echo JText::_('COM_COMMUNITY_PROFILE_NAME_TIPS');
        ?>
 "><?php 
        echo JText::_('COM_COMMUNITY_NAME');
        ?>
</span> <span class="required-sign">*</span></td>
            <td>
                <input type="text" value="<?php 
        echo CStringHelper::escape($row->name);
        ?>
" name="name" />
            </td>
        </tr>
        <tr>
            <td class="key"><span class="js-tooltip" title="<?php 
        echo JText::_('COM_COMMUNITY_PROFILE_TYPE_TIPS');
        ?>
 "><?php 
        echo JText::_('COM_COMMUNITY_TYPE');
        ?>
</span></td>
            <td><?php 
        echo $this->_buildTypes($row->type);
        ?>
</td>
        </tr>
        <tr style="<?php 
        echo $row->type != 'group' ? 'display: table-row;' : 'display: none;';
        ?>
" class="fieldGroups">
            <td class="key"><span class="js-tooltip" title="<?php 
        echo JText::_('COM_COMMUNITY_PROFILE_GROUPS_TIPS');
        ?>
 "><?php 
        echo JText::_('COM_COMMUNITY_GROUPS');
        ?>
</span></td>
            <td colspan="4">
                <select name="group">
            <?php 
        for ($i = 0; $i < count($fieldGroups); $i++) {
            $selected = isset($group->id) && $group->id == $fieldGroups[$i]->id ? ' selected="selected"' : '';
            ?>
                <option value="<?php 
            echo $fieldGroups[$i]->ordering;
            ?>
"<?php 
            echo $selected;
            ?>
><?php 
            echo $fieldGroups[$i]->name;
            ?>
</option>
            <?php 
        }
        ?>
                </select>
            </td>
        </tr>
        <tr>
            <td class="key"><span class="js-tooltip" title="<?php 
        echo JText::_('COM_COMMUNITY_PROFILE_FIELD_TIPS');
        ?>
 "><?php 
        echo JText::_('COM_COMMUNITY_FIELD_CODE');
        ?>
 </span><span class="required-sign">*</span></td>
            <td><input type="text" value="<?php 
        echo CStringHelper::escape($row->fieldcode);
        ?>
" name="fieldcode" maxlength="255" /></td>
        </tr>

        <tr>
            <td valign="top" class="key"><span class="js-tooltip" title="<?php 
        echo JText::_('COM_COMMUNITY_PROFILE_REGISTRATION_TIPS');
        ?>
 "><?php 
        echo JText::_('COM_COMMUNITY_REGISTRATION');
        ?>
</span></td>
            <td colspan="4">
                <?php 
        echo $this->_buildRadio($row->registration, 'registration', array(JText::_('COM_COMMUNITY_NO_OPTION'), JText::_('COM_COMMUNITY_YES_OPTION')));
        ?>
                <?php 
        // echo CHTMLInput::checkbox('registration' ,'ace-switch ace-switch-5', null , $row->registration );
        ?>
            </td>
        </tr>
        <tr>
            <td class="key"><span class="js-tooltip" title="<?php 
        echo JText::_('COM_COMMUNITY_PROFILE_VISIBLE_TIPS');
        ?>
 "><?php 
        echo JText::_('COM_COMMUNITY_VISIBLE');
        ?>
</span></td>
            <td><?php 
        echo $this->_buildRadio($row->visible, 'visible', array(JText::_('COM_COMMUNITY_PROFILEFIELD_PERSONAL_OPTION'), JText::_('COM_COMMUNITY_PROFILEFIELD_ALL_OPTION'), JText::_('COM_COMMUNITY_PROFILEFIELD_ADMINONLY_OPTION')));
        ?>
</td>
        </tr>
        <tr>
            <td class="key"><span class="js-tooltip" title="<?php 
        echo JText::_('COM_COMMUNITY_PROFILE_PUBLISHED_TIPS');
        ?>
 "><?php 
        echo JText::_('COM_COMMUNITY_PUBLISHED');
        ?>
</span></td>
            <td>
                <span><?php 
        echo $this->_buildRadio($row->published, 'published', array(JText::_('COM_COMMUNITY_NO_OPTION'), JText::_('COM_COMMUNITY_YES_OPTION')));
        ?>
</span>
            </td>
        </tr>
        <tr>
            <td class="key" width="200" ><span class="js-tooltip" title="<?php 
        echo JText::_('COM_COMMUNITY_PROFILE_REQUIRED_TIPS');
        ?>
 "><?php 
        echo JText::_('COM_COMMUNITY_REQUIRED');
        ?>
</span></td>
            <td><?php 
        echo $this->_buildRadio($row->required, 'required', array(JText::_('COM_COMMUNITY_NO_OPTION'), JText::_('COM_COMMUNITY_YES_OPTION')));
        ?>
</td>
        </tr>

        <?php 
        echo $this->_buildOptions($row, $row->id, $row->type);
        ?>
    </tbody>
</table>
<!-- Start custom params -->
<div id="fieldParams" class="fieldParams">
        <?php 
        echo $this->_buildFieldParams($row->type, $row->params);
        ?>
</div>
<!-- End custom params -->
</form>
<?php 
        $contents = ob_get_contents();
        ob_end_clean();
        $buttons = '<input type="button" class="btn btn-small btn-primary pull-right" onclick="javascript:azcommunity.saveField(\'' . $row->id . '\');return false;" value="' . JText::_('COM_COMMUNITY_SAVE') . '"/>';
        $buttons .= '&nbsp;&nbsp;<input type="button" class="btn btn-small pull-left" onclick="javascript:cWindowHide();" value="' . JText::_('COM_COMMUNITY_CANCEL') . '"/>';
        $response->addAssign('cWindowContent', 'innerHTML', $contents);
        $response->addAssign('cwin_logo', 'innerHTML', $windowTitle);
        $response->addScriptCall('jQuery(".js-tooltip, .hasTooltip").tooltip({html: true,placement:\'right\'});');
        $response->addScriptCall('if (window.MooTools) (function($) { $$(".js-tooltip, .hasTooltip").each(function (e) {e.hide = null;});})(MooTools);');
        $response->addScriptCall('cWindowActions', $buttons);
        return $response->sendResponse();
    }
Exemple #13
0
 /**
  * AJAX method to add predefined activity
  **/
 public function ajaxAddPredefined($key, $message = '')
 {
     $objResponse = new JAXResponse();
     $my = CFactory::getUser();
     $filter = JFilterInput::getInstance();
     $key = $filter->clean($key, 'string');
     $message = $filter->clean($message, 'string');
     CFactory::load('libraries', 'activities');
     CFactory::load('helpers', 'owner');
     if (!COwnerHelper::isCommunityAdmin()) {
         return;
     }
     // Predefined system custom activity.
     $system = array('system.registered', 'system.populargroup', 'system.totalphotos', 'system.popularprofiles', 'system.popularphotos', 'system.popularvideos');
     $act = new stdClass();
     $act->actor = $my->id;
     $act->target = 0;
     $act->app = 'system';
     $act->access = PRIVACY_FORCE_PUBLIC;
     $params = new CParameter('');
     if (in_array($key, $system)) {
         switch ($key) {
             case 'system.registered':
                 CFactory::load('helpers', 'time');
                 $usersModel = CFactory::getModel('user');
                 $now = new JDate();
                 $date = CTimeHelper::getDate();
                 $title = JText::sprintf('COM_COMMUNITY_TOTAL_USERS_REGISTERED_THIS_MONTH_ACTIVITY_TITLE', $usersModel->getTotalRegisteredByMonth($now->toFormat('%Y-%m')), $date->_monthToString($now->toFormat('%m')));
                 $act->cmd = 'system.registered';
                 $act->title = $title;
                 $act->content = '';
                 break;
             case 'system.populargroup':
                 $groupsModel = CFactory::getModel('groups');
                 $activeGroup = $groupsModel->getMostActiveGroup();
                 $title = JText::sprintf('COM_COMMUNITY_MOST_POPULAR_GROUP_ACTIVITY_TITLE', $activeGroup->name);
                 $params->set('action', 'groups.join');
                 $params->set('group_url', CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $activeGroup->id));
                 $act->cmd = 'groups.popular';
                 $act->cid = $activeGroup->id;
                 $act->title = $title;
                 break;
             case 'system.totalphotos':
                 $photosModel = CFactory::getModel('photos');
                 $total = $photosModel->getTotalSitePhotos();
                 $params->set('photos_url', CRoute::_('index.php?option=com_community&view=photos'));
                 $act->cmd = 'photos.total';
                 $act->title = JText::sprintf('COM_COMMUNITY_TOTAL_PHOTOS_ACTIVITY_TITLE', $total);
                 break;
             case 'system.popularprofiles':
                 CFactory::load('libraries', 'tooltip');
                 $act->cmd = 'members.popular';
                 $act->title = JText::sprintf('COM_COMMUNITY_ACTIVITIES_TOP_PROFILES', 5);
                 $params->set('action', 'top_users');
                 $params->set('count', 5);
                 break;
             case 'system.popularphotos':
                 $act->cmd = 'photos.popular';
                 $act->title = JText::sprintf('COM_COMMUNITY_ACTIVITIES_TOP_PHOTOS', 5);
                 $params->set('action', 'top_photos');
                 $params->set('count', 5);
                 break;
             case 'system.popularvideos':
                 $act->cmd = 'videos.popular';
                 $act->title = JText::sprintf('COM_COMMUNITY_ACTIVITIES_TOP_VIDEOS', 5);
                 $params->set('action', 'top_videos');
                 $params->set('count', 5);
                 break;
         }
     } else {
         // For additional custom activities, we only take the content passed by them.
         if (!empty($message)) {
             CFactory::load('helpers', 'string');
             $message = CStringHelper::escape($message);
             $app = explode('.', $key);
             $app = isset($app[0]) ? $app[0] : 'system';
             $act->title = JText::_($message);
             $act->app = $app;
         }
     }
     $this->cacheClean(array(COMMUNITY_CACHE_TAG_ACTIVITIES));
     // Allow comments on all these
     $act->comment_id = CActivities::COMMENT_SELF;
     $act->comment_type = $key;
     // Allow like for all admin activities
     $act->like_id = CActivities::LIKE_SELF;
     $act->like_type = $key;
     // Add activity logging
     CActivityStream::add($act, $params->toString());
     $objResponse->addAssign('activity-stream-container', 'innerHTML', $this->_getActivityStream());
     $objResponse->addScriptCall("joms.jQuery('.jomTipsJax').addClass('jomTips');");
     $objResponse->addScriptCall('joms.tooltip.setup();');
     return $objResponse->sendResponse();
 }
Exemple #14
0
 public function ajaxAddApp($name, $position)
 {
     // Check permissions
     $my =& JFactory::getUser();
     if ($my->id == 0) {
         return $this->ajaxBlockUnregister();
     }
     $filter = JFilterInput::getInstance();
     $name = $filter->clean($name, 'string');
     $position = $filter->clean($position, 'string');
     // Add application
     $appModel = CFactory::getModel('apps');
     $appModel->addApp($my->id, $name, $position);
     // Activity stream
     $act = new stdClass();
     $act->cmd = 'application.add';
     $act->actor = $my->id;
     $act->target = 0;
     $act->title = JText::_('COM_COMMUNITY_ACTIVITIES_APPLICATIONS_ADDED');
     $act->content = '';
     $act->app = $name;
     $act->cid = $my->id;
     CFactory::load('libraries', 'activities');
     CActivityStream::add($act);
     // User points
     CFactory::load('libraries', 'userpoints');
     CUserPoints::assignPoint('application.add');
     // Get application
     $id = $appModel->getUserApplicationId($name, $my->id);
     $appInfo = $appModel->getAppInfo($name);
     $params = new CParameter($appModel->getPluginParams($id, null));
     $isCoreApp = $params->get('coreapp');
     $app->id = $id;
     $app->title = isset($appInfo->title) ? $appInfo->title : '';
     $app->description = isset($appInfo->description) ? $appInfo->description : '';
     $app->isCoreApp = $isCoreApp;
     $app->name = $name;
     if (JFile::exists(CPluginHelper::getPluginPath('community', $name) . DS . $name . DS . 'favicon.png')) {
         $app->favicon['16'] = rtrim(JURI::root(), '/') . CPluginHelper::getPluginURI('community', $name) . '/' . $name . '/favicon.png';
     } else {
         $app->favicon['16'] = rtrim(JURI::root(), '/') . '/components/com_community/assets/app_favicon.png';
     }
     $tmpl = new CTemplate();
     $tmpl->set('apps', array($app));
     $tmpl->set('itemType', 'edit');
     $html = $tmpl->fetch('application.item');
     $objResponse = new JAXResponse();
     $objResponse->addScriptCall('joms.apps.showSettingsWindow', $app->id, $app->name);
     $objResponse->addScriptCall('joms.editLayout.addAppToLayout', $position, $html);
     // $objResponse->addScriptCall('cWindowHide();');
     return $objResponse->sendResponse();
 }
Exemple #15
0
 /**
  * Set message as Read
  */
 public function ajaxMarkMessageAsUnread($msgId)
 {
     $filter = JFilterInput::getInstance();
     $msgId = $filter->clean($msgId, 'int');
     $objResponse = new JAXResponse();
     $my = CFactory::getUser();
     $view = $this->getView('inbox');
     $model = $this->getModel('inbox');
     if ($my->id == 0) {
         return $this->ajaxBlockUnregister();
     }
     $filter = array('parent' => $msgId, 'user_id' => $my->id);
     $model->markAsUnread($filter);
     $objResponse->addScriptCall('markAsUnread', $msgId);
     $objResponse->sendResponse();
 }
Exemple #16
0
 public function ajaxCheckDefaultAlbum()
 {
     if ($this->blockUnregister()) {
         return;
     }
     $my = CFactory::getUser();
     $model = CFactory::getModel('photos');
     $objResponse = new JAXResponse();
     $album = $model->getDefaultAlbum($my->id);
     if ($album) {
         $objResponse->addScriptCall("joms.status.Creator['photo'].setURL", $album->id);
     } else {
         //create album
         $album = JTable::getInstance('Album', 'CTable');
         $album->load();
         $now = new JDate();
         $handler = $this->_getHandler($album);
         $newAlbum = true;
         $album->creator = $my->id;
         $album->created = $now->toSql();
         $album->name = JText::sprintf('COM_COMMUNITY_DEFAULT_ALBUM_CAPTION', $my->getDisplayName());
         $album->type = $handler->getType();
         $album->default = '1';
         $albumPath = $handler->getAlbumPath($album->id);
         $albumPath = CString::str_ireplace(JPATH_ROOT . '/', '', $albumPath);
         $albumPath = CString::str_ireplace('\\', '/', $albumPath);
         $album->path = $albumPath;
         $album->store();
         $objResponse->addScriptCall("joms.status.Creator['photo'].setURL", $album->id);
     }
     return $objResponse->sendResponse();
 }
Exemple #17
0
 public function ajaxGetStreamTitle($streamId)
 {
     $objResponse = new JAXResponse();
     $table = JTable::getInstance('Activity', 'CTable');
     $table->load($streamId);
     $objResponse->addScriptCall('joms.stream.showTextarea', $table->title, $streamId);
     $objResponse->sendResponse();
 }
Exemple #18
0
    /**
     * AJAX method to display the form
     * 
     * @param	int	fieldId	The fieldId that we are editing
     * @param	boolean	isGroup	Determines whether the current field is a group
     * 
     * @return	JAXResponse object	Azrul's AJAX Response object
     **/
    function ajaxEditField($fieldId, $isGroup = false)
    {
        $user =& JFactory::getUser();
        CFactory::load('helpers', 'string');
        if ($user->get('guest')) {
            JError::raiseError(403, JText::_('CC ACCESS FORBIDDEN'));
            return;
        }
        $response = new JAXResponse();
        $model =& $this->getModel('profiles');
        $fieldGroups = $model->getGroups();
        // Load the JTable Object.
        $row =& JTable::getInstance('profiles', 'CommunityTable');
        $row->load($fieldId);
        $windowTitle = $row->id == 0 ? JText::_('CC NEW FIELD') : JText::_('CC EDIT FIELD');
        $group = $model->getFieldGroup($row->ordering);
        ob_start();
        ?>
<div style="background-color: #F9F9F9; border: 1px solid #D5D5D5; margin-bottom: 10px; padding: 5px;font-weight: bold;">
	<?php 
        echo JText::_('CC CREATE NEW CUSTOM PROFILE FOR YOUR SITE');
        ?>
</div>
<div id="error-notice" style="color: red; font-weight:700;"></div>
<div style="clear: both;"></div>
<form action="#" method="post" name="editField" id="editField">
<table cellspacing="0" class="paramlist admintable" border="0" width="100%">
	<tbody>
		<tr>
			<td class="key"><?php 
        echo JText::_('CC NAME');
        ?>
</td>
			<td>:</td>
			<td>
				<input type="text" value="<?php 
        echo CStringHelper::escape($row->name);
        ?>
" name="name" />
			</td>
			<td class="key"><?php 
        echo JText::_('CC PUBLISHED');
        ?>
</td>
			<td>:</td>
			<td>
				<span><?php 
        echo $this->_buildRadio($row->published, 'published', array('Yes', 'No'));
        ?>
</span>
			</td>
		</tr>
		<tr>
			<td class="key"><?php 
        echo JText::_('CC TYPE');
        ?>
</td>
			<td>:</td>
			<td><?php 
        echo $this->_buildTypes($row->type);
        ?>
</td>
			<td class="key"><?php 
        echo JText::_('CC REQUIRED');
        ?>
</td>
			<td>:</td>
			<td colspan="4"><?php 
        echo $this->_buildRadio($row->required, 'required', array('Yes', 'No'));
        ?>
</td>
		</tr>
		<tr style="<?php 
        echo $row->type != 'group' ? 'display: table-row;' : 'display: none;';
        ?>
" class="fieldGroups">
			<td class="key"><?php 
        echo JText::_('CC GROUP');
        ?>
</td>
			<td>:</td>
			<td colspan="4">
				<select name="group">
			<?php 
        for ($i = 0; $i < count($fieldGroups); $i++) {
            $selected = isset($group->id) && $group->id == $fieldGroups[$i]->id ? ' selected="selected"' : '';
            ?>
				<option value="<?php 
            echo $fieldGroups[$i]->ordering;
            ?>
"<?php 
            echo $selected;
            ?>
><?php 
            echo $fieldGroups[$i]->name;
            ?>
</option>
			<?php 
        }
        ?>
				</select>
			</td>
		</tr>		
		<tr>
			<td class="key"><?php 
        echo JText::_('CC FIELD CODE');
        ?>
</td>
			<td>:</td>
			<td><input type="text" value="<?php 
        echo CStringHelper::escape($row->fieldcode);
        ?>
" name="fieldcode" maxlength="255" /></td>
			<td class="key"><?php 
        echo JText::_('CC VISIBLE');
        ?>
</td>
			<td>:</td>
			<td><?php 
        echo $this->_buildRadio($row->visible, 'visible', array('Yes', 'No'));
        ?>
</td>
		</tr>
		
		<tr>
			<td valign="top" class="key"><?php 
        echo JText::_('CC REGISTRATION');
        ?>
</td>
			<td valign="top">:</td>
			<td colspan="4">
				<?php 
        echo $this->_buildRadio($row->registration, 'registration', array('Yes', 'No'));
        ?>
			</td>
		</tr>
		<?php 
        echo $this->_buildSize($row);
        ?>
		<tr>
			<td valign="top" class="key"><?php 
        echo JText::_('CC TOOLTIP');
        ?>
</td>
			<td valign="top">:</td>
			<td colspan="4">
				<textarea rows="3" cols="50" name="tips"><?php 
        echo $row->tips;
        ?>
</textarea>
			</td>
		</tr>
		<?php 
        echo $this->_buildOptions($row, $row->id, $row->type);
        ?>
	</tbody>
</table>
<!-- Start custom params -->
<div id="fieldParams" class="fieldParams">
		<?php 
        echo $this->_buildFieldParams($row->type, $row->params);
        ?>
</div>
<!-- End custom params -->
</form>
<?php 
        $contents = ob_get_contents();
        ob_end_clean();
        $buttons = '<input type="button" class="button" onclick="javascript:azcommunity.saveField(\'' . $row->id . '\');return false;" value="' . JText::_('CC SAVE') . '"/>';
        $buttons .= '&nbsp;&nbsp;<input type="button" class="button" onclick="javascript:cWindowHide();" value="' . JText::_('CC CANCEL') . '"/>';
        $response->addAssign('cWindowContent', 'innerHTML', $contents);
        $response->addAssign('cwin_logo', 'innerHTML', $windowTitle);
        $response->addScriptCall('cWindowActions', $buttons);
        return $response->sendResponse();
    }
Exemple #19
0
    public function ajaxEditCategory($id)
    {
        $response = new JAXResponse();
        $uri = JURI::base();
        $db = JFactory::getDBO();
        $data = '';
        $children = array();
        // Get the event categories
        $model = $this->getModel('groupcategories');
        $categories = $model->getCategories();
        //all the children cannot be the parent to this id
        if ($id) {
            $children = $model->getCategoryChilds($id, $categories);
        }
        $row = JTable::getInstance('groupcategories', 'CommunityTable');
        $row->load($id);
        // Escape the output
        //CFactory::load( 'helpers' , 'string' );
        $row->name = CStringHelper::escape($row->name);
        $row->description = CStringHelper::escape($row->description);
        ob_start();
        ?>

		<div class="alert notice">
			<?php 
        echo JText::_('COM_COMMUNITY_GROUPS_CATEGORY_DESC');
        ?>
		</div>

		<form action="#" method="post" name="editGroupCategory" id="editGroupCategory">
		<table cellspacing="0" class="admintable" border="0" width="100%">
			<tbody>
				<tr>
					<td class="key" width="150" ><span class="js-tooltip"  title="<?php 
        echo JText::_('COM_COMMUNITY_PARENT_TIPS');
        ?>
"><?php 
        echo JText::_('COM_COMMUNITY_PARENT');
        ?>
</span></td>
					<td>
					    <select name="parent">
						    <option value="<?php 
        echo COMMUNITY_NO_PARENT;
        ?>
"><?php 
        echo JText::_('COM_COMMUNITY_NO_PARENT');
        ?>
</option>
						    <?php 
        for ($i = 0; $i < count($categories); $i++) {
            if ($categories[$i]->id != $id && !in_array($categories[$i]->id, $children)) {
                $selected = $row->parent == $categories[$i]->id ? ' selected="selected"' : '';
                ?>
						    <option value="<?php 
                echo $categories[$i]->id;
                ?>
"<?php 
                echo $selected;
                ?>
><?php 
                echo $categories[$i]->name;
                ?>
</option>
						    <?php 
            }
        }
        ?>
					    </select>
					</td>
				</tr>
				<tr>
					<td class="key"><span class="js-tooltip"  title="<?php 
        echo JText::_('COM_COMMUNITY_NAME_CATEGORY_TIPS');
        ?>
"><?php 
        echo JText::_('COM_COMMUNITY_NAME');
        ?>
</span></td>
					<td><input type="text" name="name" size="35" value="<?php 
        echo $id ? $row->name : '';
        ?>
" /></td>
				</tr>
				<tr>
					<td class="key"><span class="js-tooltip"  title="<?php 
        echo JText::_('COM_COMMUNITY_DESC_CATEGORY_TIPS');
        ?>
"><?php 
        echo JText::_('COM_COMMUNITY_DESCRIPTION');
        ?>
</span></td>
					<td>
						<textarea name="description" rows="5" cols="30"><?php 
        echo $id ? $row->description : '';
        ?>
</textarea>
					</td>
				</tr>
			</tbody>

			<input type="hidden" name="id" value="<?php 
        echo $id ? $row->id : 0;
        ?>
" />
		</table>
		</form>

<?php 
        $contents = ob_get_contents();
        ob_end_clean();
        $buttons = '<input type="button" class="btn btn-small btn-primary pull-right" onclick="javascript:azcommunity.saveGroupCategory();return false;" value="' . JText::_('COM_COMMUNITY_SAVE') . '"/>';
        $buttons .= '<input type="button" class="btn btn-small pull-left" onclick="javascript:cWindowHide();" value="' . JText::_('COM_COMMUNITY_CANCEL') . '"/>';
        $this->cacheClean(array(COMMUNITY_CACHE_TAG_GROUPS_CAT));
        $response->addAssign('cWindowContent', 'innerHTML', $contents);
        $response->addScriptCall('cWindowActions', $buttons);
        return $response->sendResponse();
    }
Exemple #20
0
    public function ajaxSaveTemplateFile($templateName, $fileName, $fileData, $override)
    {
        $response = new JAXResponse();
        $filePath = COMMUNITY_BASE_PATH . '/templates/' . JString::strtolower($templateName) . '/' . JString::strtolower($fileName);
        if ($override) {
            $filePath = JPATH_ROOT . '/templates/' . JString::strtolower($templateName) . '/html/com_community/' . JString::strtolower($fileName);
        }
        jimport('joomla.filesystem.file');
        if (JFile::write($filePath, $fileData)) {
            $response->addScriptCall('joms.jQuery("#status").remove();');
            $response->addScriptCall('joms.jQuery("<div id=\'status\'></div>")
				.html("' . JText::sprintf('%1$s saved successfully.', $fileName) . '")
				.attr("class","alert alert-success")
				.css({"float": "left", "width": "97%"})
				.insertAfter("textarea");');
        } else {
            $response->addScriptCall('alert', JText::_('COM_COMMUNITY_TEMPLATES_FILE_SAVE_ERROR'));
        }
        return $response->sendResponse();
    }
Exemple #21
0
 /**
  * restrict user to block community admin
  */
 public function ajaxRestrictBlockAdmin()
 {
     $config = CFactory::getConfig();
     $response = new JAXResponse();
     $buttons = '<form name="jsform-profile-ajaxblockuser" method="post" action="" style="float:right;">';
     $buttons .= '<input type="button" class="button" onclick="cWindowHide();return false;" name="cancel" value="' . JText::_('CC BUTTON CLOSE') . '" />';
     $buttons .= '</form>';
     $response->addAssign('cWindowContent', 'innerHTML', JText::_('CC CANNOT BLOCK COMMUNITY ADMIN'));
     $response->addScriptCall('joms.jQuery("#cwin_logo").html("' . $config->get('sitename') . '");');
     $response->addScriptCall('cWindowActions', $buttons);
     $response->sendResponse();
 }
Exemple #22
0
 public function ajaxAssignAuthKey()
 {
     $objResponse = new JAXResponse();
     $authKey = "";
     $ipaddress = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
     $mySess =& JFactory::getSession();
     $token = $mySess->get('JS_REG_TOKEN', '');
     $model =& $this->getModel('register');
     $authKey = $model->getAuthKey($token, $ipaddress);
     $objResponse->addScriptCall("joms.registrations.assignAuthKey('jomsForm','authkey','" . $authKey . "');");
     $objResponse->addScriptCall("joms.jQuery('#authenticate').val('1');");
     $objResponse->addScriptCall("joms.jQuery('#btnSubmit').click();");
     return $objResponse->sendResponse();
 }
Exemple #23
0
 /**
  * 
  * @param type $coords
  */
 public function ajaxGetAddressFromCoords($coords)
 {
     $objResponse = new JAXResponse();
     $model = CFactory::getModel('activities');
     $user = CFactory::getUser();
     $locations = $model->getUserVisitedLocation($user->id);
     $address = array();
     /**
      * Get address from array of coors
      */
     $coords = array_filter($coords);
     foreach ($coords as $coord) {
         if (isset($coord[0]) && isset($coords[1])) {
             /* Get address from coords */
             $geoAddress = $this->_getAddressFromCoord($coord[0], $coord[1]);
             if ($geoAddress) {
                 /* Store array of address */
                 $address[] = array('lat' => $coord[0], 'lng' => $coord[1], 'name' => $geoAddress->formatted_address);
             }
         }
     }
     /**
      * Get address from database
      */
     if ($locations) {
         foreach ($locations as $location) {
             $address[] = array('lat' => $location->latitude, 'lng' => $location->longitude, 'name' => $location->location);
         }
     }
     /**
      * These address will use for auto complete
      */
     $address = array_filter($address);
     $objResponse->addScriptCall('joms.location.updateAddress', $address);
     /**
      * Do update init location
      * @todo We'll need find out which address is better for init
      */
     $objResponse->addScriptCall('joms.sharebox.location.initLocation', $address[0]['name'], $address[0]['lat'], $address[0]['lng']);
     /*  */
     $objResponse->sendResponse($locations);
 }
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
 /**
  * restrict blocked user to access owner details
  */
 public function ajaxBlockWarn()
 {
     $objResponse = new JAXResponse();
     $config = CFactory::getConfig();
     $html = JText::_('COM_COMMUNITY_YOU_HAD_BLOCKED_THIS_USER');
     $actions = '<form method="post" action="" style="float:right;">';
     $actions .= '<input type="button" class="button" onclick="cWindowHide();return false;" name="cancel" value="' . JText::_('COM_COMMUNITY_BUTTON_CLOSE_BUTTON') . '" />';
     $actions .= '</form>';
     $objResponse->addScriptCall('cWindowAddContent', $html, $actions);
     $objResponse->addScriptCall('joms.jQuery("#cwin_logo").html("' . $config->get('sitename') . '");');
     return $objResponse->sendResponse();
 }
    public function ajaxEditCategory($id)
    {
        $response = new JAXResponse();
        $uri = JURI::base();
        $db =& JFactory::getDBO();
        $data = '';
        // Get the event categories
        $model = $this->getModel('videoscategories');
        $categories = $model->getCategories();
        $row =& JTable::getInstance('VideosCategory', 'CTable');
        $row->load($id);
        // Escape the output
        CFactory::load('helpers', 'string');
        $row->name = CStringHelper::escape($row->name);
        $row->description = CStringHelper::escape($row->description);
        ob_start();
        ?>
		<div style="line-height: 32px; padding-bottom: 10px;">
			<img src="<?php 
        echo $uri;
        ?>
components/com_community/assets/icons/groups_add.gif" style="float: left;" />
			<?php 
        echo JText::_('COM_COMMUNITY_VIDEOS_CREATE_NEW_CATEGORIES');
        ?>
		</div>
		<div style="clear: both;"></div>
		
		<form action="#" method="post" name="editVideosCategory" id="editVideosCategory">
		<table cellspacing="0" class="admintable" border="0" width="100%">
			<tbody>
				<tr>
					<td class="key" width="10%"><?php 
        echo JText::_('COM_COMMUNITY_PARENT');
        ?>
</td>
					<td>:</td>
					<td>
					    <select name="parent">
						<option value="<?php 
        echo COMMUNITY_NO_PARENT;
        ?>
"><?php 
        echo JText::_('COM_COMMUNITY_NO_PARENT');
        ?>
</option>
						<?php 
        for ($i = 0; $i < count($categories); $i++) {
            // Do not show itself as potential parent
            if ($categories[$i]->id != $id) {
                $selected = $row->parent == $categories[$i]->id ? ' selected="selected"' : '';
                ?>
						    <option value="<?php 
                echo $categories[$i]->id;
                ?>
"<?php 
                echo $selected;
                ?>
><?php 
                echo $categories[$i]->name;
                ?>
</option>
						    <?php 
            }
        }
        ?>
					    </select>
					</td>
				</tr>
				<tr>
					<td class="key" width="10%"><?php 
        echo JText::_('COM_COMMUNITY_NAME');
        ?>
</td>
					<td>:</td>
					<td><input type="text" name="name" size="35" value="<?php 
        echo $id ? $row->name : '';
        ?>
" /></td>
				</tr>
				<tr>
					<td class="key" valign="top"><?php 
        echo JText::_('COM_COMMUNITY_DESCRIPTION');
        ?>
</td>
					<td valign="top">:</td>
					<td>
						<textarea name="description" rows="5" cols="30"><?php 
        echo $id ? $row->description : '';
        ?>
</textarea>
					</td>
				</tr>
			</tbody>
		
			<input type="hidden" name="id" value="<?php 
        echo $id ? $row->id : 0;
        ?>
" />
		</table>
		</form>

<?php 
        $contents = ob_get_contents();
        ob_end_clean();
        $buttons = '<input type="button" class="button" onclick="javascript:azcommunity.saveVideosCategory();return false;" value="' . JText::_('COM_COMMUNITY_SAVE') . '"/>';
        $buttons .= '&nbsp;&nbsp;<input type="button" class="button" onclick="javascript:cWindowHide();" value="' . JText::_('COM_COMMUNITY_CANCEL') . '"/>';
        $this->cacheClean(array(COMMUNITY_CACHE_TAG_VIDEOS_CAT));
        $response->addAssign('cWindowContent', 'innerHTML', $contents);
        $response->addScriptCall('cWindowActions', $buttons);
        return $response->sendResponse();
    }
Exemple #27
0
    public function ajaxEditGroup($groupId)
    {
        $response = new JAXResponse();
        $model = $this->getModel('groupcategories');
        $categories = $model->getCategories();
        $group =& JTable::getInstance('Group', 'CTable');
        $group->load($groupId);
        $requireApproval = $group->approvals ? ' checked="true"' : '';
        $noApproval = !$group->approvals ? '' : ' checked="true"';
        // Escape the output
        CFactory::load('helpers', 'string');
        $group->name = CStringHelper::escape($group->name);
        $group->description = CStringHelper::escape($group->description);
        ob_start();
        ?>
<form name="editgroup" action="" method="post" id="editgroup">
<div style="background-color: #F9F9F9; border: 1px solid #D5D5D5; margin-bottom: 10px; padding: 5px;font-weight: bold;">
	<?php 
        echo JText::_('COM_COMMUNITY_GROUPS_EDIT_GROUP');
        ?>
</div>
<table cellspacing="0" class="admintable" border="0" width="100%">
	<tbody>
		<tr>
			<td class="key" valign="top"><?php 
        echo JText::_('COM_COMMUNITY_AVATAR');
        ?>
</td>
			<td valign="top">:</td>
			<td>
				<img width="90" src="<?php 
        echo $group->getThumbAvatar();
        ?>
" style="border: 1px solid #eee;"/>
			</td>
		</tr>
		<tr>
			<td class="key"><?php 
        echo JText::_('COM_COMMUNITY_PUBLISH_STATUS');
        ?>
</td>
			<td>:</td>
			<td>
				<input type="radio" name="published" value="1" id="publish" <?php 
        echo $group->published == '1' ? 'checked="true"' : '';
        ?>
/>
				<label for="publish"><?php 
        echo JText::_('COM_COMMUNITY_PUBLISH');
        ?>
</label>
				<input type="radio" name="published" value="0" id="unpublish" <?php 
        echo $group->published == '0' ? 'checked="true"' : '';
        ?>
>
				<label for="unpublish"><?php 
        echo JText::_('COM_COMMUNITY_UNPUBLISH');
        ?>
</label>
			</td>
		</tr>
		<tr>
			<td class="key"><?php 
        echo JText::_('COM_COMMUNITY_GROUP_TYPE');
        ?>
</td>
			<td>:</td>
			<td>
				<input type="radio" name="approvals" value="1" id="approve" <?php 
        echo $group->approvals == '1' ? 'checked="true"' : '';
        ?>
/>
				<label for="approve"><?php 
        echo JText::_('COM_COMMUNITY_GROUP_PRIVATE');
        ?>
</label>
				<input type="radio" name="approvals" value="0" id="unapprove" <?php 
        echo $group->approvals == '0' ? 'checked="true"' : '';
        ?>
/>
				<label for="unapprove"><?php 
        echo JText::_('COM_COMMUNITY_PUBLIC');
        ?>
</label>
			</td>
		</tr>
		<tr>
			<td class="key"><?php 
        echo JText::_('COM_COMMUNITY_CATEGORY');
        ?>
</td>
			<td>:</td>
			<td>
				<select name="categoryid">
				<?php 
        for ($i = 0; $i < count($categories); $i++) {
            $selected = $group->categoryid == $categories[$i]->id ? ' selected="selected"' : '';
            ?>
						<option value="<?php 
            echo $categories[$i]->id;
            ?>
"<?php 
            echo $selected;
            ?>
><?php 
            echo $categories[$i]->name;
            ?>
</option>
				<?php 
        }
        ?>
				</select>
			</td>
		</tr>
		<tr>
			<td class="key"><?php 
        echo JText::_('COM_COMMUNITY_NAME');
        ?>
</td>
			<td>:</td>
			<td>
				<span>
					<input type="text" name="name" class="inputbox" value="<?php 
        echo $group->name;
        ?>
" style="width: 250px;" />
				</span>
			</td>
		</tr>
		<tr>
			<td class="key"><?php 
        echo JText::_('COM_COMMUNITY_DESCRIPTION');
        ?>
</td>
			<td>:</td>
			<td>
				<textarea name="description" style="width: 250px;" rows="5"><?php 
        echo $group->description;
        ?>
</textarea>
			</td>
		</tr>
	</tbody>
</table>
<input type="hidden" name="id" value="<?php 
        echo $group->id;
        ?>
" />
<input type="hidden" name="option" value="com_community" />
<input type="hidden" name="task" value="savegroup" />
<input type="hidden" name="view" value="groups" />
<?php 
        $contents = ob_get_contents();
        ob_end_clean();
        $response->addAssign('cWindowContent', 'innerHTML', $contents);
        $action = '<input type="button" class="button" onclick="azcommunity.saveGroup();" name="' . JText::_('COM_COMMUNITY_SAVE') . '" value="' . JText::_('COM_COMMUNITY_SAVE') . '" />';
        $action .= '&nbsp;<input type="button" class="button" onclick="cWindowHide();" name="' . JText::_('COM_COMMUNITY_CLOSE') . '" value="' . JText::_('COM_COMMUNITY_CLOSE') . '" />';
        $response->addScriptCall('cWindowActions', $action);
        return $response->sendResponse();
    }
Exemple #28
0
 public function ajaxAutoupdate($ordercode = '', $email = '')
 {
     //do save config first
     if (!empty($ordercode) && !empty($email)) {
         $config = JTable::getInstance('configuration', 'CommunityTable');
         $config->load('config');
         $config->name = 'config';
         $params = new JRegistry($config->params);
         $params->set('autoupdateordercode', $ordercode);
         $params->set('autoupdateemail', $email);
         $config->params = $params->toString();
         $saved = $config->store();
     }
     require_once JPATH_ROOT . '/administrator/components/com_community/libraries/autoupdate.php';
     //Check update
     $res = CAutoUpdate::getUpdate();
     @ob_end_clean();
     $objResponse = new JAXResponse();
     if (!$res) {
         $msg = implode("\n", CAutoUpdate::getError());
         $objResponse->addScriptCall('joms.jQuery(".autoupdate-loader").hide(); ');
         $objResponse->addScriptCall('joms.jQuery("#autoupdateordercode,#autoupdateemail,#autoupdatesubmit").removeAttr("disabled");');
         $objResponse->addScriptCall('joms.jQuery("#autoupdatesubmit").val("' . JText::_('COM_COMMUNITY_CONFIGURATION_CHECK_AUTOUPDATE') . '");');
         $objResponse->addScriptCall('alert("' . JText::sprintf('COM_COMMUNITY_CONFIGURATION_AUTOUPDATE_ERROR', $msg) . '");');
         return $objResponse->sendResponse();
     }
     $objResponse->addScriptCall('joms.jQuery(".autoupdate-loader").hide(); ');
     $objResponse->addScriptCall('joms.jQuery("#autoupdateordercode,#autoupdateemail,#autoupdatesubmit").removeAttr("disabled");');
     $objResponse->addScriptCall('joms.jQuery("#autoupdatesubmit").val("' . JText::_('COM_COMMUNITY_CONFIGURATION_CHECK_AUTOUPDATE') . '");');
     if ($res) {
         jimport('joomla.installer.installer');
         jimport('joomla.installer.helper');
         //$package = JInstallerHelper::unpack($res);
         //Adapted from JInstallerHelper::unpack
         // Path to the archive =========
         $archivename = $res;
         // Temporary folder to extract the archive into
         $tmpdir = uniqid('install_');
         // Clean the paths to use for archive extraction
         $extractdir = JPath::clean(dirname($res) . '/' . $tmpdir);
         $archivename = JPath::clean($archivename);
         // Do the unpacking of the archive
         $result = JArchive::extract($archivename, $extractdir);
         if ($result === false) {
             $objResponse->addScriptCall('joms.jQuery(".autoupdate-loader").hide();');
             $objResponse->addScriptCall('joms.jQuery(".do-download-update").remove();');
             $objResponse->addScriptCall('alert("JomSocial package cannot be unpacked.")');
             return $objResponse->sendResponse();
         }
         $appszip = false;
         $extractdirfiles = scandir($extractdir);
         //error_log(print_r($extractdirfiles, true));
         foreach ($extractdirfiles as $f) {
             if (strpos($f, 'com_community_') !== FALSE) {
                 //error_log('DIR: '.$extractdir.'/'.$f);
                 $package = JInstallerHelper::unpack($extractdir . '/' . $f);
             }
         }
         //shouldnt be empty here, something's wrong with the package
         if (empty($package)) {
             $objResponse->addScriptCall('joms.jQuery(".autoupdate-loader").hide();');
             $objResponse->addScriptCall('joms.jQuery(".do-download-update").remove();');
             $objResponse->addScriptCall('alert("' . JText::_('COM_COMMUNITY_CONFIGURATION_AUTOUPDATE_ERROR_NO_COMPONENT') . '")');
             return $objResponse->sendResponse();
         }
         //error_log( 'PACKAGE:'. print_r($package,true) );
         // Get an installer instance
         //
         //$installer = JInstaller::getInstance();
         //$installer->install($package['dir']);
         $objResponse->addScriptCall('joms.jQuery(".autoupdate-loader").hide();');
         $objResponse->addScriptCall('joms.jQuery(".do-download-update").remove();');
         $objResponse->addScriptCall('joms.jQuery("#autoupdate-progress").empty();');
         $objResponse->addScriptCall("joms.jQuery('#autoupdatesubmit').after(' <form onsubmit=\"return confirm(\\'" . JText::_('COM_COMMUNITY_CONFIGURATION_AUTOUPDATE_ASK_PROCEED') . "\\');\" class=\"do-download-update\" style=\"display:inline\" method=\"post\" action=\"" . JURI::base() . "index.php?option=com_installer&view=install\"><input type=\"hidden\" name=\"install_directory\" value=\\'" . $package['extractdir'] . "\\'><input type=\"hidden\" name=\"task\" value=\"install.install\"><input type=\"hidden\" name=\"installtype\" value=\"folder\"><input type=\"submit\" value=\"" . JText::_('COM_COMMUNITY_CONFIGURATION_AUTOUPDATE_INSTALL_BUTTON') . "\" />" . JHTML::_('form.token') . "</form>');");
     }
     return $objResponse->sendResponse();
 }
Exemple #29
0
    public function ajaxEditGroup($groupId)
    {
        $response = new JAXResponse();
        $model = $this->getModel('groupcategories');
        $categories = $model->getCategories();
        $group = JTable::getInstance('Group', 'CTable');
        $group->load($groupId);
        $requireApproval = $group->approvals ? ' checked="true"' : '';
        $noApproval = !$group->approvals ? '' : ' checked="true"';
        // Escape the output
        $group->name = CStringHelper::escape($group->name);
        $group->description = CStringHelper::escape($group->description);
        $params = $group->getParams();
        $config = CFactory::getConfig();
        ob_start();
        ?>
<form name="editgroup" action="" method="post" id="editgroup">
<div class="alert alert-info">
    <?php 
        echo JText::_('COM_COMMUNITY_GROUPS_EDIT_GROUP');
        ?>
</div>
<table cellspacing="0" class="admintable" border="0" width="100%">
    <tbody>
        <tr>
            <td class="key" width="100"><?php 
        echo JText::_('COM_COMMUNITY_GROUPS_TITLE');
        ?>
</td>
            <td>
                <input type="text" name="name" value="<?php 
        echo $group->name;
        ?>
" style="width: 200px;" />
            </td>
        </tr>
        <tr>
            <td class="key"><?php 
        echo JText::_('COM_COMMUNITY_AVATAR');
        ?>
</td>
            <td>
                <img width="90" src="<?php 
        echo $group->getThumbAvatar();
        ?>
" style="border: 1px solid #eee;"/>
            </td>
        </tr>
        <tr>
            <td class="key"><?php 
        echo JText::_('COM_COMMUNITY_PUBLISH_STATUS');
        ?>
</td>
            <td>
                <?php 
        echo CHTMLInput::checkbox('published', 'ace-switch ace-switch-5', null, $group->get('published'));
        ?>
            </td>
        </tr>
        <tr>
            <td class="key"><?php 
        echo JText::_('COM_COMMUNITY_GROUP_TYPE');
        ?>
</td>
            <td>
                <select style="visibility:visible;" name='approvals'>
                    <option value='0' <?php 
        echo $group->approvals == COMMUNITY_PUBLIC_GROUP ? ' selected="selected"' : '';
        ?>
 ><?php 
        echo JText::_('COM_COMMUNITY_PUBLIC');
        ?>
</option>
                    <option value='1' <?php 
        echo $group->approvals == COMMUNITY_PRIVATE_GROUP ? ' selected="selected"' : '';
        ?>
 ><?php 
        echo JText::_('COM_COMMUNITY_GROUP_PRIVATE');
        ?>
</option>
                </select>
            </td>
        </tr>
        <tr>
            <td class="key"><?php 
        echo JText::_('COM_COMMUNITY_CATEGORY');
        ?>
</td>
            <td>
                <select name="categoryid">
                <?php 
        for ($i = 0; $i < count($categories); $i++) {
            $selected = $group->categoryid == $categories[$i]->id ? ' selected="selected"' : '';
            ?>
                        <option value="<?php 
            echo $categories[$i]->id;
            ?>
"<?php 
            echo $selected;
            ?>
><?php 
            echo $categories[$i]->name;
            ?>
</option>
                <?php 
        }
        ?>
                </select>
            </td>
        </tr>
        <tr>
            <td class="key"><?php 
        echo JText::_('COM_COMMUNITY_DESCRIPTION');
        ?>
</td>
            <td>
                <textarea name="description" style="width: 250px;" rows="5"
                    data-wysiwyg="trumbowyg" data-btns="viewHTML,|,bold,italic,underline,|,unorderedList,orderedList"><?php 
        echo $group->description;
        ?>
</textarea>
            </td>
        </tr>
    <!--    <tr>
        <td class="key"><?php 
        echo JText::_('COM_COMMUNITY_GROUPS_DISCUSS_ORDER');
        ?>
</td>
        <td class="paramlist_value">
            <select style="visibility:visible;" name='discussordering'>
                <option value='0' <?php 
        echo $params->get('discussordering') == 0 ? ' selected="selected"' : '';
        ?>
 ><?php 
        echo JText::_('COM_COMMUNITY_GROUPS_DISCUSS_ORDER_LAST_REPLIED');
        ?>
</option>
                <option value='1' <?php 
        echo $params->get('discussordering') == 1 ? ' selected="selected"' : '';
        ?>
 ><?php 
        echo JText::_('COM_COMMUNITY_GROUPS_DISCUSS_ORDER_CREATION_DATE');
        ?>
</option>
            </select>
        </td>
    </tr>-->
    <tr>
        <td class="key"><?php 
        echo JText::_('COM_COMMUNITY_PHOTOS');
        ?>
</td>
        <td class="paramlist_value">
            <select style="visibility:visible;" name='photopermission'>
                <option value='-1' <?php 
        echo $params->get('photopermission') == GROUP_PHOTO_PERMISSION_DISABLE ? ' selected="selected"' : '';
        ?>
 ><?php 
        echo JText::_('COM_COMMUNITY_GROUPS_PHOTO_DISABLED');
        ?>
</option>
                <option value='1'  <?php 
        echo $params->get('photopermission') == GROUP_PHOTO_PERMISSION_ADMINS ? ' selected="selected"' : '';
        ?>
 ><?php 
        echo JText::_('COM_COMMUNITY_GROUPS_PHOTO_UPLOAD_ALOW_ADMIN');
        ?>
</option>
                <option value='2'  <?php 
        echo $params->get('photopermission') == GROUP_PHOTO_PERMISSION_ALL ? ' selected="selected"' : '';
        ?>
 ><?php 
        echo JText::_('COM_COMMUNITY_GROUPS_PHOTO_UPLOAD_ALLOW_MEMBER');
        ?>
</option>
            </select>
        </td>
    </tr>
    <tr>
        <td class="key"><?php 
        echo JText::_('COM_COMMUNITY_GROUPS_RECENT_PHOTO');
        ?>
</td>
        <td class="paramlist_value">
            <input type="text" name="grouprecentphotos" id="grouprecentphotos-admin" size="1" value="<?php 
        echo $params->get('grouprecentphotos', GROUP_PHOTO_RECENT_LIMIT);
        ?>
" />
        </td>
    </tr>
    <tr>
        <td class="key"><?php 
        echo JText::_('COM_COMMUNITY_VIDEOS');
        ?>
</td>
        <td class="paramlist_value">
            <div class="space-12"></div>
            <select style="visibility:visible;" name='videopermission'>
                <option value='-1' <?php 
        echo $params->get('videopermission') == GROUP_VIDEO_PERMISSION_DISABLE ? ' selected="selected"' : '';
        ?>
 ><?php 
        echo JText::_('COM_COMMUNITY_GROUPS_VIDEO_DISABLED');
        ?>
</option>
                <option value='1' <?php 
        echo $params->get('videopermission') == GROUP_VIDEO_PERMISSION_ADMINS ? ' selected="selected"' : '';
        ?>
 ><?php 
        echo JText::_('COM_COMMUNITY_GROUPS_VIDEO_UPLOAD_ALLOW_ADMIN');
        ?>
</option>
                <option value='2' <?php 
        echo $params->get('videopermission') == GROUP_VIDEO_PERMISSION_ALL ? ' selected="selected"' : '';
        ?>
 ><?php 
        echo JText::_('COM_COMMUNITY_GROUPS_VIDEO_UPLOAD_ALLOW_MEMBER');
        ?>
</option>
            </select>
            <div class="space-12"></div>
        </td>
    </tr>
    <tr>
        <td class="key">
            <label for="grouprecentvideos-admin" class="title"><?php 
        echo JText::_('COM_COMMUNITY_GROUPS_RECENT_VIDEO');
        ?>
</td>
        <td class="paramlist_value">
            <input type="text" name="grouprecentvideos" id="grouprecentvideos-admin" size="1" value="<?php 
        echo $params->get('grouprecentvideos', GROUP_VIDEO_RECENT_LIMIT);
        ?>
" />
        </td>
    </tr>
    <tr>
        <td class="key"><?php 
        echo JText::_('COM_COMMUNITY_EVENTS');
        ?>
</td>
        <td class="paramlist_value">
            <div class="space-12"></div>
            <select style="visibility:visible;" name='eventpermission'>
                <option value='-1' <?php 
        echo $params->get('eventpermission') == GROUP_EVENT_PERMISSION_DISABLE ? ' selected="selected"' : '';
        ?>
 ><?php 
        echo JText::_('COM_COMMUNITY_GROUP_EVENTS_DISABLE');
        ?>
</option>
                <option value='1' <?php 
        echo $params->get('eventpermission') == GROUP_EVENT_PERMISSION_ADMINS ? ' selected="selected"' : '';
        ?>
 ><?php 
        echo JText::_('COM_COMMUNITY_GROUP_EVENTS_ADMIN_CREATION');
        ?>
</option>
                <option value='2' <?php 
        echo $params->get('eventpermission') == GROUP_EVENT_PERMISSION_ALL ? ' selected="selected"' : '';
        ?>
 ><?php 
        echo JText::_('COM_COMMUNITY_GROUP_EVENTS_MEMBERS_CREATION');
        ?>
</option>
            </select>
            <div class="space-12"></div>
        </td>
    </tr>
    <tr>
        <td class="key">
            <label for="grouprecentevents-admin" class="title"><?php 
        echo JText::_('COM_COMMUNITY_GROUP_EVENTS');
        ?>
</td>
        <td class="paramlist_value">
            <input type="text" name="grouprecentevents" id="grouprecentevents-admin" size="1" value="<?php 
        echo $params->get('grouprecentevents', GROUP_EVENT_RECENT_LIMIT);
        ?>
" />
        </td>
    </tr>
    <?php 
        if ($config->get('groupdiscussfilesharing') && $config->get('creatediscussion')) {
            ?>
    <tr>
        <td class="key"><?php 
            echo JText::_('COM_COMMUNITY_DISCUSSION');
            ?>
</td>
        <td>
            <label>
                <input type="checkbox" name="groupdiscussionfilesharing" style="position:relative;opacity:1" value="1"
                    <?php 
            echo $params->get('groupdiscussionfilesharing') >= 1 ? 'checked' : '';
            ?>
                > <?php 
            echo JText::_('COM_COMMUNITY_GROUPS_DISCUSSION_ENABLE_FILE_SHARING');
            ?>
                <input type="hidden" name="discussordering" value="0" />
            </label>
        </td>
    </tr>
    <?php 
        }
        ?>
    <?php 
        if ($config->get('createannouncement')) {
            ?>
    <tr>
        <td class="key"><?php 
            echo JText::_('COM_COMMUNITY_ANNOUNCEMENT');
            ?>
</td>
        <td>
            <label>
                <input type="checkbox" name="groupannouncementfilesharing" style="position:relative;opacity:1" value="1"
                    <?php 
            echo $params->get('groupannouncementfilesharing') >= 1 ? 'checked' : '';
            ?>
                > <?php 
            echo JText::_('COM_COMMUNITY_GROUPS_ANNOUNCEMENT_ENABLE_FILE_SHARING');
            ?>
            </label>
        </td>
    </tr>
    <?php 
        }
        ?>
    <tr>
        <td class="key"><?php 
        echo JText::_('COM_COMMUNITY_GROUPS_NEW_MEMBER_NOTIFICATION');
        ?>
</td>
        <td class="paramlist_value">
            <div class="space-12"></div>
            <select style="visibility:visible;" name='newmembernotification'>
                <option value='1' <?php 
        echo $params->get('newmembernotification', '1') == true ? ' selected="selected"' : '';
        ?>
 ><?php 
        echo JText::_('COM_COMMUNITY_ENABLE');
        ?>
</option>
                <option value='0' <?php 
        echo $params->get('newmembernotification', '1') == false ? ' selected="selected"' : '';
        ?>
><?php 
        echo JText::_('COM_COMMUNITY_DISABLE');
        ?>
</option>
            </select>
            <div class="space-12"></div>
        </td>
    </tr>
    <tr>
        <td class="key"><?php 
        echo JText::_('COM_COMMUNITY_GROUPS_JOIN_REQUEST_NOTIFICATION');
        ?>
</td>
        <td class="paramlist_value">
            <div class="space-12"></div>
            <select style="visibility:visible;" name='joinrequestnotification'>
                <option value='1' <?php 
        echo $params->get('joinrequestnotification', '1') == true ? ' selected="selected"' : '';
        ?>
 ><?php 
        echo JText::_('COM_COMMUNITY_ENABLE');
        ?>
</option>
                <option value='0' <?php 
        echo $params->get('joinrequestnotification', '1') == false ? ' selected="selected"' : '';
        ?>
><?php 
        echo JText::_('COM_COMMUNITY_DISABLE');
        ?>
</option>
            </select>
            <div class="space-12"></div>
        </td>
    </tr>
    <tr>
        <td class="key"><?php 
        echo JText::_('COM_COMMUNITY_GROUPS_WALL_NOTIFICATION');
        ?>
</td>
        <td class="paramlist_value">
            <div class="space-12"></div>
            <select style="visibility:visible;" name='wallnotification'>
                <option value='1' <?php 
        echo $params->get('wallnotification', '1') == true ? ' selected="selected"' : '';
        ?>
 ><?php 
        echo JText::_('COM_COMMUNITY_ENABLE');
        ?>
</option>
                <option value='0' <?php 
        echo $params->get('wallnotification', '1') == false ? ' selected="selected"' : '';
        ?>
 ><?php 
        echo JText::_('COM_COMMUNITY_DISABLE');
        ?>
</option>
            </select>
            <div class="space-12"></div>
        </td>
    </tr>
    </tbody>
</table>
<input type="hidden" name="id" value="<?php 
        echo $group->id;
        ?>
" />
<input type="hidden" name="option" value="com_community" />
<input type="hidden" name="task" value="savegroup" />
<input type="hidden" name="view" value="groups" />
<?php 
        $contents = ob_get_contents();
        ob_end_clean();
        $response->addAssign('cWindowContent', 'innerHTML', $contents);
        $action = '<input type="button" class="btn btn-small btn-primary pull-right" onclick="azcommunity.saveGroup();" name="' . JText::_('COM_COMMUNITY_SAVE') . '" value="' . JText::_('COM_COMMUNITY_SAVE') . '" />';
        $action .= '&nbsp;<input type="button" class="btn btn-small pull-left" onclick="cWindowHide();" name="' . JText::_('COM_COMMUNITY_CLOSE') . '" value="' . JText::_('COM_COMMUNITY_CLOSE') . '" />';
        $response->addScriptCall('cWindowActions', $action);
        $response->addScriptCall('joms.util.wysiwyg.start');
        return $response->sendResponse();
    }
Exemple #30
0
    public function ajaxCheckVersion()
    {
        $response = new JAXResponse();
        $communityController = new CommunityController();
        $stableVersion = $communityController->_getCurrentVersionData();
        $localVersion = $communityController->_getLocalVersionNumber();
        $data = $this->_getCurrentVersionData();
        //this is only used to get the links for change log and update instructions
        ob_start();
        if ($stableVersion) {
            // Test versions
            if (version_compare($localVersion, $stableVersion->version, '<')) {
                ?>

                    <h5><?php 
                echo JText::_('COM_COMMUNITY_UPDATE_SUMMARY');
                ?>
</h5>
                    <div style="color: red"><?php 
                echo JText::_('COM_COMMUNITY_OLDER_VERSION_OF_JOM_SOCIAL');
                ?>
</div>
                    <div><?php 
                echo JText::sprintf('Version installed: <span style="font-weight:700; color: red">%1$s</span>', $this->_getLocalVersionString());
                ?>
</div>
                    <div><?php 
                echo JText::sprintf('Latest version available: <span style="font-weight:700;">%1$s</span>', $stableVersion->version);
                ?>
</div>
                    <div><?php 
                echo JText::sprintf('View full changelog at <a href="%1$s" target="_blank">%2$s</a>', $data->changelogURL, $data->changelogURL);
                ?>
</div>
                    <div><?php 
                echo JText::sprintf('View the upgrade instructions at <a href="%1$s" target="_blank">%2$s</a>', $data->instructionURL, $data->instructionURL);
                ?>
</div>
                <?php 
            } else {
                ?>
                    <div class="clearfix">
                        <h5><?php 
                echo JText::_('COM_COMMUNITY_UPDATE_SUMMARY');
                ?>
</h5>

                        <div><?php 
                echo JText::_('COM_COMMUNITY_LATEST_VERSION_OF_JOM_SOCIAL');
                ?>
</div>
                        <div><?php 
                echo JText::sprintf('Version installed: <span style="font-weight:700;">%1$s</span>', $this->_getLocalVersionString());
                ?>
</div>
                    </div>
                <?php 
            }
        } else {
            ?>
                <div
                    style="color: red"><?php 
            echo JText::_('Please enable "allow_url_fopen" to check version');
            ?>
</div>
            <?php 
        }
        $contents = ob_get_contents();
        ob_end_clean();
        $response->addAssign('cWindowContent', 'innerHTML', $contents);
        $action = '<input type="button" class="btn btn-small pull-right" onclick="cWindowHide();" name="' . JText::_('COM_COMMUNITY_CLOSE') . '" value="' . JText::_('COM_COMMUNITY_CLOSE') . '" />';
        $response->addScriptCall('cWindowActions', $action);
        return $response->sendResponse();
    }