예제 #1
0
 /**
  * Function used to vlidate upload form fields
  */
 function validate_video_upload_form($array = NULL, $is_upload = FALSE)
 {
     global $LANG;
     //First Load All Fields in an array
     $required_fields = $this->loadRequiredFields($array);
     $location_fields = $this->loadLocationFields($array);
     $date_fields = $this->loadDateForm('', '/', TRUE);
     $option_fields = $this->loadOptionFields($array);
     if ($array == NULL) {
         $array = $_POST;
     }
     if (is_array($_FILES)) {
         $array = array_merge($array, $_FILES);
     }
     //Mergin Array
     $upload_fields = array_merge($required_fields, $location_fields, $option_fields);
     //Adding Custom Upload Fields
     if (count($this->custom_upload_fields) > 0 && $is_upload) {
         $upload_fields = array_merge($upload_fields, $this->custom_upload_fields);
     }
     //Adding Custom Form Fields
     if (count($this->custom_form_fields) > 0) {
         $upload_fields = array_merge($upload_fields, $this->custom_form_fields);
     }
     validate_cb_form($upload_fields, $array);
 }
예제 #2
0
 /**
  * Function used to validate form fields
  */
 function validate_form_fields($array = NULL)
 {
     $reqFileds = $this->load_required_fields($array);
     if ($array == NULL) {
         $array = $_POST;
     }
     if (is_array($_FILES)) {
         $array = array_merge($array, $_FILES);
     }
     $otherFields = $this->load_other_fields($array);
     $collection_fields = array_merge($reqFileds, $otherFields);
     validate_cb_form($collection_fields, $array);
 }
예제 #3
0
 /**
  * Function used add new topic in group
  * @param ARRAY details
  */
 function add_topic($array, $redirect_to_topic = false)
 {
     global $db;
     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'] || !apply_func($field['clean_func'], $val) && !is_array($field['clean_func'])) {
                 $val = $val;
             } else {
                 $val = apply_func($field['clean_func'], sql_free($val));
             }
             if (empty($val) && !empty($field['default_value'])) {
                 $val = $field['default_value'];
             }
             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
         $db->insert(tbl($this->gp_topic_tbl), $query_field, $query_val);
         $insert_id = $db->insert_id();
         //Increasing Group Topic Counts
         $count_topics = $this->count_group_topics($array['group_id']);
         $db->update(tbl($this->gp_tbl), array("total_topics"), array($count_topics), " group_id='" . $array['group_id'] . "'");
         //leaving msg
         e(lang("grp_tpc_msg"), "m");
         //Redirecting to topic
         if ($redirect_to_topic) {
             $grp_details = $this->get_details($insert_id);
             redirect_to(group_link($grp_details));
         }
         return $insert_id;
     }
 }
예제 #4
0
 /**
  * Function used to update playlist details
  */
 function edit_playlist($array = null)
 {
     global $db;
     if (is_null($array)) {
         $array = $_POST;
     }
     $name = mysql_clean($array['name']);
     $pdetails = $this->get_playlist($array['pid'] ? $array['pid'] : $array['list_id']);
     if (!$pdetails) {
         e(lang("playlist_not_exist"));
     } elseif (!userid()) {
         e(lang("you_not_logged_in"));
     } elseif ($this->playlist_exists($name, userid(), $this->type)) {
         e(sprintf(lang("play_list_with_this_name_arlready_exists"), $name));
     } else {
         $upload_fields = $this->load_playlist_fields($array);
         $fields = array();
         foreach ($upload_fields as $group) {
             $fields = array_merge($fields, $group['fields']);
         }
         validate_cb_form($fields, $array);
         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 (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_values[$name] = $val;
                 }
             }
             if (has_access('admin_access')) {
                 if (isset($array['played']) and !empty($array['played'])) {
                     $query_values['played'] = $array['played'];
                 }
             }
             $query_values['last_update'] = NOW();
             $db->update(tbl('playlists'), array_keys($query_values), array_values($query_values), " playlist_id = '" . $pdetails['playlist_id'] . "' ");
             $array['playlist_id'] = $array['pid'] ? $array['pid'] : $array['list_id'];
             cb_do_action('update_playlist', array('object_id' => $array['pid'] ? $array['pid'] : $array['list_id'], 'results' => $array));
         }
         /*$db->update(tbl($this->playlist_tbl),array("playlist_name"),
           array($name)," playlist_id='".$params['pid']."'");*/
         e(lang("play_list_updated"), "m");
     }
 }
예제 #5
0
 /**
  * Function used to validate Signup Form
  */
 function validate_form_fields($array = NULL)
 {
     global $userquery;
     $fields = $this->load_signup_fields($array);
     if ($array == NULL) {
         $array = $_POST;
     }
     if (is_array($_FILES)) {
         $array = array_merge($array, $_FILES);
     }
     //Mergin Array
     $signup_fields = array_merge($fields, $this->custom_signup_fields);
     validate_cb_form($signup_fields, $array);
 }