/** * @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() . ' /> ' . ' <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; }
/** * Checks user access permission * * @param int $userIdPosted * @return null|string */ private function _authorizedEdit($userIdPosted) { global $_CB_framework; $iAmAdmin = Application::MyUser()->isSuperAdmin(); if (!$iAmAdmin) { if (Application::MyUser()->isAuthorizedToPerformActionOnAsset('core.manage', 'com_users')) { if ($userIdPosted == 0) { $action = 'core.create'; } elseif ($userIdPosted == $_CB_framework->myId()) { $action = 'core.edit.own'; } else { $action = 'core.edit'; } $iAmAdmin = Application::MyUser()->isAuthorizedToPerformActionOnAsset($action, 'com_users') && !Application::User((int) $userIdPosted)->isSuperAdmin(); } } if (!$iAmAdmin) { return CBTxt::T("Not Authorized"); } else { return null; } }
/** * @param cbgalleryFolderTable $row * @param string $type * @param UserTable $viewer * @param UserTable $user * @param TabTable $tab * @param cbTabHandler $plugin * @return string */ static public function showFolder( $row, $type, $viewer, $user, $tab, $plugin ) { global $_CB_framework, $_PLUGINS; $_PLUGINS->trigger( 'gallery_onBeforeDisplayFolder', array( &$row, $type, $viewer, $user, $tab, $plugin ) ); /** @var Registry $params */ $params = $tab->params; switch( $type ) { case 'photos': $galleryType = CBTxt::T( 'Photos' ); break; case 'files': $galleryType = CBTxt::T( 'Files' ); break; case 'videos': $galleryType = CBTxt::T( 'Videos' ); break; case 'music': $galleryType = CBTxt::T( 'Music' ); break; default: $galleryType = CBTxt::T( 'Items' ); break; } switch( $type ) { case 'photos': case 'videos': case 'music': $typeTranslated = CBTxt::T( 'Album' ); break; default: $typeTranslated = CBTxt::T( 'Folder' ); break; } $profileOwner = ( $viewer->get( 'id' ) == $user->get( 'id' ) ); $cbModerator = Application::User( (int) $viewer->get( 'id' ) )->isGlobalModerator(); $date = cbFormatDate( $row->get( 'date' ), true, (int) $params->get( 'tab_' . $type . '_folder_items_time_display', 0 ), $params->get( 'tab_' . $type . '_folder_items_date_format', 'F j, Y' ), $params->get( 'tab_' . $type . '_folder_items_time_format', ' g:h A' ) ); $return = '<div class="galleryFolderTitle page-header clearfix">' . '<h3 class="row">' . '<div class="col-sm-8 text-left">' . ( $row->get( 'title' ) ? htmlspecialchars( $row->get( 'title' ) ) . ( $row->get( 'id' ) !== 0 ? '<div class="small" title="' . htmlspecialchars( $row->get( 'date' ) ) . '">' . $date . '</div>' : null ) : $date ) . '</div>' . '<div class="col-sm-4 text-right">' . '<small>' . '<a href="' . $_CB_framework->userProfileUrl( (int) $user->get( 'id' ), true, (int) $tab->get( 'tabid' ) ) . '">' . CBuser::getInstance( (int) $row->get( 'user_id' ), false )->getField( 'formatname', null, 'html', 'none', 'profile', 0, true ) . '</a>' . '</small>'; if ( ( $row->get( 'id' ) !== 0 ) && ( $cbModerator || $profileOwner ) ) { $menuItems = '<ul class="galleryFolderMenuItems dropdown-menu" style="display: block; position: relative; margin: 0;">' . '<li class="galleryFolderMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'folders', 'func' => 'edit', 'type' => $type, 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ), 'folder' => true ) ) . '"><span class="fa fa-edit"></span> ' . CBTxt::T( 'Edit' ) . '</a></li>'; if ( ( $row->get( 'published' ) == -1 ) && $plugin->params->get( $type . '_folder_approval', 0 ) ) { if ( $cbModerator ) { $menuItems .= '<li class="galleryFolderMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'folders', 'func' => 'publish', 'type' => $type, 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ), 'folder' => true ) ) . '"><span class="fa fa-check"></span> ' . CBTxt::T( 'Approve' ) . '</a></li>'; } } elseif ( $row->get( 'published' ) > 0 ) { $menuItems .= '<li class="galleryFolderMenuItem"><a href="javascript: void(0);" onclick="if ( confirm( \'' . addslashes( CBTxt::T( 'FOLDER_UNPUBLISH_TYPE', 'Are you sure you want to unpublish this [type]?', array( '[type]' => $typeTranslated ) ) ) . '\' ) ) { location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'folders', 'func' => 'unpublish', 'type' => $type, 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ), 'folder' => true ) ) . '\'; }"><span class="fa fa-times-circle"></span> ' . CBTxt::T( 'Unpublish' ) . '</a></li>'; } else { $menuItems .= '<li class="galleryFolderMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'folders', 'func' => 'publish', 'type' => $type, 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ), 'folder' => true ) ) . '"><span class="fa fa-check"></span> ' . CBTxt::T( 'Publish' ) . '</a></li>'; } $menuItems .= '<li class="galleryFolderMenuItem"><a href="javascript: void(0);" onclick="if ( confirm( \'' . addslashes( CBTxt::T( 'FOLDER_DELETE_TYPE', 'Are you sure you want to delete this [folder_type] and all its [item_type]?', array( '[folder_type]' => $typeTranslated, '[item_type]' => $galleryType ) ) ) . '\' ) ) { location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'folders', 'func' => 'delete', 'type' => $type, 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '\'; }"><span class="fa fa-trash-o"></span> ' . CBTxt::T( 'Delete' ) . '</a></li>' . '</ul>'; $menuAttr = cbTooltip( 1, $menuItems, null, 'auto', null, null, null, 'class="btn btn-default btn-xs" data-cbtooltip-menu="true" data-cbtooltip-classes="qtip-nostyle"' ); $return .= '<div class="folderMenu">' . '<div class="galleryFolderMenu btn-group">' . '<button type="button" ' . trim( $menuAttr ) . '><span class="fa fa-cog"></span> <span class="fa fa-caret-down"></span></button>' . '</div>' . '</div>'; } $return .= '</div>' . '</h3>' . '</div>' . ( $row->get( 'description' ) ? '<div class="galleryFolderDescription well well-sm">' . htmlspecialchars( $row->get( 'description' ) ) . '</div>' : null ); return $return; }
/** * @param int[] $paging * @param string $where * @param UserTable $viewer * @param UserTable $user * @param PluginTable $plugin * @return cbconsultationsconsultationTable[] */ static public function getconsultations( $paging, $where, $viewer, $user, /** @noinspection PhpUnusedParameterInspection */ $plugin ) { global $_CB_database; $categories = cbconsultationsModel::getCategoriesList( true ); $consultations = array(); if ( $categories ) { $query = 'SELECT a.*' . ', a.' . $_CB_database->NameQuote( 'created_by' ) . ' AS user' . ', a.' . $_CB_database->NameQuote( 'introtext' ) . ' AS consultation_intro' . ', a.' . $_CB_database->NameQuote( 'fulltext' ) . ' AS consultation_full' . ', b.' . $_CB_database->NameQuote( 'name' ) . ' AS category' . ', b.' . $_CB_database->NameQuote( 'published' ) . ' AS category_published' . ', b.' . $_CB_database->NameQuote( 'alias' ) . ' AS category_alias' . "\n FROM " . $_CB_database->NameQuote( '#__k2_items' ) . " AS a" . "\n LEFT JOIN " . $_CB_database->NameQuote( '#__k2_categories' ) . " AS b" . ' ON b.' . $_CB_database->NameQuote( 'id' ) . ' = a.' . $_CB_database->NameQuote( 'catid' ) . "\n LEFT JOIN " . $_CB_database->NameQuote( '#__users' ) . " AS c" . ' ON c.' . $_CB_database->NameQuote( 'id' ) . ' = a.' . $_CB_database->NameQuote( 'created_by' ) . "\n WHERE a." . $_CB_database->NameQuote( 'catid' ) . " IN ( " . implode( ',', $categories ) . " )" . "\n AND a." . $_CB_database->NameQuote( 'created_by' ) . " = " . (int) $user->get( 'id' ) . ( ( $viewer->get( 'id' ) != $user->get( 'id' ) ) && ( ! Application::User( (int) $viewer->get( 'id' ) )->isGlobalModerator() ) ? "\n AND a." . $_CB_database->NameQuote( 'published' ) . " = 1" : null ) . "\n AND a." . $_CB_database->NameQuote( 'access' ) . " IN " . $_CB_database->safeArrayOfIntegers( Application::MyUser()->getAuthorisedViewLevels() ) . $where . "\n ORDER BY a." . $_CB_database->NameQuote( 'created' ) . " DESC"; if ( $paging ) { $_CB_database->setQuery( $query, $paging[0], $paging[1] ); } else { $_CB_database->setQuery( $query ); } $consultations = $_CB_database->loadObjectList( null, 'cbconsultationsconsultationTable', array( $_CB_database ) ); } return $consultations; }
/** * @param cbinvitesInviteTable[] $rows * @param cbPageNav $pageNav * @param bool $searching * @param array $input * @param UserTable $viewer * @param UserTable $user * @param TabTable $tab * @param cbTabHandler $plugin * @return string */ static function showTab( $rows, $pageNav, $searching, $input, $viewer, $user, $tab, $plugin ) { global $_CB_framework, $_CB_database; $params = new Registry( $tab->params ); $profileOwner = ( $viewer->get( 'id' ) == $user->get( 'id' ) ); $cbModerator = Application::User( (int) $viewer->get( 'id' ) )->isGlobalModerator(); $tabPaging = $params->get( 'tab_paging', 1 ); $canSearch = ( $params->get( 'tab_search', 1 ) && ( $searching || $pageNav->total ) ); $inviteLimit = (int) $plugin->params->get( 'invite_limit', null ); $canCreate = false; $user_groups_can_create = array(12,16); //proizvoditeli, komercheskie organizacii $gids = $user->get('gids'); if ( $profileOwner ) { if ( $cbModerator ) { $canCreate = true; } elseif ( $user->get( 'id' ) ) { if ( $inviteLimit ) { $query = 'SELECT COUNT(*)' . "\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_invites' ) . "\n WHERE " . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->get( 'id' ) . "\n AND ( " . $_CB_database->NameQuote( 'user' ) . " IS NULL OR " . $_CB_database->NameQuote( 'user' ) . " = " . $_CB_database->Quote( '' ) . " )"; $_CB_database->setQuery( $query ); $inviteCount = (int) $_CB_database->loadResult(); if ( $inviteCount < $inviteLimit ) { $canCreate = true; } } else { $canCreate = true; } } } $groupcancreate = false; if($gids){ foreach($gids as $gid){ if(in_array($gid, $user_groups_can_create)){ $groupcancreate = true; } } } if(!$groupcancreate){ $canCreate = false; } $return = '<div class="medizdTab">' . '<form action="' . $_CB_framework->userProfileUrl( $user->get( 'id' ), true, $tab->tabid ) . '" method="post" name="medizdForm" id="inviteForm" class="medizdForm">'; if ( $canCreate || $canSearch ) { $return .= '<div class="medizdHeader row" style="margin-bottom: 10px;">'; if ( $canCreate ) { $return .= '<div class="' . ( ! $canSearch ? 'col-sm-12' : 'col-sm-8' ) . ' text-left">' . '<button type="button" onclick="location.href=\'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'medizd', 'func' => 'new' ) ) . '\';" class="invitesButton invitesButtonNew btn btn-success"><span class="fa fa-plus-circle"></span> ' . CBTxt::T( 'MEDPR_NEW_PRODUCT' ) . '</button>' . '</div>'; } if ( $canSearch ) { $return .= '<div class="' . ( ! $canCreate ? 'col-sm-offset-8 ' : null ) . 'col-sm-4 text-right">' . '<div class="input-group">' . '<span class="input-group-addon"><span class="fa fa-search"></span></span>' . $input['search'] . '</div>' . '</div>'; } $return .= '</div>'; } $menuAccess = ( $cbModerator || $profileOwner ); $return .= '<table class="invitesContainer table table-hover table-responsive">' . '<thead>' . '<tr>' . '<th class="text-left">' . CBTxt::T( 'MEDPR_CODE' ) . '</th>' . '<th style="width: 25%;" class="text-left hidden-xs">' . CBTxt::T( 'Name' ) . '</th>' . '<th style="width: 5%;" class="text-center hidden-xs">' . CBTxt::T( 'Date' ) . '</th>' . '<th style="width: 1%;" class="text-left hidden-xs"></th>' . '</tr>' . '</thead>' . '<tbody>'; if ( $rows ) foreach ( $rows as $row ) { $return .= '<tr>' . '<td class="text-left"><a href="'.JRoute::_(JUri::base().'index.php?option=com_medicineproducts&view=item&id='.$row->id).'">' . $row->code . '</td>' . '<td style="width: 50%;" class="text-left hidden-xs">' . $row->name . '</td>' . '<td style="width: 25%;" class="text-center hidden-xs">' . $row->created; $return .= '</td>'; if ( ( $cbModerator || $profileOwner ) ) { $menuItems = '<ul class="invitesMenuItems dropdown-menu" style="display: block; position: relative; margin: 0;">'; $link = $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'medizd', 'func' => 'edit', 'id' => (int) $row->get( 'id' ))); $menuItems .= '<li class="invitesMenuItem"><a href="' . $link . '"><span class="fa fa-edit"></span> ' . CBTxt::T( 'Edit' ) . '</a></li>' . '<li class="invitesMenuItem"><a href="javascript: void(0);" onclick="if ( confirm( \'' . addslashes( CBTxt::T( 'MEDPR_CONFIRM_DEL' ) ) . '\' ) ) { location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'medizd', 'func' => 'delete', 'id' => (int) $row->get( 'id' ) ) ) . '\'; }"><span class="fa fa-trash-o"></span> ' . CBTxt::T( 'Delete' ) . '</a></li>'; $menuItems .= '</ul>'; $menuAttr = cbTooltip( 1, $menuItems, null, 'auto', null, null, null, 'class="btn btn-default btn-xs" data-cbtooltip-menu="true" data-cbtooltip-classes="qtip-nostyle"' ); $return .= '<td style="width: 1%;" class="text-right">' . '<div class="invitesMenu btn-group">' . '<button type="button"' . $menuAttr . '><span class="fa fa-cog"></span> <span class="fa fa-caret-down"></span></button>' . '</div>' . '</td>'; } else{ $return .= '<td style="width: 1%;" class="text-right"></td>'; } $return .= '</tr>'; } else { $return .= '<tr>' . '<td colspan="3" class="text-left">'; if ( $searching ) { $return .= CBTxt::T( 'MEDPR_PRODUCT_SEARCH_NULL' ); } else { if ( $viewer->id == $user->id ) { $return .= CBTxt::T( 'MEDPR_NO_PRODUCT' ); } else { $return .= CBTxt::T( 'MEDPR_USER_NO_PRODUCT' ); } } $return .= '</td>' . '</tr>'; } $return .= '</tbody>'; if ( $tabPaging && ( $pageNav->total > $pageNav->limit ) ) { $return .= '<tfoot>' . '<tr>' . '<td colspan="3" class="text-center">' . $pageNav->getListLinks() . '</td>' . '</tr>' . '</tfoot>'; } $return .= '</table>' . $pageNav->getLimitBox( false ) . '</form>' . '</div>'; return $return; }
/** * Renders the Articles tab * * @param Table[] $rows Articles to render * @param cbPageNav $pageNav Pagination * @param boolean $searching Currently searching * @param string[] $input HTML of input elements * @param UserTable $viewer Viewing user * @param UserTable $user Viewed user * @param stdClass $model The model reference * @param TabTable $tab Current Tab * @param PluginTable $plugin Current Plugin * @return string HTML */ static public function showPreparatyTab( $rows, $pageNav, $searching, $input, $viewer, $user, /** @noinspection PhpUnusedParameterInspection */ $model, $tab, /** @noinspection PhpUnusedParameterInspection */ $plugin ) { global $_CB_framework, $_LANG; $app =& JFactory::getApplication(); $menu = $app->getMenu(); $active = $menu->getActive(); $Itemid = $active->id; $tabPaging = $tab->params->get( 'tab_paging', 1 ); $canSearch = ( $tab->params->get( 'tab_search', 1 ) && ( $searching || $pageNav->total ) ); $canCreate = false; $profileOwner = ( $viewer->get( 'id' ) == $user->get( 'id' ) ); $cbModerator = Application::User( (int) $viewer->get( 'id' ) )->isGlobalModerator(); //$canPublish = ( $cbModerator || ( $profileOwner && ( ! $plugin->params->get( 'hangout_approval', 0 ) ) ) ); if ( $profileOwner ) { if ( $cbModerator ) { $canCreate = true; } elseif ( $user->get( 'id' ) && Application::User( (int) $viewer->get( 'id' ) )->canViewAccessLevel( (int) $plugin->params->get( 'hangout_create_access', 2 ) ) ) { if ( ( ! $blogLimit ) || ( $blogLimit && ( $pageNav->total < $blogLimit ) ) ) { $canCreate = true; } } } $return = '<div class="articlesTab">' . '<form action="' . $_CB_framework->userProfileUrl( $user->id, true, $tab->tabid ) . '" method="post" name="articleForm" id="articleForm" class="articleForm">'; if ( $canCreate ) { $return .= '<div class="' . ( ! $canSearch ? 'col-sm-12' : 'col-sm-8' ) . ' text-left">' . '<button type="button" onclick="location.href=\'' . ($_CB_framework->getCfg( 'live_site' ).'/index.php?option=com_flexicontent&view=item&typeid=2&task=add&Itemid='.$Itemid) . '\';" class="blogsButton blogsButtonNew btn btn-success"><span class="fa fa-plus-circle"></span> ' . $_LANG['New Preparat'] . '</button>' . '</div>'; } if ( $canSearch ) { $return .= '<div class="articlesHeader row" style="margin-bottom: 10px;">' . '<div class="col-sm-offset-8 col-sm-4 text-right">' . '<div class="input-group">' . '<span class="input-group-addon"><span class="fa fa-search"></span></span>' . $input['search'] . '</div>' . '</div>' . '</div>'; } $return .= '<table class="articlesContainer table table-hover table-responsive">' . '<thead>' . '<tr>' . '<th style="width: 50%;" class="text-left">' . $_LANG['Preparat'] . '</th>' . '<th style="width: 25%;" class="text-left hidden-xs">' . CBTxt::T( 'Category' ) . '</th>' . '<th style="width: 25%;" class="text-left hidden-xs">' . CBTxt::T( 'Created' ) . '</th>' . '<th style="width: 1%;" class="text-left hidden-xs"></th>' . '</tr>' . '</thead>' . '<tbody>'; $attribs = ''; $image = FLEXI_J16GE ? JHTML::image(FLEXI_ICONPATH.'edit.png', JText::_( 'FLEXI_EDIT' ), $attribs) : JHTML::_('image.site', 'edit.png', FLEXI_ICONPATH, NULL, NULL, JText::_( 'FLEXI_EDIT' ), $attribs) ; if ( $rows ) foreach ( $rows as $row ) { $item_url = cbpreparatyModel::getUrl( $row, true, 'article' , $Itemid); //$item_url_edit = cbpreparatyModel::getUrl( $row, true, 'article' , 445); $link = $_CB_framework->getCfg( 'live_site' ). '/' .$item_url .(strstr($item_url, '?') ? '&' : '?'). 'task=edit'; $edit_row = $profileOwner ? '<a href="'.$link.'">'.$image.'</a> ' : ''; $return .= '<tr>' . '<td style="width: 50%;" class="text-left">'.$edit_row.'<a href="' . cbpreparatyModel::getUrl( $row, true, 'article' ) . '">' . $row->get( 'title' ) . '</a></td>' . '<td style="width: 25%;" class="text-left hidden-xs">' . ( $row->get( 'category' ) ? $row->get( 'category_title' ) : CBTxt::T( 'None' ) ) . '</td>' . '<td style="width: 25%;" class="text-left hidden-xs">' . cbFormatDate( $row->get( 'created' ) ) . '</td>'; if ( ( $cbModerator || $profileOwner ) ) { $menuItems = '<ul class="invitesMenuItems dropdown-menu" style="display: block; position: relative; margin: 0;">'; $menuItems .= '<li class="invitesMenuItem"><a href="' . $link . '"><span class="fa fa-edit"></span> ' . CBTxt::T( 'Edit' ) . '</a></li>' . '<li class="invitesMenuItem"><a href="javascript: void(0);" onclick="if ( confirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to delete this Drug?' ) ) . '\' ) ) { location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'preparaty', 'func' => 'delete', 'id' => (int) $row->get( 'id' ) ) ) . '\'; }"><span class="fa fa-trash-o"></span> ' . CBTxt::T( 'Delete' ) . '</a></li>'; $menuItems .= '</ul>'; $menuAttr = cbTooltip( 1, $menuItems, null, 'auto', null, null, null, 'class="btn btn-default btn-xs" data-cbtooltip-menu="true" data-cbtooltip-classes="qtip-nostyle"' ); $return .= '<td style="width: 1%;" class="text-right">' . '<div class="invitesMenu btn-group">' . '<button type="button"' . $menuAttr . '><span class="fa fa-cog"></span> <span class="fa fa-caret-down"></span></button>' . '</div>' . '</td>'; } else{ $return .= '<td style="width: 1%;" class="text-right"></td>'; } $return .= '</tr>'; } else { $return .= '<tr>' . '<td colspan="3" class="text-left">'; if ( $searching ) { $return .= $_LANG['No preparaty search results found.']; } else { if ( $viewer->id == $user->id ) { $return .= $_LANG['You have no preparaty.']; } else { $return .= $_LANG['This user has no preparaty.']; } } $return .= '</td>' . '</tr>'; } $return .= '</tbody>'; if ( $tabPaging && ( $pageNav->total > $pageNav->limit ) ) { $return .= '<tfoot>' . '<tr>' . '<td colspan="3" class="text-center">' . $pageNav->getListLinks() . '</td>' . '</tr>' . '</tfoot>'; } $return .= '</table>' . $pageNav->getLimitBox( false ) . '</form>' . '</div>'; return $return; }
/** * @param \CB\Database\Table\UserTable $user */ public function prepareStatus($user) { global $_CB_framework; $this->ui = $_CB_framework->getUi(); $this->cbUserIsModerator = Application::User((int) $user->id)->isGlobalModerator(); $this->cbMyIsModerator = Application::MyUser()->isModeratorFor(Application::User((int) $user->id)); $params = $this->params; switch ($params->get('statusFormat', 'menuList')) { case 'menuBar': $this->menuList = new cbMenuBar(1); break; case 'menuUL': $this->menuList = new cbMenuUL(1); break; case 'menuDivs': $this->menuList = new cbMenuDivs(1); break; case 'menuList': default: $this->menuList = new cbMenuList(1); break; } $this->menuList->outputScripts(1); }
/** * Sends a PM notification * * @param cbmypmsproTable $pm * @param null|string $message */ private function sendNotification($pm, $message = null) { if (!$pm->get('id')) { return; } $itemId = uddeIMgetItemid($this->uddeIMConfigRAW); if (!uddeIMexistsEMN($pm->get('toid'))) { uddeIMinsertEMNdefaults($pm->get('toid'), $this->uddeIMConfigRAW); } $emailNotify = $this->uddeIMConfig->get('allowemailnotify', 0); $isModerated = uddeIMgetEMNmoderated($pm->get('fromid')); $isReply = stristr($pm->get('message'), $this->uddeIMConfig->get('quotedivider'), '__________'); $isOnline = uddeIMisOnline($pm->get('toid')); // Strip the html and bbcode as uddeim supports neither in its notification: $message = strip_tags(uddeIMbbcode_strip($message ? $message : $pm->get('message'), $this->uddeIMConfigRAW)); if (!$isModerated) { if ($emailNotify == 1 || $emailNotify == 2 && Application::User($pm->get('toid'))->isSuperAdmin()) { $status = uddeIMgetEMNstatus($pm->get('toid')); if ($status == 1 || $status == 2 && !$isOnline || $status == 10 && !$isReply || $status == 20 && !$isOnline && !$isReply) { uddeIMdispatchEMN($pm->get('id'), $itemId, 0, $pm->get('fromid'), $pm->get('toid'), $message, 0, $this->uddeIMConfigRAW); } } } }
/** * @param int[] $paging * @param string $where * @param UserTable $viewer * @param UserTable $user * @param PluginTable $plugin * @return cbblogsBlogTable[] */ static public function getBlogs( $paging, $where, $viewer, $user, $plugin ) { global $_CB_database; $section = $plugin->params->get( 'blog_j_section', null ); $query = 'SELECT a.*' . ', a.' . $_CB_database->NameQuote( 'created_by' ) . ' AS user' . ', a.' . $_CB_database->NameQuote( 'introtext' ) . ' AS blog_intro' . ', a.' . $_CB_database->NameQuote( 'fulltext' ) . ' AS blog_full' . ', a.' . $_CB_database->NameQuote( 'state' ) . ' AS published' . ', b.' . $_CB_database->NameQuote( 'title' ) . ' AS category' . ', b.' . $_CB_database->NameQuote( 'published' ) . ' AS category_published' . ', b.' . $_CB_database->NameQuote( 'alias' ) . ' AS category_alias' . "\n FROM " . $_CB_database->NameQuote( '#__content' ) . " AS a" . "\n LEFT JOIN " . $_CB_database->NameQuote( '#__categories' ) . " AS b" . ' ON b.' . $_CB_database->NameQuote( 'id' ) . ' = a.' . $_CB_database->NameQuote( 'catid' ) . "\n LEFT JOIN " . $_CB_database->NameQuote( '#__users' ) . " AS c" . ' ON c.' . $_CB_database->NameQuote( 'id' ) . ' = a.' . $_CB_database->NameQuote( 'created_by' ); if ( $section ) { $query .= "\n LEFT JOIN " . $_CB_database->NameQuote( '#__categories' ) . " AS d" . ' ON d.' . $_CB_database->NameQuote( 'id' ) . ' = ' . (int) $section; } $query .= "\n WHERE b." . $_CB_database->NameQuote( 'extension' ) . " = " . $_CB_database->Quote( 'com_content' ); if ( $section ) { $query .= "\n AND b." . $_CB_database->NameQuote( 'lft' ) . " BETWEEN ( d." . $_CB_database->NameQuote( 'lft' ) . " + 1 ) AND ( d." . $_CB_database->NameQuote( 'rgt' ) . " - 1 )" . "\n AND d." . $_CB_database->NameQuote( 'extension' ) . " = " . $_CB_database->Quote( 'com_content' ); } $query .= "\n AND a." . $_CB_database->NameQuote( 'created_by' ) . " = " . (int) $user->get( 'id' ) . ( ( $viewer->get( 'id' ) != $user->get( 'id' ) ) && ( ! Application::User( (int) $viewer->get( 'id' ) )->isGlobalModerator() ) ? "\n AND a." . $_CB_database->NameQuote( 'state' ) . " = 1" : null ) . "\n AND a." . $_CB_database->NameQuote( 'access' ) . " IN " . $_CB_database->safeArrayOfIntegers( Application::MyUser()->getAuthorisedViewLevels() ) . "\n AND b." . $_CB_database->NameQuote( 'published' ) . " = 1" . "\n AND b." . $_CB_database->NameQuote( 'access' ) . " IN " . $_CB_database->safeArrayOfIntegers( Application::MyUser()->getAuthorisedViewLevels() ) . $where . "\n ORDER BY a." . $_CB_database->NameQuote( 'created' ) . " DESC"; if ( $paging ) { $_CB_database->setQuery( $query, $paging[0], $paging[1] ); } else { $_CB_database->setQuery( $query ); } return $_CB_database->loadObjectList( null, 'cbblogsBlogTable', array( $_CB_database ) ); }
/** * @param int $id * @param UserTable $user */ private function deleteMedizd( $id, $user ) { global $_CB_framework; $cbModerator = Application::User( (int) $user->get( 'id' ) )->isGlobalModerator(); $row = new cbmedizdProductTable(); $row->load( (int) $id ); $canAccess = false; if ( $row->get( 'id' ) && ( $cbModerator || ( $row->get( 'user_id' ) == $user->get( 'id' ) ) ) ) { $canAccess = true; } $profileUrl = $_CB_framework->userProfileUrl( $row->get( 'user_id', $user->get( 'id' ) ), false, 'cbmedizdTab' ); if ( $canAccess ) { if ( ! $row->delete() ) { cbRedirect( $profileUrl, CBTxt::T( 'FAILED_DELETE_ERROR', 'Failed to delete! Error: [error]', array( '[error]' => $row->getError() ) ), 'error' ); } cbRedirect( $profileUrl, CBTxt::T( 'MEDPR_PROD_DELSUCC' ) ); } else { cbRedirect( $profileUrl, CBTxt::T( 'Not authorized.' ), 'error' ); } }
/** * @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() . ' /> ' . ' <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; }
/** * @param cbinvitesInviteTable $row * @param array $input * @param UserTable $user * @param cbPluginHandler $plugin */ static function showProductEdit( $row, $input, $user, $plugin ) { global $_CB_framework, $_PLUGINS; cbValidator::loadValidation(); $cbModerator = Application::User( (int) $user->get( 'id' ) )->isGlobalModerator(); $pageTitle = ( $row->get( 'id' ) ? CBTxt::T( 'MEDPR_EDIT_PRODUCT' ) : CBTxt::T( 'MEDPR_CREATE_PRODUCT' ) ); $_CB_framework->setPageTitle( $pageTitle ); $_CB_framework->appendPathWay( htmlspecialchars( CBTxt::T( 'MEDPR_MEDICINE_PRODUCT' ) ), $_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' => 'medizd', 'func' => 'edit', 'id' => (int) $row->get( 'id' ) ) : array( 'action' => 'medizd', 'func' => 'new' ) ) ) ); initToolTip(); $return = '<div class="medizdEdit">' . '<form action="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'medizd', 'func' => 'save', 'id' => (int) $row->get( 'id' ) ) ) . '" method="post" enctype="multipart/form-data" name="medizdForm" id="medizdForm" class="cb_form medizdForm 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( 'MEDPR_CODE' ) . '</label>' . '<div class="cb_field col-sm-9">' . $input['code'] . getFieldIcons( 1, 1, null) . '</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( 'Name' ) . '</label>' . '<div class="cb_field col-sm-9">' . $input['name'] . getFieldIcons( 1, 1, null) . '</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( 'MEDPR_DESCRIPTION' ) . '</label>' . '<div class="cb_field col-sm-9">' . $input['description'] . getFieldIcons( 1, 0, null ) . '</div>' . '</div>'; $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( 'Category' ) . '</label>' . '<div class="cb_field col-sm-9">' . $input['category'] . getFieldIcons( 1, 1, null) . '</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( 'MEDPR_MANUFACTURE' ) . '</label>' . '<div class="cb_field col-sm-9">' . $input['proizvoditel'] . getFieldIcons( 1, 0, null) . '</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( 'MEDPR_COUNTRY' ) . '</label>' . '<div class="cb_field col-sm-9">' . $input['country'] . getFieldIcons( 1, 0, null) . '</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( 'MEDPR_PRICE' ) . '</label>' . '<div class="cb_field col-sm-9">' . $input['price'] . getFieldIcons( 1, 0, 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( 'MEDPR_UPDATE_PRODUCT' ) : CBTxt::T( 'MEDPR_SAVE_PRODUCT' ) ) ) . '" class="invitesButton invitesButtonSubmit btn btn-primary"' . cbValidator::getSubmitBtnHtmlAttributes() . ' /> ' . ' <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, 'cbmedizdFormTab' ) . '\'; }" />' . '</div>' . '</div>' . cbGetSpoofInputTag( 'plugin' ) . '</form>' . '</div>'; echo $return; }
/** * @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() . ' /> ' . ' <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; }
static function userProfile($user, $option, $submitvalue) { global $_CB_framework, $ueConfig, $_POST, $_PLUGINS; $_PLUGINS->loadPluginGroup('user'); $_PLUGINS->trigger('onBeforeUserProfileRequest', array(&$user, 1)); if ($_PLUGINS->is_errors()) { echo "<script type=\"text/javascript\">alert(\"" . $_PLUGINS->getErrorMSG() . "\"); window.history.go(-1); </script>\n"; exit; } $cbTemplate = HTML_comprofiler::_cbTemplateLoad(); $cbMyIsModerator = Application::MyUser()->isModeratorFor(Application::User((int) $user->id)); $cbUserIsModerator = Application::User((int) $user->id)->isGlobalModerator(); $showProfile = 1; if ($user->banned != 0 || $user->block == 1 && $user->confirmed && $user->approved) { if ($user->banned != 0) { if ($_CB_framework->myId() != $user->id) { $_CB_framework->enqueueMessage(CBTxt::T('UE_USERPROFILEBANNED', 'This profile has been banned by a moderator.') . ($user->bannedreason && $cbMyIsModerator ? '<p>' . nl2br($user->bannedreason) . '</p>' : null), 'error'); } else { $_CB_framework->enqueueMessage(CBTxt::T('UE_BANNED_CHANGE_PROFILE', 'Your Profile is banned. Only you and moderators can see it.<br />Please follow the request of the moderator, then choose moderation / unban to submit a request for unbanning your profile.') . ($user->bannedreason ? '<p>' . nl2br($user->bannedreason) . '</p>' : null), 'error'); } } if ($user->block == 1) { $_CB_framework->enqueueMessage(CBTxt::T('UE_USERPROFILEBLOCKED', 'This profile is no longer available.'), 'error'); } if ($_CB_framework->myId() != $user->id && $cbMyIsModerator != 1) { $showProfile = 0; } } if (!$user->confirmed) { $_CB_framework->enqueueMessage(CBTxt::T('UE_USER_NOT_CONFIRMED', 'This user has not yet confirmed his email address and account!'), 'error'); } if (!$user->approved) { $_CB_framework->enqueueMessage(CBTxt::T('UE_USER_NOT_APPROVED', 'This user has not yet been approved by a moderator!'), 'error'); } if ((!$user->confirmed || !$user->approved) && $cbMyIsModerator != 1) { $showProfile = 0; } if ($showProfile == 1) { $results = $_PLUGINS->trigger('onBeforeUserProfileDisplay', array(&$user, 1, $cbUserIsModerator, $cbMyIsModerator)); if ($_PLUGINS->is_errors()) { echo "<script type=\"text/javascript\">alert(\"" . $_PLUGINS->getErrorMSG() . "\"); window.history.go(-1); </script>\n"; exit; } $output = 'html'; $cbUser =& CBuser::getInstance($user->id); $_CB_framework->displayedUser((int) $user->id); $userViewTabs = $cbUser->getProfileView(); $_CB_framework->setPageTitle(cbUnHtmlspecialchars(getNameFormat($user->name, $user->username, $ueConfig['name_format']))); $_CB_framework->appendPathWay(getNameFormat($user->name, $user->username, $ueConfig['name_format'])); outputCbTemplate(1); initToolTip(1); $pageClass = $_CB_framework->getMenuPageClass(); $return = '<div class="cbProfile cb_template cb_template_' . selectTemplate('dir') . ($pageClass ? ' ' . htmlspecialchars($pageClass) : null) . '">'; if (is_array($results)) { $return .= implode('', $results); } $return .= $_PLUGINS->callTemplate($cbTemplate, 'Profile', 'drawProfile', array(&$user, &$userViewTabs), $output) . '</div>' . cbPoweredBy(); echo $return; if ($_CB_framework->myId() != $user->id) { recordViewHit($_CB_framework->myId(), $user->id, getenv('REMOTE_ADDR')); } $_PLUGINS->trigger('onAfterUserProfileDisplay', array($user, true)); $_CB_framework->setMenuMeta(); } }
/** * @param cbgalleryFolderTable[] $rows * @param cbPageNav $pageNav * @param int $uncategorized * @param string $type * @param UserTable $viewer * @param UserTable $user * @param TabTable $tab * @param cbTabHandler $plugin * @return string */ static public function showFolders( $rows, $pageNav, $uncategorized, $type, $viewer, $user, $tab, $plugin ) { global $_CB_framework, $_PLUGINS; $_PLUGINS->trigger( 'gallery_onBeforeDisplayFolders', array( &$rows, $pageNav, $uncategorized, $type, $viewer, $user, $tab, $plugin ) ); switch( $type ) { case 'photos': $galleryType = CBTxt::T( 'Photos' ); break; case 'files': $galleryType = CBTxt::T( 'Files' ); break; case 'videos': $galleryType = CBTxt::T( 'Videos' ); break; case 'music': $galleryType = CBTxt::T( 'Music' ); break; default: $galleryType = CBTxt::T( 'Items' ); break; } switch( $type ) { case 'photos': case 'videos': case 'music': $typeTranslated = CBTxt::T( 'Album' ); break; default: $typeTranslated = CBTxt::T( 'Folder' ); break; } /** @var Registry $params */ $params = $tab->params; $profileOwner = ( $viewer->get( 'id' ) == $user->get( 'id' ) ); $cbModerator = Application::User( (int) $viewer->get( 'id' ) )->isGlobalModerator(); $return = '<div class="' . htmlspecialchars( $type ) . 'FoldersContainer" style="margin-bottom: 10px;">'; if ( $uncategorized ) { switch( $type ) { case 'photos': $count = CBTxt::T( 'FOLDER_PHOTOS_COUNT', '%%COUNT%% Photo|%%COUNT%% Photos', array( '%%COUNT%%' => $uncategorized ) ); break; case 'files': $count = CBTxt::T( 'FOLDER_FILES_COUNT', '%%COUNT%% File|%%COUNT%% Files', array( '%%COUNT%%' => $uncategorized ) ); break; case 'videos': $count = CBTxt::T( 'FOLDER_VIDEOS_COUNT', '%%COUNT%% Video|%%COUNT%% Videos', array( '%%COUNT%%' => $uncategorized ) ); break; case 'music': $count = CBTxt::T( 'FOLDER_MUSIC_COUNT', '%%COUNT%% Music|%%COUNT%% Music', array( '%%COUNT%%' => $uncategorized ) ); break; default: $count = CBTxt::T( 'FOLDER_ITEM_COUNT', '%%COUNT%% Item|%%COUNT%% Items', array( '%%COUNT%%' => $uncategorized ) ); break; } $return .= '<div class="galleryContainer img-thumbnail">' . '<div class="galleryContainerInner" style="height: 100px; width: 100px;">' . '<div class="galleryContainerTop" style="height: 60px">' . '<div class="galleryContainerContent">' . ( $uncategorized ? '<span class="galleryFoldersNotEmpty fa fa-folder-open-o"></span>' : '<span class="galleryFoldersEmpty fa fa-folder-o"></span>' ) . '</div>' . '</div>' . '<div class="galleryContainerBottom" style="height: 40px">' . '<div class="galleryContainerContent">' . '<div class="galleryContainerContentRow text-nowrap text-overflow small">' . '<strong>' . '<a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'folders', 'func' => 'show', 'type' => $type, 'id' => 0, 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '">' . CBTxt::T( 'Uncategorized' ) . '</a>' . '</strong>' . '</div>' . '<div class="galleryContainerContentRow text-nowrap text-overflow small">' . $count . '</div>' . '</div>' . '</div>' . '</div>' . '</div>'; } if ( $rows ) foreach ( $rows as $row ) { $return .= '<div class="galleryContainer img-thumbnail">'; if ( $cbModerator || $profileOwner ) { $menuItems = '<ul class="galleryFoldersMenuItems dropdown-menu" style="display: block; position: relative; margin: 0;">' . '<li class="galleryFoldersMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'folders', 'func' => 'edit', 'type' => $type, 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '"><span class="fa fa-edit"></span> ' . CBTxt::T( 'Edit' ) . '</a></li>'; if ( ( $row->get( 'published' ) == -1 ) && $plugin->params->get( $type . '_folder_approval', 0 ) ) { if ( $cbModerator ) { $menuItems .= '<li class="galleryFoldersMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'folders', 'func' => 'publish', 'type' => $type, 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '"><span class="fa fa-check"></span> ' . CBTxt::T( 'Approve' ) . '</a></li>'; } } elseif ( $row->get( 'published' ) > 0 ) { $menuItems .= '<li class="galleryFoldersMenuItem"><a href="javascript: void(0);" onclick="if ( confirm( \'' . addslashes( CBTxt::T( 'FOLDER_UNPUBLISH_TYPE', 'Are you sure you want to unpublish this [type]?', array( '[type]' => $typeTranslated ) ) ) . '\' ) ) { location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'folders', 'func' => 'unpublish', 'type' => $type, 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '\'; }"><span class="fa fa-times-circle"></span> ' . CBTxt::T( 'Unpublish' ) . '</a></li>'; } else { $menuItems .= '<li class="galleryFoldersMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'folders', 'func' => 'publish', 'type' => $type, 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '"><span class="fa fa-check"></span> ' . CBTxt::T( 'Publish' ) . '</a></li>'; } $menuItems .= '<li class="galleryFoldersMenuItem"><a href="javascript: void(0);" onclick="if ( confirm( \'' . addslashes( CBTxt::T( 'FOLDER_DELETE_TYPE', 'Are you sure you want to delete this [folder_type] and all its [item_type]?', array( '[folder_type]' => $typeTranslated, '[item_type]' => $galleryType ) ) ) . '\' ) ) { location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'folders', 'func' => 'delete', 'type' => $type, 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '\'; }"><span class="fa fa-trash-o"></span> ' . CBTxt::T( 'Delete' ) . '</a></li>' . '</ul>'; $menuAttr = cbTooltip( 1, $menuItems, null, 'auto', null, null, null, 'class="btn btn-default btn-xs" data-cbtooltip-menu="true" data-cbtooltip-classes="qtip-nostyle"' ); $return .= '<div class="galleryContainerMenu">' . '<div class="galleryFoldersMenu btn-group">' . '<button type="button" ' . trim( $menuAttr ) . '><span class="fa fa-cog"></span> <span class="fa fa-caret-down"></span></button>' . '</div>' . '</div>'; } $title = ( $row->get( 'title' ) ? htmlspecialchars( $row->get( 'title' ) ) : cbFormatDate( $row->get( 'date' ), true, (int) $params->get( 'tab_' . $type . '_folders_time_display', 0 ), $params->get( 'tab_' . $type . '_folders_date_format', 'M j, Y' ), $params->get( 'tab_' . $type . '_folders_time_format', ' g:h A' ) ) ); switch( $type ) { case 'photos': $count = CBTxt::T( 'FOLDER_PHOTOS_COUNT', '%%COUNT%% Photo|%%COUNT%% Photos', array( '%%COUNT%%' => $row->countItems() ) ); break; case 'files': $count = CBTxt::T( 'FOLDER_FILES_COUNT', '%%COUNT%% File|%%COUNT%% Files', array( '%%COUNT%%' => $row->countItems() ) ); break; case 'videos': $count = CBTxt::T( 'FOLDER_VIDEOS_COUNT', '%%COUNT%% Video|%%COUNT%% Video', array( '%%COUNT%%' => $row->countItems() ) ); break; case 'music': $count = CBTxt::T( 'FOLDER_MUSIC_COUNT', '%%COUNT%% Music|%%COUNT%% Music', array( '%%COUNT%%' => $row->countItems() ) ); break; default: $count = CBTxt::T( 'FOLDER_ITEM_COUNT', '%%COUNT%% Item|%%COUNT%% Items', array( '%%COUNT%%' => $row->countItems() ) ); break; } $return .= '<div class="galleryContainerInner" style="height: 100px; width: 100px;">' . '<div class="galleryContainerTop" style="height: 60px">' . '<div class="galleryContainerContent">' . ( $row->countItems() ? '<span class="galleryFoldersNotEmpty fa fa-folder-open-o"></span>' : '<span class="galleryFoldersEmpty fa fa-folder-o"></span>' ) . '</div>' . '</div>' . '<div class="galleryContainerBottom" style="height: 40px">' . '<div class="galleryContainerContent">' . '<div class="galleryContainerContentRow text-nowrap text-overflow small">' . '<strong>' . '<a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'folders', 'func' => 'show', 'type' => $type, 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '" title="' . htmlspecialchars( $row->get( 'date' ) ) . '">' . $title . '</a>' . '</strong>' . '</div>' . '<div class="galleryContainerContentRow text-nowrap text-overflow small">' . $count . ( $row->get( 'description' ) ? '<div class="galleryContainerDescription">' . cbTooltip( 1, $row->get( 'description' ), $title, 400, null, '<span class="fa fa-info-circle text-muted"></span>' ) . '</div>' : null ) . '</div>' . '</div>' . '</div>' . '</div>' . '</div>'; } if ( $params->get( 'tab_' . $type . '_folders_paging', 1 ) && ( $pageNav->total > $pageNav->limit ) ) { $return .= '<div class="galleryFoldersPaging text-center">' . $pageNav->getListLinks() . '</div>'; } $return .= '</div>' . $pageNav->getLimitBox( false ); return $return; }
/** * Deletes a folder * * @param int $id * @param string $type * @param TabTable $tab * @param UserTable $user * @param UserTable $viewer */ private function deleteFolder( $id, $type, $tab, $user, $viewer ) { global $_CB_framework; $row = new cbgalleryFolderTable(); $row->load( (int) $id ); $profileUrl = $_CB_framework->userProfileUrl( (int) $row->get( 'user_id', $user->get( 'id' ) ), false, $tab->get( 'tabid' ) ); if ( ( ! $row->get( 'id' ) ) || ( $row->get( 'type' ) != $type ) || ( ( $viewer->get( 'id' ) != $row->get( 'user_id' ) ) && ( ! Application::User( (int) $viewer->get( 'id' ) )->isGlobalModerator() ) ) ) { cbRedirect( $profileUrl, CBTxt::T( 'Not authorized.' ), 'error' ); } switch( $type ) { case 'photos': case 'videos': case 'music': $typeTranslated = CBTxt::T( 'Album' ); break; default: $typeTranslated = CBTxt::T( 'Folder' ); break; } if ( ! $row->canDelete() ) { cbRedirect( $profileUrl, CBTxt::T( 'FOLDER_FAILED_TO_DELETE', '[type] failed to delete! Error: [error]', array( '[type]' => $typeTranslated, '[error]' => $row->getError() ) ), 'error' ); } if ( ! $row->delete() ) { cbRedirect( $profileUrl, CBTxt::T( 'FOLDER_FAILED_TO_DELETE', '[type] failed to delete! Error: [error]', array( '[type]' => $typeTranslated, '[error]' => $row->getError() ) ), 'error' ); } cbRedirect( $profileUrl, CBTxt::T( 'FOLDER_DELETED_SUCCESSFULLY', '[type] deleted successfully!', array( '[type]' => $typeTranslated ) ) ); }
function deleteUsers($cid, $inComprofilerOnly = false) { global $_CB_framework; $msg = null; if (!Application::MyUser()->isAuthorizedToPerformActionOnAsset('core.admin', 'com_comprofiler')) { $msg = CBTxt::T('You cannot delete a user. Only higher-level users have this power.'); } if (!$msg && is_array($cid) && count($cid)) { new cbTabs(0, 2, null, false); // loads plugins foreach ($cid as $id) { $obj = null; if (!$inComprofilerOnly) { $obj =& $_CB_framework->_getCmsUserObject((int) $id); } if ($obj !== null || $inComprofilerOnly) { // Just a double-check as framework checks that too: if ($_CB_framework->myId() != $id && ($obj === null || !(Application::User((int) $id)->isSuperAdmin() && !Application::MyUser()->isSuperAdmin()))) { // delete user $result = cbDeleteUser($id, null, $inComprofilerOnly); if ($result === null) { $msg .= CBTxt::T('User not found'); } elseif (is_string($result) && $result != "") { $msg .= $result; } } else { // cannot delete Super Admin where it is the only one that exists $msg .= CBTxt::T('You cannot delete yourself nor a Super Administrator without being Super Administrator'); } } else { $msg .= CBTxt::T('User not found'); } } } return $msg; }
/** * @param int $id * @param UserTable $user * @param stdClass $model * @param PluginTable $plugin */ private function deleteBlog( $id, $user, /** @noinspection PhpUnusedParameterInspection */ $model, /** @noinspection PhpUnusedParameterInspection */ $plugin ) { global $_CB_framework; $row = new cbblogsBlogTable(); $canAccess = false; if ( $row->load( (int) $id ) ) { if ( $row->get( 'id' ) && ( ( $row->get( 'user' ) == $user->get( 'id' ) ) || Application::User( (int) $user->get( 'id' ) )->isGlobalModerator() ) ) { $canAccess = true; } } $profileUrl = $_CB_framework->userProfileUrl( $row->get( 'user', $user->get( 'id' ) ), false, 'cbblogsTab' ); if ( $canAccess ) { if ( ! $row->canDelete() ) { cbRedirect( $profileUrl, CBTxt::T( 'BLOG_FAILED_TO_DELETE_ERROR_ERROR', 'Blog failed to delete! Error: [error]', array( '[error]' => $row->getError() ) ), 'error' ); } if ( ! $row->delete( (int) $id ) ) { cbRedirect( $profileUrl, CBTxt::T( 'BLOG_FAILED_TO_DELETE_ERROR_ERROR', 'Blog failed to delete! Error: [error]', array( '[error]' => $row->getError() ) ), 'error' ); } cbRedirect( $profileUrl, CBTxt::T( 'Blog deleted successfully!' ) ); } else { cbRedirect( $profileUrl, CBTxt::T( 'Not authorized.' ), 'error' ); } }
/** * @param int[] $paging * @param string $where * @param UserTable $viewer * @param UserTable $user * @param PluginTable $plugin * @return cbconsultationsconsultationTable[] */ static public function getconsultations( $paging, $where, $viewer, $user, /** @noinspection PhpUnusedParameterInspection */ $plugin ) { global $_CB_database; $query = 'SELECT a.*' . "\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_consultations' ) . " AS a" . "\n LEFT JOIN " . $_CB_database->NameQuote( '#__users' ) . " AS c" . ' ON c.' . $_CB_database->NameQuote( 'id' ) . ' = a.' . $_CB_database->NameQuote( 'user' ) . "\n WHERE a." . $_CB_database->NameQuote( 'user' ) . " = " . (int) $user->get( 'id' ) . ( ( $viewer->get( 'id' ) != $user->get( 'id' ) ) && ( ! Application::User( (int) $viewer->get( 'id' ) )->isGlobalModerator() ) ? "\n AND a." . $_CB_database->NameQuote( 'published' ) . " = 1" : null ) . "\n AND a." . $_CB_database->NameQuote( 'access' ) . " IN " . $_CB_database->safeArrayOfIntegers( Application::MyUser()->getAuthorisedViewLevels() ) . $where . "\n ORDER BY a." . $_CB_database->NameQuote( 'created' ) . " DESC"; if ( $paging ) { $_CB_database->setQuery( $query, $paging[0], $paging[1] ); } else { $_CB_database->setQuery( $query ); } $consultations = $_CB_database->loadObjectList( null, 'cbconsultationsconsultationTable', array( $_CB_database ) ); return $consultations; }
/** * @param int $id * @param UserTable $user */ private function deleteInvite( $id, $user ) { global $_CB_framework; $cbModerator = Application::User( (int) $user->get( 'id' ) )->isGlobalModerator(); $row = new cbinvitesInviteTable(); $row->load( (int) $id ); $canAccess = false; if ( $row->get( 'id' ) && ( $cbModerator || ( $row->get( 'user_id' ) == $user->get( 'id' ) ) ) ) { $canAccess = true; } $profileUrl = $_CB_framework->userProfileUrl( $row->get( 'user_id', $user->get( 'id' ) ), false, 'cbinvitesTab' ); if ( $canAccess ) { if ( $row->isAccepted() ) { cbRedirect( $profileUrl, CBTxt::T( 'Invite already accepted and can not be deleted.' ), 'error' ); } if ( ! $row->delete() ) { cbRedirect( $profileUrl, CBTxt::T( 'INVITE_FAILED_DELETE_ERROR', 'Invite failed to delete! Error: [error]', array( '[error]' => $row->getError() ) ), 'error' ); } cbRedirect( $profileUrl, CBTxt::T( 'Invite deleted successfully!' ) ); } else { cbRedirect( $profileUrl, CBTxt::T( 'Not authorized.' ), 'error' ); } }
/** * @param cbgalleryItemTable[] $rows * @param cbPageNav $pageNav * @param cbgalleryFolderTable|null $folder * @param bool $searching * @param UserTable $viewer * @param UserTable $user * @param TabTable $tab * @param cbTabHandler $plugin * @return string */ static public function showFiles( $rows, $pageNav, $folder, $searching, $viewer, $user, $tab, $plugin ) { global $_CB_framework, $_PLUGINS; $_PLUGINS->trigger( 'gallery_onBeforeDisplayFiles', array( &$rows, $pageNav, $folder, $searching, $viewer, $user, $tab, $plugin ) ); /** @var Registry $params */ $params = $tab->params; $profileOwner = ( $viewer->get( 'id' ) == $user->get( 'id' ) ); $cbModerator = Application::User( (int) $viewer->get( 'id' ) )->isGlobalModerator(); $return = '<table class="filesItemsContainer table table-hover table-responsive">' . '<thead>' . '<tr>' . '<th colspan="2"> </th>' . '<th style="width: 15%;" class="text-center">' . CBTxt::T( 'Type' ) . '</th>' . '<th style="width: 15%;" class="text-left">' . CBTxt::T( 'Size' ) . '</th>' . '<th style="width: 20%;" class="text-left hidden-xs">' . CBTxt::T( 'Date' ) . '</th>' . '<th style="width: 1%;" class="text-right"> </th>' . '</tr>' . '</thead>' . '<tbody>'; if ( $rows ) foreach ( $rows as $row ) { $extension = null; $size = 0; $title = ( $row->get( 'title' ) ? htmlspecialchars( $row->get( 'title' ) ) : $row->getFileName() ); $item = $title; if ( $row->checkExists() ) { if ( $row->getLinkDomain() ) { $showPath = htmlspecialchars( $row->getFilePath() ); $downloadPath = $showPath; } else { $showPath = $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'items', 'func' => 'show', 'type' => 'files', 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ), 'v' => uniqid() ), 'raw', 0, true ); $downloadPath = $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'items', 'func' => 'download', 'type' => 'files', 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ), 'v' => uniqid() ), 'raw', 0, true ); } $extension = $row->getExtension(); $size = $row->getFileSize(); switch ( $extension ) { case 'txt': case 'pdf': case 'jpg': case 'jpeg': case 'png': case 'gif': case 'js': case 'css': case 'mp4': case 'mp3': case 'wav': $item = '<a href="' . $showPath . '" target="_blank">' . $item . '</a>'; break; default: $item = '<a href="' . $downloadPath . '" target="_blank">' . $item . '</a>'; break; } $download = '<a href="' . $downloadPath . '" target="_blank" title="' . htmlspecialchars( CBTxt::T( 'Click to Download' ) ) . '" class="filesItemsDownload btn btn-xs btn-default">' . '<span class="fa fa-download"></span>' . '</a>'; } else { $download = '<button type="button" class="filesItemsDownload btn btn-xs btn-default disabled">' . '<span class="fa fa-download"></span>' . '</button>'; } if ( $row->get( 'description' ) ) { $item .= ' ' . cbTooltip( 1, $row->get( 'description' ), $title, 400, null, '<span class="fa fa-info-circle text-muted"></span>' ); } $return .= '<tr>' . '<td style="width: 1%;" class="text-center">' . $download . '</td>' . '<td class="text-left">' . $item . '</td>' . '<td style="width: 15%;" class="text-center"><span class="filesItemsType fa fa-' . htmlspecialchars( self::getFileIcon( $extension ) ) . '" title="' . htmlspecialchars( ( $extension ? strtoupper( $extension ) : CBTxt::T( 'Unknown' ) ) ) . '"></span></td>' . '<td style="width: 15%;" class="text-left">' . $size . '</td>' . '<td style="width: 20%;" class="text-left hidden-xs">' . '<span title="' . htmlspecialchars( $row->get( 'date' ) ) . '">' . cbFormatDate( $row->get( 'date' ), true, (int) $params->get( 'tab_files_items_time_display', 0 ), $params->get( 'tab_files_items_date_format', 'M j, Y' ), $params->get( 'tab_files_items_time_format', ' g:h A' ) ) . '</span>' . '</td>'; if ( $cbModerator || $profileOwner ) { $menuItems = '<ul class="galleryItemsMenuItems dropdown-menu" style="display: block; position: relative; margin: 0;">' . '<li class="galleryItemsMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'items', 'func' => 'edit', 'type' => 'files', 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '"><span class="fa fa-edit"></span> ' . CBTxt::T( 'Edit' ) . '</a></li>'; if ( ( $row->get( 'published' ) == -1 ) && $plugin->params->get( 'files_item_approval', 0 ) ) { if ( $cbModerator ) { $menuItems .= '<li class="galleryItemsMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'items', 'func' => 'publish', 'type' => 'files', 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '"><span class="fa fa-check"></span> ' . CBTxt::T( 'Approve' ) . '</a></li>'; } } elseif ( $row->get( 'published' ) > 0 ) { $menuItems .= '<li class="galleryItemsMenuItem"><a href="javascript: void(0);" onclick="if ( confirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to unpublish this File?' ) ) . '\' ) ) { location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'items', 'func' => 'unpublish', 'type' => 'files', 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '\'; }"><span class="fa fa-times-circle"></span> ' . CBTxt::T( 'Unpublish' ) . '</a></li>'; } else { $menuItems .= '<li class="galleryItemsMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'items', 'func' => 'publish', 'type' => 'files', 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '"><span class="fa fa-check"></span> ' . CBTxt::T( 'Publish' ) . '</a></li>'; } $menuItems .= '<li class="galleryItemsMenuItem"><a href="javascript: void(0);" onclick="if ( confirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to delete this File?' ) ) . '\' ) ) { location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'items', 'func' => 'delete', 'type' => 'files', 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '\'; }"><span class="fa fa-trash-o"></span> ' . CBTxt::T( 'Delete' ) . '</a></li>' . '</ul>'; $menuAttr = cbTooltip( 1, $menuItems, null, 'auto', null, null, null, 'class="btn btn-default btn-xs" data-cbtooltip-menu="true" data-cbtooltip-classes="qtip-nostyle"' ); $return .= '<td style="width: 1%;" class="text-right">' . '<div class="galleryItemsMenu btn-group">' . '<button type="button" ' . trim( $menuAttr ) . '><span class="fa fa-cog"></span> <span class="fa fa-caret-down"></span></button>' . '</div>' . '</td>'; } else{ $return .= '<td style="width: 1%;"></td>'; } $return .= '</tr>'; } else { $return .= '<tr>' . '<td colspan="6" class="text-left">'; if ( $searching ) { $return .= CBTxt::T( 'No file search results found.' ); } else { if ( $folder ) { $return .= CBTxt::T( 'This folder has no files.' ); } else { if ( $viewer->get( 'id' ) == $user->get( 'id' ) ) { $return .= CBTxt::T( 'You have no files.' ); } else { $return .= CBTxt::T( 'This user has no files.' ); } } } $return .= '</td>' . '</tr>'; } $return .= '</tbody>'; if ( $params->get( ( $folder ? 'tab_files_folder_items_paging' : 'tab_files_items_paging' ), 1 ) && ( $pageNav->total > $pageNav->limit ) ) { $return .= '<tfoot>' . '<tr>' . '<td colspan="6" class="galleryItemsPaging text-center">' . $pageNav->getListLinks() . '</td>' . '</tr>' . '</tfoot>'; } $return .= '</table>' . $pageNav->getLimitBox( false ); return $return; }
/** * Checks if user has increment access to this field * * @param FieldTable $field * @param UserTable $user * @return boolean */ private function getIncrementAccess(&$field, &$user) { global $_CB_framework, $_CB_database; static $cache = array(); $myId = (int) $_CB_framework->myId(); $userId = (int) $user->get('id'); $fieldId = (int) $field->get('fieldid'); $ipAddresses = cbGetIParray(); $ipAddress = trim(array_shift($ipAddresses)); $incrementDelay = $field->params->get('points_inc_delay', null); $customDelay = $field->params->get('points_inc_delay_custom', null); $cacheId = $myId . $userId . $fieldId; if (!isset($cache[$cacheId])) { $ratingAccess = (int) $field->params->get('points_access', 1); $excludeSelf = (int) $field->params->get('points_access_exclude', 0); $includeSelf = (int) $field->params->get('points_access_include', 0); $viewAccessLevel = (int) $field->params->get('points_access_custom', 1); $access = false; switch ($ratingAccess) { case 8: if (Application::MyUser()->canViewAccessLevel($viewAccessLevel) && ($userId == $myId && !$excludeSelf || $userId != $myId)) { $access = true; } break; case 7: if (Application::MyUser()->isModeratorFor(Application::User((int) $userId)) && ($userId == $myId && !$excludeSelf || $userId != $myId)) { $access = true; } break; case 6: if ($userId != $myId) { $cbConnection = new cbConnection($userId); if ($cbConnection->getConnectionDetails($userId, $myId) !== false) { $access = true; } } else { if ($userId == $myId && $includeSelf) { $access = true; } } break; case 5: if ($myId == 0 && $userId != $myId || $userId == $myId && $includeSelf) { $access = true; } break; case 4: if ($myId > 0 && ($userId == $myId && !$excludeSelf || $userId != $myId)) { $access = true; } break; case 3: if ($userId != $myId) { $access = true; } break; case 2: if ($userId == $myId) { $access = true; } break; case 1: default: if ($userId == $myId && !$excludeSelf || $userId != $myId) { $access = true; } break; } $cache[$cacheId] = $access; } $canAccess = $cache[$cacheId]; if ($canAccess && $incrementDelay) { $query = 'SELECT ' . $_CB_database->NameQuote('date') . "\n FROM " . $_CB_database->NameQuote('#__comprofiler_ratings') . "\n WHERE " . $_CB_database->NameQuote('type') . " = " . $_CB_database->Quote('field') . "\n AND " . $_CB_database->NameQuote('item') . " = " . $fieldId . "\n AND " . $_CB_database->NameQuote('target') . " = " . $userId . "\n AND " . $_CB_database->NameQuote('user_id') . " = " . $myId; if ($myId == 0) { $query .= "\n AND " . $_CB_database->NameQuote('ip_address') . " = " . $_CB_database->Quote($ipAddress); } $query .= "\n ORDER BY " . $_CB_database->NameQuote('date') . " DESC"; $_CB_database->setQuery($query, 0, 1); $incrementDate = $_CB_database->loadResult(); if ($incrementDate) { if ($incrementDelay == 'FOREVER') { $canAccess = false; } elseif ($incrementDelay == 'CUSTOM') { if ($customDelay && $_CB_framework->getUTCTimestamp(strtoupper($customDelay), $_CB_framework->getUTCTimestamp($incrementDate)) >= $_CB_framework->getUTCNow()) { $canAccess = false; } } elseif ($_CB_framework->getUTCTimestamp($incrementDelay, $_CB_framework->getUTCTimestamp($incrementDate)) >= $_CB_framework->getUTCNow()) { $canAccess = false; } } } return $canAccess; }
/** * @param string $type * @param TabTable $tab * @param UserTable $user * @param UserTable $viewer * @param bool|int $start * @return null|string */ private function getItems( $type, $tab, $user, $viewer, $start = false ) { global $_CB_framework, $_CB_database, $_PLUGINS; /** @var Registry $params */ $params = $tab->params; $tabPrefix = 'tab_' . (int) $tab->get( 'tabid' ) . '_'; $publishedOnly = ( ( $viewer->get( 'id' ) != $user->get( 'id' ) ) && ( ! Application::User( (int) $viewer->get( 'id' ) )->isGlobalModerator() ) ); $input = array(); // Items: $typePrefix = $tabPrefix . $type . '_items_'; $limit = (int) $params->get( 'tab_' . $type . '_items_limit', 15 ); $limitstart = ( $start !== false ? (int) $start : $_CB_framework->getUserStateFromRequest( $typePrefix . 'limitstart{com_comprofiler}', $typePrefix . 'limitstart' ) ); $search = $_CB_framework->getUserStateFromRequest( $typePrefix . 'search{com_comprofiler}', $typePrefix . 'search' ); $where = null; if ( $search && $params->get( 'tab_' . $type . '_items_search', 1 ) ) { $where .= "\n AND ( " . $_CB_database->NameQuote( 'value' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $search, true ) . '%', false ) . " OR " . $_CB_database->NameQuote( 'title' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $search, true ) . '%', false ) . " OR " . $_CB_database->NameQuote( 'description' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $search, true ) . '%', false ) . " )"; } $itemsSearching = ( $where ? true : false ); $query = 'SELECT COUNT(*)' . "\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_gallery_items' ) . "\n WHERE " . $_CB_database->NameQuote( 'type' ) . " = " . $_CB_database->Quote( $type ) . "\n AND " . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->get( 'id' ) . "\n AND " . $_CB_database->NameQuote( 'folder' ) . " = 0" . ( $publishedOnly ? "\n AND " . $_CB_database->NameQuote( 'published' ) . " = 1" : null ) . $where; $_CB_database->setQuery( $query ); $total = (int) $_CB_database->loadResult(); if ( $total <= $limitstart ) { $limitstart = 0; } $itemsPageNav = new cbPageNav( $total, $limitstart, $limit ); $itemsPageNav->setInputNamePrefix( $typePrefix ); $orderBy = $params->get( 'tab_' . $type . '_items_orderby', 'date_desc' ); if ( ! $orderBy ) { $orderBy = 'date_desc'; } $orderBy = explode( '_', $orderBy ); $query = 'SELECT *' . "\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_gallery_items' ) . "\n WHERE " . $_CB_database->NameQuote( 'type' ) . " = " . $_CB_database->Quote( $type ) . "\n AND " . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->get( 'id' ) . "\n AND " . $_CB_database->NameQuote( 'folder' ) . " = 0" . ( $publishedOnly ? "\n AND " . $_CB_database->NameQuote( 'published' ) . " = 1" : null ) . $where . "\n ORDER BY " . $_CB_database->NameQuote( $orderBy[0] ) . " " . strtoupper( $orderBy[1] ); if ( $params->get( 'tab_' . $type . '_items_paging', 1 ) ) { $_CB_database->setQuery( $query, $itemsPageNav->limitstart, $itemsPageNav->limit ); } else { $_CB_database->setQuery( $query ); } $items = $_CB_database->loadObjectList( null, 'cbgalleryItemTable', array( $_CB_database ) ); $itemsCount = count( $items ); $_PLUGINS->trigger( 'gallery_onLoadItems', array( &$items, $user ) ); if ( $itemsCount && ( ! count( $items ) ) ) { return $this->getItems( $type, $tab, $user, $viewer, ( $limitstart + $limit ) ); } switch( $type ) { case 'photos': $placeholder = CBTxt::T( 'Search Photos...' ); break; case 'files': $placeholder = CBTxt::T( 'Search Files...' ); break; case 'videos': $placeholder = CBTxt::T( 'Search Videos...' ); break; case 'music': $placeholder = CBTxt::T( 'Search Music...' ); break; default: $placeholder = CBTxt::T( 'Search...' ); break; } $input['search_items'] = '<input type="text" name="' . htmlspecialchars( $typePrefix . 'search' ) . '" value="' . htmlspecialchars( $search ) . '" onchange="document.' . htmlspecialchars( $type ) . 'ItemsForm.submit();" placeholder="' . htmlspecialchars( $placeholder ) . '" class="form-control" />'; return array( $items, $itemsPageNav, $itemsSearching, $input ); }
/** * @param cbgalleryItemTable[] $rows * @param cbPageNav $pageNav * @param cbgalleryFolderTable|null $folder * @param bool $searching * @param UserTable $viewer * @param UserTable $user * @param TabTable $tab * @param cbTabHandler $plugin * @return string */ static public function showMusic( $rows, $pageNav, $folder, $searching, $viewer, $user, $tab, $plugin ) { global $_CB_framework, $_PLUGINS; $_PLUGINS->trigger( 'gallery_onBeforeDisplayMusic', array( &$rows, $pageNav, $folder, $searching, $viewer, $user, $tab, $plugin ) ); /** @var Registry $params */ $params = $tab->params; $allowDownload = $params->get( 'tab_music_download', 0 ); $profileOwner = ( $viewer->get( 'id' ) == $user->get( 'id' ) ); $cbModerator = Application::User( (int) $viewer->get( 'id' ) )->isGlobalModerator(); $return = null; if ( $rows ) { $js = "var musicPlayer = null;" . "$( '.musicItemPlay" . (int) $tab->get( 'tabid' ) . "' ).on( 'click', function( event ) {" . "event.preventDefault();" . "if ( $( this ).hasClass( 'musicItemPlaying' ) ) {" . "if ( musicPlayer != null ) {" . "musicPlayer.pause();" . "}" . "} else if ( $( this ).hasClass( 'musicItemPaused' ) ) {" . "if ( musicPlayer != null ) {" . "musicPlayer.play();" . "}" . "} else {" . "$( '.musicItemsPlayer" . (int) $tab->get( 'tabid' ) . "Container' ).hide();" . "if ( musicPlayer != null ) {" . "musicPlayer.remove();" . "$( '.musicItemsPlayer" . (int) $tab->get( 'tabid' ) . "Container > .mejs-offscreen' ).remove();" . "}" . "$( '#musicItemsPlayer" . (int) $tab->get( 'tabid' ) . "' ).attr( 'src', $( this ).attr( 'href' ) ).attr( 'type', $( this ).data( 'mimetype' ) ).attr( 'controls', 'controls' ).attr( 'autoplay', 'autoplay' ).attr( 'preload', 'none' );" . "musicPlayer = new MediaElementPlayer( '#musicItemsPlayer" . (int) $tab->get( 'tabid' ) . "', {" . "isVideo: false," . "success: function( media ) {" . "media.addEventListener( 'play', function() {" . "$( '.musicItemPlay" . (int) $tab->get( 'tabid' ) . ".active' ).removeClass( 'musicItemPaused' ).addClass( 'musicItemPlaying' ).find( '.fa' ).removeClass( 'fa-play' ).addClass( 'fa-pause' );" . "}, false );" . "media.addEventListener( 'pause', function() {" . "$( '.musicItemPlay" . (int) $tab->get( 'tabid' ) . ".active' ).removeClass( 'musicItemPlaying' ).addClass( 'musicItemPaused' ).find( '.fa' ).removeClass( 'fa-pause' ).addClass( 'fa-play' );" . "}, false );" . "media.addEventListener( 'ended', function() {" . "var music = $( '.musicItemPlay" . (int) $tab->get( 'tabid' ) . ".active' );" . "var repeat = $( '.musicItemRepeat" . (int) $tab->get( 'tabid' ) . "' );" . "var shuffle = $( '.musicItemShuffle" . (int) $tab->get( 'tabid' ) . "' );" . "var next = null;" . "music.removeClass( 'musicItemPlayed' ).addClass( 'musicItemPlayed' );" . "if ( repeat.hasClass( 'btn-primary' ) ) {" . "if ( shuffle.hasClass( 'btn-primary' ) ) {" . "next = music.closest( 'tr' ).parent().children( 'tr' ).find( '.musicItemPlay" . (int) $tab->get( 'tabid' ) . "' ).filter( ':not(.active)' );" . "if ( next.length ) {" . "next = next.eq( Math.floor( Math.random() * next.length ) );" . "}" . "} else {" . "next = music.closest( 'tr' ).nextAll( 'tr' ).find( '.musicItemPlay" . (int) $tab->get( 'tabid' ) . "' ).first();" . "if ( ! next.length ) {" . "next = music.closest( 'tr' ).parent().children( 'tr' ).find( '.musicItemPlay" . (int) $tab->get( 'tabid' ) . "' ).first();" . "}" . "}" . "} else {" . "if ( shuffle.hasClass( 'btn-primary' ) ) {" . "next = music.closest( 'tr' ).parent().children( 'tr' ).find( '.musicItemPlay" . (int) $tab->get( 'tabid' ) . "' ).filter( ':not(.musicItemPlayed,.active)' ).first();" . "if ( next.length ) {" . "next = next.eq( Math.floor( Math.random() * next.length ) );" . "}" . "} else {" . "next = music.closest( 'tr' ).nextAll( 'tr' ).find( '.musicItemPlay" . (int) $tab->get( 'tabid' ) . "' ).filter( ':not(.musicItemPlayed)' ).first();" . "if ( ! next.length ) {" . "next = music.closest( 'tr' ).parent().children( 'tr' ).find( '.musicItemPlay" . (int) $tab->get( 'tabid' ) . "' ).filter( ':not(.musicItemPlayed)' ).first();" . "}" . "}" . "if ( ! next.length ) {" . "music.closest( 'tr' ).parent().children( 'tr' ).find( '.musicItemPlay" . (int) $tab->get( 'tabid' ) . "' ).removeClass( 'musicItemPlayed' );" . "}" . "}" . "if ( next.length ) {" . "next.click();" . "}" . "}, false );" . "}" . "});" . "$( '.musicItemsPlayer" . (int) $tab->get( 'tabid' ) . "Container' ).slideDown();" . "$( '.musicItemPlay" . (int) $tab->get( 'tabid' ) . "' ).find( '.fa' ).removeClass( 'fa-play fa-pause' ).addClass( 'fa-play' );" . "$( '.musicItemPlay" . (int) $tab->get( 'tabid' ) . "' ).removeClass( 'active musicItemPlaying musicItemPaused' );" . "$( '.musicItemPlay" . (int) $tab->get( 'tabid' ) . "' ).closest( 'tr' ).removeClass( 'active' );" . "$( this ).addClass( 'active musicItemPaused' );" . "$( this ).closest( 'tr' ).addClass( 'active' );" . "musicPlayer.play();" . "}" . "});" . "$( '.musicItemToggle' ).on( 'click', function( event ) {" . "event.preventDefault();" . "if ( $( this ).hasClass( 'btn-primary' ) ) {" . "$( this ).removeClass( 'btn-primary' ).addClass( 'btn-muted' );" . "} else {" . "$( this ).addClass( 'btn-primary' ).removeClass( 'btn-muted' );" . "}" . "});"; $_CB_framework->outputCbJQuery( $js, 'media' ); $width = (int) $params->get( 'tab_music_width', 0 ); $return .= '<div class="musicItemsPlayer' . (int) $tab->get( 'tabid' ) . 'Container text-center" style="display: none; margin: 0 auto 10px auto;' . ( $width ? ' max-width: ' . $width . 'px;' : null ) . '">' . '<audio width="640" style="width: 100%;" id="musicItemsPlayer' . (int) $tab->get( 'tabid' ) . '" controls="controls" autoplay="autoplay" preload="none"></audio>' . '</div>'; } $return .= '<table class="musicItemsContainer table table-hover table-responsive">' . '<thead>' . '<tr>' . '<th style="width: 1%;" class="text-left">#</th>' . '<th class="text-left" colspan="' . ( $allowDownload ? 3 : 2 ) . '">'; if ( $rows ) { $return .= '<button type="button" class="musicItemToggle musicItemRepeat' . (int) $tab->get( 'tabid' ) . ' btn btn-xs btn-primary" title="' . htmlspecialchars( CBTxt::T( 'Repeat' ) ) . '"><span class="fa fa-refresh"></span></button>' . ' <button type="button" class="musicItemToggle musicItemShuffle' . (int) $tab->get( 'tabid' ) . ' btn btn-xs btn-primary" title="' . htmlspecialchars( CBTxt::T( 'Shuffle' ) ) . '"><span class="fa fa-random"></span></button>'; } $return .= '</th>' . '<th style="width: 20%;" class="text-left hidden-xs">' . CBTxt::T( 'Date' ) . '</th>' . '<th style="width: 1%;" class="text-right"> </th>' . '</tr>' . '</thead>' . '<tbody>'; $i = 0; if ( $rows ) foreach ( $rows as $row ) { $exists = $row->checkExists(); $title = ( $row->get( 'title' ) ? htmlspecialchars( $row->get( 'title' ) ) : $row->getFileName() ); $item = $title; if ( $exists ) { if ( $row->getLinkDomain() ) { $showPath = htmlspecialchars( $row->getFilePath() ); $downloadPath = $showPath; } else { $showPath = $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'items', 'func' => 'show', 'type' => 'music', 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ), 'v' => uniqid() ), 'raw', 0, true ); $downloadPath = $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'items', 'func' => 'download', 'type' => 'music', 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ), 'v' => uniqid() ), 'raw', 0, true ); } $play = '<a href="' . $showPath . '" title="' . htmlspecialchars( CBTxt::T( 'Click to Play' ) ) . '" class="musicItemsPlay musicItemPlay' . (int) $tab->get( 'tabid' ) . ' btn btn-xs btn-default" data-mimetype="' . htmlspecialchars( $row->getMimeType() ) . '">' . '<span class="fa fa-play"></span>' . '</a>'; $item = '<a href="' . $showPath . '" target="_blank">' . $item . '</a>'; $download = '<a href="' . $downloadPath . '" target="_blank" title="' . htmlspecialchars( CBTxt::T( 'Click to Download' ) ) . '" class="musicItemsDownload btn btn-xs btn-default">' . '<span class="fa fa-download"></span>' . '</a>'; } else { $play = '<button type="button" class="musicItemsPlay btn btn-xs btn-default disabled">' . '<span class="fa fa-play"></span>' . '</button>'; $download = '<button type="button" class="musicItemsDownload btn btn-xs btn-default disabled">' . '<span class="fa fa-download"></span>' . '</button>'; } if ( $row->get( 'description' ) ) { $item .= ' ' . cbTooltip( 1, $row->get( 'description' ), $title, 400, null, '<span class="fa fa-info-circle text-muted"></span>' ); } $return .= '<tr' . ( $exists ? ' class="musicItemPlayable"' : null ) . '>' . '<td style="width: 1%;" class="text-center">' . ( $i + 1 ) . '</td>' . '<td style="width: 1%;" class="text-center">' . $play . '</td>' . ( $allowDownload ? '<td style="width: 1%;" class="text-center">' . $download . '</td>' : null ) . '<td class="text-left">' . $item . '</td>' . '<td style="width: 20%;" class="text-left hidden-xs">' . '<span title="' . htmlspecialchars( $row->get( 'date' ) ) . '">' . cbFormatDate( $row->get( 'date' ), true, (int) $params->get( 'tab_music_items_time_display', 0 ), $params->get( 'tab_music_items_date_format', 'M j, Y' ), $plugin->params->get( 'tab_music_items_time_format', ' g:h A' ) ) . '</span>' . '</td>'; if ( $cbModerator || $profileOwner ) { $menuItems = '<ul class="galleryItemsMenuItems dropdown-menu" style="display: block; position: relative; margin: 0;">' . '<li class="galleryItemsMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'items', 'func' => 'edit', 'type' => 'music', 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '"><span class="fa fa-edit"></span> ' . CBTxt::T( 'Edit' ) . '</a></li>'; if ( ( $row->get( 'published' ) == -1 ) && $plugin->params->get( 'music_item_approval', 0 ) ) { if ( $cbModerator ) { $menuItems .= '<li class="galleryItemsMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'items', 'func' => 'publish', 'type' => 'music', 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '"><span class="fa fa-check"></span> ' . CBTxt::T( 'Approve' ) . '</a></li>'; } } elseif ( $row->get( 'published' ) > 0 ) { $menuItems .= '<li class="galleryItemsMenuItem"><a href="javascript: void(0);" onclick="if ( confirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to unpublish this Music?' ) ) . '\' ) ) { location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'items', 'func' => 'unpublish', 'type' => 'music', 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '\'; }"><span class="fa fa-times-circle"></span> ' . CBTxt::T( 'Unpublish' ) . '</a></li>'; } else { $menuItems .= '<li class="galleryItemsMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'items', 'func' => 'publish', 'type' => 'music', 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '"><span class="fa fa-check"></span> ' . CBTxt::T( 'Publish' ) . '</a></li>'; } $menuItems .= '<li class="galleryItemsMenuItem"><a href="javascript: void(0);" onclick="if ( confirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to delete this Music?' ) ) . '\' ) ) { location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'items', 'func' => 'delete', 'type' => 'music', 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '\'; }"><span class="fa fa-trash-o"></span> ' . CBTxt::T( 'Delete' ) . '</a></li>' . '</ul>'; $menuAttr = cbTooltip( 1, $menuItems, null, 'auto', null, null, null, 'class="btn btn-default btn-xs" data-cbtooltip-menu="true" data-cbtooltip-classes="qtip-nostyle"' ); $return .= '<td style="width: 1%;" class="text-right">' . '<div class="galleryItemsMenu btn-group">' . '<button type="button" ' . trim( $menuAttr ) . '><span class="fa fa-cog"></span> <span class="fa fa-caret-down"></span></button>' . '</div>' . '</td>'; } else{ $return .= '<td style="width: 1%;"></td>'; } $return .= '</tr>'; $i++; } else { $return .= '<tr>' . '<td colspan="' . ( $allowDownload ? 6 : 5 ) . '" class="text-left">'; if ( $searching ) { $return .= CBTxt::T( 'No music search results found.' ); } else { if ( $folder ) { $return .= CBTxt::T( 'This album has no music.' ); } else { if ( $viewer->get( 'id' ) == $user->get( 'id' ) ) { $return .= CBTxt::T( 'You have no music.' ); } else { $return .= CBTxt::T( 'This user has no music.' ); } } } $return .= '</td>' . '</tr>'; } $return .= '</tbody>'; if ( $params->get( ( $folder ? 'tab_music_folder_items_paging' : 'tab_music_items_paging' ), 1 ) && ( $pageNav->total > $pageNav->limit ) ) { $return .= '<tfoot>' . '<tr>' . '<td colspan="' . ( $allowDownload ? 6 : 5 ) . '" class="galleryItemsPaging text-center">' . $pageNav->getListLinks() . '</td>' . '</tr>' . '</tfoot>'; } $return .= '</table>' . $pageNav->getLimitBox( false ); return $return; }
/** * Evaluate [cb:if ...] * * @access private (public because it's recursively calling itself in the preg_replace_callback function at bottom) * * @param string|array $input * @param array $extraStrings * @return string */ public function _evaluateIfs($input, $extraStrings = array()) { // $regex = "#\[if ([^\]]+)\](.*?)\[/if\]#s"; // $regex = '#\[indent]((?:[^[]|\[(?!/?indent])|(?R))+)\[/indent]#s'; $regex = '#\\[cb:if(?: +user="******"/\\[\\] ]+)")?( +[^\\]]+)\\]((?:[^\\[]|\\[(?!/?cb:if[^\\]]*])|(?R))+)\\[/cb:if]#'; $that = $this; return preg_replace_callback($regex, function (array $matches) use($extraStrings, $that) { $regex2 = '# +(?:(&&|and|\\|\\||or|) +)?([^=<!>~ ]+) *(=|<|>|>=|<=|<>|!=|=~|!~| includes |!includes ) *"([^"]*)"#'; $conditions = null; if (preg_match_all($regex2, $matches[2], $conditions)) { $user = $that->_evaluateUserAttrib($matches[1]); $resultsIdx = 0; $results = array($resultsIdx => true); for ($i = 0, $n = count($conditions[0]); $i < $n; $i++) { $operator = $conditions[1][$i]; $field = $conditions[2][$i]; $compare = $conditions[3][$i]; $value = $conditions[4][$i]; if ($field === 'viewaccesslevel') { $var = Application::User((int) $user->getUserData()->get('id'))->getAuthorisedViewLevels(); } elseif ($field === 'usergroup') { $var = Application::User((int) $user->getUserData()->get('id'))->getAuthorisedGroups(); } elseif ($field === 'application_context') { $var = Application::Cms()->getClientId() ? 'administrator' : 'frontend'; } elseif ($field === 'language_code') { list($var) = explode('-', Application::Cms()->getLanguageTag()); } elseif ($field === 'language_tag') { $var = Application::Cms()->getLanguageTag(); } elseif ($field) { if (isset($extraStrings[$field])) { $var = $extraStrings[$field]; } else { $var = $user->getField($field, null, 'php', 'none', 'profile', 0, true); // allow accessing all fields in the if if (is_array($var)) { $var = array_shift($var); } elseif (isset($user->_cbuser->{$field})) { // fall-back to the record if it exists: $var = $user->_cbuser->get($field); } else { $fieldLower = strtolower($field); if (isset($user->_cbuser->{$fieldLower})) { // second fall-back to the record if it exists: $var = $user->_cbuser->get($fieldLower); } else { $var = null; } } } } else { $var = null; } // When using an includes or !includes operator ensure the value stays an array if it is an array: if (is_array($var) && !in_array($compare, array(' includes ', '!includes '))) { $var = implode('|*|', $var); } // Ensure user id is always an integer: if (in_array($field, array('id', 'user_id'))) { $var = (int) $var; } if ($field == 'user_id' && $value == 'myid') { $value = (int) Application::MyUser()->getUserId(); } switch ($compare) { case '=': $r = $var == $value; break; case '<': $r = $var < $value; break; case '>': $r = $var > $value; break; case '>=': $r = $var >= $value; break; case '<=': $r = $var <= $value; break; case '<>': case '!=': $r = $var != $value; break; case '=~': case '!~': $ma = @preg_match($value, $var); $r = $compare == '=~' ? $ma === 1 : $ma == 0; if ($ma === false) { // error in regexp itself: global $_CB_framework; if ($_CB_framework->getCfg('debug') > 0) { echo sprintf(CBTxt::T("CB Regexp Error %s in expression %s"), !is_callable('preg_last_error') ? '' : preg_last_error(), htmlspecialchars($value)); } } break; case ' includes ': // [cb:if viewaccesslevel includes "1"] or [cb:if multicheckboxfield includes "choice2"] $r = in_array($value, (array) $var); break; case '!includes ': // [cb:if viewaccesslevel !includes "3"] or [cb:if multicheckboxfield !includes "choice2"] $r = !in_array($value, (array) $var); break; default: return CBTxt::T('UNDEFINED_IF_COMPARISON_OPERATOR_OPERATOR', 'Undefined [cb:if ...] comparison operator [OPERATOR] !', array('[OPERATOR]' => $compare)); } if (in_array($operator, array('or', '||'))) { $resultsIdx++; $results[++$resultsIdx] = true; } // combine and: $results[$resultsIdx] = $results[$resultsIdx] && $r; } // combine or: $r = false; foreach ($results as $rr) { $r = $r || $rr; } return $r ? $matches[3] : ''; } else { return ''; } }, $input); }
/** * Executes the action * * @param cbautoactionsActionTable $trigger * @param UserTable $user * @param string $rawPassword * @param array $vars * @param array $extras * @return mixed */ public function getAction( $trigger, $user, $rawPassword = null, $vars = array(), $extras = array() ) { $cbUser = new CBuser(); $cbUser->_cbuser = $user; $extras = array_merge( $extras, $this->getExtras( $vars ) ); $vars['self'] = $trigger; $vars['user'] = $user; $trigger->set( '_cbuser', $cbUser ); $trigger->set( '_password', ( $rawPassword ? $rawPassword : $user->get( 'password' ) ) ); $trigger->set( '_extras', $extras ); $trigger->set( '_vars', $vars ); if ( $user->get( 'id' ) ) { $gids = Application::User( (int) $user->get( 'id' ) )->getAuthorisedGroups( false ); array_unshift( $gids, -3 ); if ( Application::User( (int) $user->get( 'id' ) )->isGlobalModerator() ) { array_unshift( $gids, -5 ); } else { array_unshift( $gids, -4 ); } } else { $gids = $user->get( 'gids', array() ); array_unshift( $gids, -2 ); } if ( $user->get( 'id' ) == Application::MyUser()->getUserId() ) { array_unshift( $gids, -7 ); } else { array_unshift( $gids, -6 ); } array_unshift( $gids, -1 ); $trigger->set( '_gids', $gids ); $access = explode( '|*|', $trigger->get( 'access' ) ); if ( ! array_intersect( $access, $gids ) ) { if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) { var_dump( CBTxt::T( 'AUTO_ACTION_ACCESS_FAILED', ':: Action [action] :: Access check for [user_id] failed: looking for [access] in [groups]', array( '[action]' => (int) $trigger->get( 'id' ), '[user_id]' => (int) $user->get( 'id' ), '[access]' => implode( ', ', $access ), '[groups]' => implode( ', ', $gids ) ) ) ); } return null; } foreach ( $trigger->getConditions() as $i => $conditional ) { /** @var ParamsInterface $conditional */ $condTranslate = $conditional->get( 'translate', 0, GetterInterface::BOOLEAN ); $condField = $trigger->getSubstituteString( $conditional->get( 'field', null, GetterInterface::HTML ), true, $condTranslate ); $condOperator = $conditional->get( 'operator', '0', GetterInterface::STRING ); $condValue = $trigger->getSubstituteString( $conditional->get( 'value', null, GetterInterface::HTML ), true, $condTranslate ); if ( ! cbautoactionsClass::getFieldMatch( $condField, $condOperator, $condValue, $vars ) ) { if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) { var_dump( CBTxt::T( 'AUTO_ACTION_CONDITIONAL_FAILED', ':: Action [action] :: Conditional [cond] failed for [user_id]: [field] [operator] [value]', array( '[action]' => (int) $trigger->get( 'id' ), '[cond]' => ( $i + 1 ), '[user_id]' => (int) $user->get( 'id' ), '[field]' => cbautoactionsClass::formatCondition( $condField ), '[operator]' => cbautoactionsClass::getOperatorTitle( $condOperator ), '[value]' => cbautoactionsClass::formatCondition( $condValue ) ) ) ); } return null; } } $excludeGlobal = explode( ',', $this->params->get( 'exclude', null, GetterInterface::STRING ) ); $excludeTrigger = explode( ',', $trigger->getParams()->get( 'exclude', null, GetterInterface::STRING ) ); $exclude = array_filter( array_merge( $excludeGlobal, $excludeTrigger ) ); if ( $exclude ) { cbArrayToInts( $exclude ); $exclude = array_unique( $exclude ); if ( in_array( (int) $user->get( 'id' ), $exclude ) ) { if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) { var_dump( CBTxt::T( 'AUTO_ACTION_USER_EXCLUDED', ':: Action [action] :: User [user_id] excluded', array( '[action]' => (int) $trigger->get( 'id' ), '[user_id]' => (int) $user->get( 'id' ) ) ) ); } return null; } } return $trigger->call( 'execute', array( $user ) ); }
/** * Renders the Blogs tab * * @param OrderedTable[] $rows Blogs to render * @param cbPageNav $pageNav Pagination * @param boolean $searching Currently searching * @param string[] $input HTML of input elements * @param UserTable $viewer Viewing user * @param UserTable $user Viewed user * @param stdClass $model The model reference * @param TabTable $tab Current Tab * @param PluginTable $plugin Current Plugin * @return string HTML */ static function showBlogTab($rows, $pageNav, $searching, $input, $viewer, $user, $model, $tab, $plugin) { global $_CB_framework; $blogLimit = (int) $plugin->params->get('blog_limit', null); $tabPaging = $tab->params->get('tab_paging', 1); $canSearch = $tab->params->get('tab_search', 1) && ($searching || $pageNav->total); $canCreate = false; $profileOwner = $viewer->get('id') == $user->get('id'); $cbModerator = Application::User((int) $viewer->get('id'))->isGlobalModerator(); $canPublish = $cbModerator || $profileOwner && !$plugin->params->get('blog_approval', 0); if ($profileOwner) { if ($cbModerator) { $canCreate = true; } elseif ($user->get('id') && Application::User((int) $viewer->get('id'))->canViewAccessLevel((int) $plugin->params->get('blog_create_access', 2))) { if (!$blogLimit || $blogLimit && $pageNav->total < $blogLimit) { $canCreate = true; } } } $return = '<div class="blogsTab">' . '<form action="' . $_CB_framework->userProfileUrl($user->get('id'), true, $tab->tabid) . '" method="post" name="blogForm" id="blogForm" class="blogForm">'; if ($canCreate || $canSearch) { $return .= '<div class="blogsHeader row" style="margin-bottom: 10px;">'; if ($canCreate) { $return .= '<div class="' . (!$canSearch ? 'col-sm-12' : 'col-sm-8') . ' text-left">' . '<button type="button" onclick="location.href=\'' . $_CB_framework->pluginClassUrl($plugin->element, false, array('action' => 'blogs', 'func' => 'new')) . '\';" class="blogsButton blogsButtonNew btn btn-success"><span class="fa fa-plus-circle"></span> ' . CBTxt::T('New Blog') . '</button>' . '</div>'; } if ($canSearch) { $return .= '<div class="' . (!$canCreate ? 'col-sm-offset-8 ' : null) . 'col-sm-4 text-right">' . '<div class="input-group">' . '<span class="input-group-addon"><span class="fa fa-search"></span></span>' . $input['search'] . '</div>' . '</div>'; } $return .= '</div>'; } $menuAccess = $cbModerator || $profileOwner || $canPublish; $return .= '<table class="blogsContainer table table-hover table-responsive">' . '<thead>' . '<tr>' . '<th style="width: 50%;" class="text-left">' . CBTxt::T('Title') . '</th>' . '<th style="width: 25%;" class="text-left hidden-xs">' . CBTxt::T('Category') . '</th>' . '<th style="width: 24%;" class="text-left hidden-xs">' . CBTxt::T('Created') . '</th>' . ($menuAccess ? '<th style="width: 1%;" class="text-right"> </th>' : null) . '</tr>' . '</thead>' . '<tbody>'; if ($rows) { foreach ($rows as $row) { $return .= '<tr>' . '<td style="width: 50%;" class="text-left">' . ($row->get('published') ? '<a href="' . cbblogsModel::getUrl($row, true, 'article') . '">' . $row->get('title') . '</a>' : $row->get('title')) . '</td>' . '<td style="width: 25%;" class="text-left hidden-xs">' . ($row->get('category_published') ? '<a href="' . cbblogsModel::getUrl($row, true, 'category') . '">' . $row->get('category') . '</a>' : $row->get('category')) . '</td>' . '<td style="width: 24%;" class="text-left hidden-xs">' . cbFormatDate($row->get('created')) . '</td>'; if ($menuAccess) { $menuItems = '<ul class="blogsMenuItems dropdown-menu" style="display: block; position: relative; margin: 0;">'; if ($cbModerator || $profileOwner) { $menuItems .= '<li class="blogsMenuItem"><a href="' . $_CB_framework->pluginClassUrl($plugin->element, true, array('action' => 'blogs', 'func' => 'edit', 'id' => (int) $row->get('id'))) . '"><span class="fa fa-edit"></span> ' . CBTxt::T('Edit') . '</a></li>'; } if ($canPublish) { if ($row->get('published')) { $menuItems .= '<li class="blogsMenuItem"><a href="javascript: void(0);" onclick="if ( confirm( \'' . addslashes(CBTxt::T('Are you sure you want to unpublish this Blog?')) . '\' ) ) { location.href = \'' . $_CB_framework->pluginClassUrl($plugin->element, false, array('action' => 'blogs', 'func' => 'unpublish', 'id' => (int) $row->get('id'))) . '\'; }"><span class="fa fa-times-circle"></span> ' . CBTxt::T('Unpublish') . '</a></li>'; } else { $menuItems .= '<li class="blogsMenuItem"><a href="' . $_CB_framework->pluginClassUrl($plugin->element, true, array('action' => 'blogs', 'func' => 'publish', 'id' => (int) $row->get('id'))) . '"><span class="fa fa-check"></span> ' . CBTxt::T('Publish') . '</a></li>'; } } if ($cbModerator || $profileOwner) { $menuItems .= '<li class="blogsMenuItem"><a href="javascript: void(0);" onclick="if ( confirm( \'' . addslashes(CBTxt::T('Are you sure you want to delete this Blog?')) . '\' ) ) { location.href = \'' . $_CB_framework->pluginClassUrl($plugin->element, false, array('action' => 'blogs', 'func' => 'delete', 'id' => (int) $row->get('id'))) . '\'; }"><span class="fa fa-trash-o"></span> ' . CBTxt::T('Delete') . '</a></li>'; } $menuItems .= '</ul>'; $menuAttr = cbTooltip(1, $menuItems, null, 'auto', null, null, null, 'class="btn btn-default btn-xs" data-cbtooltip-menu="true" data-cbtooltip-classes="qtip-nostyle"'); $return .= '<td style="width: 1%;" class="text-right">' . '<div class="blogsMenu btn-group">' . '<button type="button"' . $menuAttr . '><span class="fa fa-cog"></span> <span class="fa fa-caret-down"></span></button>' . '</div>' . '</td>'; } $return .= '</tr>'; } } else { $return .= '<tr>' . '<td colspan="' . ($menuAccess ? 4 : 3) . '" class="text-left">'; if ($searching) { $return .= CBTxt::T('No blog search results found.'); } else { if ($viewer->id == $user->id) { $return .= CBTxt::T('You have no blogs.'); } else { $return .= CBTxt::T('This user has no blogs.'); } } $return .= '</td>' . '</tr>'; } $return .= '</tbody>'; if ($tabPaging && $pageNav->total > $pageNav->limit) { $return .= '<tfoot>' . '<tr>' . '<td colspan="' . ($menuAccess ? 4 : 3) . '" class="text-center">' . $pageNav->getListLinks() . '</td>' . '</tr>' . '</tfoot>'; } $return .= '</table>' . $pageNav->getLimitBox(false) . '</form>' . '</div>'; return $return; }
/** * @deprecated 2.0 use Application::MyUser()->isGlobalModerator(); or Application::User( (int) $user_id )->isGlobalModerator(); * @see User::isGlobalModerator() * * @param int $user_id * @return boolean */ public function get_user_moderator($user_id) { global $_PLUGINS; $isModerator = Application::User((int) $user_id)->isGlobalModerator(); if ($_PLUGINS) { $_PLUGINS->trigger('onUserModerator', array($user_id, &$isModerator)); } return $isModerator; }
/** * @param null|int $userId * @return bool */ static public function isModerator( $userId = null ) { static $cache = array(); if ( $userId === null ) { $userId = Application::MyUser()->getUserId(); } if ( ! isset( $cache[$userId] ) ) { $cache[$userId] = Application::User( (int) $userId )->isGlobalModerator(); } return $cache[$userId]; }
/** * @param cbgalleryFolderTable $row * @param array $input * @param string $type * @param TabTable $tab * @param UserTable $user * @param UserTable $viewer * @param cbPluginHandler $plugin */ static public function showFolderEdit( $row, $input, $type, $tab, $user, $viewer, $plugin ) { global $_CB_framework, $_PLUGINS; $_PLUGINS->trigger( 'gallery_onBeforeFolderEdit', array( &$row, &$input, $type, $tab, $user, $viewer, $plugin ) ); cbValidator::loadValidation(); switch( $type ) { case 'photos': $galleryType = CBTxt::T( 'Photos' ); break; case 'files': $galleryType = CBTxt::T( 'Files' ); break; case 'videos': $galleryType = CBTxt::T( 'Videos' ); break; case 'music': $galleryType = CBTxt::T( 'Music' ); break; default: $galleryType = CBTxt::T( 'Items' ); break; } switch( $type ) { case 'photos': case 'videos': case 'music': $typeTranslated = CBTxt::T( 'Album' ); break; default: $typeTranslated = CBTxt::T( 'Folder' ); break; } $cbModerator = Application::User( (int) $viewer->get( 'id' ) )->isGlobalModerator(); $pageTitle = ( $row->get( 'id' ) ? CBTxt::T( 'EDIT_FOLDER_TYPE', 'Edit [type]', array( '[type]' => $typeTranslated ) ) : CBTxt::T( 'NEW_FOLDER_TYPE', 'New [type]', array( '[type]' => $typeTranslated ) ) ); if ( $plugin->input( 'folder', false, GetterInterface::BOOLEAN ) ) { $returnUrl = $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'folders', 'func' => 'show', 'type' => $type, 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ); $formUrl = $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'folders', 'func' => 'save', 'type' => $type, 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ), 'folder' => true ) ); } else { $returnUrl = $_CB_framework->userProfileUrl( (int) $user->get( 'id' ), true, $tab->get( 'tabid' ) ); $formUrl = $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'folders', 'func' => 'save', 'type' => $type, 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ); } $_CB_framework->setPageTitle( $pageTitle ); $_CB_framework->appendPathWay( htmlspecialchars( $galleryType ), $returnUrl ); $_CB_framework->appendPathWay( htmlspecialchars( $pageTitle ), $_CB_framework->pluginClassUrl( $plugin->element, true, ( $row->get( 'id' ) ? array( 'action' => 'folders', 'func' => 'edit', 'type' => $type, 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) : array( 'action' => 'folders', 'func' => 'new', 'type' => $type, 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) ) ); initToolTip(); $return = '<div class="' . htmlspecialchars( $type ) . 'FolderEdit">' . '<form action="' . $formUrl . '" method="post" enctype="multipart/form-data" name="' . htmlspecialchars( $type ) . 'FolderForm" id="' . htmlspecialchars( $type ) . 'FolderForm" class="cb_form ' . htmlspecialchars( $type ) . 'FolderForm galleryFolderForm form-auto cbValidation">' . ( $pageTitle ? '<div class="galleryFolderTitle page-header"><h3>' . $pageTitle . '</h3></div>' : null ); if ( $cbModerator || ( ! $plugin->params->get( $type . '_folder_approval', 0 ) ) || ( $row->get( 'id' ) && ( $row->get( 'published' ) != -1 ) ) ) { $return .= '<div class="cbft_select cbtt_select form-group cb_form_line clearfix">' . '<label for="published" class="col-sm-3 control-label">' . CBTxt::T( 'Published' ) . '</label>' . '<div class="cb_field col-sm-9">' . $input['published'] . getFieldIcons( 1, 0, null, CBTxt::T( 'FOLDER_PUBLISHED_DESCRIPTION', 'Select publish status of the [type]. If unpublished the [type] will not be visible to the public.', array( '[type]' => $typeTranslated ) ) ) . '</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::T( 'Title' ) . '</label>' . '<div class="cb_field col-sm-9">' . $input['title'] . getFieldIcons( 1, 0, null, CBTxt::T( 'FOLDER_TITLE_DESCRIPTION', 'Optionally input a title. If no title is provided the date will be displayed as the title.', array( '[type]' => $typeTranslated ) ) ) . '</div>' . '</div>' . '<div class="cbft_textarea cbtt_textarea form-group cb_form_line clearfix">' . '<label for="description" class="col-sm-3 control-label">' . CBTxt::T( 'Description' ) . '</label>' . '<div class="cb_field col-sm-9">' . $input['description'] . getFieldIcons( 1, 0, null, CBTxt::T( 'FOLDER_DESCRIPTION_DESCRIPTION', 'Optionally input a description.', array( '[type]' => $typeTranslated ) ) ) . '</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( 'FOLDER_OWNER_DESCRIPTION', 'Input owner as single integer user_id.', array( '[type]' => $typeTranslated ) ) ) . '</div>' . '</div>'; } if ( $plugin->params->get( $type . '_folder_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::T( '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_FOLDER_TYPE', 'Update [type]', array( '[type]' => $typeTranslated ) ) : CBTxt::T( 'CREATE_FOLDER_TYPE', 'Create [type]', array( '[type]' => $typeTranslated ) ) ) ) . '" class="galleryButton galleryButtonSubmit btn btn-primary" ' . cbValidator::getSubmitBtnHtmlAttributes() . ' /> ' . ' <input type="button" value="' . htmlspecialchars( CBTxt::T( 'Cancel' ) ) . '" class="galleryButton galleryButtonCancel btn btn-default" onclick="if ( confirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to cancel? All unsaved data will be lost!' ) ) . '\' ) ) { location.href = \'' . $returnUrl . '\'; }" />' . '</div>' . '</div>' . cbGetSpoofInputTag( 'plugin' ) . '</form>' . '</div>'; echo $return; }