/** * @param UserTable $viewer Viewing User * @param UserTable $user Viewed at User * @param TabTable $tab Current Tab * @param PluginTable $plugin Current Plugin * @return string HTML */ public static function getPosts($viewer, $user, $tab, $plugin) { global $_CB_framework, $_CB_database; if (!class_exists('KunenaForumMessageHelper')) { return CBTxt::T('Kunena not installed, enabled, or failed to load.'); } $exclude = $plugin->params->get('forum_exclude', null); if ($exclude) { $exclude = explode('|*|', $exclude); cbArrayToInts($exclude); $exclude = implode(',', $exclude); } cbimport('cb.pagination'); cbforumsClass::getTemplate('tab_posts'); $limit = (int) $tab->params->get('tab_posts_limit', 15); $limitstart = $_CB_framework->getUserStateFromRequest('tab_posts_limitstart{com_comprofiler}', 'tab_posts_limitstart'); $filterSearch = $_CB_framework->getUserStateFromRequest('tab_posts_search{com_comprofiler}', 'tab_posts_search'); $where = array(); if (isset($filterSearch) && $filterSearch != '') { $where[] = '( m.' . $_CB_database->NameQuote('subject') . ' LIKE ' . $_CB_database->Quote('%' . $_CB_database->getEscaped($filterSearch, true) . '%', false) . ' OR t.' . $_CB_database->NameQuote('message') . ' LIKE ' . $_CB_database->Quote('%' . $_CB_database->getEscaped($filterSearch, true) . '%', false) . ' )'; } $searching = count($where) ? true : false; if ($exclude) { $where[] = '( m.' . $_CB_database->NameQuote('catid') . ' NOT IN ( ' . $exclude . ' ) )'; } $params = array('user' => (int) $user->id, 'starttime' => -1, 'where' => count($where) ? implode(' AND ', $where) : null); $posts = KunenaForumMessageHelper::getLatestMessages(false, 0, 0, $params); $total = array_shift($posts); if ($total <= $limitstart) { $limitstart = 0; } $pageNav = new cbPageNav($total, $limitstart, $limit); $pageNav->setInputNamePrefix('tab_posts_'); if ($tab->params->get('tab_posts_paging', 1)) { $posts = KunenaForumMessageHelper::getLatestMessages(false, (int) $pageNav->limitstart, (int) $pageNav->limit, $params); $posts = array_pop($posts); } else { $posts = array_pop($posts); } $rows = array(); /** @var KunenaForumMessage[] $posts */ if ($posts) { foreach ($posts as $post) { $row = new stdClass(); $row->id = $post->id; $row->subject = $post->subject; $row->message = $post->message; $row->date = $post->time; $row->url = $post->getUrl(); $row->category_id = $post->getCategory()->id; $row->category_name = $post->getCategory()->name; $row->category_url = $post->getCategory()->getUrl(); $rows[] = $row; } } $input = array(); $input['search'] = '<input type="text" name="tab_posts_search" value="' . htmlspecialchars($filterSearch) . '" onchange="document.forumPostsForm.submit();" placeholder="' . htmlspecialchars(CBTxt::T('Search Posts...')) . '" class="form-control" />'; return HTML_cbforumsTabPosts::showPosts($rows, $pageNav, $searching, $input, $viewer, $user, $tab, $plugin); }
/** * Sets selected plan (or gets the state with FALSE) * @param int[]|boolean $plans * @return array|null */ public function setSelectedPlans($plans) { static $state = null; if ($plans === false) { return $state; } if (is_array($plans)) { cbArrayToInts($plans); } $state = $plans; return null; }
/** * Gets articles * * @param int[] $paging * @param string $where * @param UserTable $viewer * @param UserTable $user * @param PluginTable $plugin * @return Table[] */ public static function getArticles($paging, $where, $viewer, $user, $plugin) { global $_CB_database; $categories = $plugin->params->get('article_k2_category', null); $query = 'SELECT a.*' . ', b.' . $_CB_database->NameQuote('id') . ' AS category' . ', b.' . $_CB_database->NameQuote('name') . ' AS category_title' . ', 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 WHERE a." . $_CB_database->NameQuote('created_by') . " = " . (int) $user->get('id') . "\n AND a." . $_CB_database->NameQuote('published') . " = 1" . "\n AND a." . $_CB_database->NameQuote('trash') . " = 0" . "\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('trash') . " = 0" . "\n AND b." . $_CB_database->NameQuote('access') . " IN " . $_CB_database->safeArrayOfIntegers(Application::MyUser()->getAuthorisedViewLevels()); if ($categories) { $categories = explode('|*|', $categories); cbArrayToInts($categories); $query .= "\n AND a." . $_CB_database->NameQuote('catid') . " NOT IN ( " . implode(',', $categories) . " )"; } $query .= $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, '\\CBLib\\Database\\Table\\Table', array(null, '#__k2_items', 'id')); }
/** * @param cbautoactionsActionTable $trigger * @param UserTable $user * @return mixed */ public function execute( $trigger, $user ) { $params = $trigger->getParams()->subTree( 'action' ); $actions = $params->get( 'actions' ); $return = null; if ( $actions ) { $actions = explode( '|*|', $actions ); cbArrayToInts( $actions ); foreach ( $actions as $actionId ) { $action = new cbautoactionsActionTable(); if ( $action->load( $actionId ) ) { $return .= cbautoactionsClass::triggerAction( $action, $user, $trigger->get( '_password' ), $trigger->get( '_extras' ), $trigger->get( '_vars' ) ); } } } return $return; }
/** * @param cbautoactionsActionTable $trigger * @param UserTable $user */ public function execute( $trigger, $user ) { global $_CB_framework; if ( ! $this->installed() ) { if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) { var_dump( CBTxt::T( 'AUTO_ACTION_ACYMAILING_NOT_INSTALLED', ':: Action [action] :: AcyMailing is not installed', array( '[action]' => (int) $trigger->get( 'id' ) ) ) ); } return; } $params = $trigger->getParams()->subTree( 'acymailing' ); require_once( $_CB_framework->getCfg( 'absolute_path' ) . '/administrator/components/com_acymailing/helpers/helper.php' ); /** @var subscriberClass $acySubscriberAPI */ $acySubscriberAPI = acymailing::get( 'class.subscriber' ); $subscriberId = $acySubscriberAPI->subid( (int) $user->get( 'id' ) ); if ( ! $subscriberId ) { $newSubscriber = new stdClass(); $newSubscriber->email = $user->get( 'email' ); $newSubscriber->userid = (int) $user->get( 'id' ); $newSubscriber->name = $user->get( 'name' ); $newSubscriber->created = $_CB_framework->getUTCTimestamp( $user->get( 'registerDate' ) ); $newSubscriber->confirmed = 1; $newSubscriber->enabled = 1; $newSubscriber->accept = 1; $newSubscriber->ip = $user->get( 'registeripaddr' ); $newSubscriber->html = 1; $subscriberId = $acySubscriberAPI->save( $newSubscriber ); } if ( ! $subscriberId ) { if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) { var_dump( CBTxt::T( 'AUTO_ACTION_ACYMAILING_NO_SUB', ':: Action [action] :: AcyMailing skipped due to missing subscriber id', array( '[action]' => (int) $trigger->get( 'id' ) ) ) ); } return; } $lists = array(); $subscribe = $params->get( 'subscribe' ); if ( $subscribe ) { $subscribe = explode( '|*|', $subscribe ); cbArrayToInts( $subscribe ); foreach ( $subscribe as $listId ) { $lists[$listId] = array( 'status' => 1 ); } } $unsubscribe = $params->get( 'unsubscribe' ); if ( $unsubscribe ) { $unsubscribe = explode( '|*|', $unsubscribe ); cbArrayToInts( $unsubscribe ); foreach ( $unsubscribe as $listId ) { $lists[$listId] = array( 'status' => -1 ); } } $remove = $params->get( 'remove' ); if ( $remove ) { $remove = explode( '|*|', $remove ); cbArrayToInts( $remove ); foreach ( $remove as $listId ) { $lists[$listId] = array( 'status' => 0 ); } } $pending = $params->get( 'pending' ); if ( $pending ) { $pending = explode( '|*|', $pending ); cbArrayToInts( $pending ); foreach ( $pending as $listId ) { $lists[$listId] = array( 'status' => 2 ); } } if ( $lists ) { $acySubscriberAPI->saveSubscription( $subscriberId, $lists ); } }
function _fixCBmandatoryDb( $dryRun ) { cbimport( 'cb.sql.upgrader' ); $this->_sqlUpgrader = new CBSQLupgrader( $this->_db, $this->_silentWhenOK ); $this->_sqlUpgrader->setDryRun( $dryRun ); $sql = 'SELECT * FROM `#__comprofiler_tabs` ORDER BY `tabid`'; // `tabid`, `pluginclass` $this->_db->setQuery( $sql ); $tabs = $this->_db->loadObjectList( 'tabid' ); if ( $this->_db->getErrorNum() ) { $this->_sqlUpgrader->_setError( 'Tabs selection query error: ' . $this->_db->getErrorMsg() ); return false; } $sql = 'SELECT `fieldid`, `tabid` FROM `#__comprofiler_fields` ORDER BY `tabid`'; $this->_db->setQuery( $sql ); $fields = $this->_db->loadObjectList( 'fieldid' ); if ( $this->_db->getErrorNum() ) { $this->_sqlUpgrader->_setError( sprintf( 'Fields selection query error: ' . $this->_db->getErrorMsg() ), $sql ); return false; } // 1) count and index tabs by core pluginclass and tabid holding array of fieldsids, so we can delete empty duplicate core tabs: $coreTabs = array(); foreach ( $tabs as $t ) { if ( in_array( $t->pluginclass, $this->_tabsShouldBe ) ) { $coreTabs[$t->pluginclass][$t->tabid] = array(); } } // 2) group fieldids by tabid // 3) add fields to $coreTabs[pluginclass][tabid][fieldid] $tabsFields = array(); foreach ( $fields as $f ) { if ( isset( $tabs[$f->tabid] ) ) { $tabsFields[$f->tabid][$f->fieldid] = $f->fieldid; if ( $tabs[$f->tabid]->pluginclass != '' ) { $coreTabs[$tabs[$f->tabid]->pluginclass][$f->tabid][$f->fieldid] = $f->fieldid; } } } // 4) delete empty duplicate core tabs according to $coreTabs[pluginclass][tabid][fieldid] foreach ( $coreTabs as /* $pluginClass => */ $tabIds ) { if ( count( $tabIds ) > 1 ) { // there is more than one core tab for this core plugin class ! We need to decide which to keep: $tabidCandidatesToKeep = array(); // 1st priority: keep tabs that are enabled AND have fields: foreach ( $tabIds as $tId => $tFields ) { if ( ( $tabs[$tId]->enabled == 1 ) && ( count( $tFields ) > 0 ) ) { $tabidCandidatesToKeep[] = $tId; } } // 2nd priority: keep tabs that have fields: if ( count( $tabidCandidatesToKeep ) == 0 ) { foreach ( $tabIds as $tId => $tFields ) { if ( count( $tFields ) > 0 ) { $tabidCandidatesToKeep[] = $tId; } } } // 3rd priority: keep tabs that are enabled: if ( count( $tabidCandidatesToKeep ) == 0 ) { foreach ( $tabIds as $tId => $tFields ) { if ( $tabs[$tId]->enabled == 1 ) { $tabidCandidatesToKeep[] = $tId; } } } // 4th priority: keep tab with the correct id: if ( count( $tabidCandidatesToKeep ) == 0 ) { foreach ( $tabIds as $tId => $tFields ) { if ( isset( $this->_tabsShouldBe[$tId] ) && ( $tabs[$tId]->pluginclass == $this->_tabsShouldBe[$tId] ) ) { $tabidCandidatesToKeep[] = $tId; } } } // 5th priority: well no more priorities to think of ! : just take first one ! if ( count( $tabidCandidatesToKeep ) == 0 ) { foreach ( $tabIds as $tId => $tFields ) { $tabidCandidatesToKeep[] = $tId; break; } } // ok, by now we got at least one tab to keep: let's see which, in case we got more than one: if ( count( $tabidCandidatesToKeep ) == 1 ) { $tabToKeep = (int) $tabidCandidatesToKeep[0]; } else { $tabToKeep = null; // a) has the right core id: foreach ( $tabidCandidatesToKeep as $tId ) { if ( isset( $this->_tabsShouldBe[$tId] ) && ( $tabs[$tId]->pluginclass == $this->_tabsShouldBe[$tId] ) ) { $tabToKeep = $tId; break; } } // b) first with fields: if ( $tabToKeep === null ) { foreach ( $tabidCandidatesToKeep as $tId ) { if ( count( $coreTabs[$tabs[$tId]->pluginclass][$tId] ) > 0 ) { $tabToKeep = $tId; break; } } } // c) first enabled one: if ( $tabToKeep === null ) { foreach ( $tabidCandidatesToKeep as $tId ) { if ( $tabs[$tId]->enabled == 1 ) { $tabToKeep = $tId; break; } } } // d) first one: if ( $tabToKeep === null ) { foreach ( $tabidCandidatesToKeep as $tId ) { $tabToKeep = $tId; break; } } } if ( $tabToKeep !== null ) { $tabsToDelete = array_diff( array_keys( $tabIds ), array( $tabToKeep ) ); // first reassign the fields of the tabs to delete: $fieldsToReassign = array(); foreach ( $tabIds as $tId => $tFields ) { if ( ( $tId != $tabToKeep ) && count( $tFields ) > 0 ) { $fieldsToReassign = array_merge( $fieldsToReassign, $tFields ); } } if ( count( $fieldsToReassign ) > 0 ) { cbArrayToInts( $fieldsToReassign ); $sql = 'UPDATE `#__comprofiler_fields` SET `tabid` = ' . (int) $tabToKeep . ' WHERE `fieldid` IN (' . implode( ',', $fieldsToReassign ) . ')'; if ( ! $this->_sqlUpgrader->_doQuery( $sql ) ) { $this->_sqlUpgrader->_setError( 'Failed changing fieldids ' . implode( ',', $fieldsToReassign ) . ' from duplicates of kept core tabid: ' . $tabToKeep . ' because of error:' . $this->_db->getErrorMsg(), $sql ); break; } else { $this->_sqlUpgrader->_setLog( 'Changed fieldids ' . implode( ',', $fieldsToReassign ) . ' from duplicates of kept core tabid: ' . $tabToKeep, $sql, 'change' ); } } cbArrayToInts( $tabsToDelete ); // c) remove duplicate core tabs: $sql = 'DELETE FROM `#__comprofiler_tabs` WHERE `tabid` IN (' . implode( ',', $tabsToDelete ) . ')'; if ( ! $this->_sqlUpgrader->_doQuery( $sql ) ) { $this->_sqlUpgrader->_setError( 'Failed deleting duplicates tabids ' . implode( ',', $tabsToDelete ) . ' of the used core tabid: ' . $tabToKeep . ' because of error:' . $this->_db->getErrorMsg(), $sql ); break; } else { $this->_sqlUpgrader->_setLog( 'Deleted duplicate core tabs tabids ' . implode( ',', $tabsToDelete ) . ' of the used core tabid: ' . $tabToKeep, $sql, 'change' ); } } } } // 5) refetch tabs with now free space at reserved positions: $sql = 'SELECT * FROM `#__comprofiler_tabs` ORDER BY `tabid`'; // `tabid`, `pluginclass` $this->_db->setQuery( $sql ); $tabs = $this->_db->loadObjectList( 'tabid' ); if ( $this->_db->getErrorNum() ) { $this->_sqlUpgrader->_setError( 'Tabs 2nd selection query error: ' . $this->_db->getErrorMsg(), $sql ); return false; } unset( $coreTabs ); // this one is now invalid, and not needed anymore $sql = 'SELECT `fieldid`, `tabid` FROM `#__comprofiler_fields` ORDER BY `tabid`'; $this->_db->setQuery( $sql ); $fields = $this->_db->loadObjectList( 'fieldid' ); if ( $this->_db->getErrorNum() ) { $this->_sqlUpgrader->_setError( 'Fields 3nd selection query error: ' . $this->_db->getErrorMsg(), $sql ); return false; } // group fieldids by tabid $tabsFields = array(); foreach ( $fields as $f ) { if ( isset( $tabs[$f->tabid] ) ) { $tabsFields[$f->tabid][$f->fieldid] = $f->fieldid; } } // 6) check tabs one by one, making room in reserved positions: foreach ( $tabs as $t ) { if ( isset( $this->_tabsShouldBe[$t->tabid] ) && ( $t->pluginclass == $this->_tabsShouldBe[$t->tabid] ) ) { // ok, cool, tabid and plugin matches: no corrective action: continue; } if ( isset( $this->_tabsShouldBe[$t->tabid] ) ) { // not ok: tabid is taken by another tab: we need to relocate this tab at last position: // a) insert same tab in another tabid $oldTabId = $t->tabid; if ( ! $dryRun ) { $t->tabid = null; if ( ! $this->_db->insertObject( '#__comprofiler_tabs', $t, 'tabid' ) ) { $this->_sqlUpgrader->_setError( 'Failed moving (inserting) non-core tabid: ' . $oldTabId . ' because of error:' . $this->_db->getErrorMsg(), $sql ); break; } $t->tabid = $this->_db->insertid(); } else { $t->tabid = $t->tabid + 10000; // just to fake the insert } $this->_sqlUpgrader->_setLog( 'Inserted old tabid ' . $oldTabId . ' as new tabid ' . $t->tabid, ( $dryRun ? 'INSERT tabobject' : $this->_db->getQuery() ), 'change' ); // b) change fields' tabid: if ( isset( $tabsFields[$oldTabId] ) && ( count( $tabsFields[$oldTabId] ) > 0 ) ) { $sql = 'UPDATE `#__comprofiler_fields` SET `tabid` = ' . (int) $t->tabid . ' WHERE `tabid` = ' . (int) $oldTabId; if ( ! $this->_sqlUpgrader->_doQuery( $sql ) ) { $this->_sqlUpgrader->_setError( 'Failed changing fields from old non-core tab with core tabid: ' . $oldTabId . ' to new tabid: ' . $t->tabid . ' because of error:' . $this->_db->getErrorMsg(), $sql ); break; } else { $this->_sqlUpgrader->_setLog( 'Changed fields from old non-core tab with core tabid: ' . $oldTabId . ' (that must be for ' . $this->_tabsShouldBe[$oldTabId] . ') to new tabid: ' . $t->tabid, $sql, 'change' ); } } // c) remove old tab: $sql = 'DELETE FROM `#__comprofiler_tabs` WHERE tabid = ' . (int) $oldTabId; if ( ! $this->_sqlUpgrader->_doQuery( $sql ) ) { $this->_sqlUpgrader->_setError( 'Failed deleting old non-core tabid: ' . $oldTabId . ' which is already copied to new tabid: ' . $t->tabid . ' because of error:' . $this->_db->getErrorMsg(), $sql ); break; } else { $this->_sqlUpgrader->_setLog( 'Deleted old non-core tabid: ' . $oldTabId . ' which is already copied to new tabid: ' . $t->tabid, $sql, 'change' ); } } } // 7) refetch tabs with now free space at reserved positions as well as fields and recompute $tabFields: $sql = 'SELECT * FROM `#__comprofiler_tabs` ORDER BY `tabid`'; // `tabid`, `pluginclass` $this->_db->setQuery( $sql ); $tabs = $this->_db->loadObjectList( 'tabid' ); if ( $this->_db->getErrorNum() ) { $this->_sqlUpgrader->_setError( 'Tabs 3rd selection query error: ' . $this->_db->getErrorMsg(), $sql ); return false; } $sql = 'SELECT `fieldid`, `tabid` FROM `#__comprofiler_fields` ORDER BY `tabid`'; $this->_db->setQuery( $sql ); $fields = $this->_db->loadObjectList( 'fieldid' ); if ( $this->_db->getErrorNum() ) { $this->_sqlUpgrader->_setError( 'Fields 3nd selection query error: ' . $this->_db->getErrorMsg(), $sql ); return false; } // group fieldids by tabid $tabsFields = array(); foreach ( $fields as $f ) { if ( isset( $tabs[$f->tabid] ) ) { $tabsFields[$f->tabid][$f->fieldid] = $f->fieldid; } } // 8) check tabs one by one, moving tabs back to reserved positions if needed: foreach ( $tabs as $t ) { if ( isset( $this->_tabsShouldBe[$t->tabid] ) && ( $t->pluginclass == $this->_tabsShouldBe[$t->tabid] ) ) { // ok, cool, tabid and plugin matches: no corrective action: continue; } if ( ( ! isset( $this->_tabsShouldBe[$t->tabid] ) ) && in_array( $t->pluginclass, $this->_tabsShouldBe ) ) { // ok we found a core CB tab which doesn't have the right id: the right id is now free, so just update the tab: $newTabId = array_search( $t->pluginclass, $this->_tabsShouldBe ); if ( $newTabId !== false ) { // a) move the core tab to the right tabid: $sql = 'UPDATE `#__comprofiler_tabs` SET `tabid` = ' . (int) $newTabId . ' WHERE `tabid` = ' . (int) $t->tabid; if ( ! $this->_sqlUpgrader->_doQuery( $sql ) ) { $this->_sqlUpgrader->_setError( 'Failed moving core tab from old tabid: ' . $t->tabid . ' to new tabid: ' . $newTabId . ' because of error:' . $this->_db->getErrorMsg(), $sql ); break; } else { $this->_sqlUpgrader->_setLog( 'Moved core tab from old tabid: ' . $t->tabid . ' to new tabid: ' . $newTabId, $sql, 'change' ); } // b) change fields' tabid: if ( isset( $tabsFields[$t->tabid] ) && ( count( $tabsFields[$t->tabid] ) > 0 ) ) { $sql = 'UPDATE `#__comprofiler_fields` SET `tabid` = ' . (int) $newTabId . ' WHERE `tabid` = ' . (int) $t->tabid; if ( ! $this->_sqlUpgrader->_doQuery( $sql ) ) { $this->_sqlUpgrader->_setError( 'Failed changing fields from old core tabid: ' . $oldTabId . ' to new tabid: ' . $t->tabid . ' because of error:' . $this->_db->getErrorMsg(), $sql ); break; } else { $this->_sqlUpgrader->_setLog( 'Changed fields from old core tabid: ' . $oldTabId . ' to new tabid: ' . $t->tabid, $sql, 'change' ); } } } } } // now missing core tabs will be inserted in the new 1.2 upgrader in next step. return true; }
/** * Sanitizes an array to array of (int) as RETURN * * @param array $array in ONLY * @return array */ function cbToArrayOfInt($array) { return cbArrayToInts($array); }
private function saveAutoEdit( $id, $task, $user, $plugin ) { $row = cbgjAutoData::getAutos( null, array( 'id', '=', (int) $id ), null, null, false ); $row->set( 'published', (int) cbgjClass::getCleanParam( true, 'published', $row->get( 'published' ) ) ); $row->set( 'title', cbgjClass::getCleanParam( true, 'title', $row->get( 'title' ) ) ); $row->set( 'description', cbgjClass::getCleanParam( true, 'description', $row->get( 'description' ) ) ); $row->set( 'trigger', str_replace( ' ', '', cbgjClass::getCleanParam( true, 'trigger', $row->get( 'trigger' ) ) ) ); $row->set( 'object', (int) cbgjClass::getCleanParam( true, 'object', $row->get( 'object' ) ) ); if ( $row->get( 'object' ) == 3 ) { $row->set( 'variable', (int) cbgjClass::getCleanParam( true, 'variable_user', $row->get( 'variable' ) ) ); } elseif ( $row->get( 'object' ) == 2 ) { $row->set( 'variable', null ); } elseif ( $row->get( 'object' ) == 1 ) { $row->set( 'variable', (int) cbgjClass::getCleanParam( true, 'variable', $row->get( 'variable' ) ) ); } $row->set( 'access', cbgjClass::getCleanParam( true, 'access', $row->get( 'access' ) ) ); $row->set( 'exclude', cbgjClass::getCleanParam( true, 'exclude', $row->get( 'exclude' ) ) ); $row->set( 'ordering', (int) cbgjClass::getCleanParam( true, 'ordering', $row->get( 'ordering' ) ) ); if ( $row->get( 'exclude' ) ) { $exclude = explode( ',', $row->get( 'exclude' ) ); cbArrayToInts( $exclude ); $row->set( 'exclude', implode( ',', $exclude ) ); } $row->setParams( $_POST['params'] ); if ( $row->get( 'trigger' ) == '' ) { $row->set( '_error', CBTxt::T( 'Trigger not specified!' ) ); } elseif ( $row->get( 'access' ) == '' ) { $row->set( '_error', CBTxt::T( 'Access not specified!' ) ); } elseif ( $row->get( 'object' ) ) { if ( $row->get( 'object' ) == 3 ) { if ( ! $row->get( 'variable' ) ) { $row->set( '_error', CBTxt::T( 'Specific user not specified!' ) ); } } elseif ( $row->get( 'object' ) == 1 ) { if ( ! $row->get( 'variable' ) ) { $row->set( '_error', CBTxt::T( 'User variable not specified!' ) ); } } } else { $params = $row->getParams(); if ( $params->get( 'auto', null ) == '' ) { $row->set( '_error', CBTxt::T( 'Auto not specified!' ) ); } else { if ( $params->get( 'auto', null ) == 1 ) { if ( $params->get( 'groups', null ) == '' ) { $row->set( '_error', CBTxt::T( 'Groups not specified!' ) ); } elseif ( $params->get( 'status', null ) == '' ) { $row->set( '_error', CBTxt::T( 'Status not specified!' ) ); } } elseif ( $params->get( 'auto', null ) == 2 ) { if ( $params->get( 'category', null ) == '' ) { $row->set( '_error', CBTxt::T( 'Category not specified!' ) ); } elseif ( $params->get( 'grp_name', null ) == '' ) { $row->set( '_error', CBTxt::T( 'Group Name not specified!' ) ); } elseif ( $params->get( 'type', null ) == '' ) { $row->set( '_error', CBTxt::T( 'Type not specified!' ) ); } elseif ( $params->get( 'category', null ) == -1 ) { if ( $params->get( 'cat_name', null ) == '' ) { $row->set( '_error', CBTxt::T( 'Category Name not specified!' ) ); } } } elseif ( $params->get( 'auto', null ) == 3 ) { if ( $params->get( 'cat_name', null ) == '' ) { $row->set( '_error', CBTxt::T( 'Category Name not specified!' ) ); } elseif ( $params->get( 'types', null ) == '' ) { $row->set( '_error', CBTxt::T( 'Types not specified!' ) ); } } elseif ( $params->get( 'auto', null ) == 4 ) { if ( $params->get( 'groups', null ) == '' ) { $row->set( '_error', CBTxt::T( 'Groups not specified!' ) ); } } } } $row->setFields( $_POST['fields'] ); $row->setOperators( $_POST['operators'] ); $row->setValues( $_POST['values'] ); if ( $row->getError() || ( ! $row->store() ) ) { return $this->getAutoEdit( $id, $user, $plugin, CBTxt::P( 'Auto failed to save! Error: [error]', array( '[error]' => $row->getError() ) ) ); } if ( in_array( $task, array( 'apply', 'auto_apply' ) ) ) { cbgjClass::getPluginURL( array( 'plugin', 'auto_edit', (int) $row->get( 'id' ) ), CBTxt::T( 'Auto saved successfully!' ), false, true ); } else { cbgjClass::getPluginURL( array( 'plugin', 'auto' ), CBTxt::T( 'Auto saved successfully!' ), false, true ); } }
public function getAccess( $trigger, $fbConfig, $params ) { if ( $trigger == 'getAllowedForumsRead' ) { $plugin = cbgjClass::getPlugin(); $forum = $plugin->params->get( 'forum_id', null ); if ( $forum ) { $forums = array(); $categories = cbgjData::getCategories( array( 'forum_cat_access' ), array( 'params', 'REGEX', 'forum_id=[[:digit:]]+' ) ); if ( $categories ) foreach ( $categories as $category ) { $catParams = $category->getParams(); $forums[] = $catParams->get( 'forum_id', null ); } $groups = cbgjData::getGroups( array( 'forum_grp_access' ), array( 'params', 'REGEX', 'forum_id=[[:digit:]]+' ) ); if ( $groups ) foreach ( $groups as $group ) { $grpParams = $group->getParams(); $forums[] = $grpParams->get( 'forum_id', null ); } if ( ! empty( $forums ) ) { $forums[] = $forum; $existingAccess = explode( ',', $params[1] ); $cleanAccess = array_diff( $forums, $existingAccess ); $newAccess = array_merge( $existingAccess, $cleanAccess ); cbArrayToInts( $newAccess ); $params[1] = implode( ',', $newAccess ); } } } elseif ( $trigger == 'checkSubscribers' ) { $plugin = cbgjClass::getPlugin(); $forum = $plugin->params->get( 'forum_id', null ); if ( $forum ) { $forumId = $params[0]->id; $users = $params[1]; $ids = array(); if ( $forumId && $users ) foreach ( $users as $user ) { $category = cbgjData::getCategories( array( array( 'forum_cat_access' ), $user ), array( 'params', 'REGEX', 'forum_id=[[:<:]]' . (int) $forumId . '[[:>:]]' ), null, null, false ); if ( $category->get( 'id' ) ) { $ids[] = $user; } $group = cbgjData::getGroups( array( array( 'forum_grp_access' ), $user ), array( 'params', 'REGEX', 'forum_id=[[:<:]]' . (int) $forumId . '[[:>:]]' ), null, null, false ); if ( $group->get( 'id' ) ) { $ids[] = $user; } } if ( ! empty( $ids ) ) { $existingAccess = $params[1]; $cleanAccess = array_diff( $ids, $existingAccess ); $newAccess = array_merge( $existingAccess, $cleanAccess ); cbArrayToInts( $newAccess ); $params[1] = array_values( array_unique( $newAccess ) ); } } } elseif ( ( $trigger == 'onStart' ) && cbGetParam( $_REQUEST, 'catid', 0 ) ) { $plugin = cbgjClass::getPlugin(); $backlink = $plugin->params->get( 'forum_backlink', 1 ); $forum = $plugin->params->get( 'forum_id', null ); if ( $backlink && $forum ) { cbgjClass::getTemplate( 'cbgroupjiveforums' ); $catid = (int) cbGetParam( $_REQUEST, 'catid', 0 ); if ( $forum == $catid ) { echo '<div id="cbGj"><div id="cbGjInner"><div class="gjTop gjTopCenter"><a href="' . cbgjClass::getPluginURL( array( 'overview' ) ) . '" role="button" class="gjButton btn"><i class="icon-share-alt"></i> ' . CBTxt::P( 'Back to [overview]', array( '[overview]' => cbgjClass::getOverride( 'overview' ) ) ) . '</a></div></div></div>'; } else { $category = cbgjData::getCategories( array( 'cat_access', 'mod_lvl1' ), array( 'params', 'REGEX', 'forum_id=[[:<:]]' . (int) $catid . '[[:>:]]' ), null, null, false ); if ( $category->get( 'id' ) ) { echo '<div id="cbGj"><div id="cbGjInner"><div class="gjTop gjTopCenter"><a href="' . $category->getUrl() . '" role="button" class="gjButton btn"><i class="icon-share-alt"></i> ' . CBTxt::P( 'Back to [category]', array( '[category]' => cbgjClass::getOverride( 'category' ) ) ) . '</a></div></div></div>'; } else { $group = cbgjData::getGroups( array( 'grp_access', 'mod_lvl2' ), array( 'params', 'REGEX', 'forum_id=[[:<:]]' . (int) $catid . '[[:>:]]' ), null, null, false ); if ( $group->get( 'id' ) ) { echo '<div id="cbGj"><div id="cbGjInner"><div class="gjTop gjTopCenter"><a href="' . $group->getUrl() . '" role="button" class="gjButton btn"><i class="icon-share-alt"></i> ' . CBTxt::P( 'Back to [group]', array( '[group]' => cbgjClass::getOverride( 'group' ) ) ) . '</a></div></div></div>'; } } } } } }
/** * @param cbautoactionsActionTable $trigger * @param UserTable $user */ public function execute( $trigger, $user ) { global $_CB_database; if ( ! $this->installed() ) { if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) { var_dump( CBTxt::T( 'AUTO_ACTION_GROUPJIVE_NOT_INSTALLED', ':: Action [action] :: CB GroupJive is not installed', array( '[action]' => (int) $trigger->get( 'id' ) ) ) ); } return; } foreach ( $trigger->getParams()->subTree( 'groupjive' ) as $row ) { /** @var ParamsInterface $row */ switch( (int) $row->get( 'mode', 1, GetterInterface::INT ) ) { case 3: $owner = $row->get( 'owner', null, GetterInterface::STRING ); if ( ! $owner ) { $owner = (int) $user->get( 'id' ); } else { $owner = (int) $trigger->getSubstituteString( $owner ); } if ( ! $owner ) { if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) { var_dump( CBTxt::T( 'AUTO_ACTION_GROUPJIVE_NO_OWNER', ':: Action [action] :: CB GroupJive skipped due to missing owner', array( '[action]' => (int) $trigger->get( 'id' ) ) ) ); } continue; } $name = $trigger->getSubstituteString( $row->get( 'name', null, GetterInterface::STRING ) ); if ( ! $name ) { if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) { var_dump( CBTxt::T( 'AUTO_ACTION_GROUPJIVE_NO_NAME', ':: Action [action] :: CB GroupJive skipped due to missing name', array( '[action]' => (int) $trigger->get( 'id' ) ) ) ); } continue; } $category = new CategoryTable(); $category->load( array( 'name' => $name ) ); if ( ! $category->get( 'id' ) ) { if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) { var_dump( CBTxt::T( 'AUTO_ACTION_GROUPJIVE_NO_CATEGORY', ':: Action [action] :: CB GroupJive skipped due to missing category', array( '[action]' => (int) $trigger->get( 'id' ) ) ) ); } continue; } $category->set( 'published', 1 ); $category->set( 'user_id', $owner ); $category->set( 'name', $name ); $category->set( 'description', $trigger->getSubstituteString( $row->get( 'description', null, GetterInterface::STRING ) ) ); $category->set( 'access', 1 ); $category->set( 'create_access', 0 ); $category->set( 'types', $row->get( 'types', '1|*|2|*|3', GetterInterface::STRING ) ); $category->set( 'ordering', 1 ); if ( ! $category->store() ) { if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) { var_dump( CBTxt::T( 'AUTO_ACTION_GROUPJIVE_FAILED', ':: Action [action] :: CB GroupJive failed to save. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $category->getError() ) ) ); continue; } } break; case 2: $owner = $row->get( 'owner', null, GetterInterface::STRING ); if ( ! $owner ) { $owner = (int) $user->get( 'id' ); } else { $owner = (int) $trigger->getSubstituteString( $owner ); } if ( ! $owner ) { if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) { var_dump( CBTxt::T( 'AUTO_ACTION_GROUPJIVE_NO_OWNER', ':: Action [action] :: CB GroupJive skipped due to missing owner', array( '[action]' => (int) $trigger->get( 'id' ) ) ) ); } continue; } $categoryId = (int) $row->get( 'category', -1, GetterInterface::INT ); $category = new CategoryTable(); if ( $categoryId == -1 ) { $name = $trigger->getSubstituteString( $row->get( 'category_name', null, GetterInterface::STRING ) ); if ( ! $name ) { if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) { var_dump( CBTxt::T( 'AUTO_ACTION_GROUPJIVE_NO_CAT_NAME', ':: Action [action] :: CB GroupJive skipped due to missing category name', array( '[action]' => (int) $trigger->get( 'id' ) ) ) ); } continue; } $category->load( array( 'name' => $name ) ); if ( ! $category->get( 'id' ) ) { $category->set( 'published', 1 ); $category->set( 'user_id', $owner ); $category->set( 'name', $name ); $category->set( 'description', $trigger->getSubstituteString( $row->get( 'category_description', null, GetterInterface::STRING ) ) ); $category->set( 'access', 1 ); $category->set( 'create_access', 0 ); $category->set( 'types', $row->get( 'category_types', '1|*|2|*|3', GetterInterface::STRING ) ); $category->set( 'ordering', 1 ); if ( ! $category->store() ) { if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) { var_dump( CBTxt::T( 'AUTO_ACTION_GROUPJIVE_FAILED', ':: Action [action] :: CB GroupJive failed to save. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $category->getError() ) ) ); } continue; } } } else { $category->load( (int) $categoryId ); } if ( ! $category->get( 'id' ) ) { if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) { var_dump( CBTxt::T( 'AUTO_ACTION_GROUPJIVE_NO_CATEGORY', ':: Action [action] :: CB GroupJive skipped due to missing category', array( '[action]' => (int) $trigger->get( 'id' ) ) ) ); } continue; } $name = $trigger->getSubstituteString( $row->get( 'name', null, GetterInterface::STRING ) ); if ( ! $name ) { if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) { var_dump( CBTxt::T( 'AUTO_ACTION_GROUPJIVE_NO_NAME', ':: Action [action] :: CB GroupJive skipped due to missing name', array( '[action]' => (int) $trigger->get( 'id' ) ) ) ); } continue; } $group = new GroupTable(); $join = false; if ( $row->get( 'unique', 1, GetterInterface::BOOLEAN ) ) { $group->load( array( 'category' => (int) $category->get( 'id' ), 'user_id' => (int) $owner, 'name' => $name ) ); } else { $group->load( array( 'category' => (int) $category->get( 'id' ), 'name' => $name ) ); if ( $row->get( 'autojoin', 1, GetterInterface::BOOLEAN ) ) { $join = true; } } if ( ! $group->get( 'id' ) ) { $group->set( 'published', 1 ); $group->set( 'category', (int) $category->get( 'id' ) ); $group->set( 'user_id', $owner ); $group->set( 'name', $name ); $group->set( 'description', $trigger->getSubstituteString( $row->get( 'description', null, GetterInterface::STRING ) ) ); $group->set( 'types', (int) $row->get( 'type', 1, GetterInterface::INT ) ); $group->set( 'ordering', 1 ); if ( ! $group->store() ) { if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) { var_dump( CBTxt::T( 'AUTO_ACTION_GROUPJIVE_FAILED', ':: Action [action] :: CB GroupJive failed to save. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $group->getError() ) ) ); } continue; } } elseif ( $join ) { $groupUser = new \CB\Plugin\GroupJive\Table\UserTable( $_CB_database ); $groupUser->load( array( 'group' => (int) $group->get( 'id' ), 'user_id' => (int) $user->get( 'id' ) ) ); if ( ! $groupUser->get( 'id' ) ) { $groupUser->set( 'user_id', (int) $user->get( 'id' ) ); $groupUser->set( 'group', (int) $group->get( 'id' ) ); $groupUser->set( 'status', (int) $row->get( 'group_status', 1, GetterInterface::INT ) ); if ( ! $groupUser->store() ) { if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) { var_dump( CBTxt::T( 'AUTO_ACTION_GROUPJIVE_FAILED', ':: Action [action] :: CB GroupJive failed to save. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $groupUser->getError() ) ) ); } continue; } } } break; case 4: $groups = $row->get( 'groups', null, GetterInterface::STRING ); if ( $groups ) { $groups = explode( '|*|', $groups ); cbArrayToInts( $groups ); foreach ( $groups as $groupId ) { $group = new GroupTable(); $group->load( (int) $groupId ); if ( $group->get( 'id' ) ) { $groupUser = new \CB\Plugin\GroupJive\Table\UserTable( $_CB_database ); $groupUser->load( array( 'group' => (int) $group->get( 'id' ), 'user_id' => (int) $user->get( 'id' ) ) ); if ( $groupUser->get( 'id' ) && ( $groupUser->get( 'status' ) != 4 ) ) { $groupUser->delete(); } } } } break; case 1: default: $groups = $row->get( 'groups', null, GetterInterface::STRING ); if ( $groups ) { $groups = explode( '|*|', $groups ); cbArrayToInts( $groups ); foreach ( $groups as $groupId ) { $group = new GroupTable(); $group->load( (int) $groupId ); if ( $group->get( 'id' ) ) { $groupUser = new \CB\Plugin\GroupJive\Table\UserTable( $_CB_database ); $groupUser->load( array( 'group' => (int) $group->get( 'id' ), 'user_id' => (int) $user->get( 'id' ) ) ); if ( ! $groupUser->get( 'id' ) ) { $groupUser->set( 'user_id', (int) $user->get( 'id' ) ); $groupUser->set( 'group', (int) $group->get( 'id' ) ); $groupUser->set( 'status', (int) $row->get( 'status', 1, GetterInterface::INT ) ); if ( ! $groupUser->store() ) { if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) { var_dump( CBTxt::T( 'AUTO_ACTION_GROUPJIVE_FAILED', ':: Action [action] :: CB GroupJive failed to save. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $groupUser->getError() ) ) ); } continue; } } } } } break; } } }
/** * Loads all the bot files for a particular group (if group not already loaded) * @param string $group The group name, relates to the sub-directory in the plugins directory * @param mixed $ids array of int : ids of plugins to load. OR: string : name of element (OR new in CB 1.2.2: string if ends with a ".": elements starting with "string.") * @param int $publishedStatus if 1 (DEFAULT): load only published plugins, if 0: load all plugins including unpublished ones * @return boolean TRUE: load done, FALSE: no plugin loaded */ function loadPluginGroup($group, $ids = null, $publishedStatus = 1) { global $_CB_framework, $_CB_database; static $dbCache = null; $this->_iserror = false; $group = trim($group); if ($group && !isset($this->_pluginGroups[$group]) || !$this->all_in_array_key($ids, $this->_plugins)) { $cmsAccess = CBuser::getMyInstance()->getAuthorisedViewLevelsIds(true); $cmsAccessCleaned = implode(',', cbArrayToInts($cmsAccess)); if (!isset($dbCache[$publishedStatus][$cmsAccessCleaned][$group])) { $where = array(); if ($publishedStatus == 1) { $where[] = 'published = 1'; } else { $where[] = 'published >= ' . (int) $publishedStatus; } $where[] = 'access IN (' . $cmsAccessCleaned . ')'; if ($group) { $where[] = 'type = ' . $_CB_database->Quote(trim($group)); } /* if ( ( $ids !== null ) && ( count( $ids ) > 0 ) ) { cbArrayToInts( $ids ); if ( count( $ids ) == 1 ) { $where[] = 'id = ' . implode( '', $ids ); } else { $where[] = 'id IN (' . implode( ',', $ids ) . ')'; } } */ $_CB_database->setQuery("SELECT id, folder, element, published, type, params, CONCAT_WS('/',folder,element) AS lookup, name" . "\n FROM #__comprofiler_plugin" . "\n WHERE " . implode(' AND ', $where) . "\n ORDER BY ordering"); $dbCache[$publishedStatus][$cmsAccessCleaned][$group] = $_CB_database->loadObjectList(); if ($_CB_database->getErrorNum()) { $dbCache[$publishedStatus][$cmsAccessCleaned][$group] = null; return false; } } if (count($ids) == 0) { $ids = null; } foreach ($dbCache[$publishedStatus][$cmsAccessCleaned][$group] as $plugin) { if ($ids === null || (is_array($ids) ? in_array($plugin->id, $ids) : (substr($ids, strlen($ids) - 1, 1) == '.' ? substr($plugin->element, 0, strlen($ids)) == $ids : $plugin->element == $ids))) { if (!isset($this->_plugins[$plugin->id]) && $this->_loadPluginFile($plugin)) { $this->_plugins[$plugin->id] = $plugin; if (!isset($this->_pluginGroups[$plugin->type][$plugin->id])) { $this->_pluginGroups[$plugin->type][$plugin->id] =& $this->_plugins[$plugin->id]; } } } } } return true; }
} } if ( in_array( $mode, array( 11, 12, 13, 14, 15 ) ) ) { if ( $includeGrp ) { $includeGrp = explode( ',', $includeGrp ); cbArrayToInts( $includeGrp ); $include_exclude[] = array( 'group', 'IN', $includeGrp ); } if ( $excludeGrp ) { $excludeGrp = explode( ',', $excludeGrp ); cbArrayToInts( $excludeGrp ); $include_exclude[] = array( 'group', '!IN', $excludeGrp ); } } if ( $mode == 0 ) { $rows = cbgjData::getCategories( array( array( 'cat_access', 'mod_lvl1' ), $user ), $include_exclude, array( 'date', 'DESC' ), $display ); $return .= '<div class="gjLatestCategories' . $classLayout . '">'; if ( $rows ) foreach ( $rows as $row ) { $authorized = cbgjClass::getAuthorization( $row, null, $user ); $nestedCount = ( ( ( ( ! $row->get( 'nested' ) ) && cbgjClass::hasAccess( 'mod_lvl1', $authorized ) ) || $row->get( 'nested' ) ) && $row->nestedCount() );
/** * @param cbautoactionsActionTable $trigger * @param UserTable $user */ public function execute( $trigger, $user ) { global $_CB_framework; if ( ( ! $user->get( 'id' ) ) || ( ! $this->installed() ) ) { if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) { var_dump( CBTxt::T( 'AUTO_ACTION_CBSUBS_NOT_INSTALLED', ':: Action [action] :: CB Paid Subscriptions is not installed', array( '[action]' => (int) $trigger->get( 'id' ) ) ) ); } return; } foreach ( $trigger->getParams()->subTree( 'cbsubs' ) as $row ) { /** @var ParamsInterface $row */ $plans = $row->get( 'plans' ); if ( $plans ) { $plans = explode( '|*|', $plans ); cbArrayToInts( $plans ); $mode = $row->get( 'mode', 1, GetterInterface::INT ); $subscriptions = cbpaidSomethingMgr::getAllSomethingOfUser( $user, null ); $activePlans = array(); if ( $subscriptions ) foreach ( $subscriptions as $type ) { foreach ( array_keys( $type ) as $typeId ) { /** @var cbpaidSomething $subscription */ $subscription = $type[$typeId]; $subscriptionId = (int) $subscription->get( 'id' ); $subscriptionStatus = $subscription->get( 'status' ); $planId = (int) $subscription->get( 'plan_id' ); if ( in_array( $planId, $plans ) ) { switch ( $mode ) { case 2: if ( $subscriptionStatus != 'A' ) { $subscription->activate( $user, $_CB_framework->now(), true, 'R' ); } break; case 3: if ( $subscriptionStatus == 'A' ) { cbpaidControllerOrder::doUnsubscribeConfirm( $user, null, $planId, $subscriptionId ); } break; case 4: if ( $subscription->canDelete() ) { $subscription->revert( $user, 'Denied' ); $subscription->delete(); } break; case 1: default: if ( ( $subscriptionStatus == 'A' ) && ( ! in_array( $planId, $activePlans ) ) ) { $activePlans[] = $planId; } break; } } } } if ( $mode == 1 ) { $plansMgr = cbpaidPlansMgr::getInstance(); $postData = array(); $chosenPlans = array(); foreach ( $plans as $planId ) { if ( ! in_array( $planId, $activePlans ) ) { $chosenPlans[$planId] = $plansMgr->loadPlan( $planId ); } } if ( $chosenPlans ) { cbpaidControllerOrder::createSubscriptionsAndPayment( $user, $chosenPlans, $postData, null, null, 'A', null, 'U', 'free' ); } } } } }
/** * Are all of the int values of array $a1 in array $a2 and the other way around too (means arrays contain same integer values) ? * * @param array $a1 * @param array $a2 * @return boolean */ protected static function _ArraysEquivalent($a1, $a2) { cbArrayToInts($a1); cbArrayToInts($a2); return self::_allValuesOfArrayInArray($a1, $a2) && self::_allValuesOfArrayInArray($a2, $a1); }
/** * @param cbautoactionsActionTable $trigger * @param UserTable $user */ public function execute( $trigger, $user ) { global $ueConfig; if ( ! $user->get( 'id' ) ) { if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) { var_dump( CBTxt::T( 'AUTO_ACTION_CONNECTION_NO_USER', ':: Action [action] :: Connection skipped due to no user', array( '[action]' => (int) $trigger->get( 'id' ) ) ) ); } return; } foreach ( $trigger->getParams()->subTree( 'connection' ) as $row ) { /** @var ParamsInterface $row */ $users = $trigger->getSubstituteString( $row->get( 'users', null, GetterInterface::STRING ) ); if ( $users ) { $users = explode( ',', $users ); cbArrayToInts( $users ); $message = $trigger->getSubstituteString( $row->get( 'message', null, GetterInterface::RAW ), false ); $mutual = $row->get( 'mutual', 2, GetterInterface::INT ); $cross = $row->get( 'cross', 1, GetterInterface::INT ); $notify = $row->get( 'notify', 0, GetterInterface::BOOLEAN ); if ( $mutual ) { $oldMutual = $ueConfig['useMutualConnections']; $ueConfig['useMutualConnections'] = ( $mutual == 1 ? '1' : '0' ); } if ( $cross ) { $oldCross = $ueConfig['autoAddConnections']; $ueConfig['autoAddConnections'] = ( $cross == 1 ? '1' : '0' ); } if ( $row->get( 'direction', 0, GetterInterface::BOOLEAN ) ) { foreach ( $users as $userId ) { if ( $userId != $user->get( 'id' ) ) { $connections = new cbConnection( $userId ); if ( ! $connections->getConnectionDetails( $userId, $user->get( 'id' ) ) ) { $connections->addConnection( $user->get( 'id' ), $message, $notify ); } } } } else { $connections = new cbConnection( $user->get( 'id' ) ); foreach ( $users as $userId ) { if ( $userId != $user->get( 'id' ) ) { if ( ! $connections->getConnectionDetails( $user->get( 'id' ), $userId ) ) { $connections->addConnection( $userId, $message, $notify ); } } } } if ( $mutual ) { $ueConfig['useMutualConnections'] = $oldMutual; } if ( $cross ) { $ueConfig['autoAddConnections'] = $oldCross; } } } }
$pms = 0; if ($show_pms != 0) { $pms = $pms_type; // RC2 quick fix if ($pms != 0) { if (class_exists('moscomprofilerUser', false)) { $viewLevels = CBuser::getMyInstance()->getAuthorisedViewLevelsIds(checkJversion() >= 2 ? false : true); } else { // Compute View Level using CMS without loading cb.table and cb.database if they are not already loaded (e.g. when using this function in modules): if (checkJversion() >= 2) { $viewLevels = JUser::getInstance()->getAuthorisedViewLevels(); } else { $viewLevels = range(0, $_CB_framework->myCmsGid()); } } $cleanedANDpubAccess = ' AND published = 1 AND access IN (' . implode(',', cbArrayToInts($viewLevels)) . ')'; if (checkJversion() >= 2) { $cleanedANDpubAccess .= ' AND ' . $_CB_database->NameQuote('language') . ' IN ( ' . $_CB_database->Quote($_CB_framework->getCfg('lang_tag')) . ', ' . $_CB_database->Quote('*') . ', ' . $_CB_database->Quote('') . ' )'; } switch ($pms) { case 1: $pmsnameprefix = ""; $query_pms_count = "SELECT count(id) FROM #__" . $pmsnameprefix . "pms WHERE username="******" AND readstate=0"; $_CB_database->setQuery($query_pms_count); $total_pms = $_CB_database->loadResult(); $query_pms_link = "SELECT id FROM #__menu WHERE link LIKE '%com_" . $pmsnameprefix . "pms%'" . $cleanedANDpubAccess; $_CB_database->setQuery($query_pms_link); $pms_link_id = $_CB_database->loadResult(); $pms_link = "index.php?option=com_" . $pmsnameprefix . "pms&page=index" . ($pms_link_id ? "&Itemid=" . $pms_link_id : ""); break; case 2:
/** * Generates the HTML to display the user profile tab * * @param \CB\Database\Table\TabTable $tab the tab database entry * @param \CB\Database\Table\UserTable $user the user being displayed * @param int $ui 1 for front-end, 2 for back-end * @return string|boolean Either string HTML for tab content, or false if ErrorMSG generated */ public function getDisplayTab($tab, $user, $ui) { global $_CB_framework, $_CB_database, $ueConfig; $return = null; if ($_CB_framework->myId() != $user->id && $_CB_framework->myId() > 0 && (isset($ueConfig['connectionPath']) && $ueConfig['connectionPath']) && $ueConfig['allowConnections']) { $myCBUser = CBuser::getInstance((int) $user->id, false); $myName = $myCBUser->getField('formatname', null, 'html', 'none', 'profile', 0, true); $myAvatar = $myCBUser->getField('avatar', null, 'html', 'none', 'profile', 0, true, array('_hideApproval' => 1)); $i = 0; $cbCon = new cbConnection($_CB_framework->myId()); $conGroups = $cbCon->getDegreeOfSepPath($_CB_framework->myId(), $user->id); $directConDetails = $cbCon->getConnectionDetails($_CB_framework->myId(), $user->id); $addConnURL = $_CB_framework->viewUrl('addconnection', true, array('connectionid' => (int) $user->id)); $removeConnURL = $_CB_framework->viewUrl('removeconnection', true, array('connectionid' => (int) $user->id)); $acceptConnURL = $_CB_framework->viewUrl('acceptconnection', true, array('connectionid' => (int) $user->id)); $denyConnURL = $_CB_framework->viewUrl('denyconnection', true, array('connectionid' => (int) $user->id)); if ($ueConfig['conNotifyType'] != 0) { cbValidator::loadValidation(); $tooltipTitle = sprintf(CBTxt::T('UE_CONNECTTO', 'Connect to %s'), $myName); $ooltipHTML = '<div class="form-group cb_form_line clearfix">' . CBTxt::Th('UE_CONNECTIONINVITATIONMSG', 'Personalize your invitation to connect by adding a message that will be included with your connection.') . '</div>' . '<form action="' . $addConnURL . '" method="post" id="connOverForm" name="connOverForm" class="cb_form cbValidation">' . '<div class="form-group cb_form_line clearfix">' . '<label for="message" class="control-label">' . CBTxt::T('UE_MESSAGE', 'Message') . '</label>' . '<div class="cb_field">' . '<textarea cols="40" rows="8" name="message" class="form-control"></textarea>' . '</div>' . '</div>' . '<div class="form-group cb_form_line clearfix">' . '<input type="submit" class="btn btn-primary cbConnReqSubmit" value="' . htmlspecialchars(CBTxt::Th('UE_SENDCONNECTIONREQUEST', 'Request Connection')) . '"' . cbValidator::getSubmitBtnHtmlAttributes() . ' />' . ' <input type="button" id="cbConnReqCancel" class="btn btn-default cbConnReqCancel cbTooltipClose" value="' . htmlspecialchars(CBTxt::Th('UE_CANCELCONNECTIONREQUEST', 'Cancel')) . '" />' . '</div>' . '</form>'; $tooltip = cbTooltip($ui, $ooltipHTML, $tooltipTitle, 400, null, null, null, 'data-hascbtooltip="true" data-cbtooltip-modal="true"'); } else { $tooltip = null; } $connected = '<div class="cbConnectionPaths alert alert-info">' . CBTxt::Th('CONNECTIONS_YOU_ARE_DIRECTLY_CONNECTED_WITH_USER', 'You are directly connected with [user]', array('[user]' => $myAvatar)) . '</div>'; $requestConnection = '<div class="cbConnectionPaths alert alert-info clearfix">' . '<div class="cbConnPathMessage col-sm-8">' . CBTxt::Th('CONNECTIONS_YOU_HAVE_NO_CONNECTION_WITH_USER', 'You have no established connection with [user]', array('[user]' => $myAvatar)) . '</div>' . '<div class="cbConnPathActions col-sm-4 text-right">' . '<input type="button" value="' . htmlspecialchars(CBTxt::Th('Request Connection')) . '" class="btn btn-success cbConnPathAccept"' . ($tooltip ? ' ' . $tooltip : ' onclick="location.href = \'' . addslashes($addConnURL) . '\';"') . ' />' . '</div>' . '</div>'; $cancelRequest = '<div class="cbConnectionPaths alert alert-info clearfix">' . '<div class="cbConnPathMessage col-sm-8">' . CBTxt::Th('CONNECTIONS_YOUR_CONNECTION_REQUEST_WITH_USER_IS_PENDING', 'Your connection request with [user] is pending acceptance', array('[user]' => $myAvatar)) . '</div>' . '<div class="cbConnPathActions col-sm-4 text-right">' . '<input type="button" value="' . htmlspecialchars(CBTxt::Th('Cancel Request')) . '" class="btn btn-danger cbConnPathReject" onclick="if ( confirm( \'' . addslashes(CBTxt::T('UE_CONFIRMREMOVECONNECTION', 'Are you sure you want to remove this connection?')) . '\' ) ) { location.href = \'' . addslashes($removeConnURL) . '\'; } else { return false }" />' . '</div>' . '</div>'; $acceptDenyRequest = '<div class="cbConnectionPaths alert alert-info clearfix">' . '<div class="cbConnPathMessage col-sm-8">' . CBTxt::Th('CONNECTIONS_THE_CONNECTION_WITH_USER_IS_PENDING_YOUR_ACCEPTANCE', 'The connection with [user] is pending your acceptance', array('[user]' => $myAvatar)) . '</div>' . '<div class="cbConnPathActions col-sm-4 text-right">' . '<input type="button" value="' . htmlspecialchars(CBTxt::Th('Accept')) . '" class="btn btn-success cbConnPathAccept" onclick="location.href = \'' . addslashes($acceptConnURL) . '\';" />' . ' <input type="button" value="' . htmlspecialchars(CBTxt::Th('Reject')) . '" class="btn btn-danger cbConnPathReject" onclick="if ( confirm( \'' . addslashes(CBTxt::T('UE_CONFIRMREMOVECONNECTION', 'Are you sure you want to remove this connection?')) . '\' ) ) { location.href = \'' . addslashes($denyConnURL) . '\'; } else { return false }" />' . '</div>' . '</div>'; $return .= $this->_writeTabDescription($tab, $user); if (is_array($conGroups) && count($conGroups) > 2) { cbArrayToInts($conGroups); $query = "SELECT u.name, u.email, u.username, c.avatar, c.avatarapproved, u.id " . "\n FROM #__comprofiler AS c" . "\n LEFT JOIN #__users AS u ON c.id=u.id" . "\n WHERE c.id IN (" . implode(',', $conGroups) . ")" . "\n AND c.approved=1 AND c.confirmed=1 AND c.banned=0 AND u.block=0"; $_CB_database->setQuery($query); $connections = $_CB_database->loadObjectList('id'); $prevConID = null; $prevConName = null; if (isset($connections[$user->id])) { $return .= '<div class="cbConnectionPaths alert alert-info">' . CBTxt::Th('CONNECTIONS_YOUR_CONNECTION_PATH_TO_USER_OF_DEGREE_IS', 'Your connection path to [user] of [degrees] degrees is ', array('[user]' => $myAvatar, '[degrees]' => $cbCon->getDegreeOfSep())); foreach ($conGroups as $conGroup) { $cbUser = CBuser::getInstance((int) $conGroup); if (!$cbUser) { $cbUser = CBuser::getInstance(null); } if ($i != 0) { $return .= ' <span class="fa fa-chevron-right fa-sm"></span> '; } $conName = $cbUser->getField('formatname', null, 'html', 'none', 'profile', 0, true); $conAvatar = $cbUser->getField('avatar', null, 'html', 'none', 'profile', 0, true, array('_hideApproval' => 1)); if ($conGroup != $_CB_framework->myId() && isset($connections[$conGroup])) { $conDetail = $cbCon->getConnectionDetails($prevConID, $conGroup); $tipField = getConnectionTab::renderConnectionToolTip($conDetail); $tipField .= '<div style="text-align: center; margin: 8px;">' . $cbUser->getField('avatar', null, 'html', 'none', 'list', 0, true) . '</div>'; $tipTitle = $prevConName . CBTxt::T('UE_DETAILSABOUT', ' Details About [PERSON_NAME]', array('[PERSON_NAME]' => htmlspecialchars($conName))); if ($conGroup != $user->id) { $href = $_CB_framework->userProfileUrl((int) $conGroup); } else { $href = null; } $return .= cbTooltip($ui, $tipField, $tipTitle, 300, null, $conAvatar, $href); } else { $return .= $conAvatar; } $i++; $prevConID = $conGroup; $prevConName = $conName; } $return .= '</div>'; if ($directConDetails !== false && $directConDetails->pending) { $return .= $cancelRequest; } elseif ($directConDetails !== false && !$directConDetails->accepted) { $return .= $acceptDenyRequest; } elseif ($directConDetails === false) { $return .= $requestConnection; } } else { $return .= $requestConnection; } } elseif (is_array($conGroups) && count($conGroups) == 2) { $return .= $connected; } else { if ($directConDetails !== false && $directConDetails->pending) { $return .= $cancelRequest; } elseif ($directConDetails !== false && !$directConDetails->accepted) { $return .= $acceptDenyRequest; } else { $return .= $requestConnection; } } } return $return; }
/** * Publishes or Unpublishes one or more plugins * @param array An array of unique category id numbers * @param integer 0 if unpublishing, 1 if publishing */ function publishPlugin($cid = null, $publish = 1, $option) { global $_CB_database, $_CB_framework; if (count($cid) < 1) { $action = $publish ? CBTxt::T('publish') : CBTxt::T('unpublish'); echo "<script type=\"text/javascript\"> alert('" . addslashes(sprintf(CBTxt::T('Select a plugin to %s'), $action)) . "'); window.history.go(-1);</script>\n"; exit; } cbArrayToInts($cid); if ($publish == 0) { foreach ($cid as $id) { $row = new moscomprofilerPlugin($_CB_database); if ($row->load((int) $id)) { if ($row->type == "language" && $row->published) { cbRedirect($_CB_framework->backendUrl("index.php?option={$option}&task=showPlugins"), CBTxt::T('Language plugins cannot be unpublished, only uninstalled'), 'error'); } elseif ($row->id == 1 && $row->published) { cbRedirect($_CB_framework->backendUrl("index.php?option={$option}&task=showPlugins"), CBTxt::T('Core plugin cannot be unpublished'), 'error'); } } else { cbRedirect($_CB_framework->backendUrl("index.php?option={$option}&task=showPlugins"), CBTxt::T('Plugin can not be found'), 'error'); } } } $cids = implode(',', $cid); $query = "UPDATE #__comprofiler_plugin SET published = " . (int) $publish . "\n WHERE id IN ({$cids})" . "\n AND ((checked_out = 0) OR (checked_out = " . (int) $_CB_framework->myId() . "))"; $_CB_database->setQuery($query); if (!$_CB_database->query()) { echo "<script type=\"text/javascript\"> alert('" . $_CB_database->getErrorMsg() . "'); window.history.go(-1); </script>\n"; exit; } if (count($cid) == 1) { $row = new moscomprofilerPlugin($_CB_database); $row->checkin($cid[0]); } cbRedirect($_CB_framework->backendUrl("index.php?option={$option}&task=showPlugins")); }
/** * Generates the HTML to display the user profile tab * @param moscomprofilerTab $tab the tab database entry * @param moscomprofilerUser $user the user being displayed * @param int $ui 1 for front-end, 2 for back-end * @return mixed either string HTML for tab content, or false if ErrorMSG generated */ function getDisplayTab($tab, $user, $ui) { global $_CB_framework, $_CB_database, $ueConfig; // Display shortest connection path / Degree of relationship: $return = ""; if ($_CB_framework->myId() != $user->id && $_CB_framework->myId() > 0 && isset($ueConfig['connectionPath']) && $ueConfig['connectionPath'] && $ueConfig['allowConnections']) { $return .= $this->_writeTabDescription($tab, $user); $return .= "\t\t<div class=\"cbConnectionPaths\">"; $i = 0; $cbCon = new cbConnection($_CB_framework->myId()); $congroups = $cbCon->getDegreeOfSepPath($_CB_framework->myId(), $user->id); $directConDetails = $cbCon->getConnectionDetails($_CB_framework->myId(), $user->id); if (is_array($congroups) && count($congroups) > 2) { cbArrayToInts($congroups); $query = "SELECT u.name,u.email,u.username,c.avatar,c.avatarapproved, u.id " . "\n FROM #__comprofiler AS c" . "\n LEFT JOIN #__users AS u ON c.id=u.id" . "\n WHERE c.id IN (" . implode(',', $congroups) . ")" . "\n AND c.approved=1 AND c.confirmed=1 AND c.banned=0 AND u.block=0"; $_CB_database->setQuery($query); $connections = $_CB_database->loadObjectList('id'); $prevConID = null; $prevConName = null; if (isset($connections[$user->id])) { $live_site = $_CB_framework->getCfg('live_site'); $return .= _UE_CONNECTIONPATH1 . getNameFormat($connections[$user->id]->name, $connections[$user->id]->username, $ueConfig['name_format']) . " ( " . $cbCon->getDegreeOfSep() . _UE_CONNECTIONPATH2; foreach ($congroups as $congroup) { if ($i != 0) { $return .= ' <img src="' . $live_site . '/components/com_comprofiler/images/arrow.png" alt="" /> '; } $conName = getNameFormat($connections[$congroup]->name, $connections[$congroup]->username, $ueConfig['name_format']); if ($congroup != $_CB_framework->myId() && isset($connections[$congroup])) { $conDetail = $cbCon->getConnectionDetails($prevConID, $congroup); $conAvatar = getFieldValue('image', $connections[$congroup]->avatar, $connections[$congroup]); $tipField = "<b>" . _UE_CONNECTEDSINCE . "</b> : " . dateConverter($conDetail->membersince, 'Y-m-d', $ueConfig['date_format']); if (getLangDefinition($conDetail->type) != null) { $tipField .= "<br /><b>" . _UE_CONNECTIONTYPE . "</b> : " . getConnectionTypes($conDetail->type); } if ($conDetail->description != null) { $tipField .= "<br /><b>" . _UE_CONNECTEDCOMMENT . "</b> : " . htmlspecialchars($conDetail->description); } $tipField .= "<div style=\"text-align:center;margin:8px;\">" . htmlspecialchars(preg_replace('/onclick\\s*=\\s*".+"/Uis', "", $conAvatar), ENT_QUOTES) . "</div>"; $tipTitle = $prevConName . _UE_DETAILSABOUT . str_replace("'", "&#039;", $conName); $htmltext = $conName; $href = 'javascript:void(0)'; if ($congroup != $user->id) { $href = cbSef("index.php?option=com_comprofiler&task=userProfile&user="******"<br />" . sprintf(_UE_DIRECTCONNECTIONPENDINGACCEPTANCE, getNameFormat($user->name, $user->username, $ueConfig['name_format'])); } } else { $return .= _UE_NOESTABLISHEDCONNECTION . getNameFormat($user->name, $user->username, $ueConfig['name_format']); } } elseif (is_array($congroups) && count($congroups) == 2) { $return .= _UE_DIRECTCONNECTION . getNameFormat($user->name, $user->username, $ueConfig['name_format']); } else { if ($directConDetails !== false && $directConDetails->pending) { $return .= "<br />" . sprintf(_UE_DIRECTCONNECTIONPENDINGACCEPTANCE, getNameFormat($user->name, $user->username, $ueConfig['name_format'])); } else { $return .= _UE_NOESTABLISHEDCONNECTION . getNameFormat($user->name, $user->username, $ueConfig['name_format']); } } $return .= "</div>"; } return $return; }
function showUsers( $option, $task, $cid ) { global $_CB_database, $_CB_framework, $_POST, $_PLUGINS, $_CB_TxtIntStore; $this->_importNeeded(); $limit = (int) $_CB_framework->getCfg( 'list_limit' ); if ( $limit == 0 ) { $limit = 10; } $filter_type = $_CB_framework->getUserStateFromRequest( "filter_type{$option}", 'filter_type', 0 ); $filter_status = $_CB_framework->getUserStateFromRequest( "filter_status{$option}", 'filter_status', 0 ); $filter_logged = intval( $_CB_framework->getUserStateFromRequest( "filter_logged{$option}", 'filter_logged', 0 ) ); $lastCBlist = $_CB_framework->getUserState( "view{$option}lastCBlist", null ); if( $lastCBlist == 'showusers' ) { if ( $task == 'showusers' ) { $limit = $_CB_framework->getUserStateFromRequest( "viewlistlimit", 'limit', $limit ); $limitstart = $_CB_framework->getUserStateFromRequest( "view{$option}limitstart", 'limitstart', 0 ); } $lastSearch = $_CB_framework->getUserState( "search{$option}", null ); $search = $_CB_framework->getUserStateFromRequest( "search{$option}", 'search', '' ); if ( $lastSearch != $search ) { $limitstart = 0; $_CB_framework->setUserState( "view{$option}limitstart", $limitstart ); } $search = stripslashes( trim( ( $_CB_TxtIntStore->_iso != 'UTF-8' ) ? strtolower( $search ) : ( is_callable( 'mb_convert_case' ) ? mb_convert_case( $search, MB_CASE_LOWER, "UTF-8") : utf8_encode(strtolower(utf8_decode( $search ) ) ) ) ) ); } else { $filter_type = 0; $filter_status = 0; $filter_logged = 0; clearSearchBox(); $search = ''; $limitstart = 0; $_CB_framework->setUserState( "view{$option}limitstart", $limitstart ); $_CB_framework->setUserState( "view{$option}lastCBlist", "showusers" ); } if ( $task !== 'showusers' ) { if ( $task == 'ajaxemailusers' ) { $limitstart = cbGetParam( $_POST, 'limitstart', 0 ); $limit = cbGetParam( $_POST, 'limit', 0 ); } else { $limitstart = 0; if ( $task == 'emailusers' ) { $limit = 101; // so that first 100 users and more... is displayed. } else { $limit = cbGetParam( $_POST, 'limit', 0 ); } } } $tablesSQL = array( 'u' => '#__users AS u' ); $joinsSQL = array( 'ue' => 'LEFT JOIN #__comprofiler AS ue ON u.id = ue.id' ); $tablesWhereSQL = array(); if ( isset( $search ) && ( $search != "") ) { $tablesWhereSQL[] = "(u.username LIKE '%" . $_CB_database->getEscaped( $search, true ) . "%' OR u.email LIKE '%" . $_CB_database->getEscaped( $search, true ) . "%' OR u.name LIKE '%" . $_CB_database->getEscaped( $search, true ) . "%')"; } if ( $filter_type ) { if ( checkJversion() == 2 ) { $tablesWhereSQL[] = "aro.group_id = " . (int) $filter_type; } else { if ( $filter_type == 'Public Frontend' ) { $tablesWhereSQL[] = "(u.usertype = 'Registered' OR u.usertype = 'Author' OR u.usertype = 'Editor'OR u.usertype = 'Publisher')"; } else if ( $filter_type == 'Public Backend' ) { $tablesWhereSQL[] = "( u.usertype = 'Manager' OR u.usertype = 'Administrator' OR u.usertype = 'Super Administrator' )"; } else { $tablesWhereSQL[] = "u.usertype = " . $_CB_database->Quote( $filter_type ); } } } $tBlocked = CBTxt::T('Blocked'); $tEnabled = CBTxt::T('Enabled'); $tUnconfirmed = CBTxt::T('Unconfirmed'); $tConfirmed = CBTxt::T('Confirmed'); $tUnapproved = CBTxt::T('Unapproved'); $tDisapproved = CBTxt::T('Disapproved'); $tApproved = CBTxt::T('Approved'); $tBanned = CBTxt::T('Banned'); $p = ' + '; $userstates = array( $tBlocked => 'u.block = 1', $tEnabled => 'u.block = 0', $tUnconfirmed => 'ue.confirmed = 0', $tConfirmed => 'ue.confirmed = 1', $tUnapproved => 'ue.approved = 0', $tDisapproved => 'ue.approved = 2', $tApproved => 'ue.approved = 1', $tBanned => 'ue.banned <> 0', $tBlocked . $p . $tUnconfirmed . $p . $tUnapproved => '(u.block = 1 AND ue.confirmed = 0 AND ue.approved = 0)', $tEnabled . $p . $tUnconfirmed . $p . $tUnapproved => '(u.block = 0 AND ue.confirmed = 0 AND ue.approved = 0)', $tBlocked . $p . $tConfirmed . $p . $tUnapproved => '(u.block = 1 AND ue.confirmed = 1 AND ue.approved = 0)', $tEnabled . $p . $tConfirmed . $p . $tUnapproved => '(u.block = 0 AND ue.confirmed = 1 AND ue.approved = 0)', $tBlocked . $p . $tUnconfirmed . $p . $tDisapproved => '(u.block = 1 AND ue.confirmed = 0 AND ue.approved = 2)', $tEnabled . $p . $tUnconfirmed . $p . $tDisapproved => '(u.block = 0 AND ue.confirmed = 0 AND ue.approved = 2)', $tBlocked . $p . $tConfirmed . $p . $tDisapproved => '(u.block = 1 AND ue.confirmed = 1 AND ue.approved = 2)', $tEnabled . $p . $tConfirmed . $p . $tDisapproved => '(u.block = 0 AND ue.confirmed = 1 AND ue.approved = 2)', $tBlocked . $p . $tUnconfirmed . $p . $tApproved => '(u.block = 1 AND ue.confirmed = 0 AND ue.approved = 1)', $tEnabled . $p . $tUnconfirmed . $p . $tApproved => '(u.block = 0 AND ue.confirmed = 0 AND ue.approved = 1)', $tBlocked . $p . $tConfirmed . $p . $tApproved => '(u.block = 1 AND ue.confirmed = 1 AND ue.approved = 1)', $tEnabled . $p . $tConfirmed . $p . $tApproved => '(u.block = 0 AND ue.confirmed = 1 AND ue.approved = 1)', CBTxt::T('Avatar not approved') => "(ue.avatar > '' AND ue.avatarapproved = 0)" ); if ( $filter_status ) { $tablesWhereSQL[] = $userstates[$filter_status]; } if ( $filter_logged == 1 ) { $tablesWhereSQL[] = "s.userid = u.id"; } else if ($filter_logged == 2) { $tablesWhereSQL[] = "s.userid IS NULL"; } // exclude any child group id's for this user //$_CB_framework->acl->_debug = true; $pgids = $_CB_framework->acl->get_group_children( userGID( $_CB_framework->myId() ), 'ARO', 'RECURSE' ); if ( is_array( $pgids ) && (count( $pgids ) > 0 ) ) { if ( checkJversion() == 2 ) { $tablesWhereSQL[] = "( aro.group_id NOT IN ( " . implode( ',', $pgids ) . " ) )"; } else { $tablesWhereSQL[] = "( u.gid NOT IN ( " . implode( ',', $pgids ) . " ) )"; } } // Filter the checkmarked users only: if ( $task !== 'showusers' ) { if ( is_array( $cid ) && ( count( $cid ) > 0 ) ) { cbArrayToInts( $cid ); $tablesWhereSQL[] = "( u.id IN ( " . implode( ',', $cid ) . " ) )"; } } // Advanced searches: $myCbUser =& CBuser::getInstance( $_CB_framework->myId() ); $myUser =& $myCbUser->getUserData(); $tabs = $myCbUser->_getCbTabs(); // new cbTabs( 0, 1 ); //TBD: later: this private method should not be called here, but the whole users-list should go into there and be called here. $allFields = $tabs->_getTabFieldsDb( null, $myUser, 'adminfulllist' ); foreach ( $allFields as $k => $v ) { if ( in_array( $v->type, array( 'pm', 'status', 'formatname', 'hidden', 'delimiter', 'userparams' ) ) ) { unset( $allFields[$k] ); // delimiter, userparams do not have search for now! } } $searchVals = new stdClass(); $list_compare_types = 1; // Advanced: all possibilities (WARNING: can be slow) $tableReferences = array( '#__comprofiler' => 'ue', '#__users' => 'u' ); $searchesFromFields = $tabs->applySearchableContents( $allFields, $searchVals, $_POST, $list_compare_types ); $whereFields = $searchesFromFields->reduceSqlFormula( $tableReferences, $joinsSQL, TRUE ); if ( $whereFields ) { $tablesWhereSQL[] = '(' . $whereFields . ')'; } $searchTabContent = $tabs->getSearchablesContents( $allFields, $myUser, $searchVals, $list_compare_types ); if ($filter_logged == 1 || $filter_logged == 2) { $joinsSQL[] .= "\n INNER JOIN #__session AS s ON s.userid = u.id"; // } else { done later, to avoid blocking site: // $joinsSQL[] .= "\n LEFT JOIN #__session AS s ON s.userid = u.id"; } if ( checkJversion() == 2 ) { $joinsSQL[] = "INNER JOIN #__user_usergroup_map AS aro ON aro.user_id = u.id"; // map user to aro for selection (and display if no selection) if ( $filter_type ) { $joinsSQL[] = "LEFT JOIN #__user_usergroup_map AS arodisplay ON arodisplay.user_id = u.id"; // map user to aro for display of all groups $joinsSQL[] = "INNER JOIN #__usergroups AS g ON g.id = arodisplay.group_id"; // map aro to group for display group name } else { $joinsSQL[] = "INNER JOIN #__usergroups AS g ON g.id = aro.group_id"; // map aro to group } } $_PLUGINS->loadPluginGroup('user'); $_PLUGINS->trigger( 'onBeforeBackendUsersListBuildQuery', array( &$tablesSQL, &$joinsSQL, &$tablesWhereSQL, $option ) ); $queryFrom = "\n FROM " . implode( ', ', $tablesSQL ) . ( count( $joinsSQL ) ? "\n " . implode( "\n ", $joinsSQL ) : '' ) . ( count( $tablesWhereSQL ) ? "\n WHERE " . implode( ' AND ', $tablesWhereSQL ) : '' ) ; // Counting query: $query = "SELECT COUNT(DISTINCT u.id)" . $queryFrom ; $_CB_database->setQuery( $query ); $total = $_CB_database->loadResult(); if ( $total === null ) { echo $_CB_database->getErrorMsg(); } if ( $total <= $limitstart ) { $limitstart = 0; } cbimport( 'cb.pagination' ); $pageNav = new cbPageNav( $total, $limitstart, $limit ); if ( checkJversion() == 2 ) { $grp_name = 'title'; } elseif ( checkJversion() == 1 ) { $grp_name = 'name'; $joinsSQL[] = "INNER JOIN #__core_acl_aro AS aro ON aro.value = u.id"; // map user to aro $joinsSQL[] = "INNER JOIN #__core_acl_groups_aro_map AS gm ON gm.aro_id = aro.id"; // map aro to group $joinsSQL[] = "INNER JOIN #__core_acl_aro_groups AS g ON g.id = gm.group_id"; $tablesWhereSQL[] = "aro.section_value = 'users'"; } else { $grp_name = 'name'; $joinsSQL[] = "INNER JOIN #__core_acl_aro AS aro ON aro.value = u.id"; // map user to aro $joinsSQL[] = "INNER JOIN #__core_acl_groups_aro_map AS gm ON gm.aro_id = aro.aro_id"; // map aro to group $joinsSQL[] = "INNER JOIN #__core_acl_aro_groups AS g ON g.group_id = gm.group_id"; $tablesWhereSQL[] = "aro.section_value = 'users'"; } $queryFrom = "\n FROM " . implode( ', ', $tablesSQL ) . ( count( $joinsSQL ) ? "\n " . implode( "\n ", $joinsSQL ) : '' ) . ( count( $tablesWhereSQL ) ? "\n WHERE " . implode( ' AND ', $tablesWhereSQL ) : '' ) ; // Main query: if ( checkJversion() == 2 ) { $query = "SELECT u.*, GROUP_CONCAT( DISTINCT g.$grp_name ORDER BY g.$grp_name SEPARATOR ', ') AS groupname, ue.approved, ue.confirmed" . $queryFrom . ' GROUP BY u.id' ; } else { $query = "SELECT DISTINCT u.*, g.$grp_name AS groupname, ue.approved, ue.confirmed" . $queryFrom ; } $_CB_database->setQuery( $query, (int) $pageNav->limitstart, (int) $pageNav->limit ); $rows = $_CB_database->loadObjectList( null, 'moscomprofilerUser', array( &$_CB_database ) ); if ($_CB_database->getErrorNum()) { echo $_CB_database->stderr(); return false; } // creates the CBUsers in cache corresponding to the $users: foreach ( array_keys( $rows ) as $k) { // do not do this otherwise substitutions do not work: // CBuser::setUserGetCBUserInstance( $rows[$k] ); } $template = 'SELECT COUNT(s.userid) FROM #__session AS s WHERE s.userid = '; $n = count( $rows ); for ( $i = 0; $i < $n; $i++ ) { $row = &$rows[$i]; $query = $template . (int) $row->id; $_CB_database->setQuery( $query ); $row->loggedin = $_CB_database->loadResult(); } $select_tag_attribs = 'class="inputbox" size="1" onchange="document.adminForm.submit( );"'; $inputTextExtras = ''; if ( $task != 'showusers' ) { $inputTextExtras = ' disabled="disabled"'; $select_tag_attribs .= $inputTextExtras; } // get list of Log Status for dropdown filter $logged[] = moscomprofilerHTML::makeOption( 0, CBTxt::T('- Select Login State -')); $logged[] = moscomprofilerHTML::makeOption( 1, CBTxt::T('Logged In')); $lists['logged'] = moscomprofilerHTML::selectList( $logged, 'filter_logged', $select_tag_attribs, 'value', 'text', "$filter_logged", 2 ); // get list of Groups for dropdown filter if ( checkJversion() == 2 ) { $query = "SELECT id AS value, title AS text" . "\n FROM #__usergroups"; } else { $query = "SELECT name AS value, name AS text" . "\n FROM #__core_acl_aro_groups" . "\n WHERE name != 'ROOT'" . "\n AND name != 'USERS'"; } $types[] = moscomprofilerHTML::makeOption( '0', CBTxt::T('- Select Group -') ); $_CB_database->setQuery( $query ); $types = array_merge( $types, $_CB_database->loadObjectList() ); $lists['type'] = moscomprofilerHTML::selectList( $types, 'filter_type', $select_tag_attribs, 'value', 'text', "$filter_type", 2 ); $status[] = moscomprofilerHTML::makeOption( 0, CBTxt::T('- Select User Status -')); foreach ( array_keys( $userstates ) as $k ) { $status[] = moscomprofilerHTML::makeOption( $k, $k ); } $lists['status'] = moscomprofilerHTML::selectList( $status, 'filter_status', $select_tag_attribs, 'value', 'text', "$filter_status", 2 ); $pluginAdditions = $_PLUGINS->trigger( 'onAfterBackendUsersList', array( 1, &$rows, &$pageNav, &$search, &$lists, $option, $select_tag_attribs ) ); $pluginColumns = array(); foreach ( $pluginAdditions as $addition ) { if ( is_array( $addition ) ) { $pluginColumns = array_merge( $pluginColumns, $addition ); } } if ( $task == 'showusers' ) { $usersView = _CBloadView( 'users' ); $usersView->showUsers( $rows, $pageNav, $search, $option, $lists, $pluginColumns, $inputTextExtras, $searchTabContent ); } else { $emailSubject = stripslashes( cbGetParam( $_POST, 'emailsubject', '' ) ); $emailBody = stripslashes( cbGetParam( $_POST, 'emailbody', '', _CB_ALLOWRAW | _CB_NOTRIM ) ); $emailsPerBatch = stripslashes( cbGetParam( $_POST, 'emailsperbatch', 50 ) ); $emailPause = stripslashes( cbGetParam( $_POST, 'emailpause', 30 ) ); $simulationMode = stripslashes( cbGetParam( $_POST, 'simulationmode', '' ) ); if ( count( $cid ) > 0 && count( $cid ) < $total ) { $total = count( $cid ); } if ( $task == 'emailusers' ) { $pluginRows = $_PLUGINS->trigger( 'onBeforeBackendUsersEmailForm', array( &$rows, &$pageNav, &$search, &$lists, &$cid, &$emailSubject, &$emailBody, &$inputTextExtras, &$select_tag_attribs, $simulationMode, $option ) ); $usersView = _CBloadView( 'users' ); $usersView->emailUsers( $rows, $total, $search, $option, $lists, $cid, $inputTextExtras, $searchTabContent, $emailSubject, $emailBody, $emailsPerBatch, $emailPause, $simulationMode, $pluginRows ); } elseif ( $task == 'startemailusers' ) { $pluginRows = $_PLUGINS->trigger( 'onBeforeBackendUsersEmailStart', array( &$rows, $total, $search, $lists, $cid, &$emailSubject, &$emailBody, &$inputTextExtras, $simulationMode, $option ) ); $usersView = _CBloadView( 'users' ); $usersView->startEmailUsers( $rows, $search, $option, $lists, $cid, $inputTextExtras, $searchTabContent, $emailSubject, $emailBody, $emailsPerBatch, $emailPause, $total, $simulationMode, $pluginRows ); } elseif ( $task == 'ajaxemailusers' ) { $this->_cbadmin_emailUsers( $rows, $emailSubject, $emailBody, $limitstart, $limit, $total, $simulationMode ); } } return true; }
/** * Mutator: * Prepares field data rollback * Override * * @param FieldTable $field * @param UserTable $user RETURNED populated: touch only variables related to saving this field (also when not validating for showing re-edit) * @param array $postdata Typically $_POST (but not necessarily), filtering required. * @param string $reason 'edit' for save user edit, 'register' for save registration */ public function rollbackFieldDataSave( &$field, &$user, &$postdata, $reason ) { if ( ! in_array( $reason, array( 'register', 'edit' ) ) ) { return; } $value = $this->getValue( $field, $user, $postdata, true ); if ( $value ) { $groups = explode( '|*|', $value ); cbArrayToInts( $groups ); foreach ( $groups as $groupId ) { $row = new \CB\Plugin\GroupJive\Table\UserTable(); $row->load( array( 'user_id' => (int) $user->get( 'id' ), 'group' => (int) $groupId ) ); if ( ! $row->get( 'id' ) ) { continue; } if ( ! $row->canDelete() ) { $this->_setValidationError( $field, $user, $reason, $row->getError() ); break; } if ( ! $row->delete() ) { $this->_setValidationError( $field, $user, $reason, $row->getError() ); break; } } } }
/** * Prepare top most GID from array of IDs * * @param array $gids * @return int */ function getBackwardsCompatibleGid($gids) { static $mod = null; static $admin = null; static $super_admin = null; if ($super_admin === null) { $mod = $this->mapGroupNamesToValues('Manager'); $admin = $this->mapGroupNamesToValues('Administrator'); $super_admin = $this->mapGroupNamesToValues('Superadministrator'); } $gids = (array) $gids; cbArrayToInts($gids); if (in_array($super_admin, $gids)) { $gid = $super_admin; } elseif (in_array($admin, $gids)) { $gid = $admin; } elseif (in_array($mod, $gids)) { $gid = $mod; } else { $gid = empty($gids) ? null : $gids[count($gids) - 1]; } return $gid; }
/** * @return string The html for the limit # input box */ function getLimitBox($showLimitBox = true) { if ($showLimitBox) { if (!in_array((int) $this->limit, $this->_limits)) { $this->_limits[] = (int) $this->limit; cbArrayToInts($this->_limits); sort($this->_limits); } $limits = array(); foreach ($this->_limits as $i) { $limits[] = moscomprofilerHTML::makeOption("{$i}"); } // build the html select list $html = moscomprofilerHTML::selectList($limits, $this->_fieldName('limit'), 'class="inputbox" size="1" onchange="' . $this->js_limitstart(0) . '"', 'value', 'text', $this->limit, 2); } else { $html = "\n<input type=\"hidden\" name=\"" . $this->_fieldName('limit') . '" value="' . (int) $this->limit . '" />'; } $html .= "\n<input type=\"hidden\" name=\"" . $this->_fieldName('limitstart') . '" value="' . (int) $this->limitstart . '" />'; return $html; }
/** * @param cbautoactionsActionTable $trigger * @param UserTable $user */ public function execute( $trigger, $user ) { if ( ! $user->get( 'id' ) ) { if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) { var_dump( CBTxt::T( 'AUTO_ACTION_USERGROUP_NO_USER', ':: Action [action] :: Usergroup skipped due to no user', array( '[action]' => (int) $trigger->get( 'id' ) ) ) ); } return; } $cache = $user->get( 'password' ); $user->set( 'password', null ); foreach ( $trigger->getParams()->subTree( 'usergroup' ) as $row ) { /** @var ParamsInterface $row */ $groups = $row->get( 'groups', null, GetterInterface::STRING ); if ( $groups ) { $groups = explode( '|*|', $groups ); cbArrayToInts( $groups ); } $session = JFactory::getSession(); $jUser = $session->get( 'user' ); $isMe = ( $jUser ? ( $jUser->id == $user->get( 'id' ) ) : false ); switch ( $row->get( 'mode', 'add', GetterInterface::STRING ) ) { case 'create': $title = $trigger->getSubstituteString( $row->get( 'title', null, GetterInterface::STRING ) ); if ( ! $title ) { if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) { var_dump( CBTxt::T( 'AUTO_ACTION_USERGROUP_NO_TITLE', ':: Action [action] :: Usergroup skipped due to missing title', array( '[action]' => (int) $trigger->get( 'id' ) ) ) ); } continue; } $usergroup = JTable::getInstance( 'usergroup' ); $usergroup->load( array( 'title' => $title ) ); if ( ! $usergroup->id ) { $usergroup->parent_id = (int) $row->get( 'parent', 0, GetterInterface::INT ); $usergroup->title = $title; if ( ! $usergroup->store() ) { if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) { var_dump( CBTxt::T( 'AUTO_ACTION_USERGROUP_CREATE_FAILED', ':: Action [action] :: Usergroup failed to create', array( '[action]' => (int) $trigger->get( 'id' ) ) ) ); } continue; } } if ( $row->get( 'add', 1, GetterInterface::BOOLEAN ) ) { if ( ! in_array( $usergroup->id, $user->get( 'gids' ) ) ) { $user->gids[] = $usergroup->id; if ( ! $user->store() ) { if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) { var_dump( CBTxt::T( 'AUTO_ACTION_USERGROUP_FAILED', ':: Action [action] :: Usergroup failed to save. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $user->getError() ) ) ); } continue; } if ( $isMe ) { JAccess::clearStatics(); $session->set( 'user', new JUser( $user->get( 'id' ) ) ); } } } break; case 'replace': if ( ! $groups ) { if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) { var_dump( CBTxt::T( 'AUTO_ACTION_USERGROUP_NO_GROUPS', ':: Action [action] :: Usergroup skipped due to missing groups', array( '[action]' => (int) $trigger->get( 'id' ) ) ) ); } continue; } $user->set( 'gids', $groups ); if ( ! $user->store() ) { if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) { var_dump( CBTxt::T( 'AUTO_ACTION_USERGROUP_FAILED', ':: Action [action] :: Usergroup failed to save. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $user->getError() ) ) ); } continue; } if ( $isMe ) { JAccess::clearStatics(); $session->set( 'user', new JUser( $user->get( 'id' ) ) ); } break; case 'remove': if ( ! $groups ) { if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) { var_dump( CBTxt::T( 'AUTO_ACTION_USERGROUP_NO_GROUPS', ':: Action [action] :: Usergroup skipped due to missing groups', array( '[action]' => (int) $trigger->get( 'id' ) ) ) ); } continue; } $removed = false; foreach( $user->get( 'gids' ) as $k => $gid ) { if ( in_array( $gid, $groups ) ) { unset( $user->gids[$k] ); $removed = true; } } if ( $removed ) { if ( ! $user->store() ) { if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) { var_dump( CBTxt::T( 'AUTO_ACTION_USERGROUP_FAILED', ':: Action [action] :: Usergroup failed to save. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $user->getError() ) ) ); } continue; } if ( $isMe ) { JAccess::clearStatics(); $session->set( 'user', new JUser( $user->get( 'id' ) ) ); } } break; case 'add': default: if ( ! $groups ) { if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) { var_dump( CBTxt::T( 'AUTO_ACTION_USERGROUP_NO_GROUPS', ':: Action [action] :: Usergroup skipped due to missing groups', array( '[action]' => (int) $trigger->get( 'id' ) ) ) ); } continue; } $usergroups = $groups; foreach( $usergroups as $k => $usergroup ) { if ( in_array( $usergroup, $user->get( 'gids' ) ) ) { unset( $usergroups[$k] ); } } if ( $usergroups ) { $user->set( 'gids', array_unique( array_merge( $user->get( 'gids' ), $usergroups ) ) ); if ( ! $user->store() ) { if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) { var_dump( CBTxt::T( 'AUTO_ACTION_USERGROUP_FAILED', ':: Action [action] :: Usergroup failed to save. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $user->getError() ) ) ); } continue; } if ( $isMe ) { JAccess::clearStatics(); $session->set( 'user', new JUser( $user->get( 'id' ) ) ); } } break; } } $user->set( 'password', $cache ); }
/** * builds and returns limitbox select input or hidden limit input * * @param bool $showLimitBox * @param bool $showLabel * @return string */ public function getLimitBox($showLimitBox = true, $showLabel = false) { if ($showLimitBox) { if (!in_array((int) $this->limit, $this->limits)) { $this->limits[] = (int) $this->limit; cbArrayToInts($this->limits); sort($this->limits); } $limits = array(); foreach ($this->limits as $i) { $limits[] = moscomprofilerHTML::makeOption($i); } $return = '<span class="' . htmlspecialchars($this->classes['cbPaginationLimit']) . '">' . ($showLabel ? CBTxt::Th('PAGENAV_DISPLAY_NUMBER_PER_PAGE', 'Display #') . ' ' : null) . moscomprofilerHTML::selectList($limits, $this->fieldName('limit'), 'class="' . htmlspecialchars($this->classes['cbPageLimitbox']) . '" onchange="' . $this->limitstartJs(0) . '"', 'value', 'text', (int) $this->limit, 2) . '</span>'; } else { $return = '<input type="hidden" name="' . $this->fieldName('limit') . '" value="' . (int) $this->limit . '" />'; } $return .= '<input type="hidden" name="' . $this->fieldName('limitstart') . '" value="' . (int) $this->limitstart . '" />'; return $return; }
static function editList( &$row, $lists, $fields, $option, $tabid, $paramsEditorHtml ) { global $_CB_database, $_CB_framework; HTML_comprofiler::secureAboveForm('editList'); outputCbTemplate( 2 ); outputCbJs( 2 ); initToolTip(2); global $_CB_Backend_Title; $_CB_Backend_Title = array( 0 => array( 'cbicon-48-lists', htmlspecialchars( CBTxt::T('Community Builder List') ) . ": <small>" . ( $row->listid ? htmlspecialchars( CBTxt::T('Edit') ) . ' [ '. htmlspecialchars( getLangDefinition( $row->title ) ) .' ]' : htmlspecialchars( CBTxt::T('New') ) ) . '</small>' ) ); if ( $row->listid && ( ! $row->published ) ) { echo '<div class="cbWarning">' . htmlspecialchars( CBTxt::T('List is not published') ) . '</div>' . "\n"; } $notFoundFielIds = array(); $fieldids = array(); $col1options=""; $col2options=""; $col3options=""; $col4options=""; if($tabid >0) { $col1fields=explode('|*|',$row->col1fields); for ($i=0, $n=count( $col1fields ); $i < $n; $i++) { $col1field = $col1fields[$i]; if(trim($col1field)!='' && trim($col1field)!=null) { $text = array_search($col1field,$fields); if ( is_string( $text ) ) { $col1options .= "<option value=\"".$col1field."\">". htmlspecialchars( getLangDefinition($text) ) ."\n"; $fieldids[] = $col1field; } else { $notFoundFielIds[] = $col1field; } } } $col2fields=explode('|*|',$row->col2fields); for ($i=0, $n=count( $col2fields ); $i < $n; $i++) { $col2field = $col2fields[$i]; if(trim($col2field)!='' && trim($col2field)!=null) { $text = array_search($col2field,$fields); if ( is_string( $text ) ) { $col2options .= "<option value=\"".$col2field."\">". htmlspecialchars( getLangDefinition($text) ) ."\n"; $fieldids[] = $col2field; } else { $notFoundFielIds[] = $col2field; } } } $col3fields=explode('|*|',$row->col3fields); for ($i=0, $n=count( $col3fields ); $i < $n; $i++) { $col3field = $col3fields[$i]; if(trim($col3field)!='' && trim($col3field)!=null) { $text = array_search($col3field,$fields); if ( is_string( $text ) ) { $col3options .= "<option value=\"".$col3field."\">". htmlspecialchars( getLangDefinition($text) ) ."\n"; $fieldids[] = $col3field; } else { $notFoundFielIds[] = $col3field; } } } $col4fields=explode('|*|',$row->col4fields); for ($i=0, $n=count( $col4fields ); $i < $n; $i++) { $col4field = $col4fields[$i]; if(trim($col4field)!='' && trim($col4field)!=null) { $text = array_search($col4field,$fields); if ( is_string( $text ) ) { $col4options .= "<option value=\"".$col4field."\">". htmlspecialchars( getLangDefinition($text) ) ."\n"; $fieldids[] = $col4field; } else { $notFoundFielIds[] = $col4field; } } } } // this query is for listing displayable fields which are not yet in a column: $fieldsRemaining = array_diff( $fields, $fieldids ); if ( count( $fieldsRemaining ) > 0 ) { $_CB_database->setQuery( "SELECT f.fieldid, f.title, f.name" . "\n FROM #__comprofiler_fields f" . "\n INNER JOIN #__comprofiler_plugin AS p ON (f.pluginid = p.id)" . "\n WHERE f.fieldid IN (" . implode( ',', $fieldsRemaining ) . ')' . "\n AND p.published = 1" ); $fields = $_CB_database->loadObjectList(); } else { $fields = array(); } $stripME = array(" ASC", " DESC","`"); $sortsArray = explode( ', ', $row->sortfields ); $SQLfunctions = array(); $k = -1; foreach ( $sortsArray as $k => $v ) { $WhereIn = trim( str_replace($stripME, "", $v ) ); if ( substr( $WhereIn, -1, 1 ) == ')') { $SQLfunctions[] = $WhereIn; unset( $sortsArray[$k] ); } else { $sortsArray[$k] = $_CB_database->Quote( $WhereIn ); } } $sortsArray[$k+1] = $_CB_database->Quote( 'onlinestatus' ); //TBD: refactor to field, temporarly in here... // this query is for listing sortable fields // sortsArray never empty, so this is ok: $_CB_database->setQuery( "SELECT f.title, f.name" . "\n FROM #__comprofiler_fields f" . "\n INNER JOIN #__comprofiler_plugin AS p ON (f.pluginid = p.id)" . "\n WHERE ( f.published = 1 OR f.name IN ('name','username') )" . "\n AND f.name <> 'NA'" . "\n AND f.tablecolumns <> ''" . "\n AND p.published = 1" . "\n AND f.name NOT IN(" . implode( ',', $sortsArray ) . ")" ); /* $stripME = array(" ASC", " DESC","`"); $WhereIn = str_replace($stripME, "", $row->sortfields); $WhereIn = "'".str_replace(", ","','",$WhereIn)."'"; $_CB_database->setQuery( "SELECT f.title, f.name" . "\nFROM #__comprofiler_fields f" . "\nWHERE f.published = 1 AND f.name!='NA'" . "\nAND f.name NOT IN(".$WhereIn.")" ); */ $sortfields = $_CB_database->loadObjectList(); if ( ( ! $_CB_database->getErrorNum() ) && ( count( $sortfields ) > 0 ) && ! in_array( 'RAND()', $SQLfunctions ) ) { $randomSort = new stdClass(); $randomSort->title = CBTxt::T('Sort Randomly'); $randomSort->name = "RAND()"; $sortfields[] = $randomSort; } // this query is for listing filterable fields $_CB_database->setQuery( "SELECT f.title, f.name" . "\n FROM #__comprofiler_fields f" . "\n INNER JOIN #__comprofiler_plugin AS p ON (f.pluginid = p.id)" . "\n WHERE f.published = 1" . "\n AND f.name <> 'NA'" . "\n AND f.tablecolumns <> ''" . "\n AND p.published = 1" . "\n OR f.name IN ('name','username')" ); $filterfields = $_CB_database->loadObjectList(); $sortlists=explode(", ",str_replace("`","",$row->sortfields)); $sortparts=array(); $i=0; foreach($sortlists as $sortlist) { $sortlistpart=array(); $sortlistpart=explode(" ",$sortlist); if(!ISSET($sortlistpart[1])) $sortlistpart[1]=""; $sortparts[$i]['field']=$sortlistpart[0]; $sortparts[$i]['dir']=$sortlistpart[1]; if ( substr( $sortlistpart[0], -1, 1 ) != ')' ) { $_CB_database->setQuery("SELECT title FROM #__comprofiler_fields WHERE name='".$sortlistpart[0]."'",0,1); $sortparts[$i]['title']=$_CB_database->loadResult(); } else { switch ( $sortlistpart[0] ) { case 'RAND()': $sortparts[$i]['title'] = CBTxt::T('Sort Randomly'); break; default: $sortparts[$i]['title'] = CBTxt::T('Non-existing field') . ": " . $sortlistpart[0]; break; } } $i++; } if ( count( $notFoundFielIds ) > 0 ) { cbArrayToInts( $notFoundFielIds ); $_CB_database->setQuery( "SELECT f.name, f.title, f.published, f.profile, p.published AS pluginpublished, p.name AS pluginname" . "\n FROM #__comprofiler_fields AS f" . "\n INNER JOIN #__comprofiler_plugin AS p ON (f.pluginid = p.id)" . "\n WHERE f.fieldid IN (" . implode( ',', $notFoundFielIds ) . ")" // . "\n WHERE f.published = 1" // . "\n AND f.profile > 0" // . "\n AND p.published = 1" . "\n ORDER BY f.ordering" ); $problemFields = $_CB_database->loadObjectList(); if ( ( ! $_CB_database->getErrorNum() ) && ( count( $problemFields ) > 0 ) ) { echo '<div class="cbWarning">' . htmlspecialchars( CBTxt::T('Following fields are in list but not visible in here for following reason(s)') ) . ':<ul>'; foreach ( $problemFields as $f ) { if ( $f->published != 1 ) { echo '<li>'. htmlspecialchars( sprintf(CBtxt::T('Field "%s (%s)" is not published !'), getLangDefinition( $f->title ), $f->name) ) . '</li>'; } if ( $f->profile <= 0 ) { echo '<li>'. htmlspecialchars( sprintf(CBtxt::T('Field "%s (%s)" is not displayed on profile !'), getLangDefinition( $f->title ), $f->name) ) . '</li>'; } if ( $f->pluginpublished != 1 ) { echo '<li>'. htmlspecialchars( sprintf(CBtxt::T('Field "%s (%s)" is from plugin "%s" but this plugin is not published !'), getLangDefinition( $f->title ), $f->name, $f->pluginname) ) . '</li>'; } } echo '</ul>' . htmlspecialchars( CBTxt::T('If you save this users list now, the fields listed above will be removed from this users list. If you want to keep these fields in this list, cancel now and go to Components / Community Builder / Field Manager.') ) . '</div>' . "\n"; } } $editorSave_description = $_CB_framework->saveCmsEditorJS( 'description' ); ob_start(); ?> function getObject(obj) { return document.getElementById(obj); } function shDiv(objID,sh) { var strObj; strObj = getObject(objID); if(sh==0) { strObj.style.display="none"; } else { strObj.style.display="block"; } } function submitbutton(pressbutton) { if (pressbutton == 'showLists') { <?php echo $editorSave_description; ?> submitform( pressbutton ); return; } var coll = document.adminForm; var errorMSG = ''; var iserror=0; if (coll.col1enabled.checked == true) coll.col1title.setAttribute('mosReq',1); if (coll.col2enabled.checked == true) coll.col2title.setAttribute('mosReq',1); if (coll.col3enabled.checked == true) coll.col3title.setAttribute('mosReq',1); if (coll.col4enabled.checked == true) coll.col4title.setAttribute('mosReq',1); getSortList(document.adminForm.sort); getFilterList(document.adminForm.filter); if (coll != null) { var elements = coll.elements; // loop through all input elements in form for (var i=0; i < elements.length; i++) { // check if element is mandatory; here mosReq=1 if ((typeof(elements.item(i).getAttribute('mosReq')) != "undefined") && (elements.item(i).getAttribute('mosReq') == 1)) { if (elements.item(i).value == '') { //alert(elements.item(i).getAttribute('mosLabel') + ':' + elements.item(i).getAttribute('mosReq')); // add up all error messages errorMSG += elements.item(i).getAttribute('mosLabel') + ' : <?php echo _UE_REQUIRED_ERROR; ?>\n'; // notify user by changing background color, in this case to red elements.item(i).style.backgroundColor = "red"; iserror=1; } } } } if(iserror==1) { alert(errorMSG); } else { selectAll(document.adminForm.col1); selectAll(document.adminForm.col2); selectAll(document.adminForm.col3); selectAll(document.adminForm.col4); <?php echo $editorSave_description; ?> submitform( pressbutton ); } } function addOption(selectObj, value) { optionSelected = (value == null); if(value == null) value = prompt('', ''); if(value != null) { if(value.indexOf(',') != -1) alert('<?php echo addslashes( CBTxt::T('Commas are not allowed in size values') ); ?>'); else { var i = selectObj.options.length; value = value.replace(/1\/2/g, '�'); selectObj.options.length = i + 1; selectObj.options[i].value = (value != '' && value != ' ') ? value : ' '; selectObj.options[i].text = (value != '' && value != ' ') ? value : '[empty]'; selectObj.options[i].selected = optionSelected; // uncomment the line below if you want the select list to change it's size to match the number of options it contains. // selectObj.size = selectObj.options.length; } } } function editOptions(selectObj) { for(var i = 0; i < selectObj.options.length; i++) { if(selectObj.options[i].selected) { var value = prompt('', selectObj.options[i].value); if(value != null) { if(value.indexOf(',') != -1) alert('<?php echo addslashes( CBTxt::T('Commas are not allowed in size values') ); ?>'); else { selectObj.options[i].value = value; selectObj.options[i].text = (value != '') ? value : '[empty]'; selectObj.options[i].selected = true; } } } } } function deleteOptions(selectObj) { for(var i = 0; i < selectObj.options.length; i++) { if(selectObj.options[i].selected) { for(var j = i; j < selectObj.options.length - 1; j++) { selectObj.options[j].value = selectObj.options[j + 1].value; selectObj.options[j].text = selectObj.options[j + 1].text; selectObj.options[j].selected = selectObj.options[j + 1].selected; } selectObj.options.length = selectObj.options.length - 1; i--; } } } function moveOptions(selectObj, direction) { if(selectObj.selectedIndex != -1) { if(direction < 0) { for(i = 0; i < selectObj.options.length; i++) { swapValue = (i == 0 || selectObj.options[i + direction].selected) ? null : selectObj.options[i + direction].value; swapText = (i == 0 || selectObj.options[i + direction].selected) ? null : selectObj.options[i + direction].text; if(selectObj.options[i].selected && swapValue != null && swapText != null) { thisValue = selectObj.options[i].value; thisText = selectObj.options[i].text; selectObj.options[i].value = swapValue; selectObj.options[i].text = swapText; selectObj.options[i + direction].value = thisValue; selectObj.options[i + direction].text = thisText; selectObj.options[i].selected = false; selectObj.options[i + direction].selected = true; } } } else { for(i = selectObj.options.length - 1; i >= 0; i--) { swapValue = (i == selectObj.options.length - 1 || selectObj.options[i + direction].selected) ? null : selectObj.options[i + direction].value; swapText = (i == selectObj.options.length - 1 || selectObj.options[i + direction].selected) ? null : selectObj.options[i + direction].text; if(selectObj.options[i].selected && swapValue != null && swapText != null) { thisValue = selectObj.options[i].value; thisText = selectObj.options[i].text; selectObj.options[i].value = swapValue; selectObj.options[i].text = swapText; selectObj.options[i + direction].value = thisValue; selectObj.options[i + direction].text = thisText; selectObj.options[i].selected = false; selectObj.options[i + direction].selected = true; } } } } } var NS4 = (document.layers); function moveOption(fromObj, toObj) { for(var i = fromObj.options.length - 1; i >= 0; i--) { if(fromObj.options[i].selected) { fromObj.options[i].selected = false; var optionText = fromObj.options[i].text.replace(' [ASC]',''); optionText = optionText.replace(' [DESC]',''); var optionValue = fromObj.options[i].value.replace(' ASC',''); optionValue = optionValue.replace(' DESC',''); for(var j = i; j < fromObj.options.length - 1; j++) { fromObj.options[j].text = fromObj.options[j + 1].text; fromObj.options[j].value = fromObj.options[j + 1].value; } fromObj.options.length = fromObj.options.length - 1; toObjIndex = toObj.options.length; toObj.options.length = toObj.options.length + 1; toObj.options[toObjIndex].text = optionText; toObj.options[toObjIndex].value = optionValue; if(NS4) history.go(0); } } } function moveOption2(fromObj, toObj, appendValue) { if(fromObj.options[fromObj.selectedIndex].selected) { fromObjIndex=fromObj.selectedIndex; fromObj.options[fromObjIndex].selected = false; optionText = fromObj.options[fromObjIndex].text+ ' ['+appendValue+']'; optionValue = fromObj.options[fromObjIndex].value+' '+appendValue; for(var j = fromObjIndex; j < fromObj.options.length - 1; j++) { fromObj.options[j].text = fromObj.options[j + 1].text; fromObj.options[j].value = fromObj.options[j + 1].value; } fromObj.options.length = fromObj.options.length - 1; toObjIndex = toObj.options.length; toObj.options.length = toObj.options.length + 1; toObj.options[toObjIndex].text = optionText; toObj.options[toObjIndex].value = optionValue; toObj.options[toObjIndex].selected=false; if(NS4) history.go(0); } } function moveOption3(fromObj, toObj, comparison, condition) { if(fromObj.options[fromObj.selectedIndex].selected) { if((condition=='' || condition==null) && document.adminForm.condition.getAttribute('Req')==1) { alert('<?php echo addslashes( CBTxt::T('You must define a condition text!') ); ?>'); return; } fromObjIndex=fromObj.selectedIndex; fromObj.options[fromObjIndex].selected = false; optionText = fromObj.options[fromObjIndex].text+ ' '+comparison+' '+condition; condition=condition.replace("'", "\\'"); if(condition!='' && condition!=null) condition="'"+escape(condition)+"'"; optionValue = fromObj.options[fromObjIndex].value+' '+comparison+condition; toObjIndex = toObj.options.length; toObj.options.length = toObj.options.length + 1; toObj.options[toObjIndex].text = optionText; toObj.options[toObjIndex].value = optionValue; toObj.options[toObjIndex].selected=false; if(NS4) history.go(0); } } function moveOption4(fromObj, toObj) { for(var i = fromObj.options.length - 1; i >= 0; i--) { if(fromObj.options[i].selected) { fromObj.options[i].selected = false; for(var j = i; j < fromObj.options.length - 1; j++) { fromObj.options[j].text = fromObj.options[j + 1].text; fromObj.options[j].value = fromObj.options[j + 1].value; } fromObj.options.length = fromObj.options.length - 1; if(NS4) history.go(0); } } } function getSortList(selectObj) { var sortfields=''; var j=0; selectAll(selectObj); if(selectObj.selectedIndex != -1) { for(i = 0; i < selectObj.options.length; i++) { if(j>0) sortfields += ', '; sortfields += selectObj.options[i].value; j++; } //alert(sortfields); document.adminForm.sortfields.value=sortfields; } } function getFilterList(selectObj) { var filterfields=''; var j=0; var advType=getObject('ft2'); var simType=getObject('ft1'); //alert(simType.checked); if(simType.checked) { selectAll(selectObj); if(selectObj.selectedIndex != -1) { for(i = 0; i < selectObj.options.length; i++) { if(j>0) filterfields += ' AND '; filterfields += selectObj.options[i].value; j++; } } if(filterfields!="") { document.adminForm.filterfields.value="s("+filterfields+")"; } else { document.adminForm.filterfields.value=""; } } else { if(document.adminForm.advFilterText.value!="") { document.adminForm.filterfields.value="a("+escape(document.adminForm.advFilterText.value)+")"; } else { document.adminForm.filterfields.value=""; } } } function selectAll(selectObj) { if(selectObj.options.length) for(i = 0; i < selectObj.options.length; i++) selectObj.options[i].selected = true; return false; } function loadUGIDs(selectObj) { var UGIDs=''; var j=0; if(selectObj.selectedIndex != -1) { for(i = 0; i < selectObj.options.length; i++) { if(selectObj.options[i].selected) { if(j>0) UGIDs += ', '; UGIDs += selectObj.options[i].value; j++; } } document.adminForm.usergroupids.value=UGIDs; } } function enableListColumn(colnum) { var oForm; var colName; oForm=document.adminForm; colName="col"+colnum+"enabled"; if(oForm.elements[colName].checked) { //alert("Enabled"); oForm.col1title.readOnly=false; oForm.col1captions.disabled=false; //document.col1.disabled=false; oForm.col1up.disabled=false; oForm.col1down.disabled=false; oForm.col1remove.disabled=false; oForm.addcol1.disabled=false; } else { //alert("Disabled"); oForm.col1title.readOnly=true; oForm.col1captions.disabled=true; //document.col1.disabled=true; oForm.col1up.disabled=true; oForm.col1down.disabled=true; oForm.col1remove.disabled=true; oForm.addcol1.disabled=true; } } function filterCondition(needCond) { if(needCond==0) { document.adminForm.condition.value=""; document.adminForm.condition.readOnly=true; document.adminForm.condition.setAttribute("Req",0); } else { document.adminForm.condition.value=""; document.adminForm.condition.readOnly=false; document.adminForm.condition.setAttribute("Req",1); } } <?php $jsListsJs = ob_get_contents(); ob_end_clean(); $_CB_framework->document->addHeadScriptDeclaration( $jsListsJs ); ?> <form action="<?php echo $_CB_framework->backendUrl( 'index.php?option=com_comprofiler&task=saveList' ); ?>" method="POST" name="adminForm"> <table cellpadding="4" cellspacing="1" border="0" width="100%" class="adminform"> <tr> <td width="20%"><?php echo htmlspecialchars( CBTxt::T('URL for menu link to this list') ); ?>:</td> <td align=left width="40%"><?php if ( $row->listid ) { $url = 'index.php?option=com_comprofiler&task=usersList&listid=' . (int) $row->listid; echo '<a href="' . $_CB_framework->getCfg('live_site') . '/' . $url . '" target="_blank">' . $url . '</a>'; } else { echo htmlspecialchars( CBTxt::T('You need to save this new list first to see the direct menu link url.') ); } ?></td> <td width="40%"> </td> </tr> <tr> <td width="20%"><?php echo htmlspecialchars( CBTxt::T('URL for search link to this list') ); ?>:</td> <td align=left width="40%"><?php if ( $row->listid ) { $url = 'index.php?option=com_comprofiler&task=usersList&listid=' . (int) $row->listid . '&searchmode=1'; echo '<a href="' . $_CB_framework->getCfg('live_site') . '/' . $url . '" target="_blank">' . $url . '</a>'; } else { echo htmlspecialchars( CBTxt::T('You need to save this new list first to see the direct menu link url.') ); } ?></td> <td width="40%"><?php echo htmlspecialchars( CBTxt::T('Only fields appearing in list columns and on profiles and which are have the searchable attribute ON will appear in search criterias of the list.') ); ?></td> </tr> <tr> <td><?php echo htmlspecialchars( CBTxt::T('Title') ); ?>:</td> <td align=left><input type="text" name="title" mosReq="1" mosLabel="<?php echo htmlspecialchars( CBTxt::T('Title') ); ?>" class="inputbox" value="<?php echo htmlspecialchars($row->title); ?>" /></td> <td><?php echo htmlspecialchars( CBTxt::T('Title appears in frontend on top of the list.') ); ?></td> </tr> <tr> <td><?php echo htmlspecialchars( CBTxt::T('Description') ); ?>:</td> <td align=left><?php echo $_CB_framework->displayCmsEditor( 'description', $row->description, 600, 200, 50, 7 ); // <textarea name="description" cols="50" rows="7">< ?php echo htmlspecialchars($row->description); ? ></textarea> ?></td> <td><?php echo htmlspecialchars( CBTxt::T('Description appears in frontend under the title of the list.') ); ?></td> </tr> <tr> <td><?php echo htmlspecialchars( CBTxt::T('User Group to allow access to') ); ?>:</td> <td><?php echo $lists['useraccessgroup']; ?></td> <td><?php echo htmlspecialchars( CBTxt::T('All groups above that level will also have access to the list.') ); ?></td> </tr> <tr> <td><?php echo htmlspecialchars( CBTxt::T('User Groups to Include in List') ); ?>:</td> <td><?php echo $lists['usergroups']; ?></td> <td><strong><font color="red"><?php echo htmlspecialchars( CBTxt::T('Multiple choices') ); ?>:</font> <?php echo htmlspecialchars( CBTxt::T('CTRL/CMD-click to add/remove single choices.') ); ?></strong></td> </tr> <tr> <td><?php echo htmlspecialchars( CBTxt::T('Published') ); ?>:</td> <td><?php echo $lists['published']; ?></td> <td> </td> </tr> <tr> <td><?php echo htmlspecialchars( CBTxt::T('Default') ); ?>:</td> <td><?php echo $lists['default']; ?></td> <td><strong><font color="red"><?php echo htmlspecialchars( CBTxt::T('WARNING') ); ?>:</font></strong> <?php echo htmlspecialchars( CBTxt::T('The default list should be the one with the lowest user groups access rights !') ); ?></td> </tr> <tr> <td><?php echo htmlspecialchars( CBTxt::T('Sort By') ); ?>:</td> <td> <select name="sortfieldlist"> <?php for ($i=0, $n=count( $sortfields ); $i < $n; $i++) { $sortfield =& $sortfields[$i]; if ( substr( $sortfield->name, -1, 1 ) != ')' ) { $sortfieldName = '`' . $sortfield->name . '`'; } else { $sortfieldName = $sortfield->name; } echo "<option value=\"" . $sortfieldName . "\">". htmlspecialchars( getLangDefinition($sortfield->title) ) ."</option>\n"; } ?> </select><select name=direction><option value="ASC"><?php echo htmlspecialchars( CBTxt::T('ASC') ); ?></option><option value="DESC"><?php echo htmlspecialchars( CBTxt::T('DESC') ); ?></option></select><input type=button onclick="moveOption2(this.form.sortfieldlist, sort, this.form.direction.value);" value=" <?php echo htmlspecialchars( CBTxt::T('Add') ); ?> "><br /> <select id=sort name=sort size="5" multiple mosReq="1" mosLabel="<?php echo htmlspecialchars( CBTxt::T('Sort By') ); ?>"> <?php for ($i=0, $n=count( $sortparts ); $i < $n; $i++) { $sortpart = $sortparts[$i]; if( $sortpart['field'] != '' ) { if ( substr( $sortpart['field'], -1, 1 ) != ')' ) { $sortfiNam = '`' . $sortpart['field'] . '`'; } else { $sortfiNam = $sortpart['field']; } echo '<option value="' . $sortfiNam . ' ' . $sortpart['dir'] . '">' . htmlspecialchars( getLangDefinition($sortpart['title']) ) . ' [' . $sortpart['dir'] . "]</option>\n"; } } ?> </select><br /> <input type=button onclick="moveOptions(sort, -1);" value=" <?php echo htmlspecialchars( CBTxt::T('+') ); ?> " /> <input type=button onclick="moveOptions(sort, 1);" value=" <?php echo htmlspecialchars( CBTxt::T('-') ); ?> " /> <br /> <input type=button onclick="moveOption(this.form.sort,this.form.sortfieldlist);" value=" <?php echo htmlspecialchars( CBTxt::T('Remove') ); ?> "> </td> <td> </td> </tr> <tr> <td><?php echo htmlspecialchars( CBTxt::T('Filter') ); ?>:</td> <td colspan="2"> <?php $simChecked=""; $advChecked=""; $simStyle="display:none;"; $advStyle="display:none;"; //echo $row->filterfields; $filttype=substr($row->filterfields,0,1); $row->filterfields=substr($row->filterfields,2,-1); //substr($row->filterfields,1,-1) // echo "row->filterfields=".$row->filterfields; if($filttype=="a") { $advChecked="CHECKED"; $advStyle="display:block;"; } else { $simChecked="checked=\"checked\""; $simStyle="display:block;"; } $filterlists=explode(" AND ",$row->filterfields); $filterparts=array(); $i=0; foreach($filterlists as $filterlist) { $filterlistpart=array(); $filterlistpart=explode(" ",$filterlist); $filterparts[$i]['field']=str_replace("`","",$filterlistpart[0]); $_CB_database->setQuery("SELECT title FROM #__comprofiler_fields WHERE name='".$filterparts[$i]['field']."'", 0, 1); $filtertitle=$_CB_database->loadResult(); $filterparts[$i]['value']=$filterlist; $filterparts[$i]['title']=str_replace(array("'","`"),"",str_replace($filterparts[$i]['field'],getLangDefinition($filtertitle),$filterlist)); $i++; } ?> <label for=ft1 ><input type="radio" <?php echo $simChecked; ?> id="ft1" onclick="javascript:shDiv('simFilter',1);shDiv('advFilter',0);" name=filtertype value="0" checked="checked" /><?php echo htmlspecialchars( CBTxt::T('Simple') ); ?> </label><label for=ft2 ><input type="radio" <?php echo $advChecked; ?> onclick="javascript:shDiv('simFilter',0);shDiv('advFilter',1);" id="ft2" name="filtertype" value="1" /><?php echo htmlspecialchars( CBTxt::T('Advanced') ); ?> </label> <br /> <div id="simFilter" name="simFilter" style="<?php echo $simStyle; ?>" > <select name="filterfieldlist"> <?php foreach ($filterfields AS $filterfield) { echo "<option value=\"`".$filterfield->name."`\">". htmlspecialchars( getLangDefinition($filterfield->title) ) ."\n"; } ?> </select> <select name=comparison onchange="javascript:filterCondition(this.options[this.selectedIndex].getAttribute('needCond'));"> <option value=">" needCond="1"><?php echo htmlspecialchars( CBTxt::T('Greater Than') ); ?></option> <option value=">=" needCond="1"><?php echo htmlspecialchars( CBTxt::T('Greater Than or Equal To') ); ?></option> <option value="<" needCond="1"><?php echo htmlspecialchars( CBTxt::T('Less Than') ); ?></option> <option value="<=" needCond="1"><?php echo htmlspecialchars( CBTxt::T('Less Than or Equal To') ); ?></option> <option value="=" needCond="1"><?php echo htmlspecialchars( CBTxt::T('Equal To') ); ?></option> <option value="!=" needCond="1"><?php echo htmlspecialchars( CBTxt::T('Not Equal To') ); ?></option> <option value="= ''" needCond="0"><?php echo htmlspecialchars( CBTxt::T('Is Empty') ); ?></option> <option value="!= ''" needCond="0"><?php echo htmlspecialchars( CBTxt::T('Is Not Empty') ); ?></option> <option value="IS NULL" needCond="0"><?php echo htmlspecialchars( CBTxt::T('Is NULL') ); ?></option> <option value="IS NOT NULL" needCond="0"><?php echo htmlspecialchars( CBTxt::T('Is Not NULL') ); ?></option> <option value="LIKE" needCond="1"><?php echo htmlspecialchars( CBTxt::T('Like') ); ?></option> </select> <input type=text name=condition value="" Req=1 /> <input type=button onclick="moveOption3(this.form.filterfieldlist, filter, this.form.comparison.value, this.form.condition.value);" value=" <?php echo htmlspecialchars( CBTxt::T('Add') ); ?> "> <br /> <select id=filter name=filter size="5" multiple mosReq=0 mosLabel="<?php echo htmlspecialchars( CBTxt::T('Filter By') ); ?>"> <?php foreach ($filterparts AS $filterpart) { if($filterpart['value']!='') { echo "<option value=\"".$filterpart['value']."\">".stripslashes(utf8RawUrlDecode($filterpart['title']))."\n"; //BB todo sortout htmlspecialchars...not compatible with utf8rawdecode } } ?> </select><br /> <input type=button onclick="moveOptions(filter, -1);" value=" <?php echo htmlspecialchars( CBTxt::T('+') ); ?> " /> <input type=button onclick="moveOptions(filter, 1);" value=" <?php echo htmlspecialchars( CBTxt::T('-') ); ?> " /> <br /> <input type=button onclick="moveOption4(this.form.filter,this.form.filterfieldlist);" value=" <?php echo htmlspecialchars( CBTxt::T('Remove') ); ?> "> </div> <div id="advFilter" name="advFilter" style="<?php echo $advStyle; ?>"> <textarea name="advFilterText" cols="50" rows="7"><?php echo stripslashes(utf8RawUrlDecode($row->filterfields)); //BB todo sortout htmlspecialchars...not compatible with utf8rawdecode ?></textarea> </div> </td> </tr> </table> <table cellpadding="4" cellspacing="1" border="0" width="100%" class="adminform"> <tr> <td width="100%" colspan="3" style="text-align:center;"> <?php echo CBTxt::T('<strong>Note:</strong> fields must be on profile to appear in this list and be visible on the users-list.'); ?> </td> </tr> <tr> <td width="33%"> <?php echo htmlspecialchars( CBTxt::T('Enable Column 1') ); ?>: <input type=checkbox <?php /* onclick="javascript:enableListColumn(1);" */ ?> name="col1enabled" <?php if($row->col1enabled == 1) echo ' checked="checked" '; ?> value=1 ><br /> <?php echo htmlspecialchars( CBTxt::T('Column 1 Title') ); ?>:<br /> <input type="text" name="col1title" mosReq=0 mosLabel="<?php echo htmlspecialchars( CBTxt::T('Column 1 Title') ); ?>" class="inputbox" value="<?php echo htmlspecialchars($row->col1title); ?>" /><br /> <?php echo htmlspecialchars( CBTxt::T('Column 1 Captions') ); ?>:<input type=checkbox name=col1captions <?php if($row->col1captions == 1) echo " CHECKED "; ?> value=1 ><br /> <select id=col1 size="5" multiple name=col1[] > <?php echo $col1options; ?> </select><br /> <input name=col1up type=button onclick="moveOptions(col1, -1);" value=" <?php echo htmlspecialchars( CBTxt::T('+') ); ?> " /> <input name=col1down type=button onclick="moveOptions(col1, 1);" value=" <?php echo htmlspecialchars( CBTxt::T('-') ); ?> " /> <br /> <input name=col1remove type=button onclick="moveOption(col1,this.form.fieldlist);" value=" <?php echo htmlspecialchars( CBTxt::T('Remove') ); ?> "> </td> <td width="33%" rowspan=3 valign=center align=center><?php echo htmlspecialchars( CBTxt::T('Field List') ); ?>:<br /> <input name=addcol1 type=button onclick="moveOption(this.form.fieldlist, col1);" value=" <?php echo htmlspecialchars( CBTxt::T('<- Add') ); ?> "> <input type=button onclick="moveOption(this.form.fieldlist, col2);" value=" <?php echo htmlspecialchars( CBTxt::T('Add ->') ); ?> "><br /> <select name="fieldlist" size="10" multiple> <?php foreach ( $fields as $field ) { echo "<option value=\"".$field->fieldid."\">".htmlspecialchars( getLangDefinition($field->title) )."\n"; } ?> </select><br /> <input type=button onclick="moveOption(this.form.fieldlist, col3);" value=" <?php echo htmlspecialchars( CBTxt::T('<- Add') ); ?> "> <input type=button onclick="moveOption(this.form.fieldlist, col4);" value=" <?php echo htmlspecialchars( CBTxt::T('Add ->') ); ?> "> </td> <td width="33%"> <?php echo htmlspecialchars( CBTxt::T('Enable Column 2') ); ?>: <input type=checkbox name=col2enabled <?php if($row->col2enabled == 1) echo " CHECKED "; ?> value=1 ><br /> <?php echo htmlspecialchars( CBTxt::T('Column 2 Title') ); ?>:<br /> <input type="text" name="col2title" mosReq=0 mosLabel="<?php echo htmlspecialchars( CBTxt::T('Column 2 Title') ); ?>" class="inputbox" value="<?php echo htmlspecialchars($row->col2title); ?>" /><br /> <?php echo htmlspecialchars( CBTxt::T('Column 2 Captions') ); ?>:<input type=checkbox name=col2captions <?php if($row->col2captions == 1) echo " CHECKED "; ?> value=1 ><br /> <select id=col2 size="5" multiple name=col2[] > <?php echo $col2options; ?> </select><br /> <input type=button onclick="moveOptions(col2, -1);" value=" <?php echo htmlspecialchars( CBTxt::T('+') ); ?> " /> <input type=button onclick="moveOptions(col2, 1);" value=" <?php echo htmlspecialchars( CBTxt::T('-') ); ?> " /> <br /> <input type=button onclick="moveOption(col2,this.form.fieldlist);" value=" <?php echo htmlspecialchars( CBTxt::T('Remove') ); ?> "> </td> </tr> <tr> </tr> <tr> <td width="33%"> <?php echo htmlspecialchars( CBTxt::T('Enable Column 3') ); ?>: <input type=checkbox name=col3enabled <?php if($row->col3enabled == 1) echo " CHECKED "; ?> value=1 /><br /> <?php echo htmlspecialchars( CBTxt::T('Column 3 Title') ); ?>:<br /> <input type="text" name="col3title" mosReq=0 mosLabel="<?php echo htmlspecialchars( CBTxt::T('Column 3 Title') ); ?>" class="inputbox" value="<?php echo htmlspecialchars($row->col3title); ?>" /><br /> <?php echo htmlspecialchars( CBTxt::T('Column 3 Captions') ); ?>:<input type=checkbox name=col3captions <?php if($row->col3captions == 1) echo " CHECKED "; ?> value=1 ><br /> <select id=col3 size="5" multiple name=col3[]> <?php echo $col3options; ?> </select><br /> <input type=button onclick="moveOptions(col3, -1);" value=" <?php echo htmlspecialchars( CBTxt::T('+') ); ?> " /> <input type=button onclick="moveOptions(col3, 1);" value=" <?php echo htmlspecialchars( CBTxt::T('-') ); ?> " /> <br /> <input type=button onclick="moveOption(col3,this.form.fieldlist);" value=" <?php echo htmlspecialchars( CBTxt::T('Remove') ); ?> "> </td> <td width="33%"> <?php echo htmlspecialchars( CBTxt::T('Enable Column 4') ); ?>: <input type=checkbox name=col4enabled <?php if($row->col4enabled == 1) echo " CHECKED "; ?> value=1 ><br /> <?php echo htmlspecialchars( CBTxt::T('Column 4 Title') ); ?>:<br /> <input type="text" name="col4title" mosReq=0 mosLabel="<?php echo htmlspecialchars( CBTxt::T('Column 4 Title') ); ?>" class="inputbox" value="<?php echo htmlspecialchars($row->col4title); ?>" /><br /> <?php echo htmlspecialchars( CBTxt::T('Column 4 Captions') ); ?>:<input type=checkbox name=col4captions <?php if($row->col4captions == 1) echo " CHECKED "; ?> value=1 ><br /> <select id=col4 size="5" multiple name=col4[]> <?php echo $col4options; ?> </select><br /> <input type=button onclick="moveOptions(col4, -1);" value=" <?php echo htmlspecialchars( CBTxt::T('+') ); ?> " /> <input type=button onclick="moveOptions(col4, 1);" value=" <?php echo htmlspecialchars( CBTxt::T('-') ); ?> " /> <br /> <input type=button onclick="moveOption(col4,this.form.fieldlist);" value=" <?php echo htmlspecialchars( CBTxt::T('Remove') ); ?> "> </td> </tr> </table> <?php // params: if ( $paramsEditorHtml ) { foreach ( $paramsEditorHtml as $paramsEditorHtmlBlock ) { ?> <table class="adminform" cellspacing="0" cellpadding="0" width="100%"> <tr> <th colspan="2"> <?php echo $paramsEditorHtmlBlock['title']; ?> </th> </tr> <tr> <td> <?php echo $paramsEditorHtmlBlock['content']; ?> </td> </tr> </table> <?php } } ?> <table cellpadding="4" cellspacing="1" border="0" width="100%" class="adminform"> <tr> <td colspan="3"> </td> </tr> </table> <input type="hidden" name="sortfields" value="<?php echo $row->sortfields; ?>" /> <input type="hidden" name="filterfields" value="<?php echo $row->filterfields; ?>" /> <input type="hidden" name="usergroupids" value="<?php echo $row->usergroupids; ?>" /> <input type="hidden" name="listid" value="<?php echo $row->listid; ?>" /> <input type="hidden" name="ordering" value="<?php echo $row->ordering; ?>" /> <input type="hidden" name="option" value="com_comprofiler" /> <input type="hidden" name="task" value="" /> <?php echo cbGetSpoofInputTag( 'list' ); ?> </form> <?php }
case 7: // 6 Months $cutOffTimestamp = $_CB_framework->getUTCTimestamp( '-6 MONTH', $now ); break; case 8: // 1 Year (365 Days) $cutOffTimestamp = $_CB_framework->getUTCTimestamp( '-1 YEAR', $now ); break; default: // No Limit $cutOffTimestamp = false; break; } if ( $cutOffTimestamp ) { array_unshift( $where, 'date', '>=', $_CB_framework->getUTCDate( 'Y-m-d H:i:s', $cutOffTimestamp ) ); } if ( $exclude ) { $exclude = explode( ',', $exclude ); cbArrayToInts( $exclude ); if ( $exclude ) { array_unshift( $where, 'user_id', '!IN', $exclude ); } } $rows = cbactivityData::getActivity( $where, null, $limit ); if ( $rows ) { echo HTML_cbactivityModule::showActivityModule( $rows, $avatar, $titleLimit, $descLimit, $imgThumbnails, $user, $plugin ); } ?>
/** * Gets articles * * @param int[] $paging * @param string $where * @param UserTable $viewer * @param UserTable $user * @param PluginTable $plugin * @return Table[] */ static public function getDocman( $paging, $where, /** @noinspection PhpUnusedParameterInspection */ $viewer, $user, $plugin ) { global $_CB_database; $categories = $plugin->params->get( 'article_j_category', null ); $query = 'SELECT a.*' . ', b.' . $_CB_database->NameQuote( 'docman_category_id' ) . ' AS category' . ', b.' . $_CB_database->NameQuote( 'title' ) . ' AS category_title' . ', b.' . $_CB_database->NameQuote( 'enabled' ) . ' AS category_published' . ', b.' . $_CB_database->NameQuote( 'slug' ) . ' AS category_slug' . "\n FROM " . $_CB_database->NameQuote( '#__docman_documents' ) . " AS a" . "\n LEFT JOIN " . $_CB_database->NameQuote( '#__docman_categories' ) . " AS b" . ' ON b.' . $_CB_database->NameQuote( 'docman_category_id' ) . ' = a.' . $_CB_database->NameQuote( 'docman_category_id' ) . "\n WHERE a." . $_CB_database->NameQuote( 'created_by' ) . " = " . (int) $user->get( 'id' ) . "\n AND a." . $_CB_database->NameQuote( 'enabled' ) . " = 1" . "\n AND (a." . $_CB_database->NameQuote( 'access' ) . " IN " . $_CB_database->safeArrayOfIntegers( Application::MyUser()->getAuthorisedViewLevels() ) . "\n OR a." . $_CB_database->NameQuote( 'access' ) . " = -1 )" . "\n AND b." . $_CB_database->NameQuote( 'enabled' ) . " = 1" . "\n AND b." . $_CB_database->NameQuote( 'access' ) . " IN " . $_CB_database->safeArrayOfIntegers( Application::MyUser()->getAuthorisedViewLevels() ); if ( $categories ) { $categories = explode( '|*|', $categories ); cbArrayToInts( $categories ); $query .= "\n AND a." . $_CB_database->NameQuote( 'catid' ) . " NOT IN ( " . implode( ',', $categories ) . " )"; } $query .= $where . "\n ORDER BY a." . $_CB_database->NameQuote( 'created_on' ) . " DESC"; if ( $paging ) { $_CB_database->setQuery( $query, $paging[0], $paging[1] ); } else { $_CB_database->setQuery( $query ); } return $_CB_database->loadObjectList( null, '\CBLib\Database\Table\Table', array( null, '#__docman_documents', 'id' ) ); }
/** * Loads all the bot files for a particular group (if group not already loaded) * * @param string $group The group name, relates to the sub-directory in the plugins directory * @param mixed $ids array of int : ids of plugins to load. OR: string : name of element (OR new in CB 1.2.2: string if ends with a ".": elements starting with "string.") * @param int $publishedStatus if 1 (DEFAULT): load only published plugins, if 0: load all plugins including unpublished ones * @return boolean TRUE: load done, FALSE: no plugin loaded */ public function loadPluginGroup($group, $ids = null, $publishedStatus = 1) { global $_CB_framework, $_CB_database; static $dbCache = null; $this->_iserror = false; $group = trim($group); if ($group && !isset($this->_pluginGroups[$group]) || !$this->all_in_array_key($ids, $this->_plugins)) { $cmsAccess = Application::MyUser()->getAuthorisedViewLevels(); $cmsAccessCleaned = implode(',', cbArrayToInts($cmsAccess)); if (!isset($dbCache[$publishedStatus][$cmsAccessCleaned][$group])) { $where = array(); if ($publishedStatus == 1) { $where[0] = $_CB_database->NameQuote('published') . ' = 1'; } else { $where[0] = $_CB_database->NameQuote('published') . ' >= ' . (int) $publishedStatus; } $where[1] = $_CB_database->NameQuote('viewaccesslevel') . ' IN (' . $cmsAccessCleaned . ')'; if ($group) { $where[2] = $_CB_database->NameQuote('type') . ' = ' . $_CB_database->Quote(trim($group)); } $queryFunction = function ($where) use($_CB_database) { return 'SELECT *' . ', CONCAT_WS( "/", ' . $_CB_database->NameQuote('folder') . ', ' . $_CB_database->NameQuote('element') . ' ) AS lookup' . "\n FROM " . $_CB_database->NameQuote('#__comprofiler_plugin') . "\n WHERE " . implode("\n AND ", $where) . "\n ORDER BY " . $_CB_database->NameQuote('ordering'); }; $query = $queryFunction($where); $_CB_database->setQuery($query); try { $plugins = $_CB_database->loadObjectList('id', '\\CB\\Database\\Table\\PluginTable', array(&$_CB_database)); } catch (\RuntimeException $e) { try { $cmsAccessOld = array(); foreach ($cmsAccess as $level) { $cmsAccessOld[] = $level > 3 ? $level : $level - 1; } $where[1] = $_CB_database->NameQuote('access') . ' IN ' . $_CB_database->safeArrayOfIntegers($cmsAccessOld); $query = $queryFunction($where); $_CB_database->setQuery($query); $plugins = $_CB_database->loadObjectList('id', '\\CB\\Database\\Table\\PluginTable', array(&$_CB_database)); $_CB_framework->enqueueMessage(CBTxt::T('CB_PLUGINS_DATABASE_NOT_UPGRADED', 'CB Plugins database not upgraded.') . ' ' . CBTxt::T('CB_DATABASE_PLEASE_CHECK_WITH_INSTRUCTIONS', 'Please check and fix CB database in administration area in Components / Community Builder / Tools / Check Community Builder Database.') . (Application::MyUser()->isSuperAdmin() ? '<br />SQL Error (visible to super-admins only): ' . $e->getMessage() : ''), $_CB_framework->getUi() == 2 ? 'warning' : 'notice'); } catch (\RuntimeException $e) { $_CB_framework->enqueueMessage(CBTxt::T('CB_PLUGINS_DATABASE_ERROR', 'CB Plugins database error.') . ' ' . CBTxt::T('CB_DATABASE_PLEASE_CHECK_WITH_INSTRUCTIONS', 'Please check and fix CB database in administration area in Components / Community Builder / Tools / Check Community Builder Database.') . (Application::MyUser()->isSuperAdmin() ? '<br />SQL Error (visible to super-admins only): ' . $e->getMessage() : ''), 'error'); $dbCache[$publishedStatus][$cmsAccessCleaned][$group] = array(); return false; } } if ($_CB_database->getErrorNum()) { $dbCache[$publishedStatus][$cmsAccessCleaned][$group] = null; return false; } else { $dbCache[$publishedStatus][$cmsAccessCleaned][$group] = $plugins; } } if (count($ids) == 0) { $ids = null; } $plugins = $dbCache[$publishedStatus][$cmsAccessCleaned][$group]; if ($plugins) { foreach ($plugins as $plugin) { if ($ids === null || (is_array($ids) ? in_array($plugin->id, $ids) : (substr($ids, strlen($ids) - 1, 1) == '.' ? substr($plugin->element, 0, strlen($ids)) == $ids : $plugin->element == $ids))) { if (!isset($this->_plugins[$plugin->id]) && $this->_checkPluginFile($plugin)) { $this->_plugins[$plugin->id] = $plugin; if (!isset($this->_pluginGroups[$plugin->type][$plugin->id])) { $this->_pluginGroups[$plugin->type][$plugin->id] =& $this->_plugins[$plugin->id]; } $this->_loadPluginFile($plugin); } } } } else { return false; } } return true; }
/** * Get viewable categories * * @param moscomprofilerUser $user * @param object $forum * @return array */ function getAllowedCategories($user_id, $forum) { global $_CB_framework, $_CB_database; if ($user_id === null) { $user_id = $_CB_framework->myId(); } static $cache = array(); if (!isset($cache[$user_id])) { if ($forum->prefix != 'kunena' || $forum->prefix == 'kunena' && !class_exists('KunenaForum')) { $query = 'SELECT ' . $_CB_database->NameQuote('allowed') . "\n FROM " . $_CB_database->NameQuote('#__' . $forum->prefix . '_sessions') . "\n WHERE " . $_CB_database->NameQuote('userid') . ' = ' . (int) $user_id; $_CB_database->setQuery($query, 0, 1); $categories = $_CB_database->loadResult(); if ($categories && $categories != 'na') { $allowed = explode(',', $categories); cbArrayToInts($allowed); } else { $allowed = null; } } elseif (class_exists('KunenaAccess')) { $allowed = KunenaAccess::getInstance()->getAllowedCategories((int) $user_id); } else { $allowed = null; } $cache[$user_id] = $allowed; } return $cache[$user_id]; }