2009-08-25 12:16:42 +00:00
< ? php
2009-11-16 11:55:31 +00:00
/**
2009-12-21 21:11:54 +00:00
* @ Author : Arslan Hassan , Fawaz Tahir
* @ Software : ClipBucket , Community Bucket
2009-11-16 11:55:31 +00:00
* @ License : CBLA
2009-12-21 21:11:54 +00:00
* @ Since : 15 December 2009
2009-11-16 11:55:31 +00:00
*/
2009-12-29 11:28:48 +00:00
define ( " ALLOWED_GROUP_CATEGORIES " , " 3 " );
2009-12-21 21:11:54 +00:00
class CBGroups extends CBCategory
{
var $gp_thumb_width = '140' ;
var $gp_thumb_height = '140' ;
var $gp_small_thumb_width = '60' ;
var $gp_small_thumb_height = '60' ;
2009-11-16 11:55:31 +00:00
var $gp_tbl = '' ;
2009-12-21 21:11:54 +00:00
var $custom_group_fields = array ();
var $actions = '' ;
2010-01-05 09:47:10 +00:00
var $group_manager_funcs = array ();
2009-12-21 21:11:54 +00:00
2009-11-16 11:55:31 +00:00
/**
* Constructor function to set values of tables
*/
2010-01-06 11:59:41 +00:00
function CBGroups ()
{
2009-11-16 11:55:31 +00:00
$this -> cat_tbl = 'group_categories' ;
$this -> gp_tbl = 'groups' ;
2009-12-21 21:11:54 +00:00
$this -> gp_mem_tbl = 'group_members' ;
//We will using CB Commenting system as posts
//$this->gp_post_tbl = 'group_posts';
$this -> gp_topic_tbl = 'group_topics' ;
$this -> gp_invite_tbl = 'group_invitations' ;
$this -> gp_vdo_tbl = 'group_videos' ;
2010-01-06 11:59:41 +00:00
//Adding Actions such Report, share,fav etc
2009-12-21 21:11:54 +00:00
$this -> action = new cbactions ();
2010-01-06 11:59:41 +00:00
$this -> action -> type = 'g' ;
$this -> action -> name = 'group' ;
2009-12-21 21:11:54 +00:00
$this -> action -> obj_class = 'cbgroup' ;
2010-01-06 11:59:41 +00:00
$this -> action -> check_func = 'group_exists' ;
$this -> action -> type_tbl = $this -> gp_tbl ;
$this -> action -> type_id_field = 'group_id' ;
2009-12-21 21:11:54 +00:00
2009-11-16 11:55:31 +00:00
}
2009-12-21 21:11:54 +00:00
2009-11-16 11:55:31 +00:00
/**
* Function used to check if the provided URL is taken or not
* @ param = $url { URL of group provided by user }
*/
2009-12-21 21:11:54 +00:00
function group_url_exists ( $url ) {
2009-11-16 11:55:31 +00:00
global $db ;
2010-02-06 11:29:50 +00:00
$result = $db -> count ( tbl ( $this -> gp_tbl ), " * " , " group_url=' $url ' " );
2009-12-21 21:11:54 +00:00
if ( $result [ 0 ] > 0 )
return true ;
else
return false ;
2009-11-16 11:55:31 +00:00
}
/**
2009-12-21 21:11:54 +00:00
* Function used to get group details
* @ param $ID { groupid }
2009-11-16 11:55:31 +00:00
*/
2009-12-21 21:11:54 +00:00
function get_group ( $id )
{
2009-11-16 11:55:31 +00:00
global $db ;
2010-02-06 11:29:50 +00:00
$gp_details = $db -> select ( tbl ( $this -> gp_tbl ), " * " , " group_id=' $id ' " );
2009-12-21 21:11:54 +00:00
if ( $db -> num_rows > 0 ) {
return $gp_details [ 0 ];
} else {
return false ;
}
2009-11-16 11:55:31 +00:00
}
2009-12-21 21:11:54 +00:00
function get_group_details ( $id ){ return $this -> get_group ( $id ); }
function get_details ( $id ){ return $this -> get_group ( $id ); }
2009-11-16 11:55:31 +00:00
/**
2009-12-21 21:11:54 +00:00
* Funtion used to get gorup details
* @ param , $URL { group url }
2009-11-16 11:55:31 +00:00
*/
2009-12-21 21:11:54 +00:00
function get_group_with_url ( $url )
{
2009-11-16 11:55:31 +00:00
global $db ;
2010-02-06 11:29:50 +00:00
$gp_details = $db -> select ( tbl ( $this -> gp_tbl ), " * " , " group_url=' $url ' " );
2009-12-21 21:11:54 +00:00
if ( $db -> num_rows > 0 ) {
return $gp_details [ 0 ];
} else {
return false ;
}
2009-11-16 11:55:31 +00:00
}
2009-12-21 21:11:54 +00:00
function get_group_details_with_url ( $id ){ return $this -> get_group_with_url ( $id ); }
function get_details_with_url ( $id ){ return $this -> get_group_with_url ( $id ); }
function group_details_url ( $id ){ return $this -> get_group_with_url ( $id ); }
2009-11-16 11:55:31 +00:00
2009-12-21 21:11:54 +00:00
2009-11-16 11:55:31 +00:00
/**
* Function used to make user a member of group
* @ param = $userid { ID of user who is going to Join Group }
* @ param = $gpid { ID of group which is being joined }
*/
2009-12-21 21:11:54 +00:00
function join_group ( $gpid , $userid ) {
2009-11-16 11:55:31 +00:00
global $db ;
2009-12-21 21:11:54 +00:00
//Getting group details
$group = $this -> get_group_details ( $gpid );
if ( ! $group )
e ( " Group does not exist " );
elseif ( ! $this -> is_joinable ( $group , $userid , TRUE ))
return false ;
elseif ( ! $userid )
e ( lang ( 'group_join_login_err' ));
else
{
if ( $group [ 'group_privacy' ] == 1 )
$active = 'no' ;
else
$active = 'yes' ;
2010-02-06 11:29:50 +00:00
$db -> insert ( tbl ( $this -> gp_mem_tbl ),
2009-12-21 21:11:54 +00:00
array ( " group_id " , " userid " , " date_added " , " active " ),
array ( $gpid , $userid , now (), $active ));
2009-08-25 12:16:42 +00:00
2009-11-16 11:55:31 +00:00
//Count total members
$total_members = $this -> total_members ( $gpid );
//Update Stats
2010-02-06 11:29:50 +00:00
$db -> update ( tbl ( $this -> gp_tbl ),
2009-11-16 11:55:31 +00:00
array ( " total_members " ),
array ( $total_members ),
" group_id=' $gpid ' " );
e ( lang ( 'You have successfully joined group.' ), 'm' );
2009-08-25 12:16:42 +00:00
}
2009-11-16 11:55:31 +00:00
}
2009-12-21 21:11:54 +00:00
2009-11-16 11:55:31 +00:00
/**
2009-12-21 21:11:54 +00:00
* Creating Group Required Fields
2009-11-16 11:55:31 +00:00
*/
2009-12-21 21:11:54 +00:00
function load_required_fields ( $default = NULL , $is_update = FALSE )
{
if ( $default == NULL )
$default = $_POST ;
2009-11-16 11:55:31 +00:00
2009-12-21 21:11:54 +00:00
$gptitle = $default [ 'group_name' ];
$gpdescription = $default [ 'group_description' ];
if ( is_array ( $default [ 'category' ]))
$cat_array = array ( $default [ 'category' ]);
else
{
preg_match_all ( '/#([0-9]+)#/' , $default [ 'category' ], $m );
$cat_array = array ( $m [ 1 ]);
2009-08-25 12:16:42 +00:00
}
2009-12-21 21:11:54 +00:00
$tags = $default [ 'group_tags' ];
$gpurl = $default [ 'group_url' ];
if ( ! $is_update )
$url_form = array (
'title' => lang ( 'grp_url_title' ),
'type' => 'textfield' ,
'name' => 'group_url' ,
'id' => 'group_url' ,
'value' => cleanForm ( $gpurl ),
'hint_1' => '' ,
'hint_2' => lang ( 'grp_url_msg' ),
'db_field' => 'group_url' ,
'required' => 'yes' ,
'invalid_err' => lang ( 'grp_url_error' ),
'syntax_type' => 'field_text' ,
'function_error_msg' => lang ( 'user_contains_disallow_err' ),
'db_value_check_func' => 'group_url_exists' ,
'db_value_exists' => false ,
'db_value_err' => lang ( 'grp_url_error2' )
);
else
$url_form = array (
'title' => lang ( 'grp_url_title' ),
'type' => 'textfield' ,
'name' => 'group_url' ,
'id' => 'group_url' ,
'value' => cleanForm ( $gpurl ),
'hint_1' => '' ,
'hint_2' => lang ( 'grp_url_msg' ),
'db_field' => 'group_url' ,
'required' => 'yes' ,
'invalid_err' => lang ( 'grp_url_error' ),
'syntax_type' => 'field_text' ,
'function_error_msg' => lang ( 'user_contains_disallow_err' ),
);
$fields = array
(
'name' => array (
'title' => lang ( 'grp_name_title' ),
'type' => " textfield " ,
'name' => " group_name " ,
'id' => " group_name " ,
'value' => $gptitle ,
'db_field' => 'group_name' ,
'required' => 'yes' ,
'invalid_err' => lang ( 'grp_name_error' ),
),
'tags' => array (
'title' => lang ( 'tag_title' ),
'type' => 'textfield' ,
'name' => 'group_tags' ,
'id' => 'group_tags' ,
'value' => cleanForm ( genTags ( $tags )),
'hint_1' => '' ,
'hint_2' => lang ( 'grp_tags_msg1' ),
'db_field' => 'group_tags' ,
'required' => 'yes' ,
'invalid_err' => lang ( 'grp_tags_error' ),
'validate_function' => 'genTags'
),
'desc' => array (
'title' => lang ( 'vdo_desc' ),
'type' => 'textarea' ,
'name' => 'group_description' ,
'id' => 'group_description' ,
'value' => cleanForm ( $gpdescription ),
'size' => '35' ,
'extra_params' => ' rows="4" ' ,
'db_field' => 'group_description' ,
'invalid_err' => lang ( 'grp_des_error' ),
'required' => 'yes'
),
$url_form ,
'cat' => array (
'title' => lang ( 'grp_cat_tile' ),
'type' => 'checkbox' ,
'name' => 'category[]' ,
'id' => 'category' ,
'value' => array ( 'category' , $cat_array ),
2010-02-02 16:19:41 +00:00
'hint_1' => sprintf ( lang ( 'vdo_cat_msg' ), ALLOWED_GROUP_CATEGORIES ),
2009-12-21 21:11:54 +00:00
'db_field' => 'category' ,
'required' => 'yes' ,
2009-12-29 11:28:48 +00:00
'validate_function' => 'validate_group_category' ,
2009-12-21 21:11:54 +00:00
'invalid_err' => lang ( 'grp_cat_error' ),
'display_function' => 'convert_to_categories' ,
'category_type' => 'group' ,
),
);
return $fields ;
2009-11-16 11:55:31 +00:00
}
/**
2009-12-21 21:11:54 +00:00
* Function used to load other group option fields
2009-11-16 11:55:31 +00:00
*/
2010-02-02 16:19:41 +00:00
function load_other_fields ( $default = NULL )
2009-12-21 21:11:54 +00:00
{
global $LANG , $uploadFormOptionFieldsArray ;
2010-02-02 16:19:41 +00:00
if ( ! $default )
2009-12-21 21:11:54 +00:00
$default = $_POST ;
$gpprivacy = $default [ 'group_privacy' ];
2010-02-02 16:19:41 +00:00
$gpposting = $default [ 'post_type' ];
2009-12-21 21:11:54 +00:00
$group_option_fields = array
(
'privacy' => array ( 'title' => lang ( 'privacy' ),
'type' => 'radiobutton' ,
'name' => 'group_privacy' ,
'id' => 'group_privacy' ,
'value' => array ( '0' => lang ( 'grp_join_opt1' ), '1' => lang ( 'grp_join_opt2' ), 2 => lang ( 'grp_join_opt3' )),
'checked' => $gpprivacy ,
'db_field' => 'group_privacy' ,
'required' => 'no' ,
'display_function' => 'display_sharing_opt' ,
),
'posting' => array ( 'title' => lang ( 'grp_forum_posting' ),
'type' => 'radiobutton' ,
'name' => 'post_type' ,
'id' => 'post_type' ,
'value' => array ( '0' => lang ( 'vdo_br_opt1' ), '1' => lang ( 'vdo_br_opt2' ), 2 => lang ( 'grp_join_opt3' )),
'checked' => $gpposting ,
'db_field' => 'post_type' ,
'required' => 'no' ,
'display_function' => 'display_sharing_opt' ,
),
);
return $group_option_fields ;
2009-11-16 11:55:31 +00:00
}
2009-12-21 21:11:54 +00:00
2009-11-16 11:55:31 +00:00
/**
2009-12-21 21:11:54 +00:00
* Function used to validate Signup Form
2009-11-16 11:55:31 +00:00
*/
2009-12-21 21:11:54 +00:00
function validate_form_fields ( $array = NULL , $update = false )
{
$fields = $this -> load_required_fields ( $array , $update );
if ( $array == NULL )
$array = $_POST ;
if ( is_array ( $_FILES ))
$array = array_merge ( $array , $_FILES );
//Mergin Array
$group_fields = array_merge ( $fields , $this -> load_other_fields ());
validate_cb_form ( $group_fields , $array );
2009-11-16 11:55:31 +00:00
}
/**
2009-12-21 21:11:54 +00:00
* Function used to create new groups
* @ Author : Fawaz Tahir , Arslan Hassan
* @ Params : array { Group Input Details }
* @ since : 15 December 2009
2009-11-16 11:55:31 +00:00
*/
2009-12-21 21:11:54 +00:00
function create_group ( $array , $user = false , $redirect_to_group = false )
{
2009-11-16 11:55:31 +00:00
global $db ;
2009-12-21 21:11:54 +00:00
if ( $array == NULL )
$array = $_POST ;
if ( is_array ( $_FILES ))
$array = array_merge ( $array , $_FILES );
$this -> validate_form_fields ( $array );
if ( ! error ())
{
$group_fields = $this -> load_required_fields ( $array );
$group_fields = array_merge ( $group_fields , $this -> load_other_fields ());
//Adding Custom Signup Fields
if ( count ( $this -> custom_group_fields ) > 0 )
$group_fields = array_merge ( $group_fields , $this -> custom_group_fields );
foreach ( $group_fields as $field )
{
$name = formObj :: rmBrackets ( $field [ 'name' ]);
$val = $array [ $name ];
if ( $field [ 'use_func_val' ])
$val = $field [ 'validate_function' ]( $val );
if ( ! empty ( $field [ 'db_field' ]))
$query_field [] = $field [ 'db_field' ];
if ( is_array ( $val ))
{
$new_val = '' ;
foreach ( $val as $v )
{
$new_val .= " # " . $v . " # " ;
}
$val = $new_val ;
}
if ( ! $field [ 'clean_func' ] || ( ! function_exists ( $field [ 'clean_func' ]) && ! is_array ( $field [ 'clean_func' ])))
$val = mysql_clean ( $val );
else
$val = apply_func ( $field [ 'clean_func' ], $val );
if ( ! empty ( $field [ 'db_field' ]))
$query_val [] = $val ;
}
}
if ( ! error ())
{
//UID
$query_field [] = " userid " ;
$query_val [] = $user ;
//DATE ADDED
$query_field [] = " date_added " ;
$query_val [] = now ();
//Inserting IN Database now
2010-02-06 11:29:50 +00:00
$db -> insert ( tbl ( $this -> gp_tbl ), $query_field , $query_val );
2009-12-21 21:11:54 +00:00
$insert_id = $db -> insert_id ();
//Owner Joiing Group
ignore_errors ();
$this -> join_group ( $insert_id , $user );
//Updating User Total Groups
$this -> update_user_total_groups ( $user );
if ( $redirect_to_group )
{
$grp_details = $this -> get_details ( $insert_id );
redirect_to ( group_link ( array ( 'details' => $grp_details ) ));
}
2010-01-21 13:49:49 +00:00
//loggin Upload
$log_array = array
(
'success' => 'yes' ,
'action_obj_id' => $insert_id ,
'details' => " created new group " );
insert_log ( 'add_group' , $log_array );
2009-12-21 21:11:54 +00:00
return $insert_id ;
}
2009-11-16 11:55:31 +00:00
}
2009-12-21 21:11:54 +00:00
2009-11-16 11:55:31 +00:00
/**
2009-12-21 21:11:54 +00:00
* Function used to update group
* @ Author : Fawaz Tahir , Arslan Hassan
* @ Params : array { Group Input Details }
* @ since : 15 December 2009
2009-11-16 11:55:31 +00:00
*/
2009-12-21 21:11:54 +00:00
function update_group ( $array = NULL )
{
2009-11-16 11:55:31 +00:00
global $db ;
2009-12-21 21:11:54 +00:00
if ( $array == NULL )
$array = $_POST ;
if ( is_array ( $_FILES ))
$array = array_merge ( $array , $_FILES );
$this -> validate_form_fields ( $array , true );
$gid = $array [ 'group_id' ];
if ( ! error ())
{
$group_fields = $this -> load_required_fields ( $array );
$group_fields = array_merge ( $group_fields , $this -> load_other_fields ());
//Adding Custom Signup Fields
if ( count ( $this -> custom_group_fields ) > 0 )
$group_fields = array_merge ( $group_fields , $this -> custom_group_fields );
foreach ( $group_fields as $field )
{
$name = formObj :: rmBrackets ( $field [ 'name' ]);
$val = $array [ $name ];
if ( $field [ 'use_func_val' ])
$val = $field [ 'validate_function' ]( $val );
if ( ! empty ( $field [ 'db_field' ]))
$query_field [] = $field [ 'db_field' ];
if ( is_array ( $val ))
{
$new_val = '' ;
foreach ( $val as $v )
{
$new_val .= " # " . $v . " # " ;
}
$val = $new_val ;
}
if ( ! $field [ 'clean_func' ] || ( ! function_exists ( $field [ 'clean_func' ]) && ! is_array ( $field [ 'clean_func' ])))
$val = mysql_clean ( $val );
else
$val = apply_func ( $field [ 'clean_func' ], $val );
if ( ! empty ( $field [ 'db_field' ]))
$query_val [] = $val ;
}
}
2010-01-05 09:47:10 +00:00
if ( has_access ( 'admin_access' , TRUE ))
{
if ( ! empty ( $array [ 'total_views' ]))
{
$query_field [] = 'total_views' ;
$query_val [] = $array [ 'total_views' ];
}
if ( ! empty ( $array [ 'total_videos' ]))
{
$query_field [] = 'total_videos' ;
$query_val [] = $array [ 'total_videos' ];
}
if ( ! empty ( $array [ 'total_members' ]))
{
$query_field [] = 'total_members' ;
$query_val [] = $array [ 'total_members' ];
}
if ( ! empty ( $array [ 'total_topics' ]))
{
$query_field [] = 'total_topics' ;
$query_val [] = $array [ 'total_topics' ];
}
}
2009-12-21 21:11:54 +00:00
//Getting Group URL value
$gp_url = $this -> get_gp_field_only ( $gid , " group_url " );
//Checking Group URL
if ( $array [ 'group_url' ] != $gp_url )
if ( group_url_exists ( $array [ 'group_url' ]))
e ( lang ( 'grp_url_error2' ));
if ( ! error ())
{
if ( ! userid ())
{
e ( " You are not logged in " );
} elseif ( ! $this -> group_exists ( $gid )){
e ( " Group deos not exist " );
} elseif ( ! $this -> is_owner ( $gid , userid ()) && ! has_access ( 'admin_access' , TRUE ))
{
e ( " You cannot edit this group " );
} else {
2010-02-06 11:29:50 +00:00
$db -> update ( tbl ( $this -> gp_tbl ), $query_field , $query_val , " group_id=' $gid ' " );
2009-12-21 21:11:54 +00:00
e ( " Group details have been updated " , m );
//Updating Group Thumb
if ( ! empty ( $array [ 'thumb_file' ][ 'tmp_name' ]))
$this -> create_group_image ( $gid , $array [ 'thumb_file' ]);
}
}
2009-11-16 11:55:31 +00:00
}
2009-12-21 21:11:54 +00:00
2009-11-16 11:55:31 +00:00
/**
* Function used to get default image for group .
*/
2009-12-21 21:11:54 +00:00
function get_default_thumb ( $size = NULL )
{
if ( $size == 'small' )
$this -> get_default_thumb = GP_THUMB_URL . '/no_thumb-small.png' ;
else
$this -> get_default_thumb = GP_THUMB_URL . '/no_thumb.png' ;
2009-11-16 11:55:31 +00:00
return $this -> get_default_thumb ;
}
2009-12-21 21:11:54 +00:00
2009-11-16 11:55:31 +00:00
/**
2009-12-21 21:11:54 +00:00
* Function used to create group thumbnail
* @ param = $gpid { ID of group for which thumbnail is being created }
* @ param = $file { Source of image file $_FILES }
2009-11-16 11:55:31 +00:00
*/
2009-12-21 21:11:54 +00:00
function create_group_image ( $gpid , $file )
{
global $imgObj ;
$file_ext = strtolower ( getext ( $file [ 'name' ]));
$exts = array ( 'jpg' , 'png' , 'gif' , 'jpeg' );
2009-11-16 11:55:31 +00:00
2009-12-21 21:11:54 +00:00
foreach ( $exts as $ext )
{
if ( $ext == $file_ext )
{
$thumb_name = $gpid . '.' . $ext ;
$small_thumb_name = $gpid . '-small.' . $ext ;
$path = GP_THUMB_DIR . '/' . $thumb_name ;
$small_path = GP_THUMB_DIR . '/' . $small_thumb_name ;
foreach ( $exts as $unlink_ext )
if ( file_exists ( GP_THUMB_DIR . '/' . $gpid . '.' . $unlink_ext ))
unlink ( GP_THUMB_DIR . '/' . $gpid . '.' . $unlink_ext );
move_uploaded_file ( $file [ 'tmp_name' ], $path );
if ( ! $imgObj -> ValidateImage ( $path , $ext ))
e ( lang ( 'Please Upload a valid with JPG OR GIF OR PNG Image.' ));
else
{
$imgObj -> CreateThumb ( $path , $path , $this -> gp_thumb_width , $ext , $this -> gp_thumb_height , true );
$imgObj -> CreateThumb ( $path , $small_path , $this -> gp_small_thumb_width , $ext , $this -> gp_small_thumb_height , true );
}
}
2009-08-25 12:16:42 +00:00
}
2009-11-16 11:55:31 +00:00
}
/**
2009-12-21 21:11:54 +00:00
* Function used to get group thumb .
* @ param Group Details array
*/
function get_gp_thumb ( $grp_details , $size = NULL )
{
$exts = array ( 'jpg' , 'png' , 'gif' , 'jpeg' );
$gpid = $grp_details [ 'group_id' ];
foreach ( $exts as $ext )
{
if ( $size == 'small' )
$file_size = " -small " ;
if ( file_exists ( GP_THUMB_DIR . '/' . $gpid . " $file_size . " . $ext ))
return GP_THUMB_URL . '/' . $gpid . " $file_size . " . $ext ;
}
return $this -> get_default_thumb ( $size );
}
function get_group_thumb ( $grp_details , $size = NULL ){ return $this -> get_gp_thumb ( $grp_details , $size ); }
/**
* function used to get group icon
2009-11-16 11:55:31 +00:00
*/
2009-12-21 21:11:54 +00:00
function get_topic_icon ( $topic )
{
$file = TOPIC_ICON_DIR . '/' . $topic [ 'topic_icon' ];
if ( file_exists ( $file ) && ! empty ( $topic [ 'topic_icon' ]))
{
return TOPIC_ICON_URL . '/' . $topic [ 'topic_icon' ];
} else
return TOPIC_ICON_URL . '/dot.gif' ;
}
/**
* Function used add new topic in group
* @ param ARRAY details
*/
function add_topic ( $array , $redirect_to_topic = false )
{
2009-11-16 11:55:31 +00:00
global $db ;
2009-12-21 21:11:54 +00:00
if ( $array == NULL )
$array = $_POST ;
if ( is_array ( $_FILES ))
$array = array_merge ( $array , $_FILES );
$fields = $this -> load_add_topic_form_fields ( $array );
validate_cb_form ( $fields , $array );
$user = userid ();
if ( ! error ())
{
foreach ( $fields as $field )
{
$name = formObj :: rmBrackets ( $field [ 'name' ]);
$val = $array [ $name ];
if ( $field [ 'use_func_val' ])
$val = $field [ 'validate_function' ]( $val );
if ( ! empty ( $field [ 'db_field' ]))
$query_field [] = $field [ 'db_field' ];
if ( is_array ( $val ))
{
$new_val = '' ;
foreach ( $val as $v )
{
$new_val .= " # " . $v . " # " ;
}
$val = $new_val ;
}
if ( ! $field [ 'clean_func' ] || ( ! function_exists ( $field [ 'clean_func' ]) && ! is_array ( $field [ 'clean_func' ])))
$val = mysql_clean ( $val );
else
$val = apply_func ( $field [ 'clean_func' ], $val );
if ( ! empty ( $field [ 'db_field' ]))
$query_val [] = $val ;
}
}
$gp_details = $this -> get_group_details ( $array [ 'group_id' ]);
//Checking for weather user is allowed to post topics or not
$this -> validate_posting_previlige ( $gp_details );
if ( ! error ())
{
//Adding Topic icon
$query_field [] = " topic_icon " ;
$query_val [] = $array [ 'topic_icon' ];
//UID
$query_field [] = " userid " ;
$query_val [] = $user ;
//DATE ADDED
$query_field [] = " date_added " ;
$query_val [] = now ();
$query_field [] = " last_post_time " ;
$query_val [] = now ();
//GID
$query_field [] = " group_id " ;
$query_val [] = $array [ 'group_id' ];
//Checking If posting requires approval or not
$query_field [] = " approved " ;
if ( $gp_details [ 'post_type' ] == 1 )
$query_val [] = " no " ;
else
$query_val [] = " yes " ;
//Inserting IN Database now
2010-02-06 11:29:50 +00:00
$db -> insert ( tbl ( $this -> gp_topic_tbl ), $query_field , $query_val );
2009-12-21 21:11:54 +00:00
$insert_id = $db -> insert_id ();
2009-11-16 11:55:31 +00:00
2009-12-21 21:11:54 +00:00
//Increasing Group Topic Counts
$count_topics = $this -> count_group_topics ( $array [ 'group_id' ]);
2010-02-06 11:29:50 +00:00
$db -> update ( tbl ( $this -> gp_tbl ), array ( " total_topics " ), array ( $count_topics ), " group_id=' " . $array [ 'group_id' ] . " ' " );
2009-11-16 11:55:31 +00:00
2009-12-21 21:11:54 +00:00
//leaving msg
e ( " Topic has been added " , " m " );
2009-11-16 11:55:31 +00:00
2009-12-21 21:11:54 +00:00
//Redirecting to topic
if ( $redirect_to_topic )
{
$grp_details = $this -> get_details ( $insert_id );
redirect_to ( group_link ( $grp_details ));
2009-08-25 12:16:42 +00:00
}
2009-11-16 11:55:31 +00:00
2009-12-21 21:11:54 +00:00
return $insert_id ;
2009-11-16 11:55:31 +00:00
2009-12-21 21:11:54 +00:00
}
2009-11-16 11:55:31 +00:00
}
/**
2009-12-21 21:11:54 +00:00
* Function used to delete group topic
2009-11-16 11:55:31 +00:00
*/
2009-12-21 21:11:54 +00:00
function delete_topic ( $tid )
{
global $db ;
$topic = $this -> get_topic_details ( $tid );
$group = $this -> get_group_details ( $topic [ 'group_id' ]);
if ( ! $topic )
e ( " Topic does not exist " );
elseif ( ! $group )
e ( " Group does not exist " );
elseif ( userid () != $topic [ 'userid' ] && userid () != $group [ 'userid' ])
e ( " You cannot delete this topic " );
else
{
2010-02-06 11:29:50 +00:00
$db -> delete ( tbl ( $this -> gp_topic_tbl ), array ( " topic_id " , " group_id " ), array ( $tid , $topic [ 'group_id' ]));
2009-12-21 21:11:54 +00:00
//Deleting Topic Posts
$this -> delete_comments ( $tid );
e ( " Topic has been deleted " , " m " );
2009-08-25 12:16:42 +00:00
}
2009-11-16 11:55:31 +00:00
}
/**
2009-12-21 21:11:54 +00:00
* Function used to delete all user topics
2009-11-16 11:55:31 +00:00
*/
2009-12-21 21:11:54 +00:00
function delete_user_topics ( $uid , $gid )
{
2009-11-16 11:55:31 +00:00
global $db ;
2009-12-21 21:11:54 +00:00
$group = $this -> get_group_details ( $gid );
2009-11-16 11:55:31 +00:00
2009-12-21 21:11:54 +00:00
if ( ! $group )
e ( " Group does not exist " );
elseif ( userid () != $group [ 'userid' ] && userid () != $uid && ! has_access ( 'admin_access' , true ))
e ( " You cannot delete user topics " );
else
{
$usr_topics = $this -> get_topics ( array ( 'group' => $gid , 'user' => $uid ));
if ( is_array ( $usr_topics ))
foreach ( $usr_topics as $topic )
$this -> delete_topic ( $topic [ 'topic_id' ]);
e ( " Topics have been deleted " , " m " );
2009-08-25 12:16:42 +00:00
}
2009-11-16 11:55:31 +00:00
}
2009-12-21 21:11:54 +00:00
2009-11-16 11:55:31 +00:00
/**
2009-12-21 21:11:54 +00:00
* Function used to delete all group topics
2009-11-16 11:55:31 +00:00
*/
2009-12-21 21:11:54 +00:00
function delete_group_topics ( $gid )
{
2009-11-16 11:55:31 +00:00
global $db ;
2009-12-21 21:11:54 +00:00
$group = $this -> get_group_details ( $gid );
if ( ! $group )
e ( " Group does not exist " );
elseif ( userid () != $group [ 'userid' ] && ! has_access ( 'admin_access' , true ))
e ( " You cannot delete group topics " );
else
{
$topics = $this -> get_topics ( array ( 'group' => $gid ));
if ( is_array ( $topics ))
foreach ( $topics as $topic )
$this -> delete_topic ( $topic [ 'topic_id' ]);
e ( " Topics have been deleted " , " m " );
}
}
/**
* Function used to check weather posting is allowed or not
*/
function validate_posting_previlige ( $gdetails )
{
if ( is_numeric ( $getails ))
$gdetails = $this -> get_group_details ( $getails );
if ( ! $gdetails || empty ( $gdetails [ 'group_id' ]))
e ( " Group does not exist " );
if ( ! userid ())
e ( " Please login to post topics " );
elseif ( ! $this -> is_member ( userid (), $gdetails [ 'group_id' ], TRUE ))
e ( " You are not member of this group or you are not approved by group owner " );
elseif ( $gdetails [ 'post_type' ] == 2 && userid () != $gdetails [ 'userid' ] && ! has_access ( 'admin_access' , true ))
e ( " You are not allowed to post topics " );
else
{
return true ;
2009-08-25 12:16:42 +00:00
}
2009-12-21 21:11:54 +00:00
return false ;
2009-11-16 11:55:31 +00:00
}
2009-12-21 21:11:54 +00:00
2009-11-16 11:55:31 +00:00
/**
2009-12-21 21:11:54 +00:00
* Function used to get group topics
* INPUT Group ID
2009-11-16 11:55:31 +00:00
*/
2009-12-21 21:11:54 +00:00
function get_group_topics ( $params )
{
global $db ;
$gid = $params [ 'group' ] ? $params [ 'group' ] : $params ;
$limit = $params [ 'limit' ];
$order = $params [ 'order' ] ? $params [ 'order' ] : " last_post_time DESC " ;
if ( $params [ 'approved' ])
$approved_query = " AND approved='yes' " ;
if ( $params [ 'user' ])
$user_query = " AND userid=' " . $params [ 'user' ] . " ' " ;
2010-02-06 11:29:50 +00:00
$results = $db -> select ( tbl ( $this -> gp_topic_tbl ), " * " , " group_id=' $gid ' $approved_query $user_query " , $limit , $order );
2009-12-21 21:11:54 +00:00
if ( $db -> num_rows > 0 )
return $results ;
else
return false ;
2009-11-16 11:55:31 +00:00
}
2009-12-21 21:11:54 +00:00
function GetTopics ( $params ){ return $this -> get_group_topics ( $params ); }
function get_topics ( $params ){ return $this -> get_group_topics ( $params ); }
2009-11-16 11:55:31 +00:00
/**
2009-12-21 21:11:54 +00:00
* Function used to check weather topic exists or not
* @ param TOPIC ID { id of topic }
2009-11-16 11:55:31 +00:00
*/
2009-12-21 21:11:54 +00:00
function topic_exists ( $tid )
{
global $db ;
2010-02-06 11:29:50 +00:00
$count = $db -> count ( tbl ( $this -> gp_topic_tbl ), 'topic_id' , " topic_id=' $tid ' " );
2009-12-21 21:11:54 +00:00
if ( $count [ 0 ] > 0 )
return true ;
else
return false ;
2009-11-16 11:55:31 +00:00
}
/**
2009-12-21 21:11:54 +00:00
* Function used to get topic details
* @ param TOPIC ID { id of topic }
*/
function get_topic_details ( $topic )
{
global $db ;
2010-02-06 11:29:50 +00:00
$result = $db -> select ( tbl ( $this -> gp_topic_tbl ), " * " , " topic_id=' $topic ' " );
2009-12-21 21:11:54 +00:00
if ( $db -> num_rows > 0 )
return $result [ 0 ];
else
return false ;
}
function gettopic ( $topic ){ return $this -> get_topic_details ( $topic ); }
function get_topic ( $topic ){ return $this -> get_topic_details ( $topic ); }
/**
* Function used to check weather user is invited or not
2009-11-16 11:55:31 +00:00
*/
2009-12-21 21:11:54 +00:00
function is_invited ( $uid , $gid , $owner , $gen_err = FALSE )
{
global $db ;
2010-02-06 11:29:50 +00:00
$count = $db -> count ( tbl ( $this -> gp_invite_tbl ), 'invitation_id' , " invited=' $uid ' AND group_id=' $gid ' AND userid=' $owner ' " );
2009-12-21 21:11:54 +00:00
if ( $count [ 0 ] > 0 )
return true ;
else
{
if ( $gen_err )
e ( lang ( 'grp_prvt_err1' ));
return false ;
2009-08-25 12:16:42 +00:00
}
2009-12-21 21:11:54 +00:00
}
function is_userinvite ( $uid , $gid , $owner ){ return $this -> is_invited ( $uid , $gid , $owner ); }
/**
* Function used to check whether user is already a member or not
* @ param = $user { User to check }
* @ param = $gpid { ID of group in which we will check }
*/
function is_member ( $user , $gpid , $active = false ) {
global $db ;
$active_query = " " ;
if ( $active )
$active_query = " AND active='yes' " ;
2010-02-06 11:29:50 +00:00
$data = $db -> count ( tbl ( $this -> gp_mem_tbl ), " * " , " group_id=' $gpid ' AND userid=' $user ' $active_query " );
2009-08-25 12:16:42 +00:00
2009-12-21 21:11:54 +00:00
if ( $data [ 0 ] > 0 ) {
return true ;
} else {
return false ;
2009-11-16 11:55:31 +00:00
}
}
2009-12-21 21:11:54 +00:00
function joined_group ( $user , $gpid ){ return $this -> is_member ( $user , $gpid );}
2009-11-16 11:55:31 +00:00
/**
2009-12-21 21:11:54 +00:00
* Function use to check weather user is owner or not of the group
* @ param GID { group id }
* @ param UID { logged in user or just user }
2009-11-16 11:55:31 +00:00
*/
2009-12-21 21:11:54 +00:00
function is_owner ( $gid , $uid = NULL )
{
if ( ! $uid )
$uid = userid ();
if ( ! is_array ( $gid ))
$group = $this -> get_group_details ( $gid );
else
$group = $gid ;
if ( $group [ 'userid' ] == $uid )
return true ;
else
return false ;
}
/**
* Function used to count total number of members in a group .
* @ param = $gpid { ID of group whose members are going to be counted }
*/
function total_members ( $gpid )
{
global $db ;
2010-02-06 11:29:50 +00:00
$totalmem = $db -> count ( tbl ( " group_members " ), " * " , " group_id=' $gpid ' " );
2009-12-21 21:11:54 +00:00
return $totalmem [ 0 ];
}
/**
* Function used to get group members
*/
function get_members ( $gid , $approved = NULL , $limit = NULL )
{
global $db ;
$app_query = " " ;
if ( $approved )
2010-02-06 11:29:50 +00:00
$app_query = " AND " . tbl ( $this -> gp_mem_tbl ) . " .active=' $approved ' " ;
$result = $db -> select ( tbl ( $this -> gp_mem_tbl ) . " LEFT JOIN users ON " . tbl ( $this -> gp_mem_tbl ) . " .userid=users.userid " , " * " , " group_id=' $gid ' $app_query " , $limit );
2009-12-21 21:11:54 +00:00
if ( $db -> num_rows > 0 )
return $result ;
else
return false ;
}
/**
* Function used to check weather member is active or not
*/
function is_active_member ( $uid , $gid )
{
global $db ;
2010-02-06 11:29:50 +00:00
$count = $db -> count ( tbl ( $this -> gp_mem_tbl ), " userid " , " userid=' $uid ' AND group_id=' $gid ' AND active='yes' " );
2009-12-21 21:11:54 +00:00
if ( $count [ 0 ] > 0 )
return true ;
else
return false ;
}
/**
* function used to count number of topics in a group
*/
function count_group_topics ( $group )
{
global $db ;
2010-02-06 11:29:50 +00:00
$totaltopics = $db -> count ( tbl ( $this -> gp_topic_tbl ), " * " , " group_id=' $group ' " );
2009-12-21 21:11:54 +00:00
return $totaltopics ;
}
function CountTopics ( $group ){ return $this -> count_group_topics ( $group ); }
function count_topics ( $group ){ return $this -> count_group_topics ( $group ); }
/**
* Function used to add video to group
*/
function add_group_video ( $vid , $gid , $update_group = false )
{
global $db , $cbvid ;
$group = $this -> get_details ( $gid );
$video = $cbvid -> get_video_details ( $vid );
if ( ! $group )
e ( " Group does note exist " );
elseif ( ! $video )
e ( " Video does not exist " );
elseif ( $video [ 'userid' ] != userid ())
e ( " You cannot add this video " );
elseif ( $this -> is_group_video ( $vid , $gid ))
return false ;
else
{
2010-02-06 11:29:50 +00:00
$db -> insert ( tbl ( $this -> gp_vdo_tbl ), array ( " videoid " , " group_id " , " userid " ), array ( $vid , $gid , userid ()));
2009-12-21 21:11:54 +00:00
e ( " Video has been added " , " m " );
if ( $update_group )
$this -> update_group_videos_count ( $gid );
}
}
/**
* Removing video gro group
*/
function remove_group_video ( $vid , $gid , $update_group = false )
{
global $db , $cbvid ;
$group = $this -> get_details ( $gid );
$video = $cbvid -> get_video_details ( $vid );
if ( ! $group )
e ( " Group does note exist " );
elseif ( ! $video )
e ( " Video does not exist " );
elseif ( $video [ 'userid' ] != userid ())
e ( " You cannot remove this video " );
elseif ( ! $this -> is_group_video ( $vid , $gid ))
return false ;
else
{
2010-02-06 11:29:50 +00:00
$db -> delete ( tbl ( $this -> gp_vdo_tbl ), array ( " videoid " , " group_id " ), array ( $vid , $gid ));
2009-12-21 21:11:54 +00:00
e ( " Video has been removed " , " m " );
if ( $update_group )
$this -> update_group_videos_count ( $gid );
}
}
/**
* Function used to check weather video is already in group or not
*/
function is_group_video ( $vid , $gid )
{
global $db ;
2010-02-06 11:29:50 +00:00
$count = $db -> count ( tbl ( $this -> gp_vdo_tbl ), " group_video_id " , " videoid=' $vid ' AND group_id=' $gid ' " );
2009-12-21 21:11:54 +00:00
if ( $count [ 0 ] > 0 )
return true ;
else
return false ;
}
/**
* Function used to count videos of group
* @ param GID { group ID }
*/
function count_videos ( $gpid )
{
global $db ;
2010-02-06 11:29:50 +00:00
$totalmem = $db -> count ( tbl ( " group_videos " ), " * " , " group_id=' $gpid ' " );
2009-12-21 21:11:54 +00:00
return $totalmem ;
}
function total_videos ( $gid ){ return $this -> count_videos ( $gid );}
/**
* Function used to update number of videos of group
*/
function update_group_videos_count ( $gid )
{
global $db ;
$total = $this -> count_videos ( $gid );
2010-02-06 11:29:50 +00:00
$db -> update ( tbl ( $this -> gp_tbl ), array ( 'total_videos' ), array ( $total ), " group_id=' $gid ' " );
2009-12-21 21:11:54 +00:00
}
/**
* Function used to get group videos
*/
function get_group_videos ( $gid , $approved = NULL , $limit = NULL )
{
global $db , $cbvid ;
if ( $approved )
$approved_query = " AND approved=' $approved ' " ;
2010-02-06 11:29:50 +00:00
$result = $db -> select ( tbl ( $this -> gp_vdo_tbl ) . " LEFT JOIN video ON " . tbl ( $this -> gp_vdo_tbl ) . " .videoid=video.videoid " , " * " ,
2009-12-21 21:11:54 +00:00
" group_id=' $gid ' $approved_query AND video.active='yes' AND status='Successful' " , $limit );
if ( $db -> num_rows > 0 )
return $result ;
else
return false ;
}
/**
* Function used to activate or detactivate or delete group member
*/
function member_actions ( $gid , $memuid , $case , $deleting_group = FALSE )
{
global $db ;
//getting group details
$group = $this -> get_group_details ( $gid );
if ( ! $group )
e ( " Group does not exist " );
elseif ( ! $this -> is_member ( $memuid , $gid ))
e ( " User is not group member " );
elseif ( userid () != $group [ 'userid' ] && ! has_access ( " admin_access " , true ))
e ( " You are not owner of this group " );
elseif ( $group [ 'userid' ] == $memuid && ! $deleting_group )
e ( " You cannot perform actions on group owner " );
else
switch ( $case )
{
case " activate " :
case " active " :
{
2010-02-06 11:29:50 +00:00
$db -> update ( tbl ( $this -> gp_mem_tbl ), array ( " active " ), array ( " yes " ), " userid=' $memuid ' AND group_id=' $gid ' " );
2009-12-21 21:11:54 +00:00
e ( " User has been activated " , " m " );
}
break ;
case " deactivate " :
case " deactive " :
case " unactivate " :
case " unactive " :
{
2010-02-06 11:29:50 +00:00
$db -> update ( tbl ( $this -> gp_mem_tbl ), array ( " active " ), array ( " no " ), " userid=' $memuid ' AND group_id=' $gid ' " );
2009-12-21 21:11:54 +00:00
e ( " User has been deactivated " , " m " );
}
break ;
case " delete " :
{
//Delete All Videos oF member
2010-02-06 11:29:50 +00:00
$db -> delete ( tbl ( $this -> gp_vdo_tbl ), array ( " userid " , " group_id " ), array ( $memuid , gid ));
2009-12-21 21:11:54 +00:00
//Deleting ALl Topics Of
$this -> delete_user_topics ( $memuid , $gid );
//Delete Member
2010-02-06 11:29:50 +00:00
$db -> delete ( tbl ( $this -> gp_mem_tbl ), array ( " userid " , " group_id " ), array ( $memuid , $gid ));
2009-12-21 21:11:54 +00:00
$total_members = $this -> total_members ( $gid );
$total_videos = $this -> total_videos ( $gid );
$count_topics = $this -> count_group_topics ( $gid );
//Update Stat
2010-02-06 11:29:50 +00:00
$db -> update ( tbl ( $this -> gp_tbl ), array ( " total_topics " , " total_members " , " total_videos " ),
2009-12-21 21:11:54 +00:00
array ( $count_topics , $total_members , $total_videos ), " group_id=' " . $gid . " ' " );
e ( " User has been deleted " , " m " );
}
break ;
}
}
/**
* Function used to perform actions on videos
*/
function video_actions ( $gid , $vid , $case )
{
global $db ;
//getting group details
$group = $this -> get_group_details ( $gid );
if ( ! $group )
e ( " Group does not exist " );
elseif ( ! $this -> is_group_video ( $vid , $gid ))
e ( " Video does not exist " );
2010-01-05 09:47:10 +00:00
elseif ( userid () != $group [ 'userid' ] && ! has_access ( " admin_access " ))
2009-12-21 21:11:54 +00:00
e ( " You are not owner of this group " );
else
switch ( $case )
{
case " activate " :
case " active " :
{
2010-02-06 11:29:50 +00:00
$db -> update ( tbl ( $this -> gp_vdo_tbl ), array ( " approved " ), array ( " yes " ), " videoid =' $vid ' AND group_id=' $gid ' " );
2009-12-21 21:11:54 +00:00
e ( " Video has been activated " , " m " );
}
break ;
case " deactivate " :
case " deactive " :
case " unactivate " :
case " unactive " :
{
2010-02-06 11:29:50 +00:00
$db -> update ( tbl ( $this -> gp_vdo_tbl ), array ( " approved " ), array ( " no " ), " videoid =' $vid ' AND group_id=' $gid ' " );
2009-12-21 21:11:54 +00:00
e ( " Video has been deactivated " , " m " );
}
break ;
case " delete " :
{
//Delete video
2010-02-06 11:29:50 +00:00
$db -> delete ( tbl ( $this -> gp_vdo_tbl ), array ( " videoid " , " group_id " ), array ( $vid , $gid ));
2009-12-21 21:11:54 +00:00
$total_videos = $this -> total_videos ( $gid );
//Update Stat
2010-02-06 11:29:50 +00:00
$db -> update ( tbl ( $this -> gp_tbl ), array ( " total_videos " ),
2009-12-21 21:11:54 +00:00
array ( $total_videos ), " group_id=' " . $gid . " ' " );
e ( " Video has been deleted " , " m " );
}
break ;
}
}
/**
* Function used to invite members to group
*/
function invite_member ( $user , $gid , $owner = NULL )
{
global $cbemail , $db , $userquery ;
$group = $this -> get_group_details ( $gid );
if ( ! $owner )
$owner = userid ();
$sender = $userquery -> get_user_details ( $owner );
$reciever = $userquery -> get_user_details ( $user );
if ( ! $group )
e ( " Group does not exist " );
elseif ( ! $sender )
e ( " Sender not exists " );
elseif ( ! $reciever )
e ( " Reciever not exists " );
elseif ( $this -> is_member ( $user , $gid ))
e ( " Member has alread joined this group " );
elseif ( $owner != $group [ 'userid' ])
e ( " You are not owner of this group " );
else
{
//Inserting Invitation Code in database
2010-02-06 11:29:50 +00:00
$db -> insert ( tbl ( $this -> gp_invite_tbl ), array ( 'group_id' , 'userid' , 'invited' , 'date_added' ),
2009-12-21 21:11:54 +00:00
array ( $gid , $owner , $user , now ()));
e ( " User has been invited " , " m " );
//Now Sending Email To User
$tpl = $cbemail -> get_template ( 'group_invitation' );
$more_var = array
(
'{reciever}' => $reciever [ 'username' ],
'{sender}' => $sender [ 'username' ],
'{group_url}' => group_link ( array ( 'details' => $group )),
'{group_name}' => $group [ 'group_name' ],
'{group_description}' => $group [ 'group_description' ]
);
if ( ! is_array ( $var ))
$var = array ();
$var = array_merge ( $more_var , $var );
$subj = $cbemail -> replace ( $tpl [ 'email_template_subject' ], $var );
$msg = nl2br ( $cbemail -> replace ( $tpl [ 'email_template' ], $var ));
//Now Finally Sending Email
cbmail ( array ( 'to' => $reciever [ 'email' ], 'from' => WEBSITE_EMAIL , 'subject' => $subj , 'content' => $msg ));
}
}
/**
* Function used to invite members to group
*/
function invite_members ( $user_array , $group , $owner = NULL )
{
global $eh ;
$total = count ( $user_array );
for ( $i = 0 ; $i <= $total ; $i ++ )
{
$this -> invite_member ( $user_array [ $i ], $group , $owner );
}
$eh -> flush ();
e ( " Invitations have been sent " , " m " );
}
/**
* Function used to leave group
*/
function leave_group ( $gid , $uid )
{
global $db ;
if ( ! $this -> is_member ( $uid , $gid ))
e ( " You are not member of this group " );
elseif ( $this -> is_owner ( $gid , $uid ))
e ( " Group owner cannot leave group " );
else
{
2010-02-06 11:29:50 +00:00
$db -> delete ( tbl ( $this -> gp_mem_tbl ), array ( " userid " , " group_id " ), array ( $uid , $gid ));
2009-12-21 21:11:54 +00:00
e ( " You have left the group " , " m " );
}
}
/**
* Function used to delete group
*/
function delete_group ( $gid )
{
global $db ;
$group = $this -> get_group_details ( $gid );
if ( ! $group )
e ( " Group does not exist " );
elseif ( userid () != $group [ 'userid' ] && ! has_access ( 'admin_access' , true ))
e ( " You cannot delete this group " );
else
{
//Deleting Everything Related To This Group
$this -> delete_group_topics ( $gid );
$this -> delete_group_videos ( $gid );
$this -> delete_group_members ( $gid );
2010-02-06 11:29:50 +00:00
$db -> delete ( tbl ( $this -> gp_tbl ), array ( " group_id " ), array ( $gid ));
2009-12-21 21:11:54 +00:00
$this -> update_user_total_groups ( $group [ 'userid' ]);
e ( " Group has been deleted " , " m " );
}
}
/**
* Functin used to delete all memebrs of group
*/
function delete_group_members ( $gid )
{
global $db ;
$group = $this -> get_group_details ( $gid );
if ( ! $group )
e ( " Group does not exist " );
elseif ( userid () != $group [ 'userid' ] && ! has_access ( 'admin_access' , true ))
e ( " You cannot delete group members " );
else
{
2010-02-06 11:29:50 +00:00
$db -> delete ( tbl ( $this -> gp_mem_tbl ), array ( " group_id " ), array ( $gid ));
2009-12-21 21:11:54 +00:00
e ( " Members have been deleted " , " m " );
}
}
/**
* Functin used to delete all videos of group
*/
function delete_group_videos ( $gid )
{
global $db ;
$group = $this -> get_group_details ( $gid );
if ( ! $group )
e ( " Group does not exist " );
elseif ( userid () != $group [ 'userid' ] && ! has_access ( 'admin_access' , true ))
e ( " You cannot delete group videos " );
else
{
2010-02-06 11:29:50 +00:00
$db -> delete ( tbl ( $this -> gp_vdo_tbl ), array ( " group_id " ), array ( $gid ));
2009-12-21 21:11:54 +00:00
e ( " videos have been deleted " , " m " );
}
}
/**
* Function used to check weather group exists or not
*/
function group_exists ( $gid )
{
global $db ;
2010-02-06 11:29:50 +00:00
$result = $db -> count ( tbl ( $this -> gp_tbl ), " group_id " , " group_id=' $gid ' " );
2009-12-21 21:11:54 +00:00
if ( $result > 0 )
return true ;
else
return false ;
}
2010-01-05 09:47:10 +00:00
/**
* Function used to perform gorups actions
*/
function grp_actions ( $type , $gid )
{
global $db ;
$gdetails = $this -> get_details ( $gid );
if ( ! $gdetails )
e ( " Group does not exist " );
else
{
switch ( $type )
{
case " activate " :
case " active " :
{
2010-02-06 11:29:50 +00:00
$db -> update ( tbl ( $this -> gp_tbl ), array ( " active " ), array ( " yes " ), " group_id=' $gid ' " );
2010-01-05 09:47:10 +00:00
e ( " Group has been activated " , " m " );
}
break ;
case " deactivate " :
case " deactive " :
{
2010-02-06 11:29:50 +00:00
$db -> update ( tbl ( $this -> gp_tbl ), array ( " active " ), array ( " no " ), " group_id=' $gid ' " );
2010-01-05 09:47:10 +00:00
e ( " Group has been deactivated " , " m " );
}
break ;
case " featured " :
case " feature " :
{
2010-02-06 11:29:50 +00:00
$db -> update ( tbl ( $this -> gp_tbl ), array ( " featured " ), array ( " yes " ), " group_id=' $gid ' " );
2010-01-05 09:47:10 +00:00
e ( " Group has been set as featured " , " m " );
}
break ;
case " unfeatured " :
case " unfeature " :
{
2010-02-06 11:29:50 +00:00
$db -> update ( tbl ( $this -> gp_tbl ), array ( " featured " ), array ( " no " ), " group_id=' $gid ' " );
2010-01-05 09:47:10 +00:00
e ( " Group has been removed from featured list " , " m " );
}
break ;
case " delete " :
{
$this -> delete_group ( $gid );
e ( " Group has been deleted " , " m " );
}
break ;
}
}
2009-12-21 21:11:54 +00:00
}
/**
* Function used to get all topic icons
*/
function get_topic_icons ()
{
$dir = TOPIC_ICON_DIR ;
$icons = glob ( $dir . '/*.png' );
$new_icons = '' ;
foreach ( $icons as $icon )
{
$icon_parts = explode ( '/' , $icon );
$icon_file = $icon_parts [ count ( $icon_parts ) - 1 ];
$new_icons [] = array ( 'file' => $icon_file , 'path' => $icon , 'url' => TOPIC_ICON_URL . '/' . $icon_file );
}
if ( count ( $new_icons ) > 0 )
return $new_icons ;
else
return false ;
}
/**
* Function used to load ADD Topic Form
*/
function load_add_topic_form_fields ( $array = NULL )
{
if ( $array == NULL )
$array = $_POST ;
$topic_title = $_POST [ 'topic_title' ];
$topic_post = $_POST [ 'topic_post' ];
$fields = array
(
'title' => array (
'title' => " Topic title " ,
'type' => 'textfield' ,
'name' => 'topic_title' ,
'id' => 'topic_title' ,
'value' => cleanForm ( $topic_title ),
'size' => '45' ,
'db_field' => 'topic_title' ,
'required' => 'yes' ,
'min_length' => 4 ,
'max_length' => 180 ,
),
'topic_post' => array (
'title' => " Topic Post " ,
'type' => 'textarea' ,
'name' => 'topic_post' ,
'id' => 'topic_post' ,
'value' => cleanForm ( $topic_post ),
'size' => '45' ,
'db_field' => 'topic_post' ,
'required' => 'yes' ,
'min_length' => 4 ,
'max_length' => 800 ,
'anchor_before' => 'before_topic_post_box' ,
)
);
return $fields ;
}
/**
* Function used to add video comment
*/
function add_comment ( $comment , $obj_id , $reply_to = NULL )
{
global $myquery , $db ;
2010-02-02 16:19:41 +00:00
if ( ! $this -> topic_exists ( $obj_id ))
e ( " Topic does not exist " );
else
2009-12-21 21:11:54 +00:00
{
2010-02-02 16:19:41 +00:00
$owner = $this -> get_group_owner_from_topic ( $obj_id );
$add_comment = $myquery -> add_comment ( $comment , $obj_id , $reply_to , 't' , $owner );
if ( $add_comment )
{
//Loggin Comment
$log_array = array
(
'success' => 'yes' ,
'details' => " comment on a topic " ,
'action_obj_id' => $obj_id ,
'action_done_id' => $add_comment ,
);
insert_log ( 'topic_comment' , $log_array );
//Updating Number of comments of topics
$this -> update_comments_count ( $obj_id );
}
return $add_comment ;
2009-12-21 21:11:54 +00:00
}
}
/**
* Function used to delete comment
*/
function delete_comment ( $cid , $objid )
{
global $myquery ;
$tdetails = $this -> get_topic_details ( $objid );
$gdetails = $this -> get_group_details ( $tdetails [ 'group_id' ]);
$forceDelete = false ;
if ( userid () == $gdetails [ 'userid' ])
$forceDelete = true ;
$myquery -> delete_comment ( $cid , 't' , false , $forceDelete );
$this -> update_comments_count ( $objid );
}
/**
* Function delete all comments of topic
*/
function delete_comments ( $tid )
{
global $myquery ;
$tdetails = $this -> get_topic_details ( $tid );
$gdetails = $this -> get_group_details ( $tdetails [ 'group_id' ]);
$forceDelete = false ;
if ( userid () == $gdetails [ 'userid' ])
{
$forceDelete = true ;
$myquery -> delete_comments ( $tid , 't' , $forceDelete );
$this -> update_comments_count ( $objid );
}
}
/**
* Function used to update video comments count
*/
function update_comments_count ( $id )
{
global $db ;
$total_comments = $this -> count_topic_comments ( $id );
if ( ! userid ())
$userid = 0 ;
else
$userid = userid ();
2010-02-06 11:29:50 +00:00
$db -> update ( tbl ( $this -> gp_topic_tbl ), array ( " total_replies " , " last_poster " , " last_post_time " ),
2009-12-21 21:11:54 +00:00
array ( $total_comments , $userid , now ()), " topic_id=' $id ' " );
}
/**
* Function used to count total video comments
*/
function count_topic_comments ( $id )
{
global $db ;
2010-02-06 11:29:50 +00:00
$total_comments = $db -> count ( tbl ( 'comments' ), " comment_id " , " type='t' AND type_id=' $id ' " );
2009-12-21 21:11:54 +00:00
return $total_comments ;
}
/**
* Function used to crearte view topic link
*/
function topic_link ( $tdetails )
{
if ( SEO == yes )
return BASEURL . '/view_topic/' . SEO ( $tdetails [ 'topic_title' ]) . '_tid_' . $tdetails [ 'topic_id' ];
else
return BASEURL . '/view_topic?tid=' . $tdetails [ 'topic_id' ];
}
/**
* function and show otpion links
*/
function group_opt_link ( $group , $type )
{
switch ( $type )
{
case 'join' :
{
if ( $this -> is_joinable ( $group ))
{
if ( SEO == " yes " )
return '<a href="' . group_link ( array ( 'details' => $group )) . '?join=yes">Join</a>' ;
else
return '<a href="' . group_link ( array ( 'details' => $group )) . '&join=yes">Join</a>' ;
} else
return false ;
}
break ;
case 'invite' :
{
if ( $this -> is_owner ( $group ))
2009-11-16 11:55:31 +00:00
{
2009-12-21 21:11:54 +00:00
return '<a href="' . BASEURL . '/invite_group.php?url=' . $group [ 'group_url' ] . '">Invite</a>' ;
2009-11-16 11:55:31 +00:00
}
}
2009-12-21 21:11:54 +00:00
break ;
case 'leave' :
{
if ( $this -> is_member ( userid (), $group [ 'group_id' ]) && ! $this -> is_owner ( $group ))
{
if ( SEO == " yes " )
return '<a href="' . group_link ( array ( 'details' => $group )) . '?leave=yes">Leave</a>' ;
else
return '<a href="' . group_link ( array ( 'details' => $group )) . '&leave=yes">Leave</a>' ;
}
}
break ;
case 'remove_group' :
{
if ( $this -> is_owner ( $group ))
{
2009-12-29 11:28:48 +00:00
return '<a href="' . BASEURL . '/manage_groups.php?mode=manage&gid_delete=' . $group [ 'group_id' ] . '">Remove Group</a>' ;
2009-12-21 21:11:54 +00:00
}
}
break ;
case 'manage_members' :
{
if ( $this -> is_owner ( $group ))
{
2010-01-17 13:26:50 +00:00
return '<a href="' . BASEURL . '/manage_groups.php?mode=manage_members&gid=' . $group [ 'group_id' ] . '">Manage Members</a>' ;
2009-12-21 21:11:54 +00:00
}
}
break ;
case 'manage_videos' :
{
if ( $this -> is_owner ( $group ))
{
2010-01-17 13:26:50 +00:00
return '<a href="' . BASEURL . '/manage_groups.php?mode=manage_videos&gid=' . $group [ 'group_id' ] . '">Manage Videos</a>' ;
2009-12-21 21:11:54 +00:00
}
}
break ;
case 'add_videos' :
{
if ( $this -> is_member ( userid (), $group [ 'group_id' ]))
{
return '<a href="' . BASEURL . '/add_group_videos.php?url=' . $group [ 'group_url' ] . '">Add Videos</a>' ;
}
}
break ;
2010-01-17 13:26:50 +00:00
case 'edit_group' :
{
if ( $this -> is_owner ( $group ))
{
return '<a href="' . BASEURL . '/edit_group.php?gid=' . $group [ 'group_id' ] . '">Edit group</a>' ;
}
}
break ;
2009-12-21 21:11:54 +00:00
}
return false ;
}
/**
* Function used to check weather
* this group is joinable or not
* it will check
* - user is logged in or not
* - if user is logged in , check is he member or not
* - if he is not a member , check is he invited
* - if is invited then show the link
*/
function is_joinable ( $group , $uid = NULL , $gen_err = FALSE )
{
if ( ! $uid )
$uid = userid ();
$group_id = $group [ 'group_id' ];
if ( $this -> is_member ( $uid , $group [ 'group_id' ]))
{
if ( $gen_err )
e ( lang ( 'grp_join_error' ));
return false ;
} elseif ( $group [ 'group_privacy' ] != 2 || $this -> is_invited ( $uid , $group_id , $group [ 'userid' ], $gen_err ))
return true ;
else
return false ;
}
/**
* Function used to get groups
* @ parma ARRAY
* group_id => { id of group } INT
* user => { all groups of the user INT
* category => { all groups in specified category INT , INT , INT
* featured => { get featured groups only } yes , no
* limit => { number of results including offset }
* order => { soring by }
* date_margin => { date span }
*/
2010-01-27 11:37:26 +00:00
function get_groups ( $params = NULL , $force_admin = FALSE )
2009-12-21 21:11:54 +00:00
{
global $db ;
$limit = $params [ 'limit' ];
$order = $params [ 'order' ];
2010-01-05 09:47:10 +00:00
$cond = " " ;
2010-01-27 11:37:26 +00:00
if ( ! has_access ( 'admin_access' , TRUE ) && ! $force_admin )
2010-02-06 14:27:00 +00:00
$cond .= " " . tbl ( " groups.active " ) . " ='yes' " ;
2010-01-05 09:47:10 +00:00
else
{
if ( $params [ 'active' ])
2010-02-06 14:27:00 +00:00
$cond .= " " . tbl ( " groups.active " ) . " =' " . $params [ 'active' ] . " ' " ;
2010-01-05 09:47:10 +00:00
}
2009-12-21 21:11:54 +00:00
//Setting Category Condition
2010-01-05 09:47:10 +00:00
if ( ! is_array ( $params [ 'category' ]))
$is_all = strtolower ( $params [ 'category' ]);
if ( $params [ 'category' ] && $is_all != 'all' )
2009-12-21 21:11:54 +00:00
{
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 " ;
2010-02-06 15:57:58 +00:00
$cond .= " " . tbl ( " groups.category " ) . " LIKE '%# $cat_params #%' " ;
2009-12-21 21:11:54 +00:00
}
$cond .= " ) " ;
}
//date span
if ( $params [ 'date_span' ])
{
if ( $cond != '' )
$cond .= ' AND ' ;
$cond .= " " . cbsearch :: date_margin ( " date_added " , $params [ 'date_span' ]);
}
//uid
if ( $params [ 'user' ])
{
if ( $cond != '' )
$cond .= ' AND ' ;
2010-02-06 15:57:58 +00:00
$cond .= " " . tbl ( " groups.userid " ) . " =' " . $params [ 'user' ] . " ' " ;
2009-12-21 21:11:54 +00:00
}
$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 )
{
2010-02-06 15:57:58 +00:00
$tag_n_title .= " " . tbl ( " groups.group_tags " ) . " LIKE '% " . $tag . " %' " ;
2009-12-21 21:11:54 +00:00
if ( $loop < $total )
$tag_n_title .= " OR " ;
$loop ++ ;
}
} else
{
if ( $tag_n_title != '' )
$tag_n_title .= ' OR ' ;
2010-02-06 15:57:58 +00:00
$tag_n_title .= " " . tbl ( " groups.group_tags " ) . " LIKE '% " . $params [ 'tags' ] . " %' " ;
2009-12-21 21:11:54 +00:00
}
}
//TITLE
if ( $params [ 'title' ])
{
if ( $tag_n_title != '' )
$tag_n_title .= ' OR ' ;
2010-02-06 15:57:58 +00:00
$tag_n_title .= " " . tbl ( " groups.group_name " ) . " LIKE '% " . $params [ 'title' ] . " %' " ;
2009-12-21 21:11:54 +00:00
}
if ( $tag_n_title )
{
if ( $cond != '' )
$cond .= ' AND ' ;
$cond .= " ( $tag_n_title ) " ;
}
//FEATURED
if ( $params [ 'featured' ])
{
if ( $cond != '' )
$cond .= ' AND ' ;
2010-02-06 15:57:58 +00:00
$cond .= " " . tbl ( " groups.featured " ) . " = ' " . $params [ 'featured' ] . " ' " ;
2010-01-05 09:47:10 +00:00
}
//GROUP ID
if ( $params [ 'group_id' ])
{
if ( $cond != '' )
$cond .= ' AND ' ;
$cond .= " group_id = ' " . $params [ 'group_id' ] . " ' " ;
2009-12-21 21:11:54 +00:00
}
//Exclude Vids
if ( $params [ 'exclude' ])
{
if ( $cond != '' )
$cond .= ' AND ' ;
2010-02-06 15:57:58 +00:00
$cond .= " " . tbl ( " groups.group_id " ) . " <> ' " . $params [ 'exclude' ] . " ' " ;
2009-12-21 21:11:54 +00:00
}
2010-01-18 07:29:28 +00:00
if ( ! $params [ 'count_only' ])
{
if ( ! empty ( $cond ))
2010-01-15 15:38:47 +00:00
$cond .= " AND " ;
2010-02-06 15:57:58 +00:00
$result = $db -> select ( tbl ( $this -> gp_tbl . " ,users " ), '*' , $cond . " " . tbl ( " groups.userid " ) . " = " . tbl ( " users.userid " ) . " " , $limit , $order );
2010-01-18 07:29:28 +00:00
}
2009-12-21 21:11:54 +00:00
2010-02-06 15:57:58 +00:00
//echo $db->db_query;
2009-12-21 21:11:54 +00:00
if ( $params [ 'count_only' ])
2010-02-06 11:29:50 +00:00
return $result = $db -> count ( tbl ( $this -> gp_tbl ), '*' , $cond );
2009-12-21 21:11:54 +00:00
if ( $params [ 'assign' ])
assign ( $params [ 'assign' ], $result );
else
return $result ;
}
/**
* Function used to get group field
* @ param INT gid
* @ param FIELD name
*/
function get_gp_field ( $gid , $field )
{
global $db ;
2010-02-06 11:29:50 +00:00
$results = $db -> select ( tbl ( $this -> gp_tbl ), $field , " group_id=' $gid ' " );
2009-12-21 21:11:54 +00:00
if ( $db -> num_rows > 0 )
{
return $results [ 0 ];
} else {
return false ;
}
} function get_gp_fields ( $gid , $field ){ return $this -> get_gp_field ( $gid , $field );}
/**
* This function will return
* group field without array
*/
function get_gp_field_only ( $gid , $field )
{
$fields = $this -> get_gp_field ( $gid , $field );
return $fields [ $field ];
}
/**
* Function used to get groups joined by user
*/
function user_joined_groups ( $uid , $limit = NULL )
{
global $db ;
# REF QUERY : SELECT * FROM group_members,groups WHERE group_members.userid = '1' AND group_members.group_id = groups.group_id
2010-02-06 11:29:50 +00:00
$result = $db -> select ( tbl ( $this -> gp_tbl ) . ',' . tbl ( $this -> gp_mem_tbl ), " * " , tbl ( $this -> gp_mem_tbl ) . " .userid=' $uid ' AND
" .tbl( $this->gp_mem_tbl ). " . group_id = " .tbl( $this->gp_tbl ). " . group_id " , $limit ,tbl( $this->gp_tbl ). " . group_name " );
2009-12-21 21:11:54 +00:00
if ( $db -> num_rows > 0 )
return $result ;
else
return false ;
}
/***
* Function used to update user total number of groups
*/
function update_user_total_groups ( $user )
{
global $db ;
2010-02-06 11:29:50 +00:00
$count = $db -> count ( tbl ( $this -> gp_tbl ), " group_id " , " userid=' $user ' " );
$db -> update ( tbl ( " users " ), array ( " total_groups " ), array ( $count ), " userid=' $user ' " );
2009-11-16 11:55:31 +00:00
}
2009-12-23 13:06:42 +00:00
/**
* Function used to use to initialize search object for video section
* op => operator ( AND OR )
*/
function init_search ()
{
$this -> search = new cbsearch ;
$this -> search -> db_tbl = " groups " ;
$this -> search -> columns = array (
2010-02-06 08:32:19 +00:00
array ( 'field' => 'group_name' , 'type' => 'LIKE' , 'var' => '%{KEY}%' ),
2009-12-23 13:06:42 +00:00
);
$this -> search -> cat_tbl = $this -> cat_tbl ;
$this -> search -> display_template = LAYOUT . '/blocks/group.html' ;
$this -> search -> template_var = 'group' ;
$this -> search -> multi_cat = true ;
/**
* Setting up the sorting thing
*/
$sorting = array (
'date_added' => lang ( " date_added " ),
'total_views' => lang ( " views " ),
'total_comments' => lang ( " comments " ),
'total_videos' => lang ( " videos " ),
'total_members' => lang ( " total members " ),
);
$this -> search -> sorting = array (
'date_added' => " date_added DESC " ,
'total_views' => " total_views DESC " ,
'total_comments' => " total_comments DESC " ,
'total_videos' => " total_videos DESC " ,
'total_members' => " total_members DESC " ,
);
/**
* Setting Up The Search Fields
*/
$default = $_GET ;
if ( is_array ( $default [ 'category' ]))
$cat_array = array ( $default [ 'category' ]);
$uploaded = $default [ 'datemargin' ];
$sort = $default [ 'sort' ];
$this -> search -> search_type [ 'groups' ] = array ( 'title' => 'Groups' );
$fields = array (
2009-12-25 17:13:06 +00:00
'query' => array (
2009-12-23 13:06:42 +00:00
'title' => lang ( 'keywords' ),
'type' => 'textfield' ,
2009-12-25 17:13:06 +00:00
'name' => 'query' ,
'id' => 'query' ,
'value' => cleanForm ( $default [ 'query' ])
2009-12-23 13:06:42 +00:00
),
'category' => array (
2010-01-05 09:47:10 +00:00
'title' => lang ( 'category' ),
2009-12-23 13:06:42 +00:00
'type' => 'checkbox' ,
'name' => 'category[]' ,
'id' => 'category' ,
'value' => array ( 'category' , $cat_array ),
'category_type' => 'group' ,
),
'date_margin' => array (
2010-01-05 09:47:10 +00:00
'title' => lang ( 'created' ),
2009-12-23 13:06:42 +00:00
'type' => 'dropdown' ,
'name' => 'datemargin' ,
'id' => 'datemargin' ,
'value' => $this -> search -> date_margins (),
'checked' => $uploaded ,
),
'sort' => array (
'title' => lang ( 'sort_by' ),
'type' => 'dropdown' ,
'name' => 'sort' ,
'value' => $sorting ,
'checked' => $sort
)
);
$this -> search -> search_type [ 'groups' ][ 'fields' ] = $fields ;
}
2009-12-29 11:28:48 +00:00
/**
* Function used to validate group category
* @ param input array
*/
function validate_group_category ( $array = NULL )
{
if ( $array == NULL )
$array = $_POST [ 'category' ];
if ( count ( $array ) == 0 )
return false ;
else
{
foreach ( $array as $arr )
{
if ( $this -> category_exists ( $arr ))
$new_array [] = $arr ;
}
}
if ( count ( $new_array ) == 0 )
{
2010-01-13 09:53:21 +00:00
e ( lang ( 'vdo_cat_err3' ));
2009-12-29 11:28:48 +00:00
return false ;
} elseif ( count ( $new_array ) > ALLOWED_GROUP_CATEGORIES )
{
2010-01-13 09:53:21 +00:00
e ( sprintf ( lang ( 'vdo_cat_err2' ), ALLOWED_GROUP_CATEGORIES ));
2009-12-29 11:28:48 +00:00
return false ;
}
return true ;
}
2010-02-02 16:19:41 +00:00
/**
* Get group owner from topic
*/
function get_group_owner_from_topic ( $tid )
{
global $db ;
2010-02-06 11:29:50 +00:00
$results = $db -> select ( tbl ( " group_topics " ) . " , " . tbl ( " groups " ),
tbl ( " group_topics " ) . " .group_id, " . tbl ( " group_topics " ) . " .topic_id, " . tbl ( " groups " ) . " userid, " . tbl ( " groups " ) . " .group_id " ,
tbl ( " group_topics " ) . " .group_id = " . tbl ( " groups " ) . " .group_id AND " . tbl ( " group_topics " ) . " .topic_id=' $tid ' " );
2010-02-02 16:19:41 +00:00
if ( $db -> num_rows > 0 )
return $results [ 0 ][ 'userid' ];
else
return false ;
}
2009-08-25 12:16:42 +00:00
}
?>