Example #1
0
 function Address($pAddressId)
 {
     parent::__construct();
     if (is_numeric($pAddressId)) {
         $this->mAddressId = $pAddressId;
     }
 }
Example #2
0
function geoserverGetTilelayerList(&$pListHash)
{
    global $gBitSystem;
    require_once LIBERTY_PKG_PATH . "LibertyContent.php";
    $ret = array();
    $bindVars = array();
    $selectSql = '';
    $joinSql = '';
    $whereSql = '';
    if (empty($pListHash['sort_mode'])) {
        // $pListHash['sort_mode'] = array( 'gtl.`tiles_name_asc`' );
        $pListHash['sort_mode'] = array('gtt.`theme_title_asc`', 'gtl.`tiles_name_asc`');
    }
    @LibertyContent::prepGetList($pListHash);
    $joinSql .= " INNER JOIN `" . BIT_DB_PREFIX . "geoserver_tilelayers_meta` gtm ON( gtm.`tilelayer_id` = gtl.`tilelayer_id` ) " . " LEFT JOIN `" . BIT_DB_PREFIX . "geoserver_tilelayers_themes` gtt ON( gtt.`theme_id` = gtm.`theme_id` ) ";
    $selectSql .= ", gtm.*, gtt.theme_title";
    if (@BitBase::verifyId($pListHash['theme_id'])) {
        $whereSql = " WHERE gtm.`theme_id` = ? ";
        $bindVars[] = $pListHash['theme_id'];
    }
    $sql = "SELECT gtl.* {$selectSql}\n\t\t\tFROM `" . BIT_DB_PREFIX . "gmaps_tilelayers` gtl {$joinSql}\n\t\t\t{$whereSql}\n\t\t\tORDER BY " . $gBitSystem->mDb->convertSortmode($pListHash['sort_mode']);
    $result = $gBitSystem->mDb->query($sql, $bindVars, $pListHash['max_records'], $pListHash['offset']);
    while ($aux = $result->fetchRow()) {
        $ret[$aux['tilelayer_id']] = $aux;
    }
    $pListHash['cant'] = $gBitSystem->mDb->getOne("SELECT COUNT( gtl.`tilelayer_id` ) FROM `" . BIT_DB_PREFIX . "gmaps_tilelayers` gtl {$joinSql} {$whereSql}", $bindVars);
    @LibertyContent::postGetList($pListHash);
    return $ret;
}
Example #3
0
 /**
  * getRefererList gets a list of referers
  *
  * @param array $pListHash
  * @access public
  * @return array of referers
  */
 function getRefererList(&$pListHash)
 {
     global $gBitSystem;
     $hashKey = '';
     $ret = $bindVars = array();
     $selectSql = $joinSql = $whereSql = $groupSql = "";
     $hashSql = "uu.`user_id` AS `hash_key`, ";
     if (empty($pListHash['sort_mode'])) {
         $pListHash['sort_mode'] = 'uu.`registration_date_desc`';
     }
     static::prepGetList($pListHash);
     if (empty($pListHash['period_format'])) {
         $pListHash['period_format'] = 'Y-W';
     }
     if (!empty($pListHash['period_format']) && !empty($pListHash['timeframe'])) {
         $whereSql .= empty($whereSql) ? ' WHERE ' : ' AND ';
         $whereSql .= $this->mDb->SQLDate($pListHash['period_format'], $this->mDb->SQLIntToTimestamp('registration_date')) . '=?';
         $bindVars[] = $pListHash['timeframe'];
         $hashKey = 'host';
     } else {
         $hashSql = $this->mDb->SQLDate($pListHash['period_format'], $this->mDb->SQLIntToTimestamp('registration_date')) . ' AS `hash_key`,';
         $hashKey = 'period';
     }
     if (!empty($pListHash['find']) && is_string($pListHash['find'])) {
         $whereSql .= empty($whereSql) ? ' WHERE ' : ' AND ';
         $whereSql .= " UPPER( `referer_url` ) LIKE ?";
         $bindVars[] = '%' . strtoupper($pListHash['find']) . '%';
         if (empty($pListHash['timeframe']) && !empty($pListHash['period_format'])) {
             $hashSql = $this->mDb->SQLDate($pListHash['period_format'], $this->mDb->SQLIntToTimestamp('registration_date')) . ' AS `hash_key`,';
             $hashKey = 'period';
         }
     }
     $query = "SELECT {$hashSql} uu.*, sru.`referer_url`\n\t\t\t\t\tFROM `" . BIT_DB_PREFIX . "users_users` uu\n\t\t\t\t\t \tLEFT JOIN `" . BIT_DB_PREFIX . "stats_referer_users_map` srum ON(uu.`user_id`=srum.`user_id`)\n\t\t\t\t\t\tLEFT JOIN  `" . BIT_DB_PREFIX . "stats_referer_urls` sru ON (sru.`referer_url_id`=srum.`referer_url_id`)\n\t\t\t\t{$whereSql} ORDER BY " . $this->mDb->convertSortmode($pListHash['sort_mode']);
     if ($rs = $this->mDb->query($query, $bindVars, -1, $pListHash['offset'], $gBitSystem->isLive() ? 3600 : BIT_QUERY_DEFAULT)) {
         while ($row = $rs->fetchRow()) {
             $key = $row['hash_key'];
             if ($hashKey == 'host') {
                 $key = 'none';
                 if (!empty($row['referer_url'])) {
                     $parseUrl = parse_url($row['referer_url']);
                     if (!empty($parseUrl['query'])) {
                         parse_str($parseUrl['query'], $params);
                         if (!empty($params['adurl'])) {
                             parse_str($params['adurl'], $params);
                         }
                     }
                     $key = $parseUrl['host'];
                 }
             }
             $ret[$key][$row['user_id']] = $row;
         }
     }
     LibertyContent::postGetList($pListHash);
     if ($hashKey == 'host') {
         uasort($ret, array($this, 'sortRefererHash'));
     }
     return $ret;
 }
Example #4
0
/**
 * feed_get_actions
 */
function feed_get_actions($pListHash)
{
    global $gBitDb;
    $whereSql = '';
    $bindVars = array();
    BitBase::prepGetList($pListHash);
    if (!empty($pListHash['user_id'])) {
        $whereSql = " WHERE lal.user_id = ? ";
        $bindVars[] = $pListHash['user_id'];
    } else {
        $whereSql = "WHERE 1=1 ";
    }
    $query = "SELECT lal.content_id, lal.user_id, lal.log_message, MAX(lal.last_modified) AS last_modified, uu.login, uu.real_name, uu.email\n\t\t\t  FROM liberty_action_log lal\n\t\t\t  INNER JOIN liberty_content lc ON (lc.content_id=lal.content_id)\n\t\t\t  INNER JOIN users_users uu ON (uu.user_id=lal.user_id)\n\t\t\t  {$whereSql} AND lc.content_type_guid != 'feedstatus'\n\t\t\t  GROUP BY lal.content_id, lal.user_id, uu.login, uu.real_name, uu.email, lal.log_message\n\t\t\t  ORDER BY MAX(lal.last_modified) DESC";
    $res = $gBitDb->query($query, $bindVars, $pListHash['max_records']);
    $conjugationQuery = "SELECT * FROM feed_conjugation";
    $overrides = $gBitDb->getAssoc($conjugationQuery);
    $actions = array();
    //loop through directed actions
    while ($action = $res->fetchRow()) {
        if (!empty($action['content_id'])) {
            //indicates that this isn't a direct action, more of a "status update" ex. "Ronald is pleased with his artwork"
            if ($content = LibertyContent::getLibertyObject($action['content_id'])) {
                $contentType = $content->getContentType();
                $action['real_log'] = BitUser::getDisplayNameFromHash(empty($pListHash['no_link_user']), $action) . ' ';
                if (!empty($overrides[strtolower($contentType)])) {
                    $action['real_log'] .= $overrides[$contentType]['conjugation_phrase'];
                    if ($overrides[$contentType]['is_target_linked'] == 'y') {
                        $action['real_log'] .= ' <a href="' . $content->getDisplayUrl() . '">' . $content->getTitle() . '</a>';
                    }
                    if (!empty($overrides[$contentType]['feed_icon_url'])) {
                        $action['feed_icon_url'] = $overrides[$contentType]['feed_icon_url'];
                    }
                } else {
                    $action['real_log'] .= tra('edited') . ' <a href="' . $content->getDisplayUrl() . '">' . $content->getTitle() . '</a>';
                }
            } else {
                unset($action);
                //invalid content_id
            }
            if (empty($action['feed_icon_url'])) {
                $action['feed_icon_url'] = FEED_PKG_URL . 'icons/pixelmixerbasic/pencil_16.png';
            }
            $actions[] = $action;
        }
    }
    return $actions;
}
Example #5
0
function data_alias($pData, $pParams, $pCommonObject)
{
    $page = '';
    require_once WIKI_PKG_PATH . "BitPage.php";
    foreach ($pParams as $key => $value) {
        if (!empty($value)) {
            switch ($key) {
                case 'page':
                    $page = $value;
                    break;
                default:
                    break;
            }
        }
    }
    return tra("This page is an alias for:") . '&nbsp;' . BitPage::getPageLink($page, LibertyContent::pageExists($page));
}
Example #6
0
 /**
  * getList 
  * 
  * @param array $pListHash 
  * @access public
  * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
  */
 function getList(&$pListHash)
 {
     global $gLibertySystem;
     if (empty($pListHash['sort_mode'])) {
         $pListHash['sort_mode'] = 'tagpos_asc';
     }
     LibertyBase::prepGetList($pListHash);
     $bindvars = array();
     if (!empty($pListHash['find'])) {
         $findesc = '%' . $pListHash['find'] . '%';
         $mid = " WHERE (`tagname` LIKE ?)";
         $bindvars[] = $findesc;
         if (!empty($pListHash['format_guid'])) {
             $mid = " AND `format_guid`=?";
             $bindvars[] = $pListHash['format_guid'];
         }
     } elseif (!empty($pListHash['format_guid'])) {
         $mid = " WHERE `format_guid`=?";
         $bindvars[] = $pListHash['format_guid'];
     } else {
         $mid = '';
     }
     $query = "SELECT * FROM `" . BIT_DB_PREFIX . "quicktags` {$mid} ORDER BY " . $this->mDb->convertSortmode($pListHash['sort_mode']);
     $result = $this->mDb->query($query, $bindvars, $pListHash['max_records'], $pListHash['offset']);
     $tmp = array();
     while ($res = $result->fetchRow()) {
         $res['iconpath'] = $res['tagicon'];
         $tmp[] = $res;
     }
     $ret = array();
     foreach ($gLibertySystem->mPlugins as $plugin) {
         if ($plugin['plugin_type'] == 'format') {
             foreach ($tmp as $qt) {
                 if ($qt['format_guid'] == $plugin['plugin_guid']) {
                     $ret[$plugin['plugin_guid']][] = $qt;
                 }
             }
         }
     }
     $pListHash["cant"] = $this->mDb->getOne("SELECT COUNT(*) FROM `" . BIT_DB_PREFIX . "quicktags` {$mid}", $bindvars);
     LibertyContent::postGetList($pListHash);
     return $ret;
 }
Example #7
0
$gBitSystem->verifyPermission('p_wiki_list_pages');
$rankingOptions = array(array('output' => tra('Most Often Viewed'), 'value' => 'hits_desc'), array('output' => tra('Most Recently Modified'), 'value' => 'last_modified_desc'), array('output' => tra('Most Active Authors'), 'value' => 'top_authors'));
$gBitSmarty->assign('rankingOptions', $rankingOptions);
if (!empty($_REQUEST['sort_mode'])) {
    switch ($_REQUEST['sort_mode']) {
        case 'last_modified_desc':
            $gBitSmarty->assign('attribute', 'last_modified');
            $_REQUEST['attribute'] = tra('Date of last modification');
            break;
        case 'top_authors':
            $gBitSmarty->assign('attribute', 'ag_hits');
            $_REQUEST['attribute'] = tra('Hits to items by this Author');
            break;
        default:
            $gBitSmarty->assign('attribute', 'hits');
            $_REQUEST['attribute'] = tra('Hits');
            break;
    }
} else {
    $gBitSmarty->assign('attribute', 'hits');
    $_REQUEST['attribute'] = tra('Hits');
}
$_REQUEST['title'] = tra('Wiki Rankings');
$_REQUEST['content_type_guid'] = BITPAGE_CONTENT_TYPE_GUID;
$_REQUEST['max_records'] = !empty($_REQUEST['max_records']) ? $_REQUEST['max_records'] : 10;
if (empty($gContent)) {
    $gContent = new LibertyContent();
}
$rankList = $gContent->getContentRanking($_REQUEST);
$gBitSmarty->assign('rankList', $rankList);
$gBitSystem->display('bitpackage:liberty/rankings.tpl', tra("Wiki Rankings"), array('display_mode' => 'display'));
Example #8
0
 function getList(&$pListHash)
 {
     global $gBitUser, $gBitSystem;
     $this->prepGetList($pListHash);
     $ret = NULL;
     $bindVars = array();
     $selectSql = '';
     $joinSql = '';
     $whereSql = '';
     array_push($bindVars, $this->mContentTypeGuid);
     $this->getServicesSql('content_list_sql_function', $selectSql, $joinSql, $whereSql, $bindVars);
     if (@$this->verifyId($pListHash['gmap_id']) || isset($pListHash['set_id'])) {
         $selectSql .= ", gpk.*, gps.`set_id`, gps.`style_id`, gps.`polylinestyle_id` ";
         $joinSql .= " INNER JOIN `" . BIT_DB_PREFIX . "gmaps_polygon_keychain` gpk ON (gp.`polygon_id` = gpk.`polygon_id`) ";
         $joinSql .= " INNER JOIN `" . BIT_DB_PREFIX . "gmaps_polygon_sets` gps ON (gpk.`set_id` = gps.`set_id`) ";
     }
     if (isset($pListHash['set_id'])) {
         if (!is_array($pListHash['set_id']) && is_numeric($pListHash['set_id'])) {
             $sets = array($pListHash['set_id']);
         } elseif (is_array($pListHash['set_id'])) {
             $sets = $pListHash['set_id'];
         }
         $hasOne = FALSE;
         foreach ($sets as $value) {
             if (@$this->verifyId($value)) {
                 if ($hasOne != TRUE) {
                     $whereSql .= " AND ( gpk.`set_id` = ? ";
                     $hasOne = TRUE;
                 } else {
                     $whereSql .= " OR gpk.`set_id` = ? ";
                 }
                 array_push($bindVars, (int) $value);
             }
         }
         if ($hasOne == TRUE) {
             $whereSql .= " ) ";
         }
     }
     if (@$this->verifyId($pListHash['gmap_id'])) {
         $selectSql .= ", gsk.* ";
         $joinSql .= " INNER JOIN `" . BIT_DB_PREFIX . "gmaps_sets_keychain` gsk ON( gps.`set_id` = gsk.`set_id`) ";
         $whereSql .= " AND gsk.`set_type` = 'polygons' AND gsk.`gmap_id` = ? ";
         array_push($bindVars, (int) $pListHash['gmap_id']);
     }
     switch ($pListHash['sort_mode']) {
         case 'pos_desc':
         case 'pos_asc':
             $sortModePrefix = 'gpk.';
             break;
         default:
             $sortModePrefix = 'lc.';
             break;
     }
     $secondarySortMode = $pListHash['sort_mode'] != 'title_asc' ? ', title ASC' : '';
     $sort_mode = $sortModePrefix . $this->mDb->convertSortmode($pListHash['sort_mode']) . $secondarySortMode;
     $query = "SELECT lc.*, gp.*, \n\t\t\t\t  uue.`login` AS modifier_user, uue.`real_name` AS modifier_real_name,\n\t\t\t\t  uuc.`login` AS creator_user, uuc.`real_name` AS creator_real_name {$selectSql}\n\t\t\t\t  FROM `" . BIT_DB_PREFIX . "gmaps_polygons` gp \n\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON( gp.`content_id`=lc.`content_id` ) {$joinSql}\n\t\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uue ON (uue.`user_id` = lc.`modifier_user_id`)\n\t\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uuc ON (uuc.`user_id` = lc.`user_id`)\n\t\t\t\t  WHERE lc.`content_type_guid` = ? {$whereSql}\n\t\t\t\t  ORDER BY {$sort_mode}";
     $query_cant = "\n\t\t\tSELECT COUNT( * )\n\t\t    FROM `" . BIT_DB_PREFIX . "gmaps_polygons` gp \n\t\t\t\tINNER JOIN      `" . BIT_DB_PREFIX . "liberty_content`       lc ON lc.`content_id` = gp.`content_id`\n\t\t\t\tINNER JOIN\t\t`" . BIT_DB_PREFIX . "users_users`\t\t\t uu ON uu.`user_id`\t\t\t   = lc.`user_id`\n\t\t\t\t{$joinSql}\n\t\t\tWHERE lc.`content_type_guid` = ? {$whereSql} ";
     $result = $this->mDb->query($query, $bindVars, $pListHash['max_records'], $pListHash['offset']);
     $cant = $this->mDb->getOne($query_cant, $bindVars);
     $ret = array();
     while ($res = $result->fetchRow()) {
         $res['display_url'] = $this->getDisplayUrlFromHash($res);
         $ret[] = $res;
     }
     $pListHash["data"] = $ret;
     $pListHash["cant"] = $cant;
     LibertyContent::postGetList($pListHash);
     return $pListHash;
 }
Example #9
0
 /**
  * getPropertyList( &$pParamHash );
  * Get list of property records
  */
 function getPropertyList(&$pParamHash)
 {
     global $gBitSystem, $gBitUser;
     if (empty($pParamHash['sort_mode'])) {
         if (empty($_REQUEST["sort_mode"])) {
             $pParamHash['sort_mode'] = 'title_asc';
         } else {
             $pParamHash['sort_mode'] = $_REQUEST['sort_mode'];
         }
     }
     LibertyContent::prepGetList($pParamHash);
     $findSql = '';
     $selectSql = '';
     $joinSql = '';
     $whereSql = '';
     $bindVars = array();
     // this will set $find, $sort_mode, $max_records and $offset
     extract($pParamHash);
     $where = ' WHERE ';
     if (isset($find_org) and is_string($find_org) and $find_org != '') {
         $findSql .= $where . "UPPER( c.`organisation` ) like ? ";
         $bindVars[] = '%' . strtoupper($find_org) . '%';
         $where = ' AND ';
     }
     if (isset($find_xao) and is_string($find_xao) and $find_xao != '') {
         $findSql .= $where . " ( UPPER( d.`sao` ) like ? OR UPPER( d.`pao` ) like ? ) ";
         $bindVars[] = '%' . strtoupper($find_xao) . '%';
         $bindVars[] = '%' . strtoupper($find_xao) . '%';
         $where = ' AND ';
     }
     if (isset($find_street) and is_string($find_street) and $find_street != '') {
         $findSql .= $where . "UPPER( d.`add2` ) like ? ";
         $bindVars[] = '%' . strtoupper($find_street) . '%';
         $where = ' AND ';
     }
     if (isset($find_postcode) and is_string($find_postcode) and $find_postcode != '') {
         $findSql .= $where . "UPPER( `d.postcode` ) LIKE ? ";
         $bindVars[] = strtoupper($find_postcode) . '%';
         $where = ' AND ';
     }
     // If no selected filter then reduce result set artificially - use street starting A
     if ($where == ' WHERE ') {
         $findSql .= $where . "UPPER( d.`add2` ) like ? ";
         $bindVars[] = 'A%';
         $pParamHash['find_street'] = 'A';
     }
     $query = "SELECT CASE WHEN c.uprn = 0 THEN 'Private' ELSE 'Business' END AS p_type, p.*, d.add2, d.add3 AS title, d.postcode, c.* {$selectSql}\n\t\t\tFROM `" . BIT_DB_PREFIX . "property` p\n\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "postcode` d ON d.`postcode` = p.`postcode`\n\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "contact` c ON c.`content_id` = p.`owner_id` {$findSql}\n\t\t\t{$joinSql} {$whereSql} ORDER BY " . $this->mDb->convertSortmode($sort_mode);
     $query_cant = "SELECT COUNT( * )\n\t\t\tFROM `" . BIT_DB_PREFIX . "property` p\n\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "postcode` d ON d.`postcode` = p.`postcode`\n\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "contact` c ON c.`content_id` = p.`owner_id` {$findSql}\n\t\t\t{$joinSql} {$whereSql}";
     $result = $this->mDb->query($query, $bindVars, $max_records, $offset);
     $ret = array();
     while ($res = $result->fetchRow()) {
         if (!empty($parse_split)) {
             $res = array_merge($this->parseSplit($res), $res);
         }
         /*			$os1 = new OSRef($res['x_coordinate'], $res['y_coordinate']);
         			$ll1 = $os1->toLatLng();
         			$res['prop_lat'] = $ll1->lat;
         			$res['prop_lng'] = $ll1->lng;
         			$res['display_usrn'] = $this->getUsrnEntryUrl( $res['usrn'] );
         			$res['display_uprn'] = $this->getUprnEntryUrl( $res['uprn'] );
         */
         $ret[] = $res;
     }
     $pParamHash["cant"] = $this->mDb->getOne($query_cant, $bindVars);
     LibertyContent::postGetList($pParamHash);
     return $ret;
 }
Example #10
0
 /**
  * getIconList 
  * 
  * @param array $pListHash 
  * @access public
  * @return array of icons
  */
 function getIconList(&$pListHash)
 {
     $whereSql = "";
     $bindVars = $ret = array();
     if (empty($pListHash['sort_mode'])) {
         $pListHash['sort_mode'] = array('gmit.`theme_title_asc`', 'gmis.`name_asc`');
     }
     $this->prepGetList($pListHash);
     if (!empty($pListHash['theme_title'])) {
         $pListHash['theme_id'] = $this->getIconThemeId($pListHash['theme_title']);
     }
     if (@BitBase::verifyId($pListHash['theme_id'])) {
         $whereSql = " WHERE gmis.`theme_id` = ? ";
         $bindVars[] = $pListHash['theme_id'];
     }
     $sql = "SELECT gmis.`icon_id` AS `key`, gmis.*, gmit.`theme_title`\n\t\t\tFROM `" . BIT_DB_PREFIX . "gmaps_icon_styles` gmis\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "gmaps_icon_themes` gmit ON( gmit.`theme_id` = gmis.`theme_id` )\n\t\t\t{$whereSql}\n\t\t\tORDER BY " . $this->mDb->convertSortmode($pListHash['sort_mode']);
     $result = $this->mDb->query($sql, $bindVars, $pListHash['max_records'], $pListHash['offset']);
     while ($aux = $result->fetchRow()) {
         // convert relative path to valid url
         $aux['image'] = BIT_ROOT_URL . str_replace('//', '/', str_replace('+', '%20', str_replace('%2F', '/', urlencode($aux['image']))));
         $ret[] = $aux;
     }
     $pListHash['cant'] = $this->mDb->getOne("SELECT COUNT( `icon_id` ) FROM `" . BIT_DB_PREFIX . "gmaps_icon_styles` gmis {$whereSql}", $bindVars);
     LibertyContent::postGetList($pListHash);
     return $ret;
 }
Example #11
0
 /**
  * get list of all rated content
  * @param $pListHash contains array of items used to limit search results
  * @param $pListHash[sort_mode] column and orientation by which search results are sorted
  * @param $pListHash[find] search for a pigeonhole title - case insensitive
  * @param $pListHash[max_records] maximum number of rows to return
  * @param $pListHash[offset] number of results data is offset by
  * @access public
  * @return array of rated content
  **/
 function getList(&$pListHash)
 {
     global $gBitSystem, $gBitUser, $gLibertySystem;
     $ret = $bindVars = array();
     $where = $order = '';
     $where .= empty($where) ? ' WHERE ' : ' AND ';
     $where .= ' sts.`version` = 0';
     if (!empty($pListHash['sort_mode'])) {
         $order .= " ORDER BY " . $this->mDb->convert_sortmode($pListHash['sort_mode']) . " ";
     } else {
         // set a default sort_mode
         $order .= " ORDER BY sts.`rating` DESC";
     }
     LibertyContent::prepGetList($pListHash);
     if (!empty($pListHash['find'])) {
         $where .= empty($where) ? ' WHERE ' : ' AND ';
         $where .= " UPPER( lc.`title` ) LIKE ? ";
         $bindVars[] = '%' . strtoupper($pListHash['find']) . '%';
     }
     $query = "SELECT sts.*, lch.`hits`, lch.`last_hit`, lc.`event_time`, lc.`title`,\n\t\t\tlc.`last_modified`, lc.`content_type_guid`, lc.`ip`, lc.`created`,\n\t\t\tlct.`content_name`\n\t\t\tFROM `" . BIT_DB_PREFIX . "stars_version` sts\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON ( lc.`content_id` = sts.`content_id` )\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content_types` lct ON ( lct.`content_type_guid` = lc.`content_type_guid` )\n\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "liberty_content_hits` lch ON ( lc.`content_id` = lch.`content_id` )\n\t\t\t{$where} {$order}";
     $result = $this->mDb->query($query, $bindVars, $pListHash['max_records'], $pListHash['offset']);
     while ($aux = $result->fetchRow()) {
         $type =& $gLibertySystem->mContentTypes[$aux['content_type_guid']];
         if (empty($type['content_object'])) {
             include_once $gBitSystem->mPackages[$type['handler_package']]['path'] . $type['handler_file'];
             $type['content_object'] = new $type['handler_class']();
         }
         if (!empty($gBitSystem->mPackages[$type['handler_package']])) {
             $aux['display_link'] = $type['content_object']->getDisplayLink($aux['title'], $aux);
             $aux['title'] = $type['content_object']->getTitleFromHash($aux);
             $aux['display_url'] = $type['content_object']->getDisplayUrl($aux['content_id'], $aux);
         }
         $ret[] = $aux;
     }
     $query = "SELECT COUNT( sts.`content_id` ) FROM `" . BIT_DB_PREFIX . "stars_version` sts {$where}";
     $pListHash['cant'] = $this->mDb->getOne($query, $bindVars);
     LibertyContent::postGetList($pListHash);
     return $ret;
 }
Example #12
0
 /**
  * get list of all pigeonholes
  * @param $pListHash contains array of items used to limit search results
  * @param $pListHash[sort_mode] column and orientation by which search results are sorted
  * @param $pListHash[find] search for a pigeonhole title - case insensitive
  * @param $pListHash[max_records] maximum number of rows to return
  * @param $pListHash[offset] number of results data is offset by
  * @param $pListHash[title] pigeonhole name
  * @param $pListHash[parent_id] pigeonhole parent_id, optional
  * @param $pListHash[root_structure_id] only load the pigoenhole this root_structure_id is part of
  * @param $pListHash[load_only_root] only load top most items
  * @param $pListHash[parent_content_id] all the sons of the pigeonhole parent content_id , optional
  * @param $pListHash[load_also_root] if parent_content_id is set load also the father, optionnal
  * @return array of pigeonholes in 'data' and count of pigeonholes in 'cant'
  * @access public
  **/
 function getList(&$pListHash)
 {
     global $gBitSystem, $gBitUser, $gBitDbType;
     LibertyContent::prepGetList($pListHash);
     $ret = $bindVars = array();
     $where = $order = $join = $select = '';
     if (@BitBase::verifyId($pListHash['root_structure_id'])) {
         $where .= empty($where) ? ' WHERE ' : ' AND ';
         $where .= " ls.`root_structure_id`=? ";
         $bindVars[] = $pListHash['root_structure_id'];
     }
     if (!empty($pListHash['load_only_root'])) {
         $where .= empty($where) ? ' WHERE ' : ' AND ';
         $where .= " ls.`structure_id`=ls.`root_structure_id` ";
     }
     if (!empty($pListHash['find'])) {
         $where .= empty($where) ? ' WHERE ' : ' AND ';
         $where .= " UPPER( lc.`title` ) LIKE ? ";
         $bindVars[] = '%' . strtoupper($pListHash['find']) . '%';
     }
     if (!empty($pListHash['title'])) {
         $where .= empty($where) ? ' WHERE ' : ' AND ';
         $where .= ' lc.`title` = ?';
         $bindVars[] = $pListHash['title'];
     }
     if ($gBitSystem->isFeatureActive('pigeonholes_allow_forbid_insertion') && !empty($pListHash['insertable'])) {
         $where .= empty($where) ? ' WHERE ' : ' AND ';
         $where .= ' lcp.`pref_value` IS NULL OR lcp.`pref_value` != \'on\' ';
         $join .= ' LEFT JOIN `' . BIT_DB_PREFIX . 'liberty_content_prefs` lcp ON (lc.`content_id` = lcp.`content_id` AND lcp.`pref_name` = \'no_insert\') ';
         $select .= ' , lcp.`pref_value` AS no_insert ';
     }
     if (isset($pListHash['parent_id'])) {
         $where .= empty($where) ? ' WHERE ' : ' AND ';
         $where .= ' ls.`parent_id` = ? ';
         $bindVars[] = $pListHash['parent_id'];
     }
     if (!empty($pListHash['parent_content_id'])) {
         $join .= 'INNER JOIN `' . BIT_DB_PREFIX . 'liberty_structures` lsf ON (ls.`parent_id` = lsf.`structure_id`';
         if (!empty($pListHash['load_also_root'])) {
             $join .= ' OR ls.`structure_id`= lsf.`structure_id`';
         }
         $join .= ')';
         $where .= empty($where) ? ' WHERE ' : ' AND ';
         $where .= ' lsf.`content_id` = ? ';
         $bindVars[] = $pListHash['parent_content_id'];
     }
     if (!empty($pListHash['sort_mode'])) {
         $order .= " ORDER BY " . $this->mDb->convertSortmode($pListHash['sort_mode']) . " ";
     } else {
         // default sort mode makes list look nice
         $order .= " ORDER BY ls.`root_structure_id`, ls.`structure_id` ASC";
     }
     // only use subselect for old crappy mysql
     if ($gBitDbType != 'mysql') {
         $subselect = ", (\n\t\t\t\tSELECT COUNT( pm.`content_id` )\n\t\t\t\tFROM `" . BIT_DB_PREFIX . "pigeonhole_members` pm\n\t\t\t\tWHERE pm.`parent_id`=pig.`content_id`\n\t\t\t) AS members_count";
     } else {
         $subselect = "";
     }
     $query = "SELECT pig.*, ls.`root_structure_id`, ls.`parent_id`, lc.`title`, lc.`data`, lc.`user_id`, lc.`content_type_guid`, lc.`format_guid`,\n\t\t\tuue.`login` AS modifier_user, uue.`real_name` AS modifier_real_name,\n\t\t\tuuc.`login` AS creator_user, uuc.`real_name` AS creator_real_name {$select} {$subselect}\n\t\t\tFROM `" . BIT_DB_PREFIX . "pigeonholes` pig\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON ( lc.`content_id` = pig.`content_id` )\n\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uue ON ( uue.`user_id` = lc.`modifier_user_id` )\n\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uuc ON ( uuc.`user_id` = lc.`user_id` )\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_structures` ls ON ( ls.`structure_id` = pig.`structure_id` )\n\t\t\t{$join} {$where} {$order}";
     $result = $this->mDb->query($query, $bindVars, $pListHash['max_records'], $pListHash['offset']);
     while ($aux = $result->fetchRow()) {
         //$content_ids[]        = $aux['content_id'];
         $aux['user'] = $aux['creator_user'];
         $aux['real_name'] = isset($aux['creator_real_name']) ? $aux['creator_real_name'] : $aux['creator_user'];
         $aux['display_name'] = BitUser::getDisplayNameFromHash(FALSE, $aux);
         $aux['editor'] = isset($aux['modifier_real_name']) ? $aux['modifier_real_name'] : $aux['modifier_user'];
         $aux['display_link'] = Pigeonholes::getDisplayLink($aux['title'], $aux);
         // get member count for mysql - haha
         if ($gBitDbType == 'mysql') {
             $aux['members_count'] = $this->mDb->getOne("SELECT COUNT( pm.`content_id` ) FROM `" . BIT_DB_PREFIX . "pigeonhole_members` pm WHERE pm.`parent_id`=?", array($aux['content_id']));
         }
         if (!empty($pListHash['parse_data']) && !empty($aux['data'])) {
             $aux['parsed_data'] = $this->parseData($aux['data'], $aux['format_guid']);
         }
         if (!empty($pListHash['force_extras']) || !empty($pListHash['load_extras']) && $aux['structure_id'] == @$pListHash['structure_id']) {
             $aux['path'] = $this->getPigeonholePath($aux['structure_id']);
             $aux['display_path'] = Pigeonholes::getDisplayPath($aux['path']);
             // Move all the members data into the right place
             $memberListHash = array('content_id' => $aux['content_id'], 'content_type_guid' => !empty($pListHash['content_type_guid']) ? $pListHash['content_type_guid'] : NULL, 'max_records' => !empty($pListHash['members_max_records']) ? $pListHash['members_max_records'] : NULL, 'list_page' => !empty($pListHash['members_list_page']) ? $pListHash['members_list_page'] : NULL, 'sort_mode' => !empty($pListHash['members_sort_mode']) ? $pListHash['members_sort_mode'] : NULL, 'find' => !empty($pListHash['members_find']) ? $pListHash['members_find'] : NULL);
             $aux['members'] = $this->getMemberList($memberListHash);
             $aux['listInfo'] = $memberListHash['listInfo'];
             //$aux['members_count'] = count( $aux['members'] );
             if ($gBitSystem->getConfig('pigeonholes_list_style') == 'table') {
                 $this->alphabetiseMembers($aux['members']);
             }
         }
         $ret[$aux['structure_id']] = $aux;
     }
     $query = "SELECT COUNT( lc.`title` )\n\t\t\tFROM `" . BIT_DB_PREFIX . "pigeonholes` pig\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON ( lc.`content_id` = pig.`content_id` )\n\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uue ON ( uue.`user_id` = lc.`modifier_user_id` )\n\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uuc ON ( uuc.`user_id` = lc.`user_id` )\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_structures` ls ON ( ls.`structure_id` = pig.`structure_id` )\n\t\t\t{$join} {$where}";
     $pListHash['cant'] = $this->mDb->getOne($query, $bindVars);
     LibertyContent::postGetList($pListHash);
     return $ret;
 }
Example #13
0
 /**
  * getCitizenList( &$pParamHash );
  * Get list of citizen records 
  */
 function getCitizenList(&$pParamHash)
 {
     global $gBitSystem, $gBitUser;
     if (empty($pParamHash['sort_mode'])) {
         if (empty($_REQUEST["sort_mode"])) {
             $pParamHash['sort_mode'] = 'surname_asc';
         } else {
             $pParamHash['sort_mode'] = $_REQUEST['sort_mode'];
         }
     }
     LibertyContent::prepGetList($pParamHash);
     $findSql = '';
     $selectSql = '';
     $joinSql = '';
     $whereSql = '';
     $bindVars = array();
     $type = 'surname';
     // this will set $find, $sort_mode, $max_records and $offset
     extract($pParamHash);
     if (isset($find_org) and is_string($find_org) and $find_org != '') {
         $whereSql .= " AND UPPER( ci.`organisation` ) like ? ";
         $bindVars[] = '%' . strtoupper($find_org) . '%';
         $type = 'organisation';
         $pParamHash["listInfo"]["ihash"]["find_org"] = $find_org;
     }
     if (isset($find_name) and is_string($find_name) and $find_name != '') {
         $split = preg_split('|[,. ]|', $find_name, 2);
         $whereSql .= " AND UPPER( ci.`surname` ) STARTING ? ";
         $bindVars[] = strtoupper($split[0]);
         if (array_key_exists(1, $split)) {
             $split[1] = trim($split[1]);
             $whereSql .= " AND UPPER( ci.`forename` ) STARTING ? ";
             $bindVars[] = strtoupper($split[1]);
         }
         $pParamHash["listInfo"]["ihash"]["find_name"] = $find_name;
     }
     if (isset($find_street) and is_string($find_street) and $find_street != '') {
         $whereSql .= " AND UPPER( a.`street` ) like ? ";
         $bindVars[] = '%' . strtoupper($find_street) . '%';
         $pParamHash["listInfo"]["ihash"]["find_street"] = $find_street;
     }
     if (isset($find_org) and is_string($find_postcode) and $find_postcode != '') {
         $whereSql .= " AND UPPER( `a.postcode` ) LIKE ? ";
         $bindVars[] = '%' . strtoupper($find_postcode) . '%';
         $pParamHash["listInfo"]["ihash"]["find_postcode"] = $find_postcode;
     }
     $query = "SELECT ci.*, a.UPRN, a.POSTCODE, a.SAO, a.PAO, a.NUMBER, a.STREET, a.LOCALITY, a.TOWN, a.COUNTY, ci.parent_id as uprn,\n\t\t\t(SELECT COUNT(*) FROM `" . BIT_DB_PREFIX . "citizen_xref` x WHERE x.content_id = ci.content_id ) AS links, \n\t\t\t(SELECT COUNT(*) FROM `" . BIT_DB_PREFIX . "task_ticket` e WHERE e.usn = ci.usn ) AS enquiries {$selectSql} \n\t\t\tFROM `" . BIT_DB_PREFIX . "citizen` ci \n\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "citizen_address` a ON a.content_id = ci.content_id {$findSql}\n\t\t\t{$joinSql} \n\t\t\tWHERE ci.`" . $type . "` <> '' {$whereSql} ORDER BY " . $this->mDb->convertSortmode($sort_mode);
     $query_cant = "SELECT COUNT( * )\n\t\t\tFROM `" . BIT_DB_PREFIX . "citizen` ci\n\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "citizen_address` a ON a.content_id = ci.content_id {$findSql}\n\t\t\t{$joinSql} WHERE ci.`" . $type . "` <> '' {$whereSql} ";
     //			INNER JOIN `".BIT_DB_PREFIX."citizen_address` a ON a.content_id = ci.content_id
     $result = $this->mDb->query($query, $bindVars, $max_records, $offset);
     $ret = array();
     while ($res = $result->fetchRow()) {
         if (!empty($parse_split)) {
             $res = array_merge($this->parseSplit($res), $res);
         }
         $ret[] = $res;
     }
     $pParamHash["cant"] = $this->mDb->getOne($query_cant, $bindVars);
     LibertyContent::postGetList($pParamHash);
     return $ret;
 }
Example #14
0
 $gStructure = new LibertyStructure($_REQUEST["structure_id"]);
 $gStructure->load();
 // order matters for these conditionals
 if (empty($gStructure) || !$gStructure->isValid()) {
     $gBitSystem->fatalError(tra('Invalid structure'));
 }
 if ($gStructure->mInfo['root_structure_id'] == $gStructure->mInfo['structure_id']) {
     $rootStructure =& $gStructure;
 } else {
     $rootStructure = new LibertyStructure($gStructure->mInfo['root_structure_id']);
     $rootStructure->load();
     $rootStructure->loadNavigation();
     $rootStructure->loadPath();
 }
 if (empty($gContent)) {
     $gContent = LibertyContent::getLibertyObject($gStructure->getField('content_id'));
     $gContent->verifyUpdatePermission();
 }
 $gBitSmarty->assign_by_ref('gStructure', $gStructure);
 $gBitSmarty->assign('editingStructure', TRUE);
 $gBitSmarty->assign('structureInfo', $gStructure->mInfo);
 // Store the actively stored structure name
 $gBitUser->storePreference('edit_structure_name', $rootStructure->mInfo['title']);
 $gBitUser->storePreference('edit_structure_id', $rootStructure->mStructureId);
 if (isset($_REQUEST["action"]) && $_REQUEST["action"] == 'remove' || !empty($_REQUEST["confirm"])) {
     $gBitUser->verifyTicket();
     if ($_REQUEST["action"] == 'remove' && ($gBitThemes->isAjaxRequest() || !empty($_REQUEST["confirm"]))) {
         $gBitUser->verifyTicket();
         if ($gStructure->removeStructureNode($_REQUEST["structure_id"], false)) {
             if ($gBitThemes->isAjaxRequest()) {
                 $feedback['success'] = tra("removed from") . ' ' . $gContent->getContentTypeName();
Example #15
0
 function getList(&$pParamHash)
 {
     global $gBitSystem, $gLibertySystem;
     if (!isset($pParamHash['sort_mode']) or $pParamHash['sort_mode'] == '') {
         $pParamHash['sort_mode'] = 'created_desc';
     }
     if (empty($pParamHash['max_records'])) {
         $pParamHash['max_records'] = $gBitSystem->getConfig('max_records');
     }
     LibertyContent::prepGetList($pParamHash);
     $sort_mode = $this->mDb->convertSortmode($pParamHash['sort_mode']);
     $joinSql = $whereSql = $selectSql = '';
     $bindVars = $ret = array();
     $pParamHash['include_comments'] = TRUE;
     $this->getServicesSql('content_list_sql_function', $selectSql, $joinSql, $whereSql, $bindVars, NULL, $pParamHash);
     if (!empty($pParamHash['root_content_type_guid'])) {
         if (is_string($pParamHash['root_content_type_guid'])) {
             $pParamHash['root_content_type_guid'] = array($pParamHash['root_content_type_guid']);
         } elseif (is_array($pParamHash['root_content_type_guid'])) {
             $contentTypes = array_keys($gLibertySystem->mContentTypes);
             $max = count($pParamHash['root_content_type_guid']);
             $guidSql = '';
             for ($i = 0; $i < $max; $i++) {
                 if (in_array($pParamHash['root_content_type_guid'][$i], $contentTypes)) {
                     if (strlen($guidSql)) {
                         $guidSql .= ' OR ';
                     }
                     $guidSql .= " rlc.`content_type_guid`=? ";
                     $bindVars[] = $pParamHash['root_content_type_guid'][$i];
                 }
             }
             $whereSql .= " AND ( {$guidSql} )";
         }
     }
     if (!empty($pParamHash['content_type_guid'])) {
         $whereSql .= " AND rlc.`content_type_guid`=? ";
         $bindVars[] = $pParamHash['content_type_guid'];
     }
     if (!empty($pParamHash['user_id'])) {
         $whereSql .= " AND ptc.`user_id`=? ";
         $bindVars[] = $pParamHash['user_id'];
     }
     if (!empty($pParamHash['created_ge'])) {
         $whereSql .= " AND lc.`created`>=? ";
         $bindVars[] = $pParamHash['created_ge'];
     }
     // left outer join on root so updater works
     $query = "SELECT\n\t\t\t\t\tlcom.`comment_id`,\n\t\t\t\t\tlc.`content_id`,\n\t\t\t\t\tlcom.`parent_id`,\n\t\t\t\t\tlcom.`anon_name`,\n\t\t\t\t\tlcom.`root_id`,\n\t\t\t\t\tlc.`title` AS `content_title`,\n\t\t\t\t\trlc.`title` AS `root_content_title`,\n\t\t\t\t\tlc.`created`,\n\t\t\t\t\tlc.`data`,\n\t\t\t\t\tlc.`last_modified` as `last_modified`,\n\t\t\t\t\tlc.`title` as `title`,\n\t\t\t\t\tptc.`content_type_guid` as `parent_content_type_guid`,\n\t\t\t\t\trlc.`content_type_guid` as `root_content_type_guid`,\n\t\t\t\t\tlc.`content_type_guid`,\n\t\t\t\t\tuu.`login` AS `creator_user`,\n\t\t\t\t\tuu.`login`,\n\t\t\t\t\tuu.`real_name`,\n\t\t\t\t\tuu.`user_id`\n\t\t\t\t\t{$selectSql}\n\t\t\t\t  FROM `" . BIT_DB_PREFIX . "liberty_comments` lcom\n\t\t\t\t  \t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON( lcom.`content_id`=lc.`content_id` )\n\t\t\t      \t\tINNER JOIN `" . BIT_DB_PREFIX . "users_users` uu ON( uu.`user_id`=lc.`user_id`)\n\t\t\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_content` rlc ON( rlc.`content_id`=lcom.`root_id` )\n\t\t\t\t\t\t{$joinSql}, `" . BIT_DB_PREFIX . "liberty_content` ptc\n\t\t\t\t  WHERE lcom.`parent_id`=ptc.`content_id` {$whereSql}\n\t\t\t\t  ORDER BY {$sort_mode}";
     if ($result = $this->mDb->query($query, $bindVars, $pParamHash['max_records'], $pParamHash['offset'])) {
         while ($row = $result->FetchRow()) {
             $row['display_link'] = $this->getDisplayLink($row['content_title'], $row);
             $row['display_url'] = static::getDisplayUrlFromHash($row);
             $row['direct_url'] = static::getDirectUrlFromHash($row);
             if (!empty($pParamHash['parse'])) {
                 $row['parsed_data'] = $this->parseData($row);
             }
             $ret[] = $row;
         }
     }
     return $ret;
 }
Example #16
0
 /**
  * This function generates a list of records from the liberty_content database for use in a list page
  **/
 function getList(&$pParamHash)
 {
     global $gBitSystem, $gBitUser;
     // this makes sure parameters used later on are set
     LibertyContent::prepGetList($pParamHash);
     $selectSql = $joinSql = $whereSql = '';
     $bindVars = array();
     array_push($bindVars, $this->mContentTypeGuid);
     $this->getServicesSql('content_list_sql_function', $selectSql, $joinSql, $whereSql, $bindVars);
     if (is_array($pParamHash['find'])) {
         // you can use an array of pages
         $whereSql .= " AND lc.`title` IN( " . implode(',', array_fill(0, count($pParamHash['find']), '?')) . " )";
         $bindVars = array_merge($bindVars, $pParamHash['find']);
     } elseif (is_string($pParamHash['find'])) {
         // or a string
         $whereSql .= " AND UPPER( lc.`title` )like ? ";
         $bindVars[] = '%' . strtoupper($pParamHash['find']) . '%';
     }
     $query = "SELECT sten.*, lc.`title`, lc.`data` {$selectSql}\n\t\t\tFROM `" . BIT_DB_PREFIX . "stencils` sten INNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON( lc.`content_id` = sten.`content_id` ) {$joinSql}\n\t\t\tWHERE lc.`content_type_guid` = ? {$whereSql}\n\t\t\tORDER BY " . $this->mDb->convertSortmode($pParamHash['sort_mode']);
     $query_cant = "select count(*)\n\t\t\t\tFROM `" . BIT_DB_PREFIX . "stencils` sten INNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON( lc.`content_id` = sten.`content_id` ) {$joinSql}\n\t\t\tWHERE lc.`content_type_guid` = ? {$whereSql}";
     $result = $this->mDb->query($query, $bindVars, $pParamHash['max_records'], $pParamHash['offset']);
     $ret = array();
     while ($res = $result->fetchRow()) {
         // generate output that can be copied and pasted into the textarea
         if (!empty($pParamHash['get_usage'])) {
             // extract all variables
             preg_match_all($this->validRegexp, $res['data'], $matches);
             $res['usage'] = "{{{$res['title']}|\n";
             foreach ($matches[1] as $match) {
                 $res['usage'] .= "|{$match}=\n";
             }
             $res['usage'] .= "}}";
         }
         $ret[] = $res;
     }
     $pParamHash["cant"] = $this->mDb->getOne($query_cant, $bindVars);
     // add all pagination info to pParamHash
     LibertyContent::postGetList($pParamHash);
     return $ret;
 }
Example #17
0
<?php

require_once '../../kernel/setup_inc.php';
include_once KERNEL_PKG_PATH . 'simple_form_functions_lib.php';
$gBitSystem->verifyPermission('p_admin');
$gContent = new LibertyContent();
// logging options
$logSettings = array('liberty_action_log' => array('label' => 'Action Logs', 'note' => 'Log all changes made to liberty content.', 'type' => 'toggle'));
$gBitSmarty->assign('logSettings', $logSettings);
// form processing
if (!empty($_REQUEST['apply_settings'])) {
    $settings = array_merge($logSettings);
    foreach (array_keys($settings) as $item) {
        simple_set_toggle($item, LIBERTY_PKG_NAME);
    }
    if (!empty($_REQUEST['log_prune'])) {
        $gContent->expungeActionLog($_REQUEST['log_prune']);
    }
}
// get list of log entries
$listHash = $_REQUEST;
// since this is all just text and we don't want to search through hundreds of pages
$listHash['max_records'] = $gBitSystem->getConfig('max_records', 10) * 5;
$actionLogs = $gContent->getActionLogs($listHash);
$gBitSmarty->assign('listInfo', $listHash['listInfo']);
$gBitSmarty->assign('actionLogs', $actionLogs);
$gBitSystem->display('bitpackage:liberty/action_logs.tpl', tra('Action Logs'), array('display_mode' => 'admin'));
 /**
  * get list of all recommended content
  *
  * @param $pListHash contains array of items used to limit search results
  * @param $pListHash[sort_mode] column and orientation by which search results are sorted
  * @param $pListHash[find] search for a pigeonhole title - case insensitive
  * @param $pListHash[max_records] maximum number of rows to return
  * @param $pListHash[offset] number of results data is offset by
  * @access public
  * @return array of recommended content
  **/
 function getList(&$pListHash)
 {
     global $gBitSystem, $gBitUser, $gLibertySystem;
     $ret = $bindVars = array();
     $where = $join = $select = '';
     // set custom sorting before we call prepGetList()
     if (!empty($pListHash['sort_mode'])) {
         $order = " ORDER BY " . $this->mDb->convertSortmode($pListHash['sort_mode']) . " ";
     } else {
         // set a default sort_mode
         $order = " ORDER BY rcm.`qualified_time` DESC";
     }
     LibertyContent::prepGetList($pListHash);
     if (!empty($pListHash['user_id'])) {
         $where .= empty($where) ? ' WHERE ' : ' AND ';
         $where .= " rcmh.`user_id`=? ";
         $bindVars[] = $pListHash['user_id'];
         $select .= ", rcmh.`recommending` AS `user_recommending`";
         $join .= " LEFT JOIN `" . BIT_DB_PREFIX . "recommends` rcmh ON( rcm.`content_id` = rcmh.`content_id` AND rcmh.`recommending` != 0) ";
         $order = " ORDER BY rcmh.`recommending` DESC";
     }
     if (!empty($pListHash['timeout'])) {
         $where .= empty($where) ? ' WHERE ' : ' AND ';
         $where .= " rcm.`qualified_time` >= ? ";
         $bindVars[] = $pListHash['timeout'];
     }
     if (!empty($pListHash['recommends'])) {
         $where .= empty($where) ? ' WHERE ' : ' AND ';
         $where .= " rcm.recommending >= ? ";
         $bindVars[] = $pListHash['recommends'];
     }
     if (!empty($pListHash['find'])) {
         $where .= empty($where) ? ' WHERE ' : ' AND ';
         $where .= " UPPER( lc.`title` ) LIKE ? ";
         $bindVars[] = '%' . strtoupper($pListHash['find']) . '%';
     }
     if (!empty($pListHash['content_type'])) {
         if (is_array($pListHash['content_type'])) {
             $where .= empty($where) ? ' WHERE ' : ' AND ';
             $where .= " lc.`content_type_guid` IN( " . implode(',', array_fill(0, count($pListHash['content_type']), '?')) . " )";
             $bindVars = array_merge($bindVars, $pListHash['content_type_guid']);
         } else {
             $where .= empty($where) ? ' WHERE ' : ' AND ';
             $where .= " lc.`content_type_guid` = ? ";
             $bindVars[] = $pListHash['content_type'];
         }
     }
     $query = "\n\t\t\tSELECT rcm.*, lch.`hits`, lch.`last_hit`, lc.`event_time`, lc.`title`,\n\t\t\tlc.`last_modified`, lc.`content_type_guid`, lc.`ip`, lc.`created`, uu.`email`, uu.`login`, uu.`real_name` {$select}\n\t\t\tFROM `" . BIT_DB_PREFIX . "recommends_sum` rcm\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON ( lc.`content_id` = rcm.`content_id` )\n\t\t\t\tINNER JOIN\t\t`" . BIT_DB_PREFIX . "users_users`\t\t\t uu ON ( uu.`user_id`\t\t\t   = lc.`user_id` )\n\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "liberty_content_hits` lch ON ( lc.`content_id` = lch.`content_id` )\n\t\t\t{$join} {$where} {$order}";
     $result = $this->mDb->query($query, $bindVars, $pListHash['max_records'], $pListHash['offset']);
     while ($aux = $result->fetchRow()) {
         $type =& $gLibertySystem->mContentTypes[$aux['content_type_guid']];
         if (empty($type['content_object'])) {
             include_once $gBitSystem->mPackages[$type['handler_package']]['path'] . $type['handler_file'];
             $type['content_object'] = new $type['handler_class']();
         }
         if (!empty($gBitSystem->mPackages[$type['handler_package']])) {
             $aux['display_link'] = $type['content_object']->getDisplayLink($aux['title'], $aux);
             $aux['title'] = $type['content_object']->getTitleFromHash($aux);
             $aux['display_url'] = $type['content_object']->getDisplayUrlFromHash($aux);
         }
         $ret[] = $aux;
     }
     $query = "\n\t\t\tSELECT COUNT( rcm.`content_id` )\n\t\t\tFROM `" . BIT_DB_PREFIX . "recommends_sum` rcm\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON ( lc.`content_id` = rcm.`content_id` )\n\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "liberty_content_hits` lch ON ( lc.`content_id` = lch.`content_id` )\n\t\t\t{$join} {$where}";
     $pListHash['cant'] = $this->mDb->getOne($query, $bindVars);
     LibertyContent::postGetList($pListHash);
     return $ret;
 }
Example #19
0
 function removeStructureNode($structure_id, $delete = FALSE)
 {
     // Now recursively remove
     if (@$this->verifyId($structure_id)) {
         $query = "SELECT *\n\t\t\t\t\t  FROM `" . BIT_DB_PREFIX . "liberty_structures`\n\t\t\t\t\t  WHERE `parent_id`=?";
         $result = $this->mDb->query($query, array((int) $structure_id));
         // Iterate down through the child nodes
         while ($res = $result->fetchRow()) {
             $this->removeStructureNode($res["structure_id"], $delete);
         }
         // Only delete a page if other structures arent referencing it
         if ($delete) {
             $page_info = $this->getNode($structure_id);
             $query = "SELECT COUNT(*) FROM `" . BIT_DB_PREFIX . "liberty_structures` WHERE `content_id`=?";
             $count = $this->mDb->getOne($query, array((int) $page_info["page_id"]));
             if ($count = 1) {
                 $this->remove_all_versions($page_info["page_id"]);
             }
         }
         // If we are removing the root node, remove the entry in liberty_content as well
         $query = "SELECT `content_id`\n\t\t\t\t\t  FROM `" . BIT_DB_PREFIX . "liberty_structures`\n\t\t\t\t\t  WHERE `structure_id`=? AND `structure_id`=`root_structure_id`";
         $content_id = $this->mDb->getOne($query, array((int) $structure_id));
         // Delete the liberty_content stuff
         $lc = new LibertyContent($content_id);
         $lc->expunge();
         // Remove the structure node
         $query = "DELETE FROM `" . BIT_DB_PREFIX . "liberty_structures` WHERE `structure_id`=?";
         $result = $this->mDb->query($query, array((int) $structure_id));
         return true;
     }
 }
Example #20
0
 /**
  * search 
  * 
  * @param array $pSearchHash basically the same parameters as a regular list
  * @access public
  * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
  */
 function search(&$pSearchHash)
 {
     // PHP compatability issues
     include_once UTIL_PKG_PATH . 'PHP_Compat/Compat/Function/stripos.php';
     global $gLibertySystem, $gBitSystem, $gBitUser, $gBitDbType;
     // initiate stuff
     BitBase::prepGetList($pSearchHash);
     $ret = $bindVars = array();
     $selectSql = $whereSql = $orderSql = $joinSql = '';
     // if all content has been selected, there is an empty value in the array
     if (isset($pSearchHash['content_type_guid']) && !is_array($pSearchHash['content_type_guid'])) {
         $pSearchHash['content_type_guid'] = array($pSearchHash['content_type_guid']);
     }
     if (!empty($pSearchHash['content_type_guid']) && in_array('', $pSearchHash['content_type_guid'])) {
         $pSearchHash['content_type_guid'] = array();
     }
     // check if the user has the required permissions to view the requested content type
     foreach ($gLibertySystem->mContentTypes as $contentType) {
         if ((empty($pSearchHash['content_type_guid']) || in_array($contentType["content_type_guid"], $pSearchHash['content_type_guid'])) && $this->hasViewPermission($contentType["content_type_guid"])) {
             $allowed[] = $contentType["content_type_guid"];
         }
     }
     if (in_array('bitcomment', $allowed)) {
         $pSearchHash['include_comments'] = TRUE;
     }
     if (!empty($allowed)) {
         $whereSql .= empty($whereSql) ? ' WHERE ' : ' AND ';
         $whereSql .= " lc.`content_type_guid` IN( " . implode(',', array_fill(0, count($allowed), '?')) . " ) ";
         $bindVars = array_merge($bindVars, $allowed);
     } else {
         $this->mErrors['permission'] = tra("You don't have the required permissions to search the requested content types.");
     }
     // create valid search SQL
     if ($errors = $this->prepareSearchSql($pSearchHash, $whereSql, $bindVars)) {
         $this->mErrors = $errors;
     }
     // get service SQL
     LibertyContent::getServicesSql('content_list_sql_function', $selectSql, $joinSql, $whereSql, $bindVars, NULL, $pSearchHash);
     if (!empty($pSearchHash['sort_mode'])) {
         $orderSql = " ORDER BY lc." . $this->mDb->convertSortmode($pSearchHash['sort_mode']);
     }
     // only continue if we haven't choked so far
     if (empty($this->mErrors)) {
         $query = "\n\t\t\t\tSELECT \n\t\t\t\tuue.`login` AS `modifier_user`,\n\t\t\t\tuue.`real_name` AS `modifier_real_name`,\n\t\t\t\tuue.`user_id` AS `modifier_user_id`,\n\t\t\t\tuuc.`login` AS `creator_user`,\n\t\t\t\tuuc.`real_name` AS `creator_real_name`,\n\t\t\t\tuuc.`user_id` AS `creator_user_id`,\n\t\t\t\tlc.`data`, \n\t\t\t\tlc.`content_id`, \n\t\t\t\tlc.`title`, \n\t\t\t\tlcds.`data` AS `summary`, \n\t\t\t\tlct.`content_name`, \n\t\t\t\tlct.`content_name_plural`, \n\t\t\t\tlch.`hits`,  \n\t\t\t\tlc.`last_modified`,\n\t\t\t\tlc.`created`,\n\t\t\t\tlc.`content_type_guid`\n\t\t\t\t{$selectSql}\n\t\t\t\tFROM `" . BIT_DB_PREFIX . "liberty_content` lc\n\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "users_users` uuc ON (lc.`user_id`=uuc.`user_id`)\n\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "users_users` uue ON (lc.`modifier_user_id`=uue.`user_id`)\n\t\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_content_data` lcds ON ( lc.`content_id` = lcds.`content_id` AND lcds.`data_type` = 'summary' )\n\t\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_content_types` lct ON ( lc.`content_type_guid` = lct.`content_type_guid` )\n\t\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_content_hits` lch ON ( lc.`content_id` = lch.`content_id` )\n\t\t\t\t{$joinSql} {$whereSql} {$orderSql}";
         $result = $this->mDb->query($query, $bindVars, $pSearchHash['max_records'], $pSearchHash['offset']);
         while ($aux = $result->fetchRow()) {
             $data = $aux['summary'] . "\n" . $aux['data'];
             $aux['len'] = strlen($data);
             $lines = explode("\n", strip_tags($data));
             foreach ($pSearchHash['findHash'] as $val) {
                 $val = trim($val, "%");
                 $i = 0;
                 foreach ($lines as $number => $line) {
                     if ($i < 3 && !empty($line) && stripos($line, $val) !== FALSE) {
                         $aux['display_lines'][$number + 1] = encode_email_addresses($line);
                         $i++;
                     }
                 }
                 if (!empty($aux['display_lines'])) {
                     ksort($aux['display_lines']);
                 }
             }
             $aux['display_url'] = BIT_ROOT_URL . "index.php?content_id=" . $aux['content_id'];
             $ret[] = $aux;
         }
         // do some custom sorting
         usort($ret, 'ilike_relevance_sort');
         $query = "\n\t\t\t\tSELECT COUNT( lc.`content_id` )\n\t\t\t\tFROM `" . BIT_DB_PREFIX . "liberty_content` lc\n\t\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_content_data` lcds ON ( lc.`content_id` = lcds.`content_id` )\n\t\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_content_types` lct ON ( lc.`content_type_guid` = lct.`content_type_guid` )\n\t\t\t\t{$joinSql} {$whereSql}";
         $pSearchHash['cant'] = $this->mDb->getOne($query, $bindVars);
         BitBase::postGetList($pSearchHash);
         return $ret;
     } else {
         return FALSE;
     }
 }
Example #21
0
/**
 * Convert a stored video file to flashvideo
 *
 * @param array $pParamHash
 * @access public
 * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
 */
function mime_video_converter(&$pParamHash, $pOnlyGetParameters = FALSE)
{
    global $gBitSystem;
    // video conversion can take a while
    ini_set("max_execution_time", "1800");
    $ret = FALSE;
    if (@BitBase::verifyId($pParamHash['attachment_id'])) {
        // we might have some attachment preferences set if this is an update
        LibertyMime::expungeAttachmentPreferences($pParamHash['attachment_id']);
        // these are set in the liberty plugin admin screen
        $ffmpeg = trim($gBitSystem->getConfig('ffmpeg_path', shell_exec('which ffmpeg')));
        $width = trim($gBitSystem->getConfig('mime_video_width', 320));
        $begin = date('U');
        $log = $actionLog = array();
        if (!is_executable($ffmpeg)) {
            $log['time'] = date('Y-M-d - H:i:s O');
            $log['duration'] = 0;
            $log['message'] = 'ERROR: ffmpeg does not seem to be available on your system at: ' . $ffmpeg . ' Please set the path to ffmpeg in the liberty plugin administration screen.';
            $actionLog['log_message'] = "ERROR: ffmpeg does not seem to be available on your system at: '{$ffmpeg}' Please set the path to ffmpeg in the liberty plugin administration screen.";
        } else {
            // this is the codec we'll use - currently this might be: flv, h264, h264-2pass
            $codec = $gBitSystem->getConfig("mime_video_video_codec", "flv");
            $source = STORAGE_PKG_PATH . $pParamHash['upload']['dest_branch'] . $pParamHash['upload']['name'];
            $destPath = dirname($source);
            // set some default values if ffpeg-php isn't available or fails
            $default['aspect'] = 4 / 3;
            $default['video_width'] = $width;
            $default['video_height'] = round($width / 4 * 3);
            $default['size'] = "{$default['video_width']}x{$default['video_height']}";
            $default['offset'] = '00:00:10';
            if (extension_loaded('ffmpeg')) {
                // we silence these calls since they might spew errors
                $movie = @new ffmpeg_movie($source);
                $info = array('vcodec' => @$movie->getVideoCodec(), 'duration' => round(@$movie->getDuration()), 'width' => @$movie->getFrameWidth(), 'height' => @$movie->getFrameHeight(), 'video_bitrate' => @$movie->getVideoBitRate(), 'acodec' => @$movie->getAudioCodec(), 'audio_bitrate' => @$movie->getAudioBitRate(), 'audio_samplerate' => @$movie->getAudioSampleRate());
                // make sure audio sample rate is valid
                if (!empty($info['audio_samplerate']) && !in_array($info['audio_samplerate'], array(11025, 22050, 44100))) {
                    unset($info['audio_samplerate']);
                }
            } else {
                // alternative method using ffmpeg to fetch source dimensions
                $command = "{$ffmpeg} -i " . escapeshellarg($source) . ' 2>&1';
                exec($command, $output, $status);
                if (!preg_match('/Stream #(?:[0-9\\.]+)(?:.*)\\: Video: (?P<videocodec>.*) (?P<width>[0-9]*)x(?P<height>[0-9]*)/', implode('\\n', $output), $matches)) {
                    preg_match('/Could not find codec parameters \\(Video: (?P<videocodec>.*) (?P<width>[0-9]*)x(?P<height>[0-9]*)\\)/', implode('\\n', $output), $matches);
                }
                if (!empty($matches['width']) && !empty($matches['height'])) {
                    $info['width'] = $matches['width'];
                    $info['height'] = $matches['height'];
                }
            }
            // our player supports flv and h264 so we might as well use the default
            if (!$gBitSystem->isFeatureActive('mime_video_force_encode') && !empty($info) && ($info['vcodec'] == 'h264' && (empty($info['acodec']) || $info['acodec'] == 'mpeg4aac' || $info['acodec'] == 'aac') || $info['vcodec'] == 'flv' && (empty($info['acodec']) || $info['acodec'] == 'mp3'))) {
                // work out what the target filename is
                $extension = $info['vcodec'] == "flv" ? "flv" : "mp4";
                $dest_file = $destPath . "/flick.{$extension}";
                // if the video can be processed by ffmpeg-php, width and height are greater than 1
                if (!empty($info['width']) && $info['width'] > 1) {
                    $info['aspect'] = $info['width'] / $info['height'];
                    $info['offset'] = strftime("%T", round($info['duration'] / 5 - 60 * 60));
                } else {
                    $info = $default;
                }
                // store prefs and create thumbnails
                LibertyMime::expungeMetaData($pParamHash['attachment_id']);
                LibertyMime::storeMetaData($pParamHash['attachment_id'], 'Video', $info);
                mime_video_create_thumbnail($source, $info['offset']);
                if (!is_file($dest_file) && !link($source, $dest_file)) {
                    copy($source, $dest_file);
                }
                mime_video_fix_streaming($dest_file);
                $log['message'] = 'SUCCESS: Converted to flash video';
                $actionLog['log_message'] = "Video file was successfully uploaded and thumbnails extracted.";
                $ret = TRUE;
            } else {
                // work out what the target filename is
                $extension = $codec == "flv" ? "flv" : "mp4";
                $dest_file = $destPath . "/flick.{$extension}";
                // if the video can be processed by ffmpeg-php, width and height are greater than 1
                if (!empty($info['width']) && $info['width'] > 1) {
                    // reset some values to reduce video size
                    if ($info['width'] < $width) {
                        $width = $info['width'];
                    }
                    // here we calculate the size and aspect ratio of the output video
                    $size_ratio = $width / $info['width'];
                    $info['aspect'] = $info['width'] / $info['height'];
                    $info['video_width'] = $width;
                    $info['video_height'] = round($size_ratio * $info['height']);
                    // height of video needs to be an even number
                    if ($info['video_height'] % 2) {
                        $info['video_height']++;
                    }
                    $info['size'] = "{$info['video_width']}x{$info['video_height']}";
                } else {
                    $info = $default;
                }
                // transfer settings to vars for easy manipulation for various APIs of ffmpeg
                $audio_bitrate = $gBitSystem->getConfig('mime_video_audio_bitrate', 32000) / 1000 . 'kb';
                $audio_samplerate = $gBitSystem->getConfig('mime_video_audio_samplerate', 22050);
                $video_bitrate = $gBitSystem->getConfig('mime_video_video_bitrate', 160000) / 1000 . 'kb';
                $acodec_mp3 = $gBitSystem->getConfig('ffmpeg_mp3_lib', 'libmp3lame');
                $me_param = $gBitSystem->getConfig('ffmpeg_me_method', 'me');
                if ($codec == "h264") {
                    $parameters = " -i '{$source}'" . " -acodec libfaac" . " -ab {$audio_bitrate}" . " -ar {$audio_samplerate}" . " -vcodec libx264" . " -b {$video_bitrate}" . " -bt {$video_bitrate}" . " -s " . $info['size'] . " -aspect " . $info['aspect'] . " -flags +loop -cmp +chroma -refs 1 -coder 0 -me_range 16 -g 300 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -maxrate 10M -bufsize 10M -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30" . " -partitions +parti4x4+partp8x8+partb8x8 -{$me_param} epzs -subq 5 -trellis 1" . " -y '{$dest_file}'";
                } elseif ($codec == "h264-2pass") {
                    // it is not possible to pass in the path for the x264 log file and it is always generated in the working dir.
                    $cwd = getcwd();
                    chdir(dirname($dest_file));
                    $passlogfile = dirname($dest_file) . "/ffmpeg2pass";
                    // pass 1
                    $parameters = " -i '{$source}'" . " -an" . " -pass 1" . " -passlogfile {$passlogfile}" . " -vcodec libx264" . " -b {$video_bitrate}" . " -bt {$video_bitrate}" . " -s " . $info['size'] . " -aspect " . $info['aspect'] . " -flags +loop -cmp +chroma -refs 1 -coder 0 -me_range 16 -g 300 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bf 16 -maxrate 10M -bufsize 10M -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30" . " -partitions 0 -{$me_param} epzs -subq 1 -trellis 0" . " -y '{$dest_file}'";
                    // pass 2
                    $parameters2 = " -i '{$source}'" . " -acodec libfaac" . " -ab {$audio_bitrate}" . " -ar {$audio_samplerate}" . " -pass 2" . " -passlogfile {$passlogfile}" . " -vcodec libx264" . " -b {$video_bitrate}" . " -bt {$video_bitrate}" . " -s " . $info['size'] . " -aspect " . $info['aspect'] . " -flags +loop -cmp +chroma -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4" . " -partitions +parti8x8+parti4x4+partp8x8+partp4x4+partb8x8 -flags2 +brdo+dct8x8+wpred+bpyramid+mixed_refs -{$me_param} epzs -subq 7 -trellis 1 -refs 6 -bf 16 -directpred 3 -b_strategy 1 -bidir_refine 1 -coder 1" . " -y '{$dest_file}'";
                } else {
                    $parameters = " -i '{$source}'" . " -acodec {$acodec_mp3}" . " -ab {$audio_bitrate}" . " -ar {$audio_samplerate}" . " -f flv" . " -b {$video_bitrate}" . " -bt {$video_bitrate}" . " -s " . $info['size'] . " -aspect " . $info['aspect'] . " -y '{$dest_file}'";
                }
                if ($pOnlyGetParameters) {
                    return $parameters;
                } else {
                    // we keep the output of this that we can store it to the error file if we need to do so
                    $debug = shell_exec("{$ffmpeg} {$parameters} 2>&1");
                    if (!empty($parameters2)) {
                        $debug .= shell_exec("{$ffmpeg} {$parameters2} 2>&1");
                        // change back to whence we came
                        chdir($cwd);
                    }
                }
                // make sure the conversion was successfull
                if (is_file($dest_file) && filesize($dest_file) > 48) {
                    mime_video_fix_streaming($dest_file);
                    // try to work out a reasonable timepoint where to extract a screenshot
                    if (preg_match('!Duration: ([\\d:\\.]*)!', $debug, $time)) {
                        list($h, $m, $s) = explode(':', $time[1]);
                        $seconds = round(60 * 60 * (int) $h + 60 * (int) $m + (double) $s);
                        // we need to subract one hour from our time for strftime to return the correct value
                        $info['offset'] = strftime("%T", round($seconds / 5 - 60 * 60));
                    } else {
                        $info['offset'] = "00:00:10";
                    }
                    // store some video specific settings
                    LibertyMime::expungeMetaData($pParamHash['attachment_id']);
                    LibertyMime::storeMetaData($pParamHash['attachment_id'], 'Video', $info);
                    // since the flv conversion worked, we will create a preview screenshots to show.
                    mime_video_create_thumbnail($dest_file, $info['offset']);
                    $log['message'] = 'SUCCESS: Converted to flash video';
                    $actionLog['log_message'] = "Converted to flashvideo in " . (date('U') - $begin) . " seconds";
                    $ret = TRUE;
                } else {
                    // remove unsuccessfully converted file
                    @unlink($dest_file);
                    $log['message'] = "ERROR: The video you uploaded could not be converted by ffmpeg.\nDEBUG OUTPUT:\n\n" . $debug;
                    $actionLog['log_message'] = "Video could not be converted to flashvideo. An error dump was saved to: " . $destPath . '/error';
                    // write error message to error file
                    $h = fopen($destPath . "/error", 'w');
                    fwrite($h, "{$ffmpeg} {$parameters}\n\n{$debug}");
                    fclose($h);
                }
                @unlink($destPath . '/processing');
            }
        }
        $log['time'] = date('d/M/Y:H:i:s O');
        $log['duration'] = date('U') - $begin;
        // we'll insert some info into the database for reference
        $actionLog['content_id'] = $pParamHash['content_id'];
        $actionLog['title'] = "Uploaded file: {$pParamHash['upload']['name']} [Attchment ID: {$pParamHash['attachment_id']}]";
        // if this all goes t**s up, we'll know why
        $pParamHash['log'] = $log;
        // we'll add an entry in the action logs
        LibertyContent::storeActionLogFromHash(array('action_log' => $actionLog));
        // return the log
        $pParamHash['log'] = $log;
    }
    return $ret;
}
Example #22
0
 function getList(&$pListHash)
 {
     global $gBitUser, $gBitSystem;
     $this->prepGetList($pListHash);
     $selectSql = '';
     $joinSql = '';
     $whereSql = '';
     $bindVars = array();
     array_push($bindVars, $this->mContentTypeGuid);
     $this->getServicesSql('content_list_sql_function', $selectSql, $joinSql, $whereSql, $bindVars, NULL, $pListHash);
     if (@$this->verifyId($pListHash['blog_id'])) {
         $selectSql .= ', bpm.crosspost_note';
         array_push($bindVars, (int) $pListHash['blog_id']);
         $joinSql .= " LEFT OUTER JOIN `" . BIT_DB_PREFIX . "blogs_posts_map` bpm ON ( bpm.`post_content_id` = bp.`content_id` ) ";
         $joinSql .= " LEFT OUTER JOIN `" . BIT_DB_PREFIX . "blogs` b ON ( bpm.`blog_content_id`=b.`content_id` ) ";
         //	" ON ( b.`content_id` = bpm.`blog_content_id` AND bp.`content_id` = bpm.`post_content_id` )";
         $whereSql .= ' AND b.`blog_id` = ? ';
         $pListHash['sort_mode'] = 'publish_date_desc';
     }
     if (@$this->verifyId($pListHash['post_id_gt'])) {
         array_push($bindVars, (int) $pListHash['post_id_gt']);
         $whereSql .= ' AND bp.`post_id` > ? ';
     }
     if (@$this->verifyId($pListHash['post_id_lt'])) {
         array_push($bindVars, (int) $pListHash['post_id_lt']);
         $whereSql .= ' AND bp.`post_id` < ? ';
     }
     if (@$this->verifyId($pListHash['user_id'])) {
         array_push($bindVars, (int) $pListHash['user_id']);
         $whereSql .= ' AND lc.`user_id` = ? ';
     }
     $this->getServicesSql('content_user_collection_function', $selectSql, $joinSql, $whereSql, $bindVars, NULL, $pListHash);
     // map user to login in case we used one instead of the other
     if (!empty($pListHash['user'])) {
         $pListHash['login'] = $pListHash['user'];
     }
     if (!empty($pListHash['login'])) {
         array_push($bindVars, $pListHash['login']);
         $whereSql .= ' AND uu.`login` = ? ';
     }
     if ($pListHash['find']) {
         $findesc = '%' . strtoupper($pListHash['find']) . '%';
         $whereSql .= "AND (UPPER(lc.`data`) like ?) ";
         $bindVars[] = $findesc;
     }
     if (!empty($pListHash['date']) && is_numeric($pListHash['date'])) {
         $whereSql .= " AND  lc.`created`<=? ";
         $bindVars[] = $pListHash['date'];
     }
     if (!empty($pListHash['date_start']) && is_numeric($pListHash['date_start'])) {
         $whereSql .= " AND  lc.`created`>=? ";
         $bindVars[] = $pListHash['date_start'];
     }
     if (!empty($pListHash['date_end']) && is_numeric($pListHash['date_end'])) {
         $whereSql .= " AND  lc.`created`<=? ";
         $bindVars[] = $pListHash['date_end'];
     }
     if (!empty($pListHash['content_perm_name'])) {
         $this->getContentListPermissionsSql($pListHash['content_perm_name'], $selectSql, $joinSql, $whereSql, $bindVars);
     }
     /* Check if the post wants to be viewed before / after respective dates
      * Note: expiring posts are determined by the expired date being greater than the publish date
      */
     static::getDateRestrictions($pListHash, $whereSql, $bindVars);
     /* sort_mode is never empty due to call to prepGetList above
      * I think this will have to be perminently removed and default
      * set before passing the list hash in if a different default is
      * desired from that in prepGetList. -wjames5
      */
     /*
     if( empty( $pListHash['sort_mode'] ) ) {
     	$pListHash['sort_mode'] = 'publish_date_desc';
     	$sortModePrefix = 'bp';
     	//$pListHash['sort_mode'] = 'created_desc';
     } else {
     */
     $sortModePrefix = '';
     if (!empty($pListHash['sort_mode']) && !strpos($pListHash['sort_mode'], '.')) {
         switch ($pListHash['sort_mode']) {
             case 'publish_date_asc':
             case 'publish_date_desc':
             case 'post_id_desc':
             case 'post_id_asc':
                 $sortModePrefix = 'bp.';
                 break;
             case 'date_added_desc':
                 $sortModePrefix = 'bpm.';
                 break;
             case 'hits_asc':
             case 'hits_desc':
                 $sortModePrefix = 'lch.';
                 break;
             case 'sort_date_asc':
             case 'sort_date_desc':
                 break;
             case 'real_name_asc':
             case 'real_name_desc':
                 $sortModePrefix = 'uu.';
                 break;
                 // these technicall are not correct, however, we do not double join on users_users, so we sort by creator real_name
             // these technicall are not correct, however, we do not double join on users_users, so we sort by creator real_name
             case 'creator_real_name_asc':
             case 'modifier_real_name_asc':
                 $sortModePrefix = 'uu.';
                 $pListHash['sort_mode'] = 'real_name_asc';
                 break;
             case 'registration_date_desc':
                 $sortModePrefix = 'uu.';
                 $pListHash['sort_mode'] = 'registration_date_desc';
                 break;
             case 'creator_real_name_desc':
             case 'modifier_real_name_desc':
                 $sortModePrefix = 'uu.';
                 $pListHash['sort_mode'] = 'real_name_desc';
                 break;
             default:
                 $sortModePrefix = 'lc.';
                 break;
         }
     }
     $secondarySortMode = $pListHash['sort_mode'] != 'last_modified_desc' ? ', last_modified DESC' : '';
     $sort_mode = $sortModePrefix . $this->mDb->convertSortmode($pListHash['sort_mode']) . $secondarySortMode;
     $query = "\n\t\t\tSELECT\n\t\t\t\tbp.`post_id`, bp.`publish_date`, bp.`expire_date`, bp.`trackbacks_to`, bp.`trackbacks_from`,\n\t\t\t\tlc.*, lch.`hits`, lcds.`data` AS `summary`, COALESCE( bp.`publish_date`, lc.`last_modified` ) AS sort_date,\n\t\t\t\tuu.`email`, uu.`login`, uu.`real_name`,\n\t\t\t\t\tlfa.`file_name` as `avatar_file_name`, lfa.`mime_type` AS `avatar_mime_type`, laa.`attachment_id` AS `avatar_attachment_id`,\n\t\t\t\t\tlfp.`file_name` AS `image_file_name`, lfp.`mime_type` AS `image_mime_type`, lap.`attachment_id` AS `image_attachment_id`\n\t\t\tFROM `" . BIT_DB_PREFIX . "blog_posts` bp\n\t\t\t\tINNER JOIN      `" . BIT_DB_PREFIX . "liberty_content`       lc ON lc.`content_id`         = bp.`content_id`\n\t\t\t\tINNER JOIN\t\t`" . BIT_DB_PREFIX . "users_users`\t\t\t uu ON uu.`user_id`\t\t\t   = lc.`user_id`\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_content_hits` lch ON lc.`content_id`         = lch.`content_id`\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_content_data` lcds ON (lc.`content_id` = lcds.`content_id` AND lcds.`data_type`='summary')\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_attachments`\tlaa ON (uu.`user_id` = laa.`user_id` AND laa.`attachment_id` = uu.`avatar_attachment_id`)\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_files`\t    lfa ON lfa.`file_id`\t\t   = laa.`foreign_id`\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_attachments`  lap ON lap.`content_id`        = lc.`content_id` AND lap.`is_primary` = 'y'\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_files`        lfp ON lfp.`file_id`           = lap.`foreign_id`\n\t\t\t\t{$joinSql}\n\t\t\tWHERE lc.`content_type_guid` = ? {$whereSql}\n\t\t\tORDER BY {$sort_mode}";
     # Get count of total number of items available
     $query_cant = "\n\t\t\tSELECT COUNT( * )\n\t\t\tFROM `" . BIT_DB_PREFIX . "blog_posts` bp\n\t\t\t\tINNER JOIN      `" . BIT_DB_PREFIX . "liberty_content`       lc ON lc.`content_id` = bp.`content_id`\n\t\t\t\tINNER JOIN\t\t`" . BIT_DB_PREFIX . "users_users`\t\t\t uu ON uu.`user_id`\t\t\t   = lc.`user_id`\n\t\t\t\t{$joinSql}\n\t\t\tWHERE lc.`content_type_guid` = ? {$whereSql} ";
     $cant = $this->mDb->getOne($query_cant, $bindVars);
     $pListHash["cant"] = $cant;
     # Check for offset out of range
     if ($pListHash['offset'] < 0) {
         $pListHash['offset'] = 0;
     } elseif ($pListHash['offset'] > $pListHash["cant"]) {
         $lastPageNumber = ceil($pListHash["cant"] / $pListHash['max_records']) - 1;
         $pListHash['offset'] = $pListHash['max_records'] * $lastPageNumber;
     }
     $result = $this->mDb->query($query, $bindVars, $pListHash['max_records'], $pListHash['offset']);
     $ret = array();
     $comment = new LibertyComment();
     while ($res = $result->fetchRow()) {
         $res['no_fatal'] = TRUE;
         $accessError = $this->invokeServices('content_verify_access', $res, FALSE);
         if (empty($accessError)) {
             foreach (array('avatar', 'image') as $img) {
                 $res[$img] = liberty_fetch_thumbnails(array('source_file' => liberty_mime_get_source_file(array('user_id' => $res['user_id'], 'package' => liberty_mime_get_storage_sub_dir_name(array('mime_type' => $res[$img . '_mime_type'], 'name' => $res[$img . '_file_name'])), 'file_name' => basename($res[$img . '_file_name']), 'sub_dir' => $res[$img . '_attachment_id']))));
             }
             $res['thumbnail_url'] = BitBlogPost::getImageThumbnails($res);
             $res['num_comments'] = $comment->getNumComments($res['content_id']);
             $res['post_url'] = BitBlogPost::getDisplayUrlFromHash($res);
             $res['display_url'] = $res['post_url'];
             $res['display_link'] = $this->getDisplayLink($res['title'], $res);
             $res['blogs'] = $this->getBlogMemberships($res['content_id']);
             // trackbacks
             if ($res['trackbacks_from'] != null) {
                 $res['trackbacks_from'] = unserialize($res['trackbacks_from']);
             }
             if (!is_array($res['trackbacks_from'])) {
                 $res['trackbacks_from'] = array();
             }
             $res['trackbacks_from_count'] = count(array_keys($res['trackbacks_from']));
             if ($res['trackbacks_to'] != null) {
                 $res['trackbacks_to'] = unserialize($res['trackbacks_to']);
             }
             if ($res['user_id'] == $gBitUser->mUserId) {
                 $res['ownsblog'] = 'y';
             } else {
                 $res['ownsblog'] = 'n';
             }
             $res['trackbacks_to_count'] = count($res['trackbacks_to']);
             $res['pages'] = $this->getNumberOfPages($res['data']);
             // deal with the parsing
             $parseHash['format_guid'] = $res['format_guid'];
             $parseHash['content_id'] = $res['content_id'];
             $parseHash['user_id'] = $res['user_id'];
             // support for ...split... and auto split
             if (!empty($pListHash['full_data'])) {
                 $parseHash['data'] = $res['data'];
                 $res['parsed'] = $this->parseData($parseHash);
             } else {
                 $parseHash['data'] = $res['data'];
                 $parseHash['no_cache'] = TRUE;
                 $splitArray = $this->parseSplit($parseHash, $gBitSystem->getConfig('blog_posts_description_length', 500));
                 $res = array_merge($res, $splitArray);
             }
             if (!empty($this->mInfo['summary'])) {
                 $res['summary'] = $parseHash['data'] = $this->mInfo['summary'];
                 $parseHash['no_cache'] = TRUE;
                 $res['parsed_summary'] = $this->parsedData($parseHash);
             }
             if (!empty($res['crosspost_note'])) {
                 $res['crosspost_note_raw'] = $parseHash['data'] = $res['crosspost_note'];
                 $parseHash['no_cache'] = TRUE;
                 $res['crosspost_note'] = $this->parseData($parseHash);
             }
             $ret[] = $res;
         } elseif (!empty($accessError)) {
             if (!empty($accessError['access_control'])) {
                 $res['post_url'] = BitBlogPost::getDisplayUrlFromHash($res['content_id'], $res);
                 $res['display_url'] = $res['post_url'];
                 /* this needs to be part of loop that gets all blogs post is in
                 			$res['blog_url'] = BitBlog::getDisplayUrlFromHash( $res['blog_content_id'] );
                 			*/
                 $res["parsed_data"] = $accessError['access_control'];
                 $ret[] = $res;
             }
         } else {
         }
     }
     LibertyContent::postGetList($pListHash);
     return $ret;
 }
Example #23
0
}
$gBitSmarty->assign('useAnd', $_REQUEST['useAnd']);
// Build the query using words
if (!isset($_REQUEST["words"]) || empty($_REQUEST["words"])) {
    $_REQUEST["words"] = '';
} else {
    $_REQUEST["words"] = strip_tags($_REQUEST["words"]);
}
$gBitSmarty->assign('words', $_REQUEST["words"]);
$results = $searchlib->find($_REQUEST);
if ($_REQUEST['cant'] != 1) {
    $where2 .= "s";
}
$gBitSmarty->assign('where2', tra($where2));
$gBitSmarty->assign('content_type_guid', $_REQUEST["content_type_guid"]);
$stubContent = new LibertyContent();
if ($_REQUEST['cant'] > 0) {
    foreach (array_keys($results) as $k) {
        if (empty($results[$k]['title'])) {
            $date_format = $gBitSystem->get_long_date_format();
            if ($gBitSystem->mServerTimestamp->get_display_offset()) {
                $date_format = preg_replace("/ ?%Z/", "", $date_format);
            } else {
                $date_format = preg_replace("/%Z/", "UTC", $date_format);
            }
            $date_string = $gBitSystem->mServerTimestamp->getDisplayDateFromUTC($results[$k]['created']);
            $results[$k]['title'] = $gBitSystem->mServerTimestamp->strftime($date_format, $date_string, true);
        }
        if (!empty($results[$k]['data'])) {
            $results[$k]['parsed'] = $stubContent->parseData($results[$k]);
        }
Example #24
0
 /**
  * setActivePlugins
  *
  * @param array $pPluginGuids an array of all the plugin guids that are active. Any left out are *inactive*!
  * @access public
  * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
  */
 function setActivePlugins($pPluginGuids)
 {
     global $gBitSystem;
     if (is_array($pPluginGuids)) {
         // zap list of plugins from DB
         $gBitSystem->storeConfigMatch("/^{$this->mSystem}_plugin_status/i", NULL, 'n', LIBERTY_PKG_NAME);
         foreach (array_keys($this->mPlugins) as $guid) {
             $this->mPlugins[$guid]['is_active'] = 'n';
         }
         // set active those specified
         foreach (array_keys($pPluginGuids) as $guid) {
             if ($pPluginGuids[$guid][0] == 'y') {
                 $this->setActivePlugin($guid);
             }
         }
         // load any plugins made active, but not already loaded
         $this->loadActivePlugins();
         // finally we need to remove all cache files since the content has been changed
         LibertyContent::expungeCache();
     }
 }
Example #25
0
 /**
  * getList 
  * 
  * @param array $pListHash 
  * @access public
  * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
  */
 function getList(&$pListHash, $pStructureId = NULL)
 {
     LibertyContent::prepGetList($pListHash);
     $ret = $bindVars = array();
     $selectSql = $joinSql = $whereSql = "";
     if (@BitBase::verifyId($pListHash['gallery_content_id'])) {
         $whereSql = " WHERE trm.`gallery_content_id` = ? ";
         $bindVars[] = $pListHash['gallery_content_id'];
     }
     if (@BitBase::verifyId($pListHash['user_id'])) {
         $whereSql .= empty($whereSql) ? ' WHERE ' : ' AND ';
         $whereSql .= " lc.`user_id` = ? ";
         $bindVars[] = $pListHash['user_id'];
     }
     if (!empty($pListHash['title']) && is_string($pListHash['title'])) {
         $whereSql .= empty($whereSql) ? ' WHERE ' : ' AND ';
         $whereSql .= " trm.`item_content_id` = lc.`content_id` AND UPPER( lc.`title` ) = ?";
         $bindVars[] = strtoupper($pListHash['title']);
     }
     if (!empty($pListHash['max_age']) && is_numeric($pListHash['max_age'])) {
         $whereSql .= empty($whereSql) ? ' WHERE ' : ' AND ';
         $whereSql .= " lc.`created` > ? ";
         $bindVars[] = $pListHash['max_age'];
     }
     if (!empty($pListHash['sort_mode'])) {
         $orderSql = " ORDER BY " . $this->mDb->convertSortmode($pListHash['sort_mode']) . " ";
     } else {
         $orderSql = " ORDER BY trm.`item_position` ASC ";
     }
     // only join attachments table when we need it for sorting
     if (strstr($pListHash['sort_mode'], 'la.hits') !== FALSE) {
         $joinSql .= " LEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_attachments` la ON ( la.`content_id` = lc.`content_id` ) ";
     }
     $this->getServicesSql('content_list_sql_function', $selectSql, $joinSql, $whereSql, $bindVars);
     $ret = array();
     $query = "\n\t\t\tSELECT\n\t\t\t\tlct.`content_name`,\n\t\t\t\tuu.`login`, uu.`real_name`,\n\t\t\t\tlc.`content_id`, lc.`last_modified`, lc.`user_id`, lc.`title`, lc.`content_type_guid`, lc.`created`, lc.`data`,\n\t\t\t\tlch.`hits` {$selectSql}\n\t\t\tFROM `" . BIT_DB_PREFIX . "treasury_map` trm\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON ( lc.`content_id` = trm.`item_content_id` )\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content_types` lct ON ( lc.`content_type_guid` = lct.`content_type_guid` )\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "users_users` uu ON ( uu.`user_id` = lc.`user_id` )\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_content_hits` lch ON ( lch.`content_id` = lc.`content_id` )\n\t\t\t{$joinSql} {$whereSql} {$orderSql}";
     $result = $this->mDb->query($query, $bindVars, $pListHash['max_records'], $pListHash['offset']);
     while ($aux = $result->fetchRow()) {
         $item = new TreasuryItem($aux['content_id']);
         $item->load();
         $ret[] = $item;
     }
     $query = "SELECT COUNT( trm.`item_content_id` )\n\t\t\tFROM `" . BIT_DB_PREFIX . "treasury_map` trm\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON ( lc.`content_id` = trm.`item_content_id` )\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content_types` lct ON ( lc.`content_type_guid` = lct.`content_type_guid` )\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "users_users` uu ON ( uu.`user_id` = lc.`user_id` )\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_content_hits` lch ON ( lch.`content_id` = lc.`content_id` )\n\t\t\t{$joinSql} {$whereSql}";
     $pListHash['cant'] = $this->mDb->getOne($query, $bindVars);
     LibertyContent::postGetList($pListHash);
     return count($this->mErrors) == 0 ? $ret : FALSE;
 }
Example #26
0
 /**
  * see if the documentation page exists, if not create it and return the appropriate content_id
  * 
  * @param array $pPackage 
  * @access public
  * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
  */
 function getDocumentionPage($pPackage = NULL)
 {
     global $gBitUser, $gBitSystem;
     $ret = FALSE;
     if (empty($pPackage) && $this->isValid()) {
         $pPackage = $this->mPackage;
     }
     if (!empty($pPackage)) {
         $page = ucfirst($pPackage) . "Package";
         require_once LIBERTY_PKG_PATH . "LibertyContent.php";
         $lc = new LibertyContent();
         $ret = $lc->pageExists($page);
         if ($gBitSystem->isPackageActive('wiki') && !$ret && $gBitUser->hasPermission('p_wiki_edit_page')) {
             require_once WIKI_PKG_PATH . "BitPage.php";
             $wp = new BitPage();
             $create = array('title' => $page, 'creator_user_id' => $gBitUser->mUserId, 'modifier_user_id' => $gBitUser->mUserId, 'edit' => "This page contains information about {$pPackage}");
             // get some rudimentary page details
             if ($wp->store($create)) {
                 $ret = $lc->pageExists($page);
             }
         }
     }
     return $ret;
 }
Example #27
0
 /**
  * verify - standard API method, with a twist. It will gobble up anything in $_FILES if available, unless an array of arrays is passed in to  $pParamHash['_files_override']
  *
  * @access private
  * @author Christian Fowler<*****@*****.**>
  * @param $pParamHash
  * @return FALSE if errors were present, TRUE meaning object is ready to store
  * @deprecated deprecated since version 2.1.0-beta
  */
 function verify(&$pParamHash)
 {
     //deprecated( "This method has been replaced by a method in LibertyMime. Please try to migrate your code." );
     global $gBitSystem, $gBitUser;
     // check to see if we have any files to upload
     if (isset($pParamHash['_files_override'])) {
         // we have been passed in a manually stuffed files attachment, such as a custom uploader would have done.
         // process this, and skip over $_FILES
         $uploads = $pParamHash['_files_override'];
     } elseif (!empty($_FILES)) {
         // we have some _FILES hanging around we will gobble up. This is inherently dagnerous chewing up a _FILES like this as
         // it can cause premature storing of a _FILE if you are trying to store multiple pieces of content at once.
         foreach ($_FILES as $key => $file) {
             if (!empty($file['name'])) {
                 $uploads[$key] = $file;
             }
         }
     }
     // don't check for p_liberty_attach_attachments permission on bitpermuser class so registration with avatar upload works
     if (strtolower(get_class($this)) == 'bitpermuser') {
         $pParamHash['no_perm_check'] = TRUE;
     }
     // check for the required permissions to upload a file to the liberty attachments area
     if (!empty($uploads) && empty($pParamHash['no_perm_check'])) {
         if (!$gBitUser->hasPermission('p_liberty_attach_attachments')) {
             $this->mErrors['permission'] = tra('You do not have permission to upload attachments.');
         }
     }
     if (!empty($pParamHash['attachment_id']) && !$this->verifyId($pParamHash['attachment_id'])) {
         $this->mErrors['file'] = tra('System Error: Non-numeric storage_id.');
     }
     if (empty($pParamHash['user_id'])) {
         // storage is always owned by the user that uploaded it!
         // er... or at least admin if somehow we have a NULL mUserId - anon uploads maybe?
         $pParamHash['user_id'] = @$this->verifyId($gBitUser->mUserId) ? $gBitUser->mUserId : ROOT_USER_ID;
     }
     if (empty($pParamHash['process_storage'])) {
         $pParamHash['process_storage'] = NULL;
     }
     if (empty($pParamHash['subdir'])) {
         $pParamHash['subdir'] = 'files';
     }
     if (!empty($uploads)) {
         foreach (array_keys($uploads) as $f) {
             $this->verifyAttachment($pParamHash, $uploads[$f], $f);
         }
     }
     // primary attachment. Allow 'none' to clear the primary.
     if (!@BitBase::verifyId($pParamHash['liberty_attachments']['primary']) && (empty($pParamHash['liberty_attachments']['primary']) || $pParamHash['liberty_attachments']['primary'] != 'none')) {
         $pParamHash['liberty_attachments']['primary'] = NULL;
     }
     // if we have an error we get them all by checking parent classes for additional errors
     if (count($this->mErrors) > 0) {
         parent::verify($pParamHash);
     }
     return count($this->mErrors) == 0;
 }
Example #28
0
 /**
  * Generate list of GEDCOM archives
  * $pListHash values used
  * @param offset Number of the first record to list
  * @param maxRecords Number of records to list
  * @param letter Filter surname list by letter selected
  */
 function listSurnames(&$pListHash)
 {
     LibertyContent::prepGetList($pListHash);
     $bindVars = array($this->mGEDCOMId);
     $selectSql = '';
     if (isset($pListHash['letter']) && $pListHash['letter'] != '') {
         $selectSql .= 'AND `n_surname` STARTING ? ';
         array_push($bindVars, $pListHash['letter']);
     }
     $query = "SELECT UPPER(`n_surname`), COUNT(UPPER(`n_surname`))\n\t\t\t\t\tFROM " . PHPGEDVIEW_DB_PREFIX . "name` WHERE `n_file` = ? AND `n_surname` NOT STARTING '@' {$selectSql}\n\t\t\t\t\tGROUP BY UPPER(`n_surname`)\n\t\t\t\t\tORDER BY 1";
     $query_cant = "SELECT DISTINCT UPPER(`n_surname`)\n\t\t\t\t\tFROM " . PHPGEDVIEW_DB_PREFIX . "name` WHERE `n_file` = ? AND `n_surname` NOT STARTING '@' {$selectSql}";
     $query_tot = "SELECT COUNT(`n_surname`)\n\t\t\t\t\tFROM " . PHPGEDVIEW_DB_PREFIX . "name` WHERE `n_file` = ? AND `n_surname` NOT STARTING '@' {$selectSql}";
     // If sort mode is versions then offset is 0, maxRecords is -1 (again) and sort_mode is nil
     // If sort mode is links then offset is 0, maxRecords is -1 (again) and sort_mode is nil
     // If sort mode is backlinks then offset is 0, maxRecords is -1 (again) and sort_mode is nil
     $ret = array();
     $this->mDb->StartTrans();
     $result = $this->mDb->query($query, $bindVars, $pListHash['max_records'], $pListHash['offset']);
     // total number of surnames
     $cant = $this->mDb->query($query_cant, $bindVars);
     // total number of individuals acorss selected surnames
     $tot = $this->mDb->getOne($query_tot, $bindVars);
     $this->mDb->CompleteTrans();
     $ind_total = 0;
     while ($res = $result->fetchRow()) {
         $aux = array();
         $aux = $res;
         $ind_total += $res['count'];
         $ret[] = $aux;
     }
     $pListHash['cant'] = $cant->NumRows();
     $pListHash['listInfo']['sub_total'] = $tot;
     LibertyContent::postGetList($pListHash);
     return $ret;
 }
Example #29
0
 /**
  * getList This function generates a list of records from the liberty_content database for use in a list page
  * 
  * @param array $pParamHash 
  * @access public
  * @return array List of sample data
  */
 function getList(&$pParamHash)
 {
     // this makes sure parameters used later on are set
     LibertyContent::prepGetList($pParamHash);
     $selectSql = $joinSql = $whereSql = '';
     $bindVars = array();
     array_push($bindVars, $this->mContentTypeGuid);
     $this->getServicesSql('content_list_sql_function', $selectSql, $joinSql, $whereSql, $bindVars);
     // this will set $find, $sort_mode, $max_records and $offset
     extract($pParamHash);
     if (is_array($find)) {
         // you can use an array of pages
         $whereSql .= " AND lc.`title` IN( " . implode(',', array_fill(0, count($find), '?')) . " )";
         $bindVars = array_merge($bindVars, $find);
     } elseif (is_string($find)) {
         // or a string
         $whereSql .= " AND UPPER( lc.`title` )like ? ";
         $bindVars[] = '%' . strtoupper($find) . '%';
     }
     $query = "\n\t\t\tSELECT sample.*, lc.`content_id`, lc.`title`, lc.`data` {$selectSql}\n\t\t\tFROM `" . BIT_DB_PREFIX . "sample_data` sample\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON( lc.`content_id` = sample.`content_id` ) {$joinSql}\n\t\t\tWHERE lc.`content_type_guid` = ? {$whereSql}\n\t\t\tORDER BY " . $this->mDb->convertSortmode($sort_mode);
     $query_cant = "\n\t\t\tSELECT COUNT(*)\n\t\t\tFROM `" . BIT_DB_PREFIX . "sample_data` sample\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON( lc.`content_id` = sample.`content_id` ) {$joinSql}\n\t\t\tWHERE lc.`content_type_guid` = ? {$whereSql}";
     $result = $this->mDb->query($query, $bindVars, $max_records, $offset);
     $ret = array();
     while ($res = $result->fetchRow()) {
         $ret[] = $res;
     }
     $pParamHash["cant"] = $this->mDb->getOne($query_cant, $bindVars);
     // add all pagination info to pParamHash
     LibertyContent::postGetList($pParamHash);
     return $ret;
 }
Example #30
0
 function getAvailableContentStatuses($pUserMinimum = -100, $pUserMaximum = 100)
 {
     global $gBitSystem;
     if ($gBitSystem->isFeatureActive('events_moderation')) {
         return LibertyContent::getAvailableContentStatuses(-100, 0);
     }
     return parent::getAvailableContentStatuses();
 }