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(); }
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 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(); }
/** * Ajax method to load a template file * * @param $templateName The template name * @param $fileName The file name **/ function ajaxLoadTemplateFile($templateName, $fileName, $override) { $response = new JAXResponse(); if ($fileName == 'none') { $response->addScriptCall('azcommunity.resetTemplateForm();'); } else { $filePath = COMMUNITY_BASE_PATH . DS . 'templates' . DS . JString::strtolower($templateName) . DS . JString::strtolower($fileName); if ($override) { $filePath = JPATH_ROOT . DS . 'templates' . DS . JString::strtolower($templateName) . DS . 'html' . DS . 'com_community' . DS . JString::strtolower($fileName); } jimport('joomla.filesystem.file'); $contents = JFile::read($filePath); $response->addAssign('data', 'value', $contents); $response->addAssign('fileName', 'value', $fileName); $response->addAssign('templateName', 'value', $templateName); $response->addAssign('filePath', 'innerHTML', $filePath); } 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(); }
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(); }
public function ajaxIphoneInbox() { $objResponse = new JAXResponse(); $document = JFactory::getDocument(); $viewType = $document->getType(); $view = $this->getView('inbox', '', $viewType); $html = ''; ob_start(); $this->display(); $content = ob_get_contents(); ob_end_clean(); $tmpl = new CTemplate(); $tmpl->set('toolbar_active', 'inbox'); $simpleToolbar = $tmpl->fetch('toolbar.simple'); $objResponse->addAssign('social-content', 'innerHTML', $simpleToolbar . $content); return $objResponse->sendResponse(); }
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(); }
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(); }
/** * 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(); }
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(); }
/** * 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(); }
function ajaxCheckVersion() { $response = new JAXResponse(); $data = $this->_getCurrentVersionData(); ob_start(); // Get the current build number $build = $this->_getLocalBuildNumber(); $version = $this->_getLocalVersionNumber(); // Test versions if ($version < $data->version || $version <= $data->version && $build < $data->build) { ?> <div> <fieldset> <legend><?php echo JText::_('CC UPDATE SUMMARY'); ?> <div style="color: red"><?php echo JText::_('CC YOU ARE CURRENTLY RUNNING ON AN OLDER VERSION OF JOM SOCIAL'); ?> </div> <div style="margin: 3px;"><?php echo JText::sprintf('Version installed: <span style="font-weight:700; color: red">%1$s</strong>', $this->_getLocalVersionString()); ?> </div> <div style="margin: 3px;"><?php echo JText::sprintf('Latest version available: <span style="font-weight:700;">%1$s</span>', $data->version . '.' . $data->build); ?> </div> </fieldset> <div style="margin: 10px 3px 3px 3px;"> <?php echo JText::sprintf('View full changelog at <a href="%1$s" target="_blank">%2$s</a>', $data->changelogURL, $data->changelogURL); ?> </div> <div style="margin: 3px;"> <?php echo JText::sprintf('View the upgrade instructions at <a href="%1$s" target="_blank">%2$s</a>', $data->instructionURL, $data->instructionURL); ?> </div> </div> <?php } else { ?> <div> <fieldset> <legend><?php echo JText::_('CC UPDATE SUMMARY'); ?> <div style="margin: 3px"><?php echo JText::_('CC YOU ARE CURRENTLY RUNNING THE LATEST VERSION OF JOM SOCIAL'); ?> </div> <div style="margin: 3px;"><?php echo JText::sprintf('Version installed: <span style="font-weight:700;">%1$s</strong>', $this->_getLocalVersionString()); ?> </div> </fieldset> </div> <?php $response->addScriptCall('cWindowResize', 160); } $contents = ob_get_contents(); ob_end_clean(); $response->addAssign('cWindowContent', 'innerHTML', $contents); $action = '<input type="button" class="button" onclick="cWindowHide();" name="' . JText::_('CC CLOSE') . '" value="' . JText::_('CC CLOSE') . '" />'; $response->addScriptCall('cWindowActions', $action); return $response->sendResponse(); }
public function ajaxBrowse($position = 'content') { $filter = JFilterInput::getInstance(); $position = $filter->clean($position, 'string'); // Get the proper views and models $view = CFactory::getView('apps'); $appsModel = CFactory::getModel('apps'); $my = CFactory::getUser(); $data = new stdClass(); // Check permissions if ($my->id == 0) { return $this->blockUnregister(); } // Get the application listing $apps = $appsModel->getAvailableApps(false); $realApps = array(); for ($i = 0; $i < count($apps); $i++) { $app =& $apps[$i]; // Hide wall apps if (!$appsModel->isAppUsed($my->id, $app->name) && $app->coreapp != '1' && $app->name != 'walls') { $app->position = $position; $realApps[] = $app; } } $data->applications = $realApps; $objResponse = new JAXResponse(); $html = $view->get('ajaxBrowse', $data); $objResponse->addAssign("cwin_logo", 'innerHTML', JText::_('COM_COMMUNITY_APPS_BROWSE')); $objResponse->addScriptCall('cWindowAddContent', $html); return $objResponse->sendResponse(); }
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(); }
public function ajaxShowSuccss($content = '') { $windowTitle = JText::_('COM_COMMUNITY_ZENCODER_REGISTRATION_FORM'); //$buttons = '<input type="button" class="button" onclick="javascript:cWindowHide();" value="' . JText::_('COM_COMMUNITY_ZENDCODER_OK_BUTTON') . '"/>'; $buttons = '<input type="button" class="button" onclick="javascript:window.location.reload();" value="' . JText::_('COM_COMMUNITY_ZENDCODER_OK_BUTTON') . '"/>'; $response = new JAXResponse(); $response->addAssign('cWindowContent', 'innerHTML', $content); $response->addAssign('cwin_logo', 'innerHTML', $windowTitle); $response->addScriptCall('cWindowActions', $buttons); return $response->sendResponse(); }
public function ajaxSubmitInvitation($callback, $cid, $values) { //CFactory::load( 'helpers' , 'validate' ); $filter = JFilterInput::getInstance(); $callback = $filter->clean($callback, 'string'); $cid = $filter->clean($cid, 'int'); $values = $filter->clean($values, 'array'); $objResponse = new JAXResponse(); $my = CFactory::getUser(); $methods = explode(',', $callback); $emails = array(); $recipients = array(); $users = ''; $message = $values['message']; $values['friends'] = isset($values['friends']) ? $values['friends'] : array(); if (!is_array($values['friends'])) { $values['friends'] = array($values['friends']); } // This is where we process external email addresses if (!empty($values['emails'])) { $emails = explode(',', $values['emails']); foreach ($emails as $email) { if (!CValidateHelper::email($email)) { $objResponse->addAssign('invitation-error', 'innerHTML', JText::sprintf('COM_COMMUNITY_INVITE_EMAIL_INVALID', $email)); return $objResponse->sendResponse(); } $recipients[] = $email; } } // This is where we process site members that are being invited if (!empty($values['friends'][0])) { $users = explode(',', $values['friends'][0]); foreach ($users as $id) { $recipients[] = $id; } } if (!empty($recipients)) { $arguments = array($cid, $recipients, $emails, $message); if (is_array($methods) && $methods[0] != 'plugins') { $controller = JString::strtolower(basename($methods[0])); $function = $methods[1]; require_once JPATH_ROOT . '/components/com_community/controllers/controller.php'; $file = JPATH_ROOT . '/components/com_community/controllers' . '/' . $controller . '.php'; if (JFile::exists($file)) { require_once $file; $controller = JString::ucfirst($controller); $controller = 'Community' . $controller . 'Controller'; $controller = new $controller(); if (method_exists($controller, $function)) { $inviteMail = call_user_func_array(array($controller, $function), $arguments); } else { $objResponse->addAssign('invitation-error', 'innerHTML', JText::_('COM_COMMUNITY_INVITE_EXTERNAL_METHOD_ERROR')); return $objResponse->sendResponse(); } } else { $objResponse->addAssign('invitation-error', 'innerHTML', JText::_('COM_COMMUNITY_INVITE_EXTERNAL_METHOD_ERROR')); return $objResponse->sendResponse(); } } else { if (is_array($methods) && $methods[0] == 'plugins') { // Load 3rd party applications $element = JString::strtolower(basename($methods[1])); $function = $methods[2]; $file = CPluginHelper::getPluginPath('community', $element) . '/' . $element . '.php'; if (JFile::exists($file)) { require_once $file; $className = 'plgCommunity' . JString::ucfirst($element); if (method_exists($controller, $function)) { $inviteMail = call_user_func_array(array($className, $function), $arguments); } else { $objResponse->addAssign('invitation-error', 'innerHTML', JText::_('COM_COMMUNITY_INVITE_EXTERNAL_METHOD_ERROR')); return $objResponse->sendResponse(); } } else { $objResponse->addAssign('invitation-error', 'innerHTML', JText::_('COM_COMMUNITY_INVITE_EXTERNAL_METHOD_ERROR')); return $objResponse->sendResponse(); } } } //CFactory::load( 'libraries' , 'invitation' ); // If the responsible method returns a false value, we should know that they want to stop the invitation process. if ($inviteMail instanceof CInvitationMail) { if ($inviteMail->hasError()) { $objResponse->addAssign('invitation-error', 'innerHTML', $inviteMail->getError()); return $objResponse->sendResponse(); } else { // Once stored, we need to store selected user so they wont be invited again $invitation = JTable::getInstance('Invitation', 'CTable'); $invitation->load($callback, $cid); if (!empty($values['friends'])) { if (!$invitation->id) { // If the record doesn't exists, we need add them into the $invitation->cid = $cid; $invitation->callback = $callback; } $invitation->users = empty($invitation->users) ? implode(',', $values['friends']) : $invitation->users . ',' . implode(',', $values['friends']); $invitation->store(); } // Add notification //CFactory::load( 'libraries' , 'notification' ); CNotificationLibrary::add($inviteMail->getCommand(), $my->id, $recipients, $inviteMail->getTitle(), $inviteMail->getContent(), '', $inviteMail->getParams()); } } else { $objResponse->addScriptCall(JText::_('COM_COMMUNITY_INVITE_INVALID_RETURN_TYPE')); return $objResponse->sendResponse(); } } else { $objResponse->addAssign('invitation-error', 'innerHTML', JText::_('COM_COMMUNITY_INVITE_NO_SELECTION')); return $objResponse->sendResponse(); } $actions = '<input type="button" class="btn" onclick="cWindowHide();" value="' . JText::_('COM_COMMUNITY_BUTTON_CLOSE_BUTTON') . '"/>'; $html = JText::_('COM_COMMUNITY_INVITE_SENT'); $objResponse->addAssign('cwin_logo', 'innerHTML', JText::_('COM_COMMUNITY_INVITE_FRIENDS')); $objResponse->addScriptCall('cWindowAddContent', $html, $actions); return $objResponse->sendResponse(); }
/** * Photo Upload Popup */ public function ajaxUploadPhoto($albumId = '', $groupId = '') { $my = CFactory::getUser(); $objPhoto = CFactory::getModel('photos'); $excludedAlbumType = array('profile.avatar', 'group.avatar', 'event.avatar', 'group.Cover', 'profile.Cover', 'event.Cover'); if (empty($groupId) || $groupId == 'undefined') { $dataAlbums = $objPhoto->getAlbums($my->id, false, false, 'date', $excludedAlbumType); } else { $dataAlbums = $objPhoto->getGroupAlbums($groupId, false, false, '', false, '', $excludedAlbumType); } $selectedAlbum = $albumId; $preMessage = ''; if (CLimitsLibrary::exceedDaily('photos', $my->id)) { $preMessage = JText::_('COM_COMMUNITY_PHOTOS_LIMIT_PERDAY_REACHED'); $disableUpload = true; } else { $preMessage = JText::_('COM_COMMUNITY_PHOTOS_DEFAULT_UPLOAD_NOTICE'); $disableUpload = false; } $config = CFactory::getConfig(); $maxFileSize = $config->get('maxuploadsize') . 'mb'; $objResponse = new JAXResponse(); $tmpl = new CTemplate(); $html = $tmpl->set('my', $my)->set('allAlbums', $dataAlbums)->set('preMessage', $preMessage)->set('disableUpload', $disableUpload)->set('selectedAlbum', $selectedAlbum)->set('groupId', $groupId)->set('maxFileSize', $maxFileSize)->fetch('photos/uploader'); $label = array('filename' => JText::_("COM_COMMUNITY_PHOTOS_MULTIUPLOAD_FILENAME"), 'size' => JText::_("COM_COMMUNITY_PHOTOS_MULTIUPLOAD_SIZE"), 'status' => JText::_("COM_COMMUNITY_PHOTOS_MULTIUPLOAD_STATUS"), 'filedrag' => JText::_("COM_COMMUNITY_PHOTOS_MULTIUPLOAD_DRAG_FILES"), 'addfiles' => JText::_("COM_COMMUNITY_PHOTOS_MULTIUPLOAD_ADD_FILES"), 'startupload' => JText::_("COM_COMMUNITY_PHOTOS_MULTIUPLOAD_START_UPLOAD"), 'invalidfiletype' => JText::_("COM_COMMUNITY_PHOTOS_INVALID_FILE_ERROR"), 'exceedfilesize' => JText::_("COM_COMMUNITY_VIDEOS_IMAGE_FILE_SIZE_EXCEEDED"), 'stopupload' => JText::_("COM_COMMUNITY_PHOTOS_MULTIUPLOAD_STOP_UPLOAD")); $label = json_encode($label); $objResponse->addAssign('cwin_logo', 'innerHTML', JText::_('COM_COMMUNITY_PHOTOS_UPLOAD_PHOTOS')); $objResponse->addScriptCall('joms.photos.multiUpload.updateLabel', $label); $objResponse->addScriptCall('cWindowAddContent', $html); // return $objResponse->sendResponse(); $json = array('title' => JText::_('COM_COMMUNITY_PHOTOS_UPLOAD_PHOTOS'), 'html' => $html); die(json_encode($json)); }
/** * Add an application for the user * * @param $name string Application name / element */ public function ajaxAdd($name) { // Check permissions $my = CFactory::getUser(); $filter = JFilterInput::getInstance(); $name = $filter->clean($name, 'string'); if ($my->id == 0) { return $this->ajaxBlockUnregister(); } $objResponse = new JAXResponse(); $appModel = CFactory::getModel('apps'); // Get List of added apps $apps = $appModel->getAvailableApps(); $addedApps = array(); for ($i = 0; $i < count($apps); $i++) { $app = $apps[$i]; if ($appModel->isAppUsed($my->id, $app->name)) { $addedApps[] = $app; } } $appModel->addApp($my->id, $name); $theApp = $appModel->getAppInfo($name); $appId = $appModel->getUserApplicationId($name, $my->id); $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 = 'app.install.' . $name; $act->cid = 0; $params = new JRegistry(''); $params->set('app', $name); CActivityStream::addActor($act, $params->toString()); //CFactory::load( 'libraries' , 'userpoints' ); CUserPoints::assignPoint('application.add'); // Change cWindow title $objResponse->addAssign('cwin_logo', 'innerHTML', JText::_('COM_COMMUNITY_ADD_APPLICATION_TITLE')); $formAction = CRoute::_('index.php?option=com_community&view=friends&task=deleteSent', false); $action = '<form name="cancelRequest" action="" method="POST">'; $action .= '<input type="button" class="input button" name="save" onclick="joms.apps.showSettingsWindow(\'' . $appId . '\',\'' . $name . '\');" value="' . JText::_('COM_COMMUNITY_VIDEOS_SETTINGS_BUTTON') . '" /> '; $action .= '<input type="button" class="input button" onclick="cWindowHide();return false;" name="cancel" value="' . JText::_('COM_COMMUNITY_BUTTON_CLOSE_BUTTON') . '" />'; $action .= '</form>'; $html = '<div class="ajax-notice-apps-added">' . JText::_('COM_COMMUNITY_APPS_AJAX_ADDED') . '</div>'; $objResponse->addScriptCall('cWindowAddContent', $html, $action); $objResponse->addScriptCall("joms.jQuery('." . $name . " .added-button').remove();"); $objResponse->addScriptCall("joms.jQuery('." . $name . "').append('<span class=\"added-ribbon\">" . JText::_('COM_COMMUNITY_APPS_LIST_ADDED') . "</span>');"); return $objResponse->sendResponse(); }
public function ajaxEditPhoto($id) { $response = new JAXResponse(); $photo = JTable::getInstance('Photos', 'CommunityTable'); $photo->load($id); //var_dump($photo);exit; ob_start(); ?> <form name="editphoto" action="" method="post" id="editphoto"> <table cellspacing="0" class="admintable" border="0" width="100%"> <tbody> <tr> <td class="key"><?php echo JText::_('COM_COMMUNITY_TITLE'); ?> </td> <td><input type="text" id="caption" name="caption" class="input text" value="<?php echo $photo->caption; ?> " style="width: 90%;" maxlength="255" /></tD> </tr> </tbody> </table> <input type="hidden" name="id" value="<?php echo $photo->id; ?> "/> <input type="hidden" name="option" value="com_community"/> <input type="hidden" name="task" value="savephotos"/> <input type="hidden" name="view" value="photos"/> </form> <?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.savePhoto();" name="' . JText::_('COM_COMMUNITY_SAVE') . '" value="' . JText::_('COM_COMMUNITY_SAVE') . '" />'; $action .= ' <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); return $response->sendResponse(); }
/** * AJAX method to toggle publish status * * @param int id Current field id * @param string field The field publish type * * @return JAXResponse object Azrul's AJAX Response object **/ public function ajaxTogglePublish($id, $field, $viewName) { $user = JFactory::getUser(); // @rule: Disallow guests. if ($user->get('guest')) { JError::raiseError(403, JText::_('COM_COMMUNITY_ACCESS_FORBIDDEN')); return; } $response = new JAXResponse(); // Load the JTable Object. $row = JTable::getInstance($viewName, 'CommunityTable'); $row->load($id); if ($row->{$field} == 1) { $row->{$field} = 0; $row->store(); $image = 'publish_x.png'; } else { $row->{$field} = 1; $row->store(); $image = 'tick.png'; } // Get the view $view = $this->getView($viewName, 'html'); $html = $view->getPublish($row, $field, $viewName . ',ajaxTogglePublish'); $response->addAssign($field . $id, 'innerHTML', $html); if ($viewName == 'videos' && $row->{$field} == 0) { $params = new CParameter(''); $params->set('url', ''); $params->set('target', $row->creator); CNotificationLibrary::add('system_messaging', NULL, $row->creator, JText::sprintf('COM_COMMUNITY_VIDEO_UNPUBLISHED', $row->title), '', '', $params); } return $response->sendResponse(); }
public function ajaxUploadNewPicture($userId) { $filter = JFilterInput::getInstance(); $userId = $filter->clean($userId, 'int'); $objResponse = new JAXResponse(); $my = CFactory::getUser(); //CFactory::load( 'helpers', 'owner' ); $this->cacheClean(array(COMMUNITY_CACHE_TAG_ACTIVITIES, COMMUNITY_CACHE_TAG_FRONTPAGE)); if (!isCommunityAdmin()) { return $this->ajaxBlockUnregister(); } $title = JText::_('COM_COMMUNITY_CHANGE_AVATAR'); $formAction = CRoute::_('index.php?option=com_community&view=profile&task=uploadAvatar', false); $config = CFactory::getConfig(); $uploadLimit = (double) $config->get('maxuploadsize'); $uploadLimit .= 'MB'; $content = '<form name="jsform-profile-ajaxuploadnewpicture" action="' . $formAction . '" id="uploadForm" method="post" enctype="multipart/form-data" class="reset-gap">'; $content .= '<input class="btn" type="file" id="file-upload" name="Filedata" />'; $content .= '<input type="hidden" name="action" value="doUpload" />'; $content .= '<input type="hidden" name="userid" value="' . $userId . '" />'; $content .= '</form>'; $actions = '<input type="button" class="btn" onclick="cWindowHide();return false;" value="' . JText::_('COM_COMMUNITY_CANCEL_BUTTON') . '" />'; $actions .= '<input type="button" value="' . JText::_('COM_COMMUNITY_BUTTON_UPLOAD_PICTURE') . '" class="btn btn-primary pull-right" onclick="joms.jQuery(\'#uploadForm\').submit();" />'; if ($uploadLimit != 0) { $content .= '<p class="info">' . JText::sprintf('COM_COMMUNITY_MAX_FILE_SIZE_FOR_UPLOAD', $uploadLimit) . '</p>'; } $objResponse->addAssign('cwin_logo', 'innerHTML', $title); $objResponse->addScriptCall('cWindowAddContent', $content, $actions); return $objResponse->sendResponse(); }
/** * 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 .= ' <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(); }
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 .= ' <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(); }
/** * Display confirm dialog to ignore user * @param int $userId * @return type */ public function ajaxConfirmIgnoreUser($userId) { $objResponse = new JAXResponse(); $header = JText::_('COM_COMMUNITY_TITLE_CONFIRM_IGNORE_USER'); $message = JText::_('COM_COMMUNITY_MESSAGE_CONFIRM_IGNORE_USER'); $actions = '<button class="btn" onclick="cWindowHide();">' . JText::_('COM_COMMUNITY_NO') . '</button>'; $actions .= '<button class="btn btn-primary pull-right" onclick="jax.call(\'community\', \'profile,ajaxIgnoreUser\', \'' . $userId . '\' );">' . JText::_('COM_COMMUNITY_YES') . '</button>'; $objResponse->addAssign('cwin_logo', 'innerHTML', $header); $objResponse->addScriptCall('cWindowAddContent', $message, $actions); return $objResponse->sendResponse(); }
public function ajaxGetActivities($filter, $user_id = 0, $view = '') { $objResponse = new JAXResponse(); $input_filter = JFilterInput::getInstance(); $filter = $input_filter->clean($filter, 'string'); $user_id = $input_filter->clean($user_id, 'int'); $view = $input_filter->clean($view, 'string'); $html = CActivities::getActivitiesByFilter($filter, $user_id); $html = '<div class="cActivity-LoadLatest joms-latest-activities-container"><a id="activity-update-click" class="btn btn-block" href="javascript:void(0);"></a></div>' . $html; $objResponse->addAssign('activity-stream-container', 'innerHTML', $html); $objResponse->addScriptCall("joms.filters.hideLoading();"); // Set main UL data attributes 'filter' $objResponse->addScriptCall("joms.jQuery('#activity-stream-container ul.cStreamList').data('filter', '" . $filter . "');"); return $objResponse->sendResponse(); }
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 .= ' <input type="button" class="button" onclick="cWindowHide();" name="' . JText::_('COM_COMMUNITY_CLOSE') . '" value="' . JText::_('COM_COMMUNITY_CLOSE') . '" />'; $response->addScriptCall('cWindowActions', $action); return $response->sendResponse(); }
/** * 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 .= ' <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(); }
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 .= ' <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(); }
public function ajaxShowTnc($fb = false) { $objResponse = new JAXResponse(); $config = CFactory::getConfig(); $html = $config->get('registrationTerms'); $objResponse->addAssign('cwin_logo', 'innerHTML', JText::_('COM_COMMUNITY_TERMS_AND_CONDITION')); $actions = ''; if ($fb == true) { $actions = '<input type="button" value="' . JText::_('COM_COMMUNITY_BACK_BUTTON') . '" class="button" onclick="joms.connect.update();return false;" />'; } $objResponse->addScriptCall('cWindowAddContent', $html, $actions); return $objResponse->sendResponse(); }