コード例 #1
0
function get_contentgroups_data_where_perm($data, $perm)
{
    // returns an indexed array containing all fields speicfied in $data in an assoc array where user has permission $perm
    global $db, $config_vars, $userdata;
    $where = get_allowed_contentgroups_where($userdata['user_id'], $perm, 'id');
    $sql = "select {$data} from {$config_vars['table_prefix']}groups where {$where}";
    if (!($result = $db->sql_query($sql))) {
        error_report(SQL_ERROR, 'get_contentgroups_data_where_perm', __LINE__, __FILE__, $sql);
    }
    // generate catgroup array for each catgroup that is returned by the query
    return generate_array_from_row($row);
}
コード例 #2
0
 function get_surrounding_content($cat_id)
 {
     // Returns an Array of album_content objects of all content which is in the categorie with id $cat_id
     global $db, $config_vars, $userdata, $filetypes;
     // get auth where
     $auth_where = get_allowed_contentgroups_where($userdata['user_id'], "view", 'content.contentgroup_id');
     // get all content
     $sql = 'SELECT content.id,content.file,content_in_cat.place_in_cat FROM ' . $config_vars['table_prefix'] . "content as content," . $config_vars['table_prefix'] . "content_in_cat as content_in_cat\n\t\t\tWHERE ({$auth_where}) and \n\t\t\t\t(content.id = content_in_cat.content_id) and (content_in_cat.cat_id = {$cat_id})\n\t\t\tORDER BY content_in_cat.place_in_cat";
     if (!($result = $db->sql_query($sql))) {
         $error = new phreak_error(E_WARNING, SQL_ERROR, __LINE__, __FILE__, 'get_surrounding_content', $this->id, 0, 0, $sql);
         $error->commit();
         //error_report(SQL_ERROR, 'get_surrounding_content' , __LINE__, __FILE__,$sql);
     }
     $objarray['place'] = 1;
     $objarray['amount'] = $db->sql_affectedrows();
     while ($row = $db->sql_fetchrow($result)) {
         if ($row['id'] == $this->id) {
             $objarray['prev'] = get_content_from_row($lastrow);
             $objarray['next'] = get_content_from_row($db->sql_fetchrow($result));
             return $objarray;
         }
         $objarray['place']++;
         $lastrow = $row;
     }
 }