Example #1
0
 public function admin_setAppProperties($properties)
 {
     $props = json_decode($properties, true);
     if (!is_array($props)) {
         $this->throw_code(api10_FacebookApiErrorCode::API_EC_PARAM_BAD_JSON);
     }
     $app_profile = array();
     $app_fields = get_editable_app_fields();
     foreach ($props as $key => $val) {
         if (!isset($app_fields[$key])) {
             throw new api10_FacebookApiException(array('error_code' => api10_FacebookApiErrorCode::API_EC_PARAM, 'error_msg' => $key . ' is not a valid application property.'));
         }
         $app_profile[$key] = $val;
     }
     return application_update($this->app_id, $app_profile, $this->user_id);
 }
Example #2
0
function application_update($app_id, $app_profile, $user_id)
{
    global $data_conn;
    if (!application_is_owner($app_id, $user_id)) {
        return false;
    }
    // Ensure application_id does not drift away from original id
    if (isset($app_profile['application_id']) && $app_id != $app_profile['application_id']) {
        error_log("Error: Cannot change value of application_id in application_update.");
        return false;
    }
    $sql_set_terms = array();
    $editable_fields = get_editable_app_fields();
    foreach ($app_profile as $name => $val) {
        if (isset($editable_fields[$name])) {
            $sql_set_terms[] = "`{$name}`=" . (is_int($val) ? "%d" : "%s");
            $params[] = $val;
        }
    }
    $params[] = $app_id;
    if (!empty($sql_set_terms)) {
        $sql = 'UPDATE application SET ' . implode(",", $sql_set_terms) . ' WHERE application_id=%d';
        if (!vqueryf($data_conn, $sql, $params)) {
            error_log('PLATFORM: unable to update application profile on db');
            return false;
        }
    }
    return true;
}