/** * Looks for all external calendars on a certain pid-list * * @param string $pidList * to search in * @return array array of array (array of $rows) */ function findAll($pidList) { $enableFields = ''; $orderBy = \TYPO3\CMS\Cal\Utility\Functions::getOrderBy('tx_cal_calendar'); if (TYPO3_MODE == 'BE') { $enableFields = BackendUtility::BEenableFields('tx_cal_calendar') . ' AND tx_cal_calendar.deleted = 0'; } else { $enableFields = $this->cObj->enableFields('tx_cal_calendar'); } $return = array(); if ($pidList == '') { $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tx_cal_calendar', ' type IN (1,2) ' . $enableFields, '', $orderBy); } else { $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tx_cal_calendar', ' type IN (1,2) AND pid IN (' . $pidList . ') ' . $enableFields, '', $orderBy); } if ($result) { while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { $return[] = $row; } $GLOBALS['TYPO3_DB']->sql_free_result($result); } return $return; }
function getIdsFromTable($list, $pidList, $includePublic, $includeData = false, $onlyPublic = false) { $this->calendarIds = array(); $collectedIds = array(); // Logged in? Show public & private calendar // calendar ids specified? show these calendar only - if allowed - else show public calendar $limitationList = ''; if ($list != '') { // $this->conf['calendar'] $limitationList = $list; } // Lets see if the user is logged in if ($this->rightsObj->isLoggedIn() && !$onlyPublic) { $userId = $this->rightsObj->getUserId(); $groupIds = implode(',', $this->rightsObj->getUserGroups()); } $ids = array(); if ($userId === '') { // && !$includePublic return $ids; } if ($includeData) { $select = 'tx_cal_calendar.*'; } else { $select = 'tx_cal_calendar.uid'; } $orderBy = \TYPO3\CMS\Cal\Utility\Functions::getOrderBy('tx_cal_calendar'); $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tx_cal_calendar_user_group_mm.uid_local', 'tx_cal_calendar_user_group_mm LEFT JOIN tx_cal_calendar ON tx_cal_calendar.uid=tx_cal_calendar_user_group_mm.uid_local', '1=1 ' . $this->cObj->enableFields('tx_cal_calendar'), '', $orderBy); if ($result) { while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { $ids[] = $row['uid_local']; } $GLOBALS['TYPO3_DB']->sql_free_result($result); } $ids = array_unique($ids); if ($includePublic) { if (!empty($ids)) { $where = 'uid NOT IN (' . implode(',', $ids) . ') ' . $this->cObj->enableFields('tx_cal_calendar'); } else { $where = '0=0 ' . $this->cObj->enableFields('tx_cal_calendar'); } if ($pidList != '') { $where .= ' AND pid IN (' . $pidList . ')'; } if ($includeData) { $select = '*'; } else { $select = 'uid'; } $table = 'tx_cal_calendar'; $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select, $table, $where, '', $orderBy); if ($result) { while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { if (!in_array($row['uid'], $collectedIds)) { if ($includeData) { $this->calendarIds[] = $row; } else { $this->calendarIds[] = $row['uid']; } $collectedIds[] = $row['uid']; } } $GLOBALS['TYPO3_DB']->sql_free_result($result); } } if (!$onlyPublic) { if (!empty($ids)) { $where = 'uid NOT IN (' . implode(',', $ids) . ')'; } else { $where = ''; } $table = 'tx_cal_calendar'; if ($includeData) { $select = '*'; } else { $select = 'uid'; } if ($userId) { $where = '((tx_cal_calendar_user_group_mm.uid_foreign IN (' . $userId . ') AND tx_cal_calendar_user_group_mm.tablenames="fe_users" AND tx_cal_calendar_user_group_mm.uid_local=tx_cal_calendar.uid)'; $where .= 'OR (tx_cal_calendar_user_group_mm.uid_foreign IN (' . $groupIds . ') AND tx_cal_calendar_user_group_mm.tablenames="fe_groups"))'; $table .= ' LEFT JOIN tx_cal_calendar_user_group_mm ON tx_cal_calendar_user_group_mm.uid_local=tx_cal_calendar.uid'; } if ($pidList != '') { $where .= strlen($where) ? ' AND pid IN (' . $pidList . ')' : ' pid IN (' . $pidList . ')'; } if ($where == '') { $where .= ' 0=0 ' . $this->cObj->enableFields('tx_cal_calendar'); } else { $where .= $this->cObj->enableFields('tx_cal_calendar'); } if ($limitationList != '') { $where .= ' AND uid IN (' . $limitationList . ')'; } $groupBy = 'tx_cal_calendar.uid'; $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select, $table, $where, $groupBy, $orderBy); if ($result) { while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { if (!in_array($row['uid'], $collectedIds)) { if ($includeData) { $this->calendarIds[] = $row; } else { $this->calendarIds[] = $row['uid']; } $collectedIds[] = $row['uid']; } } $GLOBALS['TYPO3_DB']->sql_free_result($result); } } if ($limitationList != '' && !empty($this->calendarIds)) { $limitationArray = explode(',', $limitationList); $this->calendarIds = array_intersect($this->calendarIds, $limitationArray); } return $this->calendarIds; }
/** * Generates the sql query and builds organizer objects out of the result rows * * @param string $pidList * to search in * @param string $additionalWhere * where clause * @return array containing the organizer objects */ function getOrganizerFromTable($pidList = '', $additionalWhere = '') { $organizers = array(); $orderBy = \TYPO3\CMS\Cal\Utility\Functions::getOrderBy($this->tableId); if ($pidList != '') { $additionalWhere .= ' AND ' . $this->tableId . '.pid IN (' . $pidList . ')'; } $additionalWhere .= $this->getAdditionalWhereForLocalizationAndVersioning($this->tableId); $select = '*'; $table = $this->tableId; $where = 'tx_cal_controller_isorganizer = 1 AND l18n_parent = 0 ' . $additionalWhere . $this->cObj->enableFields($this->tableId); $groupBy = ''; $orderBy = \TYPO3\CMS\Cal\Utility\Functions::getOrderBy($this->tableId); $limit = ''; $hookObjectsArr = \TYPO3\CMS\Cal\Utility\Functions::getHookObjectsArray('tx_cal_organizer_address_service', 'organizerServiceClass', 'service'); foreach ($hookObjectsArr as $hookObj) { if (method_exists($hookObj, 'preGetOrganizerFromTableExec')) { $hookObj->preGetLocationFromTableExec($this, $select, $table, $where, $groupBy, $orderBy, $limit); } } $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select, $table, $where, $groupBy, $orderBy, $limit); if ($result) { while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { $organizers[] = new \TYPO3\CMS\Cal\Model\OrganizerAddress($row, $pidList); } $GLOBALS['TYPO3_DB']->sql_free_result($result); } return $organizers; }
/** * Generates the sql query and builds location objects out of the result rows * * @param string $pidList * to search in * @param string $additionalWhere * where clause * @return array containing the location objects */ function getLocationFromTable($pidList = '', $additionalWhere = '') { $locations = array(); $orderBy = \TYPO3\CMS\Cal\Utility\Functions::getOrderBy('tx_cal_location'); if ($pidList != '') { $additionalWhere .= ' AND tx_cal_location.pid IN (' . $pidList . ')'; } $additionalWhere .= $this->getAdditionalWhereForLocalizationAndVersioning('tx_cal_location'); $table = 'tx_cal_location'; $select = '*'; $where = ' l18n_parent = 0 ' . $additionalWhere . $this->cObj->enableFields('tx_cal_location'); $groupBy = ''; $limit = ''; $rightsObj =& \TYPO3\CMS\Cal\Utility\Registry::Registry('basic', 'rightscontroller'); $feUserUid = $rightsObj->getUserId(); $feGroupsArray = $rightsObj->getUserGroups(); $hookObjectsArr = \TYPO3\CMS\Cal\Utility\Functions::getHookObjectsArray('tx_cal_location_service', 'locationServiceClass', 'service'); foreach ($hookObjectsArr as $hookObj) { if (method_exists($hookObj, 'preGetLocationFromTableExec')) { $hookObj->preGetLocationFromTableExec($this, $select, $table, $where, $groupBy, $orderBy, $limit); } } $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select, $table, $where, $groupBy, $orderBy, $limit); if ($result) { while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { if ($GLOBALS['TSFE']->sys_language_content) { $row = $GLOBALS['TSFE']->sys_page->getRecordOverlay('tx_cal_location', $row, $GLOBALS['TSFE']->sys_language_content, $GLOBALS['TSFE']->sys_language_contentOL, ''); } if ($GLOBALS['TSFE']->sys_page->versioningPreview == TRUE) { // get workspaces Overlay $GLOBALS['TSFE']->sys_page->versionOL('tx_cal_location', $row); } $lastLocation = new \TYPO3\CMS\Cal\Model\Location($row, $pidList); $select = 'uid_foreign,tablenames'; $table = 'tx_cal_location_shared_user_mm'; $where = 'uid_local = ' . $row['uid']; $sharedUserResult = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select, $table, $where); if ($sharedUserResult) { while ($sharedUserRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($sharedUserResult)) { if ($sharedUserRow['tablenames'] == 'fe_users') { $lastLocation->addSharedUser($sharedUserRow['uid_foreign']); } else { if ($sharedUserRow['tablenames'] == 'fe_groups') { $lastLocation->addSharedGroup($sharedUserRow['uid_foreign']); } } } $GLOBALS['TYPO3_DB']->sql_free_result($sharedUserResult); } $locations[] = $lastLocation; } $GLOBALS['TYPO3_DB']->sql_free_result($result); } return $locations; }