Ejemplo n.º 1
1
 /**
  * Replaces [fieldname] by the content of the user row (except for [password])
  *
  * @param  string         $msg
  * @param  boolean|array  $htmlspecialchars  on replaced values only: FALSE : no htmlspecialchars, TRUE: do htmlspecialchars, ARRAY: callback method
  * @param  boolean        $menuStats
  * @param  array          $extraStrings
  * @param  boolean|int    $translateLanguage  on $msg only
  * @return string
  */
 public function replaceUserVars($msg, $htmlspecialchars = true, $menuStats = true, $extraStrings = null, $translateLanguage = true)
 {
     if ($extraStrings === null) {
         $extraStrings = array();
     }
     if ($translateLanguage === true) {
         $msg = $htmlspecialchars ? CBTxt::Th($msg) : CBTxt::T($msg);
     }
     if (strpos($msg, '[') === false) {
         return $msg;
     }
     $msg = $this->_evaluateIfs($msg, $extraStrings);
     $msg = $this->_evaluateCbTags($msg);
     $msg = $this->_evaluateCbFields($msg, $htmlspecialchars);
     foreach ($extraStrings as $k => $v) {
         if (!is_object($v) && !is_array($v)) {
             if (is_array($htmlspecialchars)) {
                 $v = call_user_func_array($htmlspecialchars, array($v));
             }
             $msg = cbstr_ireplace("[" . $k . "]", $htmlspecialchars === true ? htmlspecialchars($v) : $v, $msg);
         }
     }
     if ($menuStats) {
         // find [menu .... : path1:path2:path3 /] and replace with HTML code if menu active, otherwise remove it all
         $msg = $this->_replacePragma($msg, 'menu', 'menuBar');
         // no more [status ] as they are standard fields !		$msg = $this->_replacePragma( $msg, $row, 'status', 'menuList' );
     }
     $msg = str_replace(array("&91;", "&93;"), array("[", "]"), $msg);
     return $msg;
 }
Ejemplo n.º 2
0
 /**
  * Outputs legacy mass mailer display
  *
  * @deprecated 2.0
  *
  * @param UserTable[]  $rows
  * @param string       $emailSubject
  * @param string       $emailBody
  * @param string       $emailAttach
  * @param string       $emailFromName
  * @param string       $emailFromAddr
  * @param string       $emailReplyName
  * @param string       $emailReplyAddr
  * @param int          $emailsPerBatch
  * @param int          $emailsBatch
  * @param int          $emailPause
  * @param bool         $simulationMode
  * @param array        $pluginRows
  */
 public function emailUsers($rows, $emailSubject, $emailBody, $emailAttach, $emailFromName, $emailFromAddr, $emailReplyName, $emailReplyAddr, $emailsPerBatch, $emailsBatch, $emailPause, $simulationMode, $pluginRows)
 {
     global $_CB_framework, $_CB_Backend_Title;
     _CBsecureAboveForm('showUsers');
     cbimport('cb.validator');
     outputCbTemplate(2);
     outputCbJs(2);
     $_CB_Backend_Title = array(0 => array('fa fa-envelope-o', CBTxt::T('Community Builder: Mass Mailer')));
     $editorSave = $_CB_framework->saveCmsEditorJS('emailbody');
     if ($editorSave) {
         $js = "\$( '.cbEmailUsersForm' ).submit( function() { " . $editorSave . "});";
     } else {
         $js = null;
     }
     cbValidator::outputValidatorJs($js);
     $emailsList = array();
     foreach (array_slice($rows, 0, 100) as $row) {
         $emailsList[] = htmlspecialchars($row->name) . ' <' . htmlspecialchars($row->email) . '>';
     }
     $return = '<form action="' . $_CB_framework->backendUrl('index.php') . '" method="post" name="adminForm" class="cb_form form-auto cbEmailUsersForm">' . '<div class="form-group cb_form_line clearfix">' . '<label class="control-label col-sm-3">' . CBTxt::Th('SEND_EMAIL_TO_TOTAL_USERS', 'Send Email to [total] users', array('[total]' => (int) count($rows))) . '</label>' . '<div class="cb_field col-sm-9">' . '<div>' . implode(', ', $emailsList) . (count($rows) > 100 ? ' <strong>' . CBTxt::Th('AND_COUNT_MORE_USERS', 'and [count] more users.', array('[count]' => (int) (count($rows) - 100))) . '</strong>' : null) . '</div>' . '</div>' . '</div>' . '<div class="form-group cb_form_line clearfix">' . '<label class="control-label col-sm-3">' . CBTxt::Th('MASS_MAILER_SIMULATION_MODE_LABEL', 'Simulation Mode') . '</label>' . '<div class="cb_field col-sm-9">' . '<div>' . '<input type="checkbox" name="simulationmode" id="simulationmode"' . ($simulationMode ? ' checked="checked"' : null) . ' /> <label for="simulationmode">' . CBTxt::T('Do not send emails, just show me how it works') . '</label>' . getFieldIcons(2, false, false, CBTxt::T('MASS_MAILER_SIMULATION_MODE_TOOLTIP', 'Check this box to simulate email sending in a dry run mode. No emails are actually sent.'), CBTxt::T('MASS_MAILER_SIMULATION_MODE_LABEL', 'Simulation Mode'), false, 4) . '</div>' . '</div>' . '</div>' . '<div class="form-group cb_form_line clearfix">' . '<label class="control-label col-sm-3">' . CBTxt::Th('MASS_MAILER_SUBJECT_LABEL', 'Email Subject') . '</label>' . '<div class="cb_field col-sm-9">' . '<div>' . '<input type="text" name="emailsubject" value="' . htmlspecialchars($emailSubject) . '" class="form-control required" size="60" />' . getFieldIcons(2, false, false, CBTxt::T('MASS_MAILER_SUBJECT_TOOLTIP', 'Type in the subject of the mass mailing (CB field substitutions are supported).'), CBTxt::T('MASS_MAILER_SUBJECT_LABEL', 'Email Subject'), false, 4) . '</div>' . '</div>' . '</div>' . '<div class="form-group cb_form_line clearfix">' . '<label class="control-label col-sm-3">' . CBTxt::Th('MASS_MAILER_MESSAGE_LABEL', 'Email Message') . '</label>' . '<div class="cb_field col-sm-9">' . '<div>' . $_CB_framework->displayCmsEditor('emailbody', $emailBody, 600, 200, 50, 7) . getFieldIcons(2, false, false, CBTxt::T('MASS_MAILER_MESSAGE_TOOLTIP', 'Type in the main message body of your mass mailing (HTML editor and CB field substitutions are supported).'), CBTxt::T('MASS_MAILER_MESSAGE_LABEL', 'Email Message'), false, 4) . '</div>' . '</div>' . '</div>' . '<div class="form-group cb_form_line clearfix">' . '<label class="control-label col-sm-3">' . CBTxt::Th('MASS_MAILER_ATTACHMENTS_LABEL', 'Email Attachments') . '</label>' . '<div class="cb_field col-sm-9">' . '<div>' . '<input type="text" name="emailattach" value="' . htmlspecialchars($emailAttach) . '" class="form-control" size="80" />' . getFieldIcons(2, false, false, CBTxt::T('MASS_MAILER_ATTACHMENTS_TOOLTIP', 'Absolute server path to file that should be attached to each email. Multiple files can be specified using a comma separator.'), CBTxt::T('MASS_MAILER_ATTACHMENTS_LABEL', 'Email Attachments'), false, 4) . '</div>' . '</div>' . '</div>' . '<div class="form-group cb_form_line clearfix">' . '<label class="control-label col-sm-3">' . CBTxt::Th('Substitutions for Subject, Message, and Attachments') . '</label>' . '<div class="cb_field col-sm-9">' . '<div>' . CBTxt::T('You can use all CB substitutions as in most parts: e.g.: [cb:if team="winners"] Congratulations [cb:userfield field="name" /], you are in the winning team! [/cb:if]') . '</div>' . '</div>' . '</div>' . $this->_pluginRows($pluginRows) . '<div class="form-group cb_form_line clearfix">' . '<label class="control-label col-sm-3">' . CBTxt::Th('MASS_MAILER_FROM_NAME_LABEL', 'From Name') . '</label>' . '<div class="cb_field col-sm-9">' . '<div>' . '<input type="text" name="emailfromname" value="' . htmlspecialchars($emailFromName) . '" class="form-control" size="30" />' . getFieldIcons(2, false, false, CBTxt::T('MASS_MAILER_FROM_NAME_TOOLTIP', 'The name to be used in the From field of email. If left empty the CB and Joomla configuration defaults will be used.'), CBTxt::T('MASS_MAILER_FROM_NAME_LABEL', 'From Name'), false, 4) . '</div>' . '</div>' . '</div>' . '<div class="form-group cb_form_line clearfix">' . '<label class="control-label col-sm-3">' . CBTxt::Th('MASS_MAILER_FROM_ADDRESS_LABEL', 'From Email Address') . '</label>' . '<div class="cb_field col-sm-9">' . '<div>' . '<input type="text" name="emailfromaddr" value="' . htmlspecialchars($emailFromAddr) . '" class="form-control" size="40" />' . getFieldIcons(2, false, false, CBTxt::T('MASS_MAILER_FROM_ADDRESS_TOOLTIP', 'The email address to be user in the From field of email. If left empty the CB and Joomla settings will be used.'), CBTxt::T('MASS_MAILER_FROM_ADDRESS_LABEL', 'From Email Address'), false, 4) . '</div>' . '</div>' . '</div>' . '<div class="form-group cb_form_line clearfix">' . '<label class="control-label col-sm-3">' . CBTxt::Th('MASS_MAILER_REPLY_TO_NAME_LABEL', 'Reply-To Name') . '</label>' . '<div class="cb_field col-sm-9">' . '<div>' . '<input type="text" name="emailreplyname" value="' . htmlspecialchars($emailReplyName) . '" class="form-control" size="30" />' . getFieldIcons(2, false, false, CBTxt::T('MASS_MAILER_REPLY_TO_NAME_TOOLTIP', 'The Reply-To Name value to be used in the From field of email. If left empty the CB and Joomla settings will be used.'), CBTxt::T('MASS_MAILER_REPLY_TO_NAME_LABEL', 'Reply-To Name'), false, 4) . '</div>' . '</div>' . '</div>' . '<div class="form-group cb_form_line clearfix">' . '<label class="control-label col-sm-3">' . CBTxt::Th('MASS_MAILER_REPLY_TO_ADDRESS_LABEL', 'Reply-To Email Address') . '</label>' . '<div class="cb_field col-sm-9">' . '<div>' . '<input type="text" name="emailreplyaddr" value="' . htmlspecialchars($emailReplyAddr) . '" class="form-control" size="40" />' . getFieldIcons(2, false, false, CBTxt::T('MASS_MAILER_REPLY_TO_ADDRESS_TOOLTIP', 'The Reply-To Email address to be used in the email.'), CBTxt::T('MASS_MAILER_REPLY_TO_ADDRESS_LABEL', 'Reply-To Email Address'), false, 4) . '</div>' . '</div>' . '</div>' . '<div class="form-group cb_form_line clearfix">' . '<label class="control-label col-sm-3">' . CBTxt::Th('MASS_MAILER_EMAILS_PER_BATCH_LABEL', 'Emails per batch') . '</label>' . '<div class="cb_field col-sm-9">' . '<div>' . '<input type="text" name="emailsperbatch" value="' . htmlspecialchars($emailsPerBatch) . '" class="form-control required digits" size="12" />' . getFieldIcons(2, false, false, CBTxt::T('MASS_MAILER_EMAILS_PER_BATCH_TOOLTIP', 'The number of emails to be sent in each batch (default 50).'), CBTxt::T('MASS_MAILER_EMAILS_PER_BATCH_LABEL', 'Emails per batch'), false, 4) . '</div>' . '</div>' . '</div>' . '<div class="form-group cb_form_line clearfix">' . '<label class="control-label col-sm-3">' . CBTxt::Th('MASS_MAILER_SECONDS_BETWEEN_BATCHES_LABEL', 'Seconds of pause between batches') . '</label>' . '<div class="cb_field col-sm-9">' . '<div>' . '<input type="text" name="emailpause" value="' . htmlspecialchars($emailPause) . '" class="form-control required digits" size="12" />' . getFieldIcons(2, false, false, CBTxt::T('MASS_MAILER_SECONDS_BETWEEN_BATCHES_TOOLTIP', 'The number of seconds to pause between batch sending (default is 30 sec).'), CBTxt::T('MASS_MAILER_SECONDS_BETWEEN_BATCHES_LABEL', 'Seconds of pause between batches'), false, 4) . '</div>' . '</div>' . '</div>' . '<input type="hidden" name="option" value="com_comprofiler" />' . '<input type="hidden" name="view" value="emailusers" />' . '<input type="hidden" name="boxchecked" value="0" />';
     foreach ($rows as $row) {
         $return .= '<input type="hidden" name="cid[]" value="' . (int) $row->id . '">';
     }
     $return .= cbGetSpoofInputTag('user') . '</form>';
     echo $return;
 }
Ejemplo n.º 3
0
 /**
  * @param  OrderedTable  $row
  * @param  string[]      $input
  * @param  UserTable     $user
  * @param  stdClass      $model
  * @param  PluginTable   $plugin
  */
 static function showBlogEdit($row, $input, $user, $model, $plugin)
 {
     global $_CB_framework, $_PLUGINS;
     cbValidator::loadValidation();
     $blogMode = $plugin->params->get('blog_mode', 1);
     $pageTitle = $row->get('id') ? CBTxt::T('Edit Blog') : CBTxt::T('Create Blog');
     $cbModerator = Application::User((int) $user->get('id'))->isGlobalModerator();
     $_CB_framework->setPageTitle($pageTitle);
     $_CB_framework->appendPathWay(htmlspecialchars(CBTxt::T('Blogs')), $_CB_framework->userProfileUrl($row->get('user', $user->get('id')), true, 'cbblogsTab'));
     $_CB_framework->appendPathWay(htmlspecialchars($pageTitle), $_CB_framework->pluginClassUrl($plugin->element, true, $row->get('id') ? array('action' => 'blogs', 'func' => 'edit', 'id' => (int) $row->get('id')) : array('action' => 'blogs', 'func' => 'new')));
     initToolTip();
     $return = '<div class="blogEdit">' . '<form action="' . $_CB_framework->pluginClassUrl($plugin->element, true, array('action' => 'blogs', 'func' => 'save', 'id' => (int) $row->get('id'))) . '" method="post" enctype="multipart/form-data" name="blogForm" id="blogForm" class="cb_form blogForm form-auto cbValidation">' . ($pageTitle ? '<div class="blogsTitle page-header"><h3>' . $pageTitle . '</h3></div>' : null);
     if ($cbModerator || !$plugin->params->get('blog_approval', 0)) {
         $return .= '<div class="cbft_select cbtt_select form-group cb_form_line clearfix">' . '<label for="published" class="col-sm-3 control-label">' . CBTxt::Th('Published') . '</label>' . '<div class="cb_field col-sm-9">' . $input['published'] . getFieldIcons(1, 0, null, CBTxt::T('Select publish status of the blog. Unpublished blogs will not be visible to the public.')) . '</div>' . '</div>';
     }
     if ($plugin->params->get('blog_category_config', 1) || $cbModerator) {
         $return .= '<div class="cbft_select cbtt_select form-group cb_form_line clearfix">' . '<label for="category" class="col-sm-3 control-label">' . CBTxt::Th('Category') . '</label>' . '<div class="cb_field col-sm-9">' . $input['category'] . getFieldIcons(1, 0, null, CBTxt::T('Select blog category. Select the category that best describes your blog.')) . '</div>' . '</div>';
     }
     if ($plugin->params->get('blog_access_config', 1) || $cbModerator) {
         $return .= '<div class="cbft_select cbtt_select form-group cb_form_line clearfix">' . '<label for="access" class="col-sm-3 control-label">' . CBTxt::Th('Access') . '</label>' . '<div class="cb_field col-sm-9">' . $input['access'] . getFieldIcons(1, 0, null, CBTxt::T('Select access to blog; all groups above that level will also have access to the blog.')) . '</div>' . '</div>';
     }
     $return .= '<div class="cbft_text cbtt_input form-group cb_form_line clearfix">' . '<label for="title" class="col-sm-3 control-label">' . CBTxt::Th('Title') . '</label>' . '<div class="cb_field col-sm-9">' . $input['title'] . getFieldIcons(1, 1, null, CBTxt::T('Input blog title. This is the title that will distinguish this blog from others. Suggested to input something unique and intuitive.')) . '</div>' . '</div>';
     if (in_array($blogMode, array(1, 2))) {
         $return .= '<div class="cbft_textarea cbtt_textarea form-group cb_form_line clearfix">' . '<label for="blog_intro" class="col-sm-3 control-label">' . ($blogMode == 1 ? CBTxt::T('Blog Intro') : CBTxt::T('Blog')) . '</label>' . '<div class="cb_field col-sm-9">' . $input['blog_intro'] . getFieldIcons(1, 0, null, CBTxt::T('Input HTML supported blog intro contents. Suggested to use minimal but well formatting for easy readability.')) . '</div>' . '</div>';
     }
     if (in_array($blogMode, array(1, 3))) {
         $return .= '<div class="cbft_textarea cbtt_textarea form-group cb_form_line clearfix">' . '<label for="blog_full" class="col-sm-3 control-label">' . ($blogMode == 1 ? CBTxt::T('Blog Full') : CBTxt::T('Blog')) . '</label>' . '<div class="cb_field col-sm-9">' . $input['blog_full'] . getFieldIcons(1, 0, null, CBTxt::T('Input HTML supported blog contents. Suggested to use minimal but well formatting for easy readability.')) . '</div>' . '</div>';
     }
     if ($cbModerator) {
         $return .= '<div class="cbft_text cbtt_input form-group cb_form_line clearfix">' . '<label for="user" class="col-sm-3 control-label">' . CBTxt::T('Owner') . '</label>' . '<div class="cb_field col-sm-9">' . $input['user'] . getFieldIcons(1, 1, null, CBTxt::T('Input owner of blog as single integer user_id.')) . '</div>' . '</div>';
     }
     if ($plugin->params->get('blog_captcha', 0) && !$cbModerator) {
         $_PLUGINS->loadPluginGroup('user');
         $captcha = $_PLUGINS->trigger('onGetCaptchaHtmlElements', array(false));
         if (!empty($captcha)) {
             $captcha = $captcha[0];
             $return .= '<div class="form-group cb_form_line clearfix">' . '<label class="col-sm-3 control-label">' . CBTxt::Th('Captcha') . '</label>' . '<div class="cb_field col-sm-9">' . (isset($captcha[0]) ? $captcha[0] : null) . '</div>' . '</div>' . '<div class="form-group cb_form_line clearfix">' . '<div class="cb_field col-sm-offset-3 col-sm-9">' . str_replace('inputbox', 'form-control', isset($captcha[1]) ? $captcha[1] : null) . getFieldIcons(1, 1, null) . '</div>' . '</div>';
         }
     }
     $return .= '<div class="form-group cb_form_line clearfix">' . '<div class="col-sm-offset-3 col-sm-9">' . '<input type="submit" value="' . htmlspecialchars($row->get('id') ? CBTxt::T('Update Blog') : CBTxt::T('Create Blog')) . '" class="blogsButton blogsButtonSubmit btn btn-primary"' . cbValidator::getSubmitBtnHtmlAttributes() . ' />&nbsp;' . ' <input type="button" value="' . htmlspecialchars(CBTxt::T('Cancel')) . '" class="blogsButton blogsButtonCancel btn btn-default" onclick="if ( confirm( \'' . addslashes(CBTxt::T('Are you sure you want to cancel? All unsaved data will be lost!')) . '\' ) ) { location.href = \'' . $_CB_framework->userProfileUrl($row->get('user', $user->get('id')), false, 'cbblogsTab') . '\'; }" />' . '</div>' . '</div>' . cbGetSpoofInputTag('plugin') . '</form>' . '</div>';
     echo $return;
 }
Ejemplo n.º 4
0
function finishInstallation($option)
{
    global $_CB_framework, $ueConfig, $task;
    // Try extending time, as unziping/ftping took already quite some... :
    @set_time_limit(240);
    _CBsecureAboveForm('finishInstallation');
    $tgzFile = $_CB_framework->getCfg('absolute_path') . '/administrator/components/com_comprofiler/pluginsfiles.tgz';
    $installerFile = $_CB_framework->getCfg('absolute_path') . '/administrator/components/com_comprofiler/';
    if (file_exists($installerFile . 'comprofiler.xml')) {
        $installerFile .= 'comprofiler.xml';
    } elseif (file_exists($installerFile . 'comprofilej.xml')) {
        $installerFile .= 'comprofilej.xml';
    } elseif (file_exists($installerFile . 'comprofileg.xml')) {
        $installerFile .= 'comprofileg.xml';
    }
    if (!file_exists($tgzFile)) {
        echo CBTxt::T('UE_NOT_AUTHORIZED', 'You are not authorized to view this page!');
        return;
    }
    $installer = new cbInstallerPlugin();
    $client = 2;
    // Check that the zlib is available
    if (!extension_loaded('zlib')) {
        cbInstaller::renderInstallMessage(CBTxt::T('The installer cannot continue before zlib is installed'), CBTxt::T('Installer - Error'), $installer->returnTo($option, $task, $client));
        return;
    }
    if (!$installer->upload($tgzFile, true, false)) {
        cbInstaller::renderInstallMessage(sprintf(CBTxt::T('Uncompressing %s failed.'), $tgzFile), CBTxt::T('Installer - Error'), $installer->returnTo($option, '', 2));
        return;
    }
    $adminFS = cbAdminFileSystem::getInstance();
    $installFrom = $installer->installDir();
    $filesList = cbReadDirectory($installFrom, '.', true);
    // check if core directories exist as are needed to install plugins:
    $baseDir = $_CB_framework->getCfg('absolute_path') . '/components/com_comprofiler';
    if (!$adminFS->is_dir($baseDir . '/plugin')) {
        if (!$adminFS->mkdir($baseDir . '/plugin')) {
            cbInstaller::renderInstallMessage(sprintf(CBTxt::T('Failed to create directory "%s"'), $baseDir . '/plugin'), CBTxt::T('Installer - Error'), $installer->returnTo($option, '', 2));
            return;
        }
        if (!$adminFS->copy($baseDir . '/index.html', $baseDir . '/plugin/index.html')) {
            cbInstaller::renderInstallMessage(sprintf(CBTxt::T('Failed to create index "%s"'), $baseDir . '/plugin/index.html'), CBTxt::T('Installer - Error'), $installer->returnTo($option, '', 2));
            return;
        }
    }
    if (!$adminFS->is_dir($baseDir . '/plugin/language')) {
        if (!$adminFS->mkdir($baseDir . '/plugin/language')) {
            cbInstaller::renderInstallMessage(sprintf(CBTxt::T('Failed to create directory "%s"'), $baseDir . '/plugin/language'), CBTxt::T('Installer - Error'), $installer->returnTo($option, '', 2));
            return;
        }
        if (!$adminFS->copy($baseDir . '/index.html', $baseDir . '/plugin/language/index.html')) {
            cbInstaller::renderInstallMessage(sprintf(CBTxt::T('Failed to create index "%s"'), $baseDir . '/plugin/language/index.html'), CBTxt::T('Installer - Error'), $installer->returnTo($option, '', 2));
            return;
        }
    }
    if (!$adminFS->is_dir($baseDir . '/plugin/templates')) {
        if (!$adminFS->mkdir($baseDir . '/plugin/templates')) {
            cbInstaller::renderInstallMessage(sprintf(CBTxt::T('Failed to create directory "%s"'), $baseDir . '/plugin/templates'), CBTxt::T('Installer - Error'), $installer->returnTo($option, '', 2));
            return;
        }
        if (!$adminFS->copy($baseDir . '/index.html', $baseDir . '/plugin/templates/index.html')) {
            cbInstaller::renderInstallMessage(sprintf(CBTxt::T('Failed to create index "%s"'), $baseDir . '/plugin/templates/index.html'), CBTxt::T('Installer - Error'), $installer->returnTo($option, '', 2));
            return;
        }
    }
    if (!$adminFS->is_dir($baseDir . '/plugin/user')) {
        if (!$adminFS->mkdir($baseDir . '/plugin/user')) {
            cbInstaller::renderInstallMessage(sprintf(CBTxt::T('Failed to create directory "%s"'), $baseDir . '/plugin/user'), CBTxt::T('Installer - Error'), $installer->returnTo($option, '', 2));
            return;
        }
        if (!$adminFS->copy($baseDir . '/index.html', $baseDir . '/plugin/user/index.html')) {
            cbInstaller::renderInstallMessage(sprintf(CBTxt::T('Failed to create index "%s"'), $baseDir . '/plugin/user/index.html'), CBTxt::T('Installer - Error'), $installer->returnTo($option, '', 2));
            return;
        }
    }
    // install core plugins:
    foreach ($filesList as $file) {
        if (preg_match('/^.+\\.xml$/i', $file)) {
            $plgPath = $installFrom . (substr($installFrom, -1, 1) == '/' ? '' : '/') . $file;
            $plgXml = new \CBLib\Xml\SimpleXMLElement(trim(file_get_contents($plgPath)));
            if ($plgXml->getName() == 'cbinstall') {
                $plgDir = dirname($plgPath) . '/';
                $plgInstaller = new cbInstallerPlugin();
                if (!$plgInstaller->install($plgDir)) {
                    cbInstaller::renderInstallMessage(sprintf(CBTxt::T('Installing plugin failed with error: %s : %s'), $plgInstaller->i_elementname ? $plgInstaller->i_elementname : $file, $plgInstaller->getError()), CBTxt::T('Installer - Error'), $installer->returnTo($option, '', 2));
                    return;
                }
            }
        }
    }
    $result = $adminFS->deldir(_cbPathName($installFrom . '/'));
    if ($result === false) {
        cbInstaller::renderInstallMessage(CBTxt::T('Deleting expanded tgz file directory failed with an error.'), CBTxt::T('Installer - Error'), $installer->returnTo($option, '', 2));
    }
    $tgzFileOS = _cbPathName($tgzFile, false);
    $result = $adminFS->unlink($tgzFileOS);
    if ($result === false) {
        cbInstaller::renderInstallMessage(sprintf(CBTxt::T('Deleting file %s failed with an error.'), $tgzFileOS), CBTxt::T('Installer - Error'), $installer->returnTo($option, '', 2));
    }
    // adapt published fields to global CB config (regarding name type)
    _cbAdaptNameFieldsPublished($ueConfig);
    $htmlToDisplay = $_CB_framework->getUserState('com_comprofiler_install');
    // clears the session buffer memory after installaion done:
    $_CB_framework->setUserState('com_comprofiler_install', '');
    $installerXml = new SimpleXMLElement(file_get_contents($installerFile));
    if (is_object($installerXml)) {
        $description = $installerXml->getElementByPath('description');
        if ($description !== false) {
            echo '<h2>' . $description->data() . '</h2>';
        }
    }
    echo $htmlToDisplay;
    echo '<div style="color:green;font-size:18px;font-weight:bold;margin-top:15px;margin-bottom:15px;">' . CBTxt::Th('Installation done.') . '</div>' . '<div style="color:green;font-size:18px;font-weight:bold;margin-top:15px;margin-bottom:15px;">' . CBTxt::Th('Now is a great time to checkout the <a href="[help_url]" target="_blank">Getting Started</a> resources.', null, array('[help_url]' => 'http://www.joomlapolis.com/documentation/community-builder/getting-started?pk_campaign=in-cb&amp;pk_kwd=installedwelcomescreen')) . '</div>' . '<div style="margin-bottom:10px;">' . '<div style="font-size:12px;"><a href="http://www.joomlapolis.com/cb-solutions?pk_campaign=in-cb&amp;pk_kwd=installedwelcomescreen" target="_blank">' . CBTxt::Th('Click here to see more CB Plugins (Languages, Fields, Tabs, Signup-Connect, Paid Memberships and over 30 more) by CB Team at joomlapolis.com') . '</a></div>' . '<div style="font-size:12px;"><a href="http://extensions.joomla.org/extensions/clients-a-communities/communities/210" target="_blank">' . CBTxt::Th('Click here to see our CB listing on the Joomla! Extensions Directory (JED) and find third-party add-ons for your website.') . '</a></div>' . '<div style="font-size:12px;margin:10px 0 25px;">or &nbsp; <a href="index.php?option=com_comprofiler&view=showconfig" class="btn btn-primary">' . CBTxt::Th('Start to Configure Community Builder') . '</a></div>' . '</div>';
    $_CB_framework->setUserState("com_comprofiler_install", '');
}
Ejemplo n.º 5
0
 /**
  * @deprecated 2.0 We need to add that Config allowModeratorsUserEdit as param when we remove its use.
  *             Current uses are only: cbCheckIfUserCanPerformUserTask( $user->id, 'allowModeratorsUserEdit' )
  *
  * @param  int     $user_id
  * @param  string  $action
  * @return boolean|null|string
  */
 public function get_user_permission_task($user_id, $action)
 {
     global $_CB_framework, $_PLUGINS, $ueConfig;
     if ($user_id == 0) {
         $user_id = $_CB_framework->myId();
     } else {
         $user_id = (int) $user_id;
     }
     if ($user_id == 0) {
         $ret = false;
     } elseif ($user_id == $_CB_framework->myId()) {
         $ret = null;
     } else {
         if (!isset($ueConfig[$action]) || $ueConfig[$action] == 0) {
             $ret = CBTxt::Th('UE_FUNCTIONALITY_DISABLED', 'This functionality is currently disabled.');
         } elseif ($ueConfig[$action] == 1) {
             $isModerator = Application::MyUser()->isGlobalModerator();
             if (!$isModerator) {
                 $ret = false;
             } else {
                 $isModerator_user = Application::User((int) $user_id)->isGlobalModerator();
                 if ($isModerator_user) {
                     /** @noinspection PhpDeprecationInspection */
                     $ret = $this->get_users_permission(array($user_id), 'edit', true);
                 } else {
                     $ret = null;
                 }
             }
         } elseif ($ueConfig[$action] > 1) {
             // 8: super admins only
             // 7: admins and super admins only
             if (Application::MyUser()->isSuperAdmin()) {
                 $ret = null;
             } elseif ($ueConfig[$action] != 7) {
                 $ret = false;
             } else {
                 // Admins and Super-admins:
                 if (Application::MyUser()->isAuthorizedToPerformActionOnAsset('core.manage', 'com_users') && Application::MyUser()->isAuthorizedToPerformActionOnAsset('core.edit', 'com_users')) {
                     $ret = null;
                 } else {
                     $ret = false;
                 }
             }
         } else {
             $ret = false;
         }
     }
     if ($ret === false) {
         $ret = CBTxt::Th('UE_NOT_AUTHORIZED', 'You are not authorized to view this page!');
         if ($_CB_framework->myId() < 1) {
             $ret .= '<br />' . CBTxt::Th('UE_DO_LOGIN', 'You need to log in.');
         }
     }
     if ($_PLUGINS) {
         $_PLUGINS->trigger('onUserPermissionTask', array($user_id, $action, &$ret));
     }
     return $ret;
 }
Ejemplo n.º 6
0
	/**
	 * Displays backend menu items
	 *
	 * @param array $menu
	 * @param bool  $disabled
	 */
	public function adminMenu( &$menu, $disabled )
	{
		global $_CB_framework, $_PLUGINS;

		$gjMenu					=	array();

		$gjMenu['component']	=	array(	'title' => CBTxt::T( 'GroupJive' ) );
		$gjMenu['menu']			=	array(	array(	'title' => CBTxt::T( 'Categories' ), 'link' => $_CB_framework->backendViewUrl( 'editPlugin', true, array( 'action' => 'showgjcategories', 'cid' => $this->getPluginId() ) ), 'icon' => 'cbgj-categories',
													'submenu' => array( array( 'title' => CBTxt::Th( 'Add New Category' ), 'link' => $_CB_framework->backendViewUrl( 'editPlugin', true, array( 'cid' => $this->getPluginId(), 'table' => 'gjcategoriesbrowser', 'action' => 'editrow' ) ), 'icon' => 'cb-new' ) )
											),
											array(	'title' => CBTxt::T( 'Groups' ), 'link' => $_CB_framework->backendViewUrl( 'editPlugin', true, array( 'action' => 'showgjgroups', 'cid' => $this->getPluginId() ) ), 'icon' => 'cbgj-groups',
													'submenu' => array( array( 'title' => CBTxt::Th( 'Add New Group' ), 'link' => $_CB_framework->backendViewUrl( 'editPlugin', true, array( 'cid' => $this->getPluginId(), 'table' => 'gjgroupsbrowser', 'action' => 'editrow' ) ), 'icon' => 'cb-new' ) )
											),
											array(	'title' => CBTxt::T( 'GROUP_USERS', 'Users' ), 'link' => $_CB_framework->backendViewUrl( 'editPlugin', true, array( 'action' => 'showgjusers', 'cid' => $this->getPluginId() ) ), 'icon' => 'cbgj-users',
													'submenu' => array( array( 'title' => CBTxt::Th( 'Add New User to Group' ), 'link' => $_CB_framework->backendViewUrl( 'editPlugin', true, array( 'cid' => $this->getPluginId(), 'table' => 'gjusersbrowser', 'action' => 'editrow' ) ), 'icon' => 'cb-new' ) )
											),
											array(	'title' => CBTxt::T( 'Invites' ), 'link' => $_CB_framework->backendViewUrl( 'editPlugin', true, array( 'action' => 'showgjinvites', 'cid' => $this->getPluginId() ) ), 'icon' => 'cbgj-invites',
													'submenu' => array( array( 'title' => CBTxt::Th( 'Invite New User to Group' ), 'link' => $_CB_framework->backendViewUrl( 'editPlugin', true, array( 'cid' => $this->getPluginId(), 'table' => 'gjinvitesbrowser', 'action' => 'editrow' ) ), 'icon' => 'cb-new' ) )
											)
										);

		$_PLUGINS->trigger( 'gj_onAdminMenu', array( &$gjMenu['menu'] ) );

		$gjMenu['menu'][]		=	array(	'title' => CBTxt::T( 'Notifications' ), 'link' => $_CB_framework->backendViewUrl( 'editPlugin', true, array( 'action' => 'showgjnotifications', 'cid' => $this->getPluginId() ) ), 'icon' => 'cbgj-invites' );
		$gjMenu['menu'][]		=	array(	'title' => CBTxt::T( 'Configuration' ), 'link' => $_CB_framework->backendViewUrl( 'editrow', true, array( 'table' => 'pluginsbrowser', 'action' => 'editrow', 'cid' => $this->getPluginId() ) ), 'icon' => 'cbgj-config' );

		$menu['gj']				=	$gjMenu;
	}
Ejemplo n.º 7
0
 /**
  * Renders by ECHO the list view body
  *
  * @return void
  */
 protected function _renderBody()
 {
     global $ueConfig;
     $formatting = isset($ueConfig['use_divs']) && !$ueConfig['use_divs'] ? 'table' : 'divs';
     $layout = $formatting == 'divs' && $this->layout == 'grid' ? 'grid' : 'list';
     $gridStyle = null;
     $columnCount = count($this->columns);
     $hasCanvas = false;
     if ($columnCount && isset($this->columns[0]->fields)) {
         foreach ($this->columns[0]->fields as $field) {
             if (isset($field['fieldid']) && (int) $field['fieldid'] == 17) {
                 $hasCanvas = true;
             }
         }
     }
     if ((int) $this->gridHeight) {
         $gridStyle .= 'height:' . (int) $this->gridHeight . 'px;';
     }
     if ((int) $this->gridWidth) {
         $gridStyle .= 'width:' . (int) $this->gridWidth . 'px;';
     }
     if ($formatting == 'divs') {
         $return = '<div id="cbUserTable" class="cbUserListDiv ' . ($layout == 'grid' ? 'cbUserListLayoutGrid' : 'cbUserListLayoutList') . ' cbUserListT_' . $this->listId . ($hasCanvas ? ' cbUserListCanvas' : null) . '">';
     } else {
         $return = '<table id="cbUserTable" class="table table-hover cbUserListTable cbUserListLayoutList cbUserListT_' . $this->listId . ($hasCanvas ? ' cbUserListCanvas' : null) . '">' . '<thead>';
     }
     if ($columnCount && $layout != 'grid') {
         if ($formatting == 'divs') {
             $return .= '<div class="cbColumns clearfix cbUserListHeader">';
         } else {
             $return .= '<tr class="sectiontableheader cbUserListHeader">';
         }
         foreach ($this->columns as $index => $column) {
             if ($formatting == 'divs') {
                 $return .= '<div class="cbColumn' . $column->size . ' col-sm-' . $column->size . ' cbUserListHeaderCol' . ($index + 1) . ($column->cssclass ? ' ' . $column->cssclass : null) . '">' . $column->titleRendered . '</div>';
             } else {
                 $return .= '<th class="cbUserListHeaderCol' . ($index + 1) . ($column->cssclass ? ' ' . $column->cssclass : null) . '">' . $column->titleRendered . '</th>';
             }
         }
         if ($formatting == 'divs') {
             $return .= '</div>';
         } else {
             $return .= '</tr>';
         }
     }
     $return .= '</thead>' . '<tbody>';
     $i = 0;
     if (is_array($this->users) && count($this->users) > 0) {
         foreach ($this->users as $userIndex => $user) {
             if ($this->allowProfileLink) {
                 $style = 'cursor: hand; cursor: pointer;';
             } else {
                 $style = null;
             }
             if ($this->allowProfileLink) {
                 $attributes = ' id="cbU' . $i . '"';
             } else {
                 $attributes = null;
             }
             $class = 'cbUserListRow';
             if ($user->banned) {
                 $class .= ' cbUserListRowBanned';
             }
             if (!$user->confirmed) {
                 $class .= ' cbUserListRowUnconfirmed';
             }
             if (!$user->approved) {
                 $class .= ' cbUserListRowUnapproved';
             }
             if ($user->block) {
                 $class .= ' cbUserListRowBlocked';
             }
             if ($layout == 'grid') {
                 $class .= ' containerBox img-thumbnail';
             } else {
                 $class .= ' sectiontableentry' . (1 + $i % 2);
                 if ($formatting == 'divs') {
                     $class .= ' cbColumns clearfix';
                 }
             }
             if ($columnCount) {
                 if ($formatting == 'divs') {
                     $return .= '<div class="' . $class . '"' . ($style ? ' style="' . $style . '"' : null) . $attributes . '>';
                 } else {
                     $return .= '<tr class="' . $class . '"' . ($style ? ' style="' . $style . '"' : null) . $attributes . '>';
                 }
                 if ($layout == 'grid') {
                     $return .= '<div class="containerBoxInner"' . ($gridStyle ? ' style="' . $gridStyle . '"' : null) . '>';
                 }
                 foreach ($this->columns as $columnIndex => $column) {
                     $cellFields = $this->tableContent[$userIndex][$columnIndex];
                     if ($formatting == 'divs') {
                         $return .= '<div class="cbUserListRowColumn cbUserListRowCol' . ($columnIndex + 1) . ($layout != 'grid' ? ' cbColumn' . $column->size . ' col-sm-' . $column->size : null) . ($column->cssclass ? ' ' . $column->cssclass : null) . '">' . $this->_getUserListCell($cellFields) . '</div>';
                     } else {
                         $return .= '<td class="cbUserListRowColumn cbUserListRowCol' . ($columnIndex + 1) . ($column->cssclass ? ' ' . $column->cssclass : null) . '">' . $this->_getUserListCell($cellFields) . '</td>';
                     }
                 }
                 if ($layout == 'grid') {
                     $return .= '</div>';
                 }
                 if ($formatting == 'divs') {
                     $return .= '</div>';
                 } else {
                     $return .= '</tr>';
                 }
             }
             $i++;
         }
     } else {
         if ($formatting == 'divs') {
             if ($layout != 'grid') {
                 $return .= '<div class="cbUserListRow cbColumns clearfix">';
             }
             $return .= '<div class="sectiontableentry1' . ($layout != 'grid' ? ' cbColumn12 col-sm-12' : null) . '">' . CBTxt::Th('UE_NO_USERS_IN_LIST', 'No users in this list') . '</div>';
             if ($layout != 'grid') {
                 $return .= '</div>';
             }
         } else {
             $return .= '<tr class="sectiontableentry1">' . '<td colspan="' . $columnCount . '">' . CBTxt::Th('UE_NO_USERS_IN_LIST', 'No users in this list') . '</td>' . '</tr>';
         }
     }
     if ($layout == 'grid') {
         $return .= '<div class="clearfix"></div>';
     }
     if ($formatting == 'divs') {
         $return .= '</div>';
     } else {
         $return .= '<tbody>' . '</table>';
     }
     echo $return;
 }
Ejemplo n.º 8
0
function processConnectionActions($connectionids)
{
    global $_CB_framework, $ueConfig, $_PLUGINS;
    // simple spoof check security
    cbSpoofCheck('manageconnections');
    if (!$ueConfig['allowConnections']) {
        $msg = CBTxt::Th('UE_FUNCTIONALITY_DISABLED', 'This functionality is currently disabled.');
    } elseif (!($_CB_framework->myId() > 0)) {
        $msg = CBTxt::Th('UE_NOT_AUTHORIZED', 'You are not authorized to view this page!');
    } else {
        $msg = null;
    }
    $_PLUGINS->loadPluginGroup('user');
    $_PLUGINS->trigger('onBeforeProcessConnectionsRequest', array($connectionids, &$msg));
    if ($msg) {
        $_CB_framework->enqueueMessage($msg, 'error');
        return;
    }
    $cbCon = new cbConnection($_CB_framework->myId());
    if (is_array($connectionids)) {
        foreach ($connectionids as $cid) {
            $action = cbGetParam($_POST, $cid . 'action');
            if ($action == 'd') {
                $cbCon->denyConnection($_CB_framework->myId(), $cid);
            } elseif ($action == 'a') {
                $cbCon->acceptConnection($_CB_framework->myId(), $cid);
            }
        }
    }
    $error = $cbCon->getErrorMSG();
    if ($error) {
        cbRedirect($_CB_framework->viewUrl('manageconnections', false), $error, 'error');
    } else {
        cbRedirect($_CB_framework->viewUrl('manageconnections', false), is_array($connectionids) ? CBTxt::Th('UE_CONNECTIONACTIONSSUCCESSFULL', 'Connection actions successful!') : null);
    }
}
Ejemplo n.º 9
0
 /**
  * returns html page count results as "Results 1-10 of x" or if raw returns array of results as array( from, to, total )
  * @param bool $raw
  * @return array|string
  */
 function getPagesCounter($raw = false)
 {
     $fromResult = $this->limitstart + 1;
     if ($this->limitstart + $this->limit < $this->total) {
         $toResult = $this->limitstart + $this->limit;
     } else {
         $toResult = $this->total;
     }
     if ($raw) {
         $return = $this->total > 0 ? array(0, 0, (int) $this->total) : array((int) $fromResult, (int) $toResult, (int) $this->total);
     } else {
         $return = '<span class="' . htmlspecialchars($this->classes['cbPaginationCounter']) . '">';
         if ($this->total > 0) {
             // Formatted that way to not be picked-up by translation grabber, as used for pluralization, not for translation:
             $return .= strtr(Pluralization::pluralize('{1} ([NUMFIRST]/%%TOTALRESULTS%%)|]1,Inf] ([NUMFIRST]-[NUMLAST]/%%TOTALRESULTS%%)', array('%%TOTALRESULTS%%' => (int) $this->total), 'en'), array('[NUMFIRST]' => (int) $fromResult, '[NUMLAST]' => (int) $toResult, '%%TOTALRESULTS%%' => (int) $this->total));
         } else {
             $return .= CBTxt::Th('PAGENAV_NO_RESULTS UE_NO_RESULTS', 'No results');
         }
         $return .= '</span>';
     }
     return $return;
 }
Ejemplo n.º 10
0
 /**
  * Writes the edit form for new and existing module
  *
  * A new record is defined when <var>$row</var> is passed with the <var>id</var>
  * property set to 0.
  *
  * @param  array                     $options
  * @param  array                     $actionPath
  * @param  SimpleXMLElement          $viewModel
  * @param  TableInterface|\stdClass  $data
  * @param  RegistryEditController    $params
  * @param  PluginTable               $pluginRow
  * @param  string                    $viewType     ( 'view', 'param', 'depends': means: <param> tag => param, <field> tag => view )
  * @param  string                    $cbprevstate
  * @param  boolean                   $htmlOutput   True to output headers for CSS and Javascript
  */
 public static function editPluginView($options, $actionPath, $viewModel, $data, $params, $pluginRow, $viewType, $cbprevstate, $htmlOutput)
 {
     global $_CB_framework, $_CB_Backend_Title, $_PLUGINS, $ueConfig;
     $name = $viewModel->attributes('name');
     $label = $viewModel->attributes('label');
     $iconPair = explode(':', $viewModel->attributes('icon'));
     if (count($iconPair) > 1) {
         $iconset = isset($iconPair[0]) ? $iconPair[0] : null;
         $icon = isset($iconPair[1]) ? $iconPair[1] : null;
     } else {
         $iconset = 'fa';
         $icon = isset($iconPair[0]) ? $iconPair[0] : null;
     }
     if ($icon) {
         if ($iconset == 'fa') {
             $icon = 'fa fa-' . $icon;
         } elseif ($iconset) {
             $icon = $iconset . $icon;
         }
     }
     $id = null;
     if (is_object($data)) {
         $dataArray = get_object_vars($data);
         if (in_array('id', $dataArray)) {
             // General object
             $id = (int) $data->id;
         } elseif (in_array('tabid', $dataArray)) {
             // Field object
             $id = (int) $data->tabid;
         } elseif (in_array('fieldid', $dataArray)) {
             // Tab object
             $id = (int) $data->fieldid;
         }
     }
     if ($id !== null) {
         if (isset($data->title)) {
             $item = $data->title;
         } elseif (isset($data->name)) {
             $item = $data->name;
         } else {
             $item = $id;
         }
         $title = ($id ? CBTxt::T('Edit') : CBTxt::T('New')) . ($label ? ' ' . htmlspecialchars(CBTxt::T($label)) . ' ' : null) . ($item ? ' [' . htmlspecialchars(CBTxt::T($item)) . ']' : null);
     } else {
         $title = $label ? htmlspecialchars(CBTxt::T($label)) : null;
     }
     if ($viewModel->attributes('label')) {
         $showDisclaimer = true;
         if ($pluginRow) {
             if (!$icon) {
                 $icon = 'cb-' . str_replace('.', '_', $pluginRow->element) . '-' . $name;
             }
             $_CB_Backend_Title = array(0 => array($icon, htmlspecialchars(CBTxt::T($pluginRow->name)) . ($title ? ': ' . $title : null)));
         } else {
             if (!$icon) {
                 $icon = 'cb-' . $name;
             }
             $_CB_Backend_Title = array(0 => array($icon, htmlspecialchars(CBTxt::T('Community Builder')) . ($title ? ': ' . $title : null)));
         }
         // Null the label so the view form doesn't output it as we already did as page title:
         $viewModel->addAttribute('label', null);
     } else {
         $showDisclaimer = false;
     }
     $htmlFormatting = $viewModel->attributes('viewformatting');
     if (!$htmlFormatting) {
         if ($_CB_framework->getUi() == 1 && (isset($ueConfig['use_divs']) && $ueConfig['use_divs'] == 1)) {
             $htmlFormatting = 'div';
         } else {
             $htmlFormatting = 'table';
         }
     }
     new cbTabs(true, 2);
     $settingsHtml = $params->draw(null, null, null, null, null, null, false, $viewType, $htmlFormatting);
     if ($htmlOutput) {
         outputCbTemplate();
         outputCbJs();
         self::outputAdminJs();
         initToolTip();
         self::outputRegTemplate();
     }
     $return = null;
     if ($pluginRow && $pluginRow->id) {
         if (!$pluginRow->published) {
             $return .= '<div class="alert alert-danger">' . CBTxt::T('PLUGIN_NAME_IS_NOT_PUBLISHED', '[plugin_name] is not published.', array('[plugin_name]' => htmlspecialchars(CBTxt::T($pluginRow->name)))) . '</div>';
         }
         if (!$_PLUGINS->checkPluginCompatibility($pluginRow)) {
             $return .= '<div class="alert alert-danger">' . CBTxt::T('PLUGIN_NAME_IS_NOT_COMPATIBLE_WITH_YOUR_CURRENT_CB_VERSION', '[plugin_name] is not compatible with your current CB version.', array('[plugin_name]' => htmlspecialchars(CBTxt::T($pluginRow->name)))) . '</div>';
         }
     }
     if (is_object($data) && isset($data->id) && $data->id) {
         if (isset($data->published) && !$data->published) {
             $return .= '<div class="alert alert-danger">' . CBTxt::T('NAME_IS_NOT_PUBLISHED', '[name] is not published.', array('[name]' => htmlspecialchars(CBTxt::T($label)))) . '</div>';
         }
         if (isset($data->enabled) && !$data->enabled) {
             $return .= '<div class="alert alert-danger">' . CBTxt::T('NAME_IS_NOT_ENABLED', '[name] is not enabled.', array('[name]' => htmlspecialchars(CBTxt::T($label)))) . '</div>';
         }
     }
     if ($viewModel->attributes('formformatting') == 'none') {
         $return .= $settingsHtml ? $settingsHtml : null;
     } else {
         cbValidator::loadValidation();
         $cssClass = RegistryEditView::buildClasses($viewModel);
         if (!$cssClass) {
             $cssClass = 'cb_form form-auto';
         }
         $return .= '<form enctype="multipart/form-data" action="' . $_CB_framework->backendUrl('index.php') . '" method="post" name="adminForm" class="cbValidation ' . htmlspecialchars($cssClass) . '" id="cbAdminFormForm">' . ($settingsHtml ? $settingsHtml : null) . '<input type="hidden" name="option" value="' . htmlspecialchars($options['option']) . '" />' . ($pluginRow ? '<input type="hidden" name="cid" value="' . (int) $pluginRow->id . '" />' : null) . ($cbprevstate ? '<input type="hidden" name="cbprevstate" value="' . htmlspecialchars($cbprevstate) . '" />' : null);
         if ($actionPath) {
             foreach ($actionPath as $k => $v) {
                 $return .= '<input type="hidden" name="' . htmlspecialchars($k) . '" value="' . htmlspecialchars($v) . '" />';
             }
         }
         $return .= cbGetSpoofInputTag('plugin') . '</form>';
     }
     if ($showDisclaimer) {
         $disclaimerTitle = 'Disclaimer';
         $disclaimerText = 'This software comes "as is" with no guarantee for accuracy, function or fitness for any purpose.';
         $disclaimerTitleTr = CBTxt::Th('Disclaimer');
         $disclaimerTextTr = CBTxt::Th('This software comes "as is" with no guarantee for accuracy, function or fitness for any purpose.');
         $return .= '<div class="cbregCopyrightfooter content-spacer" style="font-size:11px; color:black; display:block;">' . CBTxt::Th('CB_FOOTNOTE_OPEN_SOURCE_WITH_PLUGINS', 'Community Builder for Joomla, an open-source social framework by <a href="http://www.joomlapolis.com/?pk_campaign=in-cb&amp;pk_kwd=footer" target="_blank">Joomlapolis.com</a>, easy to extend with <a href="http://www.joomlapolis.com/cb-solutions?pk_campaign=in-cb&pk_kwd=footer" target="_blank">CB plugins</a>. Professional <a href="http://www.joomlapolis.com/support?pk_campaign=in-cb&pk_kwd=footer" target="_blank">Support</a> is available with a <a href="http://www.joomlapolis.com/memberships?pk_campaign=in-cb&pk_kwd=footer" target="_blank">Membership</a>.') . '<br /><strong>' . $disclaimerTitle . ':</strong> ' . $disclaimerText . ($disclaimerText != $disclaimerTextTr ? '<br /><strong>' . $disclaimerTitleTr . ':</strong> ' . $disclaimerTextTr : null) . '<br />' . CBTxt::Th('CB_FOOTNOTE_REVIEW_AND_RATE_AT_JED', 'If you use Community Builder, please post a rating and a review on the <a href="[JEDURL]" target="_blank">Joomla! Extensions Directory</a>.', array('[JEDURL]' => htmlspecialchars('http://extensions.joomla.org/extensions/clients-a-communities/communities/210 '))) . '</div>';
     }
     echo $return;
 }
Ejemplo n.º 11
0
 /**
  * Renders as ECHO HTML code of a table
  *
  * @param SimpleXMLElement $modelView
  * @param array $modelRows
  * @param DrawController $controllerView
  * @param array $options
  * @param string $viewType ( 'view', 'param', 'depends': means: <param> tag => param, <field> tag => view )
  */
 protected function renderList(&$modelView, &$modelRows, &$controllerView, &$options, $viewType = 'view')
 {
     global $_CB_framework;
     static $JS_loaded = 0;
     $pluginParams = $this->_pluginParams;
     $renderer = new RegistryEditView($this->input, $this->_db, $pluginParams, $this->_types, $this->_actions, $this->_views, $this->_pluginObject, $this->_tabid);
     $renderer->setParentView($modelView);
     $renderer->setModelOfDataRows($modelRows);
     $name = $modelView->attributes('name');
     $listFieldsRows = $modelView->getElementByPath('listfields/rows');
     $listFieldsPager = $modelView->getElementByPath('listfields/paging');
     $filtersArray = $controllerView->filters($renderer, 'table');
     $batchArray = $controllerView->batchprocess($renderer, 'table');
     outputCbJs();
     $tableLabel = trim(CBTxt::Th($modelView->attributes('label')));
     $tableMenu = $modelView->getElementByPath('tablemenu');
     if (!$JS_loaded++) {
         if ($controllerView->pageNav !== null) {
             $searchButtonJs = $controllerView->pageNav->limitstartJs(0);
         } else {
             $searchButtonJs = 'cbParentForm( this ).submit();';
         }
         $js = "\$( '.cbTableHeader' ).on( 'click', '.cbTableHeaderExpand', function() {" . "\$( this ).removeClass( 'btn-default cbTableHeaderExpand' ).addClass( 'btn-primary cbTableHeaderCollapse' );" . "\$( this ).find( '.fa' ).removeClass( 'fa-caret-down' ).addClass( 'fa-caret-up' );" . "\$( '.' + \$( this ).data( 'toggle' ) ).slideDown();" . "});" . "\$( '.cbTableHeader' ).on( 'click', '.cbTableHeaderCollapse', function() {" . "var toggle = \$( this ).data( 'toggle' );" . "\$( this ).removeClass( 'btn-primary cbTableHeaderCollapse' ).addClass( 'btn-default cbTableHeaderExpand' );" . "\$( this ).find( '.fa' ).removeClass( 'fa-caret-up' ).addClass( 'fa-caret-down' );" . "\$( '.' + toggle ).slideUp();" . "if ( toggle == 'cbBatchTools' ) {" . "\$( '.' + toggle ).find( 'input,textarea,select' ).val( '' );" . "if ( \$.fn.cbselect ) {" . "\$( '.' + toggle ).find( 'select.cbSelect2' ).each( function() {" . "\$( this ).cbselect( 'set', '' );" . "});" . "}" . "} else {" . "\$( '.' + toggle ).find( 'input,textarea,select' ).each( function() {" . "var value = null;" . "if ( \$( this ).hasClass( 'cbSelect2' ) ) {" . "if ( \$.fn.cbselect ) {" . "value = \$( this ).cbselect( 'get' );" . "} else {" . "value = \$( this ).val();" . "}" . "} else {" . "value = \$( this ).val();" . "}" . "if ( ( value != null ) && ( value != '' ) ) {" . "\$( '.cbTableHeaderClear' ).click(); return;" . "}" . "});" . "}" . "});" . "\$( '.cbTableHeader' ).on( 'click', '.cbTableHeaderClear', function() {" . "\$( '.cbTableHeader' ).find( 'input,textarea,select' ).val( '' );" . "if ( \$.fn.cbselect ) {" . "\$( '.cbTableHeader' ).find( 'select.cbSelect2' ).each( function() {" . "\$( this ).cbselect( 'set', '' );" . "});" . "}" . $searchButtonJs . "});" . "\$( '.cbTableBrowserRowsHeader' ).on( 'click', '.cbTableBrowserSort', function() {" . "\$( '.cbTableHeader' ).find( '.cbTableBrowserSorting > select' ).val( \$( this ).data( 'table-sort' ) ).change();" . "});" . ($this->_filtered ? "\$( '.cbSearchToolsToggle' ).click();" : null);
         $_CB_framework->outputCbJQuery($js);
     }
     $return = '<div class="table-responsive cbTableBrowserDiv' . ($name ? ' cbDIV' . htmlspecialchars($name) : null) . '">';
     if ($tableLabel || $tableMenu || $controllerView->hasSearchFields() || $controllerView->hasOrderbyFields() || count($filtersArray) > 0 || count($batchArray) > 0) {
         $return .= '<table class="table table-noborder cbTableBrowserHeader' . ($name ? ' cbTA' . htmlspecialchars($name) : null) . '">' . '<thead>' . '<tr class="cbTableHeader">';
         if ($tableLabel || $tableMenu) {
             $return .= '<th style="width: 10%;" class="text-left cbTableBrowserLabel' . ($name ? ' cbTH' . htmlspecialchars($name) : null) . '">' . ($tableLabel ? $tableLabel : null);
             if ($tableMenu) {
                 $menuIndex = 1;
                 $return .= $tableLabel ? '<div><small>[ ' : null;
                 foreach ($tableMenu->children() as $menu) {
                     /** @var SimpleXMLElement $menu */
                     $menuAction = $menu->attributes('action');
                     $menuLabelHtml = trim(CBTxt::Th(htmlspecialchars($menu->attributes('label'))));
                     $menuDesc = $menu->attributes('description');
                     if ($menuDesc) {
                         $menuDesc = ' title="' . trim(htmlspecialchars(CBTxt::T($menuDesc))) . '"';
                     }
                     $return .= $menuIndex > 1 ? ' - ' : null;
                     if ($menuAction) {
                         $data = null;
                         $link = $controllerView->drawUrl($menuAction, $menu, $data, 0, true);
                         if ($link) {
                             $return .= '<a href="' . $link . '"' . $menuDesc . '>' . $menuLabelHtml . '</a>';
                         }
                     } elseif ($menuDesc) {
                         $return .= '<span' . $menuDesc . '>' . $menuLabelHtml . '</span>';
                     } else {
                         $return .= $menuLabelHtml;
                     }
                     $menuIndex++;
                 }
                 $return .= $tableLabel ? ' ]</small></div>' : null;
             }
             $return .= '</th>';
         }
         if ($controllerView->hasSearchFields() || $controllerView->hasOrderbyFields() || count($filtersArray) > 0 || count($batchArray) > 0) {
             $return .= '<th class="cbTableHeaderTools">' . '<div class="text-left clearfix cbTableBrowserTools">';
             if ($controllerView->hasSearchFields()) {
                 $return .= $controllerView->quicksearchfields();
             }
             if (count($filtersArray) > 0) {
                 if ($controllerView->hasSearchFields()) {
                     $return .= ' ';
                 }
                 $return .= '<button type="button" class="btn btn-default cbSearchToolsToggle cbTableHeaderExpand" data-toggle="cbSearchTools">' . CBTxt::Th('Search Tools') . ' <span class="fa fa-caret-down"></span></button>';
             }
             if (count($batchArray) > 0) {
                 if (count($filtersArray) > 0 || $controllerView->hasSearchFields()) {
                     $return .= ' ';
                 }
                 $return .= '<button type="button" class="btn btn-default cbBatchToolsToggle cbTableHeaderExpand" data-toggle="cbBatchTools">' . CBTxt::Th('Batch Tools') . ' <span class="fa fa-caret-down"></span></button>';
             }
             $return .= ' <button type="button" class="btn btn-default cbTableHeaderClear">' . CBTxt::Th('Clear') . '</button>';
             if ($controllerView->hasOrderbyFields()) {
                 if (count($filtersArray) > 0 || count($batchArray) > 0 || $controllerView->hasSearchFields()) {
                     $return .= ' ';
                 }
                 $return .= '<span class="text-right pull-right cbTableBrowserSorting">' . $controllerView->orderbyfields() . '</span>';
             }
             $return .= '</div>';
             if (count($filtersArray) > 0) {
                 $return .= '<fieldset class="cbFilters cbSearchTools cbFieldset">' . '<legend>' . CBTxt::Th('Search Tools') . '</legend>' . implode(' ', $filtersArray) . '</fieldset>';
             }
             if (count($batchArray) > 0) {
                 $return .= '<fieldset class="cbBatchProcess cbBatchTools cbFieldset">' . '<legend>' . CBTxt::Th('Batch Tools') . '</legend>' . implode(' ', $batchArray) . '</fieldset>';
             }
             $return .= '</th>';
         }
         $return .= '</tr>' . '</thead>' . '</table>';
     }
     if ($listFieldsRows) {
         $columnCount = 0;
         $return .= '<table class="table table-hover cbTableBrowserRows' . ($name ? ' cbTL' . htmlspecialchars($name) : null) . '">' . '<thead>' . '<tr class="cbTableBrowserRowsHeader">';
         foreach ($listFieldsRows->children() as $field) {
             /** @var SimpleXMLElement $field */
             if ($field->attributes('type') != 'hidden' && Access::authorised($field)) {
                 $classes = RegistryEditView::buildClasses($field);
                 $attributes = ($classes ? ' class="' . htmlspecialchars($classes) . '"' : null) . ($field->attributes('width') || $field->attributes('align') ? ' style="' . ($field->attributes('width') ? 'width: ' . htmlspecialchars($field->attributes('width')) . ';' : null) . ($field->attributes('align') ? 'text-align: ' . htmlspecialchars($field->attributes('align')) . ';' : null) . '"' : null) . ($field->attributes('nowrap') ? ' nowrap="nowrap"' : null);
                 $fieldName = $field->attributes('name');
                 $fieldOrdering = $field->attributes('allowordering');
                 $return .= '<th' . $attributes . '>';
                 if ($field->attributes('type') == 'primarycheckbox') {
                     $jsToggleAll = "cbToggleAll( this, " . count($modelRows) . ", '" . $controllerView->fieldId('id') . "' );";
                     $return .= '<input type="checkbox" id="' . $controllerView->fieldId('toggle') . '" name="' . $controllerView->fieldName('toggle') . '" value="" onclick="' . $jsToggleAll . '" />';
                 } else {
                     $fieldIcon = null;
                     if ($fieldOrdering) {
                         $fieldSort = explode(',', $fieldOrdering);
                         $fieldAsc = in_array('ascending', $fieldSort);
                         $fieldDesc = in_array('descending', $fieldSort);
                         if ($fieldAsc && $this->orderby == $fieldName . '_asc') {
                             // If ascending is allowed and is already active then set click to descending if descending is allowed:
                             if ($fieldDesc) {
                                 $return .= '<a href="javascript: void(0);" class="text-nowrap cbTableBrowserSort cbTableBrowserSortDesc" data-table-sort="' . htmlspecialchars($fieldName . '_desc') . '">';
                             } else {
                                 $return .= '<a href="javascript: void(0);">';
                             }
                             $fieldIcon = ' <span class="fa fa-sort-alpha-asc text-default"></span>';
                         } elseif ($fieldDesc && $this->orderby == $fieldName . '_desc') {
                             // If descending is allowed and is already active then set click to ascending if ascending is allowed:
                             if ($fieldAsc) {
                                 $return .= '<a href="javascript: void(0);" class="text-nowrap cbTableBrowserSort cbTableBrowserSortAsc" data-table-sort="' . htmlspecialchars($fieldName . '_asc') . '">';
                             } else {
                                 $return .= '<a href="javascript: void(0);">';
                             }
                             $fieldIcon = ' <span class="fa fa-sort-alpha-desc text-default"></span>';
                         } elseif ($fieldSort[0] == 'ascending') {
                             // Default to ascending if this field allows it:
                             $return .= '<a href="javascript: void(0);" class="cbTableBrowserSort cbTableBrowserSortAsc" data-table-sort="' . htmlspecialchars($fieldName . '_asc') . '">';
                         } elseif ($fieldSort[0] == 'descending') {
                             // Default to descending if this field allows it:
                             $return .= '<a href="javascript: void(0);" class="cbTableBrowserSort cbTableBrowserSortDesc" data-table-sort="' . htmlspecialchars($fieldName . '_desc') . '">';
                         } else {
                             $return .= '<a href="javascript: void(0);">';
                         }
                     }
                     $return .= $field->attributes('description') ? cbTooltip(2, CBTxt::Th($field->attributes('description')), null, null, null, CBTxt::Th($field->attributes('label')), null, 'data-hascbtooltip="true"') : CBTxt::Th($field->attributes('label'));
                     if ($fieldOrdering) {
                         $return .= $fieldIcon . '</a>';
                     }
                 }
                 if ($field->attributes('type') == 'ordering') {
                     if (!$fieldOrdering || in_array($this->orderby, array($fieldName . '_asc', $fieldName . '_desc', $fieldName))) {
                         if ($fieldOrdering) {
                             $field->addAttribute('noordering', 'false');
                         }
                         if (strpos($field->attributes('onclick'), 'number') !== false) {
                             $jsOrderSave = "cbsaveorder( this, " . count($modelRows) . ", '" . $controllerView->fieldId('id', null, false) . "', '" . $controllerView->taskName(false) . "', '" . $controllerView->subtaskName(false) . "', '" . $controllerView->subtaskValue('saveorder/' . $field->attributes('name'), false) . "' );";
                             $return .= ' <a href="javascript: void(0);" onclick="' . $jsOrderSave . '">' . '<span class="fa fa-save fa-lg text-default" title="' . htmlspecialchars(CBTxt::T('Save Order')) . '"></span>' . '</a>';
                         }
                     } else {
                         if ($fieldOrdering) {
                             $field->addAttribute('noordering', 'true');
                         }
                     }
                 }
                 $return .= '</th>';
                 $columnCount++;
             }
         }
         $return .= '</tr>' . '</thead>' . '</tbody>';
         $total = count($modelRows);
         $controllerView->pageNav->setRowsNumber($total);
         if ($total) {
             for ($i = 0; $i < $total; $i++) {
                 $controllerView->pageNav->setRowIndex($i);
                 $renderer->setModelOfDataRowsNumber($i);
                 $row = $modelRows[$i];
                 $rowlink = $listFieldsRows->attributes('link');
                 if ($rowlink) {
                     $hrefRowEdit = $controllerView->drawUrl($rowlink, $listFieldsRows, $row, $row->id, false);
                     if ($hrefRowEdit) {
                         if ($listFieldsRows->attributes('target') == '_blank') {
                             $onclickJS = 'window.open(\'' . htmlspecialchars(cbUnHtmlspecialchars($hrefRowEdit)) . '\', \'cbinvoice\', \'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no\'); return false;';
                         } else {
                             $onclickJS = "window.location='" . htmlspecialchars(cbUnHtmlspecialchars($hrefRowEdit)) . "'";
                         }
                         $rowOnclickHtml = ' onclick="' . $onclickJS . '"';
                     } else {
                         $rowOnclickHtml = null;
                     }
                 } else {
                     $rowOnclickHtml = null;
                 }
                 $controllerView->setControl_name($this->name . '[rows][' . $i . ']');
                 $return .= '<tr class="cbTableBrowserRow"' . $rowOnclickHtml . '>' . $renderer->renderEditRowView($listFieldsRows, $row, $controllerView, $options, $viewType, 'td') . '</tr>';
             }
         }
         $controllerView->setControl_name($this->name);
         $return .= '</tbody>';
         if ($total && (!$listFieldsPager || $listFieldsPager && $listFieldsPager->attributes('type') != 'none')) {
             if ($listFieldsPager) {
                 $showPageLinks = strpos($listFieldsPager->attributes('type'), 'nopagelinks') === false;
                 $showLimitBox = strpos($listFieldsPager->attributes('type'), 'nolimitbox') === false;
                 $showPagesCount = strpos($listFieldsPager->attributes('type'), 'nopagescount') === false;
             } else {
                 $showPageLinks = true;
                 $showLimitBox = true;
                 $showPagesCount = true;
             }
             if ($controllerView->pageNav->total <= $controllerView->pageNav->limit) {
                 $showPageLinks = false;
             }
             $return .= '<tfoot>' . '<tr class="cbTableBrowserRowsPaging">' . '<th colspan="' . (int) $columnCount . '" class="text-center">' . $controllerView->pageNav->getListFooter($showPageLinks, $showLimitBox, $showPagesCount) . '</th>' . '</tr>' . '</tfoot>' . '</table>';
         } elseif ($controllerView->pageNav !== null) {
             $return .= '</table>' . $controllerView->pageNav->getLimitBox(false);
         } else {
             $return .= '</table>';
         }
     } elseif ($controllerView->pageNav !== null) {
         $return .= $controllerView->pageNav->getLimitBox(false);
     }
     $return .= '<input type="hidden" name="' . $controllerView->fieldName('subtask') . '" value="" />';
     $statistics = $controllerView->getStatistics();
     if ($statistics) {
         foreach ($statistics as $stat) {
             $return .= $renderer->renderEditRowView($stat['view'], $stat['values'], $controllerView, $options, 'view', 'table');
         }
     }
     $return .= '</div>';
     echo $return;
 }
Ejemplo n.º 12
0
	/**
	 * Implements a form xpath-type field for showing a given xpath value
	 *
	 * @param  string              $name          The name of the form element
	 * @param  string              $value         The value of the element
	 * @param  SimpleXMLElement    $node          The xml element for the parameter
	 * @param  string              $control_name  The control name
	 * @return string                             The html for the element
	 */
	function _form_xpath( /** @noinspection PhpUnusedParameterInspection */ $name, $value, &$node, $control_name ) {
		$fromNode				=	$node->attributes( 'path' );
		$fromFile				=	$node->attributes( 'file' );
		$translate				=	$node->attributes( 'translate' );

		$return					=	null;

		if ( $fromNode && ( $fromFile !== null ) ) {
			$this->substituteName( $fromFile, true );
			$this->substituteName( $fromNode, false );

			if ( $fromFile !== '' ) {
				$fromFile		=	static::pathFromXML( $fromFile . '.xml', $node, $this->_pluginObject );
			}

			if ( ( $fromFile === '' ) || is_readable( $fromFile ) ) {
				if ( $fromFile === '' ) {
					$fromRoot	=	$node;
				} else {
					$fromRoot	=	new SimpleXMLElement( $fromFile, LIBXML_NONET | ( defined('LIBXML_COMPACT') ? LIBXML_COMPACT : 0 ), true );
				}

				/** @var SimpleXMLElement[] $xmlPath */
				$xmlPath		=	$fromRoot->xpath( $fromNode );

				if ( $xmlPath && count( $xmlPath ) ) {
					$return		=	$xmlPath[0]->data();
				}

				if ( $translate == 'yes' ) {
					$return		=	CBTxt::Th( $return );
				}
			}
		}

		return $return;
	}
Ejemplo n.º 13
0
 /**
  * Handles the backend plugin edition
  *
  * @param  string           $option
  * @param  string           $action
  * @param  SimpleXMLElement $element
  * @param  string           $mode
  * @return string                        HTML
  *
  * @throws \LogicException
  */
 public function drawView($option, $action, $element, $mode)
 {
     global $_CB_Backend_Menu;
     $ui = $this->clientId == 1 ? 2 : 1;
     $context = new Context();
     $pluginParams = $context->getParams();
     $interfaceUi = $ui == 2 ? 'admin' : 'frontend';
     $adminActionsModel = $element->getChildByNameAttr('actions', 'ui', $interfaceUi);
     if (!$adminActionsModel) {
         $adminActionsModel = $element->getChildByNameAttr('actions', 'ui', 'all');
     }
     if (!$adminActionsModel) {
         throw new \LogicException('No ' . $interfaceUi . ' actions defined in XML');
     }
     // Check permission if specified:
     if (!Access::authorised($adminActionsModel)) {
         return CBTxt::T("Access to these actions is not authorized by the permissions of your user groups.");
     }
     // General-purpose extenders:
     $extenders = $adminActionsModel->xpath('extend');
     /** @var SimpleXMLElement[] $extenders */
     foreach ($extenders as $k => $extends) {
         $error = RegistryEditView::extendXMLnode($extenders[$k], $element, null, $context->getPluginObject());
         if ($error) {
             echo $error;
         }
     }
     $found = false;
     $actionPath = array();
     if ($action) {
         $actionsModel = $adminActionsModel->getChildByNameAttr('action', 'name', $action);
         $found = $actionsModel != null;
         if ($found) {
             $requests = explode(' ', $actionsModel->attributes('request'));
             $values = explode(' ', $actionsModel->attributes('action'));
             $actionPath = array();
             for ($i = 0, $n = count($requests); $i < $n; $i++) {
                 $actionPath[$requests[$i]] = $values[$i];
             }
         }
     }
     if (!$found) {
         // EVENT: select the event from URL and compute the selected $actionPath
         $found = false;
         $actionsModel = null;
         foreach ($adminActionsModel->children() as $actionsModel) {
             /** @var SimpleXMLElement $actionsModel */
             $request = $actionsModel->attributes('request');
             if ($request) {
                 $requests = explode(' ', $request);
                 $values = explode(' ', $actionsModel->attributes('action'));
                 $actionPath = array();
                 for ($i = 0, $n = count($requests); $i < $n; $i++) {
                     $actionPath[$requests[$i]] = $this->input->get($requests[$i], null, GetterInterface::STRING);
                     // Temporary fix for older versions of CBSubs before CBSubs 4.0.0 stable to avoid warnings on ajax version checks:
                     if ($requests[$i] === 'view' && $actionPath['view'] === null) {
                         $actionPath['view'] = $this->input->get('task', null, GetterInterface::STRING);
                     }
                     if ($actionPath[$requests[$i]] != $values[$i]) {
                         break;
                     }
                 }
                 if ($i == $n) {
                     $found = true;
                     break;
                 }
             }
         }
     }
     if (!$found) {
         $actionPath = array();
         // try finding first default one:
         if ($ui == 2) {
             $actionsModel = $adminActionsModel->getChildByNameAttr('action', 'request', '');
         }
         if (!isset($actionsModel)) {
             return CBTxt::T('AHAWOW_REQUESTED_ACTION_NOT_DEFINED_IN_XML', "Requested action '[ACTION]' not defined in XML.", array('[ACTION]' => htmlspecialchars($action)));
         }
     }
     // Check permission if specified:
     if (!isset($actionsModel) || !Access::authorised($actionsModel)) {
         return CBTxt::T("This action is not authorized by the permissions of your user groups.");
     }
     if (!isset($actionPath['view'])) {
         $actionPath['view'] = $ui == 2 ? 'editPlugin' : '';
         //TODO: 2nd should come from target routing
     } elseif ($actionPath['view'] != 'editPlugin') {
         $actionPath['act'] = '';
     }
     // EVENT: fetch the input parameters from URL:
     $parametersNames = explode(' ', $actionsModel->attributes('requestparameters'));
     $parametersValues = array();
     foreach ($parametersNames as $paraNam) {
         $parametersValues[$paraNam] = null;
         if (strpos($paraNam, '[') === false) {
             if (trim($paraNam)) {
                 $parametersValues[$paraNam] = $this->input->get($paraNam, '', GetterInterface::STRING);
             }
         } else {
             $matches = null;
             preg_match_all('/(.*)(?:\\[(.*)\\])+/', $paraNam, $matches);
             if (is_array($matches) && count($matches) >= 3 && count($matches[2]) >= 1) {
                 $parametersValues[$paraNam] = $this->input->get($matches[1][0] . '.' . $matches[2][0], null, GetterInterface::STRING);
             }
         }
     }
     $keyValues = array();
     // Action-specific general extenders:
     $extenders = $adminActionsModel->xpath('actionspecific/extend');
     /** @var SimpleXMLElement[] $extenders */
     foreach ($extenders as $k => $extends) {
         $error = RegistryEditView::extendXMLnode($extenders[$k], $element, $actionsModel, $context->getPluginObject());
         if ($error) {
             echo $error;
         }
     }
     // First extend what can be extended so the showview's below have a complete XML tree:
     /** @var $actionItem SimpleXMLElement */
     foreach ($actionsModel->xpath('extend') as $actionItem) {
         $error = RegistryEditView::extendXMLnode($actionItem, $element, $actionsModel, $context->getPluginObject());
         if ($error) {
             echo $error;
         }
     }
     /** @var $actionItem SimpleXMLElement */
     foreach ($actionsModel->children() as $actionItem) {
         // CONTROLLER: select the controller:
         switch ($actionItem->getName()) {
             case 'extend':
                 // Treated just above.
                 break;
             case 'showview':
                 $viewName = $actionItem->attributes('view');
                 $showviewType = $actionItem->attributes('type');
                 $viewMode = $actionItem->attributes('mode');
                 // MODEL: load data to view:
                 $dataModel = $actionItem->getElementByPath('data');
                 if ($dataModel) {
                     $dataModelType = $dataModel->attributes('type');
                     $cbDatabase = $this->db;
                     if (in_array($dataModelType, array('sql:row', 'sql:multiplerows', 'sql:field', 'parameters'))) {
                         $xmlsql = new XmlQuery($cbDatabase, null, $pluginParams);
                         $data = $xmlsql->loadObjectFromData($dataModel);
                         if ($data === null) {
                             return 'showview::sql:row: load failed: ' . $cbDatabase->getErrorMsg();
                         }
                         $dataModelValueName = $dataModel->attributes('value');
                         $dataModelValueType = $dataModel->attributes('valuetype');
                         // if the value of key is a parameter name, replace it with the corresponding parameter:
                         $dataModelValueTypeArray = explode(':', $dataModelValueType);
                         if ($dataModelValueTypeArray[0] == 'request') {
                             if (isset($parametersValues[$dataModelValueName])) {
                                 $dataModelValue = $parametersValues[$dataModelValueName];
                                 // database escaping to int is done at request time
                                 $keyValues[$dataModelValueName] = $dataModelValue;
                                 unset($parametersValues[$dataModelValueName]);
                             } else {
                                 echo sprintf('showview::sql::row %s: request %s not in parameters of action.', $dataModel->attributes('name'), $dataModelValueName);
                             }
                         }
                         if ($dataModelType == 'sql:field') {
                             $data = new Registry($data);
                         }
                     } elseif ($dataModelType == 'class') {
                         $dataModelClass = $dataModel->attributes('class');
                         $dataModelValue = $dataModel->attributes('value');
                         $dataModelValueName = $dataModelValue;
                         $dataModelValueType = $dataModel->attributes('valuetype');
                         $dataModelValueTypeArray = explode(':', $dataModelValueType);
                         if ($dataModelValueTypeArray[0] == 'request') {
                             if (isset($parametersValues[$dataModelValueName])) {
                                 $dataModelValue = $parametersValues[$dataModelValueName];
                                 $keyValues[$dataModelValueName] = $dataModelValue;
                                 unset($parametersValues[$dataModelValueName]);
                             } else {
                                 echo sprintf('showview::sql::row %s: request %s not in parameters of action.', $dataModel->attributes('name'), $dataModelValue);
                             }
                         }
                         if (strpos($dataModelClass, '::') === false) {
                             $data = new $dataModelClass($cbDatabase);
                             // normal clas="className"
                             /** @var $data TableInterface */
                             $data->load($dataModelValue);
                         } else {
                             $dataModelSingleton = explode('::', $dataModelClass);
                             // class object loader from singleton: class="loaderClass::loadStaticMethor" with 1 parameter, the key value.
                             if (is_callable($dataModelSingleton)) {
                                 if (is_callable(array($dataModelSingleton[0], 'getInstance'))) {
                                     $instance = call_user_func_array(array($dataModelSingleton[0], 'getInstance'), array(&$cbDatabase));
                                     $rows = call_user_func_array(array($instance, $dataModelSingleton[1]), array($dataModelValue));
                                 } else {
                                     $rows = call_user_func_array($dataModelSingleton, array($dataModelValue));
                                 }
                             } else {
                                 echo sprintf('showview::class %s: missing singleton class creator %s.', $dataModel->attributes('name'), $dataModelClass);
                                 $std = new \stdClass();
                                 $rows = array($std);
                             }
                             $data = $rows[0];
                         }
                     } else {
                         $data = null;
                         echo 'showview: Data model type ' . $dataModelType . ' is not implemented !';
                     }
                 } else {
                     if ($this->_data instanceof TableInterface || $this->_data instanceof \comprofilerDBTable) {
                         $data = $this->_data;
                         $dataModelType = 'sql:row';
                     } elseif ($this->_data instanceof ParamsInterface) {
                         $data = $this->_data;
                         $dataModelType = 'sql:row';
                     } else {
                         $data = null;
                         $dataModelType = null;
                     }
                 }
                 // VIEW: select view:
                 $allViewsModels = $element->getElementByPath('views');
                 if ($viewName && (!$showviewType || $showviewType == 'view')) {
                     ////// $viewModel		= $allViewsModels->getChildByNameAttributes( 'view', array( 'name' => $viewName ) );
                     $xpathUi = '/*/views/view[@ui="' . $interfaceUi . '" and @name="' . $viewName . '"]';
                     $xpathAll = '/*/views/view[@ui="all" and @name="' . $viewName . '"]';
                     $viewModel = $element->xpath($xpathUi);
                     if (!$viewModel) {
                         $viewModel = $element->xpath($xpathAll);
                     }
                     if (!$viewModel) {
                         $viewModel = RegistryEditView::xpathWithAutoLoad($element, $xpathUi);
                     }
                     if (!$viewModel) {
                         $viewModel = RegistryEditView::xpathWithAutoLoad($element, $xpathAll);
                     }
                     /*
                     						if ( ! $viewModel ) {
                     							$viewModel		=	RegistryEditView::xpathWithAutoLoad( $element, '/ * / views/view[not(@ui) and @name="' . $viewName . '"]' );
                     						}
                     */
                     if ($viewModel) {
                         $viewModel = $viewModel[0];
                     } else {
                         return 'XML:showview: View ' . $viewName . ' not defined in ui ' . $interfaceUi . ' in XML';
                     }
                 } elseif ($showviewType == 'xml') {
                     // e.g.: <showview name="gateway_paymentstatus_information" mode="view" type="xml" file="processors/{payment_method}/edit.gateway" path="/*/views/view[@name=&quot;paymentstatusinformation&quot;]" mandatory="false" />
                     $fromNode = $actionItem->attributes('path');
                     $fromFile = $actionItem->attributes('file');
                     if ($fromNode && $fromFile !== null) {
                         // $this->substituteName( $fromFile, true );
                         // $this->substituteName( $fromNode, false );
                         $fromFile = $context->getPluginPath() . '/' . $fromFile . '.xml';
                         if ($fromFile === '' || is_readable($fromFile)) {
                             if ($fromFile === '') {
                                 $fromRoot = $element;
                             } else {
                                 $fromRoot = new SimpleXMLElement($fromFile, LIBXML_NONET | (defined('LIBXML_COMPACT') ? LIBXML_COMPACT : 0), true);
                             }
                             $viewModel = $fromRoot->xpath($fromNode);
                             if (!$viewModel) {
                                 trigger_error('Admin:showview: View ' . $viewName . ': file ' . $fromFile . ', path: ' . $fromNode . ' does not exist or is empty.', E_USER_NOTICE);
                             }
                             $viewModel = $viewModel[0];
                         } else {
                             throw new \LogicException('Admin:showview: View ' . $viewName . ': file ' . $fromFile . ' does not exist or is not readable.');
                         }
                     } else {
                         throw new \LogicException('Admin:showview: View ' . $viewName . ' file or path not defined..', E_USER_NOTICE);
                     }
                 } else {
                     throw new \LogicException('Admin:showview: View ' . $viewName . ' not of supported type.', E_USER_NOTICE);
                 }
                 $viewUi = $viewModel->attributes('ui');
                 if ($viewUi & $viewUi != 'all' && $viewUi != $interfaceUi) {
                     throw new \LogicException('showview: View ' . $viewName . ' not allowed for ' . $interfaceUi);
                 }
                 $extendedParser = $allViewsModels->getElementByPath('extendxmlparser');
                 $actionPath = array_merge($actionPath, $keyValues);
                 $options = array_merge($this->getBaseOptions(), $actionPath, $parametersValues);
                 if ($ui == 2) {
                     $options = array_merge($options, $actionPath, $parametersValues);
                 }
                 $cbprevstate = $this->input->get('cbprevstate', null, GetterInterface::STRING);
                 $params = new RegistryEditController($this->input, $this->db, new Registry(), $viewModel, $element, $context->getPluginObject());
                 $displayData = $this->bindInput($viewMode, $data);
                 // Set the parameters with the $displayData :
                 $registry = new Registry();
                 $registry->load($displayData);
                 $registry->setStorage($displayData);
                 $params->setRegistry($registry);
                 $params->setPluginParams($pluginParams);
                 $params->setOptions($options);
                 if ($extendedParser) {
                     $params->setExtendedViewParser($extendedParser);
                 }
                 $extenders = $allViewsModels->xpath('extend');
                 foreach ($extenders as $extends) {
                     RegistryEditView::extendXMLnode($extends, $element, $actionsModel, $context->getPluginObject());
                 }
                 $viewType = $viewModel->attributes('type');
                 switch ($viewType) {
                     case 'params':
                         if ($mode == 'edit') {
                             if ($viewMode == 'edit' || $viewMode == 'show') {
                                 $viewTypeMode = $viewMode == 'edit' ? 'param' : 'view';
                                 if ($ui == 2) {
                                     $htmlOutput = $this->input->get('no_html', 0, GetterInterface::COMMAND) != 1 && $this->input->get('format', null, GetterInterface::COMMAND) != 'raw';
                                     ActionViewAdmin::editPluginView($options, $actionPath, $viewModel, $displayData, $params, $context->getPluginObject(), $viewTypeMode, $cbprevstate, $htmlOutput);
                                     $settings = null;
                                     $html = null;
                                 } else {
                                     /** @global \stdClass $_CB_Backend_Menu   : 'show' : only displays close button, 'edit' : special close button */
                                     global $_CB_Backend_Menu;
                                     $_CB_Backend_Menu = new \stdClass();
                                     $html = '';
                                     outputCbTemplate();
                                     outputCbJs();
                                     // $_CB_framework->outputCbJQuery( '' );
                                     initToolTip();
                                     $htmlFormatting = $viewModel->attributes('viewformatting');
                                     if (!$htmlFormatting) {
                                         global $ueConfig;
                                         if (isset($ueConfig['use_divs']) && $ueConfig['use_divs'] == 1) {
                                             $htmlFormatting = 'div';
                                         } else {
                                             $htmlFormatting = 'table';
                                         }
                                     }
                                     $settings = $params->draw(null, null, null, null, null, null, false, $viewTypeMode, $htmlFormatting);
                                 }
                                 if ($ui == 2) {
                                     $_CB_Backend_Menu->mode = $viewMode;
                                     // Implemented in lower level in RegistryEditView:  $toolbarMenu = $viewModel->getElementByPath( 'toolbarmenu' );
                                 }
                                 if ($ui != 2) {
                                     $actionView = new ActionView();
                                     $buttonSaveText = $actionsModel->attributes('label');
                                     if (!$buttonSaveText) {
                                         $buttonSaveText = 'Save';
                                     }
                                     $buttonSaveText = CBTxt::Th($buttonSaveText);
                                     //	CBTxt::Th("Save"); For translation strings extraction
                                     $warning = null;
                                     if ($viewTypeMode == 'param') {
                                         $settings .= '<div class="cbControlButtonsLine">' . "\n\t" . '<span class="cb_button_wrapper">' . '<button type="submit" name="actbutton" value="' . 'save' . $action . '" class="button cbregButton cbregSaveButton">' . $buttonSaveText . '</button>' . '</span>' . "\n\t" . '</div>' . "\n";
                                         $postedActionPath = $actionPath;
                                         unset($postedActionPath['view']);
                                         $formHiddens = array_merge($this->getBaseOptions(), array('act' => 'save' . $action), $postedActionPath);
                                     } else {
                                         $formHiddens = null;
                                     }
                                     $html .= $actionView->drawForm($settings, $warning, $formHiddens, array_merge($this->_getParams, array('act' => $action)), RegistryEditView::buildClasses($viewModel));
                                     return $html;
                                 }
                             } else {
                                 echo 'showview::params: mode is ' . $mode . ' but view mode is ' . $viewMode . ' instead of edit.';
                             }
                         } elseif (in_array($mode, array('apply', 'save', 'savenew', 'savecopy'))) {
                             $this->savePluginView($options, $actionPath, $keyValues, $parametersValues, $viewModel, $data, $params, $mode, $dataModelType, $context->getPluginObject(), $dataModel, $pluginParams, $cbprevstate, $ui);
                             if ($ui == 2 && $mode == 'apply') {
                                 // We arrive here only in case of saving error, as redirect (performed in savePluginView) would loose the inputs:
                                 return $this->drawView($option, $action, $element, 'edit');
                             }
                         } else {
                             echo 'showview::params: view type params mode ' . $mode . ' is not implemented !';
                         }
                         break;
                     default:
                         echo 'showview::not-params: type of view ' . $viewType . ' is not implemented !';
                         break;
                 }
                 break;
             default:
                 echo 'action::not-showview: child xml element "' . $actionItem->getName() . '" of action is not implemented !';
                 break;
         }
     }
     return null;
 }
Ejemplo n.º 14
0
	/**
	 * @param  OrderedTable  $row
	 * @param  string[]      $input
	 * @param  UserTable     $user
	 * @param  stdClass      $model
	 * @param  PluginTable   $plugin
	 */
	static function showBlogEdit( $row, $input, $user, /** @noinspection PhpUnusedParameterInspection */ $model, $plugin )
	{
		global $_CB_framework, $_PLUGINS, $_LANG;

		cbValidator::loadValidation();

		$blogMode			=	$plugin->params->get( 'hangout_mode', 1 );
		$pageTitle			=	( $row->get( 'id' ) ? $_LANG['Edit Hangout'] : $_LANG['Create Hangout'] );
		$cbModerator		=	Application::User( (int) $user->get( 'id' ) )->isGlobalModerator();

		$_CB_framework->setPageTitle( $pageTitle );
		$_CB_framework->appendPathWay( htmlspecialchars( $_LANG['Hangout'] ), $_CB_framework->userProfileUrl( $row->get( 'user', $user->get( 'id' ) ), true, 'cbhangoutTab' ) );
		$_CB_framework->appendPathWay( htmlspecialchars( $pageTitle ), $_CB_framework->pluginClassUrl( $plugin->element, true, ( $row->get( 'id' ) ? array( 'action' => 'hangout', 'func' => 'edit', 'id' => (int) $row->get( 'id' ) ) : array( 'action' => 'hangout', 'func' => 'new' ) ) ) );

		initToolTip();

		$return				=	'<div class="blogEdit">'
							.		'<form action="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'hangout', 'func' => 'save', 'id' => (int) $row->get( 'id' ) ) ) . '" method="post" enctype="multipart/form-data" name="blogForm" id="blogForm" class="cb_form blogForm form-auto cbValidation">'
							.			( $pageTitle ? '<div class="blogsTitle page-header"><h3>' . $pageTitle . '</h3></div>' : null );

		if ( $cbModerator || ( ! $plugin->params->get( 'hangout_approval', 0 ) ) ) {
			$return			.=			'<div class="cbft_select cbtt_select form-group cb_form_line clearfix">'
							.				'<label for="published" class="col-sm-3 control-label">' . CBTxt::Th( 'Published' ) . '</label>'
							.				'<div class="cb_field col-sm-9">'
							.					$input['published']
							.					getFieldIcons( 1, 0, null, '' )
							.				'</div>'
							.			'</div>';
		}

		if ( $plugin->params->get( 'hangout_category_config', 1 ) || $cbModerator ) {
			$return			.=			'<div class="cbft_select cbtt_select form-group cb_form_line clearfix">'
							.				'<label for="category" class="col-sm-3 control-label">' . CBTxt::Th( 'Category' ) . '</label>'
							.				'<div class="cb_field col-sm-9">'
							.					$input['category']
							.					getFieldIcons( 1, 0, null, '' )
							.				'</div>'
							.			'</div>';
		}

		if ( $plugin->params->get( 'hangout_access_config', 1 ) || $cbModerator ) {
			$return			.=			'<div class="cbft_select cbtt_select form-group cb_form_line clearfix">'
							.				'<label for="access" class="col-sm-3 control-label">' . CBTxt::Th( 'Access' ) . '</label>'
							.				'<div class="cb_field col-sm-9">'
							.					$input['access']
							.					getFieldIcons( 1, 0, null, '' )
							.				'</div>'
							.			'</div>';
		}

		$return				.=			'<div class="cbft_text cbtt_input form-group cb_form_line clearfix">'
							.				'<label for="title" class="col-sm-3 control-label">' . CBTxt::Th( 'Title' ) . '</label>'
							.				'<div class="cb_field col-sm-9">'
							.					$input['title']
							.					getFieldIcons( 1, 1, null, '' )
							.				'</div>'
							.			'</div>';

		if ( in_array( $blogMode, array( 1, 2 ) ) ) {
			$return			.=			'<div class="cbft_textarea cbtt_textarea form-group cb_form_line clearfix">'
							.				'<label for="hangout_intro" class="col-sm-3 control-label">' . ( $blogMode == 1 ? $_LANG['Text intro'] : $_LANG['Text intro'] ) . '</label>'
							.				'<div class="cb_field col-sm-9">'
							.					$input['hangout_intro']
							.					getFieldIcons( 1, 0, null, '' )
							.				'</div>'
							.			'</div>';
		}

		if ( in_array( $blogMode, array( 1, 3 ) ) ) {
			$return			.=			'<div class="cbft_textarea cbtt_textarea form-group cb_form_line clearfix">'
							.				'<label for="hangout_full" class="col-sm-3 control-label">' . ( $blogMode == 1 ? $_LANG['Text full'] : $_LANG['Text full'] ) . '</label>'
							.				'<div class="cb_field col-sm-9">'
							.					$input['hangout_full']
							.					getFieldIcons( 1, 0, null, '' )
							.				'</div>'
							.			'</div>';
                        
                        $return			.=			'<div class="cbft_text cbtt_input form-group cb_form_line clearfix">'
							.				'<label for="title" class="col-sm-3 control-label">' . $_LANG['Price'] . '</label>'
							.				'<div class="cb_field col-sm-9">'
							.					$input['price']
							.					getFieldIcons( 1, 0, null, $_LANG['Input price']  )
							.				'</div>'
							.			'</div>';
                        
		}

		if ( $cbModerator ) {
			$return			.=			'<div class="cbft_text cbtt_input form-group cb_form_line clearfix">'
							.				'<label for="user" class="col-sm-3 control-label">' . CBTxt::T( 'Owner' ) . '</label>'
							.				'<div class="cb_field col-sm-9">'
							.					$input['user']
							.					getFieldIcons( 1, 1, null, '' )
							.				'</div>'
							.			'</div>';
		}

		if ( $plugin->params->get( 'hangout_captcha', 0 ) && ( ! $cbModerator ) ) {
			$_PLUGINS->loadPluginGroup( 'user' );

			$captcha		=	$_PLUGINS->trigger( 'onGetCaptchaHtmlElements', array( false ) );

			if ( ! empty( $captcha ) ) {
				$captcha	=	$captcha[0];

				$return		.=			'<div class="form-group cb_form_line clearfix">'
							.				'<label class="col-sm-3 control-label">' . CBTxt::Th( 'Captcha' ) . '</label>'
							.				'<div class="cb_field col-sm-9">'
							.					( isset( $captcha[0] ) ? $captcha[0] : null )
							.				'</div>'
							.			'</div>'
							.			'<div class="form-group cb_form_line clearfix">'
							.				'<div class="cb_field col-sm-offset-3 col-sm-9">'
							.					str_replace( 'inputbox', 'form-control', ( isset( $captcha[1] ) ? $captcha[1] : null ) )
							.					getFieldIcons( 1, 1, null )
							.				'</div>'
							.			'</div>';
			}
		}

		$return				.=			'<div class="form-group cb_form_line clearfix">'
							.				'<div class="col-sm-offset-3 col-sm-9">'
							.					'<input type="submit" value="' . htmlspecialchars( ( $row->get( 'id' ) ? $_LANG["Update Hangout"] : $_LANG["Create Hangout"] ) ) . '" class="blogsButton blogsButtonSubmit btn btn-primary"' . cbValidator::getSubmitBtnHtmlAttributes() . ' />&nbsp;'
							.					' <input type="button" value="' . htmlspecialchars( CBTxt::T( 'Cancel' ) ) . '" class="blogsButton blogsButtonCancel btn btn-default" onclick="if ( confirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to cancel? All unsaved data will be lost!' ) ) . '\' ) ) { location.href = \'' . $_CB_framework->userProfileUrl( $row->get( 'user', $user->get( 'id' ) ), false, 'cbhangoutTab' ) . '\'; }" />'
							.				'</div>'
							.			'</div>'
							.			cbGetSpoofInputTag( 'plugin' )
							.		'</form>'
							.	'</div>';

		echo $return;
	}
Ejemplo n.º 15
0
 /**
  * Renders the header of the menu group
  *
  * @param  SimpleXMLElement  $param
  * @param  string              $htmlFormatting
  * @return string
  */
 protected function renderMenuGroupHeader(&$param, $htmlFormatting)
 {
     $html = array();
     $legend = $param->attributes('label');
     $description = $param->attributes('description');
     $cssclass = RegistryEditView::buildClasses($param);
     if ($htmlFormatting == 'table') {
         $html[] = '<tr><td colspan="3" style="width: 100%;"' . ($cssclass ? ' class="' . htmlspecialchars($cssclass) . '"' : '') . '>';
     } elseif ($htmlFormatting == 'td') {
         $html[] = '<td' . ($cssclass ? ' class="' . htmlspecialchars($cssclass) . '"' : '') . '>';
     }
     if ($legend) {
         $html[] = '<h2>' . CBTxt::Th($legend) . '</h2>';
     }
     if ($htmlFormatting == 'table') {
         $html[] = '<table class="table table-noborder">';
         if ($description) {
             $html[] = '<tr><td colspan="3" style="width: 100%;"><strong>' . CBTxt::Th($description) . '</strong></td></tr>';
         }
     } elseif ($htmlFormatting == 'td') {
         if ($description) {
             $html[] = '<td colspan="3" style="width: 100%;"><strong>' . CBTxt::Th($description) . '</strong></td>';
         }
     } else {
         if ($description) {
             $html[] = '<strong>' . CBTxt::Th($description) . '</strong>';
         }
     }
     if (!in_array($htmlFormatting, array('table', 'td'))) {
         $html[] = '<div class="cbButtonMenu' . ($cssclass ? ' ' . htmlspecialchars($cssclass) : '') . '">';
     }
     return implode('', $html);
 }
Ejemplo n.º 16
0
	/**
	 * @param cbinvitesInviteTable $row
	 * @param array                $input
	 * @param UserTable            $user
	 * @param cbPluginHandler      $plugin
	 */
	static function showInviteEdit( $row, $input, $user, $plugin )
	{
		global $_CB_framework, $_PLUGINS;

		cbValidator::loadValidation();

		$cbModerator		=	Application::User( (int) $user->get( 'id' ) )->isGlobalModerator();
		$pageTitle			=	( $row->get( 'to' ) ? CBTxt::T( 'Edit Invite' ) : CBTxt::T( 'Create Invite' ) );

		$_CB_framework->setPageTitle( $pageTitle );
		$_CB_framework->appendPathWay( htmlspecialchars( CBTxt::T( 'Invites' ) ), $_CB_framework->userProfileUrl( $row->get( 'user', $user->get( 'id' ) ), true, 'cbinvitesTab' ) );
		$_CB_framework->appendPathWay( htmlspecialchars( $pageTitle ), $_CB_framework->pluginClassUrl( $plugin->element, true, ( $row->get( 'id' ) ? array( 'action' => 'invites', 'func' => 'edit', 'id' => (int) $row->get( 'id' ) ) : array( 'action' => 'invites', 'func' => 'new' ) ) ) );

		initToolTip();

		$return				=	'<div class="invitesEdit">'
							.		'<form action="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'invites', 'func' => 'save', 'id' => (int) $row->get( 'id' ) ) ) . '" method="post" enctype="multipart/form-data" name="invitesForm" id="invitesForm" class="cb_form invitesForm form-auto cbValidation">'
							.			( $pageTitle ? '<div class="invitesTitle page-header"><h3>' . $pageTitle . '</h3></div>' : null )
							.			'<div class="cbft_text cbtt_input form-group cb_form_line clearfix">'
							.				'<label for="to" class="col-sm-3 control-label">' . CBTxt::T( 'To' ) . '</label>'
							.				'<div class="cb_field col-sm-9">'
							.					$input['to']
							.					getFieldIcons( 1, 1, null, ( $plugin->params->get( 'invite_multiple', 1 ) ? CBTxt::T( 'Input invite email to address. Separate multiple email addresses with a comma.' ) : CBTxt::T( 'Input invite email to address.' ) ) )
							.				'</div>'
							.			'</div>'
							.			'<div class="cbft_text cbtt_input form-group cb_form_line clearfix">'
							.				'<label for="subject" class="col-sm-3 control-label">' . CBTxt::T( 'Subject' ) . '</label>'
							.				'<div class="cb_field col-sm-9">'
							.					$input['subject']
							.					getFieldIcons( 1, 0, null, CBTxt::T( 'Input invite email subject; if left blank a subject will be applied.' ) )
							.				'</div>'
							.			'</div>'
							.			'<div class="cbft_textarea cbtt_textarea form-group cb_form_line clearfix">'
							.				'<label for="body" class="col-sm-3 control-label">' . CBTxt::T( 'Body' ) . '</label>'
							.				'<div class="cb_field col-sm-9">'
							.					$input['body']
							.					getFieldIcons( 1, 0, null, CBTxt::T( 'Optionally input private message to include with invite email.' ) )
							.				'</div>'
							.			'</div>';

		if ( $cbModerator ) {
			$return			.=			'<div class="cbft_text cbtt_input form-group cb_form_line clearfix">'
							.				'<label for="user_id" class="col-sm-3 control-label">' . CBTxt::T( 'Owner' ) . '</label>'
							.				'<div class="cb_field col-sm-9">'
							.					$input['user_id']
							.					getFieldIcons( 1, 1, null, CBTxt::T( 'Input owner of invite as single integer user_id. This is the user who sent the invite.' ) )
							.				'</div>'
							.			'</div>'
							.			'<div class="cbft_text cbtt_input form-group cb_form_line clearfix">'
							.				'<label for="user" class="col-sm-3 control-label">' . CBTxt::T( 'User' ) . '</label>'
							.				'<div class="cb_field col-sm-9">'
							.					$input['user']
							.					getFieldIcons( 1, 0, null, CBTxt::T( 'Optionally input user of invite as single integer user_id. This is the user who accepted the invite.' ) )
							.				'</div>'
							.			'</div>';
		}

		if ( $plugin->params->get( 'invite_captcha', 0 ) && ( ! $cbModerator ) ) {
			$_PLUGINS->loadPluginGroup( 'user' );

			$captcha		=	$_PLUGINS->trigger( 'onGetCaptchaHtmlElements', array( false ) );

			if ( ! empty( $captcha ) ) {
				$captcha	=	$captcha[0];

				$return		.=			'<div class="form-group cb_form_line clearfix">'
							.				'<label class="col-sm-3 control-label">' . CBTxt::Th( 'Captcha' ) . '</label>'
							.				'<div class="cb_field col-sm-9">'
							.					( isset( $captcha[0] ) ? $captcha[0] : null )
							.				'</div>'
							.			'</div>'
							.			'<div class="form-group cb_form_line clearfix">'
							.				'<div class="cb_field col-sm-offset-3 col-sm-9">'
							.					str_replace( 'inputbox', 'form-control', ( isset( $captcha[1] ) ? $captcha[1] : null ) )
							.					getFieldIcons( 1, 1, null )
							.				'</div>'
							.			'</div>';
			}
		}

		$return				.=			'<div class="form-group cb_form_line clearfix">'
							.				'<div class="col-sm-offset-3 col-sm-9">'
							.					'<input type="submit" value="' . htmlspecialchars( ( $row->get( 'id' ) ? CBTxt::T( 'Update Invite' ) : CBTxt::T( 'Send Invite' ) ) ) . '" class="invitesButton invitesButtonSubmit btn btn-primary"' . cbValidator::getSubmitBtnHtmlAttributes() . ' />&nbsp;'
							.					' <input type="button" value="' . htmlspecialchars( CBTxt::T( 'Cancel' ) ) . '" class="invitesButton invitesButtonCancel btn btn-default" onclick="if ( confirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to cancel? All unsaved data will be lost!' ) ) . '\' ) ) { location.href = \'' . $_CB_framework->userProfileUrl( $row->get( 'user', $user->get( 'id' ) ), false, 'cbinvitesTab' ) . '\'; }" />'
							.				'</div>'
							.			'</div>'
							.			cbGetSpoofInputTag( 'plugin' )
							.		'</form>'
							.	'</div>';

		echo $return;
	}
 /**
  * @param  array       $connections
  * @param  array       $actions
  * @param  int         $total
  * @param  cbTabs      $connMgmtTabs
  * @param  array       $pagingParams
  * @param  int         $perpage
  * @param  array|null  $connecteds
  */
 static function manageConnections($connections, $actions, $total, &$connMgmtTabs, &$pagingParams, $perpage, $connecteds = null)
 {
     global $_CB_framework, $ueConfig, $_PLUGINS, $_REQUEST;
     $results = $_PLUGINS->trigger('onBeforeManageConnectionsFormDisplay', array(&$connections, &$actions, &$total, &$connMgmtTabs, &$pagingParams, &$perpage, &$connecteds));
     if ($_PLUGINS->is_errors()) {
         echo "<script type=\"text/javascript\">alert(\"" . $_PLUGINS->getErrorMSG() . "\"); window.history.go(-1); </script>\n";
         exit;
     }
     outputCbTemplate(1);
     initToolTip(1);
     cbValidator::loadValidation();
     $js = "if ( typeof confirmSubmit != 'function' ) {" . "function confirmSubmit() {" . "if ( confirm( '" . addslashes(CBTxt::T('UE_CONFIRMREMOVECONNECTION', 'Are you sure you want to remove this connection?')) . "' ) ) {" . "return true;" . "} else {" . "return false;" . "}" . "};" . "}";
     $_CB_framework->document->addHeadScriptDeclaration($js);
     $connectionCategories = explode("\n", $ueConfig['connection_categories']);
     $connectionTypes = array();
     if ($connectionCategories) {
         foreach ($connectionCategories as $connectionCategory) {
             if (trim($connectionCategory) != null && trim($connectionCategory) != "") {
                 $connectionTypes[] = moscomprofilerHTML::makeOption(trim($connectionCategory), CBTxt::T(trim($connectionCategory)));
             }
         }
     }
     $tabs = new cbTabs(0, 1);
     $pageClass = $_CB_framework->getMenuPageClass();
     $return = '<div class="cbManageConnections cb_template cb_template_' . selectTemplate('dir') . ($pageClass ? ' ' . htmlspecialchars($pageClass) : null) . '">';
     if (is_array($results)) {
         $return .= implode('', $results);
     }
     $return .= '<div class="page-header"><h3>' . CBTxt::Th('UE_MANAGECONNECTIONS', 'Manage Connections') . '</h3></div>' . $tabs->startPane('myCon') . $tabs->startTab('myCon', CBTxt::Th('UE_MANAGEACTIONS', 'Manage Actions') . ' <span class="badge">' . count($actions) . '</span>', 'action');
     if (!count($actions) > 0) {
         $return .= '<div class="form-group cb_form_line clearfix tab_description">' . CBTxt::Th('UE_NOACTIONREQUIRED', 'No Pending Actions') . '</div>' . '<div class="form-group cb_form_line clearfix">' . '<input type="button" class="btn btn-default cbMngConnCancel" value="' . htmlspecialchars(CBTxt::Th('UE_CANCEL', 'Cancel')) . '" onclick="window.location=\'' . $_CB_framework->userProfileUrl() . '\'; return false;" />' . '</div>';
     } else {
         $return .= '<form action="' . $_CB_framework->viewUrl('processconnectionactions') . '" method="post" id="adminForm" name="adminForm" class="cb_form form-auto cbValidation">' . '<div class="form-group cb_form_line clearfix tab_description">' . CBTxt::Th('UE_CONNECT_ACTIONREQUIRED', 'Below you see users proposing to connect with you. You have the choice to accept or decline their request.') . '</div>' . '<div class="table">';
         foreach ($actions as $action) {
             $cbUser = CBuser::getInstance((int) $action->id, false);
             $tipField = '<b>' . CBTxt::Th('UE_CONNECTIONREQUIREDON', 'Connection Required on') . '</b>: ' . $_CB_framework->getUTCDate(array($ueConfig['date_format'], 'Y-m-d'), $action->membersince);
             if ($action->reason != null) {
                 $tipField .= '<br /><b>' . CBTxt::Th('UE_CONNECTIONMESSAGE', 'Personal message included') . '</b>: <br />' . htmlspecialchars($action->reason, ENT_QUOTES);
             }
             $tipTitle = CBTxt::Th('UE_CONNECTIONREQUESTDETAIL', 'Connection Request Details');
             $htmlText = $cbUser->getField('avatar', null, 'html', 'none', 'list', 0, true);
             $tooltip = cbTooltip(1, $tipField, $tipTitle, 300, null, $htmlText, null, 'style="display: inline-block; padding: 5px;"');
             $return .= '<div class="containerBox img-thumbnail">' . '<div class="containerBoxInner" style="min-height: 130px; min-width: 90px;">' . $cbUser->getField('onlinestatus', null, 'html', 'none', 'profile', 0, true, array('_imgMode' => 1)) . ' ' . $cbUser->getField('formatname', null, 'html', 'none', 'list', 0, true) . '<br />' . $tooltip . '<br />' . '<span class="fa fa-check" title="' . htmlspecialchars(CBTxt::T('UE_ACCEPTCONNECTION', 'Accept Connection')) . '"></span>' . ' <input type="radio" name="' . (int) $action->id . 'action" value="a" checked="checked" />' . ' <span class="fa fa-times" title="' . htmlspecialchars(CBTxt::T('UE_DECLINECONNECTION', 'Decline Connection')) . '"></span>' . ' <input type="radio" name="' . (int) $action->id . 'action" value="d" />' . '<input type="hidden" name="uid[]" value="' . (int) $action->id . '" />' . '</div>' . '</div>';
         }
         $return .= '</div>' . '<div class="form-group cb_form_line clearfix">' . '<input type="submit" class="btn btn-primary cbMngConnSubmit" value="' . htmlspecialchars(CBTxt::Th('UE_UPDATE', 'Update')) . '"' . cbValidator::getSubmitBtnHtmlAttributes() . ' />' . ' <input type="button" class="btn btn-default cbMngConnCancel" value="' . htmlspecialchars(CBTxt::Th('UE_CANCEL', 'Cancel')) . '" onclick="window.location=\'' . $_CB_framework->userProfileUrl() . '\'; return false;" />' . '</div>' . cbGetSpoofInputTag('manageconnections') . '</form>';
     }
     $return .= $tabs->endTab() . $tabs->startTab('myCon', CBTxt::Th('UE_MANAGECONNECTIONS', 'Manage Connections'), 'connections');
     if (!count($connections) > 0) {
         $return .= '<div class="form-group cb_form_line clearfix tab_description">' . CBTxt::Th('UE_NOCONNECTIONS', 'This user has no current connections.') . '</div>' . '<div class="form-group cb_form_line clearfix">' . '<input type="button" class="btn btn-default cbMngConnCancel" value="' . htmlspecialchars(CBTxt::Th('UE_CANCEL', 'Cancel')) . '" onclick="window.location=\'' . $_CB_framework->userProfileUrl() . '\'; return false;" />' . '</div>';
     } else {
         $return .= '<form action="' . $_CB_framework->viewUrl('saveconnections') . '" method="post" id="adminForm" name="adminForm" class="cb_form form-auto cbValidation">' . '<div class="form-group cb_form_line clearfix tab_description">' . CBTxt::Th('UE_CONNECT_MANAGECONNECTIONS', 'Below you see users to whom you are connected directly. ') . '</div>' . '<table class="table table-hover table-responsive">' . '<thead>' . '<tr>' . '<th style="width: 25%;" class="text-center">' . CBTxt::Th('UE_CONNECTION', 'Connections') . '</th>' . '<th style="width: 35%;" class="text-center">' . CBTxt::Th('UE_CONNECTIONTYPE', 'Type') . '</th>' . '<th style="width: 40%;" class="text-center">' . CBTxt::Th('UE_CONNECTIONCOMMENT', 'Comment') . '</th>' . '</tr>' . '</thead>' . '<tbody>';
         $i = 1;
         foreach ($connections as $connection) {
             $cbUser = CBuser::getInstance((int) $connection->id, false);
             $tipField = '<b>' . CBTxt::Th('UE_CONNECTEDSINCE', 'Connected Since') . '</b>: ' . $_CB_framework->getUTCDate(array($ueConfig['date_format'], 'Y-m-d'), $connection->membersince);
             if ($connection->type != null) {
                 $tipField .= '<br /><b>' . CBTxt::Th('UE_CONNECTIONTYPE', 'Type') . '</b>: ' . getConnectionTypes($connection->type);
             }
             if ($connection->description != null) {
                 $tipField .= '<br /><b>' . CBTxt::Th('UE_CONNECTEDCOMMENT', 'Comment') . '</b>: ' . htmlspecialchars($connection->description);
             }
             $tipTitle = CBTxt::Th('UE_CONNECTEDDETAIL', 'Connection Details');
             $htmlText = $cbUser->getField('avatar', null, 'html', 'none', 'list', 0, true);
             $tooltip = cbTooltip(1, $tipField, $tipTitle, 300, null, $htmlText, null, 'style="display: inline-block; padding: 5px;"');
             if ($connection->accepted == 1 && $connection->pending == 1) {
                 $actionImg = '<span class="fa fa-clock-o" title="' . htmlspecialchars(CBTxt::T('UE_CONNECTIONPENDING', 'Connection Pending')) . '"></span>' . ' <a href="' . $_CB_framework->viewUrl('removeconnection', true, array('act' => 'manage', 'connectionid' => (int) $connection->memberid)) . '" onclick="return confirmSubmit();" >' . '<span class="fa fa-times-circle-o" title="' . htmlspecialchars(CBTxt::T('UE_REMOVECONNECTION', 'Remove Connection')) . '"></span>' . '</a>';
             } elseif ($connection->accepted == 1 && $connection->pending == 0) {
                 $actionImg = '<a href="' . $_CB_framework->viewUrl('removeconnection', true, array('act' => 'manage', 'connectionid' => (int) $connection->memberid)) . '" onclick="return confirmSubmit();" >' . '<span class="fa fa-times-circle-o" title="' . htmlspecialchars(CBTxt::T('UE_REMOVECONNECTION', 'Remove Connection')) . '"></span>' . '</a>';
             } elseif ($connection->accepted == 0) {
                 $actionImg = '<a href="' . $_CB_framework->viewUrl('acceptconnection', true, array('act' => 'manage', 'connectionid' => (int) $connection->memberid)) . '" onclick="return confirmSubmit();" >' . '<span class="fa fa-check-circle-o" title="' . htmlspecialchars(CBTxt::T('UE_ACCEPTCONNECTION', 'Accept Connection')) . '"></span>' . '</a>' . ' <a href="' . $_CB_framework->viewUrl('removeconnection', true, array('act' => 'manage', 'connectionid' => (int) $connection->memberid)) . '" onclick="return confirmSubmit();" >' . '<span class="fa fa-times-circle-o" title="' . htmlspecialchars(CBTxt::T('UE_REMOVECONNECTION', 'Remove Connection')) . '"></span>' . '</a>';
             } else {
                 $actionImg = null;
             }
             $return .= '<tr>' . '<td class="text-center">' . $cbUser->getField('onlinestatus', null, 'html', 'none', 'profile', 0, true, array('_imgMode' => 1)) . ' ' . $cbUser->getField('formatname', null, 'html', 'none', 'list', 0, true) . '<br />' . $tooltip . '<br />' . $actionImg . ' <a href="' . $_CB_framework->userProfileUrl((int) $connection->memberid) . '">' . '<span class="fa fa-user" title="' . htmlspecialchars(CBTxt::T('UE_VIEWPROFILE', 'View Profile')) . '"></span>' . '</a>' . ' ' . $cbUser->getField('email', null, 'html', 'none', 'profile', 0, true, array('_imgMode' => 1)) . ' ' . $cbUser->getField('pm', null, 'html', 'none', 'profile', 0, true, array('_imgMode' => 1)) . '</td>' . '<td class="text-center">' . moscomprofilerHTML::selectList($connectionTypes, $connection->id . 'connectiontype[]', 'class="form-control" multiple="multiple" size="5"', 'value', 'text', explode('|*|', trim($connection->type)), 0) . '</td>' . '<td class="text-center">' . '<textarea cols="25" class="form-control"  rows="5" name="' . (int) $connection->id . 'description">' . htmlspecialchars($connection->description) . '</textarea>' . '<input type="hidden" name="uid[]" value="' . (int) $connection->id . '" />' . '</td>' . '</tr>';
             $i = $i == 1 ? 2 : 1;
         }
         $return .= '</tbody>' . '</table>';
         if ($perpage < $total) {
             $return .= '<div class="form-group cb_form_line text-center clearfix">' . $connMgmtTabs->_writePaging($pagingParams, 'connections_', $perpage, $total, 'manageconnections') . '</div>';
         }
         $return .= '<div class="form-group cb_form_line clearfix">' . '<input type="submit" class="btn btn-primary cbMngConnSubmit" value="' . htmlspecialchars(CBTxt::Th('UE_UPDATE', 'Update')) . '"' . cbValidator::getSubmitBtnHtmlAttributes() . ' />' . ' <input type="button" class="btn btn-default cbMngConnCancel" value="' . htmlspecialchars(CBTxt::Th('UE_CANCEL', 'Cancel')) . '" onclick="window.location=\'' . $_CB_framework->userProfileUrl() . '\'; return false;" />' . '</div>' . cbGetSpoofInputTag('manageconnections') . '</form>';
     }
     $return .= $tabs->endTab();
     if ($ueConfig['autoAddConnections'] == 0) {
         $return .= $tabs->startTab('myCon', CBTxt::Th('UE_CONNECTEDWITH', 'Manage Connections With Me'), 'connected');
         if (!count($connecteds) > 0) {
             $return .= '<div class="form-group cb_form_line clearfix tab_description">' . CBTxt::Th('UE_NOCONNECTEDWITH', 'There are currently no users connected with you.') . '</div>' . '<div class="form-group cb_form_line clearfix">' . '<input type="button" class="btn btn-default cbMngConnCancel" value="' . htmlspecialchars(CBTxt::Th('UE_CANCEL', 'Cancel')) . '" onclick="window.location=\'' . $_CB_framework->userProfileUrl() . '\'; return false;" />' . '</div>';
         } else {
             $htmlConnectedWidth = CBTxt::Th('UE_CONNECT_CONNECTEDWITH', '');
             $return .= ($htmlConnectedWidth ? '<div class="form-group cb_form_line clearfix tab_description">' . $htmlConnectedWidth . '</div>' : null) . '<div class="table">';
             foreach ($connecteds as $connected) {
                 $cbUser = CBuser::getInstance((int) $connected->id, false);
                 $tipField = '<b>' . CBTxt::Th('UE_CONNECTEDSINCE', 'Connected Since') . '</b>: ' . $_CB_framework->getUTCDate(array($ueConfig['date_format'], 'Y-m-d'), $connected->membersince);
                 if ($connected->type != null) {
                     $tipField .= '<br /><b>' . CBTxt::Th('UE_CONNECTIONTYPE', 'Type') . '</b>: ' . getConnectionTypes($connected->type);
                 }
                 if ($connected->description != null) {
                     $tipField .= '<br /><b>' . CBTxt::Th('UE_CONNECTEDCOMMENT', 'Comment') . '</b>: ' . htmlspecialchars($connected->description);
                 }
                 $tipTitle = CBTxt::Th('UE_CONNECTEDDETAIL', 'Connection Details');
                 $htmlText = $cbUser->getField('avatar', null, 'html', 'none', 'list', 0, true);
                 $tooltip = cbTooltip(1, $tipField, $tipTitle, 300, null, $htmlText, null, 'style="padding: 5px;"');
                 if ($connected->accepted == 1 && $connected->pending == 1) {
                     $actionImg = '<span class="fa fa-clock-o" title="' . htmlspecialchars(CBTxt::T('UE_CONNECTIONPENDING', 'Connection Pending')) . '"></span>' . ' <a href="' . $_CB_framework->viewUrl('removeconnection', true, array('act' => 'manage', 'connectionid' => (int) $connected->memberid)) . '" >' . '<span class="fa fa-times-circle-o" title="' . htmlspecialchars(CBTxt::T('UE_REMOVECONNECTION', 'Remove Connection')) . '"></span>' . '</a>';
                 } elseif ($connected->accepted == 1 && $connected->pending == 0) {
                     $actionImg = '<a href="' . $_CB_framework->viewUrl('denyconnection', true, array('act' => 'manage', 'connectionid' => (int) $connected->referenceid)) . '" >' . '<span class="fa fa-times-circle-o" title="' . htmlspecialchars(CBTxt::T('UE_REMOVECONNECTION', 'Remove Connection')) . '"></span>' . '</a>';
                 } elseif ($connected->accepted == 0) {
                     $actionImg = '<a href="' . $_CB_framework->viewUrl('acceptconnection', true, array('act' => 'manage', 'connectionid' => (int) $connected->referenceid)) . '" >' . '<span class="fa fa-check-circle-o" title="' . htmlspecialchars(CBTxt::T('UE_ACCEPTCONNECTION', 'Accept Connection')) . '"></span>' . '</a>' . ' <a href="' . $_CB_framework->viewUrl('denyconnection', true, array('act' => 'manage', 'connectionid' => (int) $connected->referenceid)) . '" >' . '<span class="fa fa-times-circle-o" title="' . htmlspecialchars(CBTxt::T('UE_REMOVECONNECTION', 'Remove Connection')) . '"></span>' . '</a>';
                 } else {
                     $actionImg = null;
                 }
                 $return .= '<div class="containerBox img-thumbnail">' . '<div class="containerBoxInner" style="min-height: 130px; min-width: 90px;">' . $actionImg . '<br />' . $cbUser->getField('onlinestatus', null, 'html', 'none', 'profile', 0, true, array('_imgMode' => 1)) . ' ' . $cbUser->getField('formatname', null, 'html', 'none', 'list', 0, true) . '<br />' . $tooltip . '<br />' . ' <a href="' . $_CB_framework->userProfileUrl((int) $connected->referenceid) . '">' . '<span class="fa fa-user" title="' . htmlspecialchars(CBTxt::T('UE_VIEWPROFILE', 'View Profile')) . '"></span>' . '</a>' . ' ' . $cbUser->getField('email', null, 'html', 'none', 'profile', 0, true, array('_imgMode' => 1)) . ' ' . $cbUser->getField('pm', null, 'html', 'none', 'profile', 0, true, array('_imgMode' => 1)) . '</div>' . '</div>';
             }
             $return .= '</div>' . '<div class="form-group cb_form_line clearfix">' . '<input type="button" class="btn btn-default cbMngConnCancel" value="' . htmlspecialchars(CBTxt::Th('UE_CANCEL', 'Cancel')) . '" onclick="window.location=\'' . $_CB_framework->userProfileUrl() . '\'; return false;" />' . '</div>';
         }
         $return .= $tabs->endTab();
     }
     $return .= $tabs->endPane() . '</div>' . cbPoweredBy();
     echo $return;
     $_CB_framework->setMenuMeta();
 }
Ejemplo n.º 18
0
 /**
  * Outputs legacy user mass mailer and user reconfirm email display
  *
  * @param  string  $option
  * @param  string  $task
  * @param  int[]   $cid
  * @return bool
  * @deprecated 2.0
  */
 public function showUsers($option, $task, $cid)
 {
     global $_CB_framework, $_CB_database, $ueConfig, $_PLUGINS;
     cbimport('language.all');
     cbimport('cb.tabs');
     cbimport('cb.params');
     cbimport('cb.pagination');
     cbimport('cb.lists');
     // We just need the user rows as we've already filtered down the IDs in user management:
     $query = 'SELECT *' . "\n FROM " . $_CB_database->NameQuote('#__comprofiler') . " AS c" . "\n INNER JOIN " . $_CB_database->NameQuote('#__users') . " AS u" . ' ON u.' . $_CB_database->NameQuote('id') . ' = c.' . $_CB_database->NameQuote('id') . "\n WHERE u." . $_CB_database->NameQuote('id') . " IN ( " . implode(', ', cbArrayToInts($cid)) . " )";
     $_CB_database->setQuery($query);
     $rows = $_CB_database->loadObjectList(null, '\\CB\\Database\\Table\\UserTable', array($_CB_database));
     $total = count($rows);
     if ($task == 'resendconfirmationemails') {
         if (!$rows) {
             cbRedirect($_CB_framework->backendViewUrl('showusers', false), CBTxt::T('SELECT_A_ROW_TO_TASK', 'Select a row to [task]', array('[task]' => $task)), 'error');
         }
         $count = 0;
         /** @var UserTable[] $rows */
         foreach ($rows as $row) {
             if ($row->confirmed == 0) {
                 if ($row->cbactivation == '') {
                     // Generate a new confirmation code if the user doesn't have one (requires email confirmation to be enabled):
                     $row->store();
                 }
                 $cbNotification = new cbNotification();
                 $cbNotification->sendFromSystem($row->id, CBTxt::T($ueConfig['reg_pend_appr_sub']), CBTxt::T($ueConfig['reg_pend_appr_msg']), true, isset($ueConfig['reg_email_html']) ? (int) $ueConfig['reg_email_html'] : 0);
                 ++$count;
             }
         }
         cbRedirect($_CB_framework->backendViewUrl('showusers', false), CBTxt::T('SENT_CONFIRMATION_EMAILS_TO_NUM_USERS_USERS', 'Sent confirmation emails to [NUM_USERS] users', array('[NUM_USERS]' => $count)));
     } else {
         $emailSubject = stripslashes(cbGetParam($_POST, 'emailsubject', ''));
         $emailBody = stripslashes(rawurldecode(cbGetParam($_POST, 'emailbody', '', _CB_ALLOWRAW | _CB_NOTRIM)));
         $emailAttach = stripslashes(cbGetParam($_POST, 'emailattach', ''));
         $emailsPerBatch = stripslashes(cbGetParam($_POST, 'emailsperbatch', 50));
         $emailsBatch = stripslashes(cbGetParam($_POST, 'emailsbatch', 0));
         $emailFromName = stripslashes(cbGetParam($_POST, 'emailfromname', ''));
         $emailFromAddr = stripslashes(cbGetParam($_POST, 'emailfromaddr', ''));
         $emailReplyName = stripslashes(cbGetParam($_POST, 'emailreplyname', ''));
         $emailReplyAddr = stripslashes(cbGetParam($_POST, 'emailreplyaddr', ''));
         $emailPause = stripslashes(cbGetParam($_POST, 'emailpause', 30));
         $simulationMode = stripslashes(cbGetParam($_POST, 'simulationmode', ''));
         // B/C trigger variables:
         if (count($cid) > 0 && count($cid) < $total) {
             $total = count($cid);
         }
         $pageNav = new cbPageNav($total, 0, 10);
         $search = '';
         $lists = array();
         $inputTextExtras = null;
         $select_tag_attribs = null;
         if ($task == 'emailusers') {
             if (!$rows) {
                 cbRedirect($_CB_framework->backendViewUrl('showusers', false), CBTxt::T('SELECT_A_ROW_TO_TASK', 'Select a row to [task]', array('[task]' => $task)), 'error');
             }
             $pluginRows = $_PLUGINS->trigger('onBeforeBackendUsersEmailForm', array(&$rows, &$pageNav, &$search, &$lists, &$cid, &$emailSubject, &$emailBody, &$inputTextExtras, &$select_tag_attribs, $simulationMode, $option, &$emailAttach, &$emailFromName, &$emailFromAddr, &$emailReplyName, &$emailReplyAddr));
             $usersView = _CBloadView('users');
             /** @var CBView_users $usersView */
             $usersView->emailUsers($rows, $emailSubject, $emailBody, $emailAttach, $emailFromName, $emailFromAddr, $emailReplyName, $emailReplyAddr, $emailsPerBatch, $emailsBatch, $emailPause, $simulationMode, $pluginRows);
         } elseif ($task == 'startemailusers') {
             $pluginRows = $_PLUGINS->trigger('onBeforeBackendUsersEmailStart', array(&$rows, $total, $search, $lists, $cid, &$emailSubject, &$emailBody, &$inputTextExtras, $simulationMode, $option, &$emailAttach, &$emailFromName, &$emailFromAddr, &$emailReplyName, &$emailReplyAddr));
             $usersView = _CBloadView('users');
             /** @var CBView_users $usersView */
             $usersView->startEmailUsers($rows, $emailSubject, $emailBody, $emailAttach, $emailFromName, $emailFromAddr, $emailReplyName, $emailReplyAddr, $emailsPerBatch, $emailsBatch, $emailPause, $simulationMode, $pluginRows);
         } elseif ($task == 'ajaxemailusers') {
             cbSpoofCheck('cbadmingui');
             cbRegAntiSpamCheck();
             $cbNotification = new cbNotification();
             $mode = 1;
             // html
             $errors = 0;
             $success = array();
             $failed = array();
             $users = array_slice($rows, $emailsBatch, $emailsPerBatch);
             if ($simulationMode) {
                 $success = array('<div class="alert alert-info">' . CBTxt::T('Emails do not send in simulation mode') . '</div>');
             } else {
                 foreach ($users as $user) {
                     $extraStrings = array();
                     $_PLUGINS->trigger('onBeforeBackendUserEmail', array(&$user, &$emailSubject, &$emailBody, $mode, &$extraStrings, $simulationMode, &$emailAttach, &$emailFromName, &$emailFromAddr, &$emailReplyName, &$emailReplyAddr));
                     $attachments = cbReplaceVars($emailAttach, $user, $mode, true, $extraStrings);
                     if ($attachments) {
                         $attachments = preg_split(' *, *', $attachments);
                     } else {
                         $attachments = null;
                     }
                     if (!$cbNotification->sendFromSystem($user, $emailSubject, $this->makeLinksAbsolute($emailBody), true, $mode, null, null, $attachments, $extraStrings, false, $emailFromName, $emailFromAddr, $emailReplyName, $emailReplyAddr)) {
                         $failed[] = '<div class="alert alert-danger">' . '<strong>' . htmlspecialchars($user->name . ' <' . $user->email . '>') . '</strong>: ' . CBTxt::Th('ERROR_SENDING_EMAIL_ERRORMSG', 'Error sending email: [ERROR_MSG]', array('[ERROR_MSG]' => $cbNotification->errorMSG)) . '</div>';
                         ++$errors;
                     } else {
                         $success[] = htmlspecialchars($user->name . ' <' . $user->email . '>');
                     }
                 }
             }
             $usernames = implode(', ', $success) . implode('', $failed);
             if ($total < $emailsPerBatch) {
                 $limit = $total;
             } else {
                 $limit = $emailsPerBatch;
             }
             ob_start();
             $usersView = _CBloadView('users');
             /** @var CBView_users $usersView */
             $usersView->ajaxResults($usernames, $emailSubject, $this->makeLinksAbsolute($emailBody), $emailAttach, $emailFromName, $emailFromAddr, $emailReplyName, $emailReplyAddr, $emailsBatch, $limit, $total, $errors);
             $html = ob_get_contents();
             ob_end_clean();
             $reply = array('result' => 1, 'htmlcontent' => $html);
             if (!($total - ((int) $emailsBatch + (int) $emailsPerBatch) > 0)) {
                 $reply['result'] = 2;
             }
             echo json_encode($reply);
         }
     }
 }
Ejemplo n.º 19
0
 /**
  * Returns HTML for "install from discovery" tab
  * Used by Backend XML only
  * @deprecated Do not use directly, only for XML tabs backend
  *
  * @return string
  */
 public function displayDiscoveries()
 {
     global $_CB_framework, $_CB_database;
     // Prepare array of discovered plugins (not installed, but exists):
     $allPlgsFolders = array();
     $discoveredPlgs = array();
     $existingPlgList = array();
     $existingPlgFolders = array();
     $failingXmlFiles = array();
     // Discovers all installed plugins
     $query = 'SELECT ' . $_CB_database->NameQuote('folder') . ', ' . $_CB_database->NameQuote('type') . "\n FROM " . $_CB_database->NameQuote('#__comprofiler_plugin');
     $_CB_database->setQuery($query);
     $existingPlgs = $_CB_database->loadAssocList();
     // Constructs list of installed plugins': 1) folders by type ($existingPlgList) and 2) list of installed folder paths ($existingPlgFolders)
     foreach ($existingPlgs as $existingPlg) {
         $plgType = $existingPlg['type'];
         $existingPlgList[$plgType][] = $existingPlg['folder'];
         $existingPlgFolders[] = $existingPlg['type'] . '/' . $existingPlg['folder'];
     }
     // Discovers inside each type all the directories:
     foreach ($existingPlgList as $plgType => $existingPlgs) {
         $plgFolders = array_filter(cbReadDirectory($_CB_framework->getCfg('absolute_path') . '/components/com_comprofiler/plugin/' . $plgType), function ($subSubFolder) {
             return !in_array($subSubFolder, array('index.html', 'default'));
         });
         // Adds each directory of each type to the list of checks:
         foreach ($plgFolders as $plgFolder) {
             $plgFolderAndType = $plgType . '/' . $plgFolder;
             $allPlgsFolders[] = $plgFolderAndType;
             // Checks for sub-plugins, templates and known folders that might contain plugins:
             foreach (array('plugin', 'templates', 'processors', 'products') as $subFolder) {
                 $subfolderPath = $_CB_framework->getCfg('absolute_path') . '/components/com_comprofiler/plugin/' . $plgFolderAndType . '/' . $subFolder;
                 if (file_exists($subfolderPath)) {
                     $subPluginsFolders = array_map(function ($subSubFolder) use($plgFolderAndType, $subFolder) {
                         return $plgFolderAndType . '/' . $subFolder . '/' . $subSubFolder;
                     }, array_filter(cbReadDirectory($subfolderPath), function ($subSubFolder) {
                         return !in_array($subSubFolder, array('index.html', 'default'));
                     }));
                     // Consolidates sub-folders:
                     $allPlgsFolders = array_merge($allPlgsFolders, $subPluginsFolders);
                 }
             }
         }
     }
     // As discoveries above might lead to multiple entries depending on database of installed plugins, makes discoveries unique:
     $allPlgsFolders = array_unique($allPlgsFolders);
     // Checks for each discovered folder if there are cbinstall-xml files, and if yes, if they are in the installed plugins list:
     foreach ($allPlgsFolders as $plgFolderAndType) {
         $plgFolderDir = $_CB_framework->getCfg('absolute_path') . '/components/com_comprofiler/plugin/' . $plgFolderAndType;
         if (!is_file($plgFolderDir) && !in_array($plgFolderAndType, $existingPlgFolders)) {
             $plgFiles = cbReadDirectory($plgFolderDir);
             if ($plgFiles) {
                 foreach ($plgFiles as $plgFile) {
                     if (preg_match('/^.+\\.xml$/i', $plgFile)) {
                         $plgPath = $plgFolderDir . (substr($plgFolderDir, -1, 1) == '/' ? '' : '/') . $plgFile;
                         try {
                             $plgXml = @new SimpleXMLElement(trim(file_get_contents($plgPath)));
                             $elements = explode('/', $plgFolderAndType);
                             $lastFolder = array_pop($elements);
                             if ($plgXml->getName() == 'cbinstall' && $lastFolder != 'default' && !array_key_exists($plgFolderAndType, $discoveredPlgs)) {
                                 $discoveredPlgs[$plgFolderAndType] = array('name' => isset($plgXml->name) ? (string) $plgXml->name : $plgFolderAndType, 'file' => $plgFolderAndType);
                             }
                         } catch (\Exception $e) {
                             $failingXmlFiles[] = $plgPath;
                         }
                     }
                 }
             }
         }
     }
     $return = '';
     if (count($failingXmlFiles) > 0) {
         $return .= '<div class="col-sm-12">' . '<div class="col-sm-12 alert alert-danger" role="alert">' . '<h4>' . CBTxt::Th('Malformed XML files discovered in CB plugin folders:') . '</h4>';
         foreach ($failingXmlFiles as $failedFilePath) {
             $return .= '<div class="cbft_text form-group cb_form_line clearfix">' . CBTxt::Th('XML_FILE_FILE_IS_MALFORMED', 'XML file [FILE_PATH_AND_NAME] is malformed and should be replaced or fixed, or the plugin should be removed', array('[FILE_PATH_AND_NAME]' => '<strong>' . htmlspecialchars($failedFilePath) . '</strong>')) . '</div>';
         }
         $return .= '</div>' . '</div>';
     }
     if ($discoveredPlgs) {
         foreach ($discoveredPlgs as $discoveredPlg) {
             $return .= '<div class="cbft_text form-group cb_form_line clearfix">' . '<div class="control-label col-sm-3">' . htmlspecialchars($discoveredPlg['name']) . '</div>' . '<div class="cb_field col-sm-9">' . '<input type="button" class="btn btn-primary btn-sm" value="' . htmlspecialchars(CBTxt::T('Install Package')) . '" onclick="submitbutton( \'act=apply&amp;func=installPluginDisc&amp;plgfile=' . addslashes($discoveredPlg['file']) . '\' )" />' . '</div>' . '</div>';
         }
     } else {
         $return .= '<div class="col-sm-12">' . CBTxt::Th('No plugins discovered.') . '</div>';
     }
     return $return;
 }
function cbUpdateChecker()
{
    global $_CB_framework, $ueConfig;
    $js = "function cbCheckVersion() {" . "document.getElementById( 'cbLatestVersion' ).innerHTML = '" . addslashes(CBTxt::T('Checking latest version now...')) . "';" . "CBmakeHttpRequest( '" . $_CB_framework->backendUrl('index.php?option=com_comprofiler&view=latestVersion', false, 'raw') . "', 'cbLatestVersion', '" . addslashes(CBTxt::T('There was a problem with the request.')) . "', null );" . "return false;" . "};" . "function cbInitAjax() {" . "CBmakeHttpRequest( '" . $_CB_framework->backendUrl('index.php?option=com_comprofiler&view=latestVersion', false, 'raw') . "', 'cbLatestVersion', '" . addslashes(CBTxt::T('There was a problem with the request.')) . "', null );" . "};";
    if (!(isset($ueConfig['noVersionCheck']) && $ueConfig['noVersionCheck'] == '1')) {
        $js .= "cbAddEvent( window, 'load', cbInitAjax );";
    }
    $_CB_framework->document->addHeadScriptDeclaration($js);
    $return = '<table class="table table-noborder table-responsive">' . '<tbody>' . '<tr>' . '<td class="titleCell" style="width: 25%;">' . CBTxt::Th('Your version is') . '</td>' . '<td class="fieldCell" style="width: 75%;">' . $ueConfig['version'] . '</td>' . '</tr>' . '<tr>' . '<td class="titleCell" style="width: 25%;">' . CBTxt::Th('Latest version') . '</td>' . '<td class="fieldCell" style="width: 75%;">';
    if (isset($ueConfig['noVersionCheck']) && $ueConfig['noVersionCheck'] == '1') {
        $return .= '<div id="cbLatestVersion">' . '<a href="check_now" onclick="return cbCheckVersion();" style="cursor: pointer; text-decoration:underline;">' . htmlspecialchars(CBTxt::T('check now')) . '</a>' . '</div>';
    } else {
        $return .= '<div id="cbLatestVersion" style="color: #CCC;">...</div>';
    }
    $return .= '</td>' . '</tr>' . '</tbody>' . '</table>';
    return $return;
}
Ejemplo n.º 21
0
 /**
  * Returns a field in specified format
  *
  * @param  FieldTable  $field
  * @param  UserTable   $user
  * @param  string      $output  'html', 'xml', 'json', 'php', 'csvheader', 'csv', 'rss', 'fieldslist', 'htmledit'
  * @param  string      $reason  'profile' for user profile view, 'edit' for profile edit, 'register' for registration, 'list' for user-lists
  * @param  int         $list_compare_types   IF reason == 'search' : 0 : simple 'is' search, 1 : advanced search with modes, 2 : simple 'any' search
  * @return mixed
  */
 public function getField(&$field, &$user, $output, $reason, $list_compare_types)
 {
     global $_CB_framework;
     $return = null;
     if ($output == 'htmledit' && $reason != 'search') {
         if (Application::MyUser()->getUserId() != $user->get('id')) {
             // Terms and Conditions should never be required to be accepted by a user other than the profile owner:
             $field->set('required', 0);
         }
         $value = $user->get($field->name);
         $termsOutput = $field->params->get('terms_output', 'text');
         $termsType = CBTxt::T($field->params->get('terms_type', null));
         $termsDisplay = $field->params->get('terms_display', 'modal');
         $termsURL = $field->params->get('terms_url', null);
         $termsText = CBTxt::T($field->params->get('terms_text', null));
         $termsWidth = $field->params->get('terms_width', 400);
         $termsHeight = $field->params->get('terms_height', 200);
         if ($termsOutput == 'url' && !$termsURL || $termsOutput == 'text' && !$termsText) {
             return parent::getField($field, $user, $output, $reason, $list_compare_types);
         }
         if (!$termsType) {
             $termsType = CBTxt::T('TERMS_AND_CONDITIONS', 'Terms and Conditions');
         }
         if (!$termsWidth) {
             $termsWidth = 400;
         }
         if (!$termsHeight) {
             $termsHeight = 200;
         }
         if ($termsDisplay == 'iframe') {
             if (is_numeric($termsHeight)) {
                 $termsHeight .= 'px';
             }
             if (is_numeric($termsWidth)) {
                 $termsWidth .= 'px';
             }
             if ($termsOutput == 'url') {
                 $return .= '<div class="embed-responsive cbTermsFrameContainer" style="padding-bottom: ' . htmlspecialchars($termsHeight) . ';">' . '<iframe class="embed-responsive-item cbTermsFrameURL" style="width: ' . htmlspecialchars($termsWidth) . ';" src="' . htmlspecialchars($termsURL) . '"></iframe>' . '</div>';
             } else {
                 $return .= '<div class="cbTermsFrameText" style="height:' . htmlspecialchars($termsHeight) . ';width:' . htmlspecialchars($termsWidth) . ';overflow:auto;">' . $termsText . '</div>';
             }
             $label = CBTxt::Th('TERMS_FIELD_I_AGREE_ON_THE_ABOVE_CONDITIONS', 'I Agree to the above [type].', array('[type]' => $termsType));
         } else {
             $attributes = ' class="cbTermsLink"';
             if ($termsOutput == 'text' && $termsDisplay == 'window') {
                 $termsDisplay = 'modal';
             }
             if ($termsDisplay == 'modal') {
                 // Tooltip height percentage would be based off window height (including scrolling); lets change it to be based off the viewport height:
                 $termsHeight = substr($termsHeight, -1) == '%' ? (int) substr($termsHeight, 0, -1) . 'vh' : $termsHeight;
                 if ($termsOutput == 'url') {
                     $tooltip = '<iframe class="cbTermsModalURL" height="100%" width="100%" src="' . htmlspecialchars($termsURL) . '"></iframe>';
                 } else {
                     $tooltip = '<div class="cbTermsModalText" style="height:100%;width:100%;overflow:auto;">' . $termsText . '</div>';
                 }
                 $url = 'javascript:void(0);';
                 $attributes .= ' ' . cbTooltip($_CB_framework->getUi(), $tooltip, $termsType, array($termsWidth, $termsHeight), null, null, null, 'data-hascbtooltip="true" data-cbtooltip-modal="true"');
             } else {
                 $url = htmlspecialchars($termsURL);
                 $attributes .= ' target="_blank"';
             }
             $label = CBTxt::Th('TERMS_FIELD_ACCEPT_URL_CONDITIONS', 'Accept <!--suppress HtmlUnknownTarget --><a href="[url]"[attributes]>[type]</a>', array('[url]' => $url, '[attributes]' => $attributes, '[type]' => $termsType));
         }
         $inputName = $field->name;
         $translatedTitle = $this->getFieldTitle($field, $user, 'html', $reason);
         $htmlDescription = $this->getFieldDescription($field, $user, 'htmledit', $reason);
         $trimmedDescription = trim(strip_tags($htmlDescription));
         $attributes = null;
         if ($this->_isRequired($field, $user, $reason)) {
             $attributes .= ' class="required"';
         }
         $attributes .= $trimmedDescription ? cbTooltip($_CB_framework->getUi(), $htmlDescription, $translatedTitle, null, null, null, null, 'data-hascbtooltip="true"') : null;
         $return .= '<span class="cbSnglCtrlLbl">' . '<label for="' . htmlspecialchars($inputName) . '" class="checkbox-inline">' . '<input type="checkbox" id="' . htmlspecialchars($inputName) . '" name="' . htmlspecialchars($inputName) . '" value="1"' . ($value == 1 ? ' checked="checked"' : null) . $attributes . ' />' . $label . '</label>' . '</span>' . $this->_fieldIconsHtml($field, $user, $output, $reason, null, $field->type, $value, 'input', null, true, $this->_isRequired($field, $user, $reason) && !$this->_isReadOnly($field, $user, $reason));
     } else {
         $return .= parent::getField($field, $user, $output, $reason, $list_compare_types);
     }
     return $return;
 }
Ejemplo n.º 22
0
	/**
	 * Displays backend menu items
	 *
	 * @param array $menu
	 */
	public function adminMenu( &$menu )
	{
		global $_CB_framework;

		$menu[]		=	array(	'title' => CBTxt::T( 'Events' ), 'link' => $_CB_framework->backendViewUrl( 'editPlugin', true, array( 'action' => 'showgjevents', 'cid' => $this->getPluginId() ) ), 'icon' => 'cbgj-events',
								'submenu' => array(	array( 'title' => CBTxt::Th( 'Add New Event to Group' ), 'link' => $_CB_framework->backendViewUrl( 'editPlugin', true, array( 'cid' => $this->getPluginId(), 'table' => 'gjeventsbrowser', 'action' => 'editrow' ) ), 'icon' => 'cb-new' ),
													array( 'title' => CBTxt::T( 'Event Attendance' ), 'link' => $_CB_framework->backendViewUrl( 'editPlugin', true, array( 'action' => 'showgjattendance', 'cid' => $this->getPluginId() ) ), 'icon' => 'cbgj-eventsattendance' )
								)
							);
	}
            if (file_exists($_CB_framework->getCfg('absolute_path') . '/components/com_comprofiler/plugin/user/plug_cbpaidsubscriptions/plugin/cbsubstax')) {
                $cbsubsMenu['menu'][] = array('title' => CBTxt::Th('Taxes'), 'link' => $_CB_framework->backendViewUrl('editPlugin', true, array('cid' => $pluginId, 'action' => 'showtaxsettings', 'cbprevstate' => base64_encode($prevStateBase))), 'access' => array('cbsubs.financial', 'com_cbsubs'), 'icon' => 'cbsubs-taxes', 'submenu' => array(array('title' => CBTxt::Th('Sales Tax / VAT Report'), 'link' => $_CB_framework->backendViewUrl('editPlugin', true, array('cid' => $pluginId, 'action' => 'showtable', 'table' => 'taxreportmonthly', 'cbprevstate' => base64_encode($prevStateBase . '&action=showtaxsettings'))), 'access' => array('cbsubs.financial', 'com_cbsubs'), 'icon' => 'cbsubs-taxes_report')));
            }
            if (file_exists($_CB_framework->getCfg('absolute_path') . '/components/com_comprofiler/plugin/user/plug_cbpaidsubscriptions/plugin/cbsubspromotion')) {
                $cbsubsMenu['menu'][] = array('title' => CBTxt::Th('Promotions'), 'link' => $_CB_framework->backendViewUrl('editPlugin', true, array('cid' => $pluginId, 'action' => 'showpromotionssettings', 'cbprevstate' => base64_encode($prevStateBase))), 'access' => array('cbsubs.marketing', 'com_cbsubs'), 'icon' => 'cbsubs-promotions', 'submenu' => array(array('title' => CBTxt::Th('Add New Promotion'), 'link' => $_CB_framework->backendViewUrl('editPlugin', true, array('cid' => $pluginId, 'action' => 'editrow', 'table' => 'promotionsbrowser')), 'access' => array('cbsubs.marketing', 'com_cbsubs'), 'icon' => 'cb-new'), array('title' => CBTxt::Th('Promotions Used'), 'link' => $_CB_framework->backendViewUrl('editPlugin', true, array('cid' => $pluginId, 'action' => 'showtable', 'table' => 'promotionsuses', 'cbprevstate' => base64_encode($prevStateBase . '&action=showpromotionssettings'))), 'access' => array('cbsubs.marketing', 'com_cbsubs'), 'icon' => 'cbsubs-promotions_used'), array('title' => CBTxt::Th('Promotions Statistics'), 'link' => $_CB_framework->backendViewUrl('editPlugin', true, array('cid' => $pluginId, 'action' => 'showtable', 'table' => 'promotionsstats', 'cbprevstate' => base64_encode($prevStateBase . '&action=showpromotionssettings'))), 'access' => array('cbsubs.marketing', 'com_cbsubs'), 'icon' => 'cbsubs-promotions_statistics')));
            }
            if (file_exists($_CB_framework->getCfg('absolute_path') . '/components/com_comprofiler/plugin/user/plug_cbpaidsubscriptions/plugin/cbsubsmailer')) {
                $cbsubsMenu['menu'][] = array('title' => CBTxt::Th('Mailer'), 'link' => $_CB_framework->backendViewUrl('editPlugin', true, array('cid' => $pluginId, 'action' => 'showmailersettings', 'cbprevstate' => base64_encode($prevStateBase))), 'access' => array(array('core.admin', 'cbsubs.marketing'), 'com_cbsubs'), 'icon' => 'cbsubs-mailer', 'submenu' => array(array('title' => CBTxt::Th('Add New Mailer'), 'link' => $_CB_framework->backendViewUrl('editPlugin', true, array('cid' => $pluginId, 'action' => 'editrow', 'table' => 'mailersbrowser', 'cbprevstate' => base64_encode($prevStateBase . '&action=showmailersettings'))), 'access' => array('cbsubs.marketing', 'com_cbsubs'), 'icon' => 'cb-new'), array('title' => CBTxt::Th('Messages Queue'), 'link' => $_CB_framework->backendViewUrl('editPlugin', true, array('cid' => $pluginId, 'action' => 'showtable', 'table' => 'mailermailqueue', 'cbprevstate' => base64_encode($prevStateBase . '&action=showmailersettings'))), 'access' => array('cbsubs.marketing', 'com_cbsubs'), 'icon' => 'cbsubs-mailer_queue'), array('title' => CBTxt::Th('Sent Messages'), 'link' => $_CB_framework->backendViewUrl('editPlugin', true, array('cid' => $pluginId, 'action' => 'showtable', 'table' => 'mailersentmessages', 'cbprevstate' => base64_encode($prevStateBase . '&action=showmailersettings'))), 'access' => array('cbsubs.marketing', 'com_cbsubs'), 'icon' => 'cbsubs-mailer_sent')));
            }
            $menu[] = $cbsubsMenu;
        }
    }
    if ($params->get('menu_cbgj', 1) && file_exists($_CB_framework->getCfg('absolute_path') . '/components/com_comprofiler/plugin/user/plug_cbgroupjive')) {
        $query = 'SELECT ' . $_CB_database->NameQuote('id') . "\n FROM " . $_CB_database->NameQuote('#__comprofiler_plugin') . "\n WHERE " . $_CB_database->NameQuote('element') . ' = ' . $_CB_database->Quote('cbgroupjive');
        $_CB_database->setQuery($query, 0, 1);
        $pluginId = $_CB_database->loadResult();
        if ($pluginId) {
            $gjMenu = array();
            $gjMenu['component'] = array('title' => CBTxt::Th('GroupJive'));
            $gjMenu['menu'] = array(array('title' => CBTxt::Th('Plugin'), 'link' => $_CB_framework->backendViewUrl('editPlugin', true, array('cid' => $pluginId)), 'icon' => 'cbgj-plugin'), array('title' => CBTxt::Th('Categories'), 'link' => $_CB_framework->backendViewUrl('editPlugin', true, array('cid' => $pluginId, 'action' => 'categories')), 'icon' => 'cbgj-categories', 'submenu' => array(array('title' => CBTxt::Th('Add New Category'), 'link' => $_CB_framework->backendViewUrl('editPlugin', true, array('cid' => $pluginId, 'action' => 'categories.new')), 'icon' => 'cb-new'))), array('title' => CBTxt::Th('Groups'), 'link' => $_CB_framework->backendViewUrl('editPlugin', true, array('cid' => $pluginId, 'action' => 'groups')), 'icon' => 'cbgj-groups', 'submenu' => array(array('title' => CBTxt::Th('Add New Group'), 'link' => $_CB_framework->backendViewUrl('editPlugin', true, array('cid' => $pluginId, 'action' => 'groups.new')), 'icon' => 'cb-new'))), array('title' => CBTxt::Th('Users'), 'link' => $_CB_framework->backendViewUrl('editPlugin', true, array('cid' => $pluginId, 'action' => 'users')), 'icon' => 'cbgj-users', 'submenu' => array(array('title' => CBTxt::Th('Add New User to Group'), 'link' => $_CB_framework->backendViewUrl('editPlugin', true, array('cid' => $pluginId, 'action' => 'users.new')), 'icon' => 'cb-new'))), array('title' => CBTxt::Th('Invites'), 'link' => $_CB_framework->backendViewUrl('editPlugin', true, array('cid' => $pluginId, 'action' => 'invites')), 'icon' => 'cbgj-invites'), array('title' => CBTxt::Th('Configuration'), 'link' => $_CB_framework->backendViewUrl('editPlugin', true, array('cid' => $pluginId, 'action' => 'config')), 'icon' => 'cbgj-configuration'), array('title' => CBTxt::Th('Tools'), 'link' => $_CB_framework->backendViewUrl('editPlugin', true, array('cid' => $pluginId, 'action' => 'tools')), 'icon' => 'cbgj-tools'), array('title' => CBTxt::Th('Integrations'), 'link' => $_CB_framework->backendViewUrl('editPlugin', true, array('cid' => $pluginId, 'action' => 'integrations')), 'icon' => 'cbgj-integrations'), array('title' => CBTxt::Th('Menus'), 'link' => $_CB_framework->backendViewUrl('editPlugin', true, array('cid' => $pluginId, 'action' => 'menus')), 'icon' => 'cbgj-menus'));
            if (file_exists($_CB_framework->getCfg('absolute_path') . '/components/com_comprofiler/plugin/user/plug_cbgroupjive/plugins/cbgroupjiveauto')) {
                $gjMenu['menu'][] = array('title' => CBTxt::Th('Auto'), 'link' => $_CB_framework->backendViewUrl('editPlugin', true, array('cid' => $pluginId, 'action' => 'plugin.auto')), 'icon' => 'cbgj-auto');
            }
            $menu[] = $gjMenu;
        }
    }
    if ($params->get('menu_plugins', 1)) {
        $_PLUGINS->loadPluginGroup('user');
        $_PLUGINS->trigger('mod_onCBAdminMenu', array(&$menu, $disabled));
    }
}
Ejemplo n.º 24
0
	/**
	 * Accepts a connection request $connectionId for user $userId
	 *
	 * @param  int      $userId               User id
	 * @param  int      $connectionId         Connection id
	 * @param  boolean  $notifyNewConnection  [optional, default true] Notify to the other contact the new connection
	 * @return boolean                        Result (throws \RuntimeException in case of database error)
	 *
	 * @throws \RuntimeException
	 */
	public function acceptConnection( $userId, $connectionId, $notifyNewConnection = true )
	{
		global $ueConfig, $_PLUGINS;

		if ( $this->getConnectionDetails( $connectionId, $userId ) === false ) {
			$this->_setErrorMSG( CBTxt::T( 'UE_NODIRECTCONNECTION', 'There is no direct connection.' ) );
			return false;
		}

		$_PLUGINS->loadPluginGroup( 'user' );
		$_PLUGINS->trigger( 'onBeforeAcceptConnection', array( $userId, $connectionId, $ueConfig['useMutualConnections'], $ueConfig['autoAddConnections'] ) );
		if( $_PLUGINS->is_errors() ) {
			$this->_setUserMSG( $_PLUGINS->getErrorMSG() );
			return false;
		}

		$this->activateConnectionInDatabase( $userId, $connectionId );

		if ( $notifyNewConnection ) {
			$msg			=	CBTxt::Th( 'UE_CONNECTIONACCEPTSUCCESSFULL', 'Connection Successfully Accepted!' );
			$subject		=	CBTxt::T( 'UE_CONNECTIONACCEPTED_SUB', 'Connection Request Accepted!' );
			$messageHTML	=	CBTxt::T( 'UE_CONNECTIONACCEPTED_MSG', 'Your request to connect with %s was accepted!' );
			$messageText	=	$messageHTML;

			$result			=	$this->_notifyConnectionChange( $userId, $connectionId, $msg, $subject, $messageHTML, $messageText );
		} else {
			$result			=	true;
		}
		$_PLUGINS->trigger( 'onAfterAcceptConnection', array( $userId, $connectionId, $ueConfig['useMutualConnections'], $ueConfig['autoAddConnections'] ) );

		return $result;
	}
 /**
  * Displays "Not authorized", and if not logged-in "you need to login"
  *
  */
 function cbNotAuth($enqueue = false)
 {
     global $_CB_framework;
     if ($enqueue) {
         $_CB_framework->enqueueMessage(CBTxt::T('UE_NOT_AUTHORIZED', 'You are not authorized to view this page!') . ($_CB_framework->myId() < 1 ? ' ' . CBTxt::T('You need to log in.') : null), 'error');
     } else {
         $return = '<div class="cbNotAuth cb_template cb_template_' . selectTemplate('dir') . '">' . '<div class="error">' . CBTxt::Th('UE_NOT_AUTHORIZED', 'You are not authorized to view this page!') . '</div>';
         if ($_CB_framework->myId() < 1) {
             $return .= '<div class="error">' . CBTxt::Th('UE_DO_LOGIN', 'You need to log in.') . '</div>';
         }
         $return .= '</div>';
         echo $return;
     }
 }
    /**
     * Gives credits display for frontend and backend
     */
    function teamCredits()
    {
        global $_CB_framework, $ueConfig;
        $ui = $_CB_framework->getUi();
        outputCbTemplate($ui);
        outputCbJs($ui);
        ?>
		<div class="cbTeamCredits cb_template cb_template_<?php 
        echo selectTemplate('dir');
        ?>
">
			<div class="container-fluid">
				<div class="row text-center">
					<p>
						<?php 
        if ($ui == 2) {
            ?>
							<a href="http://www.joomlapolis.com/?pk_campaign=in-cb&amp;pk_kwd=credits" target="_blank">
								<img src="<?php 
            echo $_CB_framework->getCfg('live_site');
            ?>
/components/com_comprofiler/images/smcblogo.gif" class="img-responsive-inline" />
							</a>
							<?php 
            echo cbUpdateChecker();
            ?>
						<?php 
        } else {
            ?>
							<strong><?php 
            echo CBTxt::Th('UE_SITE_POWEREDBY TEAM_CREDITS_SITE_POWEREDBY', 'This site\'s community features are powered by Community Builder');
            ?>
</strong>
							<br />
							<a href="http://www.joomlapolis.com/?pk_campaign=in-cb&amp;pk_kwd=credits" target="_blank">
								<img src="<?php 
            echo $_CB_framework->getCfg('live_site');
            ?>
/components/com_comprofiler/images/smcblogo.gif" class="img-responsive-inline" />
							</a>
						<?php 
        }
        ?>
					</p>
				</div>
				<br />
				<div class="row">
					<?php 
        $w = "<p><strong>Community Builder</strong>&trade; (CB) is the complete <strong>Social Networking software</strong> solution for <strong>Joomla</strong>&trade; that is used by this website to support its <strong>membership management</strong>.</p>\n\t\t\t\t\t\t\t\t<p>This <strong>Joomla extension</strong> is the <strong>most popular Joomla social network component on the Joomla Extensions Directory</strong>.</p>\n\t\t\t\t\t\t\t\t<p>It comes with a built-in CB template, but more cool and fast <strong>Joomla and CB templates</strong> are available.</p>\n\t\t\t\t\t\t\t\t<p>Community Builder has <strong>many CB add-ons</strong>, both free and commercial that can extend the functionality of any Joomla website. One of these is the <strong>paid memberships software</strong> solution, CBSubs&trade;, that can manage <strong>paid subscriptions</strong> to access your website content. Many more exciting CB plugins are in our <strong>CB incubator</strong>.</p>\n\t\t\t\t\t\t\t\t<p>Finally, for those wanting a turnkey <strong>Online Social Network</strong>, Joomlapolis.com offers business-class <strong>Joomla hosting</strong>, including a one-click social networking website installer.</p>";
        echo str_replace('</strong>', '</a>', preg_replace_callback('/<strong>/', 'teamCreditsReplacer', $w));
        ?>
					<p><strong>Software: Copyright 2004-2016 joomlapolis.com. This component is released under the GNU/GPL version 2 License. All copyright statements must be kept. Derivate work must prominently duly acknowledge original work and include visible online links. Official site:</strong></p>
					<p class="text-center"><strong><a href="http://www.joomlapolis.com/?pk_campaign=in-cb&amp;pk_kwd=credits">www.joomlapolis.com</a></strong></p>
					<?php 
        if ($ui == 1) {
            ?>
						<p><strong>Please note that the authors and distributors of this software are not affiliated nor related in any way with the site owners using this free software here, and declines any warranty regarding the content and functions of this site.</strong></p>
					<?php 
        }
        ?>
				</div>
				<br />
				<div class="row text-center">
					<strong>Credits:</strong>
					<script type="text/javascript">//<!--
						/*
						 Fading Scroller- By DynamicDrive.com
						 For full source code, and usage terms, visit http://www.dynamicdrive.com
						 This notice MUST stay intact for use
						 fcontent[4]="<h3>damian caynes<br />inspired digital<br /></h3>Logo Design";
						 */
						var delay=1000; //set delay between message change (in miliseconds)
						var fcontent=[];
						begintag=''; //set opening tag, such as font declarations
						fcontent[0]="<h3>CBJoe/JoomlaJoe/MamboJoe<br /></h3>Founder &amp; First Developer";
						fcontent[1]="<h3>DJTrail<br /></h3>Co-Founder";
						fcontent[2]="<h3>Nick A.<br /></h3>Documentation and Public Relations";
						fcontent[3]="<h3>Beat B.<br /></h3>Lead Developer";
						fcontent[4]="<h3>Kyle L.<br /></h3>Developer and Support";
						fcontent[5]="<h3>Lou Griffith<br /></h3>Logo Design";
						closetag='';

						var fwidth='100%';	//'250px' //set scroller width
						var fheight='80px'; //set scroller height

						var fadescheme=0<?php 
        echo $ui == 2 || $ueConfig['templatedir'] != 'dark' ? 0 : 1;
        ?>
; //set 0 to fade text color from (white to black), 1 for (black to white)
						var fadelinks=1; //should links inside scroller content also fade like text? 0 for no, 1 for yes.

						///No need to edit below this line/////////////////

						var hex=(fadescheme==0)? 255 : 0;
						var startcolor=(fadescheme==0)? "rgb(255,255,255)" : "rgb(0,0,0)";
						var endcolor=(fadescheme==0)? "rgb(0,0,0)" : "rgb(255,255,255)";

						var ie4=document.all&&!document.getElementById;
						var ns4=document.layers;
						var DOM2=document.getElementById;
						var faderdelay=0;
						var index=0;
						var linksobj=null;

						if (DOM2)
							faderdelay=2000;

						//function to change content
						function changecontent(){
							if (index>=fcontent.length)
								index=0;
							if (DOM2){
								document.getElementById("fscroller").style.color=startcolor;
								document.getElementById("fscroller").innerHTML=begintag+fcontent[index]+closetag;
								linksobj=document.getElementById("fscroller").getElementsByTagName("A");
								if (fadelinks)
									linkcolorchange(linksobj);
								colorfade();
							}
							index++;
							setTimeout("changecontent()",delay+faderdelay);
						}

						// colorfade() partially by Marcio Galli for Netscape Communications.  ////////////
						// Modified by Dynamicdrive.com

						var frame=20, i;

						function linkcolorchange(obj){
							if (obj.length>0){
								for (i=0;i<obj.length;i++)
									obj[i].style.color="rgb("+hex+","+hex+","+hex+")";
							}
						}

						function colorfade() {
							// 20 frames fading process
							if(frame>0) {
								hex=(fadescheme==0)? hex-12 : hex+12; // increase or decrease color value depd on fadescheme
								document.getElementById("fscroller").style.color="rgb("+hex+","+hex+","+hex+")"; // Set color value.
								if (fadelinks)
									linkcolorchange(linksobj);
								frame--;
								setTimeout("colorfade()",20);
							} else {
								document.getElementById("fscroller").style.color=endcolor;
								frame=20;
								hex=(fadescheme==0)? 255 : 0;
							}
						}

						if (ie4||DOM2)
							document.write('<div id="fscroller" style="border:0 solid black;width:'+fwidth+';height:'+fheight+';padding:2px"></div>');
						window.onload=changecontent;
						//-->
					</script>
				</div>
				<?php 
        if ($ui == 2) {
            ?>
					<br />
					<div class="row text-center">
						<p><strong>Please note there is a free installation document, as well as a full documentation subscription for this free component available at <a href="http://www.joomlapolis.com/?pk_campaign=in-cb&amp;pk_kwd=credits">www.joomlapolis.com</a></strong></p>
					</div>
					<br />
					<div class="row text-center">
						<p>If you like the services provided by this free component, <a href="http://www.joomlapolis.com/?pk_campaign=in-cb&amp;pk_kwd=credits">please consider making a small donation to support the team behind it</a></p>
					</div>
				<?php 
        } elseif ($_CB_framework->myId()) {
            ?>
					<br />
					<div class="row text-center">
						<p><a href="<?php 
            echo cbSef('index.php?option=com_comprofiler' . getCBprofileItemid(true));
            ?>
"><?php 
            echo CBTxt::Th('TEAM_CREDITS_BACK_TO_YOUR_PROFILE UE_BACK_TO_YOUR_PROFILE', 'Back to your profile');
            ?>
</a></p>
					</div>
				<?php 
        }
        ?>
				<br />
				<table class="table table-bordered table-responsive">
					<tr>
						<th colspan="<?php 
        echo $ui == 2 ? 3 : 2;
        ?>
">Community Builder includes following components</th>
					</tr>
					<tr>
						<th>Application</th>
						<?php 
        if ($ui == 2) {
            ?>
							<th>Version</th>
						<?php 
        }
        ?>
						<th>License</th>
					</tr>
					<tr>
						<td>
							<a href="http://www.foood.net" target="_blank">Icons (old icons)</a>
						</td>
						<?php 
        if ($ui == 2) {
            ?>
							<td>N/A</td>
						<?php 
        }
        ?>
						<td>
							<a href="http://www.foood.net/agreement.htm" target="_blank">License</a>
						</td>
					</tr>
					<tr>
						<td>
							<a href="http://nuovext.pwsp.net/" target="_blank">Icons</a>
						</td>
						<?php 
        if ($ui == 2) {
            ?>
							<td>2.2</td>
						<?php 
        }
        ?>
						<td>
							<a href="http://www.gnu.org/licenses/lgpl.html" target="_blank">GNU Lesser General Public License</a>
						</td>
					</tr>
					<tr>
						<td>
							<a href="http://webfx.eae.net" target="_blank">Tabs</a>
						</td>
						<?php 
        if ($ui == 2) {
            ?>
							<td>1.02</td>
						<?php 
        }
        ?>
						<td>
							<a href="http://www.apache.org/licenses/LICENSE-2.0" target="_blank">Apache License, Version 2.0</a>
						</td>
					</tr>
					<tr>
						<td>
							<a href="http://www.dynarch.com/projects/calendar" target="_blank">Calendar</a>
						</td>
						<?php 
        if ($ui == 2) {
            ?>
							<td>1.1</td>
						<?php 
        }
        ?>
						<td>
							<a href="http://www.gnu.org/licenses/lgpl.html" target="_blank">GNU Lesser General Public License</a>
						</td>
					</tr>
					<tr>
						<td>
							<a href="http://www.dynamicdrive.com/dynamicindex7/jasoncalendar.htm" target="_blank">Jason&#039;s Calendar</a>
						</td>
						<?php 
        if ($ui == 2) {
            ?>
							<td>2005-09-05</td>
						<?php 
        }
        ?>
						<td>
							<a href="http://dynamicdrive.com/notice.htm" target="_blank">Dynamic Drive terms of use License</a>
						</td>
					</tr>
					<tr>
						<td>
							<a href="http://docs.guzzlephp.org/en/guzzle4/index.html" target="_blank">Guzzle</a>
						</td>
						<?php 
        if ($ui == 2) {
            ?>
							<td>4.1.3</td>
						<?php 
        }
        ?>
						<td>
							<a href="http://opensource.org/licenses/MIT" target="_blank">MIT</a>
						</td>
					</tr>
					<tr>
						<td>
							<a href="https://github.com/php-fig/log" target="_blank">Psr/Log</a>
						</td>
						<?php 
        if ($ui == 2) {
            ?>
							<td>1.0.0</td>
						<?php 
        }
        ?>
						<td>
							<a href="https://github.com/php-fig/log/blob/master/LICENSE" target="_blank">MIT</a>
						</td>
					</tr>
					<tr>
						<td>
							<a href="https://github.com/avalanche123/Imagine" target="_blank">Imagine</a>
						</td>
						<?php 
        if ($ui == 2) {
            ?>
							<td>0.6.1</td>
						<?php 
        }
        ?>
						<td>
							<a href="https://github.com/avalanche123/Imagine/blob/develop/LICENSE" target="_blank">MIT and third-party licenses</a>
						</td>
					</tr>
					<tr>
						<td>
							<a href="http://snoopy.sourceforge.net/" target="_blank">Snoopy</a>
						</td>
						<?php 
        if ($ui == 2) {
            ?>
							<td>1.2.3</td>
						<?php 
        }
        ?>
						<td>
							<a href="http://www.gnu.org/licenses/lgpl.html" target="_blank">GNU Lesser General Public License</a>
						</td>
					</tr>
					<tr>
						<td>
							<a href="http://www.phpclasses.org/browse/package/2189.html" target="_blank">PHPMailer</a>
						</td>
						<?php 
        if ($ui == 2) {
            ?>
							<td>5.2.8</td>
						<?php 
        }
        ?>
						<td>
							<a href="http://www.gnu.org/licenses/lgpl.html" target="_blank">GNU Lesser General Public License</a>
						</td>
					</tr>
					<tr>
						<td>
							<a href="http://www.phpclasses.org/browse/package/2189.html" target="_blank">PHP Input Filter</a>
							<a href="http://freshmeat.net/projects/inputfilter/" target="_blank">(forge)</a>
						</td>
						<?php 
        if ($ui == 2) {
            ?>
							<td>1.2.2+</td>
						<?php 
        }
        ?>
						<td>
							<a href="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html" target="_blank">GNU General Public License</a>
						</td>
					</tr>
					<tr>
						<td>
							<a href="http://www.joomlapolis.com/?pk_campaign=in-cb&amp;pk_kwd=credits" target="_blank">BestMenus</a>
						</td>
						<?php 
        if ($ui == 2) {
            ?>
							<td>1.0</td>
						<?php 
        }
        ?>
						<td>
							<a href="http://www.joomlapolis.com/?pk_campaign=in-cb&amp;pk_kwd=credits" target="_blank">Open Source GPL (GNU General Public License) v2</a>
						</td>
					</tr>
					<tr>
						<td>
							<a href="http://jquery.com/" target="_blank">jQuery</a>
						</td>
						<?php 
        if ($ui == 2) {
            ?>
							<td><?php 
            echo _CB_JQUERY_VERSION;
            ?>
</td>
						<?php 
        }
        ?>
						<td>
							<a href="http://docs.jquery.com/" target="_blank">MIT license</a>
						</td>
					</tr>
				</table>
			</div>
		</div>
	<?php 
    }
 /**
  * Renders the tooltip for a connection
  *
  * @param  \CB\Database\Table\MemberTable  $connection  Connection to render field tip for
  * @return string                                       HTML for the description of the connection
  */
 public static function renderConnectionToolTip($connection)
 {
     $tipField = CBTxt::Th('CONNECTION_TIP_CONNECTED_SINCE_CONNECTION_DATE', 'Connected Since [CONNECTION_DATE]', array('[CONNECTION_DATE]' => cbFormatDate($connection->membersince)));
     if ($connection->type != null) {
         $tipField .= '<br />' . CBTxt::Th('CONNECTION_TIP_TYPES_LIST', '{1} Type: [CONNECTIONS_TYPES]|]1,Inf] Types: [CONNECTIONS_TYPES]|%%COUNT%%', array('%%COUNT%%' => count(explode("|*|", $connection->type)), '[CONNECTIONS_TYPES]' => getConnectionTypes($connection->type)));
     }
     if ($connection->description != null) {
         $tipField .= '<br />' . CBTxt::Th('CONNECTION_TIP_CONNECTION_COMMENT', 'Comment: [CONNECTION_DESCRIPTION]', array('[CONNECTION_DESCRIPTION]' => htmlspecialchars($connection->description)));
     }
     return $tipField;
 }
Ejemplo n.º 28
0
 /**
  * @param  \CB\Database\Table\TabTable   $tab       the tab database entry
  * @param  \CB\Database\Table\UserTable  $user      the user being displayed
  * @param  int                           $ui        1 for front-end, 2 for back-end
  * @return boolean
  */
 public function getMenuAndStatus($tab, $user, $ui)
 {
     global $_CB_framework, $_CB_database, $ueConfig, $_REQUEST, $_POST;
     $params = $this->params;
     $userId = $user->id && $_CB_framework->myId() == $user->id ? null : $user->id;
     $firstMenuName = $params->get('firstMenuName', '');
     // CBTxt::T( '_UE_MENU_CB', 'Community' )
     $firstSubMenuName = $params->get('firstSubMenuName', '');
     // CBTxt::T( '_UE_MENU_ABOUT_CB', 'About Community Builder...' )
     $firstSubMenuHref = $params->get('firstSubMenuHref', '');
     $secondSubMenuName = $params->get('secondSubMenuName', '');
     $secondSubMenuHref = $params->get('secondSubMenuHref', '');
     // ----- CUSTOM MENU -----
     if ($firstMenuName != '') {
         $customMenu = array();
         $customMenu['arrayPos'] = $firstMenuName;
         $customMenu['position'] = 'menuBar';
         $customMenu['caption'] = CBTxt::T($firstMenuName);
         $this->addMenu($customMenu);
         if ($firstSubMenuName != '') {
             // Custom 1:
             $first = array();
             $first['arrayPos'] = array($firstMenuName => array('_UE_FIRST' => null));
             $first['position'] = 'menuBar';
             $first['caption'] = CBTxt::T($firstSubMenuName);
             $first['url'] = $firstSubMenuHref == '' ? "javascript: void( 0 );" : cbSef($firstSubMenuHref);
             $first['target'] = '';
             $first['img'] = '';
             $first['tooltip'] = '';
             $this->addMenu($first);
             if ($secondSubMenuName != '') {
                 // Custom 2:
                 $second = array();
                 $second['arrayPos'] = array($firstMenuName => array('_UE_SECOND' => null));
                 $second['position'] = 'menuBar';
                 $second['caption'] = CBTxt::T($secondSubMenuName);
                 $second['url'] = $secondSubMenuHref == '' ? "javascript: void( 0 );" : cbSef($secondSubMenuHref);
                 $second['target'] = '';
                 $second['img'] = '';
                 $second['tooltip'] = '';
                 $this->addMenu($second);
             }
         }
     }
     // ----- VIEW MENU -----
     $viewMenu = array();
     $viewMenu['arrayPos'] = '_UE_MENU_VIEW';
     $viewMenu['position'] = 'menuBar';
     $viewMenu['caption'] = CBTxt::T('_UE_MENU_VIEW', 'View');
     $this->addMenu($viewMenu);
     if ($_CB_framework->myId() > 0) {
         if ($_CB_framework->displayedUser() === null || $_CB_framework->myId() != $user->id && $_CB_framework->displayedUser() !== null) {
             // View My Profile:
             $myProfile = array();
             $myProfile['arrayPos'] = array('_UE_MENU_VIEW' => array('_UE_MENU_VIEWMYPROFILE' => null));
             $myProfile['position'] = 'menuBar';
             $myProfile['caption'] = CBTxt::T('UE_MENU_VIEWMYPROFILE', 'View Your Profile');
             $myProfile['url'] = $_CB_framework->userProfileUrl();
             $myProfile['target'] = '';
             $myProfile['img'] = '<span class="fa fa-home"></span> ';
             $myProfile['tooltip'] = CBTxt::T('UE_MENU_VIEWMYPROFILE_DESC', 'View your own profile');
             $this->addMenu($myProfile);
         }
     }
     // ----- EDIT MENU -----
     $editMenu = array();
     $editMenu['arrayPos'] = '_UE_MENU_EDIT';
     $editMenu['position'] = 'menuBar';
     $editMenu['caption'] = CBTxt::T('_UE_MENU_EDIT', 'Edit');
     $this->addMenu($editMenu);
     if (!cbCheckIfUserCanPerformUserTask($user->id, 'allowModeratorsUserEdit')) {
         if ($user->id == $_CB_framework->myId()) {
             $menuTexts = array('_UE_UPDATEPROFILE' => CBTxt::T('UE_UPDATEPROFILE', 'Update Your Profile'), '_UE_MENU_UPDATEPROFILE_DESC' => CBTxt::T('UE_MENU_UPDATEPROFILE_DESC', 'Change your profile settings'));
         } else {
             $menuTexts = array('_UE_UPDATEPROFILE' => CBTxt::T('UE_MOD_MENU_UPDATEPROFILE', 'Update user profile'), '_UE_MENU_UPDATEPROFILE_DESC' => CBTxt::T('UE_MOD_MENU_UPDATEPROFILE_DESC', 'Change profile settings of this user profile'));
         }
         // Update Profile:
         $updateProfile = array();
         $updateProfile['arrayPos'] = array('_UE_MENU_EDIT' => array('_UE_UPDATEPROFILE' => null));
         $updateProfile['position'] = 'menuBar';
         $updateProfile['caption'] = $menuTexts['_UE_UPDATEPROFILE'];
         $updateProfile['url'] = $_CB_framework->userProfileEditUrl($userId);
         $updateProfile['target'] = '';
         $updateProfile['img'] = '<span class="fa fa-edit"></span> ';
         $updateProfile['tooltip'] = $menuTexts['_UE_MENU_UPDATEPROFILE_DESC'];
         $this->addMenu($updateProfile);
     }
     // ----- MESSAGES MENU -----
     $messagesMenu = array();
     $messagesMenu['arrayPos'] = '_UE_MENU_MESSAGES';
     $messagesMenu['position'] = 'menuBar';
     $messagesMenu['caption'] = CBTxt::T('_UE_MENU_MESSAGES', 'Messages');
     $this->addMenu($messagesMenu);
     if ($_CB_framework->myId() != $user->id && $_CB_framework->myId() > 0) {
         global $_CB_PMS;
         $resultArray = $_CB_PMS->getPMSlinks($user->id, $_CB_framework->myId(), '', '', 1);
         if (count($resultArray) > 0) {
             foreach ($resultArray as $res) {
                 if (is_array($res)) {
                     // Send Private Message:
                     $sendMessage = array();
                     $sendMessage['arrayPos'] = array('_UE_MENU_MESSAGES' => array('_UE_PM_USER' => null));
                     $sendMessage['position'] = 'menuBar';
                     $sendMessage['caption'] = $res['caption'];
                     // Already translated in CB Menu
                     $sendMessage['url'] = cbSef($res['url']);
                     $sendMessage['target'] = '';
                     $sendMessage['img'] = '<span class="fa fa-comment"></span> ';
                     $sendMessage['tooltip'] = $res['tooltip'];
                     // Already translated in CB Menu
                     $this->addMenu($sendMessage);
                 }
             }
         }
     }
     if ($ueConfig['allow_email_display'] != 4 && $_CB_framework->myId() != $user->id && $_CB_framework->myId() > 0) {
         switch ($ueConfig['allow_email_display']) {
             case 1:
                 // Display Email only
                 $caption = moscomprofilerHTML::emailCloaking(htmlspecialchars($user->email), 0);
                 $url = "javascript: void( 0 );;";
                 $desc = CBTxt::T('UE_MENU_USEREMAIL_DESC', 'Email address of this user');
                 break;
             case 2:
                 // Display Email with link
                 $caption = moscomprofilerHTML::emailCloaking(htmlspecialchars($user->email), 1);
                 $url = "javascript: void( 0 );;";
                 $desc = CBTxt::T('UE_MENU_SENDUSEREMAIL_DESC', 'Send an Email to this user');
                 break;
             case 3:
                 // Display Email-to text with link to web-form
             // Display Email-to text with link to web-form
             default:
                 $caption = CBTxt::T('UE_MENU_SENDUSEREMAIL', 'Send Email to User');
                 $url = $_CB_framework->viewUrl('emailuser', true, array('uid' => $userId));
                 $desc = CBTxt::T('UE_MENU_SENDUSEREMAIL_DESC', 'Send an Email to this user');
                 break;
         }
         // Send Email:
         $sendEmail = array();
         $sendEmail['arrayPos'] = array('_UE_MENU_MESSAGES' => array('_UE_MENU_SENDUSEREMAIL' => null));
         $sendEmail['position'] = 'menuBar';
         $sendEmail['caption'] = $caption;
         $sendEmail['url'] = $url;
         $sendEmail['target'] = '';
         $sendEmail['img'] = '<span class="fa fa-envelope"></span> ';
         $sendEmail['tooltip'] = $desc;
         $this->addMenu($sendEmail);
     }
     // ----- CONNECTIONS MENU -----
     $connectionsMenu = array();
     $connectionsMenu['arrayPos'] = '_UE_MENU_CONNECTIONS';
     $connectionsMenu['position'] = 'menuBar';
     $connectionsMenu['caption'] = CBTxt::T('_UE_MENU_CONNECTIONS', 'Connections');
     $this->addMenu($connectionsMenu);
     if ($ueConfig['allowConnections'] && $_CB_framework->myId() > 0) {
         // Manage My Connections:
         $manageConnections = array();
         $manageConnections['arrayPos'] = array('_UE_MENU_CONNECTIONS' => array('_UE_MENU_MANAGEMYCONNECTIONS' => null));
         $manageConnections['position'] = 'menuBar';
         $manageConnections['caption'] = CBTxt::T('UE_MENU_MANAGEMYCONNECTIONS', 'Manage Your Connections');
         $manageConnections['url'] = $_CB_framework->viewUrl('manageconnections');
         $manageConnections['target'] = '';
         $manageConnections['img'] = '<span class="fa fa-users"></span> ';
         $manageConnections['tooltip'] = CBTxt::T('UE_MENU_MANAGEMYCONNECTIONS_DESC', 'Manage your existing connections and pending connections actions');
         $this->addMenu($manageConnections);
         if ($_CB_framework->myId() != $user->id) {
             $cbConnection = new cbConnection((int) $_CB_framework->myId());
             $cbUser =& CBuser::getInstance((int) $user->id, false);
             $connClass = null;
             $connLink = null;
             $connDesc = null;
             $connMsg = null;
             $connImg = null;
             $isConnection = $cbConnection->isConnected((int) $user->id);
             if ($isConnection) {
                 $isApproved = $cbConnection->isConnectionApproved((int) $user->id);
                 $isAccepted = $cbConnection->isConnectionAccepted((int) $user->id);
             } else {
                 $isApproved = false;
                 $isAccepted = false;
             }
             if (!$isConnection) {
                 $connUrl = $_CB_framework->viewUrl('addconnection', true, array('connectionid' => (int) $user->id));
                 if ($ueConfig['useMutualConnections'] == 1) {
                     $connClass = 'UE_ADDCONNECTIONREQUEST';
                     $connMsg = CBTxt::T('UE_ADDCONNECTIONREQUEST', 'Request Connection');
                     $connDesc = CBTxt::T('UE_ADDCONNECTIONREQUEST_DESC', 'Request a Connection to that user');
                 } else {
                     $connClass = 'UE_ADDCONNECTION';
                     $connMsg = CBTxt::T('UE_ADDCONNECTION', 'Add Connection');
                     $connDesc = CBTxt::T('UE_ADDCONNECTION_DESC', 'Add a Connection to that user');
                 }
                 if ($ueConfig['conNotifyType'] != 0) {
                     cbValidator::loadValidation();
                     $tooltipTitle = sprintf(CBTxt::T('UE_CONNECTTO', 'Connect to %s'), $cbUser->getField('formatname', null, 'html', 'none', 'profile', 0, true));
                     $connectionInvitationMsg = CBTxt::T('UE_CONNECTIONINVITATIONMSG', 'Personalize your invitation to connect by adding a message that will be included with your connection.');
                     $tooltip = null;
                     if ($connectionInvitationMsg) {
                         $tooltip .= '<div class="form-group cb_form_line clearfix">' . $connectionInvitationMsg . '</div>';
                     }
                     $tooltip .= '<form action="' . $connUrl . '" method="post" id="connOverForm" name="connOverForm" class="cb_form cbValidation">' . '<div class="form-group cb_form_line clearfix">' . '<label for="message" class="control-label">' . CBTxt::T('UE_MESSAGE', 'Message') . '</label>' . '<div class="cb_field">' . '<textarea cols="40" rows="8" name="message" class="form-control"></textarea>' . '</div>' . '</div>' . '<div class="form-group cb_form_line clearfix">' . '<input type="submit" class="btn btn-primary cbConnReqSubmit" value="' . htmlspecialchars(CBTxt::Th('UE_SENDCONNECTIONREQUEST', 'Request Connection')) . '"' . cbValidator::getSubmitBtnHtmlAttributes() . ' />' . ' <input type="button" id="cbConnReqCancel" class="btn btn-default cbConnReqCancel cbTooltipClose" value="' . htmlspecialchars(CBTxt::Th('UE_CANCELCONNECTIONREQUEST', 'Cancel')) . '" />' . '</div>' . '</form>';
                     $connLink = cbTooltip($ui, $tooltip, $tooltipTitle, 400, null, '<span class="fa fa-heart"></span> ' . CBTxt::Th($connMsg), 'javascript: void( 0 );', 'data-hascbtooltip="true" data-cbtooltip-modal="true"');
                 } else {
                     $connLink = $connUrl;
                     $connImg = '<span class="fa fa-heart"></span> ';
                 }
             } else {
                 if ($isAccepted) {
                     $connUrl = $_CB_framework->viewUrl('removeconnection', true, array('connectionid' => (int) $user->id));
                     if ($isApproved) {
                         $connClass = 'UE_REMOVECONNECTION';
                         $connMsg = CBTxt::T('UE_REMOVECONNECTION', 'Remove Connection');
                         $connDesc = CBTxt::T('UE_REMOVECONNECTION_DESC', 'Remove Connection to that user');
                     } else {
                         $connClass = 'UE_REVOKECONNECTIONREQUEST';
                         $connMsg = CBTxt::T('UE_REVOKECONNECTIONREQUEST', 'Revoke Connection Request');
                         $connDesc = CBTxt::T('UE_REVOKECONNECTIONREQUEST_DESC', 'Cancel the Connection Request to that user');
                     }
                     $js = "if ( typeof confirmSubmit != 'function' ) {" . "function confirmSubmit() {" . "if ( confirm( '" . addslashes(CBTxt::T('UE_CONFIRMREMOVECONNECTION', 'Are you sure you want to remove this connection?')) . "' ) ) {" . "return true;" . "} else {" . "return false;" . "}" . "};" . "}";
                     $_CB_framework->document->addHeadScriptDeclaration($js);
                     $connLink = $connUrl . '" onclick="return confirmSubmit();';
                     $connImg = '<span class="fa fa-heart-o"></span> ';
                 } else {
                     $connClass = null;
                     $connMsg = null;
                 }
             }
             if ($connMsg) {
                 // Request/Add/Remove/Revoke Connection:
                 $connectionRequest = array();
                 $connectionRequest['arrayPos'] = array('_UE_MENU_CONNECTIONS' => array($connClass => null));
                 $connectionRequest['position'] = 'menuBar';
                 $connectionRequest['caption'] = $connMsg;
                 $connectionRequest['url'] = $connLink;
                 $connectionRequest['target'] = '';
                 $connectionRequest['img'] = $connImg;
                 $connectionRequest['tooltip'] = $connDesc;
                 $this->addMenu($connectionRequest);
             }
         }
     }
     // ----- MODERATE MENU -----
     $moderateMenu = array();
     $moderateMenu['arrayPos'] = '_UE_MENU_MODERATE';
     $moderateMenu['position'] = 'menuBar';
     $moderateMenu['caption'] = CBTxt::T('_UE_MENU_MODERATE', 'Moderate');
     $this->addMenu($moderateMenu);
     if ($_CB_framework->myId() == $user->id) {
         if ($user->banned == 1 && $this->cbUserIsModerator == 0 && $ueConfig['allowUserBanning'] == 1) {
             // Request Unban:
             $requestUnban = array();
             $requestUnban['arrayPos'] = array('_UE_MENU_MODERATE' => array('_UE_REQUESTUNBANPROFILE' => null));
             $requestUnban['position'] = 'menuBar';
             $requestUnban['caption'] = CBTxt::T('UE_REQUESTUNBANPROFILE', 'Submit Unban Request');
             $requestUnban['url'] = $_CB_framework->viewUrl('banprofile', true, array('act' => 2, 'reportform' => 1, 'uid' => (int) $user->id));
             $requestUnban['target'] = '';
             $requestUnban['img'] = '<span class="fa fa-envelope"></span> ';
             $requestUnban['tooltip'] = CBTxt::T('UE_MENU_REQUESTUNBANPROFILE_DESC', 'Submit a request to the site moderator to unban your profile');
             $this->addMenu($requestUnban);
         }
     } else {
         if ($ueConfig['allowUserReports'] == 1 && $this->cbUserIsModerator == 0 && $_CB_framework->myId() > 0) {
             // Report User:
             $reportUser = array();
             $reportUser['arrayPos'] = array('_UE_MENU_MODERATE' => array('_UE_REPORTUSER' => null));
             $reportUser['position'] = 'menuBar';
             $reportUser['caption'] = CBTxt::T('UE_REPORTUSER', 'Report User');
             $reportUser['url'] = $_CB_framework->viewUrl('reportuser', true, array('uid' => (int) $user->id));
             $reportUser['target'] = '';
             $reportUser['img'] = '<span class="fa fa-bullhorn"></span> ';
             $reportUser['tooltip'] = CBTxt::T('UE_MENU_REPORTUSER_DESC', 'Report this user to the site moderator so that he can take appropriate action');
             $this->addMenu($reportUser);
         }
         if ($this->cbMyIsModerator == 1 && $this->cbUserIsModerator == 0) {
             $query = 'SELECT COUNT(*)' . "\n FROM " . $_CB_database->NameQuote('#__comprofiler_userreports') . "\n WHERE " . $_CB_database->NameQuote('reporteduser') . " = " . (int) $user->id . "\n AND " . $_CB_database->NameQuote('reportedstatus') . " = 0";
             $_CB_database->setQuery($query);
             $pendingReports = $_CB_database->loadResult();
             $query = 'SELECT COUNT(*)' . "\n FROM " . $_CB_database->NameQuote('#__comprofiler_userreports') . "\n WHERE " . $_CB_database->NameQuote('reporteduser') . " = " . (int) $user->id;
             $_CB_database->setQuery($query);
             $processedReports = $_CB_database->loadResult();
             if ($ueConfig['allowUserBanning'] == 1) {
                 if ($user->banned != 0) {
                     // Unban Profile:
                     $unbanUser = array();
                     $unbanUser['arrayPos'] = array('_UE_MENU_MODERATE' => array('_UE_UNBANPROFILE' => null));
                     $unbanUser['position'] = 'menuBar';
                     $unbanUser['caption'] = CBTxt::T('UE_UNBANPROFILE', 'Unban Profile');
                     $unbanUser['url'] = $_CB_framework->viewUrl('banprofile', true, array('act' => 0, 'reportform' => 0, 'uid' => (int) $user->id));
                     $unbanUser['target'] = '';
                     $unbanUser['img'] = '<span class="fa fa-check-circle-o"></span> ';
                     $unbanUser['tooltip'] = CBTxt::T('UE_MENU_UNBANPROFILE_DESC', 'As Site Moderator: Unban this profile, making it visible to other users');
                     $this->addMenu($unbanUser);
                 } else {
                     // Ban Profile:
                     $banUser = array();
                     $banUser['arrayPos'] = array('_UE_MENU_MODERATE' => array('_UE_BANPROFILE' => null));
                     $banUser['position'] = 'menuBar';
                     $banUser['caption'] = CBTxt::T('UE_BANPROFILE', 'Ban Profile');
                     $banUser['url'] = $_CB_framework->viewUrl('banprofile', true, array('act' => 1, 'uid' => (int) $user->id));
                     $banUser['target'] = '';
                     $banUser['img'] = '<span class="fa fa-ban"></span> ';
                     $banUser['tooltip'] = CBTxt::T('UE_MENU_BANPROFILE_DESC', 'As Site Moderator: Ban this profile, making it invisible to other users');
                     $this->addMenu($banUser);
                 }
                 if ($user->bannedby) {
                     // Ban History:
                     $banHistory = array();
                     $banHistory['arrayPos'] = array('_UE_MENU_MODERATE' => array('_UE_MENU_BANPROFILE_HISTORY' => null));
                     $banHistory['position'] = 'menuBar';
                     $banHistory['caption'] = CBTxt::T('UE_MENU_BANPROFILE_HISTORY', 'Ban history');
                     $banHistory['url'] = $_CB_framework->viewUrl('moderatebans', true, array('act' => 2, 'uid' => (int) $user->id));
                     $banHistory['target'] = '';
                     $banHistory['img'] = '<span class="fa fa-book"></span> ';
                     $banHistory['tooltip'] = CBTxt::T('UE_MENU_BANPROFILE_HISTORY_DESC', 'As Site Moderator: See ban history of this profile');
                     $this->addMenu($banHistory);
                 }
             }
             if ($ueConfig['allowUserReports'] == 1 && $pendingReports > 0) {
                 // View Pending Reports:
                 $userReports = array();
                 $userReports['arrayPos'] = array('_UE_MENU_MODERATE' => array('_UE_VIEWUSERREPORTS' => null));
                 $userReports['position'] = 'menuBar';
                 $userReports['caption'] = CBTxt::T('UE_VIEWUSERREPORTS', 'View User Reports');
                 $userReports['url'] = $_CB_framework->viewUrl('viewreports', true, array('uid' => (int) $user->id));
                 $userReports['target'] = '';
                 $userReports['img'] = '<span class="fa fa-warning"></span> ';
                 $userReports['tooltip'] = CBTxt::T('UE_MENU_VIEWUSERREPORTS_DESC', 'As Site Moderator: View User Reports for this user');
                 $this->addMenu($userReports);
             } elseif ($ueConfig['allowUserReports'] == 1 && $processedReports > 0) {
                 // View Processed Reports:
                 $userReports = array();
                 $userReports['arrayPos'] = array('_UE_MENU_MODERATE' => array('_UE_VIEWUSERREPORTS' => null));
                 $userReports['position'] = 'menuBar';
                 $userReports['caption'] = CBTxt::T('UE_MOD_MENU_VIEWOLDUSERREPORTS', 'View processed user reports');
                 $userReports['url'] = $_CB_framework->viewUrl('viewreports', true, array('act' => 1, 'uid' => (int) $user->id));
                 $userReports['target'] = '';
                 $userReports['img'] = '<span class="fa fa-warning"></span> ';
                 $userReports['tooltip'] = CBTxt::T('UE_MOD_MENU_VIEWOLDUSERREPORTS_DESC', 'As site moderator: View processed user reports for this user');
                 $this->addMenu($userReports);
             }
         }
     }
 }
Ejemplo n.º 29
0
 /**
  * Direct access to field for custom operations, like for Ajax
  *
  * WARNING: direct unchecked access, except if $user is set, then check well for the $reason ...
  *
  * @param  FieldTable  $field
  * @param  UserTable    $user
  * @param  array                 $postdata
  * @param  string                $reason     'profile' for user profile view, 'edit' for profile edit, 'register' for registration, 'search' for searches
  * @return string                            Expected output.
  */
 public function fieldClass(&$field, &$user, &$postdata, $reason)
 {
     global $_CB_framework;
     // simple spoof check security
     if (!cbSpoofCheck('fieldclass', 'POST', 2) || $reason == 'register' && $_CB_framework->getUi() == 1 && !cbRegAntiSpamCheck(2)) {
         echo '<div class="alert alert-danger">' . CBTxt::Th('UE_SESSION_EXPIRED', 'Session expired or cookies are not enabled in your browser. Please press "reload page" in your browser, and enable cookies in your browser.') . "</div>";
         exit;
     }
     return false;
 }
Ejemplo n.º 30
-1
 /**
  * Draws Users list (ECHO)
  *
  * @param  int      $userId
  * @param  int      $listId
  * @param  array    $postData
  * @return void
  */
 public function drawUsersList($userId, $listId, $postData)
 {
     global $_CB_database, $_PLUGINS;
     $_PLUGINS->loadPluginGroup('user');
     $searchData = cbGetParam($postData, 'search');
     $limitstart = (int) cbGetParam($postData, 'limitstart');
     $searchMode = (int) cbGetParam($postData, 'searchmode', 0);
     $random = (int) cbGetParam($postData, 'rand', 0);
     $cbUser = CBuser::getInstance((int) $userId, false);
     $user = $cbUser->getUserData();
     $search = null;
     $input = array();
     $publishedLists = array();
     $query = 'SELECT *' . "\n FROM " . $_CB_database->NameQuote('#__comprofiler_lists') . "\n WHERE " . $_CB_database->NameQuote('published') . " = 1" . "\n AND " . $_CB_database->NameQuote('viewaccesslevel') . " IN " . $_CB_database->safeArrayOfIntegers(Application::MyUser()->getAuthorisedViewLevels()) . "\n ORDER BY " . $_CB_database->NameQuote('ordering');
     $_CB_database->setQuery($query);
     /** @var ListTable[] $userLists */
     $userLists = $_CB_database->loadObjectList(null, '\\CB\\Database\\Table\\ListTable', array($_CB_database));
     if ($userLists) {
         foreach ($userLists as $userList) {
             $publishedLists[] = moscomprofilerHTML::makeOption((int) $userList->listid, strip_tags($cbUser->replaceUserVars($userList->title, false, false)));
             if (!$listId && $userList->default) {
                 $listId = (int) $userList->listid;
             }
         }
         if (!$listId) {
             $listId = (int) $userLists[0]->listid;
         }
     }
     if (!$listId) {
         echo CBTxt::Th('UE_NOLISTFOUND', 'There are no published user lists!');
         return;
     }
     if ($userLists) {
         $input['plists'] = moscomprofilerHTML::selectList($publishedLists, 'listid', 'class="form-control input-block" onchange="this.form.submit();"', 'value', 'text', (int) $listId, 1);
     }
     $row = self::getInstance((int) $listId);
     if (!$row) {
         echo CBTxt::Th('UE_LIST_DOES_NOT_EXIST', 'This list does not exist');
         return;
     }
     if (!$cbUser->authoriseView('userslist', $row->listid)) {
         echo CBTxt::Th('UE_NOT_AUTHORIZED', 'You are not authorized to view this page!');
         return;
     }
     $params = new Registry($row->params);
     if ($params->get('hotlink_protection', 0) == 1) {
         if ($searchData !== null || $limitstart) {
             cbSpoofCheck('userslist', 'GET');
         }
     }
     $limit = (int) $params->get('list_limit', 30);
     if (!$limit) {
         $limit = 30;
     }
     if ($params->get('list_paging', 1) != 1) {
         $limitstart = 0;
     }
     $isModerator = Application::MyUser()->isGlobalModerator();
     $_PLUGINS->trigger('onStartUsersList', array(&$listId, &$row, &$search, &$limitstart, &$limit));
     // Prepare query variables:
     $userGroupIds = explode('|*|', $row->usergroupids);
     $orderBy = self::getSorting($listId, $userId, $random);
     $filterBy = self::getFiltering($listId, $userId);
     $columns = self::getColumns($listId, $userId);
     // Grab all the fields the $user can access:
     $tabs = new cbTabs(0, 1);
     $fields = $tabs->_getTabFieldsDb(null, $user, 'list');
     // Build the field SQL:
     $tableReferences = array('#__comprofiler' => 'ue', '#__users' => 'u');
     $searchableFields = array();
     $fieldsSQL = cbUsersList::getFieldsSQL($columns, $fields, $tableReferences, $searchableFields, $params);
     $_PLUGINS->trigger('onAfterUsersListFieldsSql', array(&$columns, &$fields, &$tableReferences));
     // Build the internal joins and where statements best off list parameters:
     $tablesSQL = array();
     $joinsSQL = array();
     $tablesWhereSQL = array();
     if ($isModerator) {
         if (!$params->get('list_show_blocked', 0)) {
             $tablesWhereSQL['block'] = 'u.block = 0';
         }
         if (!$params->get('list_show_banned', 1)) {
             $tablesWhereSQL['banned'] = 'ue.banned = 0';
         }
         if (!$params->get('list_show_unapproved', 0)) {
             $tablesWhereSQL['approved'] = 'ue.approved = 1';
         }
         if (!$params->get('list_show_unconfirmed', 0)) {
             $tablesWhereSQL['confirmed'] = 'ue.confirmed = 1';
         }
     } else {
         $tablesWhereSQL = array('block' => 'u.block = 0', 'approved' => 'ue.approved = 1', 'confirmed' => 'ue.confirmed = 1', 'banned' => 'ue.banned = 0');
     }
     $joinsSQL[] = 'JOIN #__user_usergroup_map g ON g.`user_id` = u.`id`';
     if ($userGroupIds) {
         $tablesWhereSQL['gid'] = 'g.group_id IN ' . $_CB_database->safeArrayOfIntegers($userGroupIds);
     }
     foreach ($tableReferences as $table => $name) {
         if ($name == 'u') {
             $tablesSQL[] = $table . ' ' . $name;
         } else {
             $joinsSQL[] = 'JOIN ' . $table . ' ' . $name . ' ON ' . $name . '.`id` = u.`id`';
         }
     }
     // Build the search criteria:
     $searchValues = new stdClass();
     $searchesFromFields = $tabs->applySearchableContents($searchableFields, $searchValues, $postData, $params->get('list_compare_types', 0));
     $whereFields = $searchesFromFields->reduceSqlFormula($tableReferences, $joinsSQL, true);
     if ($whereFields) {
         $tablesWhereSQL[] = '(' . $whereFields . ')';
     }
     $_PLUGINS->trigger('onBeforeUsersListBuildQuery', array(&$tablesSQL, &$joinsSQL, &$tablesWhereSQL));
     // Construct the FROM and WHERE for the userlist query:
     $queryFrom = "FROM " . implode(', ', $tablesSQL) . (count($joinsSQL) ? "\n " . implode("\n ", $joinsSQL) : '') . "\n WHERE " . implode("\n AND ", $tablesWhereSQL) . " " . $filterBy;
     $_PLUGINS->trigger('onBeforeUsersListQuery', array(&$queryFrom, 1, $listId));
     // $ui = 1 (frontend)
     $errorMsg = null;
     // Checks if the list is being actively searched and it allows searching; otherwise reset back to normal:
     $searchCount = count(get_object_vars($searchValues));
     if ($params->get('list_search', 1) > 0 && $params->get('list_search_empty', 0) && !$searchCount) {
         $searchMode = 1;
         $listAll = false;
     } else {
         $listAll = $searchCount ? true : false;
     }
     if ($searchMode == 0 || $searchMode == 1 && $searchCount || $searchMode == 2) {
         // Prepare the userlist count query for pagination:
         $_CB_database->setQuery("SELECT COUNT( DISTINCT u.id ) " . $queryFrom);
         $total = $_CB_database->loadResult();
         if ($limit > $total || $limitstart >= $total) {
             $limitstart = 0;
         }
         // Prepare the actual userlist query to build a list of users:
         $query = "SELECT DISTINCT ue.*, u.*, '' AS 'NA' " . ($fieldsSQL ? ", " . $fieldsSQL . " " : '') . $queryFrom . " " . $orderBy;
         $_CB_database->setQuery($query, (int) $limitstart, (int) $limit);
         /** @var UserTable[] $users */
         $users = $_CB_database->loadObjectList(null, '\\CB\\Database\\Table\\UserTable', array($_CB_database));
         if (!$_CB_database->getErrorNum()) {
             $profileLink = $params->get('allow_profilelink', 1);
             // If users exist lets cache them and disable profile linking if necessary:
             if ($users) {
                 foreach (array_keys($users) as $k) {
                     // Add this user to cache:
                     CBuser::setUserGetCBUserInstance($users[$k]);
                     if (!$profileLink) {
                         $users[$k]->set('_allowProfileLink', 0);
                     }
                 }
             }
         } else {
             $errorMsg = CBTxt::T('UE_ERROR_IN_QUERY_TURN_SITE_DEBUG_ON_TO_VIEW', 'There is an error in the database query. Site admin can turn site debug to on to view and fix the query.');
         }
         if ($searchCount) {
             $search = '';
         } else {
             $search = null;
         }
         if ($search === null && ($searchMode == 1 && $searchCount || $searchMode == 2)) {
             $search = '';
         }
     } else {
         $total = 0;
         $users = array();
         if ($search === null) {
             $search = '';
         }
     }
     $pageNav = new cbPageNav($total, $limitstart, $limit);
     HTML_comprofiler::usersList($row, $users, $columns, $fields, $input, $search, $searchMode, $pageNav, $user, $searchableFields, $searchValues, $tabs, $errorMsg, $listAll, $random);
 }