function set_cover_photo($pid, $cid, $myaccount = false) { global $db, $userquery, $cbphoto; if (!$this->collection_exists($cid)) { e(lang('collection_not_exists')); return false; } if (!$this->object_exists($pid)) { e(lang(sprintf('%s does not exist', $this->objType))); return false; } if (!$this->object_in_collection($pid, $cid)) { e(sprintf(lang("object_not_in_collect"), $this->objName)); return false; } if (!$this->is_collection_owner($cid) || userid() != $cbphoto->get_photo_owner($pid)) { e(lang('cant_perform_action_collect')); return false; } $fields = tbl_fields(array('p' => get_photo_fields(), 'c' => get_collection_fields())); $query = ' SELECT ' . $fields . ' FROM ' . tbl('collections') . ' as c'; $query .= " LEFT JOIN " . tbl('photos') . " as p ON c.collection_id = p.collection_id "; start_where(); add_where(" c.collection_id = '{$cid}' "); add_where(" p.photo_id = '{$pid}' "); if (get_where()) { $query .= ' WHERE ' . get_where(); } end_where(); $result = db_select($query); if ($myaccount) { if ($result['is_avatar'] == 'yes' || $result['is_avatar_collection'] == 'yes') { return false; } } $cover_photo = json_decode($result['cover_photo'], true); if ($pid == $cover_photo['photo_id']) { $update = true; } else { //Create array so we can reduce one query per collection YOSH !!! $result = $result[0]; $cover_photo['photo_id'] = $result['photo_id']; $cover_photo['photo_key'] = $result['photo_key']; $cover_photo['filename'] = $result['filename']; $cover_photo['ext'] = $result['ext']; $cover_photo['is_collection_cover'] = true; // This flag will help us make a query to get is_mature for cover photo while displaying $jecp = json_encode($cover_photo); $field = array('cover_photo' => $jecp); $update = db_update(tbl('collections'), $field, " collection_id = '" . $result['collection_id'] . "' "); } if ($update) { return $cover_photo; } else { return false; } }
function get_basic_user_details($uid) { $uid = mysql_clean($uid); $fields = get_user_fields(); $fields = tbl_fields($fields, 'users'); $query = " SELECT " . $fields . " FROM " . tbl('users'); $query .= " WHERE userid='" . $uid . "' "; $query .= " LIMIT 1"; $results = db_select($query); if ($results) { return $results[0]; } }
/** * function usedt to get all the details of a video from database * including conversion status and profile statuses. */ function get_video_conversion_status($file_name) { $fields_arr = array('v' => array('title', 'userid'), 'u' => array('username', 'first_name', 'last_name'), 'cq' => array('queue_name', 'queue_ext', 'queue_tmp_ext', 'file_directory', 'conversion', 'conversion_counts', 'status AS queue_status', 'active', 'messages', 'date_added', 'time_started', 'time_completed'), 'vp' => array('name', 'format', 'suffix', 'ext'), 'vf' => array('*')); $fields = tbl_fields($fields_arr); $query = " SELECT " . $fields; $query .= " FROM " . tbl('video') . ' AS v '; $query .= " LEFT JOIN " . tbl('users') . ' AS u '; $query .= " ON v.userid = u.userid "; $query .= " LEFT JOIN " . tbl('conversion_queue') . " AS cq "; $query .= " ON v.file_name = cq.queue_name "; $query .= " LEFT JOIN " . tbl('video_files') . " AS vf "; $query .= " ON v.file_name = vf.file_name "; $query .= " LEFT JOIN " . tbl('video_profiles') . " AS vp "; $query .= " ON vf.profile_id = vp.profile_id "; $query .= " WHERE v.file_name = '{$file_name}' "; $result = db_select($query); if ($result) { return $result; } else { return false; } }
/** * Function used to get videos * this function has all options * that you need to fetch videos * please see docs.clip-bucket.com for more details */ function get_videos($params) { global $db, $cb_columns; $limit = $params['limit']; $order = $params['order']; $cond = ""; $superCond = ""; if (!has_access('admin_access', TRUE)) { $superCond = " " . "video.status" . "='Successful' AND\r\n\t\t\t" . "video.active" . "='yes' AND " . "video.broadcast" . " !='unlisted' "; } else { if ($params['active']) { $cond .= " " . "video.active" . "='" . $params['active'] . "'"; } if ($params['status']) { if ($cond != '') { $cond .= " AND "; } $cond .= " " . "video.status" . "='" . $params['status'] . "'"; } if ($params['broadcast']) { if ($cond != '') { $cond .= " AND "; } $cond .= " " . "video.broadcast" . "='" . $params['broadcast'] . "'"; } } //Setting Category Condition $all = false; if (!is_array($params['category'])) { if (strtolower($params['category']) == 'all') { $all = true; } } if ($params['category'] && !$all) { if ($cond != '') { $cond .= ' AND '; } $cond .= " ("; if (!is_array($params['category'])) { $cats = explode(',', $params['category']); } else { $cats = $params['category']; } $count = 0; foreach ($cats as $cat_params) { $count++; if ($count > 1) { $cond .= " OR "; } $cond .= " " . "video.category" . " LIKE '%#{$cat_params}#%' "; } $cond .= ")"; } //date span if ($params['date_span']) { if ($cond != '') { $cond .= ' AND '; } if ($params['date_span_column']) { $column = $params['date_span_column']; } else { $column = 'date_added'; } $cond .= " " . cbsearch::date_margin($column, $params['date_span']); } //uid if ($params['user']) { if (!is_array($params['user'])) { if ($cond != '') { $cond .= ' AND '; } $cond .= " " . "video.userid" . "='" . $params['user'] . "'"; } else { if ($cond != '') { $cond .= ' AND ('; } $uQu = 0; foreach ($params['user'] as $user) { if ($uQu > 0) { $cond .= ' OR '; } $cond .= " " . "video.userid" . "='" . $user . "'"; $uQu++; } $cond .= " ) "; } } //non-uid to exclude user videos from related if ($params['nonuser']) { if ($cond != '') { $cond .= ' AND '; } $cond .= " " . "video.userid" . " <> '" . $params['nonuser'] . "' "; } //padding videos in mass_embed pllugin if ($params['mass_embed_status']) { if ($cond != '') { $cond .= ' AND '; } $cond .= " " . "video.mass_embed_status" . " = '" . $params['mass_embed_status'] . "' "; } $tag_n_title = ''; //Tags if ($params['tags']) { //checking for commas ;) $tags = explode(",", $params['tags']); if (count($tags) > 0) { if ($tag_n_title != '') { $tag_n_title .= ' OR '; } $total = count($tags); $loop = 1; foreach ($tags as $tag) { $tag_n_title .= " " . 'video.tags' . " LIKE '%" . $tag . "%'"; if ($loop < $total) { $tag_n_title .= " OR "; } $loop++; } } else { if ($tag_n_title != '') { $tag_n_title .= ' OR '; } $tag_n_title .= " " . 'video.tags' . " LIKE '%" . $params['tags'] . "%'"; } } //TITLE if ($params['title']) { if ($tag_n_title != '') { $tag_n_title .= ' OR '; } $tag_n_title .= " " . 'video.title' . " LIKE '%" . $params['title'] . "%'"; } if ($tag_n_title) { if ($cond != '') { $cond .= ' AND '; } $cond .= " ({$tag_n_title}) "; } //FEATURED if ($params['featured']) { //exit($params['featured']); if ($cond != '') { $cond .= ' AND '; } $cond .= " " . "video.featured" . " = '" . $params['featured'] . "' "; } //VIDEO ID if ($params['videoid']) { if ($cond != '') { $cond .= ' AND '; } $cond .= " " . "video.videoid" . " = '" . $params['videoid'] . "' "; } //VIDEO ID if ($params['videoids']) { if (is_array($params['videoids'])) { if ($cond != '') { $cond .= ' AND '; } $cond .= ' ( '; $curVid = 0; foreach ($params['videoids'] as $vid) { if (is_numeric($vid)) { if ($curVid > 0) { $cond .= " OR "; } $cond .= " " . "video.videoid" . " = '" . $vid . "' "; } $curVid++; } $cond .= ' ) '; } } //VIDEO KEY if ($params['videokey']) { if (!is_array($params['videokey'])) { if ($cond != '') { $cond .= ' AND '; } $cond .= " " . tbl("video.videokey") . " = '" . $params['videokey'] . "' "; } else { if ($cond != '') { $cond .= ' AND ('; } $vkeyQue = 0; foreach ($params['videokey'] as $videokey) { if ($vkeyQue > 0) { $cond .= ' OR '; } $cond .= " " . tbl("video.videokey") . " = '" . $videokey . "' "; $vkeyQue++; } $cond .= " ) "; } } //Exclude Vids if ($params['exclude']) { if (!is_array($params['exclude'])) { if ($cond != '') { $cond .= ' AND '; } $cond .= " " . 'video.videoid' . " <> '" . $params['exclude'] . "' "; } else { foreach ($params['exclude'] as $exclude) { if ($cond != '') { $cond .= ' AND '; } $cond .= " " . 'video.videoid' . " <> '" . $exclude . "' "; } } } //Duration if ($params['duration']) { $duration_op = $params['duration_op']; if (!$duration_op) { $duration_op = "="; } if ($cond != '') { $cond .= ' AND '; } $cond .= " " . 'video.duration' . " " . $duration_op . " '" . $params['duration'] . "' "; } //Filename if ($params['filename']) { if (!is_array($params['filename'])) { if ($cond != '') { $cond .= ' AND '; } $cond .= " " . 'video.file_name' . " <> '" . $params['filename'] . "' "; } else { if ($cond != '') { $cond .= ' AND ('; } $fileNameQue = 0; foreach ($params['filename'] as $filename) { if ($fileNameQue > 0) { $cond .= ' OR '; } $cond .= " " . "video.file_name" . " = '" . $filename . "' "; $fileNameQue++; } $cond .= " ) "; } } if ($params['cond']) { if ($params['cond_and']) { if ($cond != '') { $cond .= ' AND '; } } $cond .= " " . $params['cond']; } $functions = cb_get_functions('get_videos'); if ($functions) { foreach ($functions as $func) { $array = array('params' => $params, 'cond' => $cond); if (function_exists($func['func'])) { $returned = $func['func']($array); if ($returned) { $cond = $returned; } } } } $fields = array('video' => get_video_fields(), 'users' => $cb_columns->object('users')->temp_change('featured', 'user_featured')->get_columns()); $fields = tbl_fields($fields); if (!$params['count_only'] && !$params['show_related']) { $query = "SELECT {$fields} FROM " . cb_sql_table('video'); $query .= " LEFT JOIN " . cb_sql_table('users') . " ON video.userid = users.userid"; if (!empty($superCond)) { if ($cond !== "") { $cond .= " AND " . $superCond; } else { $cond .= $superCond; } } if ($cond) { $query .= " WHERE " . $cond; } $query .= $order ? " ORDER BY " . $order : false; $query .= $limit ? " LIMIT " . $limit : false; #pr( $query, true ); $result = select($query); #if(!empty($cond)) # $cond .= " AND "; #$result = $db->select(tbl('video,users'),tbl('video.*,users.userid,users.username'),$cond." ".tbl("video.userid")." = ".tbl("users.userid"),$limit,$order); //echo $db->db_query; } global $cbsearch; if ($params['show_related']) { $cond = ""; if ($superCond) { $cond = $superCond . " AND "; } $cond .= "MATCH(" . "video.title,video.tags" . ")\r\n\t\t\tAGAINST ('" . $params['title'] . "' IN BOOLEAN MODE) "; if ($params['exclude']) { if ($cond != '') { $cond .= ' AND '; } $cond .= " " . 'video.videoid' . " <> '" . $params['exclude'] . "' "; } $query = " SELECT " . $fields . " FROM " . cb_sql_table('video'); $query .= " LEFT JOIN " . cb_sql_table('users'); $query .= " ON video.userid = users.userid "; if ($cond) { $query .= " WHERE " . $cond; } $query .= $order ? " ORDER BY " . $order : false; $query .= $limit ? " LIMIT " . $limit : false; $result = select($query); #$result = $db->select(tbl('video,users'),tbl('video.*,users.userid,users.username'), #$cond." AND ".tbl("video.userid")." = ".tbl("users.userid"),$limit,$order); if ($db->num_rows == 0) { $cond = ""; if ($superCond) { $cond = $superCond . " AND "; } //Try Finding videos via tags $cond .= "MATCH(" . "video.title,video.tags" . ")\r\n\t\t\t\tAGAINST ('" . $params['tags'] . "' IN BOOLEAN MODE) "; if ($params['exclude']) { if ($cond != '') { $cond .= ' AND '; } $cond .= " " . 'video.videoid' . " <> '" . $params['exclude'] . "' "; } $query = " SELECT " . $fields . " FROM " . cb_sql_table('video'); $query .= " LEFT JOIN " . cb_sql_table('users'); $query .= " ON video.userid = users.userid "; if ($cond) { $query .= " WHERE " . $cond; } $query .= $order ? " ORDER BY " . $order : false; $query .= $limit ? " LIMIT " . $limit : false; $result = select($query); #$result = $db->select(tbl('video,users'),tbl('video.*,users.userid,users.username'), #$cond." AND ".tbl("video.userid")." = ".tbl("users.userid"),$limit,$order); } assign($params['assign'], $result); } if ($params['pr']) { pr($result, true); } if ($params['count_only']) { return $result = $db->count(cb_sql_table('video'), 'videoid', $cond); } if ($params['assign']) { assign($params['assign'], apply_filters($result, 'get_video')); } else { return apply_filters($result, 'get_video'); } }
/** * myaccount dashboard, recent video comments widget * * @global object $userquery * @param array $widget * @return string */ function account_dashboard_recent_video_comments($widget) { global $userquery; if (!userid()) { return false; } $configs = get_dashboard_widget_configs($widget['id']); $no_of_comments = $configs['number_of_comments'] ? $configs['number_of_comments'] : 15; $no_of_days = $configs['number_of_days'] ? $configs['number_of_days'] : 8; if ($userquery->udetails['total_videos'] > 0) { $fields = array('video' => array('videoid', 'videokey', 'title', 'description', 'views'), 'users' => get_user_fields(), 'comments' => array('comment_id', 'type', 'comment', 'userid', 'type_id', 'type_owner_id', 'date_added')); $fields = tbl_fields($fields); $query = "SELECT {$fields} FROM " . tbl('comments') . " AS comments "; $query .= "LEFT JOIN " . tbl('video') . " AS video ON " . 'comments.type_id' . " = " . 'video.videoid' . " "; $query .= "LEFT JOIN " . tbl('users') . " AS users ON " . 'comments.userid' . " = " . 'users.userid' . " "; start_where(); add_where(" " . 'comments.type_owner_id' . " = " . userid()); add_where(" " . 'comments.type' . " = 'v' "); add_where(" " . 'comments.userid' . " <> " . userid()); add_where(" " . 'comments.date_added' . " BETWEEN SYSDATE() - INTERVAL {$no_of_days} DAY AND SYSDATE() "); if (get_where()) { $query .= " WHERE " . get_where(); } end_where(); $query .= " ORDER BY " . 'comments.date_added' . " DESC LIMIT {$no_of_comments}"; $comments = db_select($query); } // Comment Template $params['file'] = 'blocks/account/dashboard_comments.html'; $params['widget'] = $widget; $params['comments'] = $comments; $params['configs'] = $configs; return fetch_template_file($params); }
/** * Get Photos */ function get_photos($p) { global $db, $cb_columns; $tables = "photos,users"; $order = $p['order']; $limit = $p['limit']; $cond = ""; if (!has_access('admin_access', TRUE)) { $cond = " " . 'photos.broadcast' . " = 'public' AND " . 'photos.active' . " = 'yes'"; } else { if ($p['active']) { $cond .= " " . 'photos.active' . " = '" . $p['active'] . "'"; } if ($p['broadcast']) { if ($cond != "") { $cond .= " AND "; } $cond .= " " . 'photos.broadcast' . " = '" . $p['broadcast'] . "'"; } } if ($p['pid']) { if ($cond != "") { $cond .= " AND "; } $cond .= $this->constructMultipleQuery(array("ids" => $p['pid'], "sign" => "=", "operator" => "OR")); } if ($p['key']) { if ($cond != "") { $cond .= " AND "; } $cond .= " " . 'photos.photo_key' . " = '" . $p['key'] . "'"; } if ($p['filename']) { if ($cond != "") { $cond .= " AND "; } $cond .= " " . 'photos.filename' . " = '" . $p['filename'] . "'"; } if ($p['extension']) { foreach ($this->exts as $ext) { if (in_array($ext, $this->exts)) { if ($cond != "") { $cond .= " AND "; } $cond .= " " . 'photos.ext' . " = '" . $p['extension'] . "'"; } } } if ($p['date_span']) { if ($cond != "") { $cond .= " AND "; } $cond .= " " . cbsearch::date_margin("photos.date_added", $p['date_span']); } if ($p['featured']) { if ($cond != "") { $cond .= " AND "; } $cond .= " " . 'photos.featured' . " = '" . $p['featured'] . "'"; } if ($p['user']) { if ($cond != "") { $cond .= " AND "; } $cond .= $this->constructMultipleQuery(array("ids" => $p['user'], "sign" => "=", "operator" => "AND", "column" => "userid")); } if ($p['exclude']) { if ($cond != "") { $cond .= " AND "; } $cond .= $this->constructMultipleQuery(array("ids" => $p['exclude'], "sign" => "<>")); } $title_tag = ''; if ($p['title']) { $title_tag = " " . 'photos.photo_title' . " LIKE '%" . $p['title'] . "%'"; } if ($p['tags']) { $tags = explode(",", $p['tags']); if (count($tags) > 0) { if ($title_tag != '') { $title_tag .= " OR "; } $total = count($tags); $loop = 1; foreach ($tags as $tag) { $title_tag .= " " . 'photos.photo_tags' . " LIKE '%{$tag}%'"; if ($loop < $total) { $title_tag .= " OR "; } $loop++; } } else { if ($title_tag != '') { $title_tag .= " OR "; } $title_tag .= " " . 'photos.photo_tags' . " LIKE '%" . $p['tags'] . "%'"; } } if ($title_tag != "") { if ($cond != '') { $cond .= " AND "; } $cond .= " ({$title_tag}) "; } if ($p['ex_user']) { if ($cond != "") { $cond .= " AND "; } $cond .= $this->constructMultipleQuery(array("ids" => $p['ex_user'], "sign" => "<>", "operator" => "AND", "column" => "userid")); } if ($p['extra_cond']) { if ($cond != "") { $cond .= " AND "; } $cond .= $p['extra_cond']; } if ($p['get_orphans']) { $p['collection'] = (string) "0"; } if ($p['collection'] || $p['get_orphans']) { if ($cond != "") { $cond .= " AND "; } $cond .= $this->constructMultipleQuery(array("ids" => $p['collection'], "sign" => "=", "operator" => "OR", "column" => "collection_id")); } else { if ($cond != "") { $cond .= " AND "; } $cond .= " " . 'photos.collection_id' . " <> '0'"; } $fields = array('photos' => get_photo_fields(), 'users' => get_user_fields(), 'collections' => array('collection_name', 'type', 'category', 'views as collection_views', 'date_added as collection_added')); $string = tbl_fields($fields); $main_query = "SELECT {$string} FROM " . table('photos'); $main_query .= " LEFT JOIN " . table('collections') . " ON photos.collection_id = collections.collection_id"; $main_query .= " LEFT JOIN " . table('users') . " ON collections.userid = users.userid"; $order = $order ? " ORDER BY " . $order : false; $limit = $limit ? " LIMIT " . $limit : false; if (!$p['count_only'] && !$p['show_related']) { $query = $main_query; if ($cond) { $query .= " WHERE " . $cond; } $query .= $order; $query .= $limit; $result = select($query); } if ($p['show_related']) { $query = $main_query; $cond = "MATCH(" . 'photos.photo_title,photos.photo_tags' . ")"; $cond .= " AGAINST ('" . cbsearch::set_the_key($p['title']) . "' IN BOOLEAN MODE)"; if ($p['exclude']) { if ($cond != "") { $cond .= " AND "; } $cond .= $this->constructMultipleQuery(array("ids" => $p['exclude'], "sign" => "<>")); } if ($p['collection']) { if ($cond != "") { $cond .= " AND "; } $cond .= $this->constructMultipleQuery(array("ids" => $p['collection'], "sign" => "<>", "column" => "collection_id")); } if ($p['extra_cond']) { if ($cond != "") { $cond .= " AND "; } $cond .= $p['extra_cond']; } $where = " WHERE " . $cond . " AND photos.collection_id <> 0"; $query .= $where; $query .= $order; $query .= $limit; $result = select($query); // We found nothing from TITLE of Photos, let's try TAGS if ($db->num_rows == 0) { $query = $main_query; $tags = cbsearch::set_the_key($p['tags']); $tags = str_replace('+', '', $tags); $cond = "MATCH(" . 'photos.photo_title,photos.photo_tags' . ")"; $cond .= " AGAINST ('" . $tags . "' IN BOOLEAN MODE)"; if ($p['exclude']) { if ($cond != "") { $cond .= " AND "; } $cond .= $this->constructMultipleQuery(array("ids" => $p['exclude'], "sign" => "<>")); } if ($p['collection']) { if ($cond != "") { $cond .= " AND "; } $cond .= $this->constructMultipleQuery(array("ids" => $p['collection'], "sign" => "<>", "column" => "collection_id")); } if ($p['extra_cond']) { if ($cond != "") { $cond .= " AND "; } $cond .= $p['extra_cond']; } $where = " WHERE " . $cond . " AND photos.collection_id <> 0"; $query .= $where; $query .= $order; $query .= $limit; $result = select($query); } } if ($p['count_only']) { if ($p['extra_cond']) { if ($cond != "") { $cond .= " AND "; } $cond .= $p['extra_cond']; } $result = $db->count(table("photos"), "photo_id", $cond); } ##pr( $query, true ); if ($p['assign']) { assign($p['assign'], $result); } else { return $result; } }
/** * get request info from table * * @param INT $rid Request ID * @return ARRAY $req Request Details Array */ function get_request($rid) { $rid = mysql_clean($rid); $fields_arr = array('userid', 'friend_id', 'message', 'seen', 'ignored', 'time_added'); $fields = tbl_fields($fields_arr); $query = "SELECT " . $fields . " FROM " . tbl('friend_requests'); $query .= " WHERE req_id='" . $rid . "' LIMIT 1"; $results = db_select($query); if ($results) { return $results[0]; } else { return false; } }
/** * Get thread along with all the details.. * * @param INT $thread_id * @param ARRAY $thread */ function get_thread($tid) { $tid = mysql_clean($tid); $fields_array = array('t' => array('thread_id', 'total_recipients', 'total_messages', 'date_added', 'time_added', 'last_message_date', 'main_recipients', 'last_message', 'subject'), 'r' => array('recipient_id')); $the_fields = tbl_fields($fields_array); $thread_id = $tid; $query = " SELECT {$the_fields} FROM " . tbl('recipients') . " as r"; $query .= " INNER JOIN " . tbl('threads') . ' as t ON '; $query .= ' t.thread_id=r.thread_id '; start_where(); if ($o['userid']) { add_where("r.userid='" . $o['userid'] . "'"); } elseif (userid()) { add_where("r.userid='" . userid() . "'"); } else { return false; } add_where("r.thread_id='" . $tid . "'"); if (get_where()) { $query .= " WHERE " . get_where(); } end_where(); $query .= " LIMIT 1 "; $results = db_select($query); if ($results) { return $results[0]; } else { return false; } }
/** * function used to get feed object * * @param INT feed_id * @return ARRAY object details */ function get_feed_object($fid) { $fields_arr = array('f' => array('object_id', 'object_type'), 'o' => array('content AS object')); $fields = tbl_fields($fields_arr); $query = "SELECT {$fields} FROM "; $query .= tbl('feeds') . " AS f "; $query .= " LEFT JOIN " . tbl('objects_cache') . " AS o "; $query .= " ON f.object_cached_id=o.object_id "; $query .= " WHERE f.feed_id='{$fid}' "; $query .= " LIMIT 1"; $results = db_select($query); if ($results) { $object = $results[0]; if ($object['object']) { $object['object'] = json_decode($object['object'], true); } return $object; } else { return false; } }
/** * Gets subscribed content from subscriptions_content table * of provided userid. * * @author Fawaz Tahir <*****@*****.**> * @global int $cb_subscriptions_content_limit * @param type $userid * @return boolean */ function get_user_subscriptions_content($userid = null) { global $cb_subscriptions_content_limit; if (is_null($userid)) { $userid = userid(); } if (!$userid) { return false; } $fields = tbl_fields(array('subscriptions' => array('subscription_id', 'userid as subscriber_id', 'subscribed_to', 'subscribed_content'), 'subscriptions_content' => get_subscription_content_fields(), 'users' => get_user_fields(), 'objects_cache' => array('content', 'last_updated'))); $query = "SELECT " . $fields . " FROM " . cb_sql_table('subscriptions_content'); $query .= " LEFT JOIN " . cb_sql_table('subscriptions') . " ON subscriptions_content.subscription_id = subscriptions.subscription_id"; $query .= " LEFT JOIN " . cb_sql_table('objects_cache') . " ON subscriptions_content.content_cache_id = objects_cache.object_id "; $query .= " LEFT JOIN " . cb_sql_table('users') . " ON subscriptions.userid = users.userid "; $subscriptions = get_user_subscriptions(); $subs_query = build_user_subscriptions_query_string($subscriptions); start_where(); add_where(" subscriptions.userid = '" . $userid . "' "); add_where(" subscriptions_content.is_content_hidden = 'no' "); if ($subs_query) { add_where($subs_query); } $query .= " WHERE " . get_where(); end_where(); $query .= " ORDER BY subscriptions_content.date_added DESC"; $query .= " LIMIT " . $cb_subscriptions_content_limit; $results = db_select($query); if ($results) { return $results; } else { return false; } }
/** * Function used to get group admins * * @param $gid */ function get_group_admins($gid) { global $db; $gid = mysql_clean($gid); $app_query = ""; $app_query = " AND " . tbl($this->gp_mem_tbl) . ".active='{$approved}'"; //List of fields we need from a user table $user_fields = get_user_fields(); $user_fields = apply_filters($user_fields, 'get_group_members'); $fields_arr = array('users' => $user_fields, 'members' => array('is_admin', 'ban', 'active')); $fields = tbl_fields($fields_arr); $query = " SELECT " . $fields . " FROM " . tbl('group_members') . " AS members "; $query .= " LEFT JOIN " . tbl('users') . " AS users ON "; $query .= " users.userid = members.userid "; $query .= " WHERE members.group_id='{$gid}' AND members.is_admin='yes' "; $result = db_select($query); if ($db->num_rows > 0) { return $result; } else { return false; } }
/** * Function used to get users */ function get_users($params = NULL, $force_admin = FALSE) { global $db; $limit = $params['limit']; $order = $params['order']; $cond = ""; if (!has_access('admin_access', TRUE) && !$force_admin) { $cond .= " \tusers.usr_status='Ok' AND users.ban_status ='no' "; } else { if ($params['ban']) { $cond .= " users.ban_status ='" . $params['ban'] . "'"; } if ($params['status']) { if ($cond != '') { $cond .= " AND "; } $cond .= " \tusers.usr_status='" . $params['status'] . "'"; } } //Setting Category Condition if (!is_array($params['category'])) { $is_all = strtolower($params['category']); } if ($params['category'] && $is_all != 'all') { if ($cond != '') { $cond .= ' AND '; } $cond .= " ("; if (!is_array($params['category'])) { $cats = explode(',', $params['category']); } else { $cats = $params['category']; } $count = 0; foreach ($cats as $cat_params) { $count++; if ($count > 1) { $cond .= " OR "; } $cond .= " users.category LIKE '%{$cat_params}%' "; } $cond .= ")"; } //date span if ($params['date_span']) { if ($cond != '') { $cond .= ' AND '; } $cond .= " " . cbsearch::date_margin("users.doj", $params['date_span']); } /*//uid if($params['user']) { if($cond!='') $cond .= ' AND '; $cond .= " userid='".$params['user']."'"; } $tag_n_title=''; //Tags if($params['tags']) { //checking for commas ;) $tags = explode(",",$params['tags']); if(count($tags)>0) { if($tag_n_title!='') $tag_n_title .= ' OR '; $total = count($tags); $loop = 1; foreach($tags as $tag) { $tag_n_title .= " tags LIKE '%".$tag."%'"; if($loop<$total) $tag_n_title .= " OR "; $loop++; } }else { if($tag_n_title!='') $tag_n_title .= ' OR '; $tag_n_title .= " tags LIKE '%".$params['tags']."%'"; } } //TITLE if($params['title']) { if($tag_n_title!='') $tag_n_title .= ' OR '; $tag_n_title .= " title LIKE '%".$params['tags']."%'"; } if($tag_n_title) { if($cond!='') $cond .= ' AND '; $cond .= " ($tag_n_title) "; }*/ //FEATURED if ($params['featured']) { if ($cond != '') { $cond .= ' AND '; } $cond .= " users.featured = '" . $params['featured'] . "' "; } //Email if ($params['username']) { if ($cond != '') { $cond .= ' AND '; } $cond .= " users.username = '******'username'] . "' "; } //Email if ($params['email']) { if ($cond != '') { $cond .= ' AND '; } $cond .= " users.email = '" . $params['email'] . "' "; } //Exclude Users if ($params['exclude']) { if ($cond != '') { $cond .= ' AND '; } $cond .= " users.userid <> '" . $params['exclude'] . "' "; } //Getting specific User if ($params['userid']) { if ($cond != '') { $cond .= ' AND '; } $cond .= " users.userid = '" . $params['userid'] . "' "; } //Sex if ($params['gender']) { if ($cond != '') { $cond .= ' AND '; } $cond .= " users.sex = '" . $params['gender'] . "' "; } //Level if ($params['level']) { if ($cond != '') { $cond .= ' AND '; } $cond .= " users.level = '" . $params['level'] . "' "; } if ($params['cond']) { if ($cond != '') { $cond .= ' AND '; } $cond .= " " . $params['cond'] . " "; } if (!$params['count_only']) { $fields = array('users' => get_user_fields(), 'profile' => array('rating', 'rated_by', 'voters', 'first_name', 'last_name')); $fields['users'][] = 'last_active'; $query = " SELECT " . tbl_fields($fields) . " FROM " . tbl('users') . " AS users "; $query .= " LEFT JOIN " . table('user_profile', 'profile ') . " ON users.userid = profile.userid "; if ($cond) { $query .= " WHERE " . $cond; } if ($order) { $query .= " ORDER BY " . $order; } if ($limit) { $query .= " LIMIT " . $limit; } //$result = $db->select(tbl('users'),'*',$cond,$limit,$order); $result = select($query); } if ($params['count_only']) { //$cond= substr($cond,8); $result = $db->count(tbl('users') . " AS users ", 'userid', $cond); //echo $cond; //return $result; } if ($params['assign']) { assign($params['assign'], $result); } else { return $result; } }