/** * Function used to create new groups * @Author : Fawaz Tahir, Arslan Hassan * @Params : array { Group Input Details } * @since : 15 December 2009 */ function create_group($array, $user = false, $redirect_to_group = false) { global $db; 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 = $val; } else { $val = apply_func($field['clean_func'], sql_free('|no_mc|' . $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(); $query_field[] = "total_members"; $query_val[] = 1; //Inserting IN Database now $db->insert(tbl($this->gp_tbl), $query_field, $query_val); $insert_id = $db->insert_id(); //Owner Joiing Group ignore_errors(); $db->insert(tbl($this->gp_mem_tbl), array("group_id", "userid", "date_added", "active"), array($insert_id, $user, now(), 'yes')); //$this->join_group($insert_id,$user,false); //Updating User Total Groups $this->update_user_total_groups($user); //Adding Feed addFeed(array('action' => 'create_group', 'object_id' => $insert_id, 'object' => 'group')); //Updating Group Thumb if (!empty($array['thumb_file']['tmp_name'])) { $this->create_group_image($insert_id, $array['thumb_file']); } if ($redirect_to_group) { $grp_details = $this->get_details($insert_id); redirect_to(group_link(array('details' => $grp_details))); } //loggin Upload $log_array = array('success' => 'yes', 'action_obj_id' => $insert_id, 'details' => "created new group"); insert_log('add_group', $log_array); return $insert_id; } }
/** * Get Mapped Datatype * * return the abstract type for a given native type * * @author Brian Hendrickson <*****@*****.**> * @access public * @param string raw_datatype * @param string */ function get_mapped_datatype($raw_datatype) { trigger_before('get_mapped_datatype', $this, $this); if (strstr($raw_datatype, "(")) { $raw_datatype = substr($raw_datatype, 0, strpos($raw_datatype, "(")); } if (array_key_exists($raw_datatype, $this->datatype_map)) { return $this->datatype_map[$raw_datatype]; } else { if (ignore_errors()) { return 'char'; } trigger_error("Error, the {$raw_datatype} datatype is not listed in dbscript's datatype map.", E_USER_NOTICE); } }